|
|
|
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.URlib=e():t.URlib=e()}(this,(()=>(()=>{var t={4019:t=>{function e(t,e,r){"use strict";this.alias=[],this.prob=[],this.outcomes=e||this.indexedOutcomes(t.length),this.rng=r||Math.random,this.precomputeAlias(t)}e.prototype.next=function(t){"use strict";var e=t||1,r=[],n=0;do{var i=Math.floor(this.rng()*this.prob.length);r[n]=this.outcomes[this.rng()<this.prob[i]?i:this.alias[i]]}while(++n<e);return e>1?r:r[0]},e.prototype.precomputeAlias=function(t){"use strict";var e,r,n,i=t.length,o=0,a=0,u=0,s=[],f=[],c=[];for(r=0;r<i;++r){if(t[r]<0)throw"Probability must be a positive: p["+r+"]="+t[r];o+=t[r]}if(0===o)throw"Probability cannot be zero.";for(r=0;r<i;++r)s[r]=t[r]*i/o;for(r=i-1;r>=0;--r)s[r]<1?f[a++]=r:c[u++]=r;for(;a&&u;)n=f[--a],e=c[--u],this.prob[n]=s[n],this.alias[n]=e,s[e]=s[e]+s[n]-1,s[e]<1?f[a++]=e:c[u++]=e;for(;u;)this.prob[c[--u]]=1;for(;a;)this.prob[f[--a]]=1},e.prototype.indexedOutcomes=function(t){"use strict";for(var e=[],r=0;r<t;r++)e[r]=r;return e},e.prototype.randomInt=function(t,e){"use strict";return Math.floor(this.rng()*(e-t))+t},t.exports=function(t,r,n){"use strict";return new e(t,r,n)}},9760:function(t,e,r){"use strict";var n=r(8764).Buffer,i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=i(r(9282)),a=r(3154);let u=[];var s;!function(t){t.STANDARD="standard",t.URI="uri",t.MINIMAL="minimal"}(s||(s={}));const f=t=>"ableacidalsoapexaquaarchatomauntawayaxisbackbaldbarnbeltbetabiasbluebodybragbrewbulbbuzzcalmcashcatschefcityclawcodecolacookcostcruxcurlcuspcyandarkdatadaysdelidicedietdoordowndrawdropdrumdulldutyeacheasyechoedgeepicevenexamexiteyesfactfairfernfigsfilmfishfizzflapflewfluxfoxyfreefrogfuelfundgalagamegeargemsgiftgirlglowgoodgraygrimgurugushgyrohalfhanghardhawkheathelphighhillholyhopehornhutsicedideaidleinchinkyintoirisironitemjadejazzjoinjoltjowljudojugsjumpjunkjurykeepkenokeptkeyskickkilnkingkitekiwiknoblamblavalazyleaflegsliarlimplionlistlogoloudloveluaulucklungmainmanymathmazememomenumeowmildmintmissmonknailnavyneednewsnextnoonnotenumbobeyoboeomitonyxopenovalowlspaidpartpeckplaypluspoempoolposepuffpumapurrquadquizraceramprealredorichroadrockroofrubyruinrunsrustsafesagascarsetssilkskewslotsoapsolosongstubsurfswantacotasktaxitenttiedtimetinytoiltombtoystriptunatwinuglyundouniturgeuservastveryvetovialvibeviewvisavoidvowswallwandwarmwaspwavewaxywebswhatwhenwhizwolfworkyankyawnyellyogayurtzapszerozestzinczonezoom".slice(4*t,4*t+4),c=t=>`${t}${a.getCRCHex(n.from(t,"hex"))}`,l=(t,e)=>{const r=c(t);return n.from(r,"hex").reduce(((t,e)=>[...t,f(e)]),[]).join(e)},h=(t,e,r)=>{const i=(4==r?t.split(e):a.partition(t,2)).map((t=>((t,e)=>{o.default(t.length===e,"Invalid Bytewords: word.length does not match wordLength provided");if(0===u.length){u=[...new Array(676)].map((()=>-1));for(let t=0;t<256;t++){const e=f(t);let r=e[0].charCodeAt(0)-"a".charCodeAt(0),n=e[3].charCodeAt(0)-"a".charCodeAt(0);u[26*n+r]=t}}let r=t[0].toLowerCase().charCodeAt(0)-"a".charCodeAt(0),i=t[4==e?3:1].toLowerCase().charCodeAt(0)-"a".charCodeAt(0);o.default(0<=r&&r<26&&0<=i&&i<26,"Invalid Bytewords: invalid word");let a=u[26*i+r];if(o.default(-1!==a,"Invalid Bytewords: value not in lookup table"),4==e){const e=f(a);let r=t[1].toLowerCase(),n=t[2].toLowerCase();o.default(r===e[1]&&n===e[2],"Invalid Bytewords: invalid middle letters of word")}return n.from([a]).toString("hex")})(t,r))).join("");o.default(i.length>=5,"Invalid Bytewords: invalid decoded string length");const[s,c]=a.split(n.from(i,"hex"),4),l=a.getCRCHex(s);return o.default(l===c.toString("hex"),"Invalid Checksum"),s.toString("hex")};e.default={decode:(t,e=s.MINIMAL)=>{switch(e){case s.STANDARD:return h(t," ",4);case s.URI:return h(t,"-",4);case s.MINIMAL:return h(t,"",2);default:throw new Error(`Invalid style ${e}`)}},encode:(t,e=s.MINIMAL)=>{switch(e){case s.STANDARD:return l(t," ");case s.URI:return l(t,"-");ca
|