@wovin/connect-nftstorage 0.0.3-RC1 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +0,0 @@
1
- var me=Object.create;var G=Object.defineProperty;var xe=Object.getOwnPropertyDescriptor;var Ee=Object.getOwnPropertyNames;var Oe=Object.getPrototypeOf,Se=Object.prototype.hasOwnProperty;var _e=(t,e,r)=>e in t?G(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var lt=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var pt=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),ht=(t,e)=>{for(var r in e)G(t,r,{get:e[r],enumerable:!0})},Le=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Ee(e))!Se.call(t,o)&&o!==r&&G(t,o,{get:()=>e[o],enumerable:!(n=xe(e,o))||n.enumerable});return t};var bt=(t,e,r)=>(r=t!=null?me(Oe(t)):{},Le(e||!t||!t.__esModule?G(r,"default",{value:t,enumerable:!0}):r,t));var U=(t,e,r)=>(_e(t,typeof e!="symbol"?e+"":e,r),r);var Ae=Object.create,k=Object.defineProperty,De=Object.getOwnPropertyDescriptor,H=Object.getOwnPropertyNames,Ce=Object.getPrototypeOf,Ne=Object.prototype.hasOwnProperty,Fe=(t,e,r)=>e in t?k(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Y=(t,e)=>function(){return e||(0,t[H(t)[0]])((e={exports:{}}).exports,e),e.exports},Re=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of H(e))!Ne.call(t,o)&&o!==r&&k(t,o,{get:()=>e[o],enumerable:!(n=De(e,o))||n.enumerable});return t},ee=(t,e,r)=>(r=t!=null?Ae(Ce(t)):{},Re(e||!t||!t.__esModule?k(r,"default",{value:t,enumerable:!0}):r,t)),D=(t,e,r)=>(Fe(t,typeof e!="symbol"?e+"":e,r),r),Ie=Y({"../../node_modules/.pnpm/browser-or-node@2.1.1/node_modules/browser-or-node/lib/index.js"(t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var e=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(c){return typeof c}:function(c){return c&&typeof Symbol=="function"&&c.constructor===Symbol&&c!==Symbol.prototype?"symbol":typeof c},r=typeof window<"u"&&typeof window.document<"u",n=typeof process<"u"&&process.versions!=null&&process.versions.node!=null,o=(typeof self>"u"?"undefined":e(self))==="object"&&self.constructor&&self.constructor.name==="DedicatedWorkerGlobalScope",s=typeof window<"u"&&window.name==="nodejs"||typeof navigator<"u"&&(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom")),a=typeof Deno<"u"&&typeof Deno.version<"u"&&typeof Deno.version.deno<"u";t.isBrowser=r,t.isWebWorker=o,t.isNode=n,t.isJsDom=s,t.isDeno=a}}),Ue=Y({"../../node_modules/.pnpm/fast-json-stable-stringify@2.1.0/node_modules/fast-json-stable-stringify/index.js"(t,e){"use strict";e.exports=function(r,n){n||(n={}),typeof n=="function"&&(n={cmp:n});var o=typeof n.cycles=="boolean"?n.cycles:!1,s=n.cmp&&function(c){return function(i){return function(u,d){var h={key:u,value:i[u]},b={key:d,value:i[d]};return c(h,b)}}}(n.cmp),a=[];return function c(i){if(i&&i.toJSON&&typeof i.toJSON=="function"&&(i=i.toJSON()),i!==void 0){if(typeof i=="number")return isFinite(i)?""+i:"null";if(typeof i!="object")return JSON.stringify(i);var u,d;if(Array.isArray(i)){for(d="[",u=0;u<i.length;u++)u&&(d+=","),d+=c(i[u])||"null";return d+"]"}if(i===null)return"null";if(a.indexOf(i)!==-1){if(o)return JSON.stringify("__cycle__");throw new TypeError("Converting circular structure to JSON")}var h=a.push(i)-1,b=Object.keys(i).sort(s&&s(i));for(d="",u=0;u<b.length;u++){var L=b[u],f=c(i[L]);f&&(d&&(d+=","),d+=JSON.stringify(L)+":"+f)}return a.splice(h,1),"{"+d+"}"}}(r)}}}),B=ee(Ie(),1),ze=ee(Ue(),1),te=!1,re=!1;B.isNode&&(process?.env?.LOGGER_TIME_PREFIX&&(te=process?.env?.LOGGER_TIME_PREFIX==="true"),process?.env?.LOGGER_PERF_PREFIX&&(re=process?.env?.LOGGER_PERF_PREFIX==="true"));var Be=Object.freeze({prefix:void 0,time:te,delta:re,dimDebugOnServer:!0,printOriginOnServer:!0,serverInspectOptions:{},customFormattersOnServer:!0,printStackLinesOnServer:!1,dim:!0}),$=[],ne=class{constructor(t,e,r,n){U(this,"sinceFirst",0);U(this,"sinceLast",0);U(this,"time",!1);U(this,"delta",!1);Object.assign(this,{sinceFirst:t,sinceLast:e,time:r,delta:n})}toString(){let t=this.sinceFirst*.001,e=t.toFixed(t<5?2:1),r=this.sinceLast<1e3?`${this.sinceLast.toFixed(0)}`.padStart(5," "):`${`${(this.sinceLast*.001).toFixed(this.sinceLast<1e4?1:0)}`.padStart(4," ")}s`;return`[${[this.time?e:null,this.delta?r:null].join(",")}]`}},oe=class{constructor(t,e){Object.assign(this,{style:t,string:e})}},z=!1,p=class{static setup(t=p.INFO,e={}){e=Object.assign({},Be,e),t>10&&console.debug("setup logger",{config:e});let r=this.wrapLog(console.debug,{...e,dim:e.dimDebugOnServer}),n=(...i)=>{window?.FORCE_DISABLE_LOGLEVEL&&r(...i)};n.isDisabled=!0,n.isEnabled=!1;let o=this.wrapLog(console.groupCollapsed,e),s=(i,u)=>{function d(...b){let L=b[b.length-1];return L===n?L():(o(...b.slice(0,-1)),(async()=>{try{let l=L();return l instanceof Promise?await l:l}finally{console.groupEnd()}})())}let h=Object.assign(u.bind({}),{isEnabled:i,isDisabled:!i,group:d,force:u});return i?h:Object.assign(n.bind({}),{isEnabled:i,isDisabled:!i,group:d,force:h})},a=s(t>=p.ERROR,this.wrapLog(console.error,e));return{ERROR:(...i)=>(a(...i),new Error((0,ze.default)(i))),WARN:s(t>=p.WARN,this.wrapLog(console.warn,e)),LOG:s(t>=p.INFO,this.wrapLog(console.log,e)),DEBUG:s(t>=p.DEBUG,this.wrapLog(console.log,{...e,dim:e.dimDebugOnServer})),VERBOSE:s(t>=p.VERBOSE,this.wrapLog(console.debug,{...e,dim:e.dimDebugOnServer}))}}static wrapLog(t,e){if(B.isNode)return t.bind(console);{let r=[];if(e.time||e.delta){let o=B.isBrowser&&navigator.userAgent.includes("Chrome")?["",p.timeStr(!!e.time,!!e.delta)]:[];r.push(...o)}return e.prefix&&(z?r.push(new oe("dim",e.prefix)):r.push(e.prefix)),t.bind(console,...r)}}static timeStr(t,e,r=0){if(!performance.now)return;let n=performance.now();p.firstLog||(p.firstLog=n,p.lastLog=n);let o=new ne(n-p.firstLog,n-p.lastLog,t,e);return p.lastLog=n,r?o.toString():o}static getOriginFromStack(t){let e=!1;for(let r of t.split(`
2
- `)){let n=r.match(/^\s+at\s+(.*)/);if(n){if(e)return n[1].trim().replace(__dirname,"");e=!0}}}},S=p;D(S,"ERROR",2);D(S,"WARN",4);D(S,"INFO",6);D(S,"LOG",6);D(S,"DEBUG",8);D(S,"VERBOSE",10);D(S,"firstLog",0);D(S,"lastLog",0);B.isBrowser?(window.devtoolsFormatters=window.devtoolsFormatters??[],window.devtoolsFormatters.push({header:t=>{if($&&$.length){for(let e of $)if(e.match(t))return["span",{},e.format(t)]}return null},hasBody:()=>!0},{header:t=>{if(!(t instanceof ne))return null;z||(z=!0);let e=S.timeStr(t.time,t.delta);return["span",{style:"font-weight: light; color: grey"},e?.toString()]},hasBody:()=>!1},{header:t=>t instanceof oe?(z||(z=!0),["span",{style:"font-weight: light; color: grey; "},t.string]):null,hasBody:()=>!1})):B.isNode;function Me(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<t.length;o++){var s=t.charAt(o),a=s.charCodeAt(0);if(r[a]!==255)throw new TypeError(s+" is ambiguous");r[a]=o}var c=t.length,i=t.charAt(0),u=Math.log(c)/Math.log(256),d=Math.log(256)/Math.log(c);function h(f){if(f instanceof Uint8Array||(ArrayBuffer.isView(f)?f=new Uint8Array(f.buffer,f.byteOffset,f.byteLength):Array.isArray(f)&&(f=Uint8Array.from(f))),!(f instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(f.length===0)return"";for(var l=0,C=0,g=0,v=f.length;g!==v&&f[g]===0;)g++,l++;for(var m=(v-g)*d+1>>>0,w=new Uint8Array(m);g!==v;){for(var x=f[g],A=0,y=m-1;(x!==0||A<C)&&y!==-1;y--,A++)x+=256*w[y]>>>0,w[y]=x%c>>>0,x=x/c>>>0;if(x!==0)throw new Error("Non-zero carry");C=A,g++}for(var O=m-C;O!==m&&w[O]===0;)O++;for(var V=i.repeat(l);O<m;++O)V+=t.charAt(w[O]);return V}function b(f){if(typeof f!="string")throw new TypeError("Expected String");if(f.length===0)return new Uint8Array;var l=0;if(f[l]!==" "){for(var C=0,g=0;f[l]===i;)C++,l++;for(var v=(f.length-l)*u+1>>>0,m=new Uint8Array(v);f[l];){var w=r[f.charCodeAt(l)];if(w===255)return;for(var x=0,A=v-1;(w!==0||x<g)&&A!==-1;A--,x++)w+=c*m[A]>>>0,m[A]=w%256>>>0,w=w/256>>>0;if(w!==0)throw new Error("Non-zero carry");g=x,l++}if(f[l]!==" "){for(var y=v-g;y!==v&&m[y]===0;)y++;for(var O=new Uint8Array(C+(v-y)),V=C;y!==v;)O[V++]=m[y++];return O}}}function L(f){var l=b(f);if(l)return l;throw new Error(`Non-${e} character`)}return{encode:h,decodeUnsafe:b,decode:L}}var Pe=Me,Te=Pe,se=Te;var Ot=new Uint8Array(0);var ie=(t,e)=>{if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0},N=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")};var J=class{constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},q=class{constructor(e,r,n){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return ae(this,e)}},W=class{constructor(e){this.decoders=e}or(e){return ae(this,e)}decode(e){let r=e[0],n=this.decoders[r];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},ae=(t,e)=>new W({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}}),X=class{constructor(e,r,n,o){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new J(e,r,n),this.decoder=new q(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},ce=({name:t,prefix:e,encode:r,decode:n})=>new X(t,e,r,n),Q=({prefix:t,name:e,alphabet:r})=>{let{encode:n,decode:o}=se(r,e);return ce({prefix:t,name:e,encode:n,decode:s=>N(o(s))})},je=(t,e,r,n)=>{let o={};for(let d=0;d<e.length;++d)o[e[d]]=d;let s=t.length;for(;t[s-1]==="=";)--s;let a=new Uint8Array(s*r/8|0),c=0,i=0,u=0;for(let d=0;d<s;++d){let h=o[t[d]];if(h===void 0)throw new SyntaxError(`Non-${n} character`);i=i<<r|h,c+=r,c>=8&&(c-=8,a[u++]=255&i>>c)}if(c>=r||255&i<<8-c)throw new SyntaxError("Unexpected end of data");return a},Ve=(t,e,r)=>{let n=e[e.length-1]==="=",o=(1<<r)-1,s="",a=0,c=0;for(let i=0;i<t.length;++i)for(c=c<<8|t[i],a+=8;a>r;)a-=r,s+=e[o&c>>a];if(a&&(s+=e[o&c<<r-a]),n)for(;s.length*r&7;)s+="=";return s},E=({name:t,prefix:e,bitsPerChar:r,alphabet:n})=>ce({prefix:e,name:t,encode(o){return Ve(o,n,r)},decode(o){return je(o,n,r,t)}});var M=E({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Ct=E({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Nt=E({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Ft=E({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Rt=E({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),It=E({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Ut=E({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),zt=E({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Bt=E({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var _=Q({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Tt=Q({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ge=ue,fe=128,$e=127,ke=~$e,Je=Math.pow(2,31);function ue(t,e,r){e=e||[],r=r||0;for(var n=r;t>=Je;)e[r++]=t&255|fe,t/=128;for(;t&ke;)e[r++]=t&255|fe,t>>>=7;return e[r]=t|0,ue.bytes=r-n+1,e}var qe=K,We=128,de=127;function K(t,n){var r=0,n=n||0,o=0,s=n,a,c=t.length;do{if(s>=c)throw K.bytes=0,new RangeError("Could not decode varint");a=t[s++],r+=o<28?(a&de)<<o:(a&de)*Math.pow(2,o),o+=7}while(a>=We);return K.bytes=s-n,r}var Xe=Math.pow(2,7),Qe=Math.pow(2,14),Ke=Math.pow(2,21),Ze=Math.pow(2,28),He=Math.pow(2,35),Ye=Math.pow(2,42),et=Math.pow(2,49),tt=Math.pow(2,56),rt=Math.pow(2,63),nt=function(t){return t<Xe?1:t<Qe?2:t<Ke?3:t<Ze?4:t<He?5:t<Ye?6:t<et?7:t<tt?8:t<rt?9:10},ot={encode:Ge,decode:qe,encodingLength:nt},st=ot,P=st;var T=(t,e=0)=>[P.decode(t,e),P.decode.bytes],F=(t,e,r=0)=>(P.encode(t,e,r),e),R=t=>P.encodingLength(t);var pe=(t,e)=>{let r=e.byteLength,n=R(t),o=n+R(r),s=new Uint8Array(o+r);return F(t,s,0),F(r,s,n),s.set(e,o),new I(t,r,e,s)},he=t=>{let e=N(t),[r,n]=T(e),[o,s]=T(e.subarray(n)),a=e.subarray(n+s);if(a.byteLength!==o)throw new Error("Incorrect length");return new I(r,o,a,e)},be=(t,e)=>{if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&ie(t.bytes,r.bytes)}},I=class{constructor(e,r,n,o){this.code=e,this.size=r,this.digest=n,this.bytes=o}};var we=(t,e)=>{let{bytes:r,version:n}=t;switch(n){case 0:return ct(r,Z(t),e||_.encoder);default:return ft(r,Z(t),e||M.encoder)}};var ge=new WeakMap,Z=t=>{let e=ge.get(t);if(e==null){let r=new Map;return ge.set(t,r),r}return e},ye=class t{constructor(e,r,n,o){this.code=r,this.version=e,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:r}=this;if(e!==j)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==dt)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return t.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:r}=this.multihash,n=pe(e,r);return t.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return t.equals(this,e)}static equals(e,r){let n=r;return n&&e.code===n.code&&e.version===n.version&&be(e.multihash,n.multihash)}toString(e){return we(this,e)}toJSON(){return{"/":we(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let r=e;if(r instanceof t)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:s,bytes:a}=r;return new t(n,o,s,a||ve(n,o,s.bytes))}else if(r[ut]===!0){let{version:n,multihash:o,code:s}=r,a=he(o);return t.create(n,s,a)}else return null}static create(e,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(r!==j)throw new Error(`Version 0 CID must use dag-pb (code: ${j}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let o=ve(e,r,n.bytes);return new t(e,r,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,j,e)}static createV1(e,r){return t.create(1,e,r)}static decode(e){let[r,n]=t.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=t.inspectBytes(e),n=r.size-r.multihashSize,o=N(e.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let s=o.subarray(r.multihashSize-r.digestSize),a=new I(r.multihashCode,r.digestSize,s,o);return[r.version===0?t.createV0(a):t.createV1(r.codec,a),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[h,b]=T(e.subarray(r));return r+=b,h},o=n(),s=j;if(o===18?(o=0,r=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let a=r,c=n(),i=n(),u=r+i,d=u-a;return{version:o,codec:s,multihashCode:c,digestSize:i,multihashSize:d,size:u}}static parse(e,r){let[n,o]=at(e,r),s=t.decode(o);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Z(s).set(n,e),s}},at=(t,e)=>{switch(t[0]){case"Q":{let r=e||_;return[_.prefix,r.decode(`${_.prefix}${t}`)]}case _.prefix:{let r=e||_;return[_.prefix,r.decode(t)]}case M.prefix:{let r=e||M;return[M.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}},ct=(t,e,r)=>{let{prefix:n}=r;if(n!==_.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=e.get(n);if(o==null){let s=r.encode(t).slice(1);return e.set(n,s),s}else return o},ft=(t,e,r)=>{let{prefix:n}=r,o=e.get(n);if(o==null){let s=r.encode(t);return e.set(n,s),s}else return o},j=112,dt=18,ve=(t,e,r)=>{let n=R(t),o=n+R(e),s=new Uint8Array(o+r.byteLength);return F(t,s,0),F(e,s,n),s.set(r,o),s},ut=Symbol.for("@ipld/js-cid/CID");export{lt as a,pt as b,ht as c,bt as d,S as e,he as f,ye as g};
3
- //# sourceMappingURL=chunk-ZATDQB6W.min.js.map
@@ -1,16 +0,0 @@
1
- import{a as rn,b as Pt,c as It,d as We,e as Ye,g as Qe}from"./chunk-ZATDQB6W.min.js";var An=Pt(Le=>{"use strict";Object.defineProperty(Le,"__esModule",{value:!0});Le.BrowserRandomSource=void 0;var Sn=65536,br=class{constructor(){this.isAvailable=!1,this.isInstantiated=!1;let r=typeof self<"u"?self.crypto||self.msCrypto:null;r&&r.getRandomValues!==void 0&&(this._crypto=r,this.isAvailable=!0,this.isInstantiated=!0)}randomBytes(r){if(!this.isAvailable||!this._crypto)throw new Error("Browser random byte generator is not available.");let n=new Uint8Array(r);for(let e=0;e<n.length;e+=Sn)this._crypto.getRandomValues(n.subarray(e,e+Math.min(n.length-e,Sn)));return n}};Le.BrowserRandomSource=br});var ye=Pt(xr=>{"use strict";Object.defineProperty(xr,"__esModule",{value:!0});function xa(t){for(var r=0;r<t.length;r++)t[r]=0;return t}xr.wipe=xa});var _n=Pt(()=>{"use strict"});var Cn=Pt(Ne=>{"use strict";Object.defineProperty(Ne,"__esModule",{value:!0});Ne.NodeRandomSource=void 0;var ga=ye(),gr=class{constructor(){if(this.isAvailable=!1,this.isInstantiated=!1,typeof rn<"u"){let r=_n();r&&r.randomBytes&&(this._crypto=r,this.isAvailable=!0,this.isInstantiated=!0)}}randomBytes(r){if(!this.isAvailable||!this._crypto)throw new Error("Node.js random byte generator is not available.");let n=this._crypto.randomBytes(r);if(n.length!==r)throw new Error("NodeRandomSource: got fewer bytes than requested");let e=new Uint8Array(r);for(let i=0;i<e.length;i++)e[i]=n[i];return(0,ga.wipe)(n),e}};Ne.NodeRandomSource=gr});var In=Pt(Fe=>{"use strict";Object.defineProperty(Fe,"__esModule",{value:!0});Fe.SystemRandomSource=void 0;var Ea=An(),Sa=Cn(),Er=class{constructor(){if(this.isAvailable=!1,this.name="",this._source=new Ea.BrowserRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Browser";return}if(this._source=new Sa.NodeRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Node";return}}randomBytes(r){if(!this.isAvailable)throw new Error("System random byte generator is not available.");return this._source.randomBytes(r)}};Fe.SystemRandomSource=Er});var Pn=Pt(Ct=>{"use strict";Object.defineProperty(Ct,"__esModule",{value:!0});function Aa(t,r){var n=t>>>16&65535,e=t&65535,i=r>>>16&65535,a=r&65535;return e*a+(n*a+e*i<<16>>>0)|0}Ct.mul=Math.imul||Aa;function _a(t,r){return t+r|0}Ct.add=_a;function Ca(t,r){return t-r|0}Ct.sub=Ca;function Ia(t,r){return t<<r|t>>>32-r}Ct.rotl=Ia;function Pa(t,r){return t<<32-r|t>>>r}Ct.rotr=Pa;function Ua(t){return typeof t=="number"&&isFinite(t)&&Math.floor(t)===t}Ct.isInteger=Number.isInteger||Ua;Ct.MAX_SAFE_INTEGER=9007199254740991;Ct.isSafeInteger=function(t){return Ct.isInteger(t)&&t>=-Ct.MAX_SAFE_INTEGER&&t<=Ct.MAX_SAFE_INTEGER}});var Ir=Pt(q=>{"use strict";Object.defineProperty(q,"__esModule",{value:!0});var Un=Pn();function Ba(t,r){return r===void 0&&(r=0),(t[r+0]<<8|t[r+1])<<16>>16}q.readInt16BE=Ba;function La(t,r){return r===void 0&&(r=0),(t[r+0]<<8|t[r+1])>>>0}q.readUint16BE=La;function Na(t,r){return r===void 0&&(r=0),(t[r+1]<<8|t[r])<<16>>16}q.readInt16LE=Na;function Fa(t,r){return r===void 0&&(r=0),(t[r+1]<<8|t[r])>>>0}q.readUint16LE=Fa;function Bn(t,r,n){return r===void 0&&(r=new Uint8Array(2)),n===void 0&&(n=0),r[n+0]=t>>>8,r[n+1]=t>>>0,r}q.writeUint16BE=Bn;q.writeInt16BE=Bn;function Ln(t,r,n){return r===void 0&&(r=new Uint8Array(2)),n===void 0&&(n=0),r[n+0]=t>>>0,r[n+1]=t>>>8,r}q.writeUint16LE=Ln;q.writeInt16LE=Ln;function Sr(t,r){return r===void 0&&(r=0),t[r]<<24|t[r+1]<<16|t[r+2]<<8|t[r+3]}q.readInt32BE=Sr;function Ar(t,r){return r===void 0&&(r=0),(t[r]<<24|t[r+1]<<16|t[r+2]<<8|t[r+3])>>>0}q.readUint32BE=Ar;function _r(t,r){return r===void 0&&(r=0),t[r+3]<<24|t[r+2]<<16|t[r+1]<<8|t[r]}q.readInt32LE=_r;function Cr(t,r){return r===void 0&&(r=0),(t[r+3]<<24|t[r+2]<<16|t[r+1]<<8|t[r])>>>0}q.readUint32LE=Cr;function Re(t,r,n){return r===void 0&&(r=new Uint8Array(4)),n===void 0&&(n=0),r[n+0]=t>>>24,r[n+1]=t>>>16,r[n+2]=t>>>8,r[n+3]=t>>>0,r}q.writeUint32BE=Re;q.writeInt32BE=Re;function Te(t,r,n){return r===void 0&&(r=new Uint8Array(4)),n===void 0&&(n=0),r[n+0]=t>>>0,r[n+1]=t>>>8,r[n+2]=t>>>16,r[n+3]=t>>>24,r}q.writeUint32LE=Te;q.writeInt32LE=Te;function Ra(t,r){r===void 0&&(r=0);var n=Sr(t,r),e=Sr(t,r+4);return n*4294967296+e-(e>>31)*4294967296}q.readInt64BE=Ra;function Ta(t,r){r===void 0&&(r=0);var n=Ar(t,r),e=Ar(t,r+4);return n*4294967296+e}q.readUint64BE=Ta;function Ma(t,r){r===void 0&&(r=0);var n=_r(t,r),e=_r(t,r+4);return e*4294967296+n-(n>>31)*4294967296}q.readInt64LE=Ma;function ka(t,r){r===void 0&&(r=0);var n=Cr(t,r),e=Cr(t,r+4);return e*4294967296+n}q.readUint64LE=ka;function Nn(t,r,n){return r===void 0&&(r=new Uint8Array(8)),n===void 0&&(n=0),Re(t/4294967296>>>0,r,n),Re(t>>>0,r,n+4),r}q.writeUint64BE=Nn;q.writeInt64BE=Nn;function Fn(t,r,n){return r===void 0&&(r=new Uint8Array(8)),n===void 0&&(n=0),Te(t>>>0,r,n),Te(t/4294967296>>>0,r,n+4),r}q.writeUint64LE=Fn;q.writeInt64LE=Fn;function Oa(t,r,n){if(n===void 0&&(n=0),t%8!==0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(t/8>r.length-n)throw new Error("readUintBE: array is too short for the given bitLength");for(var e=0,i=1,a=t/8+n-1;a>=n;a--)e+=r[a]*i,i*=256;return e}q.readUintBE=Oa;function Ka(t,r,n){if(n===void 0&&(n=0),t%8!==0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(t/8>r.length-n)throw new Error("readUintLE: array is too short for the given bitLength");for(var e=0,i=1,a=n;a<n+t/8;a++)e+=r[a]*i,i*=256;return e}q.readUintLE=Ka;function $a(t,r,n,e){if(n===void 0&&(n=new Uint8Array(t/8)),e===void 0&&(e=0),t%8!==0)throw new Error("writeUintBE supports only bitLengths divisible by 8");if(!Un.isSafeInteger(r))throw new Error("writeUintBE value must be an integer");for(var i=1,a=t/8+e-1;a>=e;a--)n[a]=r/i&255,i*=256;return n}q.writeUintBE=$a;function qa(t,r,n,e){if(n===void 0&&(n=new Uint8Array(t/8)),e===void 0&&(e=0),t%8!==0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!Un.isSafeInteger(r))throw new Error("writeUintLE value must be an integer");for(var i=1,a=e;a<e+t/8;a++)n[a]=r/i&255,i*=256;return n}q.writeUintLE=qa;function Ha(t,r){r===void 0&&(r=0);var n=new DataView(t.buffer,t.byteOffset,t.byteLength);return n.getFloat32(r)}q.readFloat32BE=Ha;function za(t,r){r===void 0&&(r=0);var n=new DataView(t.buffer,t.byteOffset,t.byteLength);return n.getFloat32(r,!0)}q.readFloat32LE=za;function Ga(t,r){r===void 0&&(r=0);var n=new DataView(t.buffer,t.byteOffset,t.byteLength);return n.getFloat64(r)}q.readFloat64BE=Ga;function Va(t,r){r===void 0&&(r=0);var n=new DataView(t.buffer,t.byteOffset,t.byteLength);return n.getFloat64(r,!0)}q.readFloat64LE=Va;function Ja(t,r,n){r===void 0&&(r=new Uint8Array(4)),n===void 0&&(n=0);var e=new DataView(r.buffer,r.byteOffset,r.byteLength);return e.setFloat32(n,t),r}q.writeFloat32BE=Ja;function Xa(t,r,n){r===void 0&&(r=new Uint8Array(4)),n===void 0&&(n=0);var e=new DataView(r.buffer,r.byteOffset,r.byteLength);return e.setFloat32(n,t,!0),r}q.writeFloat32LE=Xa;function Za(t,r,n){r===void 0&&(r=new Uint8Array(8)),n===void 0&&(n=0);var e=new DataView(r.buffer,r.byteOffset,r.byteLength);return e.setFloat64(n,t),r}q.writeFloat64BE=Za;function Wa(t,r,n){r===void 0&&(r=new Uint8Array(8)),n===void 0&&(n=0);var e=new DataView(r.buffer,r.byteOffset,r.byteLength);return e.setFloat64(n,t,!0),r}q.writeFloat64LE=Wa});var kn=Pt(xt=>{"use strict";Object.defineProperty(xt,"__esModule",{value:!0});xt.randomStringForEntropy=xt.randomString=xt.randomUint32=xt.randomBytes=xt.defaultRandomSource=void 0;var Ya=In(),Qa=Ir(),Rn=ye();xt.defaultRandomSource=new Ya.SystemRandomSource;function Pr(t,r=xt.defaultRandomSource){return r.randomBytes(t)}xt.randomBytes=Pr;function ja(t=xt.defaultRandomSource){let r=Pr(4,t),n=(0,Qa.readUint32LE)(r);return(0,Rn.wipe)(r),n}xt.randomUint32=ja;var Tn="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function Mn(t,r=Tn,n=xt.defaultRandomSource){if(r.length<2)throw new Error("randomString charset is too short");if(r.length>256)throw new Error("randomString charset is too long");let e="",i=r.length,a=256-256%i;for(;t>0;){let l=Pr(Math.ceil(t*256/a),n);for(let c=0;c<l.length&&t>0;c++){let f=l[c];f<a&&(e+=r.charAt(f%i),t--)}(0,Rn.wipe)(l)}return e}xt.randomString=Mn;function ts(t,r=Tn,n=xt.defaultRandomSource){let e=Math.ceil(t/(Math.log(r.length)/Math.LN2));return Mn(e,r,n)}xt.randomStringForEntropy=ts});var $n=Pt(Ft=>{"use strict";Object.defineProperty(Ft,"__esModule",{value:!0});var se=Ir(),ae=ye();Ft.DIGEST_LENGTH=64;Ft.BLOCK_SIZE=128;var Kn=function(){function t(){this.digestLength=Ft.DIGEST_LENGTH,this.blockSize=Ft.BLOCK_SIZE,this._stateHi=new Int32Array(8),this._stateLo=new Int32Array(8),this._tempHi=new Int32Array(16),this._tempLo=new Int32Array(16),this._buffer=new Uint8Array(256),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return t.prototype._initState=function(){this._stateHi[0]=1779033703,this._stateHi[1]=3144134277,this._stateHi[2]=1013904242,this._stateHi[3]=2773480762,this._stateHi[4]=1359893119,this._stateHi[5]=2600822924,this._stateHi[6]=528734635,this._stateHi[7]=1541459225,this._stateLo[0]=4089235720,this._stateLo[1]=2227873595,this._stateLo[2]=4271175723,this._stateLo[3]=1595750129,this._stateLo[4]=2917565137,this._stateLo[5]=725511199,this._stateLo[6]=4215389547,this._stateLo[7]=327033209},t.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},t.prototype.clean=function(){ae.wipe(this._buffer),ae.wipe(this._tempHi),ae.wipe(this._tempLo),this.reset()},t.prototype.update=function(r,n){if(n===void 0&&(n=r.length),this._finished)throw new Error("SHA512: can't update because hash was finished.");var e=0;if(this._bytesHashed+=n,this._bufferLength>0){for(;this._bufferLength<Ft.BLOCK_SIZE&&n>0;)this._buffer[this._bufferLength++]=r[e++],n--;this._bufferLength===this.blockSize&&(Ur(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,this.blockSize),this._bufferLength=0)}for(n>=this.blockSize&&(e=Ur(this._tempHi,this._tempLo,this._stateHi,this._stateLo,r,e,n),n%=this.blockSize);n>0;)this._buffer[this._bufferLength++]=r[e++],n--;return this},t.prototype.finish=function(r){if(!this._finished){var n=this._bytesHashed,e=this._bufferLength,i=n/536870912|0,a=n<<3,l=n%128<112?128:256;this._buffer[e]=128;for(var c=e+1;c<l-8;c++)this._buffer[c]=0;se.writeUint32BE(i,this._buffer,l-8),se.writeUint32BE(a,this._buffer,l-4),Ur(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,l),this._finished=!0}for(var c=0;c<this.digestLength/8;c++)se.writeUint32BE(this._stateHi[c],r,c*8),se.writeUint32BE(this._stateLo[c],r,c*8+4);return this},t.prototype.digest=function(){var r=new Uint8Array(this.digestLength);return this.finish(r),r},t.prototype.saveState=function(){if(this._finished)throw new Error("SHA256: cannot save finished state");return{stateHi:new Int32Array(this._stateHi),stateLo:new Int32Array(this._stateLo),buffer:this._bufferLength>0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},t.prototype.restoreState=function(r){return this._stateHi.set(r.stateHi),this._stateLo.set(r.stateLo),this._bufferLength=r.bufferLength,r.buffer&&this._buffer.set(r.buffer),this._bytesHashed=r.bytesHashed,this._finished=!1,this},t.prototype.cleanSavedState=function(r){ae.wipe(r.stateHi),ae.wipe(r.stateLo),r.buffer&&ae.wipe(r.buffer),r.bufferLength=0,r.bytesHashed=0},t}();Ft.SHA512=Kn;var On=new Int32Array([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 Ur(t,r,n,e,i,a,l){for(var c=n[0],f=n[1],p=n[2],u=n[3],y=n[4],g=n[5],U=n[6],S=n[7],C=e[0],M=e[1],R=e[2],k=e[3],B=e[4],N=e[5],H=e[6],z=e[7],D,w,$,V,I,A,_,P;l>=128;){for(var ot=0;ot<16;ot++){var et=8*ot+a;t[ot]=se.readUint32BE(i,et),r[ot]=se.readUint32BE(i,et+4)}for(var ot=0;ot<80;ot++){var Et=c,At=f,Ht=p,rt=u,W=y,nt=g,Q=U,at=S,st=C,ut=M,ht=R,tt=k,pt=B,dt=N,ft=H,ct=z;if(D=S,w=z,I=w&65535,A=w>>>16,_=D&65535,P=D>>>16,D=(y>>>14|B<<18)^(y>>>18|B<<14)^(B>>>9|y<<23),w=(B>>>14|y<<18)^(B>>>18|y<<14)^(y>>>9|B<<23),I+=w&65535,A+=w>>>16,_+=D&65535,P+=D>>>16,D=y&g^~y&U,w=B&N^~B&H,I+=w&65535,A+=w>>>16,_+=D&65535,P+=D>>>16,D=On[ot*2],w=On[ot*2+1],I+=w&65535,A+=w>>>16,_+=D&65535,P+=D>>>16,D=t[ot%16],w=r[ot%16],I+=w&65535,A+=w>>>16,_+=D&65535,P+=D>>>16,A+=I>>>16,_+=A>>>16,P+=_>>>16,$=_&65535|P<<16,V=I&65535|A<<16,D=$,w=V,I=w&65535,A=w>>>16,_=D&65535,P=D>>>16,D=(c>>>28|C<<4)^(C>>>2|c<<30)^(C>>>7|c<<25),w=(C>>>28|c<<4)^(c>>>2|C<<30)^(c>>>7|C<<25),I+=w&65535,A+=w>>>16,_+=D&65535,P+=D>>>16,D=c&f^c&p^f&p,w=C&M^C&R^M&R,I+=w&65535,A+=w>>>16,_+=D&65535,P+=D>>>16,A+=I>>>16,_+=A>>>16,P+=_>>>16,at=_&65535|P<<16,ct=I&65535|A<<16,D=rt,w=tt,I=w&65535,A=w>>>16,_=D&65535,P=D>>>16,D=$,w=V,I+=w&65535,A+=w>>>16,_+=D&65535,P+=D>>>16,A+=I>>>16,_+=A>>>16,P+=_>>>16,rt=_&65535|P<<16,tt=I&65535|A<<16,f=Et,p=At,u=Ht,y=rt,g=W,U=nt,S=Q,c=at,M=st,R=ut,k=ht,B=tt,N=pt,H=dt,z=ft,C=ct,ot%16===15)for(var et=0;et<16;et++)D=t[et],w=r[et],I=w&65535,A=w>>>16,_=D&65535,P=D>>>16,D=t[(et+9)%16],w=r[(et+9)%16],I+=w&65535,A+=w>>>16,_+=D&65535,P+=D>>>16,$=t[(et+1)%16],V=r[(et+1)%16],D=($>>>1|V<<31)^($>>>8|V<<24)^$>>>7,w=(V>>>1|$<<31)^(V>>>8|$<<24)^(V>>>7|$<<25),I+=w&65535,A+=w>>>16,_+=D&65535,P+=D>>>16,$=t[(et+14)%16],V=r[(et+14)%16],D=($>>>19|V<<13)^(V>>>29|$<<3)^$>>>6,w=(V>>>19|$<<13)^($>>>29|V<<3)^(V>>>6|$<<26),I+=w&65535,A+=w>>>16,_+=D&65535,P+=D>>>16,A+=I>>>16,_+=A>>>16,P+=_>>>16,t[et]=_&65535|P<<16,r[et]=I&65535|A<<16}D=c,w=C,I=w&65535,A=w>>>16,_=D&65535,P=D>>>16,D=n[0],w=e[0],I+=w&65535,A+=w>>>16,_+=D&65535,P+=D>>>16,A+=I>>>16,_+=A>>>16,P+=_>>>16,n[0]=c=_&65535|P<<16,e[0]=C=I&65535|A<<16,D=f,w=M,I=w&65535,A=w>>>16,_=D&65535,P=D>>>16,D=n[1],w=e[1],I+=w&65535,A+=w>>>16,_+=D&65535,P+=D>>>16,A+=I>>>16,_+=A>>>16,P+=_>>>16,n[1]=f=_&65535|P<<16,e[1]=M=I&65535|A<<16,D=p,w=R,I=w&65535,A=w>>>16,_=D&65535,P=D>>>16,D=n[2],w=e[2],I+=w&65535,A+=w>>>16,_+=D&65535,P+=D>>>16,A+=I>>>16,_+=A>>>16,P+=_>>>16,n[2]=p=_&65535|P<<16,e[2]=R=I&65535|A<<16,D=u,w=k,I=w&65535,A=w>>>16,_=D&65535,P=D>>>16,D=n[3],w=e[3],I+=w&65535,A+=w>>>16,_+=D&65535,P+=D>>>16,A+=I>>>16,_+=A>>>16,P+=_>>>16,n[3]=u=_&65535|P<<16,e[3]=k=I&65535|A<<16,D=y,w=B,I=w&65535,A=w>>>16,_=D&65535,P=D>>>16,D=n[4],w=e[4],I+=w&65535,A+=w>>>16,_+=D&65535,P+=D>>>16,A+=I>>>16,_+=A>>>16,P+=_>>>16,n[4]=y=_&65535|P<<16,e[4]=B=I&65535|A<<16,D=g,w=N,I=w&65535,A=w>>>16,_=D&65535,P=D>>>16,D=n[5],w=e[5],I+=w&65535,A+=w>>>16,_+=D&65535,P+=D>>>16,A+=I>>>16,_+=A>>>16,P+=_>>>16,n[5]=g=_&65535|P<<16,e[5]=N=I&65535|A<<16,D=U,w=H,I=w&65535,A=w>>>16,_=D&65535,P=D>>>16,D=n[6],w=e[6],I+=w&65535,A+=w>>>16,_+=D&65535,P+=D>>>16,A+=I>>>16,_+=A>>>16,P+=_>>>16,n[6]=U=_&65535|P<<16,e[6]=H=I&65535|A<<16,D=S,w=z,I=w&65535,A=w>>>16,_=D&65535,P=D>>>16,D=n[7],w=e[7],I+=w&65535,A+=w>>>16,_+=D&65535,P+=D>>>16,A+=I>>>16,_+=A>>>16,P+=_>>>16,n[7]=S=_&65535|P<<16,e[7]=z=I&65535|A<<16,a+=128,l-=128}return a}function es(t){var r=new Kn;r.update(t);var n=r.digest();return r.clean(),n}Ft.hash=es});var kr=Pt(X=>{"use strict";Object.defineProperty(X,"__esModule",{value:!0});X.convertSecretKeyToX25519=X.convertPublicKeyToX25519=X.verify=X.sign=X.extractPublicKeyFromSecretKey=X.generateKeyPair=X.generateKeyPairFromSeed=X.SEED_LENGTH=X.SECRET_KEY_LENGTH=X.PUBLIC_KEY_LENGTH=X.SIGNATURE_LENGTH=void 0;var rs=kn(),me=$n(),Vn=ye();X.SIGNATURE_LENGTH=64;X.PUBLIC_KEY_LENGTH=32;X.SECRET_KEY_LENGTH=64;X.SEED_LENGTH=32;function L(t){let r=new Float64Array(16);if(t)for(let n=0;n<t.length;n++)r[n]=t[n];return r}var ns=new Uint8Array(32);ns[0]=9;var Nr=L(),ue=L([1]),is=L([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),os=L([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),qn=L([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),Hn=L([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),as=L([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function $t(t,r){for(let n=0;n<16;n++)t[n]=r[n]|0}function Br(t){let r=1;for(let n=0;n<16;n++){let e=t[n]+r+65535;r=Math.floor(e/65536),t[n]=e-r*65536}t[0]+=r-1+37*(r-1)}function Jn(t,r,n){let e=~(n-1);for(let i=0;i<16;i++){let a=e&(t[i]^r[i]);t[i]^=a,r[i]^=a}}function ve(t,r){let n=L(),e=L();for(let i=0;i<16;i++)e[i]=r[i];Br(e),Br(e),Br(e);for(let i=0;i<2;i++){n[0]=e[0]-65517;for(let l=1;l<15;l++)n[l]=e[l]-65535-(n[l-1]>>16&1),n[l-1]&=65535;n[15]=e[15]-32767-(n[14]>>16&1);let a=n[15]>>16&1;n[14]&=65535,Jn(e,n,1-a)}for(let i=0;i<16;i++)t[2*i]=e[i]&255,t[2*i+1]=e[i]>>8}function Xn(t,r){let n=0;for(let e=0;e<32;e++)n|=t[e]^r[e];return(1&n-1>>>8)-1}function zn(t,r){let n=new Uint8Array(32),e=new Uint8Array(32);return ve(n,t),ve(e,r),Xn(n,e)}function Zn(t){let r=new Uint8Array(32);return ve(r,t),r[0]&1}function ss(t,r){for(let n=0;n<16;n++)t[n]=r[2*n]+(r[2*n+1]<<8);t[15]&=32767}function Vt(t,r,n){for(let e=0;e<16;e++)t[e]=r[e]+n[e]}function Xt(t,r,n){for(let e=0;e<16;e++)t[e]=r[e]-n[e]}function Y(t,r,n){let e,i,a=0,l=0,c=0,f=0,p=0,u=0,y=0,g=0,U=0,S=0,C=0,M=0,R=0,k=0,B=0,N=0,H=0,z=0,D=0,w=0,$=0,V=0,I=0,A=0,_=0,P=0,ot=0,et=0,Et=0,At=0,Ht=0,rt=n[0],W=n[1],nt=n[2],Q=n[3],at=n[4],st=n[5],ut=n[6],ht=n[7],tt=n[8],pt=n[9],dt=n[10],ft=n[11],ct=n[12],mt=n[13],vt=n[14],Dt=n[15];e=r[0],a+=e*rt,l+=e*W,c+=e*nt,f+=e*Q,p+=e*at,u+=e*st,y+=e*ut,g+=e*ht,U+=e*tt,S+=e*pt,C+=e*dt,M+=e*ft,R+=e*ct,k+=e*mt,B+=e*vt,N+=e*Dt,e=r[1],l+=e*rt,c+=e*W,f+=e*nt,p+=e*Q,u+=e*at,y+=e*st,g+=e*ut,U+=e*ht,S+=e*tt,C+=e*pt,M+=e*dt,R+=e*ft,k+=e*ct,B+=e*mt,N+=e*vt,H+=e*Dt,e=r[2],c+=e*rt,f+=e*W,p+=e*nt,u+=e*Q,y+=e*at,g+=e*st,U+=e*ut,S+=e*ht,C+=e*tt,M+=e*pt,R+=e*dt,k+=e*ft,B+=e*ct,N+=e*mt,H+=e*vt,z+=e*Dt,e=r[3],f+=e*rt,p+=e*W,u+=e*nt,y+=e*Q,g+=e*at,U+=e*st,S+=e*ut,C+=e*ht,M+=e*tt,R+=e*pt,k+=e*dt,B+=e*ft,N+=e*ct,H+=e*mt,z+=e*vt,D+=e*Dt,e=r[4],p+=e*rt,u+=e*W,y+=e*nt,g+=e*Q,U+=e*at,S+=e*st,C+=e*ut,M+=e*ht,R+=e*tt,k+=e*pt,B+=e*dt,N+=e*ft,H+=e*ct,z+=e*mt,D+=e*vt,w+=e*Dt,e=r[5],u+=e*rt,y+=e*W,g+=e*nt,U+=e*Q,S+=e*at,C+=e*st,M+=e*ut,R+=e*ht,k+=e*tt,B+=e*pt,N+=e*dt,H+=e*ft,z+=e*ct,D+=e*mt,w+=e*vt,$+=e*Dt,e=r[6],y+=e*rt,g+=e*W,U+=e*nt,S+=e*Q,C+=e*at,M+=e*st,R+=e*ut,k+=e*ht,B+=e*tt,N+=e*pt,H+=e*dt,z+=e*ft,D+=e*ct,w+=e*mt,$+=e*vt,V+=e*Dt,e=r[7],g+=e*rt,U+=e*W,S+=e*nt,C+=e*Q,M+=e*at,R+=e*st,k+=e*ut,B+=e*ht,N+=e*tt,H+=e*pt,z+=e*dt,D+=e*ft,w+=e*ct,$+=e*mt,V+=e*vt,I+=e*Dt,e=r[8],U+=e*rt,S+=e*W,C+=e*nt,M+=e*Q,R+=e*at,k+=e*st,B+=e*ut,N+=e*ht,H+=e*tt,z+=e*pt,D+=e*dt,w+=e*ft,$+=e*ct,V+=e*mt,I+=e*vt,A+=e*Dt,e=r[9],S+=e*rt,C+=e*W,M+=e*nt,R+=e*Q,k+=e*at,B+=e*st,N+=e*ut,H+=e*ht,z+=e*tt,D+=e*pt,w+=e*dt,$+=e*ft,V+=e*ct,I+=e*mt,A+=e*vt,_+=e*Dt,e=r[10],C+=e*rt,M+=e*W,R+=e*nt,k+=e*Q,B+=e*at,N+=e*st,H+=e*ut,z+=e*ht,D+=e*tt,w+=e*pt,$+=e*dt,V+=e*ft,I+=e*ct,A+=e*mt,_+=e*vt,P+=e*Dt,e=r[11],M+=e*rt,R+=e*W,k+=e*nt,B+=e*Q,N+=e*at,H+=e*st,z+=e*ut,D+=e*ht,w+=e*tt,$+=e*pt,V+=e*dt,I+=e*ft,A+=e*ct,_+=e*mt,P+=e*vt,ot+=e*Dt,e=r[12],R+=e*rt,k+=e*W,B+=e*nt,N+=e*Q,H+=e*at,z+=e*st,D+=e*ut,w+=e*ht,$+=e*tt,V+=e*pt,I+=e*dt,A+=e*ft,_+=e*ct,P+=e*mt,ot+=e*vt,et+=e*Dt,e=r[13],k+=e*rt,B+=e*W,N+=e*nt,H+=e*Q,z+=e*at,D+=e*st,w+=e*ut,$+=e*ht,V+=e*tt,I+=e*pt,A+=e*dt,_+=e*ft,P+=e*ct,ot+=e*mt,et+=e*vt,Et+=e*Dt,e=r[14],B+=e*rt,N+=e*W,H+=e*nt,z+=e*Q,D+=e*at,w+=e*st,$+=e*ut,V+=e*ht,I+=e*tt,A+=e*pt,_+=e*dt,P+=e*ft,ot+=e*ct,et+=e*mt,Et+=e*vt,At+=e*Dt,e=r[15],N+=e*rt,H+=e*W,z+=e*nt,D+=e*Q,w+=e*at,$+=e*st,V+=e*ut,I+=e*ht,A+=e*tt,_+=e*pt,P+=e*dt,ot+=e*ft,et+=e*ct,Et+=e*mt,At+=e*vt,Ht+=e*Dt,a+=38*H,l+=38*z,c+=38*D,f+=38*w,p+=38*$,u+=38*V,y+=38*I,g+=38*A,U+=38*_,S+=38*P,C+=38*ot,M+=38*et,R+=38*Et,k+=38*At,B+=38*Ht,i=1,e=a+i+65535,i=Math.floor(e/65536),a=e-i*65536,e=l+i+65535,i=Math.floor(e/65536),l=e-i*65536,e=c+i+65535,i=Math.floor(e/65536),c=e-i*65536,e=f+i+65535,i=Math.floor(e/65536),f=e-i*65536,e=p+i+65535,i=Math.floor(e/65536),p=e-i*65536,e=u+i+65535,i=Math.floor(e/65536),u=e-i*65536,e=y+i+65535,i=Math.floor(e/65536),y=e-i*65536,e=g+i+65535,i=Math.floor(e/65536),g=e-i*65536,e=U+i+65535,i=Math.floor(e/65536),U=e-i*65536,e=S+i+65535,i=Math.floor(e/65536),S=e-i*65536,e=C+i+65535,i=Math.floor(e/65536),C=e-i*65536,e=M+i+65535,i=Math.floor(e/65536),M=e-i*65536,e=R+i+65535,i=Math.floor(e/65536),R=e-i*65536,e=k+i+65535,i=Math.floor(e/65536),k=e-i*65536,e=B+i+65535,i=Math.floor(e/65536),B=e-i*65536,e=N+i+65535,i=Math.floor(e/65536),N=e-i*65536,a+=i-1+37*(i-1),i=1,e=a+i+65535,i=Math.floor(e/65536),a=e-i*65536,e=l+i+65535,i=Math.floor(e/65536),l=e-i*65536,e=c+i+65535,i=Math.floor(e/65536),c=e-i*65536,e=f+i+65535,i=Math.floor(e/65536),f=e-i*65536,e=p+i+65535,i=Math.floor(e/65536),p=e-i*65536,e=u+i+65535,i=Math.floor(e/65536),u=e-i*65536,e=y+i+65535,i=Math.floor(e/65536),y=e-i*65536,e=g+i+65535,i=Math.floor(e/65536),g=e-i*65536,e=U+i+65535,i=Math.floor(e/65536),U=e-i*65536,e=S+i+65535,i=Math.floor(e/65536),S=e-i*65536,e=C+i+65535,i=Math.floor(e/65536),C=e-i*65536,e=M+i+65535,i=Math.floor(e/65536),M=e-i*65536,e=R+i+65535,i=Math.floor(e/65536),R=e-i*65536,e=k+i+65535,i=Math.floor(e/65536),k=e-i*65536,e=B+i+65535,i=Math.floor(e/65536),B=e-i*65536,e=N+i+65535,i=Math.floor(e/65536),N=e-i*65536,a+=i-1+37*(i-1),t[0]=a,t[1]=l,t[2]=c,t[3]=f,t[4]=p,t[5]=u,t[6]=y,t[7]=g,t[8]=U,t[9]=S,t[10]=C,t[11]=M,t[12]=R,t[13]=k,t[14]=B,t[15]=N}function Jt(t,r){Y(t,r,r)}function Wn(t,r){let n=L(),e;for(e=0;e<16;e++)n[e]=r[e];for(e=253;e>=0;e--)Jt(n,n),e!==2&&e!==4&&Y(n,n,r);for(e=0;e<16;e++)t[e]=n[e]}function us(t,r){let n=L(),e;for(e=0;e<16;e++)n[e]=r[e];for(e=250;e>=0;e--)Jt(n,n),e!==1&&Y(n,n,r);for(e=0;e<16;e++)t[e]=n[e]}function Fr(t,r){let n=L(),e=L(),i=L(),a=L(),l=L(),c=L(),f=L(),p=L(),u=L();Xt(n,t[1],t[0]),Xt(u,r[1],r[0]),Y(n,n,u),Vt(e,t[0],t[1]),Vt(u,r[0],r[1]),Y(e,e,u),Y(i,t[3],r[3]),Y(i,i,os),Y(a,t[2],r[2]),Vt(a,a,a),Xt(l,e,n),Xt(c,a,i),Vt(f,a,i),Vt(p,e,n),Y(t[0],l,c),Y(t[1],p,f),Y(t[2],f,c),Y(t[3],l,p)}function Gn(t,r,n){for(let e=0;e<4;e++)Jn(t[e],r[e],n)}function Tr(t,r){let n=L(),e=L(),i=L();Wn(i,r[2]),Y(n,r[0],i),Y(e,r[1],i),ve(t,e),t[31]^=Zn(n)<<7}function Yn(t,r,n){$t(t[0],Nr),$t(t[1],ue),$t(t[2],ue),$t(t[3],Nr);for(let e=255;e>=0;--e){let i=n[e/8|0]>>(e&7)&1;Gn(t,r,i),Fr(r,t),Fr(t,t),Gn(t,r,i)}}function Mr(t,r){let n=[L(),L(),L(),L()];$t(n[0],qn),$t(n[1],Hn),$t(n[2],ue),Y(n[3],qn,Hn),Yn(t,n,r)}function Qn(t){if(t.length!==X.SEED_LENGTH)throw new Error(`ed25519: seed must be ${X.SEED_LENGTH} bytes`);let r=(0,me.hash)(t);r[0]&=248,r[31]&=127,r[31]|=64;let n=new Uint8Array(32),e=[L(),L(),L(),L()];Mr(e,r),Tr(n,e);let i=new Uint8Array(64);return i.set(t),i.set(n,32),{publicKey:n,secretKey:i}}X.generateKeyPairFromSeed=Qn;function fs(t){let r=(0,rs.randomBytes)(32,t),n=Qn(r);return(0,Vn.wipe)(r),n}X.generateKeyPair=fs;function cs(t){if(t.length!==X.SECRET_KEY_LENGTH)throw new Error(`ed25519: secret key must be ${X.SECRET_KEY_LENGTH} bytes`);return new Uint8Array(t.subarray(32))}X.extractPublicKeyFromSecretKey=cs;var Lr=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 jn(t,r){let n,e,i,a;for(e=63;e>=32;--e){for(n=0,i=e-32,a=e-12;i<a;++i)r[i]+=n-16*r[e]*Lr[i-(e-32)],n=Math.floor((r[i]+128)/256),r[i]-=n*256;r[i]+=n,r[e]=0}for(n=0,i=0;i<32;i++)r[i]+=n-(r[31]>>4)*Lr[i],n=r[i]>>8,r[i]&=255;for(i=0;i<32;i++)r[i]-=n*Lr[i];for(e=0;e<32;e++)r[e+1]+=r[e]>>8,t[e]=r[e]&255}function Rr(t){let r=new Float64Array(64);for(let n=0;n<64;n++)r[n]=t[n];for(let n=0;n<64;n++)t[n]=0;jn(t,r)}function ls(t,r){let n=new Float64Array(64),e=[L(),L(),L(),L()],i=(0,me.hash)(t.subarray(0,32));i[0]&=248,i[31]&=127,i[31]|=64;let a=new Uint8Array(64);a.set(i.subarray(32),32);let l=new me.SHA512;l.update(a.subarray(32)),l.update(r);let c=l.digest();l.clean(),Rr(c),Mr(e,c),Tr(a,e),l.reset(),l.update(a.subarray(0,32)),l.update(t.subarray(32)),l.update(r);let f=l.digest();Rr(f);for(let p=0;p<32;p++)n[p]=c[p];for(let p=0;p<32;p++)for(let u=0;u<32;u++)n[p+u]+=f[p]*i[u];return jn(a.subarray(32),n),a}X.sign=ls;function ti(t,r){let n=L(),e=L(),i=L(),a=L(),l=L(),c=L(),f=L();return $t(t[2],ue),ss(t[1],r),Jt(i,t[1]),Y(a,i,is),Xt(i,i,t[2]),Vt(a,t[2],a),Jt(l,a),Jt(c,l),Y(f,c,l),Y(n,f,i),Y(n,n,a),us(n,n),Y(n,n,i),Y(n,n,a),Y(n,n,a),Y(t[0],n,a),Jt(e,t[0]),Y(e,e,a),zn(e,i)&&Y(t[0],t[0],as),Jt(e,t[0]),Y(e,e,a),zn(e,i)?-1:(Zn(t[0])===r[31]>>7&&Xt(t[0],Nr,t[0]),Y(t[3],t[0],t[1]),0)}function ps(t,r,n){let e=new Uint8Array(32),i=[L(),L(),L(),L()],a=[L(),L(),L(),L()];if(n.length!==X.SIGNATURE_LENGTH)throw new Error(`ed25519: signature must be ${X.SIGNATURE_LENGTH} bytes`);if(ti(a,t))return!1;let l=new me.SHA512;l.update(n.subarray(0,32)),l.update(t),l.update(r);let c=l.digest();return Rr(c),Yn(i,a,c),Mr(a,n.subarray(32)),Fr(i,a),Tr(e,i),!Xn(n,e)}X.verify=ps;function ds(t){let r=[L(),L(),L(),L()];if(ti(r,t))throw new Error("Ed25519: invalid public key");let n=L(),e=L(),i=r[1];Vt(n,ue,i),Xt(e,ue,i),Wn(e,e),Y(n,n,e);let a=new Uint8Array(32);return ve(a,n),a}X.convertPublicKeyToX25519=ds;function hs(t){let r=(0,me.hash)(t.subarray(0,32));r[0]&=248,r[31]&=127,r[31]|=64;let n=new Uint8Array(r.subarray(0,32));return(0,Vn.wipe)(r),n}X.convertSecretKeyToX25519=hs});var li=Pt((Wf,qe)=>{"use strict";var yt=function(t){"use strict";var r=1e7,n=7,e=9007199254740992,i=g(e),a="0123456789abcdefghijklmnopqrstuvwxyz",l=typeof BigInt=="function";function c(o,s,d,h){return typeof o>"u"?c[0]:typeof s<"u"?+s==10&&!d?T(o):Dt(o,s,d,h):T(o)}function f(o,s){this.value=o,this.sign=s,this.isSmall=!1}f.prototype=Object.create(c.prototype);function p(o){this.value=o,this.sign=o<0,this.isSmall=!0}p.prototype=Object.create(c.prototype);function u(o){this.value=o}u.prototype=Object.create(c.prototype);function y(o){return-e<o&&o<e}function g(o){return o<1e7?[o]:o<1e14?[o%1e7,Math.floor(o/1e7)]:[o%1e7,Math.floor(o/1e7)%1e7,Math.floor(o/1e14)]}function U(o){S(o);var s=o.length;if(s<4&&At(o,i)<0)switch(s){case 0:return 0;case 1:return o[0];case 2:return o[0]+o[1]*r;default:return o[0]+(o[1]+o[2]*r)*r}return o}function S(o){for(var s=o.length;o[--s]===0;);o.length=s+1}function C(o){for(var s=new Array(o),d=-1;++d<o;)s[d]=0;return s}function M(o){return o>0?Math.floor(o):Math.ceil(o)}function R(o,s){var d=o.length,h=s.length,v=new Array(d),m=0,x=r,b,E;for(E=0;E<h;E++)b=o[E]+s[E]+m,m=b>=x?1:0,v[E]=b-m*x;for(;E<d;)b=o[E]+m,m=b===x?1:0,v[E++]=b-m*x;return m>0&&v.push(m),v}function k(o,s){return o.length>=s.length?R(o,s):R(s,o)}function B(o,s){var d=o.length,h=new Array(d),v=r,m,x;for(x=0;x<d;x++)m=o[x]-v+s,s=Math.floor(m/v),h[x]=m-s*v,s+=1;for(;s>0;)h[x++]=s%v,s=Math.floor(s/v);return h}f.prototype.add=function(o){var s=T(o);if(this.sign!==s.sign)return this.subtract(s.negate());var d=this.value,h=s.value;return s.isSmall?new f(B(d,Math.abs(h)),this.sign):new f(k(d,h),this.sign)},f.prototype.plus=f.prototype.add,p.prototype.add=function(o){var s=T(o),d=this.value;if(d<0!==s.sign)return this.subtract(s.negate());var h=s.value;if(s.isSmall){if(y(d+h))return new p(d+h);h=g(Math.abs(h))}return new f(B(h,Math.abs(d)),d<0)},p.prototype.plus=p.prototype.add,u.prototype.add=function(o){return new u(this.value+T(o).value)},u.prototype.plus=u.prototype.add;function N(o,s){var d=o.length,h=s.length,v=new Array(d),m=0,x=r,b,E;for(b=0;b<h;b++)E=o[b]-m-s[b],E<0?(E+=x,m=1):m=0,v[b]=E;for(b=h;b<d;b++){if(E=o[b]-m,E<0)E+=x;else{v[b++]=E;break}v[b]=E}for(;b<d;b++)v[b]=o[b];return S(v),v}function H(o,s,d){var h;return At(o,s)>=0?h=N(o,s):(h=N(s,o),d=!d),h=U(h),typeof h=="number"?(d&&(h=-h),new p(h)):new f(h,d)}function z(o,s,d){var h=o.length,v=new Array(h),m=-s,x=r,b,E;for(b=0;b<h;b++)E=o[b]+m,m=Math.floor(E/x),E%=x,v[b]=E<0?E+x:E;return v=U(v),typeof v=="number"?(d&&(v=-v),new p(v)):new f(v,d)}f.prototype.subtract=function(o){var s=T(o);if(this.sign!==s.sign)return this.add(s.negate());var d=this.value,h=s.value;return s.isSmall?z(d,Math.abs(h),this.sign):H(d,h,this.sign)},f.prototype.minus=f.prototype.subtract,p.prototype.subtract=function(o){var s=T(o),d=this.value;if(d<0!==s.sign)return this.add(s.negate());var h=s.value;return s.isSmall?new p(d-h):z(h,Math.abs(d),d>=0)},p.prototype.minus=p.prototype.subtract,u.prototype.subtract=function(o){return new u(this.value-T(o).value)},u.prototype.minus=u.prototype.subtract,f.prototype.negate=function(){return new f(this.value,!this.sign)},p.prototype.negate=function(){var o=this.sign,s=new p(-this.value);return s.sign=!o,s},u.prototype.negate=function(){return new u(-this.value)},f.prototype.abs=function(){return new f(this.value,!1)},p.prototype.abs=function(){return new p(Math.abs(this.value))},u.prototype.abs=function(){return new u(this.value>=0?this.value:-this.value)};function D(o,s){var d=o.length,h=s.length,v=d+h,m=C(v),x=r,b,E,O,G,K;for(O=0;O<d;++O){G=o[O];for(var J=0;J<h;++J)K=s[J],b=G*K+m[O+J],E=Math.floor(b/x),m[O+J]=b-E*x,m[O+J+1]+=E}return S(m),m}function w(o,s){var d=o.length,h=new Array(d),v=r,m=0,x,b;for(b=0;b<d;b++)x=o[b]*s+m,m=Math.floor(x/v),h[b]=x-m*v;for(;m>0;)h[b++]=m%v,m=Math.floor(m/v);return h}function $(o,s){for(var d=[];s-- >0;)d.push(0);return d.concat(o)}function V(o,s){var d=Math.max(o.length,s.length);if(d<=30)return D(o,s);d=Math.ceil(d/2);var h=o.slice(d),v=o.slice(0,d),m=s.slice(d),x=s.slice(0,d),b=V(v,x),E=V(h,m),O=V(k(v,h),k(x,m)),G=k(k(b,$(N(N(O,b),E),d)),$(E,2*d));return S(G),G}function I(o,s){return-.012*o-.012*s+15e-6*o*s>0}f.prototype.multiply=function(o){var s=T(o),d=this.value,h=s.value,v=this.sign!==s.sign,m;if(s.isSmall){if(h===0)return c[0];if(h===1)return this;if(h===-1)return this.negate();if(m=Math.abs(h),m<r)return new f(w(d,m),v);h=g(m)}return I(d.length,h.length)?new f(V(d,h),v):new f(D(d,h),v)},f.prototype.times=f.prototype.multiply;function A(o,s,d){return o<r?new f(w(s,o),d):new f(D(s,g(o)),d)}p.prototype._multiplyBySmall=function(o){return y(o.value*this.value)?new p(o.value*this.value):A(Math.abs(o.value),g(Math.abs(this.value)),this.sign!==o.sign)},f.prototype._multiplyBySmall=function(o){return o.value===0?c[0]:o.value===1?this:o.value===-1?this.negate():A(Math.abs(o.value),this.value,this.sign!==o.sign)},p.prototype.multiply=function(o){return T(o)._multiplyBySmall(this)},p.prototype.times=p.prototype.multiply,u.prototype.multiply=function(o){return new u(this.value*T(o).value)},u.prototype.times=u.prototype.multiply;function _(o){var s=o.length,d=C(s+s),h=r,v,m,x,b,E;for(x=0;x<s;x++){b=o[x],m=0-b*b;for(var O=x;O<s;O++)E=o[O],v=2*(b*E)+d[x+O]+m,m=Math.floor(v/h),d[x+O]=v-m*h;d[x+s]=m}return S(d),d}f.prototype.square=function(){return new f(_(this.value),!1)},p.prototype.square=function(){var o=this.value*this.value;return y(o)?new p(o):new f(_(g(Math.abs(this.value))),!1)},u.prototype.square=function(o){return new u(this.value*this.value)};function P(o,s){var d=o.length,h=s.length,v=r,m=C(s.length),x=s[h-1],b=Math.ceil(v/(2*x)),E=w(o,b),O=w(s,b),G,K,J,_t,St,Xe,Ze;for(E.length<=d&&E.push(0),O.push(0),x=O[h-1],K=d-h;K>=0;K--){for(G=v-1,E[K+h]!==x&&(G=Math.floor((E[K+h]*v+E[K+h-1])/x)),J=0,_t=0,Xe=O.length,St=0;St<Xe;St++)J+=G*O[St],Ze=Math.floor(J/v),_t+=E[K+St]-(J-Ze*v),J=Ze,_t<0?(E[K+St]=_t+v,_t=-1):(E[K+St]=_t,_t=0);for(;_t!==0;){for(G-=1,J=0,St=0;St<Xe;St++)J+=E[K+St]-v+O[St],J<0?(E[K+St]=J+v,J=0):(E[K+St]=J,J=1);_t+=J}m[K]=G}return E=et(E,b)[0],[U(m),U(E)]}function ot(o,s){for(var d=o.length,h=s.length,v=[],m=[],x=r,b,E,O,G,K;d;){if(m.unshift(o[--d]),S(m),At(m,s)<0){v.push(0);continue}E=m.length,O=m[E-1]*x+m[E-2],G=s[h-1]*x+s[h-2],E>h&&(O=(O+1)*x),b=Math.ceil(O/G);do{if(K=w(s,b),At(K,m)<=0)break;b--}while(b);v.push(b),m=N(m,K)}return v.reverse(),[U(v),U(m)]}function et(o,s){var d=o.length,h=C(d),v=r,m,x,b,E;for(b=0,m=d-1;m>=0;--m)E=b*v+o[m],x=M(E/s),b=E-x*s,h[m]=x|0;return[h,b|0]}function Et(o,s){var d,h=T(s);if(l)return[new u(o.value/h.value),new u(o.value%h.value)];var v=o.value,m=h.value,x;if(m===0)throw new Error("Cannot divide by zero");if(o.isSmall)return h.isSmall?[new p(M(v/m)),new p(v%m)]:[c[0],o];if(h.isSmall){if(m===1)return[o,c[0]];if(m==-1)return[o.negate(),c[0]];var b=Math.abs(m);if(b<r){d=et(v,b),x=U(d[0]);var E=d[1];return o.sign&&(E=-E),typeof x=="number"?(o.sign!==h.sign&&(x=-x),[new p(x),new p(E)]):[new f(x,o.sign!==h.sign),new p(E)]}m=g(b)}var O=At(v,m);if(O===-1)return[c[0],o];if(O===0)return[c[o.sign===h.sign?1:-1],c[0]];v.length+m.length<=200?d=P(v,m):d=ot(v,m),x=d[0];var G=o.sign!==h.sign,K=d[1],J=o.sign;return typeof x=="number"?(G&&(x=-x),x=new p(x)):x=new f(x,G),typeof K=="number"?(J&&(K=-K),K=new p(K)):K=new f(K,J),[x,K]}f.prototype.divmod=function(o){var s=Et(this,o);return{quotient:s[0],remainder:s[1]}},u.prototype.divmod=p.prototype.divmod=f.prototype.divmod,f.prototype.divide=function(o){return Et(this,o)[0]},u.prototype.over=u.prototype.divide=function(o){return new u(this.value/T(o).value)},p.prototype.over=p.prototype.divide=f.prototype.over=f.prototype.divide,f.prototype.mod=function(o){return Et(this,o)[1]},u.prototype.mod=u.prototype.remainder=function(o){return new u(this.value%T(o).value)},p.prototype.remainder=p.prototype.mod=f.prototype.remainder=f.prototype.mod,f.prototype.pow=function(o){var s=T(o),d=this.value,h=s.value,v,m,x;if(h===0)return c[1];if(d===0)return c[0];if(d===1)return c[1];if(d===-1)return s.isEven()?c[1]:c[-1];if(s.sign)return c[0];if(!s.isSmall)throw new Error("The exponent "+s.toString()+" is too large.");if(this.isSmall&&y(v=Math.pow(d,h)))return new p(M(v));for(m=this,x=c[1];h&!0&&(x=x.times(m),--h),h!==0;)h/=2,m=m.square();return x},p.prototype.pow=f.prototype.pow,u.prototype.pow=function(o){var s=T(o),d=this.value,h=s.value,v=BigInt(0),m=BigInt(1),x=BigInt(2);if(h===v)return c[1];if(d===v)return c[0];if(d===m)return c[1];if(d===BigInt(-1))return s.isEven()?c[1]:c[-1];if(s.isNegative())return new u(v);for(var b=this,E=c[1];(h&m)===m&&(E=E.times(b),--h),h!==v;)h/=x,b=b.square();return E},f.prototype.modPow=function(o,s){if(o=T(o),s=T(s),s.isZero())throw new Error("Cannot take modPow with modulus 0");var d=c[1],h=this.mod(s);for(o.isNegative()&&(o=o.multiply(c[-1]),h=h.modInv(s));o.isPositive();){if(h.isZero())return c[0];o.isOdd()&&(d=d.multiply(h).mod(s)),o=o.divide(2),h=h.square().mod(s)}return d},u.prototype.modPow=p.prototype.modPow=f.prototype.modPow;function At(o,s){if(o.length!==s.length)return o.length>s.length?1:-1;for(var d=o.length-1;d>=0;d--)if(o[d]!==s[d])return o[d]>s[d]?1:-1;return 0}f.prototype.compareAbs=function(o){var s=T(o),d=this.value,h=s.value;return s.isSmall?1:At(d,h)},p.prototype.compareAbs=function(o){var s=T(o),d=Math.abs(this.value),h=s.value;return s.isSmall?(h=Math.abs(h),d===h?0:d>h?1:-1):-1},u.prototype.compareAbs=function(o){var s=this.value,d=T(o).value;return s=s>=0?s:-s,d=d>=0?d:-d,s===d?0:s>d?1:-1},f.prototype.compare=function(o){if(o===1/0)return-1;if(o===-1/0)return 1;var s=T(o),d=this.value,h=s.value;return this.sign!==s.sign?s.sign?1:-1:s.isSmall?this.sign?-1:1:At(d,h)*(this.sign?-1:1)},f.prototype.compareTo=f.prototype.compare,p.prototype.compare=function(o){if(o===1/0)return-1;if(o===-1/0)return 1;var s=T(o),d=this.value,h=s.value;return s.isSmall?d==h?0:d>h?1:-1:d<0!==s.sign?d<0?-1:1:d<0?1:-1},p.prototype.compareTo=p.prototype.compare,u.prototype.compare=function(o){if(o===1/0)return-1;if(o===-1/0)return 1;var s=this.value,d=T(o).value;return s===d?0:s>d?1:-1},u.prototype.compareTo=u.prototype.compare,f.prototype.equals=function(o){return this.compare(o)===0},u.prototype.eq=u.prototype.equals=p.prototype.eq=p.prototype.equals=f.prototype.eq=f.prototype.equals,f.prototype.notEquals=function(o){return this.compare(o)!==0},u.prototype.neq=u.prototype.notEquals=p.prototype.neq=p.prototype.notEquals=f.prototype.neq=f.prototype.notEquals,f.prototype.greater=function(o){return this.compare(o)>0},u.prototype.gt=u.prototype.greater=p.prototype.gt=p.prototype.greater=f.prototype.gt=f.prototype.greater,f.prototype.lesser=function(o){return this.compare(o)<0},u.prototype.lt=u.prototype.lesser=p.prototype.lt=p.prototype.lesser=f.prototype.lt=f.prototype.lesser,f.prototype.greaterOrEquals=function(o){return this.compare(o)>=0},u.prototype.geq=u.prototype.greaterOrEquals=p.prototype.geq=p.prototype.greaterOrEquals=f.prototype.geq=f.prototype.greaterOrEquals,f.prototype.lesserOrEquals=function(o){return this.compare(o)<=0},u.prototype.leq=u.prototype.lesserOrEquals=p.prototype.leq=p.prototype.lesserOrEquals=f.prototype.leq=f.prototype.lesserOrEquals,f.prototype.isEven=function(){return(this.value[0]&1)===0},p.prototype.isEven=function(){return(this.value&1)===0},u.prototype.isEven=function(){return(this.value&BigInt(1))===BigInt(0)},f.prototype.isOdd=function(){return(this.value[0]&1)===1},p.prototype.isOdd=function(){return(this.value&1)===1},u.prototype.isOdd=function(){return(this.value&BigInt(1))===BigInt(1)},f.prototype.isPositive=function(){return!this.sign},p.prototype.isPositive=function(){return this.value>0},u.prototype.isPositive=p.prototype.isPositive,f.prototype.isNegative=function(){return this.sign},p.prototype.isNegative=function(){return this.value<0},u.prototype.isNegative=p.prototype.isNegative,f.prototype.isUnit=function(){return!1},p.prototype.isUnit=function(){return Math.abs(this.value)===1},u.prototype.isUnit=function(){return this.abs().value===BigInt(1)},f.prototype.isZero=function(){return!1},p.prototype.isZero=function(){return this.value===0},u.prototype.isZero=function(){return this.value===BigInt(0)},f.prototype.isDivisibleBy=function(o){var s=T(o);return s.isZero()?!1:s.isUnit()?!0:s.compareAbs(2)===0?this.isEven():this.mod(s).isZero()},u.prototype.isDivisibleBy=p.prototype.isDivisibleBy=f.prototype.isDivisibleBy;function Ht(o){var s=o.abs();if(s.isUnit())return!1;if(s.equals(2)||s.equals(3)||s.equals(5))return!0;if(s.isEven()||s.isDivisibleBy(3)||s.isDivisibleBy(5))return!1;if(s.lesser(49))return!0}function rt(o,s){for(var d=o.prev(),h=d,v=0,m,x,b,E;h.isEven();)h=h.divide(2),v++;t:for(b=0;b<s.length;b++)if(!o.lesser(s[b])&&(E=yt(s[b]).modPow(h,o),!(E.isUnit()||E.equals(d)))){for(m=v-1;m!=0;m--){if(E=E.square().mod(o),E.isUnit())return!1;if(E.equals(d))continue t}return!1}return!0}f.prototype.isPrime=function(o){var s=Ht(this);if(s!==t)return s;var d=this.abs(),h=d.bitLength();if(h<=64)return rt(d,[2,3,5,7,11,13,17,19,23,29,31,37]);for(var v=Math.log(2)*h.toJSNumber(),m=Math.ceil(o===!0?2*Math.pow(v,2):v),x=[],b=0;b<m;b++)x.push(yt(b+2));return rt(d,x)},u.prototype.isPrime=p.prototype.isPrime=f.prototype.isPrime,f.prototype.isProbablePrime=function(o,s){var d=Ht(this);if(d!==t)return d;for(var h=this.abs(),v=o===t?5:o,m=[],x=0;x<v;x++)m.push(yt.randBetween(2,h.minus(2),s));return rt(h,m)},u.prototype.isProbablePrime=p.prototype.isProbablePrime=f.prototype.isProbablePrime,f.prototype.modInv=function(o){for(var s=yt.zero,d=yt.one,h=T(o),v=this.abs(),m,x,b;!v.isZero();)m=h.divide(v),x=s,b=h,s=d,h=v,d=x.subtract(m.multiply(d)),v=b.subtract(m.multiply(v));if(!h.isUnit())throw new Error(this.toString()+" and "+o.toString()+" are not co-prime");return s.compare(0)===-1&&(s=s.add(o)),this.isNegative()?s.negate():s},u.prototype.modInv=p.prototype.modInv=f.prototype.modInv,f.prototype.next=function(){var o=this.value;return this.sign?z(o,1,this.sign):new f(B(o,1),this.sign)},p.prototype.next=function(){var o=this.value;return o+1<e?new p(o+1):new f(i,!1)},u.prototype.next=function(){return new u(this.value+BigInt(1))},f.prototype.prev=function(){var o=this.value;return this.sign?new f(B(o,1),!0):z(o,1,this.sign)},p.prototype.prev=function(){var o=this.value;return o-1>-e?new p(o-1):new f(i,!0)},u.prototype.prev=function(){return new u(this.value-BigInt(1))};for(var W=[1];2*W[W.length-1]<=r;)W.push(2*W[W.length-1]);var nt=W.length,Q=W[nt-1];function at(o){return Math.abs(o)<=r}f.prototype.shiftLeft=function(o){var s=T(o).toJSNumber();if(!at(s))throw new Error(String(s)+" is too large for shifting.");if(s<0)return this.shiftRight(-s);var d=this;if(d.isZero())return d;for(;s>=nt;)d=d.multiply(Q),s-=nt-1;return d.multiply(W[s])},u.prototype.shiftLeft=p.prototype.shiftLeft=f.prototype.shiftLeft,f.prototype.shiftRight=function(o){var s,d=T(o).toJSNumber();if(!at(d))throw new Error(String(d)+" is too large for shifting.");if(d<0)return this.shiftLeft(-d);for(var h=this;d>=nt;){if(h.isZero()||h.isNegative()&&h.isUnit())return h;s=Et(h,Q),h=s[1].isNegative()?s[0].prev():s[0],d-=nt-1}return s=Et(h,W[d]),s[1].isNegative()?s[0].prev():s[0]},u.prototype.shiftRight=p.prototype.shiftRight=f.prototype.shiftRight;function st(o,s,d){s=T(s);for(var h=o.isNegative(),v=s.isNegative(),m=h?o.not():o,x=v?s.not():s,b=0,E=0,O=null,G=null,K=[];!m.isZero()||!x.isZero();)O=Et(m,Q),b=O[1].toJSNumber(),h&&(b=Q-1-b),G=Et(x,Q),E=G[1].toJSNumber(),v&&(E=Q-1-E),m=O[0],x=G[0],K.push(d(b,E));for(var J=d(h?1:0,v?1:0)!==0?yt(-1):yt(0),_t=K.length-1;_t>=0;_t-=1)J=J.multiply(Q).add(yt(K[_t]));return J}f.prototype.not=function(){return this.negate().prev()},u.prototype.not=p.prototype.not=f.prototype.not,f.prototype.and=function(o){return st(this,o,function(s,d){return s&d})},u.prototype.and=p.prototype.and=f.prototype.and,f.prototype.or=function(o){return st(this,o,function(s,d){return s|d})},u.prototype.or=p.prototype.or=f.prototype.or,f.prototype.xor=function(o){return st(this,o,function(s,d){return s^d})},u.prototype.xor=p.prototype.xor=f.prototype.xor;var ut=1<<30,ht=(r&-r)*(r&-r)|ut;function tt(o){var s=o.value,d=typeof s=="number"?s|ut:typeof s=="bigint"?s|BigInt(ut):s[0]+s[1]*r|ht;return d&-d}function pt(o,s){if(s.compareTo(o)<=0){var d=pt(o,s.square(s)),h=d.p,v=d.e,m=h.multiply(s);return m.compareTo(o)<=0?{p:m,e:v*2+1}:{p:h,e:v*2}}return{p:yt(1),e:0}}f.prototype.bitLength=function(){var o=this;return o.compareTo(yt(0))<0&&(o=o.negate().subtract(yt(1))),o.compareTo(yt(0))===0?yt(0):yt(pt(o,yt(2)).e).add(yt(1))},u.prototype.bitLength=p.prototype.bitLength=f.prototype.bitLength;function dt(o,s){return o=T(o),s=T(s),o.greater(s)?o:s}function ft(o,s){return o=T(o),s=T(s),o.lesser(s)?o:s}function ct(o,s){if(o=T(o).abs(),s=T(s).abs(),o.equals(s))return o;if(o.isZero())return s;if(s.isZero())return o;for(var d=c[1],h,v;o.isEven()&&s.isEven();)h=ft(tt(o),tt(s)),o=o.divide(h),s=s.divide(h),d=d.multiply(h);for(;o.isEven();)o=o.divide(tt(o));do{for(;s.isEven();)s=s.divide(tt(s));o.greater(s)&&(v=s,s=o,o=v),s=s.subtract(o)}while(!s.isZero());return d.isUnit()?o:o.multiply(d)}function mt(o,s){return o=T(o).abs(),s=T(s).abs(),o.divide(ct(o,s)).multiply(s)}function vt(o,s,d){o=T(o),s=T(s);var h=d||Math.random,v=ft(o,s),m=dt(o,s),x=m.subtract(v).add(1);if(x.isSmall)return v.add(Math.floor(h()*x));for(var b=ce(x,r).value,E=[],O=!0,G=0;G<b.length;G++){var K=O?b[G]+(G+1<b.length?b[G+1]/r:0):r,J=M(h()*K);E.push(J),J<b[G]&&(O=!1)}return v.add(c.fromArray(E,r,!1))}var Dt=function(o,s,d,h){d=d||a,o=String(o),h||(o=o.toLowerCase(),d=d.toLowerCase());var v=o.length,m,x=Math.abs(s),b={};for(m=0;m<d.length;m++)b[d[m]]=m;for(m=0;m<v;m++){var E=o[m];if(E!=="-"&&E in b&&b[E]>=x){if(E==="1"&&x===1)continue;throw new Error(E+" is not a valid digit in base "+s+".")}}s=T(s);var O=[],G=o[0]==="-";for(m=G?1:0;m<o.length;m++){var E=o[m];if(E in b)O.push(T(b[E]));else if(E==="<"){var K=m;do m++;while(o[m]!==">"&&m<o.length);O.push(T(o.slice(K+1,m)))}else throw new Error(E+" is not a valid character")}return jr(O,s,G)};function jr(o,s,d){var h=c[0],v=c[1],m;for(m=o.length-1;m>=0;m--)h=h.add(o[m].times(v)),v=v.times(s);return d?h.negate():h}function uo(o,s){return s=s||a,o<s.length?s[o]:"<"+o+">"}function ce(o,s){if(s=yt(s),s.isZero()){if(o.isZero())return{value:[0],isNegative:!1};throw new Error("Cannot convert nonzero numbers to base 0.")}if(s.equals(-1)){if(o.isZero())return{value:[0],isNegative:!1};if(o.isNegative())return{value:[].concat.apply([],Array.apply(null,Array(-o.toJSNumber())).map(Array.prototype.valueOf,[1,0])),isNegative:!1};var d=Array.apply(null,Array(o.toJSNumber()-1)).map(Array.prototype.valueOf,[0,1]);return d.unshift([1]),{value:[].concat.apply([],d),isNegative:!1}}var h=!1;if(o.isNegative()&&s.isPositive()&&(h=!0,o=o.abs()),s.isUnit())return o.isZero()?{value:[0],isNegative:!1}:{value:Array.apply(null,Array(o.toJSNumber())).map(Number.prototype.valueOf,1),isNegative:h};for(var v=[],m=o,x;m.isNegative()||m.compareAbs(s)>=0;){x=m.divmod(s),m=x.quotient;var b=x.remainder;b.isNegative()&&(b=s.minus(b).abs(),m=m.next()),v.push(b.toJSNumber())}return v.push(m.toJSNumber()),{value:v.reverse(),isNegative:h}}function tn(o,s,d){var h=ce(o,s);return(h.isNegative?"-":"")+h.value.map(function(v){return uo(v,d)}).join("")}f.prototype.toArray=function(o){return ce(this,o)},p.prototype.toArray=function(o){return ce(this,o)},u.prototype.toArray=function(o){return ce(this,o)},f.prototype.toString=function(o,s){if(o===t&&(o=10),o!==10)return tn(this,o,s);for(var d=this.value,h=d.length,v=String(d[--h]),m="0000000",x;--h>=0;)x=String(d[h]),v+=m.slice(x.length)+x;var b=this.sign?"-":"";return b+v},p.prototype.toString=function(o,s){return o===t&&(o=10),o!=10?tn(this,o,s):String(this.value)},u.prototype.toString=p.prototype.toString,u.prototype.toJSON=f.prototype.toJSON=p.prototype.toJSON=function(){return this.toString()},f.prototype.valueOf=function(){return parseInt(this.toString(),10)},f.prototype.toJSNumber=f.prototype.valueOf,p.prototype.valueOf=function(){return this.value},p.prototype.toJSNumber=p.prototype.valueOf,u.prototype.valueOf=u.prototype.toJSNumber=function(){return parseInt(this.toString(),10)};function en(o){if(y(+o)){var s=+o;if(s===M(s))return l?new u(BigInt(s)):new p(s);throw new Error("Invalid integer: "+o)}var d=o[0]==="-";d&&(o=o.slice(1));var h=o.split(/e/i);if(h.length>2)throw new Error("Invalid integer: "+h.join("e"));if(h.length===2){var v=h[1];if(v[0]==="+"&&(v=v.slice(1)),v=+v,v!==M(v)||!y(v))throw new Error("Invalid integer: "+v+" is not a valid exponent.");var m=h[0],x=m.indexOf(".");if(x>=0&&(v-=m.length-x-1,m=m.slice(0,x)+m.slice(x+1)),v<0)throw new Error("Cannot include negative exponent part for integers");m+=new Array(v+1).join("0"),o=m}var b=/^([0-9][0-9]*)$/.test(o);if(!b)throw new Error("Invalid integer: "+o);if(l)return new u(BigInt(d?"-"+o:o));for(var E=[],O=o.length,G=n,K=O-G;O>0;)E.push(+o.slice(K,O)),K-=G,K<0&&(K=0),O-=G;return S(E),new f(E,d)}function fo(o){if(l)return new u(BigInt(o));if(y(o)){if(o!==M(o))throw new Error(o+" is not an integer.");return new p(o)}return en(o.toString())}function T(o){return typeof o=="number"?fo(o):typeof o=="string"?en(o):typeof o=="bigint"?new u(o):o}for(var zt=0;zt<1e3;zt++)c[zt]=T(zt),zt>0&&(c[-zt]=T(-zt));return c.one=c[1],c.zero=c[0],c.minusOne=c[-1],c.max=dt,c.min=ft,c.gcd=ct,c.lcm=mt,c.isInstance=function(o){return o instanceof f||o instanceof p||o instanceof u},c.randBetween=vt,c.fromArray=function(o,s,d){return jr(o.map(T),T(s||10),d)},c}();typeof qe<"u"&&qe.hasOwnProperty("exports")&&(qe.exports=yt);typeof define=="function"&&define.amd&&define(function(){return yt})});function kt(t,r){r||(r=t.reduce((i,a)=>i+a.length,0));let n=new Uint8Array(r),e=0;for(let i of t)n.set(i,e),e+=i.length;return n}function te(t,r){if(t===r)return!0;if(t.byteLength!==r.byteLength)return!1;for(let n=0;n<t.byteLength;n++)if(t[n]!==r[n])return!1;return!0}var nr={};It(nr,{identity:()=>mo});function co(t,r){if(t.length>=255)throw new TypeError("Alphabet too long");for(var n=new Uint8Array(256),e=0;e<n.length;e++)n[e]=255;for(var i=0;i<t.length;i++){var a=t.charAt(i),l=a.charCodeAt(0);if(n[l]!==255)throw new TypeError(a+" is ambiguous");n[l]=i}var c=t.length,f=t.charAt(0),p=Math.log(c)/Math.log(256),u=Math.log(256)/Math.log(c);function y(S){if(S instanceof Uint8Array||(ArrayBuffer.isView(S)?S=new Uint8Array(S.buffer,S.byteOffset,S.byteLength):Array.isArray(S)&&(S=Uint8Array.from(S))),!(S instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(S.length===0)return"";for(var C=0,M=0,R=0,k=S.length;R!==k&&S[R]===0;)R++,C++;for(var B=(k-R)*u+1>>>0,N=new Uint8Array(B);R!==k;){for(var H=S[R],z=0,D=B-1;(H!==0||z<M)&&D!==-1;D--,z++)H+=256*N[D]>>>0,N[D]=H%c>>>0,H=H/c>>>0;if(H!==0)throw new Error("Non-zero carry");M=z,R++}for(var w=B-M;w!==B&&N[w]===0;)w++;for(var $=f.repeat(C);w<B;++w)$+=t.charAt(N[w]);return $}function g(S){if(typeof S!="string")throw new TypeError("Expected String");if(S.length===0)return new Uint8Array;var C=0;if(S[C]!==" "){for(var M=0,R=0;S[C]===f;)M++,C++;for(var k=(S.length-C)*p+1>>>0,B=new Uint8Array(k);S[C];){var N=n[S.charCodeAt(C)];if(N===255)return;for(var H=0,z=k-1;(N!==0||H<R)&&z!==-1;z--,H++)N+=c*B[z]>>>0,B[z]=N%256>>>0,N=N/256>>>0;if(N!==0)throw new Error("Non-zero carry");R=H,C++}if(S[C]!==" "){for(var D=k-R;D!==k&&B[D]===0;)D++;for(var w=new Uint8Array(M+(k-D)),$=M;D!==k;)w[$++]=B[D++];return w}}}function U(S){var C=g(S);if(C)return C;throw new Error(`Non-${r} character`)}return{encode:y,decodeUnsafe:g,decode:U}}var lo=co,po=lo,nn=po;var Eu=new Uint8Array(0);var on=(t,r)=>{if(t===r)return!0;if(t.byteLength!==r.byteLength)return!1;for(let n=0;n<t.byteLength;n++)if(t[n]!==r[n])return!1;return!0},Nt=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")};var an=t=>new TextEncoder().encode(t),sn=t=>new TextDecoder().decode(t);var je=class{constructor(r,n,e){this.name=r,this.prefix=n,this.baseEncode=e}encode(r){if(r instanceof Uint8Array)return`${this.prefix}${this.baseEncode(r)}`;throw Error("Unknown type, must be binary type")}},tr=class{constructor(r,n,e){if(this.name=r,this.prefix=n,n.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=n.codePointAt(0),this.baseDecode=e}decode(r){if(typeof r=="string"){if(r.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(r)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(r.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(r){return fn(this,r)}},er=class{constructor(r){this.decoders=r}or(r){return fn(this,r)}decode(r){let n=r[0],e=this.decoders[n];if(e)return e.decode(r);throw RangeError(`Unable to decode multibase string ${JSON.stringify(r)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},fn=(t,r)=>new er({...t.decoders||{[t.prefix]:t},...r.decoders||{[r.prefix]:r}}),rr=class{constructor(r,n,e,i){this.name=r,this.prefix=n,this.baseEncode=e,this.baseDecode=i,this.encoder=new je(r,n,e),this.decoder=new tr(r,n,i)}encode(r){return this.encoder.encode(r)}decode(r){return this.decoder.decode(r)}},ee=({name:t,prefix:r,encode:n,decode:e})=>new rr(t,r,n,e),Ot=({prefix:t,name:r,alphabet:n})=>{let{encode:e,decode:i}=nn(n,r);return ee({prefix:t,name:r,encode:e,decode:a=>Nt(i(a))})},ho=(t,r,n,e)=>{let i={};for(let u=0;u<r.length;++u)i[r[u]]=u;let a=t.length;for(;t[a-1]==="=";)--a;let l=new Uint8Array(a*n/8|0),c=0,f=0,p=0;for(let u=0;u<a;++u){let y=i[t[u]];if(y===void 0)throw new SyntaxError(`Non-${e} character`);f=f<<n|y,c+=n,c>=8&&(c-=8,l[p++]=255&f>>c)}if(c>=n||255&f<<8-c)throw new SyntaxError("Unexpected end of data");return l},yo=(t,r,n)=>{let e=r[r.length-1]==="=",i=(1<<n)-1,a="",l=0,c=0;for(let f=0;f<t.length;++f)for(c=c<<8|t[f],l+=8;l>n;)l-=n,a+=r[i&c>>l];if(l&&(a+=r[i&c<<n-l]),e)for(;a.length*n&7;)a+="=";return a},lt=({name:t,prefix:r,bitsPerChar:n,alphabet:e})=>ee({prefix:r,name:t,encode(i){return yo(i,e,n)},decode(i){return ho(i,e,n,t)}});var mo=ee({prefix:"\0",name:"identity",encode:t=>sn(t),decode:t=>an(t)});var ir={};It(ir,{base2:()=>vo});var vo=lt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var or={};It(or,{base8:()=>Do});var Do=lt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var ar={};It(ar,{base10:()=>wo});var wo=Ot({prefix:"9",name:"base10",alphabet:"0123456789"});var sr={};It(sr,{base16:()=>bo,base16upper:()=>xo});var bo=lt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),xo=lt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var ur={};It(ur,{base32:()=>re,base32hex:()=>Ao,base32hexpad:()=>Co,base32hexpadupper:()=>Io,base32hexupper:()=>_o,base32pad:()=>Eo,base32padupper:()=>So,base32upper:()=>go,base32z:()=>Po});var re=lt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),go=lt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Eo=lt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),So=lt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Ao=lt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),_o=lt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Co=lt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Io=lt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Po=lt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var fr={};It(fr,{base36:()=>Uo,base36upper:()=>Bo});var Uo=Ot({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Bo=Ot({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var cr={};It(cr,{base58btc:()=>Bt,base58flickr:()=>Lo});var Bt=Ot({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Lo=Ot({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var lr={};It(lr,{base64:()=>No,base64pad:()=>Fo,base64url:()=>Ro,base64urlpad:()=>To});var No=lt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Fo=lt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Ro=lt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),To=lt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var pr={};It(pr,{base256emoji:()=>$o});var cn=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),Mo=cn.reduce((t,r,n)=>(t[n]=r,t),[]),ko=cn.reduce((t,r,n)=>(t[r.codePointAt(0)]=n,t),[]);function Oo(t){return t.reduce((r,n)=>(r+=Mo[n],r),"")}function Ko(t){let r=[];for(let n of t){let e=ko[n.codePointAt(0)];if(e===void 0)throw new Error(`Non-base256emoji character: ${n}`);r.push(e)}return new Uint8Array(r)}var $o=ee({prefix:"\u{1F680}",name:"base256emoji",encode:Oo,decode:Ko});var mr={};It(mr,{sha256:()=>aa,sha512:()=>sa});var qo=dn,ln=128,Ho=127,zo=~Ho,Go=Math.pow(2,31);function dn(t,r,n){r=r||[],n=n||0;for(var e=n;t>=Go;)r[n++]=t&255|ln,t/=128;for(;t&zo;)r[n++]=t&255|ln,t>>>=7;return r[n]=t|0,dn.bytes=n-e+1,r}var Vo=dr,Jo=128,pn=127;function dr(t,e){var n=0,e=e||0,i=0,a=e,l,c=t.length;do{if(a>=c)throw dr.bytes=0,new RangeError("Could not decode varint");l=t[a++],n+=i<28?(l&pn)<<i:(l&pn)*Math.pow(2,i),i+=7}while(l>=Jo);return dr.bytes=a-e,n}var Xo=Math.pow(2,7),Zo=Math.pow(2,14),Wo=Math.pow(2,21),Yo=Math.pow(2,28),Qo=Math.pow(2,35),jo=Math.pow(2,42),ta=Math.pow(2,49),ea=Math.pow(2,56),ra=Math.pow(2,63),na=function(t){return t<Xo?1:t<Zo?2:t<Wo?3:t<Yo?4:t<Qo?5:t<jo?6:t<ta?7:t<ea?8:t<ra?9:10},ia={encode:qo,decode:Vo,encodingLength:na},oa=ia,le=oa;var pe=(t,r=0)=>[le.decode(t,r),le.decode.bytes],ne=(t,r,n=0)=>(le.encode(t,r,n),r),ie=t=>le.encodingLength(t);var Gt=(t,r)=>{let n=r.byteLength,e=ie(t),i=e+ie(n),a=new Uint8Array(i+n);return ne(t,a,0),ne(n,a,e),a.set(r,i),new oe(t,n,r,a)},hn=t=>{let r=Nt(t),[n,e]=pe(r),[i,a]=pe(r.subarray(e)),l=r.subarray(e+a);if(l.byteLength!==i)throw new Error("Incorrect length");return new oe(n,i,l,r)},yn=(t,r)=>t===r?!0:t.code===r.code&&t.size===r.size&&on(t.bytes,r.bytes),oe=class{constructor(r,n,e,i){this.code=r,this.size=n,this.digest=e,this.bytes=i}};var yr=({name:t,code:r,encode:n})=>new hr(t,r,n),hr=class{constructor(r,n,e){this.name=r,this.code=n,this.encode=e}digest(r){if(r instanceof Uint8Array){let n=this.encode(r);return n instanceof Uint8Array?Gt(this.code,n):n.then(e=>Gt(this.code,e))}else throw Error("Unknown type, must be binary type")}};var vn=t=>async r=>new Uint8Array(await crypto.subtle.digest(t,r)),aa=yr({name:"sha2-256",code:18,encode:vn("SHA-256")}),sa=yr({name:"sha2-512",code:19,encode:vn("SHA-512")});var vr={};It(vr,{identity:()=>ca});var Dn=0,ua="identity",wn=Nt,fa=t=>Gt(Dn,wn(t)),ca={code:Dn,name:ua,encode:wn,digest:fa};var zu=new TextEncoder,Gu=new TextDecoder;var Ue=class t{constructor(r,n,e,i){this.code=n,this.version=r,this.multihash=e,this.bytes=i,this.byteOffset=i.byteOffset,this.byteLength=i.byteLength,this.asCID=this,this._baseCache=new Map,Object.defineProperties(this,{byteOffset:Pe,byteLength:Pe,code:Ie,version:Ie,multihash:Ie,bytes:Ie,_baseCache:Pe,asCID:Pe})}toV0(){switch(this.version){case 0:return this;default:{let{code:r,multihash:n}=this;if(r!==he)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(n.code!==ma)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return t.createV0(n)}}}toV1(){switch(this.version){case 0:{let{code:r,digest:n}=this.multihash,e=Gt(r,n);return t.createV1(this.code,e)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}equals(r){return r&&this.code===r.code&&this.version===r.version&&yn(this.multihash,r.multihash)}toString(r){let{bytes:n,version:e,_baseCache:i}=this;switch(e){case 0:return ha(n,i,r||Bt.encoder);default:return ya(n,i,r||re.encoder)}}toJSON(){return{code:this.code,version:this.version,hash:this.multihash.bytes}}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return"CID("+this.toString()+")"}static isCID(r){return Da(/^0\.0/,wa),!!(r&&(r[xn]||r.asCID===r))}get toBaseEncodedString(){throw new Error("Deprecated, use .toString()")}get codec(){throw new Error('"codec" property is deprecated, use integer "code" property instead')}get buffer(){throw new Error("Deprecated .buffer property, use .bytes to get Uint8Array instead")}get multibaseName(){throw new Error('"multibaseName" property is deprecated')}get prefix(){throw new Error('"prefix" property is deprecated')}static asCID(r){if(r instanceof t)return r;if(r!=null&&r.asCID===r){let{version:n,code:e,multihash:i,bytes:a}=r;return new t(n,e,i,a||bn(n,e,i.bytes))}else if(r!=null&&r[xn]===!0){let{version:n,multihash:e,code:i}=r,a=hn(e);return t.create(n,i,a)}else return null}static create(r,n,e){if(typeof n!="number")throw new Error("String codecs are no longer supported");switch(r){case 0:{if(n!==he)throw new Error(`Version 0 CID must use dag-pb (code: ${he}) block encoding`);return new t(r,n,e,e.bytes)}case 1:{let i=bn(r,n,e.bytes);return new t(r,n,e,i)}default:throw new Error("Invalid version")}}static createV0(r){return t.create(0,he,r)}static createV1(r,n){return t.create(1,r,n)}static decode(r){let[n,e]=t.decodeFirst(r);if(e.length)throw new Error("Incorrect length");return n}static decodeFirst(r){let n=t.inspectBytes(r),e=n.size-n.multihashSize,i=Nt(r.subarray(e,e+n.multihashSize));if(i.byteLength!==n.multihashSize)throw new Error("Incorrect length");let a=i.subarray(n.multihashSize-n.digestSize),l=new oe(n.multihashCode,n.digestSize,a,i);return[n.version===0?t.createV0(l):t.createV1(n.codec,l),r.subarray(n.size)]}static inspectBytes(r){let n=0,e=()=>{let[y,g]=pe(r.subarray(n));return n+=g,y},i=e(),a=he;if(i===18?(i=0,n=0):i===1&&(a=e()),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let l=n,c=e(),f=e(),p=n+f,u=p-l;return{version:i,codec:a,multihashCode:c,digestSize:f,multihashSize:u,size:p}}static parse(r,n){let[e,i]=da(r,n),a=t.decode(i);return a._baseCache.set(e,r),a}},da=(t,r)=>{switch(t[0]){case"Q":{let n=r||Bt;return[Bt.prefix,n.decode(`${Bt.prefix}${t}`)]}case Bt.prefix:{let n=r||Bt;return[Bt.prefix,n.decode(t)]}case re.prefix:{let n=r||re;return[re.prefix,n.decode(t)]}default:{if(r==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[t[0],r.decode(t)]}}},ha=(t,r,n)=>{let{prefix:e}=n;if(e!==Bt.prefix)throw Error(`Cannot string encode V0 in ${n.name} encoding`);let i=r.get(e);if(i==null){let a=n.encode(t).slice(1);return r.set(e,a),a}else return i},ya=(t,r,n)=>{let{prefix:e}=n,i=r.get(e);if(i==null){let a=n.encode(t);return r.set(e,a),a}else return i},he=112,ma=18,bn=(t,r,n)=>{let e=ie(t),i=e+ie(r),a=new Uint8Array(i+n.byteLength);return ne(t,a,0),ne(r,a,e),a.set(n,i),a},xn=Symbol.for("@ipld/js-cid/CID"),Ie={writable:!1,configurable:!1,enumerable:!0},Pe={writable:!1,enumerable:!1,configurable:!1},va="0.0.0-dev",Da=(t,r)=>{if(t.test(va))console.warn(r);else throw new Error(r)},wa=`CID.isCID(v) is deprecated and will be removed in the next major release.
2
- Following code pattern:
3
-
4
- if (CID.isCID(value)) {
5
- doSomethingWithCID(value)
6
- }
7
-
8
- Is replaced with:
9
-
10
- const cid = CID.asCID(value)
11
- if (cid) {
12
- // Make sure to use cid instead of value
13
- doSomethingWithCID(cid)
14
- }
15
- `;var Dr={...nr,...ir,...or,...ar,...sr,...ur,...fr,...cr,...lr,...pr},ju={...mr,...vr};function En(t,r,n,e){return{name:t,prefix:r,encoder:{name:t,prefix:r,encode:n},decoder:{decode:e}}}var gn=En("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),wr=En("ascii","a",t=>{let r="a";for(let n=0;n<t.length;n++)r+=String.fromCharCode(t[n]);return r},t=>{t=t.substring(1);let r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}),ba={utf8:gn,"utf-8":gn,hex:Dr.base16,latin1:wr,ascii:wr,binary:wr,...Dr},Be=ba;function wt(t,r="utf8"){let n=Be[r];if(!n)throw new Error(`Unsupported encoding "${r}"`);return n.decoder.decode(`${n.prefix}${t}`)}function bt(t,r="utf8"){let n=Be[r];if(!n)throw new Error(`Unsupported encoding "${r}"`);return n.encoder.encode(t).substring(1)}var fe=We(kr(),1);var De=new Uint8Array([237,1]),Pf=new Uint8Array([234,1]),Me=new Uint8Array([128,36]),Uf=new Uint8Array([129,36]),Bf=new Uint8Array([130,36]),ke=new Uint8Array([133,36]),Oe=new Uint8Array([0,245,2]),Ke="did:key:z";function Zt(t,r){if(!t.startsWith(Ke))throw new Error("Please use a base58-encoded DID formatted `did:key:z...`");let n=t.slice(Ke.length),e=wt(n,"base58btc");if(!ys(e,r))throw new Error(`Expected prefix: ${r}`);return e.slice(r.length)}function $e(t,r){let n=kt([r,t]),e=bt(n,"base58btc");return Ke+e}var ys=(t,r)=>te(r,t.subarray(0,r.byteLength));var ei=t=>Zt(t,De),ri=t=>$e(t,De);var Or=function(t,r,n,e){function i(a){return a instanceof n?a:new n(function(l){l(a)})}return new(n||(n=Promise))(function(a,l){function c(u){try{p(e.next(u))}catch(y){l(y)}}function f(u){try{p(e.throw(u))}catch(y){l(y)}}function p(u){u.done?a(u.value):i(u.value).then(c,f)}p((e=e.apply(t,r||[])).next())})},ii=class t{constructor(r,n,e){this.jwtAlg="EdDSA",this.secretKey=r,this.publicKey=n,this.exportable=e}static create(r){return Or(this,void 0,void 0,function*(){let{exportable:n}=r||{},e=fe.generateKeyPair();return new t(e.secretKey,e.publicKey,n??!1)})}static fromSecretKey(r,n){let{format:e="base64pad",exportable:i=!1}=n||{},a=wt(r,e),l=fe.extractPublicKeyFromSecretKey(a);return new t(a,l,i)}did(){return ri(this.publicKey)}sign(r){return Or(this,void 0,void 0,function*(){return fe.sign(this.secretKey,r)})}export(r="base64pad"){return Or(this,void 0,void 0,function*(){if(!this.exportable)throw new Error("Key is not exportable");return bt(this.secretKey,r)})}};var ms=globalThis||window||self,qt=ms.crypto;var si=function(t,r,n,e){function i(a){return a instanceof n?a:new n(function(l){l(a)})}return new(n||(n=Promise))(function(a,l){function c(u){try{p(e.next(u))}catch(y){l(y)}}function f(u){try{p(e.throw(u))}catch(y){l(y)}}function p(u){u.done?a(u.value):i(u.value).then(c,f)}p((e=e.apply(t,r||[])).next())})},ui="RSASSA-PKCS1-v1_5";var vs="SHA-256",Ds=128;var ws=t=>si(void 0,void 0,void 0,function*(){return yield qt.subtle.importKey("spki",t,{name:ui,hash:{name:vs}},!0,["verify"])});var Kr=(t,r,n)=>si(void 0,void 0,void 0,function*(){return yield qt.subtle.verify({name:ui,saltLength:Ds},yield ws(t),n,r)}),fi=t=>{let r=Zt(t,ke);return gs(r)},ci=t=>Zt(t,Oe);var oi=new Uint8Array([48,13,6,9,42,134,72,134,247,13,1,1,1,5,0]),bs=new Uint8Array([48]),xs=new Uint8Array([3]),gs=t=>{let r=kt([xs,ai(t.length+1),new Uint8Array([0]),t]);return kt([bs,ai(oi.length+r.length),oi,r])};function ai(t){if(t<0||!isFinite(t))throw new TypeError(`Expected non-negative number. Got ${t}`);if(t<=127)return new Uint8Array([t]);let r=[];for(;t!==0;)r.push(t&255),t=t>>>8;return r.reverse(),new Uint8Array([128|r.length&255,...r])}var we=We(li(),1);var pi=function(t,r,n,e){function i(a){return a instanceof n?a:new n(function(l){l(a)})}return new(n||(n=Promise))(function(a,l){function c(u){try{p(e.next(u))}catch(y){l(y)}}function f(u){try{p(e.throw(u))}catch(y){l(y)}}function p(u){u.done?a(u.value):i(u.value).then(c,f)}p((e=e.apply(t,r||[])).next())})},di="ECDSA",Ss="P-256",As="SHA-256";var _s=t=>pi(void 0,void 0,void 0,function*(){return yield qt.subtle.importKey("raw",t,{name:di,namedCurve:Ss},!0,["verify"])});var hi=(t,r,n)=>pi(void 0,void 0,void 0,function*(){return yield qt.subtle.verify({name:di,hash:{name:As}},yield _s(t),n,r)}),yi=t=>{let r=Zt(t,Me);return Cs(r)};var Cs=t=>{if(t.length!==33)throw new Error("Expected 33 byte compress pubkey");if(t[0]!==2&&t[0]!==3)throw new Error("Expected first byte to be 0x02 or 0x03");let r=(0,we.default)(2),n=r.pow(256).subtract(r.pow(224)).add(r.pow(192)).add(r.pow(96)).subtract(1),e=(0,we.default)("41058363725152142129326129780047268409114441015993725554835256314039467401291"),i=n.add(1).divide(4),a=(0,we.default)(t[0]-2),l=t.slice(1),c=(0,we.default)(bt(l,"base10")),f=c.pow(3).subtract(c.multiply(3)).add(e).modPow(i,n),p;f.mod(2).equals(a)?p=f:p=n.subtract(f);let u=wt(p.toString(10),"base10"),y=32-u.length,g=new Uint8Array(32);return g.set(u,y),kt([[4],l,g])};var mi=We(kr(),1);var Is=function(t,r,n,e){function i(a){return a instanceof n?a:new n(function(l){l(a)})}return new(n||(n=Promise))(function(a,l){function c(u){try{p(e.next(u))}catch(y){l(y)}}function f(u){try{p(e.throw(u))}catch(y){l(y)}}function p(u){u.done?a(u.value):i(u.value).then(c,f)}p((e=e.apply(t,r||[])).next())})},vi={prefix:De,jwtAlg:"EdDSA",verifySignature:(t,r,n)=>Is(void 0,void 0,void 0,function*(){let e=ei(t);return mi.verify(e,r,n)})};var Di=function(t,r,n,e){function i(a){return a instanceof n?a:new n(function(l){l(a)})}return new(n||(n=Promise))(function(a,l){function c(u){try{p(e.next(u))}catch(y){l(y)}}function f(u){try{p(e.throw(u))}catch(y){l(y)}}function p(u){u.done?a(u.value):i(u.value).then(c,f)}p((e=e.apply(t,r||[])).next())})},wi={prefix:ke,jwtAlg:"RS256",verifySignature:(t,r,n)=>Di(void 0,void 0,void 0,function*(){let e=fi(t);return Kr(e,r,n)})},bi={prefix:Oe,jwtAlg:"RS256",verifySignature:(t,r,n)=>Di(void 0,void 0,void 0,function*(){let e=ci(t);return Kr(e,r,n)})};var Ps=function(t,r,n,e){function i(a){return a instanceof n?a:new n(function(l){l(a)})}return new(n||(n=Promise))(function(a,l){function c(u){try{p(e.next(u))}catch(y){l(y)}}function f(u){try{p(e.throw(u))}catch(y){l(y)}}function p(u){u.done?a(u.value):i(u.value).then(c,f)}p((e=e.apply(t,r||[])).next())})},xi={prefix:Me,jwtAlg:"ES256",verifySignature:(t,r,n)=>Ps(void 0,void 0,void 0,function*(){let e=yi(t);return hi(e,r,n)})};var Us=function(t,r,n,e){function i(a){return a instanceof n?a:new n(function(l){l(a)})}return new(n||(n=Promise))(function(a,l){function c(u){try{p(e.next(u))}catch(y){l(y)}}function f(u){try{p(e.throw(u))}catch(y){l(y)}}function p(u){u.done?a(u.value):i(u.value).then(c,f)}p((e=e.apply(t,r||[])).next())})},Bs=function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=t[Symbol.asyncIterator],n;return r?r.call(t):(t=typeof __values=="function"?__values(t):t[Symbol.iterator](),n={},e("next"),e("throw"),e("return"),n[Symbol.asyncIterator]=function(){return this},n);function e(a){n[a]=t[a]&&function(l){return new Promise(function(c,f){l=t[a](l),i(c,f,l.done,l.value)})}}function i(a,l,c,f){Promise.resolve(f).then(function(p){a({value:p,done:c})},l)}},gi="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",Ei=(t=6)=>{let r="";for(let n=0;n<t;n++)r+=gi[Math.floor(Math.random()*gi.length)];return r};function F(t,r){return typeof t=="object"&&t!=null&&r in t}function it(t){return typeof t=="object"&&t!=null}function Ls(t){return typeof t=="object"&&t!=null&&Symbol.iterator in t}function Ns(t){return typeof t=="object"&&t!=null&&Symbol.asyncIterator in t}function Si(t){if(Ls(t)){for(let r of t)return r;return}else{if(Ns(t))return Us(this,void 0,void 0,function*(){var r,n;try{for(var e=Bs(t),i;i=yield e.next(),!i.done;)return i.value}catch(a){r={error:a}}finally{try{i&&!i.done&&(n=e.return)&&(yield n.call(e))}finally{if(r)throw r.error}}});throw new TypeError(`Expected either Iterable or AsyncIterable, but got ${t}`)}}function Ci(t){return it(t)&&F(t,"major")&&typeof t.major=="number"&&F(t,"minor")&&typeof t.minor=="number"&&F(t,"patch")&&typeof t.patch=="number"}var Fs=/^0|[1-9]\d*/,Rs=t=>r=>{let n=r.match(t);return n?n[0].length===r.length:!1};function He(t){var r,n,e;let i=t.match(/^(?<major>0|[1-9]\d*)\.(?<minor>0|[1-9]\d*)\.(?<patch>0|[1-9]\d*)(?:-(?<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/);if(i===null)return null;let a=`${(r=i.groups)===null||r===void 0?void 0:r.major}.${(n=i.groups)===null||n===void 0?void 0:n.minor}.${(e=i.groups)===null||e===void 0?void 0:e.patch}`.split(".");if(a.length!==3||!a.every(Rs(Fs)))return null;let[l,c,f]=a.map(p=>parseInt(p,10));return!Number.isSafeInteger(l)||!Number.isSafeInteger(c)||!Number.isSafeInteger(f)||l<0||c<0||f<0?null:{major:l,minor:c,patch:f}}function Ii(t){return`${t.major}.${t.minor}.${t.patch}`}var Ai=1,_i=0,zr=-1;function Hr(t,r){return t==null?r==null?_i:zr:r==null||t>r?Ai:t<r?zr:_i}function Ts(t,r){let n=typeof t=="string"?He(t):t,e=typeof r=="string"?He(r):r;return Hr(n?.major,e?.major)||Hr(n?.minor,e?.minor)||Hr(n?.patch,e?.patch)}function be(t,r){return Ts(t,r)===zr}function Pi(t,r){return!be(t,r)}var j="*";var Ui="/";function Vr(t){return t===j||it(t)&&F(t,"namespace")&&typeof t.namespace=="string"&&F(t,"segments")&&Array.isArray(t.segments)&&t.segments.every(r=>typeof r=="string")}function Ms(t){return t.join(Ui)}function Bi(t){switch(t){case j:return t;default:return Ms([t.namespace,...t.segments])}}function Li(t){switch(t){case j:return j;default:{let[r,...n]=t.split(Ui);return{namespace:r,segments:n}}}}var Jr=":";function Xr(t){return it(t)&&F(t,"scheme")&&typeof t.scheme=="string"&&F(t,"hierPart")&&(t.hierPart===j||typeof t.hierPart=="string")}function Fi(t){return{scheme:"my",hierPart:t}}function Ri(t){return`${t.scheme}${Jr}${t.hierPart}`}function Ti(t){let[r,...n]=t.split(Jr);return{scheme:r,hierPart:n.join(Jr)}}function Lt(t){return it(t)&&F(t,"with")&&Xr(t.with)&&F(t,"can")&&Vr(t.can)}function ze(t){return it(t)&&F(t,"with")&&typeof t.with=="string"&&F(t,"can")&&typeof t.can=="string"}function Mi(t){return{with:Fi(t),can:j}}function ki(t){return{with:Ri(t.with),can:Bi(t.can)}}function Oi(t){return{with:Ti(t.with),can:Li(t.can)}}function Ge(t){return it(t)&&F(t,"jwtAlg")&&typeof t.jwtAlg=="string"&&F(t,"sign")&&typeof t.sign=="function"}function $i(t){return it(t)&&F(t,"alg")&&typeof t.alg=="string"&&F(t,"typ")&&typeof t.typ=="string"&&F(t,"ucv")&&Ci(t.ucv)}function qi(t){return it(t)&&F(t,"iss")&&typeof t.iss=="string"&&F(t,"aud")&&typeof t.aud=="string"&&F(t,"exp")&&typeof t.exp=="number"&&(!F(t,"nbf")||typeof t.nbf=="number")&&(!F(t,"nnc")||typeof t.nnc=="string")&&F(t,"att")&&Array.isArray(t.att)&&t.att.every(r=>Lt(r)||ze(r))&&(!F(t,"fct")||Array.isArray(t.fct)&&t.fct.every(it))&&F(t,"prf")&&Array.isArray(t.prf)&&t.prf.every(r=>typeof r=="string")}var Os={major:0,minor:3,patch:0};function Ks(t){return it(t)&&F(t,"alg")&&typeof t.alg=="string"&&F(t,"typ")&&typeof t.typ=="string"&&F(t,"uav")&&typeof t.uav=="string"}function $s(t){return it(t)&&F(t,"iss")&&typeof t.iss=="string"&&F(t,"aud")&&typeof t.aud=="string"&&(!F(t,"nbf")||typeof t.nbf=="number")&&F(t,"exp")&&typeof t.exp=="number"&&F(t,"rsc")&&(typeof t.rsc=="string"||it(t))&&F(t,"ptc")&&typeof t.ptc=="string"&&(!F(t,"prf")||typeof t.prf=="string")}function Hi(t,r){let n=(i,a)=>new Error(`Can't parse UCAN ${i}: ${a}`);if(!it(t))throw n("header","Invalid format: Expected a record");let e="0.9.1";if(!F(t,"ucv")||typeof t.ucv!="string"){if(!F(t,"uav")||typeof t.uav!="string")throw n("header","Invalid format: Missing version indicator");if(t.uav!=="1.0.0")throw n("header",`Unsupported version 'uav: ${t.uav}'`);e="0.3.0"}else if(be(t.ucv,"0.8.0"))throw n("header",`Unsupported version 'ucv: ${t.ucv}'`);if(Pi(e,"0.8.0")){if(typeof t.ucv!="string")throw n("header","Invalid format: Missing 'ucv' key or 'ucv' is not a string");if(t.ucv=He(t.ucv),t.ucv==null)throw n("header","Invalid format: 'ucv' string cannot be parsed into a semantic version");if(!$i(t))throw n("header","Invalid format");if(!qi(r))throw n("payload","Invalid format");return{header:t,payload:r}}if(!Ks(t))throw n("header","Invalid version 0.3.0 format");if(!$s(r))throw n("payload","Invalid version 0.3.0 format");return{header:{alg:t.alg,typ:t.typ,ucv:Os},payload:{iss:r.iss,aud:r.aud,nbf:r.nbf,exp:r.exp,att:(()=>{if(r.rsc===j||typeof r.rsc=="string")return[Mi(j)];let i=r.rsc;return Object.keys(i).map(a=>({with:{scheme:a,hierPart:i[a]},can:r.ptc===j?j:{namespace:a,segments:[r.ptc]}}))})(),prf:r.prf!=null?[r.prf]:[]}}}var zi=function(t,r,n,e){function i(a){return a instanceof n?a:new n(function(l){l(a)})}return new(n||(n=Promise))(function(a,l){function c(u){try{p(e.next(u))}catch(y){l(y)}}function f(u){try{p(e.throw(u))}catch(y){l(y)}}function p(u){u.done?a(u.value):i(u.value).then(c,f)}p((e=e.apply(t,r||[])).next())})},Yt=function(t){return this instanceof Yt?(this.v=t,this):new Yt(t)},qs=function(t,r,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=n.apply(t,r||[]),i,a=[];return i={},l("next"),l("throw"),l("return"),i[Symbol.asyncIterator]=function(){return this},i;function l(g){e[g]&&(i[g]=function(U){return new Promise(function(S,C){a.push([g,U,S,C])>1||c(g,U)})})}function c(g,U){try{f(e[g](U))}catch(S){y(a[0][3],S)}}function f(g){g.value instanceof Yt?Promise.resolve(g.value.v).then(p,u):y(a[0][2],g)}function p(g){c("next",g)}function u(g){c("throw",g)}function y(g,U){g(U),a.shift(),a.length&&c(a[0][0],a[0][1])}},Hs="JWT",zs={major:0,minor:8,patch:1},Gi=t=>r=>{let n=r.issuer,e=Zr(Object.assign(Object.assign({},r),{issuer:n.did()}));return xe(t)(e,n)};function Zr(t){let{issuer:r,audience:n,capabilities:e=[],lifetimeInSeconds:i=30,expiration:a,notBefore:l,facts:c,proofs:f=[],addNonce:p=!1}=t;if(!r.startsWith("did:"))throw new Error("The issuer must be a DID");if(!n.startsWith("did:"))throw new Error("The audience must be a DID");let u=Math.floor(Date.now()/1e3),y=a||u+i;return{aud:n,att:e,exp:y,fct:c,iss:r,nbf:l,nnc:p?Ei():void 0,prf:f}}var Wr=t=>(r,n,e)=>zi(void 0,void 0,void 0,function*(){let i={alg:n,typ:Hs,ucv:zs};if(!t.verifyIssuerAlg(r.iss,n))throw new Error("The issuer's key type must match the given key type.");let a=Gs(i),l=Vs(r),c=`${a}.${l}`,f=wt(c,"utf8"),p=yield e(f);return Object.freeze({header:i,payload:r,signedData:c,signature:bt(p,"base64url")})}),xe=t=>(r,n)=>Wr(t)(r,n.jwtAlg,e=>n.sign(e));function gt(t){return`${t.signedData}.${t.signature}`}function Gs(t){let r=Object.assign(Object.assign({},t),{ucv:Ii(t.ucv)});return bt(wt(JSON.stringify(r),"utf8"),"base64url")}function Vs(t){let r=Object.assign(Object.assign({},t),{att:t.att.map(ki)});return bt(wt(JSON.stringify(r),"utf8"),"base64url")}function Js(t){let[r,n,e]=t.split(".");if(r==null||n==null||e==null)throw new Error(`Can't parse UCAN: ${t}: Expected JWT format: 3 dot-separated base64url-encoded values.`);let i,a;try{i=bt(wt(r,"base64url"),"utf8")}catch{throw new Error(`Can't parse UCAN header: ${r}: Can't parse as base64url.`)}try{a=JSON.parse(i)}catch{throw new Error(`Can't parse UCAN header: ${r}: Can't parse encoded JSON inside.`)}let l,c;try{l=bt(wt(n,"base64url"),"utf8")}catch{throw new Error(`Can't parse UCAN payload: ${n}: Can't parse as base64url.`)}try{c=JSON.parse(l)}catch{throw new Error(`Can't parse UCAN payload: ${n}: Can't parse encoded JSON inside.`)}let{header:f,payload:p}=Hi(a,c),u=p.att.reduce((y,g)=>ze(g)?[...y,Oi(g)]:Lt(g)?[...y,g]:y,[]);return{header:f,payload:Object.assign(Object.assign({},p),{att:u})}}var Qt=t=>(r,n)=>zi(void 0,void 0,void 0,function*(){let{checkIssuer:e=!0,checkSignature:i=!0,checkIsExpired:a=!0,checkIsTooEarly:l=!0}=n??{},{header:c,payload:f}=Js(r),[p,u,y]=r.split(".");if(e&&!t.verifyIssuerAlg(f.iss,c.alg))throw new Error(`Invalid UCAN: ${r}: Issuer key type does not match UCAN's \`alg\` property.`);if(i){let S=wt(y,"base64url"),C=wt(`${p}.${u}`,"utf8");if(!(yield t.verifySignature(f.iss,C,S)))throw new Error(`Invalid UCAN: ${r}: Signature invalid.`)}let g=`${p}.${u}`,U={header:c,payload:f,signedData:g,signature:y};if(a&&Xs(U))throw new Error(`Invalid UCAN: ${r}: Expired.`);if(l&&Zs(U))throw new Error(`Invalid UCAN: ${r}: Not active yet (too early).`);return U}),Ve=t=>function(r,n){return qs(this,arguments,function*(){let{checkAddressing:e=!0,checkTimeBoundsSubset:i=!0,checkVersionMonotonic:a=!0}=n||{};for(let l of r.payload.prf)try{let c=yield Yt(Qt(t)(l,n));if(e&&r.payload.iss!==c.payload.aud)throw new Error(`Invalid Proof: Issuer ${r.payload.iss} doesn't match parent's audience ${c.payload.aud}`);if(i&&c.payload.nbf!=null&&r.payload.exp>c.payload.nbf)throw new Error(`Invalid Proof: 'Not before' (${c.payload.nbf}) is after parent's expiration (${r.payload.exp})`);if(i&&r.payload.nbf!=null&&r.payload.nbf>c.payload.exp)throw new Error(`Invalid Proof: Expiration (${c.payload.exp}) is before parent's 'not before' (${r.payload.nbf})`);if(a&&be(r.header.ucv,c.header.ucv))throw new Error(`Invalid Proof: Version (${c.header.ucv}) is higher than parent's version (${r.header.ucv})`);yield yield Yt(c)}catch(c){c instanceof Error?yield yield Yt(c):yield yield Yt(new Error(`Error when trying to parse UCAN proof: ${c}`))}})};function Xs(t){return t.payload.exp<=Math.floor(Date.now()/1e3)}var Zs=t=>t.payload.nbf==null?!1:t.payload.nbf>Math.floor(Date.now()/1e3);var Ws=function(t,r,n,e){function i(a){return a instanceof n?a:new n(function(l){l(a)})}return new(n||(n=Promise))(function(a,l){function c(u){try{p(e.next(u))}catch(y){l(y)}}function f(u){try{p(e.throw(u))}catch(y){l(y)}}function p(u){u.done?a(u.value):i(u.value).then(c,f)}p((e=e.apply(t,r||[])).next())})},Z=function(t){return this instanceof Z?(this.v=t,this):new Z(t)},Rt=function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=t[Symbol.asyncIterator],n;return r?r.call(t):(t=typeof __values=="function"?__values(t):t[Symbol.iterator](),n={},e("next"),e("throw"),e("return"),n[Symbol.asyncIterator]=function(){return this},n);function e(a){n[a]=t[a]&&function(l){return new Promise(function(c,f){l=t[a](l),i(c,f,l.done,l.value)})}}function i(a,l,c,f){Promise.resolve(f).then(function(p){a({value:p,done:c})},l)}},Ee=function(t){var r,n;return r={},e("next"),e("throw",function(i){throw i}),e("return"),r[Symbol.iterator]=function(){return this},r;function e(i,a){r[i]=t[i]?function(l){return(n=!n)?{value:Z(t[i](l)),done:i==="return"}:a?a(l):l}:a}},Se=function(t,r,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=n.apply(t,r||[]),i,a=[];return i={},l("next"),l("throw"),l("return"),i[Symbol.asyncIterator]=function(){return this},i;function l(g){e[g]&&(i[g]=function(U){return new Promise(function(S,C){a.push([g,U,S,C])>1||c(g,U)})})}function c(g,U){try{f(e[g](U))}catch(S){y(a[0][3],S)}}function f(g){g.value instanceof Z?Promise.resolve(g.value.v).then(p,u):y(a[0][2],g)}function p(g){c("next",g)}function u(g){c("throw",g)}function y(g,U){g(U),a.shift(),a.length&&c(a[0][0],a[0][1])}},Tt=t=>function(r,n,e=()=>Ws(this,void 0,void 0,function*(){return!1})){return Se(this,arguments,function*(){if(yield Z(e(n)))return yield yield Z(new Error(`UCAN Revoked: ${gt(n)}`)),yield Z(void 0);yield Z(yield*Ee(Rt(Qs(n)))),yield Z(yield*Ee(Rt(js(t,r,n,e))))})};function Ae(t){return"capability"in t?t.chainStep==null?t.ucan.payload.iss:Ae(t.chainStep):t.ownershipDID}var Vi={canDelegateResource(t,r){return t.scheme!==r.scheme?!1:t.hierPart===r.hierPart},canDelegateAbility(t,r){return t===j?!0:r===j||t.namespace!==r.namespace||t.segments.length!==r.segments.length?!1:t.segments.reduce((n,e,i)=>n&&r.segments[i]===e,!0)}};function jt(t,r,n){if("capability"in n)return nu(t,n.capability,r);let e=n.scope;return e===j?!0:e.scheme==r.with.scheme&&t.canDelegateAbility(e.ability,r.can)}function Ys(t,r,n,e){if(r!==e.ownershipDID)return!1;let i=e.scope;return i===j?!0:n===j?!1:i.scheme===n.scheme&&t.canDelegateAbility(i.ability,n.ability)}function*Qs(t){for(let r of t.payload.att)switch(r.with.scheme.toLowerCase()){case"my":{let n=r.with.hierPart===j?j:{scheme:r.with.hierPart,ability:r.can};yield{ownershipDID:t.payload.iss,scope:n,ucan:t};break}case"as":case"prf":break;default:yield{capability:r,ucan:t}}}function js(t,r,n,e){return Se(this,arguments,function*(){var a,l;let c=0;try{for(var f=Rt(Ve(t)(n)),p;p=yield Z(f.next()),!p.done;){let y=p.value;if(y instanceof Error){yield yield Z(y);continue}for(let g of n.payload.att)try{switch(g.with.scheme.toLowerCase()){case"my":continue;case"as":{yield Z(yield*Ee(Rt(tu(t,r,g,n,y,e))));break}case"prf":{yield Z(yield*Ee(Rt(eu(t,r,g,n,y,c,e))));break}default:yield Z(yield*Ee(Rt(ru(t,r,g,n,y,e))))}}catch(U){yield yield Z(u(U))}c++}}catch(y){a={error:y}}finally{try{p&&!p.done&&(l=f.return)&&(yield Z(l.call(f)))}finally{if(a)throw a.error}}function u(y){return y instanceof Error?y:new Error(`Error during capability delegation checking: ${y}`)}})}function tu(t,r,n,e,i,a){return Se(this,arguments,function*(){var c,f;let p=n.with.hierPart.split(":"),u=p[p.length-1],y=p.slice(0,-1).join(":"),g=u===j?j:{scheme:u,ability:n.can};try{for(var U=Rt(Tt(t)(r,i,a)),S;S=yield Z(U.next()),!S.done;){let C=S.value;if(C instanceof Error){yield yield Z(C);continue}"ownershipDID"in C&&Ys(r,y,g,C)&&(yield yield Z({ownershipDID:y,scope:g,ucan:e,chainStep:C}))}}catch(C){c={error:C}}finally{try{S&&!S.done&&(f=U.return)&&(yield Z(f.call(U)))}finally{if(c)throw c.error}}})}function eu(t,r,n,e,i,a,l){return Se(this,arguments,function*(){var f,p;if(n.with.hierPart!==j&&parseInt(n.with.hierPart,10)!==a)return yield Z(void 0);try{for(var u=Rt(Tt(t)(r,i,l)),y;y=yield Z(u.next()),!y.done;){let g=y.value;if(g instanceof Error){yield yield Z(g);continue}"capability"in g&&(yield yield Z({capability:g.capability,ucan:e,chainStep:g}))}}catch(g){f={error:g}}finally{try{y&&!y.done&&(p=u.return)&&(yield Z(p.call(u)))}finally{if(f)throw f.error}}})}function ru(t,r,n,e,i,a){return Se(this,arguments,function*(){var c,f;try{for(var p=Rt(Tt(t)(r,i,a)),u;u=yield Z(p.next()),!u.done;){let y=u.value;if(y instanceof Error){yield yield Z(y);continue}jt(r,n,y)&&(yield yield Z({capability:n,ucan:e,chainStep:y}))}}catch(y){c={error:y}}finally{try{u&&!u.done&&(f=p.return)&&(yield Z(f.call(p)))}finally{if(c)throw c.error}}})}function nu(t,r,n){return t.canDelegateResource(r.with,n.with)&&t.canDelegateAbility(r.can,n.can)}var Ji=function(t,r,n,e){function i(a){return a instanceof n?a:new n(function(l){l(a)})}return new(n||(n=Promise))(function(a,l){function c(u){try{p(e.next(u))}catch(y){l(y)}}function f(u){try{p(e.throw(u))}catch(y){l(y)}}function p(u){u.done?a(u.value):i(u.value).then(c,f)}p((e=e.apply(t,r||[])).next())})},ou=function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=t[Symbol.asyncIterator],n;return r?r.call(t):(t=typeof __values=="function"?__values(t):t[Symbol.iterator](),n={},e("next"),e("throw"),e("return"),n[Symbol.asyncIterator]=function(){return this},n);function e(a){n[a]=t[a]&&function(l){return new Promise(function(c,f){l=t[a](l),i(c,f,l.done,l.value)})}}function i(a,l,c,f){Promise.resolve(f).then(function(p){a({value:p,done:c})},l)}},au=t=>({ok:!0,value:t}),Yr=t=>({ok:!1,error:t}),Xi=t=>(r,n)=>Ji(void 0,void 0,void 0,function*(){var e,i,a,l,c;let{audience:f,requiredCapabilities:p}=n,u=(a=n.semantics)!==null&&a!==void 0?a:Vi,y=(l=n.isRevoked)!==null&&l!==void 0?l:()=>Ji(void 0,void 0,void 0,function*(){return!1}),g=(c=n.checkFacts)!==null&&c!==void 0?c:()=>!0;if(typeof r!="string")throw new TypeError(`Expected an encoded UCAN string as first argument, but got ${r}`);if(typeof f!="string"||!f.startsWith("did:"))throw new TypeError(`Expected a DID string as second argument, but got ${f}`);if(typeof y!="function")throw new TypeError(`Expected a function returning a promise as third argument, but got ${y}`);if(!Array.isArray(p))throw new TypeError(`Expected an array as fourth argument, but got ${p}`);if(p.length<1)throw new TypeError("Expected a non-empty list of required capabilities as 4th argument.");if(p.some(C=>!Lt(C.capability)||typeof C.rootIssuer!="string"||!C.rootIssuer.startsWith("did:")))throw new TypeError(`Expected an array of records of capabilities and rootIssuers as DID strings as 4th argument, but got ${p}`);if(typeof u.canDelegateResource!="function"||typeof u.canDelegateAbility!="function")throw new TypeError(`Expected a record with two functions 'canDelegateResource' and 'canDelegateAbility' as 5th argument, but got ${u}`);if(typeof g!="function")throw new TypeError(`Expected a function as 6th argument, but got ${g}`);try{let C=yield Qt(t)(r);if(C.payload.aud!==f)return Yr([new Error(`Invalid UCAN: Expected audience to be ${f}, but it's ${C.payload.aud}`)]);let M=[],R=new Set(p),k=[];try{t:for(var U=ou(Tt(t)(u,C,y)),S;S=yield U.next(),!S.done;){let B=S.value;if(B instanceof Error){M.push(B);continue}for(let N of R)jt(u,N.capability,B)&&Ae(B)===N.rootIssuer&&(R.delete(N),k.push(Object.assign(Object.assign({},N),{proof:B})));if(R.size===0)break t}}catch(B){e={error:B}}finally{try{S&&!S.done&&(i=U.return)&&(yield i.call(U))}finally{if(e)throw e.error}}return R.size>0?Yr(M):au(k)}catch(C){return Yr([C instanceof Error?C:new Error(`Unknown error during UCAN verification: ${C}`)])}});var uu=function(t,r,n,e){function i(a){return a instanceof n?a:new n(function(l){l(a)})}return new(n||(n=Promise))(function(a,l){function c(u){try{p(e.next(u))}catch(y){l(y)}}function f(u){try{p(e.throw(u))}catch(y){l(y)}}function p(u){u.done?a(u.value):i(u.value).then(c,f)}p((e=e.apply(t,r||[])).next())})};function Zi(t){return it(t)&&F(t,"issuer")&&Ge(t.issuer)&&F(t,"audience")&&typeof t.audience=="string"&&F(t,"expiration")&&typeof t.expiration=="number"}function fu(t){return it(t)&&F(t,"issuer")&&Ge(t.issuer)&&F(t,"expiration")&&typeof t.expiration=="number"}var cu=t=>class Ut{constructor(n,e){this.state=n,this.defaultable=e}static create(){return new Ut({},{capabilities:[],facts:[],proofs:[],addNonce:!1})}issuedBy(n){if(!Ge(n))throw new TypeError(`Expected a Keypair, but got ${n}`);return new Ut(Object.assign(Object.assign({},this.state),{issuer:n}),this.defaultable)}toAudience(n){if(typeof n!="string")throw new TypeError(`Expected audience DID as string, but got ${n}`);return new Ut(Object.assign(Object.assign({},this.state),{audience:n}),this.defaultable)}withLifetimeInSeconds(n){if(typeof n!="number")throw new TypeError(`Expected seconds as number, but got ${n}`);if(!isFinite(n)||n<=0)throw new TypeError(`Expected seconds to be a positive number, but got ${n}`);return this.withExpiration(Math.floor(Date.now()/1e3)+n)}withExpiration(n){if(typeof n!="number"||!isFinite(n))throw new TypeError(`Expected expiration as number, but got ${n}`);if(this.defaultable.notBefore!=null&&n<this.defaultable.notBefore)throw new Error(`Can't set expiration to ${n} which is before 'notBefore': ${this.defaultable.notBefore}`);return new Ut(Object.assign(Object.assign({},this.state),{expiration:n}),this.defaultable)}withNotBefore(n){if(typeof n!="number"||!isFinite(n))throw new TypeError(`Expected notBeforeTimestamp as number, but got ${n}`);if(F(this.state,"expiration")&&typeof this.state.expiration=="number"&&this.state.expiration<n)throw new Error(`Can't set 'notBefore' to ${n} which is after expiration: ${this.state.expiration}`);return new Ut(this.state,Object.assign(Object.assign({},this.defaultable),{notBefore:n}))}withFact(n,...e){if(!it(n)||e.some(i=>!it(i)))throw new TypeError(`Expected fact(s) to be a record, but got ${n}`);return new Ut(this.state,Object.assign(Object.assign({},this.defaultable),{facts:[...this.defaultable.facts,n,...e]}))}withNonce(){return new Ut(this.state,Object.assign(Object.assign({},this.defaultable),{addNonce:!0}))}claimCapability(n,...e){if(!Lt(n))throw new TypeError(`Expected capability, but got ${JSON.stringify(n,null," ")}`);return new Ut(this.state,Object.assign(Object.assign({},this.defaultable),{capabilities:[...this.defaultable.capabilities,n,...e]}))}delegateCapability(n,e,i){if(!Lt(n))throw new TypeError(`Expected 'requiredCapability' as a second argument, but got ${n}`);if(!fu(this.state))throw new Error("Can't delegate capabilities without having these paramenters set in the builder: issuer and expiration.");function a(l){return F(l,"capability")||F(l,"ownershipDID")}if(a(e)){if(i==null)throw new TypeError("Expected 'semantics' as third argument if a 'proof' DelegationChain was passed as second.");let l=e,c=l.ucan;if(!jt(i,n,l))throw new Error("Can't add capability to UCAN: Given proof doesn't give required rights to delegate.");return new Ut(this.state,Object.assign(Object.assign({},this.defaultable),{capabilities:[...this.defaultable.capabilities,n],proofs:this.defaultable.proofs.find(f=>gt(f)===gt(c))==null?[...this.defaultable.proofs,c]:this.defaultable.proofs}))}else{let l=e,c=this.state.issuer.did(),f=Si(l.findWithCapability(c,n,c));if(f!=null){let p=f.ucan,u=gt(p);return new Ut(this.state,Object.assign(Object.assign({},this.defaultable),{capabilities:[...this.defaultable.capabilities,n],proofs:this.defaultable.proofs.find(y=>gt(y)===u)==null?[...this.defaultable.proofs,p]:this.defaultable.proofs}))}else throw new Error("Couldn't add capability to UCAN. Couldn't find anything providing this capability in given store.")}}buildPayload(){if(!Zi(this.state))throw new Error("Builder is missing one of the required properties before it can be built: issuer, audience and expiration.");return Zr({issuer:this.state.issuer.did(),audience:this.state.audience,expiration:this.state.expiration,notBefore:this.defaultable.notBefore,addNonce:this.defaultable.addNonce,capabilities:this.defaultable.capabilities,facts:this.defaultable.facts,proofs:this.defaultable.proofs.map(n=>gt(n))})}build(){return uu(this,void 0,void 0,function*(){if(!Zi(this.state))throw new Error("Builder is missing one of the required properties before it can be built: issuer, audience and expiration.");let n=this.buildPayload();return yield xe(t)(n,this.state.issuer)})}},Wi=cu;var Yi=function(t,r,n,e){function i(a){return a instanceof n?a:new n(function(l){l(a)})}return new(n||(n=Promise))(function(a,l){function c(u){try{p(e.next(u))}catch(y){l(y)}}function f(u){try{p(e.throw(u))}catch(y){l(y)}}function p(u){u.done?a(u.value):i(u.value).then(c,f)}p((e=e.apply(t,r||[])).next())})},Qi=function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=t[Symbol.asyncIterator],n;return r?r.call(t):(t=typeof __values=="function"?__values(t):t[Symbol.iterator](),n={},e("next"),e("throw"),e("return"),n[Symbol.asyncIterator]=function(){return this},n);function e(a){n[a]=t[a]&&function(l){return new Promise(function(c,f){l=t[a](l),i(c,f,l.done,l.value)})}}function i(a,l,c,f){Promise.resolve(f).then(function(p){a({value:p,done:c})},l)}},lu=t=>class Qr{constructor(n,e){this.index=e,this.knownSemantics=n}static empty(n){return new Qr(n,{})}static fromTokens(n,e){var i,a,l,c;return Yi(this,void 0,void 0,function*(){let f=Qr.empty(n);try{for(i=Qi(e);a=yield i.next(),!a.done;){let p=a.value,u=yield Qt(t)(p);yield f.add(u)}}catch(p){l={error:p}}finally{try{a&&!a.done&&(c=i.return)&&(yield c.call(i))}finally{if(l)throw l.error}}return f})}add(n){var e,i,a;return Yi(this,void 0,void 0,function*(){let l=n.payload.aud,c=(a=this.index[l])!==null&&a!==void 0?a:[],f=gt(n);if(c.find(g=>gt(g.processedUcan)===f)!=null)return;let p=[];try{for(var u=Qi(Tt(t)(this.knownSemantics,n)),y;y=yield u.next(),!y.done;){let g=y.value;if(g instanceof Error){console.warn("Delegation chain error while storing UCAN:",g);continue}p.push(g)}}catch(g){e={error:g}}finally{try{y&&!y.done&&(i=u.return)&&(yield i.call(u))}finally{if(e)throw e.error}}c.find(g=>gt(g.processedUcan)===f)==null&&(c.push({processedUcan:n,capabilities:p}),this.index[l]=c)})}getByAudience(n){var e;return((e=this.index[n])!==null&&e!==void 0?e:[]).map(i=>i.processedUcan)}findByAudience(n,e){var i,a,l;return(l=(a=(i=this.index[n])===null||i===void 0?void 0:i.find(c=>e(c.processedUcan)))===null||a===void 0?void 0:a.processedUcan)!==null&&l!==void 0?l:null}*findWithCapability(n,e,i){let a=this.index[n];if(a!=null)for(let l of a)for(let c of l.capabilities)jt(this.knownSemantics,e,c)&&Ae(c)===i&&(yield c)}},ji=lu;var pu=function(t,r,n,e){function i(a){return a instanceof n?a:new n(function(l){l(a)})}return new(n||(n=Promise))(function(a,l){function c(u){try{p(e.next(u))}catch(y){l(y)}}function f(u){try{p(e.throw(u))}catch(y){l(y)}}function p(u){u.done?a(u.value):i(u.value).then(c,f)}p((e=e.apply(t,r||[])).next())})},Je=class{constructor(r,n){this.keys=r,this.methods=n}verifyIssuerAlg(r,n){let e=no(r);if(e==="key"){let i=ro(r);for(let a of this.keys)if(to(i,a.prefix))return n===a.jwtAlg}else{let i=this.methods[e];if(i)return i.checkJwtAlg(r,n)}throw new Error(`DID method not supported by plugins: ${r}`)}verifySignature(r,n,e){return pu(this,void 0,void 0,function*(){let i=no(r);if(i==="key"){let a=ro(r);for(let l of this.keys)if(to(a,l.prefix))return l.verifySignature(r,n,e)}else{let a=this.methods[i];if(a)return a.verifySignature(r,n,e)}throw new Error(`DID method not supported by plugins: ${r}`)})}};var to=(t,r)=>te(r,t.subarray(0,r.byteLength)),eo="did:key:z",ro=t=>{if(!t.startsWith(eo))throw new Error(`Not a valid base58 formatted did:key: ${t}`);return wt(t.slice(eo.length),"base58btc")},no=t=>{let r=t.split(":");if(r[0]!=="did")throw new Error(`Not a DID: ${t}`);if(r[1].length<1)throw new Error(`No DID method included: ${t}`);return r[1]};var io=t=>{let r=Gi(t),n=Wr(t),e=xe(t),i=Qt(t),a=Ve(t),l=Xi(t),c=Tt(t),f=Wi(t),p=ji(t);return{build:r,sign:n,signWithKeypair:e,validate:i,validateProofs:a,verify:l,delegationChains:c,Builder:f,Store:p}};var oo=new Je([vi,xi,wi,bi],{});var Mt=io(oo),ao=Mt.build,dl=Mt.sign,hl=Mt.signWithKeypair,so=Mt.validate,yl=Mt.validateProofs,ml=Mt.verify,vl=Mt.Builder,Dl=Mt.Store,wl=Mt.delegationChains;var{WARN:Ul,LOG:Du,DEBUG:_e,VERBOSE:Bl,ERROR:Ll}=Ye.setup(Ye.DEBUG);async function Nl(t,r){let n=await(await fetch("https://api.nft.storage/upload",{method:"POST",headers:{Authorization:`Bearer ${gt(r)}`,"Content-Type":"application/car","x-agent-did":r.payload.iss},body:t})).json();if(Du("[storeCar] result",n),!n.ok)throw new Error("Failed to register DID "+JSON.stringify(n.error));return Qe.parse(n.value.cid)}async function Fl(t,r,n){_e("[createRequestToken] ",{keypair:t,ucanToken:n});let e=n.payload;return ao({issuer:t,audience:r,capabilities:e.att,proofs:[gt(n)]})}async function Rl(t,r){_e("Registering",{did:r});let n=await(await fetch("https://api.nft.storage/user/did",{method:"POST",headers:{Authorization:`Bearer ${t}`},body:JSON.stringify({did:r})})).json();if(_e("Register DID result",n),!n.ok)throw new Error("Failed to register DID "+JSON.stringify(n.error))}async function Tl(t){_e("Get root UCAN",{apiKey:t});let r=await(await fetch("https://api.nft.storage/ucan/token",{method:"POST",headers:{Authorization:`Bearer ${t}`}})).json();if(_e("Get root UCAN result",r),!r.ok)throw new Error("Failed get root UCAN "+JSON.stringify(r.error));return so(r.value)}export{ii as a,Nl as b,Fl as c,Rl as d,Tl as e};
16
- //# sourceMappingURL=chunk-ZCSMRYJN.min.js.map