@junobuild/core 0.0.8 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/index.js +15 -15
- package/dist/browser/index.js.map +4 -4
- package/dist/declarations/cmc/cmc.did.d.ts +30 -30
- package/dist/declarations/cmc/cmc.factory.did.js +63 -63
- package/dist/declarations/cmc/index.d.ts +18 -18
- package/dist/declarations/cmc/index.js +22 -22
- package/dist/declarations/console/console.did.d.ts +45 -32
- package/dist/declarations/console/console.factory.did.js +60 -47
- package/dist/declarations/console/console.factory.did.mjs +60 -47
- package/dist/declarations/console/index.d.ts +18 -18
- package/dist/declarations/console/index.js +22 -22
- package/dist/declarations/frontend/frontend.did.d.ts +136 -136
- package/dist/declarations/frontend/frontend.factory.did.js +206 -206
- package/dist/declarations/frontend/index.d.ts +18 -18
- package/dist/declarations/frontend/index.js +22 -22
- package/dist/declarations/ic/ic.did.d.ts +63 -63
- package/dist/declarations/ic/ic.factory.did.js +126 -126
- package/dist/declarations/internet_identity/index.d.ts +18 -18
- package/dist/declarations/internet_identity/index.js +22 -22
- package/dist/declarations/internet_identity/internet_identity.did +79 -20
- package/dist/declarations/internet_identity/internet_identity.did.d.ts +152 -109
- package/dist/declarations/internet_identity/internet_identity.factory.did.js +231 -185
- package/dist/declarations/ledger/index.d.ts +18 -18
- package/dist/declarations/ledger/index.js +22 -22
- package/dist/declarations/ledger/ledger.did.d.ts +64 -64
- package/dist/declarations/ledger/ledger.factory.did.js +96 -96
- package/dist/declarations/mission_control/index.d.ts +18 -18
- package/dist/declarations/mission_control/index.js +22 -22
- package/dist/declarations/mission_control/mission_control.did.d.ts +34 -17
- package/dist/declarations/mission_control/mission_control.factory.did.js +48 -26
- package/dist/declarations/satellite/index.d.ts +18 -18
- package/dist/declarations/satellite/index.js +22 -22
- package/dist/declarations/satellite/satellite.did.d.ts +132 -113
- package/dist/declarations/satellite/satellite.factory.did.js +192 -167
- package/dist/declarations/satellite/satellite.factory.did.mjs +190 -167
- package/dist/index.js +1 -1
- package/dist/node/index.mjs +23 -23
- package/dist/node/index.mjs.map +4 -4
- package/dist/types/constants/auth.constants.d.ts +10 -3
- package/dist/types/index.d.ts +1 -0
- package/dist/types/providers/auth.providers.d.ts +31 -0
- package/dist/types/services/auth-timout.services.d.ts +1 -1
- package/dist/types/services/auth.services.d.ts +2 -2
- package/dist/types/services/user.services.d.ts +2 -2
- package/dist/types/stores/auth.store.d.ts +0 -1
- package/dist/types/types/auth.types.d.ts +4 -4
- package/dist/types/types/doc.types.d.ts +1 -0
- package/dist/types/types/list.types.d.ts +3 -0
- package/dist/types/types/storage.types.d.ts +3 -0
- package/dist/types/utils/list.utils.d.ts +1 -1
- package/dist/workers/auth.worker.js.map +3 -3
- package/package.json +1 -1
- package/dist/index.cjs.js +0 -1
package/dist/browser/index.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import{a as Un,b as ao,c as rr,d as Bn,e as me,f as so,g as nr,h as fo,i as st,j as ke,k as Rn,l as je,m as co,n as Nn,o as It,p as Cn,q as ee,r as Fn,s as ir,t as or,u as Pn}from"./chunk-A53P2AD6.js";var qn=rr(ar=>{"use strict";ar.byteLength=lo;ar.toByteArray=po;ar.fromByteArray=mo;var Ct=[],Et=[],uo=typeof Uint8Array<"u"?Uint8Array:Array,Kr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(re=0,Yn=Kr.length;re<Yn;++re)Ct[re]=Kr[re],Et[Kr.charCodeAt(re)]=re;var re,Yn;Et["-".charCodeAt(0)]=62;Et["_".charCodeAt(0)]=63;function Vn(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");r===-1&&(r=t);var i=r===t?0:4-r%4;return[r,i]}function lo(e){var t=Vn(e),r=t[0],i=t[1];return(r+i)*3/4-i}function ho(e,t,r){return(t+r)*3/4-r}function po(e){var t,r=Vn(e),i=r[0],a=r[1],u=new uo(ho(e,i,a)),d=0,m=a>0?i-4:i,w;for(w=0;w<m;w+=4)t=Et[e.charCodeAt(w)]<<18|Et[e.charCodeAt(w+1)]<<12|Et[e.charCodeAt(w+2)]<<6|Et[e.charCodeAt(w+3)],u[d++]=t>>16&255,u[d++]=t>>8&255,u[d++]=t&255;return a===2&&(t=Et[e.charCodeAt(w)]<<2|Et[e.charCodeAt(w+1)]>>4,u[d++]=t&255),a===1&&(t=Et[e.charCodeAt(w)]<<10|Et[e.charCodeAt(w+1)]<<4|Et[e.charCodeAt(w+2)]>>2,u[d++]=t>>8&255,u[d++]=t&255),u}function xo(e){return Ct[e>>18&63]+Ct[e>>12&63]+Ct[e>>6&63]+Ct[e&63]}function yo(e,t,r){for(var i,a=[],u=t;u<r;u+=3)i=(e[u]<<16&16711680)+(e[u+1]<<8&65280)+(e[u+2]&255),a.push(xo(i));return a.join("")}function mo(e){for(var t,r=e.length,i=r%3,a=[],u=16383,d=0,m=r-i;d<m;d+=u)a.push(yo(e,d,d+u>m?m:d+u));return i===1?(t=e[r-1],a.push(Ct[t>>2]+Ct[t<<4&63]+"==")):i===2&&(t=(e[r-2]<<8)+e[r-1],a.push(Ct[t>>10]+Ct[t>>4&63]+Ct[t<<2&63]+"=")),a.join("")}});var ti=rr(ve=>{"use strict";var Mr=qn(),be=fo(),Hn=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;ve.Buffer=g;ve.SlowBuffer=Eo;ve.INSPECT_MAX_BYTES=50;var sr=2147483647;ve.kMaxLength=sr;g.TYPED_ARRAY_SUPPORT=wo();!g.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function wo(){try{var e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),e.foo()===42}catch{return!1}}Object.defineProperty(g.prototype,"parent",{enumerable:!0,get:function(){if(g.isBuffer(this))return this.buffer}});Object.defineProperty(g.prototype,"offset",{enumerable:!0,get:function(){if(g.isBuffer(this))return this.byteOffset}});function Wt(e){if(e>sr)throw new RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return Object.setPrototypeOf(t,g.prototype),t}function g(e,t,r){if(typeof e=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return Hr(e)}return Wn(e,t,r)}g.poolSize=8192;function Wn(e,t,r){if(typeof e=="string")return _o(e,t);if(ArrayBuffer.isView(e))return bo(e);if(e==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(Ft(e,ArrayBuffer)||e&&Ft(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Ft(e,SharedArrayBuffer)||e&&Ft(e.buffer,SharedArrayBuffer)))return Vr(e,t,r);if(typeof e=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');var i=e.valueOf&&e.valueOf();if(i!=null&&i!==e)return g.from(i,t,r);var a=vo(e);if(a)return a;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]=="function")return g.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}g.from=function(e,t,r){return Wn(e,t,r)};Object.setPrototypeOf(g.prototype,Uint8Array.prototype);Object.setPrototypeOf(g,Uint8Array);function zn(e){if(typeof e!="number")throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function go(e,t,r){return zn(e),e<=0?Wt(e):t!==void 0?typeof r=="string"?Wt(e).fill(t,r):Wt(e).fill(t):Wt(e)}g.alloc=function(e,t,r){return go(e,t,r)};function Hr(e){return zn(e),Wt(e<0?0:Ir(e)|0)}g.allocUnsafe=function(e){return Hr(e)};g.allocUnsafeSlow=function(e){return Hr(e)};function _o(e,t){if((typeof t!="string"||t==="")&&(t="utf8"),!g.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var r=Gn(e,t)|0,i=Wt(r),a=i.write(e,t);return a!==r&&(i=i.slice(0,a)),i}function Yr(e){for(var t=e.length<0?0:Ir(e.length)|0,r=Wt(t),i=0;i<t;i+=1)r[i]=e[i]&255;return r}function bo(e){if(Ft(e,Uint8Array)){var t=new Uint8Array(e);return Vr(t.buffer,t.byteOffset,t.byteLength)}return Yr(e)}function Vr(e,t,r){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw new RangeError('"length" is outside of buffer bounds');var i;return t===void 0&&r===void 0?i=new Uint8Array(e):r===void 0?i=new Uint8Array(e,t):i=new Uint8Array(e,t,r),Object.setPrototypeOf(i,g.prototype),i}function vo(e){if(g.isBuffer(e)){var t=Ir(e.length)|0,r=Wt(t);return r.length===0||e.copy(r,0,0,t),r}if(e.length!==void 0)return typeof e.length!="number"||$r(e.length)?Wt(0):Yr(e);if(e.type==="Buffer"&&Array.isArray(e.data))return Yr(e.data)}function Ir(e){if(e>=sr)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+sr.toString(16)+" bytes");return e|0}function Eo(e){return+e!=e&&(e=0),g.alloc(+e)}g.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==g.prototype};g.compare=function(t,r){if(Ft(t,Uint8Array)&&(t=g.from(t,t.offset,t.byteLength)),Ft(r,Uint8Array)&&(r=g.from(r,r.offset,r.byteLength)),!g.isBuffer(t)||!g.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===r)return 0;for(var i=t.length,a=r.length,u=0,d=Math.min(i,a);u<d;++u)if(t[u]!==r[u]){i=t[u],a=r[u];break}return i<a?-1:a<i?1:0};g.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};g.concat=function(t,r){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return g.alloc(0);var i;if(r===void 0)for(r=0,i=0;i<t.length;++i)r+=t[i].length;var a=g.allocUnsafe(r),u=0;for(i=0;i<t.length;++i){var d=t[i];if(Ft(d,Uint8Array))u+d.length>a.length?g.from(d).copy(a,u):Uint8Array.prototype.set.call(a,d,u);else if(g.isBuffer(d))d.copy(a,u);else throw new TypeError('"list" argument must be an Array of Buffers');u+=d.length}return a};function Gn(e,t){if(g.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||Ft(e,ArrayBuffer))return e.byteLength;if(typeof e!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var r=e.length,i=arguments.length>2&&arguments[2]===!0;if(!i&&r===0)return 0;for(var a=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return qr(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return Ln(e).length;default:if(a)return i?-1:qr(e).length;t=(""+t).toLowerCase(),a=!0}}g.byteLength=Gn;function Ao(e,t,r){var i=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,t>>>=0,r<=t))return"";for(e||(e="utf8");;)switch(e){case"hex":return Po(this,t,r);case"utf8":case"utf-8":return Xn(this,t,r);case"ascii":return Co(this,t,r);case"latin1":case"binary":return Fo(this,t,r);case"base64":return Ro(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ko(this,t,r);default:if(i)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),i=!0}}g.prototype._isBuffer=!0;function ne(e,t,r){var i=e[t];e[t]=e[r],e[r]=i}g.prototype.swap16=function(){var t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var r=0;r<t;r+=2)ne(this,r,r+1);return this};g.prototype.swap32=function(){var t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var r=0;r<t;r+=4)ne(this,r,r+3),ne(this,r+1,r+2);return this};g.prototype.swap64=function(){var t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var r=0;r<t;r+=8)ne(this,r,r+7),ne(this,r+1,r+6),ne(this,r+2,r+5),ne(this,r+3,r+4);return this};g.prototype.toString=function(){var t=this.length;return t===0?"":arguments.length===0?Xn(this,0,t):Ao.apply(this,arguments)};g.prototype.toLocaleString=g.prototype.toString;g.prototype.equals=function(t){if(!g.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:g.compare(this,t)===0};g.prototype.inspect=function(){var t="",r=ve.INSPECT_MAX_BYTES;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"};Hn&&(g.prototype[Hn]=g.prototype.inspect);g.prototype.compare=function(t,r,i,a,u){if(Ft(t,Uint8Array)&&(t=g.from(t,t.offset,t.byteLength)),!g.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(r===void 0&&(r=0),i===void 0&&(i=t?t.length:0),a===void 0&&(a=0),u===void 0&&(u=this.length),r<0||i>t.length||a<0||u>this.length)throw new RangeError("out of range index");if(a>=u&&r>=i)return 0;if(a>=u)return-1;if(r>=i)return 1;if(r>>>=0,i>>>=0,a>>>=0,u>>>=0,this===t)return 0;for(var d=u-a,m=i-r,w=Math.min(d,m),T=this.slice(a,u),j=t.slice(r,i),O=0;O<w;++O)if(T[O]!==j[O]){d=T[O],m=j[O];break}return d<m?-1:m<d?1:0};function Jn(e,t,r,i,a){if(e.length===0)return-1;if(typeof r=="string"?(i=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,$r(r)&&(r=a?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(a)return-1;r=e.length-1}else if(r<0)if(a)r=0;else return-1;if(typeof t=="string"&&(t=g.from(t,i)),g.isBuffer(t))return t.length===0?-1:In(e,t,r,i,a);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?a?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):In(e,[t],r,i,a);throw new TypeError("val must be string, number or Buffer")}function In(e,t,r,i,a){var u=1,d=e.length,m=t.length;if(i!==void 0&&(i=String(i).toLowerCase(),i==="ucs2"||i==="ucs-2"||i==="utf16le"||i==="utf-16le")){if(e.length<2||t.length<2)return-1;u=2,d/=2,m/=2,r/=2}function w(at,it){return u===1?at[it]:at.readUInt16BE(it*u)}var T;if(a){var j=-1;for(T=r;T<d;T++)if(w(e,T)===w(t,j===-1?0:T-j)){if(j===-1&&(j=T),T-j+1===m)return j*u}else j!==-1&&(T-=T-j),j=-1}else for(r+m>d&&(r=d-m),T=r;T>=0;T--){for(var O=!0,Q=0;Q<m;Q++)if(w(e,T+Q)!==w(t,Q)){O=!1;break}if(O)return T}return-1}g.prototype.includes=function(t,r,i){return this.indexOf(t,r,i)!==-1};g.prototype.indexOf=function(t,r,i){return Jn(this,t,r,i,!0)};g.prototype.lastIndexOf=function(t,r,i){return Jn(this,t,r,i,!1)};function To(e,t,r,i){r=Number(r)||0;var a=e.length-r;i?(i=Number(i),i>a&&(i=a)):i=a;var u=t.length;i>u/2&&(i=u/2);for(var d=0;d<i;++d){var m=parseInt(t.substr(d*2,2),16);if($r(m))return d;e[r+d]=m}return d}function So(e,t,r,i){return fr(qr(t,e.length-r),e,r,i)}function Oo(e,t,r,i){return fr(Mo(t),e,r,i)}function Uo(e,t,r,i){return fr(Ln(t),e,r,i)}function Bo(e,t,r,i){return fr(Yo(t,e.length-r),e,r,i)}g.prototype.write=function(t,r,i,a){if(r===void 0)a="utf8",i=this.length,r=0;else if(i===void 0&&typeof r=="string")a=r,i=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(i)?(i=i>>>0,a===void 0&&(a="utf8")):(a=i,i=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var u=this.length-r;if((i===void 0||i>u)&&(i=u),t.length>0&&(i<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");a||(a="utf8");for(var d=!1;;)switch(a){case"hex":return To(this,t,r,i);case"utf8":case"utf-8":return So(this,t,r,i);case"ascii":case"latin1":case"binary":return Oo(this,t,r,i);case"base64":return Uo(this,t,r,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Bo(this,t,r,i);default:if(d)throw new TypeError("Unknown encoding: "+a);a=(""+a).toLowerCase(),d=!0}};g.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Ro(e,t,r){return t===0&&r===e.length?Mr.fromByteArray(e):Mr.fromByteArray(e.slice(t,r))}function Xn(e,t,r){r=Math.min(e.length,r);for(var i=[],a=t;a<r;){var u=e[a],d=null,m=u>239?4:u>223?3:u>191?2:1;if(a+m<=r){var w,T,j,O;switch(m){case 1:u<128&&(d=u);break;case 2:w=e[a+1],(w&192)===128&&(O=(u&31)<<6|w&63,O>127&&(d=O));break;case 3:w=e[a+1],T=e[a+2],(w&192)===128&&(T&192)===128&&(O=(u&15)<<12|(w&63)<<6|T&63,O>2047&&(O<55296||O>57343)&&(d=O));break;case 4:w=e[a+1],T=e[a+2],j=e[a+3],(w&192)===128&&(T&192)===128&&(j&192)===128&&(O=(u&15)<<18|(w&63)<<12|(T&63)<<6|j&63,O>65535&&O<1114112&&(d=O))}}d===null?(d=65533,m=1):d>65535&&(d-=65536,i.push(d>>>10&1023|55296),d=56320|d&1023),i.push(d),a+=m}return No(i)}var $n=4096;function No(e){var t=e.length;if(t<=$n)return String.fromCharCode.apply(String,e);for(var r="",i=0;i<t;)r+=String.fromCharCode.apply(String,e.slice(i,i+=$n));return r}function Co(e,t,r){var i="";r=Math.min(e.length,r);for(var a=t;a<r;++a)i+=String.fromCharCode(e[a]&127);return i}function Fo(e,t,r){var i="";r=Math.min(e.length,r);for(var a=t;a<r;++a)i+=String.fromCharCode(e[a]);return i}function Po(e,t,r){var i=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>i)&&(r=i);for(var a="",u=t;u<r;++u)a+=Vo[e[u]];return a}function ko(e,t,r){for(var i=e.slice(t,r),a="",u=0;u<i.length-1;u+=2)a+=String.fromCharCode(i[u]+i[u+1]*256);return a}g.prototype.slice=function(t,r){var i=this.length;t=~~t,r=r===void 0?i:~~r,t<0?(t+=i,t<0&&(t=0)):t>i&&(t=i),r<0?(r+=i,r<0&&(r=0)):r>i&&(r=i),r<t&&(r=t);var a=this.subarray(t,r);return Object.setPrototypeOf(a,g.prototype),a};function ht(e,t,r){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}g.prototype.readUintLE=g.prototype.readUIntLE=function(t,r,i){t=t>>>0,r=r>>>0,i||ht(t,r,this.length);for(var a=this[t],u=1,d=0;++d<r&&(u*=256);)a+=this[t+d]*u;return a};g.prototype.readUintBE=g.prototype.readUIntBE=function(t,r,i){t=t>>>0,r=r>>>0,i||ht(t,r,this.length);for(var a=this[t+--r],u=1;r>0&&(u*=256);)a+=this[t+--r]*u;return a};g.prototype.readUint8=g.prototype.readUInt8=function(t,r){return t=t>>>0,r||ht(t,1,this.length),this[t]};g.prototype.readUint16LE=g.prototype.readUInt16LE=function(t,r){return t=t>>>0,r||ht(t,2,this.length),this[t]|this[t+1]<<8};g.prototype.readUint16BE=g.prototype.readUInt16BE=function(t,r){return t=t>>>0,r||ht(t,2,this.length),this[t]<<8|this[t+1]};g.prototype.readUint32LE=g.prototype.readUInt32LE=function(t,r){return t=t>>>0,r||ht(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};g.prototype.readUint32BE=g.prototype.readUInt32BE=function(t,r){return t=t>>>0,r||ht(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};g.prototype.readIntLE=function(t,r,i){t=t>>>0,r=r>>>0,i||ht(t,r,this.length);for(var a=this[t],u=1,d=0;++d<r&&(u*=256);)a+=this[t+d]*u;return u*=128,a>=u&&(a-=Math.pow(2,8*r)),a};g.prototype.readIntBE=function(t,r,i){t=t>>>0,r=r>>>0,i||ht(t,r,this.length);for(var a=r,u=1,d=this[t+--a];a>0&&(u*=256);)d+=this[t+--a]*u;return u*=128,d>=u&&(d-=Math.pow(2,8*r)),d};g.prototype.readInt8=function(t,r){return t=t>>>0,r||ht(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};g.prototype.readInt16LE=function(t,r){t=t>>>0,r||ht(t,2,this.length);var i=this[t]|this[t+1]<<8;return i&32768?i|4294901760:i};g.prototype.readInt16BE=function(t,r){t=t>>>0,r||ht(t,2,this.length);var i=this[t+1]|this[t]<<8;return i&32768?i|4294901760:i};g.prototype.readInt32LE=function(t,r){return t=t>>>0,r||ht(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};g.prototype.readInt32BE=function(t,r){return t=t>>>0,r||ht(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};g.prototype.readFloatLE=function(t,r){return t=t>>>0,r||ht(t,4,this.length),be.read(this,t,!0,23,4)};g.prototype.readFloatBE=function(t,r){return t=t>>>0,r||ht(t,4,this.length),be.read(this,t,!1,23,4)};g.prototype.readDoubleLE=function(t,r){return t=t>>>0,r||ht(t,8,this.length),be.read(this,t,!0,52,8)};g.prototype.readDoubleBE=function(t,r){return t=t>>>0,r||ht(t,8,this.length),be.read(this,t,!1,52,8)};function wt(e,t,r,i,a,u){if(!g.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>a||t<u)throw new RangeError('"value" argument is out of bounds');if(r+i>e.length)throw new RangeError("Index out of range")}g.prototype.writeUintLE=g.prototype.writeUIntLE=function(t,r,i,a){if(t=+t,r=r>>>0,i=i>>>0,!a){var u=Math.pow(2,8*i)-1;wt(this,t,r,i,u,0)}var d=1,m=0;for(this[r]=t&255;++m<i&&(d*=256);)this[r+m]=t/d&255;return r+i};g.prototype.writeUintBE=g.prototype.writeUIntBE=function(t,r,i,a){if(t=+t,r=r>>>0,i=i>>>0,!a){var u=Math.pow(2,8*i)-1;wt(this,t,r,i,u,0)}var d=i-1,m=1;for(this[r+d]=t&255;--d>=0&&(m*=256);)this[r+d]=t/m&255;return r+i};g.prototype.writeUint8=g.prototype.writeUInt8=function(t,r,i){return t=+t,r=r>>>0,i||wt(this,t,r,1,255,0),this[r]=t&255,r+1};g.prototype.writeUint16LE=g.prototype.writeUInt16LE=function(t,r,i){return t=+t,r=r>>>0,i||wt(this,t,r,2,65535,0),this[r]=t&255,this[r+1]=t>>>8,r+2};g.prototype.writeUint16BE=g.prototype.writeUInt16BE=function(t,r,i){return t=+t,r=r>>>0,i||wt(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=t&255,r+2};g.prototype.writeUint32LE=g.prototype.writeUInt32LE=function(t,r,i){return t=+t,r=r>>>0,i||wt(this,t,r,4,4294967295,0),this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=t&255,r+4};g.prototype.writeUint32BE=g.prototype.writeUInt32BE=function(t,r,i){return t=+t,r=r>>>0,i||wt(this,t,r,4,4294967295,0),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255,r+4};g.prototype.writeIntLE=function(t,r,i,a){if(t=+t,r=r>>>0,!a){var u=Math.pow(2,8*i-1);wt(this,t,r,i,u-1,-u)}var d=0,m=1,w=0;for(this[r]=t&255;++d<i&&(m*=256);)t<0&&w===0&&this[r+d-1]!==0&&(w=1),this[r+d]=(t/m>>0)-w&255;return r+i};g.prototype.writeIntBE=function(t,r,i,a){if(t=+t,r=r>>>0,!a){var u=Math.pow(2,8*i-1);wt(this,t,r,i,u-1,-u)}var d=i-1,m=1,w=0;for(this[r+d]=t&255;--d>=0&&(m*=256);)t<0&&w===0&&this[r+d+1]!==0&&(w=1),this[r+d]=(t/m>>0)-w&255;return r+i};g.prototype.writeInt8=function(t,r,i){return t=+t,r=r>>>0,i||wt(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=t&255,r+1};g.prototype.writeInt16LE=function(t,r,i){return t=+t,r=r>>>0,i||wt(this,t,r,2,32767,-32768),this[r]=t&255,this[r+1]=t>>>8,r+2};g.prototype.writeInt16BE=function(t,r,i){return t=+t,r=r>>>0,i||wt(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=t&255,r+2};g.prototype.writeInt32LE=function(t,r,i){return t=+t,r=r>>>0,i||wt(this,t,r,4,2147483647,-2147483648),this[r]=t&255,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24,r+4};g.prototype.writeInt32BE=function(t,r,i){return t=+t,r=r>>>0,i||wt(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255,r+4};function Zn(e,t,r,i,a,u){if(r+i>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Qn(e,t,r,i,a){return t=+t,r=r>>>0,a||Zn(e,t,r,4,34028234663852886e22,-34028234663852886e22),be.write(e,t,r,i,23,4),r+4}g.prototype.writeFloatLE=function(t,r,i){return Qn(this,t,r,!0,i)};g.prototype.writeFloatBE=function(t,r,i){return Qn(this,t,r,!1,i)};function Dn(e,t,r,i,a){return t=+t,r=r>>>0,a||Zn(e,t,r,8,17976931348623157e292,-17976931348623157e292),be.write(e,t,r,i,52,8),r+8}g.prototype.writeDoubleLE=function(t,r,i){return Dn(this,t,r,!0,i)};g.prototype.writeDoubleBE=function(t,r,i){return Dn(this,t,r,!1,i)};g.prototype.copy=function(t,r,i,a){if(!g.isBuffer(t))throw new TypeError("argument should be a Buffer");if(i||(i=0),!a&&a!==0&&(a=this.length),r>=t.length&&(r=t.length),r||(r=0),a>0&&a<i&&(a=i),a===i||t.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(i<0||i>=this.length)throw new RangeError("Index out of range");if(a<0)throw new RangeError("sourceEnd out of bounds");a>this.length&&(a=this.length),t.length-r<a-i&&(a=t.length-r+i);var u=a-i;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,i,a):Uint8Array.prototype.set.call(t,this.subarray(i,a),r),u};g.prototype.fill=function(t,r,i,a){if(typeof t=="string"){if(typeof r=="string"?(a=r,r=0,i=this.length):typeof i=="string"&&(a=i,i=this.length),a!==void 0&&typeof a!="string")throw new TypeError("encoding must be a string");if(typeof a=="string"&&!g.isEncoding(a))throw new TypeError("Unknown encoding: "+a);if(t.length===1){var u=t.charCodeAt(0);(a==="utf8"&&u<128||a==="latin1")&&(t=u)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(r<0||this.length<r||this.length<i)throw new RangeError("Out of range index");if(i<=r)return this;r=r>>>0,i=i===void 0?this.length:i>>>0,t||(t=0);var d;if(typeof t=="number")for(d=r;d<i;++d)this[d]=t;else{var m=g.isBuffer(t)?t:g.from(t,a),w=m.length;if(w===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(d=0;d<i-r;++d)this[d+r]=m[d%w]}return this};var jo=/[^+/0-9A-Za-z-_]/g;function Ko(e){if(e=e.split("=")[0],e=e.trim().replace(jo,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function qr(e,t){t=t||1/0;for(var r,i=e.length,a=null,u=[],d=0;d<i;++d){if(r=e.charCodeAt(d),r>55295&&r<57344){if(!a){if(r>56319){(t-=3)>-1&&u.push(239,191,189);continue}else if(d+1===i){(t-=3)>-1&&u.push(239,191,189);continue}a=r;continue}if(r<56320){(t-=3)>-1&&u.push(239,191,189),a=r;continue}r=(a-55296<<10|r-56320)+65536}else a&&(t-=3)>-1&&u.push(239,191,189);if(a=null,r<128){if((t-=1)<0)break;u.push(r)}else if(r<2048){if((t-=2)<0)break;u.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;u.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((t-=4)<0)break;u.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return u}function Mo(e){for(var t=[],r=0;r<e.length;++r)t.push(e.charCodeAt(r)&255);return t}function Yo(e,t){for(var r,i,a,u=[],d=0;d<e.length&&!((t-=2)<0);++d)r=e.charCodeAt(d),i=r>>8,a=r%256,u.push(a),u.push(i);return u}function Ln(e){return Mr.toByteArray(Ko(e))}function fr(e,t,r,i){for(var a=0;a<i&&!(a+r>=t.length||a>=e.length);++a)t[a+r]=e[a];return a}function Ft(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function $r(e){return e!==e}var Vo=function(){for(var e="0123456789abcdef",t=new Array(256),r=0;r<16;++r)for(var i=r*16,a=0;a<16;++a)t[i+a]=e[r]+e[a];return t}()});var xi={};Bn(xi,{default:()=>aa});var aa,yi=ao(()=>{aa={}});var mi=rr((ef,pr)=>{var se=(yi(),so(xi));if(se&&se.default){pr.exports=se.default;for(let e in se)pr.exports[e]=se[e]}else se&&(pr.exports=se)});var Zr=rr((rf,xr)=>{(function(e){"use strict";var t=function(o){var f,s=new Float64Array(16);if(o)for(f=0;f<o.length;f++)s[f]=o[f];return s},r=function(){throw new Error("no PRNG")},i=new Uint8Array(16),a=new Uint8Array(32);a[0]=9;var u=t(),d=t([1]),m=t([56129,1]),w=t([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),T=t([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),j=t([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),O=t([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),Q=t([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function at(o,f,s,n){o[f]=s>>24&255,o[f+1]=s>>16&255,o[f+2]=s>>8&255,o[f+3]=s&255,o[f+4]=n>>24&255,o[f+5]=n>>16&255,o[f+6]=n>>8&255,o[f+7]=n&255}function it(o,f,s,n,c){var h,p=0;for(h=0;h<c;h++)p|=o[f+h]^s[n+h];return(1&p-1>>>8)-1}function bt(o,f,s,n){return it(o,f,s,n,16)}function Mt(o,f,s,n){return it(o,f,s,n,32)}function Dt(o,f,s,n){for(var c=n[0]&255|(n[1]&255)<<8|(n[2]&255)<<16|(n[3]&255)<<24,h=s[0]&255|(s[1]&255)<<8|(s[2]&255)<<16|(s[3]&255)<<24,p=s[4]&255|(s[5]&255)<<8|(s[6]&255)<<16|(s[7]&255)<<24,b=s[8]&255|(s[9]&255)<<8|(s[10]&255)<<16|(s[11]&255)<<24,S=s[12]&255|(s[13]&255)<<8|(s[14]&255)<<16|(s[15]&255)<<24,k=n[4]&255|(n[5]&255)<<8|(n[6]&255)<<16|(n[7]&255)<<24,B=f[0]&255|(f[1]&255)<<8|(f[2]&255)<<16|(f[3]&255)<<24,et=f[4]&255|(f[5]&255)<<8|(f[6]&255)<<16|(f[7]&255)<<24,N=f[8]&255|(f[9]&255)<<8|(f[10]&255)<<16|(f[11]&255)<<24,Y=f[12]&255|(f[13]&255)<<8|(f[14]&255)<<16|(f[15]&255)<<24,V=n[8]&255|(n[9]&255)<<8|(n[10]&255)<<16|(n[11]&255)<<24,W=s[16]&255|(s[17]&255)<<8|(s[18]&255)<<16|(s[19]&255)<<24,$=s[20]&255|(s[21]&255)<<8|(s[22]&255)<<16|(s[23]&255)<<24,q=s[24]&255|(s[25]&255)<<8|(s[26]&255)<<16|(s[27]&255)<<24,I=s[28]&255|(s[29]&255)<<8|(s[30]&255)<<16|(s[31]&255)<<24,H=n[12]&255|(n[13]&255)<<8|(n[14]&255)<<16|(n[15]&255)<<24,C=c,K=h,R=p,F=b,P=S,U=k,x=B,y=et,E=N,_=Y,v=V,A=W,M=$,z=q,J=I,G=H,l,Z=0;Z<20;Z+=2)l=C+M|0,P^=l<<7|l>>>32-7,l=P+C|0,E^=l<<9|l>>>32-9,l=E+P|0,M^=l<<13|l>>>32-13,l=M+E|0,C^=l<<18|l>>>32-18,l=U+K|0,_^=l<<7|l>>>32-7,l=_+U|0,z^=l<<9|l>>>32-9,l=z+_|0,K^=l<<13|l>>>32-13,l=K+z|0,U^=l<<18|l>>>32-18,l=v+x|0,J^=l<<7|l>>>32-7,l=J+v|0,R^=l<<9|l>>>32-9,l=R+J|0,x^=l<<13|l>>>32-13,l=x+R|0,v^=l<<18|l>>>32-18,l=G+A|0,F^=l<<7|l>>>32-7,l=F+G|0,y^=l<<9|l>>>32-9,l=y+F|0,A^=l<<13|l>>>32-13,l=A+y|0,G^=l<<18|l>>>32-18,l=C+F|0,K^=l<<7|l>>>32-7,l=K+C|0,R^=l<<9|l>>>32-9,l=R+K|0,F^=l<<13|l>>>32-13,l=F+R|0,C^=l<<18|l>>>32-18,l=U+P|0,x^=l<<7|l>>>32-7,l=x+U|0,y^=l<<9|l>>>32-9,l=y+x|0,P^=l<<13|l>>>32-13,l=P+y|0,U^=l<<18|l>>>32-18,l=v+_|0,A^=l<<7|l>>>32-7,l=A+v|0,E^=l<<9|l>>>32-9,l=E+A|0,_^=l<<13|l>>>32-13,l=_+E|0,v^=l<<18|l>>>32-18,l=G+J|0,M^=l<<7|l>>>32-7,l=M+G|0,z^=l<<9|l>>>32-9,l=z+M|0,J^=l<<13|l>>>32-13,l=J+z|0,G^=l<<18|l>>>32-18;C=C+c|0,K=K+h|0,R=R+p|0,F=F+b|0,P=P+S|0,U=U+k|0,x=x+B|0,y=y+et|0,E=E+N|0,_=_+Y|0,v=v+V|0,A=A+W|0,M=M+$|0,z=z+q|0,J=J+I|0,G=G+H|0,o[0]=C>>>0&255,o[1]=C>>>8&255,o[2]=C>>>16&255,o[3]=C>>>24&255,o[4]=K>>>0&255,o[5]=K>>>8&255,o[6]=K>>>16&255,o[7]=K>>>24&255,o[8]=R>>>0&255,o[9]=R>>>8&255,o[10]=R>>>16&255,o[11]=R>>>24&255,o[12]=F>>>0&255,o[13]=F>>>8&255,o[14]=F>>>16&255,o[15]=F>>>24&255,o[16]=P>>>0&255,o[17]=P>>>8&255,o[18]=P>>>16&255,o[19]=P>>>24&255,o[20]=U>>>0&255,o[21]=U>>>8&255,o[22]=U>>>16&255,o[23]=U>>>24&255,o[24]=x>>>0&255,o[25]=x>>>8&255,o[26]=x>>>16&255,o[27]=x>>>24&255,o[28]=y>>>0&255,o[29]=y>>>8&255,o[30]=y>>>16&255,o[31]=y>>>24&255,o[32]=E>>>0&255,o[33]=E>>>8&255,o[34]=E>>>16&255,o[35]=E>>>24&255,o[36]=_>>>0&255,o[37]=_>>>8&255,o[38]=_>>>16&255,o[39]=_>>>24&255,o[40]=v>>>0&255,o[41]=v>>>8&255,o[42]=v>>>16&255,o[43]=v>>>24&255,o[44]=A>>>0&255,o[45]=A>>>8&255,o[46]=A>>>16&255,o[47]=A>>>24&255,o[48]=M>>>0&255,o[49]=M>>>8&255,o[50]=M>>>16&255,o[51]=M>>>24&255,o[52]=z>>>0&255,o[53]=z>>>8&255,o[54]=z>>>16&255,o[55]=z>>>24&255,o[56]=J>>>0&255,o[57]=J>>>8&255,o[58]=J>>>16&255,o[59]=J>>>24&255,o[60]=G>>>0&255,o[61]=G>>>8&255,o[62]=G>>>16&255,o[63]=G>>>24&255}function le(o,f,s,n){for(var c=n[0]&255|(n[1]&255)<<8|(n[2]&255)<<16|(n[3]&255)<<24,h=s[0]&255|(s[1]&255)<<8|(s[2]&255)<<16|(s[3]&255)<<24,p=s[4]&255|(s[5]&255)<<8|(s[6]&255)<<16|(s[7]&255)<<24,b=s[8]&255|(s[9]&255)<<8|(s[10]&255)<<16|(s[11]&255)<<24,S=s[12]&255|(s[13]&255)<<8|(s[14]&255)<<16|(s[15]&255)<<24,k=n[4]&255|(n[5]&255)<<8|(n[6]&255)<<16|(n[7]&255)<<24,B=f[0]&255|(f[1]&255)<<8|(f[2]&255)<<16|(f[3]&255)<<24,et=f[4]&255|(f[5]&255)<<8|(f[6]&255)<<16|(f[7]&255)<<24,N=f[8]&255|(f[9]&255)<<8|(f[10]&255)<<16|(f[11]&255)<<24,Y=f[12]&255|(f[13]&255)<<8|(f[14]&255)<<16|(f[15]&255)<<24,V=n[8]&255|(n[9]&255)<<8|(n[10]&255)<<16|(n[11]&255)<<24,W=s[16]&255|(s[17]&255)<<8|(s[18]&255)<<16|(s[19]&255)<<24,$=s[20]&255|(s[21]&255)<<8|(s[22]&255)<<16|(s[23]&255)<<24,q=s[24]&255|(s[25]&255)<<8|(s[26]&255)<<16|(s[27]&255)<<24,I=s[28]&255|(s[29]&255)<<8|(s[30]&255)<<16|(s[31]&255)<<24,H=n[12]&255|(n[13]&255)<<8|(n[14]&255)<<16|(n[15]&255)<<24,C=c,K=h,R=p,F=b,P=S,U=k,x=B,y=et,E=N,_=Y,v=V,A=W,M=$,z=q,J=I,G=H,l,Z=0;Z<20;Z+=2)l=C+M|0,P^=l<<7|l>>>32-7,l=P+C|0,E^=l<<9|l>>>32-9,l=E+P|0,M^=l<<13|l>>>32-13,l=M+E|0,C^=l<<18|l>>>32-18,l=U+K|0,_^=l<<7|l>>>32-7,l=_+U|0,z^=l<<9|l>>>32-9,l=z+_|0,K^=l<<13|l>>>32-13,l=K+z|0,U^=l<<18|l>>>32-18,l=v+x|0,J^=l<<7|l>>>32-7,l=J+v|0,R^=l<<9|l>>>32-9,l=R+J|0,x^=l<<13|l>>>32-13,l=x+R|0,v^=l<<18|l>>>32-18,l=G+A|0,F^=l<<7|l>>>32-7,l=F+G|0,y^=l<<9|l>>>32-9,l=y+F|0,A^=l<<13|l>>>32-13,l=A+y|0,G^=l<<18|l>>>32-18,l=C+F|0,K^=l<<7|l>>>32-7,l=K+C|0,R^=l<<9|l>>>32-9,l=R+K|0,F^=l<<13|l>>>32-13,l=F+R|0,C^=l<<18|l>>>32-18,l=U+P|0,x^=l<<7|l>>>32-7,l=x+U|0,y^=l<<9|l>>>32-9,l=y+x|0,P^=l<<13|l>>>32-13,l=P+y|0,U^=l<<18|l>>>32-18,l=v+_|0,A^=l<<7|l>>>32-7,l=A+v|0,E^=l<<9|l>>>32-9,l=E+A|0,_^=l<<13|l>>>32-13,l=_+E|0,v^=l<<18|l>>>32-18,l=G+J|0,M^=l<<7|l>>>32-7,l=M+G|0,z^=l<<9|l>>>32-9,l=z+M|0,J^=l<<13|l>>>32-13,l=J+z|0,G^=l<<18|l>>>32-18;o[0]=C>>>0&255,o[1]=C>>>8&255,o[2]=C>>>16&255,o[3]=C>>>24&255,o[4]=U>>>0&255,o[5]=U>>>8&255,o[6]=U>>>16&255,o[7]=U>>>24&255,o[8]=v>>>0&255,o[9]=v>>>8&255,o[10]=v>>>16&255,o[11]=v>>>24&255,o[12]=G>>>0&255,o[13]=G>>>8&255,o[14]=G>>>16&255,o[15]=G>>>24&255,o[16]=x>>>0&255,o[17]=x>>>8&255,o[18]=x>>>16&255,o[19]=x>>>24&255,o[20]=y>>>0&255,o[21]=y>>>8&255,o[22]=y>>>16&255,o[23]=y>>>24&255,o[24]=E>>>0&255,o[25]=E>>>8&255,o[26]=E>>>16&255,o[27]=E>>>24&255,o[28]=_>>>0&255,o[29]=_>>>8&255,o[30]=_>>>16&255,o[31]=_>>>24&255}function Zt(o,f,s,n){Dt(o,f,s,n)}function Yt(o,f,s,n){le(o,f,s,n)}var Vt=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function We(o,f,s,n,c,h,p){var b=new Uint8Array(16),S=new Uint8Array(64),k,B;for(B=0;B<16;B++)b[B]=0;for(B=0;B<8;B++)b[B]=h[B];for(;c>=64;){for(Zt(S,b,p,Vt),B=0;B<64;B++)o[f+B]=s[n+B]^S[B];for(k=1,B=8;B<16;B++)k=k+(b[B]&255)|0,b[B]=k&255,k>>>=8;c-=64,f+=64,n+=64}if(c>0)for(Zt(S,b,p,Vt),B=0;B<c;B++)o[f+B]=s[n+B]^S[B];return 0}function ze(o,f,s,n,c){var h=new Uint8Array(16),p=new Uint8Array(64),b,S;for(S=0;S<16;S++)h[S]=0;for(S=0;S<8;S++)h[S]=n[S];for(;s>=64;){for(Zt(p,h,c,Vt),S=0;S<64;S++)o[f+S]=p[S];for(b=1,S=8;S<16;S++)b=b+(h[S]&255)|0,h[S]=b&255,b>>>=8;s-=64,f+=64}if(s>0)for(Zt(p,h,c,Vt),S=0;S<s;S++)o[f+S]=p[S];return 0}function Oe(o,f,s,n,c){var h=new Uint8Array(32);Yt(h,n,c,Vt);for(var p=new Uint8Array(8),b=0;b<8;b++)p[b]=n[b+16];return ze(o,f,s,p,h)}function Qt(o,f,s,n,c,h,p){var b=new Uint8Array(32);Yt(b,h,p,Vt);for(var S=new Uint8Array(8),k=0;k<8;k++)S[k]=h[k+16];return We(o,f,s,n,c,S,b)}var de=function(o){this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.leftover=0,this.fin=0;var f,s,n,c,h,p,b,S;f=o[0]&255|(o[1]&255)<<8,this.r[0]=f&8191,s=o[2]&255|(o[3]&255)<<8,this.r[1]=(f>>>13|s<<3)&8191,n=o[4]&255|(o[5]&255)<<8,this.r[2]=(s>>>10|n<<6)&7939,c=o[6]&255|(o[7]&255)<<8,this.r[3]=(n>>>7|c<<9)&8191,h=o[8]&255|(o[9]&255)<<8,this.r[4]=(c>>>4|h<<12)&255,this.r[5]=h>>>1&8190,p=o[10]&255|(o[11]&255)<<8,this.r[6]=(h>>>14|p<<2)&8191,b=o[12]&255|(o[13]&255)<<8,this.r[7]=(p>>>11|b<<5)&8065,S=o[14]&255|(o[15]&255)<<8,this.r[8]=(b>>>8|S<<8)&8191,this.r[9]=S>>>5&127,this.pad[0]=o[16]&255|(o[17]&255)<<8,this.pad[1]=o[18]&255|(o[19]&255)<<8,this.pad[2]=o[20]&255|(o[21]&255)<<8,this.pad[3]=o[22]&255|(o[23]&255)<<8,this.pad[4]=o[24]&255|(o[25]&255)<<8,this.pad[5]=o[26]&255|(o[27]&255)<<8,this.pad[6]=o[28]&255|(o[29]&255)<<8,this.pad[7]=o[30]&255|(o[31]&255)<<8};de.prototype.blocks=function(o,f,s){for(var n=this.fin?0:2048,c,h,p,b,S,k,B,et,N,Y,V,W,$,q,I,H,C,K,R,F=this.h[0],P=this.h[1],U=this.h[2],x=this.h[3],y=this.h[4],E=this.h[5],_=this.h[6],v=this.h[7],A=this.h[8],M=this.h[9],z=this.r[0],J=this.r[1],G=this.r[2],l=this.r[3],Z=this.r[4],rt=this.r[5],nt=this.r[6],X=this.r[7],L=this.r[8],tt=this.r[9];s>=16;)c=o[f+0]&255|(o[f+1]&255)<<8,F+=c&8191,h=o[f+2]&255|(o[f+3]&255)<<8,P+=(c>>>13|h<<3)&8191,p=o[f+4]&255|(o[f+5]&255)<<8,U+=(h>>>10|p<<6)&8191,b=o[f+6]&255|(o[f+7]&255)<<8,x+=(p>>>7|b<<9)&8191,S=o[f+8]&255|(o[f+9]&255)<<8,y+=(b>>>4|S<<12)&8191,E+=S>>>1&8191,k=o[f+10]&255|(o[f+11]&255)<<8,_+=(S>>>14|k<<2)&8191,B=o[f+12]&255|(o[f+13]&255)<<8,v+=(k>>>11|B<<5)&8191,et=o[f+14]&255|(o[f+15]&255)<<8,A+=(B>>>8|et<<8)&8191,M+=et>>>5|n,N=0,Y=N,Y+=F*z,Y+=P*(5*tt),Y+=U*(5*L),Y+=x*(5*X),Y+=y*(5*nt),N=Y>>>13,Y&=8191,Y+=E*(5*rt),Y+=_*(5*Z),Y+=v*(5*l),Y+=A*(5*G),Y+=M*(5*J),N+=Y>>>13,Y&=8191,V=N,V+=F*J,V+=P*z,V+=U*(5*tt),V+=x*(5*L),V+=y*(5*X),N=V>>>13,V&=8191,V+=E*(5*nt),V+=_*(5*rt),V+=v*(5*Z),V+=A*(5*l),V+=M*(5*G),N+=V>>>13,V&=8191,W=N,W+=F*G,W+=P*J,W+=U*z,W+=x*(5*tt),W+=y*(5*L),N=W>>>13,W&=8191,W+=E*(5*X),W+=_*(5*nt),W+=v*(5*rt),W+=A*(5*Z),W+=M*(5*l),N+=W>>>13,W&=8191,$=N,$+=F*l,$+=P*G,$+=U*J,$+=x*z,$+=y*(5*tt),N=$>>>13,$&=8191,$+=E*(5*L),$+=_*(5*X),$+=v*(5*nt),$+=A*(5*rt),$+=M*(5*Z),N+=$>>>13,$&=8191,q=N,q+=F*Z,q+=P*l,q+=U*G,q+=x*J,q+=y*z,N=q>>>13,q&=8191,q+=E*(5*tt),q+=_*(5*L),q+=v*(5*X),q+=A*(5*nt),q+=M*(5*rt),N+=q>>>13,q&=8191,I=N,I+=F*rt,I+=P*Z,I+=U*l,I+=x*G,I+=y*J,N=I>>>13,I&=8191,I+=E*z,I+=_*(5*tt),I+=v*(5*L),I+=A*(5*X),I+=M*(5*nt),N+=I>>>13,I&=8191,H=N,H+=F*nt,H+=P*rt,H+=U*Z,H+=x*l,H+=y*G,N=H>>>13,H&=8191,H+=E*J,H+=_*z,H+=v*(5*tt),H+=A*(5*L),H+=M*(5*X),N+=H>>>13,H&=8191,C=N,C+=F*X,C+=P*nt,C+=U*rt,C+=x*Z,C+=y*l,N=C>>>13,C&=8191,C+=E*G,C+=_*J,C+=v*z,C+=A*(5*tt),C+=M*(5*L),N+=C>>>13,C&=8191,K=N,K+=F*L,K+=P*X,K+=U*nt,K+=x*rt,K+=y*Z,N=K>>>13,K&=8191,K+=E*l,K+=_*G,K+=v*J,K+=A*z,K+=M*(5*tt),N+=K>>>13,K&=8191,R=N,R+=F*tt,R+=P*L,R+=U*X,R+=x*nt,R+=y*rt,N=R>>>13,R&=8191,R+=E*Z,R+=_*l,R+=v*G,R+=A*J,R+=M*z,N+=R>>>13,R&=8191,N=(N<<2)+N|0,N=N+Y|0,Y=N&8191,N=N>>>13,V+=N,F=Y,P=V,U=W,x=$,y=q,E=I,_=H,v=C,A=K,M=R,f+=16,s-=16;this.h[0]=F,this.h[1]=P,this.h[2]=U,this.h[3]=x,this.h[4]=y,this.h[5]=E,this.h[6]=_,this.h[7]=v,this.h[8]=A,this.h[9]=M},de.prototype.finish=function(o,f){var s=new Uint16Array(10),n,c,h,p;if(this.leftover){for(p=this.leftover,this.buffer[p++]=1;p<16;p++)this.buffer[p]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(n=this.h[1]>>>13,this.h[1]&=8191,p=2;p<10;p++)this.h[p]+=n,n=this.h[p]>>>13,this.h[p]&=8191;for(this.h[0]+=n*5,n=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=n,n=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=n,s[0]=this.h[0]+5,n=s[0]>>>13,s[0]&=8191,p=1;p<10;p++)s[p]=this.h[p]+n,n=s[p]>>>13,s[p]&=8191;for(s[9]-=1<<13,c=(n^1)-1,p=0;p<10;p++)s[p]&=c;for(c=~c,p=0;p<10;p++)this.h[p]=this.h[p]&c|s[p];for(this.h[0]=(this.h[0]|this.h[1]<<13)&65535,this.h[1]=(this.h[1]>>>3|this.h[2]<<10)&65535,this.h[2]=(this.h[2]>>>6|this.h[3]<<7)&65535,this.h[3]=(this.h[3]>>>9|this.h[4]<<4)&65535,this.h[4]=(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14)&65535,this.h[5]=(this.h[6]>>>2|this.h[7]<<11)&65535,this.h[6]=(this.h[7]>>>5|this.h[8]<<8)&65535,this.h[7]=(this.h[8]>>>8|this.h[9]<<5)&65535,h=this.h[0]+this.pad[0],this.h[0]=h&65535,p=1;p<8;p++)h=(this.h[p]+this.pad[p]|0)+(h>>>16)|0,this.h[p]=h&65535;o[f+0]=this.h[0]>>>0&255,o[f+1]=this.h[0]>>>8&255,o[f+2]=this.h[1]>>>0&255,o[f+3]=this.h[1]>>>8&255,o[f+4]=this.h[2]>>>0&255,o[f+5]=this.h[2]>>>8&255,o[f+6]=this.h[3]>>>0&255,o[f+7]=this.h[3]>>>8&255,o[f+8]=this.h[4]>>>0&255,o[f+9]=this.h[4]>>>8&255,o[f+10]=this.h[5]>>>0&255,o[f+11]=this.h[5]>>>8&255,o[f+12]=this.h[6]>>>0&255,o[f+13]=this.h[6]>>>8&255,o[f+14]=this.h[7]>>>0&255,o[f+15]=this.h[7]>>>8&255},de.prototype.update=function(o,f,s){var n,c;if(this.leftover){for(c=16-this.leftover,c>s&&(c=s),n=0;n<c;n++)this.buffer[this.leftover+n]=o[f+n];if(s-=c,f+=c,this.leftover+=c,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(s>=16&&(c=s-s%16,this.blocks(o,f,c),f+=c,s-=c),s){for(n=0;n<s;n++)this.buffer[this.leftover+n]=o[f+n];this.leftover+=s}};function Ue(o,f,s,n,c,h){var p=new de(h);return p.update(s,n,c),p.finish(o,f),0}function Ge(o,f,s,n,c,h){var p=new Uint8Array(16);return Ue(p,0,s,n,c,h),bt(o,f,p,0)}function Be(o,f,s,n,c){var h;if(s<32)return-1;for(Qt(o,0,f,0,s,n,c),Ue(o,16,o,32,s-32,o),h=0;h<16;h++)o[h]=0;return 0}function Re(o,f,s,n,c){var h,p=new Uint8Array(32);if(s<32||(Oe(p,0,32,n,c),Ge(f,16,f,32,s-32,p)!==0))return-1;for(Qt(o,0,f,0,s,n,c),h=0;h<32;h++)o[h]=0;return 0}function qt(o,f){var s;for(s=0;s<16;s++)o[s]=f[s]|0}function Tr(o){var f,s,n=1;for(f=0;f<16;f++)s=o[f]+n+65535,n=Math.floor(s/65536),o[f]=s-n*65536;o[0]+=n-1+37*(n-1)}function he(o,f,s){for(var n,c=~(s-1),h=0;h<16;h++)n=c&(o[h]^f[h]),o[h]^=n,f[h]^=n}function pe(o,f){var s,n,c,h=t(),p=t();for(s=0;s<16;s++)p[s]=f[s];for(Tr(p),Tr(p),Tr(p),n=0;n<2;n++){for(h[0]=p[0]-65517,s=1;s<15;s++)h[s]=p[s]-65535-(h[s-1]>>16&1),h[s-1]&=65535;h[15]=p[15]-32767-(h[14]>>16&1),c=h[15]>>16&1,h[14]&=65535,he(p,h,1-c)}for(s=0;s<16;s++)o[2*s]=p[s]&255,o[2*s+1]=p[s]>>8}function xn(o,f){var s=new Uint8Array(32),n=new Uint8Array(32);return pe(s,o),pe(n,f),Mt(s,0,n,0)}function yn(o){var f=new Uint8Array(32);return pe(f,o),f[0]&1}function Sr(o,f){var s;for(s=0;s<16;s++)o[s]=f[2*s]+(f[2*s+1]<<8);o[15]&=32767}function St(o,f,s){for(var n=0;n<16;n++)o[n]=f[n]+s[n]}function Ot(o,f,s){for(var n=0;n<16;n++)o[n]=f[n]-s[n]}function D(o,f,s){var n,c,h=0,p=0,b=0,S=0,k=0,B=0,et=0,N=0,Y=0,V=0,W=0,$=0,q=0,I=0,H=0,C=0,K=0,R=0,F=0,P=0,U=0,x=0,y=0,E=0,_=0,v=0,A=0,M=0,z=0,J=0,G=0,l=s[0],Z=s[1],rt=s[2],nt=s[3],X=s[4],L=s[5],tt=s[6],lt=s[7],ot=s[8],ft=s[9],ct=s[10],ut=s[11],dt=s[12],pt=s[13],xt=s[14],yt=s[15];n=f[0],h+=n*l,p+=n*Z,b+=n*rt,S+=n*nt,k+=n*X,B+=n*L,et+=n*tt,N+=n*lt,Y+=n*ot,V+=n*ft,W+=n*ct,$+=n*ut,q+=n*dt,I+=n*pt,H+=n*xt,C+=n*yt,n=f[1],p+=n*l,b+=n*Z,S+=n*rt,k+=n*nt,B+=n*X,et+=n*L,N+=n*tt,Y+=n*lt,V+=n*ot,W+=n*ft,$+=n*ct,q+=n*ut,I+=n*dt,H+=n*pt,C+=n*xt,K+=n*yt,n=f[2],b+=n*l,S+=n*Z,k+=n*rt,B+=n*nt,et+=n*X,N+=n*L,Y+=n*tt,V+=n*lt,W+=n*ot,$+=n*ft,q+=n*ct,I+=n*ut,H+=n*dt,C+=n*pt,K+=n*xt,R+=n*yt,n=f[3],S+=n*l,k+=n*Z,B+=n*rt,et+=n*nt,N+=n*X,Y+=n*L,V+=n*tt,W+=n*lt,$+=n*ot,q+=n*ft,I+=n*ct,H+=n*ut,C+=n*dt,K+=n*pt,R+=n*xt,F+=n*yt,n=f[4],k+=n*l,B+=n*Z,et+=n*rt,N+=n*nt,Y+=n*X,V+=n*L,W+=n*tt,$+=n*lt,q+=n*ot,I+=n*ft,H+=n*ct,C+=n*ut,K+=n*dt,R+=n*pt,F+=n*xt,P+=n*yt,n=f[5],B+=n*l,et+=n*Z,N+=n*rt,Y+=n*nt,V+=n*X,W+=n*L,$+=n*tt,q+=n*lt,I+=n*ot,H+=n*ft,C+=n*ct,K+=n*ut,R+=n*dt,F+=n*pt,P+=n*xt,U+=n*yt,n=f[6],et+=n*l,N+=n*Z,Y+=n*rt,V+=n*nt,W+=n*X,$+=n*L,q+=n*tt,I+=n*lt,H+=n*ot,C+=n*ft,K+=n*ct,R+=n*ut,F+=n*dt,P+=n*pt,U+=n*xt,x+=n*yt,n=f[7],N+=n*l,Y+=n*Z,V+=n*rt,W+=n*nt,$+=n*X,q+=n*L,I+=n*tt,H+=n*lt,C+=n*ot,K+=n*ft,R+=n*ct,F+=n*ut,P+=n*dt,U+=n*pt,x+=n*xt,y+=n*yt,n=f[8],Y+=n*l,V+=n*Z,W+=n*rt,$+=n*nt,q+=n*X,I+=n*L,H+=n*tt,C+=n*lt,K+=n*ot,R+=n*ft,F+=n*ct,P+=n*ut,U+=n*dt,x+=n*pt,y+=n*xt,E+=n*yt,n=f[9],V+=n*l,W+=n*Z,$+=n*rt,q+=n*nt,I+=n*X,H+=n*L,C+=n*tt,K+=n*lt,R+=n*ot,F+=n*ft,P+=n*ct,U+=n*ut,x+=n*dt,y+=n*pt,E+=n*xt,_+=n*yt,n=f[10],W+=n*l,$+=n*Z,q+=n*rt,I+=n*nt,H+=n*X,C+=n*L,K+=n*tt,R+=n*lt,F+=n*ot,P+=n*ft,U+=n*ct,x+=n*ut,y+=n*dt,E+=n*pt,_+=n*xt,v+=n*yt,n=f[11],$+=n*l,q+=n*Z,I+=n*rt,H+=n*nt,C+=n*X,K+=n*L,R+=n*tt,F+=n*lt,P+=n*ot,U+=n*ft,x+=n*ct,y+=n*ut,E+=n*dt,_+=n*pt,v+=n*xt,A+=n*yt,n=f[12],q+=n*l,I+=n*Z,H+=n*rt,C+=n*nt,K+=n*X,R+=n*L,F+=n*tt,P+=n*lt,U+=n*ot,x+=n*ft,y+=n*ct,E+=n*ut,_+=n*dt,v+=n*pt,A+=n*xt,M+=n*yt,n=f[13],I+=n*l,H+=n*Z,C+=n*rt,K+=n*nt,R+=n*X,F+=n*L,P+=n*tt,U+=n*lt,x+=n*ot,y+=n*ft,E+=n*ct,_+=n*ut,v+=n*dt,A+=n*pt,M+=n*xt,z+=n*yt,n=f[14],H+=n*l,C+=n*Z,K+=n*rt,R+=n*nt,F+=n*X,P+=n*L,U+=n*tt,x+=n*lt,y+=n*ot,E+=n*ft,_+=n*ct,v+=n*ut,A+=n*dt,M+=n*pt,z+=n*xt,J+=n*yt,n=f[15],C+=n*l,K+=n*Z,R+=n*rt,F+=n*nt,P+=n*X,U+=n*L,x+=n*tt,y+=n*lt,E+=n*ot,_+=n*ft,v+=n*ct,A+=n*ut,M+=n*dt,z+=n*pt,J+=n*xt,G+=n*yt,h+=38*K,p+=38*R,b+=38*F,S+=38*P,k+=38*U,B+=38*x,et+=38*y,N+=38*E,Y+=38*_,V+=38*v,W+=38*A,$+=38*M,q+=38*z,I+=38*J,H+=38*G,c=1,n=h+c+65535,c=Math.floor(n/65536),h=n-c*65536,n=p+c+65535,c=Math.floor(n/65536),p=n-c*65536,n=b+c+65535,c=Math.floor(n/65536),b=n-c*65536,n=S+c+65535,c=Math.floor(n/65536),S=n-c*65536,n=k+c+65535,c=Math.floor(n/65536),k=n-c*65536,n=B+c+65535,c=Math.floor(n/65536),B=n-c*65536,n=et+c+65535,c=Math.floor(n/65536),et=n-c*65536,n=N+c+65535,c=Math.floor(n/65536),N=n-c*65536,n=Y+c+65535,c=Math.floor(n/65536),Y=n-c*65536,n=V+c+65535,c=Math.floor(n/65536),V=n-c*65536,n=W+c+65535,c=Math.floor(n/65536),W=n-c*65536,n=$+c+65535,c=Math.floor(n/65536),$=n-c*65536,n=q+c+65535,c=Math.floor(n/65536),q=n-c*65536,n=I+c+65535,c=Math.floor(n/65536),I=n-c*65536,n=H+c+65535,c=Math.floor(n/65536),H=n-c*65536,n=C+c+65535,c=Math.floor(n/65536),C=n-c*65536,h+=c-1+37*(c-1),c=1,n=h+c+65535,c=Math.floor(n/65536),h=n-c*65536,n=p+c+65535,c=Math.floor(n/65536),p=n-c*65536,n=b+c+65535,c=Math.floor(n/65536),b=n-c*65536,n=S+c+65535,c=Math.floor(n/65536),S=n-c*65536,n=k+c+65535,c=Math.floor(n/65536),k=n-c*65536,n=B+c+65535,c=Math.floor(n/65536),B=n-c*65536,n=et+c+65535,c=Math.floor(n/65536),et=n-c*65536,n=N+c+65535,c=Math.floor(n/65536),N=n-c*65536,n=Y+c+65535,c=Math.floor(n/65536),Y=n-c*65536,n=V+c+65535,c=Math.floor(n/65536),V=n-c*65536,n=W+c+65535,c=Math.floor(n/65536),W=n-c*65536,n=$+c+65535,c=Math.floor(n/65536),$=n-c*65536,n=q+c+65535,c=Math.floor(n/65536),q=n-c*65536,n=I+c+65535,c=Math.floor(n/65536),I=n-c*65536,n=H+c+65535,c=Math.floor(n/65536),H=n-c*65536,n=C+c+65535,c=Math.floor(n/65536),C=n-c*65536,h+=c-1+37*(c-1),o[0]=h,o[1]=p,o[2]=b,o[3]=S,o[4]=k,o[5]=B,o[6]=et,o[7]=N,o[8]=Y,o[9]=V,o[10]=W,o[11]=$,o[12]=q,o[13]=I,o[14]=H,o[15]=C}function vt(o,f){D(o,f,f)}function mn(o,f){var s=t(),n;for(n=0;n<16;n++)s[n]=f[n];for(n=253;n>=0;n--)vt(s,s),n!==2&&n!==4&&D(s,s,f);for(n=0;n<16;n++)o[n]=s[n]}function wn(o,f){var s=t(),n;for(n=0;n<16;n++)s[n]=f[n];for(n=250;n>=0;n--)vt(s,s),n!==1&&D(s,s,f);for(n=0;n<16;n++)o[n]=s[n]}function Je(o,f,s){var n=new Uint8Array(32),c=new Float64Array(80),h,p,b=t(),S=t(),k=t(),B=t(),et=t(),N=t();for(p=0;p<31;p++)n[p]=f[p];for(n[31]=f[31]&127|64,n[0]&=248,Sr(c,s),p=0;p<16;p++)S[p]=c[p],B[p]=b[p]=k[p]=0;for(b[0]=B[0]=1,p=254;p>=0;--p)h=n[p>>>3]>>>(p&7)&1,he(b,S,h),he(k,B,h),St(et,b,k),Ot(b,b,k),St(k,S,B),Ot(S,S,B),vt(B,et),vt(N,b),D(b,k,b),D(k,S,et),St(et,b,k),Ot(b,b,k),vt(S,b),Ot(k,B,N),D(b,k,m),St(b,b,B),D(k,k,b),D(b,B,N),D(B,S,c),vt(S,et),he(b,S,h),he(k,B,h);for(p=0;p<16;p++)c[p+16]=b[p],c[p+32]=k[p],c[p+48]=S[p],c[p+64]=B[p];var Y=c.subarray(32),V=c.subarray(16);return mn(Y,Y),D(V,V,Y),pe(o,V),0}function Xe(o,f){return Je(o,f,a)}function gn(o,f){return r(f,32),Xe(o,f)}function Ze(o,f,s){var n=new Uint8Array(32);return Je(n,s,f),Yt(o,i,n,Vt)}var _n=Be,Li=Re;function to(o,f,s,n,c,h){var p=new Uint8Array(32);return Ze(p,c,h),_n(o,f,s,n,p)}function eo(o,f,s,n,c,h){var p=new Uint8Array(32);return Ze(p,c,h),Li(o,f,s,n,p)}var bn=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function vn(o,f,s,n){for(var c=new Int32Array(16),h=new Int32Array(16),p,b,S,k,B,et,N,Y,V,W,$,q,I,H,C,K,R,F,P,U,x,y,E,_,v,A,M=o[0],z=o[1],J=o[2],G=o[3],l=o[4],Z=o[5],rt=o[6],nt=o[7],X=f[0],L=f[1],tt=f[2],lt=f[3],ot=f[4],ft=f[5],ct=f[6],ut=f[7],dt=0;n>=128;){for(P=0;P<16;P++)U=8*P+dt,c[P]=s[U+0]<<24|s[U+1]<<16|s[U+2]<<8|s[U+3],h[P]=s[U+4]<<24|s[U+5]<<16|s[U+6]<<8|s[U+7];for(P=0;P<80;P++)if(p=M,b=z,S=J,k=G,B=l,et=Z,N=rt,Y=nt,V=X,W=L,$=tt,q=lt,I=ot,H=ft,C=ct,K=ut,x=nt,y=ut,E=y&65535,_=y>>>16,v=x&65535,A=x>>>16,x=(l>>>14|ot<<32-14)^(l>>>18|ot<<32-18)^(ot>>>41-32|l<<32-(41-32)),y=(ot>>>14|l<<32-14)^(ot>>>18|l<<32-18)^(l>>>41-32|ot<<32-(41-32)),E+=y&65535,_+=y>>>16,v+=x&65535,A+=x>>>16,x=l&Z^~l&rt,y=ot&ft^~ot&ct,E+=y&65535,_+=y>>>16,v+=x&65535,A+=x>>>16,x=bn[P*2],y=bn[P*2+1],E+=y&65535,_+=y>>>16,v+=x&65535,A+=x>>>16,x=c[P%16],y=h[P%16],E+=y&65535,_+=y>>>16,v+=x&65535,A+=x>>>16,_+=E>>>16,v+=_>>>16,A+=v>>>16,R=v&65535|A<<16,F=E&65535|_<<16,x=R,y=F,E=y&65535,_=y>>>16,v=x&65535,A=x>>>16,x=(M>>>28|X<<32-28)^(X>>>34-32|M<<32-(34-32))^(X>>>39-32|M<<32-(39-32)),y=(X>>>28|M<<32-28)^(M>>>34-32|X<<32-(34-32))^(M>>>39-32|X<<32-(39-32)),E+=y&65535,_+=y>>>16,v+=x&65535,A+=x>>>16,x=M&z^M&J^z&J,y=X&L^X&tt^L&tt,E+=y&65535,_+=y>>>16,v+=x&65535,A+=x>>>16,_+=E>>>16,v+=_>>>16,A+=v>>>16,Y=v&65535|A<<16,K=E&65535|_<<16,x=k,y=q,E=y&65535,_=y>>>16,v=x&65535,A=x>>>16,x=R,y=F,E+=y&65535,_+=y>>>16,v+=x&65535,A+=x>>>16,_+=E>>>16,v+=_>>>16,A+=v>>>16,k=v&65535|A<<16,q=E&65535|_<<16,z=p,J=b,G=S,l=k,Z=B,rt=et,nt=N,M=Y,L=V,tt=W,lt=$,ot=q,ft=I,ct=H,ut=C,X=K,P%16===15)for(U=0;U<16;U++)x=c[U],y=h[U],E=y&65535,_=y>>>16,v=x&65535,A=x>>>16,x=c[(U+9)%16],y=h[(U+9)%16],E+=y&65535,_+=y>>>16,v+=x&65535,A+=x>>>16,R=c[(U+1)%16],F=h[(U+1)%16],x=(R>>>1|F<<32-1)^(R>>>8|F<<32-8)^R>>>7,y=(F>>>1|R<<32-1)^(F>>>8|R<<32-8)^(F>>>7|R<<32-7),E+=y&65535,_+=y>>>16,v+=x&65535,A+=x>>>16,R=c[(U+14)%16],F=h[(U+14)%16],x=(R>>>19|F<<32-19)^(F>>>61-32|R<<32-(61-32))^R>>>6,y=(F>>>19|R<<32-19)^(R>>>61-32|F<<32-(61-32))^(F>>>6|R<<32-6),E+=y&65535,_+=y>>>16,v+=x&65535,A+=x>>>16,_+=E>>>16,v+=_>>>16,A+=v>>>16,c[U]=v&65535|A<<16,h[U]=E&65535|_<<16;x=M,y=X,E=y&65535,_=y>>>16,v=x&65535,A=x>>>16,x=o[0],y=f[0],E+=y&65535,_+=y>>>16,v+=x&65535,A+=x>>>16,_+=E>>>16,v+=_>>>16,A+=v>>>16,o[0]=M=v&65535|A<<16,f[0]=X=E&65535|_<<16,x=z,y=L,E=y&65535,_=y>>>16,v=x&65535,A=x>>>16,x=o[1],y=f[1],E+=y&65535,_+=y>>>16,v+=x&65535,A+=x>>>16,_+=E>>>16,v+=_>>>16,A+=v>>>16,o[1]=z=v&65535|A<<16,f[1]=L=E&65535|_<<16,x=J,y=tt,E=y&65535,_=y>>>16,v=x&65535,A=x>>>16,x=o[2],y=f[2],E+=y&65535,_+=y>>>16,v+=x&65535,A+=x>>>16,_+=E>>>16,v+=_>>>16,A+=v>>>16,o[2]=J=v&65535|A<<16,f[2]=tt=E&65535|_<<16,x=G,y=lt,E=y&65535,_=y>>>16,v=x&65535,A=x>>>16,x=o[3],y=f[3],E+=y&65535,_+=y>>>16,v+=x&65535,A+=x>>>16,_+=E>>>16,v+=_>>>16,A+=v>>>16,o[3]=G=v&65535|A<<16,f[3]=lt=E&65535|_<<16,x=l,y=ot,E=y&65535,_=y>>>16,v=x&65535,A=x>>>16,x=o[4],y=f[4],E+=y&65535,_+=y>>>16,v+=x&65535,A+=x>>>16,_+=E>>>16,v+=_>>>16,A+=v>>>16,o[4]=l=v&65535|A<<16,f[4]=ot=E&65535|_<<16,x=Z,y=ft,E=y&65535,_=y>>>16,v=x&65535,A=x>>>16,x=o[5],y=f[5],E+=y&65535,_+=y>>>16,v+=x&65535,A+=x>>>16,_+=E>>>16,v+=_>>>16,A+=v>>>16,o[5]=Z=v&65535|A<<16,f[5]=ft=E&65535|_<<16,x=rt,y=ct,E=y&65535,_=y>>>16,v=x&65535,A=x>>>16,x=o[6],y=f[6],E+=y&65535,_+=y>>>16,v+=x&65535,A+=x>>>16,_+=E>>>16,v+=_>>>16,A+=v>>>16,o[6]=rt=v&65535|A<<16,f[6]=ct=E&65535|_<<16,x=nt,y=ut,E=y&65535,_=y>>>16,v=x&65535,A=x>>>16,x=o[7],y=f[7],E+=y&65535,_+=y>>>16,v+=x&65535,A+=x>>>16,_+=E>>>16,v+=_>>>16,A+=v>>>16,o[7]=nt=v&65535|A<<16,f[7]=ut=E&65535|_<<16,dt+=128,n-=128}return n}function Lt(o,f,s){var n=new Int32Array(8),c=new Int32Array(8),h=new Uint8Array(256),p,b=s;for(n[0]=1779033703,n[1]=3144134277,n[2]=1013904242,n[3]=2773480762,n[4]=1359893119,n[5]=2600822924,n[6]=528734635,n[7]=1541459225,c[0]=4089235720,c[1]=2227873595,c[2]=4271175723,c[3]=1595750129,c[4]=2917565137,c[5]=725511199,c[6]=4215389547,c[7]=327033209,vn(n,c,f,s),s%=128,p=0;p<s;p++)h[p]=f[b-s+p];for(h[s]=128,s=256-128*(s<112?1:0),h[s-9]=0,at(h,s-8,b/536870912|0,b<<3),vn(n,c,h,s),p=0;p<8;p++)at(o,8*p,n[p],c[p]);return 0}function Qe(o,f){var s=t(),n=t(),c=t(),h=t(),p=t(),b=t(),S=t(),k=t(),B=t();Ot(s,o[1],o[0]),Ot(B,f[1],f[0]),D(s,s,B),St(n,o[0],o[1]),St(B,f[0],f[1]),D(n,n,B),D(c,o[3],f[3]),D(c,c,T),D(h,o[2],f[2]),St(h,h,h),Ot(p,n,s),Ot(b,h,c),St(S,h,c),St(k,n,s),D(o[0],p,b),D(o[1],k,S),D(o[2],S,b),D(o[3],p,k)}function En(o,f,s){var n;for(n=0;n<4;n++)he(o[n],f[n],s)}function Or(o,f){var s=t(),n=t(),c=t();mn(c,f[2]),D(s,f[0],c),D(n,f[1],c),pe(o,n),o[31]^=yn(s)<<7}function Ur(o,f,s){var n,c;for(qt(o[0],u),qt(o[1],d),qt(o[2],d),qt(o[3],u),c=255;c>=0;--c)n=s[c/8|0]>>(c&7)&1,En(o,f,n),Qe(f,o),Qe(o,o),En(o,f,n)}function De(o,f){var s=[t(),t(),t(),t()];qt(s[0],j),qt(s[1],O),qt(s[2],d),D(s[3],j,O),Ur(o,s,f)}function Br(o,f,s){var n=new Uint8Array(64),c=[t(),t(),t(),t()],h;for(s||r(f,32),Lt(n,f,32),n[0]&=248,n[31]&=127,n[31]|=64,De(c,n),Or(o,c),h=0;h<32;h++)f[h+32]=o[h];return 0}var Le=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function Rr(o,f){var s,n,c,h;for(n=63;n>=32;--n){for(s=0,c=n-32,h=n-12;c<h;++c)f[c]+=s-16*f[n]*Le[c-(n-32)],s=Math.floor((f[c]+128)/256),f[c]-=s*256;f[c]+=s,f[n]=0}for(s=0,c=0;c<32;c++)f[c]+=s-(f[31]>>4)*Le[c],s=f[c]>>8,f[c]&=255;for(c=0;c<32;c++)f[c]-=s*Le[c];for(n=0;n<32;n++)f[n+1]+=f[n]>>8,o[n]=f[n]&255}function Nr(o){var f=new Float64Array(64),s;for(s=0;s<64;s++)f[s]=o[s];for(s=0;s<64;s++)o[s]=0;Rr(o,f)}function An(o,f,s,n){var c=new Uint8Array(64),h=new Uint8Array(64),p=new Uint8Array(64),b,S,k=new Float64Array(64),B=[t(),t(),t(),t()];Lt(c,n,32),c[0]&=248,c[31]&=127,c[31]|=64;var et=s+64;for(b=0;b<s;b++)o[64+b]=f[b];for(b=0;b<32;b++)o[32+b]=c[32+b];for(Lt(p,o.subarray(32),s+32),Nr(p),De(B,p),Or(o,B),b=32;b<64;b++)o[b]=n[b];for(Lt(h,o,s+64),Nr(h),b=0;b<64;b++)k[b]=0;for(b=0;b<32;b++)k[b]=p[b];for(b=0;b<32;b++)for(S=0;S<32;S++)k[b+S]+=h[b]*c[S];return Rr(o.subarray(32),k),et}function ro(o,f){var s=t(),n=t(),c=t(),h=t(),p=t(),b=t(),S=t();return qt(o[2],d),Sr(o[1],f),vt(c,o[1]),D(h,c,w),Ot(c,c,o[2]),St(h,o[2],h),vt(p,h),vt(b,p),D(S,b,p),D(s,S,c),D(s,s,h),wn(s,s),D(s,s,c),D(s,s,h),D(s,s,h),D(o[0],s,h),vt(n,o[0]),D(n,n,h),xn(n,c)&&D(o[0],o[0],Q),vt(n,o[0]),D(n,n,h),xn(n,c)?-1:(yn(o[0])===f[31]>>7&&Ot(o[0],u,o[0]),D(o[3],o[0],o[1]),0)}function Cr(o,f,s,n){var c,h=new Uint8Array(32),p=new Uint8Array(64),b=[t(),t(),t(),t()],S=[t(),t(),t(),t()];if(s<64||ro(S,n))return-1;for(c=0;c<s;c++)o[c]=f[c];for(c=0;c<32;c++)o[c+32]=n[c];if(Lt(p,o,s),Nr(p),Ur(b,S,p),De(S,f.subarray(32)),Qe(b,S),Or(h,b),s-=64,Mt(f,0,h,0)){for(c=0;c<s;c++)o[c]=0;return-1}for(c=0;c<s;c++)o[c]=f[c+64];return s}var Fr=32,tr=24,Ne=32,xe=16,Ce=32,er=32,Fe=32,Pe=32,Pr=32,Tn=tr,no=Ne,io=xe,Ht=64,te=32,ye=64,kr=32,jr=64;e.lowlevel={crypto_core_hsalsa20:Yt,crypto_stream_xor:Qt,crypto_stream:Oe,crypto_stream_salsa20_xor:We,crypto_stream_salsa20:ze,crypto_onetimeauth:Ue,crypto_onetimeauth_verify:Ge,crypto_verify_16:bt,crypto_verify_32:Mt,crypto_secretbox:Be,crypto_secretbox_open:Re,crypto_scalarmult:Je,crypto_scalarmult_base:Xe,crypto_box_beforenm:Ze,crypto_box_afternm:_n,crypto_box:to,crypto_box_open:eo,crypto_box_keypair:gn,crypto_hash:Lt,crypto_sign:An,crypto_sign_keypair:Br,crypto_sign_open:Cr,crypto_secretbox_KEYBYTES:Fr,crypto_secretbox_NONCEBYTES:tr,crypto_secretbox_ZEROBYTES:Ne,crypto_secretbox_BOXZEROBYTES:xe,crypto_scalarmult_BYTES:Ce,crypto_scalarmult_SCALARBYTES:er,crypto_box_PUBLICKEYBYTES:Fe,crypto_box_SECRETKEYBYTES:Pe,crypto_box_BEFORENMBYTES:Pr,crypto_box_NONCEBYTES:Tn,crypto_box_ZEROBYTES:no,crypto_box_BOXZEROBYTES:io,crypto_sign_BYTES:Ht,crypto_sign_PUBLICKEYBYTES:te,crypto_sign_SECRETKEYBYTES:ye,crypto_sign_SEEDBYTES:kr,crypto_hash_BYTES:jr,gf:t,D:w,L:Le,pack25519:pe,unpack25519:Sr,M:D,A:St,S:vt,Z:Ot,pow2523:wn,add:Qe,set25519:qt,modL:Rr,scalarmult:Ur,scalarbase:De};function Sn(o,f){if(o.length!==Fr)throw new Error("bad key size");if(f.length!==tr)throw new Error("bad nonce size")}function oo(o,f){if(o.length!==Fe)throw new Error("bad public key size");if(f.length!==Pe)throw new Error("bad secret key size")}function _t(){for(var o=0;o<arguments.length;o++)if(!(arguments[o]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function On(o){for(var f=0;f<o.length;f++)o[f]=0}e.randomBytes=function(o){var f=new Uint8Array(o);return r(f,o),f},e.secretbox=function(o,f,s){_t(o,f,s),Sn(s,f);for(var n=new Uint8Array(Ne+o.length),c=new Uint8Array(n.length),h=0;h<o.length;h++)n[h+Ne]=o[h];return Be(c,n,n.length,f,s),c.subarray(xe)},e.secretbox.open=function(o,f,s){_t(o,f,s),Sn(s,f);for(var n=new Uint8Array(xe+o.length),c=new Uint8Array(n.length),h=0;h<o.length;h++)n[h+xe]=o[h];return n.length<32||Re(c,n,n.length,f,s)!==0?null:c.subarray(Ne)},e.secretbox.keyLength=Fr,e.secretbox.nonceLength=tr,e.secretbox.overheadLength=xe,e.scalarMult=function(o,f){if(_t(o,f),o.length!==er)throw new Error("bad n size");if(f.length!==Ce)throw new Error("bad p size");var s=new Uint8Array(Ce);return Je(s,o,f),s},e.scalarMult.base=function(o){if(_t(o),o.length!==er)throw new Error("bad n size");var f=new Uint8Array(Ce);return Xe(f,o),f},e.scalarMult.scalarLength=er,e.scalarMult.groupElementLength=Ce,e.box=function(o,f,s,n){var c=e.box.before(s,n);return e.secretbox(o,f,c)},e.box.before=function(o,f){_t(o,f),oo(o,f);var s=new Uint8Array(Pr);return Ze(s,o,f),s},e.box.after=e.secretbox,e.box.open=function(o,f,s,n){var c=e.box.before(s,n);return e.secretbox.open(o,f,c)},e.box.open.after=e.secretbox.open,e.box.keyPair=function(){var o=new Uint8Array(Fe),f=new Uint8Array(Pe);return gn(o,f),{publicKey:o,secretKey:f}},e.box.keyPair.fromSecretKey=function(o){if(_t(o),o.length!==Pe)throw new Error("bad secret key size");var f=new Uint8Array(Fe);return Xe(f,o),{publicKey:f,secretKey:new Uint8Array(o)}},e.box.publicKeyLength=Fe,e.box.secretKeyLength=Pe,e.box.sharedKeyLength=Pr,e.box.nonceLength=Tn,e.box.overheadLength=e.secretbox.overheadLength,e.sign=function(o,f){if(_t(o,f),f.length!==ye)throw new Error("bad secret key size");var s=new Uint8Array(Ht+o.length);return An(s,o,o.length,f),s},e.sign.open=function(o,f){if(_t(o,f),f.length!==te)throw new Error("bad public key size");var s=new Uint8Array(o.length),n=Cr(s,o,o.length,f);if(n<0)return null;for(var c=new Uint8Array(n),h=0;h<c.length;h++)c[h]=s[h];return c},e.sign.detached=function(o,f){for(var s=e.sign(o,f),n=new Uint8Array(Ht),c=0;c<n.length;c++)n[c]=s[c];return n},e.sign.detached.verify=function(o,f,s){if(_t(o,f,s),f.length!==Ht)throw new Error("bad signature size");if(s.length!==te)throw new Error("bad public key size");var n=new Uint8Array(Ht+o.length),c=new Uint8Array(Ht+o.length),h;for(h=0;h<Ht;h++)n[h]=f[h];for(h=0;h<o.length;h++)n[h+Ht]=o[h];return Cr(c,n,n.length,s)>=0},e.sign.keyPair=function(){var o=new Uint8Array(te),f=new Uint8Array(ye);return Br(o,f),{publicKey:o,secretKey:f}},e.sign.keyPair.fromSecretKey=function(o){if(_t(o),o.length!==ye)throw new Error("bad secret key size");for(var f=new Uint8Array(te),s=0;s<f.length;s++)f[s]=o[32+s];return{publicKey:f,secretKey:new Uint8Array(o)}},e.sign.keyPair.fromSeed=function(o){if(_t(o),o.length!==kr)throw new Error("bad seed size");for(var f=new Uint8Array(te),s=new Uint8Array(ye),n=0;n<32;n++)s[n]=o[n];return Br(f,s,!0),{publicKey:f,secretKey:s}},e.sign.publicKeyLength=te,e.sign.secretKeyLength=ye,e.sign.seedLength=kr,e.sign.signatureLength=Ht,e.hash=function(o){_t(o);var f=new Uint8Array(jr);return Lt(f,o,o.length),f},e.hash.hashLength=jr,e.verify=function(o,f){return _t(o,f),o.length===0||f.length===0||o.length!==f.length?!1:it(o,0,f,0,o.length)===0},e.setPRNG=function(o){r=o},function(){var o=typeof self<"u"?self.crypto||self.msCrypto:null;if(o&&o.getRandomValues){var f=65536;e.setPRNG(function(s,n){var c,h=new Uint8Array(n);for(c=0;c<n;c+=f)o.getRandomValues(h.subarray(c,c+Math.min(n-c,f)));for(c=0;c<n;c++)s[c]=h[c];On(h)})}else typeof Un<"u"&&(o=mi(),o&&o.randomBytes&&e.setPRNG(function(s,n){var c,h=o.randomBytes(n);for(c=0;c<n;c++)s[c]=h[c];On(h)}))}()})(typeof xr<"u"&&xr.exports?xr.exports:self.nacl=self.nacl||{})});var we=class{callbacks=[];populate(t){this.callbacks.forEach(({callback:r})=>r(t))}subscribe(t){let r=Symbol();return this.callbacks.push({id:r,callback:t}),()=>this.callbacks=this.callbacks.filter(({id:i})=>i!==r)}};var ge=class extends we{authUser=null;constructor(){super()}static getInstance(){return ge.instance||(ge.instance=new ge),ge.instance}set(t){this.authUser=t,this.populate(t)}get(){return this.authUser}subscribe(t){let r=super.subscribe(t);return t(this.authUser),r}isLoggedIn(){return!this.authUser?.data?.principal.isAnonymous()}reset(){this.authUser=null,this.populate(this.authUser)}},Nt=ge;nr(Nt,"instance");var kn=({message:e,detail:t})=>{let r=new CustomEvent(e,{detail:t,bubbles:!0});document.dispatchEvent(r)};var $t=e=>e==null;var jn=BigInt(144e11),Kn=576,Mn=576;var _e=class extends we{env;constructor(){super()}static getInstance(){return _e.instance||(_e.instance=new _e),_e.instance}set(t){this.env=t,this.populate(t)}get(){return this.env}localIdentity(){return this.get()?.localIdentityCanisterId!==void 0}subscribe(t){let r=super.subscribe(t);return t(this.env),r}},mt=_e;nr(mt,"instance");var hi=me(ti());var cr;(function(e){e[e.SysFatal=1]="SysFatal",e[e.SysTransient=2]="SysTransient",e[e.DestinationInvalid=3]="DestinationInvalid",e[e.CanisterReject=4]="CanisterReject",e[e.CanisterError=5]="CanisterError"})(cr||(cr={}));var qo=function(e,t){var r={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(r[i]=e[i]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,i=Object.getOwnPropertySymbols(e);a<i.length;a++)t.indexOf(i[a])<0&&Object.prototype.propertyIsEnumerable.call(e,i[a])&&(r[i[a]]=e[i[a]]);return r},Ho=new TextEncoder().encode(`
|
|
2
|
-
ic-request`),
|
|
1
|
+
import{a as Bn,b as co,c as nr,d as Nn,e as me,f as uo,g as ir,h as lo,i as ot,j as ke,k as Pn,l as je,m as ho,n as Cn,o as Gt,p as Fn,q as ne,r as kn,s as or,t as ar,u as jn}from"./chunk-A53P2AD6.js";var Wn=nr(cr=>{"use strict";cr.byteLength=xo;cr.toByteArray=mo;cr.fromByteArray=_o;var kt=[],At=[],po=typeof Uint8Array<"u"?Uint8Array:Array,Vr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(ie=0,$n=Vr.length;ie<$n;++ie)kt[ie]=Vr[ie],At[Vr.charCodeAt(ie)]=ie;var ie,$n;At["-".charCodeAt(0)]=62;At["_".charCodeAt(0)]=63;function In(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");r===-1&&(r=t);var i=r===t?0:4-r%4;return[r,i]}function xo(e){var t=In(e),r=t[0],i=t[1];return(r+i)*3/4-i}function yo(e,t,r){return(t+r)*3/4-r}function mo(e){var t,r=In(e),i=r[0],a=r[1],u=new po(yo(e,i,a)),d=0,m=a>0?i-4:i,w;for(w=0;w<m;w+=4)t=At[e.charCodeAt(w)]<<18|At[e.charCodeAt(w+1)]<<12|At[e.charCodeAt(w+2)]<<6|At[e.charCodeAt(w+3)],u[d++]=t>>16&255,u[d++]=t>>8&255,u[d++]=t&255;return a===2&&(t=At[e.charCodeAt(w)]<<2|At[e.charCodeAt(w+1)]>>4,u[d++]=t&255),a===1&&(t=At[e.charCodeAt(w)]<<10|At[e.charCodeAt(w+1)]<<4|At[e.charCodeAt(w+2)]>>2,u[d++]=t>>8&255,u[d++]=t&255),u}function wo(e){return kt[e>>18&63]+kt[e>>12&63]+kt[e>>6&63]+kt[e&63]}function go(e,t,r){for(var i,a=[],u=t;u<r;u+=3)i=(e[u]<<16&16711680)+(e[u+1]<<8&65280)+(e[u+2]&255),a.push(wo(i));return a.join("")}function _o(e){for(var t,r=e.length,i=r%3,a=[],u=16383,d=0,m=r-i;d<m;d+=u)a.push(go(e,d,d+u>m?m:d+u));return i===1?(t=e[r-1],a.push(kt[t>>2]+kt[t<<4&63]+"==")):i===2&&(t=(e[r-2]<<8)+e[r-1],a.push(kt[t>>10]+kt[t>>4&63]+kt[t<<2&63]+"=")),a.join("")}});var ii=nr(ve=>{"use strict";var qr=Wn(),be=lo(),zn=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;ve.Buffer=g;ve.SlowBuffer=So;ve.INSPECT_MAX_BYTES=50;var ur=2147483647;ve.kMaxLength=ur;g.TYPED_ARRAY_SUPPORT=bo();!g.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function bo(){try{var e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),e.foo()===42}catch{return!1}}Object.defineProperty(g.prototype,"parent",{enumerable:!0,get:function(){if(g.isBuffer(this))return this.buffer}});Object.defineProperty(g.prototype,"offset",{enumerable:!0,get:function(){if(g.isBuffer(this))return this.byteOffset}});function Jt(e){if(e>ur)throw new RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return Object.setPrototypeOf(t,g.prototype),t}function g(e,t,r){if(typeof e=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return Wr(e)}return Xn(e,t,r)}g.poolSize=8192;function Xn(e,t,r){if(typeof e=="string")return Eo(e,t);if(ArrayBuffer.isView(e))return Ao(e);if(e==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(jt(e,ArrayBuffer)||e&&jt(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(jt(e,SharedArrayBuffer)||e&&jt(e.buffer,SharedArrayBuffer)))return $r(e,t,r);if(typeof e=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');var i=e.valueOf&&e.valueOf();if(i!=null&&i!==e)return g.from(i,t,r);var a=To(e);if(a)return a;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]=="function")return g.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}g.from=function(e,t,r){return Xn(e,t,r)};Object.setPrototypeOf(g.prototype,Uint8Array.prototype);Object.setPrototypeOf(g,Uint8Array);function Zn(e){if(typeof e!="number")throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function vo(e,t,r){return Zn(e),e<=0?Jt(e):t!==void 0?typeof r=="string"?Jt(e).fill(t,r):Jt(e).fill(t):Jt(e)}g.alloc=function(e,t,r){return vo(e,t,r)};function Wr(e){return Zn(e),Jt(e<0?0:zr(e)|0)}g.allocUnsafe=function(e){return Wr(e)};g.allocUnsafeSlow=function(e){return Wr(e)};function Eo(e,t){if((typeof t!="string"||t==="")&&(t="utf8"),!g.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var r=Qn(e,t)|0,i=Jt(r),a=i.write(e,t);return a!==r&&(i=i.slice(0,a)),i}function Hr(e){for(var t=e.length<0?0:zr(e.length)|0,r=Jt(t),i=0;i<t;i+=1)r[i]=e[i]&255;return r}function Ao(e){if(jt(e,Uint8Array)){var t=new Uint8Array(e);return $r(t.buffer,t.byteOffset,t.byteLength)}return Hr(e)}function $r(e,t,r){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw new RangeError('"length" is outside of buffer bounds');var i;return t===void 0&&r===void 0?i=new Uint8Array(e):r===void 0?i=new Uint8Array(e,t):i=new Uint8Array(e,t,r),Object.setPrototypeOf(i,g.prototype),i}function To(e){if(g.isBuffer(e)){var t=zr(e.length)|0,r=Jt(t);return r.length===0||e.copy(r,0,0,t),r}if(e.length!==void 0)return typeof e.length!="number"||Gr(e.length)?Jt(0):Hr(e);if(e.type==="Buffer"&&Array.isArray(e.data))return Hr(e.data)}function zr(e){if(e>=ur)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+ur.toString(16)+" bytes");return e|0}function So(e){return+e!=e&&(e=0),g.alloc(+e)}g.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==g.prototype};g.compare=function(t,r){if(jt(t,Uint8Array)&&(t=g.from(t,t.offset,t.byteLength)),jt(r,Uint8Array)&&(r=g.from(r,r.offset,r.byteLength)),!g.isBuffer(t)||!g.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===r)return 0;for(var i=t.length,a=r.length,u=0,d=Math.min(i,a);u<d;++u)if(t[u]!==r[u]){i=t[u],a=r[u];break}return i<a?-1:a<i?1:0};g.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};g.concat=function(t,r){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return g.alloc(0);var i;if(r===void 0)for(r=0,i=0;i<t.length;++i)r+=t[i].length;var a=g.allocUnsafe(r),u=0;for(i=0;i<t.length;++i){var d=t[i];if(jt(d,Uint8Array))u+d.length>a.length?g.from(d).copy(a,u):Uint8Array.prototype.set.call(a,d,u);else if(g.isBuffer(d))d.copy(a,u);else throw new TypeError('"list" argument must be an Array of Buffers');u+=d.length}return a};function Qn(e,t){if(g.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||jt(e,ArrayBuffer))return e.byteLength;if(typeof e!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var r=e.length,i=arguments.length>2&&arguments[2]===!0;if(!i&&r===0)return 0;for(var a=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return Ir(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return ni(e).length;default:if(a)return i?-1:Ir(e).length;t=(""+t).toLowerCase(),a=!0}}g.byteLength=Qn;function Oo(e,t,r){var i=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,t>>>=0,r<=t))return"";for(e||(e="utf8");;)switch(e){case"hex":return Ko(this,t,r);case"utf8":case"utf-8":return Ln(this,t,r);case"ascii":return ko(this,t,r);case"latin1":case"binary":return jo(this,t,r);case"base64":return Co(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Mo(this,t,r);default:if(i)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),i=!0}}g.prototype._isBuffer=!0;function oe(e,t,r){var i=e[t];e[t]=e[r],e[r]=i}g.prototype.swap16=function(){var t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var r=0;r<t;r+=2)oe(this,r,r+1);return this};g.prototype.swap32=function(){var t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var r=0;r<t;r+=4)oe(this,r,r+3),oe(this,r+1,r+2);return this};g.prototype.swap64=function(){var t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var r=0;r<t;r+=8)oe(this,r,r+7),oe(this,r+1,r+6),oe(this,r+2,r+5),oe(this,r+3,r+4);return this};g.prototype.toString=function(){var t=this.length;return t===0?"":arguments.length===0?Ln(this,0,t):Oo.apply(this,arguments)};g.prototype.toLocaleString=g.prototype.toString;g.prototype.equals=function(t){if(!g.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:g.compare(this,t)===0};g.prototype.inspect=function(){var t="",r=ve.INSPECT_MAX_BYTES;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"};zn&&(g.prototype[zn]=g.prototype.inspect);g.prototype.compare=function(t,r,i,a,u){if(jt(t,Uint8Array)&&(t=g.from(t,t.offset,t.byteLength)),!g.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(r===void 0&&(r=0),i===void 0&&(i=t?t.length:0),a===void 0&&(a=0),u===void 0&&(u=this.length),r<0||i>t.length||a<0||u>this.length)throw new RangeError("out of range index");if(a>=u&&r>=i)return 0;if(a>=u)return-1;if(r>=i)return 1;if(r>>>=0,i>>>=0,a>>>=0,u>>>=0,this===t)return 0;for(var d=u-a,m=i-r,w=Math.min(d,m),A=this.slice(a,u),C=t.slice(r,i),O=0;O<w;++O)if(A[O]!==C[O]){d=A[O],m=C[O];break}return d<m?-1:m<d?1:0};function Dn(e,t,r,i,a){if(e.length===0)return-1;if(typeof r=="string"?(i=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,Gr(r)&&(r=a?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(a)return-1;r=e.length-1}else if(r<0)if(a)r=0;else return-1;if(typeof t=="string"&&(t=g.from(t,i)),g.isBuffer(t))return t.length===0?-1:Gn(e,t,r,i,a);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?a?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):Gn(e,[t],r,i,a);throw new TypeError("val must be string, number or Buffer")}function Gn(e,t,r,i,a){var u=1,d=e.length,m=t.length;if(i!==void 0&&(i=String(i).toLowerCase(),i==="ucs2"||i==="ucs-2"||i==="utf16le"||i==="utf-16le")){if(e.length<2||t.length<2)return-1;u=2,d/=2,m/=2,r/=2}function w(st,it){return u===1?st[it]:st.readUInt16BE(it*u)}var A;if(a){var C=-1;for(A=r;A<d;A++)if(w(e,A)===w(t,C===-1?0:A-C)){if(C===-1&&(C=A),A-C+1===m)return C*u}else C!==-1&&(A-=A-C),C=-1}else for(r+m>d&&(r=d-m),A=r;A>=0;A--){for(var O=!0,Q=0;Q<m;Q++)if(w(e,A+Q)!==w(t,Q)){O=!1;break}if(O)return A}return-1}g.prototype.includes=function(t,r,i){return this.indexOf(t,r,i)!==-1};g.prototype.indexOf=function(t,r,i){return Dn(this,t,r,i,!0)};g.prototype.lastIndexOf=function(t,r,i){return Dn(this,t,r,i,!1)};function Uo(e,t,r,i){r=Number(r)||0;var a=e.length-r;i?(i=Number(i),i>a&&(i=a)):i=a;var u=t.length;i>u/2&&(i=u/2);for(var d=0;d<i;++d){var m=parseInt(t.substr(d*2,2),16);if(Gr(m))return d;e[r+d]=m}return d}function Ro(e,t,r,i){return lr(Ir(t,e.length-r),e,r,i)}function Bo(e,t,r,i){return lr(qo(t),e,r,i)}function No(e,t,r,i){return lr(ni(t),e,r,i)}function Po(e,t,r,i){return lr(Ho(t,e.length-r),e,r,i)}g.prototype.write=function(t,r,i,a){if(r===void 0)a="utf8",i=this.length,r=0;else if(i===void 0&&typeof r=="string")a=r,i=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(i)?(i=i>>>0,a===void 0&&(a="utf8")):(a=i,i=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var u=this.length-r;if((i===void 0||i>u)&&(i=u),t.length>0&&(i<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");a||(a="utf8");for(var d=!1;;)switch(a){case"hex":return Uo(this,t,r,i);case"utf8":case"utf-8":return Ro(this,t,r,i);case"ascii":case"latin1":case"binary":return Bo(this,t,r,i);case"base64":return No(this,t,r,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Po(this,t,r,i);default:if(d)throw new TypeError("Unknown encoding: "+a);a=(""+a).toLowerCase(),d=!0}};g.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Co(e,t,r){return t===0&&r===e.length?qr.fromByteArray(e):qr.fromByteArray(e.slice(t,r))}function Ln(e,t,r){r=Math.min(e.length,r);for(var i=[],a=t;a<r;){var u=e[a],d=null,m=u>239?4:u>223?3:u>191?2:1;if(a+m<=r){var w,A,C,O;switch(m){case 1:u<128&&(d=u);break;case 2:w=e[a+1],(w&192)===128&&(O=(u&31)<<6|w&63,O>127&&(d=O));break;case 3:w=e[a+1],A=e[a+2],(w&192)===128&&(A&192)===128&&(O=(u&15)<<12|(w&63)<<6|A&63,O>2047&&(O<55296||O>57343)&&(d=O));break;case 4:w=e[a+1],A=e[a+2],C=e[a+3],(w&192)===128&&(A&192)===128&&(C&192)===128&&(O=(u&15)<<18|(w&63)<<12|(A&63)<<6|C&63,O>65535&&O<1114112&&(d=O))}}d===null?(d=65533,m=1):d>65535&&(d-=65536,i.push(d>>>10&1023|55296),d=56320|d&1023),i.push(d),a+=m}return Fo(i)}var Jn=4096;function Fo(e){var t=e.length;if(t<=Jn)return String.fromCharCode.apply(String,e);for(var r="",i=0;i<t;)r+=String.fromCharCode.apply(String,e.slice(i,i+=Jn));return r}function ko(e,t,r){var i="";r=Math.min(e.length,r);for(var a=t;a<r;++a)i+=String.fromCharCode(e[a]&127);return i}function jo(e,t,r){var i="";r=Math.min(e.length,r);for(var a=t;a<r;++a)i+=String.fromCharCode(e[a]);return i}function Ko(e,t,r){var i=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>i)&&(r=i);for(var a="",u=t;u<r;++u)a+=$o[e[u]];return a}function Mo(e,t,r){for(var i=e.slice(t,r),a="",u=0;u<i.length-1;u+=2)a+=String.fromCharCode(i[u]+i[u+1]*256);return a}g.prototype.slice=function(t,r){var i=this.length;t=~~t,r=r===void 0?i:~~r,t<0?(t+=i,t<0&&(t=0)):t>i&&(t=i),r<0?(r+=i,r<0&&(r=0)):r>i&&(r=i),r<t&&(r=t);var a=this.subarray(t,r);return Object.setPrototypeOf(a,g.prototype),a};function ht(e,t,r){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}g.prototype.readUintLE=g.prototype.readUIntLE=function(t,r,i){t=t>>>0,r=r>>>0,i||ht(t,r,this.length);for(var a=this[t],u=1,d=0;++d<r&&(u*=256);)a+=this[t+d]*u;return a};g.prototype.readUintBE=g.prototype.readUIntBE=function(t,r,i){t=t>>>0,r=r>>>0,i||ht(t,r,this.length);for(var a=this[t+--r],u=1;r>0&&(u*=256);)a+=this[t+--r]*u;return a};g.prototype.readUint8=g.prototype.readUInt8=function(t,r){return t=t>>>0,r||ht(t,1,this.length),this[t]};g.prototype.readUint16LE=g.prototype.readUInt16LE=function(t,r){return t=t>>>0,r||ht(t,2,this.length),this[t]|this[t+1]<<8};g.prototype.readUint16BE=g.prototype.readUInt16BE=function(t,r){return t=t>>>0,r||ht(t,2,this.length),this[t]<<8|this[t+1]};g.prototype.readUint32LE=g.prototype.readUInt32LE=function(t,r){return t=t>>>0,r||ht(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};g.prototype.readUint32BE=g.prototype.readUInt32BE=function(t,r){return t=t>>>0,r||ht(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};g.prototype.readIntLE=function(t,r,i){t=t>>>0,r=r>>>0,i||ht(t,r,this.length);for(var a=this[t],u=1,d=0;++d<r&&(u*=256);)a+=this[t+d]*u;return u*=128,a>=u&&(a-=Math.pow(2,8*r)),a};g.prototype.readIntBE=function(t,r,i){t=t>>>0,r=r>>>0,i||ht(t,r,this.length);for(var a=r,u=1,d=this[t+--a];a>0&&(u*=256);)d+=this[t+--a]*u;return u*=128,d>=u&&(d-=Math.pow(2,8*r)),d};g.prototype.readInt8=function(t,r){return t=t>>>0,r||ht(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};g.prototype.readInt16LE=function(t,r){t=t>>>0,r||ht(t,2,this.length);var i=this[t]|this[t+1]<<8;return i&32768?i|4294901760:i};g.prototype.readInt16BE=function(t,r){t=t>>>0,r||ht(t,2,this.length);var i=this[t+1]|this[t]<<8;return i&32768?i|4294901760:i};g.prototype.readInt32LE=function(t,r){return t=t>>>0,r||ht(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};g.prototype.readInt32BE=function(t,r){return t=t>>>0,r||ht(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};g.prototype.readFloatLE=function(t,r){return t=t>>>0,r||ht(t,4,this.length),be.read(this,t,!0,23,4)};g.prototype.readFloatBE=function(t,r){return t=t>>>0,r||ht(t,4,this.length),be.read(this,t,!1,23,4)};g.prototype.readDoubleLE=function(t,r){return t=t>>>0,r||ht(t,8,this.length),be.read(this,t,!0,52,8)};g.prototype.readDoubleBE=function(t,r){return t=t>>>0,r||ht(t,8,this.length),be.read(this,t,!1,52,8)};function _t(e,t,r,i,a,u){if(!g.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>a||t<u)throw new RangeError('"value" argument is out of bounds');if(r+i>e.length)throw new RangeError("Index out of range")}g.prototype.writeUintLE=g.prototype.writeUIntLE=function(t,r,i,a){if(t=+t,r=r>>>0,i=i>>>0,!a){var u=Math.pow(2,8*i)-1;_t(this,t,r,i,u,0)}var d=1,m=0;for(this[r]=t&255;++m<i&&(d*=256);)this[r+m]=t/d&255;return r+i};g.prototype.writeUintBE=g.prototype.writeUIntBE=function(t,r,i,a){if(t=+t,r=r>>>0,i=i>>>0,!a){var u=Math.pow(2,8*i)-1;_t(this,t,r,i,u,0)}var d=i-1,m=1;for(this[r+d]=t&255;--d>=0&&(m*=256);)this[r+d]=t/m&255;return r+i};g.prototype.writeUint8=g.prototype.writeUInt8=function(t,r,i){return t=+t,r=r>>>0,i||_t(this,t,r,1,255,0),this[r]=t&255,r+1};g.prototype.writeUint16LE=g.prototype.writeUInt16LE=function(t,r,i){return t=+t,r=r>>>0,i||_t(this,t,r,2,65535,0),this[r]=t&255,this[r+1]=t>>>8,r+2};g.prototype.writeUint16BE=g.prototype.writeUInt16BE=function(t,r,i){return t=+t,r=r>>>0,i||_t(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=t&255,r+2};g.prototype.writeUint32LE=g.prototype.writeUInt32LE=function(t,r,i){return t=+t,r=r>>>0,i||_t(this,t,r,4,4294967295,0),this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=t&255,r+4};g.prototype.writeUint32BE=g.prototype.writeUInt32BE=function(t,r,i){return t=+t,r=r>>>0,i||_t(this,t,r,4,4294967295,0),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255,r+4};g.prototype.writeIntLE=function(t,r,i,a){if(t=+t,r=r>>>0,!a){var u=Math.pow(2,8*i-1);_t(this,t,r,i,u-1,-u)}var d=0,m=1,w=0;for(this[r]=t&255;++d<i&&(m*=256);)t<0&&w===0&&this[r+d-1]!==0&&(w=1),this[r+d]=(t/m>>0)-w&255;return r+i};g.prototype.writeIntBE=function(t,r,i,a){if(t=+t,r=r>>>0,!a){var u=Math.pow(2,8*i-1);_t(this,t,r,i,u-1,-u)}var d=i-1,m=1,w=0;for(this[r+d]=t&255;--d>=0&&(m*=256);)t<0&&w===0&&this[r+d+1]!==0&&(w=1),this[r+d]=(t/m>>0)-w&255;return r+i};g.prototype.writeInt8=function(t,r,i){return t=+t,r=r>>>0,i||_t(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=t&255,r+1};g.prototype.writeInt16LE=function(t,r,i){return t=+t,r=r>>>0,i||_t(this,t,r,2,32767,-32768),this[r]=t&255,this[r+1]=t>>>8,r+2};g.prototype.writeInt16BE=function(t,r,i){return t=+t,r=r>>>0,i||_t(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=t&255,r+2};g.prototype.writeInt32LE=function(t,r,i){return t=+t,r=r>>>0,i||_t(this,t,r,4,2147483647,-2147483648),this[r]=t&255,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24,r+4};g.prototype.writeInt32BE=function(t,r,i){return t=+t,r=r>>>0,i||_t(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255,r+4};function ti(e,t,r,i,a,u){if(r+i>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function ei(e,t,r,i,a){return t=+t,r=r>>>0,a||ti(e,t,r,4,34028234663852886e22,-34028234663852886e22),be.write(e,t,r,i,23,4),r+4}g.prototype.writeFloatLE=function(t,r,i){return ei(this,t,r,!0,i)};g.prototype.writeFloatBE=function(t,r,i){return ei(this,t,r,!1,i)};function ri(e,t,r,i,a){return t=+t,r=r>>>0,a||ti(e,t,r,8,17976931348623157e292,-17976931348623157e292),be.write(e,t,r,i,52,8),r+8}g.prototype.writeDoubleLE=function(t,r,i){return ri(this,t,r,!0,i)};g.prototype.writeDoubleBE=function(t,r,i){return ri(this,t,r,!1,i)};g.prototype.copy=function(t,r,i,a){if(!g.isBuffer(t))throw new TypeError("argument should be a Buffer");if(i||(i=0),!a&&a!==0&&(a=this.length),r>=t.length&&(r=t.length),r||(r=0),a>0&&a<i&&(a=i),a===i||t.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(i<0||i>=this.length)throw new RangeError("Index out of range");if(a<0)throw new RangeError("sourceEnd out of bounds");a>this.length&&(a=this.length),t.length-r<a-i&&(a=t.length-r+i);var u=a-i;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,i,a):Uint8Array.prototype.set.call(t,this.subarray(i,a),r),u};g.prototype.fill=function(t,r,i,a){if(typeof t=="string"){if(typeof r=="string"?(a=r,r=0,i=this.length):typeof i=="string"&&(a=i,i=this.length),a!==void 0&&typeof a!="string")throw new TypeError("encoding must be a string");if(typeof a=="string"&&!g.isEncoding(a))throw new TypeError("Unknown encoding: "+a);if(t.length===1){var u=t.charCodeAt(0);(a==="utf8"&&u<128||a==="latin1")&&(t=u)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(r<0||this.length<r||this.length<i)throw new RangeError("Out of range index");if(i<=r)return this;r=r>>>0,i=i===void 0?this.length:i>>>0,t||(t=0);var d;if(typeof t=="number")for(d=r;d<i;++d)this[d]=t;else{var m=g.isBuffer(t)?t:g.from(t,a),w=m.length;if(w===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(d=0;d<i-r;++d)this[d+r]=m[d%w]}return this};var Yo=/[^+/0-9A-Za-z-_]/g;function Vo(e){if(e=e.split("=")[0],e=e.trim().replace(Yo,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function Ir(e,t){t=t||1/0;for(var r,i=e.length,a=null,u=[],d=0;d<i;++d){if(r=e.charCodeAt(d),r>55295&&r<57344){if(!a){if(r>56319){(t-=3)>-1&&u.push(239,191,189);continue}else if(d+1===i){(t-=3)>-1&&u.push(239,191,189);continue}a=r;continue}if(r<56320){(t-=3)>-1&&u.push(239,191,189),a=r;continue}r=(a-55296<<10|r-56320)+65536}else a&&(t-=3)>-1&&u.push(239,191,189);if(a=null,r<128){if((t-=1)<0)break;u.push(r)}else if(r<2048){if((t-=2)<0)break;u.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;u.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((t-=4)<0)break;u.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return u}function qo(e){for(var t=[],r=0;r<e.length;++r)t.push(e.charCodeAt(r)&255);return t}function Ho(e,t){for(var r,i,a,u=[],d=0;d<e.length&&!((t-=2)<0);++d)r=e.charCodeAt(d),i=r>>8,a=r%256,u.push(a),u.push(i);return u}function ni(e){return qr.toByteArray(Vo(e))}function lr(e,t,r,i){for(var a=0;a<i&&!(a+r>=t.length||a>=e.length);++a)t[a+r]=e[a];return a}function jt(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function Gr(e){return e!==e}var $o=function(){for(var e="0123456789abcdef",t=new Array(256),r=0;r<16;++r)for(var i=r*16,a=0;a<16;++a)t[i+a]=e[r]+e[a];return t}()});var gi={};Nn(gi,{default:()=>ca});var ca,_i=co(()=>{ca={}});var bi=nr((pf,mr)=>{var ce=(_i(),uo(gi));if(ce&&ce.default){mr.exports=ce.default;for(let e in ce)mr.exports[e]=ce[e]}else ce&&(mr.exports=ce)});var Lr=nr((xf,wr)=>{(function(e){"use strict";var t=function(o){var f,s=new Float64Array(16);if(o)for(f=0;f<o.length;f++)s[f]=o[f];return s},r=function(){throw new Error("no PRNG")},i=new Uint8Array(16),a=new Uint8Array(32);a[0]=9;var u=t(),d=t([1]),m=t([56129,1]),w=t([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),A=t([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),C=t([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),O=t([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),Q=t([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function st(o,f,s,n){o[f]=s>>24&255,o[f+1]=s>>16&255,o[f+2]=s>>8&255,o[f+3]=s&255,o[f+4]=n>>24&255,o[f+5]=n>>16&255,o[f+6]=n>>8&255,o[f+7]=n&255}function it(o,f,s,n,c){var h,p=0;for(h=0;h<c;h++)p|=o[f+h]^s[n+h];return(1&p-1>>>8)-1}function vt(o,f,s,n){return it(o,f,s,n,16)}function qt(o,f,s,n){return it(o,f,s,n,32)}function Lt(o,f,s,n){for(var c=n[0]&255|(n[1]&255)<<8|(n[2]&255)<<16|(n[3]&255)<<24,h=s[0]&255|(s[1]&255)<<8|(s[2]&255)<<16|(s[3]&255)<<24,p=s[4]&255|(s[5]&255)<<8|(s[6]&255)<<16|(s[7]&255)<<24,b=s[8]&255|(s[9]&255)<<8|(s[10]&255)<<16|(s[11]&255)<<24,S=s[12]&255|(s[13]&255)<<8|(s[14]&255)<<16|(s[15]&255)<<24,j=n[4]&255|(n[5]&255)<<8|(n[6]&255)<<16|(n[7]&255)<<24,R=f[0]&255|(f[1]&255)<<8|(f[2]&255)<<16|(f[3]&255)<<24,et=f[4]&255|(f[5]&255)<<8|(f[6]&255)<<16|(f[7]&255)<<24,N=f[8]&255|(f[9]&255)<<8|(f[10]&255)<<16|(f[11]&255)<<24,Y=f[12]&255|(f[13]&255)<<8|(f[14]&255)<<16|(f[15]&255)<<24,V=n[8]&255|(n[9]&255)<<8|(n[10]&255)<<16|(n[11]&255)<<24,W=s[16]&255|(s[17]&255)<<8|(s[18]&255)<<16|(s[19]&255)<<24,I=s[20]&255|(s[21]&255)<<8|(s[22]&255)<<16|(s[23]&255)<<24,q=s[24]&255|(s[25]&255)<<8|(s[26]&255)<<16|(s[27]&255)<<24,$=s[28]&255|(s[29]&255)<<8|(s[30]&255)<<16|(s[31]&255)<<24,H=n[12]&255|(n[13]&255)<<8|(n[14]&255)<<16|(n[15]&255)<<24,P=c,K=h,B=p,F=b,k=S,U=j,x=R,y=et,E=N,_=Y,v=V,T=W,M=I,z=q,J=$,G=H,l,Z=0;Z<20;Z+=2)l=P+M|0,k^=l<<7|l>>>32-7,l=k+P|0,E^=l<<9|l>>>32-9,l=E+k|0,M^=l<<13|l>>>32-13,l=M+E|0,P^=l<<18|l>>>32-18,l=U+K|0,_^=l<<7|l>>>32-7,l=_+U|0,z^=l<<9|l>>>32-9,l=z+_|0,K^=l<<13|l>>>32-13,l=K+z|0,U^=l<<18|l>>>32-18,l=v+x|0,J^=l<<7|l>>>32-7,l=J+v|0,B^=l<<9|l>>>32-9,l=B+J|0,x^=l<<13|l>>>32-13,l=x+B|0,v^=l<<18|l>>>32-18,l=G+T|0,F^=l<<7|l>>>32-7,l=F+G|0,y^=l<<9|l>>>32-9,l=y+F|0,T^=l<<13|l>>>32-13,l=T+y|0,G^=l<<18|l>>>32-18,l=P+F|0,K^=l<<7|l>>>32-7,l=K+P|0,B^=l<<9|l>>>32-9,l=B+K|0,F^=l<<13|l>>>32-13,l=F+B|0,P^=l<<18|l>>>32-18,l=U+k|0,x^=l<<7|l>>>32-7,l=x+U|0,y^=l<<9|l>>>32-9,l=y+x|0,k^=l<<13|l>>>32-13,l=k+y|0,U^=l<<18|l>>>32-18,l=v+_|0,T^=l<<7|l>>>32-7,l=T+v|0,E^=l<<9|l>>>32-9,l=E+T|0,_^=l<<13|l>>>32-13,l=_+E|0,v^=l<<18|l>>>32-18,l=G+J|0,M^=l<<7|l>>>32-7,l=M+G|0,z^=l<<9|l>>>32-9,l=z+M|0,J^=l<<13|l>>>32-13,l=J+z|0,G^=l<<18|l>>>32-18;P=P+c|0,K=K+h|0,B=B+p|0,F=F+b|0,k=k+S|0,U=U+j|0,x=x+R|0,y=y+et|0,E=E+N|0,_=_+Y|0,v=v+V|0,T=T+W|0,M=M+I|0,z=z+q|0,J=J+$|0,G=G+H|0,o[0]=P>>>0&255,o[1]=P>>>8&255,o[2]=P>>>16&255,o[3]=P>>>24&255,o[4]=K>>>0&255,o[5]=K>>>8&255,o[6]=K>>>16&255,o[7]=K>>>24&255,o[8]=B>>>0&255,o[9]=B>>>8&255,o[10]=B>>>16&255,o[11]=B>>>24&255,o[12]=F>>>0&255,o[13]=F>>>8&255,o[14]=F>>>16&255,o[15]=F>>>24&255,o[16]=k>>>0&255,o[17]=k>>>8&255,o[18]=k>>>16&255,o[19]=k>>>24&255,o[20]=U>>>0&255,o[21]=U>>>8&255,o[22]=U>>>16&255,o[23]=U>>>24&255,o[24]=x>>>0&255,o[25]=x>>>8&255,o[26]=x>>>16&255,o[27]=x>>>24&255,o[28]=y>>>0&255,o[29]=y>>>8&255,o[30]=y>>>16&255,o[31]=y>>>24&255,o[32]=E>>>0&255,o[33]=E>>>8&255,o[34]=E>>>16&255,o[35]=E>>>24&255,o[36]=_>>>0&255,o[37]=_>>>8&255,o[38]=_>>>16&255,o[39]=_>>>24&255,o[40]=v>>>0&255,o[41]=v>>>8&255,o[42]=v>>>16&255,o[43]=v>>>24&255,o[44]=T>>>0&255,o[45]=T>>>8&255,o[46]=T>>>16&255,o[47]=T>>>24&255,o[48]=M>>>0&255,o[49]=M>>>8&255,o[50]=M>>>16&255,o[51]=M>>>24&255,o[52]=z>>>0&255,o[53]=z>>>8&255,o[54]=z>>>16&255,o[55]=z>>>24&255,o[56]=J>>>0&255,o[57]=J>>>8&255,o[58]=J>>>16&255,o[59]=J>>>24&255,o[60]=G>>>0&255,o[61]=G>>>8&255,o[62]=G>>>16&255,o[63]=G>>>24&255}function Ht(o,f,s,n){for(var c=n[0]&255|(n[1]&255)<<8|(n[2]&255)<<16|(n[3]&255)<<24,h=s[0]&255|(s[1]&255)<<8|(s[2]&255)<<16|(s[3]&255)<<24,p=s[4]&255|(s[5]&255)<<8|(s[6]&255)<<16|(s[7]&255)<<24,b=s[8]&255|(s[9]&255)<<8|(s[10]&255)<<16|(s[11]&255)<<24,S=s[12]&255|(s[13]&255)<<8|(s[14]&255)<<16|(s[15]&255)<<24,j=n[4]&255|(n[5]&255)<<8|(n[6]&255)<<16|(n[7]&255)<<24,R=f[0]&255|(f[1]&255)<<8|(f[2]&255)<<16|(f[3]&255)<<24,et=f[4]&255|(f[5]&255)<<8|(f[6]&255)<<16|(f[7]&255)<<24,N=f[8]&255|(f[9]&255)<<8|(f[10]&255)<<16|(f[11]&255)<<24,Y=f[12]&255|(f[13]&255)<<8|(f[14]&255)<<16|(f[15]&255)<<24,V=n[8]&255|(n[9]&255)<<8|(n[10]&255)<<16|(n[11]&255)<<24,W=s[16]&255|(s[17]&255)<<8|(s[18]&255)<<16|(s[19]&255)<<24,I=s[20]&255|(s[21]&255)<<8|(s[22]&255)<<16|(s[23]&255)<<24,q=s[24]&255|(s[25]&255)<<8|(s[26]&255)<<16|(s[27]&255)<<24,$=s[28]&255|(s[29]&255)<<8|(s[30]&255)<<16|(s[31]&255)<<24,H=n[12]&255|(n[13]&255)<<8|(n[14]&255)<<16|(n[15]&255)<<24,P=c,K=h,B=p,F=b,k=S,U=j,x=R,y=et,E=N,_=Y,v=V,T=W,M=I,z=q,J=$,G=H,l,Z=0;Z<20;Z+=2)l=P+M|0,k^=l<<7|l>>>32-7,l=k+P|0,E^=l<<9|l>>>32-9,l=E+k|0,M^=l<<13|l>>>32-13,l=M+E|0,P^=l<<18|l>>>32-18,l=U+K|0,_^=l<<7|l>>>32-7,l=_+U|0,z^=l<<9|l>>>32-9,l=z+_|0,K^=l<<13|l>>>32-13,l=K+z|0,U^=l<<18|l>>>32-18,l=v+x|0,J^=l<<7|l>>>32-7,l=J+v|0,B^=l<<9|l>>>32-9,l=B+J|0,x^=l<<13|l>>>32-13,l=x+B|0,v^=l<<18|l>>>32-18,l=G+T|0,F^=l<<7|l>>>32-7,l=F+G|0,y^=l<<9|l>>>32-9,l=y+F|0,T^=l<<13|l>>>32-13,l=T+y|0,G^=l<<18|l>>>32-18,l=P+F|0,K^=l<<7|l>>>32-7,l=K+P|0,B^=l<<9|l>>>32-9,l=B+K|0,F^=l<<13|l>>>32-13,l=F+B|0,P^=l<<18|l>>>32-18,l=U+k|0,x^=l<<7|l>>>32-7,l=x+U|0,y^=l<<9|l>>>32-9,l=y+x|0,k^=l<<13|l>>>32-13,l=k+y|0,U^=l<<18|l>>>32-18,l=v+_|0,T^=l<<7|l>>>32-7,l=T+v|0,E^=l<<9|l>>>32-9,l=E+T|0,_^=l<<13|l>>>32-13,l=_+E|0,v^=l<<18|l>>>32-18,l=G+J|0,M^=l<<7|l>>>32-7,l=M+G|0,z^=l<<9|l>>>32-9,l=z+M|0,J^=l<<13|l>>>32-13,l=J+z|0,G^=l<<18|l>>>32-18;o[0]=P>>>0&255,o[1]=P>>>8&255,o[2]=P>>>16&255,o[3]=P>>>24&255,o[4]=U>>>0&255,o[5]=U>>>8&255,o[6]=U>>>16&255,o[7]=U>>>24&255,o[8]=v>>>0&255,o[9]=v>>>8&255,o[10]=v>>>16&255,o[11]=v>>>24&255,o[12]=G>>>0&255,o[13]=G>>>8&255,o[14]=G>>>16&255,o[15]=G>>>24&255,o[16]=x>>>0&255,o[17]=x>>>8&255,o[18]=x>>>16&255,o[19]=x>>>24&255,o[20]=y>>>0&255,o[21]=y>>>8&255,o[22]=y>>>16&255,o[23]=y>>>24&255,o[24]=E>>>0&255,o[25]=E>>>8&255,o[26]=E>>>16&255,o[27]=E>>>24&255,o[28]=_>>>0&255,o[29]=_>>>8&255,o[30]=_>>>16&255,o[31]=_>>>24&255}function Ct(o,f,s,n){Lt(o,f,s,n)}function $t(o,f,s,n){Ht(o,f,s,n)}var It=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function We(o,f,s,n,c,h,p){var b=new Uint8Array(16),S=new Uint8Array(64),j,R;for(R=0;R<16;R++)b[R]=0;for(R=0;R<8;R++)b[R]=h[R];for(;c>=64;){for(Ct(S,b,p,It),R=0;R<64;R++)o[f+R]=s[n+R]^S[R];for(j=1,R=8;R<16;R++)j=j+(b[R]&255)|0,b[R]=j&255,j>>>=8;c-=64,f+=64,n+=64}if(c>0)for(Ct(S,b,p,It),R=0;R<c;R++)o[f+R]=s[n+R]^S[R];return 0}function ze(o,f,s,n,c){var h=new Uint8Array(16),p=new Uint8Array(64),b,S;for(S=0;S<16;S++)h[S]=0;for(S=0;S<8;S++)h[S]=n[S];for(;s>=64;){for(Ct(p,h,c,It),S=0;S<64;S++)o[f+S]=p[S];for(b=1,S=8;S<16;S++)b=b+(h[S]&255)|0,h[S]=b&255,b>>>=8;s-=64,f+=64}if(s>0)for(Ct(p,h,c,It),S=0;S<s;S++)o[f+S]=p[S];return 0}function Ge(o,f,s,n,c){var h=new Uint8Array(32);$t(h,n,c,It);for(var p=new Uint8Array(8),b=0;b<8;b++)p[b]=n[b+16];return ze(o,f,s,p,h)}function he(o,f,s,n,c,h,p){var b=new Uint8Array(32);$t(b,h,p,It);for(var S=new Uint8Array(8),j=0;j<8;j++)S[j]=h[j+16];return We(o,f,s,n,c,S,b)}var Wt=function(o){this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.leftover=0,this.fin=0;var f,s,n,c,h,p,b,S;f=o[0]&255|(o[1]&255)<<8,this.r[0]=f&8191,s=o[2]&255|(o[3]&255)<<8,this.r[1]=(f>>>13|s<<3)&8191,n=o[4]&255|(o[5]&255)<<8,this.r[2]=(s>>>10|n<<6)&7939,c=o[6]&255|(o[7]&255)<<8,this.r[3]=(n>>>7|c<<9)&8191,h=o[8]&255|(o[9]&255)<<8,this.r[4]=(c>>>4|h<<12)&255,this.r[5]=h>>>1&8190,p=o[10]&255|(o[11]&255)<<8,this.r[6]=(h>>>14|p<<2)&8191,b=o[12]&255|(o[13]&255)<<8,this.r[7]=(p>>>11|b<<5)&8065,S=o[14]&255|(o[15]&255)<<8,this.r[8]=(b>>>8|S<<8)&8191,this.r[9]=S>>>5&127,this.pad[0]=o[16]&255|(o[17]&255)<<8,this.pad[1]=o[18]&255|(o[19]&255)<<8,this.pad[2]=o[20]&255|(o[21]&255)<<8,this.pad[3]=o[22]&255|(o[23]&255)<<8,this.pad[4]=o[24]&255|(o[25]&255)<<8,this.pad[5]=o[26]&255|(o[27]&255)<<8,this.pad[6]=o[28]&255|(o[29]&255)<<8,this.pad[7]=o[30]&255|(o[31]&255)<<8};Wt.prototype.blocks=function(o,f,s){for(var n=this.fin?0:2048,c,h,p,b,S,j,R,et,N,Y,V,W,I,q,$,H,P,K,B,F=this.h[0],k=this.h[1],U=this.h[2],x=this.h[3],y=this.h[4],E=this.h[5],_=this.h[6],v=this.h[7],T=this.h[8],M=this.h[9],z=this.r[0],J=this.r[1],G=this.r[2],l=this.r[3],Z=this.r[4],rt=this.r[5],nt=this.r[6],X=this.r[7],L=this.r[8],tt=this.r[9];s>=16;)c=o[f+0]&255|(o[f+1]&255)<<8,F+=c&8191,h=o[f+2]&255|(o[f+3]&255)<<8,k+=(c>>>13|h<<3)&8191,p=o[f+4]&255|(o[f+5]&255)<<8,U+=(h>>>10|p<<6)&8191,b=o[f+6]&255|(o[f+7]&255)<<8,x+=(p>>>7|b<<9)&8191,S=o[f+8]&255|(o[f+9]&255)<<8,y+=(b>>>4|S<<12)&8191,E+=S>>>1&8191,j=o[f+10]&255|(o[f+11]&255)<<8,_+=(S>>>14|j<<2)&8191,R=o[f+12]&255|(o[f+13]&255)<<8,v+=(j>>>11|R<<5)&8191,et=o[f+14]&255|(o[f+15]&255)<<8,T+=(R>>>8|et<<8)&8191,M+=et>>>5|n,N=0,Y=N,Y+=F*z,Y+=k*(5*tt),Y+=U*(5*L),Y+=x*(5*X),Y+=y*(5*nt),N=Y>>>13,Y&=8191,Y+=E*(5*rt),Y+=_*(5*Z),Y+=v*(5*l),Y+=T*(5*G),Y+=M*(5*J),N+=Y>>>13,Y&=8191,V=N,V+=F*J,V+=k*z,V+=U*(5*tt),V+=x*(5*L),V+=y*(5*X),N=V>>>13,V&=8191,V+=E*(5*nt),V+=_*(5*rt),V+=v*(5*Z),V+=T*(5*l),V+=M*(5*G),N+=V>>>13,V&=8191,W=N,W+=F*G,W+=k*J,W+=U*z,W+=x*(5*tt),W+=y*(5*L),N=W>>>13,W&=8191,W+=E*(5*X),W+=_*(5*nt),W+=v*(5*rt),W+=T*(5*Z),W+=M*(5*l),N+=W>>>13,W&=8191,I=N,I+=F*l,I+=k*G,I+=U*J,I+=x*z,I+=y*(5*tt),N=I>>>13,I&=8191,I+=E*(5*L),I+=_*(5*X),I+=v*(5*nt),I+=T*(5*rt),I+=M*(5*Z),N+=I>>>13,I&=8191,q=N,q+=F*Z,q+=k*l,q+=U*G,q+=x*J,q+=y*z,N=q>>>13,q&=8191,q+=E*(5*tt),q+=_*(5*L),q+=v*(5*X),q+=T*(5*nt),q+=M*(5*rt),N+=q>>>13,q&=8191,$=N,$+=F*rt,$+=k*Z,$+=U*l,$+=x*G,$+=y*J,N=$>>>13,$&=8191,$+=E*z,$+=_*(5*tt),$+=v*(5*L),$+=T*(5*X),$+=M*(5*nt),N+=$>>>13,$&=8191,H=N,H+=F*nt,H+=k*rt,H+=U*Z,H+=x*l,H+=y*G,N=H>>>13,H&=8191,H+=E*J,H+=_*z,H+=v*(5*tt),H+=T*(5*L),H+=M*(5*X),N+=H>>>13,H&=8191,P=N,P+=F*X,P+=k*nt,P+=U*rt,P+=x*Z,P+=y*l,N=P>>>13,P&=8191,P+=E*G,P+=_*J,P+=v*z,P+=T*(5*tt),P+=M*(5*L),N+=P>>>13,P&=8191,K=N,K+=F*L,K+=k*X,K+=U*nt,K+=x*rt,K+=y*Z,N=K>>>13,K&=8191,K+=E*l,K+=_*G,K+=v*J,K+=T*z,K+=M*(5*tt),N+=K>>>13,K&=8191,B=N,B+=F*tt,B+=k*L,B+=U*X,B+=x*nt,B+=y*rt,N=B>>>13,B&=8191,B+=E*Z,B+=_*l,B+=v*G,B+=T*J,B+=M*z,N+=B>>>13,B&=8191,N=(N<<2)+N|0,N=N+Y|0,Y=N&8191,N=N>>>13,V+=N,F=Y,k=V,U=W,x=I,y=q,E=$,_=H,v=P,T=K,M=B,f+=16,s-=16;this.h[0]=F,this.h[1]=k,this.h[2]=U,this.h[3]=x,this.h[4]=y,this.h[5]=E,this.h[6]=_,this.h[7]=v,this.h[8]=T,this.h[9]=M},Wt.prototype.finish=function(o,f){var s=new Uint16Array(10),n,c,h,p;if(this.leftover){for(p=this.leftover,this.buffer[p++]=1;p<16;p++)this.buffer[p]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(n=this.h[1]>>>13,this.h[1]&=8191,p=2;p<10;p++)this.h[p]+=n,n=this.h[p]>>>13,this.h[p]&=8191;for(this.h[0]+=n*5,n=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=n,n=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=n,s[0]=this.h[0]+5,n=s[0]>>>13,s[0]&=8191,p=1;p<10;p++)s[p]=this.h[p]+n,n=s[p]>>>13,s[p]&=8191;for(s[9]-=1<<13,c=(n^1)-1,p=0;p<10;p++)s[p]&=c;for(c=~c,p=0;p<10;p++)this.h[p]=this.h[p]&c|s[p];for(this.h[0]=(this.h[0]|this.h[1]<<13)&65535,this.h[1]=(this.h[1]>>>3|this.h[2]<<10)&65535,this.h[2]=(this.h[2]>>>6|this.h[3]<<7)&65535,this.h[3]=(this.h[3]>>>9|this.h[4]<<4)&65535,this.h[4]=(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14)&65535,this.h[5]=(this.h[6]>>>2|this.h[7]<<11)&65535,this.h[6]=(this.h[7]>>>5|this.h[8]<<8)&65535,this.h[7]=(this.h[8]>>>8|this.h[9]<<5)&65535,h=this.h[0]+this.pad[0],this.h[0]=h&65535,p=1;p<8;p++)h=(this.h[p]+this.pad[p]|0)+(h>>>16)|0,this.h[p]=h&65535;o[f+0]=this.h[0]>>>0&255,o[f+1]=this.h[0]>>>8&255,o[f+2]=this.h[1]>>>0&255,o[f+3]=this.h[1]>>>8&255,o[f+4]=this.h[2]>>>0&255,o[f+5]=this.h[2]>>>8&255,o[f+6]=this.h[3]>>>0&255,o[f+7]=this.h[3]>>>8&255,o[f+8]=this.h[4]>>>0&255,o[f+9]=this.h[4]>>>8&255,o[f+10]=this.h[5]>>>0&255,o[f+11]=this.h[5]>>>8&255,o[f+12]=this.h[6]>>>0&255,o[f+13]=this.h[6]>>>8&255,o[f+14]=this.h[7]>>>0&255,o[f+15]=this.h[7]>>>8&255},Wt.prototype.update=function(o,f,s){var n,c;if(this.leftover){for(c=16-this.leftover,c>s&&(c=s),n=0;n<c;n++)this.buffer[this.leftover+n]=o[f+n];if(s-=c,f+=c,this.leftover+=c,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(s>=16&&(c=s-s%16,this.blocks(o,f,c),f+=c,s-=c),s){for(n=0;n<s;n++)this.buffer[this.leftover+n]=o[f+n];this.leftover+=s}};function Oe(o,f,s,n,c,h){var p=new Wt(h);return p.update(s,n,c),p.finish(o,f),0}function Je(o,f,s,n,c,h){var p=new Uint8Array(16);return Oe(p,0,s,n,c,h),vt(o,f,p,0)}function Ue(o,f,s,n,c){var h;if(s<32)return-1;for(he(o,0,f,0,s,n,c),Oe(o,16,o,32,s-32,o),h=0;h<16;h++)o[h]=0;return 0}function Re(o,f,s,n,c){var h,p=new Uint8Array(32);if(s<32||(Ge(p,0,32,n,c),Je(f,16,f,32,s-32,p)!==0))return-1;for(he(o,0,f,0,s,n,c),h=0;h<32;h++)o[h]=0;return 0}function Ot(o,f){var s;for(s=0;s<16;s++)o[s]=f[s]|0}function Be(o){var f,s,n=1;for(f=0;f<16;f++)s=o[f]+n+65535,n=Math.floor(s/65536),o[f]=s-n*65536;o[0]+=n-1+37*(n-1)}function te(o,f,s){for(var n,c=~(s-1),h=0;h<16;h++)n=c&(o[h]^f[h]),o[h]^=n,f[h]^=n}function pe(o,f){var s,n,c,h=t(),p=t();for(s=0;s<16;s++)p[s]=f[s];for(Be(p),Be(p),Be(p),n=0;n<2;n++){for(h[0]=p[0]-65517,s=1;s<15;s++)h[s]=p[s]-65535-(h[s-1]>>16&1),h[s-1]&=65535;h[15]=p[15]-32767-(h[14]>>16&1),c=h[15]>>16&1,h[14]&=65535,te(p,h,1-c)}for(s=0;s<16;s++)o[2*s]=p[s]&255,o[2*s+1]=p[s]>>8}function mn(o,f){var s=new Uint8Array(32),n=new Uint8Array(32);return pe(s,o),pe(n,f),qt(s,0,n,0)}function wn(o){var f=new Uint8Array(32);return pe(f,o),f[0]&1}function Or(o,f){var s;for(s=0;s<16;s++)o[s]=f[2*s]+(f[2*s+1]<<8);o[15]&=32767}function Ut(o,f,s){for(var n=0;n<16;n++)o[n]=f[n]+s[n]}function Rt(o,f,s){for(var n=0;n<16;n++)o[n]=f[n]-s[n]}function D(o,f,s){var n,c,h=0,p=0,b=0,S=0,j=0,R=0,et=0,N=0,Y=0,V=0,W=0,I=0,q=0,$=0,H=0,P=0,K=0,B=0,F=0,k=0,U=0,x=0,y=0,E=0,_=0,v=0,T=0,M=0,z=0,J=0,G=0,l=s[0],Z=s[1],rt=s[2],nt=s[3],X=s[4],L=s[5],tt=s[6],lt=s[7],at=s[8],ft=s[9],ct=s[10],ut=s[11],dt=s[12],pt=s[13],xt=s[14],yt=s[15];n=f[0],h+=n*l,p+=n*Z,b+=n*rt,S+=n*nt,j+=n*X,R+=n*L,et+=n*tt,N+=n*lt,Y+=n*at,V+=n*ft,W+=n*ct,I+=n*ut,q+=n*dt,$+=n*pt,H+=n*xt,P+=n*yt,n=f[1],p+=n*l,b+=n*Z,S+=n*rt,j+=n*nt,R+=n*X,et+=n*L,N+=n*tt,Y+=n*lt,V+=n*at,W+=n*ft,I+=n*ct,q+=n*ut,$+=n*dt,H+=n*pt,P+=n*xt,K+=n*yt,n=f[2],b+=n*l,S+=n*Z,j+=n*rt,R+=n*nt,et+=n*X,N+=n*L,Y+=n*tt,V+=n*lt,W+=n*at,I+=n*ft,q+=n*ct,$+=n*ut,H+=n*dt,P+=n*pt,K+=n*xt,B+=n*yt,n=f[3],S+=n*l,j+=n*Z,R+=n*rt,et+=n*nt,N+=n*X,Y+=n*L,V+=n*tt,W+=n*lt,I+=n*at,q+=n*ft,$+=n*ct,H+=n*ut,P+=n*dt,K+=n*pt,B+=n*xt,F+=n*yt,n=f[4],j+=n*l,R+=n*Z,et+=n*rt,N+=n*nt,Y+=n*X,V+=n*L,W+=n*tt,I+=n*lt,q+=n*at,$+=n*ft,H+=n*ct,P+=n*ut,K+=n*dt,B+=n*pt,F+=n*xt,k+=n*yt,n=f[5],R+=n*l,et+=n*Z,N+=n*rt,Y+=n*nt,V+=n*X,W+=n*L,I+=n*tt,q+=n*lt,$+=n*at,H+=n*ft,P+=n*ct,K+=n*ut,B+=n*dt,F+=n*pt,k+=n*xt,U+=n*yt,n=f[6],et+=n*l,N+=n*Z,Y+=n*rt,V+=n*nt,W+=n*X,I+=n*L,q+=n*tt,$+=n*lt,H+=n*at,P+=n*ft,K+=n*ct,B+=n*ut,F+=n*dt,k+=n*pt,U+=n*xt,x+=n*yt,n=f[7],N+=n*l,Y+=n*Z,V+=n*rt,W+=n*nt,I+=n*X,q+=n*L,$+=n*tt,H+=n*lt,P+=n*at,K+=n*ft,B+=n*ct,F+=n*ut,k+=n*dt,U+=n*pt,x+=n*xt,y+=n*yt,n=f[8],Y+=n*l,V+=n*Z,W+=n*rt,I+=n*nt,q+=n*X,$+=n*L,H+=n*tt,P+=n*lt,K+=n*at,B+=n*ft,F+=n*ct,k+=n*ut,U+=n*dt,x+=n*pt,y+=n*xt,E+=n*yt,n=f[9],V+=n*l,W+=n*Z,I+=n*rt,q+=n*nt,$+=n*X,H+=n*L,P+=n*tt,K+=n*lt,B+=n*at,F+=n*ft,k+=n*ct,U+=n*ut,x+=n*dt,y+=n*pt,E+=n*xt,_+=n*yt,n=f[10],W+=n*l,I+=n*Z,q+=n*rt,$+=n*nt,H+=n*X,P+=n*L,K+=n*tt,B+=n*lt,F+=n*at,k+=n*ft,U+=n*ct,x+=n*ut,y+=n*dt,E+=n*pt,_+=n*xt,v+=n*yt,n=f[11],I+=n*l,q+=n*Z,$+=n*rt,H+=n*nt,P+=n*X,K+=n*L,B+=n*tt,F+=n*lt,k+=n*at,U+=n*ft,x+=n*ct,y+=n*ut,E+=n*dt,_+=n*pt,v+=n*xt,T+=n*yt,n=f[12],q+=n*l,$+=n*Z,H+=n*rt,P+=n*nt,K+=n*X,B+=n*L,F+=n*tt,k+=n*lt,U+=n*at,x+=n*ft,y+=n*ct,E+=n*ut,_+=n*dt,v+=n*pt,T+=n*xt,M+=n*yt,n=f[13],$+=n*l,H+=n*Z,P+=n*rt,K+=n*nt,B+=n*X,F+=n*L,k+=n*tt,U+=n*lt,x+=n*at,y+=n*ft,E+=n*ct,_+=n*ut,v+=n*dt,T+=n*pt,M+=n*xt,z+=n*yt,n=f[14],H+=n*l,P+=n*Z,K+=n*rt,B+=n*nt,F+=n*X,k+=n*L,U+=n*tt,x+=n*lt,y+=n*at,E+=n*ft,_+=n*ct,v+=n*ut,T+=n*dt,M+=n*pt,z+=n*xt,J+=n*yt,n=f[15],P+=n*l,K+=n*Z,B+=n*rt,F+=n*nt,k+=n*X,U+=n*L,x+=n*tt,y+=n*lt,E+=n*at,_+=n*ft,v+=n*ct,T+=n*ut,M+=n*dt,z+=n*pt,J+=n*xt,G+=n*yt,h+=38*K,p+=38*B,b+=38*F,S+=38*k,j+=38*U,R+=38*x,et+=38*y,N+=38*E,Y+=38*_,V+=38*v,W+=38*T,I+=38*M,q+=38*z,$+=38*J,H+=38*G,c=1,n=h+c+65535,c=Math.floor(n/65536),h=n-c*65536,n=p+c+65535,c=Math.floor(n/65536),p=n-c*65536,n=b+c+65535,c=Math.floor(n/65536),b=n-c*65536,n=S+c+65535,c=Math.floor(n/65536),S=n-c*65536,n=j+c+65535,c=Math.floor(n/65536),j=n-c*65536,n=R+c+65535,c=Math.floor(n/65536),R=n-c*65536,n=et+c+65535,c=Math.floor(n/65536),et=n-c*65536,n=N+c+65535,c=Math.floor(n/65536),N=n-c*65536,n=Y+c+65535,c=Math.floor(n/65536),Y=n-c*65536,n=V+c+65535,c=Math.floor(n/65536),V=n-c*65536,n=W+c+65535,c=Math.floor(n/65536),W=n-c*65536,n=I+c+65535,c=Math.floor(n/65536),I=n-c*65536,n=q+c+65535,c=Math.floor(n/65536),q=n-c*65536,n=$+c+65535,c=Math.floor(n/65536),$=n-c*65536,n=H+c+65535,c=Math.floor(n/65536),H=n-c*65536,n=P+c+65535,c=Math.floor(n/65536),P=n-c*65536,h+=c-1+37*(c-1),c=1,n=h+c+65535,c=Math.floor(n/65536),h=n-c*65536,n=p+c+65535,c=Math.floor(n/65536),p=n-c*65536,n=b+c+65535,c=Math.floor(n/65536),b=n-c*65536,n=S+c+65535,c=Math.floor(n/65536),S=n-c*65536,n=j+c+65535,c=Math.floor(n/65536),j=n-c*65536,n=R+c+65535,c=Math.floor(n/65536),R=n-c*65536,n=et+c+65535,c=Math.floor(n/65536),et=n-c*65536,n=N+c+65535,c=Math.floor(n/65536),N=n-c*65536,n=Y+c+65535,c=Math.floor(n/65536),Y=n-c*65536,n=V+c+65535,c=Math.floor(n/65536),V=n-c*65536,n=W+c+65535,c=Math.floor(n/65536),W=n-c*65536,n=I+c+65535,c=Math.floor(n/65536),I=n-c*65536,n=q+c+65535,c=Math.floor(n/65536),q=n-c*65536,n=$+c+65535,c=Math.floor(n/65536),$=n-c*65536,n=H+c+65535,c=Math.floor(n/65536),H=n-c*65536,n=P+c+65535,c=Math.floor(n/65536),P=n-c*65536,h+=c-1+37*(c-1),o[0]=h,o[1]=p,o[2]=b,o[3]=S,o[4]=j,o[5]=R,o[6]=et,o[7]=N,o[8]=Y,o[9]=V,o[10]=W,o[11]=I,o[12]=q,o[13]=$,o[14]=H,o[15]=P}function Et(o,f){D(o,f,f)}function gn(o,f){var s=t(),n;for(n=0;n<16;n++)s[n]=f[n];for(n=253;n>=0;n--)Et(s,s),n!==2&&n!==4&&D(s,s,f);for(n=0;n<16;n++)o[n]=s[n]}function _n(o,f){var s=t(),n;for(n=0;n<16;n++)s[n]=f[n];for(n=250;n>=0;n--)Et(s,s),n!==1&&D(s,s,f);for(n=0;n<16;n++)o[n]=s[n]}function Xe(o,f,s){var n=new Uint8Array(32),c=new Float64Array(80),h,p,b=t(),S=t(),j=t(),R=t(),et=t(),N=t();for(p=0;p<31;p++)n[p]=f[p];for(n[31]=f[31]&127|64,n[0]&=248,Or(c,s),p=0;p<16;p++)S[p]=c[p],R[p]=b[p]=j[p]=0;for(b[0]=R[0]=1,p=254;p>=0;--p)h=n[p>>>3]>>>(p&7)&1,te(b,S,h),te(j,R,h),Ut(et,b,j),Rt(b,b,j),Ut(j,S,R),Rt(S,S,R),Et(R,et),Et(N,b),D(b,j,b),D(j,S,et),Ut(et,b,j),Rt(b,b,j),Et(S,b),Rt(j,R,N),D(b,j,m),Ut(b,b,R),D(j,j,b),D(b,R,N),D(R,S,c),Et(S,et),te(b,S,h),te(j,R,h);for(p=0;p<16;p++)c[p+16]=b[p],c[p+32]=j[p],c[p+48]=S[p],c[p+64]=R[p];var Y=c.subarray(32),V=c.subarray(16);return gn(Y,Y),D(V,V,Y),pe(o,V),0}function Ze(o,f){return Xe(o,f,a)}function bn(o,f){return r(f,32),Ze(o,f)}function Qe(o,f,s){var n=new Uint8Array(32);return Xe(n,s,f),$t(o,i,n,It)}var vn=Ue,ro=Re;function no(o,f,s,n,c,h){var p=new Uint8Array(32);return Qe(p,c,h),vn(o,f,s,n,p)}function io(o,f,s,n,c,h){var p=new Uint8Array(32);return Qe(p,c,h),ro(o,f,s,n,p)}var En=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function An(o,f,s,n){for(var c=new Int32Array(16),h=new Int32Array(16),p,b,S,j,R,et,N,Y,V,W,I,q,$,H,P,K,B,F,k,U,x,y,E,_,v,T,M=o[0],z=o[1],J=o[2],G=o[3],l=o[4],Z=o[5],rt=o[6],nt=o[7],X=f[0],L=f[1],tt=f[2],lt=f[3],at=f[4],ft=f[5],ct=f[6],ut=f[7],dt=0;n>=128;){for(k=0;k<16;k++)U=8*k+dt,c[k]=s[U+0]<<24|s[U+1]<<16|s[U+2]<<8|s[U+3],h[k]=s[U+4]<<24|s[U+5]<<16|s[U+6]<<8|s[U+7];for(k=0;k<80;k++)if(p=M,b=z,S=J,j=G,R=l,et=Z,N=rt,Y=nt,V=X,W=L,I=tt,q=lt,$=at,H=ft,P=ct,K=ut,x=nt,y=ut,E=y&65535,_=y>>>16,v=x&65535,T=x>>>16,x=(l>>>14|at<<32-14)^(l>>>18|at<<32-18)^(at>>>41-32|l<<32-(41-32)),y=(at>>>14|l<<32-14)^(at>>>18|l<<32-18)^(l>>>41-32|at<<32-(41-32)),E+=y&65535,_+=y>>>16,v+=x&65535,T+=x>>>16,x=l&Z^~l&rt,y=at&ft^~at&ct,E+=y&65535,_+=y>>>16,v+=x&65535,T+=x>>>16,x=En[k*2],y=En[k*2+1],E+=y&65535,_+=y>>>16,v+=x&65535,T+=x>>>16,x=c[k%16],y=h[k%16],E+=y&65535,_+=y>>>16,v+=x&65535,T+=x>>>16,_+=E>>>16,v+=_>>>16,T+=v>>>16,B=v&65535|T<<16,F=E&65535|_<<16,x=B,y=F,E=y&65535,_=y>>>16,v=x&65535,T=x>>>16,x=(M>>>28|X<<32-28)^(X>>>34-32|M<<32-(34-32))^(X>>>39-32|M<<32-(39-32)),y=(X>>>28|M<<32-28)^(M>>>34-32|X<<32-(34-32))^(M>>>39-32|X<<32-(39-32)),E+=y&65535,_+=y>>>16,v+=x&65535,T+=x>>>16,x=M&z^M&J^z&J,y=X&L^X&tt^L&tt,E+=y&65535,_+=y>>>16,v+=x&65535,T+=x>>>16,_+=E>>>16,v+=_>>>16,T+=v>>>16,Y=v&65535|T<<16,K=E&65535|_<<16,x=j,y=q,E=y&65535,_=y>>>16,v=x&65535,T=x>>>16,x=B,y=F,E+=y&65535,_+=y>>>16,v+=x&65535,T+=x>>>16,_+=E>>>16,v+=_>>>16,T+=v>>>16,j=v&65535|T<<16,q=E&65535|_<<16,z=p,J=b,G=S,l=j,Z=R,rt=et,nt=N,M=Y,L=V,tt=W,lt=I,at=q,ft=$,ct=H,ut=P,X=K,k%16===15)for(U=0;U<16;U++)x=c[U],y=h[U],E=y&65535,_=y>>>16,v=x&65535,T=x>>>16,x=c[(U+9)%16],y=h[(U+9)%16],E+=y&65535,_+=y>>>16,v+=x&65535,T+=x>>>16,B=c[(U+1)%16],F=h[(U+1)%16],x=(B>>>1|F<<32-1)^(B>>>8|F<<32-8)^B>>>7,y=(F>>>1|B<<32-1)^(F>>>8|B<<32-8)^(F>>>7|B<<32-7),E+=y&65535,_+=y>>>16,v+=x&65535,T+=x>>>16,B=c[(U+14)%16],F=h[(U+14)%16],x=(B>>>19|F<<32-19)^(F>>>61-32|B<<32-(61-32))^B>>>6,y=(F>>>19|B<<32-19)^(B>>>61-32|F<<32-(61-32))^(F>>>6|B<<32-6),E+=y&65535,_+=y>>>16,v+=x&65535,T+=x>>>16,_+=E>>>16,v+=_>>>16,T+=v>>>16,c[U]=v&65535|T<<16,h[U]=E&65535|_<<16;x=M,y=X,E=y&65535,_=y>>>16,v=x&65535,T=x>>>16,x=o[0],y=f[0],E+=y&65535,_+=y>>>16,v+=x&65535,T+=x>>>16,_+=E>>>16,v+=_>>>16,T+=v>>>16,o[0]=M=v&65535|T<<16,f[0]=X=E&65535|_<<16,x=z,y=L,E=y&65535,_=y>>>16,v=x&65535,T=x>>>16,x=o[1],y=f[1],E+=y&65535,_+=y>>>16,v+=x&65535,T+=x>>>16,_+=E>>>16,v+=_>>>16,T+=v>>>16,o[1]=z=v&65535|T<<16,f[1]=L=E&65535|_<<16,x=J,y=tt,E=y&65535,_=y>>>16,v=x&65535,T=x>>>16,x=o[2],y=f[2],E+=y&65535,_+=y>>>16,v+=x&65535,T+=x>>>16,_+=E>>>16,v+=_>>>16,T+=v>>>16,o[2]=J=v&65535|T<<16,f[2]=tt=E&65535|_<<16,x=G,y=lt,E=y&65535,_=y>>>16,v=x&65535,T=x>>>16,x=o[3],y=f[3],E+=y&65535,_+=y>>>16,v+=x&65535,T+=x>>>16,_+=E>>>16,v+=_>>>16,T+=v>>>16,o[3]=G=v&65535|T<<16,f[3]=lt=E&65535|_<<16,x=l,y=at,E=y&65535,_=y>>>16,v=x&65535,T=x>>>16,x=o[4],y=f[4],E+=y&65535,_+=y>>>16,v+=x&65535,T+=x>>>16,_+=E>>>16,v+=_>>>16,T+=v>>>16,o[4]=l=v&65535|T<<16,f[4]=at=E&65535|_<<16,x=Z,y=ft,E=y&65535,_=y>>>16,v=x&65535,T=x>>>16,x=o[5],y=f[5],E+=y&65535,_+=y>>>16,v+=x&65535,T+=x>>>16,_+=E>>>16,v+=_>>>16,T+=v>>>16,o[5]=Z=v&65535|T<<16,f[5]=ft=E&65535|_<<16,x=rt,y=ct,E=y&65535,_=y>>>16,v=x&65535,T=x>>>16,x=o[6],y=f[6],E+=y&65535,_+=y>>>16,v+=x&65535,T+=x>>>16,_+=E>>>16,v+=_>>>16,T+=v>>>16,o[6]=rt=v&65535|T<<16,f[6]=ct=E&65535|_<<16,x=nt,y=ut,E=y&65535,_=y>>>16,v=x&65535,T=x>>>16,x=o[7],y=f[7],E+=y&65535,_+=y>>>16,v+=x&65535,T+=x>>>16,_+=E>>>16,v+=_>>>16,T+=v>>>16,o[7]=nt=v&65535|T<<16,f[7]=ut=E&65535|_<<16,dt+=128,n-=128}return n}function ee(o,f,s){var n=new Int32Array(8),c=new Int32Array(8),h=new Uint8Array(256),p,b=s;for(n[0]=1779033703,n[1]=3144134277,n[2]=1013904242,n[3]=2773480762,n[4]=1359893119,n[5]=2600822924,n[6]=528734635,n[7]=1541459225,c[0]=4089235720,c[1]=2227873595,c[2]=4271175723,c[3]=1595750129,c[4]=2917565137,c[5]=725511199,c[6]=4215389547,c[7]=327033209,An(n,c,f,s),s%=128,p=0;p<s;p++)h[p]=f[b-s+p];for(h[s]=128,s=256-128*(s<112?1:0),h[s-9]=0,st(h,s-8,b/536870912|0,b<<3),An(n,c,h,s),p=0;p<8;p++)st(o,8*p,n[p],c[p]);return 0}function De(o,f){var s=t(),n=t(),c=t(),h=t(),p=t(),b=t(),S=t(),j=t(),R=t();Rt(s,o[1],o[0]),Rt(R,f[1],f[0]),D(s,s,R),Ut(n,o[0],o[1]),Ut(R,f[0],f[1]),D(n,n,R),D(c,o[3],f[3]),D(c,c,A),D(h,o[2],f[2]),Ut(h,h,h),Rt(p,n,s),Rt(b,h,c),Ut(S,h,c),Ut(j,n,s),D(o[0],p,b),D(o[1],j,S),D(o[2],S,b),D(o[3],p,j)}function Tn(o,f,s){var n;for(n=0;n<4;n++)te(o[n],f[n],s)}function Ur(o,f){var s=t(),n=t(),c=t();gn(c,f[2]),D(s,f[0],c),D(n,f[1],c),pe(o,n),o[31]^=wn(s)<<7}function Rr(o,f,s){var n,c;for(Ot(o[0],u),Ot(o[1],d),Ot(o[2],d),Ot(o[3],u),c=255;c>=0;--c)n=s[c/8|0]>>(c&7)&1,Tn(o,f,n),De(f,o),De(o,o),Tn(o,f,n)}function Le(o,f){var s=[t(),t(),t(),t()];Ot(s[0],C),Ot(s[1],O),Ot(s[2],d),D(s[3],C,O),Rr(o,s,f)}function Br(o,f,s){var n=new Uint8Array(64),c=[t(),t(),t(),t()],h;for(s||r(f,32),ee(n,f,32),n[0]&=248,n[31]&=127,n[31]|=64,Le(c,n),Ur(o,c),h=0;h<32;h++)f[h+32]=o[h];return 0}var tr=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function Nr(o,f){var s,n,c,h;for(n=63;n>=32;--n){for(s=0,c=n-32,h=n-12;c<h;++c)f[c]+=s-16*f[n]*tr[c-(n-32)],s=Math.floor((f[c]+128)/256),f[c]-=s*256;f[c]+=s,f[n]=0}for(s=0,c=0;c<32;c++)f[c]+=s-(f[31]>>4)*tr[c],s=f[c]>>8,f[c]&=255;for(c=0;c<32;c++)f[c]-=s*tr[c];for(n=0;n<32;n++)f[n+1]+=f[n]>>8,o[n]=f[n]&255}function Pr(o){var f=new Float64Array(64),s;for(s=0;s<64;s++)f[s]=o[s];for(s=0;s<64;s++)o[s]=0;Nr(o,f)}function Sn(o,f,s,n){var c=new Uint8Array(64),h=new Uint8Array(64),p=new Uint8Array(64),b,S,j=new Float64Array(64),R=[t(),t(),t(),t()];ee(c,n,32),c[0]&=248,c[31]&=127,c[31]|=64;var et=s+64;for(b=0;b<s;b++)o[64+b]=f[b];for(b=0;b<32;b++)o[32+b]=c[32+b];for(ee(p,o.subarray(32),s+32),Pr(p),Le(R,p),Ur(o,R),b=32;b<64;b++)o[b]=n[b];for(ee(h,o,s+64),Pr(h),b=0;b<64;b++)j[b]=0;for(b=0;b<32;b++)j[b]=p[b];for(b=0;b<32;b++)for(S=0;S<32;S++)j[b+S]+=h[b]*c[S];return Nr(o.subarray(32),j),et}function oo(o,f){var s=t(),n=t(),c=t(),h=t(),p=t(),b=t(),S=t();return Ot(o[2],d),Or(o[1],f),Et(c,o[1]),D(h,c,w),Rt(c,c,o[2]),Ut(h,o[2],h),Et(p,h),Et(b,p),D(S,b,p),D(s,S,c),D(s,s,h),_n(s,s),D(s,s,c),D(s,s,h),D(s,s,h),D(o[0],s,h),Et(n,o[0]),D(n,n,h),mn(n,c)&&D(o[0],o[0],Q),Et(n,o[0]),D(n,n,h),mn(n,c)?-1:(wn(o[0])===f[31]>>7&&Rt(o[0],u,o[0]),D(o[3],o[0],o[1]),0)}function Cr(o,f,s,n){var c,h=new Uint8Array(32),p=new Uint8Array(64),b=[t(),t(),t(),t()],S=[t(),t(),t(),t()];if(s<64||oo(S,n))return-1;for(c=0;c<s;c++)o[c]=f[c];for(c=0;c<32;c++)o[c+32]=n[c];if(ee(p,o,s),Pr(p),Rr(b,S,p),Le(S,f.subarray(32)),De(b,S),Ur(h,b),s-=64,qt(f,0,h,0)){for(c=0;c<s;c++)o[c]=0;return-1}for(c=0;c<s;c++)o[c]=f[c+64];return s}var Fr=32,er=24,Ne=32,xe=16,Pe=32,rr=32,Ce=32,Fe=32,kr=32,On=er,ao=Ne,so=xe,zt=64,re=32,ye=64,jr=32,Kr=64;e.lowlevel={crypto_core_hsalsa20:$t,crypto_stream_xor:he,crypto_stream:Ge,crypto_stream_salsa20_xor:We,crypto_stream_salsa20:ze,crypto_onetimeauth:Oe,crypto_onetimeauth_verify:Je,crypto_verify_16:vt,crypto_verify_32:qt,crypto_secretbox:Ue,crypto_secretbox_open:Re,crypto_scalarmult:Xe,crypto_scalarmult_base:Ze,crypto_box_beforenm:Qe,crypto_box_afternm:vn,crypto_box:no,crypto_box_open:io,crypto_box_keypair:bn,crypto_hash:ee,crypto_sign:Sn,crypto_sign_keypair:Br,crypto_sign_open:Cr,crypto_secretbox_KEYBYTES:Fr,crypto_secretbox_NONCEBYTES:er,crypto_secretbox_ZEROBYTES:Ne,crypto_secretbox_BOXZEROBYTES:xe,crypto_scalarmult_BYTES:Pe,crypto_scalarmult_SCALARBYTES:rr,crypto_box_PUBLICKEYBYTES:Ce,crypto_box_SECRETKEYBYTES:Fe,crypto_box_BEFORENMBYTES:kr,crypto_box_NONCEBYTES:On,crypto_box_ZEROBYTES:ao,crypto_box_BOXZEROBYTES:so,crypto_sign_BYTES:zt,crypto_sign_PUBLICKEYBYTES:re,crypto_sign_SECRETKEYBYTES:ye,crypto_sign_SEEDBYTES:jr,crypto_hash_BYTES:Kr,gf:t,D:w,L:tr,pack25519:pe,unpack25519:Or,M:D,A:Ut,S:Et,Z:Rt,pow2523:_n,add:De,set25519:Ot,modL:Nr,scalarmult:Rr,scalarbase:Le};function Un(o,f){if(o.length!==Fr)throw new Error("bad key size");if(f.length!==er)throw new Error("bad nonce size")}function fo(o,f){if(o.length!==Ce)throw new Error("bad public key size");if(f.length!==Fe)throw new Error("bad secret key size")}function bt(){for(var o=0;o<arguments.length;o++)if(!(arguments[o]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function Rn(o){for(var f=0;f<o.length;f++)o[f]=0}e.randomBytes=function(o){var f=new Uint8Array(o);return r(f,o),f},e.secretbox=function(o,f,s){bt(o,f,s),Un(s,f);for(var n=new Uint8Array(Ne+o.length),c=new Uint8Array(n.length),h=0;h<o.length;h++)n[h+Ne]=o[h];return Ue(c,n,n.length,f,s),c.subarray(xe)},e.secretbox.open=function(o,f,s){bt(o,f,s),Un(s,f);for(var n=new Uint8Array(xe+o.length),c=new Uint8Array(n.length),h=0;h<o.length;h++)n[h+xe]=o[h];return n.length<32||Re(c,n,n.length,f,s)!==0?null:c.subarray(Ne)},e.secretbox.keyLength=Fr,e.secretbox.nonceLength=er,e.secretbox.overheadLength=xe,e.scalarMult=function(o,f){if(bt(o,f),o.length!==rr)throw new Error("bad n size");if(f.length!==Pe)throw new Error("bad p size");var s=new Uint8Array(Pe);return Xe(s,o,f),s},e.scalarMult.base=function(o){if(bt(o),o.length!==rr)throw new Error("bad n size");var f=new Uint8Array(Pe);return Ze(f,o),f},e.scalarMult.scalarLength=rr,e.scalarMult.groupElementLength=Pe,e.box=function(o,f,s,n){var c=e.box.before(s,n);return e.secretbox(o,f,c)},e.box.before=function(o,f){bt(o,f),fo(o,f);var s=new Uint8Array(kr);return Qe(s,o,f),s},e.box.after=e.secretbox,e.box.open=function(o,f,s,n){var c=e.box.before(s,n);return e.secretbox.open(o,f,c)},e.box.open.after=e.secretbox.open,e.box.keyPair=function(){var o=new Uint8Array(Ce),f=new Uint8Array(Fe);return bn(o,f),{publicKey:o,secretKey:f}},e.box.keyPair.fromSecretKey=function(o){if(bt(o),o.length!==Fe)throw new Error("bad secret key size");var f=new Uint8Array(Ce);return Ze(f,o),{publicKey:f,secretKey:new Uint8Array(o)}},e.box.publicKeyLength=Ce,e.box.secretKeyLength=Fe,e.box.sharedKeyLength=kr,e.box.nonceLength=On,e.box.overheadLength=e.secretbox.overheadLength,e.sign=function(o,f){if(bt(o,f),f.length!==ye)throw new Error("bad secret key size");var s=new Uint8Array(zt+o.length);return Sn(s,o,o.length,f),s},e.sign.open=function(o,f){if(bt(o,f),f.length!==re)throw new Error("bad public key size");var s=new Uint8Array(o.length),n=Cr(s,o,o.length,f);if(n<0)return null;for(var c=new Uint8Array(n),h=0;h<c.length;h++)c[h]=s[h];return c},e.sign.detached=function(o,f){for(var s=e.sign(o,f),n=new Uint8Array(zt),c=0;c<n.length;c++)n[c]=s[c];return n},e.sign.detached.verify=function(o,f,s){if(bt(o,f,s),f.length!==zt)throw new Error("bad signature size");if(s.length!==re)throw new Error("bad public key size");var n=new Uint8Array(zt+o.length),c=new Uint8Array(zt+o.length),h;for(h=0;h<zt;h++)n[h]=f[h];for(h=0;h<o.length;h++)n[h+zt]=o[h];return Cr(c,n,n.length,s)>=0},e.sign.keyPair=function(){var o=new Uint8Array(re),f=new Uint8Array(ye);return Br(o,f),{publicKey:o,secretKey:f}},e.sign.keyPair.fromSecretKey=function(o){if(bt(o),o.length!==ye)throw new Error("bad secret key size");for(var f=new Uint8Array(re),s=0;s<f.length;s++)f[s]=o[32+s];return{publicKey:f,secretKey:new Uint8Array(o)}},e.sign.keyPair.fromSeed=function(o){if(bt(o),o.length!==jr)throw new Error("bad seed size");for(var f=new Uint8Array(re),s=new Uint8Array(ye),n=0;n<32;n++)s[n]=o[n];return Br(f,s,!0),{publicKey:f,secretKey:s}},e.sign.publicKeyLength=re,e.sign.secretKeyLength=ye,e.sign.seedLength=jr,e.sign.signatureLength=zt,e.hash=function(o){bt(o);var f=new Uint8Array(Kr);return ee(f,o,o.length),f},e.hash.hashLength=Kr,e.verify=function(o,f){return bt(o,f),o.length===0||f.length===0||o.length!==f.length?!1:it(o,0,f,0,o.length)===0},e.setPRNG=function(o){r=o},function(){var o=typeof self<"u"?self.crypto||self.msCrypto:null;if(o&&o.getRandomValues){var f=65536;e.setPRNG(function(s,n){var c,h=new Uint8Array(n);for(c=0;c<n;c+=f)o.getRandomValues(h.subarray(c,c+Math.min(n-c,f)));for(c=0;c<n;c++)s[c]=h[c];Rn(h)})}else typeof Bn<"u"&&(o=bi(),o&&o.randomBytes&&e.setPRNG(function(s,n){var c,h=o.randomBytes(n);for(c=0;c<n;c++)s[c]=h[c];Rn(h)}))}()})(typeof wr<"u"&&wr.exports?wr.exports:self.nacl=self.nacl||{})});var we=class{callbacks=[];populate(t){this.callbacks.forEach(({callback:r})=>r(t))}subscribe(t){let r=Symbol();return this.callbacks.push({id:r,callback:t}),()=>this.callbacks=this.callbacks.filter(({id:i})=>i!==r)}};var ge=class extends we{authUser=null;constructor(){super()}static getInstance(){return ge.instance||(ge.instance=new ge),ge.instance}set(t){this.authUser=t,this.populate(t)}get(){return this.authUser}subscribe(t){let r=super.subscribe(t);return t(this.authUser),r}reset(){this.authUser=null,this.populate(this.authUser)}},Ft=ge;ir(Ft,"instance");var Kn=({message:e,detail:t})=>{let r=new CustomEvent(e,{detail:t,bubbles:!0});document.dispatchEvent(r)};var mt=e=>e==null;var Mn=BigInt(144e11),Yn={width:576,height:576},Vn={width:505,height:705},qn="internetcomputer.org";var _e=class extends we{env;constructor(){super()}static getInstance(){return _e.instance||(_e.instance=new _e),_e.instance}set(t){this.env=t,this.populate(t)}get(){return this.env}localIdentity(){return this.get()?.localIdentityCanisterId!==void 0}subscribe(t){let r=super.subscribe(t);return t(this.env),r}},wt=_e;ir(wt,"instance");var sr=()=>typeof window<"u",Mr=()=>{let e=wt.getInstance().get()?.satelliteId??"unknown";return wt.getInstance().localIdentity()?`http://${e}.localhost:8000`:`https://${e}.icp0.io`};var Yr=({width:e,height:t})=>{if(!sr()||mt(window)||mt(window.top))return;let{top:{innerWidth:r,innerHeight:i}}=window,a=i/2+screenY-t/2,u=r/2+screenX-e/2;return`toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=${e}, height=${t}, top=${a}, left=${u}`};var fr=class{#t;constructor({domain:t}){this.#t=t}get id(){return"internet_identity"}signInOptions({windowed:t}){let r=wt.getInstance().localIdentity()?`http://${wt.getInstance().get()?.localIdentityCanisterId}.localhost:8000`:`https://identity.${this.#t??qn}`;return{...t!==!1&&{windowOpenerFeatures:Yr(Yn)},identityProvider:r}}},Hn=class{#t;#e;constructor({appName:t,logoUrl:r}){this.#t=t,this.#e=r}get id(){return"nfid"}signInOptions({windowed:t}){return{...t!==!1&&{windowOpenerFeatures:Yr(Vn)},identityProvider:`https://nfid.one/authenticate/?applicationName=${encodeURI(this.#t)}&applicationLogo=${encodeURI(this.#e)}`}}};var mi=me(ii());var dr;(function(e){e[e.SysFatal=1]="SysFatal",e[e.SysTransient=2]="SysTransient",e[e.DestinationInvalid=3]="DestinationInvalid",e[e.CanisterReject=4]="CanisterReject",e[e.CanisterError=5]="CanisterError"})(dr||(dr={}));var Io=function(e,t){var r={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(r[i]=e[i]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,i=Object.getOwnPropertySymbols(e);a<i.length;a++)t.indexOf(i[a])<0&&Object.prototype.propertyIsEnumerable.call(e,i[a])&&(r[i[a]]=e[i[a]]);return r},Wo=new TextEncoder().encode(`
|
|
2
|
+
ic-request`),Xt=class{getPrincipal(){return this._principal||(this._principal=ot.selfAuthenticating(new Uint8Array(this.getPublicKey().toDer()))),this._principal}async transformRequest(t){let{body:r}=t,i=Io(t,["body"]),a=await ne(r);return Object.assign(Object.assign({},i),{body:{content:r,sender_pubkey:this.getPublicKey().toDer(),sender_sig:await this.sign(Cn(Wo,a))}})}},ae=class{getPrincipal(){return ot.anonymous()}async transformRequest(t){return Object.assign(Object.assign({},t),{body:{content:t.body}})}};var oi=me(kn());var hr;(function(e){e.Call="call"})(hr||(hr={}));function Ke(){let e=new ArrayBuffer(16),t=new DataView(e),r=BigInt(+Date.now()),i=Math.floor(Math.random()*4294967295),a=Math.floor(Math.random()*4294967295);if(typeof t.setBigUint64=="function")t.setBigUint64(0,r);else{let u=BigInt(1)<<BigInt(32);t.setUint32(0,Number(r>>BigInt(32))),t.setUint32(4,Number(r%u))}return t.setUint32(8,i),t.setUint32(12,a),e}var zo=BigInt(1e6),Go=BigInt(60*1e3),se=class{constructor(t){this._value=(BigInt(Date.now())+BigInt(t)-Go)*zo}toCBOR(){return oi.value.u64(this._value.toString(16),16)}toHash(){return Pn(this._value)}};function ai(e=Ke){return async t=>{let r=e(),i=t.request.headers?new Headers(t.request.headers):new Headers;t.request.headers=i,t.endpoint==="call"&&(t.body.nonce=e())}}var Kt;(function(e){e.Received="received",e.Processing="processing",e.Replied="replied",e.Rejected="rejected",e.Unknown="unknown",e.Done="done"})(Kt||(Kt={}));var pr=5*60*1e3,Xo="308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100814c0e6ec71fab583b08bd81373c255c3c371b2e84863c98a4f1e08b74235d14fb5d9c0cd546d9685f913a0c0b2cc5341583bf4b4392e467db96d65b9bb4cb717112f8472e0d5a4d14505ffd7484b01291091c5f87b98883463f98091a0baaae",Zo="ic0.app",Qo=".ic0.app",Do="icp0.io",Lo=".icp0.io",ta="icp-api.io",ea=".icp-api.io",Me=class extends ke{constructor(t){super(t),this.message=t}},Ee=class extends ke{constructor(t){super(t),this.message=t}};function ra(){let e;if(typeof window<"u")if(window.fetch)e=window.fetch.bind(window);else throw new Me("Fetch implementation was not available. You appear to be in a browser context, but window.fetch was not present.");else if(typeof window<"u")if(window.fetch)e=window.fetch.bind(window);else throw new Me("Fetch implementation was not available. You appear to be in a Node.js context, but global.fetch was not available.");else typeof self<"u"&&self.fetch&&(e=self.fetch.bind(self));if(e)return e;throw new Me("Fetch implementation was not available. Please provide fetch to the HttpAgent constructor, or ensure it is available in the window or global context.")}var fe=class{constructor(t={}){if(this.rootKey=Fn(Xo),this._pipeline=[],this._timeDiffMsecs=0,this._rootKeyFetched=!1,this._retryTimes=3,this._isAgent=!0,t.source){if(!(t.source instanceof fe))throw new Error("An Agent's source can only be another HttpAgent");this._pipeline=[...t.source._pipeline],this._identity=t.source._identity,this._fetch=t.source._fetch,this._host=t.source._host,this._credentials=t.source._credentials}else this._fetch=t.fetch||ra()||fetch.bind(window),this._fetchOptions=t.fetchOptions,this._callOptions=t.callOptions;if(t.host!==void 0)!t.host.match(/^[a-z]+:/)&&typeof window<"u"?this._host=new URL(window.location.protocol+"//"+t.host):this._host=new URL(t.host);else if(t.source!==void 0)this._host=t.source._host;else{let r=typeof window<"u"?window.location:void 0;if(!r)throw new Error("Must specify a host to connect to.");this._host=new URL(r+"")}if(t.retryTimes!==void 0&&(this._retryTimes=t.retryTimes),this._host.hostname.endsWith(Qo)?this._host.hostname=Zo:this._host.hostname.endsWith(Lo)?this._host.hostname=Do:this._host.hostname.endsWith(ea)&&(this._host.hostname=ta),t.credentials){let{name:r,password:i}=t.credentials;this._credentials=`${r}${i?":"+i:""}`}this._identity=Promise.resolve(t.identity||new ae),t.disableNonce||this.addTransform(ai(Ke))}isLocal(){let t=this._host.hostname;return t==="127.0.0.1"||t.endsWith("localhost")}addTransform(t,r=t.priority||0){let i=this._pipeline.findIndex(a=>(a.priority||0)<r);this._pipeline.splice(i>=0?i:this._pipeline.length,0,Object.assign(t,{priority:r}))}async getPrincipal(){if(!this._identity)throw new Ee("This identity has expired due this application's security policy. Please refresh your authentication.");return(await this._identity).getPrincipal()}async call(t,r,i){let a=await(i!==void 0?await i:await this._identity);if(!a)throw new Ee("This identity has expired due this application's security policy. Please refresh your authentication.");let u=ot.from(t),d=r.effectiveCanisterId?ot.from(r.effectiveCanisterId):u,m=a.getPrincipal()||ot.anonymous(),w=new se(pr);Math.abs(this._timeDiffMsecs)>1e3*30&&(w=new se(pr+this._timeDiffMsecs));let A={request_type:hr.Call,canister_id:u,method_name:r.methodName,arg:r.arg,sender:m,ingress_expiry:w},C=await this._transform({request:{body:null,method:"POST",headers:new Headers(Object.assign({"Content-Type":"application/cbor"},this._credentials?{Authorization:"Basic "+btoa(this._credentials)}:{}))},endpoint:"call",body:A});C=await a.transformRequest(C);let O=or(C.body),Q=this._requestAndRetry(()=>this._fetch(""+new URL(`/api/v2/canister/${d.toText()}/call`,this._host),Object.assign(Object.assign(Object.assign({},this._callOptions),C.request),{body:O}))),[st,it]=await Promise.all([Q,ne(A)]);return{requestId:it,response:{ok:st.ok,status:st.status,statusText:st.statusText}}}async _requestAndRetry(t,r=0){if(r>this._retryTimes&&this._retryTimes!==0)throw new Error(`AgentError: Exceeded configured limit of ${this._retryTimes} retry attempts. Please check your network connection or try again in a few moments`);let i=await t();if(!i.ok){let a=await i.clone().text(),u=`Server returned an error:
|
|
3
3
|
Code: ${i.status} (${i.statusText})
|
|
4
4
|
Body: ${a}
|
|
5
|
-
`;if(this._retryTimes>r)return console.warn(u+" Retrying request."),await this._requestAndRetry(t,r+1);throw new Error(u)}return i}async query(t,r,i){let a=await(i!==void 0?await i:await this._identity);if(!a)throw new Ee("This identity has expired due this application's security policy. Please refresh your authentication.");let u=typeof t=="string"?
|
|
5
|
+
`;if(this._retryTimes>r)return console.warn(u+" Retrying request."),await this._requestAndRetry(t,r+1);throw new Error(u)}return i}async query(t,r,i){let a=await(i!==void 0?await i:await this._identity);if(!a)throw new Ee("This identity has expired due this application's security policy. Please refresh your authentication.");let u=typeof t=="string"?ot.fromText(t):t,d=a?.getPrincipal()||ot.anonymous(),m={request_type:"query",canister_id:u,method_name:r.methodName,arg:r.arg,sender:d,ingress_expiry:new se(pr)},w=await this._transform({request:{method:"POST",headers:new Headers(Object.assign({"Content-Type":"application/cbor"},this._credentials?{Authorization:"Basic "+btoa(this._credentials)}:{}))},endpoint:"read",body:m});w=await a?.transformRequest(w);let A=or(w.body),C=await this._requestAndRetry(()=>this._fetch(""+new URL(`/api/v2/canister/${u.toText()}/query`,this._host),Object.assign(Object.assign(Object.assign({},this._fetchOptions),w.request),{body:A})));return ar(await C.arrayBuffer())}async createReadStateRequest(t,r){let i=await(r!==void 0?await r:await this._identity);if(!i)throw new Ee("This identity has expired due this application's security policy. Please refresh your authentication.");let a=i?.getPrincipal()||ot.anonymous(),u=await this._transform({request:{method:"POST",headers:new Headers(Object.assign({"Content-Type":"application/cbor"},this._credentials?{Authorization:"Basic "+btoa(this._credentials)}:{}))},endpoint:"read_state",body:{request_type:"read_state",paths:t.paths,sender:a,ingress_expiry:new se(pr)}});return i?.transformRequest(u)}async readState(t,r,i,a){let u=typeof t=="string"?ot.fromText(t):t,d=a??await this.createReadStateRequest(r,i),m=or(d.body),w=await this._fetch(""+new URL(`/api/v2/canister/${u}/read_state`,this._host),Object.assign(Object.assign(Object.assign({},this._fetchOptions),d.request),{body:m}));if(!w.ok)throw new Error(`Server returned an error:
|
|
6
6
|
Code: ${w.status} (${w.statusText})
|
|
7
7
|
Body: ${await w.text()}
|
|
8
|
-
`);return
|
|
9
|
-
Request ID: ${
|
|
8
|
+
`);return ar(await w.arrayBuffer())}async syncTime(t){let r=await import("./canisterStatus-CMO3J52U.js"),i=Date.now();try{t||console.log("Syncing time with the IC. No canisterId provided, so falling back to ryjl3-tyaaa-aaaaa-aaaba-cai");let u=(await r.request({canisterId:t??ot.from("ryjl3-tyaaa-aaaaa-aaaba-cai"),agent:this,paths:["time"]})).get("time");u&&(this._timeDiffMsecs=Number(u)-Number(i))}catch(a){console.error("Caught exception while attempting to sync time:",a)}}async status(){let t=this._credentials?{Authorization:"Basic "+btoa(this._credentials)}:{},r=await this._requestAndRetry(()=>this._fetch(""+new URL("/api/v2/status",this._host),Object.assign({headers:t},this._fetchOptions)));return ar(await r.arrayBuffer())}async fetchRootKey(){return this._rootKeyFetched||(this.rootKey=(await this.status()).root_key,this._rootKeyFetched=!0),this.rootKey}invalidateIdentity(){this._identity=null}replaceIdentity(t){this._identity=Promise.resolve(t)}_transform(t){let r=Promise.resolve(t);for(let i of this._pipeline)r=r.then(a=>i(a).then(u=>u||a));return r}};var si;(function(e){e.Error="err",e.GetPrincipal="gp",e.GetPrincipalResponse="gpr",e.Query="q",e.QueryResponse="qr",e.Call="c",e.CallResponse="cr",e.ReadState="rs",e.ReadStateResponse="rsr",e.Status="s",e.StatusResponse="sr"})(si||(si={}));function Jr(){let e=typeof window>"u"&&typeof window>"u"?typeof self>"u"?void 0:self.ic.agent:window.ic.agent;if(!e)throw new Error("No Agent could be found.");return e}var xr={};Nn(xr,{backoff:()=>di,chain:()=>hi,conditionalDelay:()=>ui,defaultStrategy:()=>fi,maxAttempts:()=>ia,once:()=>ci,throttle:()=>oa,timeout:()=>li});var na=5*60*1e3;function fi(){return hi(ui(ci(),1e3),di(1e3,1.2),li(na))}function ci(){let e=!0;return async()=>e?(e=!1,!0):!1}function ui(e,t){return async(r,i,a)=>{if(await e(r,i,a))return new Promise(u=>setTimeout(u,t))}}function ia(e){let t=e;return async(r,i,a)=>{if(--t<=0)throw new Error(`Failed to retrieve a reply for request after ${e} attempts:
|
|
9
|
+
Request ID: ${Gt(i)}
|
|
10
10
|
Request status: ${a}
|
|
11
|
-
`)}}function
|
|
12
|
-
Request ID: ${
|
|
11
|
+
`)}}function oa(e){return()=>new Promise(t=>setTimeout(t,e))}function li(e){let t=Date.now()+e;return async(r,i,a)=>{if(Date.now()>t)throw new Error(`Request timed out after ${e} msec:
|
|
12
|
+
Request ID: ${Gt(i)}
|
|
13
13
|
Request status: ${a}
|
|
14
|
-
`)}}function
|
|
15
|
-
Request ID: ${
|
|
16
|
-
Reject code: ${
|
|
14
|
+
`)}}function di(e,t){let r=e;return()=>new Promise(i=>setTimeout(()=>{r*=t,i()},r))}function hi(...e){return async(t,r,i)=>{for(let a of e)await a(t,r,i)}}async function Xr(e,t,r,i,a,u){var d;let m=[new TextEncoder().encode("request_status"),r],w=a??await((d=e.createReadStateRequest)===null||d===void 0?void 0:d.call(e,{paths:[m]})),A=await e.readState(t,{paths:[m]},void 0,w);if(e.rootKey==null)throw new Error("Agent root key not initialized before polling");let C=await jn.create({certificate:A.certificate,rootKey:e.rootKey,canisterId:t,blsVerify:u}),O=C.lookup([...m,new TextEncoder().encode("status")]),Q;switch(typeof O>"u"?Q=Kt.Unknown:Q=new TextDecoder().decode(O),Q){case Kt.Replied:return C.lookup([...m,"reply"]);case Kt.Received:case Kt.Unknown:case Kt.Processing:return await i(t,r,Q),Xr(e,t,r,i,w);case Kt.Rejected:{let st=new Uint8Array(C.lookup([...m,"reject_code"]))[0],it=new TextDecoder().decode(C.lookup([...m,"reject_message"]));throw new Error(`Call was rejected:
|
|
15
|
+
Request ID: ${Gt(r)}
|
|
16
|
+
Reject code: ${st}
|
|
17
17
|
Reject text: ${it}
|
|
18
|
-
`)}case
|
|
19
|
-
Request ID: ${
|
|
20
|
-
`)}throw new Error("unreachable")}var
|
|
21
|
-
`)),this.canisterId=t,this.methodName=r,this.type=i,this.props=a}},
|
|
22
|
-
ic-request`);function Lr(e){if(typeof e!="string"||e.length<64)throw new Error("Invalid public key.");return Ae(e)}var Se=class{constructor(t,r,i){this.pubkey=t,this.expiration=r,this.targets=i}toCBOR(){return Te.value.map(Object.assign({pubkey:Te.value.bytes(this.pubkey),expiration:Te.value.u64(this.expiration.toString(16),16)},this.targets&&{targets:Te.value.array(this.targets.map(t=>Te.value.bytes(t.toUint8Array())))}))}toJSON(){return Object.assign({expiration:this.expiration.toString(16),pubkey:Jt(this.pubkey)},this.targets&&{targets:this.targets.map(t=>t.toHex())})}};async function da(e,t,r,i){let a=new Se(t.toDer(),BigInt(+r)*BigInt(1e6),i),u=new Uint8Array([...ua,...new Uint8Array(ee(a))]),d=await e.sign(u);return{delegation:a,signature:d}}var ce=class{constructor(t,r){this.delegations=t,this.publicKey=r}static async create(t,r,i=new Date(Date.now()+15*60*1e3),a={}){var u,d;let m=await da(t,r,i,a.targets);return new ce([...((u=a.previous)===null||u===void 0?void 0:u.delegations)||[],m],((d=a.previous)===null||d===void 0?void 0:d.publicKey)||t.getPublicKey().toDer())}static fromJSON(t){let{publicKey:r,delegations:i}=typeof t=="string"?JSON.parse(t):t;if(!Array.isArray(i))throw new Error("Invalid delegations.");let a=i.map(u=>{let{delegation:d,signature:m}=u,{pubkey:w,expiration:T,targets:j}=d;if(j!==void 0&&!Array.isArray(j))throw new Error("Invalid targets.");return{delegation:new Se(Lr(w),BigInt(`0x${T}`),j&&j.map(O=>{if(typeof O!="string")throw new Error("Invalid target.");return st.fromHex(O)})),signature:Lr(m)}});return new this(a,Lr(r))}static fromDelegations(t,r){return new this(t,r)}toJSON(){return{delegations:this.delegations.map(t=>{let{delegation:r,signature:i}=t,{targets:a}=r;return{delegation:Object.assign({expiration:r.expiration.toString(16),pubkey:Jt(r.pubkey)},a&&{targets:a.map(u=>u.toHex())}),signature:Jt(i)}}),publicKey:Jt(this.publicKey)}}},qe=class extends zt{constructor(t,r){super(),this._inner=t,this._delegation=r}static fromDelegation(t,r){return new this(t,r)}getDelegation(){return this._delegation}getPublicKey(){return{toDer:()=>this._delegation.publicKey}}sign(t){return this._inner.sign(t)}async transformRequest(t){let{body:r}=t,i=ca(t,["body"]),a=await ee(r);return Object.assign(Object.assign({},i),{body:{content:r,sender_sig:await this.sign(new Uint8Array([...la,...new Uint8Array(a)])),sender_delegation:this._delegation.delegations,sender_pubkey:this._delegation.publicKey}})}};function vi(e,t){for(let{delegation:a}of e.delegations)if(+new Date(Number(a.expiration/BigInt(1e6)))<=+Date.now())return!1;let r=[],i=t?.scope;i&&(Array.isArray(i)?r.push(...i.map(a=>typeof a=="string"?st.fromText(a):a)):r.push(typeof i=="string"?st.fromText(i):i));for(let a of r){let u=a.toText();for(let{delegation:d}of e.delegations){if(d.targets===void 0)continue;let m=!0;for(let w of d.targets)if(w.toText()===u){m=!1;break}if(m)return!1}}return!0}var ha=me(co()),pa=me(Zr());var Ei;(function(e){e[e.ECDSA_WITH_SHA256=-7]="ECDSA_WITH_SHA256"})(Ei||(Ei={}));var Ai=["mousedown","mousemove","keydown","touchstart","wheel"],He=class{constructor(t={}){var r;this.callbacks=[],this.idleTimeout=10*60*1e3,this.timeoutID=void 0;let{onIdle:i,idleTimeout:a=10*60*1e3}=t||{};this.callbacks=i?[i]:[],this.idleTimeout=a;let u=this._resetTimer.bind(this);window.addEventListener("load",u,!0),Ai.forEach(function(m){document.addEventListener(m,u,!0)});let d=(m,w)=>{let T;return(...j)=>{let O=this,Q=function(){T=void 0,m.apply(O,j)};clearTimeout(T),T=window.setTimeout(Q,w)}};if(t?.captureScroll){let m=d(u,(r=t?.scrollDebounce)!==null&&r!==void 0?r:100);window.addEventListener("scroll",m,!0)}u()}static create(t={}){return new this(t)}registerCallback(t){this.callbacks.push(t)}exit(){clearTimeout(this.timeoutID),window.removeEventListener("load",this._resetTimer,!0);let t=this._resetTimer.bind(this);Ai.forEach(function(r){document.removeEventListener(r,t,!0)}),this.callbacks.forEach(r=>r())}_resetTimer(){let t=this.exit.bind(this);window.clearTimeout(this.timeoutID),this.timeoutID=window.setTimeout(t,this.idleTimeout)}};var xa=(e,t)=>t.some(r=>e instanceof r),Ti,Si;function ya(){return Ti||(Ti=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function ma(){return Si||(Si=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var Oi=new WeakMap,en=new WeakMap,Ui=new WeakMap,tn=new WeakMap,nn=new WeakMap;function wa(e){let t=new Promise((r,i)=>{let a=()=>{e.removeEventListener("success",u),e.removeEventListener("error",d)},u=()=>{r(kt(e.result)),a()},d=()=>{i(e.error),a()};e.addEventListener("success",u),e.addEventListener("error",d)});return t.then(r=>{r instanceof IDBCursor&&Oi.set(r,e)}).catch(()=>{}),nn.set(t,e),t}function ga(e){if(en.has(e))return;let t=new Promise((r,i)=>{let a=()=>{e.removeEventListener("complete",u),e.removeEventListener("error",d),e.removeEventListener("abort",d)},u=()=>{r(),a()},d=()=>{i(e.error||new DOMException("AbortError","AbortError")),a()};e.addEventListener("complete",u),e.addEventListener("error",d),e.addEventListener("abort",d)});en.set(e,t)}var rn={get(e,t,r){if(e instanceof IDBTransaction){if(t==="done")return en.get(e);if(t==="objectStoreNames")return e.objectStoreNames||Ui.get(e);if(t==="store")return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return kt(e[t])},set(e,t,r){return e[t]=r,!0},has(e,t){return e instanceof IDBTransaction&&(t==="done"||t==="store")?!0:t in e}};function Bi(e){rn=e(rn)}function _a(e){return e===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(t,...r){let i=e.call(wr(this),t,...r);return Ui.set(i,t.sort?t.sort():[t]),kt(i)}:ma().includes(e)?function(...t){return e.apply(wr(this),t),kt(Oi.get(this))}:function(...t){return kt(e.apply(wr(this),t))}}function ba(e){return typeof e=="function"?_a(e):(e instanceof IDBTransaction&&ga(e),xa(e,ya())?new Proxy(e,rn):e)}function kt(e){if(e instanceof IDBRequest)return wa(e);if(tn.has(e))return tn.get(e);let t=ba(e);return t!==e&&(tn.set(e,t),nn.set(t,e)),t}var wr=e=>nn.get(e);function Ni(e,t,{blocked:r,upgrade:i,blocking:a,terminated:u}={}){let d=indexedDB.open(e,t),m=kt(d);return i&&d.addEventListener("upgradeneeded",w=>{i(kt(d.result),w.oldVersion,w.newVersion,kt(d.transaction),w)}),r&&d.addEventListener("blocked",w=>r(w.oldVersion,w.newVersion,w)),m.then(w=>{u&&w.addEventListener("close",()=>u()),a&&w.addEventListener("versionchange",T=>a(T.oldVersion,T.newVersion,T))}).catch(()=>{}),m}var va=["get","getKey","getAll","getAllKeys","count"],Ea=["put","add","delete","clear"],on=new Map;function Ri(e,t){if(!(e instanceof IDBDatabase&&!(t in e)&&typeof t=="string"))return;if(on.get(t))return on.get(t);let r=t.replace(/FromIndex$/,""),i=t!==r,a=Ea.includes(r);if(!(r in(i?IDBIndex:IDBObjectStore).prototype)||!(a||va.includes(r)))return;let u=async function(d,...m){let w=this.transaction(d,a?"readwrite":"readonly"),T=w.store;return i&&(T=T.index(m.shift())),(await Promise.all([T[r](...m),a&&w.done]))[0]};return on.set(t,u),u}Bi(e=>({...e,get:(t,r,i)=>Ri(t,r)||e.get(t,r,i),has:(t,r)=>!!Ri(t,r)||e.has(t,r)}));var Ci="auth-client-db",Fi="ic-keyval",Aa=async(e=Ci,t=Fi,r)=>(gr&&(localStorage!=null&&localStorage.getItem(Bt))&&(localStorage.removeItem(Bt),localStorage.removeItem(Rt)),await Ni(e,r,{upgrade:i=>{i.objectStoreNames,i.objectStoreNames.contains(t)&&i.clear(t),i.createObjectStore(t)}}));async function Ta(e,t,r){return await e.get(t,r)}async function Sa(e,t,r,i){return await e.put(t,i,r)}async function Oa(e,t,r){return await e.delete(t,r)}var ue=class{constructor(t,r){this._db=t,this._storeName=r}static async create(t){let{dbName:r=Ci,storeName:i=Fi,version:a=1}=t??{},u=await Aa(r,i,a);return new ue(u,i)}async set(t,r){return await Sa(this._db,this._storeName,t,r)}async get(t){var r;return(r=await Ta(this._db,this._storeName,t))!==null&&r!==void 0?r:null}async remove(t){return await Oa(this._db,this._storeName,t)}};var Rt="identity",Bt="delegation",Pi="iv",Ua=1,gr=typeof window<"u",Ie=class{constructor(t="ic-",r){this.prefix=t,this._localStorage=r}get(t){return Promise.resolve(this._getLocalStorage().getItem(this.prefix+t))}set(t,r){return this._getLocalStorage().setItem(this.prefix+t,r),Promise.resolve()}remove(t){return this._getLocalStorage().removeItem(this.prefix+t),Promise.resolve()}_getLocalStorage(){if(this._localStorage)return this._localStorage;let t=typeof window>"u"&&typeof window>"u"?typeof self>"u"?void 0:self.localStorage:window.localStorage;if(!t)throw new Error("Could not find local storage.");return t}},$e=class{get _db(){return new Promise(t=>{if(this.initializedDb){t(this.initializedDb);return}ue.create({version:Ua}).then(r=>{this.initializedDb=r,t(r)})})}async get(t){return await(await this._db).get(t)}async set(t,r){await(await this._db).set(t,r)}async remove(t){await(await this._db).remove(t)}};var Ba="https://identity.ic0.app",Ra="#authorize",an="ECDSA",sn="Ed25519",Na=500,Ca="UserInterrupt",_r=class{constructor(t,r,i,a,u,d,m,w){var T;this._identity=t,this._key=r,this._chain=i,this._storage=a,this.idleManager=u,this._createOptions=d,this._idpWindow=m,this._eventHandler=w;let j=this.logout.bind(this),O=d?.idleOptions;!O?.onIdle&&!O?.disableDefaultIdleCallback&&((T=this.idleManager)===null||T===void 0||T.registerCallback(()=>{j(),location.reload()}))}static async create(t={}){var r,i,a;let u=(r=t.storage)!==null&&r!==void 0?r:new $e,d=(i=t.keyType)!==null&&i!==void 0?i:an,m=null;if(t.identity)m=t.identity;else{let O=await u.get(Rt);if(!O&&gr)try{let Q=new Ie,at=await Q.get(Bt),it=await Q.get(Rt);at&&it&&d===an&&(console.log("Discovered an identity stored in localstorage. Migrating to IndexedDB"),await u.set(Bt,at),await u.set(Rt,it),O=at,await Q.remove(Bt),await Q.remove(Rt))}catch(Q){console.error("error while attempting to recover localstorage: "+Q)}if(O)try{typeof O=="object"?d===sn&&typeof O=="string"?m=await Ut.fromJSON(O):m=await fe.fromKeyPair(O):typeof O=="string"&&(m=Ut.fromJSON(O))}catch{}}let w=new ie,T=null;if(m)try{let O=await u.get(Bt);if(typeof O=="object"&&O!==null)throw new Error("Delegation chain is incorrectly stored. A delegation chain should be stored as a string.");t.identity?w=t.identity:O&&(T=ce.fromJSON(O),vi(T)?w=qe.fromDelegation(m,T):(await fn(u),m=null))}catch(O){console.error(O),await fn(u),m=null}let j;return!((a=t.idleOptions)===null||a===void 0)&&a.disableIdle?j=void 0:(T||t.identity)&&(j=He.create(t.idleOptions)),m||(d===sn?(m=await Ut.generate(),await u.set(Rt,JSON.stringify(m.toJSON()))):(t.storage&&d===an&&console.warn(`You are using a custom storage provider that may not support CryptoKey storage. If you are using a custom storage provider that does not support CryptoKey storage, you should use '${sn}' as the key type, as it can serialize to a string`),m=await fe.generate(),await u.set(Rt,m.getKeyPair()))),new this(w,m,T,u,j,t)}_handleSuccess(t,r){var i,a,u;let d=t.delegations.map(T=>({delegation:new Se(T.delegation.pubkey,T.delegation.expiration,T.delegation.targets),signature:T.signature.buffer})),m=ce.fromDelegations(d,t.userPublicKey.buffer),w=this._key;if(w){if(this._chain=m,this._identity=qe.fromDelegation(w,this._chain),(i=this._idpWindow)===null||i===void 0||i.close(),!this.idleManager){let T=(a=this._createOptions)===null||a===void 0?void 0:a.idleOptions;this.idleManager=He.create(T),!T?.onIdle&&!T?.disableDefaultIdleCallback&&((u=this.idleManager)===null||u===void 0||u.registerCallback(()=>{this.logout(),location.reload()}))}r?.(),this._removeEventListener(),delete this._idpWindow}}getIdentity(){return this._identity}async isAuthenticated(){return!this.getIdentity().getPrincipal().isAnonymous()&&this._chain!==null}async login(t){var r,i,a,u;let d=BigInt(8)*BigInt(36e11),m=new URL(((r=t?.identityProvider)===null||r===void 0?void 0:r.toString())||Ba);m.hash=Ra,(i=this._idpWindow)===null||i===void 0||i.close(),this._removeEventListener(),this._eventHandler=this._getEventHandler(m,Object.assign({maxTimeToLive:(a=t?.maxTimeToLive)!==null&&a!==void 0?a:d},t)),window.addEventListener("message",this._eventHandler),this._idpWindow=(u=window.open(m.toString(),"idpWindow",t?.windowOpenerFeatures))!==null&&u!==void 0?u:void 0;let w=()=>{this._idpWindow&&(this._idpWindow.closed?this._handleFailure(Ca,t?.onError):setTimeout(w,Na))};w()}_getEventHandler(t,r){return async i=>{var a,u,d;if(i.origin!==t.origin){console.warn(`WARNING: expected origin '${t.origin}', got '${i.origin}' (ignoring)`);return}let m=i.data;switch(m.kind){case"authorize-ready":{let w={kind:"authorize-client",sessionPublicKey:new Uint8Array((a=this._key)===null||a===void 0?void 0:a.getPublicKey().toDer()),maxTimeToLive:r?.maxTimeToLive,derivationOrigin:(u=r?.derivationOrigin)===null||u===void 0?void 0:u.toString()};(d=this._idpWindow)===null||d===void 0||d.postMessage(w,t.origin);break}case"authorize-client-success":try{this._handleSuccess(m,r?.onSuccess),this._chain&&await this._storage.set(Bt,JSON.stringify(this._chain.toJSON()))}catch(w){this._handleFailure(w.message,r?.onError)}break;case"authorize-client-failure":this._handleFailure(m.text,r?.onError);break;default:break}}}_handleFailure(t,r){var i;(i=this._idpWindow)===null||i===void 0||i.close(),r?.(t),this._removeEventListener(),delete this._idpWindow}_removeEventListener(){this._eventHandler&&window.removeEventListener("message",this._eventHandler),this._eventHandler=void 0}async logout(t={}){if(await fn(this._storage),this._identity=new ie,this._chain=null,t.returnTo)try{window.history.pushState({},"",t.returnTo)}catch{window.location.href=t.returnTo}}};async function fn(e){await e.remove(Rt),await e.remove(Bt),await e.remove(Pi)}var cn=()=>_r.create({idleOptions:{disableIdle:!0,disableDefaultIdleCallback:!0}});var br=()=>typeof window<"u",un=()=>{let e=mt.getInstance().get()?.satelliteId??"unknown";return mt.getInstance().localIdentity()?`http://${e}.localhost:8000`:`https://${e}.ic0.app`};var ki=({width:e,height:t})=>{if(!br()||$t(window)||$t(window.top))return;let{top:{innerWidth:r,innerHeight:i}}=window,a=i/2+screenY-t/2,u=r/2+screenX-e/2;return`toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=${e}, height=${t}, top=${a}, left=${u}`};var gt=e=>e?[e]:[],vr=e=>e?.[0],ji=async e=>{let t=new Blob([JSON.stringify(e)],{type:"application/json; charset=utf-8"});return new Uint8Array(await t.arrayBuffer())},ln=async e=>{let t=new Blob([e instanceof Uint8Array?e:new Uint8Array(e)],{type:"application/json; charset=utf-8"});return JSON.parse(await t.text())};var Er=({matcher:e,paginate:t,order:r})=>({matcher:gt(e),paginate:gt($t(t)?void 0:{start_after:gt(t.startAfter),limit:gt($t(t.limit)?void 0:BigInt(t.limit))}),order:gt($t(r)?void 0:{desc:r.desc,field:r.field==="created_at"?{CreatedAt:null}:r.field==="updated_at"?{UpdatedAt:null}:{Keys:null}})});var Ki=({IDL:e})=>{let t=e.Record({controllers:e.Vec(e.Principal)}),r=e.Record({batch_id:e.Nat,headers:e.Vec(e.Tuple(e.Text,e.Text)),chunk_ids:e.Vec(e.Nat)}),i=e.Record({updated_at:e.Opt(e.Nat64)}),a=e.Record({headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text))))}),u=e.Record({storage:a}),d=e.Record({updated_at:e.Nat64,owner:e.Principal,data:e.Vec(e.Nat8),created_at:e.Nat64}),m=e.Record({url:e.Text,method:e.Text,body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text))}),w=e.Record({token:e.Opt(e.Text),sha256:e.Opt(e.Vec(e.Nat8)),headers:e.Vec(e.Tuple(e.Text,e.Text)),index:e.Nat64,encoding_type:e.Text,full_path:e.Text}),T=e.Variant({Callback:e.Record({token:w,callback:e.Func([],[],[])})}),j=e.Record({body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),streaming_strategy:e.Opt(T),status_code:e.Nat16}),O=e.Record({token:e.Opt(w),body:e.Vec(e.Nat8)}),Q=e.Record({token:e.Opt(e.Text),collection:e.Text,name:e.Text,encoding_type:e.Opt(e.Text),full_path:e.Text}),at=e.Record({batch_id:e.Nat}),it=e.Variant({UpdatedAt:e.Null,Keys:e.Null,CreatedAt:e.Null}),bt=e.Record({field:it,desc:e.Bool}),Mt=e.Record({start_after:e.Opt(e.Text),limit:e.Opt(e.Nat64)}),Dt=e.Record({order:e.Opt(bt),matcher:e.Opt(e.Text),paginate:e.Opt(Mt)}),le=e.Record({token:e.Opt(e.Text),collection:e.Text,owner:e.Principal,name:e.Text,full_path:e.Text}),Zt=e.Record({modified:e.Nat64,sha256:e.Vec(e.Nat8),total_length:e.Nat}),Yt=e.Record({key:le,updated_at:e.Nat64,encodings:e.Vec(e.Tuple(e.Text,Zt)),headers:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64}),Vt=e.Record({matches_length:e.Nat64,length:e.Nat64,items:e.Vec(e.Tuple(e.Text,Yt))}),We=e.Record({updated_at:e.Nat64,created_at:e.Nat64,bn_id:e.Opt(e.Text)}),ze=e.Record({matches_length:e.Nat64,length:e.Nat64,items:e.Vec(e.Tuple(e.Text,d))}),Oe=e.Variant({Db:e.Null,Storage:e.Null}),Qt=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),de=e.Record({updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:Qt,created_at:e.Nat64,write:Qt}),Ue=e.Record({updated_at:e.Opt(e.Nat64),data:e.Vec(e.Nat8)}),Ge=e.Record({updated_at:e.Opt(e.Nat64),max_size:e.Opt(e.Nat),read:Qt,write:Qt}),Be=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat}),Re=e.Record({chunk_id:e.Nat});return e.Service({add_controllers:e.Func([t],[e.Vec(e.Principal)],[]),commit_asset_upload:e.Func([r],[],[]),del_asset:e.Func([e.Text,e.Text],[],[]),del_assets:e.Func([e.Opt(e.Text)],[],[]),del_custom_domain:e.Func([e.Text],[],[]),del_doc:e.Func([e.Text,e.Text,i],[],[]),get_config:e.Func([],[u],[]),get_doc:e.Func([e.Text,e.Text],[e.Opt(d)],["query"]),http_request:e.Func([m],[j],["query"]),http_request_streaming_callback:e.Func([w],[O],["query"]),init_asset_upload:e.Func([Q],[at],[]),list_assets:e.Func([e.Opt(e.Text),Dt],[Vt],["query"]),list_controllers:e.Func([],[e.Vec(e.Principal)],["query"]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,We))],["query"]),list_docs:e.Func([e.Text,Dt],[ze],["query"]),list_rules:e.Func([Oe],[e.Vec(e.Tuple(e.Text,de))],["query"]),remove_controllers:e.Func([t],[e.Vec(e.Principal)],[]),set_config:e.Func([u],[],[]),set_custom_domain:e.Func([e.Text,e.Opt(e.Text)],[],[]),set_doc:e.Func([e.Text,e.Text,Ue],[d],[]),set_rule:e.Func([Oe,e.Text,Ge],[],[]),upload_asset_chunk:e.Func([Be],[Re],[]),version:e.Func([],[e.Text],["query"])})};var Mi=async({satelliteId:e,idlFactory:t,identity:r,fetch:i,env:a="prod"})=>{let u=a==="dev"||mt.getInstance().localIdentity(),d=u?"http://127.0.0.1:8000/":"https://ic0.app",m=new ae({identity:r,...d&&{host:d},...i&&{fetch:i}});return u&&await m.fetchRootKey(),Gt.createActor(t,{agent:m,canisterId:e})};var jt=async({satelliteId:e,...t})=>{let{satelliteId:r}=e!==void 0?{satelliteId:e}:mt.getInstance().get()??{satelliteId:void 0};if(!r)throw new Error("No satellite principal defined.");return Mi({satelliteId:r,idlFactory:Ki,...t})};var Yi=async({collection:e,key:t,satellite:r})=>{let i=await jt(r),a=vr(await i.get_doc(e,t));if(!a)return;let u=await ln(a.data);return{key:t,data:u,created_at:a.created_at,updated_at:a.updated_at}},Vi=async({collection:e,doc:t,satellite:r})=>{let i=await jt(r),{key:a,data:u,updated_at:d}=t,m=await i.set_doc(e,a,{data:await ji(u),updated_at:gt(d)});return{key:a,data:u,created_at:m.created_at,updated_at:m.updated_at}},qi=async({collection:e,doc:t,satellite:r})=>{let i=await jt(r),{key:a,updated_at:u}=t;return i.del_doc(e,a,{updated_at:gt(u)})},Hi=async({collection:e,filter:t,satellite:r})=>{let i=await jt(r),{items:a,matches_length:u,length:d}=await i.list_docs(e,Er(t)),m=[];for(let[w,T]of a)m.push({key:w,data:await ln(T.data),created_at:T.created_at,updated_at:T.updated_at});return{items:m,length:d,matches_length:u}};var Kt=e=>{if(e!==void 0)return e;let t=Ar();if(!t)throw new Error("No internet identity.");return t};var Ii=async({satellite:e,...t})=>{let r=Kt(e?.identity);return Yi({...t,satellite:{...e,identity:r}})},$i=async({satellite:e,...t})=>{let r=Kt(e?.identity);return Vi({...t,satellite:{...e,identity:r}})},_c=async({satellite:e,...t})=>{let r=Kt(e?.identity);return qi({...t,satellite:{...e,identity:r}})},bc=async({satellite:e,...t})=>{let r=Kt(e?.identity);return Hi({...t,satellite:{...e,identity:r}})};var Wi=async()=>{let e=Ar();if(!e)throw new Error("No internet identity.");let t=e.getPrincipal().toText(),r=await Ii({collection:"#user",key:t});return r||await Fa({userId:t,principal:e.getPrincipal()})},Fa=async({userId:e,principal:t})=>{let r=new Date;return $i({collection:"#user",doc:{key:e,data:{principal:t,created_at:r,updated_at:r}}})};var Xt,dn=async()=>{if(Xt=Xt??await cn(),!(await Xt?.isAuthenticated()||!1))return;let t=await Wi();Nt.getInstance().set(t)},Pa=async e=>new Promise(async(t,r)=>{Xt=Xt??await cn(),await Xt.login({onSuccess:async()=>{await dn(),t()},onError:i=>r(i),maxTimeToLive:e?.maxTimeToLive??jn,...mt.getInstance().localIdentity()&&{identityProvider:`http://${mt.getInstance().get()?.localIdentityCanisterId}.localhost:8000?#authorize`},...e?.derivationOrigin!==void 0&&{derivationOrigin:e.derivationOrigin},...e?.windowed!==!1&&{windowOpenerFeatures:ki({width:Kn,height:Mn})}})}),hn=async()=>{await Xt?.logout(),Xt=void 0,Nt.getInstance().reset()},Ar=()=>Xt?.getIdentity();var zi=e=>{let t=e===!0?"./workers/auth.worker.js":e,r=new Worker(t),i=async()=>{kn({message:"junoSignOutAuthTimer"}),await hn()};return r.onmessage=async({data:a})=>{let{msg:u}=a;switch(u){case"junoSignOutAuthTimer":await i();return}},Nt.getInstance().subscribe(a=>{if($t(a)){r.postMessage({msg:"junoStopAuthTimer"});return}r.postMessage({msg:"junoStartAuthTimer"})})};var Gi=async({data:e,filename:t,collection:r,headers:i,token:a,fullPath:u,encoding:d,satellite:m})=>{let w=await jt(m),{batch_id:T}=await w.init_asset_upload({collection:r,full_path:u,name:t,token:gt(a),encoding_type:gt(d)}),j=7e5,O=[],Q=br()?new Blob([await e.arrayBuffer()]):e;for(let it=0;it<Q.size;it+=j){let bt=Q.slice(it,it+j);O.push(await ka({batchId:T,chunk:bt,actor:w}))}let at=i.find(([it,bt])=>it.toLowerCase()==="content-type")===void 0&&e.type!==void 0&&e.type!==""?[["Content-Type",e.type]]:void 0;await w.commit_asset_upload({batch_id:T,chunk_ids:O.map(({chunk_id:it})=>it),headers:[...i,...at||[]]})},ka=async({batchId:e,chunk:t,actor:r})=>r.upload_asset_chunk({batch_id:e,content:new Uint8Array(await t.arrayBuffer())}),Ji=async({collection:e,satellite:t,filter:r})=>{let i=await jt(t),{items:a,matches_length:u,length:d}=await i.list_assets(gt(e),Er(r));return{items:a.map(([m,w])=>w),length:d,matches_length:u}},Xi=async({collection:e,storageFile:t,satellite:r})=>{let i=await jt(r),{fullPath:a}=t;return i.del_asset(e,a)},Zi=async({collection:e,satellite:t})=>(await jt(t)).del_assets(gt(e));var Qi=e=>btoa([...e].map(t=>String.fromCharCode(t)).join(""));var pn=e=>encodeURI(e.toLowerCase().replace(/\s/g,"-"));var Qc=async e=>Di(e),Dc=async e=>Di({filename:e.data.name,...e}),Di=async({filename:e,data:t,collection:r,headers:i=[],fullPath:a,token:u,satellite:d,encoding:m})=>{let w=Kt(d?.identity),T=pn(e),j=a||`/${r}/${T}`;return await Gi({data:t,filename:pn(T),collection:r,token:u,headers:i,fullPath:j,encoding:m,satellite:{...d,identity:w}}),{downloadUrl:`${un()}${j}${u!==void 0?`?token=${u}`:""}`,fullPath:j,name:T}},Lc=async({collection:e,satellite:t,filter:r})=>{let{items:i,...a}=await Ji({collection:e,satellite:{...t,identity:Kt(t?.identity)},filter:r??{}}),u=un();return{assets:i.map(({key:{full_path:d,token:m,name:w},headers:T,encodings:j})=>{let O=vr(m);return{fullPath:d,name:w,downloadUrl:`${u}${d}${O!==void 0?`?token=${O}`:""}`,token:O,headers:T,encodings:j.reduce((Q,[at,{modified:it,sha256:bt,total_length:Mt}])=>({...Q,[at]:{modified:it,sha256:Qi(bt),total_length:Mt}}),{})}}),...a}},t0=async({storageFile:e,collection:t,satellite:r})=>Xi({collection:t,storageFile:e,satellite:{...r,identity:Kt(r?.identity)}}),e0=async({collection:e,satellite:t})=>Zi({collection:e,satellite:{...t,identity:Kt(t?.identity)}});var s0=async e=>{mt.getInstance().set(e),await dn();let t=e.workers?.auth!==void 0?zi(e.workers.auth):void 0;return[...t?[t]:[]]},f0=e=>Nt.getInstance().subscribe(e);export{f0 as authSubscribe,_c as delDoc,t0 as deleteAsset,e0 as deleteAssets,Ii as getDoc,s0 as initJuno,Lc as listAssets,bc as listDocs,$i as setDoc,Pa as signIn,hn as signOut,Qc as uploadBlob,Dc as uploadFile};
|
|
18
|
+
`)}case Kt.Done:throw new Error(`Call was marked as done but we never saw the reply:
|
|
19
|
+
Request ID: ${Gt(r)}
|
|
20
|
+
`)}throw new Error("unreachable")}var pi=({IDL:e})=>{let t=e.Principal,r=e.Record({controllers:e.Vec(e.Principal),freezing_threshold:e.Nat,memory_allocation:e.Nat,compute_allocation:e.Nat}),i=e.Record({controllers:e.Opt(e.Vec(e.Principal)),freezing_threshold:e.Opt(e.Nat),memory_allocation:e.Opt(e.Nat),compute_allocation:e.Opt(e.Nat)}),a=e.Vec(e.Nat8);return e.Service({canister_status:e.Func([e.Record({canister_id:t})],[e.Record({status:e.Variant({stopped:e.Null,stopping:e.Null,running:e.Null}),memory_size:e.Nat,cycles:e.Nat,settings:r,module_hash:e.Opt(e.Vec(e.Nat8))})],[]),create_canister:e.Func([e.Record({settings:e.Opt(i)})],[e.Record({canister_id:t})],[]),delete_canister:e.Func([e.Record({canister_id:t})],[],[]),deposit_cycles:e.Func([e.Record({canister_id:t})],[],[]),install_code:e.Func([e.Record({arg:e.Vec(e.Nat8),wasm_module:a,mode:e.Variant({reinstall:e.Null,upgrade:e.Null,install:e.Null}),canister_id:t})],[],[]),provisional_create_canister_with_cycles:e.Func([e.Record({settings:e.Opt(i),amount:e.Opt(e.Nat)})],[e.Record({canister_id:t})],[]),provisional_top_up_canister:e.Func([e.Record({canister_id:t,amount:e.Nat})],[],[]),raw_rand:e.Func([],[e.Vec(e.Nat8)],[]),start_canister:e.Func([e.Record({canister_id:t})],[],[]),stop_canister:e.Func([e.Record({canister_id:t})],[],[]),uninstall_code:e.Func([e.Record({canister_id:t})],[],[]),update_settings:e.Func([e.Record({canister_id:e.Principal,settings:i})],[],[])})};var yr=class extends ke{constructor(t,r,i,a){super(["Call failed:",` Canister: ${t.toText()}`,` Method: ${r} (${i})`,...Object.getOwnPropertyNames(a).map(u=>` "${u}": ${JSON.stringify(a[u])}`)].join(`
|
|
21
|
+
`)),this.canisterId=t,this.methodName=r,this.type=i,this.props=a}},Zr=class extends yr{constructor(t,r,i){var a;super(t,r,"query",{Status:i.status,Code:(a=dr[i.reject_code])!==null&&a!==void 0?a:`Unknown Code "${i.reject_code}"`,Message:i.reject_message}),this.result=i}},Qr=class extends yr{constructor(t,r,i,a){super(t,r,"update",{"Request ID":Gt(i),"HTTP status code":a.status.toString(),"HTTP status text":a.statusText}),this.requestId=i,this.response=a}},Dr;(function(e){e.Install="install",e.Reinstall="reinstall",e.Upgrade="upgrade"})(Dr||(Dr={}));var Tt=Symbol.for("ic-agent-metadata"),Zt=class{constructor(t){this[Tt]=Object.freeze(t)}static agentOf(t){return t[Tt].config.agent}static interfaceOf(t){return t[Tt].service}static canisterIdOf(t){return ot.from(t[Tt].config.canisterId)}static async install(t,r){let i=t.mode===void 0?Dr.Install:t.mode,a=t.arg?[...new Uint8Array(t.arg)]:[],u=[...new Uint8Array(t.module)],d=typeof r.canisterId=="string"?ot.fromText(r.canisterId):r.canisterId;await yi(r).install_code({mode:{[i]:null},arg:a,wasm_module:u,canister_id:d})}static async createCanister(t){let{canister_id:r}=await yi(t||{}).provisional_create_canister_with_cycles({amount:[],settings:[]});return r}static async createAndInstallCanister(t,r,i){let a=await this.createCanister(i);return await this.install(Object.assign({},r),Object.assign(Object.assign({},i),{canisterId:a})),this.createActor(t,Object.assign(Object.assign({},i),{canisterId:a}))}static createActorClass(t){let r=t({IDL:je});class i extends Zt{constructor(u){let d=typeof u.canisterId=="string"?ot.fromText(u.canisterId):u.canisterId;super({config:Object.assign(Object.assign(Object.assign({},wi),u),{canisterId:d}),service:r});for(let[m,w]of r._fields)this[m]=sa(this,m,w,u.blsVerify)}}return i}static createActor(t,r){return new(this.createActorClass(t))(r)}};function xi(e,t){let r=je.decode(e,mi.Buffer.from(t));switch(r.length){case 0:return;case 1:return r[0];default:return r}}var wi={pollingStrategyFactory:xr.defaultStrategy};function sa(e,t,r,i){let a;r.annotations.includes("query")?a=async(d,...m)=>{var w,A;d=Object.assign(Object.assign({},d),(A=(w=e[Tt].config).queryTransform)===null||A===void 0?void 0:A.call(w,t,m,Object.assign(Object.assign({},e[Tt].config),d)));let C=d.agent||e[Tt].config.agent||Jr(),O=ot.from(d.canisterId||e[Tt].config.canisterId),Q=je.encode(r.argTypes,m),st=await C.query(O,{methodName:t,arg:Q});switch(st.status){case"rejected":throw new Zr(O,t,st);case"replied":return xi(r.retTypes,st.reply.arg)}}:a=async(d,...m)=>{var w,A;d=Object.assign(Object.assign({},d),(A=(w=e[Tt].config).callTransform)===null||A===void 0?void 0:A.call(w,t,m,Object.assign(Object.assign({},e[Tt].config),d)));let C=d.agent||e[Tt].config.agent||Jr(),{canisterId:O,effectiveCanisterId:Q,pollingStrategyFactory:st}=Object.assign(Object.assign(Object.assign({},wi),e[Tt].config),d),it=ot.from(O),vt=Q!==void 0?ot.from(Q):it,qt=je.encode(r.argTypes,m),{requestId:Lt,response:Ht}=await C.call(it,{methodName:t,arg:qt,effectiveCanisterId:vt});if(!Ht.ok)throw new Qr(it,t,Lt,Ht);let Ct=st(),$t=await Xr(C,vt,Lt,Ct,i);if($t!==void 0)return xi(r.retTypes,$t);if(r.retTypes.length===0)return;throw new Error(`Call was returned undefined, but type [${r.retTypes.join(",")}].`)};let u=(...d)=>a({},...d);return u.withOptions=d=>(...m)=>a(d,...m),u}function yi(e){function t(r,i,a){let u=i[0],d=ot.fromHex("");return u&&typeof u=="object"&&u.canister_id&&(d=ot.from(u.canister_id)),{effectiveCanisterId:d}}return Zt.createActor(pi,Object.assign(Object.assign(Object.assign({},e),{canisterId:ot.fromHex("")}),{callTransform:t,queryTransform:t}))}var Ye=me(Lr());function Ae(e){var t;return new Uint8Array(((t=e.match(/.{1,2}/g))!==null&&t!==void 0?t:[]).map(r=>parseInt(r,16))).buffer}function Qt(e){return new Uint8Array(e).reduce((t,r)=>t+r.toString(16).padStart(2,"0"),"")}var ua=(e,t)=>{if(e.byteLength!==t.byteLength)return!1;let r=new Uint8Array(e),i=new Uint8Array(t);for(let a=0;a<r.length;a++)if(r[a]!==i[a])return!1;return!0},vi=e=>{if(e<=127)return 1;if(e<=255)return 2;if(e<=65535)return 3;if(e<=16777215)return 4;throw new Error("Length too long (> 4 bytes)")},Ei=(e,t,r)=>{if(r<=127)return e[t]=r,1;if(r<=255)return e[t]=129,e[t+1]=r,2;if(r<=65535)return e[t]=130,e[t+1]=r>>8,e[t+2]=r,3;if(r<=16777215)return e[t]=131,e[t+1]=r>>16,e[t+2]=r>>8,e[t+3]=r,4;throw new Error("Length too long (> 4 bytes)")},tn=(e,t)=>{if(e[t]<128)return 1;if(e[t]===128)throw new Error("Invalid length 0");if(e[t]===129)return 2;if(e[t]===130)return 3;if(e[t]===131)return 4;throw new Error("Length too long (> 4 bytes)")},la=(e,t)=>{let r=tn(e,t);if(r===1)return e[t];if(r===2)return e[t+1];if(r===3)return(e[t+1]<<8)+e[t+2];if(r===4)return(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];throw new Error("Length too long (> 4 bytes)")},Ai=Uint8Array.from([48,12,6,10,43,6,1,4,1,131,184,67,1,1]),gr=Uint8Array.from([48,5,6,3,43,101,112]),wf=Uint8Array.from([48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,10]);function _r(e,t){let r=2+vi(e.byteLength+1),i=t.byteLength+r+e.byteLength,a=0,u=new Uint8Array(1+vi(i)+i);return u[a++]=48,a+=Ei(u,a,i),u.set(t,a),a+=t.byteLength,u[a++]=3,a+=Ei(u,a,e.byteLength+1),u[a++]=0,u.set(new Uint8Array(e),a),u}var en=(e,t)=>{let r=0,i=(m,w)=>{if(a[r++]!==m)throw new Error("Expected: "+w)},a=new Uint8Array(e);if(i(48,"sequence"),r+=tn(a,r),!ua(a.slice(r,r+t.byteLength),t))throw new Error("Not the expected OID.");r+=t.byteLength,i(3,"bit string");let u=la(a,r)-1;r+=tn(a,r),i(0,"0 padding");let d=a.slice(r);if(u!==d.length)throw new Error(`DER payload mismatch: Expected length ${u} actual length ${d.length}`);return d};var St=class{constructor(t){this.rawKey=t,this.derKey=St.derEncode(t)}static from(t){return this.fromDer(t.toDer())}static fromRaw(t){return new St(t)}static fromDer(t){return new St(this.derDecode(t))}static derEncode(t){return _r(t,gr).buffer}static derDecode(t){let r=en(t,gr);if(r.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return r}toDer(){return this.derKey}toRaw(){return this.rawKey}};St.RAW_KEY_LENGTH=32;var Bt=class extends Xt{constructor(t,r){super(),this._privateKey=r,this._publicKey=St.from(t)}static generate(t){if(t&&t.length!==32)throw new Error("Ed25519 Seed needs to be 32 bytes long.");let{publicKey:r,secretKey:i}=t===void 0?Ye.sign.keyPair():Ye.sign.keyPair.fromSeed(t);return new this(St.fromRaw(r),i)}static fromParsedJson(t){let[r,i]=t;return new Bt(St.fromDer(Ae(r)),Ae(i))}static fromJSON(t){let r=JSON.parse(t);if(Array.isArray(r)){if(typeof r[0]=="string"&&typeof r[1]=="string")return this.fromParsedJson([r[0],r[1]]);throw new Error("Deserialization error: JSON must have at least 2 items.")}throw new Error(`Deserialization error: Invalid JSON type for string: ${JSON.stringify(t)}`)}static fromKeyPair(t,r){return new Bt(St.fromRaw(t),r)}static fromSecretKey(t){let r=Ye.sign.keyPair.fromSecretKey(new Uint8Array(t));return Bt.fromKeyPair(r.publicKey,r.secretKey)}toJSON(){return[Qt(this._publicKey.toDer()),Qt(this._privateKey)]}getKeyPair(){return{secretKey:this._privateKey,publicKey:this._publicKey}}getPublicKey(){return this._publicKey}async sign(t){let r=new Uint8Array(t);return Ye.sign.detached(r,new Uint8Array(this._privateKey)).buffer}};var Ve=class extends Error{constructor(t){super(t),this.message=t,Object.setPrototypeOf(this,Ve.prototype)}};function Ti(e){if(e)return e;if(typeof crypto<"u"&&crypto.subtle)return crypto.subtle;throw new Ve("Global crypto was not available and none was provided. Please inlcude a SubtleCrypto implementation. See https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto")}var ue=class extends Xt{constructor(t,r,i){super(),this._keyPair=t,this._derKey=r,this._subtleCrypto=i}static async generate(t){let{extractable:r=!1,keyUsages:i=["sign","verify"],subtleCrypto:a}=t??{},u=Ti(a),d=await u.generateKey({name:"ECDSA",namedCurve:"P-256"},r,i),m=await u.exportKey("spki",d.publicKey);return new this(d,m,u)}static async fromKeyPair(t,r){let i=Ti(r),a=await i.exportKey("spki",t.publicKey);return new ue(t,a,i)}getKeyPair(){return this._keyPair}getPublicKey(){let t=this._derKey,r=Object.create(this._keyPair.publicKey);return r.toDer=function(){return t},r}async sign(t){let r={name:"ECDSA",hash:{name:"SHA-256"}};return this._keyPair.privateKey,await this._subtleCrypto.sign(r,this._keyPair.privateKey,t)}};var Te=me(kn());var da=function(e,t){var r={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(r[i]=e[i]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,i=Object.getOwnPropertySymbols(e);a<i.length;a++)t.indexOf(i[a])<0&&Object.prototype.propertyIsEnumerable.call(e,i[a])&&(r[i[a]]=e[i[a]]);return r},ha=new TextEncoder().encode("ic-request-auth-delegation"),pa=new TextEncoder().encode(`
|
|
22
|
+
ic-request`);function rn(e){if(typeof e!="string"||e.length<64)throw new Error("Invalid public key.");return Ae(e)}var Se=class{constructor(t,r,i){this.pubkey=t,this.expiration=r,this.targets=i}toCBOR(){return Te.value.map(Object.assign({pubkey:Te.value.bytes(this.pubkey),expiration:Te.value.u64(this.expiration.toString(16),16)},this.targets&&{targets:Te.value.array(this.targets.map(t=>Te.value.bytes(t.toUint8Array())))}))}toJSON(){return Object.assign({expiration:this.expiration.toString(16),pubkey:Qt(this.pubkey)},this.targets&&{targets:this.targets.map(t=>t.toHex())})}};async function xa(e,t,r,i){let a=new Se(t.toDer(),BigInt(+r)*BigInt(1e6),i),u=new Uint8Array([...ha,...new Uint8Array(ne(a))]),d=await e.sign(u);return{delegation:a,signature:d}}var le=class{constructor(t,r){this.delegations=t,this.publicKey=r}static async create(t,r,i=new Date(Date.now()+15*60*1e3),a={}){var u,d;let m=await xa(t,r,i,a.targets);return new le([...((u=a.previous)===null||u===void 0?void 0:u.delegations)||[],m],((d=a.previous)===null||d===void 0?void 0:d.publicKey)||t.getPublicKey().toDer())}static fromJSON(t){let{publicKey:r,delegations:i}=typeof t=="string"?JSON.parse(t):t;if(!Array.isArray(i))throw new Error("Invalid delegations.");let a=i.map(u=>{let{delegation:d,signature:m}=u,{pubkey:w,expiration:A,targets:C}=d;if(C!==void 0&&!Array.isArray(C))throw new Error("Invalid targets.");return{delegation:new Se(rn(w),BigInt(`0x${A}`),C&&C.map(O=>{if(typeof O!="string")throw new Error("Invalid target.");return ot.fromHex(O)})),signature:rn(m)}});return new this(a,rn(r))}static fromDelegations(t,r){return new this(t,r)}toJSON(){return{delegations:this.delegations.map(t=>{let{delegation:r,signature:i}=t,{targets:a}=r;return{delegation:Object.assign({expiration:r.expiration.toString(16),pubkey:Qt(r.pubkey)},a&&{targets:a.map(u=>u.toHex())}),signature:Qt(i)}}),publicKey:Qt(this.publicKey)}}},qe=class extends Xt{constructor(t,r){super(),this._inner=t,this._delegation=r}static fromDelegation(t,r){return new this(t,r)}getDelegation(){return this._delegation}getPublicKey(){return{toDer:()=>this._delegation.publicKey}}sign(t){return this._inner.sign(t)}async transformRequest(t){let{body:r}=t,i=da(t,["body"]),a=await ne(r);return Object.assign(Object.assign({},i),{body:{content:r,sender_sig:await this.sign(new Uint8Array([...pa,...new Uint8Array(a)])),sender_delegation:this._delegation.delegations,sender_pubkey:this._delegation.publicKey}})}};function Si(e,t){for(let{delegation:a}of e.delegations)if(+new Date(Number(a.expiration/BigInt(1e6)))<=+Date.now())return!1;let r=[],i=t?.scope;i&&(Array.isArray(i)?r.push(...i.map(a=>typeof a=="string"?ot.fromText(a):a)):r.push(typeof i=="string"?ot.fromText(i):i));for(let a of r){let u=a.toText();for(let{delegation:d}of e.delegations){if(d.targets===void 0)continue;let m=!0;for(let w of d.targets)if(w.toText()===u){m=!1;break}if(m)return!1}}return!0}var ya=me(ho()),ma=me(Lr());var Oi;(function(e){e[e.ECDSA_WITH_SHA256=-7]="ECDSA_WITH_SHA256"})(Oi||(Oi={}));var Ui=["mousedown","mousemove","keydown","touchstart","wheel"],He=class{constructor(t={}){var r;this.callbacks=[],this.idleTimeout=10*60*1e3,this.timeoutID=void 0;let{onIdle:i,idleTimeout:a=10*60*1e3}=t||{};this.callbacks=i?[i]:[],this.idleTimeout=a;let u=this._resetTimer.bind(this);window.addEventListener("load",u,!0),Ui.forEach(function(m){document.addEventListener(m,u,!0)});let d=(m,w)=>{let A;return(...C)=>{let O=this,Q=function(){A=void 0,m.apply(O,C)};clearTimeout(A),A=window.setTimeout(Q,w)}};if(t?.captureScroll){let m=d(u,(r=t?.scrollDebounce)!==null&&r!==void 0?r:100);window.addEventListener("scroll",m,!0)}u()}static create(t={}){return new this(t)}registerCallback(t){this.callbacks.push(t)}exit(){clearTimeout(this.timeoutID),window.removeEventListener("load",this._resetTimer,!0);let t=this._resetTimer.bind(this);Ui.forEach(function(r){document.removeEventListener(r,t,!0)}),this.callbacks.forEach(r=>r())}_resetTimer(){let t=this.exit.bind(this);window.clearTimeout(this.timeoutID),this.timeoutID=window.setTimeout(t,this.idleTimeout)}};var wa=(e,t)=>t.some(r=>e instanceof r),Ri,Bi;function ga(){return Ri||(Ri=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function _a(){return Bi||(Bi=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var Ni=new WeakMap,on=new WeakMap,Pi=new WeakMap,nn=new WeakMap,sn=new WeakMap;function ba(e){let t=new Promise((r,i)=>{let a=()=>{e.removeEventListener("success",u),e.removeEventListener("error",d)},u=()=>{r(Mt(e.result)),a()},d=()=>{i(e.error),a()};e.addEventListener("success",u),e.addEventListener("error",d)});return t.then(r=>{r instanceof IDBCursor&&Ni.set(r,e)}).catch(()=>{}),sn.set(t,e),t}function va(e){if(on.has(e))return;let t=new Promise((r,i)=>{let a=()=>{e.removeEventListener("complete",u),e.removeEventListener("error",d),e.removeEventListener("abort",d)},u=()=>{r(),a()},d=()=>{i(e.error||new DOMException("AbortError","AbortError")),a()};e.addEventListener("complete",u),e.addEventListener("error",d),e.addEventListener("abort",d)});on.set(e,t)}var an={get(e,t,r){if(e instanceof IDBTransaction){if(t==="done")return on.get(e);if(t==="objectStoreNames")return e.objectStoreNames||Pi.get(e);if(t==="store")return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return Mt(e[t])},set(e,t,r){return e[t]=r,!0},has(e,t){return e instanceof IDBTransaction&&(t==="done"||t==="store")?!0:t in e}};function Ci(e){an=e(an)}function Ea(e){return e===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(t,...r){let i=e.call(br(this),t,...r);return Pi.set(i,t.sort?t.sort():[t]),Mt(i)}:_a().includes(e)?function(...t){return e.apply(br(this),t),Mt(Ni.get(this))}:function(...t){return Mt(e.apply(br(this),t))}}function Aa(e){return typeof e=="function"?Ea(e):(e instanceof IDBTransaction&&va(e),wa(e,ga())?new Proxy(e,an):e)}function Mt(e){if(e instanceof IDBRequest)return ba(e);if(nn.has(e))return nn.get(e);let t=Aa(e);return t!==e&&(nn.set(e,t),sn.set(t,e)),t}var br=e=>sn.get(e);function ki(e,t,{blocked:r,upgrade:i,blocking:a,terminated:u}={}){let d=indexedDB.open(e,t),m=Mt(d);return i&&d.addEventListener("upgradeneeded",w=>{i(Mt(d.result),w.oldVersion,w.newVersion,Mt(d.transaction),w)}),r&&d.addEventListener("blocked",w=>r(w.oldVersion,w.newVersion,w)),m.then(w=>{u&&w.addEventListener("close",()=>u()),a&&w.addEventListener("versionchange",A=>a(A.oldVersion,A.newVersion,A))}).catch(()=>{}),m}var Ta=["get","getKey","getAll","getAllKeys","count"],Sa=["put","add","delete","clear"],fn=new Map;function Fi(e,t){if(!(e instanceof IDBDatabase&&!(t in e)&&typeof t=="string"))return;if(fn.get(t))return fn.get(t);let r=t.replace(/FromIndex$/,""),i=t!==r,a=Sa.includes(r);if(!(r in(i?IDBIndex:IDBObjectStore).prototype)||!(a||Ta.includes(r)))return;let u=async function(d,...m){let w=this.transaction(d,a?"readwrite":"readonly"),A=w.store;return i&&(A=A.index(m.shift())),(await Promise.all([A[r](...m),a&&w.done]))[0]};return fn.set(t,u),u}Ci(e=>({...e,get:(t,r,i)=>Fi(t,r)||e.get(t,r,i),has:(t,r)=>!!Fi(t,r)||e.has(t,r)}));var ji="auth-client-db",Ki="ic-keyval",Oa=async(e=ji,t=Ki,r)=>(vr&&(localStorage!=null&&localStorage.getItem(Nt))&&(localStorage.removeItem(Nt),localStorage.removeItem(Pt)),await ki(e,r,{upgrade:i=>{i.objectStoreNames,i.objectStoreNames.contains(t)&&i.clear(t),i.createObjectStore(t)}}));async function Ua(e,t,r){return await e.get(t,r)}async function Ra(e,t,r,i){return await e.put(t,i,r)}async function Ba(e,t,r){return await e.delete(t,r)}var de=class{constructor(t,r){this._db=t,this._storeName=r}static async create(t){let{dbName:r=ji,storeName:i=Ki,version:a=1}=t??{},u=await Oa(r,i,a);return new de(u,i)}async set(t,r){return await Ra(this._db,this._storeName,t,r)}async get(t){var r;return(r=await Ua(this._db,this._storeName,t))!==null&&r!==void 0?r:null}async remove(t){return await Ba(this._db,this._storeName,t)}};var Pt="identity",Nt="delegation",Mi="iv",Na=1,vr=typeof window<"u",$e=class{constructor(t="ic-",r){this.prefix=t,this._localStorage=r}get(t){return Promise.resolve(this._getLocalStorage().getItem(this.prefix+t))}set(t,r){return this._getLocalStorage().setItem(this.prefix+t,r),Promise.resolve()}remove(t){return this._getLocalStorage().removeItem(this.prefix+t),Promise.resolve()}_getLocalStorage(){if(this._localStorage)return this._localStorage;let t=typeof window>"u"&&typeof window>"u"?typeof self>"u"?void 0:self.localStorage:window.localStorage;if(!t)throw new Error("Could not find local storage.");return t}},Ie=class{get _db(){return new Promise(t=>{if(this.initializedDb){t(this.initializedDb);return}de.create({version:Na}).then(r=>{this.initializedDb=r,t(r)})})}async get(t){return await(await this._db).get(t)}async set(t,r){await(await this._db).set(t,r)}async remove(t){await(await this._db).remove(t)}};var Pa="https://identity.ic0.app",Ca="#authorize",cn="ECDSA",un="Ed25519",Fa=500,ka="UserInterrupt",Er=class{constructor(t,r,i,a,u,d,m,w){var A;this._identity=t,this._key=r,this._chain=i,this._storage=a,this.idleManager=u,this._createOptions=d,this._idpWindow=m,this._eventHandler=w;let C=this.logout.bind(this),O=d?.idleOptions;!O?.onIdle&&!O?.disableDefaultIdleCallback&&((A=this.idleManager)===null||A===void 0||A.registerCallback(()=>{C(),location.reload()}))}static async create(t={}){var r,i,a;let u=(r=t.storage)!==null&&r!==void 0?r:new Ie,d=(i=t.keyType)!==null&&i!==void 0?i:cn,m=null;if(t.identity)m=t.identity;else{let O=await u.get(Pt);if(!O&&vr)try{let Q=new $e,st=await Q.get(Nt),it=await Q.get(Pt);st&&it&&d===cn&&(console.log("Discovered an identity stored in localstorage. Migrating to IndexedDB"),await u.set(Nt,st),await u.set(Pt,it),O=st,await Q.remove(Nt),await Q.remove(Pt))}catch(Q){console.error("error while attempting to recover localstorage: "+Q)}if(O)try{typeof O=="object"?d===un&&typeof O=="string"?m=await Bt.fromJSON(O):m=await ue.fromKeyPair(O):typeof O=="string"&&(m=Bt.fromJSON(O))}catch{}}let w=new ae,A=null;if(m)try{let O=await u.get(Nt);if(typeof O=="object"&&O!==null)throw new Error("Delegation chain is incorrectly stored. A delegation chain should be stored as a string.");t.identity?w=t.identity:O&&(A=le.fromJSON(O),Si(A)?w=qe.fromDelegation(m,A):(await ln(u),m=null))}catch(O){console.error(O),await ln(u),m=null}let C;return!((a=t.idleOptions)===null||a===void 0)&&a.disableIdle?C=void 0:(A||t.identity)&&(C=He.create(t.idleOptions)),m||(d===un?(m=await Bt.generate(),await u.set(Pt,JSON.stringify(m.toJSON()))):(t.storage&&d===cn&&console.warn(`You are using a custom storage provider that may not support CryptoKey storage. If you are using a custom storage provider that does not support CryptoKey storage, you should use '${un}' as the key type, as it can serialize to a string`),m=await ue.generate(),await u.set(Pt,m.getKeyPair()))),new this(w,m,A,u,C,t)}_handleSuccess(t,r){var i,a,u;let d=t.delegations.map(A=>({delegation:new Se(A.delegation.pubkey,A.delegation.expiration,A.delegation.targets),signature:A.signature.buffer})),m=le.fromDelegations(d,t.userPublicKey.buffer),w=this._key;if(w){if(this._chain=m,this._identity=qe.fromDelegation(w,this._chain),(i=this._idpWindow)===null||i===void 0||i.close(),!this.idleManager){let A=(a=this._createOptions)===null||a===void 0?void 0:a.idleOptions;this.idleManager=He.create(A),!A?.onIdle&&!A?.disableDefaultIdleCallback&&((u=this.idleManager)===null||u===void 0||u.registerCallback(()=>{this.logout(),location.reload()}))}r?.(),this._removeEventListener(),delete this._idpWindow}}getIdentity(){return this._identity}async isAuthenticated(){return!this.getIdentity().getPrincipal().isAnonymous()&&this._chain!==null}async login(t){var r,i,a,u;let d=BigInt(8)*BigInt(36e11),m=new URL(((r=t?.identityProvider)===null||r===void 0?void 0:r.toString())||Pa);m.hash=Ca,(i=this._idpWindow)===null||i===void 0||i.close(),this._removeEventListener(),this._eventHandler=this._getEventHandler(m,Object.assign({maxTimeToLive:(a=t?.maxTimeToLive)!==null&&a!==void 0?a:d},t)),window.addEventListener("message",this._eventHandler),this._idpWindow=(u=window.open(m.toString(),"idpWindow",t?.windowOpenerFeatures))!==null&&u!==void 0?u:void 0;let w=()=>{this._idpWindow&&(this._idpWindow.closed?this._handleFailure(ka,t?.onError):setTimeout(w,Fa))};w()}_getEventHandler(t,r){return async i=>{var a,u,d;if(i.origin!==t.origin){console.warn(`WARNING: expected origin '${t.origin}', got '${i.origin}' (ignoring)`);return}let m=i.data;switch(m.kind){case"authorize-ready":{let w={kind:"authorize-client",sessionPublicKey:new Uint8Array((a=this._key)===null||a===void 0?void 0:a.getPublicKey().toDer()),maxTimeToLive:r?.maxTimeToLive,derivationOrigin:(u=r?.derivationOrigin)===null||u===void 0?void 0:u.toString()};(d=this._idpWindow)===null||d===void 0||d.postMessage(w,t.origin);break}case"authorize-client-success":try{this._handleSuccess(m,r?.onSuccess),this._chain&&await this._storage.set(Nt,JSON.stringify(this._chain.toJSON()))}catch(w){this._handleFailure(w.message,r?.onError)}break;case"authorize-client-failure":this._handleFailure(m.text,r?.onError);break;default:break}}}_handleFailure(t,r){var i;(i=this._idpWindow)===null||i===void 0||i.close(),r?.(t),this._removeEventListener(),delete this._idpWindow}_removeEventListener(){this._eventHandler&&window.removeEventListener("message",this._eventHandler),this._eventHandler=void 0}async logout(t={}){if(await ln(this._storage),this._identity=new ae,this._chain=null,t.returnTo)try{window.history.pushState({},"",t.returnTo)}catch{window.location.href=t.returnTo}}};async function ln(e){await e.remove(Pt),await e.remove(Nt),await e.remove(Mi)}var dn=()=>Er.create({idleOptions:{disableIdle:!0,disableDefaultIdleCallback:!0}});var gt=e=>e?[e]:[],Ar=e=>e?.[0],Yi=async e=>{let t=new Blob([JSON.stringify(e)],{type:"application/json; charset=utf-8"});return new Uint8Array(await t.arrayBuffer())},hn=async e=>{let t=new Blob([e instanceof Uint8Array?e:new Uint8Array(e)],{type:"application/json; charset=utf-8"});return JSON.parse(await t.text())};var Tr=({matcher:e,paginate:t,order:r,owner:i})=>({matcher:gt(e),paginate:gt(mt(t)?void 0:{start_after:gt(t.startAfter),limit:gt(mt(t.limit)?void 0:BigInt(t.limit))}),order:gt(mt(r)?void 0:{desc:r.desc,field:r.field==="created_at"?{CreatedAt:null}:r.field==="updated_at"?{UpdatedAt:null}:{Keys:null}}),owner:gt(mt(i)?void 0:typeof i=="string"?ot.fromText(i):i)});var Vi=({IDL:e})=>{let t=e.Record({batch_id:e.Nat,headers:e.Vec(e.Tuple(e.Text,e.Text)),chunk_ids:e.Vec(e.Nat)}),r=e.Record({controllers:e.Vec(e.Principal)}),i=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,expires_at:e.Opt(e.Nat64)}),a=e.Record({updated_at:e.Opt(e.Nat64)}),u=e.Record({headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text))))}),d=e.Record({storage:u}),m=e.Record({updated_at:e.Nat64,owner:e.Principal,data:e.Vec(e.Nat8),created_at:e.Nat64}),w=e.Record({url:e.Text,method:e.Text,body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text))}),A=e.Record({token:e.Opt(e.Text),sha256:e.Opt(e.Vec(e.Nat8)),headers:e.Vec(e.Tuple(e.Text,e.Text)),index:e.Nat64,encoding_type:e.Text,full_path:e.Text}),C=e.Variant({Callback:e.Record({token:A,callback:e.Func([],[],[])})}),O=e.Record({body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),streaming_strategy:e.Opt(C),status_code:e.Nat16}),Q=e.Record({token:e.Opt(A),body:e.Vec(e.Nat8)}),st=e.Record({token:e.Opt(e.Text),collection:e.Text,name:e.Text,encoding_type:e.Opt(e.Text),full_path:e.Text}),it=e.Record({batch_id:e.Nat}),vt=e.Variant({UpdatedAt:e.Null,Keys:e.Null,CreatedAt:e.Null}),qt=e.Record({field:vt,desc:e.Bool}),Lt=e.Record({start_after:e.Opt(e.Text),limit:e.Opt(e.Nat64)}),Ht=e.Record({order:e.Opt(qt),owner:e.Opt(e.Principal),matcher:e.Opt(e.Text),paginate:e.Opt(Lt)}),Ct=e.Record({token:e.Opt(e.Text),collection:e.Text,owner:e.Principal,name:e.Text,full_path:e.Text}),$t=e.Record({modified:e.Nat64,sha256:e.Vec(e.Nat8),total_length:e.Nat}),It=e.Record({key:Ct,updated_at:e.Nat64,encodings:e.Vec(e.Tuple(e.Text,$t)),headers:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64}),We=e.Record({matches_length:e.Nat64,length:e.Nat64,items:e.Vec(e.Tuple(e.Text,It))}),ze=e.Record({updated_at:e.Nat64,created_at:e.Nat64,bn_id:e.Opt(e.Text)}),Ge=e.Record({matches_length:e.Nat64,length:e.Nat64,items:e.Vec(e.Tuple(e.Text,m))}),he=e.Variant({Db:e.Null,Storage:e.Null}),Wt=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),Oe=e.Record({updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:Wt,created_at:e.Nat64,write:Wt}),Je=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),expires_at:e.Opt(e.Nat64)}),Ue=e.Record({controller:Je,controllers:e.Vec(e.Principal)}),Re=e.Record({updated_at:e.Opt(e.Nat64),data:e.Vec(e.Nat8)}),Ot=e.Record({updated_at:e.Opt(e.Nat64),max_size:e.Opt(e.Nat),read:Wt,write:Wt}),Be=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat}),te=e.Record({chunk_id:e.Nat});return e.Service({commit_asset_upload:e.Func([t],[],[]),del_asset:e.Func([e.Text,e.Text],[],[]),del_assets:e.Func([e.Opt(e.Text)],[],[]),del_controllers:e.Func([r],[e.Vec(e.Tuple(e.Principal,i))],[]),del_custom_domain:e.Func([e.Text],[],[]),del_doc:e.Func([e.Text,e.Text,a],[],[]),get_config:e.Func([],[d],[]),get_doc:e.Func([e.Text,e.Text],[e.Opt(m)],["query"]),http_request:e.Func([w],[O],["query"]),http_request_streaming_callback:e.Func([A],[Q],["query"]),init_asset_upload:e.Func([st],[it],[]),list_assets:e.Func([e.Opt(e.Text),Ht],[We],["query"]),list_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,i))],["query"]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,ze))],["query"]),list_docs:e.Func([e.Text,Ht],[Ge],["query"]),list_rules:e.Func([he],[e.Vec(e.Tuple(e.Text,Oe))],["query"]),set_config:e.Func([d],[],[]),set_controllers:e.Func([Ue],[e.Vec(e.Tuple(e.Principal,i))],[]),set_custom_domain:e.Func([e.Text,e.Opt(e.Text)],[],[]),set_doc:e.Func([e.Text,e.Text,Re],[m],[]),set_rule:e.Func([he,e.Text,Ot],[],[]),upload_asset_chunk:e.Func([Be],[te],[]),version:e.Func([],[e.Text],["query"])})};var qi=async({satelliteId:e,idlFactory:t,identity:r,fetch:i,env:a="prod"})=>{let u=a==="dev"||wt.getInstance().localIdentity(),d=u?"http://127.0.0.1:8000/":"https://icp0.io",m=new fe({identity:r,...d&&{host:d},...i&&{fetch:i}});return u&&await m.fetchRootKey(),Zt.createActor(t,{agent:m,canisterId:e})};var Yt=async({satelliteId:e,...t})=>{let{satelliteId:r}=e!==void 0?{satelliteId:e}:wt.getInstance().get()??{satelliteId:void 0};if(!r)throw new Error("No satellite principal defined.");return qi({satelliteId:r,idlFactory:Vi,...t})};var Hi=async({collection:e,key:t,satellite:r})=>{let i=await Yt(r),a=Ar(await i.get_doc(e,t));if(mt(a))return;let{data:u,owner:d,...m}=a,w=await hn(u);return{key:t,owner:d.toText(),data:w,...m}},$i=async({collection:e,doc:t,satellite:r})=>{let i=await Yt(r),{key:a,data:u,updated_at:d}=t,m=await i.set_doc(e,a,{data:await Yi(u),updated_at:gt(d)}),{owner:w,updated_at:A,created_at:C}=m;return{key:a,owner:w.toText(),data:u,created_at:C,updated_at:A}},Ii=async({collection:e,doc:t,satellite:r})=>{let i=await Yt(r),{key:a,updated_at:u}=t;return i.del_doc(e,a,{updated_at:gt(u)})},Wi=async({collection:e,filter:t,satellite:r})=>{let i=await Yt(r),{items:a,matches_length:u,length:d}=await i.list_docs(e,Tr(t)),m=[];for(let[w,A]of a){let{data:C,owner:O,...Q}=A;m.push({key:w,owner:O.toText(),data:await hn(C),...Q})}return{items:m,length:d,matches_length:u}};var Vt=e=>{if(e!==void 0)return e;let t=Sr();if(!t)throw new Error("No internet identity.");return t};var zi=async({satellite:e,...t})=>{let r=Vt(e?.identity);return Hi({...t,satellite:{...e,identity:r}})},Gi=async({satellite:e,...t})=>{let r=Vt(e?.identity);return $i({...t,satellite:{...e,identity:r}})},Rc=async({satellite:e,...t})=>{let r=Vt(e?.identity);return Ii({...t,satellite:{...e,identity:r}})},Bc=async({satellite:e,...t})=>{let r=Vt(e?.identity);return Wi({...t,satellite:{...e,identity:r}})};var Ji=async e=>{let t=Sr();if(mt(t))throw new Error("No internet identity.");let r=t.getPrincipal().toText(),i=await zi({collection:"#user",key:r});return mt(i)?await ja({userId:r,provider:e}):i},ja=async({userId:e,...t})=>Gi({collection:"#user",doc:{key:e,data:t}});var Dt,pn=async e=>{if(Dt=Dt??await dn(),!(await Dt?.isAuthenticated()||!1))return;let r=await Ji(e);Ft.getInstance().set(r)},Ka=async e=>new Promise(async(t,r)=>{Dt=Dt??await dn();let i=e?.provider??new fr({});await Dt.login({onSuccess:async()=>{await pn(i.id),t()},onError:a=>r(a),maxTimeToLive:e?.maxTimeToLive??Mn,...e?.derivationOrigin!==void 0&&{derivationOrigin:e.derivationOrigin},...i.signInOptions({windowed:e?.windowed})})}),xn=async()=>{await Dt?.logout(),Dt=void 0,Ft.getInstance().reset()},Sr=()=>Dt?.getIdentity();var Xi=e=>{let t=e===!0?"./workers/auth.worker.js":e,r=new Worker(t),i=async()=>{Kn({message:"junoSignOutAuthTimer"}),await xn()};return r.onmessage=async({data:a})=>{let{msg:u}=a;switch(u){case"junoSignOutAuthTimer":await i();return}},Ft.getInstance().subscribe(a=>{if(mt(a)){r.postMessage({msg:"junoStopAuthTimer"});return}r.postMessage({msg:"junoStartAuthTimer"})})};var Zi=async({data:e,filename:t,collection:r,headers:i,token:a,fullPath:u,encoding:d,satellite:m})=>{let w=await Yt(m),{batch_id:A}=await w.init_asset_upload({collection:r,full_path:u,name:t,token:gt(a),encoding_type:gt(d)}),C=7e5,O=[],Q=sr()?new Blob([await e.arrayBuffer()]):e;for(let it=0;it<Q.size;it+=C){let vt=Q.slice(it,it+C);O.push(await Ma({batchId:A,chunk:vt,actor:w}))}let st=i.find(([it,vt])=>it.toLowerCase()==="content-type")===void 0&&e.type!==void 0&&e.type!==""?[["Content-Type",e.type]]:void 0;await w.commit_asset_upload({batch_id:A,chunk_ids:O.map(({chunk_id:it})=>it),headers:[...i,...st||[]]})},Ma=async({batchId:e,chunk:t,actor:r})=>r.upload_asset_chunk({batch_id:e,content:new Uint8Array(await t.arrayBuffer())}),Qi=async({collection:e,satellite:t,filter:r})=>{let i=await Yt(t),{items:a,matches_length:u,length:d}=await i.list_assets(gt(e),Tr(r));return{items:a.map(([m,w])=>w),length:d,matches_length:u}},Di=async({collection:e,storageFile:t,satellite:r})=>{let i=await Yt(r),{fullPath:a}=t;return i.del_asset(e,a)},Li=async({collection:e,satellite:t})=>(await Yt(t)).del_assets(gt(e));var to=e=>btoa([...e].map(t=>String.fromCharCode(t)).join(""));var yn=e=>encodeURI(e.toLowerCase().replace(/\s/g,"-"));var a0=async e=>eo(e),s0=async e=>eo({filename:e.data.name,...e}),eo=async({filename:e,data:t,collection:r,headers:i=[],fullPath:a,token:u,satellite:d,encoding:m})=>{let w=Vt(d?.identity),A=yn(e),C=a||`/${r}/${A}`;return await Zi({data:t,filename:yn(A),collection:r,token:u,headers:i,fullPath:C,encoding:m,satellite:{...d,identity:w}}),{downloadUrl:`${Mr()}${C}${u!==void 0?`?token=${u}`:""}`,fullPath:C,name:A}},f0=async({collection:e,satellite:t,filter:r})=>{let{items:i,...a}=await Qi({collection:e,satellite:{...t,identity:Vt(t?.identity)},filter:r??{}}),u=Mr();return{assets:i.map(({key:{full_path:d,token:m,name:w,owner:A},headers:C,encodings:O,created_at:Q,updated_at:st})=>{let it=Ar(m);return{fullPath:d,name:w,downloadUrl:`${u}${d}${it!==void 0?`?token=${it}`:""}`,token:it,headers:C,encodings:O.reduce((vt,[qt,{modified:Lt,sha256:Ht,total_length:Ct}])=>({...vt,[qt]:{modified:Lt,sha256:to(Ht),total_length:Ct}}),{}),owner:A.toText(),created_at:Q,updated_at:st}}),...a}},c0=async({storageFile:e,collection:t,satellite:r})=>Di({collection:t,storageFile:e,satellite:{...r,identity:Vt(r?.identity)}}),u0=async({collection:e,satellite:t})=>Li({collection:e,satellite:{...t,identity:Vt(t?.identity)}});var y0=async e=>{wt.getInstance().set(e),await pn();let t=e.workers?.auth!==void 0?Xi(e.workers.auth):void 0;return[...t?[t]:[]]},m0=e=>Ft.getInstance().subscribe(e);export{fr as InternetIdentityProvider,Hn as NFIDProvider,m0 as authSubscribe,Rc as delDoc,c0 as deleteAsset,u0 as deleteAssets,zi as getDoc,y0 as initJuno,f0 as listAssets,Bc as listDocs,Gi as setDoc,Ka as signIn,xn as signOut,a0 as uploadBlob,s0 as uploadFile};
|
|
23
23
|
/*! Bundled license information:
|
|
24
24
|
|
|
25
25
|
buffer/index.js:
|