@eluvio/elv-client-js 4.0.28 → 4.0.29

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.
@@ -48,7 +48,7 @@ e.read=function(t,e,n,r,a){var i,o,s=8*a-r-1,u=(1<<s)-1,c=u>>1,f=-7,A=n?a-1:0,l=
48
48
  * Licensed under
49
49
  * MIT License http://www.opensource.org/licenses/mit-license
50
50
  *
51
- */!function(o,s){"use strict";"object"===i(t)&&t.exports?t.exports=s():void 0===(a="function"==typeof(r=s)?r.call(e,n,e,t):r)||(t.exports=a)}(0,(function(t){"use strict";var e=t&&t.SecondLevelDomains,n={list:{ac:" com gov mil net org ",ae:" ac co gov mil name net org pro sch ",af:" com edu gov net org ",al:" com edu gov mil net org ",ao:" co ed gv it og pb ",ar:" com edu gob gov int mil net org tur ",at:" ac co gv or ",au:" asn com csiro edu gov id net org ",ba:" co com edu gov mil net org rs unbi unmo unsa untz unze ",bb:" biz co com edu gov info net org store tv ",bh:" biz cc com edu gov info net org ",bn:" com edu gov net org ",bo:" com edu gob gov int mil net org tv ",br:" adm adv agr am arq art ato b bio blog bmd cim cng cnt com coop ecn edu eng esp etc eti far flog fm fnd fot fst g12 ggf gov imb ind inf jor jus lel mat med mil mus net nom not ntr odo org ppg pro psc psi qsl rec slg srv tmp trd tur tv vet vlog wiki zlg ",bs:" com edu gov net org ",bz:" du et om ov rg ",ca:" ab bc mb nb nf nl ns nt nu on pe qc sk yk ",ck:" biz co edu gen gov info net org ",cn:" ac ah bj com cq edu fj gd gov gs gx gz ha hb he hi hl hn jl js jx ln mil net nm nx org qh sc sd sh sn sx tj tw xj xz yn zj ",co:" com edu gov mil net nom org ",cr:" ac c co ed fi go or sa ",cy:" ac biz com ekloges gov ltd name net org parliament press pro tm ",do:" art com edu gob gov mil net org sld web ",dz:" art asso com edu gov net org pol ",ec:" com edu fin gov info med mil net org pro ",eg:" com edu eun gov mil name net org sci ",er:" com edu gov ind mil net org rochest w ",es:" com edu gob nom org ",et:" biz com edu gov info name net org ",fj:" ac biz com info mil name net org pro ",fk:" ac co gov net nom org ",fr:" asso com f gouv nom prd presse tm ",gg:" co net org ",gh:" com edu gov mil org ",gn:" ac com gov net org ",gr:" com edu gov mil net org ",gt:" com edu gob ind mil net org ",gu:" com edu gov net org ",hk:" com edu gov idv net org ",hu:" 2000 agrar bolt casino city co erotica erotika film forum games hotel info ingatlan jogasz konyvelo lakas media news org priv reklam sex shop sport suli szex tm tozsde utazas video ",id:" ac co go mil net or sch web ",il:" ac co gov idf k12 muni net org ",in:" ac co edu ernet firm gen gov i ind mil net nic org res ",iq:" com edu gov i mil net org ",ir:" ac co dnssec gov i id net org sch ",it:" edu gov ",je:" co net org ",jo:" com edu gov mil name net org sch ",jp:" ac ad co ed go gr lg ne or ",ke:" ac co go info me mobi ne or sc ",kh:" com edu gov mil net org per ",ki:" biz com de edu gov info mob net org tel ",km:" asso com coop edu gouv k medecin mil nom notaires pharmaciens presse tm veterinaire ",kn:" edu gov net org ",kr:" ac busan chungbuk chungnam co daegu daejeon es gangwon go gwangju gyeongbuk gyeonggi gyeongnam hs incheon jeju jeonbuk jeonnam k kg mil ms ne or pe re sc seoul ulsan ",kw:" com edu gov net org ",ky:" com edu gov net org ",kz:" com edu gov mil net org ",lb:" com edu gov net org ",lk:" assn com edu gov grp hotel int ltd net ngo org sch soc web ",lr:" com edu gov net org ",lv:" asn com conf edu gov id mil net org ",ly:" com edu gov id med net org plc sch ",ma:" ac co gov m net org press ",mc:" asso tm ",me:" ac co edu gov its net org priv ",mg:" com edu gov mil nom org prd tm ",mk:" com edu gov inf name net org pro ",ml:" com edu gov net org presse ",mn:" edu gov org ",mo:" com edu gov net org ",mt:" com edu gov net org ",mv:" aero biz com coop edu gov info int mil museum name net org pro ",mw:" ac co com coop edu gov int museum net org ",mx:" com edu gob net org ",my:" com edu gov mil name net org sch ",nf:" arts com firm info net other per rec store web ",ng:" biz com edu gov mil mobi name net org sch ",ni:" ac co com edu gob mil net nom org ",np:" com edu gov mil net org ",nr:" biz com edu gov info net org ",om:" ac biz co com edu gov med mil museum net org pro sch ",pe:" com edu gob mil net nom org sld ",ph:" com edu gov i mil net ngo org ",pk:" biz com edu fam gob gok gon gop gos gov net org web ",pl:" art bialystok biz com edu gda gdansk gorzow gov info katowice krakow lodz lublin mil net ngo olsztyn org poznan pwr radom slupsk szczecin torun warszawa waw wroc wroclaw zgora ",pr:" ac biz com edu est gov info isla name net org pro prof ",ps:" com edu gov net org plo sec ",pw:" belau co ed go ne or ",ro:" arts com firm info nom nt org rec store tm www ",rs:" ac co edu gov in org ",sb:" com edu gov net org ",sc:" com edu gov net org ",sh:" co com edu gov net nom org ",sl:" com edu gov net org ",st:" co com consulado edu embaixada gov mil net org principe saotome store ",sv:" com edu gob org red ",sz:" ac co org ",tr:" av bbs bel biz com dr edu gen gov info k12 name net org pol tel tsk tv web ",tt:" aero biz cat co com coop edu gov info int jobs mil mobi museum name net org pro tel travel ",tw:" club com ebiz edu game gov idv mil net org ",mu:" ac co com gov net or org ",mz:" ac co edu gov org ",na:" co com ",nz:" ac co cri geek gen govt health iwi maori mil net org parliament school ",pa:" abo ac com edu gob ing med net nom org sld ",pt:" com edu gov int net nome org publ ",py:" com edu gov mil net org ",qa:" com edu gov mil net org ",re:" asso com nom ",ru:" ac adygeya altai amur arkhangelsk astrakhan bashkiria belgorod bir bryansk buryatia cbg chel chelyabinsk chita chukotka chuvashia com dagestan e-burg edu gov grozny int irkutsk ivanovo izhevsk jar joshkar-ola kalmykia kaluga kamchatka karelia kazan kchr kemerovo khabarovsk khakassia khv kirov koenig komi kostroma kranoyarsk kuban kurgan kursk lipetsk magadan mari mari-el marine mil mordovia mosreg msk murmansk nalchik net nnov nov novosibirsk nsk omsk orenburg org oryol penza perm pp pskov ptz rnd ryazan sakhalin samara saratov simbirsk smolensk spb stavropol stv surgut tambov tatarstan tom tomsk tsaritsyn tsk tula tuva tver tyumen udm udmurtia ulan-ude vladikavkaz vladimir vladivostok volgograd vologda voronezh vrn vyatka yakutia yamal yekaterinburg yuzhno-sakhalinsk ",rw:" ac co com edu gouv gov int mil net ",sa:" com edu gov med net org pub sch ",sd:" com edu gov info med net org tv ",se:" a ac b bd c d e f g h i k l m n o org p parti pp press r s t tm u w x y z ",sg:" com edu gov idn net org per ",sn:" art com edu gouv org perso univ ",sy:" com edu gov mil net news org ",th:" ac co go in mi net or ",tj:" ac biz co com edu go gov info int mil name net nic org test web ",tn:" agrinet com defense edunet ens fin gov ind info intl mincom nat net org perso rnrt rns rnu tourism ",tz:" ac co go ne or ",ua:" biz cherkassy chernigov chernovtsy ck cn co com crimea cv dn dnepropetrovsk donetsk dp edu gov if in ivano-frankivsk kh kharkov kherson khmelnitskiy kiev kirovograd km kr ks kv lg lugansk lutsk lviv me mk net nikolaev od odessa org pl poltava pp rovno rv sebastopol sumy te ternopil uzhgorod vinnica vn zaporizhzhe zhitomir zp zt ",ug:" ac co go ne or org sc ",uk:" ac bl british-library co cym gov govt icnet jet lea ltd me mil mod national-library-scotland nel net nhs nic nls org orgn parliament plc police sch scot soc ",us:" dni fed isa kids nsn ",uy:" com edu gub mil net org ",ve:" co com edu gob info mil net org web ",vi:" co com k12 net org ",vn:" ac biz com edu gov health info int name net org pro ",ye:" co com gov ltd me net org plc ",yu:" ac co edu gov org ",za:" ac agric alt bourse city co cybernet db edu gov grondar iaccess imt inca landesign law mil net ngo nis nom olivetti org pix school tm web ",zm:" ac co com edu gov net org sch ",com:"ar br cn de eu gb gr hu jpn kr no qc ru sa se uk us uy za ",net:"gb jp se uk ",org:"ae",de:"com "},has:function(t){var e=t.lastIndexOf(".");if(e<=0||e>=t.length-1)return!1;var r=t.lastIndexOf(".",e-1);if(r<=0||r>=e-1)return!1;var a=n.list[t.slice(e+1)];return!!a&&a.indexOf(" "+t.slice(r+1,e)+" ")>=0},is:function(t){var e=t.lastIndexOf(".");if(e<=0||e>=t.length-1)return!1;if(t.lastIndexOf(".",e-1)>=0)return!1;var r=n.list[t.slice(e+1)];return!!r&&r.indexOf(" "+t.slice(0,e)+" ")>=0},get:function(t){var e=t.lastIndexOf(".");if(e<=0||e>=t.length-1)return null;var r=t.lastIndexOf(".",e-1);if(r<=0||r>=e-1)return null;var a=n.list[t.slice(e+1)];return a?a.indexOf(" "+t.slice(r+1,e)+" ")<0?null:t.slice(r+1):null},noConflict:function(){return t.SecondLevelDomains===this&&(t.SecondLevelDomains=e),this}};return n}))}).call(this,n(20)(t))},function(t,e,n){"use strict";var r=n(23).rotr32;function a(t,e,n){return t&e^~t&n}function i(t,e,n){return t&e^t&n^e&n}function o(t,e,n){return t^e^n}e.ft_1=function(t,e,n,r){return 0===t?a(e,n,r):1===t||3===t?o(e,n,r):2===t?i(e,n,r):void 0},e.ch32=a,e.maj32=i,e.p32=o,e.s0_256=function(t){return r(t,2)^r(t,13)^r(t,22)},e.s1_256=function(t){return r(t,6)^r(t,11)^r(t,25)},e.g0_256=function(t){return r(t,7)^r(t,18)^t>>>3},e.g1_256=function(t){return r(t,17)^r(t,19)^t>>>10}},function(t,e,n){"use strict";var r=n(23),a=n(40),i=n(100),o=n(17),s=r.sum32,u=r.sum32_4,c=r.sum32_5,f=i.ch32,A=i.maj32,l=i.s0_256,p=i.s1_256,d=i.g0_256,h=i.g1_256,y=a.BlockHash,g=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function b(){if(!(this instanceof b))return new b;y.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=g,this.W=new Array(64)}r.inherits(b,y),t.exports=b,b.blockSize=512,b.outSize=256,b.hmacStrength=192,b.padLength=64,b.prototype._update=function(t,e){for(var n=this.W,r=0;r<16;r++)n[r]=t[e+r];for(;r<n.length;r++)n[r]=u(h(n[r-2]),n[r-7],d(n[r-15]),n[r-16]);var a=this.h[0],i=this.h[1],y=this.h[2],g=this.h[3],b=this.h[4],m=this.h[5],v=this.h[6],I=this.h[7];for(o(this.k.length===n.length),r=0;r<n.length;r++){var w=c(I,p(b),f(b,m,v),this.k[r],n[r]),C=s(l(a),A(a,i,y));I=v,v=m,m=b,b=s(g,w),g=y,y=i,i=a,a=s(w,C)}this.h[0]=s(this.h[0],a),this.h[1]=s(this.h[1],i),this.h[2]=s(this.h[2],y),this.h[3]=s(this.h[3],g),this.h[4]=s(this.h[4],b),this.h[5]=s(this.h[5],m),this.h[6]=s(this.h[6],v),this.h[7]=s(this.h[7],I)},b.prototype._digest=function(t){return"hex"===t?r.toHex32(this.h,"big"):r.split32(this.h,"big")}},function(t,e,n){"use strict";var r=n(23),a=n(40),i=n(17),o=r.rotr64_hi,s=r.rotr64_lo,u=r.shr64_hi,c=r.shr64_lo,f=r.sum64,A=r.sum64_hi,l=r.sum64_lo,p=r.sum64_4_hi,d=r.sum64_4_lo,h=r.sum64_5_hi,y=r.sum64_5_lo,g=a.BlockHash,b=[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 m(){if(!(this instanceof m))return new m;g.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=b,this.W=new Array(160)}function v(t,e,n,r,a){var i=t&n^~t&a;return i<0&&(i+=4294967296),i}function I(t,e,n,r,a,i){var o=e&r^~e&i;return o<0&&(o+=4294967296),o}function w(t,e,n,r,a){var i=t&n^t&a^n&a;return i<0&&(i+=4294967296),i}function C(t,e,n,r,a,i){var o=e&r^e&i^r&i;return o<0&&(o+=4294967296),o}function E(t,e){var n=o(t,e,28)^o(e,t,2)^o(e,t,7);return n<0&&(n+=4294967296),n}function B(t,e){var n=s(t,e,28)^s(e,t,2)^s(e,t,7);return n<0&&(n+=4294967296),n}function k(t,e){var n=o(t,e,14)^o(t,e,18)^o(e,t,9);return n<0&&(n+=4294967296),n}function Q(t,e){var n=s(t,e,14)^s(t,e,18)^s(e,t,9);return n<0&&(n+=4294967296),n}function x(t,e){var n=o(t,e,1)^o(t,e,8)^u(t,e,7);return n<0&&(n+=4294967296),n}function S(t,e){var n=s(t,e,1)^s(t,e,8)^c(t,e,7);return n<0&&(n+=4294967296),n}function _(t,e){var n=o(t,e,19)^o(e,t,29)^u(t,e,6);return n<0&&(n+=4294967296),n}function M(t,e){var n=s(t,e,19)^s(e,t,29)^c(t,e,6);return n<0&&(n+=4294967296),n}r.inherits(m,g),t.exports=m,m.blockSize=1024,m.outSize=512,m.hmacStrength=192,m.padLength=128,m.prototype._prepareBlock=function(t,e){for(var n=this.W,r=0;r<32;r++)n[r]=t[e+r];for(;r<n.length;r+=2){var a=_(n[r-4],n[r-3]),i=M(n[r-4],n[r-3]),o=n[r-14],s=n[r-13],u=x(n[r-30],n[r-29]),c=S(n[r-30],n[r-29]),f=n[r-32],A=n[r-31];n[r]=p(a,i,o,s,u,c,f,A),n[r+1]=d(a,i,o,s,u,c,f,A)}},m.prototype._update=function(t,e){this._prepareBlock(t,e);var n=this.W,r=this.h[0],a=this.h[1],o=this.h[2],s=this.h[3],u=this.h[4],c=this.h[5],p=this.h[6],d=this.h[7],g=this.h[8],b=this.h[9],m=this.h[10],x=this.h[11],S=this.h[12],_=this.h[13],M=this.h[14],D=this.h[15];i(this.k.length===n.length);for(var R=0;R<n.length;R+=2){var O=M,j=D,T=k(g,b),N=Q(g,b),P=v(g,b,m,x,S),L=I(g,b,m,x,S,_),F=this.k[R],U=this.k[R+1],H=n[R],G=n[R+1],q=h(O,j,T,N,P,L,F,U,H,G),Y=y(O,j,T,N,P,L,F,U,H,G);O=E(r,a),j=B(r,a),T=w(r,a,o,s,u),N=C(r,a,o,s,u,c);var K=A(O,j,T,N),z=l(O,j,T,N);M=S,D=_,S=m,_=x,m=g,x=b,g=A(p,d,q,Y),b=l(d,d,q,Y),p=u,d=c,u=o,c=s,o=r,s=a,r=A(q,Y,K,z),a=l(q,Y,K,z)}f(this.h,0,r,a),f(this.h,2,o,s),f(this.h,4,u,c),f(this.h,6,p,d),f(this.h,8,g,b),f(this.h,10,m,x),f(this.h,12,S,_),f(this.h,14,M,D)},m.prototype._digest=function(t){return"hex"===t?r.toHex32(this.h,"big"):r.split32(this.h,"big")}},function(t,e,n){(function(t){var r=void 0!==t&&t||"undefined"!=typeof self&&self||window,a=Function.prototype.apply;function i(t,e){this._id=t,this._clearFn=e}e.setTimeout=function(){return new i(a.call(setTimeout,r,arguments),clearTimeout)},e.setInterval=function(){return new i(a.call(setInterval,r,arguments),clearInterval)},e.clearTimeout=e.clearInterval=function(t){t&&t.close()},i.prototype.unref=i.prototype.ref=function(){},i.prototype.close=function(){this._clearFn.call(r,this._id)},e.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},e.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},e._unrefActive=e.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=setTimeout((function(){t._onTimeout&&t._onTimeout()}),e))},n(199),e.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==t&&t.setImmediate||this&&this.setImmediate,e.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==t&&t.clearImmediate||this&&this.clearImmediate}).call(this,n(10))},function(t,e,n){var r=n(201);t.exports=r("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},function(t,e){t.exports={abi:[{constant:!0,inputs:[],name:"creator",outputs:[{name:"",type:"address"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"CAN_SEE",outputs:[{name:"",type:"uint8"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"customValues",type:"bytes32[]"},{name:"stakeholders",type:"address[]"}],name:"accessRequestV3",outputs:[{name:"",type:"bool"}],payable:!0,stateMutability:"payable",type:"function"},{constant:!0,inputs:[],name:"visibility",outputs:[{name:"",type:"uint8"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[],name:"kill",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"version",outputs:[{name:"",type:"bytes32"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"versionAPI",outputs:[{name:"",type:"bytes32"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"indexCategory",outputs:[{name:"",type:"uint8"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"newCreator",type:"address"}],name:"transferCreatorship",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"owner",outputs:[{name:"",type:"address"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"candidate",type:"address"}],name:"hasAccess",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"CAN_ACCESS",outputs:[{name:"",type:"uint8"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_visibility_code",type:"uint8"}],name:"setVisibility",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"contentSpace",outputs:[{name:"",type:"address"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"CAN_EDIT",outputs:[{name:"",type:"uint8"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{payable:!0,stateMutability:"payable",type:"fallback"},{anonymous:!1,inputs:[{indexed:!1,name:"requestNonce",type:"uint256"},{indexed:!1,name:"parentAddress",type:"address"},{indexed:!1,name:"contextHash",type:"bytes32"},{indexed:!1,name:"accessor",type:"address"},{indexed:!1,name:"requestTimestamp",type:"uint256"}],name:"AccessRequestV3",type:"event"},{anonymous:!1,inputs:[{indexed:!1,name:"contentSpace",type:"address"},{indexed:!1,name:"parentAddress",type:"address"},{indexed:!1,name:"visibility",type:"uint8"}],name:"VisibilityChanged",type:"event"}]}},function(t,e,n){var r=n(30),a=n(15),i=n(11),o=n(6),s=n(7);function u(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function c(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?u(Object(n),!0).forEach((function(e){i(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):u(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}var f=n(16),A=n(229),l=n(31),p=n(25),d=p.ValidateLibrary,h=p.ValidateObject,y=p.ValidateVersion,g=p.ValidatePartHash,b=p.ValidateWriteToken,m=p.ValidateParameters,v=n(107);e.permissionLevels={owner:{short:"Owner Only",description:"Only the owner has access to the object and ability to change permissions",settings:{visibility:0,statusCode:-1,kmsConk:!1}},editable:{short:"Editable",description:"Members of the editors group have full access to the object and the ability to change permissions",settings:{visibility:0,statusCode:-1,kmsConk:!0}},viewable:{short:"Viewable",description:"In addition to editors, members of the 'accessor' group can have read-only access to the object including playing video and retrieving metadata, images and documents",settings:{visibility:0,statusCode:0,kmsConk:!0}},listable:{short:"Publicly Listable",description:"Anyone can list the public portion of this object but only accounts with specific rights can access",settings:{visibility:1,statusCode:0,kmsConk:!0}},public:{short:"Public",description:"Anyone can access this object",settings:{visibility:10,statusCode:0,kmsConk:!0}}},e.Visibility=function(){var t=s(o.mark((function t(e){var n,r,a,i=this;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.id,r=e.clearCache,t.prev=1,a=this.utils.HashToAddress(n),r&&delete this.visibilityInfo[a],this.visibilityInfo[a]||(this.visibilityInfo[a]=new Promise(function(){var t=s(o.mark((function t(e,r){return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,i.authClient.ContractHasMethod({contractAddress:a,methodName:"visibility"});case 3:if(t.sent){t.next=7;break}return e(0),t.abrupt("return");case 7:return t.t0=e,t.next=10,i.CallContractMethod({contractAddress:i.utils.HashToAddress(n),methodName:"visibility"});case 10:t.t1=t.sent,(0,t.t0)(t.t1),t.next=17;break;case 14:t.prev=14,t.t2=t.catch(0),r(t.t2);case 17:case"end":return t.stop()}}),t,null,[[0,14]])})));return function(e,n){return t.apply(this,arguments)}}())),t.prev=5,t.next=8,this.visibilityInfo[a];case 8:return t.abrupt("return",t.sent);case 11:throw t.prev=11,t.t0=t.catch(5),delete this.visibilityInfo[a],t.t0;case 15:t.next=22;break;case 17:if(t.prev=17,t.t1=t.catch(1),"CALL_EXCEPTION"!==t.t1.code){t.next=21;break}return t.abrupt("return",0);case 21:throw t.t1;case 22:case"end":return t.stop()}}),t,this,[[1,17],[5,11]])})));return function(e){return t.apply(this,arguments)}}(),e.Permission=function(){var t=s(o.mark((function t(e){var n,r,a,i,s,u,c,f,A=this;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.objectId,r=e.clearCache,h(n),t.next=4,this.AccessType({id:n});case 4:if(t.t0=t.sent,t.t1=this.authClient.ACCESS_TYPES.OBJECT,t.t0===t.t1){t.next=8;break}throw Error("Permission only valid for normal content objects: "+n);case 8:return t.next=10,this.Visibility({id:n,clearCache:r});case 10:return a=t.sent,t.next=13,this.CallContractMethod({contractAddress:this.utils.HashToAddress(n),methodName:"addressKMS"});case 13:if(i=t.sent,s=i&&"ikms".concat(this.utils.AddressToHash(i)),u=!1,!s){t.next=27;break}return t.t2=this,t.next=20,this.ContentObjectLibraryId({objectId:n});case 20:return t.t3=t.sent,t.t4=n,t.t5="eluv.caps.".concat(s),t.t6={libraryId:t.t3,objectId:t.t4,metadataSubtree:t.t5},t.next=26,t.t2.ContentObjectMetadata.call(t.t2,t.t6);case 26:u=!!t.sent;case 27:return t.next=29,this.CallContractMethod({contractAddress:this.utils.HashToAddress(n),methodName:"statusCode"});case 29:return c=t.sent,c=parseInt(c._hex,16),(f=Object.keys(this.permissionLevels).filter((function(t){var e=A.permissionLevels[t].settings;return a>=e.visibility&&c>=e.statusCode&&u===e.kmsConk})))||(f=u?["editable"]:["owner"]),t.abrupt("return",f.slice(-1)[0]);case 34:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.DefaultKMSAddress=s(o.mark((function t(){var e,n,r,a=arguments;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e=a.length>0&&void 0!==a[0]?a[0]:{},n=e.tenantId,t.t0=n,!t.t0){t.next=8;break}return t.next=5,this.AccessType({id:n});case 5:t.t1=t.sent,t.t2=this.authClient.ACCESS_TYPES.TENANT,t.t0=t.t1===t.t2;case 8:if(!t.t0){t.next=14;break}return t.next=11,this.CallContractMethod({contractAddress:this.utils.HashToAddress(n),methodName:"addressKMS"});case 11:if(!(r=t.sent)){t.next=14;break}return t.abrupt("return",r);case 14:return t.next=16,this.CallContractMethod({contractAddress:this.contentSpaceAddress,methodName:"addressKMS"});case 16:return t.abrupt("return",t.sent);case 17:case"end":return t.stop()}}),t,this)}))),e.ContentSpaceId=function(){return this.contentSpaceId},e.ContentTypeOwner=function(){var t=s(o.mark((function t(e){var n,r,a,i;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.name,r=e.typeId,a=e.versionHash,t.next=3,this.ContentType({name:n,typeId:r,versionHash:a});case 3:return i=t.sent,t.t0=this.utils,t.next=7,this.ethClient.CallContractMethod({contractAddress:this.utils.HashToAddress(i.id),methodName:"owner",methodArgs:[]});case 7:return t.t1=t.sent,t.abrupt("return",t.t0.FormatAddress.call(t.t0,t.t1));case 9:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.ContentType=function(){var t=s(o.mark((function t(e){var n,r,a,i,s,u,c;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.name,r=e.typeId,a=e.versionHash,i=e.publicOnly,s=void 0!==i&&i,this.Log("Retrieving content type: ".concat(n||r||a)),a&&(r=this.utils.DecodeVersionHash(a).objectId),!n){t.next=13;break}return this.Log("Looking up type by name in content space metadata..."),t.prev=5,t.next=8,this.ContentObjectMetadata({libraryId:this.contentSpaceLibraryId,objectId:this.contentSpaceObjectId,metadataSubtree:f("public","contentTypes",n)});case 8:r=t.sent,t.next=13;break;case 11:t.prev=11,t.t0=t.catch(5);case 13:if(r){t.next=23;break}return this.Log("Looking up type by name in available types..."),t.next=17,this.ContentTypes();case 17:if(u=t.sent,!n){t.next=22;break}return t.abrupt("return",Object.values(u).find((function(t){return(t.name||"").toLowerCase()===n.toLowerCase()})));case 22:return t.abrupt("return",Object.values(u).find((function(t){return t.hash===a})));case 23:if(a){t.next=27;break}return t.next=26,this.LatestVersionHash({objectId:r});case 26:a=t.sent;case 27:if(t.prev=27,this.Log("Looking up type by ID..."),!s){t.next=39;break}return t.next=32,this.ContentObjectMetadata({libraryId:this.contentSpaceLibraryId,objectId:r,versionHash:a,metadataSubtree:"public"});case 32:if(t.t1=t.sent,t.t1){t.next=35;break}t.t1={};case 35:t.t2=t.t1,c={public:t.t2},t.next=45;break;case 39:return t.next=41,this.ContentObjectMetadata({libraryId:this.contentSpaceLibraryId,objectId:r,versionHash:a});case 41:if(t.t3=t.sent,t.t3){t.next=44;break}t.t3={};case 44:c=t.t3;case 45:return t.abrupt("return",{id:r,hash:a,name:c.public&&c.public.name||c.name||r,meta:c});case 48:throw t.prev=48,t.t4=t.catch(27),this.Log("Error looking up content type:"),this.Log(t.t4),new Error("Content Type ".concat(n||r," is invalid"));case 53:case"end":return t.stop()}}),t,this,[[5,11],[27,48]])})));return function(e){return t.apply(this,arguments)}}(),e.ContentTypes=s(o.mark((function t(){var e,n,r,a=this;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.contentTypes=this.contentTypes||{},this.Log("Looking up all available content types"),t.next=4,this.Collection({collectionType:"contentTypes"});case 4:return e=t.sent,this.Log("Personally available types:"),this.Log(e),n={},t.prev=8,t.next=11,this.ContentObjectMetadata({libraryId:this.contentSpaceLibraryId,objectId:this.contentSpaceObjectId,metadataSubtree:"public/contentTypes"});case 11:if(t.t0=t.sent,t.t0){t.next=14;break}t.t0={};case 14:n=t.t0,t.next=19;break;case 17:t.prev=17,t.t1=t.catch(8);case 19:return r=Object.values(n).map((function(t){return a.utils.HashToAddress(t)})),this.Log("Content space types:"),this.Log(r),e=e.concat(r).filter((function(t){return t})).map((function(t){return a.utils.FormatAddress(t)})).filter((function(t,e,n){return n.indexOf(t)===e})),t.next=25,Promise.all(e.map(function(){var t=s(o.mark((function t(e){var n;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=a.utils.AddressToObjectId(e),a.contentTypes[n]){t.next=11;break}return t.prev=2,t.next=5,a.ContentType({typeId:n,publicOnly:!0});case 5:a.contentTypes[n]=t.sent,t.next=11;break;case 8:t.prev=8,t.t0=t.catch(2),console.error(t.t0);case 11:case"end":return t.stop()}}),t,null,[[2,8]])})));return function(e){return t.apply(this,arguments)}}()));case 25:return t.abrupt("return",this.contentTypes);case 26:case"end":return t.stop()}}),t,this,[[8,17]])}))),e.ContentLibraries=s(o.mark((function t(){var e,n=this;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.Collection({collectionType:"libraries"});case 2:return e=t.sent,t.abrupt("return",e.map((function(t){return n.utils.AddressToLibraryId(t)})));case 4:case"end":return t.stop()}}),t,this)}))),e.ContentLibrary=function(){var t=s(o.mark((function t(e){var n,r,a;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,d(n),r=f("qlibs",n),t.t0=this.utils,t.t1=this.HttpClient,t.next=7,this.authClient.AuthorizationHeader({libraryId:n});case 7:return t.t2=t.sent,t.t3=r,t.t4={headers:t.t2,method:"GET",path:t.t3},t.t5=t.t1.Request.call(t.t1,t.t4),t.next=13,t.t0.ResponseToJson.call(t.t0,t.t5);case 13:return a=t.sent,t.abrupt("return",c(c({},a),{},{meta:a.meta||{}}));case 15:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.ContentLibraryOwner=function(){var t=s(o.mark((function t(e){var n;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,d(n),t.t0=this.utils,t.next=5,this.ethClient.CallContractMethod({contractAddress:this.utils.HashToAddress(n),methodName:"owner",methodArgs:[]});case 5:return t.t1=t.sent,t.abrupt("return",t.t0.FormatAddress.call(t.t0,t.t1));case 7:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.LibraryContentTypes=function(){var t=s(o.mark((function t(e){var n,r,a,i=this;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,d(n),this.Log("Retrieving library content types for ".concat(n)),t.next=5,this.ethClient.CallContractMethod({contractAddress:this.utils.HashToAddress(n),methodName:"contentTypesLength",methodArgs:[]});case 5:if(r=t.sent.toNumber(),this.Log("".concat(r," types")),0!==r){t.next=9;break}return t.abrupt("return",{});case 9:return a={},t.next=12,Promise.all(Array.from(new Array(r),function(){var t=s(o.mark((function t(e,r){var s,u;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,i.ethClient.CallContractMethod({contractAddress:i.utils.HashToAddress(n),methodName:"contentTypes",methodArgs:[r]});case 2:return s=t.sent,u=i.utils.AddressToObjectId(s),t.next=6,i.ContentType({typeId:u});case 6:a[u]=t.sent;case 7:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}()));case 12:return this.Log(a),t.abrupt("return",a);case 14:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.ContentObjects=function(){var t=s(o.mark((function t(e){var n,r,a,i,s,u,c;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.filterOptions,a=void 0===r?{}:r,d(n),this.Log("Retrieving content objects from ".concat(n)),i=f("qlibs",n,"q"),s={filter:[]},a.cacheId&&(s.cache_id=a.cacheId),a.start&&(s.start=a.start),a.limit&&(s.limit=a.limit),a.select&&(s.select=a.select),a.sort&&(s.sort_by=a.sort,a.sortDesc&&(s.sort_descending=!0)),u={eq:":eq:",neq:":ne:",lt:":lt:",lte:":le:",gt:":gt:",gte:":ge:",cnt:":co:",ncnt:":nc:"},c=function(t){var e=t.key,n=t.type,r=t.filter;s.filter.push("".concat(e).concat(u[n]).concat(r))},a.filter&&(Array.isArray(a.filter)?a.filter.forEach((function(t){return c(t)})):c(a.filter)),this.Log("Filter options:"),this.Log(a),t.t0=this.utils,t.t1=this.HttpClient,t.next=19,this.authClient.AuthorizationHeader({libraryId:n});case 19:return t.t2=t.sent,t.t3=i,t.t4=s,t.t5={headers:t.t2,method:"GET",path:t.t3,queryParams:t.t4},t.t6=t.t1.Request.call(t.t1,t.t5),t.next=26,t.t0.ResponseToJson.call(t.t0,t.t6);case 26:return t.abrupt("return",t.sent);case 27:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.ContentObject=function(){var t=s(o.mark((function t(e){var n,r,a,i,s;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,a=e.versionHash,i=e.writeToken,m({libraryId:n,objectId:r,versionHash:a}),this.Log("Retrieving content object: ".concat(n||""," ").concat(i||a||r)),a&&(r=this.utils.DecodeVersionHash(a).objectId),s=f("q",i||a||r),t.t0=this.utils,t.t1=this.HttpClient,t.next=9,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,versionHash:a});case 9:return t.t2=t.sent,t.t3=s,t.t4={headers:t.t2,method:"GET",path:t.t3},t.t5=t.t1.Request.call(t.t1,t.t4),t.next=15,t.t0.ResponseToJson.call(t.t0,t.t5);case 15:return t.abrupt("return",t.sent);case 16:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.ContentObjectOwner=function(){var t=s(o.mark((function t(e){var n;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.objectId,h(n),this.Log("Retrieving content object owner: ".concat(n)),t.t0=this.utils,t.next=6,this.ethClient.CallContractMethod({contractAddress:this.utils.HashToAddress(n),methodName:"owner",methodArgs:[]});case 6:return t.t1=t.sent,t.abrupt("return",t.t0.FormatAddress.call(t.t0,t.t1));case 8:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.ContentObjectTenantId=function(){var t=s(o.mark((function t(e){var n,r;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.objectId,(r=e.versionHash)?y(r):h(n),r&&(n=this.utils.DecodeVersionHash(r).objectId),this.objectTenantIds[n]){t.next=7;break}return t.next=6,this.authClient.MakeElvMasterCall({methodName:"elv_getTenantById",params:[this.contentSpaceId,n]});case 6:this.objectTenantIds[n]=t.sent;case 7:return t.abrupt("return",this.objectTenantIds[n]);case 8:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.ContentObjectLibraryId=function(){var t=s(o.mark((function t(e){var n,r,a=this;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.objectId,(r=e.versionHash)?y(r):h(n),r&&(n=this.utils.DecodeVersionHash(r).objectId),t.next=5,this.authClient.AccessType(n);case 5:t.t0=t.sent,t.next=t.t0===this.authClient.ACCESS_TYPES.LIBRARY?8:t.t0===this.authClient.ACCESS_TYPES.OBJECT?9:t.t0===this.authClient.ACCESS_TYPES.OTHER?20:21;break;case 8:return t.abrupt("return",this.utils.AddressToLibraryId(this.utils.HashToAddress(n)));case 9:return this.objectLibraryIds[n]||(this.Log("Retrieving content object library ID: ".concat(n||r)),this.objectLibraryIds[n]=new Promise(function(){var t=s(o.mark((function t(e,r){return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.t0=e,t.t1=a.utils,t.next=5,a.CallContractMethod({contractAddress:a.utils.HashToAddress(n),methodName:"libraryAddress"});case 5:t.t2=t.sent,t.t3=t.t1.AddressToLibraryId.call(t.t1,t.t2),(0,t.t0)(t.t3),t.next=13;break;case 10:t.prev=10,t.t4=t.catch(0),r(t.t4);case 13:case"end":return t.stop()}}),t,null,[[0,10]])})));return function(e,n){return t.apply(this,arguments)}}())),t.prev=10,t.next=13,this.objectLibraryIds[n];case 13:return t.abrupt("return",t.sent);case 16:throw t.prev=16,t.t1=t.catch(10),delete this.objectLibraryIds[n],t.t1;case 20:throw Error("Unable to retrieve library ID for ".concat(r||n,": Unknown type. (wrong network or deleted object?)"));case 21:return t.abrupt("return",this.contentSpaceLibraryId);case 22:case"end":return t.stop()}}),t,this,[[10,16]])})));return function(e){return t.apply(this,arguments)}}(),e.ProduceMetadataLinks=function(){var t=s(o.mark((function t(e){var n,r,i,u,A,l,p,d,h,y=this;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,i=e.versionHash,u=e.path,A=void 0===u?"/":u,l=e.metadata,p=e.authorizationToken,d=e.noAuth,l&&"object"===a(l)){t.next=3;break}return t.abrupt("return",l);case 3:if(!Array.isArray(l)){t.next=7;break}return t.next=6,this.utils.LimitedMap(5,l,function(){var t=s(o.mark((function t(e,a){return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,y.ProduceMetadataLinks({libraryId:n,objectId:r,versionHash:i,path:f(A,a.toString()),metadata:e,authorizationToken:p,noAuth:d});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}());case 6:return t.abrupt("return",t.sent);case 7:if(!l["/"]||!l["/"].match(/\.\/(rep|files)\/.+/)&&!l["/"].match(/^\/?qfab\/([\w]+)\/?(rep|files)\/.+/)){t.next=16;break}return t.t0=c,t.t1=c({},l),t.t2={},t.next=13,this.LinkUrl({libraryId:n,objectId:r,versionHash:i,linkPath:A,authorizationToken:p,noAuth:d});case 13:return t.t3=t.sent,t.t4={url:t.t3},t.abrupt("return",(0,t.t0)(t.t1,t.t2,t.t4));case 16:return h={},t.next=19,this.utils.LimitedMap(5,Object.keys(l),function(){var t=s(o.mark((function t(e){return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,y.ProduceMetadataLinks({libraryId:n,objectId:r,versionHash:i,path:f(A,e),metadata:l[e],authorizationToken:p,noAuth:d});case 2:h[e]=t.sent;case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}());case 19:return t.abrupt("return",h);case 20:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.MetadataAuth=function(){var t=s(o.mark((function t(e){var n,r,a,i,s,u,c,f,A,l,p,d,h;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,a=e.versionHash,i=e.path,s=void 0===i?"/":i,u=e.channelAuth,c=void 0!==u&&u,f=e.noAuth,A=void 0!==f&&f,m({libraryId:n,objectId:r,versionHash:a}),a&&(r=this.utils.DecodeVersionHash(a).objectId),A=this.noAuth||A||this.staticToken,l=A,A){t.next=14;break}return t.next=8,this.Visibility({id:r});case 8:return d=t.sent,t.next=11,this.AccessType({id:r});case 11:p=t.sent,l=(s||"").replace(/^\/+/,"").startsWith("public"),A=d>=10||l&&d>=1;case 14:if(!this.oauthToken){t.next=22;break}return t.next=17,this.authClient.KMSAddress({objectId:r,versionHash:a});case 17:if(!(h=t.sent)||this.utils.EqualAddress(h,this.utils.nullAddress)){t.next=22;break}return t.next=21,this.authClient.AuthorizationToken({libraryId:n,objectId:r,versionHash:a,channelAuth:!0,oauthToken:this.oauthToken});case 21:return t.abrupt("return",t.sent);case 22:if(this.inaccessibleLibraries[n]||!l||p!==this.authClient.ACCESS_TYPES.OBJECT||c){t.next=48;break}if(t.prev=23,t.t0=this.authClient,t.t1=n,t.t1){t.next=30;break}return t.next=29,this.ContentObjectLibraryId({objectId:r,versionHash:a});case 29:t.t1=t.sent;case 30:return t.t2=t.t1,t.t3=A,t.t4={libraryId:t.t2,noAuth:t.t3},t.next=35,t.t0.AuthorizationToken.call(t.t0,t.t4);case 35:return t.abrupt("return",t.sent);case 38:if(t.prev=38,t.t5=t.catch(23),!t.t5.message||!t.t5.message.toLowerCase().startsWith("access denied")){t.next=45;break}return this.inaccessibleLibraries[n]=!0,t.next=44,this.authClient.AuthorizationToken({libraryId:n,objectId:r,versionHash:a,noAuth:A,channelAuth:c});case 44:return t.abrupt("return",t.sent);case 45:throw t.t5;case 46:t.next=51;break;case 48:return t.next=50,this.authClient.AuthorizationToken({libraryId:n,objectId:r,versionHash:a,noAuth:A,channelAuth:c});case 50:return t.abrupt("return",t.sent);case 51:case"end":return t.stop()}}),t,this,[[23,38]])})));return function(e){return t.apply(this,arguments)}}(),e.ContentObjectMetadata=function(){var t=s(o.mark((function t(e){var n,r,a,i,s,u,l,p,d,h,y,g,b,I,w,C,E,B,k,Q,x,S,_,M,D,R,O,j,T,N,P,L=arguments;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,a=e.versionHash,i=e.writeToken,s=e.metadataSubtree,u=void 0===s?"/":s,l=e.localizationSubtree,p=e.queryParams,d=void 0===p?{}:p,h=e.select,y=void 0===h?[]:h,g=e.remove,b=void 0===g?[]:g,I=e.authorizationToken,w=e.noAuth,C=void 0!==w&&w,E=e.resolveLinks,B=void 0!==E&&E,k=e.resolveIncludeSource,Q=void 0!==k&&k,x=e.resolveIgnoreErrors,S=void 0!==x&&x,_=e.linkDepthLimit,M=void 0===_?1:_,D=e.produceLinkUrls,R=void 0!==D&&D,m({libraryId:n,objectId:r,versionHash:a}),this.Log("Retrieving content object metadata: ".concat(n||""," ").concat(r||a," ").concat(i||"","\n Subtree: ").concat(u)),d=c({},d||{}),a&&(r=this.utils.DecodeVersionHash(a).objectId),O=f("q",i||a||r,"meta",u),a){t.next=12;break}if(n){t.next=11;break}return t.next=10,this.ContentObjectLibraryId({objectId:r});case 10:n=t.sent;case 11:O=f("qlibs",n,O);case 12:return t.next=14,this.MetadataAuth({libraryId:n,objectId:r,versionHash:a,path:u,noAuth:C});case 14:return j=t.sent,T=[I,d.authorization,j].flat().filter((function(t){return t})),delete d.authorization,t.prev=17,t.next=20,this.utils.ResponseToJson(this.HttpClient.Request({headers:{Authorization:T.map((function(t){return"Bearer ".concat(t)}))},queryParams:c(c({},d),{},{select:y,remove:b,link_depth:M,resolve:B,resolve_include_source:Q,resolve_ignore_errors:S}),method:"GET",path:O}));case 20:N=t.sent,t.next=33;break;case 23:if(t.prev=23,t.t0=t.catch(17),404===t.t0.status){t.next=27;break}throw t.t0;case 27:if(!A.get(t.t0.body,"errors[0].cause.cause.cause.qwtoken")){t.next=32;break}throw t.t0;case 32:N="/"===u?{}:void 0;case 33:if(!R){t.next=37;break}return t.next=36,this.ProduceMetadataLinks({libraryId:n,objectId:r,versionHash:a,path:u,metadata:N,authorizationToken:I,noAuth:C});case 36:N=t.sent;case 37:if(l){t.next=39;break}return t.abrupt("return",N);case 39:return t.prev=39,t.next=42,this.ContentObjectMetadata(c(c({},L[0]),{},{metadataSubtree:l,localizationSubtree:void 0}));case 42:return P=t.sent,t.abrupt("return",v({},N,P,(function(t,e){return null===e||""===e?t:void 0})));case 46:return t.prev=46,t.t1=t.catch(39),this.Log(t.t1,!0),t.abrupt("return",N);case 50:case"end":return t.stop()}}),t,this,[[17,23],[39,46]])})));return function(e){return t.apply(this,arguments)}}(),e.AssetMetadata=function(){var t=s(o.mark((function t(e){var n,a,i,s,u,A,l,p,d,h=this;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,a=e.objectId,i=e.versionHash,s=e.metadata,u=e.localization,A=e.noAuth,l=e.produceLinkUrls,p=void 0!==l&&l,m({libraryId:n,objectId:a,versionHash:i}),a||(a=this.utils.DecodeVersionHash(i).objectId),s){t.next=12;break}return t.next=6,this.ContentObjectMetadata({libraryId:n,objectId:a,versionHash:i,metadataSubtree:"public/asset_metadata",resolveLinks:!0,linkDepthLimit:2,resolveIgnoreErrors:!0,produceLinkUrls:p,noAuth:A});case 6:if(t.t0=t.sent,t.t0){t.next=9;break}t.t0={};case 9:s=t.t0,t.next=16;break;case 12:if(!p){t.next=16;break}return t.next=15,this.ProduceMetadataLinks({libraryId:n,objectId:a,versionHash:i,path:f("public","asset_metadata"),metadata:s,noAuth:A});case 15:s=t.sent;case 16:return s.info||(s.info={}),d=c({},s),u&&u.reverse().forEach((function(t){var e,n=(e=h.utils).SafeTraverse.apply(e,[s].concat(r(t)))||{};d=v({},d,n,(function(t,e){return null===e||""===e?t:void 0}))})),t.abrupt("return",d);case 20:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.ContentObjectVersions=function(){var t=s(o.mark((function t(e){var n,r,a;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,m({libraryId:n,objectId:r}),this.Log("Retrieving content object versions: ".concat(n||""," ").concat(r)),a=f("qid",r),t.t0=this.utils,t.t1=this.HttpClient,t.next=8,this.authClient.AuthorizationHeader({libraryId:n,objectId:r});case 8:return t.t2=t.sent,t.t3=a,t.t4={headers:t.t2,method:"GET",path:t.t3},t.t5=t.t1.Request.call(t.t1,t.t4),t.abrupt("return",t.t0.ResponseToJson.call(t.t0,t.t5));case 13:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.LatestVersionHash=function(){var t=s(o.mark((function t(e){var n,r,a,i;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.objectId,(r=e.versionHash)&&(n=this.utils.DecodeVersionHash(r).objectId),h(n),t.prev=3,t.next=6,this.CallContractMethod({contractAddress:this.utils.HashToAddress(n),methodName:"objectHash"});case 6:a=t.sent,t.next=11;break;case 9:t.prev=9,t.t0=t.catch(3);case 11:if(a){t.next=20;break}return t.next=14,this.CallContractMethod({contractAddress:this.utils.HashToAddress(n),methodName:"countVersionHashes"});case 14:if((i=t.sent).toNumber()){t.next=17;break}throw Error("Unable to determine latest version hash for ".concat(r||n," - Item deleted?"));case 17:return t.next=19,this.CallContractMethod({contractAddress:this.utils.HashToAddress(n),methodName:"versionHashes",methodArgs:[i-1]});case 19:a=t.sent;case 20:return t.abrupt("return",a);case 21:case"end":return t.stop()}}),t,this,[[3,9]])})));return function(e){return t.apply(this,arguments)}}(),e.AvailableDRMs=s(o.mark((function t(){var e,n,r,a,i,s,u,c,f;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e=["clear","aes-128"],"undefined"!=typeof window){t.next=3;break}return t.abrupt("return",e);case 3:if(window.navigator&&window.navigator.userAgent&&((n=window.navigator.userAgent.match(/(iPad|iPhone|iphone|iPod).*?(OS |os |OS_)(\d+((_|\.)\d)?((_|\.)\d)?)/))&&n[3]&&(r=n[3].split("_"),a=parseInt(r[0]),i=parseInt(r[1]),(a>13||13===a&&i>=1)&&(e[1]="sample-aes",e[2]="fairplay")),/^((?!chrome|android).)*safari/i.test(window.navigator.userAgent)&&(s=window.navigator.userAgent.match(/.+Version\/(\d+)\.(\d+)/))&&s[2]&&(u=parseInt(s[1]),c=parseInt(s[2]),(u>13||13===u&&c>=1)&&(e[1]="sample-aes",e[2]="fairplay"))),"undefined"==typeof window||"function"==typeof window.navigator.requestMediaKeySystemAccess){t.next=6;break}return t.abrupt("return",e);case 6:return t.prev=6,f=[{initDataTypes:["cenc"],audioCapabilities:[{contentType:'audio/mp4;codecs="mp4a.40.2"'}],videoCapabilities:[{contentType:'video/mp4;codecs="avc1.42E01E"'}]}],t.next=10,navigator.requestMediaKeySystemAccess("com.widevine.alpha",f);case 10:e.push("widevine"),t.next=15;break;case 13:t.prev=13,t.t0=t.catch(6);case 15:return t.abrupt("return",e);case 16:case"end":return t.stop()}}),t,null,[[6,13]])}))),e.PlayoutPathResolution=function(){var t=s(o.mark((function t(e){var n,r,a,i,s,u,c,A,l,p,d,h,y,g,b,m,v;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,a=e.versionHash,i=e.writeToken,s=e.linkPath,u=e.handler,c=e.offering,A=void 0===c?"":c,l=e.signedLink,p=void 0!==l&&l,d=e.authorizationToken,n){t.next=5;break}return t.next=4,this.ContentObjectLibraryId({objectId:r});case 4:n=t.sent;case 5:if(a){t.next=9;break}return t.next=8,this.LatestVersionHash({objectId:r});case 8:a=t.sent;case 9:if(h=f("qlibs",n,"q",i||a,"rep",u,A,"options.json"),!s){t.next=26;break}return t.next=13,this.ContentObjectMetadata({libraryId:n,objectId:r,versionHash:a,writeToken:i,metadataSubtree:s,resolveLinks:!1,resolveIgnoreErrors:!0,resolveIncludeSource:!0,authorizationToken:d});case 13:if(v=t.sent,m=!!v&&!!v["/"]&&!v["/"].endsWith("options.json"),h=f("qlibs",n,"q",i||a,"meta",s),p){t.next=25;break}return t.next=19,this.LinkTarget({libraryId:n,objectId:r,versionHash:a,writeToken:i,linkPath:s,linkInfo:v,authorizationToken:d});case 19:return b=t.sent,g=this.utils.DecodeVersionHash(b).objectId,t.next=23,this.ContentObjectLibraryId({objectId:g});case 23:y=t.sent,m||A||(h=f("q",b,"rep",u,"options.json"));case 25:m&&(h=f(h,A,"options.json"));case 26:return t.abrupt("return",{path:h,multiOfferingLink:m,linkTarget:{libraryId:y,objectId:g,versionHash:b}});case 27:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.AvailableOfferings=function(){var t=s(o.mark((function t(e){var n,r,a,i,s,u,c,f,A,l,p,d;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.objectId,r=e.versionHash,a=e.writeToken,i=e.linkPath,s=e.signedLink,u=e.directLink,c=e.handler,f=void 0===c?"playout":c,A=e.authorizationToken,n||(n=this.utils.DecodeVersionHash(r).objectId),!u){t.next=15;break}return t.t0=this,t.next=6,this.ContentObjectLibraryId({objectId:n});case 6:return t.t1=t.sent,t.t2=n,t.t3=r,t.t4=i,t.t5=A,t.t6={libraryId:t.t1,objectId:t.t2,versionHash:t.t3,metadataSubtree:t.t4,resolveLinks:!0,authorizationToken:t.t5},t.next=14,t.t0.ContentObjectMetadata.call(t.t0,t.t6);case 14:return t.abrupt("return",t.sent);case 15:return t.next=17,this.PlayoutPathResolution({objectId:n,versionHash:r,writeToken:a,linkPath:i,signedLink:s,handler:f,authorizationToken:A});case 17:return l=t.sent,p=l.path,t.prev=19,t.t7=A,t.next=23,this.authClient.AuthorizationToken({objectId:n,channelAuth:!0,oauthToken:this.oauthToken});case 23:return t.t8=t.sent,d=[t.t7,t.t8].flat().filter((function(t){return t})),t.next=27,this.utils.ResponseToJson(this.HttpClient.Request({path:p,method:"GET",headers:{Authorization:"Bearer ".concat(d.join(","))}}));case 27:return t.abrupt("return",t.sent);case 30:if(t.prev=30,t.t9=t.catch(19),!t.t9.status||500!==parseInt(t.t9.status)){t.next=34;break}return t.abrupt("return",{});case 34:throw t.t9;case 35:case"end":return t.stop()}}),t,this,[[19,30]])})));return function(e){return t.apply(this,arguments)}}(),e.PlayoutOptions=function(){var t=s(o.mark((function t(e){var n,r,a,u,A,l,p,d,g,b,m,v,I,w,C,E,B,k,Q,x,S,_,M,D,R,O,j,T,N,P,L,F,U,H,G,q,Y,K,z,J,V,W,Z,X,$,tt,et=this;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.offeringURI,r=e.objectId,a=e.versionHash,u=e.writeToken,A=e.linkPath,l=e.signedLink,p=void 0!==l&&l,d=e.protocols,g=void 0===d?["dash","hls"]:d,b=e.handler,m=void 0===b?"playout":b,v=e.offering,I=void 0===v?"default":v,w=e.playoutType,C=e.drms,E=void 0===C?[]:C,B=e.context,k=e.hlsjsProfile,Q=void 0===k||k,x=e.authorizationToken,S=e.options,_=void 0===S?{}:S,!n){t.next=8;break}if(M=n.match(/(hq__[^/]+)\/rep\/([^/]+)\/([^/]+)\/options.json/),a=M[1],m=M[2],I=M[3],a&&m&&I){t.next=8;break}throw Error("Invalid offering URI: ".concat(n));case 8:if(a?y(a):h(r),g=g.map((function(t){return t.toLowerCase()})),E=E.map((function(t){return t.toLowerCase()})),r){t.next=15;break}r=this.utils.DecodeVersionHash(a).objectId,t.next=19;break;case 15:if(a){t.next=19;break}return t.next=18,this.LatestVersionHash({objectId:r});case 18:a=t.sent;case 19:return t.next=21,this.ContentObjectLibraryId({objectId:r});case 21:if(D=t.sent,t.prev=22,A){t.next=29;break}return R=f("public","asset_metadata","sources",I),t.next=27,this.ContentObjectMetadata({libraryId:D,objectId:r,versionHash:a,metadataSubtree:R,authorizationToken:x});case 27:t.sent&&(A=R);case 29:t.next=33;break;case 31:t.prev=31,t.t0=t.catch(22);case 33:return t.next=35,this.PlayoutPathResolution({libraryId:D,objectId:r,versionHash:a,writeToken:u,linkPath:A,signedLink:p,handler:m,offering:I,authorizationToken:x});case 35:if(O=t.sent,j=O.path,T=O.linkTarget,t.t1=this.authClient,t.t2=T.objectId||r,t.t3=T.versionHash||a,t.t3){t.next=45;break}return t.next=44,this.LatestVersionHash({objectId:r});case 44:t.t3=t.sent;case 45:return t.t4=t.t3,t.t5=g,t.t6=E,t.t7=B,t.t8={objectId:t.t2,versionHash:t.t4,protocols:t.t5,drms:t.t6,context:t.t7},N=t.t1.AudienceData.call(t.t1,t.t8),t.t9=x,t.next=54,this.authClient.AuthorizationToken({libraryId:D,objectId:r,channelAuth:!0,oauthToken:this.oauthToken,audienceData:N});case 54:return t.t10=t.sent,P=[t.t9,t.t10].flat().filter((function(t){return t})),L=c({authorization:P,resolve:!!A},_),t.t11=Object,t.next=60,this.utils.ResponseToJson(this.HttpClient.Request({path:j,method:"GET",queryParams:L}));case 60:if(t.t12=t.sent,F=t.t11.values.call(t.t11,t.t12),p||!T.versionHash){t.next=68;break}return t.t13=x,t.next=66,this.authClient.AuthorizationToken({libraryId:T.libraryId,objectId:T.objectId,channelAuth:!0,oauthToken:this.oauthToken,audienceData:N});case 66:t.t14=t.sent,L.authorization=[t.t13,t.t14].flat().filter((function(t){return t}));case 68:U={},q=0;case 70:if(!(q<F.length)){t.next=116;break}if(Y=F[q],K=Y.properties.protocol,z=Y.properties.drm,H=H||Y.sid,G=G||!!Y.properties.multiview,H&&(L.sid=H),J=Y.uri.split("?")[0],w&&(J=J.replace("playlist","playlist-".concat(w))),V=Y.properties.license_servers,W=Y.properties.cert,Q&&"hls"===K&&"aes-128"===z&&(L.player_profile="hls-js"),t.t15=c,t.t16=c({},U[K]||{}),t.t17={},t.t18=c,t.t19=c({},(U[K]||{}).playoutMethods||{}),t.t20={},t.t21=i,t.t22={},t.t23=z||"clear",!p){t.next=97;break}return t.next=94,this.LinkUrl({versionHash:a,linkPath:f(A,I,J),queryParams:L,noAuth:!0});case 94:t.t24=t.sent,t.next=100;break;case 97:return t.next=99,this.Rep({libraryId:T.libraryId||D,objectId:T.objectId||r,versionHash:T.versionHash||a,rep:f(m,I,J),noAuth:!0,queryParams:L});case 99:t.t24=t.sent;case 100:for(Z in t.t25=t.t24,t.t26=z?i({},z,{licenseServers:V,cert:W}):void 0,t.t27={playoutUrl:t.t25,drms:t.t26},t.t28=(0,t.t21)(t.t22,t.t23,t.t27),t.t29=(0,t.t18)(t.t19,t.t20,t.t28),t.t30={playoutMethods:t.t29},U[K]=(0,t.t15)(t.t16,t.t17,t.t30),U[K].playoutMethods)U[K].playoutMethods[Z].drms&&U[K].playoutMethods[Z].drms[z]&&U[K].playoutMethods[Z].drms[z].cert&&((X=new URL(U[K].playoutMethods[Z].playoutUrl)).pathname=X.pathname.split("/").slice(0,-1).concat(["drm.cert"]).join("/"),U[K].playoutMethods[Z].drms[z].cert_url=X.toString());if($=g.includes(K),tt=E.includes(z||"clear")||0===E.length&&!z,$&&tt){t.next=112;break}return t.abrupt("continue",113);case 112:(!U[K].playoutUrl||z&&"clear"!==z)&&(U[K].playoutUrl=U[K].playoutMethods[z||"clear"].playoutUrl,U[K].drms=U[K].playoutMethods[z||"clear"].drms);case 113:q++,t.next=70;break;case 116:return G&&H&&(U.sessionId=H,U.multiview=!0,U.AvailableViews=s(o.mark((function t(){return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=et.utils,t.next=3,et.HttpClient.Request({path:f("q",T.versionHash||a,"rep",m,I,"views.json"),method:"GET",queryParams:{sid:H,authorization:P}});case 3:return t.t1=t.sent,t.next=6,t.t0.ResponseToFormat.call(t.t0,"json",t.t1);case 6:return t.abrupt("return",t.sent);case 7:case"end":return t.stop()}}),t)}))),U.SwitchView=function(){var t=s(o.mark((function t(e){return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,et.HttpClient.Request({path:f("q",T.versionHash||a,"rep",m,I,"select_view"),method:"POST",queryParams:{sid:H,authorization:P},body:{view:e}});case 2:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),this.Log(U),t.abrupt("return",U);case 119:case"end":return t.stop()}}),t,this,[[22,31]])})));return function(e){return t.apply(this,arguments)}}(),e.BitmovinPlayoutOptions=function(){var t=s(o.mark((function t(e){var n,r,a,i,s,u,c,f,A,l,p,d,g,b,m,v,I,w,C,E,B,k,Q,x;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.objectId,r=e.versionHash,a=e.writeToken,i=e.linkPath,s=e.signedLink,u=void 0!==s&&s,c=e.protocols,f=void 0===c?["dash","hls"]:c,A=e.drms,l=void 0===A?[]:A,p=e.handler,d=void 0===p?"playout":p,g=e.offering,b=void 0===g?"default":g,m=e.playoutType,v=e.context,I=e.authorizationToken,w=e.options,C=void 0===w?{}:w,r?y(r):h(n),n||(n=this.utils.DecodeVersionHash(r).objectId),t.next=5,this.PlayoutOptions({objectId:n,versionHash:r,writeToken:a,linkPath:i,signedLink:u,protocols:f,drms:l,handler:d,offering:b,playoutType:m,hlsjsProfile:!1,context:v,authorizationToken:I,options:C});case 5:return delete(E=t.sent).playoutMethods,t.next=9,this.PlayoutPathResolution({objectId:n,versionHash:r,writeToken:a,linkPath:i,signedLink:u,handler:d,offering:b,authorizationToken:I});case 9:if(B=t.sent,k=B.linkTarget,Q=[],I&&Q.push(I),!u&&k.versionHash){t.next=21;break}return t.t0=Q,t.next=17,this.authClient.AuthorizationToken({objectId:n,channelAuth:!0,oauthToken:this.oauthToken});case 17:t.t1=t.sent,t.t0.push.call(t.t0,t.t1),t.next=26;break;case 21:return t.t2=Q,t.next=24,this.authClient.AuthorizationToken({libraryId:k.libraryId,objectId:k.objectId,channelAuth:!0,oauthToken:this.oauthToken});case 24:t.t3=t.sent,t.t2.push.call(t.t2,t.t3);case 26:return x={drm:{}},Object.keys(E).forEach((function(t){var e=E[t];x[t]=e.playoutUrl,e.drms&&Object.keys(e.drms).forEach((function(t){if(e.drms[t].licenseServers&&0!==e.drms[t].licenseServers.length){var n=function(t){return t.toLowerCase().startsWith("https")},r=e.drms[t].licenseServers;r.find(n)&&(r=r.filter(n));var a=r.sort((function(){return.5-Math.random()}))[0];x.drm[t]||(x.drm[t]={LA_URL:a,headers:{Authorization:"Bearer ".concat(Q.flat().filter((function(t){return t})).join(","))}})}}))})),t.abrupt("return",x);case 29:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.CallBitcodeMethod=function(){var t=s(o.mark((function t(e){var n,r,a,i,s,u,c,A,l,p,d,h,y,g,b,v;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,a=e.versionHash,i=e.writeToken,s=e.method,u=e.queryParams,c=void 0===u?{}:u,A=e.body,l=void 0===A?{}:A,p=e.headers,d=void 0===p?{}:p,h=e.constant,y=void 0===h||h,g=e.format,b=void 0===g?"json":g,m({libraryId:n,objectId:r,versionHash:a}),s){t.next=4;break}throw"Bitcode method not specified";case 4:if(a&&(r=this.utils.DecodeVersionHash(a).objectId),v=f("q",i||a||r,"call",s),n&&(v=f("qlibs",n,v)),d.authorization||d.Authorization){t.next=12;break}return t.next=11,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,update:!y});case 11:d.Authorization=t.sent.Authorization;case 12:return this.Log("Calling bitcode method: ".concat(n||""," ").concat(r||a," ").concat(i||"","\n ").concat(y?"GET":"POST"," ").concat(v,"\n Query Params:\n ").concat(JSON.stringify(c||""),"\n Body:\n ").concat(JSON.stringify(l||""),"\n Headers\n ").concat(JSON.stringify(d||""))),t.t0=this.utils,t.t1=b,t.next=17,this.HttpClient.Request({body:l,headers:d,method:y?"GET":"POST",path:v,queryParams:c,allowFailover:!1});case 17:return t.t2=t.sent,t.abrupt("return",t.t0.ResponseToFormat.call(t.t0,t.t1,t.t2));case 19:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.Rep=function(){var t=s(o.mark((function t(e){var n,r,a,i,s,u,c,f,A,l,p,d,h,y,g,b;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,a=e.versionHash,i=e.rep,s=e.queryParams,u=void 0===s?{}:s,c=e.service,f=void 0===c?"fabric":c,A=e.makeAccessRequest,l=void 0!==A&&A,p=e.channelAuth,d=void 0!==p&&p,h=e.noAuth,y=void 0!==h&&h,g=e.noCache,b=void 0!==g&&g,m({libraryId:n,objectId:r,versionHash:a}),i){t.next=4;break}throw"Rep not specified";case 4:return t.abrupt("return",this.FabricUrl({libraryId:n,objectId:r,versionHash:a,rep:i,queryParams:u,service:f,makeAccessRequest:l,channelAuth:d,noAuth:y,noCache:b}));case 5:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.PublicRep=function(){var t=s(o.mark((function t(e){var n,r,a,i,s,u,c,f;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,a=e.versionHash,i=e.rep,s=e.queryParams,u=void 0===s?{}:s,c=e.service,f=void 0===c?"fabric":c,m({libraryId:n,objectId:r,versionHash:a}),i){t.next=4;break}throw"Rep not specified";case 4:return t.abrupt("return",this.FabricUrl({libraryId:n,objectId:r,versionHash:a,publicRep:i,queryParams:u,service:f,noAuth:!0}));case 5:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.FabricUrl=function(){var t=s(o.mark((function t(e){var n,r,a,i,s,u,A,l,p,d,h,y,g,b,v,I,w,C,E,B,k,Q,x;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,a=e.versionHash,i=e.writeToken,s=e.partHash,u=e.rep,A=e.publicRep,l=e.call,p=e.queryParams,d=void 0===p?{}:p,h=e.service,y=void 0===h?"fabric":h,g=e.channelAuth,b=void 0!==g&&g,v=e.makeAccessRequest,I=void 0!==v&&v,w=e.noAuth,C=void 0!==w&&w,E=e.noCache,B=void 0!==E&&E,(r||a)&&m({libraryId:n,objectId:r,versionHash:a}),a&&(r=this.utils.DecodeVersionHash(a).objectId),this.Log("Building Fabric URL:\n libraryId: ".concat(n,"\n objectId: ").concat(r,"\n versionHash: ").concat(a,"\n writeToken: ").concat(i,"\n partHash: ").concat(s,"\n rep: ").concat(u,"\n publicRep: ").concat(A,"\n call: ").concat(l,"\n channelAuth: ").concat(b,"\n noAuth: ").concat(C,"\n noCache: ").concat(B,"\n queryParams: ").concat(JSON.stringify(d||{},null,2))),k=[],d.authorization&&k.push(d.authorization),C&&d.authorization){t.next=12;break}return t.t0=k,t.next=10,this.authClient.AuthorizationToken({libraryId:n,objectId:r,versionHash:a,channelAuth:b,makeAccessRequest:I,noAuth:C,noCache:B});case 10:t.t1=t.sent,t.t0.push.call(t.t0,t.t1);case 12:if(d=c(c({},d),{},{authorization:k.flat()}),!u&&!A||!r||a){t.next=17;break}return t.next=16,this.LatestVersionHash({objectId:r});case 16:a=t.sent;case 17:return Q="",n?(Q=f(Q,"qlibs",n),(r||a)&&(Q=f(Q,"q",i||a||r))):a&&(Q=f("q",a)),s?Q=f(Q,"data",s):u?Q=f(Q,"rep",u):A?Q=f(Q,"public",A):l&&(Q=f(Q,"call",l)),x=this.HttpClient,"search"===y?x=this.SearchHttpClient:"auth"===y&&(x=this.AuthHttpClient),t.abrupt("return",x.URL({path:Q,queryParams:d}));case 23:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.FileUrl=function(){var t=s(o.mark((function t(e){var n,r,a,i,s,u,A,l,p,d,h,y;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,a=e.versionHash,i=e.writeToken,s=e.filePath,u=e.queryParams,A=void 0===u?{}:u,l=e.noCache,p=void 0!==l&&l,m({libraryId:n,objectId:r,versionHash:a}),s){t.next=4;break}throw"File path not specified";case 4:return a&&(r=this.utils.DecodeVersionHash(a).objectId),d=n?f("qlibs",n,"q",i||a||r):f("q",a),t.next=8,this.authClient.AuthorizationToken({libraryId:n,objectId:r,noCache:p});case 8:return h=t.sent,A=c(c({},A),{},{authorization:h}),t.next=12,this.ContentObjectMetadata({libraryId:n,objectId:r,versionHash:a,writeToken:i,metadataSubtree:f("files",s)});case 12:return y=t.sent,y&&y["."].encryption&&"cgck"===y["."].encryption.scheme?(d=f(d,"rep","files_download",s),A["header-x_decryption_mode"]="decrypt"):d=f(d,"files",s),t.abrupt("return",this.HttpClient.URL({path:d,queryParams:A}));case 16:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.ContentObjectImageUrl=function(){var t=s(o.mark((function t(e){var n,r,a,i,s,u,c;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,a=e.versionHash,i=e.height,s=e.imagePath,u=void 0===s?"public/display_image":s,m({libraryId:n,objectId:r,versionHash:a}),a){t.next=6;break}return t.next=5,this.LatestVersionHash({objectId:r});case 5:a=t.sent;case 6:if(this.Log("Retrieving content object image url: ".concat(n," ").concat(r," ").concat(a)),this.objectImageUrls[a]){t.next=26;break}return t.prev=8,t.next=11,this.ContentObjectMetadata({versionHash:a,metadataSubtree:u});case 11:if(t.sent){t.next=15;break}return this.Log("No image url set: ".concat(n," ").concat(r," ").concat(a)),t.abrupt("return");case 15:t.next=21;break;case 17:t.prev=17,t.t0=t.catch(8),this.Log("Unable to query for image metadata: ".concat(n," ").concat(r," ").concat(a),!0),this.Log(t.t0,!0);case 21:return c={},i&&!isNaN(parseInt(i))&&(c.height=parseInt(i)),t.next=25,this.LinkUrl({versionHash:a,linkPath:u,queryParams:c});case 25:this.objectImageUrls[a]=t.sent;case 26:return t.abrupt("return",this.objectImageUrls[a]);case 27:case"end":return t.stop()}}),t,this,[[8,17]])})));return function(e){return t.apply(this,arguments)}}(),e.ContentObjectGraph=function(){var t=s(o.mark((function t(e){var n,r,a,i,u,c,A,l,p,d,h=this;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,a=e.versionHash,i=e.autoUpdate,u=void 0!==i&&i,c=e.select,m({libraryId:n,objectId:r,versionHash:a}),this.Log("Retrieving content object graph: ".concat(n||""," ").concat(r||a)),a&&(r=this.utils.DecodeVersionHash(a).objectId),A=f("q",a||r,"links"),t.prev=5,t.t0=this.utils,t.t1=this.HttpClient,t.next=10,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,versionHash:a});case 10:return t.t2=t.sent,t.t3={auto_update:u,select:c},t.t4=A,t.t5={headers:t.t2,queryParams:t.t3,method:"GET",path:t.t4},t.t6=t.t1.Request.call(t.t1,t.t5),t.next=17,t.t0.ResponseToJson.call(t.t0,t.t6);case 17:return t.abrupt("return",t.sent);case 20:if(t.prev=20,t.t7=t.catch(5),t.prev=22,(p=t.t7.body.errors[0].cause.cause.cause.cycle)&&0!==p.length){t.next=26;break}throw t.t7;case 26:return d={},t.next=29,Promise.all(p.map(function(){var t=s(o.mark((function t(e){var n,r;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!d[e]){t.next=2;break}return t.abrupt("return");case 2:return n=h.utils.DecodeVersionHash(e).objectId,t.next=5,h.ContentObjectMetadata({versionHash:e,metadataSubtree:"public/asset_metadata/display_title"});case 5:if(t.t2=t.sent,t.t2){t.next=10;break}return t.next=9,h.ContentObjectMetadata({versionHash:e,metadataSubtree:"public/name"});case 9:t.t2=t.sent;case 10:if(t.t1=t.t2,t.t1){t.next=15;break}return t.next=14,h.ContentObjectMetadata({versionHash:e,metadataSubtree:"name"});case 14:t.t1=t.sent;case 15:if(t.t0=t.t1,t.t0){t.next=18;break}t.t0=n;case 18:r=t.t0,d[e]={name:r,objectId:n};case 20:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()));case 29:l=p.map((function(t){return"".concat(d[t].name," (").concat(d[t].objectId,")")})),t.next=35;break;case 32:throw t.prev=32,t.t8=t.catch(22),t.t7;case 35:throw new Error("Cycle found in links: ".concat(l.join(" -> ")));case 36:case"end":return t.stop()}}),t,this,[[5,20],[22,32]])})));return function(e){return t.apply(this,arguments)}}(),e.LinkTarget=function(){var t=s(o.mark((function t(e){var n,r,i,s,u,c,f,A,l;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,i=e.versionHash,s=e.writeToken,u=e.linkPath,c=e.authorizationToken,f=e.linkInfo,m({libraryId:n,objectId:r,versionHash:i}),s&&b(s),i&&(r=this.utils.DecodeVersionHash(i).objectId),!s||n){t.next=8;break}return t.next=7,this.ContentObjectLibraryId({objectId:r});case 7:n=t.sent;case 8:if(f){t.next=12;break}return t.next=11,this.ContentObjectMetadata({libraryId:n,objectId:r,versionHash:i,writeToken:s,metadataSubtree:u,resolveLinks:!1,resolveIgnoreErrors:!0,resolveIncludeSource:!0,authorizationToken:c});case 11:f=t.sent;case 12:if(!f||!f["/"]){t.next=27;break}if((A=((f["/"]||"").match(/^\/?qfab\/([\w]+)\/?.+/)||[])[1])||(A=f["."].container),!A){t.next=19;break}return t.abrupt("return",A);case 19:if(!i){t.next=21;break}return t.abrupt("return",i);case 21:if(t.t0=i,t.t0){t.next=26;break}return t.next=25,this.LatestVersionHash({objectId:r});case 25:t.t0=t.sent;case 26:return t.abrupt("return",t.t0);case 27:return t.next=29,this.ContentObjectMetadata({libraryId:n,objectId:r,versionHash:i,writeToken:s,metadataSubtree:u,resolveIncludeSource:!0,authorizationToken:c});case 29:if((f=t.sent)&&f["."]){t.next=49;break}if("object"!==a(f)){t.next=38;break}if(t.t1=i,t.t1){t.next=37;break}return t.next=36,this.LatestVersionHash({objectId:r});case 36:t.t1=t.sent;case 37:return t.abrupt("return",t.t1);case 38:if(l=u.split("/").slice(0,-1).join("/")){t.next=46;break}if(t.t2=i,t.t2){t.next=45;break}return t.next=44,this.LatestVersionHash({objectId:r});case 44:t.t2=t.sent;case 45:return t.abrupt("return",t.t2);case 46:return t.next=48,this.ContentObjectMetadata({libraryId:n,objectId:r,versionHash:i,writeToken:s,metadataSubtree:l,resolveIncludeSource:!0,authorizationToken:c});case 48:f=t.sent;case 49:return t.abrupt("return",f["."].source);case 50:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.LinkUrl=function(){var t=s(o.mark((function t(e){var n,r,a,i,s,u,A,l,p,d,h,y,g,v,I;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,a=e.versionHash,i=e.writeToken,s=e.linkPath,u=e.mimeType,A=e.authorizationToken,l=e.queryParams,p=void 0===l?{}:l,d=e.channelAuth,h=void 0!==d&&d,y=e.noAuth,g=void 0!==y&&y,m({libraryId:n,objectId:r,versionHash:a}),i&&b(i),s){t.next=5;break}throw Error("Link path not specified");case 5:return a&&(r=this.utils.DecodeVersionHash(a).objectId),v=n?f("qlibs",n,"q",i||a||r,"meta",s):f("q",a,"meta",s),I=[A],t.t0=I,t.next=11,this.MetadataAuth({libraryId:n,objectId:r,versionHash:a,path:s,channelAuth:h,noAuth:g});case 11:return t.t1=t.sent,t.t0.push.call(t.t0,t.t1),p.authorization&&I.push(p.authorization),p=c(c({},p),{},{authorization:I.flat().filter((function(t){return t})),resolve:!0}),u&&(p["header-accept"]=u),t.abrupt("return",this.HttpClient.URL({path:v,queryParams:p}));case 17:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.LinkData=function(){var t=s(o.mark((function t(e){var n,r,a,i,s,u,c,f,A,p,d;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,a=e.versionHash,i=e.writeToken,s=e.linkPath,u=e.queryParams,c=void 0===u?{}:u,f=e.format,A=void 0===f?"json":f,p=e.channelAuth,t.next=3,this.LinkUrl({libraryId:n,objectId:r,versionHash:a,writeToken:i,linkPath:s,queryParams:c,channelAuth:p});case 3:return d=t.sent,t.t0=this.utils,t.t1=A,t.next=8,l.Fetch(d);case 8:return t.t2=t.sent,t.abrupt("return",t.t0.ResponseToFormat.call(t.t0,t.t1,t.t2));case 10:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.CreateEncryptionConk=function(){var t=s(o.mark((function t(e){var n,r,a,i,s,u,c,f,A,l,p;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,a=e.versionHash,i=e.writeToken,s=e.createKMSConk,u=void 0===s||s,!this.signer.remoteSigner){t.next=3;break}return t.abrupt("return");case 3:if(m({libraryId:n,objectId:r,versionHash:a}),b(i),r||(r=client.DecodeVersionHash(a).objectId),n){t.next=10;break}return t.next=9,this.ContentObjectLibraryId({objectId:r});case 9:n=t.sent;case 10:return c="eluv.caps.iusr".concat(this.utils.AddressToHash(this.signer.address)),t.next=13,this.ContentObjectMetadata({libraryId:n,objectId:r,writeToken:i,metadataSubtree:c});case 13:if(!(f=t.sent)){t.next=20;break}return t.next=17,this.Crypto.DecryptCap(f,this.signer._signingKey().privateKey);case 17:this.encryptionConks[r]=t.sent,t.next=34;break;case 20:return t.next=22,this.Crypto.GeneratePrimaryConk({spaceId:this.contentSpaceId,objectId:r});case 22:return this.encryptionConks[r]=t.sent,t.t0=this,t.t1=n,t.t2=r,t.t3=i,t.t4=c,t.next=30,this.Crypto.EncryptConk(this.encryptionConks[r],this.signer._signingKey().publicKey);case 30:return t.t5=t.sent,t.t6={libraryId:t.t1,objectId:t.t2,writeToken:t.t3,metadataSubtree:t.t4,metadata:t.t5},t.next=34,t.t0.ReplaceMetadata.call(t.t0,t.t6);case 34:if(!u){t.next=64;break}return t.prev=35,t.next=38,this.authClient.KMSAddress({objectId:r});case 38:return A=t.sent,t.next=41,this.authClient.KMSInfo({objectId:r});case 41:return l=t.sent.publicKey,p="eluv.caps.ikms".concat(this.utils.AddressToHash(A)),t.next=45,this.ContentObjectMetadata({libraryId:n,objectId:r,writeToken:i,metadataSubtree:p});case 45:if(t.sent){t.next=58;break}return t.t7=this,t.t8=n,t.t9=r,t.t10=i,t.t11=p,t.next=54,this.Crypto.EncryptConk(this.encryptionConks[r],l);case 54:return t.t12=t.sent,t.t13={libraryId:t.t8,objectId:t.t9,writeToken:t.t10,metadataSubtree:t.t11,metadata:t.t12},t.next=58,t.t7.ReplaceMetadata.call(t.t7,t.t13);case 58:t.next=64;break;case 60:t.prev=60,t.t14=t.catch(35),console.error("Failed to create encryption cap for KMS:"),console.error(t.t14);case 64:return t.abrupt("return",this.encryptionConks[r]);case 65:case"end":return t.stop()}}),t,this,[[35,60]])})));return function(e){return t.apply(this,arguments)}}(),e.EncryptionConk=function(){var t=s(o.mark((function t(e){var n,r,a,i,s,u,c,f,A,l,p;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,a=e.versionHash,i=e.writeToken,s=e.download,u=void 0!==s&&s,m({libraryId:n,objectId:r,versionHash:a}),i&&b(i),r||(r=client.DecodeVersionHash(a).objectId),t.next=6,this.authClient.Owner({id:r});case 6:return c=t.sent,f="eluv.caps.iusr".concat(this.utils.AddressToHash(this.signer.address)),t.next=10,this.ContentObjectMetadata({libraryId:n,objectId:r,versionHash:a,metadataSubtree:f});case 10:if(A=t.sent,this.utils.EqualAddress(c,this.signer.address)||A){t.next=21;break}if(!u){t.next=18;break}return t.next=15,this.authClient.ReEncryptionConk({libraryId:n,objectId:r,versionHash:a});case 15:return t.abrupt("return",t.sent);case 18:return t.next=20,this.authClient.EncryptionConk({libraryId:n,objectId:r,versionHash:a});case 20:return t.abrupt("return",t.sent);case 21:if(this.encryptionConks[r]){t.next=38;break}return l="eluv.caps.iusr".concat(this.utils.AddressToHash(this.signer.address)),t.next=25,this.ContentObjectMetadata({libraryId:n,objectId:r,versionHash:a,writeToken:i,metadataSubtree:l});case 25:if(!(p=t.sent)){t.next=32;break}return t.next=29,this.Crypto.DecryptCap(p,this.signer._signingKey().privateKey);case 29:this.encryptionConks[r]=t.sent,t.next=38;break;case 32:if(!i){t.next=37;break}return t.next=35,this.CreateEncryptionConk({libraryId:n,objectId:r,versionHash:a,writeToken:i,createKMSConk:!1});case 35:t.next=38;break;case 37:throw"No encryption conk present for "+r;case 38:return t.abrupt("return",this.encryptionConks[r]);case 39:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.Encrypt=function(){var t=s(o.mark((function t(e){var n,r,a,i,s,u;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,a=e.writeToken,i=e.chunk,m({libraryId:n,objectId:r}),t.next=4,this.EncryptionConk({libraryId:n,objectId:r,writeToken:a});case 4:return s=t.sent,t.next=7,this.Crypto.Encrypt(s,i);case 7:return u=t.sent,t.abrupt("return",u.buffer.slice(u.byteOffset,u.byteOffset+u.byteLength));case 9:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.Decrypt=function(){var t=s(o.mark((function t(e){var n,r,a,i,s,u;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,a=e.writeToken,i=e.chunk,m({libraryId:n,objectId:r}),t.next=4,this.EncryptionConk({libraryId:n,objectId:r,writeToken:a,download:!0});case 4:return s=t.sent,t.next=7,this.Crypto.Decrypt(s,i);case 7:return u=t.sent,t.abrupt("return",u.buffer.slice(u.byteOffset,u.byteOffset+u.byteLength));case 9:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.AccessType=function(){var t=s(o.mark((function t(e){var n;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.id,t.next=3,this.authClient.AccessType(n);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.AccessInfo=function(){var t=s(o.mark((function t(e){var n,r,a;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.objectId,r=e.args,h(n),r||(r=[0,[],[]]),this.Log("Retrieving access info: ".concat(n)),t.next=6,this.ethClient.CallContractMethod({contractAddress:this.utils.HashToAddress(n),methodName:"getAccessInfo",methodArgs:r});case 6:return a=t.sent,this.Log(a),t.abrupt("return",{visibilityCode:a[0],visible:a[0]>=1,accessible:a[0]>=10,editable:a[0]>=100,hasAccess:0===a[1],accessCode:a[1],accessCharge:this.utils.WeiToEther(a[2]).toString()});case 9:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.AccessRequest=function(){var t=s(o.mark((function t(e){var n,r,a,i,s,u,c,f,A;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,a=e.versionHash,i=e.args,s=void 0===i?[]:i,u=e.update,c=void 0!==u&&u,f=e.noCache,A=void 0!==f&&f,m({libraryId:n,objectId:r,versionHash:a}),a&&(r=this.utils.DecodeVersionHash(a).objectId),t.next=5,this.authClient.MakeAccessRequest({libraryId:n,objectId:r,versionHash:a,args:s,update:c,skipCache:!0,noCache:A});case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.SetAuthContext=function(t){var e=t.context;if(e&&Object.values(e).find((function(t){return"string"!=typeof t})))throw Error("Context must be a map of string->string");this.authContext=e},e.GenerateStateChannelToken=function(){var t=s(o.mark((function t(e){var n,r,a,i,s;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.objectId,r=e.versionHash,a=e.context,i=e.noCache,s=void 0!==i&&i,r?y(r):h(n),!r){t.next=6;break}n=this.utils.DecodeVersionHash(r).objectId,t.next=10;break;case 6:if(this.stateChannelAccess[n]){t.next=10;break}return t.next=9,this.LatestVersionHash({objectId:n});case 9:r=t.sent;case 10:return this.stateChannelAccess[n]=r,t.next=13,this.authClient.AuthorizationToken({objectId:n,channelAuth:!0,oauthToken:this.oauthToken,context:a,noCache:s});case 13:return t.abrupt("return",t.sent);case 14:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.FinalizeStateChannelAccess=function(){var t=s(o.mark((function t(e){var n,r,a;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.objectId,r=e.versionHash,a=e.percentComplete,r?y(r):h(n),!r){t.next=6;break}n=this.utils.DecodeVersionHash(r).objectId,t.next=13;break;case 6:if(!this.stateChannelAccess[n]){t.next=10;break}r=this.stateChannelAccess[n],t.next=13;break;case 10:return t.next=12,this.LatestVersionHash({objectId:n});case 12:r=t.sent;case 13:return this.stateChannelAccess[n]=void 0,t.next=16,this.authClient.ChannelContentFinalize({objectId:n,versionHash:r,percent:a});case 16:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.ContentObjectAccessComplete=function(){var t=s(o.mark((function t(e){var n,r,a;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.objectId,r=e.score,a=void 0===r?100:r,h(n),!(a<0||a>100)){t.next=4;break}throw Error("Invalid AccessComplete score: "+a);case 4:return t.next=6,this.authClient.AccessComplete({id:n,score:a});case 6:return t.abrupt("return",t.sent);case 7:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.Collection=function(){var t=s(o.mark((function t(e){var n;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.collectionType,["accessGroups","contentObjects","contentTypes","contracts","libraries"].includes(n)){t.next=4;break}throw new Error("Invalid collection type: "+n);case 4:if(!this.signer){t.next=10;break}return t.next=7,this.userProfileClient.WalletAddress();case 7:t.t0=t.sent,t.next=11;break;case 10:t.t0=void 0;case 11:if(t.t0){t.next=14;break}throw new Error("Unable to get collection: User wallet doesn't exist");case 14:return this.Log("Retrieving ".concat(n," contract collection for user ").concat(this.signer.address)),t.next=17,this.ethClient.MakeProviderCall({methodName:"send",args:["elv_getWalletCollection",[this.contentSpaceId,"iusr".concat(this.utils.AddressToHash(this.signer.address)),n]]});case 17:if(t.t1=t.sent,t.t1){t.next=20;break}t.t1=[];case 20:return t.abrupt("return",t.t1);case 21:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.VerifyContentObject=function(){var t=s(o.mark((function t(e){var n,r,a;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,a=e.versionHash,m({libraryId:n,objectId:r,versionHash:a}),t.next=4,ContentObjectVerification.VerifyContentObject({client:this,libraryId:n,objectId:r,versionHash:a});case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.Proofs=function(){var t=s(o.mark((function t(e){var n,r,a,i,s;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,a=e.versionHash,i=e.partHash,m({libraryId:n,objectId:r,versionHash:a}),g(i),a&&(r=this.utils.DecodeVersionHash(a).objectId),s=f("q",a||r,"data",i,"proofs"),t.t0=this.utils,t.t1=this.HttpClient,t.next=9,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,versionHash:a});case 9:return t.t2=t.sent,t.t3=s,t.t4={headers:t.t2,method:"GET",path:t.t3},t.t5=t.t1.Request.call(t.t1,t.t4),t.abrupt("return",t.t0.ResponseToJson.call(t.t0,t.t5));case 14:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.QParts=function(){var t=s(o.mark((function t(e){var n,r,a,i,s,u;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,a=e.partHash,i=e.format,s=void 0===i?"blob":i,m({libraryId:n,objectId:r,versionHash:versionHash}),g(a),u=f("qparts",a),t.t0=this.utils,t.t1=s,t.t2=this.HttpClient,t.next=9,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,partHash:a});case 9:return t.t3=t.sent,t.t4=u,t.t5={headers:t.t3,method:"GET",path:t.t4},t.t6=t.t2.Request.call(t.t2,t.t5),t.abrupt("return",t.t0.ResponseToFormat.call(t.t0,t.t1,t.t6));case 14:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}()},function(t,e,n){var r=n(230),a=n(287)((function(t,e,n,a){r(t,e,n,a)}));t.exports=a},function(t,e,n){var r=n(65)(n(33),"Map");t.exports=r},function(t,e,n){var r=n(33).Symbol;t.exports=r},function(t,e,n){(function(e){function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var r="object"==(void 0===e?"undefined":n(e))&&e&&e.Object===Object&&e;t.exports=r}).call(this,n(10))},function(t,e,n){var r=n(67),a=n(49);t.exports=function(t,e,n){(void 0!==n&&!a(t[e],n)||void 0===n&&!(e in t))&&r(t,e,n)}},function(t,e,n){var r=n(65),a=function(){try{var t=r(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();t.exports=a},function(t,e,n){var r=n(272)(Object.getPrototypeOf,Object);t.exports=r},function(t,e){var n=Object.prototype;t.exports=function(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||n)}},function(t,e,n){var r=n(273),a=n(41),i=Object.prototype,o=i.hasOwnProperty,s=i.propertyIsEnumerable,u=r(function(){return arguments}())?r:function(t){return a(t)&&o.call(t,"callee")&&!s.call(t,"callee")};t.exports=u},function(t,e){var n=Array.isArray;t.exports=n},function(t,e){t.exports=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}},function(t,e,n){(function(t){function r(t){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var a=n(33),i=n(275),o="object"==r(e)&&e&&!e.nodeType&&e,s=o&&"object"==r(t)&&t&&!t.nodeType&&t,u=s&&s.exports===o?a.Buffer:void 0,c=(u?u.isBuffer:void 0)||i;t.exports=c}).call(this,n(20)(t))},function(t,e,n){var r=n(277),a=n(278),i=n(279),o=i&&i.isTypedArray,s=o?a(o):r;t.exports=s},function(t,e){t.exports=function(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}},function(t,e,n){var r=n(283),a=n(285),i=n(68);t.exports=function(t){return i(t)?r(t,!0):a(t)}},function(t,e){function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var r=/^(?:0|[1-9]\d*)$/;t.exports=function(t,e){var a=n(t);return!!(e=null==e?9007199254740991:e)&&("number"==a||"symbol"!=a&&r.test(t))&&t>-1&&t%1==0&&t<e}},function(t,e){t.exports=function(t){return t}},function(t,e,n){(function(e){var r=n(6),a=n(7);void 0===globalThis.Buffer&&(globalThis.Buffer=n(5).Buffer);var i,o=n(104),s=n(125),u=n(13);if("undefined"==typeof crypto){var c=n(306);c.getRandomValues=function(t){return c.randomBytes(t.length)},globalThis.crypto=c}switch(u.Platform()){case u.PLATFORM_REACT_NATIVE:case u.PLATFORM_WEB:i=n(173).default;break;default:i=n(!function(){var t=new Error("Cannot find module '@eluvio/crypto/dist/elv-crypto.bundle.node'");throw t.code="MODULE_NOT_FOUND",t}()).default}var f,A,l,p,d,h={ElvCrypto:(d=a(r.mark((function t(){return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(t.prev=0,h.elvCrypto){t.next=5;break}return t.next=4,(new i).init();case 4:h.elvCrypto=t.sent;case 5:return t.abrupt("return",h.elvCrypto);case 8:t.prev=8,t.t0=t.catch(0),console.error("Error initializing ElvCrypto:"),console.error(t.t0);case 12:case"end":return t.stop()}}),t,null,[[0,8]])}))),function(){return d.apply(this,arguments)}),EncryptedSize:function(t){var e=Math.floor(t/1e6)*h.EncryptedBlockSize(1e6);return t%1e6!=0&&(e+=h.EncryptedBlockSize(t%1e6)),e},EncryptedBlockSize:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=129,r=608,a=48,i=12*(a-1),o=12*a,s=Math.floor(t/i)*o;return t%i!=0&&(s+=o),e?s+r:s+n},EncryptConk:function(t,n){return a(r.mark((function a(){var i,o,s,c,f,A;return r.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,h.ElvCrypto();case 2:return i=r.sent,n=new Uint8Array(e.from(n.replace("0x",""),"hex")),t=new Uint8Array(e.from(JSON.stringify(t))),r.next=7,i.encryptECIES(t,n);case 7:return o=r.sent,s=o.data,c=o.ephemeralKey,f=o.tag,A=e.concat([e.from(c),e.from(f),e.from(s)]),r.abrupt("return",u.B64(A));case 13:case"end":return r.stop()}}),a)})))()},DecryptCap:function(t,n){return a(r.mark((function a(){var i,o,s,u,c;return r.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,h.ElvCrypto();case 2:return i=r.sent,n=new Uint8Array(e.from(n.replace("0x",""),"hex")),t=e.from(t,"base64"),o=t.slice(0,65),s=t.slice(65,81),u=t.slice(81),c=i.decryptECIES(new Uint8Array(u),n,new Uint8Array(o),new Uint8Array(s)),r.abrupt("return",JSON.parse(e.from(c).toString()));case 10:case"end":return r.stop()}}),a)})))()},GeneratePrimaryConk:function(t){return a(r.mark((function n(){var a,i,s,u,c,f,A;return r.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return a=t.spaceId,i=t.objectId,n.next=3,h.ElvCrypto();case 3:return s=n.sent,u=s.generatePrimaryKeys(),c=u.secretKey,f=u.publicKey,A=s.generateSymmetricKey().key,n.abrupt("return",{symm_key:"kpsy".concat(o.encode(e.from(A))),secret_key:"kpsk".concat(o.encode(e.from(c))),public_key:"kppk".concat(o.encode(e.from(f))),sid:a,qid:i});case 7:case"end":return n.stop()}}),n)})))()},GenerateTargetConk:function(){return a(r.mark((function t(){var n,a,i,s;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,h.ElvCrypto();case 2:return n=t.sent,a=n.generateTargetKeys(),i=a.secretKey,s=a.publicKey,t.abrupt("return",{secret_key:"kpsk".concat(o.encode(e.from(i))),public_key:"ktpk".concat(o.encode(e.from(s)))});case 5:case"end":return t.stop()}}),t)})))()},CapToConk:function(t){var e=function(t){return new Uint8Array(o.decode(t.slice(4)))};return{symmetricKey:e(t.symm_key),secretKey:e(t.secret_key),publicKey:e(t.public_key)}},EncryptionContext:function(t){return a(r.mark((function e(){var n,a,i,o,s,u,c;return r.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,h.ElvCrypto();case 2:return n=e.sent,a=h.CapToConk(t),i=a.symmetricKey,o=a.secretKey,(s=a.publicKey).length===n.PRIMARY_PK_KEY_SIZE?(c=n.CRYPTO_TYPE_PRIMARY,u=n.newPrimaryContext(s,o,i)):(c=n.CRYPTO_TYPE_TARGET,u=n.newTargetDecryptionContext(o,i)),e.abrupt("return",{context:u,type:c});case 6:case"end":return e.stop()}}),e)})))()},Encrypt:(p=a(r.mark((function t(n,a){var i,o,s,u,c;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,h.OpenEncryptionStream(n);case 2:if(i=t.sent,e.isBuffer(a)||a instanceof ArrayBuffer){t.next=9;break}return t.t0=e,t.next=7,new Response(a).arrayBuffer();case 7:t.t1=t.sent,a=t.t0.from.call(t.t0,t.t1);case 9:for(o=new Uint8Array(a),s=0;s<o.length;s+=1e6)u=Math.min(o.length,s+1e6),i.write(o.slice(s,u));return i.end(),c=[],t.next=15,new Promise((function(t,e){i.on("data",(function(t){c.push(t)})).on("finish",(function(){t()})).on("error",(function(t){e(t)}))}));case 15:return t.abrupt("return",e.concat(c));case 16:case"end":return t.stop()}}),t)}))),function(t,e){return p.apply(this,arguments)}),OpenEncryptionStream:(l=a(r.mark((function t(e){var n,a,i,o,u;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,h.ElvCrypto();case 2:return n=t.sent,t.next=5,h.EncryptionContext(e);case 5:return a=t.sent,i=a.context,o=new s.PassThrough,u=n.createCipher(i),t.abrupt("return",o.pipe(u).on("finish",(function(){i.free()})).on("error",(function(t){throw Error(t)})));case 10:case"end":return t.stop()}}),t)}))),function(t){return l.apply(this,arguments)}),Decrypt:(A=a(r.mark((function t(n,a){var i,o,s,u,c;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,h.OpenDecryptionStream(n);case 2:for(i=t.sent,o=new Uint8Array(a),s=0;s<o.length;s+=1e6)u=Math.min(o.length,s+1e6),i.write(o.slice(s,u));return i.end(),c=[],t.next=9,new Promise((function(t,e){i.on("data",(function(t){c.push(t)})).on("finish",(function(){t()})).on("error",(function(t){e(t)}))}));case 9:return t.abrupt("return",e.concat(c));case 10:case"end":return t.stop()}}),t)}))),function(t,e){return A.apply(this,arguments)}),OpenDecryptionStream:(f=a(r.mark((function t(e){var n,a,i,o,u,c;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,h.ElvCrypto();case 2:return n=t.sent,t.next=5,h.EncryptionContext(e);case 5:return a=t.sent,i=a.context,o=a.type,u=new s.PassThrough,c=n.createDecipher(o,i),t.abrupt("return",u.pipe(c).on("finish",(function(){i.free()})).on("error",(function(t){throw Error(t)})));case 11:case"end":return t.stop()}}),t)}))),function(t){return f.apply(this,arguments)})};t.exports=h}).call(this,n(5).Buffer)},function(t,e,n){t.exports=a;var r=n(42).EventEmitter;function a(){r.call(this)}n(3)(a,r),a.Readable=n(69),a.Writable=n(302),a.Duplex=n(303),a.Transform=n(304),a.PassThrough=n(305),a.Stream=a,a.prototype.pipe=function(t,e){var n=this;function a(e){t.writable&&!1===t.write(e)&&n.pause&&n.pause()}function i(){n.readable&&n.resume&&n.resume()}n.on("data",a),t.on("drain",i),t._isStdio||e&&!1===e.end||(n.on("end",s),n.on("close",u));var o=!1;function s(){o||(o=!0,t.end())}function u(){o||(o=!0,"function"==typeof t.destroy&&t.destroy())}function c(t){if(f(),0===r.listenerCount(this,"error"))throw t}function f(){n.removeListener("data",a),t.removeListener("drain",i),n.removeListener("end",s),n.removeListener("close",u),n.removeListener("error",c),t.removeListener("error",c),n.removeListener("end",f),n.removeListener("close",f),t.removeListener("close",f)}return n.on("error",c),t.on("error",c),n.on("end",f),n.on("close",f),t.on("close",f),t.emit("pipe",n),t}},function(t,e,n){"use strict";(function(e,r){var a=n(53);t.exports=m;var i,o=n(296);m.ReadableState=b;n(42).EventEmitter;var s=function(t,e){return t.listeners(e).length},u=n(127),c=n(70).Buffer,f=e.Uint8Array||function(){};var A=Object.create(n(43));A.inherits=n(3);var l=n(297),p=void 0;p=l&&l.debuglog?l.debuglog("stream"):function(){};var d,h=n(298),y=n(128);A.inherits(m,u);var g=["error","close","destroy","pause","resume"];function b(t,e){t=t||{};var r=e instanceof(i=i||n(28));this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.readableObjectMode);var a=t.highWaterMark,o=t.readableHighWaterMark,s=this.objectMode?16:16384;this.highWaterMark=a||0===a?a:r&&(o||0===o)?o:s,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new h,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(d||(d=n(44).StringDecoder),this.decoder=new d(t.encoding),this.encoding=t.encoding)}function m(t){if(i=i||n(28),!(this instanceof m))return new m(t);this._readableState=new b(t,this),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),u.call(this)}function v(t,e,n,r,a){var i,o=t._readableState;null===e?(o.reading=!1,function(t,e){if(e.ended)return;if(e.decoder){var n=e.decoder.end();n&&n.length&&(e.buffer.push(n),e.length+=e.objectMode?1:n.length)}e.ended=!0,C(t)}(t,o)):(a||(i=function(t,e){var n;r=e,c.isBuffer(r)||r instanceof f||"string"==typeof e||void 0===e||t.objectMode||(n=new TypeError("Invalid non-string/buffer chunk"));var r;return n}(o,e)),i?t.emit("error",i):o.objectMode||e&&e.length>0?("string"==typeof e||o.objectMode||Object.getPrototypeOf(e)===c.prototype||(e=function(t){return c.from(t)}(e)),r?o.endEmitted?t.emit("error",new Error("stream.unshift() after end event")):I(t,o,e,!0):o.ended?t.emit("error",new Error("stream.push() after EOF")):(o.reading=!1,o.decoder&&!n?(e=o.decoder.write(e),o.objectMode||0!==e.length?I(t,o,e,!1):B(t,o)):I(t,o,e,!1))):r||(o.reading=!1));return function(t){return!t.ended&&(t.needReadable||t.length<t.highWaterMark||0===t.length)}(o)}function I(t,e,n,r){e.flowing&&0===e.length&&!e.sync?(t.emit("data",n),t.read(0)):(e.length+=e.objectMode?1:n.length,r?e.buffer.unshift(n):e.buffer.push(n),e.needReadable&&C(t)),B(t,e)}Object.defineProperty(m.prototype,"destroyed",{get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(t){this._readableState&&(this._readableState.destroyed=t)}}),m.prototype.destroy=y.destroy,m.prototype._undestroy=y.undestroy,m.prototype._destroy=function(t,e){this.push(null),e(t)},m.prototype.push=function(t,e){var n,r=this._readableState;return r.objectMode?n=!0:"string"==typeof t&&((e=e||r.defaultEncoding)!==r.encoding&&(t=c.from(t,e),e=""),n=!0),v(this,t,e,!1,n)},m.prototype.unshift=function(t){return v(this,t,null,!0,!1)},m.prototype.isPaused=function(){return!1===this._readableState.flowing},m.prototype.setEncoding=function(t){return d||(d=n(44).StringDecoder),this._readableState.decoder=new d(t),this._readableState.encoding=t,this};function w(t,e){return t<=0||0===e.length&&e.ended?0:e.objectMode?1:t!=t?e.flowing&&e.length?e.buffer.head.data.length:e.length:(t>e.highWaterMark&&(e.highWaterMark=function(t){return t>=8388608?t=8388608:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function C(t){var e=t._readableState;e.needReadable=!1,e.emittedReadable||(p("emitReadable",e.flowing),e.emittedReadable=!0,e.sync?a.nextTick(E,t):E(t))}function E(t){p("emit readable"),t.emit("readable"),S(t)}function B(t,e){e.readingMore||(e.readingMore=!0,a.nextTick(k,t,e))}function k(t,e){for(var n=e.length;!e.reading&&!e.flowing&&!e.ended&&e.length<e.highWaterMark&&(p("maybeReadMore read 0"),t.read(0),n!==e.length);)n=e.length;e.readingMore=!1}function Q(t){p("readable nexttick read 0"),t.read(0)}function x(t,e){e.reading||(p("resume read 0"),t.read(0)),e.resumeScheduled=!1,e.awaitDrain=0,t.emit("resume"),S(t),e.flowing&&!e.reading&&t.read(0)}function S(t){var e=t._readableState;for(p("flow",e.flowing);e.flowing&&null!==t.read(););}function _(t,e){return 0===e.length?null:(e.objectMode?n=e.buffer.shift():!t||t>=e.length?(n=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.head.data:e.buffer.concat(e.length),e.buffer.clear()):n=function(t,e,n){var r;t<e.head.data.length?(r=e.head.data.slice(0,t),e.head.data=e.head.data.slice(t)):r=t===e.head.data.length?e.shift():n?function(t,e){var n=e.head,r=1,a=n.data;t-=a.length;for(;n=n.next;){var i=n.data,o=t>i.length?i.length:t;if(o===i.length?a+=i:a+=i.slice(0,t),0===(t-=o)){o===i.length?(++r,n.next?e.head=n.next:e.head=e.tail=null):(e.head=n,n.data=i.slice(o));break}++r}return e.length-=r,a}(t,e):function(t,e){var n=c.allocUnsafe(t),r=e.head,a=1;r.data.copy(n),t-=r.data.length;for(;r=r.next;){var i=r.data,o=t>i.length?i.length:t;if(i.copy(n,n.length-t,0,o),0===(t-=o)){o===i.length?(++a,r.next?e.head=r.next:e.head=e.tail=null):(e.head=r,r.data=i.slice(o));break}++a}return e.length-=a,n}(t,e);return r}(t,e.buffer,e.decoder),n);var n}function M(t){var e=t._readableState;if(e.length>0)throw new Error('"endReadable()" called on non-empty stream');e.endEmitted||(e.ended=!0,a.nextTick(D,e,t))}function D(t,e){t.endEmitted||0!==t.length||(t.endEmitted=!0,e.readable=!1,e.emit("end"))}function R(t,e){for(var n=0,r=t.length;n<r;n++)if(t[n]===e)return n;return-1}m.prototype.read=function(t){p("read",t),t=parseInt(t,10);var e=this._readableState,n=t;if(0!==t&&(e.emittedReadable=!1),0===t&&e.needReadable&&(e.length>=e.highWaterMark||e.ended))return p("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?M(this):C(this),null;if(0===(t=w(t,e))&&e.ended)return 0===e.length&&M(this),null;var r,a=e.needReadable;return p("need readable",a),(0===e.length||e.length-t<e.highWaterMark)&&p("length less than watermark",a=!0),e.ended||e.reading?p("reading or ended",a=!1):a&&(p("do read"),e.reading=!0,e.sync=!0,0===e.length&&(e.needReadable=!0),this._read(e.highWaterMark),e.sync=!1,e.reading||(t=w(n,e))),null===(r=t>0?_(t,e):null)?(e.needReadable=!0,t=0):e.length-=t,0===e.length&&(e.ended||(e.needReadable=!0),n!==t&&e.ended&&M(this)),null!==r&&this.emit("data",r),r},m.prototype._read=function(t){this.emit("error",new Error("_read() is not implemented"))},m.prototype.pipe=function(t,e){var n=this,i=this._readableState;switch(i.pipesCount){case 0:i.pipes=t;break;case 1:i.pipes=[i.pipes,t];break;default:i.pipes.push(t)}i.pipesCount+=1,p("pipe count=%d opts=%j",i.pipesCount,e);var u=(!e||!1!==e.end)&&t!==r.stdout&&t!==r.stderr?f:m;function c(e,r){p("onunpipe"),e===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,p("cleanup"),t.removeListener("close",g),t.removeListener("finish",b),t.removeListener("drain",A),t.removeListener("error",y),t.removeListener("unpipe",c),n.removeListener("end",f),n.removeListener("end",m),n.removeListener("data",h),l=!0,!i.awaitDrain||t._writableState&&!t._writableState.needDrain||A())}function f(){p("onend"),t.end()}i.endEmitted?a.nextTick(u):n.once("end",u),t.on("unpipe",c);var A=function(t){return function(){var e=t._readableState;p("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&s(t,"data")&&(e.flowing=!0,S(t))}}(n);t.on("drain",A);var l=!1;var d=!1;function h(e){p("ondata"),d=!1,!1!==t.write(e)||d||((1===i.pipesCount&&i.pipes===t||i.pipesCount>1&&-1!==R(i.pipes,t))&&!l&&(p("false write response, pause",n._readableState.awaitDrain),n._readableState.awaitDrain++,d=!0),n.pause())}function y(e){p("onerror",e),m(),t.removeListener("error",y),0===s(t,"error")&&t.emit("error",e)}function g(){t.removeListener("finish",b),m()}function b(){p("onfinish"),t.removeListener("close",g),m()}function m(){p("unpipe"),n.unpipe(t)}return n.on("data",h),function(t,e,n){if("function"==typeof t.prependListener)return t.prependListener(e,n);t._events&&t._events[e]?o(t._events[e])?t._events[e].unshift(n):t._events[e]=[n,t._events[e]]:t.on(e,n)}(t,"error",y),t.once("close",g),t.once("finish",b),t.emit("pipe",n),i.flowing||(p("pipe resume"),n.resume()),t},m.prototype.unpipe=function(t){var e=this._readableState,n={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,n)),this;if(!t){var r=e.pipes,a=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var i=0;i<a;i++)r[i].emit("unpipe",this,n);return this}var o=R(e.pipes,t);return-1===o||(e.pipes.splice(o,1),e.pipesCount-=1,1===e.pipesCount&&(e.pipes=e.pipes[0]),t.emit("unpipe",this,n)),this},m.prototype.on=function(t,e){var n=u.prototype.on.call(this,t,e);if("data"===t)!1!==this._readableState.flowing&&this.resume();else if("readable"===t){var r=this._readableState;r.endEmitted||r.readableListening||(r.readableListening=r.needReadable=!0,r.emittedReadable=!1,r.reading?r.length&&C(this):a.nextTick(Q,this))}return n},m.prototype.addListener=m.prototype.on,m.prototype.resume=function(){var t=this._readableState;return t.flowing||(p("resume"),t.flowing=!0,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,a.nextTick(x,t,e))}(this,t)),this},m.prototype.pause=function(){return p("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(p("pause"),this._readableState.flowing=!1,this.emit("pause")),this},m.prototype.wrap=function(t){var e=this,n=this._readableState,r=!1;for(var a in t.on("end",(function(){if(p("wrapped end"),n.decoder&&!n.ended){var t=n.decoder.end();t&&t.length&&e.push(t)}e.push(null)})),t.on("data",(function(a){(p("wrapped data"),n.decoder&&(a=n.decoder.write(a)),n.objectMode&&null==a)||(n.objectMode||a&&a.length)&&(e.push(a)||(r=!0,t.pause()))})),t)void 0===this[a]&&"function"==typeof t[a]&&(this[a]=function(e){return function(){return t[e].apply(t,arguments)}}(a));for(var i=0;i<g.length;i++)t.on(g[i],this.emit.bind(this,g[i]));return this._read=function(e){p("wrapped _read",e),r&&(r=!1,t.resume())},this},Object.defineProperty(m.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),m._fromList=_}).call(this,n(10),n(12))},function(t,e,n){t.exports=n(42).EventEmitter},function(t,e,n){"use strict";var r=n(53);function a(t,e){t.emit("error",e)}t.exports={destroy:function(t,e){var n=this,i=this._readableState&&this._readableState.destroyed,o=this._writableState&&this._writableState.destroyed;return i||o?(e?e(t):!t||this._writableState&&this._writableState.errorEmitted||r.nextTick(a,this,t),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,(function(t){!e&&t?(r.nextTick(a,n,t),n._writableState&&(n._writableState.errorEmitted=!0)):e&&e(t)})),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}}},function(t,e,n){(function(e){function n(t){try{if(!e.localStorage)return!1}catch(t){return!1}var n=e.localStorage[t];return null!=n&&"true"===String(n).toLowerCase()}t.exports=function(t,e){if(n("noDeprecation"))return t;var r=!1;return function(){if(!r){if(n("throwDeprecation"))throw new Error(e);n("traceDeprecation")?console.trace(e):console.warn(e),r=!0}return t.apply(this,arguments)}}}).call(this,n(10))},function(t,e,n){"use strict";t.exports=o;var r=n(28),a=Object.create(n(43));function i(t,e){var n=this._transformState;n.transforming=!1;var r=n.writecb;if(!r)return this.emit("error",new Error("write callback called multiple times"));n.writechunk=null,n.writecb=null,null!=e&&this.push(e),r(t);var a=this._readableState;a.reading=!1,(a.needReadable||a.length<a.highWaterMark)&&this._read(a.highWaterMark)}function o(t){if(!(this instanceof o))return new o(t);r.call(this,t),this._transformState={afterTransform:i.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,t&&("function"==typeof t.transform&&(this._transform=t.transform),"function"==typeof t.flush&&(this._flush=t.flush)),this.on("prefinish",s)}function s(){var t=this;"function"==typeof this._flush?this._flush((function(e,n){u(t,e,n)})):u(this,null,null)}function u(t,e,n){if(e)return t.emit("error",e);if(null!=n&&t.push(n),t._writableState.length)throw new Error("Calling transform done when ws.length != 0");if(t._transformState.transforming)throw new Error("Calling transform done when still transforming");return t.push(null)}a.inherits=n(3),a.inherits(o,r),o.prototype.push=function(t,e){return this._transformState.needTransform=!1,r.prototype.push.call(this,t,e)},o.prototype._transform=function(t,e,n){throw new Error("_transform() is not implemented")},o.prototype._write=function(t,e,n){var r=this._transformState;if(r.writecb=n,r.writechunk=t,r.writeencoding=e,!r.transforming){var a=this._readableState;(r.needTransform||a.needReadable||a.length<a.highWaterMark)&&this._read(a.highWaterMark)}},o.prototype._read=function(t){var e=this._transformState;null!==e.writechunk&&e.writecb&&!e.transforming?(e.transforming=!0,this._transform(e.writechunk,e.writeencoding,e.afterTransform)):e.needTransform=!0},o.prototype._destroy=function(t,e){var n=this;r.prototype._destroy.call(this,t,(function(t){e(t),n.emit("close")}))}},function(t,e,n){"use strict";var r=n(4).Buffer,a=n(73).Transform;function i(t){a.call(this),this._block=r.allocUnsafe(t),this._blockSize=t,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}n(3)(i,a),i.prototype._transform=function(t,e,n){var r=null;try{this.update(t,e)}catch(t){r=t}n(r)},i.prototype._flush=function(t){var e=null;try{this.push(this.digest())}catch(t){e=t}t(e)},i.prototype.update=function(t,e){if(function(t,e){if(!r.isBuffer(t)&&"string"!=typeof t)throw new TypeError(e+" must be a string or a buffer")}(t,"Data"),this._finalized)throw new Error("Digest already called");r.isBuffer(t)||(t=r.from(t,e));for(var n=this._block,a=0;this._blockOffset+t.length-a>=this._blockSize;){for(var i=this._blockOffset;i<this._blockSize;)n[i++]=t[a++];this._update(),this._blockOffset=0}for(;a<t.length;)n[this._blockOffset++]=t[a++];for(var o=0,s=8*t.length;s>0;++o)this._length[o]+=s,(s=this._length[o]/4294967296|0)>0&&(this._length[o]-=4294967296*s);return this},i.prototype._update=function(){throw new Error("_update is not implemented")},i.prototype.digest=function(t){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var e=this._digest();void 0!==t&&(e=e.toString(t)),this._block.fill(0),this._blockOffset=0;for(var n=0;n<4;++n)this._length[n]=0;return e},i.prototype._digest=function(){throw new Error("_digest is not implemented")},t.exports=i},function(t,e,n){"use strict";(function(e,r){var a;t.exports=B,B.ReadableState=E;n(42).EventEmitter;var i=function(t,e){return t.listeners(e).length},o=n(133),s=n(5).Buffer,u=e.Uint8Array||function(){};var c,f=n(307);c=f&&f.debuglog?f.debuglog("stream"):function(){};var A,l,p,d=n(308),h=n(134),y=n(135).getHighWaterMark,g=n(35).codes,b=g.ERR_INVALID_ARG_TYPE,m=g.ERR_STREAM_PUSH_AFTER_EOF,v=g.ERR_METHOD_NOT_IMPLEMENTED,I=g.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;n(3)(B,o);var w=h.errorOrDestroy,C=["error","close","destroy","pause","resume"];function E(t,e,r){a=a||n(36),t=t||{},"boolean"!=typeof r&&(r=e instanceof a),this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=y(this,t,"readableHighWaterMark",r),this.buffer=new d,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(A||(A=n(44).StringDecoder),this.decoder=new A(t.encoding),this.encoding=t.encoding)}function B(t){if(a=a||n(36),!(this instanceof B))return new B(t);var e=this instanceof a;this._readableState=new E(t,this,e),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),o.call(this)}function k(t,e,n,r,a){c("readableAddChunk",e);var i,o=t._readableState;if(null===e)o.reading=!1,function(t,e){if(c("onEofChunk"),e.ended)return;if(e.decoder){var n=e.decoder.end();n&&n.length&&(e.buffer.push(n),e.length+=e.objectMode?1:n.length)}e.ended=!0,e.sync?S(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,_(t)))}(t,o);else if(a||(i=function(t,e){var n;r=e,s.isBuffer(r)||r instanceof u||"string"==typeof e||void 0===e||t.objectMode||(n=new b("chunk",["string","Buffer","Uint8Array"],e));var r;return n}(o,e)),i)w(t,i);else if(o.objectMode||e&&e.length>0)if("string"==typeof e||o.objectMode||Object.getPrototypeOf(e)===s.prototype||(e=function(t){return s.from(t)}(e)),r)o.endEmitted?w(t,new I):Q(t,o,e,!0);else if(o.ended)w(t,new m);else{if(o.destroyed)return!1;o.reading=!1,o.decoder&&!n?(e=o.decoder.write(e),o.objectMode||0!==e.length?Q(t,o,e,!1):M(t,o)):Q(t,o,e,!1)}else r||(o.reading=!1,M(t,o));return!o.ended&&(o.length<o.highWaterMark||0===o.length)}function Q(t,e,n,r){e.flowing&&0===e.length&&!e.sync?(e.awaitDrain=0,t.emit("data",n)):(e.length+=e.objectMode?1:n.length,r?e.buffer.unshift(n):e.buffer.push(n),e.needReadable&&S(t)),M(t,e)}Object.defineProperty(B.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(t){this._readableState&&(this._readableState.destroyed=t)}}),B.prototype.destroy=h.destroy,B.prototype._undestroy=h.undestroy,B.prototype._destroy=function(t,e){e(t)},B.prototype.push=function(t,e){var n,r=this._readableState;return r.objectMode?n=!0:"string"==typeof t&&((e=e||r.defaultEncoding)!==r.encoding&&(t=s.from(t,e),e=""),n=!0),k(this,t,e,!1,n)},B.prototype.unshift=function(t){return k(this,t,null,!0,!1)},B.prototype.isPaused=function(){return!1===this._readableState.flowing},B.prototype.setEncoding=function(t){A||(A=n(44).StringDecoder);var e=new A(t);this._readableState.decoder=e,this._readableState.encoding=this._readableState.decoder.encoding;for(var r=this._readableState.buffer.head,a="";null!==r;)a+=e.write(r.data),r=r.next;return this._readableState.buffer.clear(),""!==a&&this._readableState.buffer.push(a),this._readableState.length=a.length,this};function x(t,e){return t<=0||0===e.length&&e.ended?0:e.objectMode?1:t!=t?e.flowing&&e.length?e.buffer.head.data.length:e.length:(t>e.highWaterMark&&(e.highWaterMark=function(t){return t>=1073741824?t=1073741824:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function S(t){var e=t._readableState;c("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(c("emitReadable",e.flowing),e.emittedReadable=!0,r.nextTick(_,t))}function _(t){var e=t._readableState;c("emitReadable_",e.destroyed,e.length,e.ended),e.destroyed||!e.length&&!e.ended||(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,T(t)}function M(t,e){e.readingMore||(e.readingMore=!0,r.nextTick(D,t,e))}function D(t,e){for(;!e.reading&&!e.ended&&(e.length<e.highWaterMark||e.flowing&&0===e.length);){var n=e.length;if(c("maybeReadMore read 0"),t.read(0),n===e.length)break}e.readingMore=!1}function R(t){var e=t._readableState;e.readableListening=t.listenerCount("readable")>0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount("data")>0&&t.resume()}function O(t){c("readable nexttick read 0"),t.read(0)}function j(t,e){c("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),T(t),e.flowing&&!e.reading&&t.read(0)}function T(t){var e=t._readableState;for(c("flow",e.flowing);e.flowing&&null!==t.read(););}function N(t,e){return 0===e.length?null:(e.objectMode?n=e.buffer.shift():!t||t>=e.length?(n=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):n=e.buffer.consume(t,e.decoder),n);var n}function P(t){var e=t._readableState;c("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,r.nextTick(L,e,t))}function L(t,e){if(c("endReadableNT",t.endEmitted,t.length),!t.endEmitted&&0===t.length&&(t.endEmitted=!0,e.readable=!1,e.emit("end"),t.autoDestroy)){var n=e._writableState;(!n||n.autoDestroy&&n.finished)&&e.destroy()}}function F(t,e){for(var n=0,r=t.length;n<r;n++)if(t[n]===e)return n;return-1}B.prototype.read=function(t){c("read",t),t=parseInt(t,10);var e=this._readableState,n=t;if(0!==t&&(e.emittedReadable=!1),0===t&&e.needReadable&&((0!==e.highWaterMark?e.length>=e.highWaterMark:e.length>0)||e.ended))return c("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?P(this):S(this),null;if(0===(t=x(t,e))&&e.ended)return 0===e.length&&P(this),null;var r,a=e.needReadable;return c("need readable",a),(0===e.length||e.length-t<e.highWaterMark)&&c("length less than watermark",a=!0),e.ended||e.reading?c("reading or ended",a=!1):a&&(c("do read"),e.reading=!0,e.sync=!0,0===e.length&&(e.needReadable=!0),this._read(e.highWaterMark),e.sync=!1,e.reading||(t=x(n,e))),null===(r=t>0?N(t,e):null)?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),0===e.length&&(e.ended||(e.needReadable=!0),n!==t&&e.ended&&P(this)),null!==r&&this.emit("data",r),r},B.prototype._read=function(t){w(this,new v("_read()"))},B.prototype.pipe=function(t,e){var n=this,a=this._readableState;switch(a.pipesCount){case 0:a.pipes=t;break;case 1:a.pipes=[a.pipes,t];break;default:a.pipes.push(t)}a.pipesCount+=1,c("pipe count=%d opts=%j",a.pipesCount,e);var o=(!e||!1!==e.end)&&t!==r.stdout&&t!==r.stderr?u:y;function s(e,r){c("onunpipe"),e===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,c("cleanup"),t.removeListener("close",d),t.removeListener("finish",h),t.removeListener("drain",f),t.removeListener("error",p),t.removeListener("unpipe",s),n.removeListener("end",u),n.removeListener("end",y),n.removeListener("data",l),A=!0,!a.awaitDrain||t._writableState&&!t._writableState.needDrain||f())}function u(){c("onend"),t.end()}a.endEmitted?r.nextTick(o):n.once("end",o),t.on("unpipe",s);var f=function(t){return function(){var e=t._readableState;c("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&i(t,"data")&&(e.flowing=!0,T(t))}}(n);t.on("drain",f);var A=!1;function l(e){c("ondata");var r=t.write(e);c("dest.write",r),!1===r&&((1===a.pipesCount&&a.pipes===t||a.pipesCount>1&&-1!==F(a.pipes,t))&&!A&&(c("false write response, pause",a.awaitDrain),a.awaitDrain++),n.pause())}function p(e){c("onerror",e),y(),t.removeListener("error",p),0===i(t,"error")&&w(t,e)}function d(){t.removeListener("finish",h),y()}function h(){c("onfinish"),t.removeListener("close",d),y()}function y(){c("unpipe"),n.unpipe(t)}return n.on("data",l),function(t,e,n){if("function"==typeof t.prependListener)return t.prependListener(e,n);t._events&&t._events[e]?Array.isArray(t._events[e])?t._events[e].unshift(n):t._events[e]=[n,t._events[e]]:t.on(e,n)}(t,"error",p),t.once("close",d),t.once("finish",h),t.emit("pipe",n),a.flowing||(c("pipe resume"),n.resume()),t},B.prototype.unpipe=function(t){var e=this._readableState,n={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,n)),this;if(!t){var r=e.pipes,a=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var i=0;i<a;i++)r[i].emit("unpipe",this,{hasUnpiped:!1});return this}var o=F(e.pipes,t);return-1===o||(e.pipes.splice(o,1),e.pipesCount-=1,1===e.pipesCount&&(e.pipes=e.pipes[0]),t.emit("unpipe",this,n)),this},B.prototype.on=function(t,e){var n=o.prototype.on.call(this,t,e),a=this._readableState;return"data"===t?(a.readableListening=this.listenerCount("readable")>0,!1!==a.flowing&&this.resume()):"readable"===t&&(a.endEmitted||a.readableListening||(a.readableListening=a.needReadable=!0,a.flowing=!1,a.emittedReadable=!1,c("on readable",a.length,a.reading),a.length?S(this):a.reading||r.nextTick(O,this))),n},B.prototype.addListener=B.prototype.on,B.prototype.removeListener=function(t,e){var n=o.prototype.removeListener.call(this,t,e);return"readable"===t&&r.nextTick(R,this),n},B.prototype.removeAllListeners=function(t){var e=o.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||r.nextTick(R,this),e},B.prototype.resume=function(){var t=this._readableState;return t.flowing||(c("resume"),t.flowing=!t.readableListening,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,r.nextTick(j,t,e))}(this,t)),t.paused=!1,this},B.prototype.pause=function(){return c("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(c("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},B.prototype.wrap=function(t){var e=this,n=this._readableState,r=!1;for(var a in t.on("end",(function(){if(c("wrapped end"),n.decoder&&!n.ended){var t=n.decoder.end();t&&t.length&&e.push(t)}e.push(null)})),t.on("data",(function(a){(c("wrapped data"),n.decoder&&(a=n.decoder.write(a)),n.objectMode&&null==a)||(n.objectMode||a&&a.length)&&(e.push(a)||(r=!0,t.pause()))})),t)void 0===this[a]&&"function"==typeof t[a]&&(this[a]=function(e){return function(){return t[e].apply(t,arguments)}}(a));for(var i=0;i<C.length;i++)t.on(C[i],this.emit.bind(this,C[i]));return this._read=function(e){c("wrapped _read",e),r&&(r=!1,t.resume())},this},"function"==typeof Symbol&&(B.prototype[Symbol.asyncIterator]=function(){return void 0===l&&(l=n(310)),l(this)}),Object.defineProperty(B.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(B.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(B.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(t){this._readableState&&(this._readableState.flowing=t)}}),B._fromList=N,Object.defineProperty(B.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),"function"==typeof Symbol&&(B.from=function(t,e){return void 0===p&&(p=n(311)),p(B,t,e)})}).call(this,n(10),n(12))},function(t,e,n){t.exports=n(42).EventEmitter},function(t,e,n){"use strict";(function(e){function n(t,e){a(t,e),r(t)}function r(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit("close")}function a(t,e){t.emit("error",e)}t.exports={destroy:function(t,i){var o=this,s=this._readableState&&this._readableState.destroyed,u=this._writableState&&this._writableState.destroyed;return s||u?(i?i(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,e.nextTick(a,this,t)):e.nextTick(a,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,(function(t){!i&&t?o._writableState?o._writableState.errorEmitted?e.nextTick(r,o):(o._writableState.errorEmitted=!0,e.nextTick(n,o,t)):e.nextTick(n,o,t):i?(e.nextTick(r,o),i(t)):e.nextTick(r,o)})),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)},errorOrDestroy:function(t,e){var n=t._readableState,r=t._writableState;n&&n.autoDestroy||r&&r.autoDestroy?t.destroy(e):t.emit("error",e)}}}).call(this,n(12))},function(t,e,n){"use strict";var r=n(35).codes.ERR_INVALID_OPT_VALUE;t.exports={getHighWaterMark:function(t,e,n,a){var i=function(t,e,n){return null!=t.highWaterMark?t.highWaterMark:e?t[n]:null}(e,a,n);if(null!=i){if(!isFinite(i)||Math.floor(i)!==i||i<0)throw new r(a?n:"highWaterMark",i);return Math.floor(i)}return t.objectMode?16:16384}}},function(t,e,n){"use strict";(function(e,r){function a(t){var e=this;this.next=null,this.entry=null,this.finish=function(){!function(t,e,n){var r=t.entry;t.entry=null;for(;r;){var a=r.callback;e.pendingcb--,a(n),r=r.next}e.corkedRequestsFree.next=t}(e,t)}}var i;t.exports=B,B.WritableState=E;var o={deprecate:n(129)},s=n(133),u=n(5).Buffer,c=e.Uint8Array||function(){};var f,A=n(134),l=n(135).getHighWaterMark,p=n(35).codes,d=p.ERR_INVALID_ARG_TYPE,h=p.ERR_METHOD_NOT_IMPLEMENTED,y=p.ERR_MULTIPLE_CALLBACK,g=p.ERR_STREAM_CANNOT_PIPE,b=p.ERR_STREAM_DESTROYED,m=p.ERR_STREAM_NULL_VALUES,v=p.ERR_STREAM_WRITE_AFTER_END,I=p.ERR_UNKNOWN_ENCODING,w=A.errorOrDestroy;function C(){}function E(t,e,o){i=i||n(36),t=t||{},"boolean"!=typeof o&&(o=e instanceof i),this.objectMode=!!t.objectMode,o&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=l(this,t,"writableHighWaterMark",o),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var s=!1===t.decodeStrings;this.decodeStrings=!s,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var n=t._writableState,a=n.sync,i=n.writecb;if("function"!=typeof i)throw new y;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(n),e)!function(t,e,n,a,i){--e.pendingcb,n?(r.nextTick(i,a),r.nextTick(M,t,e),t._writableState.errorEmitted=!0,w(t,a)):(i(a),t._writableState.errorEmitted=!0,w(t,a),M(t,e))}(t,n,a,e,i);else{var o=S(n)||t.destroyed;o||n.corked||n.bufferProcessing||!n.bufferedRequest||x(t,n),a?r.nextTick(Q,t,n,o,i):Q(t,n,o,i)}}(e,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new a(this)}function B(t){var e=this instanceof(i=i||n(36));if(!e&&!f.call(B,this))return new B(t);this._writableState=new E(t,this,e),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),s.call(this)}function k(t,e,n,r,a,i,o){e.writelen=r,e.writecb=o,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new b("write")):n?t._writev(a,e.onwrite):t._write(a,i,e.onwrite),e.sync=!1}function Q(t,e,n,r){n||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}(t,e),e.pendingcb--,r(),M(t,e)}function x(t,e){e.bufferProcessing=!0;var n=e.bufferedRequest;if(t._writev&&n&&n.next){var r=e.bufferedRequestCount,i=new Array(r),o=e.corkedRequestsFree;o.entry=n;for(var s=0,u=!0;n;)i[s]=n,n.isBuf||(u=!1),n=n.next,s+=1;i.allBuffers=u,k(t,e,!0,e.length,i,"",o.finish),e.pendingcb++,e.lastBufferedRequest=null,o.next?(e.corkedRequestsFree=o.next,o.next=null):e.corkedRequestsFree=new a(e),e.bufferedRequestCount=0}else{for(;n;){var c=n.chunk,f=n.encoding,A=n.callback;if(k(t,e,!1,e.objectMode?1:c.length,c,f,A),n=n.next,e.bufferedRequestCount--,e.writing)break}null===n&&(e.lastBufferedRequest=null)}e.bufferedRequest=n,e.bufferProcessing=!1}function S(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function _(t,e){t._final((function(n){e.pendingcb--,n&&w(t,n),e.prefinished=!0,t.emit("prefinish"),M(t,e)}))}function M(t,e){var n=S(e);if(n&&(function(t,e){e.prefinished||e.finalCalled||("function"!=typeof t._final||e.destroyed?(e.prefinished=!0,t.emit("prefinish")):(e.pendingcb++,e.finalCalled=!0,r.nextTick(_,t,e)))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit("finish"),e.autoDestroy))){var a=t._readableState;(!a||a.autoDestroy&&a.endEmitted)&&t.destroy()}return n}n(3)(B,s),E.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(E.prototype,"buffer",{get:o.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(t){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(f=Function.prototype[Symbol.hasInstance],Object.defineProperty(B,Symbol.hasInstance,{value:function(t){return!!f.call(this,t)||this===B&&(t&&t._writableState instanceof E)}})):f=function(t){return t instanceof this},B.prototype.pipe=function(){w(this,new g)},B.prototype.write=function(t,e,n){var a,i=this._writableState,o=!1,s=!i.objectMode&&(a=t,u.isBuffer(a)||a instanceof c);return s&&!u.isBuffer(t)&&(t=function(t){return u.from(t)}(t)),"function"==typeof e&&(n=e,e=null),s?e="buffer":e||(e=i.defaultEncoding),"function"!=typeof n&&(n=C),i.ending?function(t,e){var n=new v;w(t,n),r.nextTick(e,n)}(this,n):(s||function(t,e,n,a){var i;return null===n?i=new m:"string"==typeof n||e.objectMode||(i=new d("chunk",["string","Buffer"],n)),!i||(w(t,i),r.nextTick(a,i),!1)}(this,i,t,n))&&(i.pendingcb++,o=function(t,e,n,r,a,i){if(!n){var o=function(t,e,n){t.objectMode||!1===t.decodeStrings||"string"!=typeof e||(e=u.from(e,n));return e}(e,r,a);r!==o&&(n=!0,a="buffer",r=o)}var s=e.objectMode?1:r.length;e.length+=s;var c=e.length<e.highWaterMark;c||(e.needDrain=!0);if(e.writing||e.corked){var f=e.lastBufferedRequest;e.lastBufferedRequest={chunk:r,encoding:a,isBuf:n,callback:i,next:null},f?f.next=e.lastBufferedRequest:e.bufferedRequest=e.lastBufferedRequest,e.bufferedRequestCount+=1}else k(t,e,!1,s,r,a,i);return c}(this,i,s,t,e,n)),o},B.prototype.cork=function(){this._writableState.corked++},B.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,t.writing||t.corked||t.bufferProcessing||!t.bufferedRequest||x(this,t))},B.prototype.setDefaultEncoding=function(t){if("string"==typeof t&&(t=t.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((t+"").toLowerCase())>-1))throw new I(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(B.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(B.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),B.prototype._write=function(t,e,n){n(new h("_write()"))},B.prototype._writev=null,B.prototype.end=function(t,e,n){var a=this._writableState;return"function"==typeof t?(n=t,t=null,e=null):"function"==typeof e&&(n=e,e=null),null!=t&&this.write(t,e),a.corked&&(a.corked=1,this.uncork()),a.ending||function(t,e,n){e.ending=!0,M(t,e),n&&(e.finished?r.nextTick(n):t.once("finish",n));e.ended=!0,t.writable=!1}(this,a,n),this},Object.defineProperty(B.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(B.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),B.prototype.destroy=A.destroy,B.prototype._undestroy=A.undestroy,B.prototype._destroy=function(t,e){e(t)}}).call(this,n(10),n(12))},function(t,e,n){"use strict";t.exports=f;var r=n(35).codes,a=r.ERR_METHOD_NOT_IMPLEMENTED,i=r.ERR_MULTIPLE_CALLBACK,o=r.ERR_TRANSFORM_ALREADY_TRANSFORMING,s=r.ERR_TRANSFORM_WITH_LENGTH_0,u=n(36);function c(t,e){var n=this._transformState;n.transforming=!1;var r=n.writecb;if(null===r)return this.emit("error",new i);n.writechunk=null,n.writecb=null,null!=e&&this.push(e),r(t);var a=this._readableState;a.reading=!1,(a.needReadable||a.length<a.highWaterMark)&&this._read(a.highWaterMark)}function f(t){if(!(this instanceof f))return new f(t);u.call(this,t),this._transformState={afterTransform:c.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,t&&("function"==typeof t.transform&&(this._transform=t.transform),"function"==typeof t.flush&&(this._flush=t.flush)),this.on("prefinish",A)}function A(){var t=this;"function"!=typeof this._flush||this._readableState.destroyed?l(this,null,null):this._flush((function(e,n){l(t,e,n)}))}function l(t,e,n){if(e)return t.emit("error",e);if(null!=n&&t.push(n),t._writableState.length)throw new s;if(t._transformState.transforming)throw new o;return t.push(null)}n(3)(f,u),f.prototype.push=function(t,e){return this._transformState.needTransform=!1,u.prototype.push.call(this,t,e)},f.prototype._transform=function(t,e,n){n(new a("_transform()"))},f.prototype._write=function(t,e,n){var r=this._transformState;if(r.writecb=n,r.writechunk=t,r.writeencoding=e,!r.transforming){var a=this._readableState;(r.needTransform||a.needReadable||a.length<a.highWaterMark)&&this._read(a.highWaterMark)}},f.prototype._read=function(t){var e=this._transformState;null===e.writechunk||e.transforming?e.needTransform=!0:(e.transforming=!0,this._transform(e.writechunk,e.writeencoding,e.afterTransform))},f.prototype._destroy=function(t,e){u.prototype._destroy.call(this,t,(function(t){e(t)}))}},function(t,e,n){var r=n(3),a=n(37),i=n(4).Buffer,o=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],s=new Array(64);function u(){this.init(),this._w=s,a.call(this,64,56)}function c(t,e,n){return n^t&(e^n)}function f(t,e,n){return t&e|n&(t|e)}function A(t){return(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10)}function l(t){return(t>>>6|t<<26)^(t>>>11|t<<21)^(t>>>25|t<<7)}function p(t){return(t>>>7|t<<25)^(t>>>18|t<<14)^t>>>3}r(u,a),u.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},u.prototype._update=function(t){for(var e,n=this._w,r=0|this._a,a=0|this._b,i=0|this._c,s=0|this._d,u=0|this._e,d=0|this._f,h=0|this._g,y=0|this._h,g=0;g<16;++g)n[g]=t.readInt32BE(4*g);for(;g<64;++g)n[g]=0|(((e=n[g-2])>>>17|e<<15)^(e>>>19|e<<13)^e>>>10)+n[g-7]+p(n[g-15])+n[g-16];for(var b=0;b<64;++b){var m=y+l(u)+c(u,d,h)+o[b]+n[b]|0,v=A(r)+f(r,a,i)|0;y=h,h=d,d=u,u=s+m|0,s=i,i=a,a=r,r=m+v|0}this._a=r+this._a|0,this._b=a+this._b|0,this._c=i+this._c|0,this._d=s+this._d|0,this._e=u+this._e|0,this._f=d+this._f|0,this._g=h+this._g|0,this._h=y+this._h|0},u.prototype._hash=function(){var t=i.allocUnsafe(32);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t.writeInt32BE(this._h,28),t},t.exports=u},function(t,e,n){var r=n(3),a=n(37),i=n(4).Buffer,o=[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],s=new Array(160);function u(){this.init(),this._w=s,a.call(this,128,112)}function c(t,e,n){return n^t&(e^n)}function f(t,e,n){return t&e|n&(t|e)}function A(t,e){return(t>>>28|e<<4)^(e>>>2|t<<30)^(e>>>7|t<<25)}function l(t,e){return(t>>>14|e<<18)^(t>>>18|e<<14)^(e>>>9|t<<23)}function p(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^t>>>7}function d(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^(t>>>7|e<<25)}function h(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^t>>>6}function y(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^(t>>>6|e<<26)}function g(t,e){return t>>>0<e>>>0?1:0}r(u,a),u.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},u.prototype._update=function(t){for(var e=this._w,n=0|this._ah,r=0|this._bh,a=0|this._ch,i=0|this._dh,s=0|this._eh,u=0|this._fh,b=0|this._gh,m=0|this._hh,v=0|this._al,I=0|this._bl,w=0|this._cl,C=0|this._dl,E=0|this._el,B=0|this._fl,k=0|this._gl,Q=0|this._hl,x=0;x<32;x+=2)e[x]=t.readInt32BE(4*x),e[x+1]=t.readInt32BE(4*x+4);for(;x<160;x+=2){var S=e[x-30],_=e[x-30+1],M=p(S,_),D=d(_,S),R=h(S=e[x-4],_=e[x-4+1]),O=y(_,S),j=e[x-14],T=e[x-14+1],N=e[x-32],P=e[x-32+1],L=D+T|0,F=M+j+g(L,D)|0;F=(F=F+R+g(L=L+O|0,O)|0)+N+g(L=L+P|0,P)|0,e[x]=F,e[x+1]=L}for(var U=0;U<160;U+=2){F=e[U],L=e[U+1];var H=f(n,r,a),G=f(v,I,w),q=A(n,v),Y=A(v,n),K=l(s,E),z=l(E,s),J=o[U],V=o[U+1],W=c(s,u,b),Z=c(E,B,k),X=Q+z|0,$=m+K+g(X,Q)|0;$=($=($=$+W+g(X=X+Z|0,Z)|0)+J+g(X=X+V|0,V)|0)+F+g(X=X+L|0,L)|0;var tt=Y+G|0,et=q+H+g(tt,Y)|0;m=b,Q=k,b=u,k=B,u=s,B=E,s=i+$+g(E=C+X|0,C)|0,i=a,C=w,a=r,w=I,r=n,I=v,n=$+et+g(v=X+tt|0,X)|0}this._al=this._al+v|0,this._bl=this._bl+I|0,this._cl=this._cl+w|0,this._dl=this._dl+C|0,this._el=this._el+E|0,this._fl=this._fl+B|0,this._gl=this._gl+k|0,this._hl=this._hl+Q|0,this._ah=this._ah+n+g(this._al,v)|0,this._bh=this._bh+r+g(this._bl,I)|0,this._ch=this._ch+a+g(this._cl,w)|0,this._dh=this._dh+i+g(this._dl,C)|0,this._eh=this._eh+s+g(this._el,E)|0,this._fh=this._fh+u+g(this._fl,B)|0,this._gh=this._gh+b+g(this._gl,k)|0,this._hh=this._hh+m+g(this._hl,Q)|0},u.prototype._hash=function(){var t=i.allocUnsafe(64);function e(e,n,r){t.writeInt32BE(e,r),t.writeInt32BE(n,r+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),e(this._gh,this._gl,48),e(this._hh,this._hl,56),t},t.exports=u},function(t,e,n){var r=n(72);t.exports=function(t){return(new r).update(t).digest()}},function(t,e,n){t.exports=n(142)},function(t){t.exports=JSON.parse('{"sha224WithRSAEncryption":{"sign":"rsa","hash":"sha224","id":"302d300d06096086480165030402040500041c"},"RSA-SHA224":{"sign":"ecdsa/rsa","hash":"sha224","id":"302d300d06096086480165030402040500041c"},"sha256WithRSAEncryption":{"sign":"rsa","hash":"sha256","id":"3031300d060960864801650304020105000420"},"RSA-SHA256":{"sign":"ecdsa/rsa","hash":"sha256","id":"3031300d060960864801650304020105000420"},"sha384WithRSAEncryption":{"sign":"rsa","hash":"sha384","id":"3041300d060960864801650304020205000430"},"RSA-SHA384":{"sign":"ecdsa/rsa","hash":"sha384","id":"3041300d060960864801650304020205000430"},"sha512WithRSAEncryption":{"sign":"rsa","hash":"sha512","id":"3051300d060960864801650304020305000440"},"RSA-SHA512":{"sign":"ecdsa/rsa","hash":"sha512","id":"3051300d060960864801650304020305000440"},"RSA-SHA1":{"sign":"rsa","hash":"sha1","id":"3021300906052b0e03021a05000414"},"ecdsa-with-SHA1":{"sign":"ecdsa","hash":"sha1","id":""},"sha256":{"sign":"ecdsa","hash":"sha256","id":""},"sha224":{"sign":"ecdsa","hash":"sha224","id":""},"sha384":{"sign":"ecdsa","hash":"sha384","id":""},"sha512":{"sign":"ecdsa","hash":"sha512","id":""},"DSA-SHA":{"sign":"dsa","hash":"sha1","id":""},"DSA-SHA1":{"sign":"dsa","hash":"sha1","id":""},"DSA":{"sign":"dsa","hash":"sha1","id":""},"DSA-WITH-SHA224":{"sign":"dsa","hash":"sha224","id":""},"DSA-SHA224":{"sign":"dsa","hash":"sha224","id":""},"DSA-WITH-SHA256":{"sign":"dsa","hash":"sha256","id":""},"DSA-SHA256":{"sign":"dsa","hash":"sha256","id":""},"DSA-WITH-SHA384":{"sign":"dsa","hash":"sha384","id":""},"DSA-SHA384":{"sign":"dsa","hash":"sha384","id":""},"DSA-WITH-SHA512":{"sign":"dsa","hash":"sha512","id":""},"DSA-SHA512":{"sign":"dsa","hash":"sha512","id":""},"DSA-RIPEMD160":{"sign":"dsa","hash":"rmd160","id":""},"ripemd160WithRSA":{"sign":"rsa","hash":"rmd160","id":"3021300906052b2403020105000414"},"RSA-RIPEMD160":{"sign":"rsa","hash":"rmd160","id":"3021300906052b2403020105000414"},"md5WithRSAEncryption":{"sign":"rsa","hash":"md5","id":"3020300c06082a864886f70d020505000410"},"RSA-MD5":{"sign":"rsa","hash":"md5","id":"3020300c06082a864886f70d020505000410"}}')},function(t,e){var n=Math.pow(2,30)-1;t.exports=function(t,e){if("number"!=typeof t)throw new TypeError("Iterations not a number");if(t<0)throw new TypeError("Bad iterations");if("number"!=typeof e)throw new TypeError("Key length not a number");if(e<0||e>n||e!=e)throw new TypeError("Bad key length")}},function(t,e,n){(function(e,n){var r;if(e.process&&e.process.browser)r="utf-8";else if(e.process&&e.process.version){r=parseInt(n.version.split(".")[0].slice(1),10)>=6?"utf-8":"binary"}else r="utf-8";t.exports=r}).call(this,n(10),n(12))},function(t,e,n){var r=n(140),a=n(75),i=n(76),o=n(4).Buffer,s=n(143),u=n(144),c=n(146),f=o.alloc(128),A={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,rmd160:20,ripemd160:20};function l(t,e,n){var s=function(t){function e(e){return i(t).update(e).digest()}return"rmd160"===t||"ripemd160"===t?function(t){return(new a).update(t).digest()}:"md5"===t?r:e}(t),u="sha512"===t||"sha384"===t?128:64;e.length>u?e=s(e):e.length<u&&(e=o.concat([e,f],u));for(var c=o.allocUnsafe(u+A[t]),l=o.allocUnsafe(u+A[t]),p=0;p<u;p++)c[p]=54^e[p],l[p]=92^e[p];var d=o.allocUnsafe(u+n+4);c.copy(d,0,0,u),this.ipad1=d,this.ipad2=c,this.opad=l,this.alg=t,this.blocksize=u,this.hash=s,this.size=A[t]}l.prototype.run=function(t,e){return t.copy(e,this.blocksize),this.hash(e).copy(this.opad,this.blocksize),this.hash(this.opad)},t.exports=function(t,e,n,r,a){s(n,r);var i=new l(a=a||"sha1",t=c(t,u,"Password"),(e=c(e,u,"Salt")).length),f=o.allocUnsafe(r),p=o.allocUnsafe(e.length+4);e.copy(p,0,0,e.length);for(var d=0,h=A[a],y=Math.ceil(r/h),g=1;g<=y;g++){p.writeUInt32BE(g,e.length);for(var b=i.run(p,i.ipad1),m=b,v=1;v<n;v++){m=i.run(m,i.ipad2);for(var I=0;I<h;I++)b[I]^=m[I]}b.copy(f,d),d+=h}return f}},function(t,e,n){var r=n(4).Buffer;t.exports=function(t,e,n){if(r.isBuffer(t))return t;if("string"==typeof t)return r.from(t,e);if(ArrayBuffer.isView(t))return r.from(t.buffer);throw new TypeError(n+" must be a string, a Buffer, a typed array or a DataView")}},function(t,e,n){var r=n(320),a=n(80),i=n(81),o=n(333),s=n(55);function u(t,e,n){if(t=t.toLowerCase(),i[t])return a.createCipheriv(t,e,n);if(o[t])return new r({key:e,iv:n,mode:t});throw new TypeError("invalid suite type")}function c(t,e,n){if(t=t.toLowerCase(),i[t])return a.createDecipheriv(t,e,n);if(o[t])return new r({key:e,iv:n,mode:t,decrypt:!0});throw new TypeError("invalid suite type")}e.createCipher=e.Cipher=function(t,e){var n,r;if(t=t.toLowerCase(),i[t])n=i[t].key,r=i[t].iv;else{if(!o[t])throw new TypeError("invalid suite type");n=8*o[t].key,r=o[t].iv}var a=s(e,!1,n,r);return u(t,a.key,a.iv)},e.createCipheriv=e.Cipheriv=u,e.createDecipher=e.Decipher=function(t,e){var n,r;if(t=t.toLowerCase(),i[t])n=i[t].key,r=i[t].iv;else{if(!o[t])throw new TypeError("invalid suite type");n=8*o[t].key,r=o[t].iv}var a=s(e,!1,n,r);return c(t,a.key,a.iv)},e.createDecipheriv=e.Decipheriv=c,e.listCiphers=e.getCiphers=function(){return Object.keys(o).concat(a.getCiphers())}},function(t,e,n){"use strict";e.readUInt32BE=function(t,e){return(t[0+e]<<24|t[1+e]<<16|t[2+e]<<8|t[3+e])>>>0},e.writeUInt32BE=function(t,e,n){t[0+n]=e>>>24,t[1+n]=e>>>16&255,t[2+n]=e>>>8&255,t[3+n]=255&e},e.ip=function(t,e,n,r){for(var a=0,i=0,o=6;o>=0;o-=2){for(var s=0;s<=24;s+=8)a<<=1,a|=e>>>s+o&1;for(s=0;s<=24;s+=8)a<<=1,a|=t>>>s+o&1}for(o=6;o>=0;o-=2){for(s=1;s<=25;s+=8)i<<=1,i|=e>>>s+o&1;for(s=1;s<=25;s+=8)i<<=1,i|=t>>>s+o&1}n[r+0]=a>>>0,n[r+1]=i>>>0},e.rip=function(t,e,n,r){for(var a=0,i=0,o=0;o<4;o++)for(var s=24;s>=0;s-=8)a<<=1,a|=e>>>s+o&1,a<<=1,a|=t>>>s+o&1;for(o=4;o<8;o++)for(s=24;s>=0;s-=8)i<<=1,i|=e>>>s+o&1,i<<=1,i|=t>>>s+o&1;n[r+0]=a>>>0,n[r+1]=i>>>0},e.pc1=function(t,e,n,r){for(var a=0,i=0,o=7;o>=5;o--){for(var s=0;s<=24;s+=8)a<<=1,a|=e>>s+o&1;for(s=0;s<=24;s+=8)a<<=1,a|=t>>s+o&1}for(s=0;s<=24;s+=8)a<<=1,a|=e>>s+o&1;for(o=1;o<=3;o++){for(s=0;s<=24;s+=8)i<<=1,i|=e>>s+o&1;for(s=0;s<=24;s+=8)i<<=1,i|=t>>s+o&1}for(s=0;s<=24;s+=8)i<<=1,i|=t>>s+o&1;n[r+0]=a>>>0,n[r+1]=i>>>0},e.r28shl=function(t,e){return t<<e&268435455|t>>>28-e};var r=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];e.pc2=function(t,e,n,a){for(var i=0,o=0,s=r.length>>>1,u=0;u<s;u++)i<<=1,i|=t>>>r[u]&1;for(u=s;u<r.length;u++)o<<=1,o|=e>>>r[u]&1;n[a+0]=i>>>0,n[a+1]=o>>>0},e.expand=function(t,e,n){var r=0,a=0;r=(1&t)<<5|t>>>27;for(var i=23;i>=15;i-=4)r<<=6,r|=t>>>i&63;for(i=11;i>=3;i-=4)a|=t>>>i&63,a<<=6;a|=(31&t)<<1|t>>>31,e[n+0]=r>>>0,e[n+1]=a>>>0};var a=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];e.substitute=function(t,e){for(var n=0,r=0;r<4;r++){n<<=4,n|=a[64*r+(t>>>18-6*r&63)]}for(r=0;r<4;r++){n<<=4,n|=a[256+64*r+(e>>>18-6*r&63)]}return n>>>0};var i=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];e.permute=function(t){for(var e=0,n=0;n<i.length;n++)e<<=1,e|=t>>>i[n]&1;return e>>>0},e.padSplit=function(t,e,n){for(var r=t.toString(2);r.length<e;)r="0"+r;for(var a=[],i=0;i<e;i+=n)a.push(r.slice(i,i+n));return a.join(" ")}},function(t,e,n){"use strict";var r=n(17),a=n(3),i=n(148),o=n(79);function s(){this.tmp=new Array(2),this.keys=null}function u(t){o.call(this,t);var e=new s;this._desState=e,this.deriveKeys(e,t.key)}a(u,o),t.exports=u,u.create=function(t){return new u(t)};var c=[1,1,2,2,2,2,2,2,1,2,2,2,2,2,2,1];u.prototype.deriveKeys=function(t,e){t.keys=new Array(32),r.equal(e.length,this.blockSize,"Invalid key length");var n=i.readUInt32BE(e,0),a=i.readUInt32BE(e,4);i.pc1(n,a,t.tmp,0),n=t.tmp[0],a=t.tmp[1];for(var o=0;o<t.keys.length;o+=2){var s=c[o>>>1];n=i.r28shl(n,s),a=i.r28shl(a,s),i.pc2(n,a,t.keys,o)}},u.prototype._update=function(t,e,n,r){var a=this._desState,o=i.readUInt32BE(t,e),s=i.readUInt32BE(t,e+4);i.ip(o,s,a.tmp,0),o=a.tmp[0],s=a.tmp[1],"encrypt"===this.type?this._encrypt(a,o,s,a.tmp,0):this._decrypt(a,o,s,a.tmp,0),o=a.tmp[0],s=a.tmp[1],i.writeUInt32BE(n,o,r),i.writeUInt32BE(n,s,r+4)},u.prototype._pad=function(t,e){for(var n=t.length-e,r=e;r<t.length;r++)t[r]=n;return!0},u.prototype._unpad=function(t){for(var e=t[t.length-1],n=t.length-e;n<t.length;n++)r.equal(t[n],e);return t.slice(0,t.length-e)},u.prototype._encrypt=function(t,e,n,r,a){for(var o=e,s=n,u=0;u<t.keys.length;u+=2){var c=t.keys[u],f=t.keys[u+1];i.expand(s,t.tmp,0),c^=t.tmp[0],f^=t.tmp[1];var A=i.substitute(c,f),l=s;s=(o^i.permute(A))>>>0,o=l}i.rip(s,o,r,a)},u.prototype._decrypt=function(t,e,n,r,a){for(var o=n,s=e,u=t.keys.length-2;u>=0;u-=2){var c=t.keys[u],f=t.keys[u+1];i.expand(o,t.tmp,0),c^=t.tmp[0],f^=t.tmp[1];var A=i.substitute(c,f),l=o;o=(s^i.permute(A))>>>0,s=l}i.rip(o,s,r,a)}},function(t,e,n){var r=n(45),a=n(4).Buffer,i=n(151);function o(t){var e=t._cipher.encryptBlockRaw(t._prev);return i(t._prev),e}e.encrypt=function(t,e){var n=Math.ceil(e.length/16),i=t._cache.length;t._cache=a.concat([t._cache,a.allocUnsafe(16*n)]);for(var s=0;s<n;s++){var u=o(t),c=i+16*s;t._cache.writeUInt32BE(u[0],c+0),t._cache.writeUInt32BE(u[1],c+4),t._cache.writeUInt32BE(u[2],c+8),t._cache.writeUInt32BE(u[3],c+12)}var f=t._cache.slice(0,e.length);return t._cache=t._cache.slice(e.length),r(e,f)}},function(t,e){t.exports=function(t){for(var e,n=t.length;n--;){if(255!==(e=t.readUInt8(n))){e++,t.writeUInt8(e,n);break}t.writeUInt8(0,n)}}},function(t){t.exports=JSON.parse('{"aes-128-ecb":{"cipher":"AES","key":128,"iv":0,"mode":"ECB","type":"block"},"aes-192-ecb":{"cipher":"AES","key":192,"iv":0,"mode":"ECB","type":"block"},"aes-256-ecb":{"cipher":"AES","key":256,"iv":0,"mode":"ECB","type":"block"},"aes-128-cbc":{"cipher":"AES","key":128,"iv":16,"mode":"CBC","type":"block"},"aes-192-cbc":{"cipher":"AES","key":192,"iv":16,"mode":"CBC","type":"block"},"aes-256-cbc":{"cipher":"AES","key":256,"iv":16,"mode":"CBC","type":"block"},"aes128":{"cipher":"AES","key":128,"iv":16,"mode":"CBC","type":"block"},"aes192":{"cipher":"AES","key":192,"iv":16,"mode":"CBC","type":"block"},"aes256":{"cipher":"AES","key":256,"iv":16,"mode":"CBC","type":"block"},"aes-128-cfb":{"cipher":"AES","key":128,"iv":16,"mode":"CFB","type":"stream"},"aes-192-cfb":{"cipher":"AES","key":192,"iv":16,"mode":"CFB","type":"stream"},"aes-256-cfb":{"cipher":"AES","key":256,"iv":16,"mode":"CFB","type":"stream"},"aes-128-cfb8":{"cipher":"AES","key":128,"iv":16,"mode":"CFB8","type":"stream"},"aes-192-cfb8":{"cipher":"AES","key":192,"iv":16,"mode":"CFB8","type":"stream"},"aes-256-cfb8":{"cipher":"AES","key":256,"iv":16,"mode":"CFB8","type":"stream"},"aes-128-cfb1":{"cipher":"AES","key":128,"iv":16,"mode":"CFB1","type":"stream"},"aes-192-cfb1":{"cipher":"AES","key":192,"iv":16,"mode":"CFB1","type":"stream"},"aes-256-cfb1":{"cipher":"AES","key":256,"iv":16,"mode":"CFB1","type":"stream"},"aes-128-ofb":{"cipher":"AES","key":128,"iv":16,"mode":"OFB","type":"stream"},"aes-192-ofb":{"cipher":"AES","key":192,"iv":16,"mode":"OFB","type":"stream"},"aes-256-ofb":{"cipher":"AES","key":256,"iv":16,"mode":"OFB","type":"stream"},"aes-128-ctr":{"cipher":"AES","key":128,"iv":16,"mode":"CTR","type":"stream"},"aes-192-ctr":{"cipher":"AES","key":192,"iv":16,"mode":"CTR","type":"stream"},"aes-256-ctr":{"cipher":"AES","key":256,"iv":16,"mode":"CTR","type":"stream"},"aes-128-gcm":{"cipher":"AES","key":128,"iv":12,"mode":"GCM","type":"auth"},"aes-192-gcm":{"cipher":"AES","key":192,"iv":12,"mode":"GCM","type":"auth"},"aes-256-gcm":{"cipher":"AES","key":256,"iv":12,"mode":"GCM","type":"auth"}}')},function(t,e,n){var r=n(54),a=n(4).Buffer,i=n(26),o=n(3),s=n(331),u=n(45),c=n(151);function f(t,e,n,o){i.call(this);var u=a.alloc(4,0);this._cipher=new r.AES(e);var f=this._cipher.encryptBlock(u);this._ghash=new s(f),n=function(t,e,n){if(12===e.length)return t._finID=a.concat([e,a.from([0,0,0,1])]),a.concat([e,a.from([0,0,0,2])]);var r=new s(n),i=e.length,o=i%16;r.update(e),o&&(o=16-o,r.update(a.alloc(o,0))),r.update(a.alloc(8,0));var u=8*i,f=a.alloc(8);f.writeUIntBE(u,0,8),r.update(f),t._finID=r.state;var A=a.from(t._finID);return c(A),A}(this,n,f),this._prev=a.from(n),this._cache=a.allocUnsafe(0),this._secCache=a.allocUnsafe(0),this._decrypt=o,this._alen=0,this._len=0,this._mode=t,this._authTag=null,this._called=!1}o(f,i),f.prototype._update=function(t){if(!this._called&&this._alen){var e=16-this._alen%16;e<16&&(e=a.alloc(e,0),this._ghash.update(e))}this._called=!0;var n=this._mode.encrypt(this,t);return this._decrypt?this._ghash.update(t):this._ghash.update(n),this._len+=t.length,n},f.prototype._final=function(){if(this._decrypt&&!this._authTag)throw new Error("Unsupported state or unable to authenticate data");var t=u(this._ghash.final(8*this._alen,8*this._len),this._cipher.encryptBlock(this._finID));if(this._decrypt&&function(t,e){var n=0;t.length!==e.length&&n++;for(var r=Math.min(t.length,e.length),a=0;a<r;++a)n+=t[a]^e[a];return n}(t,this._authTag))throw new Error("Unsupported state or unable to authenticate data");this._authTag=t,this._cipher.scrub()},f.prototype.getAuthTag=function(){if(this._decrypt||!a.isBuffer(this._authTag))throw new Error("Attempting to get auth tag in unsupported state");return this._authTag},f.prototype.setAuthTag=function(t){if(!this._decrypt)throw new Error("Attempting to set auth tag in unsupported state");this._authTag=t},f.prototype.setAAD=function(t){if(this._called)throw new Error("Attempting to set AAD in unsupported state");this._ghash.update(t),this._alen+=t.length},t.exports=f},function(t,e,n){var r=n(54),a=n(4).Buffer,i=n(26);function o(t,e,n,o){i.call(this),this._cipher=new r.AES(e),this._prev=a.from(n),this._cache=a.allocUnsafe(0),this._secCache=a.allocUnsafe(0),this._decrypt=o,this._mode=t}n(3)(o,i),o.prototype._update=function(t){return this._mode.encrypt(this,t,this._decrypt)},o.prototype._final=function(){this._cipher.scrub()},t.exports=o},function(t,e,n){(function(t){var r=n(156),a=n(335),i=n(336);var o={binary:!0,hex:!0,base64:!0};e.DiffieHellmanGroup=e.createDiffieHellmanGroup=e.getDiffieHellman=function(e){var n=new t(a[e].prime,"hex"),r=new t(a[e].gen,"hex");return new i(n,r)},e.createDiffieHellman=e.DiffieHellman=function e(n,a,s,u){return t.isBuffer(a)||void 0===o[a]?e(n,"binary",a,s):(a=a||"binary",u=u||"binary",s=s||new t([2]),t.isBuffer(s)||(s=new t(s,u)),"number"==typeof n?new i(r(n,s),s,!0):(t.isBuffer(n)||(n=new t(n,a)),new i(n,s,!0)))}}).call(this,n(5).Buffer)},function(t,e,n){var r=n(29);t.exports=b,b.simpleSieve=y,b.fermatTest=g;var a=n(2),i=new a(24),o=new(n(157)),s=new a(1),u=new a(2),c=new a(5),f=(new a(16),new a(8),new a(10)),A=new a(3),l=(new a(7),new a(11)),p=new a(4),d=(new a(12),null);function h(){if(null!==d)return d;var t=[];t[0]=2;for(var e=1,n=3;n<1048576;n+=2){for(var r=Math.ceil(Math.sqrt(n)),a=0;a<e&&t[a]<=r&&n%t[a]!=0;a++);e!==a&&t[a]<=r||(t[e++]=n)}return d=t,t}function y(t){for(var e=h(),n=0;n<e.length;n++)if(0===t.modn(e[n]))return 0===t.cmpn(e[n]);return!0}function g(t){var e=a.mont(t);return 0===u.toRed(e).redPow(t.subn(1)).fromRed().cmpn(1)}function b(t,e){if(t<16)return new a(2===e||5===e?[140,123]:[140,39]);var n,d;for(e=new a(e);;){for(n=new a(r(Math.ceil(t/8)));n.bitLength()>t;)n.ishrn(1);if(n.isEven()&&n.iadd(s),n.testn(1)||n.iadd(u),e.cmp(u)){if(!e.cmp(c))for(;n.mod(f).cmp(A);)n.iadd(p)}else for(;n.mod(i).cmp(l);)n.iadd(p);if(y(d=n.shrn(1))&&y(n)&&g(d)&&g(n)&&o.test(d)&&o.test(n))return n}}},function(t,e,n){var r=n(2),a=n(82);function i(t){this.rand=t||new a.Rand}t.exports=i,i.create=function(t){return new i(t)},i.prototype._randbelow=function(t){var e=t.bitLength(),n=Math.ceil(e/8);do{var a=new r(this.rand.generate(n))}while(a.cmp(t)>=0);return a},i.prototype._randrange=function(t,e){var n=e.sub(t);return t.add(this._randbelow(n))},i.prototype.test=function(t,e,n){var a=t.bitLength(),i=r.mont(t),o=new r(1).toRed(i);e||(e=Math.max(1,a/48|0));for(var s=t.subn(1),u=0;!s.testn(u);u++);for(var c=t.shrn(u),f=s.toRed(i);e>0;e--){var A=this._randrange(new r(2),s);n&&n(A);var l=A.toRed(i).redPow(c);if(0!==l.cmp(o)&&0!==l.cmp(f)){for(var p=1;p<u;p++){if(0===(l=l.redSqr()).cmp(o))return!1;if(0===l.cmp(f))break}if(p===u)return!1}}return!0},i.prototype.getDivisor=function(t,e){var n=t.bitLength(),a=r.mont(t),i=new r(1).toRed(a);e||(e=Math.max(1,n/48|0));for(var o=t.subn(1),s=0;!o.testn(s);s++);for(var u=t.shrn(s),c=o.toRed(a);e>0;e--){var f=this._randrange(new r(2),o),A=t.gcd(f);if(0!==A.cmpn(1))return A;var l=f.toRed(a).redPow(u);if(0!==l.cmp(i)&&0!==l.cmp(c)){for(var p=1;p<s;p++){if(0===(l=l.redSqr()).cmp(i))return l.fromRed().subn(1).gcd(t);if(0===l.cmp(c))break}if(p===s)return(l=l.redSqr()).fromRed().subn(1).gcd(t)}}return!1}},function(t,e,n){var r=n(4).Buffer,a=n(34),i=n(73),o=n(3),s=n(337),u=n(359),c=n(142);function f(t){i.Writable.call(this);var e=c[t];if(!e)throw new Error("Unknown message digest");this._hashType=e.hash,this._hash=a(e.hash),this._tag=e.id,this._signType=e.sign}function A(t){i.Writable.call(this);var e=c[t];if(!e)throw new Error("Unknown message digest");this._hash=a(e.hash),this._tag=e.id,this._signType=e.sign}function l(t){return new f(t)}function p(t){return new A(t)}Object.keys(c).forEach((function(t){c[t].id=r.from(c[t].id,"hex"),c[t.toLowerCase()]=c[t]})),o(f,i.Writable),f.prototype._write=function(t,e,n){this._hash.update(t),n()},f.prototype.update=function(t,e){return"string"==typeof t&&(t=r.from(t,e)),this._hash.update(t),this},f.prototype.sign=function(t,e){this.end();var n=this._hash.digest(),r=s(n,t,this._hashType,this._signType,this._tag);return e?r.toString(e):r},o(A,i.Writable),A.prototype._write=function(t,e,n){this._hash.update(t),n()},A.prototype.update=function(t,e){return"string"==typeof t&&(t=r.from(t,e)),this._hash.update(t),this},A.prototype.verify=function(t,e,n){"string"==typeof e&&(e=r.from(e,n)),this.end();var a=this._hash.digest();return u(e,a,t,this._signType,this._tag)},t.exports={Sign:l,Verify:p,createSign:l,createVerify:p}},function(t,e,n){"use strict";var r=e;function a(t){return 1===t.length?"0"+t:t}function i(t){for(var e="",n=0;n<t.length;n++)e+=a(t[n].toString(16));return e}r.toArray=function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var n=[];if("string"!=typeof t){for(var r=0;r<t.length;r++)n[r]=0|t[r];return n}if("hex"===e){(t=t.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(t="0"+t);for(r=0;r<t.length;r+=2)n.push(parseInt(t[r]+t[r+1],16))}else for(r=0;r<t.length;r++){var a=t.charCodeAt(r),i=a>>8,o=255&a;i?n.push(i,o):n.push(o)}return n},r.zero2=a,r.toHex=i,r.encode=function(t,e){return"hex"===e?i(t):t}},function(t,e,n){"use strict";var r=e;r.base=n(56),r.short=n(339),r.mont=n(340),r.edwards=n(341)},function(t,e,n){"use strict";var r=e;r.bignum=n(2),r.define=n(351).define,r.base=n(354),r.constants=n(355),r.decoders=n(164),r.encoders=n(162)},function(t,e,n){"use strict";var r=e;r.der=n(163),r.pem=n(352)},function(t,e,n){"use strict";var r=n(3),a=n(86).Buffer,i=n(87),o=n(89);function s(t){this.enc="der",this.name=t.name,this.entity=t,this.tree=new u,this.tree._init(t.body)}function u(t){i.call(this,"der",t)}function c(t){return t<10?"0"+t:t}t.exports=s,s.prototype.encode=function(t,e){return this.tree._encode(t,e).join()},r(u,i),u.prototype._encodeComposite=function(t,e,n,r){var i=function(t,e,n,r){var a;"seqof"===t?t="seq":"setof"===t&&(t="set");if(o.tagByName.hasOwnProperty(t))a=o.tagByName[t];else{if("number"!=typeof t||(0|t)!==t)return r.error("Unknown tag: "+t);a=t}if(a>=31)return r.error("Multi-octet tag encoding unsupported");e||(a|=32);return a|=o.tagClassByName[n||"universal"]<<6}(t,e,n,this.reporter);if(r.length<128){var s=a.alloc(2);return s[0]=i,s[1]=r.length,this._createEncoderBuffer([s,r])}for(var u=1,c=r.length;c>=256;c>>=8)u++;var f=a.alloc(2+u);f[0]=i,f[1]=128|u;for(var A=1+u,l=r.length;l>0;A--,l>>=8)f[A]=255&l;return this._createEncoderBuffer([f,r])},u.prototype._encodeStr=function(t,e){if("bitstr"===e)return this._createEncoderBuffer([0|t.unused,t.data]);if("bmpstr"===e){for(var n=a.alloc(2*t.length),r=0;r<t.length;r++)n.writeUInt16BE(t.charCodeAt(r),2*r);return this._createEncoderBuffer(n)}return"numstr"===e?this._isNumstr(t)?this._createEncoderBuffer(t):this.reporter.error("Encoding of string type: numstr supports only digits and space"):"printstr"===e?this._isPrintstr(t)?this._createEncoderBuffer(t):this.reporter.error("Encoding of string type: printstr supports only latin upper and lower case letters, digits, space, apostrophe, left and rigth parenthesis, plus sign, comma, hyphen, dot, slash, colon, equal sign, question mark"):/str$/.test(e)||"objDesc"===e?this._createEncoderBuffer(t):this.reporter.error("Encoding of string type: "+e+" unsupported")},u.prototype._encodeObjid=function(t,e,n){if("string"==typeof t){if(!e)return this.reporter.error("string objid given, but no values map found");if(!e.hasOwnProperty(t))return this.reporter.error("objid not found in values map");t=e[t].split(/[\s.]+/g);for(var r=0;r<t.length;r++)t[r]|=0}else if(Array.isArray(t)){t=t.slice();for(var i=0;i<t.length;i++)t[i]|=0}if(!Array.isArray(t))return this.reporter.error("objid() should be either array or string, got: "+JSON.stringify(t));if(!n){if(t[1]>=40)return this.reporter.error("Second objid identifier OOB");t.splice(0,2,40*t[0]+t[1])}for(var o=0,s=0;s<t.length;s++){var u=t[s];for(o++;u>=128;u>>=7)o++}for(var c=a.alloc(o),f=c.length-1,A=t.length-1;A>=0;A--){var l=t[A];for(c[f--]=127&l;(l>>=7)>0;)c[f--]=128|127&l}return this._createEncoderBuffer(c)},u.prototype._encodeTime=function(t,e){var n,r=new Date(t);return"gentime"===e?n=[c(r.getUTCFullYear()),c(r.getUTCMonth()+1),c(r.getUTCDate()),c(r.getUTCHours()),c(r.getUTCMinutes()),c(r.getUTCSeconds()),"Z"].join(""):"utctime"===e?n=[c(r.getUTCFullYear()%100),c(r.getUTCMonth()+1),c(r.getUTCDate()),c(r.getUTCHours()),c(r.getUTCMinutes()),c(r.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+e+" time is not supported yet"),this._encodeStr(n,"octstr")},u.prototype._encodeNull=function(){return this._createEncoderBuffer("")},u.prototype._encodeInt=function(t,e){if("string"==typeof t){if(!e)return this.reporter.error("String int or enum given, but no values map");if(!e.hasOwnProperty(t))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(t));t=e[t]}if("number"!=typeof t&&!a.isBuffer(t)){var n=t.toArray();!t.sign&&128&n[0]&&n.unshift(0),t=a.from(n)}if(a.isBuffer(t)){var r=t.length;0===t.length&&r++;var i=a.alloc(r);return t.copy(i),0===t.length&&(i[0]=0),this._createEncoderBuffer(i)}if(t<128)return this._createEncoderBuffer(t);if(t<256)return this._createEncoderBuffer([0,t]);for(var o=1,s=t;s>=256;s>>=8)o++;for(var u=new Array(o),c=u.length-1;c>=0;c--)u[c]=255&t,t>>=8;return 128&u[0]&&u.unshift(0),this._createEncoderBuffer(a.from(u))},u.prototype._encodeBool=function(t){return this._createEncoderBuffer(t?255:0)},u.prototype._use=function(t,e){return"function"==typeof t&&(t=t(e)),t._getEncoder("der").tree},u.prototype._skipDefault=function(t,e,n){var r,a=this._baseState;if(null===a.default)return!1;var i=t.join();if(void 0===a.defaultBuffer&&(a.defaultBuffer=this._encodeValue(a.default,e,n).join()),i.length!==a.defaultBuffer.length)return!1;for(r=0;r<i.length;r++)if(i[r]!==a.defaultBuffer[r])return!1;return!0}},function(t,e,n){"use strict";var r=e;r.der=n(165),r.pem=n(353)},function(t,e,n){"use strict";var r=n(3),a=n(2),i=n(46).DecoderBuffer,o=n(87),s=n(89);function u(t){this.enc="der",this.name=t.name,this.entity=t,this.tree=new c,this.tree._init(t.body)}function c(t){o.call(this,"der",t)}function f(t,e){var n=t.readUInt8(e);if(t.isError(n))return n;var r=s.tagClass[n>>6],a=0==(32&n);if(31==(31&n)){var i=n;for(n=0;128==(128&i);){if(i=t.readUInt8(e),t.isError(i))return i;n<<=7,n|=127&i}}else n&=31;return{cls:r,primitive:a,tag:n,tagStr:s.tag[n]}}function A(t,e,n){var r=t.readUInt8(n);if(t.isError(r))return r;if(!e&&128===r)return null;if(0==(128&r))return r;var a=127&r;if(a>4)return t.error("length octect is too long");r=0;for(var i=0;i<a;i++){r<<=8;var o=t.readUInt8(n);if(t.isError(o))return o;r|=o}return r}t.exports=u,u.prototype.decode=function(t,e){return i.isDecoderBuffer(t)||(t=new i(t,e)),this.tree._decode(t,e)},r(c,o),c.prototype._peekTag=function(t,e,n){if(t.isEmpty())return!1;var r=t.save(),a=f(t,'Failed to peek tag: "'+e+'"');return t.isError(a)?a:(t.restore(r),a.tag===e||a.tagStr===e||a.tagStr+"of"===e||n)},c.prototype._decodeTag=function(t,e,n){var r=f(t,'Failed to decode tag of "'+e+'"');if(t.isError(r))return r;var a=A(t,r.primitive,'Failed to get length of "'+e+'"');if(t.isError(a))return a;if(!n&&r.tag!==e&&r.tagStr!==e&&r.tagStr+"of"!==e)return t.error('Failed to match tag: "'+e+'"');if(r.primitive||null!==a)return t.skip(a,'Failed to match body of: "'+e+'"');var i=t.save(),o=this._skipUntilEnd(t,'Failed to skip indefinite length body: "'+this.tag+'"');return t.isError(o)?o:(a=t.offset-i.offset,t.restore(i),t.skip(a,'Failed to match body of: "'+e+'"'))},c.prototype._skipUntilEnd=function(t,e){for(;;){var n=f(t,e);if(t.isError(n))return n;var r=A(t,n.primitive,e);if(t.isError(r))return r;var a=void 0;if(a=n.primitive||null!==r?t.skip(r):this._skipUntilEnd(t,e),t.isError(a))return a;if("end"===n.tagStr)break}},c.prototype._decodeList=function(t,e,n,r){for(var a=[];!t.isEmpty();){var i=this._peekTag(t,"end");if(t.isError(i))return i;var o=n.decode(t,"der",r);if(t.isError(o)&&i)break;a.push(o)}return a},c.prototype._decodeStr=function(t,e){if("bitstr"===e){var n=t.readUInt8();return t.isError(n)?n:{unused:n,data:t.raw()}}if("bmpstr"===e){var r=t.raw();if(r.length%2==1)return t.error("Decoding of string type: bmpstr length mismatch");for(var a="",i=0;i<r.length/2;i++)a+=String.fromCharCode(r.readUInt16BE(2*i));return a}if("numstr"===e){var o=t.raw().toString("ascii");return this._isNumstr(o)?o:t.error("Decoding of string type: numstr unsupported characters")}if("octstr"===e)return t.raw();if("objDesc"===e)return t.raw();if("printstr"===e){var s=t.raw().toString("ascii");return this._isPrintstr(s)?s:t.error("Decoding of string type: printstr unsupported characters")}return/str$/.test(e)?t.raw().toString():t.error("Decoding of string type: "+e+" unsupported")},c.prototype._decodeObjid=function(t,e,n){for(var r,a=[],i=0,o=0;!t.isEmpty();)i<<=7,i|=127&(o=t.readUInt8()),0==(128&o)&&(a.push(i),i=0);128&o&&a.push(i);var s=a[0]/40|0,u=a[0]%40;if(r=n?a:[s,u].concat(a.slice(1)),e){var c=e[r.join(" ")];void 0===c&&(c=e[r.join(".")]),void 0!==c&&(r=c)}return r},c.prototype._decodeTime=function(t,e){var n,r,a,i,o,s,u=t.raw().toString();if("gentime"===e)n=0|u.slice(0,4),r=0|u.slice(4,6),a=0|u.slice(6,8),i=0|u.slice(8,10),o=0|u.slice(10,12),s=0|u.slice(12,14);else{if("utctime"!==e)return t.error("Decoding "+e+" time is not supported yet");n=0|u.slice(0,2),r=0|u.slice(2,4),a=0|u.slice(4,6),i=0|u.slice(6,8),o=0|u.slice(8,10),s=0|u.slice(10,12),n=n<70?2e3+n:1900+n}return Date.UTC(n,r-1,a,i,o,s,0)},c.prototype._decodeNull=function(){return null},c.prototype._decodeBool=function(t){var e=t.readUInt8();return t.isError(e)?e:0!==e},c.prototype._decodeInt=function(t,e){var n=t.raw(),r=new a(n);return e&&(r=e[r.toString(10)]||r),r},c.prototype._use=function(t,e){return"function"==typeof t&&(t=t(e)),t._getDecoder("der").tree}},function(t){t.exports=JSON.parse('{"1.3.132.0.10":"secp256k1","1.3.132.0.33":"p224","1.2.840.10045.3.1.1":"p192","1.2.840.10045.3.1.7":"p256","1.3.132.0.34":"p384","1.3.132.0.35":"p521"}')},function(t,e,n){(function(e){var r=n(84),a=n(2);t.exports=function(t){return new o(t)};var i={secp256k1:{name:"secp256k1",byteLength:32},secp224r1:{name:"p224",byteLength:28},prime256v1:{name:"p256",byteLength:32},prime192v1:{name:"p192",byteLength:24},ed25519:{name:"ed25519",byteLength:32},secp384r1:{name:"p384",byteLength:48},secp521r1:{name:"p521",byteLength:66}};function o(t){this.curveType=i[t],this.curveType||(this.curveType={name:t}),this.curve=new r.ec(this.curveType.name),this.keys=void 0}function s(t,n,r){Array.isArray(t)||(t=t.toArray());var a=new e(t);if(r&&a.length<r){var i=new e(r-a.length);i.fill(0),a=e.concat([i,a])}return n?a.toString(n):a}i.p224=i.secp224r1,i.p256=i.secp256r1=i.prime256v1,i.p192=i.secp192r1=i.prime192v1,i.p384=i.secp384r1,i.p521=i.secp521r1,o.prototype.generateKeys=function(t,e){return this.keys=this.curve.genKeyPair(),this.getPublicKey(t,e)},o.prototype.computeSecret=function(t,n,r){return n=n||"utf8",e.isBuffer(t)||(t=new e(t,n)),s(this.curve.keyFromPublic(t).getPublic().mul(this.keys.getPrivate()).getX(),r,this.curveType.byteLength)},o.prototype.getPublicKey=function(t,e){var n=this.keys.getPublic("compressed"===e,!0);return"hybrid"===e&&(n[n.length-1]%2?n[0]=7:n[0]=6),s(n,t)},o.prototype.getPrivateKey=function(t){return s(this.keys.getPrivate(),t)},o.prototype.setPublicKey=function(t,n){return n=n||"utf8",e.isBuffer(t)||(t=new e(t,n)),this.keys._importPublic(t),this},o.prototype.setPrivateKey=function(t,n){n=n||"utf8",e.isBuffer(t)||(t=new e(t,n));var r=new a(t);return r=r.toString(16),this.keys=this.curve.genKeyPair(),this.keys._importPrivate(r),this}}).call(this,n(5).Buffer)},function(t,e,n){e.publicEncrypt=n(360),e.privateDecrypt=n(361),e.privateEncrypt=function(t,n){return e.publicEncrypt(t,n,!0)},e.publicDecrypt=function(t,n){return e.privateDecrypt(t,n,!0)}},function(t,e,n){var r=n(34),a=n(4).Buffer;function i(t){var e=a.allocUnsafe(4);return e.writeUInt32BE(t,0),e}t.exports=function(t,e){for(var n,o=a.alloc(0),s=0;o.length<e;)n=i(s++),o=a.concat([o,r("sha1").update(t).update(n).digest()]);return o.slice(0,e)}},function(t,e){t.exports=function(t,e){for(var n=t.length,r=-1;++r<n;)t[r]^=e[r];return t}},function(t,e,n){var r=n(2),a=n(4).Buffer;t.exports=function(t,e){return a.from(t.toRed(r.mont(e.modulus)).redPow(new r(e.publicExponent)).fromRed().toArray())}},function(t,e,n){"use strict";(function(t,r){function a(){throw new Error("secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11")}var i=n(4),o=n(29),s=i.Buffer,u=i.kMaxLength,c=t.crypto||t.msCrypto,f=Math.pow(2,32)-1;function A(t,e){if("number"!=typeof t||t!=t)throw new TypeError("offset must be a number");if(t>f||t<0)throw new TypeError("offset must be a uint32");if(t>u||t>e)throw new RangeError("offset out of range")}function l(t,e,n){if("number"!=typeof t||t!=t)throw new TypeError("size must be a number");if(t>f||t<0)throw new TypeError("size must be a uint32");if(t+e>n||t>u)throw new RangeError("buffer too small")}function p(t,e,n,a){if(r.browser){var i=t.buffer,s=new Uint8Array(i,e,n);return c.getRandomValues(s),a?void r.nextTick((function(){a(null,t)})):t}if(!a)return o(n).copy(t,e),t;o(n,(function(n,r){if(n)return a(n);r.copy(t,e),a(null,t)}))}c&&c.getRandomValues||!r.browser?(e.randomFill=function(e,n,r,a){if(!(s.isBuffer(e)||e instanceof t.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');if("function"==typeof n)a=n,n=0,r=e.length;else if("function"==typeof r)a=r,r=e.length-n;else if("function"!=typeof a)throw new TypeError('"cb" argument must be a function');return A(n,e.length),l(r,n,e.length),p(e,n,r,a)},e.randomFillSync=function(e,n,r){void 0===n&&(n=0);if(!(s.isBuffer(e)||e instanceof t.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');A(n,e.length),void 0===r&&(r=e.length-n);return l(r,n,e.length),p(e,n,r)}):(e.randomFill=a,e.randomFillSync=a)}).call(this,n(10),n(12))},function(t,e,n){(function(t){var r,a,i,o;function s(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function u(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,(a=r.key,i=void 0,i=function(t,e){if("object"!==f(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!==f(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(a,"string"),"symbol"===f(i)?i:String(i)),r)}var a,i}function c(t,e,n){return e&&u(t.prototype,e),n&&u(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function f(t){return(f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}window,o=function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var a=e[r]={i:r,l:!1,exports:{}};return t[r].call(a.exports,a,a.exports,n),a.l=!0,a.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==f(t)&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var a in t)n.d(r,a,function(e){return t[e]}.bind(null,a));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=10)}([function(t,e,n){"use strict";(function(t){n.d(e,"a",(function(){return i}));var r=n(7),a=n.n(r),i=function(){function e(t){s(this,e),this.wasm=t}return c(e,[{key:"arrayToBuf",value:function(e){var n=this.wasm,r={ptr:null,len:0};if(!e)return r;var a=null;if(e instanceof Uint8Array||void 0!==t&&e instanceof t)a=e;else{if(!(e instanceof ArrayBuffer||e.__proto__.toString().includes("ArrayBuffer")))throw new Error("arrayToBuf() failed: Expected Uint8Array, Buffer, or\n ArrayBuffer");a=new Uint8Array(e)}return r.len=a.length,r.ptr=n._malloc(a.length),n.writeArrayToMemory(a,r.ptr),r}},{key:"arrayToSmartBuf",value:function(t){var e=this.wasm,n=this.arrayToBuf(t);return n.ptr&&setTimeout((function(){e._free(n.ptr),n.len=0,n.ptr=null}),0),n}},{key:"smartMalloc",value:function(t){var e=this.wasm,n=e._malloc(t);return setTimeout((function(){e._free(n)}),0),n}}],[{key:"bytesToHex",value:function(t){return t.reduce((function(t,e){return t+e.toString(16).padStart(2,"0")}),"")}},{key:"bytesToBinary",value:function(t){return t.reduce((function(t,e){return t+e.toString(2).padStart(8,"0")+" "}),"")}},{key:"hexToBytes",value:function(t){return new Uint8Array(t.match(/.{1,2}/g).map((function(t){return parseInt(t,16)})))}},{key:"randomBytes",value:function(t){if("undefined"!=typeof window&&"undefined"!==window.crypto){var e=new Uint8Array(t);return window.crypto.getRandomValues(e),e}return a.a.randomBytes(t)}}]),e}()}).call(this,n(3).Buffer)},function(t,e,n){"use strict";n.d(e,"a",(function(){return r}));var r=function(){function t(e){s(this,t),this.wasm=e,this.ptr=null,this.len=0}return c(t,[{key:"clear",value:function(){this.len=0}},{key:"free",value:function(){null!==this.ptr&&(this.wasm._free(this.ptr),this.len=0,this.ptr=null)}},{key:"resize",value:function(t){null!==this.ptr&&this.free(),this.len=t,this.ptr=this.wasm._malloc(t)}},{key:"ensureSize",value:function(t){(null===this.ptr||this.len<t)&&this.resize(t)}}]),t}()},function(t,e){t.exports=n(362)},function(t,e,n){"use strict";(function(t){
51
+ */!function(o,s){"use strict";"object"===i(t)&&t.exports?t.exports=s():void 0===(a="function"==typeof(r=s)?r.call(e,n,e,t):r)||(t.exports=a)}(0,(function(t){"use strict";var e=t&&t.SecondLevelDomains,n={list:{ac:" com gov mil net org ",ae:" ac co gov mil name net org pro sch ",af:" com edu gov net org ",al:" com edu gov mil net org ",ao:" co ed gv it og pb ",ar:" com edu gob gov int mil net org tur ",at:" ac co gv or ",au:" asn com csiro edu gov id net org ",ba:" co com edu gov mil net org rs unbi unmo unsa untz unze ",bb:" biz co com edu gov info net org store tv ",bh:" biz cc com edu gov info net org ",bn:" com edu gov net org ",bo:" com edu gob gov int mil net org tv ",br:" adm adv agr am arq art ato b bio blog bmd cim cng cnt com coop ecn edu eng esp etc eti far flog fm fnd fot fst g12 ggf gov imb ind inf jor jus lel mat med mil mus net nom not ntr odo org ppg pro psc psi qsl rec slg srv tmp trd tur tv vet vlog wiki zlg ",bs:" com edu gov net org ",bz:" du et om ov rg ",ca:" ab bc mb nb nf nl ns nt nu on pe qc sk yk ",ck:" biz co edu gen gov info net org ",cn:" ac ah bj com cq edu fj gd gov gs gx gz ha hb he hi hl hn jl js jx ln mil net nm nx org qh sc sd sh sn sx tj tw xj xz yn zj ",co:" com edu gov mil net nom org ",cr:" ac c co ed fi go or sa ",cy:" ac biz com ekloges gov ltd name net org parliament press pro tm ",do:" art com edu gob gov mil net org sld web ",dz:" art asso com edu gov net org pol ",ec:" com edu fin gov info med mil net org pro ",eg:" com edu eun gov mil name net org sci ",er:" com edu gov ind mil net org rochest w ",es:" com edu gob nom org ",et:" biz com edu gov info name net org ",fj:" ac biz com info mil name net org pro ",fk:" ac co gov net nom org ",fr:" asso com f gouv nom prd presse tm ",gg:" co net org ",gh:" com edu gov mil org ",gn:" ac com gov net org ",gr:" com edu gov mil net org ",gt:" com edu gob ind mil net org ",gu:" com edu gov net org ",hk:" com edu gov idv net org ",hu:" 2000 agrar bolt casino city co erotica erotika film forum games hotel info ingatlan jogasz konyvelo lakas media news org priv reklam sex shop sport suli szex tm tozsde utazas video ",id:" ac co go mil net or sch web ",il:" ac co gov idf k12 muni net org ",in:" ac co edu ernet firm gen gov i ind mil net nic org res ",iq:" com edu gov i mil net org ",ir:" ac co dnssec gov i id net org sch ",it:" edu gov ",je:" co net org ",jo:" com edu gov mil name net org sch ",jp:" ac ad co ed go gr lg ne or ",ke:" ac co go info me mobi ne or sc ",kh:" com edu gov mil net org per ",ki:" biz com de edu gov info mob net org tel ",km:" asso com coop edu gouv k medecin mil nom notaires pharmaciens presse tm veterinaire ",kn:" edu gov net org ",kr:" ac busan chungbuk chungnam co daegu daejeon es gangwon go gwangju gyeongbuk gyeonggi gyeongnam hs incheon jeju jeonbuk jeonnam k kg mil ms ne or pe re sc seoul ulsan ",kw:" com edu gov net org ",ky:" com edu gov net org ",kz:" com edu gov mil net org ",lb:" com edu gov net org ",lk:" assn com edu gov grp hotel int ltd net ngo org sch soc web ",lr:" com edu gov net org ",lv:" asn com conf edu gov id mil net org ",ly:" com edu gov id med net org plc sch ",ma:" ac co gov m net org press ",mc:" asso tm ",me:" ac co edu gov its net org priv ",mg:" com edu gov mil nom org prd tm ",mk:" com edu gov inf name net org pro ",ml:" com edu gov net org presse ",mn:" edu gov org ",mo:" com edu gov net org ",mt:" com edu gov net org ",mv:" aero biz com coop edu gov info int mil museum name net org pro ",mw:" ac co com coop edu gov int museum net org ",mx:" com edu gob net org ",my:" com edu gov mil name net org sch ",nf:" arts com firm info net other per rec store web ",ng:" biz com edu gov mil mobi name net org sch ",ni:" ac co com edu gob mil net nom org ",np:" com edu gov mil net org ",nr:" biz com edu gov info net org ",om:" ac biz co com edu gov med mil museum net org pro sch ",pe:" com edu gob mil net nom org sld ",ph:" com edu gov i mil net ngo org ",pk:" biz com edu fam gob gok gon gop gos gov net org web ",pl:" art bialystok biz com edu gda gdansk gorzow gov info katowice krakow lodz lublin mil net ngo olsztyn org poznan pwr radom slupsk szczecin torun warszawa waw wroc wroclaw zgora ",pr:" ac biz com edu est gov info isla name net org pro prof ",ps:" com edu gov net org plo sec ",pw:" belau co ed go ne or ",ro:" arts com firm info nom nt org rec store tm www ",rs:" ac co edu gov in org ",sb:" com edu gov net org ",sc:" com edu gov net org ",sh:" co com edu gov net nom org ",sl:" com edu gov net org ",st:" co com consulado edu embaixada gov mil net org principe saotome store ",sv:" com edu gob org red ",sz:" ac co org ",tr:" av bbs bel biz com dr edu gen gov info k12 name net org pol tel tsk tv web ",tt:" aero biz cat co com coop edu gov info int jobs mil mobi museum name net org pro tel travel ",tw:" club com ebiz edu game gov idv mil net org ",mu:" ac co com gov net or org ",mz:" ac co edu gov org ",na:" co com ",nz:" ac co cri geek gen govt health iwi maori mil net org parliament school ",pa:" abo ac com edu gob ing med net nom org sld ",pt:" com edu gov int net nome org publ ",py:" com edu gov mil net org ",qa:" com edu gov mil net org ",re:" asso com nom ",ru:" ac adygeya altai amur arkhangelsk astrakhan bashkiria belgorod bir bryansk buryatia cbg chel chelyabinsk chita chukotka chuvashia com dagestan e-burg edu gov grozny int irkutsk ivanovo izhevsk jar joshkar-ola kalmykia kaluga kamchatka karelia kazan kchr kemerovo khabarovsk khakassia khv kirov koenig komi kostroma kranoyarsk kuban kurgan kursk lipetsk magadan mari mari-el marine mil mordovia mosreg msk murmansk nalchik net nnov nov novosibirsk nsk omsk orenburg org oryol penza perm pp pskov ptz rnd ryazan sakhalin samara saratov simbirsk smolensk spb stavropol stv surgut tambov tatarstan tom tomsk tsaritsyn tsk tula tuva tver tyumen udm udmurtia ulan-ude vladikavkaz vladimir vladivostok volgograd vologda voronezh vrn vyatka yakutia yamal yekaterinburg yuzhno-sakhalinsk ",rw:" ac co com edu gouv gov int mil net ",sa:" com edu gov med net org pub sch ",sd:" com edu gov info med net org tv ",se:" a ac b bd c d e f g h i k l m n o org p parti pp press r s t tm u w x y z ",sg:" com edu gov idn net org per ",sn:" art com edu gouv org perso univ ",sy:" com edu gov mil net news org ",th:" ac co go in mi net or ",tj:" ac biz co com edu go gov info int mil name net nic org test web ",tn:" agrinet com defense edunet ens fin gov ind info intl mincom nat net org perso rnrt rns rnu tourism ",tz:" ac co go ne or ",ua:" biz cherkassy chernigov chernovtsy ck cn co com crimea cv dn dnepropetrovsk donetsk dp edu gov if in ivano-frankivsk kh kharkov kherson khmelnitskiy kiev kirovograd km kr ks kv lg lugansk lutsk lviv me mk net nikolaev od odessa org pl poltava pp rovno rv sebastopol sumy te ternopil uzhgorod vinnica vn zaporizhzhe zhitomir zp zt ",ug:" ac co go ne or org sc ",uk:" ac bl british-library co cym gov govt icnet jet lea ltd me mil mod national-library-scotland nel net nhs nic nls org orgn parliament plc police sch scot soc ",us:" dni fed isa kids nsn ",uy:" com edu gub mil net org ",ve:" co com edu gob info mil net org web ",vi:" co com k12 net org ",vn:" ac biz com edu gov health info int name net org pro ",ye:" co com gov ltd me net org plc ",yu:" ac co edu gov org ",za:" ac agric alt bourse city co cybernet db edu gov grondar iaccess imt inca landesign law mil net ngo nis nom olivetti org pix school tm web ",zm:" ac co com edu gov net org sch ",com:"ar br cn de eu gb gr hu jpn kr no qc ru sa se uk us uy za ",net:"gb jp se uk ",org:"ae",de:"com "},has:function(t){var e=t.lastIndexOf(".");if(e<=0||e>=t.length-1)return!1;var r=t.lastIndexOf(".",e-1);if(r<=0||r>=e-1)return!1;var a=n.list[t.slice(e+1)];return!!a&&a.indexOf(" "+t.slice(r+1,e)+" ")>=0},is:function(t){var e=t.lastIndexOf(".");if(e<=0||e>=t.length-1)return!1;if(t.lastIndexOf(".",e-1)>=0)return!1;var r=n.list[t.slice(e+1)];return!!r&&r.indexOf(" "+t.slice(0,e)+" ")>=0},get:function(t){var e=t.lastIndexOf(".");if(e<=0||e>=t.length-1)return null;var r=t.lastIndexOf(".",e-1);if(r<=0||r>=e-1)return null;var a=n.list[t.slice(e+1)];return a?a.indexOf(" "+t.slice(r+1,e)+" ")<0?null:t.slice(r+1):null},noConflict:function(){return t.SecondLevelDomains===this&&(t.SecondLevelDomains=e),this}};return n}))}).call(this,n(20)(t))},function(t,e,n){"use strict";var r=n(23).rotr32;function a(t,e,n){return t&e^~t&n}function i(t,e,n){return t&e^t&n^e&n}function o(t,e,n){return t^e^n}e.ft_1=function(t,e,n,r){return 0===t?a(e,n,r):1===t||3===t?o(e,n,r):2===t?i(e,n,r):void 0},e.ch32=a,e.maj32=i,e.p32=o,e.s0_256=function(t){return r(t,2)^r(t,13)^r(t,22)},e.s1_256=function(t){return r(t,6)^r(t,11)^r(t,25)},e.g0_256=function(t){return r(t,7)^r(t,18)^t>>>3},e.g1_256=function(t){return r(t,17)^r(t,19)^t>>>10}},function(t,e,n){"use strict";var r=n(23),a=n(40),i=n(100),o=n(17),s=r.sum32,u=r.sum32_4,c=r.sum32_5,f=i.ch32,A=i.maj32,l=i.s0_256,p=i.s1_256,d=i.g0_256,h=i.g1_256,y=a.BlockHash,g=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function b(){if(!(this instanceof b))return new b;y.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=g,this.W=new Array(64)}r.inherits(b,y),t.exports=b,b.blockSize=512,b.outSize=256,b.hmacStrength=192,b.padLength=64,b.prototype._update=function(t,e){for(var n=this.W,r=0;r<16;r++)n[r]=t[e+r];for(;r<n.length;r++)n[r]=u(h(n[r-2]),n[r-7],d(n[r-15]),n[r-16]);var a=this.h[0],i=this.h[1],y=this.h[2],g=this.h[3],b=this.h[4],m=this.h[5],v=this.h[6],I=this.h[7];for(o(this.k.length===n.length),r=0;r<n.length;r++){var w=c(I,p(b),f(b,m,v),this.k[r],n[r]),C=s(l(a),A(a,i,y));I=v,v=m,m=b,b=s(g,w),g=y,y=i,i=a,a=s(w,C)}this.h[0]=s(this.h[0],a),this.h[1]=s(this.h[1],i),this.h[2]=s(this.h[2],y),this.h[3]=s(this.h[3],g),this.h[4]=s(this.h[4],b),this.h[5]=s(this.h[5],m),this.h[6]=s(this.h[6],v),this.h[7]=s(this.h[7],I)},b.prototype._digest=function(t){return"hex"===t?r.toHex32(this.h,"big"):r.split32(this.h,"big")}},function(t,e,n){"use strict";var r=n(23),a=n(40),i=n(17),o=r.rotr64_hi,s=r.rotr64_lo,u=r.shr64_hi,c=r.shr64_lo,f=r.sum64,A=r.sum64_hi,l=r.sum64_lo,p=r.sum64_4_hi,d=r.sum64_4_lo,h=r.sum64_5_hi,y=r.sum64_5_lo,g=a.BlockHash,b=[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 m(){if(!(this instanceof m))return new m;g.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=b,this.W=new Array(160)}function v(t,e,n,r,a){var i=t&n^~t&a;return i<0&&(i+=4294967296),i}function I(t,e,n,r,a,i){var o=e&r^~e&i;return o<0&&(o+=4294967296),o}function w(t,e,n,r,a){var i=t&n^t&a^n&a;return i<0&&(i+=4294967296),i}function C(t,e,n,r,a,i){var o=e&r^e&i^r&i;return o<0&&(o+=4294967296),o}function E(t,e){var n=o(t,e,28)^o(e,t,2)^o(e,t,7);return n<0&&(n+=4294967296),n}function B(t,e){var n=s(t,e,28)^s(e,t,2)^s(e,t,7);return n<0&&(n+=4294967296),n}function k(t,e){var n=o(t,e,14)^o(t,e,18)^o(e,t,9);return n<0&&(n+=4294967296),n}function Q(t,e){var n=s(t,e,14)^s(t,e,18)^s(e,t,9);return n<0&&(n+=4294967296),n}function x(t,e){var n=o(t,e,1)^o(t,e,8)^u(t,e,7);return n<0&&(n+=4294967296),n}function S(t,e){var n=s(t,e,1)^s(t,e,8)^c(t,e,7);return n<0&&(n+=4294967296),n}function _(t,e){var n=o(t,e,19)^o(e,t,29)^u(t,e,6);return n<0&&(n+=4294967296),n}function M(t,e){var n=s(t,e,19)^s(e,t,29)^c(t,e,6);return n<0&&(n+=4294967296),n}r.inherits(m,g),t.exports=m,m.blockSize=1024,m.outSize=512,m.hmacStrength=192,m.padLength=128,m.prototype._prepareBlock=function(t,e){for(var n=this.W,r=0;r<32;r++)n[r]=t[e+r];for(;r<n.length;r+=2){var a=_(n[r-4],n[r-3]),i=M(n[r-4],n[r-3]),o=n[r-14],s=n[r-13],u=x(n[r-30],n[r-29]),c=S(n[r-30],n[r-29]),f=n[r-32],A=n[r-31];n[r]=p(a,i,o,s,u,c,f,A),n[r+1]=d(a,i,o,s,u,c,f,A)}},m.prototype._update=function(t,e){this._prepareBlock(t,e);var n=this.W,r=this.h[0],a=this.h[1],o=this.h[2],s=this.h[3],u=this.h[4],c=this.h[5],p=this.h[6],d=this.h[7],g=this.h[8],b=this.h[9],m=this.h[10],x=this.h[11],S=this.h[12],_=this.h[13],M=this.h[14],D=this.h[15];i(this.k.length===n.length);for(var R=0;R<n.length;R+=2){var O=M,j=D,T=k(g,b),N=Q(g,b),P=v(g,b,m,x,S),L=I(g,b,m,x,S,_),F=this.k[R],U=this.k[R+1],H=n[R],G=n[R+1],q=h(O,j,T,N,P,L,F,U,H,G),Y=y(O,j,T,N,P,L,F,U,H,G);O=E(r,a),j=B(r,a),T=w(r,a,o,s,u),N=C(r,a,o,s,u,c);var K=A(O,j,T,N),z=l(O,j,T,N);M=S,D=_,S=m,_=x,m=g,x=b,g=A(p,d,q,Y),b=l(d,d,q,Y),p=u,d=c,u=o,c=s,o=r,s=a,r=A(q,Y,K,z),a=l(q,Y,K,z)}f(this.h,0,r,a),f(this.h,2,o,s),f(this.h,4,u,c),f(this.h,6,p,d),f(this.h,8,g,b),f(this.h,10,m,x),f(this.h,12,S,_),f(this.h,14,M,D)},m.prototype._digest=function(t){return"hex"===t?r.toHex32(this.h,"big"):r.split32(this.h,"big")}},function(t,e,n){(function(t){var r=void 0!==t&&t||"undefined"!=typeof self&&self||window,a=Function.prototype.apply;function i(t,e){this._id=t,this._clearFn=e}e.setTimeout=function(){return new i(a.call(setTimeout,r,arguments),clearTimeout)},e.setInterval=function(){return new i(a.call(setInterval,r,arguments),clearInterval)},e.clearTimeout=e.clearInterval=function(t){t&&t.close()},i.prototype.unref=i.prototype.ref=function(){},i.prototype.close=function(){this._clearFn.call(r,this._id)},e.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},e.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},e._unrefActive=e.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=setTimeout((function(){t._onTimeout&&t._onTimeout()}),e))},n(199),e.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==t&&t.setImmediate||this&&this.setImmediate,e.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==t&&t.clearImmediate||this&&this.clearImmediate}).call(this,n(10))},function(t,e,n){var r=n(201);t.exports=r("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},function(t,e){t.exports={abi:[{constant:!0,inputs:[],name:"creator",outputs:[{name:"",type:"address"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"CAN_SEE",outputs:[{name:"",type:"uint8"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"customValues",type:"bytes32[]"},{name:"stakeholders",type:"address[]"}],name:"accessRequestV3",outputs:[{name:"",type:"bool"}],payable:!0,stateMutability:"payable",type:"function"},{constant:!0,inputs:[],name:"visibility",outputs:[{name:"",type:"uint8"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[],name:"kill",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"version",outputs:[{name:"",type:"bytes32"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"versionAPI",outputs:[{name:"",type:"bytes32"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"indexCategory",outputs:[{name:"",type:"uint8"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"newCreator",type:"address"}],name:"transferCreatorship",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"owner",outputs:[{name:"",type:"address"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"candidate",type:"address"}],name:"hasAccess",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"CAN_ACCESS",outputs:[{name:"",type:"uint8"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_visibility_code",type:"uint8"}],name:"setVisibility",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"contentSpace",outputs:[{name:"",type:"address"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"CAN_EDIT",outputs:[{name:"",type:"uint8"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{payable:!0,stateMutability:"payable",type:"fallback"},{anonymous:!1,inputs:[{indexed:!1,name:"requestNonce",type:"uint256"},{indexed:!1,name:"parentAddress",type:"address"},{indexed:!1,name:"contextHash",type:"bytes32"},{indexed:!1,name:"accessor",type:"address"},{indexed:!1,name:"requestTimestamp",type:"uint256"}],name:"AccessRequestV3",type:"event"},{anonymous:!1,inputs:[{indexed:!1,name:"contentSpace",type:"address"},{indexed:!1,name:"parentAddress",type:"address"},{indexed:!1,name:"visibility",type:"uint8"}],name:"VisibilityChanged",type:"event"}]}},function(t,e,n){var r=n(30),a=n(15),i=n(11),o=n(6),s=n(7);function u(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function c(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?u(Object(n),!0).forEach((function(e){i(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):u(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}var f=n(16),A=n(229),l=n(31),p=n(25),d=p.ValidateLibrary,h=p.ValidateObject,y=p.ValidateVersion,g=p.ValidatePartHash,b=p.ValidateWriteToken,m=p.ValidateParameters,v=n(107);e.permissionLevels={owner:{short:"Owner Only",description:"Only the owner has access to the object and ability to change permissions",settings:{visibility:0,statusCode:-1,kmsConk:!1}},editable:{short:"Editable",description:"Members of the editors group have full access to the object and the ability to change permissions",settings:{visibility:0,statusCode:-1,kmsConk:!0}},viewable:{short:"Viewable",description:"In addition to editors, members of the 'accessor' group can have read-only access to the object including playing video and retrieving metadata, images and documents",settings:{visibility:0,statusCode:0,kmsConk:!0}},listable:{short:"Publicly Listable",description:"Anyone can list the public portion of this object but only accounts with specific rights can access",settings:{visibility:1,statusCode:0,kmsConk:!0}},public:{short:"Public",description:"Anyone can access this object",settings:{visibility:10,statusCode:0,kmsConk:!0}}},e.Visibility=function(){var t=s(o.mark((function t(e){var n,r,a,i=this;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.id,r=e.clearCache,t.prev=1,a=this.utils.HashToAddress(n),r&&delete this.visibilityInfo[a],this.visibilityInfo[a]||(this.visibilityInfo[a]=new Promise(function(){var t=s(o.mark((function t(e,r){return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,i.authClient.ContractHasMethod({contractAddress:a,methodName:"visibility"});case 3:if(t.sent){t.next=7;break}return e(0),t.abrupt("return");case 7:return t.t0=e,t.next=10,i.CallContractMethod({contractAddress:i.utils.HashToAddress(n),methodName:"visibility"});case 10:t.t1=t.sent,(0,t.t0)(t.t1),t.next=17;break;case 14:t.prev=14,t.t2=t.catch(0),r(t.t2);case 17:case"end":return t.stop()}}),t,null,[[0,14]])})));return function(e,n){return t.apply(this,arguments)}}())),t.prev=5,t.next=8,this.visibilityInfo[a];case 8:return t.abrupt("return",t.sent);case 11:throw t.prev=11,t.t0=t.catch(5),delete this.visibilityInfo[a],t.t0;case 15:t.next=22;break;case 17:if(t.prev=17,t.t1=t.catch(1),"CALL_EXCEPTION"!==t.t1.code){t.next=21;break}return t.abrupt("return",0);case 21:throw t.t1;case 22:case"end":return t.stop()}}),t,this,[[1,17],[5,11]])})));return function(e){return t.apply(this,arguments)}}(),e.Permission=function(){var t=s(o.mark((function t(e){var n,r,a,i,s,u,c,f,A=this;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.objectId,r=e.clearCache,h(n),t.next=4,this.AccessType({id:n});case 4:if(t.t0=t.sent,t.t1=this.authClient.ACCESS_TYPES.OBJECT,t.t0===t.t1){t.next=8;break}throw Error("Permission only valid for normal content objects: "+n);case 8:return t.next=10,this.Visibility({id:n,clearCache:r});case 10:return a=t.sent,t.next=13,this.CallContractMethod({contractAddress:this.utils.HashToAddress(n),methodName:"addressKMS"});case 13:if(i=t.sent,s=i&&"ikms".concat(this.utils.AddressToHash(i)),u=!1,!s){t.next=27;break}return t.t2=this,t.next=20,this.ContentObjectLibraryId({objectId:n});case 20:return t.t3=t.sent,t.t4=n,t.t5="eluv.caps.".concat(s),t.t6={libraryId:t.t3,objectId:t.t4,metadataSubtree:t.t5},t.next=26,t.t2.ContentObjectMetadata.call(t.t2,t.t6);case 26:u=!!t.sent;case 27:return t.next=29,this.CallContractMethod({contractAddress:this.utils.HashToAddress(n),methodName:"statusCode"});case 29:return c=t.sent,c=parseInt(c._hex,16),(f=Object.keys(this.permissionLevels).filter((function(t){var e=A.permissionLevels[t].settings;return a>=e.visibility&&c>=e.statusCode&&u===e.kmsConk})))||(f=u?["editable"]:["owner"]),t.abrupt("return",f.slice(-1)[0]);case 34:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.DefaultKMSAddress=s(o.mark((function t(){var e,n,r,a=arguments;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e=a.length>0&&void 0!==a[0]?a[0]:{},n=e.tenantId,t.t0=n,!t.t0){t.next=8;break}return t.next=5,this.AccessType({id:n});case 5:t.t1=t.sent,t.t2=this.authClient.ACCESS_TYPES.TENANT,t.t0=t.t1===t.t2;case 8:if(!t.t0){t.next=14;break}return t.next=11,this.CallContractMethod({contractAddress:this.utils.HashToAddress(n),methodName:"addressKMS"});case 11:if(!(r=t.sent)){t.next=14;break}return t.abrupt("return",r);case 14:return t.next=16,this.CallContractMethod({contractAddress:this.contentSpaceAddress,methodName:"addressKMS"});case 16:return t.abrupt("return",t.sent);case 17:case"end":return t.stop()}}),t,this)}))),e.ContentSpaceId=function(){return this.contentSpaceId},e.ContentTypeOwner=function(){var t=s(o.mark((function t(e){var n,r,a,i;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.name,r=e.typeId,a=e.versionHash,t.next=3,this.ContentType({name:n,typeId:r,versionHash:a});case 3:return i=t.sent,t.t0=this.utils,t.next=7,this.ethClient.CallContractMethod({contractAddress:this.utils.HashToAddress(i.id),methodName:"owner",methodArgs:[]});case 7:return t.t1=t.sent,t.abrupt("return",t.t0.FormatAddress.call(t.t0,t.t1));case 9:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.ContentType=function(){var t=s(o.mark((function t(e){var n,r,a,i,s,u,c;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.name,r=e.typeId,a=e.versionHash,i=e.publicOnly,s=void 0!==i&&i,this.Log("Retrieving content type: ".concat(n||r||a)),a&&(r=this.utils.DecodeVersionHash(a).objectId),!n){t.next=13;break}return this.Log("Looking up type by name in content space metadata..."),t.prev=5,t.next=8,this.ContentObjectMetadata({libraryId:this.contentSpaceLibraryId,objectId:this.contentSpaceObjectId,metadataSubtree:f("public","contentTypes",n)});case 8:r=t.sent,t.next=13;break;case 11:t.prev=11,t.t0=t.catch(5);case 13:if(r){t.next=23;break}return this.Log("Looking up type by name in available types..."),t.next=17,this.ContentTypes();case 17:if(u=t.sent,!n){t.next=22;break}return t.abrupt("return",Object.values(u).find((function(t){return(t.name||"").toLowerCase()===n.toLowerCase()})));case 22:return t.abrupt("return",Object.values(u).find((function(t){return t.hash===a})));case 23:if(a){t.next=27;break}return t.next=26,this.LatestVersionHash({objectId:r});case 26:a=t.sent;case 27:if(t.prev=27,this.Log("Looking up type by ID..."),!s){t.next=39;break}return t.next=32,this.ContentObjectMetadata({libraryId:this.contentSpaceLibraryId,objectId:r,versionHash:a,metadataSubtree:"public"});case 32:if(t.t1=t.sent,t.t1){t.next=35;break}t.t1={};case 35:t.t2=t.t1,c={public:t.t2},t.next=45;break;case 39:return t.next=41,this.ContentObjectMetadata({libraryId:this.contentSpaceLibraryId,objectId:r,versionHash:a});case 41:if(t.t3=t.sent,t.t3){t.next=44;break}t.t3={};case 44:c=t.t3;case 45:return t.abrupt("return",{id:r,hash:a,name:c.public&&c.public.name||c.name||r,meta:c});case 48:throw t.prev=48,t.t4=t.catch(27),this.Log("Error looking up content type:"),this.Log(t.t4),new Error("Content Type ".concat(n||r," is invalid"));case 53:case"end":return t.stop()}}),t,this,[[5,11],[27,48]])})));return function(e){return t.apply(this,arguments)}}(),e.ContentTypes=s(o.mark((function t(){var e,n,r,a=this;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.contentTypes=this.contentTypes||{},this.Log("Looking up all available content types"),t.next=4,this.Collection({collectionType:"contentTypes"});case 4:return e=t.sent,this.Log("Personally available types:"),this.Log(e),n={},t.prev=8,t.next=11,this.ContentObjectMetadata({libraryId:this.contentSpaceLibraryId,objectId:this.contentSpaceObjectId,metadataSubtree:"public/contentTypes"});case 11:if(t.t0=t.sent,t.t0){t.next=14;break}t.t0={};case 14:n=t.t0,t.next=19;break;case 17:t.prev=17,t.t1=t.catch(8);case 19:return r=Object.values(n).map((function(t){return a.utils.HashToAddress(t)})),this.Log("Content space types:"),this.Log(r),e=e.concat(r).filter((function(t){return t})).map((function(t){return a.utils.FormatAddress(t)})).filter((function(t,e,n){return n.indexOf(t)===e})),t.next=25,Promise.all(e.map(function(){var t=s(o.mark((function t(e){var n;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=a.utils.AddressToObjectId(e),a.contentTypes[n]){t.next=11;break}return t.prev=2,t.next=5,a.ContentType({typeId:n,publicOnly:!0});case 5:a.contentTypes[n]=t.sent,t.next=11;break;case 8:t.prev=8,t.t0=t.catch(2),console.error(t.t0);case 11:case"end":return t.stop()}}),t,null,[[2,8]])})));return function(e){return t.apply(this,arguments)}}()));case 25:return t.abrupt("return",this.contentTypes);case 26:case"end":return t.stop()}}),t,this,[[8,17]])}))),e.ContentLibraries=s(o.mark((function t(){var e,n=this;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.Collection({collectionType:"libraries"});case 2:return e=t.sent,t.abrupt("return",e.map((function(t){return n.utils.AddressToLibraryId(t)})));case 4:case"end":return t.stop()}}),t,this)}))),e.ContentLibrary=function(){var t=s(o.mark((function t(e){var n,r,a;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,d(n),r=f("qlibs",n),t.t0=this.utils,t.t1=this.HttpClient,t.next=7,this.authClient.AuthorizationHeader({libraryId:n});case 7:return t.t2=t.sent,t.t3=r,t.t4={headers:t.t2,method:"GET",path:t.t3},t.t5=t.t1.Request.call(t.t1,t.t4),t.next=13,t.t0.ResponseToJson.call(t.t0,t.t5);case 13:return a=t.sent,t.abrupt("return",c(c({},a),{},{meta:a.meta||{}}));case 15:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.ContentLibraryOwner=function(){var t=s(o.mark((function t(e){var n;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,d(n),t.t0=this.utils,t.next=5,this.ethClient.CallContractMethod({contractAddress:this.utils.HashToAddress(n),methodName:"owner",methodArgs:[]});case 5:return t.t1=t.sent,t.abrupt("return",t.t0.FormatAddress.call(t.t0,t.t1));case 7:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.LibraryContentTypes=function(){var t=s(o.mark((function t(e){var n,r,a,i=this;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,d(n),this.Log("Retrieving library content types for ".concat(n)),t.next=5,this.ethClient.CallContractMethod({contractAddress:this.utils.HashToAddress(n),methodName:"contentTypesLength",methodArgs:[]});case 5:if(r=t.sent.toNumber(),this.Log("".concat(r," types")),0!==r){t.next=9;break}return t.abrupt("return",{});case 9:return a={},t.next=12,Promise.all(Array.from(new Array(r),function(){var t=s(o.mark((function t(e,r){var s,u;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,i.ethClient.CallContractMethod({contractAddress:i.utils.HashToAddress(n),methodName:"contentTypes",methodArgs:[r]});case 2:return s=t.sent,u=i.utils.AddressToObjectId(s),t.next=6,i.ContentType({typeId:u});case 6:a[u]=t.sent;case 7:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}()));case 12:return this.Log(a),t.abrupt("return",a);case 14:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.ContentObjects=function(){var t=s(o.mark((function t(e){var n,r,a,i,s,u,c;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.filterOptions,a=void 0===r?{}:r,d(n),this.Log("Retrieving content objects from ".concat(n)),i=f("qlibs",n,"q"),s={filter:[]},a.cacheId&&(s.cache_id=a.cacheId),a.start&&(s.start=a.start),a.limit&&(s.limit=a.limit),a.select&&(s.select=a.select),a.sort&&(s.sort_by=a.sort,a.sortDesc&&(s.sort_descending=!0)),u={eq:":eq:",neq:":ne:",lt:":lt:",lte:":le:",gt:":gt:",gte:":ge:",cnt:":co:",ncnt:":nc:"},c=function(t){var e=t.key,n=t.type,r=t.filter;s.filter.push("".concat(e).concat(u[n]).concat(r))},a.filter&&(Array.isArray(a.filter)?a.filter.forEach((function(t){return c(t)})):c(a.filter)),this.Log("Filter options:"),this.Log(a),t.t0=this.utils,t.t1=this.HttpClient,t.next=19,this.authClient.AuthorizationHeader({libraryId:n});case 19:return t.t2=t.sent,t.t3=i,t.t4=s,t.t5={headers:t.t2,method:"GET",path:t.t3,queryParams:t.t4},t.t6=t.t1.Request.call(t.t1,t.t5),t.next=26,t.t0.ResponseToJson.call(t.t0,t.t6);case 26:return t.abrupt("return",t.sent);case 27:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.ContentObject=function(){var t=s(o.mark((function t(e){var n,r,a,i,s;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,a=e.versionHash,i=e.writeToken,m({libraryId:n,objectId:r,versionHash:a}),this.Log("Retrieving content object: ".concat(n||""," ").concat(i||a||r)),a&&(r=this.utils.DecodeVersionHash(a).objectId),s=f("q",i||a||r),t.t0=this.utils,t.t1=this.HttpClient,t.next=9,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,versionHash:a});case 9:return t.t2=t.sent,t.t3=s,t.t4={headers:t.t2,method:"GET",path:t.t3},t.t5=t.t1.Request.call(t.t1,t.t4),t.next=15,t.t0.ResponseToJson.call(t.t0,t.t5);case 15:return t.abrupt("return",t.sent);case 16:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.ContentObjectOwner=function(){var t=s(o.mark((function t(e){var n;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.objectId,h(n),this.Log("Retrieving content object owner: ".concat(n)),t.t0=this.utils,t.next=6,this.ethClient.CallContractMethod({contractAddress:this.utils.HashToAddress(n),methodName:"owner",methodArgs:[]});case 6:return t.t1=t.sent,t.abrupt("return",t.t0.FormatAddress.call(t.t0,t.t1));case 8:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.ContentObjectTenantId=function(){var t=s(o.mark((function t(e){var n,r;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.objectId,(r=e.versionHash)?y(r):h(n),r&&(n=this.utils.DecodeVersionHash(r).objectId),this.objectTenantIds[n]){t.next=7;break}return t.next=6,this.authClient.MakeElvMasterCall({methodName:"elv_getTenantById",params:[this.contentSpaceId,n]});case 6:this.objectTenantIds[n]=t.sent;case 7:return t.abrupt("return",this.objectTenantIds[n]);case 8:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.ContentObjectLibraryId=function(){var t=s(o.mark((function t(e){var n,r,a=this;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.objectId,(r=e.versionHash)?y(r):h(n),r&&(n=this.utils.DecodeVersionHash(r).objectId),t.next=5,this.authClient.AccessType(n);case 5:t.t0=t.sent,t.next=t.t0===this.authClient.ACCESS_TYPES.LIBRARY?8:t.t0===this.authClient.ACCESS_TYPES.OBJECT?9:t.t0===this.authClient.ACCESS_TYPES.OTHER?20:21;break;case 8:return t.abrupt("return",this.utils.AddressToLibraryId(this.utils.HashToAddress(n)));case 9:return this.objectLibraryIds[n]||(this.Log("Retrieving content object library ID: ".concat(n||r)),this.objectLibraryIds[n]=new Promise(function(){var t=s(o.mark((function t(e,r){return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.t0=e,t.t1=a.utils,t.next=5,a.CallContractMethod({contractAddress:a.utils.HashToAddress(n),methodName:"libraryAddress"});case 5:t.t2=t.sent,t.t3=t.t1.AddressToLibraryId.call(t.t1,t.t2),(0,t.t0)(t.t3),t.next=13;break;case 10:t.prev=10,t.t4=t.catch(0),r(t.t4);case 13:case"end":return t.stop()}}),t,null,[[0,10]])})));return function(e,n){return t.apply(this,arguments)}}())),t.prev=10,t.next=13,this.objectLibraryIds[n];case 13:return t.abrupt("return",t.sent);case 16:throw t.prev=16,t.t1=t.catch(10),delete this.objectLibraryIds[n],t.t1;case 20:throw Error("Unable to retrieve library ID for ".concat(r||n,": Unknown type. (wrong network or deleted object?)"));case 21:return t.abrupt("return",this.contentSpaceLibraryId);case 22:case"end":return t.stop()}}),t,this,[[10,16]])})));return function(e){return t.apply(this,arguments)}}(),e.ProduceMetadataLinks=function(){var t=s(o.mark((function t(e){var n,r,i,u,A,l,p,d,h,y=this;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,i=e.versionHash,u=e.path,A=void 0===u?"/":u,l=e.metadata,p=e.authorizationToken,d=e.noAuth,l&&"object"===a(l)){t.next=3;break}return t.abrupt("return",l);case 3:if(!Array.isArray(l)){t.next=7;break}return t.next=6,this.utils.LimitedMap(5,l,function(){var t=s(o.mark((function t(e,a){return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,y.ProduceMetadataLinks({libraryId:n,objectId:r,versionHash:i,path:f(A,a.toString()),metadata:e,authorizationToken:p,noAuth:d});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}());case 6:return t.abrupt("return",t.sent);case 7:if(!l["/"]||!l["/"].match(/\.\/(rep|files)\/.+/)&&!l["/"].match(/^\/?qfab\/([\w]+)\/?(rep|files)\/.+/)){t.next=16;break}return t.t0=c,t.t1=c({},l),t.t2={},t.next=13,this.LinkUrl({libraryId:n,objectId:r,versionHash:i,linkPath:A,authorizationToken:p,noAuth:d});case 13:return t.t3=t.sent,t.t4={url:t.t3},t.abrupt("return",(0,t.t0)(t.t1,t.t2,t.t4));case 16:return h={},t.next=19,this.utils.LimitedMap(5,Object.keys(l),function(){var t=s(o.mark((function t(e){return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,y.ProduceMetadataLinks({libraryId:n,objectId:r,versionHash:i,path:f(A,e),metadata:l[e],authorizationToken:p,noAuth:d});case 2:h[e]=t.sent;case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}());case 19:return t.abrupt("return",h);case 20:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.MetadataAuth=function(){var t=s(o.mark((function t(e){var n,r,a,i,s,u,c,f,A,l,p,d,h;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,a=e.versionHash,i=e.path,s=void 0===i?"/":i,u=e.channelAuth,c=void 0!==u&&u,f=e.noAuth,A=void 0!==f&&f,m({libraryId:n,objectId:r,versionHash:a}),a&&(r=this.utils.DecodeVersionHash(a).objectId),A=this.noAuth||A||this.staticToken,l=A,A){t.next=14;break}return t.next=8,this.Visibility({id:r});case 8:return d=t.sent,t.next=11,this.AccessType({id:r});case 11:p=t.sent,l=(s||"").replace(/^\/+/,"").startsWith("public"),A=d>=10||l&&d>=1;case 14:if(!this.oauthToken){t.next=22;break}return t.next=17,this.authClient.KMSAddress({objectId:r,versionHash:a});case 17:if(!(h=t.sent)||this.utils.EqualAddress(h,this.utils.nullAddress)){t.next=22;break}return t.next=21,this.authClient.AuthorizationToken({libraryId:n,objectId:r,versionHash:a,channelAuth:!0,oauthToken:this.oauthToken});case 21:return t.abrupt("return",t.sent);case 22:if(this.inaccessibleLibraries[n]||!l||p!==this.authClient.ACCESS_TYPES.OBJECT||c){t.next=48;break}if(t.prev=23,t.t0=this.authClient,t.t1=n,t.t1){t.next=30;break}return t.next=29,this.ContentObjectLibraryId({objectId:r,versionHash:a});case 29:t.t1=t.sent;case 30:return t.t2=t.t1,t.t3=A,t.t4={libraryId:t.t2,noAuth:t.t3},t.next=35,t.t0.AuthorizationToken.call(t.t0,t.t4);case 35:return t.abrupt("return",t.sent);case 38:if(t.prev=38,t.t5=t.catch(23),!t.t5.message||!t.t5.message.toLowerCase().startsWith("access denied")){t.next=45;break}return this.inaccessibleLibraries[n]=!0,t.next=44,this.authClient.AuthorizationToken({libraryId:n,objectId:r,versionHash:a,noAuth:A,channelAuth:c});case 44:return t.abrupt("return",t.sent);case 45:throw t.t5;case 46:t.next=51;break;case 48:return t.next=50,this.authClient.AuthorizationToken({libraryId:n,objectId:r,versionHash:a,noAuth:A,channelAuth:c});case 50:return t.abrupt("return",t.sent);case 51:case"end":return t.stop()}}),t,this,[[23,38]])})));return function(e){return t.apply(this,arguments)}}(),e.ContentObjectMetadata=function(){var t=s(o.mark((function t(e){var n,r,a,i,s,u,l,p,d,h,y,g,b,I,w,C,E,B,k,Q,x,S,_,M,D,R,O,j,T,N,P,L=arguments;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,a=e.versionHash,i=e.writeToken,s=e.metadataSubtree,u=void 0===s?"/":s,l=e.localizationSubtree,p=e.queryParams,d=void 0===p?{}:p,h=e.select,y=void 0===h?[]:h,g=e.remove,b=void 0===g?[]:g,I=e.authorizationToken,w=e.noAuth,C=void 0!==w&&w,E=e.resolveLinks,B=void 0!==E&&E,k=e.resolveIncludeSource,Q=void 0!==k&&k,x=e.resolveIgnoreErrors,S=void 0!==x&&x,_=e.linkDepthLimit,M=void 0===_?1:_,D=e.produceLinkUrls,R=void 0!==D&&D,m({libraryId:n,objectId:r,versionHash:a}),this.Log("Retrieving content object metadata: ".concat(n||""," ").concat(r||a," ").concat(i||"","\n Subtree: ").concat(u)),d=c({},d||{}),a&&(r=this.utils.DecodeVersionHash(a).objectId),O=f("q",i||a||r,"meta",u),a){t.next=12;break}if(n){t.next=11;break}return t.next=10,this.ContentObjectLibraryId({objectId:r});case 10:n=t.sent;case 11:O=f("qlibs",n,O);case 12:return t.next=14,this.MetadataAuth({libraryId:n,objectId:r,versionHash:a,path:u,noAuth:C});case 14:return j=t.sent,T=[I,d.authorization,j].flat().filter((function(t){return t})),delete d.authorization,t.prev=17,t.next=20,this.utils.ResponseToJson(this.HttpClient.Request({headers:{Authorization:T.map((function(t){return"Bearer ".concat(t)}))},queryParams:c(c({},d),{},{select:y,remove:b,link_depth:M,resolve:B,resolve_include_source:Q,resolve_ignore_errors:S}),method:"GET",path:O}));case 20:N=t.sent,t.next=33;break;case 23:if(t.prev=23,t.t0=t.catch(17),404===t.t0.status){t.next=27;break}throw t.t0;case 27:if(!A.get(t.t0.body,"errors[0].cause.cause.cause.qwtoken")){t.next=32;break}throw t.t0;case 32:N="/"===u?{}:void 0;case 33:if(!R){t.next=37;break}return t.next=36,this.ProduceMetadataLinks({libraryId:n,objectId:r,versionHash:a,path:u,metadata:N,authorizationToken:I,noAuth:C});case 36:N=t.sent;case 37:if(l){t.next=39;break}return t.abrupt("return",N);case 39:return t.prev=39,t.next=42,this.ContentObjectMetadata(c(c({},L[0]),{},{metadataSubtree:l,localizationSubtree:void 0}));case 42:return P=t.sent,t.abrupt("return",v({},N,P,(function(t,e){return null===e||""===e?t:void 0})));case 46:return t.prev=46,t.t1=t.catch(39),this.Log(t.t1,!0),t.abrupt("return",N);case 50:case"end":return t.stop()}}),t,this,[[17,23],[39,46]])})));return function(e){return t.apply(this,arguments)}}(),e.AssetMetadata=function(){var t=s(o.mark((function t(e){var n,a,i,s,u,A,l,p,d,h=this;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,a=e.objectId,i=e.versionHash,s=e.metadata,u=e.localization,A=e.noAuth,l=e.produceLinkUrls,p=void 0!==l&&l,m({libraryId:n,objectId:a,versionHash:i}),a||(a=this.utils.DecodeVersionHash(i).objectId),s){t.next=12;break}return t.next=6,this.ContentObjectMetadata({libraryId:n,objectId:a,versionHash:i,metadataSubtree:"public/asset_metadata",resolveLinks:!0,linkDepthLimit:2,resolveIgnoreErrors:!0,produceLinkUrls:p,noAuth:A});case 6:if(t.t0=t.sent,t.t0){t.next=9;break}t.t0={};case 9:s=t.t0,t.next=16;break;case 12:if(!p){t.next=16;break}return t.next=15,this.ProduceMetadataLinks({libraryId:n,objectId:a,versionHash:i,path:f("public","asset_metadata"),metadata:s,noAuth:A});case 15:s=t.sent;case 16:return s.info||(s.info={}),d=c({},s),u&&u.reverse().forEach((function(t){var e,n=(e=h.utils).SafeTraverse.apply(e,[s].concat(r(t)))||{};d=v({},d,n,(function(t,e){return null===e||""===e?t:void 0}))})),t.abrupt("return",d);case 20:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.ContentObjectVersions=function(){var t=s(o.mark((function t(e){var n,r,a;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,m({libraryId:n,objectId:r}),this.Log("Retrieving content object versions: ".concat(n||""," ").concat(r)),a=f("qid",r),t.t0=this.utils,t.t1=this.HttpClient,t.next=8,this.authClient.AuthorizationHeader({libraryId:n,objectId:r});case 8:return t.t2=t.sent,t.t3=a,t.t4={headers:t.t2,method:"GET",path:t.t3},t.t5=t.t1.Request.call(t.t1,t.t4),t.abrupt("return",t.t0.ResponseToJson.call(t.t0,t.t5));case 13:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.LatestVersionHash=function(){var t=s(o.mark((function t(e){var n,r,a,i;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.objectId,(r=e.versionHash)&&(n=this.utils.DecodeVersionHash(r).objectId),h(n),t.prev=3,t.next=6,this.CallContractMethod({contractAddress:this.utils.HashToAddress(n),methodName:"objectHash"});case 6:a=t.sent,t.next=11;break;case 9:t.prev=9,t.t0=t.catch(3);case 11:if(a){t.next=25;break}return t.prev=12,t.next=15,this.CallContractMethod({contractAddress:this.utils.HashToAddress(n),methodName:"countVersionHashes"});case 15:i=t.sent,t.next=20;break;case 18:t.prev=18,t.t1=t.catch(12);case 20:if(i.toNumber()){t.next=22;break}throw Error("Unable to determine latest version hash for ".concat(r||n," - Item deleted?"));case 22:return t.next=24,this.CallContractMethod({contractAddress:this.utils.HashToAddress(n),methodName:"versionHashes",methodArgs:[i-1]});case 24:a=t.sent;case 25:return t.abrupt("return",a);case 26:case"end":return t.stop()}}),t,this,[[3,9],[12,18]])})));return function(e){return t.apply(this,arguments)}}(),e.AvailableDRMs=s(o.mark((function t(){var e,n,r,a,i,s,u,c,f;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e=["clear","aes-128"],"undefined"!=typeof window){t.next=3;break}return t.abrupt("return",e);case 3:if(window.navigator&&window.navigator.userAgent&&((n=window.navigator.userAgent.match(/(iPad|iPhone|iphone|iPod).*?(OS |os |OS_)(\d+((_|\.)\d)?((_|\.)\d)?)/))&&n[3]&&(r=n[3].split("_"),a=parseInt(r[0]),i=parseInt(r[1]),(a>13||13===a&&i>=1)&&(e[1]="sample-aes",e[2]="fairplay")),/^((?!chrome|android).)*safari/i.test(window.navigator.userAgent)&&(s=window.navigator.userAgent.match(/.+Version\/(\d+)\.(\d+)/))&&s[2]&&(u=parseInt(s[1]),c=parseInt(s[2]),(u>13||13===u&&c>=1)&&(e[1]="sample-aes",e[2]="fairplay"))),"undefined"==typeof window||"function"==typeof window.navigator.requestMediaKeySystemAccess){t.next=6;break}return t.abrupt("return",e);case 6:return t.prev=6,f=[{initDataTypes:["cenc"],audioCapabilities:[{contentType:'audio/mp4;codecs="mp4a.40.2"'}],videoCapabilities:[{contentType:'video/mp4;codecs="avc1.42E01E"'}]}],t.next=10,navigator.requestMediaKeySystemAccess("com.widevine.alpha",f);case 10:e.push("widevine"),t.next=15;break;case 13:t.prev=13,t.t0=t.catch(6);case 15:return t.abrupt("return",e);case 16:case"end":return t.stop()}}),t,null,[[6,13]])}))),e.PlayoutPathResolution=function(){var t=s(o.mark((function t(e){var n,r,a,i,s,u,c,A,l,p,d,h,y,g,b,m,v;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,a=e.versionHash,i=e.writeToken,s=e.linkPath,u=e.handler,c=e.offering,A=void 0===c?"":c,l=e.signedLink,p=void 0!==l&&l,d=e.authorizationToken,n){t.next=5;break}return t.next=4,this.ContentObjectLibraryId({objectId:r});case 4:n=t.sent;case 5:if(a){t.next=9;break}return t.next=8,this.LatestVersionHash({objectId:r});case 8:a=t.sent;case 9:if(h=f("qlibs",n,"q",i||a,"rep",u,A,"options.json"),!s){t.next=26;break}return t.next=13,this.ContentObjectMetadata({libraryId:n,objectId:r,versionHash:a,writeToken:i,metadataSubtree:s,resolveLinks:!1,resolveIgnoreErrors:!0,resolveIncludeSource:!0,authorizationToken:d});case 13:if(v=t.sent,m=!!v&&!!v["/"]&&!v["/"].endsWith("options.json"),h=f("qlibs",n,"q",i||a,"meta",s),p){t.next=25;break}return t.next=19,this.LinkTarget({libraryId:n,objectId:r,versionHash:a,writeToken:i,linkPath:s,linkInfo:v,authorizationToken:d});case 19:return b=t.sent,g=this.utils.DecodeVersionHash(b).objectId,t.next=23,this.ContentObjectLibraryId({objectId:g});case 23:y=t.sent,m||A||(h=f("q",b,"rep",u,"options.json"));case 25:m&&(h=f(h,A,"options.json"));case 26:return t.abrupt("return",{path:h,multiOfferingLink:m,linkTarget:{libraryId:y,objectId:g,versionHash:b}});case 27:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.AvailableOfferings=function(){var t=s(o.mark((function t(e){var n,r,a,i,s,u,c,f,A,l,p,d;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.objectId,r=e.versionHash,a=e.writeToken,i=e.linkPath,s=e.signedLink,u=e.directLink,c=e.handler,f=void 0===c?"playout":c,A=e.authorizationToken,n||(n=this.utils.DecodeVersionHash(r).objectId),!u){t.next=15;break}return t.t0=this,t.next=6,this.ContentObjectLibraryId({objectId:n});case 6:return t.t1=t.sent,t.t2=n,t.t3=r,t.t4=i,t.t5=A,t.t6={libraryId:t.t1,objectId:t.t2,versionHash:t.t3,metadataSubtree:t.t4,resolveLinks:!0,authorizationToken:t.t5},t.next=14,t.t0.ContentObjectMetadata.call(t.t0,t.t6);case 14:return t.abrupt("return",t.sent);case 15:return t.next=17,this.PlayoutPathResolution({objectId:n,versionHash:r,writeToken:a,linkPath:i,signedLink:s,handler:f,authorizationToken:A});case 17:return l=t.sent,p=l.path,t.prev=19,t.t7=A,t.next=23,this.authClient.AuthorizationToken({objectId:n,channelAuth:!0,oauthToken:this.oauthToken});case 23:return t.t8=t.sent,d=[t.t7,t.t8].flat().filter((function(t){return t})),t.next=27,this.utils.ResponseToJson(this.HttpClient.Request({path:p,method:"GET",headers:{Authorization:"Bearer ".concat(d.join(","))}}));case 27:return t.abrupt("return",t.sent);case 30:if(t.prev=30,t.t9=t.catch(19),!t.t9.status||500!==parseInt(t.t9.status)){t.next=34;break}return t.abrupt("return",{});case 34:throw t.t9;case 35:case"end":return t.stop()}}),t,this,[[19,30]])})));return function(e){return t.apply(this,arguments)}}(),e.PlayoutOptions=function(){var t=s(o.mark((function t(e){var n,r,a,u,A,l,p,d,g,b,m,v,I,w,C,E,B,k,Q,x,S,_,M,D,R,O,j,T,N,P,L,F,U,H,G,q,Y,K,z,J,V,W,Z,X,$,tt,et=this;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.offeringURI,r=e.objectId,a=e.versionHash,u=e.writeToken,A=e.linkPath,l=e.signedLink,p=void 0!==l&&l,d=e.protocols,g=void 0===d?["dash","hls"]:d,b=e.handler,m=void 0===b?"playout":b,v=e.offering,I=void 0===v?"default":v,w=e.playoutType,C=e.drms,E=void 0===C?[]:C,B=e.context,k=e.hlsjsProfile,Q=void 0===k||k,x=e.authorizationToken,S=e.options,_=void 0===S?{}:S,!n){t.next=8;break}if(M=n.match(/(hq__[^/]+)\/rep\/([^/]+)\/([^/]+)\/options.json/),a=M[1],m=M[2],I=M[3],a&&m&&I){t.next=8;break}throw Error("Invalid offering URI: ".concat(n));case 8:if(a?y(a):h(r),g=g.map((function(t){return t.toLowerCase()})),E=E.map((function(t){return t.toLowerCase()})),r){t.next=15;break}r=this.utils.DecodeVersionHash(a).objectId,t.next=19;break;case 15:if(a){t.next=19;break}return t.next=18,this.LatestVersionHash({objectId:r});case 18:a=t.sent;case 19:return t.next=21,this.ContentObjectLibraryId({objectId:r});case 21:if(D=t.sent,t.prev=22,A){t.next=29;break}return R=f("public","asset_metadata","sources",I),t.next=27,this.ContentObjectMetadata({libraryId:D,objectId:r,versionHash:a,metadataSubtree:R,authorizationToken:x});case 27:t.sent&&(A=R);case 29:t.next=33;break;case 31:t.prev=31,t.t0=t.catch(22);case 33:return t.next=35,this.PlayoutPathResolution({libraryId:D,objectId:r,versionHash:a,writeToken:u,linkPath:A,signedLink:p,handler:m,offering:I,authorizationToken:x});case 35:if(O=t.sent,j=O.path,T=O.linkTarget,t.t1=this.authClient,t.t2=T.objectId||r,t.t3=T.versionHash||a,t.t3){t.next=45;break}return t.next=44,this.LatestVersionHash({objectId:r});case 44:t.t3=t.sent;case 45:return t.t4=t.t3,t.t5=g,t.t6=E,t.t7=B,t.t8={objectId:t.t2,versionHash:t.t4,protocols:t.t5,drms:t.t6,context:t.t7},N=t.t1.AudienceData.call(t.t1,t.t8),t.t9=x,t.next=54,this.authClient.AuthorizationToken({libraryId:D,objectId:r,channelAuth:!0,oauthToken:this.oauthToken,audienceData:N});case 54:return t.t10=t.sent,P=[t.t9,t.t10].flat().filter((function(t){return t})),L=c({authorization:P,resolve:!!A},_),t.t11=Object,t.next=60,this.utils.ResponseToJson(this.HttpClient.Request({path:j,method:"GET",queryParams:L}));case 60:if(t.t12=t.sent,F=t.t11.values.call(t.t11,t.t12),p||!T.versionHash){t.next=68;break}return t.t13=x,t.next=66,this.authClient.AuthorizationToken({libraryId:T.libraryId,objectId:T.objectId,channelAuth:!0,oauthToken:this.oauthToken,audienceData:N});case 66:t.t14=t.sent,L.authorization=[t.t13,t.t14].flat().filter((function(t){return t}));case 68:U={},q=0;case 70:if(!(q<F.length)){t.next=116;break}if(Y=F[q],K=Y.properties.protocol,z=Y.properties.drm,H=H||Y.sid,G=G||!!Y.properties.multiview,H&&(L.sid=H),J=Y.uri.split("?")[0],w&&(J=J.replace("playlist","playlist-".concat(w))),V=Y.properties.license_servers,W=Y.properties.cert,Q&&"hls"===K&&"aes-128"===z&&(L.player_profile="hls-js"),t.t15=c,t.t16=c({},U[K]||{}),t.t17={},t.t18=c,t.t19=c({},(U[K]||{}).playoutMethods||{}),t.t20={},t.t21=i,t.t22={},t.t23=z||"clear",!p){t.next=97;break}return t.next=94,this.LinkUrl({versionHash:a,linkPath:f(A,I,J),queryParams:L,noAuth:!0});case 94:t.t24=t.sent,t.next=100;break;case 97:return t.next=99,this.Rep({libraryId:T.libraryId||D,objectId:T.objectId||r,versionHash:T.versionHash||a,rep:f(m,I,J),noAuth:!0,queryParams:L});case 99:t.t24=t.sent;case 100:for(Z in t.t25=t.t24,t.t26=z?i({},z,{licenseServers:V,cert:W}):void 0,t.t27={playoutUrl:t.t25,drms:t.t26},t.t28=(0,t.t21)(t.t22,t.t23,t.t27),t.t29=(0,t.t18)(t.t19,t.t20,t.t28),t.t30={playoutMethods:t.t29},U[K]=(0,t.t15)(t.t16,t.t17,t.t30),U[K].playoutMethods)U[K].playoutMethods[Z].drms&&U[K].playoutMethods[Z].drms[z]&&U[K].playoutMethods[Z].drms[z].cert&&((X=new URL(U[K].playoutMethods[Z].playoutUrl)).pathname=X.pathname.split("/").slice(0,-1).concat(["drm.cert"]).join("/"),U[K].playoutMethods[Z].drms[z].cert_url=X.toString());if($=g.includes(K),tt=E.includes(z||"clear")||0===E.length&&!z,$&&tt){t.next=112;break}return t.abrupt("continue",113);case 112:(!U[K].playoutUrl||z&&"clear"!==z)&&(U[K].playoutUrl=U[K].playoutMethods[z||"clear"].playoutUrl,U[K].drms=U[K].playoutMethods[z||"clear"].drms);case 113:q++,t.next=70;break;case 116:return G&&H&&(U.sessionId=H,U.multiview=!0,U.AvailableViews=s(o.mark((function t(){return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=et.utils,t.next=3,et.HttpClient.Request({path:f("q",T.versionHash||a,"rep",m,I,"views.json"),method:"GET",queryParams:{sid:H,authorization:P}});case 3:return t.t1=t.sent,t.next=6,t.t0.ResponseToFormat.call(t.t0,"json",t.t1);case 6:return t.abrupt("return",t.sent);case 7:case"end":return t.stop()}}),t)}))),U.SwitchView=function(){var t=s(o.mark((function t(e){return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,et.HttpClient.Request({path:f("q",T.versionHash||a,"rep",m,I,"select_view"),method:"POST",queryParams:{sid:H,authorization:P},body:{view:e}});case 2:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),this.Log(U),t.abrupt("return",U);case 119:case"end":return t.stop()}}),t,this,[[22,31]])})));return function(e){return t.apply(this,arguments)}}(),e.BitmovinPlayoutOptions=function(){var t=s(o.mark((function t(e){var n,r,a,i,s,u,c,f,A,l,p,d,g,b,m,v,I,w,C,E,B,k,Q,x;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.objectId,r=e.versionHash,a=e.writeToken,i=e.linkPath,s=e.signedLink,u=void 0!==s&&s,c=e.protocols,f=void 0===c?["dash","hls"]:c,A=e.drms,l=void 0===A?[]:A,p=e.handler,d=void 0===p?"playout":p,g=e.offering,b=void 0===g?"default":g,m=e.playoutType,v=e.context,I=e.authorizationToken,w=e.options,C=void 0===w?{}:w,r?y(r):h(n),n||(n=this.utils.DecodeVersionHash(r).objectId),t.next=5,this.PlayoutOptions({objectId:n,versionHash:r,writeToken:a,linkPath:i,signedLink:u,protocols:f,drms:l,handler:d,offering:b,playoutType:m,hlsjsProfile:!1,context:v,authorizationToken:I,options:C});case 5:return delete(E=t.sent).playoutMethods,t.next=9,this.PlayoutPathResolution({objectId:n,versionHash:r,writeToken:a,linkPath:i,signedLink:u,handler:d,offering:b,authorizationToken:I});case 9:if(B=t.sent,k=B.linkTarget,Q=[],I&&Q.push(I),!u&&k.versionHash){t.next=21;break}return t.t0=Q,t.next=17,this.authClient.AuthorizationToken({objectId:n,channelAuth:!0,oauthToken:this.oauthToken});case 17:t.t1=t.sent,t.t0.push.call(t.t0,t.t1),t.next=26;break;case 21:return t.t2=Q,t.next=24,this.authClient.AuthorizationToken({libraryId:k.libraryId,objectId:k.objectId,channelAuth:!0,oauthToken:this.oauthToken});case 24:t.t3=t.sent,t.t2.push.call(t.t2,t.t3);case 26:return x={drm:{}},Object.keys(E).forEach((function(t){var e=E[t];x[t]=e.playoutUrl,e.drms&&Object.keys(e.drms).forEach((function(t){if(e.drms[t].licenseServers&&0!==e.drms[t].licenseServers.length){var n=function(t){return t.toLowerCase().startsWith("https")},r=e.drms[t].licenseServers;r.find(n)&&(r=r.filter(n));var a=r.sort((function(){return.5-Math.random()}))[0];x.drm[t]||(x.drm[t]={LA_URL:a,headers:{Authorization:"Bearer ".concat(Q.flat().filter((function(t){return t})).join(","))}})}}))})),t.abrupt("return",x);case 29:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.CallBitcodeMethod=function(){var t=s(o.mark((function t(e){var n,r,a,i,s,u,c,A,l,p,d,h,y,g,b,v;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,a=e.versionHash,i=e.writeToken,s=e.method,u=e.queryParams,c=void 0===u?{}:u,A=e.body,l=void 0===A?{}:A,p=e.headers,d=void 0===p?{}:p,h=e.constant,y=void 0===h||h,g=e.format,b=void 0===g?"json":g,m({libraryId:n,objectId:r,versionHash:a}),s){t.next=4;break}throw"Bitcode method not specified";case 4:if(a&&(r=this.utils.DecodeVersionHash(a).objectId),v=f("q",i||a||r,"call",s),n&&(v=f("qlibs",n,v)),d.authorization||d.Authorization){t.next=12;break}return t.next=11,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,update:!y});case 11:d.Authorization=t.sent.Authorization;case 12:return this.Log("Calling bitcode method: ".concat(n||""," ").concat(r||a," ").concat(i||"","\n ").concat(y?"GET":"POST"," ").concat(v,"\n Query Params:\n ").concat(JSON.stringify(c||""),"\n Body:\n ").concat(JSON.stringify(l||""),"\n Headers\n ").concat(JSON.stringify(d||""))),t.t0=this.utils,t.t1=b,t.next=17,this.HttpClient.Request({body:l,headers:d,method:y?"GET":"POST",path:v,queryParams:c,allowFailover:!1});case 17:return t.t2=t.sent,t.abrupt("return",t.t0.ResponseToFormat.call(t.t0,t.t1,t.t2));case 19:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.Rep=function(){var t=s(o.mark((function t(e){var n,r,a,i,s,u,c,f,A,l,p,d,h,y,g,b;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,a=e.versionHash,i=e.rep,s=e.queryParams,u=void 0===s?{}:s,c=e.service,f=void 0===c?"fabric":c,A=e.makeAccessRequest,l=void 0!==A&&A,p=e.channelAuth,d=void 0!==p&&p,h=e.noAuth,y=void 0!==h&&h,g=e.noCache,b=void 0!==g&&g,m({libraryId:n,objectId:r,versionHash:a}),i){t.next=4;break}throw"Rep not specified";case 4:return t.abrupt("return",this.FabricUrl({libraryId:n,objectId:r,versionHash:a,rep:i,queryParams:u,service:f,makeAccessRequest:l,channelAuth:d,noAuth:y,noCache:b}));case 5:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.PublicRep=function(){var t=s(o.mark((function t(e){var n,r,a,i,s,u,c,f;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,a=e.versionHash,i=e.rep,s=e.queryParams,u=void 0===s?{}:s,c=e.service,f=void 0===c?"fabric":c,m({libraryId:n,objectId:r,versionHash:a}),i){t.next=4;break}throw"Rep not specified";case 4:return t.abrupt("return",this.FabricUrl({libraryId:n,objectId:r,versionHash:a,publicRep:i,queryParams:u,service:f,noAuth:!0}));case 5:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.FabricUrl=function(){var t=s(o.mark((function t(e){var n,r,a,i,s,u,A,l,p,d,h,y,g,b,v,I,w,C,E,B,k,Q,x;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,a=e.versionHash,i=e.writeToken,s=e.partHash,u=e.rep,A=e.publicRep,l=e.call,p=e.queryParams,d=void 0===p?{}:p,h=e.service,y=void 0===h?"fabric":h,g=e.channelAuth,b=void 0!==g&&g,v=e.makeAccessRequest,I=void 0!==v&&v,w=e.noAuth,C=void 0!==w&&w,E=e.noCache,B=void 0!==E&&E,(r||a)&&m({libraryId:n,objectId:r,versionHash:a}),a&&(r=this.utils.DecodeVersionHash(a).objectId),this.Log("Building Fabric URL:\n libraryId: ".concat(n,"\n objectId: ").concat(r,"\n versionHash: ").concat(a,"\n writeToken: ").concat(i,"\n partHash: ").concat(s,"\n rep: ").concat(u,"\n publicRep: ").concat(A,"\n call: ").concat(l,"\n channelAuth: ").concat(b,"\n noAuth: ").concat(C,"\n noCache: ").concat(B,"\n queryParams: ").concat(JSON.stringify(d||{},null,2))),k=[],d.authorization&&k.push(d.authorization),C&&d.authorization){t.next=12;break}return t.t0=k,t.next=10,this.authClient.AuthorizationToken({libraryId:n,objectId:r,versionHash:a,channelAuth:b,makeAccessRequest:I,noAuth:C,noCache:B});case 10:t.t1=t.sent,t.t0.push.call(t.t0,t.t1);case 12:if(d=c(c({},d),{},{authorization:k.flat()}),!u&&!A||!r||a){t.next=17;break}return t.next=16,this.LatestVersionHash({objectId:r});case 16:a=t.sent;case 17:return Q="",n?(Q=f(Q,"qlibs",n),(r||a)&&(Q=f(Q,"q",i||a||r))):a&&(Q=f("q",a)),s?Q=f(Q,"data",s):u?Q=f(Q,"rep",u):A?Q=f(Q,"public",A):l&&(Q=f(Q,"call",l)),x=this.HttpClient,"search"===y?x=this.SearchHttpClient:"auth"===y&&(x=this.AuthHttpClient),t.abrupt("return",x.URL({path:Q,queryParams:d}));case 23:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.FileUrl=function(){var t=s(o.mark((function t(e){var n,r,a,i,s,u,A,l,p,d,h,y;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,a=e.versionHash,i=e.writeToken,s=e.filePath,u=e.queryParams,A=void 0===u?{}:u,l=e.noCache,p=void 0!==l&&l,m({libraryId:n,objectId:r,versionHash:a}),s){t.next=4;break}throw"File path not specified";case 4:return a&&(r=this.utils.DecodeVersionHash(a).objectId),d=n?f("qlibs",n,"q",i||a||r):f("q",a),t.next=8,this.authClient.AuthorizationToken({libraryId:n,objectId:r,noCache:p});case 8:return h=t.sent,A=c(c({},A),{},{authorization:h}),t.next=12,this.ContentObjectMetadata({libraryId:n,objectId:r,versionHash:a,writeToken:i,metadataSubtree:f("files",s)});case 12:return y=t.sent,y&&y["."].encryption&&"cgck"===y["."].encryption.scheme?(d=f(d,"rep","files_download",s),A["header-x_decryption_mode"]="decrypt"):d=f(d,"files",s),t.abrupt("return",this.HttpClient.URL({path:d,queryParams:A}));case 16:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.ContentObjectImageUrl=function(){var t=s(o.mark((function t(e){var n,r,a,i,s,u,c;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,a=e.versionHash,i=e.height,s=e.imagePath,u=void 0===s?"public/display_image":s,m({libraryId:n,objectId:r,versionHash:a}),a){t.next=6;break}return t.next=5,this.LatestVersionHash({objectId:r});case 5:a=t.sent;case 6:if(this.Log("Retrieving content object image url: ".concat(n," ").concat(r," ").concat(a)),this.objectImageUrls[a]){t.next=26;break}return t.prev=8,t.next=11,this.ContentObjectMetadata({versionHash:a,metadataSubtree:u});case 11:if(t.sent){t.next=15;break}return this.Log("No image url set: ".concat(n," ").concat(r," ").concat(a)),t.abrupt("return");case 15:t.next=21;break;case 17:t.prev=17,t.t0=t.catch(8),this.Log("Unable to query for image metadata: ".concat(n," ").concat(r," ").concat(a),!0),this.Log(t.t0,!0);case 21:return c={},i&&!isNaN(parseInt(i))&&(c.height=parseInt(i)),t.next=25,this.LinkUrl({versionHash:a,linkPath:u,queryParams:c});case 25:this.objectImageUrls[a]=t.sent;case 26:return t.abrupt("return",this.objectImageUrls[a]);case 27:case"end":return t.stop()}}),t,this,[[8,17]])})));return function(e){return t.apply(this,arguments)}}(),e.ContentObjectGraph=function(){var t=s(o.mark((function t(e){var n,r,a,i,u,c,A,l,p,d,h=this;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,a=e.versionHash,i=e.autoUpdate,u=void 0!==i&&i,c=e.select,m({libraryId:n,objectId:r,versionHash:a}),this.Log("Retrieving content object graph: ".concat(n||""," ").concat(r||a)),a&&(r=this.utils.DecodeVersionHash(a).objectId),A=f("q",a||r,"links"),t.prev=5,t.t0=this.utils,t.t1=this.HttpClient,t.next=10,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,versionHash:a});case 10:return t.t2=t.sent,t.t3={auto_update:u,select:c},t.t4=A,t.t5={headers:t.t2,queryParams:t.t3,method:"GET",path:t.t4},t.t6=t.t1.Request.call(t.t1,t.t5),t.next=17,t.t0.ResponseToJson.call(t.t0,t.t6);case 17:return t.abrupt("return",t.sent);case 20:if(t.prev=20,t.t7=t.catch(5),t.prev=22,(p=t.t7.body.errors[0].cause.cause.cause.cycle)&&0!==p.length){t.next=26;break}throw t.t7;case 26:return d={},t.next=29,Promise.all(p.map(function(){var t=s(o.mark((function t(e){var n,r;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!d[e]){t.next=2;break}return t.abrupt("return");case 2:return n=h.utils.DecodeVersionHash(e).objectId,t.next=5,h.ContentObjectMetadata({versionHash:e,metadataSubtree:"public/asset_metadata/display_title"});case 5:if(t.t2=t.sent,t.t2){t.next=10;break}return t.next=9,h.ContentObjectMetadata({versionHash:e,metadataSubtree:"public/name"});case 9:t.t2=t.sent;case 10:if(t.t1=t.t2,t.t1){t.next=15;break}return t.next=14,h.ContentObjectMetadata({versionHash:e,metadataSubtree:"name"});case 14:t.t1=t.sent;case 15:if(t.t0=t.t1,t.t0){t.next=18;break}t.t0=n;case 18:r=t.t0,d[e]={name:r,objectId:n};case 20:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()));case 29:l=p.map((function(t){return"".concat(d[t].name," (").concat(d[t].objectId,")")})),t.next=35;break;case 32:throw t.prev=32,t.t8=t.catch(22),t.t7;case 35:throw new Error("Cycle found in links: ".concat(l.join(" -> ")));case 36:case"end":return t.stop()}}),t,this,[[5,20],[22,32]])})));return function(e){return t.apply(this,arguments)}}(),e.LinkTarget=function(){var t=s(o.mark((function t(e){var n,r,i,s,u,c,f,A,l;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,i=e.versionHash,s=e.writeToken,u=e.linkPath,c=e.authorizationToken,f=e.linkInfo,m({libraryId:n,objectId:r,versionHash:i}),s&&b(s),i&&(r=this.utils.DecodeVersionHash(i).objectId),!s||n){t.next=8;break}return t.next=7,this.ContentObjectLibraryId({objectId:r});case 7:n=t.sent;case 8:if(f){t.next=12;break}return t.next=11,this.ContentObjectMetadata({libraryId:n,objectId:r,versionHash:i,writeToken:s,metadataSubtree:u,resolveLinks:!1,resolveIgnoreErrors:!0,resolveIncludeSource:!0,authorizationToken:c});case 11:f=t.sent;case 12:if(!f||!f["/"]){t.next=27;break}if((A=((f["/"]||"").match(/^\/?qfab\/([\w]+)\/?.+/)||[])[1])||(A=f["."].container),!A){t.next=19;break}return t.abrupt("return",A);case 19:if(!i){t.next=21;break}return t.abrupt("return",i);case 21:if(t.t0=i,t.t0){t.next=26;break}return t.next=25,this.LatestVersionHash({objectId:r});case 25:t.t0=t.sent;case 26:return t.abrupt("return",t.t0);case 27:return t.next=29,this.ContentObjectMetadata({libraryId:n,objectId:r,versionHash:i,writeToken:s,metadataSubtree:u,resolveIncludeSource:!0,authorizationToken:c});case 29:if((f=t.sent)&&f["."]){t.next=49;break}if("object"!==a(f)){t.next=38;break}if(t.t1=i,t.t1){t.next=37;break}return t.next=36,this.LatestVersionHash({objectId:r});case 36:t.t1=t.sent;case 37:return t.abrupt("return",t.t1);case 38:if(l=u.split("/").slice(0,-1).join("/")){t.next=46;break}if(t.t2=i,t.t2){t.next=45;break}return t.next=44,this.LatestVersionHash({objectId:r});case 44:t.t2=t.sent;case 45:return t.abrupt("return",t.t2);case 46:return t.next=48,this.ContentObjectMetadata({libraryId:n,objectId:r,versionHash:i,writeToken:s,metadataSubtree:l,resolveIncludeSource:!0,authorizationToken:c});case 48:f=t.sent;case 49:return t.abrupt("return",f["."].source);case 50:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.LinkUrl=function(){var t=s(o.mark((function t(e){var n,r,a,i,s,u,A,l,p,d,h,y,g,v,I;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,a=e.versionHash,i=e.writeToken,s=e.linkPath,u=e.mimeType,A=e.authorizationToken,l=e.queryParams,p=void 0===l?{}:l,d=e.channelAuth,h=void 0!==d&&d,y=e.noAuth,g=void 0!==y&&y,m({libraryId:n,objectId:r,versionHash:a}),i&&b(i),s){t.next=5;break}throw Error("Link path not specified");case 5:return a&&(r=this.utils.DecodeVersionHash(a).objectId),v=n?f("qlibs",n,"q",i||a||r,"meta",s):f("q",a,"meta",s),I=[A],t.t0=I,t.next=11,this.MetadataAuth({libraryId:n,objectId:r,versionHash:a,path:s,channelAuth:h,noAuth:g});case 11:return t.t1=t.sent,t.t0.push.call(t.t0,t.t1),p.authorization&&I.push(p.authorization),p=c(c({},p),{},{authorization:I.flat().filter((function(t){return t})),resolve:!0}),u&&(p["header-accept"]=u),t.abrupt("return",this.HttpClient.URL({path:v,queryParams:p}));case 17:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.LinkData=function(){var t=s(o.mark((function t(e){var n,r,a,i,s,u,c,f,A,p,d;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,a=e.versionHash,i=e.writeToken,s=e.linkPath,u=e.queryParams,c=void 0===u?{}:u,f=e.format,A=void 0===f?"json":f,p=e.channelAuth,t.next=3,this.LinkUrl({libraryId:n,objectId:r,versionHash:a,writeToken:i,linkPath:s,queryParams:c,channelAuth:p});case 3:return d=t.sent,t.t0=this.utils,t.t1=A,t.next=8,l.Fetch(d);case 8:return t.t2=t.sent,t.abrupt("return",t.t0.ResponseToFormat.call(t.t0,t.t1,t.t2));case 10:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.CreateEncryptionConk=function(){var t=s(o.mark((function t(e){var n,r,a,i,s,u,c,f,A,l,p;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,a=e.versionHash,i=e.writeToken,s=e.createKMSConk,u=void 0===s||s,!this.signer.remoteSigner){t.next=3;break}return t.abrupt("return");case 3:if(m({libraryId:n,objectId:r,versionHash:a}),b(i),r||(r=client.DecodeVersionHash(a).objectId),n){t.next=10;break}return t.next=9,this.ContentObjectLibraryId({objectId:r});case 9:n=t.sent;case 10:return c="eluv.caps.iusr".concat(this.utils.AddressToHash(this.signer.address)),t.next=13,this.ContentObjectMetadata({libraryId:n,objectId:r,writeToken:i,metadataSubtree:c});case 13:if(!(f=t.sent)){t.next=20;break}return t.next=17,this.Crypto.DecryptCap(f,this.signer._signingKey().privateKey);case 17:this.encryptionConks[r]=t.sent,t.next=34;break;case 20:return t.next=22,this.Crypto.GeneratePrimaryConk({spaceId:this.contentSpaceId,objectId:r});case 22:return this.encryptionConks[r]=t.sent,t.t0=this,t.t1=n,t.t2=r,t.t3=i,t.t4=c,t.next=30,this.Crypto.EncryptConk(this.encryptionConks[r],this.signer._signingKey().publicKey);case 30:return t.t5=t.sent,t.t6={libraryId:t.t1,objectId:t.t2,writeToken:t.t3,metadataSubtree:t.t4,metadata:t.t5},t.next=34,t.t0.ReplaceMetadata.call(t.t0,t.t6);case 34:if(!u){t.next=64;break}return t.prev=35,t.next=38,this.authClient.KMSAddress({objectId:r});case 38:return A=t.sent,t.next=41,this.authClient.KMSInfo({objectId:r});case 41:return l=t.sent.publicKey,p="eluv.caps.ikms".concat(this.utils.AddressToHash(A)),t.next=45,this.ContentObjectMetadata({libraryId:n,objectId:r,writeToken:i,metadataSubtree:p});case 45:if(t.sent){t.next=58;break}return t.t7=this,t.t8=n,t.t9=r,t.t10=i,t.t11=p,t.next=54,this.Crypto.EncryptConk(this.encryptionConks[r],l);case 54:return t.t12=t.sent,t.t13={libraryId:t.t8,objectId:t.t9,writeToken:t.t10,metadataSubtree:t.t11,metadata:t.t12},t.next=58,t.t7.ReplaceMetadata.call(t.t7,t.t13);case 58:t.next=64;break;case 60:t.prev=60,t.t14=t.catch(35),console.error("Failed to create encryption cap for KMS:"),console.error(t.t14);case 64:return t.abrupt("return",this.encryptionConks[r]);case 65:case"end":return t.stop()}}),t,this,[[35,60]])})));return function(e){return t.apply(this,arguments)}}(),e.EncryptionConk=function(){var t=s(o.mark((function t(e){var n,r,a,i,s,u,c,f,A,l,p;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,a=e.versionHash,i=e.writeToken,s=e.download,u=void 0!==s&&s,m({libraryId:n,objectId:r,versionHash:a}),i&&b(i),r||(r=client.DecodeVersionHash(a).objectId),t.next=6,this.authClient.Owner({id:r});case 6:return c=t.sent,f="eluv.caps.iusr".concat(this.utils.AddressToHash(this.signer.address)),t.next=10,this.ContentObjectMetadata({libraryId:n,objectId:r,versionHash:a,metadataSubtree:f});case 10:if(A=t.sent,this.utils.EqualAddress(c,this.signer.address)||A){t.next=21;break}if(!u){t.next=18;break}return t.next=15,this.authClient.ReEncryptionConk({libraryId:n,objectId:r,versionHash:a});case 15:return t.abrupt("return",t.sent);case 18:return t.next=20,this.authClient.EncryptionConk({libraryId:n,objectId:r,versionHash:a});case 20:return t.abrupt("return",t.sent);case 21:if(this.encryptionConks[r]){t.next=38;break}return l="eluv.caps.iusr".concat(this.utils.AddressToHash(this.signer.address)),t.next=25,this.ContentObjectMetadata({libraryId:n,objectId:r,versionHash:a,writeToken:i,metadataSubtree:l});case 25:if(!(p=t.sent)){t.next=32;break}return t.next=29,this.Crypto.DecryptCap(p,this.signer._signingKey().privateKey);case 29:this.encryptionConks[r]=t.sent,t.next=38;break;case 32:if(!i){t.next=37;break}return t.next=35,this.CreateEncryptionConk({libraryId:n,objectId:r,versionHash:a,writeToken:i,createKMSConk:!1});case 35:t.next=38;break;case 37:throw"No encryption conk present for "+r;case 38:return t.abrupt("return",this.encryptionConks[r]);case 39:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.Encrypt=function(){var t=s(o.mark((function t(e){var n,r,a,i,s,u;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,a=e.writeToken,i=e.chunk,m({libraryId:n,objectId:r}),t.next=4,this.EncryptionConk({libraryId:n,objectId:r,writeToken:a});case 4:return s=t.sent,t.next=7,this.Crypto.Encrypt(s,i);case 7:return u=t.sent,t.abrupt("return",u.buffer.slice(u.byteOffset,u.byteOffset+u.byteLength));case 9:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.Decrypt=function(){var t=s(o.mark((function t(e){var n,r,a,i,s,u;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,a=e.writeToken,i=e.chunk,m({libraryId:n,objectId:r}),t.next=4,this.EncryptionConk({libraryId:n,objectId:r,writeToken:a,download:!0});case 4:return s=t.sent,t.next=7,this.Crypto.Decrypt(s,i);case 7:return u=t.sent,t.abrupt("return",u.buffer.slice(u.byteOffset,u.byteOffset+u.byteLength));case 9:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.AccessType=function(){var t=s(o.mark((function t(e){var n;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.id,t.next=3,this.authClient.AccessType(n);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.AccessInfo=function(){var t=s(o.mark((function t(e){var n,r,a;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.objectId,r=e.args,h(n),r||(r=[0,[],[]]),this.Log("Retrieving access info: ".concat(n)),t.next=6,this.ethClient.CallContractMethod({contractAddress:this.utils.HashToAddress(n),methodName:"getAccessInfo",methodArgs:r});case 6:return a=t.sent,this.Log(a),t.abrupt("return",{visibilityCode:a[0],visible:a[0]>=1,accessible:a[0]>=10,editable:a[0]>=100,hasAccess:0===a[1],accessCode:a[1],accessCharge:this.utils.WeiToEther(a[2]).toString()});case 9:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.AccessRequest=function(){var t=s(o.mark((function t(e){var n,r,a,i,s,u,c,f,A;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,a=e.versionHash,i=e.args,s=void 0===i?[]:i,u=e.update,c=void 0!==u&&u,f=e.noCache,A=void 0!==f&&f,m({libraryId:n,objectId:r,versionHash:a}),a&&(r=this.utils.DecodeVersionHash(a).objectId),t.next=5,this.authClient.MakeAccessRequest({libraryId:n,objectId:r,versionHash:a,args:s,update:c,skipCache:!0,noCache:A});case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.SetAuthContext=function(t){var e=t.context;if(e&&Object.values(e).find((function(t){return"string"!=typeof t})))throw Error("Context must be a map of string->string");this.authContext=e},e.GenerateStateChannelToken=function(){var t=s(o.mark((function t(e){var n,r,a,i,s;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.objectId,r=e.versionHash,a=e.context,i=e.noCache,s=void 0!==i&&i,r?y(r):h(n),!r){t.next=6;break}n=this.utils.DecodeVersionHash(r).objectId,t.next=10;break;case 6:if(this.stateChannelAccess[n]){t.next=10;break}return t.next=9,this.LatestVersionHash({objectId:n});case 9:r=t.sent;case 10:return this.stateChannelAccess[n]=r,t.next=13,this.authClient.AuthorizationToken({objectId:n,channelAuth:!0,oauthToken:this.oauthToken,context:a,noCache:s});case 13:return t.abrupt("return",t.sent);case 14:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.FinalizeStateChannelAccess=function(){var t=s(o.mark((function t(e){var n,r,a;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.objectId,r=e.versionHash,a=e.percentComplete,r?y(r):h(n),!r){t.next=6;break}n=this.utils.DecodeVersionHash(r).objectId,t.next=13;break;case 6:if(!this.stateChannelAccess[n]){t.next=10;break}r=this.stateChannelAccess[n],t.next=13;break;case 10:return t.next=12,this.LatestVersionHash({objectId:n});case 12:r=t.sent;case 13:return this.stateChannelAccess[n]=void 0,t.next=16,this.authClient.ChannelContentFinalize({objectId:n,versionHash:r,percent:a});case 16:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.ContentObjectAccessComplete=function(){var t=s(o.mark((function t(e){var n,r,a;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.objectId,r=e.score,a=void 0===r?100:r,h(n),!(a<0||a>100)){t.next=4;break}throw Error("Invalid AccessComplete score: "+a);case 4:return t.next=6,this.authClient.AccessComplete({id:n,score:a});case 6:return t.abrupt("return",t.sent);case 7:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.Collection=function(){var t=s(o.mark((function t(e){var n;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.collectionType,["accessGroups","contentObjects","contentTypes","contracts","libraries"].includes(n)){t.next=4;break}throw new Error("Invalid collection type: "+n);case 4:if(!this.signer){t.next=10;break}return t.next=7,this.userProfileClient.WalletAddress();case 7:t.t0=t.sent,t.next=11;break;case 10:t.t0=void 0;case 11:if(t.t0){t.next=14;break}throw new Error("Unable to get collection: User wallet doesn't exist");case 14:return this.Log("Retrieving ".concat(n," contract collection for user ").concat(this.signer.address)),t.next=17,this.ethClient.MakeProviderCall({methodName:"send",args:["elv_getWalletCollection",[this.contentSpaceId,"iusr".concat(this.utils.AddressToHash(this.signer.address)),n]]});case 17:if(t.t1=t.sent,t.t1){t.next=20;break}t.t1=[];case 20:return t.abrupt("return",t.t1);case 21:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.VerifyContentObject=function(){var t=s(o.mark((function t(e){var n,r,a;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,a=e.versionHash,m({libraryId:n,objectId:r,versionHash:a}),t.next=4,ContentObjectVerification.VerifyContentObject({client:this,libraryId:n,objectId:r,versionHash:a});case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.Proofs=function(){var t=s(o.mark((function t(e){var n,r,a,i,s;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,a=e.versionHash,i=e.partHash,m({libraryId:n,objectId:r,versionHash:a}),g(i),a&&(r=this.utils.DecodeVersionHash(a).objectId),s=f("q",a||r,"data",i,"proofs"),t.t0=this.utils,t.t1=this.HttpClient,t.next=9,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,versionHash:a});case 9:return t.t2=t.sent,t.t3=s,t.t4={headers:t.t2,method:"GET",path:t.t3},t.t5=t.t1.Request.call(t.t1,t.t4),t.abrupt("return",t.t0.ResponseToJson.call(t.t0,t.t5));case 14:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.QParts=function(){var t=s(o.mark((function t(e){var n,r,a,i,s,u;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,a=e.partHash,i=e.format,s=void 0===i?"blob":i,m({libraryId:n,objectId:r,versionHash:versionHash}),g(a),u=f("qparts",a),t.t0=this.utils,t.t1=s,t.t2=this.HttpClient,t.next=9,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,partHash:a});case 9:return t.t3=t.sent,t.t4=u,t.t5={headers:t.t3,method:"GET",path:t.t4},t.t6=t.t2.Request.call(t.t2,t.t5),t.abrupt("return",t.t0.ResponseToFormat.call(t.t0,t.t1,t.t6));case 14:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}()},function(t,e,n){var r=n(230),a=n(287)((function(t,e,n,a){r(t,e,n,a)}));t.exports=a},function(t,e,n){var r=n(65)(n(33),"Map");t.exports=r},function(t,e,n){var r=n(33).Symbol;t.exports=r},function(t,e,n){(function(e){function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var r="object"==(void 0===e?"undefined":n(e))&&e&&e.Object===Object&&e;t.exports=r}).call(this,n(10))},function(t,e,n){var r=n(67),a=n(49);t.exports=function(t,e,n){(void 0!==n&&!a(t[e],n)||void 0===n&&!(e in t))&&r(t,e,n)}},function(t,e,n){var r=n(65),a=function(){try{var t=r(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();t.exports=a},function(t,e,n){var r=n(272)(Object.getPrototypeOf,Object);t.exports=r},function(t,e){var n=Object.prototype;t.exports=function(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||n)}},function(t,e,n){var r=n(273),a=n(41),i=Object.prototype,o=i.hasOwnProperty,s=i.propertyIsEnumerable,u=r(function(){return arguments}())?r:function(t){return a(t)&&o.call(t,"callee")&&!s.call(t,"callee")};t.exports=u},function(t,e){var n=Array.isArray;t.exports=n},function(t,e){t.exports=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}},function(t,e,n){(function(t){function r(t){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var a=n(33),i=n(275),o="object"==r(e)&&e&&!e.nodeType&&e,s=o&&"object"==r(t)&&t&&!t.nodeType&&t,u=s&&s.exports===o?a.Buffer:void 0,c=(u?u.isBuffer:void 0)||i;t.exports=c}).call(this,n(20)(t))},function(t,e,n){var r=n(277),a=n(278),i=n(279),o=i&&i.isTypedArray,s=o?a(o):r;t.exports=s},function(t,e){t.exports=function(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}},function(t,e,n){var r=n(283),a=n(285),i=n(68);t.exports=function(t){return i(t)?r(t,!0):a(t)}},function(t,e){function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var r=/^(?:0|[1-9]\d*)$/;t.exports=function(t,e){var a=n(t);return!!(e=null==e?9007199254740991:e)&&("number"==a||"symbol"!=a&&r.test(t))&&t>-1&&t%1==0&&t<e}},function(t,e){t.exports=function(t){return t}},function(t,e,n){(function(e){var r=n(6),a=n(7);void 0===globalThis.Buffer&&(globalThis.Buffer=n(5).Buffer);var i,o=n(104),s=n(125),u=n(13);if("undefined"==typeof crypto){var c=n(306);c.getRandomValues=function(t){return c.randomBytes(t.length)},globalThis.crypto=c}switch(u.Platform()){case u.PLATFORM_REACT_NATIVE:case u.PLATFORM_WEB:i=n(173).default;break;default:i=n(!function(){var t=new Error("Cannot find module '@eluvio/crypto/dist/elv-crypto.bundle.node'");throw t.code="MODULE_NOT_FOUND",t}()).default}var f,A,l,p,d,h={ElvCrypto:(d=a(r.mark((function t(){return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(t.prev=0,h.elvCrypto){t.next=5;break}return t.next=4,(new i).init();case 4:h.elvCrypto=t.sent;case 5:return t.abrupt("return",h.elvCrypto);case 8:t.prev=8,t.t0=t.catch(0),console.error("Error initializing ElvCrypto:"),console.error(t.t0);case 12:case"end":return t.stop()}}),t,null,[[0,8]])}))),function(){return d.apply(this,arguments)}),EncryptedSize:function(t){var e=Math.floor(t/1e6)*h.EncryptedBlockSize(1e6);return t%1e6!=0&&(e+=h.EncryptedBlockSize(t%1e6)),e},EncryptedBlockSize:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=129,r=608,a=48,i=12*(a-1),o=12*a,s=Math.floor(t/i)*o;return t%i!=0&&(s+=o),e?s+r:s+n},EncryptConk:function(t,n){return a(r.mark((function a(){var i,o,s,c,f,A;return r.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,h.ElvCrypto();case 2:return i=r.sent,n=new Uint8Array(e.from(n.replace("0x",""),"hex")),t=new Uint8Array(e.from(JSON.stringify(t))),r.next=7,i.encryptECIES(t,n);case 7:return o=r.sent,s=o.data,c=o.ephemeralKey,f=o.tag,A=e.concat([e.from(c),e.from(f),e.from(s)]),r.abrupt("return",u.B64(A));case 13:case"end":return r.stop()}}),a)})))()},DecryptCap:function(t,n){return a(r.mark((function a(){var i,o,s,u,c;return r.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,h.ElvCrypto();case 2:return i=r.sent,n=new Uint8Array(e.from(n.replace("0x",""),"hex")),t=e.from(t,"base64"),o=t.slice(0,65),s=t.slice(65,81),u=t.slice(81),c=i.decryptECIES(new Uint8Array(u),n,new Uint8Array(o),new Uint8Array(s)),r.abrupt("return",JSON.parse(e.from(c).toString()));case 10:case"end":return r.stop()}}),a)})))()},GeneratePrimaryConk:function(t){return a(r.mark((function n(){var a,i,s,u,c,f,A;return r.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return a=t.spaceId,i=t.objectId,n.next=3,h.ElvCrypto();case 3:return s=n.sent,u=s.generatePrimaryKeys(),c=u.secretKey,f=u.publicKey,A=s.generateSymmetricKey().key,n.abrupt("return",{symm_key:"kpsy".concat(o.encode(e.from(A))),secret_key:"kpsk".concat(o.encode(e.from(c))),public_key:"kppk".concat(o.encode(e.from(f))),sid:a,qid:i});case 7:case"end":return n.stop()}}),n)})))()},GenerateTargetConk:function(){return a(r.mark((function t(){var n,a,i,s;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,h.ElvCrypto();case 2:return n=t.sent,a=n.generateTargetKeys(),i=a.secretKey,s=a.publicKey,t.abrupt("return",{secret_key:"kpsk".concat(o.encode(e.from(i))),public_key:"ktpk".concat(o.encode(e.from(s)))});case 5:case"end":return t.stop()}}),t)})))()},CapToConk:function(t){var e=function(t){return new Uint8Array(o.decode(t.slice(4)))};return{symmetricKey:e(t.symm_key),secretKey:e(t.secret_key),publicKey:e(t.public_key)}},EncryptionContext:function(t){return a(r.mark((function e(){var n,a,i,o,s,u,c;return r.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,h.ElvCrypto();case 2:return n=e.sent,a=h.CapToConk(t),i=a.symmetricKey,o=a.secretKey,(s=a.publicKey).length===n.PRIMARY_PK_KEY_SIZE?(c=n.CRYPTO_TYPE_PRIMARY,u=n.newPrimaryContext(s,o,i)):(c=n.CRYPTO_TYPE_TARGET,u=n.newTargetDecryptionContext(o,i)),e.abrupt("return",{context:u,type:c});case 6:case"end":return e.stop()}}),e)})))()},Encrypt:(p=a(r.mark((function t(n,a){var i,o,s,u,c;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,h.OpenEncryptionStream(n);case 2:if(i=t.sent,e.isBuffer(a)||a instanceof ArrayBuffer){t.next=9;break}return t.t0=e,t.next=7,new Response(a).arrayBuffer();case 7:t.t1=t.sent,a=t.t0.from.call(t.t0,t.t1);case 9:for(o=new Uint8Array(a),s=0;s<o.length;s+=1e6)u=Math.min(o.length,s+1e6),i.write(o.slice(s,u));return i.end(),c=[],t.next=15,new Promise((function(t,e){i.on("data",(function(t){c.push(t)})).on("finish",(function(){t()})).on("error",(function(t){e(t)}))}));case 15:return t.abrupt("return",e.concat(c));case 16:case"end":return t.stop()}}),t)}))),function(t,e){return p.apply(this,arguments)}),OpenEncryptionStream:(l=a(r.mark((function t(e){var n,a,i,o,u;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,h.ElvCrypto();case 2:return n=t.sent,t.next=5,h.EncryptionContext(e);case 5:return a=t.sent,i=a.context,o=new s.PassThrough,u=n.createCipher(i),t.abrupt("return",o.pipe(u).on("finish",(function(){i.free()})).on("error",(function(t){throw Error(t)})));case 10:case"end":return t.stop()}}),t)}))),function(t){return l.apply(this,arguments)}),Decrypt:(A=a(r.mark((function t(n,a){var i,o,s,u,c;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,h.OpenDecryptionStream(n);case 2:for(i=t.sent,o=new Uint8Array(a),s=0;s<o.length;s+=1e6)u=Math.min(o.length,s+1e6),i.write(o.slice(s,u));return i.end(),c=[],t.next=9,new Promise((function(t,e){i.on("data",(function(t){c.push(t)})).on("finish",(function(){t()})).on("error",(function(t){e(t)}))}));case 9:return t.abrupt("return",e.concat(c));case 10:case"end":return t.stop()}}),t)}))),function(t,e){return A.apply(this,arguments)}),OpenDecryptionStream:(f=a(r.mark((function t(e){var n,a,i,o,u,c;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,h.ElvCrypto();case 2:return n=t.sent,t.next=5,h.EncryptionContext(e);case 5:return a=t.sent,i=a.context,o=a.type,u=new s.PassThrough,c=n.createDecipher(o,i),t.abrupt("return",u.pipe(c).on("finish",(function(){i.free()})).on("error",(function(t){throw Error(t)})));case 11:case"end":return t.stop()}}),t)}))),function(t){return f.apply(this,arguments)})};t.exports=h}).call(this,n(5).Buffer)},function(t,e,n){t.exports=a;var r=n(42).EventEmitter;function a(){r.call(this)}n(3)(a,r),a.Readable=n(69),a.Writable=n(302),a.Duplex=n(303),a.Transform=n(304),a.PassThrough=n(305),a.Stream=a,a.prototype.pipe=function(t,e){var n=this;function a(e){t.writable&&!1===t.write(e)&&n.pause&&n.pause()}function i(){n.readable&&n.resume&&n.resume()}n.on("data",a),t.on("drain",i),t._isStdio||e&&!1===e.end||(n.on("end",s),n.on("close",u));var o=!1;function s(){o||(o=!0,t.end())}function u(){o||(o=!0,"function"==typeof t.destroy&&t.destroy())}function c(t){if(f(),0===r.listenerCount(this,"error"))throw t}function f(){n.removeListener("data",a),t.removeListener("drain",i),n.removeListener("end",s),n.removeListener("close",u),n.removeListener("error",c),t.removeListener("error",c),n.removeListener("end",f),n.removeListener("close",f),t.removeListener("close",f)}return n.on("error",c),t.on("error",c),n.on("end",f),n.on("close",f),t.on("close",f),t.emit("pipe",n),t}},function(t,e,n){"use strict";(function(e,r){var a=n(53);t.exports=m;var i,o=n(296);m.ReadableState=b;n(42).EventEmitter;var s=function(t,e){return t.listeners(e).length},u=n(127),c=n(70).Buffer,f=e.Uint8Array||function(){};var A=Object.create(n(43));A.inherits=n(3);var l=n(297),p=void 0;p=l&&l.debuglog?l.debuglog("stream"):function(){};var d,h=n(298),y=n(128);A.inherits(m,u);var g=["error","close","destroy","pause","resume"];function b(t,e){t=t||{};var r=e instanceof(i=i||n(28));this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.readableObjectMode);var a=t.highWaterMark,o=t.readableHighWaterMark,s=this.objectMode?16:16384;this.highWaterMark=a||0===a?a:r&&(o||0===o)?o:s,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new h,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(d||(d=n(44).StringDecoder),this.decoder=new d(t.encoding),this.encoding=t.encoding)}function m(t){if(i=i||n(28),!(this instanceof m))return new m(t);this._readableState=new b(t,this),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),u.call(this)}function v(t,e,n,r,a){var i,o=t._readableState;null===e?(o.reading=!1,function(t,e){if(e.ended)return;if(e.decoder){var n=e.decoder.end();n&&n.length&&(e.buffer.push(n),e.length+=e.objectMode?1:n.length)}e.ended=!0,C(t)}(t,o)):(a||(i=function(t,e){var n;r=e,c.isBuffer(r)||r instanceof f||"string"==typeof e||void 0===e||t.objectMode||(n=new TypeError("Invalid non-string/buffer chunk"));var r;return n}(o,e)),i?t.emit("error",i):o.objectMode||e&&e.length>0?("string"==typeof e||o.objectMode||Object.getPrototypeOf(e)===c.prototype||(e=function(t){return c.from(t)}(e)),r?o.endEmitted?t.emit("error",new Error("stream.unshift() after end event")):I(t,o,e,!0):o.ended?t.emit("error",new Error("stream.push() after EOF")):(o.reading=!1,o.decoder&&!n?(e=o.decoder.write(e),o.objectMode||0!==e.length?I(t,o,e,!1):B(t,o)):I(t,o,e,!1))):r||(o.reading=!1));return function(t){return!t.ended&&(t.needReadable||t.length<t.highWaterMark||0===t.length)}(o)}function I(t,e,n,r){e.flowing&&0===e.length&&!e.sync?(t.emit("data",n),t.read(0)):(e.length+=e.objectMode?1:n.length,r?e.buffer.unshift(n):e.buffer.push(n),e.needReadable&&C(t)),B(t,e)}Object.defineProperty(m.prototype,"destroyed",{get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(t){this._readableState&&(this._readableState.destroyed=t)}}),m.prototype.destroy=y.destroy,m.prototype._undestroy=y.undestroy,m.prototype._destroy=function(t,e){this.push(null),e(t)},m.prototype.push=function(t,e){var n,r=this._readableState;return r.objectMode?n=!0:"string"==typeof t&&((e=e||r.defaultEncoding)!==r.encoding&&(t=c.from(t,e),e=""),n=!0),v(this,t,e,!1,n)},m.prototype.unshift=function(t){return v(this,t,null,!0,!1)},m.prototype.isPaused=function(){return!1===this._readableState.flowing},m.prototype.setEncoding=function(t){return d||(d=n(44).StringDecoder),this._readableState.decoder=new d(t),this._readableState.encoding=t,this};function w(t,e){return t<=0||0===e.length&&e.ended?0:e.objectMode?1:t!=t?e.flowing&&e.length?e.buffer.head.data.length:e.length:(t>e.highWaterMark&&(e.highWaterMark=function(t){return t>=8388608?t=8388608:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function C(t){var e=t._readableState;e.needReadable=!1,e.emittedReadable||(p("emitReadable",e.flowing),e.emittedReadable=!0,e.sync?a.nextTick(E,t):E(t))}function E(t){p("emit readable"),t.emit("readable"),S(t)}function B(t,e){e.readingMore||(e.readingMore=!0,a.nextTick(k,t,e))}function k(t,e){for(var n=e.length;!e.reading&&!e.flowing&&!e.ended&&e.length<e.highWaterMark&&(p("maybeReadMore read 0"),t.read(0),n!==e.length);)n=e.length;e.readingMore=!1}function Q(t){p("readable nexttick read 0"),t.read(0)}function x(t,e){e.reading||(p("resume read 0"),t.read(0)),e.resumeScheduled=!1,e.awaitDrain=0,t.emit("resume"),S(t),e.flowing&&!e.reading&&t.read(0)}function S(t){var e=t._readableState;for(p("flow",e.flowing);e.flowing&&null!==t.read(););}function _(t,e){return 0===e.length?null:(e.objectMode?n=e.buffer.shift():!t||t>=e.length?(n=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.head.data:e.buffer.concat(e.length),e.buffer.clear()):n=function(t,e,n){var r;t<e.head.data.length?(r=e.head.data.slice(0,t),e.head.data=e.head.data.slice(t)):r=t===e.head.data.length?e.shift():n?function(t,e){var n=e.head,r=1,a=n.data;t-=a.length;for(;n=n.next;){var i=n.data,o=t>i.length?i.length:t;if(o===i.length?a+=i:a+=i.slice(0,t),0===(t-=o)){o===i.length?(++r,n.next?e.head=n.next:e.head=e.tail=null):(e.head=n,n.data=i.slice(o));break}++r}return e.length-=r,a}(t,e):function(t,e){var n=c.allocUnsafe(t),r=e.head,a=1;r.data.copy(n),t-=r.data.length;for(;r=r.next;){var i=r.data,o=t>i.length?i.length:t;if(i.copy(n,n.length-t,0,o),0===(t-=o)){o===i.length?(++a,r.next?e.head=r.next:e.head=e.tail=null):(e.head=r,r.data=i.slice(o));break}++a}return e.length-=a,n}(t,e);return r}(t,e.buffer,e.decoder),n);var n}function M(t){var e=t._readableState;if(e.length>0)throw new Error('"endReadable()" called on non-empty stream');e.endEmitted||(e.ended=!0,a.nextTick(D,e,t))}function D(t,e){t.endEmitted||0!==t.length||(t.endEmitted=!0,e.readable=!1,e.emit("end"))}function R(t,e){for(var n=0,r=t.length;n<r;n++)if(t[n]===e)return n;return-1}m.prototype.read=function(t){p("read",t),t=parseInt(t,10);var e=this._readableState,n=t;if(0!==t&&(e.emittedReadable=!1),0===t&&e.needReadable&&(e.length>=e.highWaterMark||e.ended))return p("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?M(this):C(this),null;if(0===(t=w(t,e))&&e.ended)return 0===e.length&&M(this),null;var r,a=e.needReadable;return p("need readable",a),(0===e.length||e.length-t<e.highWaterMark)&&p("length less than watermark",a=!0),e.ended||e.reading?p("reading or ended",a=!1):a&&(p("do read"),e.reading=!0,e.sync=!0,0===e.length&&(e.needReadable=!0),this._read(e.highWaterMark),e.sync=!1,e.reading||(t=w(n,e))),null===(r=t>0?_(t,e):null)?(e.needReadable=!0,t=0):e.length-=t,0===e.length&&(e.ended||(e.needReadable=!0),n!==t&&e.ended&&M(this)),null!==r&&this.emit("data",r),r},m.prototype._read=function(t){this.emit("error",new Error("_read() is not implemented"))},m.prototype.pipe=function(t,e){var n=this,i=this._readableState;switch(i.pipesCount){case 0:i.pipes=t;break;case 1:i.pipes=[i.pipes,t];break;default:i.pipes.push(t)}i.pipesCount+=1,p("pipe count=%d opts=%j",i.pipesCount,e);var u=(!e||!1!==e.end)&&t!==r.stdout&&t!==r.stderr?f:m;function c(e,r){p("onunpipe"),e===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,p("cleanup"),t.removeListener("close",g),t.removeListener("finish",b),t.removeListener("drain",A),t.removeListener("error",y),t.removeListener("unpipe",c),n.removeListener("end",f),n.removeListener("end",m),n.removeListener("data",h),l=!0,!i.awaitDrain||t._writableState&&!t._writableState.needDrain||A())}function f(){p("onend"),t.end()}i.endEmitted?a.nextTick(u):n.once("end",u),t.on("unpipe",c);var A=function(t){return function(){var e=t._readableState;p("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&s(t,"data")&&(e.flowing=!0,S(t))}}(n);t.on("drain",A);var l=!1;var d=!1;function h(e){p("ondata"),d=!1,!1!==t.write(e)||d||((1===i.pipesCount&&i.pipes===t||i.pipesCount>1&&-1!==R(i.pipes,t))&&!l&&(p("false write response, pause",n._readableState.awaitDrain),n._readableState.awaitDrain++,d=!0),n.pause())}function y(e){p("onerror",e),m(),t.removeListener("error",y),0===s(t,"error")&&t.emit("error",e)}function g(){t.removeListener("finish",b),m()}function b(){p("onfinish"),t.removeListener("close",g),m()}function m(){p("unpipe"),n.unpipe(t)}return n.on("data",h),function(t,e,n){if("function"==typeof t.prependListener)return t.prependListener(e,n);t._events&&t._events[e]?o(t._events[e])?t._events[e].unshift(n):t._events[e]=[n,t._events[e]]:t.on(e,n)}(t,"error",y),t.once("close",g),t.once("finish",b),t.emit("pipe",n),i.flowing||(p("pipe resume"),n.resume()),t},m.prototype.unpipe=function(t){var e=this._readableState,n={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,n)),this;if(!t){var r=e.pipes,a=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var i=0;i<a;i++)r[i].emit("unpipe",this,n);return this}var o=R(e.pipes,t);return-1===o||(e.pipes.splice(o,1),e.pipesCount-=1,1===e.pipesCount&&(e.pipes=e.pipes[0]),t.emit("unpipe",this,n)),this},m.prototype.on=function(t,e){var n=u.prototype.on.call(this,t,e);if("data"===t)!1!==this._readableState.flowing&&this.resume();else if("readable"===t){var r=this._readableState;r.endEmitted||r.readableListening||(r.readableListening=r.needReadable=!0,r.emittedReadable=!1,r.reading?r.length&&C(this):a.nextTick(Q,this))}return n},m.prototype.addListener=m.prototype.on,m.prototype.resume=function(){var t=this._readableState;return t.flowing||(p("resume"),t.flowing=!0,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,a.nextTick(x,t,e))}(this,t)),this},m.prototype.pause=function(){return p("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(p("pause"),this._readableState.flowing=!1,this.emit("pause")),this},m.prototype.wrap=function(t){var e=this,n=this._readableState,r=!1;for(var a in t.on("end",(function(){if(p("wrapped end"),n.decoder&&!n.ended){var t=n.decoder.end();t&&t.length&&e.push(t)}e.push(null)})),t.on("data",(function(a){(p("wrapped data"),n.decoder&&(a=n.decoder.write(a)),n.objectMode&&null==a)||(n.objectMode||a&&a.length)&&(e.push(a)||(r=!0,t.pause()))})),t)void 0===this[a]&&"function"==typeof t[a]&&(this[a]=function(e){return function(){return t[e].apply(t,arguments)}}(a));for(var i=0;i<g.length;i++)t.on(g[i],this.emit.bind(this,g[i]));return this._read=function(e){p("wrapped _read",e),r&&(r=!1,t.resume())},this},Object.defineProperty(m.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),m._fromList=_}).call(this,n(10),n(12))},function(t,e,n){t.exports=n(42).EventEmitter},function(t,e,n){"use strict";var r=n(53);function a(t,e){t.emit("error",e)}t.exports={destroy:function(t,e){var n=this,i=this._readableState&&this._readableState.destroyed,o=this._writableState&&this._writableState.destroyed;return i||o?(e?e(t):!t||this._writableState&&this._writableState.errorEmitted||r.nextTick(a,this,t),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,(function(t){!e&&t?(r.nextTick(a,n,t),n._writableState&&(n._writableState.errorEmitted=!0)):e&&e(t)})),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}}},function(t,e,n){(function(e){function n(t){try{if(!e.localStorage)return!1}catch(t){return!1}var n=e.localStorage[t];return null!=n&&"true"===String(n).toLowerCase()}t.exports=function(t,e){if(n("noDeprecation"))return t;var r=!1;return function(){if(!r){if(n("throwDeprecation"))throw new Error(e);n("traceDeprecation")?console.trace(e):console.warn(e),r=!0}return t.apply(this,arguments)}}}).call(this,n(10))},function(t,e,n){"use strict";t.exports=o;var r=n(28),a=Object.create(n(43));function i(t,e){var n=this._transformState;n.transforming=!1;var r=n.writecb;if(!r)return this.emit("error",new Error("write callback called multiple times"));n.writechunk=null,n.writecb=null,null!=e&&this.push(e),r(t);var a=this._readableState;a.reading=!1,(a.needReadable||a.length<a.highWaterMark)&&this._read(a.highWaterMark)}function o(t){if(!(this instanceof o))return new o(t);r.call(this,t),this._transformState={afterTransform:i.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,t&&("function"==typeof t.transform&&(this._transform=t.transform),"function"==typeof t.flush&&(this._flush=t.flush)),this.on("prefinish",s)}function s(){var t=this;"function"==typeof this._flush?this._flush((function(e,n){u(t,e,n)})):u(this,null,null)}function u(t,e,n){if(e)return t.emit("error",e);if(null!=n&&t.push(n),t._writableState.length)throw new Error("Calling transform done when ws.length != 0");if(t._transformState.transforming)throw new Error("Calling transform done when still transforming");return t.push(null)}a.inherits=n(3),a.inherits(o,r),o.prototype.push=function(t,e){return this._transformState.needTransform=!1,r.prototype.push.call(this,t,e)},o.prototype._transform=function(t,e,n){throw new Error("_transform() is not implemented")},o.prototype._write=function(t,e,n){var r=this._transformState;if(r.writecb=n,r.writechunk=t,r.writeencoding=e,!r.transforming){var a=this._readableState;(r.needTransform||a.needReadable||a.length<a.highWaterMark)&&this._read(a.highWaterMark)}},o.prototype._read=function(t){var e=this._transformState;null!==e.writechunk&&e.writecb&&!e.transforming?(e.transforming=!0,this._transform(e.writechunk,e.writeencoding,e.afterTransform)):e.needTransform=!0},o.prototype._destroy=function(t,e){var n=this;r.prototype._destroy.call(this,t,(function(t){e(t),n.emit("close")}))}},function(t,e,n){"use strict";var r=n(4).Buffer,a=n(73).Transform;function i(t){a.call(this),this._block=r.allocUnsafe(t),this._blockSize=t,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}n(3)(i,a),i.prototype._transform=function(t,e,n){var r=null;try{this.update(t,e)}catch(t){r=t}n(r)},i.prototype._flush=function(t){var e=null;try{this.push(this.digest())}catch(t){e=t}t(e)},i.prototype.update=function(t,e){if(function(t,e){if(!r.isBuffer(t)&&"string"!=typeof t)throw new TypeError(e+" must be a string or a buffer")}(t,"Data"),this._finalized)throw new Error("Digest already called");r.isBuffer(t)||(t=r.from(t,e));for(var n=this._block,a=0;this._blockOffset+t.length-a>=this._blockSize;){for(var i=this._blockOffset;i<this._blockSize;)n[i++]=t[a++];this._update(),this._blockOffset=0}for(;a<t.length;)n[this._blockOffset++]=t[a++];for(var o=0,s=8*t.length;s>0;++o)this._length[o]+=s,(s=this._length[o]/4294967296|0)>0&&(this._length[o]-=4294967296*s);return this},i.prototype._update=function(){throw new Error("_update is not implemented")},i.prototype.digest=function(t){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var e=this._digest();void 0!==t&&(e=e.toString(t)),this._block.fill(0),this._blockOffset=0;for(var n=0;n<4;++n)this._length[n]=0;return e},i.prototype._digest=function(){throw new Error("_digest is not implemented")},t.exports=i},function(t,e,n){"use strict";(function(e,r){var a;t.exports=B,B.ReadableState=E;n(42).EventEmitter;var i=function(t,e){return t.listeners(e).length},o=n(133),s=n(5).Buffer,u=e.Uint8Array||function(){};var c,f=n(307);c=f&&f.debuglog?f.debuglog("stream"):function(){};var A,l,p,d=n(308),h=n(134),y=n(135).getHighWaterMark,g=n(35).codes,b=g.ERR_INVALID_ARG_TYPE,m=g.ERR_STREAM_PUSH_AFTER_EOF,v=g.ERR_METHOD_NOT_IMPLEMENTED,I=g.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;n(3)(B,o);var w=h.errorOrDestroy,C=["error","close","destroy","pause","resume"];function E(t,e,r){a=a||n(36),t=t||{},"boolean"!=typeof r&&(r=e instanceof a),this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=y(this,t,"readableHighWaterMark",r),this.buffer=new d,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(A||(A=n(44).StringDecoder),this.decoder=new A(t.encoding),this.encoding=t.encoding)}function B(t){if(a=a||n(36),!(this instanceof B))return new B(t);var e=this instanceof a;this._readableState=new E(t,this,e),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),o.call(this)}function k(t,e,n,r,a){c("readableAddChunk",e);var i,o=t._readableState;if(null===e)o.reading=!1,function(t,e){if(c("onEofChunk"),e.ended)return;if(e.decoder){var n=e.decoder.end();n&&n.length&&(e.buffer.push(n),e.length+=e.objectMode?1:n.length)}e.ended=!0,e.sync?S(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,_(t)))}(t,o);else if(a||(i=function(t,e){var n;r=e,s.isBuffer(r)||r instanceof u||"string"==typeof e||void 0===e||t.objectMode||(n=new b("chunk",["string","Buffer","Uint8Array"],e));var r;return n}(o,e)),i)w(t,i);else if(o.objectMode||e&&e.length>0)if("string"==typeof e||o.objectMode||Object.getPrototypeOf(e)===s.prototype||(e=function(t){return s.from(t)}(e)),r)o.endEmitted?w(t,new I):Q(t,o,e,!0);else if(o.ended)w(t,new m);else{if(o.destroyed)return!1;o.reading=!1,o.decoder&&!n?(e=o.decoder.write(e),o.objectMode||0!==e.length?Q(t,o,e,!1):M(t,o)):Q(t,o,e,!1)}else r||(o.reading=!1,M(t,o));return!o.ended&&(o.length<o.highWaterMark||0===o.length)}function Q(t,e,n,r){e.flowing&&0===e.length&&!e.sync?(e.awaitDrain=0,t.emit("data",n)):(e.length+=e.objectMode?1:n.length,r?e.buffer.unshift(n):e.buffer.push(n),e.needReadable&&S(t)),M(t,e)}Object.defineProperty(B.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(t){this._readableState&&(this._readableState.destroyed=t)}}),B.prototype.destroy=h.destroy,B.prototype._undestroy=h.undestroy,B.prototype._destroy=function(t,e){e(t)},B.prototype.push=function(t,e){var n,r=this._readableState;return r.objectMode?n=!0:"string"==typeof t&&((e=e||r.defaultEncoding)!==r.encoding&&(t=s.from(t,e),e=""),n=!0),k(this,t,e,!1,n)},B.prototype.unshift=function(t){return k(this,t,null,!0,!1)},B.prototype.isPaused=function(){return!1===this._readableState.flowing},B.prototype.setEncoding=function(t){A||(A=n(44).StringDecoder);var e=new A(t);this._readableState.decoder=e,this._readableState.encoding=this._readableState.decoder.encoding;for(var r=this._readableState.buffer.head,a="";null!==r;)a+=e.write(r.data),r=r.next;return this._readableState.buffer.clear(),""!==a&&this._readableState.buffer.push(a),this._readableState.length=a.length,this};function x(t,e){return t<=0||0===e.length&&e.ended?0:e.objectMode?1:t!=t?e.flowing&&e.length?e.buffer.head.data.length:e.length:(t>e.highWaterMark&&(e.highWaterMark=function(t){return t>=1073741824?t=1073741824:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function S(t){var e=t._readableState;c("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(c("emitReadable",e.flowing),e.emittedReadable=!0,r.nextTick(_,t))}function _(t){var e=t._readableState;c("emitReadable_",e.destroyed,e.length,e.ended),e.destroyed||!e.length&&!e.ended||(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,T(t)}function M(t,e){e.readingMore||(e.readingMore=!0,r.nextTick(D,t,e))}function D(t,e){for(;!e.reading&&!e.ended&&(e.length<e.highWaterMark||e.flowing&&0===e.length);){var n=e.length;if(c("maybeReadMore read 0"),t.read(0),n===e.length)break}e.readingMore=!1}function R(t){var e=t._readableState;e.readableListening=t.listenerCount("readable")>0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount("data")>0&&t.resume()}function O(t){c("readable nexttick read 0"),t.read(0)}function j(t,e){c("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),T(t),e.flowing&&!e.reading&&t.read(0)}function T(t){var e=t._readableState;for(c("flow",e.flowing);e.flowing&&null!==t.read(););}function N(t,e){return 0===e.length?null:(e.objectMode?n=e.buffer.shift():!t||t>=e.length?(n=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):n=e.buffer.consume(t,e.decoder),n);var n}function P(t){var e=t._readableState;c("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,r.nextTick(L,e,t))}function L(t,e){if(c("endReadableNT",t.endEmitted,t.length),!t.endEmitted&&0===t.length&&(t.endEmitted=!0,e.readable=!1,e.emit("end"),t.autoDestroy)){var n=e._writableState;(!n||n.autoDestroy&&n.finished)&&e.destroy()}}function F(t,e){for(var n=0,r=t.length;n<r;n++)if(t[n]===e)return n;return-1}B.prototype.read=function(t){c("read",t),t=parseInt(t,10);var e=this._readableState,n=t;if(0!==t&&(e.emittedReadable=!1),0===t&&e.needReadable&&((0!==e.highWaterMark?e.length>=e.highWaterMark:e.length>0)||e.ended))return c("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?P(this):S(this),null;if(0===(t=x(t,e))&&e.ended)return 0===e.length&&P(this),null;var r,a=e.needReadable;return c("need readable",a),(0===e.length||e.length-t<e.highWaterMark)&&c("length less than watermark",a=!0),e.ended||e.reading?c("reading or ended",a=!1):a&&(c("do read"),e.reading=!0,e.sync=!0,0===e.length&&(e.needReadable=!0),this._read(e.highWaterMark),e.sync=!1,e.reading||(t=x(n,e))),null===(r=t>0?N(t,e):null)?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),0===e.length&&(e.ended||(e.needReadable=!0),n!==t&&e.ended&&P(this)),null!==r&&this.emit("data",r),r},B.prototype._read=function(t){w(this,new v("_read()"))},B.prototype.pipe=function(t,e){var n=this,a=this._readableState;switch(a.pipesCount){case 0:a.pipes=t;break;case 1:a.pipes=[a.pipes,t];break;default:a.pipes.push(t)}a.pipesCount+=1,c("pipe count=%d opts=%j",a.pipesCount,e);var o=(!e||!1!==e.end)&&t!==r.stdout&&t!==r.stderr?u:y;function s(e,r){c("onunpipe"),e===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,c("cleanup"),t.removeListener("close",d),t.removeListener("finish",h),t.removeListener("drain",f),t.removeListener("error",p),t.removeListener("unpipe",s),n.removeListener("end",u),n.removeListener("end",y),n.removeListener("data",l),A=!0,!a.awaitDrain||t._writableState&&!t._writableState.needDrain||f())}function u(){c("onend"),t.end()}a.endEmitted?r.nextTick(o):n.once("end",o),t.on("unpipe",s);var f=function(t){return function(){var e=t._readableState;c("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&i(t,"data")&&(e.flowing=!0,T(t))}}(n);t.on("drain",f);var A=!1;function l(e){c("ondata");var r=t.write(e);c("dest.write",r),!1===r&&((1===a.pipesCount&&a.pipes===t||a.pipesCount>1&&-1!==F(a.pipes,t))&&!A&&(c("false write response, pause",a.awaitDrain),a.awaitDrain++),n.pause())}function p(e){c("onerror",e),y(),t.removeListener("error",p),0===i(t,"error")&&w(t,e)}function d(){t.removeListener("finish",h),y()}function h(){c("onfinish"),t.removeListener("close",d),y()}function y(){c("unpipe"),n.unpipe(t)}return n.on("data",l),function(t,e,n){if("function"==typeof t.prependListener)return t.prependListener(e,n);t._events&&t._events[e]?Array.isArray(t._events[e])?t._events[e].unshift(n):t._events[e]=[n,t._events[e]]:t.on(e,n)}(t,"error",p),t.once("close",d),t.once("finish",h),t.emit("pipe",n),a.flowing||(c("pipe resume"),n.resume()),t},B.prototype.unpipe=function(t){var e=this._readableState,n={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,n)),this;if(!t){var r=e.pipes,a=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var i=0;i<a;i++)r[i].emit("unpipe",this,{hasUnpiped:!1});return this}var o=F(e.pipes,t);return-1===o||(e.pipes.splice(o,1),e.pipesCount-=1,1===e.pipesCount&&(e.pipes=e.pipes[0]),t.emit("unpipe",this,n)),this},B.prototype.on=function(t,e){var n=o.prototype.on.call(this,t,e),a=this._readableState;return"data"===t?(a.readableListening=this.listenerCount("readable")>0,!1!==a.flowing&&this.resume()):"readable"===t&&(a.endEmitted||a.readableListening||(a.readableListening=a.needReadable=!0,a.flowing=!1,a.emittedReadable=!1,c("on readable",a.length,a.reading),a.length?S(this):a.reading||r.nextTick(O,this))),n},B.prototype.addListener=B.prototype.on,B.prototype.removeListener=function(t,e){var n=o.prototype.removeListener.call(this,t,e);return"readable"===t&&r.nextTick(R,this),n},B.prototype.removeAllListeners=function(t){var e=o.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||r.nextTick(R,this),e},B.prototype.resume=function(){var t=this._readableState;return t.flowing||(c("resume"),t.flowing=!t.readableListening,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,r.nextTick(j,t,e))}(this,t)),t.paused=!1,this},B.prototype.pause=function(){return c("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(c("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},B.prototype.wrap=function(t){var e=this,n=this._readableState,r=!1;for(var a in t.on("end",(function(){if(c("wrapped end"),n.decoder&&!n.ended){var t=n.decoder.end();t&&t.length&&e.push(t)}e.push(null)})),t.on("data",(function(a){(c("wrapped data"),n.decoder&&(a=n.decoder.write(a)),n.objectMode&&null==a)||(n.objectMode||a&&a.length)&&(e.push(a)||(r=!0,t.pause()))})),t)void 0===this[a]&&"function"==typeof t[a]&&(this[a]=function(e){return function(){return t[e].apply(t,arguments)}}(a));for(var i=0;i<C.length;i++)t.on(C[i],this.emit.bind(this,C[i]));return this._read=function(e){c("wrapped _read",e),r&&(r=!1,t.resume())},this},"function"==typeof Symbol&&(B.prototype[Symbol.asyncIterator]=function(){return void 0===l&&(l=n(310)),l(this)}),Object.defineProperty(B.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(B.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(B.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(t){this._readableState&&(this._readableState.flowing=t)}}),B._fromList=N,Object.defineProperty(B.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),"function"==typeof Symbol&&(B.from=function(t,e){return void 0===p&&(p=n(311)),p(B,t,e)})}).call(this,n(10),n(12))},function(t,e,n){t.exports=n(42).EventEmitter},function(t,e,n){"use strict";(function(e){function n(t,e){a(t,e),r(t)}function r(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit("close")}function a(t,e){t.emit("error",e)}t.exports={destroy:function(t,i){var o=this,s=this._readableState&&this._readableState.destroyed,u=this._writableState&&this._writableState.destroyed;return s||u?(i?i(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,e.nextTick(a,this,t)):e.nextTick(a,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,(function(t){!i&&t?o._writableState?o._writableState.errorEmitted?e.nextTick(r,o):(o._writableState.errorEmitted=!0,e.nextTick(n,o,t)):e.nextTick(n,o,t):i?(e.nextTick(r,o),i(t)):e.nextTick(r,o)})),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)},errorOrDestroy:function(t,e){var n=t._readableState,r=t._writableState;n&&n.autoDestroy||r&&r.autoDestroy?t.destroy(e):t.emit("error",e)}}}).call(this,n(12))},function(t,e,n){"use strict";var r=n(35).codes.ERR_INVALID_OPT_VALUE;t.exports={getHighWaterMark:function(t,e,n,a){var i=function(t,e,n){return null!=t.highWaterMark?t.highWaterMark:e?t[n]:null}(e,a,n);if(null!=i){if(!isFinite(i)||Math.floor(i)!==i||i<0)throw new r(a?n:"highWaterMark",i);return Math.floor(i)}return t.objectMode?16:16384}}},function(t,e,n){"use strict";(function(e,r){function a(t){var e=this;this.next=null,this.entry=null,this.finish=function(){!function(t,e,n){var r=t.entry;t.entry=null;for(;r;){var a=r.callback;e.pendingcb--,a(n),r=r.next}e.corkedRequestsFree.next=t}(e,t)}}var i;t.exports=B,B.WritableState=E;var o={deprecate:n(129)},s=n(133),u=n(5).Buffer,c=e.Uint8Array||function(){};var f,A=n(134),l=n(135).getHighWaterMark,p=n(35).codes,d=p.ERR_INVALID_ARG_TYPE,h=p.ERR_METHOD_NOT_IMPLEMENTED,y=p.ERR_MULTIPLE_CALLBACK,g=p.ERR_STREAM_CANNOT_PIPE,b=p.ERR_STREAM_DESTROYED,m=p.ERR_STREAM_NULL_VALUES,v=p.ERR_STREAM_WRITE_AFTER_END,I=p.ERR_UNKNOWN_ENCODING,w=A.errorOrDestroy;function C(){}function E(t,e,o){i=i||n(36),t=t||{},"boolean"!=typeof o&&(o=e instanceof i),this.objectMode=!!t.objectMode,o&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=l(this,t,"writableHighWaterMark",o),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var s=!1===t.decodeStrings;this.decodeStrings=!s,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var n=t._writableState,a=n.sync,i=n.writecb;if("function"!=typeof i)throw new y;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(n),e)!function(t,e,n,a,i){--e.pendingcb,n?(r.nextTick(i,a),r.nextTick(M,t,e),t._writableState.errorEmitted=!0,w(t,a)):(i(a),t._writableState.errorEmitted=!0,w(t,a),M(t,e))}(t,n,a,e,i);else{var o=S(n)||t.destroyed;o||n.corked||n.bufferProcessing||!n.bufferedRequest||x(t,n),a?r.nextTick(Q,t,n,o,i):Q(t,n,o,i)}}(e,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new a(this)}function B(t){var e=this instanceof(i=i||n(36));if(!e&&!f.call(B,this))return new B(t);this._writableState=new E(t,this,e),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),s.call(this)}function k(t,e,n,r,a,i,o){e.writelen=r,e.writecb=o,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new b("write")):n?t._writev(a,e.onwrite):t._write(a,i,e.onwrite),e.sync=!1}function Q(t,e,n,r){n||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}(t,e),e.pendingcb--,r(),M(t,e)}function x(t,e){e.bufferProcessing=!0;var n=e.bufferedRequest;if(t._writev&&n&&n.next){var r=e.bufferedRequestCount,i=new Array(r),o=e.corkedRequestsFree;o.entry=n;for(var s=0,u=!0;n;)i[s]=n,n.isBuf||(u=!1),n=n.next,s+=1;i.allBuffers=u,k(t,e,!0,e.length,i,"",o.finish),e.pendingcb++,e.lastBufferedRequest=null,o.next?(e.corkedRequestsFree=o.next,o.next=null):e.corkedRequestsFree=new a(e),e.bufferedRequestCount=0}else{for(;n;){var c=n.chunk,f=n.encoding,A=n.callback;if(k(t,e,!1,e.objectMode?1:c.length,c,f,A),n=n.next,e.bufferedRequestCount--,e.writing)break}null===n&&(e.lastBufferedRequest=null)}e.bufferedRequest=n,e.bufferProcessing=!1}function S(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function _(t,e){t._final((function(n){e.pendingcb--,n&&w(t,n),e.prefinished=!0,t.emit("prefinish"),M(t,e)}))}function M(t,e){var n=S(e);if(n&&(function(t,e){e.prefinished||e.finalCalled||("function"!=typeof t._final||e.destroyed?(e.prefinished=!0,t.emit("prefinish")):(e.pendingcb++,e.finalCalled=!0,r.nextTick(_,t,e)))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit("finish"),e.autoDestroy))){var a=t._readableState;(!a||a.autoDestroy&&a.endEmitted)&&t.destroy()}return n}n(3)(B,s),E.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(E.prototype,"buffer",{get:o.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(t){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(f=Function.prototype[Symbol.hasInstance],Object.defineProperty(B,Symbol.hasInstance,{value:function(t){return!!f.call(this,t)||this===B&&(t&&t._writableState instanceof E)}})):f=function(t){return t instanceof this},B.prototype.pipe=function(){w(this,new g)},B.prototype.write=function(t,e,n){var a,i=this._writableState,o=!1,s=!i.objectMode&&(a=t,u.isBuffer(a)||a instanceof c);return s&&!u.isBuffer(t)&&(t=function(t){return u.from(t)}(t)),"function"==typeof e&&(n=e,e=null),s?e="buffer":e||(e=i.defaultEncoding),"function"!=typeof n&&(n=C),i.ending?function(t,e){var n=new v;w(t,n),r.nextTick(e,n)}(this,n):(s||function(t,e,n,a){var i;return null===n?i=new m:"string"==typeof n||e.objectMode||(i=new d("chunk",["string","Buffer"],n)),!i||(w(t,i),r.nextTick(a,i),!1)}(this,i,t,n))&&(i.pendingcb++,o=function(t,e,n,r,a,i){if(!n){var o=function(t,e,n){t.objectMode||!1===t.decodeStrings||"string"!=typeof e||(e=u.from(e,n));return e}(e,r,a);r!==o&&(n=!0,a="buffer",r=o)}var s=e.objectMode?1:r.length;e.length+=s;var c=e.length<e.highWaterMark;c||(e.needDrain=!0);if(e.writing||e.corked){var f=e.lastBufferedRequest;e.lastBufferedRequest={chunk:r,encoding:a,isBuf:n,callback:i,next:null},f?f.next=e.lastBufferedRequest:e.bufferedRequest=e.lastBufferedRequest,e.bufferedRequestCount+=1}else k(t,e,!1,s,r,a,i);return c}(this,i,s,t,e,n)),o},B.prototype.cork=function(){this._writableState.corked++},B.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,t.writing||t.corked||t.bufferProcessing||!t.bufferedRequest||x(this,t))},B.prototype.setDefaultEncoding=function(t){if("string"==typeof t&&(t=t.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((t+"").toLowerCase())>-1))throw new I(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(B.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(B.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),B.prototype._write=function(t,e,n){n(new h("_write()"))},B.prototype._writev=null,B.prototype.end=function(t,e,n){var a=this._writableState;return"function"==typeof t?(n=t,t=null,e=null):"function"==typeof e&&(n=e,e=null),null!=t&&this.write(t,e),a.corked&&(a.corked=1,this.uncork()),a.ending||function(t,e,n){e.ending=!0,M(t,e),n&&(e.finished?r.nextTick(n):t.once("finish",n));e.ended=!0,t.writable=!1}(this,a,n),this},Object.defineProperty(B.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(B.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),B.prototype.destroy=A.destroy,B.prototype._undestroy=A.undestroy,B.prototype._destroy=function(t,e){e(t)}}).call(this,n(10),n(12))},function(t,e,n){"use strict";t.exports=f;var r=n(35).codes,a=r.ERR_METHOD_NOT_IMPLEMENTED,i=r.ERR_MULTIPLE_CALLBACK,o=r.ERR_TRANSFORM_ALREADY_TRANSFORMING,s=r.ERR_TRANSFORM_WITH_LENGTH_0,u=n(36);function c(t,e){var n=this._transformState;n.transforming=!1;var r=n.writecb;if(null===r)return this.emit("error",new i);n.writechunk=null,n.writecb=null,null!=e&&this.push(e),r(t);var a=this._readableState;a.reading=!1,(a.needReadable||a.length<a.highWaterMark)&&this._read(a.highWaterMark)}function f(t){if(!(this instanceof f))return new f(t);u.call(this,t),this._transformState={afterTransform:c.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,t&&("function"==typeof t.transform&&(this._transform=t.transform),"function"==typeof t.flush&&(this._flush=t.flush)),this.on("prefinish",A)}function A(){var t=this;"function"!=typeof this._flush||this._readableState.destroyed?l(this,null,null):this._flush((function(e,n){l(t,e,n)}))}function l(t,e,n){if(e)return t.emit("error",e);if(null!=n&&t.push(n),t._writableState.length)throw new s;if(t._transformState.transforming)throw new o;return t.push(null)}n(3)(f,u),f.prototype.push=function(t,e){return this._transformState.needTransform=!1,u.prototype.push.call(this,t,e)},f.prototype._transform=function(t,e,n){n(new a("_transform()"))},f.prototype._write=function(t,e,n){var r=this._transformState;if(r.writecb=n,r.writechunk=t,r.writeencoding=e,!r.transforming){var a=this._readableState;(r.needTransform||a.needReadable||a.length<a.highWaterMark)&&this._read(a.highWaterMark)}},f.prototype._read=function(t){var e=this._transformState;null===e.writechunk||e.transforming?e.needTransform=!0:(e.transforming=!0,this._transform(e.writechunk,e.writeencoding,e.afterTransform))},f.prototype._destroy=function(t,e){u.prototype._destroy.call(this,t,(function(t){e(t)}))}},function(t,e,n){var r=n(3),a=n(37),i=n(4).Buffer,o=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],s=new Array(64);function u(){this.init(),this._w=s,a.call(this,64,56)}function c(t,e,n){return n^t&(e^n)}function f(t,e,n){return t&e|n&(t|e)}function A(t){return(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10)}function l(t){return(t>>>6|t<<26)^(t>>>11|t<<21)^(t>>>25|t<<7)}function p(t){return(t>>>7|t<<25)^(t>>>18|t<<14)^t>>>3}r(u,a),u.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},u.prototype._update=function(t){for(var e,n=this._w,r=0|this._a,a=0|this._b,i=0|this._c,s=0|this._d,u=0|this._e,d=0|this._f,h=0|this._g,y=0|this._h,g=0;g<16;++g)n[g]=t.readInt32BE(4*g);for(;g<64;++g)n[g]=0|(((e=n[g-2])>>>17|e<<15)^(e>>>19|e<<13)^e>>>10)+n[g-7]+p(n[g-15])+n[g-16];for(var b=0;b<64;++b){var m=y+l(u)+c(u,d,h)+o[b]+n[b]|0,v=A(r)+f(r,a,i)|0;y=h,h=d,d=u,u=s+m|0,s=i,i=a,a=r,r=m+v|0}this._a=r+this._a|0,this._b=a+this._b|0,this._c=i+this._c|0,this._d=s+this._d|0,this._e=u+this._e|0,this._f=d+this._f|0,this._g=h+this._g|0,this._h=y+this._h|0},u.prototype._hash=function(){var t=i.allocUnsafe(32);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t.writeInt32BE(this._h,28),t},t.exports=u},function(t,e,n){var r=n(3),a=n(37),i=n(4).Buffer,o=[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],s=new Array(160);function u(){this.init(),this._w=s,a.call(this,128,112)}function c(t,e,n){return n^t&(e^n)}function f(t,e,n){return t&e|n&(t|e)}function A(t,e){return(t>>>28|e<<4)^(e>>>2|t<<30)^(e>>>7|t<<25)}function l(t,e){return(t>>>14|e<<18)^(t>>>18|e<<14)^(e>>>9|t<<23)}function p(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^t>>>7}function d(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^(t>>>7|e<<25)}function h(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^t>>>6}function y(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^(t>>>6|e<<26)}function g(t,e){return t>>>0<e>>>0?1:0}r(u,a),u.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},u.prototype._update=function(t){for(var e=this._w,n=0|this._ah,r=0|this._bh,a=0|this._ch,i=0|this._dh,s=0|this._eh,u=0|this._fh,b=0|this._gh,m=0|this._hh,v=0|this._al,I=0|this._bl,w=0|this._cl,C=0|this._dl,E=0|this._el,B=0|this._fl,k=0|this._gl,Q=0|this._hl,x=0;x<32;x+=2)e[x]=t.readInt32BE(4*x),e[x+1]=t.readInt32BE(4*x+4);for(;x<160;x+=2){var S=e[x-30],_=e[x-30+1],M=p(S,_),D=d(_,S),R=h(S=e[x-4],_=e[x-4+1]),O=y(_,S),j=e[x-14],T=e[x-14+1],N=e[x-32],P=e[x-32+1],L=D+T|0,F=M+j+g(L,D)|0;F=(F=F+R+g(L=L+O|0,O)|0)+N+g(L=L+P|0,P)|0,e[x]=F,e[x+1]=L}for(var U=0;U<160;U+=2){F=e[U],L=e[U+1];var H=f(n,r,a),G=f(v,I,w),q=A(n,v),Y=A(v,n),K=l(s,E),z=l(E,s),J=o[U],V=o[U+1],W=c(s,u,b),Z=c(E,B,k),X=Q+z|0,$=m+K+g(X,Q)|0;$=($=($=$+W+g(X=X+Z|0,Z)|0)+J+g(X=X+V|0,V)|0)+F+g(X=X+L|0,L)|0;var tt=Y+G|0,et=q+H+g(tt,Y)|0;m=b,Q=k,b=u,k=B,u=s,B=E,s=i+$+g(E=C+X|0,C)|0,i=a,C=w,a=r,w=I,r=n,I=v,n=$+et+g(v=X+tt|0,X)|0}this._al=this._al+v|0,this._bl=this._bl+I|0,this._cl=this._cl+w|0,this._dl=this._dl+C|0,this._el=this._el+E|0,this._fl=this._fl+B|0,this._gl=this._gl+k|0,this._hl=this._hl+Q|0,this._ah=this._ah+n+g(this._al,v)|0,this._bh=this._bh+r+g(this._bl,I)|0,this._ch=this._ch+a+g(this._cl,w)|0,this._dh=this._dh+i+g(this._dl,C)|0,this._eh=this._eh+s+g(this._el,E)|0,this._fh=this._fh+u+g(this._fl,B)|0,this._gh=this._gh+b+g(this._gl,k)|0,this._hh=this._hh+m+g(this._hl,Q)|0},u.prototype._hash=function(){var t=i.allocUnsafe(64);function e(e,n,r){t.writeInt32BE(e,r),t.writeInt32BE(n,r+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),e(this._gh,this._gl,48),e(this._hh,this._hl,56),t},t.exports=u},function(t,e,n){var r=n(72);t.exports=function(t){return(new r).update(t).digest()}},function(t,e,n){t.exports=n(142)},function(t){t.exports=JSON.parse('{"sha224WithRSAEncryption":{"sign":"rsa","hash":"sha224","id":"302d300d06096086480165030402040500041c"},"RSA-SHA224":{"sign":"ecdsa/rsa","hash":"sha224","id":"302d300d06096086480165030402040500041c"},"sha256WithRSAEncryption":{"sign":"rsa","hash":"sha256","id":"3031300d060960864801650304020105000420"},"RSA-SHA256":{"sign":"ecdsa/rsa","hash":"sha256","id":"3031300d060960864801650304020105000420"},"sha384WithRSAEncryption":{"sign":"rsa","hash":"sha384","id":"3041300d060960864801650304020205000430"},"RSA-SHA384":{"sign":"ecdsa/rsa","hash":"sha384","id":"3041300d060960864801650304020205000430"},"sha512WithRSAEncryption":{"sign":"rsa","hash":"sha512","id":"3051300d060960864801650304020305000440"},"RSA-SHA512":{"sign":"ecdsa/rsa","hash":"sha512","id":"3051300d060960864801650304020305000440"},"RSA-SHA1":{"sign":"rsa","hash":"sha1","id":"3021300906052b0e03021a05000414"},"ecdsa-with-SHA1":{"sign":"ecdsa","hash":"sha1","id":""},"sha256":{"sign":"ecdsa","hash":"sha256","id":""},"sha224":{"sign":"ecdsa","hash":"sha224","id":""},"sha384":{"sign":"ecdsa","hash":"sha384","id":""},"sha512":{"sign":"ecdsa","hash":"sha512","id":""},"DSA-SHA":{"sign":"dsa","hash":"sha1","id":""},"DSA-SHA1":{"sign":"dsa","hash":"sha1","id":""},"DSA":{"sign":"dsa","hash":"sha1","id":""},"DSA-WITH-SHA224":{"sign":"dsa","hash":"sha224","id":""},"DSA-SHA224":{"sign":"dsa","hash":"sha224","id":""},"DSA-WITH-SHA256":{"sign":"dsa","hash":"sha256","id":""},"DSA-SHA256":{"sign":"dsa","hash":"sha256","id":""},"DSA-WITH-SHA384":{"sign":"dsa","hash":"sha384","id":""},"DSA-SHA384":{"sign":"dsa","hash":"sha384","id":""},"DSA-WITH-SHA512":{"sign":"dsa","hash":"sha512","id":""},"DSA-SHA512":{"sign":"dsa","hash":"sha512","id":""},"DSA-RIPEMD160":{"sign":"dsa","hash":"rmd160","id":""},"ripemd160WithRSA":{"sign":"rsa","hash":"rmd160","id":"3021300906052b2403020105000414"},"RSA-RIPEMD160":{"sign":"rsa","hash":"rmd160","id":"3021300906052b2403020105000414"},"md5WithRSAEncryption":{"sign":"rsa","hash":"md5","id":"3020300c06082a864886f70d020505000410"},"RSA-MD5":{"sign":"rsa","hash":"md5","id":"3020300c06082a864886f70d020505000410"}}')},function(t,e){var n=Math.pow(2,30)-1;t.exports=function(t,e){if("number"!=typeof t)throw new TypeError("Iterations not a number");if(t<0)throw new TypeError("Bad iterations");if("number"!=typeof e)throw new TypeError("Key length not a number");if(e<0||e>n||e!=e)throw new TypeError("Bad key length")}},function(t,e,n){(function(e,n){var r;if(e.process&&e.process.browser)r="utf-8";else if(e.process&&e.process.version){r=parseInt(n.version.split(".")[0].slice(1),10)>=6?"utf-8":"binary"}else r="utf-8";t.exports=r}).call(this,n(10),n(12))},function(t,e,n){var r=n(140),a=n(75),i=n(76),o=n(4).Buffer,s=n(143),u=n(144),c=n(146),f=o.alloc(128),A={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,rmd160:20,ripemd160:20};function l(t,e,n){var s=function(t){function e(e){return i(t).update(e).digest()}return"rmd160"===t||"ripemd160"===t?function(t){return(new a).update(t).digest()}:"md5"===t?r:e}(t),u="sha512"===t||"sha384"===t?128:64;e.length>u?e=s(e):e.length<u&&(e=o.concat([e,f],u));for(var c=o.allocUnsafe(u+A[t]),l=o.allocUnsafe(u+A[t]),p=0;p<u;p++)c[p]=54^e[p],l[p]=92^e[p];var d=o.allocUnsafe(u+n+4);c.copy(d,0,0,u),this.ipad1=d,this.ipad2=c,this.opad=l,this.alg=t,this.blocksize=u,this.hash=s,this.size=A[t]}l.prototype.run=function(t,e){return t.copy(e,this.blocksize),this.hash(e).copy(this.opad,this.blocksize),this.hash(this.opad)},t.exports=function(t,e,n,r,a){s(n,r);var i=new l(a=a||"sha1",t=c(t,u,"Password"),(e=c(e,u,"Salt")).length),f=o.allocUnsafe(r),p=o.allocUnsafe(e.length+4);e.copy(p,0,0,e.length);for(var d=0,h=A[a],y=Math.ceil(r/h),g=1;g<=y;g++){p.writeUInt32BE(g,e.length);for(var b=i.run(p,i.ipad1),m=b,v=1;v<n;v++){m=i.run(m,i.ipad2);for(var I=0;I<h;I++)b[I]^=m[I]}b.copy(f,d),d+=h}return f}},function(t,e,n){var r=n(4).Buffer;t.exports=function(t,e,n){if(r.isBuffer(t))return t;if("string"==typeof t)return r.from(t,e);if(ArrayBuffer.isView(t))return r.from(t.buffer);throw new TypeError(n+" must be a string, a Buffer, a typed array or a DataView")}},function(t,e,n){var r=n(320),a=n(80),i=n(81),o=n(333),s=n(55);function u(t,e,n){if(t=t.toLowerCase(),i[t])return a.createCipheriv(t,e,n);if(o[t])return new r({key:e,iv:n,mode:t});throw new TypeError("invalid suite type")}function c(t,e,n){if(t=t.toLowerCase(),i[t])return a.createDecipheriv(t,e,n);if(o[t])return new r({key:e,iv:n,mode:t,decrypt:!0});throw new TypeError("invalid suite type")}e.createCipher=e.Cipher=function(t,e){var n,r;if(t=t.toLowerCase(),i[t])n=i[t].key,r=i[t].iv;else{if(!o[t])throw new TypeError("invalid suite type");n=8*o[t].key,r=o[t].iv}var a=s(e,!1,n,r);return u(t,a.key,a.iv)},e.createCipheriv=e.Cipheriv=u,e.createDecipher=e.Decipher=function(t,e){var n,r;if(t=t.toLowerCase(),i[t])n=i[t].key,r=i[t].iv;else{if(!o[t])throw new TypeError("invalid suite type");n=8*o[t].key,r=o[t].iv}var a=s(e,!1,n,r);return c(t,a.key,a.iv)},e.createDecipheriv=e.Decipheriv=c,e.listCiphers=e.getCiphers=function(){return Object.keys(o).concat(a.getCiphers())}},function(t,e,n){"use strict";e.readUInt32BE=function(t,e){return(t[0+e]<<24|t[1+e]<<16|t[2+e]<<8|t[3+e])>>>0},e.writeUInt32BE=function(t,e,n){t[0+n]=e>>>24,t[1+n]=e>>>16&255,t[2+n]=e>>>8&255,t[3+n]=255&e},e.ip=function(t,e,n,r){for(var a=0,i=0,o=6;o>=0;o-=2){for(var s=0;s<=24;s+=8)a<<=1,a|=e>>>s+o&1;for(s=0;s<=24;s+=8)a<<=1,a|=t>>>s+o&1}for(o=6;o>=0;o-=2){for(s=1;s<=25;s+=8)i<<=1,i|=e>>>s+o&1;for(s=1;s<=25;s+=8)i<<=1,i|=t>>>s+o&1}n[r+0]=a>>>0,n[r+1]=i>>>0},e.rip=function(t,e,n,r){for(var a=0,i=0,o=0;o<4;o++)for(var s=24;s>=0;s-=8)a<<=1,a|=e>>>s+o&1,a<<=1,a|=t>>>s+o&1;for(o=4;o<8;o++)for(s=24;s>=0;s-=8)i<<=1,i|=e>>>s+o&1,i<<=1,i|=t>>>s+o&1;n[r+0]=a>>>0,n[r+1]=i>>>0},e.pc1=function(t,e,n,r){for(var a=0,i=0,o=7;o>=5;o--){for(var s=0;s<=24;s+=8)a<<=1,a|=e>>s+o&1;for(s=0;s<=24;s+=8)a<<=1,a|=t>>s+o&1}for(s=0;s<=24;s+=8)a<<=1,a|=e>>s+o&1;for(o=1;o<=3;o++){for(s=0;s<=24;s+=8)i<<=1,i|=e>>s+o&1;for(s=0;s<=24;s+=8)i<<=1,i|=t>>s+o&1}for(s=0;s<=24;s+=8)i<<=1,i|=t>>s+o&1;n[r+0]=a>>>0,n[r+1]=i>>>0},e.r28shl=function(t,e){return t<<e&268435455|t>>>28-e};var r=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];e.pc2=function(t,e,n,a){for(var i=0,o=0,s=r.length>>>1,u=0;u<s;u++)i<<=1,i|=t>>>r[u]&1;for(u=s;u<r.length;u++)o<<=1,o|=e>>>r[u]&1;n[a+0]=i>>>0,n[a+1]=o>>>0},e.expand=function(t,e,n){var r=0,a=0;r=(1&t)<<5|t>>>27;for(var i=23;i>=15;i-=4)r<<=6,r|=t>>>i&63;for(i=11;i>=3;i-=4)a|=t>>>i&63,a<<=6;a|=(31&t)<<1|t>>>31,e[n+0]=r>>>0,e[n+1]=a>>>0};var a=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];e.substitute=function(t,e){for(var n=0,r=0;r<4;r++){n<<=4,n|=a[64*r+(t>>>18-6*r&63)]}for(r=0;r<4;r++){n<<=4,n|=a[256+64*r+(e>>>18-6*r&63)]}return n>>>0};var i=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];e.permute=function(t){for(var e=0,n=0;n<i.length;n++)e<<=1,e|=t>>>i[n]&1;return e>>>0},e.padSplit=function(t,e,n){for(var r=t.toString(2);r.length<e;)r="0"+r;for(var a=[],i=0;i<e;i+=n)a.push(r.slice(i,i+n));return a.join(" ")}},function(t,e,n){"use strict";var r=n(17),a=n(3),i=n(148),o=n(79);function s(){this.tmp=new Array(2),this.keys=null}function u(t){o.call(this,t);var e=new s;this._desState=e,this.deriveKeys(e,t.key)}a(u,o),t.exports=u,u.create=function(t){return new u(t)};var c=[1,1,2,2,2,2,2,2,1,2,2,2,2,2,2,1];u.prototype.deriveKeys=function(t,e){t.keys=new Array(32),r.equal(e.length,this.blockSize,"Invalid key length");var n=i.readUInt32BE(e,0),a=i.readUInt32BE(e,4);i.pc1(n,a,t.tmp,0),n=t.tmp[0],a=t.tmp[1];for(var o=0;o<t.keys.length;o+=2){var s=c[o>>>1];n=i.r28shl(n,s),a=i.r28shl(a,s),i.pc2(n,a,t.keys,o)}},u.prototype._update=function(t,e,n,r){var a=this._desState,o=i.readUInt32BE(t,e),s=i.readUInt32BE(t,e+4);i.ip(o,s,a.tmp,0),o=a.tmp[0],s=a.tmp[1],"encrypt"===this.type?this._encrypt(a,o,s,a.tmp,0):this._decrypt(a,o,s,a.tmp,0),o=a.tmp[0],s=a.tmp[1],i.writeUInt32BE(n,o,r),i.writeUInt32BE(n,s,r+4)},u.prototype._pad=function(t,e){for(var n=t.length-e,r=e;r<t.length;r++)t[r]=n;return!0},u.prototype._unpad=function(t){for(var e=t[t.length-1],n=t.length-e;n<t.length;n++)r.equal(t[n],e);return t.slice(0,t.length-e)},u.prototype._encrypt=function(t,e,n,r,a){for(var o=e,s=n,u=0;u<t.keys.length;u+=2){var c=t.keys[u],f=t.keys[u+1];i.expand(s,t.tmp,0),c^=t.tmp[0],f^=t.tmp[1];var A=i.substitute(c,f),l=s;s=(o^i.permute(A))>>>0,o=l}i.rip(s,o,r,a)},u.prototype._decrypt=function(t,e,n,r,a){for(var o=n,s=e,u=t.keys.length-2;u>=0;u-=2){var c=t.keys[u],f=t.keys[u+1];i.expand(o,t.tmp,0),c^=t.tmp[0],f^=t.tmp[1];var A=i.substitute(c,f),l=o;o=(s^i.permute(A))>>>0,s=l}i.rip(o,s,r,a)}},function(t,e,n){var r=n(45),a=n(4).Buffer,i=n(151);function o(t){var e=t._cipher.encryptBlockRaw(t._prev);return i(t._prev),e}e.encrypt=function(t,e){var n=Math.ceil(e.length/16),i=t._cache.length;t._cache=a.concat([t._cache,a.allocUnsafe(16*n)]);for(var s=0;s<n;s++){var u=o(t),c=i+16*s;t._cache.writeUInt32BE(u[0],c+0),t._cache.writeUInt32BE(u[1],c+4),t._cache.writeUInt32BE(u[2],c+8),t._cache.writeUInt32BE(u[3],c+12)}var f=t._cache.slice(0,e.length);return t._cache=t._cache.slice(e.length),r(e,f)}},function(t,e){t.exports=function(t){for(var e,n=t.length;n--;){if(255!==(e=t.readUInt8(n))){e++,t.writeUInt8(e,n);break}t.writeUInt8(0,n)}}},function(t){t.exports=JSON.parse('{"aes-128-ecb":{"cipher":"AES","key":128,"iv":0,"mode":"ECB","type":"block"},"aes-192-ecb":{"cipher":"AES","key":192,"iv":0,"mode":"ECB","type":"block"},"aes-256-ecb":{"cipher":"AES","key":256,"iv":0,"mode":"ECB","type":"block"},"aes-128-cbc":{"cipher":"AES","key":128,"iv":16,"mode":"CBC","type":"block"},"aes-192-cbc":{"cipher":"AES","key":192,"iv":16,"mode":"CBC","type":"block"},"aes-256-cbc":{"cipher":"AES","key":256,"iv":16,"mode":"CBC","type":"block"},"aes128":{"cipher":"AES","key":128,"iv":16,"mode":"CBC","type":"block"},"aes192":{"cipher":"AES","key":192,"iv":16,"mode":"CBC","type":"block"},"aes256":{"cipher":"AES","key":256,"iv":16,"mode":"CBC","type":"block"},"aes-128-cfb":{"cipher":"AES","key":128,"iv":16,"mode":"CFB","type":"stream"},"aes-192-cfb":{"cipher":"AES","key":192,"iv":16,"mode":"CFB","type":"stream"},"aes-256-cfb":{"cipher":"AES","key":256,"iv":16,"mode":"CFB","type":"stream"},"aes-128-cfb8":{"cipher":"AES","key":128,"iv":16,"mode":"CFB8","type":"stream"},"aes-192-cfb8":{"cipher":"AES","key":192,"iv":16,"mode":"CFB8","type":"stream"},"aes-256-cfb8":{"cipher":"AES","key":256,"iv":16,"mode":"CFB8","type":"stream"},"aes-128-cfb1":{"cipher":"AES","key":128,"iv":16,"mode":"CFB1","type":"stream"},"aes-192-cfb1":{"cipher":"AES","key":192,"iv":16,"mode":"CFB1","type":"stream"},"aes-256-cfb1":{"cipher":"AES","key":256,"iv":16,"mode":"CFB1","type":"stream"},"aes-128-ofb":{"cipher":"AES","key":128,"iv":16,"mode":"OFB","type":"stream"},"aes-192-ofb":{"cipher":"AES","key":192,"iv":16,"mode":"OFB","type":"stream"},"aes-256-ofb":{"cipher":"AES","key":256,"iv":16,"mode":"OFB","type":"stream"},"aes-128-ctr":{"cipher":"AES","key":128,"iv":16,"mode":"CTR","type":"stream"},"aes-192-ctr":{"cipher":"AES","key":192,"iv":16,"mode":"CTR","type":"stream"},"aes-256-ctr":{"cipher":"AES","key":256,"iv":16,"mode":"CTR","type":"stream"},"aes-128-gcm":{"cipher":"AES","key":128,"iv":12,"mode":"GCM","type":"auth"},"aes-192-gcm":{"cipher":"AES","key":192,"iv":12,"mode":"GCM","type":"auth"},"aes-256-gcm":{"cipher":"AES","key":256,"iv":12,"mode":"GCM","type":"auth"}}')},function(t,e,n){var r=n(54),a=n(4).Buffer,i=n(26),o=n(3),s=n(331),u=n(45),c=n(151);function f(t,e,n,o){i.call(this);var u=a.alloc(4,0);this._cipher=new r.AES(e);var f=this._cipher.encryptBlock(u);this._ghash=new s(f),n=function(t,e,n){if(12===e.length)return t._finID=a.concat([e,a.from([0,0,0,1])]),a.concat([e,a.from([0,0,0,2])]);var r=new s(n),i=e.length,o=i%16;r.update(e),o&&(o=16-o,r.update(a.alloc(o,0))),r.update(a.alloc(8,0));var u=8*i,f=a.alloc(8);f.writeUIntBE(u,0,8),r.update(f),t._finID=r.state;var A=a.from(t._finID);return c(A),A}(this,n,f),this._prev=a.from(n),this._cache=a.allocUnsafe(0),this._secCache=a.allocUnsafe(0),this._decrypt=o,this._alen=0,this._len=0,this._mode=t,this._authTag=null,this._called=!1}o(f,i),f.prototype._update=function(t){if(!this._called&&this._alen){var e=16-this._alen%16;e<16&&(e=a.alloc(e,0),this._ghash.update(e))}this._called=!0;var n=this._mode.encrypt(this,t);return this._decrypt?this._ghash.update(t):this._ghash.update(n),this._len+=t.length,n},f.prototype._final=function(){if(this._decrypt&&!this._authTag)throw new Error("Unsupported state or unable to authenticate data");var t=u(this._ghash.final(8*this._alen,8*this._len),this._cipher.encryptBlock(this._finID));if(this._decrypt&&function(t,e){var n=0;t.length!==e.length&&n++;for(var r=Math.min(t.length,e.length),a=0;a<r;++a)n+=t[a]^e[a];return n}(t,this._authTag))throw new Error("Unsupported state or unable to authenticate data");this._authTag=t,this._cipher.scrub()},f.prototype.getAuthTag=function(){if(this._decrypt||!a.isBuffer(this._authTag))throw new Error("Attempting to get auth tag in unsupported state");return this._authTag},f.prototype.setAuthTag=function(t){if(!this._decrypt)throw new Error("Attempting to set auth tag in unsupported state");this._authTag=t},f.prototype.setAAD=function(t){if(this._called)throw new Error("Attempting to set AAD in unsupported state");this._ghash.update(t),this._alen+=t.length},t.exports=f},function(t,e,n){var r=n(54),a=n(4).Buffer,i=n(26);function o(t,e,n,o){i.call(this),this._cipher=new r.AES(e),this._prev=a.from(n),this._cache=a.allocUnsafe(0),this._secCache=a.allocUnsafe(0),this._decrypt=o,this._mode=t}n(3)(o,i),o.prototype._update=function(t){return this._mode.encrypt(this,t,this._decrypt)},o.prototype._final=function(){this._cipher.scrub()},t.exports=o},function(t,e,n){(function(t){var r=n(156),a=n(335),i=n(336);var o={binary:!0,hex:!0,base64:!0};e.DiffieHellmanGroup=e.createDiffieHellmanGroup=e.getDiffieHellman=function(e){var n=new t(a[e].prime,"hex"),r=new t(a[e].gen,"hex");return new i(n,r)},e.createDiffieHellman=e.DiffieHellman=function e(n,a,s,u){return t.isBuffer(a)||void 0===o[a]?e(n,"binary",a,s):(a=a||"binary",u=u||"binary",s=s||new t([2]),t.isBuffer(s)||(s=new t(s,u)),"number"==typeof n?new i(r(n,s),s,!0):(t.isBuffer(n)||(n=new t(n,a)),new i(n,s,!0)))}}).call(this,n(5).Buffer)},function(t,e,n){var r=n(29);t.exports=b,b.simpleSieve=y,b.fermatTest=g;var a=n(2),i=new a(24),o=new(n(157)),s=new a(1),u=new a(2),c=new a(5),f=(new a(16),new a(8),new a(10)),A=new a(3),l=(new a(7),new a(11)),p=new a(4),d=(new a(12),null);function h(){if(null!==d)return d;var t=[];t[0]=2;for(var e=1,n=3;n<1048576;n+=2){for(var r=Math.ceil(Math.sqrt(n)),a=0;a<e&&t[a]<=r&&n%t[a]!=0;a++);e!==a&&t[a]<=r||(t[e++]=n)}return d=t,t}function y(t){for(var e=h(),n=0;n<e.length;n++)if(0===t.modn(e[n]))return 0===t.cmpn(e[n]);return!0}function g(t){var e=a.mont(t);return 0===u.toRed(e).redPow(t.subn(1)).fromRed().cmpn(1)}function b(t,e){if(t<16)return new a(2===e||5===e?[140,123]:[140,39]);var n,d;for(e=new a(e);;){for(n=new a(r(Math.ceil(t/8)));n.bitLength()>t;)n.ishrn(1);if(n.isEven()&&n.iadd(s),n.testn(1)||n.iadd(u),e.cmp(u)){if(!e.cmp(c))for(;n.mod(f).cmp(A);)n.iadd(p)}else for(;n.mod(i).cmp(l);)n.iadd(p);if(y(d=n.shrn(1))&&y(n)&&g(d)&&g(n)&&o.test(d)&&o.test(n))return n}}},function(t,e,n){var r=n(2),a=n(82);function i(t){this.rand=t||new a.Rand}t.exports=i,i.create=function(t){return new i(t)},i.prototype._randbelow=function(t){var e=t.bitLength(),n=Math.ceil(e/8);do{var a=new r(this.rand.generate(n))}while(a.cmp(t)>=0);return a},i.prototype._randrange=function(t,e){var n=e.sub(t);return t.add(this._randbelow(n))},i.prototype.test=function(t,e,n){var a=t.bitLength(),i=r.mont(t),o=new r(1).toRed(i);e||(e=Math.max(1,a/48|0));for(var s=t.subn(1),u=0;!s.testn(u);u++);for(var c=t.shrn(u),f=s.toRed(i);e>0;e--){var A=this._randrange(new r(2),s);n&&n(A);var l=A.toRed(i).redPow(c);if(0!==l.cmp(o)&&0!==l.cmp(f)){for(var p=1;p<u;p++){if(0===(l=l.redSqr()).cmp(o))return!1;if(0===l.cmp(f))break}if(p===u)return!1}}return!0},i.prototype.getDivisor=function(t,e){var n=t.bitLength(),a=r.mont(t),i=new r(1).toRed(a);e||(e=Math.max(1,n/48|0));for(var o=t.subn(1),s=0;!o.testn(s);s++);for(var u=t.shrn(s),c=o.toRed(a);e>0;e--){var f=this._randrange(new r(2),o),A=t.gcd(f);if(0!==A.cmpn(1))return A;var l=f.toRed(a).redPow(u);if(0!==l.cmp(i)&&0!==l.cmp(c)){for(var p=1;p<s;p++){if(0===(l=l.redSqr()).cmp(i))return l.fromRed().subn(1).gcd(t);if(0===l.cmp(c))break}if(p===s)return(l=l.redSqr()).fromRed().subn(1).gcd(t)}}return!1}},function(t,e,n){var r=n(4).Buffer,a=n(34),i=n(73),o=n(3),s=n(337),u=n(359),c=n(142);function f(t){i.Writable.call(this);var e=c[t];if(!e)throw new Error("Unknown message digest");this._hashType=e.hash,this._hash=a(e.hash),this._tag=e.id,this._signType=e.sign}function A(t){i.Writable.call(this);var e=c[t];if(!e)throw new Error("Unknown message digest");this._hash=a(e.hash),this._tag=e.id,this._signType=e.sign}function l(t){return new f(t)}function p(t){return new A(t)}Object.keys(c).forEach((function(t){c[t].id=r.from(c[t].id,"hex"),c[t.toLowerCase()]=c[t]})),o(f,i.Writable),f.prototype._write=function(t,e,n){this._hash.update(t),n()},f.prototype.update=function(t,e){return"string"==typeof t&&(t=r.from(t,e)),this._hash.update(t),this},f.prototype.sign=function(t,e){this.end();var n=this._hash.digest(),r=s(n,t,this._hashType,this._signType,this._tag);return e?r.toString(e):r},o(A,i.Writable),A.prototype._write=function(t,e,n){this._hash.update(t),n()},A.prototype.update=function(t,e){return"string"==typeof t&&(t=r.from(t,e)),this._hash.update(t),this},A.prototype.verify=function(t,e,n){"string"==typeof e&&(e=r.from(e,n)),this.end();var a=this._hash.digest();return u(e,a,t,this._signType,this._tag)},t.exports={Sign:l,Verify:p,createSign:l,createVerify:p}},function(t,e,n){"use strict";var r=e;function a(t){return 1===t.length?"0"+t:t}function i(t){for(var e="",n=0;n<t.length;n++)e+=a(t[n].toString(16));return e}r.toArray=function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var n=[];if("string"!=typeof t){for(var r=0;r<t.length;r++)n[r]=0|t[r];return n}if("hex"===e){(t=t.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(t="0"+t);for(r=0;r<t.length;r+=2)n.push(parseInt(t[r]+t[r+1],16))}else for(r=0;r<t.length;r++){var a=t.charCodeAt(r),i=a>>8,o=255&a;i?n.push(i,o):n.push(o)}return n},r.zero2=a,r.toHex=i,r.encode=function(t,e){return"hex"===e?i(t):t}},function(t,e,n){"use strict";var r=e;r.base=n(56),r.short=n(339),r.mont=n(340),r.edwards=n(341)},function(t,e,n){"use strict";var r=e;r.bignum=n(2),r.define=n(351).define,r.base=n(354),r.constants=n(355),r.decoders=n(164),r.encoders=n(162)},function(t,e,n){"use strict";var r=e;r.der=n(163),r.pem=n(352)},function(t,e,n){"use strict";var r=n(3),a=n(86).Buffer,i=n(87),o=n(89);function s(t){this.enc="der",this.name=t.name,this.entity=t,this.tree=new u,this.tree._init(t.body)}function u(t){i.call(this,"der",t)}function c(t){return t<10?"0"+t:t}t.exports=s,s.prototype.encode=function(t,e){return this.tree._encode(t,e).join()},r(u,i),u.prototype._encodeComposite=function(t,e,n,r){var i=function(t,e,n,r){var a;"seqof"===t?t="seq":"setof"===t&&(t="set");if(o.tagByName.hasOwnProperty(t))a=o.tagByName[t];else{if("number"!=typeof t||(0|t)!==t)return r.error("Unknown tag: "+t);a=t}if(a>=31)return r.error("Multi-octet tag encoding unsupported");e||(a|=32);return a|=o.tagClassByName[n||"universal"]<<6}(t,e,n,this.reporter);if(r.length<128){var s=a.alloc(2);return s[0]=i,s[1]=r.length,this._createEncoderBuffer([s,r])}for(var u=1,c=r.length;c>=256;c>>=8)u++;var f=a.alloc(2+u);f[0]=i,f[1]=128|u;for(var A=1+u,l=r.length;l>0;A--,l>>=8)f[A]=255&l;return this._createEncoderBuffer([f,r])},u.prototype._encodeStr=function(t,e){if("bitstr"===e)return this._createEncoderBuffer([0|t.unused,t.data]);if("bmpstr"===e){for(var n=a.alloc(2*t.length),r=0;r<t.length;r++)n.writeUInt16BE(t.charCodeAt(r),2*r);return this._createEncoderBuffer(n)}return"numstr"===e?this._isNumstr(t)?this._createEncoderBuffer(t):this.reporter.error("Encoding of string type: numstr supports only digits and space"):"printstr"===e?this._isPrintstr(t)?this._createEncoderBuffer(t):this.reporter.error("Encoding of string type: printstr supports only latin upper and lower case letters, digits, space, apostrophe, left and rigth parenthesis, plus sign, comma, hyphen, dot, slash, colon, equal sign, question mark"):/str$/.test(e)||"objDesc"===e?this._createEncoderBuffer(t):this.reporter.error("Encoding of string type: "+e+" unsupported")},u.prototype._encodeObjid=function(t,e,n){if("string"==typeof t){if(!e)return this.reporter.error("string objid given, but no values map found");if(!e.hasOwnProperty(t))return this.reporter.error("objid not found in values map");t=e[t].split(/[\s.]+/g);for(var r=0;r<t.length;r++)t[r]|=0}else if(Array.isArray(t)){t=t.slice();for(var i=0;i<t.length;i++)t[i]|=0}if(!Array.isArray(t))return this.reporter.error("objid() should be either array or string, got: "+JSON.stringify(t));if(!n){if(t[1]>=40)return this.reporter.error("Second objid identifier OOB");t.splice(0,2,40*t[0]+t[1])}for(var o=0,s=0;s<t.length;s++){var u=t[s];for(o++;u>=128;u>>=7)o++}for(var c=a.alloc(o),f=c.length-1,A=t.length-1;A>=0;A--){var l=t[A];for(c[f--]=127&l;(l>>=7)>0;)c[f--]=128|127&l}return this._createEncoderBuffer(c)},u.prototype._encodeTime=function(t,e){var n,r=new Date(t);return"gentime"===e?n=[c(r.getUTCFullYear()),c(r.getUTCMonth()+1),c(r.getUTCDate()),c(r.getUTCHours()),c(r.getUTCMinutes()),c(r.getUTCSeconds()),"Z"].join(""):"utctime"===e?n=[c(r.getUTCFullYear()%100),c(r.getUTCMonth()+1),c(r.getUTCDate()),c(r.getUTCHours()),c(r.getUTCMinutes()),c(r.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+e+" time is not supported yet"),this._encodeStr(n,"octstr")},u.prototype._encodeNull=function(){return this._createEncoderBuffer("")},u.prototype._encodeInt=function(t,e){if("string"==typeof t){if(!e)return this.reporter.error("String int or enum given, but no values map");if(!e.hasOwnProperty(t))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(t));t=e[t]}if("number"!=typeof t&&!a.isBuffer(t)){var n=t.toArray();!t.sign&&128&n[0]&&n.unshift(0),t=a.from(n)}if(a.isBuffer(t)){var r=t.length;0===t.length&&r++;var i=a.alloc(r);return t.copy(i),0===t.length&&(i[0]=0),this._createEncoderBuffer(i)}if(t<128)return this._createEncoderBuffer(t);if(t<256)return this._createEncoderBuffer([0,t]);for(var o=1,s=t;s>=256;s>>=8)o++;for(var u=new Array(o),c=u.length-1;c>=0;c--)u[c]=255&t,t>>=8;return 128&u[0]&&u.unshift(0),this._createEncoderBuffer(a.from(u))},u.prototype._encodeBool=function(t){return this._createEncoderBuffer(t?255:0)},u.prototype._use=function(t,e){return"function"==typeof t&&(t=t(e)),t._getEncoder("der").tree},u.prototype._skipDefault=function(t,e,n){var r,a=this._baseState;if(null===a.default)return!1;var i=t.join();if(void 0===a.defaultBuffer&&(a.defaultBuffer=this._encodeValue(a.default,e,n).join()),i.length!==a.defaultBuffer.length)return!1;for(r=0;r<i.length;r++)if(i[r]!==a.defaultBuffer[r])return!1;return!0}},function(t,e,n){"use strict";var r=e;r.der=n(165),r.pem=n(353)},function(t,e,n){"use strict";var r=n(3),a=n(2),i=n(46).DecoderBuffer,o=n(87),s=n(89);function u(t){this.enc="der",this.name=t.name,this.entity=t,this.tree=new c,this.tree._init(t.body)}function c(t){o.call(this,"der",t)}function f(t,e){var n=t.readUInt8(e);if(t.isError(n))return n;var r=s.tagClass[n>>6],a=0==(32&n);if(31==(31&n)){var i=n;for(n=0;128==(128&i);){if(i=t.readUInt8(e),t.isError(i))return i;n<<=7,n|=127&i}}else n&=31;return{cls:r,primitive:a,tag:n,tagStr:s.tag[n]}}function A(t,e,n){var r=t.readUInt8(n);if(t.isError(r))return r;if(!e&&128===r)return null;if(0==(128&r))return r;var a=127&r;if(a>4)return t.error("length octect is too long");r=0;for(var i=0;i<a;i++){r<<=8;var o=t.readUInt8(n);if(t.isError(o))return o;r|=o}return r}t.exports=u,u.prototype.decode=function(t,e){return i.isDecoderBuffer(t)||(t=new i(t,e)),this.tree._decode(t,e)},r(c,o),c.prototype._peekTag=function(t,e,n){if(t.isEmpty())return!1;var r=t.save(),a=f(t,'Failed to peek tag: "'+e+'"');return t.isError(a)?a:(t.restore(r),a.tag===e||a.tagStr===e||a.tagStr+"of"===e||n)},c.prototype._decodeTag=function(t,e,n){var r=f(t,'Failed to decode tag of "'+e+'"');if(t.isError(r))return r;var a=A(t,r.primitive,'Failed to get length of "'+e+'"');if(t.isError(a))return a;if(!n&&r.tag!==e&&r.tagStr!==e&&r.tagStr+"of"!==e)return t.error('Failed to match tag: "'+e+'"');if(r.primitive||null!==a)return t.skip(a,'Failed to match body of: "'+e+'"');var i=t.save(),o=this._skipUntilEnd(t,'Failed to skip indefinite length body: "'+this.tag+'"');return t.isError(o)?o:(a=t.offset-i.offset,t.restore(i),t.skip(a,'Failed to match body of: "'+e+'"'))},c.prototype._skipUntilEnd=function(t,e){for(;;){var n=f(t,e);if(t.isError(n))return n;var r=A(t,n.primitive,e);if(t.isError(r))return r;var a=void 0;if(a=n.primitive||null!==r?t.skip(r):this._skipUntilEnd(t,e),t.isError(a))return a;if("end"===n.tagStr)break}},c.prototype._decodeList=function(t,e,n,r){for(var a=[];!t.isEmpty();){var i=this._peekTag(t,"end");if(t.isError(i))return i;var o=n.decode(t,"der",r);if(t.isError(o)&&i)break;a.push(o)}return a},c.prototype._decodeStr=function(t,e){if("bitstr"===e){var n=t.readUInt8();return t.isError(n)?n:{unused:n,data:t.raw()}}if("bmpstr"===e){var r=t.raw();if(r.length%2==1)return t.error("Decoding of string type: bmpstr length mismatch");for(var a="",i=0;i<r.length/2;i++)a+=String.fromCharCode(r.readUInt16BE(2*i));return a}if("numstr"===e){var o=t.raw().toString("ascii");return this._isNumstr(o)?o:t.error("Decoding of string type: numstr unsupported characters")}if("octstr"===e)return t.raw();if("objDesc"===e)return t.raw();if("printstr"===e){var s=t.raw().toString("ascii");return this._isPrintstr(s)?s:t.error("Decoding of string type: printstr unsupported characters")}return/str$/.test(e)?t.raw().toString():t.error("Decoding of string type: "+e+" unsupported")},c.prototype._decodeObjid=function(t,e,n){for(var r,a=[],i=0,o=0;!t.isEmpty();)i<<=7,i|=127&(o=t.readUInt8()),0==(128&o)&&(a.push(i),i=0);128&o&&a.push(i);var s=a[0]/40|0,u=a[0]%40;if(r=n?a:[s,u].concat(a.slice(1)),e){var c=e[r.join(" ")];void 0===c&&(c=e[r.join(".")]),void 0!==c&&(r=c)}return r},c.prototype._decodeTime=function(t,e){var n,r,a,i,o,s,u=t.raw().toString();if("gentime"===e)n=0|u.slice(0,4),r=0|u.slice(4,6),a=0|u.slice(6,8),i=0|u.slice(8,10),o=0|u.slice(10,12),s=0|u.slice(12,14);else{if("utctime"!==e)return t.error("Decoding "+e+" time is not supported yet");n=0|u.slice(0,2),r=0|u.slice(2,4),a=0|u.slice(4,6),i=0|u.slice(6,8),o=0|u.slice(8,10),s=0|u.slice(10,12),n=n<70?2e3+n:1900+n}return Date.UTC(n,r-1,a,i,o,s,0)},c.prototype._decodeNull=function(){return null},c.prototype._decodeBool=function(t){var e=t.readUInt8();return t.isError(e)?e:0!==e},c.prototype._decodeInt=function(t,e){var n=t.raw(),r=new a(n);return e&&(r=e[r.toString(10)]||r),r},c.prototype._use=function(t,e){return"function"==typeof t&&(t=t(e)),t._getDecoder("der").tree}},function(t){t.exports=JSON.parse('{"1.3.132.0.10":"secp256k1","1.3.132.0.33":"p224","1.2.840.10045.3.1.1":"p192","1.2.840.10045.3.1.7":"p256","1.3.132.0.34":"p384","1.3.132.0.35":"p521"}')},function(t,e,n){(function(e){var r=n(84),a=n(2);t.exports=function(t){return new o(t)};var i={secp256k1:{name:"secp256k1",byteLength:32},secp224r1:{name:"p224",byteLength:28},prime256v1:{name:"p256",byteLength:32},prime192v1:{name:"p192",byteLength:24},ed25519:{name:"ed25519",byteLength:32},secp384r1:{name:"p384",byteLength:48},secp521r1:{name:"p521",byteLength:66}};function o(t){this.curveType=i[t],this.curveType||(this.curveType={name:t}),this.curve=new r.ec(this.curveType.name),this.keys=void 0}function s(t,n,r){Array.isArray(t)||(t=t.toArray());var a=new e(t);if(r&&a.length<r){var i=new e(r-a.length);i.fill(0),a=e.concat([i,a])}return n?a.toString(n):a}i.p224=i.secp224r1,i.p256=i.secp256r1=i.prime256v1,i.p192=i.secp192r1=i.prime192v1,i.p384=i.secp384r1,i.p521=i.secp521r1,o.prototype.generateKeys=function(t,e){return this.keys=this.curve.genKeyPair(),this.getPublicKey(t,e)},o.prototype.computeSecret=function(t,n,r){return n=n||"utf8",e.isBuffer(t)||(t=new e(t,n)),s(this.curve.keyFromPublic(t).getPublic().mul(this.keys.getPrivate()).getX(),r,this.curveType.byteLength)},o.prototype.getPublicKey=function(t,e){var n=this.keys.getPublic("compressed"===e,!0);return"hybrid"===e&&(n[n.length-1]%2?n[0]=7:n[0]=6),s(n,t)},o.prototype.getPrivateKey=function(t){return s(this.keys.getPrivate(),t)},o.prototype.setPublicKey=function(t,n){return n=n||"utf8",e.isBuffer(t)||(t=new e(t,n)),this.keys._importPublic(t),this},o.prototype.setPrivateKey=function(t,n){n=n||"utf8",e.isBuffer(t)||(t=new e(t,n));var r=new a(t);return r=r.toString(16),this.keys=this.curve.genKeyPair(),this.keys._importPrivate(r),this}}).call(this,n(5).Buffer)},function(t,e,n){e.publicEncrypt=n(360),e.privateDecrypt=n(361),e.privateEncrypt=function(t,n){return e.publicEncrypt(t,n,!0)},e.publicDecrypt=function(t,n){return e.privateDecrypt(t,n,!0)}},function(t,e,n){var r=n(34),a=n(4).Buffer;function i(t){var e=a.allocUnsafe(4);return e.writeUInt32BE(t,0),e}t.exports=function(t,e){for(var n,o=a.alloc(0),s=0;o.length<e;)n=i(s++),o=a.concat([o,r("sha1").update(t).update(n).digest()]);return o.slice(0,e)}},function(t,e){t.exports=function(t,e){for(var n=t.length,r=-1;++r<n;)t[r]^=e[r];return t}},function(t,e,n){var r=n(2),a=n(4).Buffer;t.exports=function(t,e){return a.from(t.toRed(r.mont(e.modulus)).redPow(new r(e.publicExponent)).fromRed().toArray())}},function(t,e,n){"use strict";(function(t,r){function a(){throw new Error("secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11")}var i=n(4),o=n(29),s=i.Buffer,u=i.kMaxLength,c=t.crypto||t.msCrypto,f=Math.pow(2,32)-1;function A(t,e){if("number"!=typeof t||t!=t)throw new TypeError("offset must be a number");if(t>f||t<0)throw new TypeError("offset must be a uint32");if(t>u||t>e)throw new RangeError("offset out of range")}function l(t,e,n){if("number"!=typeof t||t!=t)throw new TypeError("size must be a number");if(t>f||t<0)throw new TypeError("size must be a uint32");if(t+e>n||t>u)throw new RangeError("buffer too small")}function p(t,e,n,a){if(r.browser){var i=t.buffer,s=new Uint8Array(i,e,n);return c.getRandomValues(s),a?void r.nextTick((function(){a(null,t)})):t}if(!a)return o(n).copy(t,e),t;o(n,(function(n,r){if(n)return a(n);r.copy(t,e),a(null,t)}))}c&&c.getRandomValues||!r.browser?(e.randomFill=function(e,n,r,a){if(!(s.isBuffer(e)||e instanceof t.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');if("function"==typeof n)a=n,n=0,r=e.length;else if("function"==typeof r)a=r,r=e.length-n;else if("function"!=typeof a)throw new TypeError('"cb" argument must be a function');return A(n,e.length),l(r,n,e.length),p(e,n,r,a)},e.randomFillSync=function(e,n,r){void 0===n&&(n=0);if(!(s.isBuffer(e)||e instanceof t.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');A(n,e.length),void 0===r&&(r=e.length-n);return l(r,n,e.length),p(e,n,r)}):(e.randomFill=a,e.randomFillSync=a)}).call(this,n(10),n(12))},function(t,e,n){(function(t){var r,a,i,o;function s(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function u(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,(a=r.key,i=void 0,i=function(t,e){if("object"!==f(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!==f(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(a,"string"),"symbol"===f(i)?i:String(i)),r)}var a,i}function c(t,e,n){return e&&u(t.prototype,e),n&&u(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function f(t){return(f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}window,o=function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var a=e[r]={i:r,l:!1,exports:{}};return t[r].call(a.exports,a,a.exports,n),a.l=!0,a.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==f(t)&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var a in t)n.d(r,a,function(e){return t[e]}.bind(null,a));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=10)}([function(t,e,n){"use strict";(function(t){n.d(e,"a",(function(){return i}));var r=n(7),a=n.n(r),i=function(){function e(t){s(this,e),this.wasm=t}return c(e,[{key:"arrayToBuf",value:function(e){var n=this.wasm,r={ptr:null,len:0};if(!e)return r;var a=null;if(e instanceof Uint8Array||void 0!==t&&e instanceof t)a=e;else{if(!(e instanceof ArrayBuffer||e.__proto__.toString().includes("ArrayBuffer")))throw new Error("arrayToBuf() failed: Expected Uint8Array, Buffer, or\n ArrayBuffer");a=new Uint8Array(e)}return r.len=a.length,r.ptr=n._malloc(a.length),n.writeArrayToMemory(a,r.ptr),r}},{key:"arrayToSmartBuf",value:function(t){var e=this.wasm,n=this.arrayToBuf(t);return n.ptr&&setTimeout((function(){e._free(n.ptr),n.len=0,n.ptr=null}),0),n}},{key:"smartMalloc",value:function(t){var e=this.wasm,n=e._malloc(t);return setTimeout((function(){e._free(n)}),0),n}}],[{key:"bytesToHex",value:function(t){return t.reduce((function(t,e){return t+e.toString(16).padStart(2,"0")}),"")}},{key:"bytesToBinary",value:function(t){return t.reduce((function(t,e){return t+e.toString(2).padStart(8,"0")+" "}),"")}},{key:"hexToBytes",value:function(t){return new Uint8Array(t.match(/.{1,2}/g).map((function(t){return parseInt(t,16)})))}},{key:"randomBytes",value:function(t){if("undefined"!=typeof window&&"undefined"!==window.crypto){var e=new Uint8Array(t);return window.crypto.getRandomValues(e),e}return a.a.randomBytes(t)}}]),e}()}).call(this,n(3).Buffer)},function(t,e,n){"use strict";n.d(e,"a",(function(){return r}));var r=function(){function t(e){s(this,t),this.wasm=e,this.ptr=null,this.len=0}return c(t,[{key:"clear",value:function(){this.len=0}},{key:"free",value:function(){null!==this.ptr&&(this.wasm._free(this.ptr),this.len=0,this.ptr=null)}},{key:"resize",value:function(t){null!==this.ptr&&this.free(),this.len=t,this.ptr=this.wasm._malloc(t)}},{key:"ensureSize",value:function(t){(null===this.ptr||this.len<t)&&this.resize(t)}}]),t}()},function(t,e){t.exports=n(362)},function(t,e,n){"use strict";(function(t){
52
52
  /*!
53
53
  * The buffer module from node.js, for the browser.
54
54
  *