@multiformats/dns
Advanced tools
| (function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.MultiformatsDns = factory()}(typeof self !== 'undefined' ? self : this, function () { | ||
| "use strict";var MultiformatsDns=(()=>{var bt=Object.create;var K=Object.defineProperty;var xt=Object.getOwnPropertyDescriptor;var wt=Object.getOwnPropertyNames;var yt=Object.getPrototypeOf,gt=Object.prototype.hasOwnProperty;var Pe=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),w=(r,e)=>{for(var t in e)K(r,t,{get:e[t],enumerable:!0})},ze=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of wt(e))!gt.call(r,o)&&o!==t&&K(r,o,{get:()=>e[o],enumerable:!(n=xt(e,o))||n.enumerable});return r};var _e=(r,e,t)=>(t=r!=null?bt(yt(r)):{},ze(e||!r||!r.__esModule?K(t,"default",{value:r,enumerable:!0}):t,r)),vt=r=>ze(K({},"__esModule",{value:!0}),r);var Me=Pe((Fr,ne)=>{"use strict";var Et=Object.prototype.hasOwnProperty,b="~";function F(){}Object.create&&(F.prototype=Object.create(null),new F().__proto__||(b=!1));function At(r,e,t){this.fn=r,this.context=e,this.once=t||!1}function $e(r,e,t,n,o){if(typeof t!="function")throw new TypeError("The listener must be a function");var s=new At(t,n||r,o),i=b?b+e:e;return r._events[i]?r._events[i].fn?r._events[i]=[r._events[i],s]:r._events[i].push(s):(r._events[i]=s,r._eventsCount++),r}function W(r,e){--r._eventsCount===0?r._events=new F:delete r._events[e]}function m(){this._events=new F,this._eventsCount=0}m.prototype.eventNames=function(){var e=[],t,n;if(this._eventsCount===0)return e;for(n in t=this._events)Et.call(t,n)&&e.push(b?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e};m.prototype.listeners=function(e){var t=b?b+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var o=0,s=n.length,i=new Array(s);o<s;o++)i[o]=n[o].fn;return i};m.prototype.listenerCount=function(e){var t=b?b+e:e,n=this._events[t];return n?n.fn?1:n.length:0};m.prototype.emit=function(e,t,n,o,s,i){var c=b?b+e:e;if(!this._events[c])return!1;var a=this._events[c],u=arguments.length,d,f;if(a.fn){switch(a.once&&this.removeListener(e,a.fn,void 0,!0),u){case 1:return a.fn.call(a.context),!0;case 2:return a.fn.call(a.context,t),!0;case 3:return a.fn.call(a.context,t,n),!0;case 4:return a.fn.call(a.context,t,n,o),!0;case 5:return a.fn.call(a.context,t,n,o,s),!0;case 6:return a.fn.call(a.context,t,n,o,s,i),!0}for(f=1,d=new Array(u-1);f<u;f++)d[f-1]=arguments[f];a.fn.apply(a.context,d)}else{var D=a.length,p;for(f=0;f<D;f++)switch(a[f].once&&this.removeListener(e,a[f].fn,void 0,!0),u){case 1:a[f].fn.call(a[f].context);break;case 2:a[f].fn.call(a[f].context,t);break;case 3:a[f].fn.call(a[f].context,t,n);break;case 4:a[f].fn.call(a[f].context,t,n,o);break;default:if(!d)for(p=1,d=new Array(u-1);p<u;p++)d[p-1]=arguments[p];a[f].fn.apply(a[f].context,d)}}return!0};m.prototype.on=function(e,t,n){return $e(this,e,t,n,!1)};m.prototype.once=function(e,t,n){return $e(this,e,t,n,!0)};m.prototype.removeListener=function(e,t,n,o){var s=b?b+e:e;if(!this._events[s])return this;if(!t)return W(this,s),this;var i=this._events[s];if(i.fn)i.fn===t&&(!o||i.once)&&(!n||i.context===n)&&W(this,s);else{for(var c=0,a=[],u=i.length;c<u;c++)(i[c].fn!==t||o&&!i[c].once||n&&i[c].context!==n)&&a.push(i[c]);a.length?this._events[s]=a.length===1?a[0]:a:W(this,s)}return this};m.prototype.removeAllListeners=function(e){var t;return e?(t=b?b+e:e,this._events[t]&&W(this,t)):(this._events=new F,this._eventsCount=0),this};m.prototype.off=m.prototype.removeListener;m.prototype.addListener=m.prototype.on;m.prefixed=b;m.EventEmitter=m;typeof ne<"u"&&(ne.exports=m)});var dt=Pe((no,lt)=>{lt.exports=function(r){if(!r)throw Error("hashlru must have a max value, of type number, greater than 0");var e=0,t=Object.create(null),n=Object.create(null);function o(s,i){t[s]=i,e++,e>=r&&(e=0,n=t,t=Object.create(null))}return{has:function(s){return t[s]!==void 0||n[s]!==void 0},remove:function(s){t[s]!==void 0&&(t[s]=void 0),n[s]!==void 0&&(n[s]=void 0)},get:function(s){var i=t[s];if(i!==void 0)return i;if((i=n[s])!==void 0)return o(s,i),i},set:function(s,i){t[s]!==void 0?t[s]=i:o(s,i)},clear:function(){t=Object.create(null),n=Object.create(null)}}}});var Mr={};w(Mr,{MAX_RECURSIVE_DEPTH:()=>_r,RecordType:()=>g,dns:()=>$r});var U=class extends Event{type;detail;constructor(e,t){super(e),this.type=e,this.detail=t}};var oe=_e(Me(),1);var B=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},se=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},qe=r=>globalThis.DOMException===void 0?new se(r):new DOMException(r),Re=r=>{let e=r.reason===void 0?qe("This operation was aborted."):r.reason;return e instanceof Error?e:qe(e)};function ie(r,e){let{milliseconds:t,fallback:n,message:o,customTimers:s={setTimeout,clearTimeout}}=e,i,c,u=new Promise((d,f)=>{if(typeof t!="number"||Math.sign(t)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${t}\``);if(e.signal){let{signal:p}=e;p.aborted&&f(Re(p)),c=()=>{f(Re(p))},p.addEventListener("abort",c,{once:!0})}if(t===Number.POSITIVE_INFINITY){r.then(d,f);return}let D=new B;i=s.setTimeout.call(void 0,()=>{if(n){try{d(n())}catch(p){f(p)}return}typeof r.cancel=="function"&&r.cancel(),o===!1?d():o instanceof Error?f(o):(D.message=o??`Promise timed out after ${t} milliseconds`,f(D))},t),(async()=>{try{d(await r)}catch(p){f(p)}})()}).finally(()=>{u.clear(),c&&e.signal&&e.signal.removeEventListener("abort",c)});return u.clear=()=>{s.clearTimeout.call(void 0,i),i=void 0},u}function ae(r,e,t){let n=0,o=r.length;for(;o>0;){let s=Math.trunc(o/2),i=n+s;t(r[i],e)<=0?(n=++i,o-=s+1):o=s}return n}var V=class{#e=[];enqueue(e,t){t={priority:0,...t};let n={priority:t.priority,id:t.id,run:e};if(this.size===0||this.#e[this.size-1].priority>=t.priority){this.#e.push(n);return}let o=ae(this.#e,n,(s,i)=>i.priority-s.priority);this.#e.splice(o,0,n)}setPriority(e,t){let n=this.#e.findIndex(s=>s.id===e);if(n===-1)throw new ReferenceError(`No promise function with the id "${e}" exists in the queue.`);let[o]=this.#e.splice(n,1);this.enqueue(o.run,{priority:t,id:e})}dequeue(){return this.#e.shift()?.run}filter(e){return this.#e.filter(t=>t.priority===e.priority).map(t=>t.run)}get size(){return this.#e.length}};var k=class extends oe.default{#e;#i;#s=0;#d;#a;#p=0;#r;#c;#t;#m;#n=0;#f;#o;#b;#y=1n;timeout;constructor(e){if(super(),e={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:V,...e},!(typeof e.intervalCap=="number"&&e.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${e.intervalCap?.toString()??""}\` (${typeof e.intervalCap})`);if(e.interval===void 0||!(Number.isFinite(e.interval)&&e.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${e.interval?.toString()??""}\` (${typeof e.interval})`);this.#e=e.carryoverConcurrencyCount,this.#i=e.intervalCap===Number.POSITIVE_INFINITY||e.interval===0,this.#d=e.intervalCap,this.#a=e.interval,this.#t=new e.queueClass,this.#m=e.queueClass,this.concurrency=e.concurrency,this.timeout=e.timeout,this.#b=e.throwOnTimeout===!0,this.#o=e.autoStart===!1}get#g(){return this.#i||this.#s<this.#d}get#v(){return this.#n<this.#f}#E(){this.#n--,this.#u(),this.emit("next")}#A(){this.#w(),this.#x(),this.#c=void 0}get#C(){let e=Date.now();if(this.#r===void 0){let t=this.#p-e;if(t<0)this.#s=this.#e?this.#n:0;else return this.#c===void 0&&(this.#c=setTimeout(()=>{this.#A()},t)),!0}return!1}#u(){if(this.#t.size===0)return this.#r&&clearInterval(this.#r),this.#r=void 0,this.emit("empty"),this.#n===0&&this.emit("idle"),!1;if(!this.#o){let e=!this.#C;if(this.#g&&this.#v){let t=this.#t.dequeue();return t?(this.emit("active"),t(),e&&this.#x(),!0):!1}}return!1}#x(){this.#i||this.#r!==void 0||(this.#r=setInterval(()=>{this.#w()},this.#a),this.#p=Date.now()+this.#a)}#w(){this.#s===0&&this.#n===0&&this.#r&&(clearInterval(this.#r),this.#r=void 0),this.#s=this.#e?this.#n:0,this.#h()}#h(){for(;this.#u(););}get concurrency(){return this.#f}set concurrency(e){if(!(typeof e=="number"&&e>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);this.#f=e,this.#h()}async#T(e){return new Promise((t,n)=>{e.addEventListener("abort",()=>{n(e.reason)},{once:!0})})}setPriority(e,t){this.#t.setPriority(e,t)}async add(e,t={}){return t.id??=(this.#y++).toString(),t={timeout:this.timeout,throwOnTimeout:this.#b,...t},new Promise((n,o)=>{this.#t.enqueue(async()=>{this.#n++;try{t.signal?.throwIfAborted(),this.#s++;let s=e({signal:t.signal});t.timeout&&(s=ie(Promise.resolve(s),{milliseconds:t.timeout})),t.signal&&(s=Promise.race([s,this.#T(t.signal)]));let i=await s;n(i),this.emit("completed",i)}catch(s){if(s instanceof B&&!t.throwOnTimeout){n();return}o(s),this.emit("error",s)}finally{this.#E()}},t),this.emit("add"),this.#u()})}async addAll(e,t){return Promise.all(e.map(async n=>this.add(n,t)))}start(){return this.#o?(this.#o=!1,this.#h(),this):this}pause(){this.#o=!0}clear(){this.#t=new this.#m}async onEmpty(){this.#t.size!==0&&await this.#l("empty")}async onSizeLessThan(e){this.#t.size<e||await this.#l("next",()=>this.#t.size<e)}async onIdle(){this.#n===0&&this.#t.size===0||await this.#l("idle")}async#l(e,t){return new Promise(n=>{let o=()=>{t&&!t()||(this.off(e,o),n())};this.on(e,o)})}get size(){return this.#t.size}sizeBy(e){return this.#t.filter(e).length}get pending(){return this.#n}get isPaused(){return this.#o}};function Z(r){let e=[g.A];return r==null?e:Array.isArray(r)?r.length===0?e:r:[r]}var le={};w(le,{base10:()=>Nt});var Zr=new Uint8Array(0);function Fe(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}function L(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")}function Be(r){return new TextEncoder().encode(r)}function Ve(r){return new TextDecoder().decode(r)}function Ct(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var o=0;o<r.length;o++){var s=r.charAt(o),i=s.charCodeAt(0);if(t[i]!==255)throw new TypeError(s+" is ambiguous");t[i]=o}var c=r.length,a=r.charAt(0),u=Math.log(c)/Math.log(256),d=Math.log(256)/Math.log(c);function f(h){if(h instanceof Uint8Array||(ArrayBuffer.isView(h)?h=new Uint8Array(h.buffer,h.byteOffset,h.byteLength):Array.isArray(h)&&(h=Uint8Array.from(h))),!(h instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(h.length===0)return"";for(var x=0,P=0,v=0,A=h.length;v!==A&&h[v]===0;)v++,x++;for(var C=(A-v)*d+1>>>0,y=new Uint8Array(C);v!==A;){for(var T=h[v],N=0,E=C-1;(T!==0||N<P)&&E!==-1;E--,N++)T+=256*y[E]>>>0,y[E]=T%c>>>0,T=T/c>>>0;if(T!==0)throw new Error("Non-zero carry");P=N,v++}for(var I=C-P;I!==C&&y[I]===0;)I++;for(var G=a.repeat(x);I<C;++I)G+=r.charAt(y[I]);return G}function D(h){if(typeof h!="string")throw new TypeError("Expected String");if(h.length===0)return new Uint8Array;var x=0;if(h[x]!==" "){for(var P=0,v=0;h[x]===a;)P++,x++;for(var A=(h.length-x)*u+1>>>0,C=new Uint8Array(A);h[x];){var y=t[h.charCodeAt(x)];if(y===255)return;for(var T=0,N=A-1;(y!==0||T<v)&&N!==-1;N--,T++)y+=c*C[N]>>>0,C[N]=y%256>>>0,y=y/256>>>0;if(y!==0)throw new Error("Non-zero carry");v=T,x++}if(h[x]!==" "){for(var E=A-v;E!==A&&C[E]===0;)E++;for(var I=new Uint8Array(P+(A-E)),G=P;E!==A;)I[G++]=C[E++];return I}}}function p(h){var x=D(h);if(x)return x;throw new Error(`Non-${e} character`)}return{encode:f,decodeUnsafe:D,decode:p}}var Tt=Ct,St=Tt,Je=St;var ce=class{name;prefix;baseEncode;constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},fe=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,n){this.name=e,this.prefix=t;let o=t.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,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 Qe(this,e)}},ue=class{decoders;constructor(e){this.decoders=e}or(e){return Qe(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Qe(r,e){return new ue({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var he=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new ce(e,t,n),this.decoder=new fe(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function z({name:r,prefix:e,encode:t,decode:n}){return new he(r,e,t,n)}function O({name:r,prefix:e,alphabet:t}){let{encode:n,decode:o}=Je(t,r);return z({prefix:e,name:r,encode:n,decode:s=>L(o(s))})}function Dt(r,e,t,n){let o=r.length;for(;r[o-1]==="=";)--o;let s=new Uint8Array(o*t/8|0),i=0,c=0,a=0;for(let u=0;u<o;++u){let d=e[r[u]];if(d===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<t|d,i+=t,i>=8&&(i-=8,s[a++]=255&c>>i)}if(i>=t||(255&c<<8-i)!==0)throw new SyntaxError("Unexpected end of data");return s}function It(r,e,t){let n=e[e.length-1]==="=",o=(1<<t)-1,s="",i=0,c=0;for(let a=0;a<r.length;++a)for(c=c<<8|r[a],i+=8;i>t;)i-=t,s+=e[o&c>>i];if(i!==0&&(s+=e[o&c<<t-i]),n)for(;(s.length*t&7)!==0;)s+="=";return s}function Lt(r){let e={};for(let t=0;t<r.length;++t)e[r[t]]=t;return e}function l({name:r,prefix:e,bitsPerChar:t,alphabet:n}){let o=Lt(n);return z({prefix:e,name:r,encode(s){return It(s,n,t)},decode(s){return Dt(s,o,t,r)}})}var Nt=O({prefix:"9",name:"base10",alphabet:"0123456789"});var de={};w(de,{base16:()=>Ut,base16upper:()=>Ot});var Ut=l({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Ot=l({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var pe={};w(pe,{base2:()=>Pt});var Pt=l({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var me={};w(me,{base256emoji:()=>qt});var He=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}"),zt=He.reduce((r,e,t)=>(r[t]=e,r),[]),_t=He.reduce((r,e,t)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return r[n]=t,r},[]);function $t(r){return r.reduce((e,t)=>(e+=zt[t],e),"")}function Mt(r){let e=[];for(let t of r){let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);let o=_t[n];if(o==null)throw new Error(`Non-base256emoji character: ${t}`);e.push(o)}return new Uint8Array(e)}var qt=z({prefix:"\u{1F680}",name:"base256emoji",encode:$t,decode:Mt});var be={};w(be,{base32:()=>_,base32hex:()=>Vt,base32hexpad:()=>Jt,base32hexpadupper:()=>Qt,base32hexupper:()=>kt,base32pad:()=>Ft,base32padupper:()=>Bt,base32upper:()=>Rt,base32z:()=>Ht});var _=l({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Rt=l({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Ft=l({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Bt=l({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Vt=l({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),kt=l({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Jt=l({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Qt=l({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Ht=l({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var xe={};w(xe,{base36:()=>J,base36upper:()=>Xt});var J=O({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Xt=O({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var we={};w(we,{base58btc:()=>S,base58flickr:()=>Yt});var S=O({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Yt=O({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var ye={};w(ye,{base64:()=>Gt,base64pad:()=>Kt,base64url:()=>Wt,base64urlpad:()=>Zt});var Gt=l({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Kt=l({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Wt=l({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Zt=l({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var ge={};w(ge,{base8:()=>jt});var jt=l({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var ve={};w(ve,{identity:()=>er});var er=z({prefix:"\0",name:"identity",encode:r=>Ve(r),decode:r=>Be(r)});var mn=new TextEncoder,bn=new TextDecoder;var Ae={};w(Ae,{identity:()=>Ar});var nr=Ge,Xe=128,or=127,sr=~or,ir=Math.pow(2,31);function Ge(r,e,t){e=e||[],t=t||0;for(var n=t;r>=ir;)e[t++]=r&255|Xe,r/=128;for(;r&sr;)e[t++]=r&255|Xe,r>>>=7;return e[t]=r|0,Ge.bytes=t-n+1,e}var ar=Ee,cr=128,Ye=127;function Ee(r,n){var t=0,n=n||0,o=0,s=n,i,c=r.length;do{if(s>=c)throw Ee.bytes=0,new RangeError("Could not decode varint");i=r[s++],t+=o<28?(i&Ye)<<o:(i&Ye)*Math.pow(2,o),o+=7}while(i>=cr);return Ee.bytes=s-n,t}var fr=Math.pow(2,7),ur=Math.pow(2,14),hr=Math.pow(2,21),lr=Math.pow(2,28),dr=Math.pow(2,35),pr=Math.pow(2,42),mr=Math.pow(2,49),br=Math.pow(2,56),xr=Math.pow(2,63),wr=function(r){return r<fr?1:r<ur?2:r<hr?3:r<lr?4:r<dr?5:r<pr?6:r<mr?7:r<br?8:r<xr?9:10},yr={encode:nr,decode:ar,encodingLength:wr},gr=yr,Q=gr;function H(r,e=0){return[Q.decode(r,e),Q.decode.bytes]}function $(r,e,t=0){return Q.encode(r,e,t),e}function M(r){return Q.encodingLength(r)}function R(r,e){let t=e.byteLength,n=M(r),o=n+M(t),s=new Uint8Array(o+t);return $(r,s,0),$(t,s,n),s.set(e,o),new q(r,t,e,s)}function Ke(r){let e=L(r),[t,n]=H(e),[o,s]=H(e.subarray(n)),i=e.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new q(t,o,i,e)}function We(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&Fe(r.bytes,t.bytes)}}var q=class{code;size;digest;bytes;constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};var Ze=0,vr="identity",je=L;function Er(r,e){if(e?.truncate!=null&&e.truncate!==r.byteLength){if(e.truncate<0||e.truncate>r.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${r.byteLength}`);r=r.subarray(0,e.truncate)}return R(Ze,je(r))}var Ar={code:Ze,name:vr,encode:je,digest:Er};var Se={};w(Se,{sha256:()=>Tr,sha512:()=>Sr});var Cr=20;function Te({name:r,code:e,encode:t,minDigestLength:n,maxDigestLength:o}){return new Ce(r,e,t,n,o)}var Ce=class{name;code;encode;minDigestLength;maxDigestLength;constructor(e,t,n,o,s){this.name=e,this.code=t,this.encode=n,this.minDigestLength=o??Cr,this.maxDigestLength=s}digest(e,t){if(t?.truncate!=null){if(t.truncate<this.minDigestLength)throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);if(this.maxDigestLength!=null&&t.truncate>this.maxDigestLength)throw new Error(`Invalid truncate option, must be less than or equal to ${this.maxDigestLength}`)}if(e instanceof Uint8Array){let n=this.encode(e);return n instanceof Uint8Array?et(n,this.code,t?.truncate):n.then(o=>et(o,this.code,t?.truncate))}else throw Error("Unknown type, must be binary type")}};function et(r,e,t){if(t!=null&&t!==r.byteLength){if(t>r.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${r.byteLength}`);r=r.subarray(0,t)}return R(e,r)}function rt(r){return async e=>new Uint8Array(await crypto.subtle.digest(r,e))}var Tr=Te({name:"sha2-256",code:18,encode:rt("SHA-256")}),Sr=Te({name:"sha2-512",code:19,encode:rt("SHA-512")});function nt(r,e){let{bytes:t,version:n}=r;switch(n){case 0:return Ir(t,De(r),e??S.encoder);default:return Lr(t,De(r),e??_.encoder)}}var ot=new WeakMap;function De(r){let e=ot.get(r);if(e==null){let t=new Map;return ot.set(r,t),t}return e}var ee=class r{code;version;multihash;bytes;"/";constructor(e,t,n,o){this.code=t,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:t}=this;if(e!==Y)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==Nr)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(t)}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:t}=this.multihash,n=R(e,t);return r.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 r.equals(this,e)}static equals(e,t){let n=t;return n!=null&&e.code===n.code&&e.version===n.version&&We(e.multihash,n.multihash)}toString(e){return nt(this,e)}toJSON(){return{"/":nt(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let t=e;if(t instanceof r)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:o,multihash:s,bytes:i}=t;return new r(n,o,s,i??st(n,o,s.bytes))}else if(t[Ur]===!0){let{version:n,multihash:o,code:s}=t,i=Ke(o);return r.create(n,s,i)}else return null}static create(e,t,n){if(typeof t!="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(t!==Y)throw new Error(`Version 0 CID must use dag-pb (code: ${Y}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let o=st(e,t,n.bytes);return new r(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,Y,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,n]=r.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),n=t.size-t.multihashSize,o=L(e.subarray(n,n+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=o.subarray(t.multihashSize-t.digestSize),i=new q(t.multihashCode,t.digestSize,s,o);return[t.version===0?r.createV0(i):r.createV1(t.codec,i),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[f,D]=H(e.subarray(t));return t+=D,f},o=n(),s=Y;if(o===18?(o=0,t=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=t,c=n(),a=n(),u=t+a,d=u-i;return{version:o,codec:s,multihashCode:c,digestSize:a,multihashSize:d,size:u}}static parse(e,t){let[n,o]=Dr(e,t),s=r.decode(o);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return De(s).set(n,e),s}};function Dr(r,e){switch(r[0]){case"Q":{let t=e??S;return[S.prefix,t.decode(`${S.prefix}${r}`)]}case S.prefix:{let t=e??S;return[S.prefix,t.decode(r)]}case _.prefix:{let t=e??_;return[_.prefix,t.decode(r)]}case J.prefix:{let t=e??J;return[J.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}}function Ir(r,e,t){let{prefix:n}=t;if(n!==S.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=e.get(n);if(o==null){let s=t.encode(r).slice(1);return e.set(n,s),s}else return o}function Lr(r,e,t){let{prefix:n}=t,o=e.get(n);if(o==null){let s=t.encode(r);return e.set(n,s),s}else return o}var Y=112,Nr=18;function st(r,e,t){let n=M(r),o=n+M(e),s=new Uint8Array(o+t.byteLength);return $(r,s,0),$(e,s,n),s.set(t,o),s}var Ur=Symbol.for("@ipld/js-cid/CID");var Ie={...ve,...pe,...ge,...le,...de,...be,...xe,...we,...ye,...me},qn={...Se,...Ae};function it(r=0){return new Uint8Array(r)}function ct(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var at=ct("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Le=ct("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);let e=it(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),Or={utf8:at,"utf-8":at,hex:Ie.base16,latin1:Le,ascii:Le,binary:Le,...Ie},ft=Or;function ut(r,e="utf8"){let t=ft[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.encoder.encode(r).substring(1)}var Ne=60;function te(r){return{Status:r.Status??0,TC:r.TC??r.flag_tc??!1,RD:r.RD??r.flag_rd??!1,RA:r.RA??r.flag_ra??!1,AD:r.AD??r.flag_ad??!1,CD:r.CD??r.flag_cd??!1,Question:(r.Question??r.questions??[]).map(e=>({name:e.name,type:g[e.type]})),Answer:(r.Answer??r.answers??[]).map(e=>({name:e.name,type:g[e.type],TTL:e.TTL??e.ttl??Ne,data:e.data instanceof Uint8Array?ut(e.data):e.data}))}}var Pr=4;function Ue(r,e={}){let t=new k({concurrency:e.queryConcurrency??Pr});return async(n,o={})=>{let s=new URLSearchParams;s.set("name",n),Z(o.types).forEach(c=>{s.append("type",g[c])}),o.onProgress?.(new U("dns:query",n));let i=await t.add(async()=>{let c=await fetch(`${r}?${s}`,{headers:{accept:"application/dns-json"},signal:o?.signal});if(c.status!==200)throw new Error(`Unexpected HTTP status: ${c.status} - ${c.statusText}`);let a=te(await c.json());return o.onProgress?.(new U("dns:response",a)),a},{signal:o.signal});if(i==null)throw new Error("No DNS response received");return i}}function ht(){return[Ue("https://cloudflare-dns.com/dns-query"),Ue("https://dns.google/resolve")]}var pt=_e(dt(),1);var Oe=class{lru;constructor(e){this.lru=(0,pt.default)(e)}get(e,t){let n=!0,o=[];for(let s of t){let i=this.getAnswers(e,s);if(i.length===0){n=!1;break}o.push(...i)}if(n)return te({answers:o})}getAnswers(e,t){let n=`${e.toLowerCase()}-${t}`,o=this.lru.get(n);if(o!=null){let s=o.filter(i=>i.expires>Date.now()).map(({expires:i,value:c})=>({...c,TTL:Math.round((i-Date.now())/1e3),type:g[c.type]}));return s.length===0&&this.lru.remove(n),s}return[]}add(e,t){let n=`${e.toLowerCase()}-${t.type}`,o=this.lru.get(n)??[];o.push({expires:Date.now()+(t.TTL??Ne)*1e3,value:t}),this.lru.set(n,o)}remove(e,t){let n=`${e.toLowerCase()}-${t}`;this.lru.remove(n)}clear(){this.lru.clear()}};function mt(r){return new Oe(r)}var zr=1e3,re=class{resolvers;cache;constructor(e){this.resolvers={},this.cache=mt(e.cacheSize??zr),Object.entries(e.resolvers??{}).forEach(([t,n])=>{Array.isArray(n)||(n=[n]),t.endsWith(".")||(t=`${t}.`),this.resolvers[t]=n}),this.resolvers["."]==null&&(this.resolvers["."]=ht())}async query(e,t={}){let n=Z(t.types),o=t.cached!==!1?this.cache.get(e,n):void 0;if(o!=null)return t.onProgress?.(new U("dns:cache",o)),o;let s=`${e.split(".").pop()}.`,i=(this.resolvers[s]??this.resolvers["."]).sort(()=>Math.random()>.5?-1:1),c=[];for(let a of i){if(t.signal?.aborted===!0)break;try{let u=await a(e,{...t,types:n});for(let d of u.Answer)this.cache.add(e,d);return u}catch(u){c.push(u),t.onProgress?.(new U("dns:error",u))}}throw c.length===1?c[0]:new AggregateError(c,`DNS lookup of ${e} ${n} failed`)}};var g;(function(r){r[r.A=1]="A",r[r.CNAME=5]="CNAME",r[r.TXT=16]="TXT",r[r.AAAA=28]="AAAA"})(g||(g={}));var _r=32;function $r(r={}){return new re(r)}return vt(Mr);})(); | ||
| "use strict";var MultiformatsDns=(()=>{var pt=Object.create;var G=Object.defineProperty;var mt=Object.getOwnPropertyDescriptor;var bt=Object.getOwnPropertyNames;var xt=Object.getPrototypeOf,gt=Object.prototype.hasOwnProperty;var Pe=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),g=(r,e)=>{for(var t in e)G(r,t,{get:e[t],enumerable:!0})},ze=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of bt(e))!gt.call(r,i)&&i!==t&&G(r,i,{get:()=>e[i],enumerable:!(n=mt(e,i))||n.enumerable});return r};var $e=(r,e,t)=>(t=r!=null?pt(xt(r)):{},ze(e||!r||!r.__esModule?G(t,"default",{value:r,enumerable:!0}):t,r)),wt=r=>ze(G({},"__esModule",{value:!0}),r);var _e=Pe((Mr,re)=>{"use strict";var yt=Object.prototype.hasOwnProperty,m="~";function F(){}Object.create&&(F.prototype=Object.create(null),new F().__proto__||(m=!1));function vt(r,e,t){this.fn=r,this.context=e,this.once=t||!1}function Oe(r,e,t,n,i){if(typeof t!="function")throw new TypeError("The listener must be a function");var s=new vt(t,n||r,i),o=m?m+e:e;return r._events[o]?r._events[o].fn?r._events[o]=[r._events[o],s]:r._events[o].push(s):(r._events[o]=s,r._eventsCount++),r}function Z(r,e){--r._eventsCount===0?r._events=new F:delete r._events[e]}function p(){this._events=new F,this._eventsCount=0}p.prototype.eventNames=function(){var e=[],t,n;if(this._eventsCount===0)return e;for(n in t=this._events)yt.call(t,n)&&e.push(m?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e};p.prototype.listeners=function(e){var t=m?m+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,s=n.length,o=new Array(s);i<s;i++)o[i]=n[i].fn;return o};p.prototype.listenerCount=function(e){var t=m?m+e:e,n=this._events[t];return n?n.fn?1:n.length:0};p.prototype.emit=function(e,t,n,i,s,o){var c=m?m+e:e;if(!this._events[c])return!1;var a=this._events[c],f=arguments.length,d,u;if(a.fn){switch(a.once&&this.removeListener(e,a.fn,void 0,!0),f){case 1:return a.fn.call(a.context),!0;case 2:return a.fn.call(a.context,t),!0;case 3:return a.fn.call(a.context,t,n),!0;case 4:return a.fn.call(a.context,t,n,i),!0;case 5:return a.fn.call(a.context,t,n,i,s),!0;case 6:return a.fn.call(a.context,t,n,i,s,o),!0}for(u=1,d=new Array(f-1);u<f;u++)d[u-1]=arguments[u];a.fn.apply(a.context,d)}else{var x=a.length,A;for(u=0;u<x;u++)switch(a[u].once&&this.removeListener(e,a[u].fn,void 0,!0),f){case 1:a[u].fn.call(a[u].context);break;case 2:a[u].fn.call(a[u].context,t);break;case 3:a[u].fn.call(a[u].context,t,n);break;case 4:a[u].fn.call(a[u].context,t,n,i);break;default:if(!d)for(A=1,d=new Array(f-1);A<f;A++)d[A-1]=arguments[A];a[u].fn.apply(a[u].context,d)}}return!0};p.prototype.on=function(e,t,n){return Oe(this,e,t,n,!1)};p.prototype.once=function(e,t,n){return Oe(this,e,t,n,!0)};p.prototype.removeListener=function(e,t,n,i){var s=m?m+e:e;if(!this._events[s])return this;if(!t)return Z(this,s),this;var o=this._events[s];if(o.fn)o.fn===t&&(!i||o.once)&&(!n||o.context===n)&&Z(this,s);else{for(var c=0,a=[],f=o.length;c<f;c++)(o[c].fn!==t||i&&!o[c].once||n&&o[c].context!==n)&&a.push(o[c]);a.length?this._events[s]=a.length===1?a[0]:a:Z(this,s)}return this};p.prototype.removeAllListeners=function(e){var t;return e?(t=m?m+e:e,this._events[t]&&Z(this,t)):(this._events=new F,this._eventsCount=0),this};p.prototype.off=p.prototype.removeListener;p.prototype.addListener=p.prototype.on;p.prefixed=m;p.EventEmitter=p;typeof re<"u"&&(re.exports=p)});var ft=Pe((ti,ht)=>{ht.exports=function(r){if(!r)throw Error("hashlru must have a max value, of type number, greater than 0");var e=0,t=Object.create(null),n=Object.create(null);function i(s,o){t[s]=o,e++,e>=r&&(e=0,n=t,t=Object.create(null))}return{has:function(s){return t[s]!==void 0||n[s]!==void 0},remove:function(s){t[s]!==void 0&&(t[s]=void 0),n[s]!==void 0&&(n[s]=void 0)},get:function(s){var o=t[s];if(o!==void 0)return o;if((o=n[s])!==void 0)return i(s,o),o},set:function(s,o){t[s]!==void 0?t[s]=o:i(s,o)},clear:function(){t=Object.create(null),n=Object.create(null)}}}});var Or={};g(Or,{MAX_RECURSIVE_DEPTH:()=>zr,RecordType:()=>y,dns:()=>$r});var U=class extends Event{type;detail;constructor(e,t){super(e),this.type=e,this.detail=t}};var ne=$e(_e(),1);var ie=class r extends Error{name="TimeoutError";constructor(e,t){super(e,t),Error.captureStackTrace?.(this,r)}},Re=r=>r.reason??new DOMException("This operation was aborted.","AbortError");function se(r,e){let{milliseconds:t,fallback:n,message:i,customTimers:s={setTimeout,clearTimeout},signal:o}=e,c,a,d=new Promise((u,x)=>{if(typeof t!="number"||Math.sign(t)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${t}\``);if(o?.aborted){x(Re(o));return}if(o&&(a=()=>{x(Re(o))},o.addEventListener("abort",a,{once:!0})),r.then(u,x),t===Number.POSITIVE_INFINITY)return;let A=new ie;c=s.setTimeout.call(void 0,()=>{if(n){try{u(n())}catch(h){x(h)}return}typeof r.cancel=="function"&&r.cancel(),i===!1?u():i instanceof Error?x(i):(A.message=i??`Promise timed out after ${t} milliseconds`,x(A))},t)}).finally(()=>{d.clear(),a&&o&&o.removeEventListener("abort",a)});return d.clear=()=>{s.clearTimeout.call(void 0,c),c=void 0},d}function oe(r,e,t){let n=0,i=r.length;for(;i>0;){let s=Math.trunc(i/2),o=n+s;t(r[o],e)<=0?(n=++o,i-=s+1):i=s}return n}var k=class{#t=[];enqueue(e,t){let{priority:n=0,id:i}=t??{},s={priority:n,id:i,run:e};if(this.size===0||this.#t[this.size-1].priority>=n){this.#t.push(s);return}let o=oe(this.#t,s,(c,a)=>a.priority-c.priority);this.#t.splice(o,0,s)}setPriority(e,t){let n=this.#t.findIndex(s=>s.id===e);if(n===-1)throw new ReferenceError(`No promise function with the id "${e}" exists in the queue.`);let[i]=this.#t.splice(n,1);this.enqueue(i.run,{priority:t,id:e})}dequeue(){return this.#t.shift()?.run}filter(e){return this.#t.filter(t=>t.priority===e.priority).map(t=>t.run)}get size(){return this.#t.length}};var B=class extends ne.default{#t;#n;#i=0;#d;#p=!1;#m=!1;#u;#w=0;#b=0;#s;#o;#e;#y;#r=0;#h;#a;#S=1n;#f=new Map;timeout;constructor(e){if(super(),e={carryoverIntervalCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:k,...e},!(typeof e.intervalCap=="number"&&e.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${e.intervalCap?.toString()??""}\` (${typeof e.intervalCap})`);if(e.interval===void 0||!(Number.isFinite(e.interval)&&e.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${e.interval?.toString()??""}\` (${typeof e.interval})`);if(this.#t=e.carryoverIntervalCount??e.carryoverConcurrencyCount??!1,this.#n=e.intervalCap===Number.POSITIVE_INFINITY||e.interval===0,this.#d=e.intervalCap,this.#u=e.interval,this.#e=new e.queueClass,this.#y=e.queueClass,this.concurrency=e.concurrency,e.timeout!==void 0&&!(Number.isFinite(e.timeout)&&e.timeout>0))throw new TypeError(`Expected \`timeout\` to be a positive finite number, got \`${e.timeout}\` (${typeof e.timeout})`);this.timeout=e.timeout,this.#a=e.autoStart===!1,this.#$()}get#I(){return this.#n||this.#i<this.#d}get#L(){return this.#r<this.#h}#D(){this.#r--,this.#r===0&&this.emit("pendingZero"),this.#x(),this.emit("next")}#N(){this.#C(),this.#A(),this.#o=void 0}get#U(){let e=Date.now();if(this.#s===void 0){let t=this.#w-e;if(t<0){if(this.#b>0){let n=e-this.#b;if(n<this.#u)return this.#v(this.#u-n),!0}this.#i=this.#t?this.#r:0}else return this.#v(t),!0}return!1}#v(e){this.#o===void 0&&(this.#o=setTimeout(()=>{this.#N()},e))}#E(){this.#s&&(clearInterval(this.#s),this.#s=void 0)}#P(){this.#o&&(clearTimeout(this.#o),this.#o=void 0)}#x(){if(this.#e.size===0)return this.#E(),this.emit("empty"),this.#r===0&&(this.#P(),this.emit("idle")),!1;let e=!1;if(!this.#a){let t=!this.#U;if(this.#I&&this.#L){let n=this.#e.dequeue();this.#n||(this.#i++,this.#l()),this.emit("active"),this.#b=Date.now(),n(),t&&this.#A(),e=!0}}return e}#A(){this.#n||this.#s!==void 0||(this.#s=setInterval(()=>{this.#C()},this.#u),this.#w=Date.now()+this.#u)}#C(){this.#i===0&&this.#r===0&&this.#s&&this.#E(),this.#i=this.#t?this.#r:0,this.#g(),this.#l()}#g(){for(;this.#x(););}get concurrency(){return this.#h}set concurrency(e){if(!(typeof e=="number"&&e>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);this.#h=e,this.#g()}async#z(e){return new Promise((t,n)=>{e.addEventListener("abort",()=>{n(e.reason)},{once:!0})})}setPriority(e,t){if(typeof t!="number"||!Number.isFinite(t))throw new TypeError(`Expected \`priority\` to be a finite number, got \`${t}\` (${typeof t})`);this.#e.setPriority(e,t)}async add(e,t={}){return t.id??=(this.#S++).toString(),t={timeout:this.timeout,...t},new Promise((n,i)=>{let s=Symbol(`task-${t.id}`);this.#e.enqueue(async()=>{this.#r++,this.#f.set(s,{id:t.id,priority:t.priority??0,startTime:Date.now(),timeout:t.timeout});try{try{t.signal?.throwIfAborted()}catch(a){throw this.#n||this.#i--,this.#f.delete(s),a}let o=e({signal:t.signal});t.timeout&&(o=se(Promise.resolve(o),{milliseconds:t.timeout,message:`Task timed out after ${t.timeout}ms (queue has ${this.#r} running, ${this.#e.size} waiting)`})),t.signal&&(o=Promise.race([o,this.#z(t.signal)]));let c=await o;n(c),this.emit("completed",c)}catch(o){i(o),this.emit("error",o)}finally{this.#f.delete(s),queueMicrotask(()=>{this.#D()})}},t),this.emit("add"),this.#x()})}async addAll(e,t){return Promise.all(e.map(async n=>this.add(n,t)))}start(){return this.#a?(this.#a=!1,this.#g(),this):this}pause(){this.#a=!0}clear(){this.#e=new this.#y,this.#T()}async onEmpty(){this.#e.size!==0&&await this.#c("empty")}async onSizeLessThan(e){this.#e.size<e||await this.#c("next",()=>this.#e.size<e)}async onIdle(){this.#r===0&&this.#e.size===0||await this.#c("idle")}async onPendingZero(){this.#r!==0&&await this.#c("pendingZero")}async onRateLimit(){this.isRateLimited||await this.#c("rateLimit")}async onRateLimitCleared(){this.isRateLimited&&await this.#c("rateLimitCleared")}async onError(){return new Promise((e,t)=>{let n=i=>{this.off("error",n),t(i)};this.on("error",n)})}async#c(e,t){return new Promise(n=>{let i=()=>{t&&!t()||(this.off(e,i),n())};this.on(e,i)})}get size(){return this.#e.size}sizeBy(e){return this.#e.filter(e).length}get pending(){return this.#r}get isPaused(){return this.#a}#$(){this.#n||(this.on("add",()=>{this.#e.size>0&&this.#l()}),this.on("next",()=>{this.#l()}))}#l(){this.#n||this.#m||(this.#m=!0,queueMicrotask(()=>{this.#m=!1,this.#T()}))}#T(){let e=this.#p,t=!this.#n&&this.#i>=this.#d&&this.#e.size>0;t!==e&&(this.#p=t,this.emit(t?"rateLimit":"rateLimitCleared"))}get isRateLimited(){return this.#p}get isSaturated(){return this.#r===this.#h&&this.#e.size>0||this.isRateLimited&&this.#e.size>0}get runningTasks(){return[...this.#f.values()].map(e=>({...e}))}};function K(r){let e=[y.A];return r==null?e:Array.isArray(r)?r.length===0?e:r:[r]}var fe={};g(fe,{base10:()=>Lt});var Zr=new Uint8Array(0);function Me(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}function D(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")}function qe(r){return new TextEncoder().encode(r)}function Fe(r){return new TextDecoder().decode(r)}function Et(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var i=0;i<r.length;i++){var s=r.charAt(i),o=s.charCodeAt(0);if(t[o]!==255)throw new TypeError(s+" is ambiguous");t[o]=i}var c=r.length,a=r.charAt(0),f=Math.log(c)/Math.log(256),d=Math.log(256)/Math.log(c);function u(h){if(h instanceof Uint8Array||(ArrayBuffer.isView(h)?h=new Uint8Array(h.buffer,h.byteOffset,h.byteLength):Array.isArray(h)&&(h=Uint8Array.from(h))),!(h instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(h.length===0)return"";for(var b=0,z=0,v=0,C=h.length;v!==C&&h[v]===0;)v++,b++;for(var T=(C-v)*d+1>>>0,w=new Uint8Array(T);v!==C;){for(var S=h[v],N=0,E=T-1;(S!==0||N<z)&&E!==-1;E--,N++)S+=256*w[E]>>>0,w[E]=S%c>>>0,S=S/c>>>0;if(S!==0)throw new Error("Non-zero carry");z=N,v++}for(var L=T-z;L!==T&&w[L]===0;)L++;for(var Y=a.repeat(b);L<T;++L)Y+=r.charAt(w[L]);return Y}function x(h){if(typeof h!="string")throw new TypeError("Expected String");if(h.length===0)return new Uint8Array;var b=0;if(h[b]!==" "){for(var z=0,v=0;h[b]===a;)z++,b++;for(var C=(h.length-b)*f+1>>>0,T=new Uint8Array(C);h[b];){var w=t[h.charCodeAt(b)];if(w===255)return;for(var S=0,N=C-1;(w!==0||S<v)&&N!==-1;N--,S++)w+=c*T[N]>>>0,T[N]=w%256>>>0,w=w/256>>>0;if(w!==0)throw new Error("Non-zero carry");v=S,b++}if(h[b]!==" "){for(var E=C-v;E!==C&&T[E]===0;)E++;for(var L=new Uint8Array(z+(C-E)),Y=z;E!==C;)L[Y++]=T[E++];return L}}}function A(h){var b=x(h);if(b)return b;throw new Error(`Non-${e} character`)}return{encode:u,decodeUnsafe:x,decode:A}}var At=Et,Ct=At,Be=Ct;var ae=class{name;prefix;baseEncode;constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},ce=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,n){this.name=e,this.prefix=t;let i=t.codePointAt(0);if(i===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=i,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 Ve(this,e)}},ue=class{decoders;constructor(e){this.decoders=e}or(e){return Ve(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Ve(r,e){return new ue({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var he=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,n,i){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=i,this.encoder=new ae(e,t,n),this.decoder=new ce(e,t,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function $({name:r,prefix:e,encode:t,decode:n}){return new he(r,e,t,n)}function P({name:r,prefix:e,alphabet:t}){let{encode:n,decode:i}=Be(t,r);return $({prefix:e,name:r,encode:n,decode:s=>D(i(s))})}function Tt(r,e,t,n){let i=r.length;for(;r[i-1]==="=";)--i;let s=new Uint8Array(i*t/8|0),o=0,c=0,a=0;for(let f=0;f<i;++f){let d=e[r[f]];if(d===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<t|d,o+=t,o>=8&&(o-=8,s[a++]=255&c>>o)}if(o>=t||(255&c<<8-o)!==0)throw new SyntaxError("Unexpected end of data");return s}function St(r,e,t){let n=e[e.length-1]==="=",i=(1<<t)-1,s="",o=0,c=0;for(let a=0;a<r.length;++a)for(c=c<<8|r[a],o+=8;o>t;)o-=t,s+=e[i&c>>o];if(o!==0&&(s+=e[i&c<<t-o]),n)for(;(s.length*t&7)!==0;)s+="=";return s}function It(r){let e={};for(let t=0;t<r.length;++t)e[r[t]]=t;return e}function l({name:r,prefix:e,bitsPerChar:t,alphabet:n}){let i=It(n);return $({prefix:e,name:r,encode(s){return St(s,n,t)},decode(s){return Tt(s,i,t,r)}})}var Lt=P({prefix:"9",name:"base10",alphabet:"0123456789"});var le={};g(le,{base16:()=>Dt,base16upper:()=>Nt});var Dt=l({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Nt=l({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var de={};g(de,{base2:()=>Ut});var Ut=l({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var pe={};g(pe,{base256emoji:()=>_t});var Je=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}"),Pt=Je.reduce((r,e,t)=>(r[t]=e,r),[]),zt=Je.reduce((r,e,t)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return r[n]=t,r},[]);function $t(r){return r.reduce((e,t)=>(e+=Pt[t],e),"")}function Ot(r){let e=[];for(let t of r){let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);let i=zt[n];if(i==null)throw new Error(`Non-base256emoji character: ${t}`);e.push(i)}return new Uint8Array(e)}var _t=$({prefix:"\u{1F680}",name:"base256emoji",encode:$t,decode:Ot});var me={};g(me,{base32:()=>O,base32hex:()=>Ft,base32hexpad:()=>Bt,base32hexpadupper:()=>Vt,base32hexupper:()=>kt,base32pad:()=>Mt,base32padupper:()=>qt,base32upper:()=>Rt,base32z:()=>Jt});var O=l({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Rt=l({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Mt=l({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),qt=l({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Ft=l({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),kt=l({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Bt=l({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Vt=l({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Jt=l({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var be={};g(be,{base36:()=>V,base36upper:()=>Qt});var V=P({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Qt=P({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var xe={};g(xe,{base58btc:()=>I,base58flickr:()=>Ht});var I=P({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ht=P({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var ge={};g(ge,{base64:()=>Xt,base64pad:()=>Yt,base64url:()=>Gt,base64urlpad:()=>Zt});var Xt=l({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Yt=l({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Gt=l({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Zt=l({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var we={};g(we,{base8:()=>Kt});var Kt=l({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var ye={};g(ye,{identity:()=>Wt});var Wt=$({prefix:"\0",name:"identity",encode:r=>Fe(r),decode:r=>qe(r)});var dn=new TextEncoder,pn=new TextDecoder;var Ee={};g(Ee,{identity:()=>vr});var tr=Xe,Qe=128,rr=127,nr=~rr,ir=Math.pow(2,31);function Xe(r,e,t){e=e||[],t=t||0;for(var n=t;r>=ir;)e[t++]=r&255|Qe,r/=128;for(;r&nr;)e[t++]=r&255|Qe,r>>>=7;return e[t]=r|0,Xe.bytes=t-n+1,e}var sr=ve,or=128,He=127;function ve(r,n){var t=0,n=n||0,i=0,s=n,o,c=r.length;do{if(s>=c)throw ve.bytes=0,new RangeError("Could not decode varint");o=r[s++],t+=i<28?(o&He)<<i:(o&He)*Math.pow(2,i),i+=7}while(o>=or);return ve.bytes=s-n,t}var ar=Math.pow(2,7),cr=Math.pow(2,14),ur=Math.pow(2,21),hr=Math.pow(2,28),fr=Math.pow(2,35),lr=Math.pow(2,42),dr=Math.pow(2,49),pr=Math.pow(2,56),mr=Math.pow(2,63),br=function(r){return r<ar?1:r<cr?2:r<ur?3:r<hr?4:r<fr?5:r<lr?6:r<dr?7:r<pr?8:r<mr?9:10},xr={encode:tr,decode:sr,encodingLength:br},gr=xr,J=gr;function Q(r,e=0){return[J.decode(r,e),J.decode.bytes]}function _(r,e,t=0){return J.encode(r,e,t),e}function R(r){return J.encodingLength(r)}function q(r,e){let t=e.byteLength,n=R(r),i=n+R(t),s=new Uint8Array(i+t);return _(r,s,0),_(t,s,n),s.set(e,i),new M(r,t,e,s)}function Ye(r){let e=D(r),[t,n]=Q(e),[i,s]=Q(e.subarray(n)),o=e.subarray(n+s);if(o.byteLength!==i)throw new Error("Incorrect length");return new M(t,i,o,e)}function Ge(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&Me(r.bytes,t.bytes)}}var M=class{code;size;digest;bytes;constructor(e,t,n,i){this.code=e,this.size=t,this.digest=n,this.bytes=i}};var Ze=0,wr="identity",Ke=D;function yr(r,e){if(e?.truncate!=null&&e.truncate!==r.byteLength){if(e.truncate<0||e.truncate>r.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${r.byteLength}`);r=r.subarray(0,e.truncate)}return q(Ze,Ke(r))}var vr={code:Ze,name:wr,encode:Ke,digest:yr};var Te={};g(Te,{sha256:()=>Ar,sha512:()=>Cr});var Er=20;function Ce({name:r,code:e,encode:t,minDigestLength:n,maxDigestLength:i}){return new Ae(r,e,t,n,i)}var Ae=class{name;code;encode;minDigestLength;maxDigestLength;constructor(e,t,n,i,s){this.name=e,this.code=t,this.encode=n,this.minDigestLength=i??Er,this.maxDigestLength=s}digest(e,t){if(t?.truncate!=null){if(t.truncate<this.minDigestLength)throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);if(this.maxDigestLength!=null&&t.truncate>this.maxDigestLength)throw new Error(`Invalid truncate option, must be less than or equal to ${this.maxDigestLength}`)}if(e instanceof Uint8Array){let n=this.encode(e);return n instanceof Uint8Array?We(n,this.code,t?.truncate):n.then(i=>We(i,this.code,t?.truncate))}else throw Error("Unknown type, must be binary type")}};function We(r,e,t){if(t!=null&&t!==r.byteLength){if(t>r.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${r.byteLength}`);r=r.subarray(0,t)}return q(e,r)}function et(r){return async e=>new Uint8Array(await crypto.subtle.digest(r,e))}var Ar=Ce({name:"sha2-256",code:18,encode:et("SHA-256")}),Cr=Ce({name:"sha2-512",code:19,encode:et("SHA-512")});function tt(r,e){let{bytes:t,version:n}=r;switch(n){case 0:return Sr(t,Se(r),e??I.encoder);default:return Ir(t,Se(r),e??O.encoder)}}var rt=new WeakMap;function Se(r){let e=rt.get(r);if(e==null){let t=new Map;return rt.set(r,t),t}return e}var j=class r{code;version;multihash;bytes;"/";constructor(e,t,n,i){this.code=t,this.version=e,this.multihash=n,this.bytes=i,this["/"]=i}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:t}=this;if(e!==X)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==Lr)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(t)}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:t}=this.multihash,n=q(e,t);return r.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 r.equals(this,e)}static equals(e,t){let n=t;return n!=null&&e.code===n.code&&e.version===n.version&&Ge(e.multihash,n.multihash)}toString(e){return tt(this,e)}toJSON(){return{"/":tt(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let t=e;if(t instanceof r)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:i,multihash:s,bytes:o}=t;return new r(n,i,s,o??nt(n,i,s.bytes))}else if(t[Dr]===!0){let{version:n,multihash:i,code:s}=t,o=Ye(i);return r.create(n,s,o)}else return null}static create(e,t,n){if(typeof t!="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(t!==X)throw new Error(`Version 0 CID must use dag-pb (code: ${X}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let i=nt(e,t,n.bytes);return new r(e,t,n,i)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,X,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,n]=r.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),n=t.size-t.multihashSize,i=D(e.subarray(n,n+t.multihashSize));if(i.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=i.subarray(t.multihashSize-t.digestSize),o=new M(t.multihashCode,t.digestSize,s,i);return[t.version===0?r.createV0(o):r.createV1(t.codec,o),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[u,x]=Q(e.subarray(t));return t+=x,u},i=n(),s=X;if(i===18?(i=0,t=0):s=n(),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let o=t,c=n(),a=n(),f=t+a,d=f-o;return{version:i,codec:s,multihashCode:c,digestSize:a,multihashSize:d,size:f}}static parse(e,t){let[n,i]=Tr(e,t),s=r.decode(i);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Se(s).set(n,e),s}};function Tr(r,e){switch(r[0]){case"Q":{let t=e??I;return[I.prefix,t.decode(`${I.prefix}${r}`)]}case I.prefix:{let t=e??I;return[I.prefix,t.decode(r)]}case O.prefix:{let t=e??O;return[O.prefix,t.decode(r)]}case V.prefix:{let t=e??V;return[V.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}}function Sr(r,e,t){let{prefix:n}=t;if(n!==I.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let i=e.get(n);if(i==null){let s=t.encode(r).slice(1);return e.set(n,s),s}else return i}function Ir(r,e,t){let{prefix:n}=t,i=e.get(n);if(i==null){let s=t.encode(r);return e.set(n,s),s}else return i}var X=112,Lr=18;function nt(r,e,t){let n=R(r),i=n+R(e),s=new Uint8Array(i+t.byteLength);return _(r,s,0),_(e,s,n),s.set(t,i),s}var Dr=Symbol.for("@ipld/js-cid/CID");var Ie={...ye,...de,...we,...fe,...le,...me,...be,...xe,...ge,...pe},_n={...Te,...Ee};function it(r=0){return new Uint8Array(r)}function ot(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var st=ot("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Le=ot("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);let e=it(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),Nr={utf8:st,"utf-8":st,hex:Ie.base16,latin1:Le,ascii:Le,binary:Le,...Ie},at=Nr;function ct(r,e="utf8"){let t=at[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.encoder.encode(r).substring(1)}var De=60;function ee(r){return{Status:r.Status??0,TC:r.TC??r.flag_tc??!1,RD:r.RD??r.flag_rd??!1,RA:r.RA??r.flag_ra??!1,AD:r.AD??r.flag_ad??!1,CD:r.CD??r.flag_cd??!1,Question:(r.Question??r.questions??[]).map(e=>({name:e.name,type:y[e.type]})),Answer:(r.Answer??r.answers??[]).map(e=>({name:e.name,type:y[e.type],TTL:e.TTL??e.ttl??De,data:e.data instanceof Uint8Array?ct(e.data):e.data}))}}var Ur=4;function Ne(r,e={}){let t=new B({concurrency:e.queryConcurrency??Ur});return async(n,i={})=>{let s=new URLSearchParams;s.set("name",n),K(i.types).forEach(c=>{s.append("type",y[c])}),i.onProgress?.(new U("dns:query",n));let o=await t.add(async()=>{let c=await fetch(`${r}?${s}`,{headers:{accept:"application/dns-json"},signal:i?.signal});if(c.status!==200)throw new Error(`Unexpected HTTP status: ${c.status} - ${c.statusText}`);let a=ee(await c.json());return i.onProgress?.(new U("dns:response",a)),a},{signal:i.signal});if(o==null)throw new Error("No DNS response received");return o}}function ut(){return[Ne("https://cloudflare-dns.com/dns-query"),Ne("https://dns.google/resolve")]}var lt=$e(ft(),1);var Ue=class{lru;constructor(e){this.lru=(0,lt.default)(e)}get(e,t){let n=!0,i=[];for(let s of t){let o=this.getAnswers(e,s);if(o.length===0){n=!1;break}i.push(...o)}if(n)return ee({answers:i})}getAnswers(e,t){let n=`${e.toLowerCase()}-${t}`,i=this.lru.get(n);if(i!=null){let s=i.filter(o=>o.expires>Date.now()).map(({expires:o,value:c})=>({...c,TTL:Math.round((o-Date.now())/1e3),type:y[c.type]}));return s.length===0&&this.lru.remove(n),s}return[]}add(e,t){let n=`${e.toLowerCase()}-${t.type}`,i=this.lru.get(n)??[];i.push({expires:Date.now()+(t.TTL??De)*1e3,value:t}),this.lru.set(n,i)}remove(e,t){let n=`${e.toLowerCase()}-${t}`;this.lru.remove(n)}clear(){this.lru.clear()}};function dt(r){return new Ue(r)}var Pr=1e3,te=class{resolvers;cache;constructor(e){this.resolvers={},this.cache=dt(e.cacheSize??Pr),Object.entries(e.resolvers??{}).forEach(([t,n])=>{Array.isArray(n)||(n=[n]),t.endsWith(".")||(t=`${t}.`),this.resolvers[t]=n}),this.resolvers["."]==null&&(this.resolvers["."]=ut())}async query(e,t={}){let n=K(t.types),i=t.cached!==!1?this.cache.get(e,n):void 0;if(i!=null)return t.onProgress?.(new U("dns:cache",i)),i;let s=`${e.split(".").pop()}.`,o=(this.resolvers[s]??this.resolvers["."]).sort(()=>Math.random()>.5?-1:1),c=[];for(let a of o){if(t.signal?.aborted===!0)break;try{let f=await a(e,{...t,types:n});for(let d of f.Answer)this.cache.add(e,d);return f}catch(f){c.push(f),t.onProgress?.(new U("dns:error",f))}}throw c.length===1?c[0]:new AggregateError(c,`DNS lookup of ${e} ${n} failed`)}};var y;(function(r){r[r.A=1]="A",r[r.CNAME=5]="CNAME",r[r.TXT=16]="TXT",r[r.AAAA=28]="AAAA"})(y||(y={}));var zr=32;function $r(r={}){return new te(r)}return wt(Or);})(); | ||
| return MultiformatsDns})); | ||
| //# sourceMappingURL=index.min.js.map |
+3
-3
| { | ||
| "name": "@multiformats/dns", | ||
| "version": "1.0.9", | ||
| "version": "1.0.10", | ||
| "description": "Resolve DNS queries with browser fallback", | ||
@@ -164,3 +164,3 @@ "license": "Apache-2.0 OR MIT", | ||
| "hashlru": "^2.3.0", | ||
| "p-queue": "^8.0.1", | ||
| "p-queue": "^9.0.0", | ||
| "progress-events": "^1.0.0", | ||
@@ -173,3 +173,3 @@ "uint8arrays": "^5.0.2" | ||
| "aegir": "^47.0.21", | ||
| "sinon": "^18.0.0" | ||
| "sinon": "^21.0.0" | ||
| }, | ||
@@ -176,0 +176,0 @@ "browser": { |
Sorry, the diff of this file is too big to display
270260
5.07%1761
0.28%+ Added
+ Added
- Removed
- Removed
Updated