@eluvio/elv-client-js 4.0.81 → 4.0.82

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.
@@ -46,7 +46,7 @@ var r=n(4),i=r.Buffer;function a(t,e){for(var n in t)e[n]=t[n]}function o(t,e,n)
46
46
  * Licensed under
47
47
  * MIT License http://www.opensource.org/licenses/mit-license
48
48
  *
49
- */!function(o,s){"use strict";"object"===a(t)&&t.exports?t.exports=s():void 0===(i="function"==typeof(r=s)?r.call(e,n,e,t):r)||(t.exports=i)}(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 i=n.list[t.slice(e+1)];return!!i&&i.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 i=n.list[t.slice(e+1)];return i?i.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(26)(t))},function(t,e,n){"use strict";var r=n(27).rotr32;function i(t,e,n){return t&e^~t&n}function a(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?i(e,n,r):1===t||3===t?o(e,n,r):2===t?a(e,n,r):void 0},e.ch32=i,e.maj32=a,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(27),i=n(56),a=n(122),o=n(19),s=r.sum32,u=r.sum32_4,c=r.sum32_5,f=a.ch32,l=a.maj32,p=a.s0_256,d=a.s1_256,h=a.g0_256,y=a.g1_256,A=i.BlockHash,b=[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 g(){if(!(this instanceof g))return new g;A.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=b,this.W=new Array(64)}r.inherits(g,A),t.exports=g,g.blockSize=512,g.outSize=256,g.hmacStrength=192,g.padLength=64,g.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(y(n[r-2]),n[r-7],h(n[r-15]),n[r-16]);var i=this.h[0],a=this.h[1],A=this.h[2],b=this.h[3],g=this.h[4],m=this.h[5],v=this.h[6],w=this.h[7];for(o(this.k.length===n.length),r=0;r<n.length;r++){var I=c(w,d(g),f(g,m,v),this.k[r],n[r]),E=s(p(i),l(i,a,A));w=v,v=m,m=g,g=s(b,I),b=A,A=a,a=i,i=s(I,E)}this.h[0]=s(this.h[0],i),this.h[1]=s(this.h[1],a),this.h[2]=s(this.h[2],A),this.h[3]=s(this.h[3],b),this.h[4]=s(this.h[4],g),this.h[5]=s(this.h[5],m),this.h[6]=s(this.h[6],v),this.h[7]=s(this.h[7],w)},g.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(27),i=n(56),a=n(19),o=r.rotr64_hi,s=r.rotr64_lo,u=r.shr64_hi,c=r.shr64_lo,f=r.sum64,l=r.sum64_hi,p=r.sum64_lo,d=r.sum64_4_hi,h=r.sum64_4_lo,y=r.sum64_5_hi,A=r.sum64_5_lo,b=i.BlockHash,g=[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;b.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=g,this.W=new Array(160)}function v(t,e,n,r,i){var a=t&n^~t&i;return a<0&&(a+=4294967296),a}function w(t,e,n,r,i,a){var o=e&r^~e&a;return o<0&&(o+=4294967296),o}function I(t,e,n,r,i){var a=t&n^t&i^n&i;return a<0&&(a+=4294967296),a}function E(t,e,n,r,i,a){var o=e&r^e&a^r&a;return o<0&&(o+=4294967296),o}function _(t,e){var n=o(t,e,28)^o(e,t,2)^o(e,t,7);return n<0&&(n+=4294967296),n}function C(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 B(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 Q(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,b),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 i=Q(n[r-4],n[r-3]),a=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],l=n[r-31];n[r]=d(i,a,o,s,u,c,f,l),n[r+1]=h(i,a,o,s,u,c,f,l)}},m.prototype._update=function(t,e){this._prepareBlock(t,e);var n=this.W,r=this.h[0],i=this.h[1],o=this.h[2],s=this.h[3],u=this.h[4],c=this.h[5],d=this.h[6],h=this.h[7],b=this.h[8],g=this.h[9],m=this.h[10],x=this.h[11],S=this.h[12],Q=this.h[13],M=this.h[14],R=this.h[15];a(this.k.length===n.length);for(var O=0;O<n.length;O+=2){var j=M,T=R,P=k(b,g),D=B(b,g),N=v(b,g,m,x,S),L=w(b,g,m,x,S,Q),F=this.k[O],U=this.k[O+1],H=n[O],G=n[O+1],q=y(j,T,P,D,N,L,F,U,H,G),K=A(j,T,P,D,N,L,F,U,H,G);j=_(r,i),T=C(r,i),P=I(r,i,o,s,u),D=E(r,i,o,s,u,c);var Y=l(j,T,P,D),z=p(j,T,P,D);M=S,R=Q,S=m,Q=x,m=b,x=g,b=l(d,h,q,K),g=p(h,h,q,K),d=u,h=c,u=o,c=s,o=r,s=i,r=l(q,K,Y,z),i=p(q,K,Y,z)}f(this.h,0,r,i),f(this.h,2,o,s),f(this.h,4,u,c),f(this.h,6,d,h),f(this.h,8,b,g),f(this.h,10,m,x),f(this.h,12,S,Q),f(this.h,14,M,R)},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,i=Function.prototype.apply;function a(t,e){this._id=t,this._clearFn=e}e.setTimeout=function(){return new a(i.call(setTimeout,r,arguments),clearTimeout)},e.setInterval=function(){return new a(i.call(setInterval,r,arguments),clearInterval)},e.clearTimeout=e.clearInterval=function(t){t&&t.close()},a.prototype.unref=a.prototype.ref=function(){},a.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(232),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(8))},function(t,e,n){var r=n(238);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){(function(t){var r=n(36),i=n(18),a=n(17),o=n(9),s=n(10);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){a(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(30),l=n(267),p=n(41),d=n(31),h=d.ValidateLibrary,y=d.ValidateObject,A=d.ValidateVersion,b=d.ValidatePartHash,g=d.ValidateWriteToken,m=d.ValidateParameters,v=n(268);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,i,a=this;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.id,r=e.clearCache,t.prev=1,i=this.utils.HashToAddress(n),r&&delete this.visibilityInfo[i],this.visibilityInfo[i]||(this.visibilityInfo[i]=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,a.authClient.ContractHasMethod({contractAddress:i,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,a.CallContractMethod({contractAddress:a.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[i];case 8:return t.abrupt("return",t.sent);case 11:throw t.prev=11,t.t0=t.catch(5),delete this.visibilityInfo[i],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,i,a,s,u,c,f,l=this;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.objectId,r=e.clearCache,y(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 i=t.sent,t.next=13,this.CallContractMethod({contractAddress:this.utils.HashToAddress(n),methodName:"addressKMS"});case 13:if(a=t.sent,s=a&&"ikms".concat(this.utils.AddressToHash(a)),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=l.permissionLevels[t].settings;return i>=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,i=arguments;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e=i.length>0&&void 0!==i[0]?i[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,i,a;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.name,r=e.typeId,i=e.versionHash,t.next=3,this.ContentType({name:n,typeId:r,versionHash:i});case 3:return a=t.sent,t.t0=this.utils,t.next=7,this.ethClient.CallContractMethod({contractAddress:this.utils.HashToAddress(a.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,i,a,s,u,c;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.name,r=e.typeId,i=e.versionHash,a=e.publicOnly,s=void 0!==a&&a,this.Log("Retrieving content type: ".concat(n||r||i)),i&&(r=this.utils.DecodeVersionHash(i).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===i})));case 23:if(i){t.next=27;break}return t.next=26,this.LatestVersionHash({objectId:r});case 26:i=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:i,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:i});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:i,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,i=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 i.utils.HashToAddress(t)})),this.Log("Content space types:"),this.Log(r),e=e.concat(r).filter((function(t){return t})).map((function(t){return i.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=i.utils.AddressToObjectId(e),i.contentTypes[n]){t.next=11;break}return t.prev=2,t.next=5,i.ContentType({typeId:n,publicOnly:!0});case 5:i.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,i;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,h(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 i=t.sent,t.abrupt("return",c(c({},i),{},{meta:i.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,h(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,i,a=this;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,h(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 i={},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,a.ethClient.CallContractMethod({contractAddress:a.utils.HashToAddress(n),methodName:"contentTypes",methodArgs:[r]});case 2:return s=t.sent,u=a.utils.AddressToObjectId(s),t.next=6,a.ContentType({typeId:u});case 6:i[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(i),t.abrupt("return",i);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,i,a,s,u,c;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.filterOptions,i=void 0===r?{}:r,h(n),this.Log("Retrieving content objects from ".concat(n)),a=f("qlibs",n,"q"),s={filter:[]},i.cacheId&&(s.cache_id=i.cacheId),i.start&&(s.start=i.start),i.limit&&(s.limit=i.limit),i.select&&(s.select=i.select),i.sort&&(s.sort_by=i.sort,i.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))},i.filter&&(Array.isArray(i.filter)?i.filter.forEach((function(t){return c(t)})):c(i.filter)),this.Log("Filter options:"),this.Log(i),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=a,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,i,a,s;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.writeToken,m({libraryId:n,objectId:r,versionHash:i}),this.Log("Retrieving content object: ".concat(n||""," ").concat(a||i||r)),i&&(r=this.utils.DecodeVersionHash(i).objectId),s=f("q",a||i||r),t.t0=this.utils,t.t1=this.HttpClient,t.next=9,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,versionHash:i});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,y(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)?A(r):y(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,i=this;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.objectId,(r=e.versionHash)?A(r):y(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=i.utils,t.next=5,i.CallContractMethod({contractAddress:i.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,a,u,l,p,d,h,y,A=this;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,a=e.versionHash,u=e.path,l=void 0===u?"/":u,p=e.metadata,d=e.authorizationToken,h=e.noAuth,p&&"object"===i(p)){t.next=3;break}return t.abrupt("return",p);case 3:if(!Array.isArray(p)){t.next=7;break}return t.next=6,this.utils.LimitedMap(5,p,function(){var t=s(o.mark((function t(e,i){return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,A.ProduceMetadataLinks({libraryId:n,objectId:r,versionHash:a,path:f(l,i.toString()),metadata:e,authorizationToken:d,noAuth:h});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(!p["/"]||!p["/"].match(/\.\/(rep|files)\/.+/)&&!p["/"].match(/^\/?qfab\/([\w]+)\/?(rep|files)\/.+/)){t.next=16;break}return t.t0=c,t.t1=c({},p),t.t2={},t.next=13,this.LinkUrl({libraryId:n,objectId:r,versionHash:a,linkPath:l,authorizationToken:d,noAuth:h});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 y={},t.next=19,this.utils.LimitedMap(5,Object.keys(p),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,A.ProduceMetadataLinks({libraryId:n,objectId:r,versionHash:a,path:f(l,e),metadata:p[e],authorizationToken:d,noAuth:h});case 2:y[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",y);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,i,a,s,u,c,f,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,i=e.versionHash,a=e.path,s=void 0===a?"/":a,u=e.channelAuth,c=void 0!==u&&u,f=e.noAuth,l=void 0!==f&&f,m({libraryId:n,objectId:r,versionHash:i}),i&&(r=this.utils.DecodeVersionHash(i).objectId),l=this.noAuth||l||this.staticToken,p=l,l){t.next=14;break}return t.next=8,this.Visibility({id:r});case 8:return h=t.sent,t.next=11,this.AccessType({id:r});case 11:d=t.sent,p=(s||"").replace(/^\/+/,"").startsWith("public"),l=h>=10||p&&h>=1;case 14:if(!this.oauthToken){t.next=22;break}return t.next=17,this.authClient.KMSAddress({objectId:r,versionHash:i});case 17:if(!(y=t.sent)||this.utils.EqualAddress(y,this.utils.nullAddress)){t.next=22;break}return t.next=21,this.authClient.AuthorizationToken({libraryId:n,objectId:r,versionHash:i,channelAuth:!0,oauthToken:this.oauthToken});case 21:return t.abrupt("return",t.sent);case 22:if(this.inaccessibleLibraries[n]||!p||d!==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:i});case 29:t.t1=t.sent;case 30:return t.t2=t.t1,t.t3=l,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:i,noAuth:l,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:i,noAuth:l,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,i,a,s,u,p,d,h,y,A,b,g,w,I,E,_,C,k,B,x,S,Q,M,R,O,j,T,P,D,N,L=arguments;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.writeToken,s=e.metadataSubtree,u=void 0===s?"/":s,p=e.localizationSubtree,d=e.queryParams,h=void 0===d?{}:d,y=e.select,A=void 0===y?[]:y,b=e.remove,g=void 0===b?[]:b,w=e.authorizationToken,I=e.noAuth,E=void 0!==I&&I,_=e.resolveLinks,C=void 0!==_&&_,k=e.resolveIncludeSource,B=void 0!==k&&k,x=e.resolveIgnoreErrors,S=void 0!==x&&x,Q=e.linkDepthLimit,M=void 0===Q?1:Q,R=e.produceLinkUrls,O=void 0!==R&&R,m({libraryId:n,objectId:r,versionHash:i}),this.Log("Retrieving content object metadata: ".concat(n||""," ").concat(r||i," ").concat(a||"","\n Subtree: ").concat(u)),h=c({},h||{}),i&&(r=this.utils.DecodeVersionHash(i).objectId),j=f("q",a||i||r,"meta",u),i){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:j=f("qlibs",n,j);case 12:return t.next=14,this.MetadataAuth({libraryId:n,objectId:r,versionHash:i,path:u,noAuth:E});case 14:return T=t.sent,P=[w,h.authorization,T].flat().filter((function(t){return t})),delete h.authorization,t.prev=17,t.next=20,this.utils.ResponseToJson(this.HttpClient.Request({headers:{Authorization:P.map((function(t){return"Bearer ".concat(t)}))},queryParams:c(c({},h),{},{select:A,remove:g,link_depth:M,resolve:C,resolve_include_source:B,resolve_ignore_errors:S}),method:"GET",path:j}));case 20:D=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(!l.get(t.t0.body,"errors[0].cause.cause.cause.qwtoken")){t.next=32;break}throw t.t0;case 32:D="/"===u?{}:void 0;case 33:if(!O){t.next=37;break}return t.next=36,this.ProduceMetadataLinks({libraryId:n,objectId:r,versionHash:i,path:u,metadata:D,authorizationToken:w,noAuth:E});case 36:D=t.sent;case 37:if(p){t.next=39;break}return t.abrupt("return",D);case 39:return t.prev=39,t.next=42,this.ContentObjectMetadata(c(c({},L[0]),{},{metadataSubtree:p,localizationSubtree:void 0}));case 42:return N=t.sent,t.abrupt("return",v({},D,N,(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",D);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,i,a,s,u,l,p,d,h,y=this;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,i=e.objectId,a=e.versionHash,s=e.metadata,u=e.localization,l=e.noAuth,p=e.produceLinkUrls,d=void 0!==p&&p,m({libraryId:n,objectId:i,versionHash:a}),i||(i=this.utils.DecodeVersionHash(a).objectId),s){t.next=12;break}return t.next=6,this.ContentObjectMetadata({libraryId:n,objectId:i,versionHash:a,metadataSubtree:"public/asset_metadata",resolveLinks:!0,linkDepthLimit:2,resolveIgnoreErrors:!0,produceLinkUrls:d,noAuth:l});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(!d){t.next=16;break}return t.next=15,this.ProduceMetadataLinks({libraryId:n,objectId:i,versionHash:a,path:f("public","asset_metadata"),metadata:s,noAuth:l});case 15:s=t.sent;case 16:return s.info||(s.info={}),h=c({},s),u&&u.reverse().forEach((function(t){var e,n=(e=y.utils).SafeTraverse.apply(e,[s].concat(r(t)))||{};h=v({},h,n,(function(t,e){return null===e||""===e?t:void 0}))})),t.abrupt("return",h);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,i;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)),i=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=i,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,i,a;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),y(n),t.prev=3,t.next=6,this.CallContractMethod({contractAddress:this.utils.HashToAddress(n),methodName:"objectHash"});case 6:i=t.sent,t.next=11;break;case 9:t.prev=9,t.t0=t.catch(3);case 11:if(i){t.next=25;break}return t.prev=12,t.next=15,this.CallContractMethod({contractAddress:this.utils.HashToAddress(n),methodName:"countVersionHashes"});case 15:a=t.sent,t.next=20;break;case 18:t.prev=18,t.t1=t.catch(12);case 20:if(a&&a.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:[a-1]});case 24:i=t.sent;case 25:return t.abrupt("return",i);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,i,a,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("_"),i=parseInt(r[0]),a=parseInt(r[1]),(i>13||13===i&&a>=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,i,a,s,u,c,l,p,d,h,y,A,b,g,m,v;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.writeToken,s=e.linkPath,u=e.handler,c=e.offering,l=void 0===c?"":c,p=e.signedLink,d=void 0!==p&&p,h=e.authorizationToken,n){t.next=5;break}return t.next=4,this.ContentObjectLibraryId({objectId:r});case 4:n=t.sent;case 5:if(i){t.next=9;break}return t.next=8,this.LatestVersionHash({objectId:r});case 8:i=t.sent;case 9:if(y=f("qlibs",n,"q",a||i,"rep",u,l,"options.json"),!s){t.next=26;break}return t.next=13,this.ContentObjectMetadata({libraryId:n,objectId:r,versionHash:i,writeToken:a,metadataSubtree:s,resolveLinks:!1,resolveIgnoreErrors:!0,resolveIncludeSource:!0,authorizationToken:h});case 13:if(v=t.sent,m=!!v&&!!v["/"]&&!v["/"].endsWith("options.json"),y=f("qlibs",n,"q",a||i,"meta",s),d){t.next=25;break}return t.next=19,this.LinkTarget({libraryId:n,objectId:r,versionHash:i,writeToken:a,linkPath:s,linkInfo:v,authorizationToken:h});case 19:return g=t.sent,b=this.utils.DecodeVersionHash(g).objectId,t.next=23,this.ContentObjectLibraryId({objectId:b});case 23:A=t.sent,m||l||(y=f("q",g,"rep",u,"options.json"));case 25:m&&(y=f(y,l,"options.json"));case 26:return t.abrupt("return",{path:y,multiOfferingLink:m,linkTarget:{libraryId:A,objectId:b,versionHash:g}});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,i,a,s,u,c,f,l,p,d,h;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.objectId,r=e.versionHash,i=e.writeToken,a=e.linkPath,s=e.signedLink,u=e.directLink,c=e.handler,f=void 0===c?"playout":c,l=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=a,t.t5=l,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:i,linkPath:a,signedLink:s,handler:f,authorizationToken:l});case 17:return p=t.sent,d=p.path,t.prev=19,t.t7=l,t.next=23,this.authClient.AuthorizationToken({objectId:n,channelAuth:!0,oauthToken:this.oauthToken});case 23:return t.t8=t.sent,h=[t.t7,t.t8].flat().filter((function(t){return t})),t.next=27,this.utils.ResponseToJson(this.HttpClient.Request({path:d,method:"GET",headers:{Authorization:"Bearer ".concat(h.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,i,u,l,p,d,h,b,g,m,v,w,I,E,_,C,k,B,x,S,Q,M,R,O,j,T,P,D,N,L,F,U,H,G,q,K,Y,z,J,W,V,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,i=e.versionHash,u=e.writeToken,l=e.linkPath,p=e.signedLink,d=void 0!==p&&p,h=e.protocols,b=void 0===h?["dash","hls"]:h,g=e.handler,m=void 0===g?"playout":g,v=e.offering,w=void 0===v?"default":v,I=e.playoutType,E=e.drms,_=void 0===E?[]:E,C=e.context,k=e.hlsjsProfile,B=void 0===k||k,x=e.authorizationToken,S=e.options,Q=void 0===S?{}:S,!n){t.next=8;break}if(M=n.match(/(hq__[^/]+)\/rep\/([^/]+)\/([^/]+)\/options.json/),i=M[1],m=M[2],w=M[3],i&&m&&w){t.next=8;break}throw Error("Invalid offering URI: ".concat(n));case 8:if(i?A(i):y(r),b=b.map((function(t){return t.toLowerCase()})),_=_.map((function(t){return t.toLowerCase()})),r){t.next=15;break}r=this.utils.DecodeVersionHash(i).objectId,t.next=19;break;case 15:if(i){t.next=19;break}return t.next=18,this.LatestVersionHash({objectId:r});case 18:i=t.sent;case 19:return t.next=21,this.ContentObjectLibraryId({objectId:r});case 21:if(R=t.sent,t.prev=22,l){t.next=29;break}return O=f("public","asset_metadata","sources",w),t.next=27,this.ContentObjectMetadata({libraryId:R,objectId:r,versionHash:i,metadataSubtree:O,authorizationToken:x});case 27:t.sent&&(l=O);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:R,objectId:r,versionHash:i,writeToken:u,linkPath:l,signedLink:d,handler:m,offering:w,authorizationToken:x});case 35:if(j=t.sent,T=j.path,P=j.linkTarget,t.t1=this.authClient,t.t2=P.objectId||r,t.t3=P.versionHash||i,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=b,t.t6=_,t.t7=C,t.t8={objectId:t.t2,versionHash:t.t4,protocols:t.t5,drms:t.t6,context:t.t7},D=t.t1.AudienceData.call(t.t1,t.t8),t.t9=x,t.next=54,this.authClient.AuthorizationToken({libraryId:R,objectId:r,channelAuth:!0,oauthToken:this.oauthToken,audienceData:D});case 54:return t.t10=t.sent,N=[t.t9,t.t10].flat().filter((function(t){return t})),L=c({authorization:N,resolve:!!l},Q),t.t11=Object,t.next=60,this.utils.ResponseToJson(this.HttpClient.Request({path:T,method:"GET",queryParams:L}));case 60:if(t.t12=t.sent,F=t.t11.values.call(t.t11,t.t12),d||!P.versionHash){t.next=68;break}return t.t13=x,t.next=66,this.authClient.AuthorizationToken({libraryId:P.libraryId,objectId:P.objectId,channelAuth:!0,oauthToken:this.oauthToken,audienceData:D});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(K=F[q],Y=K.properties.protocol,z=K.properties.drm,H=H||K.sid,G=G||!!K.properties.multiview,H&&(L.sid=H),J=K.uri.split("?")[0],I&&(J=J.replace("playlist","playlist-".concat(I))),W=K.properties.license_servers,V=K.properties.cert,B&&"hls"===Y&&"aes-128"===z&&(L.player_profile="hls-js"),t.t15=c,t.t16=c({},U[Y]||{}),t.t17={},t.t18=c,t.t19=c({},(U[Y]||{}).playoutMethods||{}),t.t20={},t.t21=a,t.t22={},t.t23=z||"clear",!d){t.next=97;break}return t.next=94,this.LinkUrl({versionHash:i,linkPath:f(l,w,J),queryParams:L,noAuth:!0});case 94:t.t24=t.sent,t.next=100;break;case 97:return t.next=99,this.Rep({libraryId:P.libraryId||R,objectId:P.objectId||r,versionHash:P.versionHash||i,rep:f(m,w,J),noAuth:!0,queryParams:L});case 99:t.t24=t.sent;case 100:for(Z in t.t25=t.t24,t.t26=z?a({},z,{licenseServers:W,cert:V}):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[Y]=(0,t.t15)(t.t16,t.t17,t.t30),U[Y].playoutMethods)U[Y].playoutMethods[Z].drms&&U[Y].playoutMethods[Z].drms[z]&&U[Y].playoutMethods[Z].drms[z].cert&&((X=new URL(U[Y].playoutMethods[Z].playoutUrl)).pathname=X.pathname.split("/").slice(0,-1).concat(["drm.cert"]).join("/"),U[Y].playoutMethods[Z].drms[z].cert_url=X.toString());if($=b.includes(Y),tt=_.includes(z||"clear")||0===_.length&&!z,$&&tt){t.next=112;break}return t.abrupt("continue",113);case 112:(!U[Y].playoutUrl||z&&"clear"!==z)&&(U[Y].playoutUrl=U[Y].playoutMethods[z||"clear"].playoutUrl,U[Y].drms=U[Y].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",P.versionHash||i,"rep",m,w,"views.json"),method:"GET",queryParams:{sid:H,authorization:N}});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",P.versionHash||i,"rep",m,w,"select_view"),method:"POST",queryParams:{sid:H,authorization:N},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,i,a,s,u,c,f,l,p,d,h,b,g,m,v,w,I,E,_,C,k,B,x;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.objectId,r=e.versionHash,i=e.writeToken,a=e.linkPath,s=e.signedLink,u=void 0!==s&&s,c=e.protocols,f=void 0===c?["dash","hls"]:c,l=e.drms,p=void 0===l?[]:l,d=e.handler,h=void 0===d?"playout":d,b=e.offering,g=void 0===b?"default":b,m=e.playoutType,v=e.context,w=e.authorizationToken,I=e.options,E=void 0===I?{}:I,r?A(r):y(n),n||(n=this.utils.DecodeVersionHash(r).objectId),t.next=5,this.PlayoutOptions({objectId:n,versionHash:r,writeToken:i,linkPath:a,signedLink:u,protocols:f,drms:p,handler:h,offering:g,playoutType:m,hlsjsProfile:!1,context:v,authorizationToken:w,options:E});case 5:return delete(_=t.sent).playoutMethods,t.next=9,this.PlayoutPathResolution({objectId:n,versionHash:r,writeToken:i,linkPath:a,signedLink:u,handler:h,offering:g,authorizationToken:w});case 9:if(C=t.sent,k=C.linkTarget,B=[],w&&B.push(w),!u&&k.versionHash){t.next=21;break}return t.t0=B,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=B,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(_).forEach((function(t){var 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 i=r.sort((function(){return.5-Math.random()}))[0];x.drm[t]||(x.drm[t]={LA_URL:i,headers:{Authorization:"Bearer ".concat(B.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,i,a,s,u,c,l,p,d,h,y,A,b,g,v;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.writeToken,s=e.method,u=e.queryParams,c=void 0===u?{}:u,l=e.body,p=void 0===l?{}:l,d=e.headers,h=void 0===d?{}:d,y=e.constant,A=void 0===y||y,b=e.format,g=void 0===b?"json":b,m({libraryId:n,objectId:r,versionHash:i}),s){t.next=4;break}throw"Bitcode method not specified";case 4:if(i&&(r=this.utils.DecodeVersionHash(i).objectId),v=f("q",a||i||r,"call",s),n&&(v=f("qlibs",n,v)),h.authorization||h.Authorization){t.next=12;break}return t.next=11,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,update:!A});case 11:h.Authorization=t.sent.Authorization;case 12:return this.Log("Calling bitcode method: ".concat(n||""," ").concat(r||i," ").concat(a||"","\n ").concat(A?"GET":"POST"," ").concat(v,"\n Query Params:\n ").concat(JSON.stringify(c||""),"\n Body:\n ").concat(JSON.stringify(p||""),"\n Headers\n ").concat(JSON.stringify(h||""))),t.t0=this.utils,t.t1=g,t.next=17,this.HttpClient.Request({body:p,headers:h,method:A?"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,i,a,s,u,c,f,l,p,d,h,y,A,b,g;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.rep,s=e.queryParams,u=void 0===s?{}:s,c=e.service,f=void 0===c?"fabric":c,l=e.makeAccessRequest,p=void 0!==l&&l,d=e.channelAuth,h=void 0!==d&&d,y=e.noAuth,A=void 0!==y&&y,b=e.noCache,g=void 0!==b&&b,m({libraryId:n,objectId:r,versionHash:i}),a){t.next=4;break}throw"Rep not specified";case 4:return t.abrupt("return",this.FabricUrl({libraryId:n,objectId:r,versionHash:i,rep:a,queryParams:u,service:f,makeAccessRequest:p,channelAuth:h,noAuth:A,noCache:g}));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,i,a,s,u,c,f;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,i=e.versionHash,a=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:i}),a){t.next=4;break}throw"Rep not specified";case 4:return t.abrupt("return",this.FabricUrl({libraryId:n,objectId:r,versionHash:i,publicRep:a,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,i,a,s,u,l,p,d,h,y,A,b,g,v,w,I,E,_,C,k,B,x;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.writeToken,s=e.partHash,u=e.rep,l=e.publicRep,p=e.call,d=e.queryParams,h=void 0===d?{}:d,y=e.service,A=void 0===y?"fabric":y,b=e.channelAuth,g=void 0!==b&&b,v=e.makeAccessRequest,w=void 0!==v&&v,I=e.noAuth,E=void 0!==I&&I,_=e.noCache,C=void 0!==_&&_,(r||i)&&m({libraryId:n,objectId:r,versionHash:i}),i&&(r=this.utils.DecodeVersionHash(i).objectId),this.Log("Building Fabric URL:\n libraryId: ".concat(n,"\n objectId: ").concat(r,"\n versionHash: ").concat(i,"\n writeToken: ").concat(a,"\n partHash: ").concat(s,"\n rep: ").concat(u,"\n publicRep: ").concat(l,"\n call: ").concat(p,"\n channelAuth: ").concat(g,"\n noAuth: ").concat(E,"\n noCache: ").concat(C,"\n queryParams: ").concat(JSON.stringify(h||{},null,2))),k=[],h.authorization&&k.push(h.authorization),E&&h.authorization){t.next=12;break}return t.t0=k,t.next=10,this.authClient.AuthorizationToken({libraryId:n,objectId:r,versionHash:i,channelAuth:g,makeAccessRequest:w,noAuth:E,noCache:C});case 10:t.t1=t.sent,t.t0.push.call(t.t0,t.t1);case 12:if(h=c(c({},h),{},{authorization:k.flat()}),!u&&!l||!r||i){t.next=17;break}return t.next=16,this.LatestVersionHash({objectId:r});case 16:i=t.sent;case 17:return B="",n?(B=f(B,"qlibs",n),(r||i)&&(B=f(B,"q",a||i||r))):i&&(B=f("q",i)),s?B=f(B,"data",s):u?B=f(B,"rep",u):l?B=f(B,"public",l):p&&(B=f(B,"call",p)),x=this.HttpClient,"search"===A?x=this.SearchHttpClient:"auth"===A&&(x=this.AuthHttpClient),t.abrupt("return",x.URL({path:B,queryParams:h}));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,i,a,s,u,l,p,d,h,y,A;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.writeToken,s=e.filePath,u=e.queryParams,l=void 0===u?{}:u,p=e.noCache,d=void 0!==p&&p,m({libraryId:n,objectId:r,versionHash:i}),s){t.next=4;break}throw"File path not specified";case 4:return i&&(r=this.utils.DecodeVersionHash(i).objectId),h=n?f("qlibs",n,"q",a||i||r):f("q",i),t.next=8,this.authClient.AuthorizationToken({libraryId:n,objectId:r,noCache:d});case 8:return y=t.sent,l=c(c({},l),{},{authorization:y}),t.next=12,this.ContentObjectMetadata({libraryId:n,objectId:r,versionHash:i,writeToken:a,metadataSubtree:f("files",s)});case 12:return A=t.sent,A&&A["."].encryption&&"cgck"===A["."].encryption.scheme?(h=f(h,"rep","files_download",s),l["header-x_decryption_mode"]="decrypt"):h=f(h,"files",s),t.abrupt("return",this.HttpClient.URL({path:h,queryParams:l}));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,i,a,s,u,c;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.height,s=e.imagePath,u=void 0===s?"public/display_image":s,m({libraryId:n,objectId:r,versionHash:i}),i){t.next=6;break}return t.next=5,this.LatestVersionHash({objectId:r});case 5:i=t.sent;case 6:if(this.Log("Retrieving content object image url: ".concat(n," ").concat(r," ").concat(i)),this.objectImageUrls[i]){t.next=26;break}return t.prev=8,t.next=11,this.ContentObjectMetadata({versionHash:i,metadataSubtree:u});case 11:if(t.sent){t.next=15;break}return this.Log("No image url set: ".concat(n," ").concat(r," ").concat(i)),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(i),!0),this.Log(t.t0,!0);case 21:return c={},a&&!isNaN(parseInt(a))&&(c.height=parseInt(a)),t.next=25,this.LinkUrl({versionHash:i,linkPath:u,queryParams:c});case 25:this.objectImageUrls[i]=t.sent;case 26:return t.abrupt("return",this.objectImageUrls[i]);case 27:case"end":return t.stop()}}),t,this,[[8,17]])})));return function(e){return t.apply(this,arguments)}}();var w={video:"v",live_video:"lv",audio:"a",image:"i",html:"h",ebook:"b",gallery:"g",link:"l"};e.EmbedUrl=function(){var e=s(o.mark((function e(n){var r,i,a,s,u,c,f,l,p,d,h,b,g,m,v,I,E,_;return o.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=n.objectId,i=n.versionHash,a=n.duration,s=void 0===a?864e5:a,u=n.mediaType,c=void 0===u?"video":u,f=n.options,l=void 0===f?{}:f,i?A(i):r&&y(r),l.controls=void 0===l.controls?"autoHide":l.controls,p={autoHide:"h",browserDefault:"d",show:"s",hideWithVolume:"hv"},d=new URL("https://embed.v3.contentfabric.io"),e.next=7,this.NetworkInfo();case 7:return h=e.sent,b="demov3"===h.name?"demo":"test"===h.name&&955205===h.id?"testv4":h.name,e.next=11,this.Permission({objectId:r||this.utils.DecodeVersionHash(i).objectId});case 11:g=e.sent,d.searchParams.set("p",""),d.searchParams.set("net",b),i?d.searchParams.set("vid",i):r&&d.searchParams.set("oid",r),d.searchParams.set("mt",w[c.toLowerCase()]||"v"),m={},v=0,I=Object.keys(l);case 18:if(!(v<I.length)){e.next=68;break}E=I[v],e.t0=E,e.next="accountWatermark"===e.t0?23:"autoplay"===e.t0?25:"capLevelToPlayerSize"===e.t0?27:"clipEnd"===e.t0?29:"clipStart"===e.t0?31:"controls"===e.t0?33:"description"===e.t0?35:"directLink"===e.t0?37:"linkPath"===e.t0?39:"loop"===e.t0?41:"muted"===e.t0?43:"offerings"===e.t0?45:"posterUrl"===e.t0?47:"protocols"===e.t0?49:"showShare"===e.t0?51:"showTitle"===e.t0?53:"title"===e.t0?55:"viewRecordKey"===e.t0?57:"useTicketCodes"===e.t0?59:65;break;case 23:return d.searchParams.set("awm",""),e.abrupt("break",65);case 25:return d.searchParams.set("ap",""),e.abrupt("break",65);case 27:return d.searchParams.set("cap",""),e.abrupt("break",65);case 29:return d.searchParams.set("end",l.clipEnd),e.abrupt("break",65);case 31:return d.searchParams.set("start",l.clipStart),e.abrupt("break",65);case 33:return"hide"!==l.controls&&d.searchParams.set("ct",p[l.controls]),e.abrupt("break",65);case 35:return m["og:description"]=l.description,e.abrupt("break",65);case 37:return d.searchParams.set("dr",""),e.abrupt("break",65);case 39:return d.searchParams.set("ln",this.utils.B64(l.linkPath)),e.abrupt("break",65);case 41:return d.searchParams.set("lp",""),e.abrupt("break",65);case 43:return d.searchParams.set("m",""),e.abrupt("break",65);case 45:return d.searchParams.set("off",l.offerings.join(",")),e.abrupt("break",65);case 47:return d.searchParams.set("pst",l.posterUrl),e.abrupt("break",65);case 49:return d.searchParams.set("ptc",l.protocols.join(",")),e.abrupt("break",65);case 51:return d.searchParams.set("sh",""),e.abrupt("break",65);case 53:return d.searchParams.set("st",""),e.abrupt("break",65);case 55:return m["og:title"]=l.title,e.abrupt("break",65);case 57:return d.searchParams.set("vrk",l.viewRecordKey),e.abrupt("break",65);case 59:return d.searchParams.set("ptk",""),l.tenantId&&d.searchParams.set("ten",l.tenantId),l.ntpId&&d.searchParams.set("ntp",l.ntpId),l.ticketCode&&d.searchParams.set("tk",t.from(l.ticketCode).toString("base64")),l.ticketSubject&&d.searchParams.set("sbj",t.from(l.ticketSubject).toString("base64")),e.abrupt("break",65);case 65:v++,e.next=18;break;case 68:if(Object.keys(m).length>0&&d.searchParams.set("data",this.utils.B64(JSON.stringify({meta_tags:m}))),!["owner","editable","viewable"].includes(g)){e.next=74;break}return e.next=72,this.CreateSignedToken({objectId:r,versionHash:i,duration:s});case 72:_=e.sent,d.searchParams.set("ath",_);case 74:return e.abrupt("return",d.toString());case 75:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),e.ContentObjectGraph=function(){var t=s(o.mark((function t(e){var n,r,i,a,u,c,l,p,d,h,y=this;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.autoUpdate,u=void 0!==a&&a,c=e.select,m({libraryId:n,objectId:r,versionHash:i}),this.Log("Retrieving content object graph: ".concat(n||""," ").concat(r||i)),i&&(r=this.utils.DecodeVersionHash(i).objectId),l=f("q",i||r,"links"),t.prev=5,t.t0=this.utils,t.t1=this.HttpClient,t.next=10,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,versionHash:i});case 10:return t.t2=t.sent,t.t3={auto_update:u,select:c},t.t4=l,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,(d=t.t7.body.errors[0].cause.cause.cause.cycle)&&0!==d.length){t.next=26;break}throw t.t7;case 26:return h={},t.next=29,Promise.all(d.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(!h[e]){t.next=2;break}return t.abrupt("return");case 2:return n=y.utils.DecodeVersionHash(e).objectId,t.next=5,y.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,y.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,y.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,h[e]={name:r,objectId:n};case 20:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()));case 29:p=d.map((function(t){return"".concat(h[t].name," (").concat(h[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(p.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,a,s,u,c,f,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,s=e.writeToken,u=e.linkPath,c=e.authorizationToken,f=e.linkInfo,m({libraryId:n,objectId:r,versionHash:a}),s&&g(s),a&&(r=this.utils.DecodeVersionHash(a).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:a,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((l=((f["/"]||"").match(/^\/?qfab\/([\w]+)\/?.+/)||[])[1])||(l=f["."].container),!l){t.next=19;break}return t.abrupt("return",l);case 19:if(!a){t.next=21;break}return t.abrupt("return",a);case 21:if(t.t0=a,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:a,writeToken:s,metadataSubtree:u,resolveIncludeSource:!0,authorizationToken:c});case 29:if((f=t.sent)&&f["."]){t.next=49;break}if("object"!==i(f)){t.next=38;break}if(t.t1=a,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(p=u.split("/").slice(0,-1).join("/")){t.next=46;break}if(t.t2=a,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:a,writeToken:s,metadataSubtree:p,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,i,a,s,u,l,p,d,h,y,A,b,v,w;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.writeToken,s=e.linkPath,u=e.mimeType,l=e.authorizationToken,p=e.queryParams,d=void 0===p?{}:p,h=e.channelAuth,y=void 0!==h&&h,A=e.noAuth,b=void 0!==A&&A,m({libraryId:n,objectId:r,versionHash:i}),a&&g(a),s){t.next=5;break}throw Error("Link path not specified");case 5:return i&&(r=this.utils.DecodeVersionHash(i).objectId),v=n?f("qlibs",n,"q",a||i||r,"meta",s):f("q",i,"meta",s),w=[l],t.t0=w,t.next=11,this.MetadataAuth({libraryId:n,objectId:r,versionHash:i,path:s,channelAuth:y,noAuth:b});case 11:return t.t1=t.sent,t.t0.push.call(t.t0,t.t1),d.authorization&&w.push(d.authorization),d=c(c({},d),{},{authorization:w.flat().filter((function(t){return t})),resolve:!0}),u&&(d["header-accept"]=u),t.abrupt("return",this.HttpClient.URL({path:v,queryParams:d}));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,i,a,s,u,c,f,l,d,h;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.writeToken,s=e.linkPath,u=e.queryParams,c=void 0===u?{}:u,f=e.format,l=void 0===f?"json":f,d=e.channelAuth,t.next=3,this.LinkUrl({libraryId:n,objectId:r,versionHash:i,writeToken:a,linkPath:s,queryParams:c,channelAuth:d});case 3:return h=t.sent,t.t0=this.utils,t.t1=l,t.next=8,p.Fetch(h);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,i,a,s,u,c,f,l,p,d;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,i=e.versionHash,a=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:i}),g(a),r||(r=client.DecodeVersionHash(i).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:a,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=a,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 l=t.sent,t.next=41,this.authClient.KMSInfo({objectId:r});case 41:return p=t.sent.publicKey,d="eluv.caps.ikms".concat(this.utils.AddressToHash(l)),t.next=45,this.ContentObjectMetadata({libraryId:n,objectId:r,writeToken:a,metadataSubtree:d});case 45:if(t.sent){t.next=58;break}return t.t7=this,t.t8=n,t.t9=r,t.t10=a,t.t11=d,t.next=54,this.Crypto.EncryptConk(this.encryptionConks[r],p);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,i,a,s,u,c,f,l,p,d;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.writeToken,s=e.download,u=void 0!==s&&s,m({libraryId:n,objectId:r,versionHash:i}),a&&g(a),r||(r=client.DecodeVersionHash(i).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:i,metadataSubtree:f});case 10:if(l=t.sent,this.utils.EqualAddress(c,this.signer.address)||l){t.next=21;break}if(!u){t.next=18;break}return t.next=15,this.authClient.ReEncryptionConk({libraryId:n,objectId:r,versionHash:i});case 15:return t.abrupt("return",t.sent);case 18:return t.next=20,this.authClient.EncryptionConk({libraryId:n,objectId:r,versionHash:i});case 20:return t.abrupt("return",t.sent);case 21:if(this.encryptionConks[r]){t.next=38;break}return p="eluv.caps.iusr".concat(this.utils.AddressToHash(this.signer.address)),t.next=25,this.ContentObjectMetadata({libraryId:n,objectId:r,versionHash:i,writeToken:a,metadataSubtree:p});case 25:if(!(d=t.sent)){t.next=32;break}return t.next=29,this.Crypto.DecryptCap(d,this.signer._signingKey().privateKey);case 29:this.encryptionConks[r]=t.sent,t.next=38;break;case 32:if(!a){t.next=37;break}return t.next=35,this.CreateEncryptionConk({libraryId:n,objectId:r,versionHash:i,writeToken:a,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,i,a,s,u;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.writeToken,a=e.chunk,m({libraryId:n,objectId:r}),t.next=4,this.EncryptionConk({libraryId:n,objectId:r,writeToken:i});case 4:return s=t.sent,t.next=7,this.Crypto.Encrypt(s,a);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,i,a,s,u;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.writeToken,a=e.chunk,m({libraryId:n,objectId:r}),t.next=4,this.EncryptionConk({libraryId:n,objectId:r,writeToken:i,download:!0});case 4:return s=t.sent,t.next=7,this.Crypto.Decrypt(s,a);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,i;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.objectId,r=e.args,y(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 i=t.sent,this.Log(i),t.abrupt("return",{visibilityCode:i[0],visible:i[0]>=1,accessible:i[0]>=10,editable:i[0]>=100,hasAccess:0===i[1],accessCode:i[1],accessCharge:this.utils.WeiToEther(i[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,i,a,s,u,c,f,l;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.args,s=void 0===a?[]:a,u=e.update,c=void 0!==u&&u,f=e.noCache,l=void 0!==f&&f,m({libraryId:n,objectId:r,versionHash:i}),i&&(r=this.utils.DecodeVersionHash(i).objectId),t.next=5,this.authClient.MakeAccessRequest({libraryId:n,objectId:r,versionHash:i,args:s,update:c,skipCache:!0,noCache:l});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,i,a,s;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.objectId,r=e.versionHash,i=e.context,a=e.noCache,s=void 0!==a&&a,r?A(r):y(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:i,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,i;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.objectId,r=e.versionHash,i=e.percentComplete,r?A(r):y(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:i});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,i;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.objectId,r=e.score,i=void 0===r?100:r,y(n),!(i<0||i>100)){t.next=4;break}throw Error("Invalid AccessComplete score: "+i);case 4:return t.next=6,this.authClient.AccessComplete({id:n,score:i});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,i;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.versionHash,m({libraryId:n,objectId:r,versionHash:i}),t.next=4,ContentObjectVerification.VerifyContentObject({client:this,libraryId:n,objectId:r,versionHash:i});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,i,a,s;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.partHash,m({libraryId:n,objectId:r,versionHash:i}),b(a),i&&(r=this.utils.DecodeVersionHash(i).objectId),s=f("q",i||r,"data",a,"proofs"),t.t0=this.utils,t.t1=this.HttpClient,t.next=9,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,versionHash:i});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,i,a,s,u;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.partHash,a=e.format,s=void 0===a?"blob":a,m({libraryId:n,objectId:r,versionHash:versionHash}),b(i),u=f("qparts",i),t.t0=this.utils,t.t1=s,t.t2=this.HttpClient,t.next=9,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,partHash:i});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)}}()}).call(this,n(4).Buffer)},function(t,e,n){var r=n(84)(n(43),"Map");t.exports=r},function(t,e,n){var r=n(43).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(8))},function(t,e,n){var r=n(86),i=n(64);t.exports=function(t,e,n){(void 0!==n&&!i(t[e],n)||void 0===n&&!(e in t))&&r(t,e,n)}},function(t,e,n){var r=n(84),i=function(){try{var t=r(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();t.exports=i},function(t,e,n){var r=n(311)(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(312),i=n(57),a=Object.prototype,o=a.hasOwnProperty,s=a.propertyIsEnumerable,u=r(function(){return arguments}())?r:function(t){return i(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 i=n(43),a=n(314),o="object"==r(e)&&e&&!e.nodeType&&e,s=o&&"object"==r(t)&&t&&!t.nodeType&&t,u=s&&s.exports===o?i.Buffer:void 0,c=(u?u.isBuffer:void 0)||a;t.exports=c}).call(this,n(26)(t))},function(t,e,n){var r=n(316),i=n(317),a=n(318),o=a&&a.isTypedArray,s=o?i(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(322),i=n(324),a=n(87);t.exports=function(t){return a(t)?r(t,!0):i(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 i=n(t);return!!(e=null==e?9007199254740991:e)&&("number"==i||"symbol"!=i&&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(18),i=n(9),a=n(10);function o(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,n=new WeakMap;return(o=function(t){return t?n:e})(t)}function s(t,e){if(!e&&t&&t.__esModule)return t;if(null===t||"object"!=r(t)&&"function"!=typeof t)return{default:t};var n=o(e);if(n&&n.has(t))return n.get(t);var i={__proto__:null},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in t)if("default"!==s&&Object.prototype.hasOwnProperty.call(t,s)){var u=a?Object.getOwnPropertyDescriptor(t,s):null;u&&(u.get||u.set)?Object.defineProperty(i,s,u):i[s]=t[s]}return i.default=t,n&&n.set(t,i),i}void 0===globalThis.Buffer&&(globalThis.Buffer=n(4).Buffer);var u=n(126),c=n(335),f=n(28);if(globalThis.process||(globalThis.process=n(6)),"undefined"==typeof crypto){var l=n(113);l.getRandomValues=function(t){return l.randomBytes(t.length)},globalThis.crypto=l}var p,d,h,y,A,b={ElvCrypto:(A=a(i.mark((function t(){var e;return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(t.prev=0,b.elvCrypto){t.next=8;break}return t.next=4,Promise.resolve().then((function(){return s(n(421))}));case 4:return e=t.sent.default,t.next=7,(new e).init();case 7:b.elvCrypto=t.sent;case 8:return t.abrupt("return",b.elvCrypto);case 11:t.prev=11,t.t0=t.catch(0),console.error("Error initializing ElvCrypto:"),console.error(t.t0);case 15:case"end":return t.stop()}}),t,null,[[0,11]])}))),function(){return A.apply(this,arguments)}),EncryptedSize:function(t){var e=Math.floor(t/1e6)*b.EncryptedBlockSize(1e6);return t%1e6!=0&&(e+=b.EncryptedBlockSize(t%1e6)),e},EncryptedBlockSize:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=129,r=608,i=48,a=12*(i-1),o=12*i,s=Math.floor(t/a)*o;return t%a!=0&&(s+=o),e?s+r:s+n},EncryptConk:function(t,n){return a(i.mark((function r(){var a,o,s,u,c,l;return i.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.ElvCrypto();case 2:return a=r.sent,n=new Uint8Array(e.from(n.replace("0x",""),"hex")),t=new Uint8Array(e.from(JSON.stringify(t))),r.next=7,a.encryptECIES(t,n);case 7:return o=r.sent,s=o.data,u=o.ephemeralKey,c=o.tag,l=e.concat([e.from(u),e.from(c),e.from(s)]),r.abrupt("return",f.B64(l));case 13:case"end":return r.stop()}}),r)})))()},DecryptCap:function(t,n){return a(i.mark((function r(){var a,o,s,u,c;return i.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.ElvCrypto();case 2:return a=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=a.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()}}),r)})))()},GeneratePrimaryConk:function(t){return a(i.mark((function n(){var r,a,o,s,c,f,l;return i.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=t.spaceId,a=t.objectId,n.next=3,b.ElvCrypto();case 3:return o=n.sent,s=o.generatePrimaryKeys(),c=s.secretKey,f=s.publicKey,l=o.generateSymmetricKey().key,n.abrupt("return",{symm_key:"kpsy".concat(u.encode(e.from(l))),secret_key:"kpsk".concat(u.encode(e.from(c))),public_key:"kppk".concat(u.encode(e.from(f))),sid:r,qid:a});case 7:case"end":return n.stop()}}),n)})))()},GenerateTargetConk:function(){return a(i.mark((function t(){var n,r,a,o;return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.ElvCrypto();case 2:return n=t.sent,r=n.generateTargetKeys(),a=r.secretKey,o=r.publicKey,t.abrupt("return",{secret_key:"kpsk".concat(u.encode(e.from(a))),public_key:"ktpk".concat(u.encode(e.from(o)))});case 5:case"end":return t.stop()}}),t)})))()},CapToConk:function(t){var e=function(t){return new Uint8Array(u.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(i.mark((function e(){var n,r,a,o,s,u,c;return i.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.ElvCrypto();case 2:return n=e.sent,r=b.CapToConk(t),a=r.symmetricKey,o=r.secretKey,(s=r.publicKey).length===n.PRIMARY_PK_KEY_SIZE?(c=n.CRYPTO_TYPE_PRIMARY,u=n.newPrimaryContext(s,o,a)):(c=n.CRYPTO_TYPE_TARGET,u=n.newTargetDecryptionContext(o,a)),e.abrupt("return",{context:u,type:c});case 6:case"end":return e.stop()}}),e)})))()},Encrypt:(y=a(i.mark((function t(n,r){var a,o,s,u,c;return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.OpenEncryptionStream(n);case 2:if(a=t.sent,e.isBuffer(r)||r instanceof ArrayBuffer){t.next=9;break}return t.t0=e,t.next=7,new Response(r).arrayBuffer();case 7:t.t1=t.sent,r=t.t0.from.call(t.t0,t.t1);case 9:for(o=new Uint8Array(r),s=0;s<o.length;s+=1e6)u=Math.min(o.length,s+1e6),a.write(o.slice(s,u));return a.end(),c=[],t.next=15,new Promise((function(t,e){a.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 y.apply(this,arguments)}),OpenEncryptionStream:(h=a(i.mark((function t(e){var n,r,a,o,s;return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.ElvCrypto();case 2:return n=t.sent,t.next=5,b.EncryptionContext(e);case 5:return r=t.sent,a=r.context,o=new c.PassThrough,s=n.createCipher(a),t.abrupt("return",o.pipe(s).on("finish",(function(){a.free()})).on("error",(function(t){throw Error(t)})));case 10:case"end":return t.stop()}}),t)}))),function(t){return h.apply(this,arguments)}),Decrypt:(d=a(i.mark((function t(n,r){var a,o,s,u,c;return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.OpenDecryptionStream(n);case 2:for(a=t.sent,o=new Uint8Array(r),s=0;s<o.length;s+=1e6)u=Math.min(o.length,s+1e6),a.write(o.slice(s,u));return a.end(),c=[],t.next=9,new Promise((function(t,e){a.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 d.apply(this,arguments)}),OpenDecryptionStream:(p=a(i.mark((function t(e){var n,r,a,o,s,u;return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.ElvCrypto();case 2:return n=t.sent,t.next=5,b.EncryptionContext(e);case 5:return r=t.sent,a=r.context,o=r.type,s=new c.PassThrough,u=n.createDecipher(o,a),t.abrupt("return",s.pipe(u).on("finish",(function(){a.free()})).on("error",(function(t){throw Error(t)})));case 11:case"end":return t.stop()}}),t)}))),function(t){return p.apply(this,arguments)})};t.exports=b}).call(this,n(4).Buffer)},function(t,e,n){function r(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(!t)return;if("string"==typeof t)return i(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return i(t,e)}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,a=function(){};return{s:a,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,u=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return s=t.done,t},e:function(t){u=!0,o=t},f:function(){try{s||null==n.return||n.return()}finally{if(u)throw o}}}}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}var a=n(4).Buffer,o=n(11),s=o.ObjectDefineProperty,u=o.ObjectKeys,c=o.ReflectApply,f=n(32).promisify.custom,l=n(336),p=l.streamReturningOperators,d=l.promiseReturningOperators,h=n(14).codes.ERR_ILLEGAL_CONSTRUCTOR,y=n(147),A=n(89).pipeline,b=n(44).destroyer,g=n(37),m=n(152),v=n(33),w=t.exports=n(90).Stream;w.isDisturbed=v.isDisturbed,w.isErrored=v.isErrored,w.isReadable=v.isReadable,w.Readable=n(69);var I,E=r(u(p));try{var _=function(){var t=I.value,e=p[t];function n(){if(this instanceof n?this.constructor:void 0)throw h();for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return w.Readable.from(c(e,this,r))}s(n,"name",{__proto__:null,value:e.name}),s(n,"length",{__proto__:null,value:e.length}),s(w.Readable.prototype,t,{__proto__:null,value:n,enumerable:!1,configurable:!0,writable:!0})};for(E.s();!(I=E.n()).done;)_()}catch(t){E.e(t)}finally{E.f()}var C,k=r(u(d));try{var B=function(){var t=C.value,e=d[t];function n(){if(this instanceof n?this.constructor:void 0)throw h();for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return c(e,this,r)}s(n,"name",{__proto__:null,value:e.name}),s(n,"length",{__proto__:null,value:e.length}),s(w.Readable.prototype,t,{__proto__:null,value:n,enumerable:!1,configurable:!0,writable:!0})};for(k.s();!(C=k.n()).done;)B()}catch(t){k.e(t)}finally{k.f()}w.Writable=n(149),w.Duplex=n(34),w.Transform=n(151),w.PassThrough=n(150),w.pipeline=A;var x=n(70).addAbortSignal;w.addAbortSignal=x,w.finished=g,w.destroy=b,w.compose=y,s(w,"promises",{__proto__:null,configurable:!0,enumerable:!0,get:function(){return m}}),s(A,f,{__proto__:null,enumerable:!0,get:function(){return m.pipeline}}),s(g,f,{__proto__:null,enumerable:!0,get:function(){return m.finished}}),w.Stream=w,w._isUint8Array=function(t){return t instanceof Uint8Array},w._uint8ArrayToBuffer=function(t){return a.from(t.buffer,t.byteOffset,t.byteLength)}},function(t,e,n){"use strict";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)}function i(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */i=function(){return e};var t,e={},n=Object.prototype,a=n.hasOwnProperty,o=Object.defineProperty||function(t,e,n){t[e]=n.value},s="function"==typeof Symbol?Symbol:{},u=s.iterator||"@@iterator",c=s.asyncIterator||"@@asyncIterator",f=s.toStringTag||"@@toStringTag";function l(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,n){return t[e]=n}}function p(t,e,n,r){var i=e&&e.prototype instanceof g?e:g,a=Object.create(i.prototype),s=new M(r||[]);return o(a,"_invoke",{value:B(t,n,s)}),a}function d(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}e.wrap=p;var h="suspendedStart",y="executing",A="completed",b={};function g(){}function m(){}function v(){}var w={};l(w,u,(function(){return this}));var I=Object.getPrototypeOf,E=I&&I(I(R([])));E&&E!==n&&a.call(E,u)&&(w=E);var _=v.prototype=g.prototype=Object.create(w);function C(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function k(t,e){function n(i,o,s,u){var c=d(t[i],t,o);if("throw"!==c.type){var f=c.arg,l=f.value;return l&&"object"==r(l)&&a.call(l,"__await")?e.resolve(l.__await).then((function(t){n("next",t,s,u)}),(function(t){n("throw",t,s,u)})):e.resolve(l).then((function(t){f.value=t,s(f)}),(function(t){return n("throw",t,s,u)}))}u(c.arg)}var i;o(this,"_invoke",{value:function(t,r){function a(){return new e((function(e,i){n(t,r,e,i)}))}return i=i?i.then(a,a):a()}})}function B(e,n,r){var i=h;return function(a,o){if(i===y)throw new Error("Generator is already running");if(i===A){if("throw"===a)throw o;return{value:t,done:!0}}for(r.method=a,r.arg=o;;){var s=r.delegate;if(s){var u=x(s,r);if(u){if(u===b)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===h)throw i=A,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=y;var c=d(e,n,r);if("normal"===c.type){if(i=r.done?A:"suspendedYield",c.arg===b)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(i=A,r.method="throw",r.arg=c.arg)}}}function x(e,n){var r=n.method,i=e.iterator[r];if(i===t)return n.delegate=null,"throw"===r&&e.iterator.return&&(n.method="return",n.arg=t,x(e,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),b;var a=d(i,e.iterator,n.arg);if("throw"===a.type)return n.method="throw",n.arg=a.arg,n.delegate=null,b;var o=a.arg;return o?o.done?(n[e.resultName]=o.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,b):o:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,b)}function S(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function Q(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function M(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(S,this),this.reset(!0)}function R(e){if(e||""===e){var n=e[u];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=function n(){for(;++i<e.length;)if(a.call(e,i))return n.value=e[i],n.done=!1,n;return n.value=t,n.done=!0,n};return o.next=o}}throw new TypeError(r(e)+" is not iterable")}return m.prototype=v,o(_,"constructor",{value:v,configurable:!0}),o(v,"constructor",{value:m,configurable:!0}),m.displayName=l(v,f,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===m||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,v):(t.__proto__=v,l(t,f,"GeneratorFunction")),t.prototype=Object.create(_),t},e.awrap=function(t){return{__await:t}},C(k.prototype),l(k.prototype,c,(function(){return this})),e.AsyncIterator=k,e.async=function(t,n,r,i,a){void 0===a&&(a=Promise);var o=new k(p(t,n,r,i),a);return e.isGeneratorFunction(n)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},C(_),l(_,f,"Generator"),l(_,u,(function(){return this})),l(_,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),n=[];for(var r in e)n.push(r);return n.reverse(),function t(){for(;n.length;){var r=n.pop();if(r in e)return t.value=r,t.done=!1,t}return t.done=!0,t}},e.values=R,M.prototype={constructor:M,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(Q),!e)for(var n in this)"t"===n.charAt(0)&&a.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var n=this;function r(r,i){return s.type="throw",s.arg=e,n.next=r,i&&(n.method="next",n.arg=t),!!i}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],s=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var u=a.call(o,"catchLoc"),c=a.call(o,"finallyLoc");if(u&&c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(u){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&a.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var i=r;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=t,o.arg=e,i?(this.method="next",this.next=i.finallyLoc,b):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),b},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),Q(n),b}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var i=r.arg;Q(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:R(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),b}},e}function a(t,e,n,r,i,a,o){try{var s=t[a](o),u=s.value}catch(t){return void n(t)}s.done?e(u):Promise.resolve(u).then(r,i)}function o(t){return function(){var e=this,n=arguments;return new Promise((function(r,i){var o=t.apply(e,n);function s(t){a(o,r,i,s,u,"next",t)}function u(t){a(o,r,i,s,u,"throw",t)}s(void 0)}))}}var s=n(89).pipeline,u=n(34),c=n(44).destroyer,f=n(33),l=f.isNodeStream,p=f.isReadable,d=f.isWritable,h=f.isWebStream,y=f.isTransformStream,A=f.isWritableStream,b=f.isReadableStream,g=n(14),m=g.AbortError,v=g.codes,w=v.ERR_INVALID_ARG_VALUE,I=v.ERR_MISSING_ARGS,E=n(37);t.exports=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];if(0===e.length)throw new I("streams");if(1===e.length)return u.from(e[0]);var r,a,f,g,v,_=[].concat(e);if("function"==typeof e[0]&&(e[0]=u.from(e[0])),"function"==typeof e[e.length-1]){var C=e.length-1;e[C]=u.from(e[C])}for(var k=0;k<e.length;++k)if(l(e[k])||h(e[k])){if(k<e.length-1&&!(p(e[k])||b(e[k])||y(e[k])))throw new w("streams[".concat(k,"]"),_[k],"must be readable");if(k>0&&!(d(e[k])||A(e[k])||y(e[k])))throw new w("streams[".concat(k,"]"),_[k],"must be writable")}function B(t){var e=g;g=null,e?e(t):t?v.destroy(t):M||Q||v.destroy()}var x=e[0],S=s(e,B),Q=!!(d(x)||A(x)||y(x)),M=!!(p(S)||b(S)||y(S));if(v=new u({writableObjectMode:!(null==x||!x.writableObjectMode),readableObjectMode:!(null==S||!S.writableObjectMode),writable:Q,readable:M}),Q){if(l(x))v._write=function(t,e,n){x.write(t,e)?n():r=n},v._final=function(t){x.end(),a=t},x.on("drain",(function(){if(r){var t=r;r=null,t()}}));else if(h(x)){var R=y(x)?x.writable:x,O=R.getWriter();v._write=function(){var t=o(i().mark((function t(e,n,r){return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,O.ready;case 3:O.write(e).catch((function(){})),r(),t.next=10;break;case 7:t.prev=7,t.t0=t.catch(0),r(t.t0);case 10:case"end":return t.stop()}}),t,null,[[0,7]])})));return function(e,n,r){return t.apply(this,arguments)}}(),v._final=function(){var t=o(i().mark((function t(e){return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,O.ready;case 3:O.close().catch((function(){})),a=e,t.next=10;break;case 7:t.prev=7,t.t0=t.catch(0),e(t.t0);case 10:case"end":return t.stop()}}),t,null,[[0,7]])})));return function(e){return t.apply(this,arguments)}}()}var j=y(S)?S.readable:S;E(j,(function(){if(a){var t=a;a=null,t()}}))}if(M)if(l(S))S.on("readable",(function(){if(f){var t=f;f=null,t()}})),S.on("end",(function(){v.push(null)})),v._read=function(){for(;;){var t=S.read();if(null===t)return void(f=v._read);if(!v.push(t))return}};else if(h(S)){var T=y(S)?S.readable:S,P=T.getReader();v._read=o(i().mark((function t(){var e,n,r;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=1,t.next=4,P.read();case 4:if(e=t.sent,n=e.value,r=e.done,v.push(n)){t.next=9;break}return t.abrupt("return");case 9:if(!r){t.next=12;break}return v.push(null),t.abrupt("return");case 12:t.next=17;break;case 14:return t.prev=14,t.t0=t.catch(1),t.abrupt("return");case 17:t.next=0;break;case 19:case"end":return t.stop()}}),t,null,[[1,14]])})))}return v._destroy=function(t,e){t||null===g||(t=new m),f=null,r=null,a=null,null===g?e(t):(g=e,l(S)&&c(S,t))},v}},function(t,e,n){"use strict";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)}function i(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */i=function(){return e};var t,e={},n=Object.prototype,a=n.hasOwnProperty,o=Object.defineProperty||function(t,e,n){t[e]=n.value},s="function"==typeof Symbol?Symbol:{},u=s.iterator||"@@iterator",c=s.asyncIterator||"@@asyncIterator",f=s.toStringTag||"@@toStringTag";function l(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,n){return t[e]=n}}function p(t,e,n,r){var i=e&&e.prototype instanceof g?e:g,a=Object.create(i.prototype),s=new M(r||[]);return o(a,"_invoke",{value:B(t,n,s)}),a}function d(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}e.wrap=p;var h="suspendedStart",y="executing",A="completed",b={};function g(){}function m(){}function v(){}var w={};l(w,u,(function(){return this}));var I=Object.getPrototypeOf,E=I&&I(I(R([])));E&&E!==n&&a.call(E,u)&&(w=E);var _=v.prototype=g.prototype=Object.create(w);function C(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function k(t,e){function n(i,o,s,u){var c=d(t[i],t,o);if("throw"!==c.type){var f=c.arg,l=f.value;return l&&"object"==r(l)&&a.call(l,"__await")?e.resolve(l.__await).then((function(t){n("next",t,s,u)}),(function(t){n("throw",t,s,u)})):e.resolve(l).then((function(t){f.value=t,s(f)}),(function(t){return n("throw",t,s,u)}))}u(c.arg)}var i;o(this,"_invoke",{value:function(t,r){function a(){return new e((function(e,i){n(t,r,e,i)}))}return i=i?i.then(a,a):a()}})}function B(e,n,r){var i=h;return function(a,o){if(i===y)throw new Error("Generator is already running");if(i===A){if("throw"===a)throw o;return{value:t,done:!0}}for(r.method=a,r.arg=o;;){var s=r.delegate;if(s){var u=x(s,r);if(u){if(u===b)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===h)throw i=A,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=y;var c=d(e,n,r);if("normal"===c.type){if(i=r.done?A:"suspendedYield",c.arg===b)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(i=A,r.method="throw",r.arg=c.arg)}}}function x(e,n){var r=n.method,i=e.iterator[r];if(i===t)return n.delegate=null,"throw"===r&&e.iterator.return&&(n.method="return",n.arg=t,x(e,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),b;var a=d(i,e.iterator,n.arg);if("throw"===a.type)return n.method="throw",n.arg=a.arg,n.delegate=null,b;var o=a.arg;return o?o.done?(n[e.resultName]=o.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,b):o:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,b)}function S(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function Q(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function M(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(S,this),this.reset(!0)}function R(e){if(e||""===e){var n=e[u];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=function n(){for(;++i<e.length;)if(a.call(e,i))return n.value=e[i],n.done=!1,n;return n.value=t,n.done=!0,n};return o.next=o}}throw new TypeError(r(e)+" is not iterable")}return m.prototype=v,o(_,"constructor",{value:v,configurable:!0}),o(v,"constructor",{value:m,configurable:!0}),m.displayName=l(v,f,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===m||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,v):(t.__proto__=v,l(t,f,"GeneratorFunction")),t.prototype=Object.create(_),t},e.awrap=function(t){return{__await:t}},C(k.prototype),l(k.prototype,c,(function(){return this})),e.AsyncIterator=k,e.async=function(t,n,r,i,a){void 0===a&&(a=Promise);var o=new k(p(t,n,r,i),a);return e.isGeneratorFunction(n)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},C(_),l(_,f,"Generator"),l(_,u,(function(){return this})),l(_,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),n=[];for(var r in e)n.push(r);return n.reverse(),function t(){for(;n.length;){var r=n.pop();if(r in e)return t.value=r,t.done=!1,t}return t.done=!0,t}},e.values=R,M.prototype={constructor:M,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(Q),!e)for(var n in this)"t"===n.charAt(0)&&a.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var n=this;function r(r,i){return s.type="throw",s.arg=e,n.next=r,i&&(n.method="next",n.arg=t),!!i}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],s=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var u=a.call(o,"catchLoc"),c=a.call(o,"finallyLoc");if(u&&c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(u){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&a.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var i=r;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=t,o.arg=e,i?(this.method="next",this.next=i.finallyLoc,b):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),b},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),Q(n),b}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var i=r.arg;Q(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:R(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),b}},e}function a(t,e,n,r,i,a,o){try{var s=t[a](o),u=s.value}catch(t){return void n(t)}s.done?e(u):Promise.resolve(u).then(r,i)}function o(t){return function(){var e=this,n=arguments;return new Promise((function(r,i){var o=t.apply(e,n);function s(t){a(o,r,i,s,u,"next",t)}function u(t){a(o,r,i,s,u,"throw",t)}s(void 0)}))}}function s(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 u(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?s(Object(n),!0).forEach((function(e){c(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):s(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function c(t,e,n){return(e=function(t){var e=function(t,e){if("object"!==r(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,e||"default");if("object"!==r(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"===r(e)?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var f=n(6),l=n(11),p=l.PromisePrototypeThen,d=l.SymbolAsyncIterator,h=l.SymbolIterator,y=n(4).Buffer,A=n(14).codes,b=A.ERR_INVALID_ARG_TYPE,g=A.ERR_STREAM_NULL_VALUES;t.exports=function(t,e,n){var r,a;if("string"==typeof e||e instanceof y)return new t(u(u({objectMode:!0},n),{},{read:function(){this.push(e),this.push(null)}}));if(e&&e[d])a=!0,r=e[d]();else{if(!e||!e[h])throw new b("iterable",["Iterable"],e);a=!1,r=e[h]()}var s=new t(u({objectMode:!0,highWaterMark:1},n)),c=!1;function l(){return(l=o(i().mark((function t(e){var n,a,o,s,u,c,f;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=null!=e,a="function"==typeof r.throw,!n||!a){t.next=12;break}return t.next=5,r.throw(e);case 5:return o=t.sent,s=o.value,u=o.done,t.next=10,s;case 10:if(!u){t.next=12;break}return t.abrupt("return");case 12:if("function"!=typeof r.return){t.next=19;break}return t.next=15,r.return();case 15:return c=t.sent,f=c.value,t.next=19,f;case 19:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function A(){return(A=o(i().mark((function t(){var e,n,o;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(t.prev=0,!a){t.next=7;break}return t.next=4,r.next();case 4:t.t0=t.sent,t.next=8;break;case 7:t.t0=r.next();case 8:if(e=t.t0,n=e.value,!e.done){t.next=15;break}s.push(null),t.next=33;break;case 15:if(!n||"function"!=typeof n.then){t.next=21;break}return t.next=18,n;case 18:t.t1=t.sent,t.next=22;break;case 21:t.t1=n;case 22:if(null!==(o=t.t1)){t.next=28;break}throw c=!1,new g;case 28:if(!s.push(o)){t.next=32;break}return t.abrupt("continue",39);case 32:c=!1;case 33:t.next=38;break;case 35:t.prev=35,t.t2=t.catch(0),s.destroy(t.t2);case 38:return t.abrupt("break",41);case 39:t.next=0;break;case 41:case"end":return t.stop()}}),t,null,[[0,35]])})))).apply(this,arguments)}return s._read=function(){c||(c=!0,function(){A.apply(this,arguments)}())},s._destroy=function(t,e){p(function(t){return l.apply(this,arguments)}(t),(function(){return f.nextTick(e,t)}),(function(n){return f.nextTick(e,n||t)}))},s}},function(t,e,n){var r=n(6),i=n(11),a=i.ArrayPrototypeSlice,o=i.Error,s=i.FunctionPrototypeSymbolHasInstance,u=i.ObjectDefineProperty,c=i.ObjectDefineProperties,f=i.ObjectSetPrototypeOf,l=i.StringPrototypeToLowerCase,p=i.Symbol,d=i.SymbolHasInstance;t.exports=D,D.WritableState=T;var h=n(20).EventEmitter,y=n(90).Stream,A=n(4).Buffer,b=n(44),g=n(70).addAbortSignal,m=n(91),v=m.getHighWaterMark,w=m.getDefaultHighWaterMark,I=n(14).codes,E=I.ERR_INVALID_ARG_TYPE,_=I.ERR_METHOD_NOT_IMPLEMENTED,C=I.ERR_MULTIPLE_CALLBACK,k=I.ERR_STREAM_CANNOT_PIPE,B=I.ERR_STREAM_DESTROYED,x=I.ERR_STREAM_ALREADY_FINISHED,S=I.ERR_STREAM_NULL_VALUES,Q=I.ERR_STREAM_WRITE_AFTER_END,M=I.ERR_UNKNOWN_ENCODING,R=b.errorOrDestroy;function O(){}f(D.prototype,y.prototype),f(D,y);var j=p("kOnFinished");function T(t,e,r){"boolean"!=typeof r&&(r=e instanceof n(34)),this.objectMode=!(!t||!t.objectMode),r&&(this.objectMode=this.objectMode||!(!t||!t.writableObjectMode)),this.highWaterMark=t?v(this,t,"writableHighWaterMark",r):w(!1),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var i=!(!t||!1!==t.decodeStrings);this.decodeStrings=!i,this.defaultEncoding=t&&t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=U.bind(void 0,e),this.writecb=null,this.writelen=0,this.afterWriteTickInfo=null,P(this),this.pendingcb=0,this.constructed=!0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!t||!1!==t.emitClose,this.autoDestroy=!t||!1!==t.autoDestroy,this.errored=null,this.closed=!1,this.closeEmitted=!1,this[j]=[]}function P(t){t.buffered=[],t.bufferedIndex=0,t.allBuffers=!0,t.allNoop=!0}function D(t){var e=this,r=this instanceof n(34);if(!r&&!s(D,this))return new D(t);this._writableState=new T(t,this,r),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),"function"==typeof t.construct&&(this._construct=t.construct),t.signal&&g(t.signal,this)),y.call(this,t),b.construct(this,(function(){var t=e._writableState;t.writing||K(e,t),J(e,t)}))}function N(t,e,n,i){var a,o=t._writableState;if("function"==typeof n)i=n,n=o.defaultEncoding;else{if(n){if("buffer"!==n&&!A.isEncoding(n))throw new M(n)}else n=o.defaultEncoding;"function"!=typeof i&&(i=O)}if(null===e)throw new S;if(!o.objectMode)if("string"==typeof e)!1!==o.decodeStrings&&(e=A.from(e,n),n="buffer");else if(e instanceof A)n="buffer";else{if(!y._isUint8Array(e))throw new E("chunk",["string","Buffer","Uint8Array"],e);e=y._uint8ArrayToBuffer(e),n="buffer"}return o.ending?a=new Q:o.destroyed&&(a=new B("write")),a?(r.nextTick(i,a),R(t,a,!0),a):(o.pendingcb++,function(t,e,n,r,i){var a=e.objectMode?1:n.length;e.length+=a;var o=e.length<e.highWaterMark;o||(e.needDrain=!0);e.writing||e.corked||e.errored||!e.constructed?(e.buffered.push({chunk:n,encoding:r,callback:i}),e.allBuffers&&"buffer"!==r&&(e.allBuffers=!1),e.allNoop&&i!==O&&(e.allNoop=!1)):(e.writelen=a,e.writecb=i,e.writing=!0,e.sync=!0,t._write(n,r,e.onwrite),e.sync=!1);return o&&!e.errored&&!e.destroyed}(t,o,e,n,i))}function L(t,e,n,r,i,a,o){e.writelen=r,e.writecb=o,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new B("write")):n?t._writev(i,e.onwrite):t._write(i,a,e.onwrite),e.sync=!1}function F(t,e,n,r){--e.pendingcb,r(n),q(e),R(t,n)}function U(t,e){var n=t._writableState,i=n.sync,a=n.writecb;"function"==typeof a?(n.writing=!1,n.writecb=null,n.length-=n.writelen,n.writelen=0,e?(e.stack,n.errored||(n.errored=e),t._readableState&&!t._readableState.errored&&(t._readableState.errored=e),i?r.nextTick(F,t,n,e,a):F(t,n,e,a)):(n.buffered.length>n.bufferedIndex&&K(t,n),i?null!==n.afterWriteTickInfo&&n.afterWriteTickInfo.cb===a?n.afterWriteTickInfo.count++:(n.afterWriteTickInfo={count:1,cb:a,stream:t,state:n},r.nextTick(H,n.afterWriteTickInfo)):G(t,n,1,a))):R(t,new C)}function H(t){var e=t.stream,n=t.state,r=t.count,i=t.cb;return n.afterWriteTickInfo=null,G(e,n,r,i)}function G(t,e,n,r){for(!e.ending&&!t.destroyed&&0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"));n-- >0;)e.pendingcb--,r();e.destroyed&&q(e),J(t,e)}function q(t){if(!t.writing){for(var e=t.bufferedIndex;e<t.buffered.length;++e){var n,r=t.buffered[e],i=r.chunk,a=r.callback,o=t.objectMode?1:i.length;t.length-=o,a(null!==(n=t.errored)&&void 0!==n?n:new B("write"))}for(var s=t[j].splice(0),u=0;u<s.length;u++){var c;s[u](null!==(c=t.errored)&&void 0!==c?c:new B("end"))}P(t)}}function K(t,e){if(!(e.corked||e.bufferProcessing||e.destroyed)&&e.constructed){var n=e.buffered,r=e.bufferedIndex,i=e.objectMode,o=n.length-r;if(o){var s=r;if(e.bufferProcessing=!0,o>1&&t._writev){e.pendingcb-=o-1;var u=e.allNoop?O:function(t){for(var e=s;e<n.length;++e)n[e].callback(t)},c=e.allNoop&&0===s?n:a(n,s);c.allBuffers=e.allBuffers,L(t,e,!0,e.length,c,"",u),P(e)}else{do{var f=n[s],l=f.chunk,p=f.encoding,d=f.callback;n[s++]=null,L(t,e,!1,i?1:l.length,l,p,d)}while(s<n.length&&!e.writing);s===n.length?P(e):s>256?(n.splice(0,s),e.bufferedIndex=0):e.bufferedIndex=s}e.bufferProcessing=!1}}}function Y(t){return t.ending&&!t.destroyed&&t.constructed&&0===t.length&&!t.errored&&0===t.buffered.length&&!t.finished&&!t.writing&&!t.errorEmitted&&!t.closeEmitted}function z(t,e){e.prefinished||e.finalCalled||("function"!=typeof t._final||e.destroyed?(e.prefinished=!0,t.emit("prefinish")):(e.finalCalled=!0,function(t,e){var n=!1;function i(i){if(n)R(t,null!=i?i:C());else if(n=!0,e.pendingcb--,i){for(var a=e[j].splice(0),o=0;o<a.length;o++)a[o](i);R(t,i,e.sync)}else Y(e)&&(e.prefinished=!0,t.emit("prefinish"),e.pendingcb++,r.nextTick(W,t,e))}e.sync=!0,e.pendingcb++;try{t._final(i)}catch(t){i(t)}e.sync=!1}(t,e)))}function J(t,e,n){Y(e)&&(z(t,e),0===e.pendingcb&&(n?(e.pendingcb++,r.nextTick((function(t,e){Y(e)?W(t,e):e.pendingcb--}),t,e)):Y(e)&&(e.pendingcb++,W(t,e))))}function W(t,e){e.pendingcb--,e.finished=!0;for(var n=e[j].splice(0),r=0;r<n.length;r++)n[r]();if(t.emit("finish"),e.autoDestroy){var i=t._readableState;(!i||i.autoDestroy&&(i.endEmitted||!1===i.readable))&&t.destroy()}}T.prototype.getBuffer=function(){return a(this.buffered,this.bufferedIndex)},u(T.prototype,"bufferedRequestCount",{__proto__:null,get:function(){return this.buffered.length-this.bufferedIndex}}),u(D,d,{__proto__:null,value:function(t){return!!s(this,t)||this===D&&(t&&t._writableState instanceof T)}}),D.prototype.pipe=function(){R(this,new k)},D.prototype.write=function(t,e,n){return!0===N(this,t,e,n)},D.prototype.cork=function(){this._writableState.corked++},D.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,t.writing||K(this,t))},D.prototype.setDefaultEncoding=function(t){if("string"==typeof t&&(t=l(t)),!A.isEncoding(t))throw new M(t);return this._writableState.defaultEncoding=t,this},D.prototype._write=function(t,e,n){if(!this._writev)throw new _("_write()");this._writev([{chunk:t,encoding:e}],n)},D.prototype._writev=null,D.prototype.end=function(t,e,n){var i,a=this._writableState;if("function"==typeof t?(n=t,t=null,e=null):"function"==typeof e&&(n=e,e=null),null!=t){var s=N(this,t,e);s instanceof o&&(i=s)}return a.corked&&(a.corked=1,this.uncork()),i||(a.errored||a.ending?a.finished?i=new x("end"):a.destroyed&&(i=new B("end")):(a.ending=!0,J(this,a,!0),a.ended=!0)),"function"==typeof n&&(i||a.finished?r.nextTick(n,i):a[j].push(n)),this},c(D.prototype,{closed:{__proto__:null,get:function(){return!!this._writableState&&this._writableState.closed}},destroyed:{__proto__:null,get:function(){return!!this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}},writable:{__proto__:null,get:function(){var t=this._writableState;return!(!t||!1===t.writable||t.destroyed||t.errored||t.ending||t.ended)},set:function(t){this._writableState&&(this._writableState.writable=!!t)}},writableFinished:{__proto__:null,get:function(){return!!this._writableState&&this._writableState.finished}},writableObjectMode:{__proto__:null,get:function(){return!!this._writableState&&this._writableState.objectMode}},writableBuffer:{__proto__:null,get:function(){return this._writableState&&this._writableState.getBuffer()}},writableEnded:{__proto__:null,get:function(){return!!this._writableState&&this._writableState.ending}},writableNeedDrain:{__proto__:null,get:function(){var t=this._writableState;return!!t&&(!t.destroyed&&!t.ending&&t.needDrain)}},writableHighWaterMark:{__proto__:null,get:function(){return this._writableState&&this._writableState.highWaterMark}},writableCorked:{__proto__:null,get:function(){return this._writableState?this._writableState.corked:0}},writableLength:{__proto__:null,get:function(){return this._writableState&&this._writableState.length}},errored:{__proto__:null,enumerable:!1,get:function(){return this._writableState?this._writableState.errored:null}},writableAborted:{__proto__:null,enumerable:!1,get:function(){return!(!1===this._writableState.writable||!this._writableState.destroyed&&!this._writableState.errored||this._writableState.finished)}}});var V,Z=b.destroy;function X(){return void 0===V&&(V={}),V}D.prototype.destroy=function(t,e){var n=this._writableState;return!n.destroyed&&(n.bufferedIndex<n.buffered.length||n[j].length)&&r.nextTick(q,n),Z.call(this,t,e),this},D.prototype._undestroy=b.undestroy,D.prototype._destroy=function(t,e){e(t)},D.prototype[h.captureRejectionSymbol]=function(t){this.destroy(t)},D.fromWeb=function(t,e){return X().newStreamWritableFromWritableStream(t,e)},D.toWeb=function(t){return X().newWritableStreamFromStreamWritable(t)}},function(t,e,n){"use strict";var r=n(11).ObjectSetPrototypeOf;t.exports=a;var i=n(151);function a(t){if(!(this instanceof a))return new a(t);i.call(this,t)}r(a.prototype,i.prototype),r(a,i),a.prototype._transform=function(t,e,n){n(null,t)}},function(t,e,n){"use strict";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)}function i(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 a(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?i(Object(n),!0).forEach((function(e){o(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function o(t,e,n){return(e=function(t){var e=function(t,e){if("object"!==r(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,e||"default");if("object"!==r(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"===r(e)?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var s=n(11),u=s.ObjectSetPrototypeOf,c=s.Symbol;t.exports=h;var f=n(14).codes.ERR_METHOD_NOT_IMPLEMENTED,l=n(34),p=n(91).getHighWaterMark;u(h.prototype,l.prototype),u(h,l);var d=c("kCallback");function h(t){if(!(this instanceof h))return new h(t);var e=t?p(this,t,"readableHighWaterMark",!0):null;0===e&&(t=a(a({},t),{},{highWaterMark:null,readableHighWaterMark:e,writableHighWaterMark:t.writableHighWaterMark||0})),l.call(this,t),this._readableState.sync=!1,this[d]=null,t&&("function"==typeof t.transform&&(this._transform=t.transform),"function"==typeof t.flush&&(this._flush=t.flush)),this.on("prefinish",A)}function y(t){var e=this;"function"!=typeof this._flush||this.destroyed?(this.push(null),t&&t()):this._flush((function(n,r){n?t?t(n):e.destroy(n):(null!=r&&e.push(r),e.push(null),t&&t())}))}function A(){this._final!==y&&y.call(this)}h.prototype._final=y,h.prototype._transform=function(t,e,n){throw new f("_transform()")},h.prototype._write=function(t,e,n){var r=this,i=this._readableState,a=this._writableState,o=i.length;this._transform(t,e,(function(t,e){t?n(t):(null!=e&&r.push(e),a.ended||o===i.length||i.length<i.highWaterMark?n():r[d]=n)}))},h.prototype._read=function(){if(this[d]){var t=this[d];this[d]=null,t()}}},function(t,e,n){"use strict";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 i=n(11),a=i.ArrayPrototypePop,o=i.Promise,s=n(33),u=s.isIterable,c=s.isNodeStream,f=s.isWebStream,l=n(89).pipelineImpl,p=n(37).finished;n(146),t.exports={finished:p,pipeline:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return new o((function(t,n){var i,o,s=e[e.length-1];if(s&&"object"===r(s)&&!c(s)&&!u(s)&&!f(s)){var p=a(e);i=p.signal,o=p.end}l(e,(function(e,r){e?n(e):t(r)}),{signal:i,end:o})}))}}},function(t,e,n){"use strict";var r=n(5).Buffer,i=n(340).Transform;function a(t){i.call(this),this._block=r.allocUnsafe(t),this._blockSize=t,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}n(3)(a,i),a.prototype._transform=function(t,e,n){var r=null;try{this.update(t,e)}catch(t){r=t}n(r)},a.prototype._flush=function(t){var e=null;try{this.push(this.digest())}catch(t){e=t}t(e)},a.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,i=0;this._blockOffset+t.length-i>=this._blockSize;){for(var a=this._blockOffset;a<this._blockSize;)n[a++]=t[i++];this._update(),this._blockOffset=0}for(;i<t.length;)n[this._blockOffset++]=t[i++];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},a.prototype._update=function(){throw new Error("_update is not implemented")},a.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},a.prototype._digest=function(){throw new Error("_digest is not implemented")},t.exports=a},function(t,e,n){"use strict";(function(e,r){var i;t.exports=C,C.ReadableState=_;n(20).EventEmitter;var a=function(t,e){return t.listeners(e).length},o=n(155),s=n(4).Buffer,u=(void 0!==e?e:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){};var c,f=n(341);c=f&&f.debuglog?f.debuglog("stream"):function(){};var l,p,d,h=n(342),y=n(156),A=n(157).getHighWaterMark,b=n(46).codes,g=b.ERR_INVALID_ARG_TYPE,m=b.ERR_STREAM_PUSH_AFTER_EOF,v=b.ERR_METHOD_NOT_IMPLEMENTED,w=b.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;n(3)(C,o);var I=y.errorOrDestroy,E=["error","close","destroy","pause","resume"];function _(t,e,r){i=i||n(47),t=t||{},"boolean"!=typeof r&&(r=e instanceof i),this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=A(this,t,"readableHighWaterMark",r),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.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&&(l||(l=n(29).StringDecoder),this.decoder=new l(t.encoding),this.encoding=t.encoding)}function C(t){if(i=i||n(47),!(this instanceof C))return new C(t);var e=this instanceof i;this._readableState=new _(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,i){c("readableAddChunk",e);var a,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,Q(t)))}(t,o);else if(i||(a=function(t,e){var n;r=e,s.isBuffer(r)||r instanceof u||"string"==typeof e||void 0===e||t.objectMode||(n=new g("chunk",["string","Buffer","Uint8Array"],e));var r;return n}(o,e)),a)I(t,a);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?I(t,new w):B(t,o,e,!0);else if(o.ended)I(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?B(t,o,e,!1):M(t,o)):B(t,o,e,!1)}else r||(o.reading=!1,M(t,o));return!o.ended&&(o.length<o.highWaterMark||0===o.length)}function B(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(C.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(t){this._readableState&&(this._readableState.destroyed=t)}}),C.prototype.destroy=y.destroy,C.prototype._undestroy=y.undestroy,C.prototype._destroy=function(t,e){e(t)},C.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)},C.prototype.unshift=function(t){return k(this,t,null,!0,!1)},C.prototype.isPaused=function(){return!1===this._readableState.flowing},C.prototype.setEncoding=function(t){l||(l=n(29).StringDecoder);var e=new l(t);this._readableState.decoder=e,this._readableState.encoding=this._readableState.decoder.encoding;for(var r=this._readableState.buffer.head,i="";null!==r;)i+=e.write(r.data),r=r.next;return this._readableState.buffer.clear(),""!==i&&this._readableState.buffer.push(i),this._readableState.length=i.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(Q,t))}function Q(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,P(t)}function M(t,e){e.readingMore||(e.readingMore=!0,r.nextTick(R,t,e))}function R(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 O(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 j(t){c("readable nexttick read 0"),t.read(0)}function T(t,e){c("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),P(t),e.flowing&&!e.reading&&t.read(0)}function P(t){var e=t._readableState;for(c("flow",e.flowing);e.flowing&&null!==t.read(););}function D(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 N(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}C.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?N(this):S(this),null;if(0===(t=x(t,e))&&e.ended)return 0===e.length&&N(this),null;var r,i=e.needReadable;return c("need readable",i),(0===e.length||e.length-t<e.highWaterMark)&&c("length less than watermark",i=!0),e.ended||e.reading?c("reading or ended",i=!1):i&&(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?D(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&&N(this)),null!==r&&this.emit("data",r),r},C.prototype._read=function(t){I(this,new v("_read()"))},C.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,c("pipe count=%d opts=%j",i.pipesCount,e);var o=(!e||!1!==e.end)&&t!==r.stdout&&t!==r.stderr?u:A;function s(e,r){c("onunpipe"),e===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,c("cleanup"),t.removeListener("close",h),t.removeListener("finish",y),t.removeListener("drain",f),t.removeListener("error",d),t.removeListener("unpipe",s),n.removeListener("end",u),n.removeListener("end",A),n.removeListener("data",p),l=!0,!i.awaitDrain||t._writableState&&!t._writableState.needDrain||f())}function u(){c("onend"),t.end()}i.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&&a(t,"data")&&(e.flowing=!0,P(t))}}(n);t.on("drain",f);var l=!1;function p(e){c("ondata");var r=t.write(e);c("dest.write",r),!1===r&&((1===i.pipesCount&&i.pipes===t||i.pipesCount>1&&-1!==F(i.pipes,t))&&!l&&(c("false write response, pause",i.awaitDrain),i.awaitDrain++),n.pause())}function d(e){c("onerror",e),A(),t.removeListener("error",d),0===a(t,"error")&&I(t,e)}function h(){t.removeListener("finish",y),A()}function y(){c("onfinish"),t.removeListener("close",h),A()}function A(){c("unpipe"),n.unpipe(t)}return n.on("data",p),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",d),t.once("close",h),t.once("finish",y),t.emit("pipe",n),i.flowing||(c("pipe resume"),n.resume()),t},C.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,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var a=0;a<i;a++)r[a].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},C.prototype.on=function(t,e){var n=o.prototype.on.call(this,t,e),i=this._readableState;return"data"===t?(i.readableListening=this.listenerCount("readable")>0,!1!==i.flowing&&this.resume()):"readable"===t&&(i.endEmitted||i.readableListening||(i.readableListening=i.needReadable=!0,i.flowing=!1,i.emittedReadable=!1,c("on readable",i.length,i.reading),i.length?S(this):i.reading||r.nextTick(j,this))),n},C.prototype.addListener=C.prototype.on,C.prototype.removeListener=function(t,e){var n=o.prototype.removeListener.call(this,t,e);return"readable"===t&&r.nextTick(O,this),n},C.prototype.removeAllListeners=function(t){var e=o.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||r.nextTick(O,this),e},C.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(T,t,e))}(this,t)),t.paused=!1,this},C.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},C.prototype.wrap=function(t){var e=this,n=this._readableState,r=!1;for(var i 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(i){(c("wrapped data"),n.decoder&&(i=n.decoder.write(i)),n.objectMode&&null==i)||(n.objectMode||i&&i.length)&&(e.push(i)||(r=!0,t.pause()))})),t)void 0===this[i]&&"function"==typeof t[i]&&(this[i]=function(e){return function(){return t[e].apply(t,arguments)}}(i));for(var a=0;a<E.length;a++)t.on(E[a],this.emit.bind(this,E[a]));return this._read=function(e){c("wrapped _read",e),r&&(r=!1,t.resume())},this},"function"==typeof Symbol&&(C.prototype[Symbol.asyncIterator]=function(){return void 0===p&&(p=n(344)),p(this)}),Object.defineProperty(C.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(C.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(C.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(t){this._readableState&&(this._readableState.flowing=t)}}),C._fromList=D,Object.defineProperty(C.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),"function"==typeof Symbol&&(C.from=function(t,e){return void 0===d&&(d=n(345)),d(C,t,e)})}).call(this,n(8),n(6))},function(t,e,n){t.exports=n(20).EventEmitter},function(t,e,n){"use strict";(function(e){function n(t,e){i(t,e),r(t)}function r(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit("close")}function i(t,e){t.emit("error",e)}t.exports={destroy:function(t,a){var o=this,s=this._readableState&&this._readableState.destroyed,u=this._writableState&&this._writableState.destroyed;return s||u?(a?a(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,e.nextTick(i,this,t)):e.nextTick(i,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,(function(t){!a&&t?o._writableState?o._writableState.errorEmitted?e.nextTick(r,o):(o._writableState.errorEmitted=!0,e.nextTick(n,o,t)):e.nextTick(n,o,t):a?(e.nextTick(r,o),a(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(6))},function(t,e,n){"use strict";var r=n(46).codes.ERR_INVALID_OPT_VALUE;t.exports={getHighWaterMark:function(t,e,n,i){var a=function(t,e,n){return null!=t.highWaterMark?t.highWaterMark:e?t[n]:null}(e,i,n);if(null!=a){if(!isFinite(a)||Math.floor(a)!==a||a<0)throw new r(i?n:"highWaterMark",a);return Math.floor(a)}return t.objectMode?16:16384}}},function(t,e,n){"use strict";(function(e,r){function i(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 i=r.callback;e.pendingcb--,i(n),r=r.next}e.corkedRequestsFree.next=t}(e,t)}}var a;t.exports=C,C.WritableState=_;var o={deprecate:n(71)},s=n(155),u=n(4).Buffer,c=(void 0!==e?e:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){};var f,l=n(156),p=n(157).getHighWaterMark,d=n(46).codes,h=d.ERR_INVALID_ARG_TYPE,y=d.ERR_METHOD_NOT_IMPLEMENTED,A=d.ERR_MULTIPLE_CALLBACK,b=d.ERR_STREAM_CANNOT_PIPE,g=d.ERR_STREAM_DESTROYED,m=d.ERR_STREAM_NULL_VALUES,v=d.ERR_STREAM_WRITE_AFTER_END,w=d.ERR_UNKNOWN_ENCODING,I=l.errorOrDestroy;function E(){}function _(t,e,o){a=a||n(47),t=t||{},"boolean"!=typeof o&&(o=e instanceof a),this.objectMode=!!t.objectMode,o&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=p(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,i=n.sync,a=n.writecb;if("function"!=typeof a)throw new A;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(n),e)!function(t,e,n,i,a){--e.pendingcb,n?(r.nextTick(a,i),r.nextTick(M,t,e),t._writableState.errorEmitted=!0,I(t,i)):(a(i),t._writableState.errorEmitted=!0,I(t,i),M(t,e))}(t,n,i,e,a);else{var o=S(n)||t.destroyed;o||n.corked||n.bufferProcessing||!n.bufferedRequest||x(t,n),i?r.nextTick(B,t,n,o,a):B(t,n,o,a)}}(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 i(this)}function C(t){var e=this instanceof(a=a||n(47));if(!e&&!f.call(C,this))return new C(t);this._writableState=new _(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,i,a,o){e.writelen=r,e.writecb=o,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new g("write")):n?t._writev(i,e.onwrite):t._write(i,a,e.onwrite),e.sync=!1}function B(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,a=new Array(r),o=e.corkedRequestsFree;o.entry=n;for(var s=0,u=!0;n;)a[s]=n,n.isBuf||(u=!1),n=n.next,s+=1;a.allBuffers=u,k(t,e,!0,e.length,a,"",o.finish),e.pendingcb++,e.lastBufferedRequest=null,o.next?(e.corkedRequestsFree=o.next,o.next=null):e.corkedRequestsFree=new i(e),e.bufferedRequestCount=0}else{for(;n;){var c=n.chunk,f=n.encoding,l=n.callback;if(k(t,e,!1,e.objectMode?1:c.length,c,f,l),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 Q(t,e){t._final((function(n){e.pendingcb--,n&&I(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(Q,t,e)))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit("finish"),e.autoDestroy))){var i=t._readableState;(!i||i.autoDestroy&&i.endEmitted)&&t.destroy()}return n}n(3)(C,s),_.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(_.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(C,Symbol.hasInstance,{value:function(t){return!!f.call(this,t)||this===C&&(t&&t._writableState instanceof _)}})):f=function(t){return t instanceof this},C.prototype.pipe=function(){I(this,new b)},C.prototype.write=function(t,e,n){var i,a=this._writableState,o=!1,s=!a.objectMode&&(i=t,u.isBuffer(i)||i 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=a.defaultEncoding),"function"!=typeof n&&(n=E),a.ending?function(t,e){var n=new v;I(t,n),r.nextTick(e,n)}(this,n):(s||function(t,e,n,i){var a;return null===n?a=new m:"string"==typeof n||e.objectMode||(a=new h("chunk",["string","Buffer"],n)),!a||(I(t,a),r.nextTick(i,a),!1)}(this,a,t,n))&&(a.pendingcb++,o=function(t,e,n,r,i,a){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,i);r!==o&&(n=!0,i="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:i,isBuf:n,callback:a,next:null},f?f.next=e.lastBufferedRequest:e.bufferedRequest=e.lastBufferedRequest,e.bufferedRequestCount+=1}else k(t,e,!1,s,r,i,a);return c}(this,a,s,t,e,n)),o},C.prototype.cork=function(){this._writableState.corked++},C.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,t.writing||t.corked||t.bufferProcessing||!t.bufferedRequest||x(this,t))},C.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 w(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(C.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(C.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),C.prototype._write=function(t,e,n){n(new y("_write()"))},C.prototype._writev=null,C.prototype.end=function(t,e,n){var i=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),i.corked&&(i.corked=1,this.uncork()),i.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,i,n),this},Object.defineProperty(C.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(C.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),C.prototype.destroy=l.destroy,C.prototype._undestroy=l.undestroy,C.prototype._destroy=function(t,e){e(t)}}).call(this,n(8),n(6))},function(t,e,n){"use strict";t.exports=f;var r=n(46).codes,i=r.ERR_METHOD_NOT_IMPLEMENTED,a=r.ERR_MULTIPLE_CALLBACK,o=r.ERR_TRANSFORM_ALREADY_TRANSFORMING,s=r.ERR_TRANSFORM_WITH_LENGTH_0,u=n(47);function c(t,e){var n=this._transformState;n.transforming=!1;var r=n.writecb;if(null===r)return this.emit("error",new a);n.writechunk=null,n.writecb=null,null!=e&&this.push(e),r(t);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.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",l)}function l(){var t=this;"function"!=typeof this._flush||this._readableState.destroyed?p(this,null,null):this._flush((function(e,n){p(t,e,n)}))}function p(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 i("_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 i=this._readableState;(r.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.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),i=n(48),a=n(5).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,i.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 l(t){return(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10)}function p(t){return(t>>>6|t<<26)^(t>>>11|t<<21)^(t>>>25|t<<7)}function d(t){return(t>>>7|t<<25)^(t>>>18|t<<14)^t>>>3}r(u,i),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,i=0|this._b,a=0|this._c,s=0|this._d,u=0|this._e,h=0|this._f,y=0|this._g,A=0|this._h,b=0;b<16;++b)n[b]=t.readInt32BE(4*b);for(;b<64;++b)n[b]=0|(((e=n[b-2])>>>17|e<<15)^(e>>>19|e<<13)^e>>>10)+n[b-7]+d(n[b-15])+n[b-16];for(var g=0;g<64;++g){var m=A+p(u)+c(u,h,y)+o[g]+n[g]|0,v=l(r)+f(r,i,a)|0;A=y,y=h,h=u,u=s+m|0,s=a,a=i,i=r,r=m+v|0}this._a=r+this._a|0,this._b=i+this._b|0,this._c=a+this._c|0,this._d=s+this._d|0,this._e=u+this._e|0,this._f=h+this._f|0,this._g=y+this._g|0,this._h=A+this._h|0},u.prototype._hash=function(){var t=a.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),i=n(48),a=n(5).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,i.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 l(t,e){return(t>>>28|e<<4)^(e>>>2|t<<30)^(e>>>7|t<<25)}function p(t,e){return(t>>>14|e<<18)^(t>>>18|e<<14)^(e>>>9|t<<23)}function d(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^t>>>7}function h(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^(t>>>7|e<<25)}function y(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^t>>>6}function A(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^(t>>>6|e<<26)}function b(t,e){return t>>>0<e>>>0?1:0}r(u,i),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,i=0|this._ch,a=0|this._dh,s=0|this._eh,u=0|this._fh,g=0|this._gh,m=0|this._hh,v=0|this._al,w=0|this._bl,I=0|this._cl,E=0|this._dl,_=0|this._el,C=0|this._fl,k=0|this._gl,B=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],Q=e[x-30+1],M=d(S,Q),R=h(Q,S),O=y(S=e[x-4],Q=e[x-4+1]),j=A(Q,S),T=e[x-14],P=e[x-14+1],D=e[x-32],N=e[x-32+1],L=R+P|0,F=M+T+b(L,R)|0;F=(F=F+O+b(L=L+j|0,j)|0)+D+b(L=L+N|0,N)|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,i),G=f(v,w,I),q=l(n,v),K=l(v,n),Y=p(s,_),z=p(_,s),J=o[U],W=o[U+1],V=c(s,u,g),Z=c(_,C,k),X=B+z|0,$=m+Y+b(X,B)|0;$=($=($=$+V+b(X=X+Z|0,Z)|0)+J+b(X=X+W|0,W)|0)+F+b(X=X+L|0,L)|0;var tt=K+G|0,et=q+H+b(tt,K)|0;m=g,B=k,g=u,k=C,u=s,C=_,s=a+$+b(_=E+X|0,E)|0,a=i,E=I,i=r,I=w,r=n,w=v,n=$+et+b(v=X+tt|0,X)|0}this._al=this._al+v|0,this._bl=this._bl+w|0,this._cl=this._cl+I|0,this._dl=this._dl+E|0,this._el=this._el+_|0,this._fl=this._fl+C|0,this._gl=this._gl+k|0,this._hl=this._hl+B|0,this._ah=this._ah+n+b(this._al,v)|0,this._bh=this._bh+r+b(this._bl,w)|0,this._ch=this._ch+i+b(this._cl,I)|0,this._dh=this._dh+a+b(this._dl,E)|0,this._eh=this._eh+s+b(this._el,_)|0,this._fh=this._fh+u+b(this._fl,C)|0,this._gh=this._gh+g+b(this._gl,k)|0,this._hh=this._hh+m+b(this._hl,B)|0},u.prototype._hash=function(){var t=a.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){"use strict";(function(e,r){var i=n(72);t.exports=m;var a,o=n(353);m.ReadableState=g;n(20).EventEmitter;var s=function(t,e){return t.listeners(e).length},u=n(163),c=n(97).Buffer,f=(void 0!==e?e:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){};var l=Object.create(n(59));l.inherits=n(3);var p=n(354),d=void 0;d=p&&p.debuglog?p.debuglog("stream"):function(){};var h,y=n(355),A=n(164);l.inherits(m,u);var b=["error","close","destroy","pause","resume"];function g(t,e){t=t||{};var r=e instanceof(a=a||n(40));this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.readableObjectMode);var i=t.highWaterMark,o=t.readableHighWaterMark,s=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:r&&(o||0===o)?o:s,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new y,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&&(h||(h=n(29).StringDecoder),this.decoder=new h(t.encoding),this.encoding=t.encoding)}function m(t){if(a=a||n(40),!(this instanceof m))return new m(t);this._readableState=new g(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,i){var a,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,E(t)}(t,o)):(i||(a=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)),a?t.emit("error",a):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")):w(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?w(t,o,e,!1):C(t,o)):w(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 w(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&&E(t)),C(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=A.destroy,m.prototype._undestroy=A.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 h||(h=n(29).StringDecoder),this._readableState.decoder=new h(t),this._readableState.encoding=t,this};function I(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 E(t){var e=t._readableState;e.needReadable=!1,e.emittedReadable||(d("emitReadable",e.flowing),e.emittedReadable=!0,e.sync?i.nextTick(_,t):_(t))}function _(t){d("emit readable"),t.emit("readable"),S(t)}function C(t,e){e.readingMore||(e.readingMore=!0,i.nextTick(k,t,e))}function k(t,e){for(var n=e.length;!e.reading&&!e.flowing&&!e.ended&&e.length<e.highWaterMark&&(d("maybeReadMore read 0"),t.read(0),n!==e.length);)n=e.length;e.readingMore=!1}function B(t){d("readable nexttick read 0"),t.read(0)}function x(t,e){e.reading||(d("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(d("flow",e.flowing);e.flowing&&null!==t.read(););}function Q(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,i=n.data;t-=i.length;for(;n=n.next;){var a=n.data,o=t>a.length?a.length:t;if(o===a.length?i+=a:i+=a.slice(0,t),0===(t-=o)){o===a.length?(++r,n.next?e.head=n.next:e.head=e.tail=null):(e.head=n,n.data=a.slice(o));break}++r}return e.length-=r,i}(t,e):function(t,e){var n=c.allocUnsafe(t),r=e.head,i=1;r.data.copy(n),t-=r.data.length;for(;r=r.next;){var a=r.data,o=t>a.length?a.length:t;if(a.copy(n,n.length-t,0,o),0===(t-=o)){o===a.length?(++i,r.next?e.head=r.next:e.head=e.tail=null):(e.head=r,r.data=a.slice(o));break}++i}return e.length-=i,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,i.nextTick(R,e,t))}function R(t,e){t.endEmitted||0!==t.length||(t.endEmitted=!0,e.readable=!1,e.emit("end"))}function O(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){d("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 d("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?M(this):E(this),null;if(0===(t=I(t,e))&&e.ended)return 0===e.length&&M(this),null;var r,i=e.needReadable;return d("need readable",i),(0===e.length||e.length-t<e.highWaterMark)&&d("length less than watermark",i=!0),e.ended||e.reading?d("reading or ended",i=!1):i&&(d("do read"),e.reading=!0,e.sync=!0,0===e.length&&(e.needReadable=!0),this._read(e.highWaterMark),e.sync=!1,e.reading||(t=I(n,e))),null===(r=t>0?Q(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,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,d("pipe count=%d opts=%j",a.pipesCount,e);var u=(!e||!1!==e.end)&&t!==r.stdout&&t!==r.stderr?f:m;function c(e,r){d("onunpipe"),e===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,d("cleanup"),t.removeListener("close",b),t.removeListener("finish",g),t.removeListener("drain",l),t.removeListener("error",A),t.removeListener("unpipe",c),n.removeListener("end",f),n.removeListener("end",m),n.removeListener("data",y),p=!0,!a.awaitDrain||t._writableState&&!t._writableState.needDrain||l())}function f(){d("onend"),t.end()}a.endEmitted?i.nextTick(u):n.once("end",u),t.on("unpipe",c);var l=function(t){return function(){var e=t._readableState;d("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&s(t,"data")&&(e.flowing=!0,S(t))}}(n);t.on("drain",l);var p=!1;var h=!1;function y(e){d("ondata"),h=!1,!1!==t.write(e)||h||((1===a.pipesCount&&a.pipes===t||a.pipesCount>1&&-1!==O(a.pipes,t))&&!p&&(d("false write response, pause",a.awaitDrain),a.awaitDrain++,h=!0),n.pause())}function A(e){d("onerror",e),m(),t.removeListener("error",A),0===s(t,"error")&&t.emit("error",e)}function b(){t.removeListener("finish",g),m()}function g(){d("onfinish"),t.removeListener("close",b),m()}function m(){d("unpipe"),n.unpipe(t)}return n.on("data",y),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",A),t.once("close",b),t.once("finish",g),t.emit("pipe",n),a.flowing||(d("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,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var a=0;a<i;a++)r[a].emit("unpipe",this,{hasUnpiped:!1});return this}var o=O(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&&E(this):i.nextTick(B,this))}return n},m.prototype.addListener=m.prototype.on,m.prototype.resume=function(){var t=this._readableState;return t.flowing||(d("resume"),t.flowing=!0,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,i.nextTick(x,t,e))}(this,t)),this},m.prototype.pause=function(){return d("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(d("pause"),this._readableState.flowing=!1,this.emit("pause")),this},m.prototype.wrap=function(t){var e=this,n=this._readableState,r=!1;for(var i in t.on("end",(function(){if(d("wrapped end"),n.decoder&&!n.ended){var t=n.decoder.end();t&&t.length&&e.push(t)}e.push(null)})),t.on("data",(function(i){(d("wrapped data"),n.decoder&&(i=n.decoder.write(i)),n.objectMode&&null==i)||(n.objectMode||i&&i.length)&&(e.push(i)||(r=!0,t.pause()))})),t)void 0===this[i]&&"function"==typeof t[i]&&(this[i]=function(e){return function(){return t[e].apply(t,arguments)}}(i));for(var a=0;a<b.length;a++)t.on(b[a],this.emit.bind(this,b[a]));return this._read=function(e){d("wrapped _read",e),r&&(r=!1,t.resume())},this},Object.defineProperty(m.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),m._fromList=Q}).call(this,n(8),n(6))},function(t,e,n){t.exports=n(20).EventEmitter},function(t,e,n){"use strict";var r=n(72);function i(t,e){t.emit("error",e)}t.exports={destroy:function(t,e){var n=this,a=this._readableState&&this._readableState.destroyed,o=this._writableState&&this._writableState.destroyed;return a||o?(e?e(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,r.nextTick(i,this,t)):r.nextTick(i,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,(function(t){!e&&t?n._writableState?n._writableState.errorEmitted||(n._writableState.errorEmitted=!0,r.nextTick(i,n,t)):r.nextTick(i,n,t):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.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}}},function(t,e,n){"use strict";t.exports=o;var r=n(40),i=Object.create(n(59));function a(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 i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function o(t){if(!(this instanceof o))return new o(t);r.call(this,t),this._transformState={afterTransform:a.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)}i.inherits=n(3),i.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 i=this._readableState;(r.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.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(3),i=n(362),a=n(38),o=n(5).Buffer,s=n(167),u=n(94),c=n(95),f=o.alloc(128);function l(t,e){a.call(this,"digest"),"string"==typeof e&&(e=o.from(e));var n="sha512"===t||"sha384"===t?128:64;(this._alg=t,this._key=e,e.length>n)?e=("rmd160"===t?new u:c(t)).update(e).digest():e.length<n&&(e=o.concat([e,f],n));for(var r=this._ipad=o.allocUnsafe(n),i=this._opad=o.allocUnsafe(n),s=0;s<n;s++)r[s]=54^e[s],i[s]=92^e[s];this._hash="rmd160"===t?new u:c(t),this._hash.update(r)}r(l,a),l.prototype._update=function(t){this._hash.update(t)},l.prototype._final=function(){var t=this._hash.digest();return("rmd160"===this._alg?new u:c(this._alg)).update(this._opad).update(t).digest()},t.exports=function(t,e){return"rmd160"===(t=t.toLowerCase())||"ripemd160"===t?new l("rmd160",e):"md5"===t?new i(s,e):new l(t,e)}},function(t,e,n){var r=n(92);t.exports=function(t){return(new r).update(t).digest()}},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,n){e.pbkdf2=n(364),e.pbkdf2Sync=n(172)},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(8),n(6))},function(t,e,n){var r=n(167),i=n(94),a=n(95),o=n(5).Buffer,s=n(170),u=n(171),c=n(173),f=o.alloc(128),l={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,rmd160:20,ripemd160:20};function p(t,e,n){var s=function(t){function e(e){return a(t).update(e).digest()}return"rmd160"===t||"ripemd160"===t?function(t){return(new i).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+l[t]),p=o.allocUnsafe(u+l[t]),d=0;d<u;d++)c[d]=54^e[d],p[d]=92^e[d];var h=o.allocUnsafe(u+n+4);c.copy(h,0,0,u),this.ipad1=h,this.ipad2=c,this.opad=p,this.alg=t,this.blocksize=u,this.hash=s,this.size=l[t]}p.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,i){s(n,r);var a=new p(i=i||"sha1",t=c(t,u,"Password"),(e=c(e,u,"Salt")).length),f=o.allocUnsafe(r),d=o.allocUnsafe(e.length+4);e.copy(d,0,0,e.length);for(var h=0,y=l[i],A=Math.ceil(r/y),b=1;b<=A;b++){d.writeUInt32BE(b,e.length);for(var g=a.run(d,a.ipad1),m=g,v=1;v<n;v++){m=a.run(m,a.ipad2);for(var w=0;w<y;w++)g[w]^=m[w]}g.copy(f,h),h+=y}return f}},function(t,e,n){var r=n(5).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){"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 i=0,a=0,o=6;o>=0;o-=2){for(var 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(o=6;o>=0;o-=2){for(s=1;s<=25;s+=8)a<<=1,a|=e>>>s+o&1;for(s=1;s<=25;s+=8)a<<=1,a|=t>>>s+o&1}n[r+0]=i>>>0,n[r+1]=a>>>0},e.rip=function(t,e,n,r){for(var i=0,a=0,o=0;o<4;o++)for(var s=24;s>=0;s-=8)i<<=1,i|=e>>>s+o&1,i<<=1,i|=t>>>s+o&1;for(o=4;o<8;o++)for(s=24;s>=0;s-=8)a<<=1,a|=e>>>s+o&1,a<<=1,a|=t>>>s+o&1;n[r+0]=i>>>0,n[r+1]=a>>>0},e.pc1=function(t,e,n,r){for(var i=0,a=0,o=7;o>=5;o--){for(var 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|=e>>s+o&1;for(o=1;o<=3;o++){for(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|=t>>s+o&1;n[r+0]=i>>>0,n[r+1]=a>>>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,i){for(var a=0,o=0,s=r.length>>>1,u=0;u<s;u++)a<<=1,a|=t>>>r[u]&1;for(u=s;u<r.length;u++)o<<=1,o|=e>>>r[u]&1;n[i+0]=a>>>0,n[i+1]=o>>>0},e.expand=function(t,e,n){var r=0,i=0;r=(1&t)<<5|t>>>27;for(var a=23;a>=15;a-=4)r<<=6,r|=t>>>a&63;for(a=11;a>=3;a-=4)i|=t>>>a&63,i<<=6;i|=(31&t)<<1|t>>>31,e[n+0]=r>>>0,e[n+1]=i>>>0};var i=[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|=i[64*r+(t>>>18-6*r&63)]}for(r=0;r<4;r++){n<<=4,n|=i[256+64*r+(e>>>18-6*r&63)]}return n>>>0};var a=[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<a.length;n++)e<<=1,e|=t>>>a[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 i=[],a=0;a<e;a+=n)i.push(r.slice(a,a+n));return i.join(" ")}},function(t,e,n){"use strict";var r=n(19),i=n(3),a=n(174),o=n(99);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)}i(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=a.readUInt32BE(e,0),i=a.readUInt32BE(e,4);a.pc1(n,i,t.tmp,0),n=t.tmp[0],i=t.tmp[1];for(var o=0;o<t.keys.length;o+=2){var s=c[o>>>1];n=a.r28shl(n,s),i=a.r28shl(i,s),a.pc2(n,i,t.keys,o)}},u.prototype._update=function(t,e,n,r){var i=this._desState,o=a.readUInt32BE(t,e),s=a.readUInt32BE(t,e+4);a.ip(o,s,i.tmp,0),o=i.tmp[0],s=i.tmp[1],"encrypt"===this.type?this._encrypt(i,o,s,i.tmp,0):this._decrypt(i,o,s,i.tmp,0),o=i.tmp[0],s=i.tmp[1],a.writeUInt32BE(n,o,r),a.writeUInt32BE(n,s,r+4)},u.prototype._pad=function(t,e){if(!1===this.padding)return!1;for(var n=t.length-e,r=e;r<t.length;r++)t[r]=n;return!0},u.prototype._unpad=function(t){if(!1===this.padding)return 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,i){for(var o=e,s=n,u=0;u<t.keys.length;u+=2){var c=t.keys[u],f=t.keys[u+1];a.expand(s,t.tmp,0),c^=t.tmp[0],f^=t.tmp[1];var l=a.substitute(c,f),p=s;s=(o^a.permute(l))>>>0,o=p}a.rip(s,o,r,i)},u.prototype._decrypt=function(t,e,n,r,i){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];a.expand(o,t.tmp,0),c^=t.tmp[0],f^=t.tmp[1];var l=a.substitute(c,f),p=o;o=(s^a.permute(l))>>>0,s=p}a.rip(o,s,r,i)}},function(t,e,n){var r=n(60),i=n(5).Buffer,a=n(177);function o(t){var e=t._cipher.encryptBlockRaw(t._prev);return a(t._prev),e}e.encrypt=function(t,e){var n=Math.ceil(e.length/16),a=t._cache.length;t._cache=i.concat([t._cache,i.allocUnsafe(16*n)]);for(var s=0;s<n;s++){var u=o(t),c=a+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(73),i=n(5).Buffer,a=n(38),o=n(3),s=n(377),u=n(60),c=n(177);function f(t,e,n,o){a.call(this);var u=i.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=i.concat([e,i.from([0,0,0,1])]),i.concat([e,i.from([0,0,0,2])]);var r=new s(n),a=e.length,o=a%16;r.update(e),o&&(o=16-o,r.update(i.alloc(o,0))),r.update(i.alloc(8,0));var u=8*a,f=i.alloc(8);f.writeUIntBE(u,0,8),r.update(f),t._finID=r.state;var l=i.from(t._finID);return c(l),l}(this,n,f),this._prev=i.from(n),this._cache=i.allocUnsafe(0),this._secCache=i.allocUnsafe(0),this._decrypt=o,this._alen=0,this._len=0,this._mode=t,this._authTag=null,this._called=!1}o(f,a),f.prototype._update=function(t){if(!this._called&&this._alen){var e=16-this._alen%16;e<16&&(e=i.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),i=0;i<r;++i)n+=t[i]^e[i];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||!i.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(73),i=n(5).Buffer,a=n(38);function o(t,e,n,o){a.call(this),this._cipher=new r.AES(e),this._prev=i.from(n),this._cache=i.allocUnsafe(0),this._secCache=i.allocUnsafe(0),this._decrypt=o,this._mode=t}n(3)(o,a),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){var r=n(45);t.exports=g,g.simpleSieve=A,g.fermatTest=b;var i=n(2),a=new i(24),o=new(n(182)),s=new i(1),u=new i(2),c=new i(5),f=(new i(16),new i(8),new i(10)),l=new i(3),p=(new i(7),new i(11)),d=new i(4),h=(new i(12),null);function y(){if(null!==h)return h;var t=[];t[0]=2;for(var e=1,n=3;n<1048576;n+=2){for(var r=Math.ceil(Math.sqrt(n)),i=0;i<e&&t[i]<=r&&n%t[i]!=0;i++);e!==i&&t[i]<=r||(t[e++]=n)}return h=t,t}function A(t){for(var e=y(),n=0;n<e.length;n++)if(0===t.modn(e[n]))return 0===t.cmpn(e[n]);return!0}function b(t){var e=i.mont(t);return 0===u.toRed(e).redPow(t.subn(1)).fromRed().cmpn(1)}function g(t,e){if(t<16)return new i(2===e||5===e?[140,123]:[140,39]);var n,h;for(e=new i(e);;){for(n=new i(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(l);)n.iadd(d)}else for(;n.mod(a).cmp(p);)n.iadd(d);if(A(h=n.shrn(1))&&A(n)&&b(h)&&b(n)&&o.test(h)&&o.test(n))return n}}},function(t,e,n){var r=n(2),i=n(102);function a(t){this.rand=t||new i.Rand}t.exports=a,a.create=function(t){return new a(t)},a.prototype._randbelow=function(t){var e=t.bitLength(),n=Math.ceil(e/8);do{var i=new r(this.rand.generate(n))}while(i.cmp(t)>=0);return i},a.prototype._randrange=function(t,e){var n=e.sub(t);return t.add(this._randbelow(n))},a.prototype.test=function(t,e,n){var i=t.bitLength(),a=r.mont(t),o=new r(1).toRed(a);e||(e=Math.max(1,i/48|0));for(var s=t.subn(1),u=0;!s.testn(u);u++);for(var c=t.shrn(u),f=s.toRed(a);e>0;e--){var l=this._randrange(new r(2),s);n&&n(l);var p=l.toRed(a).redPow(c);if(0!==p.cmp(o)&&0!==p.cmp(f)){for(var d=1;d<u;d++){if(0===(p=p.redSqr()).cmp(o))return!1;if(0===p.cmp(f))break}if(d===u)return!1}}return!0},a.prototype.getDivisor=function(t,e){var n=t.bitLength(),i=r.mont(t),a=new r(1).toRed(i);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(i);e>0;e--){var f=this._randrange(new r(2),o),l=t.gcd(f);if(0!==l.cmpn(1))return l;var p=f.toRed(i).redPow(u);if(0!==p.cmp(a)&&0!==p.cmp(c)){for(var d=1;d<s;d++){if(0===(p=p.redSqr()).cmp(a))return p.fromRed().subn(1).gcd(t);if(0===p.cmp(c))break}if(d===s)return(p=p.redSqr()).fromRed().subn(1).gcd(t)}}return!1}},function(t,e,n){"use strict";(function(e,r){var i;t.exports=C,C.ReadableState=_;n(20).EventEmitter;var a=function(t,e){return t.listeners(e).length},o=n(184),s=n(4).Buffer,u=(void 0!==e?e:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){};var c,f=n(386);c=f&&f.debuglog?f.debuglog("stream"):function(){};var l,p,d,h=n(387),y=n(185),A=n(186).getHighWaterMark,b=n(49).codes,g=b.ERR_INVALID_ARG_TYPE,m=b.ERR_STREAM_PUSH_AFTER_EOF,v=b.ERR_METHOD_NOT_IMPLEMENTED,w=b.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;n(3)(C,o);var I=y.errorOrDestroy,E=["error","close","destroy","pause","resume"];function _(t,e,r){i=i||n(50),t=t||{},"boolean"!=typeof r&&(r=e instanceof i),this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=A(this,t,"readableHighWaterMark",r),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.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&&(l||(l=n(29).StringDecoder),this.decoder=new l(t.encoding),this.encoding=t.encoding)}function C(t){if(i=i||n(50),!(this instanceof C))return new C(t);var e=this instanceof i;this._readableState=new _(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,i){c("readableAddChunk",e);var a,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,Q(t)))}(t,o);else if(i||(a=function(t,e){var n;r=e,s.isBuffer(r)||r instanceof u||"string"==typeof e||void 0===e||t.objectMode||(n=new g("chunk",["string","Buffer","Uint8Array"],e));var r;return n}(o,e)),a)I(t,a);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?I(t,new w):B(t,o,e,!0);else if(o.ended)I(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?B(t,o,e,!1):M(t,o)):B(t,o,e,!1)}else r||(o.reading=!1,M(t,o));return!o.ended&&(o.length<o.highWaterMark||0===o.length)}function B(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(C.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(t){this._readableState&&(this._readableState.destroyed=t)}}),C.prototype.destroy=y.destroy,C.prototype._undestroy=y.undestroy,C.prototype._destroy=function(t,e){e(t)},C.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)},C.prototype.unshift=function(t){return k(this,t,null,!0,!1)},C.prototype.isPaused=function(){return!1===this._readableState.flowing},C.prototype.setEncoding=function(t){l||(l=n(29).StringDecoder);var e=new l(t);this._readableState.decoder=e,this._readableState.encoding=this._readableState.decoder.encoding;for(var r=this._readableState.buffer.head,i="";null!==r;)i+=e.write(r.data),r=r.next;return this._readableState.buffer.clear(),""!==i&&this._readableState.buffer.push(i),this._readableState.length=i.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(Q,t))}function Q(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,P(t)}function M(t,e){e.readingMore||(e.readingMore=!0,r.nextTick(R,t,e))}function R(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 O(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 j(t){c("readable nexttick read 0"),t.read(0)}function T(t,e){c("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),P(t),e.flowing&&!e.reading&&t.read(0)}function P(t){var e=t._readableState;for(c("flow",e.flowing);e.flowing&&null!==t.read(););}function D(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 N(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}C.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?N(this):S(this),null;if(0===(t=x(t,e))&&e.ended)return 0===e.length&&N(this),null;var r,i=e.needReadable;return c("need readable",i),(0===e.length||e.length-t<e.highWaterMark)&&c("length less than watermark",i=!0),e.ended||e.reading?c("reading or ended",i=!1):i&&(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?D(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&&N(this)),null!==r&&this.emit("data",r),r},C.prototype._read=function(t){I(this,new v("_read()"))},C.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,c("pipe count=%d opts=%j",i.pipesCount,e);var o=(!e||!1!==e.end)&&t!==r.stdout&&t!==r.stderr?u:A;function s(e,r){c("onunpipe"),e===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,c("cleanup"),t.removeListener("close",h),t.removeListener("finish",y),t.removeListener("drain",f),t.removeListener("error",d),t.removeListener("unpipe",s),n.removeListener("end",u),n.removeListener("end",A),n.removeListener("data",p),l=!0,!i.awaitDrain||t._writableState&&!t._writableState.needDrain||f())}function u(){c("onend"),t.end()}i.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&&a(t,"data")&&(e.flowing=!0,P(t))}}(n);t.on("drain",f);var l=!1;function p(e){c("ondata");var r=t.write(e);c("dest.write",r),!1===r&&((1===i.pipesCount&&i.pipes===t||i.pipesCount>1&&-1!==F(i.pipes,t))&&!l&&(c("false write response, pause",i.awaitDrain),i.awaitDrain++),n.pause())}function d(e){c("onerror",e),A(),t.removeListener("error",d),0===a(t,"error")&&I(t,e)}function h(){t.removeListener("finish",y),A()}function y(){c("onfinish"),t.removeListener("close",h),A()}function A(){c("unpipe"),n.unpipe(t)}return n.on("data",p),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",d),t.once("close",h),t.once("finish",y),t.emit("pipe",n),i.flowing||(c("pipe resume"),n.resume()),t},C.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,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var a=0;a<i;a++)r[a].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},C.prototype.on=function(t,e){var n=o.prototype.on.call(this,t,e),i=this._readableState;return"data"===t?(i.readableListening=this.listenerCount("readable")>0,!1!==i.flowing&&this.resume()):"readable"===t&&(i.endEmitted||i.readableListening||(i.readableListening=i.needReadable=!0,i.flowing=!1,i.emittedReadable=!1,c("on readable",i.length,i.reading),i.length?S(this):i.reading||r.nextTick(j,this))),n},C.prototype.addListener=C.prototype.on,C.prototype.removeListener=function(t,e){var n=o.prototype.removeListener.call(this,t,e);return"readable"===t&&r.nextTick(O,this),n},C.prototype.removeAllListeners=function(t){var e=o.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||r.nextTick(O,this),e},C.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(T,t,e))}(this,t)),t.paused=!1,this},C.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},C.prototype.wrap=function(t){var e=this,n=this._readableState,r=!1;for(var i 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(i){(c("wrapped data"),n.decoder&&(i=n.decoder.write(i)),n.objectMode&&null==i)||(n.objectMode||i&&i.length)&&(e.push(i)||(r=!0,t.pause()))})),t)void 0===this[i]&&"function"==typeof t[i]&&(this[i]=function(e){return function(){return t[e].apply(t,arguments)}}(i));for(var a=0;a<E.length;a++)t.on(E[a],this.emit.bind(this,E[a]));return this._read=function(e){c("wrapped _read",e),r&&(r=!1,t.resume())},this},"function"==typeof Symbol&&(C.prototype[Symbol.asyncIterator]=function(){return void 0===p&&(p=n(389)),p(this)}),Object.defineProperty(C.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(C.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(C.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(t){this._readableState&&(this._readableState.flowing=t)}}),C._fromList=D,Object.defineProperty(C.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),"function"==typeof Symbol&&(C.from=function(t,e){return void 0===d&&(d=n(390)),d(C,t,e)})}).call(this,n(8),n(6))},function(t,e,n){t.exports=n(20).EventEmitter},function(t,e,n){"use strict";(function(e){function n(t,e){i(t,e),r(t)}function r(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit("close")}function i(t,e){t.emit("error",e)}t.exports={destroy:function(t,a){var o=this,s=this._readableState&&this._readableState.destroyed,u=this._writableState&&this._writableState.destroyed;return s||u?(a?a(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,e.nextTick(i,this,t)):e.nextTick(i,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,(function(t){!a&&t?o._writableState?o._writableState.errorEmitted?e.nextTick(r,o):(o._writableState.errorEmitted=!0,e.nextTick(n,o,t)):e.nextTick(n,o,t):a?(e.nextTick(r,o),a(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(6))},function(t,e,n){"use strict";var r=n(49).codes.ERR_INVALID_OPT_VALUE;t.exports={getHighWaterMark:function(t,e,n,i){var a=function(t,e,n){return null!=t.highWaterMark?t.highWaterMark:e?t[n]:null}(e,i,n);if(null!=a){if(!isFinite(a)||Math.floor(a)!==a||a<0)throw new r(i?n:"highWaterMark",a);return Math.floor(a)}return t.objectMode?16:16384}}},function(t,e,n){"use strict";(function(e,r){function i(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 i=r.callback;e.pendingcb--,i(n),r=r.next}e.corkedRequestsFree.next=t}(e,t)}}var a;t.exports=C,C.WritableState=_;var o={deprecate:n(71)},s=n(184),u=n(4).Buffer,c=(void 0!==e?e:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){};var f,l=n(185),p=n(186).getHighWaterMark,d=n(49).codes,h=d.ERR_INVALID_ARG_TYPE,y=d.ERR_METHOD_NOT_IMPLEMENTED,A=d.ERR_MULTIPLE_CALLBACK,b=d.ERR_STREAM_CANNOT_PIPE,g=d.ERR_STREAM_DESTROYED,m=d.ERR_STREAM_NULL_VALUES,v=d.ERR_STREAM_WRITE_AFTER_END,w=d.ERR_UNKNOWN_ENCODING,I=l.errorOrDestroy;function E(){}function _(t,e,o){a=a||n(50),t=t||{},"boolean"!=typeof o&&(o=e instanceof a),this.objectMode=!!t.objectMode,o&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=p(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,i=n.sync,a=n.writecb;if("function"!=typeof a)throw new A;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(n),e)!function(t,e,n,i,a){--e.pendingcb,n?(r.nextTick(a,i),r.nextTick(M,t,e),t._writableState.errorEmitted=!0,I(t,i)):(a(i),t._writableState.errorEmitted=!0,I(t,i),M(t,e))}(t,n,i,e,a);else{var o=S(n)||t.destroyed;o||n.corked||n.bufferProcessing||!n.bufferedRequest||x(t,n),i?r.nextTick(B,t,n,o,a):B(t,n,o,a)}}(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 i(this)}function C(t){var e=this instanceof(a=a||n(50));if(!e&&!f.call(C,this))return new C(t);this._writableState=new _(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,i,a,o){e.writelen=r,e.writecb=o,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new g("write")):n?t._writev(i,e.onwrite):t._write(i,a,e.onwrite),e.sync=!1}function B(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,a=new Array(r),o=e.corkedRequestsFree;o.entry=n;for(var s=0,u=!0;n;)a[s]=n,n.isBuf||(u=!1),n=n.next,s+=1;a.allBuffers=u,k(t,e,!0,e.length,a,"",o.finish),e.pendingcb++,e.lastBufferedRequest=null,o.next?(e.corkedRequestsFree=o.next,o.next=null):e.corkedRequestsFree=new i(e),e.bufferedRequestCount=0}else{for(;n;){var c=n.chunk,f=n.encoding,l=n.callback;if(k(t,e,!1,e.objectMode?1:c.length,c,f,l),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 Q(t,e){t._final((function(n){e.pendingcb--,n&&I(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(Q,t,e)))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit("finish"),e.autoDestroy))){var i=t._readableState;(!i||i.autoDestroy&&i.endEmitted)&&t.destroy()}return n}n(3)(C,s),_.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(_.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(C,Symbol.hasInstance,{value:function(t){return!!f.call(this,t)||this===C&&(t&&t._writableState instanceof _)}})):f=function(t){return t instanceof this},C.prototype.pipe=function(){I(this,new b)},C.prototype.write=function(t,e,n){var i,a=this._writableState,o=!1,s=!a.objectMode&&(i=t,u.isBuffer(i)||i 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=a.defaultEncoding),"function"!=typeof n&&(n=E),a.ending?function(t,e){var n=new v;I(t,n),r.nextTick(e,n)}(this,n):(s||function(t,e,n,i){var a;return null===n?a=new m:"string"==typeof n||e.objectMode||(a=new h("chunk",["string","Buffer"],n)),!a||(I(t,a),r.nextTick(i,a),!1)}(this,a,t,n))&&(a.pendingcb++,o=function(t,e,n,r,i,a){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,i);r!==o&&(n=!0,i="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:i,isBuf:n,callback:a,next:null},f?f.next=e.lastBufferedRequest:e.bufferedRequest=e.lastBufferedRequest,e.bufferedRequestCount+=1}else k(t,e,!1,s,r,i,a);return c}(this,a,s,t,e,n)),o},C.prototype.cork=function(){this._writableState.corked++},C.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,t.writing||t.corked||t.bufferProcessing||!t.bufferedRequest||x(this,t))},C.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 w(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(C.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(C.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),C.prototype._write=function(t,e,n){n(new y("_write()"))},C.prototype._writev=null,C.prototype.end=function(t,e,n){var i=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),i.corked&&(i.corked=1,this.uncork()),i.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,i,n),this},Object.defineProperty(C.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(C.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),C.prototype.destroy=l.destroy,C.prototype._undestroy=l.undestroy,C.prototype._destroy=function(t,e){e(t)}}).call(this,n(8),n(6))},function(t,e,n){"use strict";t.exports=f;var r=n(49).codes,i=r.ERR_METHOD_NOT_IMPLEMENTED,a=r.ERR_MULTIPLE_CALLBACK,o=r.ERR_TRANSFORM_ALREADY_TRANSFORMING,s=r.ERR_TRANSFORM_WITH_LENGTH_0,u=n(50);function c(t,e){var n=this._transformState;n.transforming=!1;var r=n.writecb;if(null===r)return this.emit("error",new a);n.writechunk=null,n.writecb=null,null!=e&&this.push(e),r(t);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.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",l)}function l(){var t=this;"function"!=typeof this._flush||this._readableState.destroyed?p(this,null,null):this._flush((function(e,n){p(t,e,n)}))}function p(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 i("_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 i=this._readableState;(r.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.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){"use strict";var r=e;function i(t){return 1===t.length?"0"+t:t}function a(t){for(var e="",n=0;n<t.length;n++)e+=i(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 i=t.charCodeAt(r),a=i>>8,o=255&i;a?n.push(a,o):n.push(o)}return n},r.zero2=i,r.toHex=a,r.encode=function(t,e){return"hex"===e?a(t):t}},function(t,e,n){"use strict";var r=e;r.base=n(75),r.short=n(395),r.mont=n(396),r.edwards=n(397)},function(t,e,n){"use strict";var r=e;r.bignum=n(2),r.define=n(407).define,r.base=n(410),r.constants=n(411),r.decoders=n(194),r.encoders=n(192)},function(t,e,n){"use strict";var r=e;r.der=n(193),r.pem=n(408)},function(t,e,n){"use strict";var r=n(3),i=n(107).Buffer,a=n(108),o=n(110);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){a.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,a),u.prototype._encodeComposite=function(t,e,n,r){var a=function(t,e,n,r){var i;"seqof"===t?t="seq":"setof"===t&&(t="set");if(o.tagByName.hasOwnProperty(t))i=o.tagByName[t];else{if("number"!=typeof t||(0|t)!==t)return r.error("Unknown tag: "+t);i=t}if(i>=31)return r.error("Multi-octet tag encoding unsupported");e||(i|=32);return i|=o.tagClassByName[n||"universal"]<<6}(t,e,n,this.reporter);if(r.length<128){var s=i.alloc(2);return s[0]=a,s[1]=r.length,this._createEncoderBuffer([s,r])}for(var u=1,c=r.length;c>=256;c>>=8)u++;var f=i.alloc(2+u);f[0]=a,f[1]=128|u;for(var l=1+u,p=r.length;p>0;l--,p>>=8)f[l]=255&p;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=i.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 a=0;a<t.length;a++)t[a]|=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=i.alloc(o),f=c.length-1,l=t.length-1;l>=0;l--){var p=t[l];for(c[f--]=127&p;(p>>=7)>0;)c[f--]=128|127&p}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&&!i.isBuffer(t)){var n=t.toArray();!t.sign&&128&n[0]&&n.unshift(0),t=i.from(n)}if(i.isBuffer(t)){var r=t.length;0===t.length&&r++;var a=i.alloc(r);return t.copy(a),0===t.length&&(a[0]=0),this._createEncoderBuffer(a)}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(i.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,i=this._baseState;if(null===i.default)return!1;var a=t.join();if(void 0===i.defaultBuffer&&(i.defaultBuffer=this._encodeValue(i.default,e,n).join()),a.length!==i.defaultBuffer.length)return!1;for(r=0;r<a.length;r++)if(a[r]!==i.defaultBuffer[r])return!1;return!0}},function(t,e,n){"use strict";var r=e;r.der=n(195),r.pem=n(409)},function(t,e,n){"use strict";var r=n(3),i=n(2),a=n(61).DecoderBuffer,o=n(108),s=n(110);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],i=0==(32&n);if(31==(31&n)){var a=n;for(n=0;128==(128&a);){if(a=t.readUInt8(e),t.isError(a))return a;n<<=7,n|=127&a}}else n&=31;return{cls:r,primitive:i,tag:n,tagStr:s.tag[n]}}function l(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 i=127&r;if(i>4)return t.error("length octect is too long");r=0;for(var a=0;a<i;a++){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 a.isDecoderBuffer(t)||(t=new a(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(),i=f(t,'Failed to peek tag: "'+e+'"');return t.isError(i)?i:(t.restore(r),i.tag===e||i.tagStr===e||i.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 i=l(t,r.primitive,'Failed to get length of "'+e+'"');if(t.isError(i))return i;if(!n&&r.tag!==e&&r.tagStr!==e&&r.tagStr+"of"!==e)return t.error('Failed to match tag: "'+e+'"');if(r.primitive||null!==i)return t.skip(i,'Failed to match body of: "'+e+'"');var a=t.save(),o=this._skipUntilEnd(t,'Failed to skip indefinite length body: "'+this.tag+'"');return t.isError(o)?o:(i=t.offset-a.offset,t.restore(a),t.skip(i,'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=l(t,n.primitive,e);if(t.isError(r))return r;var i=void 0;if(i=n.primitive||null!==r?t.skip(r):this._skipUntilEnd(t,e),t.isError(i))return i;if("end"===n.tagStr)break}},c.prototype._decodeList=function(t,e,n,r){for(var i=[];!t.isEmpty();){var a=this._peekTag(t,"end");if(t.isError(a))return a;var o=n.decode(t,"der",r);if(t.isError(o)&&a)break;i.push(o)}return i},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 i="",a=0;a<r.length/2;a++)i+=String.fromCharCode(r.readUInt16BE(2*a));return i}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,i=[],a=0,o=0;!t.isEmpty();)a<<=7,a|=127&(o=t.readUInt8()),0==(128&o)&&(i.push(a),a=0);128&o&&i.push(a);var s=i[0]/40|0,u=i[0]%40;if(r=n?i:[s,u].concat(i.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,i,a,o,s,u=t.raw().toString();if("gentime"===e)n=0|u.slice(0,4),r=0|u.slice(4,6),i=0|u.slice(6,8),a=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),i=0|u.slice(4,6),a=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,i,a,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 i(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){var r=n(58),i=n(5).Buffer;function a(t){var e=i.allocUnsafe(4);return e.writeUInt32BE(t,0),e}t.exports=function(t,e){for(var n,o=i.alloc(0),s=0;o.length<e;)n=a(s++),o=i.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),i=n(5).Buffer;t.exports=function(t,e){return i.from(t.toRed(r.mont(e.modulus)).redPow(new r(e.publicExponent)).fromRed().toArray())}},function(t,e,n){"use strict";(function(e,r){var i;t.exports=C,C.ReadableState=_;n(20).EventEmitter;var a=function(t,e){return t.listeners(e).length},o=n(201),s=n(4).Buffer,u=(void 0!==e?e:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){};var c,f=n(423);c=f&&f.debuglog?f.debuglog("stream"):function(){};var l,p,d,h=n(424),y=n(202),A=n(203).getHighWaterMark,b=n(51).codes,g=b.ERR_INVALID_ARG_TYPE,m=b.ERR_STREAM_PUSH_AFTER_EOF,v=b.ERR_METHOD_NOT_IMPLEMENTED,w=b.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;n(3)(C,o);var I=y.errorOrDestroy,E=["error","close","destroy","pause","resume"];function _(t,e,r){i=i||n(52),t=t||{},"boolean"!=typeof r&&(r=e instanceof i),this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=A(this,t,"readableHighWaterMark",r),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.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&&(l||(l=n(29).StringDecoder),this.decoder=new l(t.encoding),this.encoding=t.encoding)}function C(t){if(i=i||n(52),!(this instanceof C))return new C(t);var e=this instanceof i;this._readableState=new _(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,i){c("readableAddChunk",e);var a,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,Q(t)))}(t,o);else if(i||(a=function(t,e){var n;r=e,s.isBuffer(r)||r instanceof u||"string"==typeof e||void 0===e||t.objectMode||(n=new g("chunk",["string","Buffer","Uint8Array"],e));var r;return n}(o,e)),a)I(t,a);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?I(t,new w):B(t,o,e,!0);else if(o.ended)I(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?B(t,o,e,!1):M(t,o)):B(t,o,e,!1)}else r||(o.reading=!1,M(t,o));return!o.ended&&(o.length<o.highWaterMark||0===o.length)}function B(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(C.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(t){this._readableState&&(this._readableState.destroyed=t)}}),C.prototype.destroy=y.destroy,C.prototype._undestroy=y.undestroy,C.prototype._destroy=function(t,e){e(t)},C.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)},C.prototype.unshift=function(t){return k(this,t,null,!0,!1)},C.prototype.isPaused=function(){return!1===this._readableState.flowing},C.prototype.setEncoding=function(t){l||(l=n(29).StringDecoder);var e=new l(t);this._readableState.decoder=e,this._readableState.encoding=this._readableState.decoder.encoding;for(var r=this._readableState.buffer.head,i="";null!==r;)i+=e.write(r.data),r=r.next;return this._readableState.buffer.clear(),""!==i&&this._readableState.buffer.push(i),this._readableState.length=i.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(Q,t))}function Q(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,P(t)}function M(t,e){e.readingMore||(e.readingMore=!0,r.nextTick(R,t,e))}function R(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 O(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 j(t){c("readable nexttick read 0"),t.read(0)}function T(t,e){c("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),P(t),e.flowing&&!e.reading&&t.read(0)}function P(t){var e=t._readableState;for(c("flow",e.flowing);e.flowing&&null!==t.read(););}function D(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 N(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}C.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?N(this):S(this),null;if(0===(t=x(t,e))&&e.ended)return 0===e.length&&N(this),null;var r,i=e.needReadable;return c("need readable",i),(0===e.length||e.length-t<e.highWaterMark)&&c("length less than watermark",i=!0),e.ended||e.reading?c("reading or ended",i=!1):i&&(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?D(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&&N(this)),null!==r&&this.emit("data",r),r},C.prototype._read=function(t){I(this,new v("_read()"))},C.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,c("pipe count=%d opts=%j",i.pipesCount,e);var o=(!e||!1!==e.end)&&t!==r.stdout&&t!==r.stderr?u:A;function s(e,r){c("onunpipe"),e===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,c("cleanup"),t.removeListener("close",h),t.removeListener("finish",y),t.removeListener("drain",f),t.removeListener("error",d),t.removeListener("unpipe",s),n.removeListener("end",u),n.removeListener("end",A),n.removeListener("data",p),l=!0,!i.awaitDrain||t._writableState&&!t._writableState.needDrain||f())}function u(){c("onend"),t.end()}i.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&&a(t,"data")&&(e.flowing=!0,P(t))}}(n);t.on("drain",f);var l=!1;function p(e){c("ondata");var r=t.write(e);c("dest.write",r),!1===r&&((1===i.pipesCount&&i.pipes===t||i.pipesCount>1&&-1!==F(i.pipes,t))&&!l&&(c("false write response, pause",i.awaitDrain),i.awaitDrain++),n.pause())}function d(e){c("onerror",e),A(),t.removeListener("error",d),0===a(t,"error")&&I(t,e)}function h(){t.removeListener("finish",y),A()}function y(){c("onfinish"),t.removeListener("close",h),A()}function A(){c("unpipe"),n.unpipe(t)}return n.on("data",p),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",d),t.once("close",h),t.once("finish",y),t.emit("pipe",n),i.flowing||(c("pipe resume"),n.resume()),t},C.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,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var a=0;a<i;a++)r[a].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},C.prototype.on=function(t,e){var n=o.prototype.on.call(this,t,e),i=this._readableState;return"data"===t?(i.readableListening=this.listenerCount("readable")>0,!1!==i.flowing&&this.resume()):"readable"===t&&(i.endEmitted||i.readableListening||(i.readableListening=i.needReadable=!0,i.flowing=!1,i.emittedReadable=!1,c("on readable",i.length,i.reading),i.length?S(this):i.reading||r.nextTick(j,this))),n},C.prototype.addListener=C.prototype.on,C.prototype.removeListener=function(t,e){var n=o.prototype.removeListener.call(this,t,e);return"readable"===t&&r.nextTick(O,this),n},C.prototype.removeAllListeners=function(t){var e=o.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||r.nextTick(O,this),e},C.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(T,t,e))}(this,t)),t.paused=!1,this},C.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},C.prototype.wrap=function(t){var e=this,n=this._readableState,r=!1;for(var i 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(i){(c("wrapped data"),n.decoder&&(i=n.decoder.write(i)),n.objectMode&&null==i)||(n.objectMode||i&&i.length)&&(e.push(i)||(r=!0,t.pause()))})),t)void 0===this[i]&&"function"==typeof t[i]&&(this[i]=function(e){return function(){return t[e].apply(t,arguments)}}(i));for(var a=0;a<E.length;a++)t.on(E[a],this.emit.bind(this,E[a]));return this._read=function(e){c("wrapped _read",e),r&&(r=!1,t.resume())},this},"function"==typeof Symbol&&(C.prototype[Symbol.asyncIterator]=function(){return void 0===p&&(p=n(426)),p(this)}),Object.defineProperty(C.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(C.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(C.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(t){this._readableState&&(this._readableState.flowing=t)}}),C._fromList=D,Object.defineProperty(C.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),"function"==typeof Symbol&&(C.from=function(t,e){return void 0===d&&(d=n(427)),d(C,t,e)})}).call(this,n(8),n(6))},function(t,e,n){t.exports=n(20).EventEmitter},function(t,e,n){"use strict";(function(e){function n(t,e){i(t,e),r(t)}function r(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit("close")}function i(t,e){t.emit("error",e)}t.exports={destroy:function(t,a){var o=this,s=this._readableState&&this._readableState.destroyed,u=this._writableState&&this._writableState.destroyed;return s||u?(a?a(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,e.nextTick(i,this,t)):e.nextTick(i,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,(function(t){!a&&t?o._writableState?o._writableState.errorEmitted?e.nextTick(r,o):(o._writableState.errorEmitted=!0,e.nextTick(n,o,t)):e.nextTick(n,o,t):a?(e.nextTick(r,o),a(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(6))},function(t,e,n){"use strict";var r=n(51).codes.ERR_INVALID_OPT_VALUE;t.exports={getHighWaterMark:function(t,e,n,i){var a=function(t,e,n){return null!=t.highWaterMark?t.highWaterMark:e?t[n]:null}(e,i,n);if(null!=a){if(!isFinite(a)||Math.floor(a)!==a||a<0)throw new r(i?n:"highWaterMark",a);return Math.floor(a)}return t.objectMode?16:16384}}},function(t,e,n){"use strict";(function(e,r){function i(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 i=r.callback;e.pendingcb--,i(n),r=r.next}e.corkedRequestsFree.next=t}(e,t)}}var a;t.exports=C,C.WritableState=_;var o={deprecate:n(71)},s=n(201),u=n(4).Buffer,c=(void 0!==e?e:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){};var f,l=n(202),p=n(203).getHighWaterMark,d=n(51).codes,h=d.ERR_INVALID_ARG_TYPE,y=d.ERR_METHOD_NOT_IMPLEMENTED,A=d.ERR_MULTIPLE_CALLBACK,b=d.ERR_STREAM_CANNOT_PIPE,g=d.ERR_STREAM_DESTROYED,m=d.ERR_STREAM_NULL_VALUES,v=d.ERR_STREAM_WRITE_AFTER_END,w=d.ERR_UNKNOWN_ENCODING,I=l.errorOrDestroy;function E(){}function _(t,e,o){a=a||n(52),t=t||{},"boolean"!=typeof o&&(o=e instanceof a),this.objectMode=!!t.objectMode,o&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=p(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,i=n.sync,a=n.writecb;if("function"!=typeof a)throw new A;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(n),e)!function(t,e,n,i,a){--e.pendingcb,n?(r.nextTick(a,i),r.nextTick(M,t,e),t._writableState.errorEmitted=!0,I(t,i)):(a(i),t._writableState.errorEmitted=!0,I(t,i),M(t,e))}(t,n,i,e,a);else{var o=S(n)||t.destroyed;o||n.corked||n.bufferProcessing||!n.bufferedRequest||x(t,n),i?r.nextTick(B,t,n,o,a):B(t,n,o,a)}}(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 i(this)}function C(t){var e=this instanceof(a=a||n(52));if(!e&&!f.call(C,this))return new C(t);this._writableState=new _(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,i,a,o){e.writelen=r,e.writecb=o,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new g("write")):n?t._writev(i,e.onwrite):t._write(i,a,e.onwrite),e.sync=!1}function B(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,a=new Array(r),o=e.corkedRequestsFree;o.entry=n;for(var s=0,u=!0;n;)a[s]=n,n.isBuf||(u=!1),n=n.next,s+=1;a.allBuffers=u,k(t,e,!0,e.length,a,"",o.finish),e.pendingcb++,e.lastBufferedRequest=null,o.next?(e.corkedRequestsFree=o.next,o.next=null):e.corkedRequestsFree=new i(e),e.bufferedRequestCount=0}else{for(;n;){var c=n.chunk,f=n.encoding,l=n.callback;if(k(t,e,!1,e.objectMode?1:c.length,c,f,l),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 Q(t,e){t._final((function(n){e.pendingcb--,n&&I(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(Q,t,e)))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit("finish"),e.autoDestroy))){var i=t._readableState;(!i||i.autoDestroy&&i.endEmitted)&&t.destroy()}return n}n(3)(C,s),_.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(_.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(C,Symbol.hasInstance,{value:function(t){return!!f.call(this,t)||this===C&&(t&&t._writableState instanceof _)}})):f=function(t){return t instanceof this},C.prototype.pipe=function(){I(this,new b)},C.prototype.write=function(t,e,n){var i,a=this._writableState,o=!1,s=!a.objectMode&&(i=t,u.isBuffer(i)||i 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=a.defaultEncoding),"function"!=typeof n&&(n=E),a.ending?function(t,e){var n=new v;I(t,n),r.nextTick(e,n)}(this,n):(s||function(t,e,n,i){var a;return null===n?a=new m:"string"==typeof n||e.objectMode||(a=new h("chunk",["string","Buffer"],n)),!a||(I(t,a),r.nextTick(i,a),!1)}(this,a,t,n))&&(a.pendingcb++,o=function(t,e,n,r,i,a){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,i);r!==o&&(n=!0,i="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:i,isBuf:n,callback:a,next:null},f?f.next=e.lastBufferedRequest:e.bufferedRequest=e.lastBufferedRequest,e.bufferedRequestCount+=1}else k(t,e,!1,s,r,i,a);return c}(this,a,s,t,e,n)),o},C.prototype.cork=function(){this._writableState.corked++},C.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,t.writing||t.corked||t.bufferProcessing||!t.bufferedRequest||x(this,t))},C.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 w(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(C.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(C.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),C.prototype._write=function(t,e,n){n(new y("_write()"))},C.prototype._writev=null,C.prototype.end=function(t,e,n){var i=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),i.corked&&(i.corked=1,this.uncork()),i.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,i,n),this},Object.defineProperty(C.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(C.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),C.prototype.destroy=l.destroy,C.prototype._undestroy=l.undestroy,C.prototype._destroy=function(t,e){e(t)}}).call(this,n(8),n(6))},function(t,e,n){"use strict";t.exports=f;var r=n(51).codes,i=r.ERR_METHOD_NOT_IMPLEMENTED,a=r.ERR_MULTIPLE_CALLBACK,o=r.ERR_TRANSFORM_ALREADY_TRANSFORMING,s=r.ERR_TRANSFORM_WITH_LENGTH_0,u=n(52);function c(t,e){var n=this._transformState;n.transforming=!1;var r=n.writecb;if(null===r)return this.emit("error",new a);n.writechunk=null,n.writecb=null,null!=e&&this.push(e),r(t);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.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",l)}function l(){var t=this;"function"!=typeof this._flush||this._readableState.destroyed?p(this,null,null):this._flush((function(e,n){p(t,e,n)}))}function p(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 i("_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 i=this._readableState;(r.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.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){(function(t){var r=n(36),i=n(17),a=n(9),o=n(10);function s(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 u(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?s(Object(n),!0).forEach((function(e){i(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):s(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}var c,f=n(28);f.Platform()===f.PLATFORM_NODE&&(globalThis.Response=n(82).Response,c=n(207));var l=n(30),p=n(31),d=p.ValidatePresence,h=p.ValidateWriteToken,y=p.ValidatePartHash,A=p.ValidateParameters;e.ListFiles=function(){var t=o(a.mark((function t(e){var n,r,i,o;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.versionHash,A({libraryId:n,objectId:r,versionHash:i}),i&&(r=this.utils.DecodeVersionHash(i).objectId),o=l("q",i||r,"meta","files"),t.t0=this.utils,t.t1=this.HttpClient,t.next=8,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,versionHash:i});case 8:return t.t2=t.sent,t.t3=o,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.UploadFilesFromS3=function(){var e=o(a.mark((function e(n){var r,i,o,s,c,f,l,p,d,y,b,g,m,v,w,I,E,_,C,k,B,x,S,Q,M,R,O,j,T;return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.libraryId,i=n.objectId,o=n.writeToken,s=n.region,c=n.bucket,f=n.fileInfo,l=n.accessKey,p=n.secret,d=n.signedUrl,y=n.encryption,b=void 0===y?"none":y,g=n.copy,m=void 0!==g&&g,v=n.callback,A({libraryId:r,objectId:i}),h(o),w=/^s3:\/\/([^/]+)\//i,I=0;case 5:if(!(I<f.length)){e.next=18;break}if(E=f[I].source,!(_=w.exec(E))){e.next=15;break}if(_[1]===c){e.next=14;break}throw Error('Full S3 file path "'+E+"\" specified, but does not match provided bucket name '"+c+"'");case 14:f[I].source=E.replace(w,"");case 15:I++,e.next=5;break;case 18:if(this.Log("Uploading files from S3: ".concat(r," ").concat(i," ").concat(o)),"cgck"!==b){e.next=25;break}return e.next=22,this.EncryptionConk({libraryId:r,objectId:i,writeToken:o});case 22:k=u(u({},k=e.sent),{},{secret_key:""}),C="kp__".concat(this.utils.B58(t.from(JSON.stringify(k))));case 25:return B={access_key_id:l,secret_access_key:p},d&&(B={signed_url:d}),x={encryption_key:C,access:{protocol:"s3",platform:"aws",path:c,storage_endpoint:{region:s},cloud_credentials:B}},S=f.map((function(t){return m?{op:"ingest-copy",path:t.path,encryption:{scheme:"cgck"===b?"cgck":"none"},ingest:{type:"key",path:t.source}}:{op:"add-reference",path:t.path,reference:{type:"key",path:t.source}}})),e.next=31,this.CreateFileUploadJob({libraryId:r,objectId:i,writeToken:o,ops:S,defaults:x});case 31:Q=e.sent,M=Q.id;case 33:return e.next=36,new Promise((function(t){return setTimeout(t,1e3)}));case 36:return e.next=38,this.UploadStatus({libraryId:r,objectId:i,writeToken:o,uploadId:M});case 38:if(!((R=e.sent).errors&&R.errors.length>1)){e.next=43;break}throw R.errors.join("\n");case 43:if(!R.error){e.next=48;break}throw this.Log("S3 file upload failed:\n".concat(JSON.stringify(R,null,2))),R.error;case 48:if("failed"!==R.status.toLowerCase()){e.next=50;break}throw"File upload failed";case 50:if(O=!1,m?(O=R.ingest_copy.done,v&&(j=R.ingest_copy.progress,v({done:O,uploaded:j.bytes.completed,total:j.bytes.total,uploadedFiles:j.files.completed,totalFiles:j.files.total,fileStatus:j.files.details}))):(O=R.add_reference.done,v&&(T=R.add_reference.progress,v({done:O,uploadedFiles:T.completed,totalFiles:T.total}))),!O){e.next=54;break}return e.abrupt("break",56);case 54:e.next=33;break;case 56:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),e.UploadFiles=function(){var e=o(a.mark((function e(n){var r,i,s,f,l,p,y,b,g,m,v,w,I,E,_,C,k,B,x,S,Q,M,R,O,j,T,P,D,N,L=this;return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=n.libraryId,i=n.objectId,s=n.writeToken,f=n.fileInfo,l=n.encryption,p=void 0===l?"none":l,y=n.callback,A({libraryId:r,objectId:i}),h(s),d("fileInfo",f),this.Log("Uploading files: ".concat(r," ").concat(i," ").concat(s)),"cgck"!==p){e.next=9;break}return e.next=8,this.EncryptionConk({libraryId:r,objectId:i,writeToken:s});case 8:b=e.sent;case 9:for(g={},m={},v=f,f=[],w=0;w<v.length;w++)(I=u(u({},v[w]),{},{data:void 0})).path=I.path.replace(/^\/+/,""),"cgck"===p&&(I.encryption={scheme:"cgck"}),m[I.path]=v[w].data,I.type="file",g[I.path]={uploaded:0,total:I.size},f.push(I);return this.Log(f),y&&y(g),e.next=18,this.CreateFileUploadJob({libraryId:r,objectId:i,writeToken:s,ops:f,encryption:p});case 18:E=e.sent,_=E.id,C=E.jobs,this.Log("Upload ID: ".concat(_)),this.Log(C),524288e3,k=[],B=0,x=0,S=function(){var e=o(a.mark((function e(){var n,o,u,f,l,d;return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=0;case 1:if(!(n<C.length)){e.next=31;break}case 2:if(!(B-x>524288e3)){e.next=7;break}return e.next=5,new Promise((function(t){return setTimeout(t,500)}));case 5:e.next=2;break;case 7:return o=C[n],e.next=10,L.UploadJobStatus({libraryId:r,objectId:i,writeToken:s,uploadId:_,jobId:o});case 10:u=e.sent,f=0;case 12:if(!(f<u.files.length)){e.next=25;break}if(l=u.files[f],d=void 0,"number"==typeof m[l.path]?(d=t.alloc(l.len),c.readSync(m[l.path],d,0,l.len,l.off)):d=m[l.path].slice(l.off,l.off+l.len),"cgck"!==p){e.next=20;break}return e.next=19,L.Crypto.Encrypt(b,d);case 19:d=e.sent;case 20:u.files[f].data=d,B+=l.len;case 22:f++,e.next=12;break;case 25:return k[n]=u,e.next=28,new Promise((function(t){return setTimeout(t,50)}));case 28:n++,e.next=1;break;case 31:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),Q=function(){var t=o(a.mark((function t(e,n){var o,c,f,l;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(k[n]){t.next=5;break}return t.next=3,new Promise((function(t){return setTimeout(t,500)}));case 3:t.next=0;break;case 5:o=k[n],c=o.files,f=a.mark((function t(){var o,f,d;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:o=c[l],f=0,d=!1;case 3:return t.prev=3,t.next=6,L.UploadFileData({libraryId:r,objectId:i,writeToken:s,uploadId:_,jobId:e,filePath:o.path,fileData:o.data,encryption:p});case 6:d=!0,t.next=17;break;case 9:if(t.prev=9,t.t0=t.catch(3),L.Log(t.t0,!0),!((f+=1)>=10)){t.next=15;break}throw t.t0;case 15:return t.next=17,new Promise((function(t){return setTimeout(t,10*f*1e3)}));case 17:if(!d&&f<10){t.next=3;break}case 18:delete k[n].files[l].data,x+=o.len,y&&(g[o.path]=u(u({},g[o.path]),{},{uploaded:g[o.path].uploaded+o.len}),y(g));case 21:case"end":return t.stop()}}),t,null,[[3,9]])})),l=0;case 9:if(!(l<c.length)){t.next=14;break}return t.delegateYield(f(),"t0",11);case 11:l++,t.next=9;break;case 14:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}(),S().catch((function(t){throw t})),M=Math.min(3,C.length),R=[],O=0;case 33:if(!(O<M)){e.next=43;break}return j=(new Date).getTime(),e.next=37,Q(C[O],O);case 37:T=((new Date).getTime()-j)/1e3,P=k[O].files.map((function(t){return t.len})).reduce((function(t,e){return t+e}),0),R.push(P/T/1048576);case 40:O++,e.next=33;break;case 43:return D=R.reduce((function(t,e){return t+e}),0)/M,N=Math.min(5,Math.ceil(D/2)),e.next=47,this.utils.LimitedMap(N,C,function(){var t=o(a.mark((function t(e,n){return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(n<M)){t.next=2;break}return t.abrupt("return");case 2:return t.next=4,Q(e,n);case 4:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}());case 47:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),e.CreateFileUploadJob=function(){var t=o(a.mark((function t(e){var n,r,i,o,s,u,c,f,p,d;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.writeToken,o=e.ops,s=e.defaults,u=void 0===s?{}:s,c=e.encryption,f=void 0===c?"none":c,A({libraryId:n,objectId:r}),h(i),this.Log("Creating file upload job: ".concat(n," ").concat(r," ").concat(i)),this.Log(o),"cgck"===f&&(u.encryption={scheme:"cgck"}),p={seq:0,seq_complete:!0,defaults:u,ops:o},d=l("q",i,"file_jobs"),t.t0=this.utils,t.t1=this.HttpClient,t.next=12,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,update:!0,encryption:f});case 12:return t.t2=t.sent,t.t3=d,t.t4=p,t.t5={headers:t.t2,method:"POST",path:t.t3,body:t.t4,allowFailover:!1},t.t6=t.t1.Request.call(t.t1,t.t5),t.abrupt("return",t.t0.ResponseToJson.call(t.t0,t.t6));case 18:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.UploadStatus=function(){var t=o(a.mark((function t(e){var n,r,i,o,s;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.writeToken,o=e.uploadId,A({libraryId:n,objectId:r}),h(i),s=l("q",i,"file_jobs",o),t.t0=this.utils,t.t1=this.HttpClient,t.next=8,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,update:!0});case 8:return t.t2=t.sent,t.t3=s,t.t4={headers:t.t2,method:"GET",path:t.t3,allowFailover:!1},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.UploadJobStatus=function(){var t=o(a.mark((function t(e){var n,i,o,s,u,c,f,p;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,i=e.objectId,o=e.writeToken,s=e.uploadId,u=e.jobId,A({libraryId:n,objectId:i}),h(o),c=l("q",o,"file_jobs",s,"uploads",u),t.t0=this.utils,t.t1=this.HttpClient,t.next=8,this.authClient.AuthorizationHeader({libraryId:n,objectId:i,update:!0});case 8:return t.t2=t.sent,t.t3=c,t.t4={start:0,limit:1e4},t.t5={headers:t.t2,method:"GET",path:t.t3,allowFailover:!1,queryParams:t.t4},t.t6=t.t1.Request.call(t.t1,t.t5),t.next=15,t.t0.ResponseToJson.call(t.t0,t.t6);case 15:f=t.sent;case 16:if(!(f.next!==f.total&&f.next>=0)){t.next=33;break}return t.t7=this.utils,t.t8=this.HttpClient,t.next=21,this.authClient.AuthorizationHeader({libraryId:n,objectId:i,update:!0});case 21:return t.t9=t.sent,t.t10=c,t.t11={start:f.next},t.t12={headers:t.t9,method:"GET",path:t.t10,allowFailover:!1,queryParams:t.t11},t.t13=t.t8.Request.call(t.t8,t.t12),t.next=28,t.t7.ResponseToJson.call(t.t7,t.t13);case 28:p=t.sent,f.files=[].concat(r(f.files),r(p.files)),f.next=p.next,t.next=16;break;case 33:return t.abrupt("return",f);case 34:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.UploadFileData=function(){var t=o(a.mark((function t(e){var n,r,i,o,s,c,f,p,d,y,b;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.writeToken,o=e.encryption,s=e.uploadId,c=e.jobId,f=e.filePath,p=e.fileData,A({libraryId:n,objectId:r}),h(i),t.next=5,this.UploadJobStatus({libraryId:n,objectId:r,writeToken:i,uploadId:s,jobId:c});case 5:if(d=t.sent,y=d.files.find((function(t){return t.path==f})),o&&"none"!==o&&(y=y.encrypted),0!==y.rem){t.next=12;break}return t.abrupt("return");case 12:y.skip&&(p=p.slice(y.skip));case 13:return b=l("q",i,"file_jobs",s,c),t.t0=this.utils,t.t1=this.HttpClient,t.t2=b,t.t3=p,t.t4=u,t.t5={"Content-type":"application/octet-stream"},t.next=22,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,update:!0});case 22:return t.t6=t.sent,t.t7=(0,t.t4)(t.t5,t.t6),t.t8={method:"POST",path:t.t2,body:t.t3,bodyType:"BINARY",headers:t.t7,allowFailover:!1,allowRetry:!1},t.t9=t.t1.Request.call(t.t1,t.t8),t.next=28,t.t0.ResponseToJson.call(t.t0,t.t9);case 28:return t.abrupt("return",t.sent);case 29:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.FinalizeUploadJob=function(){var t=o(a.mark((function t(e){var n,r,i,o;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.writeToken,A({libraryId:n,objectId:r}),h(i),this.Log("Finalizing upload job: ".concat(n," ").concat(r," ").concat(i)),o=l("q",i,"files"),t.t0=this.HttpClient,t.t1=o,t.next=9,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,update:!0});case 9:return t.t2=t.sent,t.t3={method:"POST",path:t.t1,bodyType:"BINARY",headers:t.t2,allowFailover:!1},t.next=13,t.t0.Request.call(t.t0,t.t3);case 13:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.CreateFileDirectories=function(){var t=o(a.mark((function t(e){var n,r,i,o,s;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.writeToken,o=e.filePaths,A({libraryId:n,objectId:r}),h(i),this.Log("Creating Directories: ".concat(n," ").concat(r," ").concat(i)),this.Log(o),s=o.map((function(t){return{op:"add",type:"directory",path:t}})),t.next=8,this.CreateFileUploadJob({libraryId:n,objectId:r,writeToken:i,ops:s});case 8:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.MoveFiles=function(){var t=o(a.mark((function t(e){var n,r,i,o,s;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.writeToken,o=e.filePaths,A({libraryId:n,objectId:r}),h(i),this.Log("Moving Files: ".concat(n," ").concat(r," ").concat(i)),this.Log(o),s=o.map((function(t){return{op:"move",copy_move_source_path:t.path,path:t.to}})),t.next=8,this.CreateFileUploadJob({libraryId:n,objectId:r,writeToken:i,ops:s});case 8:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.DeleteFiles=function(){var t=o(a.mark((function t(e){var n,r,i,o,s;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.writeToken,o=e.filePaths,A({libraryId:n,objectId:r}),h(i),this.Log("Deleting Files: ".concat(n," ").concat(r," ").concat(i)),this.Log(o),s=o.map((function(t){return{op:"del",path:t}})),t.next=8,this.CreateFileUploadJob({libraryId:n,objectId:r,writeToken:i,ops:s});case 8:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.DownloadFile=function(){var t=o(a.mark((function t(e){var n,r,i,o,s,c,f,p,h,y,b,g,m,v,w,I,E,_,C,k,B,x=arguments;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.versionHash,o=e.writeToken,s=e.filePath,c=e.format,f=void 0===c?"arrayBuffer":c,p=e.chunked,h=void 0!==p&&p,y=e.chunkSize,b=e.clientSideDecryption,g=void 0!==b&&b,m=e.callback,A({libraryId:n,objectId:r,versionHash:i}),d("filePath",s),i&&(r=this.utils.DecodeVersionHash(i).objectId),t.next=6,this.ContentObjectMetadata({libraryId:n,objectId:r,versionHash:i,writeToken:o,metadataSubtree:l("files",s)});case 6:return v=t.sent,w=v&&v["."].encryption&&"cgck"===v["."].encryption.scheme,I=w?"cgck":void 0,E=w&&!g?l("q",o||i||r,"rep","files_download",s):l("q",o||i||r,"files",s),t.next=12,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,versionHash:i,encryption:I,makeAccessRequest:"cgck"===I});case 12:return(_=t.sent).Accept="*/*",C="eluv.caps.iusr".concat(this.utils.AddressToHash(this.signer.address)),t.next=17,this.ContentObjectMetadata({libraryId:n,objectId:r,versionHash:i,metadataSubtree:C});case 17:if(k=t.sent,t.t1=w,!t.t1){t.next=26;break}return t.t2=this.utils,t.t3=this.signer.address,t.next=24,this.ContentObjectOwner({objectId:r});case 24:t.t4=t.sent,t.t1=!t.t2.EqualAddress.call(t.t2,t.t3,t.t4);case 26:if(t.t0=t.t1,!t.t0){t.next=29;break}t.t0=!k;case 29:if(!t.t0){t.next=31;break}_["X-Content-Fabric-Decryption-Mode"]="reencrypt";case 31:if(w&&!g&&(_["X-Content-Fabric-Decryption-Mode"]="decrypt",y=Number.MAX_SAFE_INTEGER),B=v["."].size,!w||!g){t.next=51;break}return t.t5=this,t.next=37,this.EncryptionConk({libraryId:n,objectId:r,versionHash:i,download:!0});case 37:return t.t6=t.sent,t.t7=E,t.t8=B,t.t9=_,t.t10=m,t.t11=f,t.t12=g,t.t13=h,t.t14={conk:t.t6,downloadPath:t.t7,bytesTotal:t.t8,headers:t.t9,callback:t.t10,format:t.t11,clientSideDecryption:t.t12,chunked:t.t13},t.next=48,t.t5.DownloadEncrypted.call(t.t5,t.t14);case 48:return t.abrupt("return",t.sent);case 51:return y||(y=1e7),t.prev=52,t.next=55,this.Download({downloadPath:E,bytesTotal:B,headers:_,callback:m,format:f,chunked:h,chunkSize:y});case 55:return t.abrupt("return",t.sent);case 58:if(t.prev=58,t.t15=t.catch(52),!w||g){t.next=62;break}return t.abrupt("return",this.DownloadFile(u(u({},x[0]),{},{clientSideDecryption:!0})));case 62:throw t.t15;case 63:case"end":return t.stop()}}),t,this,[[52,58]])})));return function(e){return t.apply(this,arguments)}}(),e.ContentParts=function(){var t=o(a.mark((function t(e){var n,r,i,o,s;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.versionHash,A({libraryId:n,objectId:r,versionHash:i}),this.Log("Retrieving parts: ".concat(n," ").concat(r||i)),i&&(r=this.utils.DecodeVersionHash(i).objectId),o=l("q",i||r,"parts"),t.t0=this.utils,t.t1=this.HttpClient,t.next=9,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,versionHash:i});case 9:return t.t2=t.sent,t.t3=o,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 s=t.sent,t.abrupt("return",s.parts);case 17:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.ContentPart=function(){var t=o(a.mark((function t(e){var n,r,i,o,s;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.versionHash,o=e.partHash,A({libraryId:n,objectId:r,versionHash:i}),y(o),this.Log("Retrieving part: ".concat(n," ").concat(r||i," ").concat(o)),i&&(r=this.utils.DecodeVersionHash(i).objectId),s=l("q",i||r,"parts",o),t.t0=this.utils,t.t1=this.HttpClient,t.next=10,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,versionHash:i});case 10: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=16,t.t0.ResponseToJson.call(t.t0,t.t5);case 16:return t.abrupt("return",t.sent);case 17:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.DownloadPart=function(){var t=o(a.mark((function t(e){var n,r,i,o,s,u,c,f,p,d,h,b,g,m,v,w,I;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.versionHash,o=e.writeToken,s=e.partHash,u=e.format,c=void 0===u?"arrayBuffer":u,f=e.chunked,p=void 0!==f&&f,d=e.chunkSize,h=void 0===d?1e7:d,b=e.callback,A({libraryId:n,objectId:r,versionHash:i}),y(s),i&&(r=this.utils.DecodeVersionHash(i).objectId),g=s.startsWith("hqpe"),m=g?"cgck":void 0,v=l("q",o||i||r,"data",s),t.next=9,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,versionHash:i,encryption:m,makeAccessRequest:!0});case 9:return w=t.sent,t.next=12,this.ContentPart({libraryId:n,objectId:r,versionHash:i,partHash:s});case 12:if(I=t.sent.part.size,!g){t.next=37;break}return t.t0=this.utils,t.t1=this.signer.address,t.next=18,this.ContentObjectOwner({objectId:r});case 18:if(t.t2=t.sent,t.t0.EqualAddress.call(t.t0,t.t1,t.t2)){t.next=21;break}w["X-Content-Fabric-Decryption-Mode"]="reencrypt";case 21:return t.t3=this,t.next=24,this.EncryptionConk({libraryId:n,objectId:r,download:!0});case 24:return t.t4=t.sent,t.t5=v,t.t6=I,t.t7=w,t.t8=b,t.t9=c,t.t10=p,t.t11={conk:t.t4,downloadPath:t.t5,bytesTotal:t.t6,headers:t.t7,callback:t.t8,format:t.t9,chunked:t.t10},t.next=34,t.t3.DownloadEncrypted.call(t.t3,t.t11);case 34:return t.abrupt("return",t.sent);case 37:return t.next=39,this.Download({downloadPath:v,bytesTotal:I,headers:w,callback:b,format:c,chunked:p,chunkSize:h});case 39:return t.abrupt("return",t.sent);case 40:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.Download=function(){var e=o(a.mark((function e(n){var r,i,o,s,u,c,f,l,p,d,h,y,A,b,g;return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=n.downloadPath,i=n.headers,o=n.bytesTotal,s=n.chunked,u=void 0!==s&&s,c=n.chunkSize,f=void 0===c?2e6:c,l=n.callback,p=n.format,d=void 0===p?"arrayBuffer":p,!u||l){e.next=3;break}throw Error("No callback specified for chunked download");case 3:u||(h=[]),y=0,A=Math.ceil(o/f),b=0;case 7:if(!(b<A)){e.next=35;break}return i.Range="bytes=".concat(y,"-").concat(y+f-1),e.next=11,this.HttpClient.Request({path:r,headers:i,method:"GET"});case 11:if(g=e.sent,y=Math.min(y+f,o),!u){e.next=24;break}return e.t0=l,e.t1=y,e.t2=o,e.next=19,this.utils.ResponseToFormat(d,g);case 19:e.t3=e.sent,e.t4={bytesFinished:e.t1,bytesTotal:e.t2,chunk:e.t3},(0,e.t0)(e.t4),e.next=32;break;case 24:return e.t5=h,e.t6=t,e.next=28,g.arrayBuffer();case 28:e.t7=e.sent,e.t8=e.t6.from.call(e.t6,e.t7),e.t5.push.call(e.t5,e.t8),l&&l({bytesFinished:y,bytesTotal:o});case 32:b++,e.next=7;break;case 35:if(u){e.next=39;break}return e.next=38,this.utils.ResponseToFormat(d,new Response(t.concat(h)));case 38:return e.abrupt("return",e.sent);case 39:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),e.DownloadEncrypted=function(){var e=o(a.mark((function e(n){var r,i,s,u,c,f,l,p,d,h,y,A,b,g,m,v,w,I=this;return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=n.conk,i=n.downloadPath,s=n.bytesTotal,u=n.headers,c=n.callback,f=n.format,l=void 0===f?"arrayBuffer":f,p=n.chunked,!(d=void 0!==p&&p)||c){e.next=3;break}throw Error("No callback specified for chunked download");case 3:return h=r.public_key.startsWith("ktpk"),y=this.Crypto.EncryptedBlockSize(1e6,h),A=0,l=l.toLowerCase(),b=[],e.next=10,this.Crypto.OpenDecryptionStream(r);case 10:(g=e.sent).on("data",function(){var t=o(a.mark((function t(e){var n;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!d){t.next=13;break}if("buffer"===l){t.next=10;break}if(n=e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength),"arraybuffer"!==l){t.next=7;break}e=n,t.next=10;break;case 7:return t.next=9,I.utils.ResponseToFormat(l,new Response(n));case 9:e=t.sent;case 10:c({bytesFinished:A,bytesTotal:s,chunk:e}),t.next=15;break;case 13:c&&c({bytesFinished:A,bytesTotal:s}),b.push(e);case 15:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),m=Math.ceil(s/y),v=0;case 14:if(!(v<m)){e.next=30;break}return u.Range="bytes=".concat(A,"-").concat(A+y-1),e.next=18,this.HttpClient.Request({headers:u,method:"GET",path:i});case 18:return w=e.sent,A=Math.min(A+y,s),e.t0=g,e.t1=Uint8Array,e.next=24,w.arrayBuffer();case 24:e.t2=e.sent,e.t3=new e.t1(e.t2),e.t0.write.call(e.t0,e.t3);case 27:v++,e.next=14;break;case 30:return g.end(),e.next=33,new Promise((function(t){return g.on("finish",(function(){t()}))}));case 33:if(d){e.next=37;break}return e.next=36,this.utils.ResponseToFormat(l,new Response(t.concat(b)));case 36:return e.abrupt("return",e.sent);case 37:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),e.CreatePart=function(){var t=o(a.mark((function t(e){var n,r,i,o,s,u;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.writeToken,o=e.encryption,A({libraryId:n,objectId:r}),h(i),s=l("q",i,"parts"),t.t0=this.utils,t.t1=this.HttpClient,t.next=8,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,update:!0,encryption:o});case 8:return t.t2=t.sent,t.t3=s,t.t4={headers:t.t2,method:"POST",path:t.t3,bodyType:"BINARY",body:"",allowFailover:!1},t.t5=t.t1.Request.call(t.t1,t.t4),t.next=14,t.t0.ResponseToJson.call(t.t0,t.t5);case 14:return u=t.sent,t.abrupt("return",u.part.write_token);case 16:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.UploadPartChunk=function(){var t=o(a.mark((function t(e){var n,r,i,o,s,u,c,f;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,i=e.writeToken,o=e.partWriteToken,s=e.chunk,u=e.encryption,A({libraryId:n,objectId:r}),h(i),!u||"none"===u){t.next=10;break}return t.next=6,this.EncryptionConk({libraryId:n,objectId:r,writeToken:i});case 6:return c=t.sent,t.next=9,this.Crypto.Encrypt(c,s);case 9:s=t.sent;case 10:return f=l("q",i,"parts"),t.t0=this.utils,t.t1=this.HttpClient,t.next=15,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,update:!0,encryption:u});case 15:return t.t2=t.sent,t.t3=l(f,o),t.t4=s,t.t5={headers:t.t2,method:"POST",path:t.t3,body:t.t4,bodyType:"BINARY",allowFailover:!1},t.t6=t.t1.Request.call(t.t1,t.t5),t.next=22,t.t0.ResponseToJson.call(t.t0,t.t6);case 22:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.FinalizePart=function(){var t=o(a.mark((function t(e){var n,r,i,o,s,u;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.writeToken,o=e.partWriteToken,s=e.encryption,A({libraryId:n,objectId:r}),h(i),u=l("q",i,"parts"),t.t0=this.utils,t.t1=this.HttpClient,t.next=8,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,update:!0,encryption:s});case 8:return t.t2=t.sent,t.t3=l(u,o),t.t4={headers:t.t2,method:"POST",path:t.t3,bodyType:"BINARY",body:"",allowFailover:!1},t.next=13,t.t1.Request.call(t.t1,t.t4);case 13:return t.t5=t.sent,t.next=16,t.t0.ResponseToJson.call(t.t0,t.t5);case 16:return t.abrupt("return",t.sent);case 17:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.UploadPart=function(){var t=o(a.mark((function t(e){var n,r,i,o,s,u,c,f,l,p,d,y,b;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.writeToken,o=e.data,s=e.encryption,u=void 0===s?"none":s,c=e.chunkSize,f=void 0===c?1e7:c,l=e.callback,A({libraryId:n,objectId:r}),h(i),t.next=5,this.CreatePart({libraryId:n,objectId:r,writeToken:i,encryption:u});case 5:p=t.sent,d=o.length||o.byteLength||o.size,l&&l({bytesFinished:0,bytesTotal:d}),y=0;case 9:if(!(y<d)){t.next=17;break}return b=o.slice(y,y+f),t.next=13,this.UploadPartChunk({libraryId:n,objectId:r,writeToken:i,partWriteToken:p,chunk:b,encryption:u});case 13:l&&l({bytesFinished:Math.min(y+f,d),bytesTotal:d});case 14:y+=f,t.next=9;break;case 17:return t.next=19,this.FinalizePart({libraryId:n,objectId:r,writeToken:i,partWriteToken:p,encryption:u});case 19:return t.abrupt("return",t.sent);case 20:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.DeletePart=function(){var t=o(a.mark((function t(e){var n,r,i,o,s;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.writeToken,o=e.partHash,A({libraryId:n,objectId:r}),h(i),y(o),s=l("q",i,"parts",o),t.t0=this.HttpClient,t.next=8,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,update:!0});case 8:return t.t1=t.sent,t.t2=s,t.t3={headers:t.t1,method:"DELETE",path:t.t2,allowFailover:!1},t.next=13,t.t0.Request.call(t.t0,t.t3);case 13:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}()}).call(this,n(4).Buffer)},function(t,e){},function(t,e,n){"use strict";(function(t){n.d(e,"a",(function(){return G}));var r=n(2),i=n.n(r),a=n(12),o=n.n(a);function s(t){return(s="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)}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==t||"undefined"!=typeof self&&self;function u(t,e,n){return t(n={path:e,exports:{},require:function(t,e){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==e&&n.path)}},n.exports),n.exports}var c=f;function f(t,e){if(!t)throw new Error(e||"Assertion failed")}f.equal=function(t,e,n){if(t!=e)throw new Error(n||"Assertion failed: "+t+" != "+e)};var l=u((function(t,e){var n=e;function r(t){return 1===t.length?"0"+t:t}function i(t){for(var e="",n=0;n<t.length;n++)e+=r(t[n].toString(16));return e}n.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 i=t.charCodeAt(r),a=i>>8,o=255&i;a?n.push(a,o):n.push(o)}return n},n.zero2=r,n.toHex=i,n.encode=function(t,e){return"hex"===e?i(t):t}})),p=u((function(t,e){var n=e;n.assert=c,n.toArray=l.toArray,n.zero2=l.zero2,n.toHex=l.toHex,n.encode=l.encode,n.getNAF=function(t,e,n){var r=new Array(Math.max(t.bitLength(),n)+1);r.fill(0);for(var i=1<<e+1,a=t.clone(),o=0;o<r.length;o++){var s,u=a.andln(i-1);a.isOdd()?(s=u>(i>>1)-1?(i>>1)-u:u,a.isubn(s)):s=0,r[o]=s,a.iushrn(1)}return r},n.getJSF=function(t,e){var n=[[],[]];t=t.clone(),e=e.clone();for(var r,i=0,a=0;t.cmpn(-i)>0||e.cmpn(-a)>0;){var o,s,u=t.andln(3)+i&3,c=e.andln(3)+a&3;3===u&&(u=-1),3===c&&(c=-1),o=0==(1&u)?0:3!==(r=t.andln(7)+i&7)&&5!==r||2!==c?u:-u,n[0].push(o),s=0==(1&c)?0:3!==(r=e.andln(7)+a&7)&&5!==r||2!==u?c:-c,n[1].push(s),2*i===o+1&&(i=1-i),2*a===s+1&&(a=1-a),t.iushrn(1),e.iushrn(1)}return n},n.cachedProperty=function(t,e,n){var r="_"+e;t.prototype[e]=function(){return void 0!==this[r]?this[r]:this[r]=n.call(this)}},n.parseBytes=function(t){return"string"==typeof t?n.toArray(t,"hex"):t},n.intFromLE=function(t){return new i.a(t,"hex","le")}})),d=p.getNAF,h=p.getJSF,y=p.assert;function A(t,e){this.type=t,this.p=new i.a(e.p,16),this.red=e.prime?i.a.red(e.prime):i.a.mont(this.p),this.zero=new i.a(0).toRed(this.red),this.one=new i.a(1).toRed(this.red),this.two=new i.a(2).toRed(this.red),this.n=e.n&&new i.a(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var n=this.n&&this.p.div(this.n);!n||n.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var b=A;function g(t,e){this.curve=t,this.type=e,this.precomputed=null}A.prototype.point=function(){throw new Error("Not implemented")},A.prototype.validate=function(){throw new Error("Not implemented")},A.prototype._fixedNafMul=function(t,e){y(t.precomputed);var n=t._getDoubles(),r=d(e,1,this._bitLength),i=(1<<n.step+1)-(n.step%2==0?2:1);i/=3;var a,o,s=[];for(a=0;a<r.length;a+=n.step){o=0;for(var u=a+n.step-1;u>=a;u--)o=(o<<1)+r[u];s.push(o)}for(var c=this.jpoint(null,null,null),f=this.jpoint(null,null,null),l=i;l>0;l--){for(a=0;a<s.length;a++)(o=s[a])===l?f=f.mixedAdd(n.points[a]):o===-l&&(f=f.mixedAdd(n.points[a].neg()));c=c.add(f)}return c.toP()},A.prototype._wnafMul=function(t,e){var n=4,r=t._getNAFPoints(n);n=r.wnd;for(var i=r.points,a=d(e,n,this._bitLength),o=this.jpoint(null,null,null),s=a.length-1;s>=0;s--){for(var u=0;s>=0&&0===a[s];s--)u++;if(s>=0&&u++,o=o.dblp(u),s<0)break;var c=a[s];y(0!==c),o="affine"===t.type?c>0?o.mixedAdd(i[c-1>>1]):o.mixedAdd(i[-c-1>>1].neg()):c>0?o.add(i[c-1>>1]):o.add(i[-c-1>>1].neg())}return"affine"===t.type?o.toP():o},A.prototype._wnafMulAdd=function(t,e,n,r,i){var a,o,s,u=this._wnafT1,c=this._wnafT2,f=this._wnafT3,l=0;for(a=0;a<r;a++){var p=(s=e[a])._getNAFPoints(t);u[a]=p.wnd,c[a]=p.points}for(a=r-1;a>=1;a-=2){var y=a-1,A=a;if(1===u[y]&&1===u[A]){var b=[e[y],null,null,e[A]];0===e[y].y.cmp(e[A].y)?(b[1]=e[y].add(e[A]),b[2]=e[y].toJ().mixedAdd(e[A].neg())):0===e[y].y.cmp(e[A].y.redNeg())?(b[1]=e[y].toJ().mixedAdd(e[A]),b[2]=e[y].add(e[A].neg())):(b[1]=e[y].toJ().mixedAdd(e[A]),b[2]=e[y].toJ().mixedAdd(e[A].neg()));var g=[-3,-1,-5,-7,0,7,5,1,3],m=h(n[y],n[A]);for(l=Math.max(m[0].length,l),f[y]=new Array(l),f[A]=new Array(l),o=0;o<l;o++){var v=0|m[0][o],w=0|m[1][o];f[y][o]=g[3*(v+1)+(w+1)],f[A][o]=0,c[y]=b}}else f[y]=d(n[y],u[y],this._bitLength),f[A]=d(n[A],u[A],this._bitLength),l=Math.max(f[y].length,l),l=Math.max(f[A].length,l)}var I=this.jpoint(null,null,null),E=this._wnafT4;for(a=l;a>=0;a--){for(var _=0;a>=0;){var C=!0;for(o=0;o<r;o++)E[o]=0|f[o][a],0!==E[o]&&(C=!1);if(!C)break;_++,a--}if(a>=0&&_++,I=I.dblp(_),a<0)break;for(o=0;o<r;o++){var k=E[o];0!==k&&(k>0?s=c[o][k-1>>1]:k<0&&(s=c[o][-k-1>>1].neg()),I="affine"===s.type?I.mixedAdd(s):I.add(s))}}for(a=0;a<r;a++)c[a]=null;return i?I:I.toP()},A.BasePoint=g,g.prototype.eq=function(){throw new Error("Not implemented")},g.prototype.validate=function(){return this.curve.validate(this)},A.prototype.decodePoint=function(t,e){t=p.toArray(t,e);var n=this.p.byteLength();if((4===t[0]||6===t[0]||7===t[0])&&t.length-1==2*n)return 6===t[0]?y(t[t.length-1]%2==0):7===t[0]&&y(t[t.length-1]%2==1),this.point(t.slice(1,1+n),t.slice(1+n,1+2*n));if((2===t[0]||3===t[0])&&t.length-1===n)return this.pointFromX(t.slice(1,1+n),3===t[0]);throw new Error("Unknown point format")},g.prototype.encodeCompressed=function(t){return this.encode(t,!0)},g.prototype._encode=function(t){var e=this.curve.p.byteLength(),n=this.getX().toArray("be",e);return t?[this.getY().isEven()?2:3].concat(n):[4].concat(n,this.getY().toArray("be",e))},g.prototype.encode=function(t,e){return p.encode(this._encode(e),t)},g.prototype.precompute=function(t){if(this.precomputed)return this;var e={doubles:null,naf:null,beta:null};return e.naf=this._getNAFPoints(8),e.doubles=this._getDoubles(4,t),e.beta=this._getBeta(),this.precomputed=e,this},g.prototype._hasDoubles=function(t){if(!this.precomputed)return!1;var e=this.precomputed.doubles;return!!e&&e.points.length>=Math.ceil((t.bitLength()+1)/e.step)},g.prototype._getDoubles=function(t,e){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var n=[this],r=this,i=0;i<e;i+=t){for(var a=0;a<t;a++)r=r.dbl();n.push(r)}return{step:t,points:n}},g.prototype._getNAFPoints=function(t){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var e=[this],n=(1<<t)-1,r=1===n?null:this.dbl(),i=1;i<n;i++)e[i]=e[i-1].add(r);return{wnd:t,points:e}},g.prototype._getBeta=function(){return null},g.prototype.dblp=function(t){for(var e=this,n=0;n<t;n++)e=e.dbl();return e};var m=u((function(t){"function"==typeof Object.create?t.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(t,e){if(e){t.super_=e;var n=function(){};n.prototype=e.prototype,t.prototype=new n,t.prototype.constructor=t}}})),v=p.assert;function w(t){b.call(this,"short",t),this.a=new i.a(t.a,16).toRed(this.red),this.b=new i.a(t.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(t),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}m(w,b);var I=w;function E(t,e,n,r){b.BasePoint.call(this,t,"affine"),null===e&&null===n?(this.x=null,this.y=null,this.inf=!0):(this.x=new i.a(e,16),this.y=new i.a(n,16),r&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function _(t,e,n,r){b.BasePoint.call(this,t,"jacobian"),null===e&&null===n&&null===r?(this.x=this.curve.one,this.y=this.curve.one,this.z=new i.a(0)):(this.x=new i.a(e,16),this.y=new i.a(n,16),this.z=new i.a(r,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}w.prototype._getEndomorphism=function(t){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var e,n;if(t.beta)e=new i.a(t.beta,16).toRed(this.red);else{var r=this._getEndoRoots(this.p);e=(e=r[0].cmp(r[1])<0?r[0]:r[1]).toRed(this.red)}if(t.lambda)n=new i.a(t.lambda,16);else{var a=this._getEndoRoots(this.n);0===this.g.mul(a[0]).x.cmp(this.g.x.redMul(e))?n=a[0]:(n=a[1],v(0===this.g.mul(n).x.cmp(this.g.x.redMul(e))))}return{beta:e,lambda:n,basis:t.basis?t.basis.map((function(t){return{a:new i.a(t.a,16),b:new i.a(t.b,16)}})):this._getEndoBasis(n)}}},w.prototype._getEndoRoots=function(t){var e=t===this.p?this.red:i.a.mont(t),n=new i.a(2).toRed(e).redInvm(),r=n.redNeg(),a=new i.a(3).toRed(e).redNeg().redSqrt().redMul(n);return[r.redAdd(a).fromRed(),r.redSub(a).fromRed()]},w.prototype._getEndoBasis=function(t){for(var e,n,r,a,o,s,u,c,f,l=this.n.ushrn(Math.floor(this.n.bitLength()/2)),p=t,d=this.n.clone(),h=new i.a(1),y=new i.a(0),A=new i.a(0),b=new i.a(1),g=0;0!==p.cmpn(0);){var m=d.div(p);c=d.sub(m.mul(p)),f=A.sub(m.mul(h));var v=b.sub(m.mul(y));if(!r&&c.cmp(l)<0)e=u.neg(),n=h,r=c.neg(),a=f;else if(r&&2==++g)break;u=c,d=p,p=c,A=h,h=f,b=y,y=v}o=c.neg(),s=f;var w=r.sqr().add(a.sqr());return o.sqr().add(s.sqr()).cmp(w)>=0&&(o=e,s=n),r.negative&&(r=r.neg(),a=a.neg()),o.negative&&(o=o.neg(),s=s.neg()),[{a:r,b:a},{a:o,b:s}]},w.prototype._endoSplit=function(t){var e=this.endo.basis,n=e[0],r=e[1],i=r.b.mul(t).divRound(this.n),a=n.b.neg().mul(t).divRound(this.n),o=i.mul(n.a),s=a.mul(r.a),u=i.mul(n.b),c=a.mul(r.b);return{k1:t.sub(o).sub(s),k2:u.add(c).neg()}},w.prototype.pointFromX=function(t,e){(t=new i.a(t,16)).red||(t=t.toRed(this.red));var n=t.redSqr().redMul(t).redIAdd(t.redMul(this.a)).redIAdd(this.b),r=n.redSqrt();if(0!==r.redSqr().redSub(n).cmp(this.zero))throw new Error("invalid point");var a=r.fromRed().isOdd();return(e&&!a||!e&&a)&&(r=r.redNeg()),this.point(t,r)},w.prototype.validate=function(t){if(t.inf)return!0;var e=t.x,n=t.y,r=this.a.redMul(e),i=e.redSqr().redMul(e).redIAdd(r).redIAdd(this.b);return 0===n.redSqr().redISub(i).cmpn(0)},w.prototype._endoWnafMulAdd=function(t,e,n){for(var r=this._endoWnafT1,i=this._endoWnafT2,a=0;a<t.length;a++){var o=this._endoSplit(e[a]),s=t[a],u=s._getBeta();o.k1.negative&&(o.k1.ineg(),s=s.neg(!0)),o.k2.negative&&(o.k2.ineg(),u=u.neg(!0)),r[2*a]=s,r[2*a+1]=u,i[2*a]=o.k1,i[2*a+1]=o.k2}for(var c=this._wnafMulAdd(1,r,i,2*a,n),f=0;f<2*a;f++)r[f]=null,i[f]=null;return c},m(E,b.BasePoint),w.prototype.point=function(t,e,n){return new E(this,t,e,n)},w.prototype.pointFromJSON=function(t,e){return E.fromJSON(this,t,e)},E.prototype._getBeta=function(){if(this.curve.endo){var t=this.precomputed;if(t&&t.beta)return t.beta;var e=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(t){var n=this.curve,r=function(t){return n.point(t.x.redMul(n.endo.beta),t.y)};t.beta=e,e.precomputed={beta:null,naf:t.naf&&{wnd:t.naf.wnd,points:t.naf.points.map(r)},doubles:t.doubles&&{step:t.doubles.step,points:t.doubles.points.map(r)}}}return e}},E.prototype.toJSON=function(){return this.precomputed?[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]:[this.x,this.y]},E.fromJSON=function(t,e,n){"string"==typeof e&&(e=JSON.parse(e));var r=t.point(e[0],e[1],n);if(!e[2])return r;function i(e){return t.point(e[0],e[1],n)}var a=e[2];return r.precomputed={beta:null,doubles:a.doubles&&{step:a.doubles.step,points:[r].concat(a.doubles.points.map(i))},naf:a.naf&&{wnd:a.naf.wnd,points:[r].concat(a.naf.points.map(i))}},r},E.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+">"},E.prototype.isInfinity=function(){return this.inf},E.prototype.add=function(t){if(this.inf)return t;if(t.inf)return this;if(this.eq(t))return this.dbl();if(this.neg().eq(t))return this.curve.point(null,null);if(0===this.x.cmp(t.x))return this.curve.point(null,null);var e=this.y.redSub(t.y);0!==e.cmpn(0)&&(e=e.redMul(this.x.redSub(t.x).redInvm()));var n=e.redSqr().redISub(this.x).redISub(t.x),r=e.redMul(this.x.redSub(n)).redISub(this.y);return this.curve.point(n,r)},E.prototype.dbl=function(){if(this.inf)return this;var t=this.y.redAdd(this.y);if(0===t.cmpn(0))return this.curve.point(null,null);var e=this.curve.a,n=this.x.redSqr(),r=t.redInvm(),i=n.redAdd(n).redIAdd(n).redIAdd(e).redMul(r),a=i.redSqr().redISub(this.x.redAdd(this.x)),o=i.redMul(this.x.redSub(a)).redISub(this.y);return this.curve.point(a,o)},E.prototype.getX=function(){return this.x.fromRed()},E.prototype.getY=function(){return this.y.fromRed()},E.prototype.mul=function(t){return t=new i.a(t,16),this.isInfinity()?this:this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve.endo?this.curve._endoWnafMulAdd([this],[t]):this.curve._wnafMul(this,t)},E.prototype.mulAdd=function(t,e,n){var r=[this,e],i=[t,n];return this.curve.endo?this.curve._endoWnafMulAdd(r,i):this.curve._wnafMulAdd(1,r,i,2)},E.prototype.jmulAdd=function(t,e,n){var r=[this,e],i=[t,n];return this.curve.endo?this.curve._endoWnafMulAdd(r,i,!0):this.curve._wnafMulAdd(1,r,i,2,!0)},E.prototype.eq=function(t){return this===t||this.inf===t.inf&&(this.inf||0===this.x.cmp(t.x)&&0===this.y.cmp(t.y))},E.prototype.neg=function(t){if(this.inf)return this;var e=this.curve.point(this.x,this.y.redNeg());if(t&&this.precomputed){var n=this.precomputed,r=function(t){return t.neg()};e.precomputed={naf:n.naf&&{wnd:n.naf.wnd,points:n.naf.points.map(r)},doubles:n.doubles&&{step:n.doubles.step,points:n.doubles.points.map(r)}}}return e},E.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},m(_,b.BasePoint),w.prototype.jpoint=function(t,e,n){return new _(this,t,e,n)},_.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var t=this.z.redInvm(),e=t.redSqr(),n=this.x.redMul(e),r=this.y.redMul(e).redMul(t);return this.curve.point(n,r)},_.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},_.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.z.redSqr(),n=this.z.redSqr(),r=this.x.redMul(e),i=t.x.redMul(n),a=this.y.redMul(e.redMul(t.z)),o=t.y.redMul(n.redMul(this.z)),s=r.redSub(i),u=a.redSub(o);if(0===s.cmpn(0))return 0!==u.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=s.redSqr(),f=c.redMul(s),l=r.redMul(c),p=u.redSqr().redIAdd(f).redISub(l).redISub(l),d=u.redMul(l.redISub(p)).redISub(a.redMul(f)),h=this.z.redMul(t.z).redMul(s);return this.curve.jpoint(p,d,h)},_.prototype.mixedAdd=function(t){if(this.isInfinity())return t.toJ();if(t.isInfinity())return this;var e=this.z.redSqr(),n=this.x,r=t.x.redMul(e),i=this.y,a=t.y.redMul(e).redMul(this.z),o=n.redSub(r),s=i.redSub(a);if(0===o.cmpn(0))return 0!==s.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=o.redSqr(),c=u.redMul(o),f=n.redMul(u),l=s.redSqr().redIAdd(c).redISub(f).redISub(f),p=s.redMul(f.redISub(l)).redISub(i.redMul(c)),d=this.z.redMul(o);return this.curve.jpoint(l,p,d)},_.prototype.dblp=function(t){if(0===t)return this;if(this.isInfinity())return this;if(!t)return this.dbl();var e;if(this.curve.zeroA||this.curve.threeA){var n=this;for(e=0;e<t;e++)n=n.dbl();return n}var r=this.curve.a,i=this.curve.tinv,a=this.x,o=this.y,s=this.z,u=s.redSqr().redSqr(),c=o.redAdd(o);for(e=0;e<t;e++){var f=a.redSqr(),l=c.redSqr(),p=l.redSqr(),d=f.redAdd(f).redIAdd(f).redIAdd(r.redMul(u)),h=a.redMul(l),y=d.redSqr().redISub(h.redAdd(h)),A=h.redISub(y),b=d.redMul(A);b=b.redIAdd(b).redISub(p);var g=c.redMul(s);e+1<t&&(u=u.redMul(p)),a=y,s=g,c=b}return this.curve.jpoint(a,c.redMul(i),s)},_.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},_.prototype._zeroDbl=function(){var t,e,n;if(this.zOne){var r=this.x.redSqr(),i=this.y.redSqr(),a=i.redSqr(),o=this.x.redAdd(i).redSqr().redISub(r).redISub(a);o=o.redIAdd(o);var s=r.redAdd(r).redIAdd(r),u=s.redSqr().redISub(o).redISub(o),c=a.redIAdd(a);c=(c=c.redIAdd(c)).redIAdd(c),t=u,e=s.redMul(o.redISub(u)).redISub(c),n=this.y.redAdd(this.y)}else{var f=this.x.redSqr(),l=this.y.redSqr(),p=l.redSqr(),d=this.x.redAdd(l).redSqr().redISub(f).redISub(p);d=d.redIAdd(d);var h=f.redAdd(f).redIAdd(f),y=h.redSqr(),A=p.redIAdd(p);A=(A=A.redIAdd(A)).redIAdd(A),t=y.redISub(d).redISub(d),e=h.redMul(d.redISub(t)).redISub(A),n=(n=this.y.redMul(this.z)).redIAdd(n)}return this.curve.jpoint(t,e,n)},_.prototype._threeDbl=function(){var t,e,n;if(this.zOne){var r=this.x.redSqr(),i=this.y.redSqr(),a=i.redSqr(),o=this.x.redAdd(i).redSqr().redISub(r).redISub(a);o=o.redIAdd(o);var s=r.redAdd(r).redIAdd(r).redIAdd(this.curve.a),u=s.redSqr().redISub(o).redISub(o);t=u;var c=a.redIAdd(a);c=(c=c.redIAdd(c)).redIAdd(c),e=s.redMul(o.redISub(u)).redISub(c),n=this.y.redAdd(this.y)}else{var f=this.z.redSqr(),l=this.y.redSqr(),p=this.x.redMul(l),d=this.x.redSub(f).redMul(this.x.redAdd(f));d=d.redAdd(d).redIAdd(d);var h=p.redIAdd(p),y=(h=h.redIAdd(h)).redAdd(h);t=d.redSqr().redISub(y),n=this.y.redAdd(this.z).redSqr().redISub(l).redISub(f);var A=l.redSqr();A=(A=(A=A.redIAdd(A)).redIAdd(A)).redIAdd(A),e=d.redMul(h.redISub(t)).redISub(A)}return this.curve.jpoint(t,e,n)},_.prototype._dbl=function(){var t=this.curve.a,e=this.x,n=this.y,r=this.z,i=r.redSqr().redSqr(),a=e.redSqr(),o=n.redSqr(),s=a.redAdd(a).redIAdd(a).redIAdd(t.redMul(i)),u=e.redAdd(e),c=(u=u.redIAdd(u)).redMul(o),f=s.redSqr().redISub(c.redAdd(c)),l=c.redISub(f),p=o.redSqr();p=(p=(p=p.redIAdd(p)).redIAdd(p)).redIAdd(p);var d=s.redMul(l).redISub(p),h=n.redAdd(n).redMul(r);return this.curve.jpoint(f,d,h)},_.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var t=this.x.redSqr(),e=this.y.redSqr(),n=this.z.redSqr(),r=e.redSqr(),i=t.redAdd(t).redIAdd(t),a=i.redSqr(),o=this.x.redAdd(e).redSqr().redISub(t).redISub(r),s=(o=(o=(o=o.redIAdd(o)).redAdd(o).redIAdd(o)).redISub(a)).redSqr(),u=r.redIAdd(r);u=(u=(u=u.redIAdd(u)).redIAdd(u)).redIAdd(u);var c=i.redIAdd(o).redSqr().redISub(a).redISub(s).redISub(u),f=e.redMul(c);f=(f=f.redIAdd(f)).redIAdd(f);var l=this.x.redMul(s).redISub(f);l=(l=l.redIAdd(l)).redIAdd(l);var p=this.y.redMul(c.redMul(u.redISub(c)).redISub(o.redMul(s)));p=(p=(p=p.redIAdd(p)).redIAdd(p)).redIAdd(p);var d=this.z.redAdd(o).redSqr().redISub(n).redISub(s);return this.curve.jpoint(l,p,d)},_.prototype.mul=function(t,e){return t=new i.a(t,e),this.curve._wnafMul(this,t)},_.prototype.eq=function(t){if("affine"===t.type)return this.eq(t.toJ());if(this===t)return!0;var e=this.z.redSqr(),n=t.z.redSqr();if(0!==this.x.redMul(n).redISub(t.x.redMul(e)).cmpn(0))return!1;var r=e.redMul(this.z),i=n.redMul(t.z);return 0===this.y.redMul(i).redISub(t.y.redMul(r)).cmpn(0)},_.prototype.eqXToP=function(t){var e=this.z.redSqr(),n=t.toRed(this.curve.red).redMul(e);if(0===this.x.cmp(n))return!0;for(var r=t.clone(),i=this.curve.redN.redMul(e);;){if(r.iadd(this.curve.n),r.cmp(this.curve.p)>=0)return!1;if(n.redIAdd(i),0===this.x.cmp(n))return!0}},_.prototype.inspect=function(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"},_.prototype.isInfinity=function(){return 0===this.z.cmpn(0)};var C=u((function(t,e){var n=e;n.base=b,n.short=I,n.mont=null,n.edwards=null})),k=u((function(t,e){var n,r=e,i=p.assert;function a(t){"short"===t.type?this.curve=new C.short(t):"edwards"===t.type?this.curve=new C.edwards(t):this.curve=new C.mont(t),this.g=this.curve.g,this.n=this.curve.n,this.hash=t.hash,i(this.g.validate(),"Invalid curve"),i(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function s(t,e){Object.defineProperty(r,t,{configurable:!0,enumerable:!0,get:function(){var n=new a(e);return Object.defineProperty(r,t,{configurable:!0,enumerable:!0,value:n}),n}})}r.PresetCurve=a,s("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:o.a.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),s("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:o.a.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),s("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:o.a.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),s("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:o.a.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),s("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:o.a.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),s("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.a.sha256,gRed:!1,g:["9"]}),s("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.a.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{n=null.crash()}catch(t){n=void 0}s("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:o.a.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",n]})}));function B(t){if(!(this instanceof B))return new B(t);this.hash=t.hash,this.predResist=!!t.predResist,this.outLen=this.hash.outSize,this.minEntropy=t.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=l.toArray(t.entropy,t.entropyEnc||"hex"),n=l.toArray(t.nonce,t.nonceEnc||"hex"),r=l.toArray(t.pers,t.persEnc||"hex");c(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,n,r)}var x=B;B.prototype._init=function(t,e,n){var r=t.concat(e).concat(n);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i<this.V.length;i++)this.K[i]=0,this.V[i]=1;this._update(r),this._reseed=1,this.reseedInterval=281474976710656},B.prototype._hmac=function(){return new o.a.hmac(this.hash,this.K)},B.prototype._update=function(t){var e=this._hmac().update(this.V).update([0]);t&&(e=e.update(t)),this.K=e.digest(),this.V=this._hmac().update(this.V).digest(),t&&(this.K=this._hmac().update(this.V).update([1]).update(t).digest(),this.V=this._hmac().update(this.V).digest())},B.prototype.reseed=function(t,e,n,r){"string"!=typeof e&&(r=n,n=e,e=null),t=l.toArray(t,e),n=l.toArray(n,r),c(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(t.concat(n||[])),this._reseed=1},B.prototype.generate=function(t,e,n,r){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof e&&(r=n,n=e,e=null),n&&(n=l.toArray(n,r||"hex"),this._update(n));for(var i=[];i.length<t;)this.V=this._hmac().update(this.V).digest(),i=i.concat(this.V);var a=i.slice(0,t);return this._update(n),this._reseed++,l.encode(a,e)};var S=p.assert;function Q(t,e){this.ec=t,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}var M=Q;Q.fromPublic=function(t,e,n){return e instanceof Q?e:new Q(t,{pub:e,pubEnc:n})},Q.fromPrivate=function(t,e,n){return e instanceof Q?e:new Q(t,{priv:e,privEnc:n})},Q.prototype.validate=function(){var t=this.getPublic();return t.isInfinity()?{result:!1,reason:"Invalid public key"}:t.validate()?t.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},Q.prototype.getPublic=function(t,e){return"string"==typeof t&&(e=t,t=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),e?this.pub.encode(e,t):this.pub},Q.prototype.getPrivate=function(t){return"hex"===t?this.priv.toString(16,2):this.priv},Q.prototype._importPrivate=function(t,e){this.priv=new i.a(t,e||16),this.priv=this.priv.umod(this.ec.curve.n)},Q.prototype._importPublic=function(t,e){if(t.x||t.y)return"mont"===this.ec.curve.type?S(t.x,"Need x coordinate"):"short"!==this.ec.curve.type&&"edwards"!==this.ec.curve.type||S(t.x&&t.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(t.x,t.y));this.pub=this.ec.curve.decodePoint(t,e)},Q.prototype.derive=function(t){return t.validate()||S(t.validate(),"public point not validated"),t.mul(this.priv).getX()},Q.prototype.sign=function(t,e,n){return this.ec.sign(t,this,e,n)},Q.prototype.verify=function(t,e){return this.ec.verify(t,e,this)},Q.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"};var R=p.assert;function O(t,e){if(t instanceof O)return t;this._importDER(t,e)||(R(t.r&&t.s,"Signature without r or s"),this.r=new i.a(t.r,16),this.s=new i.a(t.s,16),void 0===t.recoveryParam?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}var j=O;function T(){this.place=0}function P(t,e){var n=t[e.place++];if(!(128&n))return n;var r=15&n;if(0===r||r>4)return!1;for(var i=0,a=0,o=e.place;a<r;a++,o++)i<<=8,i|=t[o],i>>>=0;return!(i<=127)&&(e.place=o,i)}function D(t){for(var e=0,n=t.length-1;!t[e]&&!(128&t[e+1])&&e<n;)e++;return 0===e?t:t.slice(e)}function N(t,e){if(e<128)t.push(e);else{var n=1+(Math.log(e)/Math.LN2>>>3);for(t.push(128|n);--n;)t.push(e>>>(n<<3)&255);t.push(e)}}O.prototype._importDER=function(t,e){t=p.toArray(t,e);var n=new T;if(48!==t[n.place++])return!1;var r=P(t,n);if(!1===r)return!1;if(r+n.place!==t.length)return!1;if(2!==t[n.place++])return!1;var a=P(t,n);if(!1===a)return!1;var o=t.slice(n.place,a+n.place);if(n.place+=a,2!==t[n.place++])return!1;var s=P(t,n);if(!1===s)return!1;if(t.length!==s+n.place)return!1;var u=t.slice(n.place,s+n.place);if(0===o[0]){if(!(128&o[1]))return!1;o=o.slice(1)}if(0===u[0]){if(!(128&u[1]))return!1;u=u.slice(1)}return this.r=new i.a(o),this.s=new i.a(u),this.recoveryParam=null,!0},O.prototype.toDER=function(t){var e=this.r.toArray(),n=this.s.toArray();for(128&e[0]&&(e=[0].concat(e)),128&n[0]&&(n=[0].concat(n)),e=D(e),n=D(n);!(n[0]||128&n[1]);)n=n.slice(1);var r=[2];N(r,e.length),(r=r.concat(e)).push(2),N(r,n.length);var i=r.concat(n),a=[48];return N(a,i.length),a=a.concat(i),p.encode(a,t)};var L=function(){throw new Error("unsupported")},F=p.assert;function U(t){if(!(this instanceof U))return new U(t);"string"==typeof t&&(F(Object.prototype.hasOwnProperty.call(k,t),"Unknown curve "+t),t=k[t]),t instanceof k.PresetCurve&&(t={curve:t}),this.curve=t.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=t.curve.g,this.g.precompute(t.curve.n.bitLength()+1),this.hash=t.hash||t.curve.hash}var H=U;U.prototype.keyPair=function(t){return new M(this,t)},U.prototype.keyFromPrivate=function(t,e){return M.fromPrivate(this,t,e)},U.prototype.keyFromPublic=function(t,e){return M.fromPublic(this,t,e)},U.prototype.genKeyPair=function(t){t||(t={});for(var e=new x({hash:this.hash,pers:t.pers,persEnc:t.persEnc||"utf8",entropy:t.entropy||L(this.hash.hmacStrength),entropyEnc:t.entropy&&t.entropyEnc||"utf8",nonce:this.n.toArray()}),n=this.n.byteLength(),r=this.n.sub(new i.a(2));;){var a=new i.a(e.generate(n));if(!(a.cmp(r)>0))return a.iaddn(1),this.keyFromPrivate(a)}},U.prototype._truncateToN=function(t,e){var n=8*t.byteLength()-this.n.bitLength();return n>0&&(t=t.ushrn(n)),!e&&t.cmp(this.n)>=0?t.sub(this.n):t},U.prototype.sign=function(t,e,n,r){"object"===s(n)&&(r=n,n=null),r||(r={}),e=this.keyFromPrivate(e,n),t=this._truncateToN(new i.a(t,16));for(var a=this.n.byteLength(),o=e.getPrivate().toArray("be",a),u=t.toArray("be",a),c=new x({hash:this.hash,entropy:o,nonce:u,pers:r.pers,persEnc:r.persEnc||"utf8"}),f=this.n.sub(new i.a(1)),l=0;;l++){var p=r.k?r.k(l):new i.a(c.generate(this.n.byteLength()));if(!((p=this._truncateToN(p,!0)).cmpn(1)<=0||p.cmp(f)>=0)){var d=this.g.mul(p);if(!d.isInfinity()){var h=d.getX(),y=h.umod(this.n);if(0!==y.cmpn(0)){var A=p.invm(this.n).mul(y.mul(e.getPrivate()).iadd(t));if(0!==(A=A.umod(this.n)).cmpn(0)){var b=(d.getY().isOdd()?1:0)|(0!==h.cmp(y)?2:0);return r.canonical&&A.cmp(this.nh)>0&&(A=this.n.sub(A),b^=1),new j({r:y,s:A,recoveryParam:b})}}}}}},U.prototype.verify=function(t,e,n,r){t=this._truncateToN(new i.a(t,16)),n=this.keyFromPublic(n,r);var a=(e=new j(e,"hex")).r,o=e.s;if(a.cmpn(1)<0||a.cmp(this.n)>=0)return!1;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var s,u=o.invm(this.n),c=u.mul(t).umod(this.n),f=u.mul(a).umod(this.n);return this.curve._maxwellTrick?!(s=this.g.jmulAdd(c,n.getPublic(),f)).isInfinity()&&s.eqXToP(a):!(s=this.g.mulAdd(c,n.getPublic(),f)).isInfinity()&&0===s.getX().umod(this.n).cmp(a)},U.prototype.recoverPubKey=function(t,e,n,r){F((3&n)===n,"The recovery param is more than two bits"),e=new j(e,r);var a=this.n,o=new i.a(t),s=e.r,u=e.s,c=1&n,f=n>>1;if(s.cmp(this.curve.p.umod(this.curve.n))>=0&&f)throw new Error("Unable to find sencond key candinate");s=f?this.curve.pointFromX(s.add(this.curve.n),c):this.curve.pointFromX(s,c);var l=e.r.invm(a),p=a.sub(o).mul(l).umod(a),d=u.mul(l).umod(a);return this.g.mulAdd(p,s,d)},U.prototype.getKeyRecoveryParam=function(t,e,n,r){if(null!==(e=new j(e,r)).recoveryParam)return e.recoveryParam;for(var i=0;i<4;i++){var a;try{a=this.recoverPubKey(t,e,i)}catch(t){continue}if(a.eq(n))return i}throw new Error("Unable to find valid recovery factor")};var G=u((function(t,e){var n=e;n.version="6.5.4",n.utils=p,n.rand=function(){throw new Error("unsupported")},n.curve=C,n.curves=k,n.ec=H,n.eddsa=null})).ec}).call(this,n(8))},function(t,e,n){(function(t,r,i){var a;function o(t){return(o="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)}
49
+ */!function(o,s){"use strict";"object"===a(t)&&t.exports?t.exports=s():void 0===(i="function"==typeof(r=s)?r.call(e,n,e,t):r)||(t.exports=i)}(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 i=n.list[t.slice(e+1)];return!!i&&i.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 i=n.list[t.slice(e+1)];return i?i.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(26)(t))},function(t,e,n){"use strict";var r=n(27).rotr32;function i(t,e,n){return t&e^~t&n}function a(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?i(e,n,r):1===t||3===t?o(e,n,r):2===t?a(e,n,r):void 0},e.ch32=i,e.maj32=a,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(27),i=n(56),a=n(122),o=n(19),s=r.sum32,u=r.sum32_4,c=r.sum32_5,f=a.ch32,l=a.maj32,p=a.s0_256,d=a.s1_256,h=a.g0_256,y=a.g1_256,A=i.BlockHash,b=[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 g(){if(!(this instanceof g))return new g;A.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=b,this.W=new Array(64)}r.inherits(g,A),t.exports=g,g.blockSize=512,g.outSize=256,g.hmacStrength=192,g.padLength=64,g.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(y(n[r-2]),n[r-7],h(n[r-15]),n[r-16]);var i=this.h[0],a=this.h[1],A=this.h[2],b=this.h[3],g=this.h[4],m=this.h[5],v=this.h[6],w=this.h[7];for(o(this.k.length===n.length),r=0;r<n.length;r++){var I=c(w,d(g),f(g,m,v),this.k[r],n[r]),E=s(p(i),l(i,a,A));w=v,v=m,m=g,g=s(b,I),b=A,A=a,a=i,i=s(I,E)}this.h[0]=s(this.h[0],i),this.h[1]=s(this.h[1],a),this.h[2]=s(this.h[2],A),this.h[3]=s(this.h[3],b),this.h[4]=s(this.h[4],g),this.h[5]=s(this.h[5],m),this.h[6]=s(this.h[6],v),this.h[7]=s(this.h[7],w)},g.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(27),i=n(56),a=n(19),o=r.rotr64_hi,s=r.rotr64_lo,u=r.shr64_hi,c=r.shr64_lo,f=r.sum64,l=r.sum64_hi,p=r.sum64_lo,d=r.sum64_4_hi,h=r.sum64_4_lo,y=r.sum64_5_hi,A=r.sum64_5_lo,b=i.BlockHash,g=[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;b.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=g,this.W=new Array(160)}function v(t,e,n,r,i){var a=t&n^~t&i;return a<0&&(a+=4294967296),a}function w(t,e,n,r,i,a){var o=e&r^~e&a;return o<0&&(o+=4294967296),o}function I(t,e,n,r,i){var a=t&n^t&i^n&i;return a<0&&(a+=4294967296),a}function E(t,e,n,r,i,a){var o=e&r^e&a^r&a;return o<0&&(o+=4294967296),o}function _(t,e){var n=o(t,e,28)^o(e,t,2)^o(e,t,7);return n<0&&(n+=4294967296),n}function C(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 B(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 Q(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,b),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 i=Q(n[r-4],n[r-3]),a=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],l=n[r-31];n[r]=d(i,a,o,s,u,c,f,l),n[r+1]=h(i,a,o,s,u,c,f,l)}},m.prototype._update=function(t,e){this._prepareBlock(t,e);var n=this.W,r=this.h[0],i=this.h[1],o=this.h[2],s=this.h[3],u=this.h[4],c=this.h[5],d=this.h[6],h=this.h[7],b=this.h[8],g=this.h[9],m=this.h[10],x=this.h[11],S=this.h[12],Q=this.h[13],M=this.h[14],R=this.h[15];a(this.k.length===n.length);for(var O=0;O<n.length;O+=2){var j=M,T=R,P=k(b,g),D=B(b,g),N=v(b,g,m,x,S),L=w(b,g,m,x,S,Q),F=this.k[O],U=this.k[O+1],H=n[O],G=n[O+1],q=y(j,T,P,D,N,L,F,U,H,G),K=A(j,T,P,D,N,L,F,U,H,G);j=_(r,i),T=C(r,i),P=I(r,i,o,s,u),D=E(r,i,o,s,u,c);var Y=l(j,T,P,D),z=p(j,T,P,D);M=S,R=Q,S=m,Q=x,m=b,x=g,b=l(d,h,q,K),g=p(h,h,q,K),d=u,h=c,u=o,c=s,o=r,s=i,r=l(q,K,Y,z),i=p(q,K,Y,z)}f(this.h,0,r,i),f(this.h,2,o,s),f(this.h,4,u,c),f(this.h,6,d,h),f(this.h,8,b,g),f(this.h,10,m,x),f(this.h,12,S,Q),f(this.h,14,M,R)},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,i=Function.prototype.apply;function a(t,e){this._id=t,this._clearFn=e}e.setTimeout=function(){return new a(i.call(setTimeout,r,arguments),clearTimeout)},e.setInterval=function(){return new a(i.call(setInterval,r,arguments),clearInterval)},e.clearTimeout=e.clearInterval=function(t){t&&t.close()},a.prototype.unref=a.prototype.ref=function(){},a.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(232),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(8))},function(t,e,n){var r=n(238);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){(function(t){var r=n(36),i=n(18),a=n(17),o=n(9),s=n(10);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){a(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(30),l=n(267),p=n(41),d=n(31),h=d.ValidateLibrary,y=d.ValidateObject,A=d.ValidateVersion,b=d.ValidatePartHash,g=d.ValidateWriteToken,m=d.ValidateParameters,v=n(268);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,i,a=this;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.id,r=e.clearCache,t.prev=1,i=this.utils.HashToAddress(n),r&&delete this.visibilityInfo[i],this.visibilityInfo[i]||(this.visibilityInfo[i]=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,a.authClient.ContractHasMethod({contractAddress:i,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,a.CallContractMethod({contractAddress:a.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[i];case 8:return t.abrupt("return",t.sent);case 11:throw t.prev=11,t.t0=t.catch(5),delete this.visibilityInfo[i],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,i,a,s,u,c,f,l=this;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.objectId,r=e.clearCache,y(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 i=t.sent,t.next=13,this.CallContractMethod({contractAddress:this.utils.HashToAddress(n),methodName:"addressKMS"});case 13:if(a=t.sent,s=a&&"ikms".concat(this.utils.AddressToHash(a)),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=l.permissionLevels[t].settings;return i>=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,i=arguments;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e=i.length>0&&void 0!==i[0]?i[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,i,a;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.name,r=e.typeId,i=e.versionHash,t.next=3,this.ContentType({name:n,typeId:r,versionHash:i});case 3:return a=t.sent,t.t0=this.utils,t.next=7,this.ethClient.CallContractMethod({contractAddress:this.utils.HashToAddress(a.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,i,a,s,u,c;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.name,r=e.typeId,i=e.versionHash,a=e.publicOnly,s=void 0!==a&&a,this.Log("Retrieving content type: ".concat(n||r||i)),i&&(r=this.utils.DecodeVersionHash(i).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===i})));case 23:if(i){t.next=27;break}return t.next=26,this.LatestVersionHash({objectId:r});case 26:i=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:i,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:i});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:i,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,i=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 i.utils.HashToAddress(t)})),this.Log("Content space types:"),this.Log(r),e=e.concat(r).filter((function(t){return t})).map((function(t){return i.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=i.utils.AddressToObjectId(e),i.contentTypes[n]){t.next=11;break}return t.prev=2,t.next=5,i.ContentType({typeId:n,publicOnly:!0});case 5:i.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,i;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,h(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 i=t.sent,t.abrupt("return",c(c({},i),{},{meta:i.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,h(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,i,a=this;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,h(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 i={},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,a.ethClient.CallContractMethod({contractAddress:a.utils.HashToAddress(n),methodName:"contentTypes",methodArgs:[r]});case 2:return s=t.sent,u=a.utils.AddressToObjectId(s),t.next=6,a.ContentType({typeId:u});case 6:i[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(i),t.abrupt("return",i);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,i,a,s,u,c;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.filterOptions,i=void 0===r?{}:r,h(n),this.Log("Retrieving content objects from ".concat(n)),a=f("qlibs",n,"q"),s={filter:[]},i.cacheId&&(s.cache_id=i.cacheId),i.start&&(s.start=i.start),i.limit&&(s.limit=i.limit),i.select&&(s.select=i.select),i.sort&&(s.sort_by=i.sort,i.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))},i.filter&&(Array.isArray(i.filter)?i.filter.forEach((function(t){return c(t)})):c(i.filter)),this.Log("Filter options:"),this.Log(i),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=a,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,i,a,s;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.writeToken,m({libraryId:n,objectId:r,versionHash:i}),this.Log("Retrieving content object: ".concat(n||""," ").concat(a||i||r)),i&&(r=this.utils.DecodeVersionHash(i).objectId),s=f("q",a||i||r),t.t0=this.utils,t.t1=this.HttpClient,t.next=9,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,versionHash:i});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,y(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)?A(r):y(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,i=this;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.objectId,(r=e.versionHash)?A(r):y(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=i.utils,t.next=5,i.CallContractMethod({contractAddress:i.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,a,u,l,p,d,h,y,A=this;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,a=e.versionHash,u=e.path,l=void 0===u?"/":u,p=e.metadata,d=e.authorizationToken,h=e.noAuth,p&&"object"===i(p)){t.next=3;break}return t.abrupt("return",p);case 3:if(!Array.isArray(p)){t.next=7;break}return t.next=6,this.utils.LimitedMap(5,p,function(){var t=s(o.mark((function t(e,i){return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,A.ProduceMetadataLinks({libraryId:n,objectId:r,versionHash:a,path:f(l,i.toString()),metadata:e,authorizationToken:d,noAuth:h});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(!p["/"]||!p["/"].match(/\.\/(rep|files)\/.+/)&&!p["/"].match(/^\/?qfab\/([\w]+)\/?(rep|files)\/.+/)){t.next=16;break}return t.t0=c,t.t1=c({},p),t.t2={},t.next=13,this.LinkUrl({libraryId:n,objectId:r,versionHash:a,linkPath:l,authorizationToken:d,noAuth:h});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 y={},t.next=19,this.utils.LimitedMap(5,Object.keys(p),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,A.ProduceMetadataLinks({libraryId:n,objectId:r,versionHash:a,path:f(l,e),metadata:p[e],authorizationToken:d,noAuth:h});case 2:y[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",y);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,i,a,s,u,c,f,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,i=e.versionHash,a=e.path,s=void 0===a?"/":a,u=e.channelAuth,c=void 0!==u&&u,f=e.noAuth,l=void 0!==f&&f,m({libraryId:n,objectId:r,versionHash:i}),i&&(r=this.utils.DecodeVersionHash(i).objectId),l=this.noAuth||l||this.staticToken,p=l,l){t.next=14;break}return t.next=8,this.Visibility({id:r});case 8:return h=t.sent,t.next=11,this.AccessType({id:r});case 11:d=t.sent,p=(s||"").replace(/^\/+/,"").startsWith("public"),l=h>=10||p&&h>=1;case 14:if(!this.oauthToken){t.next=22;break}return t.next=17,this.authClient.KMSAddress({objectId:r,versionHash:i});case 17:if(!(y=t.sent)||this.utils.EqualAddress(y,this.utils.nullAddress)){t.next=22;break}return t.next=21,this.authClient.AuthorizationToken({libraryId:n,objectId:r,versionHash:i,channelAuth:!0,oauthToken:this.oauthToken});case 21:return t.abrupt("return",t.sent);case 22:if(this.inaccessibleLibraries[n]||!p||d!==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:i});case 29:t.t1=t.sent;case 30:return t.t2=t.t1,t.t3=l,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:i,noAuth:l,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:i,noAuth:l,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,i,a,s,u,p,d,h,y,A,b,g,w,I,E,_,C,k,B,x,S,Q,M,R,O,j,T,P,D,N,L=arguments;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.writeToken,s=e.metadataSubtree,u=void 0===s?"/":s,p=e.localizationSubtree,d=e.queryParams,h=void 0===d?{}:d,y=e.select,A=void 0===y?[]:y,b=e.remove,g=void 0===b?[]:b,w=e.authorizationToken,I=e.noAuth,E=void 0!==I&&I,_=e.resolveLinks,C=void 0!==_&&_,k=e.resolveIncludeSource,B=void 0!==k&&k,x=e.resolveIgnoreErrors,S=void 0!==x&&x,Q=e.linkDepthLimit,M=void 0===Q?1:Q,R=e.produceLinkUrls,O=void 0!==R&&R,m({libraryId:n,objectId:r,versionHash:i}),this.Log("Retrieving content object metadata: ".concat(n||""," ").concat(r||i," ").concat(a||"","\n Subtree: ").concat(u)),h=c({},h||{}),i&&(r=this.utils.DecodeVersionHash(i).objectId),j=f("q",a||i||r,"meta",u),i){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:j=f("qlibs",n,j);case 12:return t.next=14,this.MetadataAuth({libraryId:n,objectId:r,versionHash:i,path:u,noAuth:E});case 14:return T=t.sent,P=[w,h.authorization,T].flat().filter((function(t){return t})),delete h.authorization,t.prev=17,t.next=20,this.utils.ResponseToJson(this.HttpClient.Request({headers:{Authorization:P.map((function(t){return"Bearer ".concat(t)}))},queryParams:c(c({},h),{},{select:A,remove:g,link_depth:M,resolve:C,resolve_include_source:B,resolve_ignore_errors:S}),method:"GET",path:j}));case 20:D=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(!l.get(t.t0.body,"errors[0].cause.cause.cause.qwtoken")){t.next=32;break}throw t.t0;case 32:D="/"===u?{}:void 0;case 33:if(!O){t.next=37;break}return t.next=36,this.ProduceMetadataLinks({libraryId:n,objectId:r,versionHash:i,path:u,metadata:D,authorizationToken:w,noAuth:E});case 36:D=t.sent;case 37:if(p){t.next=39;break}return t.abrupt("return",D);case 39:return t.prev=39,t.next=42,this.ContentObjectMetadata(c(c({},L[0]),{},{metadataSubtree:p,localizationSubtree:void 0}));case 42:return N=t.sent,t.abrupt("return",v({},D,N,(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",D);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,i,a,s,u,l,p,d,h,y=this;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,i=e.objectId,a=e.versionHash,s=e.metadata,u=e.localization,l=e.noAuth,p=e.produceLinkUrls,d=void 0!==p&&p,m({libraryId:n,objectId:i,versionHash:a}),i||(i=this.utils.DecodeVersionHash(a).objectId),s){t.next=12;break}return t.next=6,this.ContentObjectMetadata({libraryId:n,objectId:i,versionHash:a,metadataSubtree:"public/asset_metadata",resolveLinks:!0,linkDepthLimit:2,resolveIgnoreErrors:!0,produceLinkUrls:d,noAuth:l});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(!d){t.next=16;break}return t.next=15,this.ProduceMetadataLinks({libraryId:n,objectId:i,versionHash:a,path:f("public","asset_metadata"),metadata:s,noAuth:l});case 15:s=t.sent;case 16:return s.info||(s.info={}),h=c({},s),u&&u.reverse().forEach((function(t){var e,n=(e=y.utils).SafeTraverse.apply(e,[s].concat(r(t)))||{};h=v({},h,n,(function(t,e){return null===e||""===e?t:void 0}))})),t.abrupt("return",h);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,i;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)),i=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=i,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,i,a;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),y(n),t.prev=3,t.next=6,this.CallContractMethod({contractAddress:this.utils.HashToAddress(n),methodName:"objectHash"});case 6:i=t.sent,t.next=11;break;case 9:t.prev=9,t.t0=t.catch(3);case 11:if(i){t.next=25;break}return t.prev=12,t.next=15,this.CallContractMethod({contractAddress:this.utils.HashToAddress(n),methodName:"countVersionHashes"});case 15:a=t.sent,t.next=20;break;case 18:t.prev=18,t.t1=t.catch(12);case 20:if(a&&a.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:[a-1]});case 24:i=t.sent;case 25:return t.abrupt("return",i);case 26:case"end":return t.stop()}}),t,this,[[3,9],[12,18]])})));return function(e){return t.apply(this,arguments)}}(),e.LatestVersionHashV2=function(){var t=s(o.mark((function t(e){var n,r,i,a,s;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),y(n),t.prev=3,a=f("q",n),t.t0=this.utils,t.t1=this.HttpClient,t.next=9,this.authClient.AuthorizationHeader({objectId:n});case 9: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.next=15,t.t0.ResponseToJson.call(t.t0,t.t5);case 15:s=t.sent,i=s.hash,t.next=23;break;case 19:throw t.prev=19,t.t6=t.catch(3),console.log("ERROR",t.t6),Error("Unable to determine latest version hash for ".concat(r||n));case 23:return t.abrupt("return",i);case 24:case"end":return t.stop()}}),t,this,[[3,19]])})));return function(e){return t.apply(this,arguments)}}(),e.AvailableDRMs=s(o.mark((function t(){var e,n,r,i,a,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("_"),i=parseInt(r[0]),a=parseInt(r[1]),(i>13||13===i&&a>=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,i,a,s,u,c,l,p,d,h,y,A,b,g,m,v;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.writeToken,s=e.linkPath,u=e.handler,c=e.offering,l=void 0===c?"":c,p=e.signedLink,d=void 0!==p&&p,h=e.authorizationToken,n){t.next=5;break}return t.next=4,this.ContentObjectLibraryId({objectId:r});case 4:n=t.sent;case 5:if(i){t.next=9;break}return t.next=8,this.LatestVersionHash({objectId:r});case 8:i=t.sent;case 9:if(y=f("qlibs",n,"q",a||i,"rep",u,l,"options.json"),!s){t.next=26;break}return t.next=13,this.ContentObjectMetadata({libraryId:n,objectId:r,versionHash:i,writeToken:a,metadataSubtree:s,resolveLinks:!1,resolveIgnoreErrors:!0,resolveIncludeSource:!0,authorizationToken:h});case 13:if(v=t.sent,m=!!v&&!!v["/"]&&!v["/"].endsWith("options.json"),y=f("qlibs",n,"q",a||i,"meta",s),d){t.next=25;break}return t.next=19,this.LinkTarget({libraryId:n,objectId:r,versionHash:i,writeToken:a,linkPath:s,linkInfo:v,authorizationToken:h});case 19:return g=t.sent,b=this.utils.DecodeVersionHash(g).objectId,t.next=23,this.ContentObjectLibraryId({objectId:b});case 23:A=t.sent,m||l||(y=f("q",g,"rep",u,"options.json"));case 25:m&&(y=f(y,l,"options.json"));case 26:return t.abrupt("return",{path:y,multiOfferingLink:m,linkTarget:{libraryId:A,objectId:b,versionHash:g}});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,i,a,s,u,c,f,l,p,d,h;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.objectId,r=e.versionHash,i=e.writeToken,a=e.linkPath,s=e.signedLink,u=e.directLink,c=e.handler,f=void 0===c?"playout":c,l=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=a,t.t5=l,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:i,linkPath:a,signedLink:s,handler:f,authorizationToken:l});case 17:return p=t.sent,d=p.path,t.prev=19,t.t7=l,t.next=23,this.authClient.AuthorizationToken({objectId:n,channelAuth:!0,oauthToken:this.oauthToken});case 23:return t.t8=t.sent,h=[t.t7,t.t8].flat().filter((function(t){return t})),t.next=27,this.utils.ResponseToJson(this.HttpClient.Request({path:d,method:"GET",headers:{Authorization:"Bearer ".concat(h.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,i,u,l,p,d,h,b,g,m,v,w,I,E,_,C,k,B,x,S,Q,M,R,O,j,T,P,D,N,L,F,U,H,G,q,K,Y,z,J,W,V,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,i=e.versionHash,u=e.writeToken,l=e.linkPath,p=e.signedLink,d=void 0!==p&&p,h=e.protocols,b=void 0===h?["dash","hls"]:h,g=e.handler,m=void 0===g?"playout":g,v=e.offering,w=void 0===v?"default":v,I=e.playoutType,E=e.drms,_=void 0===E?[]:E,C=e.context,k=e.hlsjsProfile,B=void 0===k||k,x=e.authorizationToken,S=e.options,Q=void 0===S?{}:S,!n){t.next=8;break}if(M=n.match(/(hq__[^/]+)\/rep\/([^/]+)\/([^/]+)\/options.json/),i=M[1],m=M[2],w=M[3],i&&m&&w){t.next=8;break}throw Error("Invalid offering URI: ".concat(n));case 8:if(i?A(i):y(r),b=b.map((function(t){return t.toLowerCase()})),_=_.map((function(t){return t.toLowerCase()})),r){t.next=15;break}r=this.utils.DecodeVersionHash(i).objectId,t.next=19;break;case 15:if(i){t.next=19;break}return t.next=18,this.LatestVersionHash({objectId:r});case 18:i=t.sent;case 19:return t.next=21,this.ContentObjectLibraryId({objectId:r});case 21:if(R=t.sent,t.prev=22,l){t.next=29;break}return O=f("public","asset_metadata","sources",w),t.next=27,this.ContentObjectMetadata({libraryId:R,objectId:r,versionHash:i,metadataSubtree:O,authorizationToken:x});case 27:t.sent&&(l=O);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:R,objectId:r,versionHash:i,writeToken:u,linkPath:l,signedLink:d,handler:m,offering:w,authorizationToken:x});case 35:if(j=t.sent,T=j.path,P=j.linkTarget,t.t1=this.authClient,t.t2=P.objectId||r,t.t3=P.versionHash||i,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=b,t.t6=_,t.t7=C,t.t8={objectId:t.t2,versionHash:t.t4,protocols:t.t5,drms:t.t6,context:t.t7},D=t.t1.AudienceData.call(t.t1,t.t8),t.t9=x,t.next=54,this.authClient.AuthorizationToken({libraryId:R,objectId:r,channelAuth:!0,oauthToken:this.oauthToken,audienceData:D});case 54:return t.t10=t.sent,N=[t.t9,t.t10].flat().filter((function(t){return t})),L=c({authorization:N,resolve:!!l},Q),t.t11=Object,t.next=60,this.utils.ResponseToJson(this.HttpClient.Request({path:T,method:"GET",queryParams:L}));case 60:if(t.t12=t.sent,F=t.t11.values.call(t.t11,t.t12),d||!P.versionHash){t.next=68;break}return t.t13=x,t.next=66,this.authClient.AuthorizationToken({libraryId:P.libraryId,objectId:P.objectId,channelAuth:!0,oauthToken:this.oauthToken,audienceData:D});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(K=F[q],Y=K.properties.protocol,z=K.properties.drm,H=H||K.sid,G=G||!!K.properties.multiview,H&&(L.sid=H),J=K.uri.split("?")[0],I&&(J=J.replace("playlist","playlist-".concat(I))),W=K.properties.license_servers,V=K.properties.cert,B&&"hls"===Y&&"aes-128"===z&&(L.player_profile="hls-js"),t.t15=c,t.t16=c({},U[Y]||{}),t.t17={},t.t18=c,t.t19=c({},(U[Y]||{}).playoutMethods||{}),t.t20={},t.t21=a,t.t22={},t.t23=z||"clear",!d){t.next=97;break}return t.next=94,this.LinkUrl({versionHash:i,linkPath:f(l,w,J),queryParams:L,noAuth:!0});case 94:t.t24=t.sent,t.next=100;break;case 97:return t.next=99,this.Rep({libraryId:P.libraryId||R,objectId:P.objectId||r,versionHash:P.versionHash||i,rep:f(m,w,J),noAuth:!0,queryParams:L});case 99:t.t24=t.sent;case 100:for(Z in t.t25=t.t24,t.t26=z?a({},z,{licenseServers:W,cert:V}):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[Y]=(0,t.t15)(t.t16,t.t17,t.t30),U[Y].playoutMethods)U[Y].playoutMethods[Z].drms&&U[Y].playoutMethods[Z].drms[z]&&U[Y].playoutMethods[Z].drms[z].cert&&((X=new URL(U[Y].playoutMethods[Z].playoutUrl)).pathname=X.pathname.split("/").slice(0,-1).concat(["drm.cert"]).join("/"),U[Y].playoutMethods[Z].drms[z].cert_url=X.toString());if($=b.includes(Y),tt=_.includes(z||"clear")||0===_.length&&!z,$&&tt){t.next=112;break}return t.abrupt("continue",113);case 112:(!U[Y].playoutUrl||z&&"clear"!==z)&&(U[Y].playoutUrl=U[Y].playoutMethods[z||"clear"].playoutUrl,U[Y].drms=U[Y].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",P.versionHash||i,"rep",m,w,"views.json"),method:"GET",queryParams:{sid:H,authorization:N}});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",P.versionHash||i,"rep",m,w,"select_view"),method:"POST",queryParams:{sid:H,authorization:N},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,i,a,s,u,c,f,l,p,d,h,b,g,m,v,w,I,E,_,C,k,B,x;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.objectId,r=e.versionHash,i=e.writeToken,a=e.linkPath,s=e.signedLink,u=void 0!==s&&s,c=e.protocols,f=void 0===c?["dash","hls"]:c,l=e.drms,p=void 0===l?[]:l,d=e.handler,h=void 0===d?"playout":d,b=e.offering,g=void 0===b?"default":b,m=e.playoutType,v=e.context,w=e.authorizationToken,I=e.options,E=void 0===I?{}:I,r?A(r):y(n),n||(n=this.utils.DecodeVersionHash(r).objectId),t.next=5,this.PlayoutOptions({objectId:n,versionHash:r,writeToken:i,linkPath:a,signedLink:u,protocols:f,drms:p,handler:h,offering:g,playoutType:m,hlsjsProfile:!1,context:v,authorizationToken:w,options:E});case 5:return delete(_=t.sent).playoutMethods,t.next=9,this.PlayoutPathResolution({objectId:n,versionHash:r,writeToken:i,linkPath:a,signedLink:u,handler:h,offering:g,authorizationToken:w});case 9:if(C=t.sent,k=C.linkTarget,B=[],w&&B.push(w),!u&&k.versionHash){t.next=21;break}return t.t0=B,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=B,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(_).forEach((function(t){var 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 i=r.sort((function(){return.5-Math.random()}))[0];x.drm[t]||(x.drm[t]={LA_URL:i,headers:{Authorization:"Bearer ".concat(B.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,i,a,s,u,c,l,p,d,h,y,A,b,g,v;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.writeToken,s=e.method,u=e.queryParams,c=void 0===u?{}:u,l=e.body,p=void 0===l?{}:l,d=e.headers,h=void 0===d?{}:d,y=e.constant,A=void 0===y||y,b=e.format,g=void 0===b?"json":b,m({libraryId:n,objectId:r,versionHash:i}),s){t.next=4;break}throw"Bitcode method not specified";case 4:if(i&&(r=this.utils.DecodeVersionHash(i).objectId),v=f("q",a||i||r,"call",s),n&&(v=f("qlibs",n,v)),h.authorization||h.Authorization){t.next=12;break}return t.next=11,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,update:!A});case 11:h.Authorization=t.sent.Authorization;case 12:return this.Log("Calling bitcode method: ".concat(n||""," ").concat(r||i," ").concat(a||"","\n ").concat(A?"GET":"POST"," ").concat(v,"\n Query Params:\n ").concat(JSON.stringify(c||""),"\n Body:\n ").concat(JSON.stringify(p||""),"\n Headers\n ").concat(JSON.stringify(h||""))),t.t0=this.utils,t.t1=g,t.next=17,this.HttpClient.Request({body:p,headers:h,method:A?"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,i,a,s,u,c,f,l,p,d,h,y,A,b,g;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.rep,s=e.queryParams,u=void 0===s?{}:s,c=e.service,f=void 0===c?"fabric":c,l=e.makeAccessRequest,p=void 0!==l&&l,d=e.channelAuth,h=void 0!==d&&d,y=e.noAuth,A=void 0!==y&&y,b=e.noCache,g=void 0!==b&&b,m({libraryId:n,objectId:r,versionHash:i}),a){t.next=4;break}throw"Rep not specified";case 4:return t.abrupt("return",this.FabricUrl({libraryId:n,objectId:r,versionHash:i,rep:a,queryParams:u,service:f,makeAccessRequest:p,channelAuth:h,noAuth:A,noCache:g}));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,i,a,s,u,c,f;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,i=e.versionHash,a=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:i}),a){t.next=4;break}throw"Rep not specified";case 4:return t.abrupt("return",this.FabricUrl({libraryId:n,objectId:r,versionHash:i,publicRep:a,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,i,a,s,u,l,p,d,h,y,A,b,g,v,w,I,E,_,C,k,B,x;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.writeToken,s=e.partHash,u=e.rep,l=e.publicRep,p=e.call,d=e.queryParams,h=void 0===d?{}:d,y=e.service,A=void 0===y?"fabric":y,b=e.channelAuth,g=void 0!==b&&b,v=e.makeAccessRequest,w=void 0!==v&&v,I=e.noAuth,E=void 0!==I&&I,_=e.noCache,C=void 0!==_&&_,(r||i)&&m({libraryId:n,objectId:r,versionHash:i}),i&&(r=this.utils.DecodeVersionHash(i).objectId),this.Log("Building Fabric URL:\n libraryId: ".concat(n,"\n objectId: ").concat(r,"\n versionHash: ").concat(i,"\n writeToken: ").concat(a,"\n partHash: ").concat(s,"\n rep: ").concat(u,"\n publicRep: ").concat(l,"\n call: ").concat(p,"\n channelAuth: ").concat(g,"\n noAuth: ").concat(E,"\n noCache: ").concat(C,"\n queryParams: ").concat(JSON.stringify(h||{},null,2))),k=[],h.authorization&&k.push(h.authorization),E&&h.authorization){t.next=12;break}return t.t0=k,t.next=10,this.authClient.AuthorizationToken({libraryId:n,objectId:r,versionHash:i,channelAuth:g,makeAccessRequest:w,noAuth:E,noCache:C});case 10:t.t1=t.sent,t.t0.push.call(t.t0,t.t1);case 12:if(h=c(c({},h),{},{authorization:k.flat()}),!u&&!l||!r||i){t.next=17;break}return t.next=16,this.LatestVersionHash({objectId:r});case 16:i=t.sent;case 17:return B="",n?(B=f(B,"qlibs",n),(r||i)&&(B=f(B,"q",a||i||r))):i&&(B=f("q",i)),s?B=f(B,"data",s):u?B=f(B,"rep",u):l?B=f(B,"public",l):p&&(B=f(B,"call",p)),x=this.HttpClient,"search"===A?x=this.SearchHttpClient:"auth"===A&&(x=this.AuthHttpClient),t.abrupt("return",x.URL({path:B,queryParams:h}));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,i,a,s,u,l,p,d,h,y,A;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.writeToken,s=e.filePath,u=e.queryParams,l=void 0===u?{}:u,p=e.noCache,d=void 0!==p&&p,m({libraryId:n,objectId:r,versionHash:i}),s){t.next=4;break}throw"File path not specified";case 4:return i&&(r=this.utils.DecodeVersionHash(i).objectId),h=n?f("qlibs",n,"q",a||i||r):f("q",i),t.next=8,this.authClient.AuthorizationToken({libraryId:n,objectId:r,noCache:d});case 8:return y=t.sent,l=c(c({},l),{},{authorization:y}),t.next=12,this.ContentObjectMetadata({libraryId:n,objectId:r,versionHash:i,writeToken:a,metadataSubtree:f("files",s)});case 12:return A=t.sent,A&&A["."].encryption&&"cgck"===A["."].encryption.scheme?(h=f(h,"rep","files_download",s),l["header-x_decryption_mode"]="decrypt"):h=f(h,"files",s),t.abrupt("return",this.HttpClient.URL({path:h,queryParams:l}));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,i,a,s,u,c;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.height,s=e.imagePath,u=void 0===s?"public/display_image":s,m({libraryId:n,objectId:r,versionHash:i}),i){t.next=6;break}return t.next=5,this.LatestVersionHash({objectId:r});case 5:i=t.sent;case 6:if(this.Log("Retrieving content object image url: ".concat(n," ").concat(r," ").concat(i)),this.objectImageUrls[i]){t.next=26;break}return t.prev=8,t.next=11,this.ContentObjectMetadata({versionHash:i,metadataSubtree:u});case 11:if(t.sent){t.next=15;break}return this.Log("No image url set: ".concat(n," ").concat(r," ").concat(i)),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(i),!0),this.Log(t.t0,!0);case 21:return c={},a&&!isNaN(parseInt(a))&&(c.height=parseInt(a)),t.next=25,this.LinkUrl({versionHash:i,linkPath:u,queryParams:c});case 25:this.objectImageUrls[i]=t.sent;case 26:return t.abrupt("return",this.objectImageUrls[i]);case 27:case"end":return t.stop()}}),t,this,[[8,17]])})));return function(e){return t.apply(this,arguments)}}();var w={video:"v",live_video:"lv",audio:"a",image:"i",html:"h",ebook:"b",gallery:"g",link:"l"};e.EmbedUrl=function(){var e=s(o.mark((function e(n){var r,i,a,s,u,c,f,l,p,d,h,b,g,m,v,I,E,_;return o.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=n.objectId,i=n.versionHash,a=n.duration,s=void 0===a?864e5:a,u=n.mediaType,c=void 0===u?"video":u,f=n.options,l=void 0===f?{}:f,i?A(i):r&&y(r),l.controls=void 0===l.controls?"autoHide":l.controls,p={autoHide:"h",browserDefault:"d",show:"s",hideWithVolume:"hv"},d=new URL("https://embed.v3.contentfabric.io"),e.next=7,this.NetworkInfo();case 7:return h=e.sent,b="demov3"===h.name?"demo":"test"===h.name&&955205===h.id?"testv4":h.name,e.next=11,this.Permission({objectId:r||this.utils.DecodeVersionHash(i).objectId});case 11:g=e.sent,d.searchParams.set("p",""),d.searchParams.set("net",b),i?d.searchParams.set("vid",i):r&&d.searchParams.set("oid",r),d.searchParams.set("mt",w[c.toLowerCase()]||"v"),m={},v=0,I=Object.keys(l);case 18:if(!(v<I.length)){e.next=68;break}E=I[v],e.t0=E,e.next="accountWatermark"===e.t0?23:"autoplay"===e.t0?25:"capLevelToPlayerSize"===e.t0?27:"clipEnd"===e.t0?29:"clipStart"===e.t0?31:"controls"===e.t0?33:"description"===e.t0?35:"directLink"===e.t0?37:"linkPath"===e.t0?39:"loop"===e.t0?41:"muted"===e.t0?43:"offerings"===e.t0?45:"posterUrl"===e.t0?47:"protocols"===e.t0?49:"showShare"===e.t0?51:"showTitle"===e.t0?53:"title"===e.t0?55:"viewRecordKey"===e.t0?57:"useTicketCodes"===e.t0?59:65;break;case 23:return d.searchParams.set("awm",""),e.abrupt("break",65);case 25:return d.searchParams.set("ap",""),e.abrupt("break",65);case 27:return d.searchParams.set("cap",""),e.abrupt("break",65);case 29:return d.searchParams.set("end",l.clipEnd),e.abrupt("break",65);case 31:return d.searchParams.set("start",l.clipStart),e.abrupt("break",65);case 33:return"hide"!==l.controls&&d.searchParams.set("ct",p[l.controls]),e.abrupt("break",65);case 35:return m["og:description"]=l.description,e.abrupt("break",65);case 37:return d.searchParams.set("dr",""),e.abrupt("break",65);case 39:return d.searchParams.set("ln",this.utils.B64(l.linkPath)),e.abrupt("break",65);case 41:return d.searchParams.set("lp",""),e.abrupt("break",65);case 43:return d.searchParams.set("m",""),e.abrupt("break",65);case 45:return d.searchParams.set("off",l.offerings.join(",")),e.abrupt("break",65);case 47:return d.searchParams.set("pst",l.posterUrl),e.abrupt("break",65);case 49:return d.searchParams.set("ptc",l.protocols.join(",")),e.abrupt("break",65);case 51:return d.searchParams.set("sh",""),e.abrupt("break",65);case 53:return d.searchParams.set("st",""),e.abrupt("break",65);case 55:return m["og:title"]=l.title,e.abrupt("break",65);case 57:return d.searchParams.set("vrk",l.viewRecordKey),e.abrupt("break",65);case 59:return d.searchParams.set("ptk",""),l.tenantId&&d.searchParams.set("ten",l.tenantId),l.ntpId&&d.searchParams.set("ntp",l.ntpId),l.ticketCode&&d.searchParams.set("tk",t.from(l.ticketCode).toString("base64")),l.ticketSubject&&d.searchParams.set("sbj",t.from(l.ticketSubject).toString("base64")),e.abrupt("break",65);case 65:v++,e.next=18;break;case 68:if(Object.keys(m).length>0&&d.searchParams.set("data",this.utils.B64(JSON.stringify({meta_tags:m}))),!["owner","editable","viewable"].includes(g)){e.next=74;break}return e.next=72,this.CreateSignedToken({objectId:r,versionHash:i,duration:s});case 72:_=e.sent,d.searchParams.set("ath",_);case 74:return e.abrupt("return",d.toString());case 75:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),e.ContentObjectGraph=function(){var t=s(o.mark((function t(e){var n,r,i,a,u,c,l,p,d,h,y=this;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.autoUpdate,u=void 0!==a&&a,c=e.select,m({libraryId:n,objectId:r,versionHash:i}),this.Log("Retrieving content object graph: ".concat(n||""," ").concat(r||i)),i&&(r=this.utils.DecodeVersionHash(i).objectId),l=f("q",i||r,"links"),t.prev=5,t.t0=this.utils,t.t1=this.HttpClient,t.next=10,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,versionHash:i});case 10:return t.t2=t.sent,t.t3={auto_update:u,select:c},t.t4=l,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,(d=t.t7.body.errors[0].cause.cause.cause.cycle)&&0!==d.length){t.next=26;break}throw t.t7;case 26:return h={},t.next=29,Promise.all(d.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(!h[e]){t.next=2;break}return t.abrupt("return");case 2:return n=y.utils.DecodeVersionHash(e).objectId,t.next=5,y.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,y.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,y.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,h[e]={name:r,objectId:n};case 20:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()));case 29:p=d.map((function(t){return"".concat(h[t].name," (").concat(h[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(p.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,a,s,u,c,f,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,s=e.writeToken,u=e.linkPath,c=e.authorizationToken,f=e.linkInfo,m({libraryId:n,objectId:r,versionHash:a}),s&&g(s),a&&(r=this.utils.DecodeVersionHash(a).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:a,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((l=((f["/"]||"").match(/^\/?qfab\/([\w]+)\/?.+/)||[])[1])||(l=f["."].container),!l){t.next=19;break}return t.abrupt("return",l);case 19:if(!a){t.next=21;break}return t.abrupt("return",a);case 21:if(t.t0=a,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:a,writeToken:s,metadataSubtree:u,resolveIncludeSource:!0,authorizationToken:c});case 29:if((f=t.sent)&&f["."]){t.next=49;break}if("object"!==i(f)){t.next=38;break}if(t.t1=a,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(p=u.split("/").slice(0,-1).join("/")){t.next=46;break}if(t.t2=a,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:a,writeToken:s,metadataSubtree:p,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,i,a,s,u,l,p,d,h,y,A,b,v,w;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.writeToken,s=e.linkPath,u=e.mimeType,l=e.authorizationToken,p=e.queryParams,d=void 0===p?{}:p,h=e.channelAuth,y=void 0!==h&&h,A=e.noAuth,b=void 0!==A&&A,m({libraryId:n,objectId:r,versionHash:i}),a&&g(a),s){t.next=5;break}throw Error("Link path not specified");case 5:return i&&(r=this.utils.DecodeVersionHash(i).objectId),v=n?f("qlibs",n,"q",a||i||r,"meta",s):f("q",i,"meta",s),w=[l],t.t0=w,t.next=11,this.MetadataAuth({libraryId:n,objectId:r,versionHash:i,path:s,channelAuth:y,noAuth:b});case 11:return t.t1=t.sent,t.t0.push.call(t.t0,t.t1),d.authorization&&w.push(d.authorization),d=c(c({},d),{},{authorization:w.flat().filter((function(t){return t})),resolve:!0}),u&&(d["header-accept"]=u),t.abrupt("return",this.HttpClient.URL({path:v,queryParams:d}));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,i,a,s,u,c,f,l,d,h;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.writeToken,s=e.linkPath,u=e.queryParams,c=void 0===u?{}:u,f=e.format,l=void 0===f?"json":f,d=e.channelAuth,t.next=3,this.LinkUrl({libraryId:n,objectId:r,versionHash:i,writeToken:a,linkPath:s,queryParams:c,channelAuth:d});case 3:return h=t.sent,t.t0=this.utils,t.t1=l,t.next=8,p.Fetch(h);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,i,a,s,u,c,f,l,p,d;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,i=e.versionHash,a=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:i}),g(a),r||(r=client.DecodeVersionHash(i).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:a,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=a,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 l=t.sent,t.next=41,this.authClient.KMSInfo({objectId:r});case 41:return p=t.sent.publicKey,d="eluv.caps.ikms".concat(this.utils.AddressToHash(l)),t.next=45,this.ContentObjectMetadata({libraryId:n,objectId:r,writeToken:a,metadataSubtree:d});case 45:if(t.sent){t.next=58;break}return t.t7=this,t.t8=n,t.t9=r,t.t10=a,t.t11=d,t.next=54,this.Crypto.EncryptConk(this.encryptionConks[r],p);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,i,a,s,u,c,f,l,p,d;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.writeToken,s=e.download,u=void 0!==s&&s,m({libraryId:n,objectId:r,versionHash:i}),a&&g(a),r||(r=client.DecodeVersionHash(i).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:i,metadataSubtree:f});case 10:if(l=t.sent,this.utils.EqualAddress(c,this.signer.address)||l){t.next=21;break}if(!u){t.next=18;break}return t.next=15,this.authClient.ReEncryptionConk({libraryId:n,objectId:r,versionHash:i});case 15:return t.abrupt("return",t.sent);case 18:return t.next=20,this.authClient.EncryptionConk({libraryId:n,objectId:r,versionHash:i});case 20:return t.abrupt("return",t.sent);case 21:if(this.encryptionConks[r]){t.next=38;break}return p="eluv.caps.iusr".concat(this.utils.AddressToHash(this.signer.address)),t.next=25,this.ContentObjectMetadata({libraryId:n,objectId:r,versionHash:i,writeToken:a,metadataSubtree:p});case 25:if(!(d=t.sent)){t.next=32;break}return t.next=29,this.Crypto.DecryptCap(d,this.signer._signingKey().privateKey);case 29:this.encryptionConks[r]=t.sent,t.next=38;break;case 32:if(!a){t.next=37;break}return t.next=35,this.CreateEncryptionConk({libraryId:n,objectId:r,versionHash:i,writeToken:a,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,i,a,s,u;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.writeToken,a=e.chunk,m({libraryId:n,objectId:r}),t.next=4,this.EncryptionConk({libraryId:n,objectId:r,writeToken:i});case 4:return s=t.sent,t.next=7,this.Crypto.Encrypt(s,a);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,i,a,s,u;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.writeToken,a=e.chunk,m({libraryId:n,objectId:r}),t.next=4,this.EncryptionConk({libraryId:n,objectId:r,writeToken:i,download:!0});case 4:return s=t.sent,t.next=7,this.Crypto.Decrypt(s,a);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,i;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.objectId,r=e.args,y(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 i=t.sent,this.Log(i),t.abrupt("return",{visibilityCode:i[0],visible:i[0]>=1,accessible:i[0]>=10,editable:i[0]>=100,hasAccess:0===i[1],accessCode:i[1],accessCharge:this.utils.WeiToEther(i[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,i,a,s,u,c,f,l;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.args,s=void 0===a?[]:a,u=e.update,c=void 0!==u&&u,f=e.noCache,l=void 0!==f&&f,m({libraryId:n,objectId:r,versionHash:i}),i&&(r=this.utils.DecodeVersionHash(i).objectId),t.next=5,this.authClient.MakeAccessRequest({libraryId:n,objectId:r,versionHash:i,args:s,update:c,skipCache:!0,noCache:l});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,i,a,s;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.objectId,r=e.versionHash,i=e.context,a=e.noCache,s=void 0!==a&&a,r?A(r):y(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:i,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,i;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.objectId,r=e.versionHash,i=e.percentComplete,r?A(r):y(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:i});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,i;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.objectId,r=e.score,i=void 0===r?100:r,y(n),!(i<0||i>100)){t.next=4;break}throw Error("Invalid AccessComplete score: "+i);case 4:return t.next=6,this.authClient.AccessComplete({id:n,score:i});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,i;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.versionHash,m({libraryId:n,objectId:r,versionHash:i}),t.next=4,ContentObjectVerification.VerifyContentObject({client:this,libraryId:n,objectId:r,versionHash:i});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,i,a,s;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.versionHash,a=e.partHash,m({libraryId:n,objectId:r,versionHash:i}),b(a),i&&(r=this.utils.DecodeVersionHash(i).objectId),s=f("q",i||r,"data",a,"proofs"),t.t0=this.utils,t.t1=this.HttpClient,t.next=9,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,versionHash:i});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,i,a,s,u;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.partHash,a=e.format,s=void 0===a?"blob":a,m({libraryId:n,objectId:r,versionHash:versionHash}),b(i),u=f("qparts",i),t.t0=this.utils,t.t1=s,t.t2=this.HttpClient,t.next=9,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,partHash:i});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)}}()}).call(this,n(4).Buffer)},function(t,e,n){var r=n(84)(n(43),"Map");t.exports=r},function(t,e,n){var r=n(43).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(8))},function(t,e,n){var r=n(86),i=n(64);t.exports=function(t,e,n){(void 0!==n&&!i(t[e],n)||void 0===n&&!(e in t))&&r(t,e,n)}},function(t,e,n){var r=n(84),i=function(){try{var t=r(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();t.exports=i},function(t,e,n){var r=n(311)(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(312),i=n(57),a=Object.prototype,o=a.hasOwnProperty,s=a.propertyIsEnumerable,u=r(function(){return arguments}())?r:function(t){return i(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 i=n(43),a=n(314),o="object"==r(e)&&e&&!e.nodeType&&e,s=o&&"object"==r(t)&&t&&!t.nodeType&&t,u=s&&s.exports===o?i.Buffer:void 0,c=(u?u.isBuffer:void 0)||a;t.exports=c}).call(this,n(26)(t))},function(t,e,n){var r=n(316),i=n(317),a=n(318),o=a&&a.isTypedArray,s=o?i(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(322),i=n(324),a=n(87);t.exports=function(t){return a(t)?r(t,!0):i(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 i=n(t);return!!(e=null==e?9007199254740991:e)&&("number"==i||"symbol"!=i&&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(18),i=n(9),a=n(10);function o(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,n=new WeakMap;return(o=function(t){return t?n:e})(t)}function s(t,e){if(!e&&t&&t.__esModule)return t;if(null===t||"object"!=r(t)&&"function"!=typeof t)return{default:t};var n=o(e);if(n&&n.has(t))return n.get(t);var i={__proto__:null},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in t)if("default"!==s&&Object.prototype.hasOwnProperty.call(t,s)){var u=a?Object.getOwnPropertyDescriptor(t,s):null;u&&(u.get||u.set)?Object.defineProperty(i,s,u):i[s]=t[s]}return i.default=t,n&&n.set(t,i),i}void 0===globalThis.Buffer&&(globalThis.Buffer=n(4).Buffer);var u=n(126),c=n(335),f=n(28);if(globalThis.process||(globalThis.process=n(6)),"undefined"==typeof crypto){var l=n(113);l.getRandomValues=function(t){return l.randomBytes(t.length)},globalThis.crypto=l}var p,d,h,y,A,b={ElvCrypto:(A=a(i.mark((function t(){var e;return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(t.prev=0,b.elvCrypto){t.next=8;break}return t.next=4,Promise.resolve().then((function(){return s(n(421))}));case 4:return e=t.sent.default,t.next=7,(new e).init();case 7:b.elvCrypto=t.sent;case 8:return t.abrupt("return",b.elvCrypto);case 11:t.prev=11,t.t0=t.catch(0),console.error("Error initializing ElvCrypto:"),console.error(t.t0);case 15:case"end":return t.stop()}}),t,null,[[0,11]])}))),function(){return A.apply(this,arguments)}),EncryptedSize:function(t){var e=Math.floor(t/1e6)*b.EncryptedBlockSize(1e6);return t%1e6!=0&&(e+=b.EncryptedBlockSize(t%1e6)),e},EncryptedBlockSize:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=129,r=608,i=48,a=12*(i-1),o=12*i,s=Math.floor(t/a)*o;return t%a!=0&&(s+=o),e?s+r:s+n},EncryptConk:function(t,n){return a(i.mark((function r(){var a,o,s,u,c,l;return i.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.ElvCrypto();case 2:return a=r.sent,n=new Uint8Array(e.from(n.replace("0x",""),"hex")),t=new Uint8Array(e.from(JSON.stringify(t))),r.next=7,a.encryptECIES(t,n);case 7:return o=r.sent,s=o.data,u=o.ephemeralKey,c=o.tag,l=e.concat([e.from(u),e.from(c),e.from(s)]),r.abrupt("return",f.B64(l));case 13:case"end":return r.stop()}}),r)})))()},DecryptCap:function(t,n){return a(i.mark((function r(){var a,o,s,u,c;return i.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.ElvCrypto();case 2:return a=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=a.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()}}),r)})))()},GeneratePrimaryConk:function(t){return a(i.mark((function n(){var r,a,o,s,c,f,l;return i.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=t.spaceId,a=t.objectId,n.next=3,b.ElvCrypto();case 3:return o=n.sent,s=o.generatePrimaryKeys(),c=s.secretKey,f=s.publicKey,l=o.generateSymmetricKey().key,n.abrupt("return",{symm_key:"kpsy".concat(u.encode(e.from(l))),secret_key:"kpsk".concat(u.encode(e.from(c))),public_key:"kppk".concat(u.encode(e.from(f))),sid:r,qid:a});case 7:case"end":return n.stop()}}),n)})))()},GenerateTargetConk:function(){return a(i.mark((function t(){var n,r,a,o;return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.ElvCrypto();case 2:return n=t.sent,r=n.generateTargetKeys(),a=r.secretKey,o=r.publicKey,t.abrupt("return",{secret_key:"kpsk".concat(u.encode(e.from(a))),public_key:"ktpk".concat(u.encode(e.from(o)))});case 5:case"end":return t.stop()}}),t)})))()},CapToConk:function(t){var e=function(t){return new Uint8Array(u.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(i.mark((function e(){var n,r,a,o,s,u,c;return i.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.ElvCrypto();case 2:return n=e.sent,r=b.CapToConk(t),a=r.symmetricKey,o=r.secretKey,(s=r.publicKey).length===n.PRIMARY_PK_KEY_SIZE?(c=n.CRYPTO_TYPE_PRIMARY,u=n.newPrimaryContext(s,o,a)):(c=n.CRYPTO_TYPE_TARGET,u=n.newTargetDecryptionContext(o,a)),e.abrupt("return",{context:u,type:c});case 6:case"end":return e.stop()}}),e)})))()},Encrypt:(y=a(i.mark((function t(n,r){var a,o,s,u,c;return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.OpenEncryptionStream(n);case 2:if(a=t.sent,e.isBuffer(r)||r instanceof ArrayBuffer){t.next=9;break}return t.t0=e,t.next=7,new Response(r).arrayBuffer();case 7:t.t1=t.sent,r=t.t0.from.call(t.t0,t.t1);case 9:for(o=new Uint8Array(r),s=0;s<o.length;s+=1e6)u=Math.min(o.length,s+1e6),a.write(o.slice(s,u));return a.end(),c=[],t.next=15,new Promise((function(t,e){a.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 y.apply(this,arguments)}),OpenEncryptionStream:(h=a(i.mark((function t(e){var n,r,a,o,s;return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.ElvCrypto();case 2:return n=t.sent,t.next=5,b.EncryptionContext(e);case 5:return r=t.sent,a=r.context,o=new c.PassThrough,s=n.createCipher(a),t.abrupt("return",o.pipe(s).on("finish",(function(){a.free()})).on("error",(function(t){throw Error(t)})));case 10:case"end":return t.stop()}}),t)}))),function(t){return h.apply(this,arguments)}),Decrypt:(d=a(i.mark((function t(n,r){var a,o,s,u,c;return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.OpenDecryptionStream(n);case 2:for(a=t.sent,o=new Uint8Array(r),s=0;s<o.length;s+=1e6)u=Math.min(o.length,s+1e6),a.write(o.slice(s,u));return a.end(),c=[],t.next=9,new Promise((function(t,e){a.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 d.apply(this,arguments)}),OpenDecryptionStream:(p=a(i.mark((function t(e){var n,r,a,o,s,u;return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.ElvCrypto();case 2:return n=t.sent,t.next=5,b.EncryptionContext(e);case 5:return r=t.sent,a=r.context,o=r.type,s=new c.PassThrough,u=n.createDecipher(o,a),t.abrupt("return",s.pipe(u).on("finish",(function(){a.free()})).on("error",(function(t){throw Error(t)})));case 11:case"end":return t.stop()}}),t)}))),function(t){return p.apply(this,arguments)})};t.exports=b}).call(this,n(4).Buffer)},function(t,e,n){function r(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(!t)return;if("string"==typeof t)return i(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return i(t,e)}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,a=function(){};return{s:a,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,u=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return s=t.done,t},e:function(t){u=!0,o=t},f:function(){try{s||null==n.return||n.return()}finally{if(u)throw o}}}}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}var a=n(4).Buffer,o=n(11),s=o.ObjectDefineProperty,u=o.ObjectKeys,c=o.ReflectApply,f=n(32).promisify.custom,l=n(336),p=l.streamReturningOperators,d=l.promiseReturningOperators,h=n(14).codes.ERR_ILLEGAL_CONSTRUCTOR,y=n(147),A=n(89).pipeline,b=n(44).destroyer,g=n(37),m=n(152),v=n(33),w=t.exports=n(90).Stream;w.isDisturbed=v.isDisturbed,w.isErrored=v.isErrored,w.isReadable=v.isReadable,w.Readable=n(69);var I,E=r(u(p));try{var _=function(){var t=I.value,e=p[t];function n(){if(this instanceof n?this.constructor:void 0)throw h();for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return w.Readable.from(c(e,this,r))}s(n,"name",{__proto__:null,value:e.name}),s(n,"length",{__proto__:null,value:e.length}),s(w.Readable.prototype,t,{__proto__:null,value:n,enumerable:!1,configurable:!0,writable:!0})};for(E.s();!(I=E.n()).done;)_()}catch(t){E.e(t)}finally{E.f()}var C,k=r(u(d));try{var B=function(){var t=C.value,e=d[t];function n(){if(this instanceof n?this.constructor:void 0)throw h();for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return c(e,this,r)}s(n,"name",{__proto__:null,value:e.name}),s(n,"length",{__proto__:null,value:e.length}),s(w.Readable.prototype,t,{__proto__:null,value:n,enumerable:!1,configurable:!0,writable:!0})};for(k.s();!(C=k.n()).done;)B()}catch(t){k.e(t)}finally{k.f()}w.Writable=n(149),w.Duplex=n(34),w.Transform=n(151),w.PassThrough=n(150),w.pipeline=A;var x=n(70).addAbortSignal;w.addAbortSignal=x,w.finished=g,w.destroy=b,w.compose=y,s(w,"promises",{__proto__:null,configurable:!0,enumerable:!0,get:function(){return m}}),s(A,f,{__proto__:null,enumerable:!0,get:function(){return m.pipeline}}),s(g,f,{__proto__:null,enumerable:!0,get:function(){return m.finished}}),w.Stream=w,w._isUint8Array=function(t){return t instanceof Uint8Array},w._uint8ArrayToBuffer=function(t){return a.from(t.buffer,t.byteOffset,t.byteLength)}},function(t,e,n){"use strict";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)}function i(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */i=function(){return e};var t,e={},n=Object.prototype,a=n.hasOwnProperty,o=Object.defineProperty||function(t,e,n){t[e]=n.value},s="function"==typeof Symbol?Symbol:{},u=s.iterator||"@@iterator",c=s.asyncIterator||"@@asyncIterator",f=s.toStringTag||"@@toStringTag";function l(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,n){return t[e]=n}}function p(t,e,n,r){var i=e&&e.prototype instanceof g?e:g,a=Object.create(i.prototype),s=new M(r||[]);return o(a,"_invoke",{value:B(t,n,s)}),a}function d(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}e.wrap=p;var h="suspendedStart",y="executing",A="completed",b={};function g(){}function m(){}function v(){}var w={};l(w,u,(function(){return this}));var I=Object.getPrototypeOf,E=I&&I(I(R([])));E&&E!==n&&a.call(E,u)&&(w=E);var _=v.prototype=g.prototype=Object.create(w);function C(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function k(t,e){function n(i,o,s,u){var c=d(t[i],t,o);if("throw"!==c.type){var f=c.arg,l=f.value;return l&&"object"==r(l)&&a.call(l,"__await")?e.resolve(l.__await).then((function(t){n("next",t,s,u)}),(function(t){n("throw",t,s,u)})):e.resolve(l).then((function(t){f.value=t,s(f)}),(function(t){return n("throw",t,s,u)}))}u(c.arg)}var i;o(this,"_invoke",{value:function(t,r){function a(){return new e((function(e,i){n(t,r,e,i)}))}return i=i?i.then(a,a):a()}})}function B(e,n,r){var i=h;return function(a,o){if(i===y)throw new Error("Generator is already running");if(i===A){if("throw"===a)throw o;return{value:t,done:!0}}for(r.method=a,r.arg=o;;){var s=r.delegate;if(s){var u=x(s,r);if(u){if(u===b)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===h)throw i=A,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=y;var c=d(e,n,r);if("normal"===c.type){if(i=r.done?A:"suspendedYield",c.arg===b)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(i=A,r.method="throw",r.arg=c.arg)}}}function x(e,n){var r=n.method,i=e.iterator[r];if(i===t)return n.delegate=null,"throw"===r&&e.iterator.return&&(n.method="return",n.arg=t,x(e,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),b;var a=d(i,e.iterator,n.arg);if("throw"===a.type)return n.method="throw",n.arg=a.arg,n.delegate=null,b;var o=a.arg;return o?o.done?(n[e.resultName]=o.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,b):o:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,b)}function S(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function Q(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function M(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(S,this),this.reset(!0)}function R(e){if(e||""===e){var n=e[u];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=function n(){for(;++i<e.length;)if(a.call(e,i))return n.value=e[i],n.done=!1,n;return n.value=t,n.done=!0,n};return o.next=o}}throw new TypeError(r(e)+" is not iterable")}return m.prototype=v,o(_,"constructor",{value:v,configurable:!0}),o(v,"constructor",{value:m,configurable:!0}),m.displayName=l(v,f,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===m||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,v):(t.__proto__=v,l(t,f,"GeneratorFunction")),t.prototype=Object.create(_),t},e.awrap=function(t){return{__await:t}},C(k.prototype),l(k.prototype,c,(function(){return this})),e.AsyncIterator=k,e.async=function(t,n,r,i,a){void 0===a&&(a=Promise);var o=new k(p(t,n,r,i),a);return e.isGeneratorFunction(n)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},C(_),l(_,f,"Generator"),l(_,u,(function(){return this})),l(_,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),n=[];for(var r in e)n.push(r);return n.reverse(),function t(){for(;n.length;){var r=n.pop();if(r in e)return t.value=r,t.done=!1,t}return t.done=!0,t}},e.values=R,M.prototype={constructor:M,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(Q),!e)for(var n in this)"t"===n.charAt(0)&&a.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var n=this;function r(r,i){return s.type="throw",s.arg=e,n.next=r,i&&(n.method="next",n.arg=t),!!i}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],s=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var u=a.call(o,"catchLoc"),c=a.call(o,"finallyLoc");if(u&&c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(u){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&a.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var i=r;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=t,o.arg=e,i?(this.method="next",this.next=i.finallyLoc,b):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),b},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),Q(n),b}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var i=r.arg;Q(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:R(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),b}},e}function a(t,e,n,r,i,a,o){try{var s=t[a](o),u=s.value}catch(t){return void n(t)}s.done?e(u):Promise.resolve(u).then(r,i)}function o(t){return function(){var e=this,n=arguments;return new Promise((function(r,i){var o=t.apply(e,n);function s(t){a(o,r,i,s,u,"next",t)}function u(t){a(o,r,i,s,u,"throw",t)}s(void 0)}))}}var s=n(89).pipeline,u=n(34),c=n(44).destroyer,f=n(33),l=f.isNodeStream,p=f.isReadable,d=f.isWritable,h=f.isWebStream,y=f.isTransformStream,A=f.isWritableStream,b=f.isReadableStream,g=n(14),m=g.AbortError,v=g.codes,w=v.ERR_INVALID_ARG_VALUE,I=v.ERR_MISSING_ARGS,E=n(37);t.exports=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];if(0===e.length)throw new I("streams");if(1===e.length)return u.from(e[0]);var r,a,f,g,v,_=[].concat(e);if("function"==typeof e[0]&&(e[0]=u.from(e[0])),"function"==typeof e[e.length-1]){var C=e.length-1;e[C]=u.from(e[C])}for(var k=0;k<e.length;++k)if(l(e[k])||h(e[k])){if(k<e.length-1&&!(p(e[k])||b(e[k])||y(e[k])))throw new w("streams[".concat(k,"]"),_[k],"must be readable");if(k>0&&!(d(e[k])||A(e[k])||y(e[k])))throw new w("streams[".concat(k,"]"),_[k],"must be writable")}function B(t){var e=g;g=null,e?e(t):t?v.destroy(t):M||Q||v.destroy()}var x=e[0],S=s(e,B),Q=!!(d(x)||A(x)||y(x)),M=!!(p(S)||b(S)||y(S));if(v=new u({writableObjectMode:!(null==x||!x.writableObjectMode),readableObjectMode:!(null==S||!S.writableObjectMode),writable:Q,readable:M}),Q){if(l(x))v._write=function(t,e,n){x.write(t,e)?n():r=n},v._final=function(t){x.end(),a=t},x.on("drain",(function(){if(r){var t=r;r=null,t()}}));else if(h(x)){var R=y(x)?x.writable:x,O=R.getWriter();v._write=function(){var t=o(i().mark((function t(e,n,r){return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,O.ready;case 3:O.write(e).catch((function(){})),r(),t.next=10;break;case 7:t.prev=7,t.t0=t.catch(0),r(t.t0);case 10:case"end":return t.stop()}}),t,null,[[0,7]])})));return function(e,n,r){return t.apply(this,arguments)}}(),v._final=function(){var t=o(i().mark((function t(e){return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,O.ready;case 3:O.close().catch((function(){})),a=e,t.next=10;break;case 7:t.prev=7,t.t0=t.catch(0),e(t.t0);case 10:case"end":return t.stop()}}),t,null,[[0,7]])})));return function(e){return t.apply(this,arguments)}}()}var j=y(S)?S.readable:S;E(j,(function(){if(a){var t=a;a=null,t()}}))}if(M)if(l(S))S.on("readable",(function(){if(f){var t=f;f=null,t()}})),S.on("end",(function(){v.push(null)})),v._read=function(){for(;;){var t=S.read();if(null===t)return void(f=v._read);if(!v.push(t))return}};else if(h(S)){var T=y(S)?S.readable:S,P=T.getReader();v._read=o(i().mark((function t(){var e,n,r;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=1,t.next=4,P.read();case 4:if(e=t.sent,n=e.value,r=e.done,v.push(n)){t.next=9;break}return t.abrupt("return");case 9:if(!r){t.next=12;break}return v.push(null),t.abrupt("return");case 12:t.next=17;break;case 14:return t.prev=14,t.t0=t.catch(1),t.abrupt("return");case 17:t.next=0;break;case 19:case"end":return t.stop()}}),t,null,[[1,14]])})))}return v._destroy=function(t,e){t||null===g||(t=new m),f=null,r=null,a=null,null===g?e(t):(g=e,l(S)&&c(S,t))},v}},function(t,e,n){"use strict";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)}function i(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */i=function(){return e};var t,e={},n=Object.prototype,a=n.hasOwnProperty,o=Object.defineProperty||function(t,e,n){t[e]=n.value},s="function"==typeof Symbol?Symbol:{},u=s.iterator||"@@iterator",c=s.asyncIterator||"@@asyncIterator",f=s.toStringTag||"@@toStringTag";function l(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,n){return t[e]=n}}function p(t,e,n,r){var i=e&&e.prototype instanceof g?e:g,a=Object.create(i.prototype),s=new M(r||[]);return o(a,"_invoke",{value:B(t,n,s)}),a}function d(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}e.wrap=p;var h="suspendedStart",y="executing",A="completed",b={};function g(){}function m(){}function v(){}var w={};l(w,u,(function(){return this}));var I=Object.getPrototypeOf,E=I&&I(I(R([])));E&&E!==n&&a.call(E,u)&&(w=E);var _=v.prototype=g.prototype=Object.create(w);function C(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function k(t,e){function n(i,o,s,u){var c=d(t[i],t,o);if("throw"!==c.type){var f=c.arg,l=f.value;return l&&"object"==r(l)&&a.call(l,"__await")?e.resolve(l.__await).then((function(t){n("next",t,s,u)}),(function(t){n("throw",t,s,u)})):e.resolve(l).then((function(t){f.value=t,s(f)}),(function(t){return n("throw",t,s,u)}))}u(c.arg)}var i;o(this,"_invoke",{value:function(t,r){function a(){return new e((function(e,i){n(t,r,e,i)}))}return i=i?i.then(a,a):a()}})}function B(e,n,r){var i=h;return function(a,o){if(i===y)throw new Error("Generator is already running");if(i===A){if("throw"===a)throw o;return{value:t,done:!0}}for(r.method=a,r.arg=o;;){var s=r.delegate;if(s){var u=x(s,r);if(u){if(u===b)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===h)throw i=A,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=y;var c=d(e,n,r);if("normal"===c.type){if(i=r.done?A:"suspendedYield",c.arg===b)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(i=A,r.method="throw",r.arg=c.arg)}}}function x(e,n){var r=n.method,i=e.iterator[r];if(i===t)return n.delegate=null,"throw"===r&&e.iterator.return&&(n.method="return",n.arg=t,x(e,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),b;var a=d(i,e.iterator,n.arg);if("throw"===a.type)return n.method="throw",n.arg=a.arg,n.delegate=null,b;var o=a.arg;return o?o.done?(n[e.resultName]=o.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,b):o:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,b)}function S(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function Q(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function M(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(S,this),this.reset(!0)}function R(e){if(e||""===e){var n=e[u];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=function n(){for(;++i<e.length;)if(a.call(e,i))return n.value=e[i],n.done=!1,n;return n.value=t,n.done=!0,n};return o.next=o}}throw new TypeError(r(e)+" is not iterable")}return m.prototype=v,o(_,"constructor",{value:v,configurable:!0}),o(v,"constructor",{value:m,configurable:!0}),m.displayName=l(v,f,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===m||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,v):(t.__proto__=v,l(t,f,"GeneratorFunction")),t.prototype=Object.create(_),t},e.awrap=function(t){return{__await:t}},C(k.prototype),l(k.prototype,c,(function(){return this})),e.AsyncIterator=k,e.async=function(t,n,r,i,a){void 0===a&&(a=Promise);var o=new k(p(t,n,r,i),a);return e.isGeneratorFunction(n)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},C(_),l(_,f,"Generator"),l(_,u,(function(){return this})),l(_,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),n=[];for(var r in e)n.push(r);return n.reverse(),function t(){for(;n.length;){var r=n.pop();if(r in e)return t.value=r,t.done=!1,t}return t.done=!0,t}},e.values=R,M.prototype={constructor:M,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(Q),!e)for(var n in this)"t"===n.charAt(0)&&a.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var n=this;function r(r,i){return s.type="throw",s.arg=e,n.next=r,i&&(n.method="next",n.arg=t),!!i}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],s=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var u=a.call(o,"catchLoc"),c=a.call(o,"finallyLoc");if(u&&c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(u){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&a.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var i=r;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=t,o.arg=e,i?(this.method="next",this.next=i.finallyLoc,b):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),b},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),Q(n),b}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var i=r.arg;Q(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:R(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),b}},e}function a(t,e,n,r,i,a,o){try{var s=t[a](o),u=s.value}catch(t){return void n(t)}s.done?e(u):Promise.resolve(u).then(r,i)}function o(t){return function(){var e=this,n=arguments;return new Promise((function(r,i){var o=t.apply(e,n);function s(t){a(o,r,i,s,u,"next",t)}function u(t){a(o,r,i,s,u,"throw",t)}s(void 0)}))}}function s(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 u(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?s(Object(n),!0).forEach((function(e){c(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):s(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function c(t,e,n){return(e=function(t){var e=function(t,e){if("object"!==r(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,e||"default");if("object"!==r(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"===r(e)?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var f=n(6),l=n(11),p=l.PromisePrototypeThen,d=l.SymbolAsyncIterator,h=l.SymbolIterator,y=n(4).Buffer,A=n(14).codes,b=A.ERR_INVALID_ARG_TYPE,g=A.ERR_STREAM_NULL_VALUES;t.exports=function(t,e,n){var r,a;if("string"==typeof e||e instanceof y)return new t(u(u({objectMode:!0},n),{},{read:function(){this.push(e),this.push(null)}}));if(e&&e[d])a=!0,r=e[d]();else{if(!e||!e[h])throw new b("iterable",["Iterable"],e);a=!1,r=e[h]()}var s=new t(u({objectMode:!0,highWaterMark:1},n)),c=!1;function l(){return(l=o(i().mark((function t(e){var n,a,o,s,u,c,f;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=null!=e,a="function"==typeof r.throw,!n||!a){t.next=12;break}return t.next=5,r.throw(e);case 5:return o=t.sent,s=o.value,u=o.done,t.next=10,s;case 10:if(!u){t.next=12;break}return t.abrupt("return");case 12:if("function"!=typeof r.return){t.next=19;break}return t.next=15,r.return();case 15:return c=t.sent,f=c.value,t.next=19,f;case 19:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function A(){return(A=o(i().mark((function t(){var e,n,o;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(t.prev=0,!a){t.next=7;break}return t.next=4,r.next();case 4:t.t0=t.sent,t.next=8;break;case 7:t.t0=r.next();case 8:if(e=t.t0,n=e.value,!e.done){t.next=15;break}s.push(null),t.next=33;break;case 15:if(!n||"function"!=typeof n.then){t.next=21;break}return t.next=18,n;case 18:t.t1=t.sent,t.next=22;break;case 21:t.t1=n;case 22:if(null!==(o=t.t1)){t.next=28;break}throw c=!1,new g;case 28:if(!s.push(o)){t.next=32;break}return t.abrupt("continue",39);case 32:c=!1;case 33:t.next=38;break;case 35:t.prev=35,t.t2=t.catch(0),s.destroy(t.t2);case 38:return t.abrupt("break",41);case 39:t.next=0;break;case 41:case"end":return t.stop()}}),t,null,[[0,35]])})))).apply(this,arguments)}return s._read=function(){c||(c=!0,function(){A.apply(this,arguments)}())},s._destroy=function(t,e){p(function(t){return l.apply(this,arguments)}(t),(function(){return f.nextTick(e,t)}),(function(n){return f.nextTick(e,n||t)}))},s}},function(t,e,n){var r=n(6),i=n(11),a=i.ArrayPrototypeSlice,o=i.Error,s=i.FunctionPrototypeSymbolHasInstance,u=i.ObjectDefineProperty,c=i.ObjectDefineProperties,f=i.ObjectSetPrototypeOf,l=i.StringPrototypeToLowerCase,p=i.Symbol,d=i.SymbolHasInstance;t.exports=D,D.WritableState=T;var h=n(20).EventEmitter,y=n(90).Stream,A=n(4).Buffer,b=n(44),g=n(70).addAbortSignal,m=n(91),v=m.getHighWaterMark,w=m.getDefaultHighWaterMark,I=n(14).codes,E=I.ERR_INVALID_ARG_TYPE,_=I.ERR_METHOD_NOT_IMPLEMENTED,C=I.ERR_MULTIPLE_CALLBACK,k=I.ERR_STREAM_CANNOT_PIPE,B=I.ERR_STREAM_DESTROYED,x=I.ERR_STREAM_ALREADY_FINISHED,S=I.ERR_STREAM_NULL_VALUES,Q=I.ERR_STREAM_WRITE_AFTER_END,M=I.ERR_UNKNOWN_ENCODING,R=b.errorOrDestroy;function O(){}f(D.prototype,y.prototype),f(D,y);var j=p("kOnFinished");function T(t,e,r){"boolean"!=typeof r&&(r=e instanceof n(34)),this.objectMode=!(!t||!t.objectMode),r&&(this.objectMode=this.objectMode||!(!t||!t.writableObjectMode)),this.highWaterMark=t?v(this,t,"writableHighWaterMark",r):w(!1),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var i=!(!t||!1!==t.decodeStrings);this.decodeStrings=!i,this.defaultEncoding=t&&t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=U.bind(void 0,e),this.writecb=null,this.writelen=0,this.afterWriteTickInfo=null,P(this),this.pendingcb=0,this.constructed=!0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!t||!1!==t.emitClose,this.autoDestroy=!t||!1!==t.autoDestroy,this.errored=null,this.closed=!1,this.closeEmitted=!1,this[j]=[]}function P(t){t.buffered=[],t.bufferedIndex=0,t.allBuffers=!0,t.allNoop=!0}function D(t){var e=this,r=this instanceof n(34);if(!r&&!s(D,this))return new D(t);this._writableState=new T(t,this,r),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),"function"==typeof t.construct&&(this._construct=t.construct),t.signal&&g(t.signal,this)),y.call(this,t),b.construct(this,(function(){var t=e._writableState;t.writing||K(e,t),J(e,t)}))}function N(t,e,n,i){var a,o=t._writableState;if("function"==typeof n)i=n,n=o.defaultEncoding;else{if(n){if("buffer"!==n&&!A.isEncoding(n))throw new M(n)}else n=o.defaultEncoding;"function"!=typeof i&&(i=O)}if(null===e)throw new S;if(!o.objectMode)if("string"==typeof e)!1!==o.decodeStrings&&(e=A.from(e,n),n="buffer");else if(e instanceof A)n="buffer";else{if(!y._isUint8Array(e))throw new E("chunk",["string","Buffer","Uint8Array"],e);e=y._uint8ArrayToBuffer(e),n="buffer"}return o.ending?a=new Q:o.destroyed&&(a=new B("write")),a?(r.nextTick(i,a),R(t,a,!0),a):(o.pendingcb++,function(t,e,n,r,i){var a=e.objectMode?1:n.length;e.length+=a;var o=e.length<e.highWaterMark;o||(e.needDrain=!0);e.writing||e.corked||e.errored||!e.constructed?(e.buffered.push({chunk:n,encoding:r,callback:i}),e.allBuffers&&"buffer"!==r&&(e.allBuffers=!1),e.allNoop&&i!==O&&(e.allNoop=!1)):(e.writelen=a,e.writecb=i,e.writing=!0,e.sync=!0,t._write(n,r,e.onwrite),e.sync=!1);return o&&!e.errored&&!e.destroyed}(t,o,e,n,i))}function L(t,e,n,r,i,a,o){e.writelen=r,e.writecb=o,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new B("write")):n?t._writev(i,e.onwrite):t._write(i,a,e.onwrite),e.sync=!1}function F(t,e,n,r){--e.pendingcb,r(n),q(e),R(t,n)}function U(t,e){var n=t._writableState,i=n.sync,a=n.writecb;"function"==typeof a?(n.writing=!1,n.writecb=null,n.length-=n.writelen,n.writelen=0,e?(e.stack,n.errored||(n.errored=e),t._readableState&&!t._readableState.errored&&(t._readableState.errored=e),i?r.nextTick(F,t,n,e,a):F(t,n,e,a)):(n.buffered.length>n.bufferedIndex&&K(t,n),i?null!==n.afterWriteTickInfo&&n.afterWriteTickInfo.cb===a?n.afterWriteTickInfo.count++:(n.afterWriteTickInfo={count:1,cb:a,stream:t,state:n},r.nextTick(H,n.afterWriteTickInfo)):G(t,n,1,a))):R(t,new C)}function H(t){var e=t.stream,n=t.state,r=t.count,i=t.cb;return n.afterWriteTickInfo=null,G(e,n,r,i)}function G(t,e,n,r){for(!e.ending&&!t.destroyed&&0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"));n-- >0;)e.pendingcb--,r();e.destroyed&&q(e),J(t,e)}function q(t){if(!t.writing){for(var e=t.bufferedIndex;e<t.buffered.length;++e){var n,r=t.buffered[e],i=r.chunk,a=r.callback,o=t.objectMode?1:i.length;t.length-=o,a(null!==(n=t.errored)&&void 0!==n?n:new B("write"))}for(var s=t[j].splice(0),u=0;u<s.length;u++){var c;s[u](null!==(c=t.errored)&&void 0!==c?c:new B("end"))}P(t)}}function K(t,e){if(!(e.corked||e.bufferProcessing||e.destroyed)&&e.constructed){var n=e.buffered,r=e.bufferedIndex,i=e.objectMode,o=n.length-r;if(o){var s=r;if(e.bufferProcessing=!0,o>1&&t._writev){e.pendingcb-=o-1;var u=e.allNoop?O:function(t){for(var e=s;e<n.length;++e)n[e].callback(t)},c=e.allNoop&&0===s?n:a(n,s);c.allBuffers=e.allBuffers,L(t,e,!0,e.length,c,"",u),P(e)}else{do{var f=n[s],l=f.chunk,p=f.encoding,d=f.callback;n[s++]=null,L(t,e,!1,i?1:l.length,l,p,d)}while(s<n.length&&!e.writing);s===n.length?P(e):s>256?(n.splice(0,s),e.bufferedIndex=0):e.bufferedIndex=s}e.bufferProcessing=!1}}}function Y(t){return t.ending&&!t.destroyed&&t.constructed&&0===t.length&&!t.errored&&0===t.buffered.length&&!t.finished&&!t.writing&&!t.errorEmitted&&!t.closeEmitted}function z(t,e){e.prefinished||e.finalCalled||("function"!=typeof t._final||e.destroyed?(e.prefinished=!0,t.emit("prefinish")):(e.finalCalled=!0,function(t,e){var n=!1;function i(i){if(n)R(t,null!=i?i:C());else if(n=!0,e.pendingcb--,i){for(var a=e[j].splice(0),o=0;o<a.length;o++)a[o](i);R(t,i,e.sync)}else Y(e)&&(e.prefinished=!0,t.emit("prefinish"),e.pendingcb++,r.nextTick(W,t,e))}e.sync=!0,e.pendingcb++;try{t._final(i)}catch(t){i(t)}e.sync=!1}(t,e)))}function J(t,e,n){Y(e)&&(z(t,e),0===e.pendingcb&&(n?(e.pendingcb++,r.nextTick((function(t,e){Y(e)?W(t,e):e.pendingcb--}),t,e)):Y(e)&&(e.pendingcb++,W(t,e))))}function W(t,e){e.pendingcb--,e.finished=!0;for(var n=e[j].splice(0),r=0;r<n.length;r++)n[r]();if(t.emit("finish"),e.autoDestroy){var i=t._readableState;(!i||i.autoDestroy&&(i.endEmitted||!1===i.readable))&&t.destroy()}}T.prototype.getBuffer=function(){return a(this.buffered,this.bufferedIndex)},u(T.prototype,"bufferedRequestCount",{__proto__:null,get:function(){return this.buffered.length-this.bufferedIndex}}),u(D,d,{__proto__:null,value:function(t){return!!s(this,t)||this===D&&(t&&t._writableState instanceof T)}}),D.prototype.pipe=function(){R(this,new k)},D.prototype.write=function(t,e,n){return!0===N(this,t,e,n)},D.prototype.cork=function(){this._writableState.corked++},D.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,t.writing||K(this,t))},D.prototype.setDefaultEncoding=function(t){if("string"==typeof t&&(t=l(t)),!A.isEncoding(t))throw new M(t);return this._writableState.defaultEncoding=t,this},D.prototype._write=function(t,e,n){if(!this._writev)throw new _("_write()");this._writev([{chunk:t,encoding:e}],n)},D.prototype._writev=null,D.prototype.end=function(t,e,n){var i,a=this._writableState;if("function"==typeof t?(n=t,t=null,e=null):"function"==typeof e&&(n=e,e=null),null!=t){var s=N(this,t,e);s instanceof o&&(i=s)}return a.corked&&(a.corked=1,this.uncork()),i||(a.errored||a.ending?a.finished?i=new x("end"):a.destroyed&&(i=new B("end")):(a.ending=!0,J(this,a,!0),a.ended=!0)),"function"==typeof n&&(i||a.finished?r.nextTick(n,i):a[j].push(n)),this},c(D.prototype,{closed:{__proto__:null,get:function(){return!!this._writableState&&this._writableState.closed}},destroyed:{__proto__:null,get:function(){return!!this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}},writable:{__proto__:null,get:function(){var t=this._writableState;return!(!t||!1===t.writable||t.destroyed||t.errored||t.ending||t.ended)},set:function(t){this._writableState&&(this._writableState.writable=!!t)}},writableFinished:{__proto__:null,get:function(){return!!this._writableState&&this._writableState.finished}},writableObjectMode:{__proto__:null,get:function(){return!!this._writableState&&this._writableState.objectMode}},writableBuffer:{__proto__:null,get:function(){return this._writableState&&this._writableState.getBuffer()}},writableEnded:{__proto__:null,get:function(){return!!this._writableState&&this._writableState.ending}},writableNeedDrain:{__proto__:null,get:function(){var t=this._writableState;return!!t&&(!t.destroyed&&!t.ending&&t.needDrain)}},writableHighWaterMark:{__proto__:null,get:function(){return this._writableState&&this._writableState.highWaterMark}},writableCorked:{__proto__:null,get:function(){return this._writableState?this._writableState.corked:0}},writableLength:{__proto__:null,get:function(){return this._writableState&&this._writableState.length}},errored:{__proto__:null,enumerable:!1,get:function(){return this._writableState?this._writableState.errored:null}},writableAborted:{__proto__:null,enumerable:!1,get:function(){return!(!1===this._writableState.writable||!this._writableState.destroyed&&!this._writableState.errored||this._writableState.finished)}}});var V,Z=b.destroy;function X(){return void 0===V&&(V={}),V}D.prototype.destroy=function(t,e){var n=this._writableState;return!n.destroyed&&(n.bufferedIndex<n.buffered.length||n[j].length)&&r.nextTick(q,n),Z.call(this,t,e),this},D.prototype._undestroy=b.undestroy,D.prototype._destroy=function(t,e){e(t)},D.prototype[h.captureRejectionSymbol]=function(t){this.destroy(t)},D.fromWeb=function(t,e){return X().newStreamWritableFromWritableStream(t,e)},D.toWeb=function(t){return X().newWritableStreamFromStreamWritable(t)}},function(t,e,n){"use strict";var r=n(11).ObjectSetPrototypeOf;t.exports=a;var i=n(151);function a(t){if(!(this instanceof a))return new a(t);i.call(this,t)}r(a.prototype,i.prototype),r(a,i),a.prototype._transform=function(t,e,n){n(null,t)}},function(t,e,n){"use strict";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)}function i(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 a(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?i(Object(n),!0).forEach((function(e){o(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function o(t,e,n){return(e=function(t){var e=function(t,e){if("object"!==r(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,e||"default");if("object"!==r(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"===r(e)?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var s=n(11),u=s.ObjectSetPrototypeOf,c=s.Symbol;t.exports=h;var f=n(14).codes.ERR_METHOD_NOT_IMPLEMENTED,l=n(34),p=n(91).getHighWaterMark;u(h.prototype,l.prototype),u(h,l);var d=c("kCallback");function h(t){if(!(this instanceof h))return new h(t);var e=t?p(this,t,"readableHighWaterMark",!0):null;0===e&&(t=a(a({},t),{},{highWaterMark:null,readableHighWaterMark:e,writableHighWaterMark:t.writableHighWaterMark||0})),l.call(this,t),this._readableState.sync=!1,this[d]=null,t&&("function"==typeof t.transform&&(this._transform=t.transform),"function"==typeof t.flush&&(this._flush=t.flush)),this.on("prefinish",A)}function y(t){var e=this;"function"!=typeof this._flush||this.destroyed?(this.push(null),t&&t()):this._flush((function(n,r){n?t?t(n):e.destroy(n):(null!=r&&e.push(r),e.push(null),t&&t())}))}function A(){this._final!==y&&y.call(this)}h.prototype._final=y,h.prototype._transform=function(t,e,n){throw new f("_transform()")},h.prototype._write=function(t,e,n){var r=this,i=this._readableState,a=this._writableState,o=i.length;this._transform(t,e,(function(t,e){t?n(t):(null!=e&&r.push(e),a.ended||o===i.length||i.length<i.highWaterMark?n():r[d]=n)}))},h.prototype._read=function(){if(this[d]){var t=this[d];this[d]=null,t()}}},function(t,e,n){"use strict";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 i=n(11),a=i.ArrayPrototypePop,o=i.Promise,s=n(33),u=s.isIterable,c=s.isNodeStream,f=s.isWebStream,l=n(89).pipelineImpl,p=n(37).finished;n(146),t.exports={finished:p,pipeline:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return new o((function(t,n){var i,o,s=e[e.length-1];if(s&&"object"===r(s)&&!c(s)&&!u(s)&&!f(s)){var p=a(e);i=p.signal,o=p.end}l(e,(function(e,r){e?n(e):t(r)}),{signal:i,end:o})}))}}},function(t,e,n){"use strict";var r=n(5).Buffer,i=n(340).Transform;function a(t){i.call(this),this._block=r.allocUnsafe(t),this._blockSize=t,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}n(3)(a,i),a.prototype._transform=function(t,e,n){var r=null;try{this.update(t,e)}catch(t){r=t}n(r)},a.prototype._flush=function(t){var e=null;try{this.push(this.digest())}catch(t){e=t}t(e)},a.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,i=0;this._blockOffset+t.length-i>=this._blockSize;){for(var a=this._blockOffset;a<this._blockSize;)n[a++]=t[i++];this._update(),this._blockOffset=0}for(;i<t.length;)n[this._blockOffset++]=t[i++];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},a.prototype._update=function(){throw new Error("_update is not implemented")},a.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},a.prototype._digest=function(){throw new Error("_digest is not implemented")},t.exports=a},function(t,e,n){"use strict";(function(e,r){var i;t.exports=C,C.ReadableState=_;n(20).EventEmitter;var a=function(t,e){return t.listeners(e).length},o=n(155),s=n(4).Buffer,u=(void 0!==e?e:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){};var c,f=n(341);c=f&&f.debuglog?f.debuglog("stream"):function(){};var l,p,d,h=n(342),y=n(156),A=n(157).getHighWaterMark,b=n(46).codes,g=b.ERR_INVALID_ARG_TYPE,m=b.ERR_STREAM_PUSH_AFTER_EOF,v=b.ERR_METHOD_NOT_IMPLEMENTED,w=b.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;n(3)(C,o);var I=y.errorOrDestroy,E=["error","close","destroy","pause","resume"];function _(t,e,r){i=i||n(47),t=t||{},"boolean"!=typeof r&&(r=e instanceof i),this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=A(this,t,"readableHighWaterMark",r),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.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&&(l||(l=n(29).StringDecoder),this.decoder=new l(t.encoding),this.encoding=t.encoding)}function C(t){if(i=i||n(47),!(this instanceof C))return new C(t);var e=this instanceof i;this._readableState=new _(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,i){c("readableAddChunk",e);var a,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,Q(t)))}(t,o);else if(i||(a=function(t,e){var n;r=e,s.isBuffer(r)||r instanceof u||"string"==typeof e||void 0===e||t.objectMode||(n=new g("chunk",["string","Buffer","Uint8Array"],e));var r;return n}(o,e)),a)I(t,a);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?I(t,new w):B(t,o,e,!0);else if(o.ended)I(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?B(t,o,e,!1):M(t,o)):B(t,o,e,!1)}else r||(o.reading=!1,M(t,o));return!o.ended&&(o.length<o.highWaterMark||0===o.length)}function B(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(C.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(t){this._readableState&&(this._readableState.destroyed=t)}}),C.prototype.destroy=y.destroy,C.prototype._undestroy=y.undestroy,C.prototype._destroy=function(t,e){e(t)},C.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)},C.prototype.unshift=function(t){return k(this,t,null,!0,!1)},C.prototype.isPaused=function(){return!1===this._readableState.flowing},C.prototype.setEncoding=function(t){l||(l=n(29).StringDecoder);var e=new l(t);this._readableState.decoder=e,this._readableState.encoding=this._readableState.decoder.encoding;for(var r=this._readableState.buffer.head,i="";null!==r;)i+=e.write(r.data),r=r.next;return this._readableState.buffer.clear(),""!==i&&this._readableState.buffer.push(i),this._readableState.length=i.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(Q,t))}function Q(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,P(t)}function M(t,e){e.readingMore||(e.readingMore=!0,r.nextTick(R,t,e))}function R(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 O(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 j(t){c("readable nexttick read 0"),t.read(0)}function T(t,e){c("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),P(t),e.flowing&&!e.reading&&t.read(0)}function P(t){var e=t._readableState;for(c("flow",e.flowing);e.flowing&&null!==t.read(););}function D(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 N(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}C.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?N(this):S(this),null;if(0===(t=x(t,e))&&e.ended)return 0===e.length&&N(this),null;var r,i=e.needReadable;return c("need readable",i),(0===e.length||e.length-t<e.highWaterMark)&&c("length less than watermark",i=!0),e.ended||e.reading?c("reading or ended",i=!1):i&&(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?D(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&&N(this)),null!==r&&this.emit("data",r),r},C.prototype._read=function(t){I(this,new v("_read()"))},C.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,c("pipe count=%d opts=%j",i.pipesCount,e);var o=(!e||!1!==e.end)&&t!==r.stdout&&t!==r.stderr?u:A;function s(e,r){c("onunpipe"),e===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,c("cleanup"),t.removeListener("close",h),t.removeListener("finish",y),t.removeListener("drain",f),t.removeListener("error",d),t.removeListener("unpipe",s),n.removeListener("end",u),n.removeListener("end",A),n.removeListener("data",p),l=!0,!i.awaitDrain||t._writableState&&!t._writableState.needDrain||f())}function u(){c("onend"),t.end()}i.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&&a(t,"data")&&(e.flowing=!0,P(t))}}(n);t.on("drain",f);var l=!1;function p(e){c("ondata");var r=t.write(e);c("dest.write",r),!1===r&&((1===i.pipesCount&&i.pipes===t||i.pipesCount>1&&-1!==F(i.pipes,t))&&!l&&(c("false write response, pause",i.awaitDrain),i.awaitDrain++),n.pause())}function d(e){c("onerror",e),A(),t.removeListener("error",d),0===a(t,"error")&&I(t,e)}function h(){t.removeListener("finish",y),A()}function y(){c("onfinish"),t.removeListener("close",h),A()}function A(){c("unpipe"),n.unpipe(t)}return n.on("data",p),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",d),t.once("close",h),t.once("finish",y),t.emit("pipe",n),i.flowing||(c("pipe resume"),n.resume()),t},C.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,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var a=0;a<i;a++)r[a].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},C.prototype.on=function(t,e){var n=o.prototype.on.call(this,t,e),i=this._readableState;return"data"===t?(i.readableListening=this.listenerCount("readable")>0,!1!==i.flowing&&this.resume()):"readable"===t&&(i.endEmitted||i.readableListening||(i.readableListening=i.needReadable=!0,i.flowing=!1,i.emittedReadable=!1,c("on readable",i.length,i.reading),i.length?S(this):i.reading||r.nextTick(j,this))),n},C.prototype.addListener=C.prototype.on,C.prototype.removeListener=function(t,e){var n=o.prototype.removeListener.call(this,t,e);return"readable"===t&&r.nextTick(O,this),n},C.prototype.removeAllListeners=function(t){var e=o.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||r.nextTick(O,this),e},C.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(T,t,e))}(this,t)),t.paused=!1,this},C.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},C.prototype.wrap=function(t){var e=this,n=this._readableState,r=!1;for(var i 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(i){(c("wrapped data"),n.decoder&&(i=n.decoder.write(i)),n.objectMode&&null==i)||(n.objectMode||i&&i.length)&&(e.push(i)||(r=!0,t.pause()))})),t)void 0===this[i]&&"function"==typeof t[i]&&(this[i]=function(e){return function(){return t[e].apply(t,arguments)}}(i));for(var a=0;a<E.length;a++)t.on(E[a],this.emit.bind(this,E[a]));return this._read=function(e){c("wrapped _read",e),r&&(r=!1,t.resume())},this},"function"==typeof Symbol&&(C.prototype[Symbol.asyncIterator]=function(){return void 0===p&&(p=n(344)),p(this)}),Object.defineProperty(C.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(C.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(C.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(t){this._readableState&&(this._readableState.flowing=t)}}),C._fromList=D,Object.defineProperty(C.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),"function"==typeof Symbol&&(C.from=function(t,e){return void 0===d&&(d=n(345)),d(C,t,e)})}).call(this,n(8),n(6))},function(t,e,n){t.exports=n(20).EventEmitter},function(t,e,n){"use strict";(function(e){function n(t,e){i(t,e),r(t)}function r(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit("close")}function i(t,e){t.emit("error",e)}t.exports={destroy:function(t,a){var o=this,s=this._readableState&&this._readableState.destroyed,u=this._writableState&&this._writableState.destroyed;return s||u?(a?a(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,e.nextTick(i,this,t)):e.nextTick(i,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,(function(t){!a&&t?o._writableState?o._writableState.errorEmitted?e.nextTick(r,o):(o._writableState.errorEmitted=!0,e.nextTick(n,o,t)):e.nextTick(n,o,t):a?(e.nextTick(r,o),a(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(6))},function(t,e,n){"use strict";var r=n(46).codes.ERR_INVALID_OPT_VALUE;t.exports={getHighWaterMark:function(t,e,n,i){var a=function(t,e,n){return null!=t.highWaterMark?t.highWaterMark:e?t[n]:null}(e,i,n);if(null!=a){if(!isFinite(a)||Math.floor(a)!==a||a<0)throw new r(i?n:"highWaterMark",a);return Math.floor(a)}return t.objectMode?16:16384}}},function(t,e,n){"use strict";(function(e,r){function i(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 i=r.callback;e.pendingcb--,i(n),r=r.next}e.corkedRequestsFree.next=t}(e,t)}}var a;t.exports=C,C.WritableState=_;var o={deprecate:n(71)},s=n(155),u=n(4).Buffer,c=(void 0!==e?e:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){};var f,l=n(156),p=n(157).getHighWaterMark,d=n(46).codes,h=d.ERR_INVALID_ARG_TYPE,y=d.ERR_METHOD_NOT_IMPLEMENTED,A=d.ERR_MULTIPLE_CALLBACK,b=d.ERR_STREAM_CANNOT_PIPE,g=d.ERR_STREAM_DESTROYED,m=d.ERR_STREAM_NULL_VALUES,v=d.ERR_STREAM_WRITE_AFTER_END,w=d.ERR_UNKNOWN_ENCODING,I=l.errorOrDestroy;function E(){}function _(t,e,o){a=a||n(47),t=t||{},"boolean"!=typeof o&&(o=e instanceof a),this.objectMode=!!t.objectMode,o&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=p(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,i=n.sync,a=n.writecb;if("function"!=typeof a)throw new A;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(n),e)!function(t,e,n,i,a){--e.pendingcb,n?(r.nextTick(a,i),r.nextTick(M,t,e),t._writableState.errorEmitted=!0,I(t,i)):(a(i),t._writableState.errorEmitted=!0,I(t,i),M(t,e))}(t,n,i,e,a);else{var o=S(n)||t.destroyed;o||n.corked||n.bufferProcessing||!n.bufferedRequest||x(t,n),i?r.nextTick(B,t,n,o,a):B(t,n,o,a)}}(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 i(this)}function C(t){var e=this instanceof(a=a||n(47));if(!e&&!f.call(C,this))return new C(t);this._writableState=new _(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,i,a,o){e.writelen=r,e.writecb=o,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new g("write")):n?t._writev(i,e.onwrite):t._write(i,a,e.onwrite),e.sync=!1}function B(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,a=new Array(r),o=e.corkedRequestsFree;o.entry=n;for(var s=0,u=!0;n;)a[s]=n,n.isBuf||(u=!1),n=n.next,s+=1;a.allBuffers=u,k(t,e,!0,e.length,a,"",o.finish),e.pendingcb++,e.lastBufferedRequest=null,o.next?(e.corkedRequestsFree=o.next,o.next=null):e.corkedRequestsFree=new i(e),e.bufferedRequestCount=0}else{for(;n;){var c=n.chunk,f=n.encoding,l=n.callback;if(k(t,e,!1,e.objectMode?1:c.length,c,f,l),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 Q(t,e){t._final((function(n){e.pendingcb--,n&&I(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(Q,t,e)))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit("finish"),e.autoDestroy))){var i=t._readableState;(!i||i.autoDestroy&&i.endEmitted)&&t.destroy()}return n}n(3)(C,s),_.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(_.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(C,Symbol.hasInstance,{value:function(t){return!!f.call(this,t)||this===C&&(t&&t._writableState instanceof _)}})):f=function(t){return t instanceof this},C.prototype.pipe=function(){I(this,new b)},C.prototype.write=function(t,e,n){var i,a=this._writableState,o=!1,s=!a.objectMode&&(i=t,u.isBuffer(i)||i 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=a.defaultEncoding),"function"!=typeof n&&(n=E),a.ending?function(t,e){var n=new v;I(t,n),r.nextTick(e,n)}(this,n):(s||function(t,e,n,i){var a;return null===n?a=new m:"string"==typeof n||e.objectMode||(a=new h("chunk",["string","Buffer"],n)),!a||(I(t,a),r.nextTick(i,a),!1)}(this,a,t,n))&&(a.pendingcb++,o=function(t,e,n,r,i,a){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,i);r!==o&&(n=!0,i="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:i,isBuf:n,callback:a,next:null},f?f.next=e.lastBufferedRequest:e.bufferedRequest=e.lastBufferedRequest,e.bufferedRequestCount+=1}else k(t,e,!1,s,r,i,a);return c}(this,a,s,t,e,n)),o},C.prototype.cork=function(){this._writableState.corked++},C.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,t.writing||t.corked||t.bufferProcessing||!t.bufferedRequest||x(this,t))},C.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 w(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(C.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(C.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),C.prototype._write=function(t,e,n){n(new y("_write()"))},C.prototype._writev=null,C.prototype.end=function(t,e,n){var i=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),i.corked&&(i.corked=1,this.uncork()),i.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,i,n),this},Object.defineProperty(C.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(C.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),C.prototype.destroy=l.destroy,C.prototype._undestroy=l.undestroy,C.prototype._destroy=function(t,e){e(t)}}).call(this,n(8),n(6))},function(t,e,n){"use strict";t.exports=f;var r=n(46).codes,i=r.ERR_METHOD_NOT_IMPLEMENTED,a=r.ERR_MULTIPLE_CALLBACK,o=r.ERR_TRANSFORM_ALREADY_TRANSFORMING,s=r.ERR_TRANSFORM_WITH_LENGTH_0,u=n(47);function c(t,e){var n=this._transformState;n.transforming=!1;var r=n.writecb;if(null===r)return this.emit("error",new a);n.writechunk=null,n.writecb=null,null!=e&&this.push(e),r(t);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.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",l)}function l(){var t=this;"function"!=typeof this._flush||this._readableState.destroyed?p(this,null,null):this._flush((function(e,n){p(t,e,n)}))}function p(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 i("_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 i=this._readableState;(r.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.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),i=n(48),a=n(5).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,i.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 l(t){return(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10)}function p(t){return(t>>>6|t<<26)^(t>>>11|t<<21)^(t>>>25|t<<7)}function d(t){return(t>>>7|t<<25)^(t>>>18|t<<14)^t>>>3}r(u,i),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,i=0|this._b,a=0|this._c,s=0|this._d,u=0|this._e,h=0|this._f,y=0|this._g,A=0|this._h,b=0;b<16;++b)n[b]=t.readInt32BE(4*b);for(;b<64;++b)n[b]=0|(((e=n[b-2])>>>17|e<<15)^(e>>>19|e<<13)^e>>>10)+n[b-7]+d(n[b-15])+n[b-16];for(var g=0;g<64;++g){var m=A+p(u)+c(u,h,y)+o[g]+n[g]|0,v=l(r)+f(r,i,a)|0;A=y,y=h,h=u,u=s+m|0,s=a,a=i,i=r,r=m+v|0}this._a=r+this._a|0,this._b=i+this._b|0,this._c=a+this._c|0,this._d=s+this._d|0,this._e=u+this._e|0,this._f=h+this._f|0,this._g=y+this._g|0,this._h=A+this._h|0},u.prototype._hash=function(){var t=a.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),i=n(48),a=n(5).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,i.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 l(t,e){return(t>>>28|e<<4)^(e>>>2|t<<30)^(e>>>7|t<<25)}function p(t,e){return(t>>>14|e<<18)^(t>>>18|e<<14)^(e>>>9|t<<23)}function d(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^t>>>7}function h(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^(t>>>7|e<<25)}function y(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^t>>>6}function A(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^(t>>>6|e<<26)}function b(t,e){return t>>>0<e>>>0?1:0}r(u,i),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,i=0|this._ch,a=0|this._dh,s=0|this._eh,u=0|this._fh,g=0|this._gh,m=0|this._hh,v=0|this._al,w=0|this._bl,I=0|this._cl,E=0|this._dl,_=0|this._el,C=0|this._fl,k=0|this._gl,B=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],Q=e[x-30+1],M=d(S,Q),R=h(Q,S),O=y(S=e[x-4],Q=e[x-4+1]),j=A(Q,S),T=e[x-14],P=e[x-14+1],D=e[x-32],N=e[x-32+1],L=R+P|0,F=M+T+b(L,R)|0;F=(F=F+O+b(L=L+j|0,j)|0)+D+b(L=L+N|0,N)|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,i),G=f(v,w,I),q=l(n,v),K=l(v,n),Y=p(s,_),z=p(_,s),J=o[U],W=o[U+1],V=c(s,u,g),Z=c(_,C,k),X=B+z|0,$=m+Y+b(X,B)|0;$=($=($=$+V+b(X=X+Z|0,Z)|0)+J+b(X=X+W|0,W)|0)+F+b(X=X+L|0,L)|0;var tt=K+G|0,et=q+H+b(tt,K)|0;m=g,B=k,g=u,k=C,u=s,C=_,s=a+$+b(_=E+X|0,E)|0,a=i,E=I,i=r,I=w,r=n,w=v,n=$+et+b(v=X+tt|0,X)|0}this._al=this._al+v|0,this._bl=this._bl+w|0,this._cl=this._cl+I|0,this._dl=this._dl+E|0,this._el=this._el+_|0,this._fl=this._fl+C|0,this._gl=this._gl+k|0,this._hl=this._hl+B|0,this._ah=this._ah+n+b(this._al,v)|0,this._bh=this._bh+r+b(this._bl,w)|0,this._ch=this._ch+i+b(this._cl,I)|0,this._dh=this._dh+a+b(this._dl,E)|0,this._eh=this._eh+s+b(this._el,_)|0,this._fh=this._fh+u+b(this._fl,C)|0,this._gh=this._gh+g+b(this._gl,k)|0,this._hh=this._hh+m+b(this._hl,B)|0},u.prototype._hash=function(){var t=a.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){"use strict";(function(e,r){var i=n(72);t.exports=m;var a,o=n(353);m.ReadableState=g;n(20).EventEmitter;var s=function(t,e){return t.listeners(e).length},u=n(163),c=n(97).Buffer,f=(void 0!==e?e:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){};var l=Object.create(n(59));l.inherits=n(3);var p=n(354),d=void 0;d=p&&p.debuglog?p.debuglog("stream"):function(){};var h,y=n(355),A=n(164);l.inherits(m,u);var b=["error","close","destroy","pause","resume"];function g(t,e){t=t||{};var r=e instanceof(a=a||n(40));this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.readableObjectMode);var i=t.highWaterMark,o=t.readableHighWaterMark,s=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:r&&(o||0===o)?o:s,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new y,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&&(h||(h=n(29).StringDecoder),this.decoder=new h(t.encoding),this.encoding=t.encoding)}function m(t){if(a=a||n(40),!(this instanceof m))return new m(t);this._readableState=new g(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,i){var a,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,E(t)}(t,o)):(i||(a=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)),a?t.emit("error",a):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")):w(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?w(t,o,e,!1):C(t,o)):w(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 w(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&&E(t)),C(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=A.destroy,m.prototype._undestroy=A.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 h||(h=n(29).StringDecoder),this._readableState.decoder=new h(t),this._readableState.encoding=t,this};function I(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 E(t){var e=t._readableState;e.needReadable=!1,e.emittedReadable||(d("emitReadable",e.flowing),e.emittedReadable=!0,e.sync?i.nextTick(_,t):_(t))}function _(t){d("emit readable"),t.emit("readable"),S(t)}function C(t,e){e.readingMore||(e.readingMore=!0,i.nextTick(k,t,e))}function k(t,e){for(var n=e.length;!e.reading&&!e.flowing&&!e.ended&&e.length<e.highWaterMark&&(d("maybeReadMore read 0"),t.read(0),n!==e.length);)n=e.length;e.readingMore=!1}function B(t){d("readable nexttick read 0"),t.read(0)}function x(t,e){e.reading||(d("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(d("flow",e.flowing);e.flowing&&null!==t.read(););}function Q(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,i=n.data;t-=i.length;for(;n=n.next;){var a=n.data,o=t>a.length?a.length:t;if(o===a.length?i+=a:i+=a.slice(0,t),0===(t-=o)){o===a.length?(++r,n.next?e.head=n.next:e.head=e.tail=null):(e.head=n,n.data=a.slice(o));break}++r}return e.length-=r,i}(t,e):function(t,e){var n=c.allocUnsafe(t),r=e.head,i=1;r.data.copy(n),t-=r.data.length;for(;r=r.next;){var a=r.data,o=t>a.length?a.length:t;if(a.copy(n,n.length-t,0,o),0===(t-=o)){o===a.length?(++i,r.next?e.head=r.next:e.head=e.tail=null):(e.head=r,r.data=a.slice(o));break}++i}return e.length-=i,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,i.nextTick(R,e,t))}function R(t,e){t.endEmitted||0!==t.length||(t.endEmitted=!0,e.readable=!1,e.emit("end"))}function O(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){d("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 d("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?M(this):E(this),null;if(0===(t=I(t,e))&&e.ended)return 0===e.length&&M(this),null;var r,i=e.needReadable;return d("need readable",i),(0===e.length||e.length-t<e.highWaterMark)&&d("length less than watermark",i=!0),e.ended||e.reading?d("reading or ended",i=!1):i&&(d("do read"),e.reading=!0,e.sync=!0,0===e.length&&(e.needReadable=!0),this._read(e.highWaterMark),e.sync=!1,e.reading||(t=I(n,e))),null===(r=t>0?Q(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,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,d("pipe count=%d opts=%j",a.pipesCount,e);var u=(!e||!1!==e.end)&&t!==r.stdout&&t!==r.stderr?f:m;function c(e,r){d("onunpipe"),e===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,d("cleanup"),t.removeListener("close",b),t.removeListener("finish",g),t.removeListener("drain",l),t.removeListener("error",A),t.removeListener("unpipe",c),n.removeListener("end",f),n.removeListener("end",m),n.removeListener("data",y),p=!0,!a.awaitDrain||t._writableState&&!t._writableState.needDrain||l())}function f(){d("onend"),t.end()}a.endEmitted?i.nextTick(u):n.once("end",u),t.on("unpipe",c);var l=function(t){return function(){var e=t._readableState;d("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&s(t,"data")&&(e.flowing=!0,S(t))}}(n);t.on("drain",l);var p=!1;var h=!1;function y(e){d("ondata"),h=!1,!1!==t.write(e)||h||((1===a.pipesCount&&a.pipes===t||a.pipesCount>1&&-1!==O(a.pipes,t))&&!p&&(d("false write response, pause",a.awaitDrain),a.awaitDrain++,h=!0),n.pause())}function A(e){d("onerror",e),m(),t.removeListener("error",A),0===s(t,"error")&&t.emit("error",e)}function b(){t.removeListener("finish",g),m()}function g(){d("onfinish"),t.removeListener("close",b),m()}function m(){d("unpipe"),n.unpipe(t)}return n.on("data",y),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",A),t.once("close",b),t.once("finish",g),t.emit("pipe",n),a.flowing||(d("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,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var a=0;a<i;a++)r[a].emit("unpipe",this,{hasUnpiped:!1});return this}var o=O(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&&E(this):i.nextTick(B,this))}return n},m.prototype.addListener=m.prototype.on,m.prototype.resume=function(){var t=this._readableState;return t.flowing||(d("resume"),t.flowing=!0,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,i.nextTick(x,t,e))}(this,t)),this},m.prototype.pause=function(){return d("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(d("pause"),this._readableState.flowing=!1,this.emit("pause")),this},m.prototype.wrap=function(t){var e=this,n=this._readableState,r=!1;for(var i in t.on("end",(function(){if(d("wrapped end"),n.decoder&&!n.ended){var t=n.decoder.end();t&&t.length&&e.push(t)}e.push(null)})),t.on("data",(function(i){(d("wrapped data"),n.decoder&&(i=n.decoder.write(i)),n.objectMode&&null==i)||(n.objectMode||i&&i.length)&&(e.push(i)||(r=!0,t.pause()))})),t)void 0===this[i]&&"function"==typeof t[i]&&(this[i]=function(e){return function(){return t[e].apply(t,arguments)}}(i));for(var a=0;a<b.length;a++)t.on(b[a],this.emit.bind(this,b[a]));return this._read=function(e){d("wrapped _read",e),r&&(r=!1,t.resume())},this},Object.defineProperty(m.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),m._fromList=Q}).call(this,n(8),n(6))},function(t,e,n){t.exports=n(20).EventEmitter},function(t,e,n){"use strict";var r=n(72);function i(t,e){t.emit("error",e)}t.exports={destroy:function(t,e){var n=this,a=this._readableState&&this._readableState.destroyed,o=this._writableState&&this._writableState.destroyed;return a||o?(e?e(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,r.nextTick(i,this,t)):r.nextTick(i,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,(function(t){!e&&t?n._writableState?n._writableState.errorEmitted||(n._writableState.errorEmitted=!0,r.nextTick(i,n,t)):r.nextTick(i,n,t):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.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}}},function(t,e,n){"use strict";t.exports=o;var r=n(40),i=Object.create(n(59));function a(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 i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function o(t){if(!(this instanceof o))return new o(t);r.call(this,t),this._transformState={afterTransform:a.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)}i.inherits=n(3),i.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 i=this._readableState;(r.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.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(3),i=n(362),a=n(38),o=n(5).Buffer,s=n(167),u=n(94),c=n(95),f=o.alloc(128);function l(t,e){a.call(this,"digest"),"string"==typeof e&&(e=o.from(e));var n="sha512"===t||"sha384"===t?128:64;(this._alg=t,this._key=e,e.length>n)?e=("rmd160"===t?new u:c(t)).update(e).digest():e.length<n&&(e=o.concat([e,f],n));for(var r=this._ipad=o.allocUnsafe(n),i=this._opad=o.allocUnsafe(n),s=0;s<n;s++)r[s]=54^e[s],i[s]=92^e[s];this._hash="rmd160"===t?new u:c(t),this._hash.update(r)}r(l,a),l.prototype._update=function(t){this._hash.update(t)},l.prototype._final=function(){var t=this._hash.digest();return("rmd160"===this._alg?new u:c(this._alg)).update(this._opad).update(t).digest()},t.exports=function(t,e){return"rmd160"===(t=t.toLowerCase())||"ripemd160"===t?new l("rmd160",e):"md5"===t?new i(s,e):new l(t,e)}},function(t,e,n){var r=n(92);t.exports=function(t){return(new r).update(t).digest()}},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,n){e.pbkdf2=n(364),e.pbkdf2Sync=n(172)},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(8),n(6))},function(t,e,n){var r=n(167),i=n(94),a=n(95),o=n(5).Buffer,s=n(170),u=n(171),c=n(173),f=o.alloc(128),l={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,rmd160:20,ripemd160:20};function p(t,e,n){var s=function(t){function e(e){return a(t).update(e).digest()}return"rmd160"===t||"ripemd160"===t?function(t){return(new i).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+l[t]),p=o.allocUnsafe(u+l[t]),d=0;d<u;d++)c[d]=54^e[d],p[d]=92^e[d];var h=o.allocUnsafe(u+n+4);c.copy(h,0,0,u),this.ipad1=h,this.ipad2=c,this.opad=p,this.alg=t,this.blocksize=u,this.hash=s,this.size=l[t]}p.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,i){s(n,r);var a=new p(i=i||"sha1",t=c(t,u,"Password"),(e=c(e,u,"Salt")).length),f=o.allocUnsafe(r),d=o.allocUnsafe(e.length+4);e.copy(d,0,0,e.length);for(var h=0,y=l[i],A=Math.ceil(r/y),b=1;b<=A;b++){d.writeUInt32BE(b,e.length);for(var g=a.run(d,a.ipad1),m=g,v=1;v<n;v++){m=a.run(m,a.ipad2);for(var w=0;w<y;w++)g[w]^=m[w]}g.copy(f,h),h+=y}return f}},function(t,e,n){var r=n(5).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){"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 i=0,a=0,o=6;o>=0;o-=2){for(var 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(o=6;o>=0;o-=2){for(s=1;s<=25;s+=8)a<<=1,a|=e>>>s+o&1;for(s=1;s<=25;s+=8)a<<=1,a|=t>>>s+o&1}n[r+0]=i>>>0,n[r+1]=a>>>0},e.rip=function(t,e,n,r){for(var i=0,a=0,o=0;o<4;o++)for(var s=24;s>=0;s-=8)i<<=1,i|=e>>>s+o&1,i<<=1,i|=t>>>s+o&1;for(o=4;o<8;o++)for(s=24;s>=0;s-=8)a<<=1,a|=e>>>s+o&1,a<<=1,a|=t>>>s+o&1;n[r+0]=i>>>0,n[r+1]=a>>>0},e.pc1=function(t,e,n,r){for(var i=0,a=0,o=7;o>=5;o--){for(var 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|=e>>s+o&1;for(o=1;o<=3;o++){for(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|=t>>s+o&1;n[r+0]=i>>>0,n[r+1]=a>>>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,i){for(var a=0,o=0,s=r.length>>>1,u=0;u<s;u++)a<<=1,a|=t>>>r[u]&1;for(u=s;u<r.length;u++)o<<=1,o|=e>>>r[u]&1;n[i+0]=a>>>0,n[i+1]=o>>>0},e.expand=function(t,e,n){var r=0,i=0;r=(1&t)<<5|t>>>27;for(var a=23;a>=15;a-=4)r<<=6,r|=t>>>a&63;for(a=11;a>=3;a-=4)i|=t>>>a&63,i<<=6;i|=(31&t)<<1|t>>>31,e[n+0]=r>>>0,e[n+1]=i>>>0};var i=[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|=i[64*r+(t>>>18-6*r&63)]}for(r=0;r<4;r++){n<<=4,n|=i[256+64*r+(e>>>18-6*r&63)]}return n>>>0};var a=[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<a.length;n++)e<<=1,e|=t>>>a[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 i=[],a=0;a<e;a+=n)i.push(r.slice(a,a+n));return i.join(" ")}},function(t,e,n){"use strict";var r=n(19),i=n(3),a=n(174),o=n(99);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)}i(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=a.readUInt32BE(e,0),i=a.readUInt32BE(e,4);a.pc1(n,i,t.tmp,0),n=t.tmp[0],i=t.tmp[1];for(var o=0;o<t.keys.length;o+=2){var s=c[o>>>1];n=a.r28shl(n,s),i=a.r28shl(i,s),a.pc2(n,i,t.keys,o)}},u.prototype._update=function(t,e,n,r){var i=this._desState,o=a.readUInt32BE(t,e),s=a.readUInt32BE(t,e+4);a.ip(o,s,i.tmp,0),o=i.tmp[0],s=i.tmp[1],"encrypt"===this.type?this._encrypt(i,o,s,i.tmp,0):this._decrypt(i,o,s,i.tmp,0),o=i.tmp[0],s=i.tmp[1],a.writeUInt32BE(n,o,r),a.writeUInt32BE(n,s,r+4)},u.prototype._pad=function(t,e){if(!1===this.padding)return!1;for(var n=t.length-e,r=e;r<t.length;r++)t[r]=n;return!0},u.prototype._unpad=function(t){if(!1===this.padding)return 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,i){for(var o=e,s=n,u=0;u<t.keys.length;u+=2){var c=t.keys[u],f=t.keys[u+1];a.expand(s,t.tmp,0),c^=t.tmp[0],f^=t.tmp[1];var l=a.substitute(c,f),p=s;s=(o^a.permute(l))>>>0,o=p}a.rip(s,o,r,i)},u.prototype._decrypt=function(t,e,n,r,i){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];a.expand(o,t.tmp,0),c^=t.tmp[0],f^=t.tmp[1];var l=a.substitute(c,f),p=o;o=(s^a.permute(l))>>>0,s=p}a.rip(o,s,r,i)}},function(t,e,n){var r=n(60),i=n(5).Buffer,a=n(177);function o(t){var e=t._cipher.encryptBlockRaw(t._prev);return a(t._prev),e}e.encrypt=function(t,e){var n=Math.ceil(e.length/16),a=t._cache.length;t._cache=i.concat([t._cache,i.allocUnsafe(16*n)]);for(var s=0;s<n;s++){var u=o(t),c=a+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(73),i=n(5).Buffer,a=n(38),o=n(3),s=n(377),u=n(60),c=n(177);function f(t,e,n,o){a.call(this);var u=i.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=i.concat([e,i.from([0,0,0,1])]),i.concat([e,i.from([0,0,0,2])]);var r=new s(n),a=e.length,o=a%16;r.update(e),o&&(o=16-o,r.update(i.alloc(o,0))),r.update(i.alloc(8,0));var u=8*a,f=i.alloc(8);f.writeUIntBE(u,0,8),r.update(f),t._finID=r.state;var l=i.from(t._finID);return c(l),l}(this,n,f),this._prev=i.from(n),this._cache=i.allocUnsafe(0),this._secCache=i.allocUnsafe(0),this._decrypt=o,this._alen=0,this._len=0,this._mode=t,this._authTag=null,this._called=!1}o(f,a),f.prototype._update=function(t){if(!this._called&&this._alen){var e=16-this._alen%16;e<16&&(e=i.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),i=0;i<r;++i)n+=t[i]^e[i];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||!i.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(73),i=n(5).Buffer,a=n(38);function o(t,e,n,o){a.call(this),this._cipher=new r.AES(e),this._prev=i.from(n),this._cache=i.allocUnsafe(0),this._secCache=i.allocUnsafe(0),this._decrypt=o,this._mode=t}n(3)(o,a),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){var r=n(45);t.exports=g,g.simpleSieve=A,g.fermatTest=b;var i=n(2),a=new i(24),o=new(n(182)),s=new i(1),u=new i(2),c=new i(5),f=(new i(16),new i(8),new i(10)),l=new i(3),p=(new i(7),new i(11)),d=new i(4),h=(new i(12),null);function y(){if(null!==h)return h;var t=[];t[0]=2;for(var e=1,n=3;n<1048576;n+=2){for(var r=Math.ceil(Math.sqrt(n)),i=0;i<e&&t[i]<=r&&n%t[i]!=0;i++);e!==i&&t[i]<=r||(t[e++]=n)}return h=t,t}function A(t){for(var e=y(),n=0;n<e.length;n++)if(0===t.modn(e[n]))return 0===t.cmpn(e[n]);return!0}function b(t){var e=i.mont(t);return 0===u.toRed(e).redPow(t.subn(1)).fromRed().cmpn(1)}function g(t,e){if(t<16)return new i(2===e||5===e?[140,123]:[140,39]);var n,h;for(e=new i(e);;){for(n=new i(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(l);)n.iadd(d)}else for(;n.mod(a).cmp(p);)n.iadd(d);if(A(h=n.shrn(1))&&A(n)&&b(h)&&b(n)&&o.test(h)&&o.test(n))return n}}},function(t,e,n){var r=n(2),i=n(102);function a(t){this.rand=t||new i.Rand}t.exports=a,a.create=function(t){return new a(t)},a.prototype._randbelow=function(t){var e=t.bitLength(),n=Math.ceil(e/8);do{var i=new r(this.rand.generate(n))}while(i.cmp(t)>=0);return i},a.prototype._randrange=function(t,e){var n=e.sub(t);return t.add(this._randbelow(n))},a.prototype.test=function(t,e,n){var i=t.bitLength(),a=r.mont(t),o=new r(1).toRed(a);e||(e=Math.max(1,i/48|0));for(var s=t.subn(1),u=0;!s.testn(u);u++);for(var c=t.shrn(u),f=s.toRed(a);e>0;e--){var l=this._randrange(new r(2),s);n&&n(l);var p=l.toRed(a).redPow(c);if(0!==p.cmp(o)&&0!==p.cmp(f)){for(var d=1;d<u;d++){if(0===(p=p.redSqr()).cmp(o))return!1;if(0===p.cmp(f))break}if(d===u)return!1}}return!0},a.prototype.getDivisor=function(t,e){var n=t.bitLength(),i=r.mont(t),a=new r(1).toRed(i);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(i);e>0;e--){var f=this._randrange(new r(2),o),l=t.gcd(f);if(0!==l.cmpn(1))return l;var p=f.toRed(i).redPow(u);if(0!==p.cmp(a)&&0!==p.cmp(c)){for(var d=1;d<s;d++){if(0===(p=p.redSqr()).cmp(a))return p.fromRed().subn(1).gcd(t);if(0===p.cmp(c))break}if(d===s)return(p=p.redSqr()).fromRed().subn(1).gcd(t)}}return!1}},function(t,e,n){"use strict";(function(e,r){var i;t.exports=C,C.ReadableState=_;n(20).EventEmitter;var a=function(t,e){return t.listeners(e).length},o=n(184),s=n(4).Buffer,u=(void 0!==e?e:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){};var c,f=n(386);c=f&&f.debuglog?f.debuglog("stream"):function(){};var l,p,d,h=n(387),y=n(185),A=n(186).getHighWaterMark,b=n(49).codes,g=b.ERR_INVALID_ARG_TYPE,m=b.ERR_STREAM_PUSH_AFTER_EOF,v=b.ERR_METHOD_NOT_IMPLEMENTED,w=b.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;n(3)(C,o);var I=y.errorOrDestroy,E=["error","close","destroy","pause","resume"];function _(t,e,r){i=i||n(50),t=t||{},"boolean"!=typeof r&&(r=e instanceof i),this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=A(this,t,"readableHighWaterMark",r),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.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&&(l||(l=n(29).StringDecoder),this.decoder=new l(t.encoding),this.encoding=t.encoding)}function C(t){if(i=i||n(50),!(this instanceof C))return new C(t);var e=this instanceof i;this._readableState=new _(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,i){c("readableAddChunk",e);var a,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,Q(t)))}(t,o);else if(i||(a=function(t,e){var n;r=e,s.isBuffer(r)||r instanceof u||"string"==typeof e||void 0===e||t.objectMode||(n=new g("chunk",["string","Buffer","Uint8Array"],e));var r;return n}(o,e)),a)I(t,a);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?I(t,new w):B(t,o,e,!0);else if(o.ended)I(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?B(t,o,e,!1):M(t,o)):B(t,o,e,!1)}else r||(o.reading=!1,M(t,o));return!o.ended&&(o.length<o.highWaterMark||0===o.length)}function B(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(C.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(t){this._readableState&&(this._readableState.destroyed=t)}}),C.prototype.destroy=y.destroy,C.prototype._undestroy=y.undestroy,C.prototype._destroy=function(t,e){e(t)},C.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)},C.prototype.unshift=function(t){return k(this,t,null,!0,!1)},C.prototype.isPaused=function(){return!1===this._readableState.flowing},C.prototype.setEncoding=function(t){l||(l=n(29).StringDecoder);var e=new l(t);this._readableState.decoder=e,this._readableState.encoding=this._readableState.decoder.encoding;for(var r=this._readableState.buffer.head,i="";null!==r;)i+=e.write(r.data),r=r.next;return this._readableState.buffer.clear(),""!==i&&this._readableState.buffer.push(i),this._readableState.length=i.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(Q,t))}function Q(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,P(t)}function M(t,e){e.readingMore||(e.readingMore=!0,r.nextTick(R,t,e))}function R(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 O(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 j(t){c("readable nexttick read 0"),t.read(0)}function T(t,e){c("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),P(t),e.flowing&&!e.reading&&t.read(0)}function P(t){var e=t._readableState;for(c("flow",e.flowing);e.flowing&&null!==t.read(););}function D(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 N(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}C.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?N(this):S(this),null;if(0===(t=x(t,e))&&e.ended)return 0===e.length&&N(this),null;var r,i=e.needReadable;return c("need readable",i),(0===e.length||e.length-t<e.highWaterMark)&&c("length less than watermark",i=!0),e.ended||e.reading?c("reading or ended",i=!1):i&&(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?D(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&&N(this)),null!==r&&this.emit("data",r),r},C.prototype._read=function(t){I(this,new v("_read()"))},C.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,c("pipe count=%d opts=%j",i.pipesCount,e);var o=(!e||!1!==e.end)&&t!==r.stdout&&t!==r.stderr?u:A;function s(e,r){c("onunpipe"),e===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,c("cleanup"),t.removeListener("close",h),t.removeListener("finish",y),t.removeListener("drain",f),t.removeListener("error",d),t.removeListener("unpipe",s),n.removeListener("end",u),n.removeListener("end",A),n.removeListener("data",p),l=!0,!i.awaitDrain||t._writableState&&!t._writableState.needDrain||f())}function u(){c("onend"),t.end()}i.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&&a(t,"data")&&(e.flowing=!0,P(t))}}(n);t.on("drain",f);var l=!1;function p(e){c("ondata");var r=t.write(e);c("dest.write",r),!1===r&&((1===i.pipesCount&&i.pipes===t||i.pipesCount>1&&-1!==F(i.pipes,t))&&!l&&(c("false write response, pause",i.awaitDrain),i.awaitDrain++),n.pause())}function d(e){c("onerror",e),A(),t.removeListener("error",d),0===a(t,"error")&&I(t,e)}function h(){t.removeListener("finish",y),A()}function y(){c("onfinish"),t.removeListener("close",h),A()}function A(){c("unpipe"),n.unpipe(t)}return n.on("data",p),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",d),t.once("close",h),t.once("finish",y),t.emit("pipe",n),i.flowing||(c("pipe resume"),n.resume()),t},C.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,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var a=0;a<i;a++)r[a].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},C.prototype.on=function(t,e){var n=o.prototype.on.call(this,t,e),i=this._readableState;return"data"===t?(i.readableListening=this.listenerCount("readable")>0,!1!==i.flowing&&this.resume()):"readable"===t&&(i.endEmitted||i.readableListening||(i.readableListening=i.needReadable=!0,i.flowing=!1,i.emittedReadable=!1,c("on readable",i.length,i.reading),i.length?S(this):i.reading||r.nextTick(j,this))),n},C.prototype.addListener=C.prototype.on,C.prototype.removeListener=function(t,e){var n=o.prototype.removeListener.call(this,t,e);return"readable"===t&&r.nextTick(O,this),n},C.prototype.removeAllListeners=function(t){var e=o.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||r.nextTick(O,this),e},C.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(T,t,e))}(this,t)),t.paused=!1,this},C.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},C.prototype.wrap=function(t){var e=this,n=this._readableState,r=!1;for(var i 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(i){(c("wrapped data"),n.decoder&&(i=n.decoder.write(i)),n.objectMode&&null==i)||(n.objectMode||i&&i.length)&&(e.push(i)||(r=!0,t.pause()))})),t)void 0===this[i]&&"function"==typeof t[i]&&(this[i]=function(e){return function(){return t[e].apply(t,arguments)}}(i));for(var a=0;a<E.length;a++)t.on(E[a],this.emit.bind(this,E[a]));return this._read=function(e){c("wrapped _read",e),r&&(r=!1,t.resume())},this},"function"==typeof Symbol&&(C.prototype[Symbol.asyncIterator]=function(){return void 0===p&&(p=n(389)),p(this)}),Object.defineProperty(C.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(C.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(C.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(t){this._readableState&&(this._readableState.flowing=t)}}),C._fromList=D,Object.defineProperty(C.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),"function"==typeof Symbol&&(C.from=function(t,e){return void 0===d&&(d=n(390)),d(C,t,e)})}).call(this,n(8),n(6))},function(t,e,n){t.exports=n(20).EventEmitter},function(t,e,n){"use strict";(function(e){function n(t,e){i(t,e),r(t)}function r(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit("close")}function i(t,e){t.emit("error",e)}t.exports={destroy:function(t,a){var o=this,s=this._readableState&&this._readableState.destroyed,u=this._writableState&&this._writableState.destroyed;return s||u?(a?a(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,e.nextTick(i,this,t)):e.nextTick(i,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,(function(t){!a&&t?o._writableState?o._writableState.errorEmitted?e.nextTick(r,o):(o._writableState.errorEmitted=!0,e.nextTick(n,o,t)):e.nextTick(n,o,t):a?(e.nextTick(r,o),a(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(6))},function(t,e,n){"use strict";var r=n(49).codes.ERR_INVALID_OPT_VALUE;t.exports={getHighWaterMark:function(t,e,n,i){var a=function(t,e,n){return null!=t.highWaterMark?t.highWaterMark:e?t[n]:null}(e,i,n);if(null!=a){if(!isFinite(a)||Math.floor(a)!==a||a<0)throw new r(i?n:"highWaterMark",a);return Math.floor(a)}return t.objectMode?16:16384}}},function(t,e,n){"use strict";(function(e,r){function i(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 i=r.callback;e.pendingcb--,i(n),r=r.next}e.corkedRequestsFree.next=t}(e,t)}}var a;t.exports=C,C.WritableState=_;var o={deprecate:n(71)},s=n(184),u=n(4).Buffer,c=(void 0!==e?e:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){};var f,l=n(185),p=n(186).getHighWaterMark,d=n(49).codes,h=d.ERR_INVALID_ARG_TYPE,y=d.ERR_METHOD_NOT_IMPLEMENTED,A=d.ERR_MULTIPLE_CALLBACK,b=d.ERR_STREAM_CANNOT_PIPE,g=d.ERR_STREAM_DESTROYED,m=d.ERR_STREAM_NULL_VALUES,v=d.ERR_STREAM_WRITE_AFTER_END,w=d.ERR_UNKNOWN_ENCODING,I=l.errorOrDestroy;function E(){}function _(t,e,o){a=a||n(50),t=t||{},"boolean"!=typeof o&&(o=e instanceof a),this.objectMode=!!t.objectMode,o&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=p(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,i=n.sync,a=n.writecb;if("function"!=typeof a)throw new A;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(n),e)!function(t,e,n,i,a){--e.pendingcb,n?(r.nextTick(a,i),r.nextTick(M,t,e),t._writableState.errorEmitted=!0,I(t,i)):(a(i),t._writableState.errorEmitted=!0,I(t,i),M(t,e))}(t,n,i,e,a);else{var o=S(n)||t.destroyed;o||n.corked||n.bufferProcessing||!n.bufferedRequest||x(t,n),i?r.nextTick(B,t,n,o,a):B(t,n,o,a)}}(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 i(this)}function C(t){var e=this instanceof(a=a||n(50));if(!e&&!f.call(C,this))return new C(t);this._writableState=new _(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,i,a,o){e.writelen=r,e.writecb=o,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new g("write")):n?t._writev(i,e.onwrite):t._write(i,a,e.onwrite),e.sync=!1}function B(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,a=new Array(r),o=e.corkedRequestsFree;o.entry=n;for(var s=0,u=!0;n;)a[s]=n,n.isBuf||(u=!1),n=n.next,s+=1;a.allBuffers=u,k(t,e,!0,e.length,a,"",o.finish),e.pendingcb++,e.lastBufferedRequest=null,o.next?(e.corkedRequestsFree=o.next,o.next=null):e.corkedRequestsFree=new i(e),e.bufferedRequestCount=0}else{for(;n;){var c=n.chunk,f=n.encoding,l=n.callback;if(k(t,e,!1,e.objectMode?1:c.length,c,f,l),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 Q(t,e){t._final((function(n){e.pendingcb--,n&&I(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(Q,t,e)))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit("finish"),e.autoDestroy))){var i=t._readableState;(!i||i.autoDestroy&&i.endEmitted)&&t.destroy()}return n}n(3)(C,s),_.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(_.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(C,Symbol.hasInstance,{value:function(t){return!!f.call(this,t)||this===C&&(t&&t._writableState instanceof _)}})):f=function(t){return t instanceof this},C.prototype.pipe=function(){I(this,new b)},C.prototype.write=function(t,e,n){var i,a=this._writableState,o=!1,s=!a.objectMode&&(i=t,u.isBuffer(i)||i 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=a.defaultEncoding),"function"!=typeof n&&(n=E),a.ending?function(t,e){var n=new v;I(t,n),r.nextTick(e,n)}(this,n):(s||function(t,e,n,i){var a;return null===n?a=new m:"string"==typeof n||e.objectMode||(a=new h("chunk",["string","Buffer"],n)),!a||(I(t,a),r.nextTick(i,a),!1)}(this,a,t,n))&&(a.pendingcb++,o=function(t,e,n,r,i,a){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,i);r!==o&&(n=!0,i="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:i,isBuf:n,callback:a,next:null},f?f.next=e.lastBufferedRequest:e.bufferedRequest=e.lastBufferedRequest,e.bufferedRequestCount+=1}else k(t,e,!1,s,r,i,a);return c}(this,a,s,t,e,n)),o},C.prototype.cork=function(){this._writableState.corked++},C.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,t.writing||t.corked||t.bufferProcessing||!t.bufferedRequest||x(this,t))},C.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 w(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(C.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(C.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),C.prototype._write=function(t,e,n){n(new y("_write()"))},C.prototype._writev=null,C.prototype.end=function(t,e,n){var i=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),i.corked&&(i.corked=1,this.uncork()),i.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,i,n),this},Object.defineProperty(C.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(C.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),C.prototype.destroy=l.destroy,C.prototype._undestroy=l.undestroy,C.prototype._destroy=function(t,e){e(t)}}).call(this,n(8),n(6))},function(t,e,n){"use strict";t.exports=f;var r=n(49).codes,i=r.ERR_METHOD_NOT_IMPLEMENTED,a=r.ERR_MULTIPLE_CALLBACK,o=r.ERR_TRANSFORM_ALREADY_TRANSFORMING,s=r.ERR_TRANSFORM_WITH_LENGTH_0,u=n(50);function c(t,e){var n=this._transformState;n.transforming=!1;var r=n.writecb;if(null===r)return this.emit("error",new a);n.writechunk=null,n.writecb=null,null!=e&&this.push(e),r(t);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.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",l)}function l(){var t=this;"function"!=typeof this._flush||this._readableState.destroyed?p(this,null,null):this._flush((function(e,n){p(t,e,n)}))}function p(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 i("_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 i=this._readableState;(r.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.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){"use strict";var r=e;function i(t){return 1===t.length?"0"+t:t}function a(t){for(var e="",n=0;n<t.length;n++)e+=i(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 i=t.charCodeAt(r),a=i>>8,o=255&i;a?n.push(a,o):n.push(o)}return n},r.zero2=i,r.toHex=a,r.encode=function(t,e){return"hex"===e?a(t):t}},function(t,e,n){"use strict";var r=e;r.base=n(75),r.short=n(395),r.mont=n(396),r.edwards=n(397)},function(t,e,n){"use strict";var r=e;r.bignum=n(2),r.define=n(407).define,r.base=n(410),r.constants=n(411),r.decoders=n(194),r.encoders=n(192)},function(t,e,n){"use strict";var r=e;r.der=n(193),r.pem=n(408)},function(t,e,n){"use strict";var r=n(3),i=n(107).Buffer,a=n(108),o=n(110);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){a.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,a),u.prototype._encodeComposite=function(t,e,n,r){var a=function(t,e,n,r){var i;"seqof"===t?t="seq":"setof"===t&&(t="set");if(o.tagByName.hasOwnProperty(t))i=o.tagByName[t];else{if("number"!=typeof t||(0|t)!==t)return r.error("Unknown tag: "+t);i=t}if(i>=31)return r.error("Multi-octet tag encoding unsupported");e||(i|=32);return i|=o.tagClassByName[n||"universal"]<<6}(t,e,n,this.reporter);if(r.length<128){var s=i.alloc(2);return s[0]=a,s[1]=r.length,this._createEncoderBuffer([s,r])}for(var u=1,c=r.length;c>=256;c>>=8)u++;var f=i.alloc(2+u);f[0]=a,f[1]=128|u;for(var l=1+u,p=r.length;p>0;l--,p>>=8)f[l]=255&p;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=i.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 a=0;a<t.length;a++)t[a]|=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=i.alloc(o),f=c.length-1,l=t.length-1;l>=0;l--){var p=t[l];for(c[f--]=127&p;(p>>=7)>0;)c[f--]=128|127&p}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&&!i.isBuffer(t)){var n=t.toArray();!t.sign&&128&n[0]&&n.unshift(0),t=i.from(n)}if(i.isBuffer(t)){var r=t.length;0===t.length&&r++;var a=i.alloc(r);return t.copy(a),0===t.length&&(a[0]=0),this._createEncoderBuffer(a)}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(i.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,i=this._baseState;if(null===i.default)return!1;var a=t.join();if(void 0===i.defaultBuffer&&(i.defaultBuffer=this._encodeValue(i.default,e,n).join()),a.length!==i.defaultBuffer.length)return!1;for(r=0;r<a.length;r++)if(a[r]!==i.defaultBuffer[r])return!1;return!0}},function(t,e,n){"use strict";var r=e;r.der=n(195),r.pem=n(409)},function(t,e,n){"use strict";var r=n(3),i=n(2),a=n(61).DecoderBuffer,o=n(108),s=n(110);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],i=0==(32&n);if(31==(31&n)){var a=n;for(n=0;128==(128&a);){if(a=t.readUInt8(e),t.isError(a))return a;n<<=7,n|=127&a}}else n&=31;return{cls:r,primitive:i,tag:n,tagStr:s.tag[n]}}function l(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 i=127&r;if(i>4)return t.error("length octect is too long");r=0;for(var a=0;a<i;a++){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 a.isDecoderBuffer(t)||(t=new a(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(),i=f(t,'Failed to peek tag: "'+e+'"');return t.isError(i)?i:(t.restore(r),i.tag===e||i.tagStr===e||i.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 i=l(t,r.primitive,'Failed to get length of "'+e+'"');if(t.isError(i))return i;if(!n&&r.tag!==e&&r.tagStr!==e&&r.tagStr+"of"!==e)return t.error('Failed to match tag: "'+e+'"');if(r.primitive||null!==i)return t.skip(i,'Failed to match body of: "'+e+'"');var a=t.save(),o=this._skipUntilEnd(t,'Failed to skip indefinite length body: "'+this.tag+'"');return t.isError(o)?o:(i=t.offset-a.offset,t.restore(a),t.skip(i,'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=l(t,n.primitive,e);if(t.isError(r))return r;var i=void 0;if(i=n.primitive||null!==r?t.skip(r):this._skipUntilEnd(t,e),t.isError(i))return i;if("end"===n.tagStr)break}},c.prototype._decodeList=function(t,e,n,r){for(var i=[];!t.isEmpty();){var a=this._peekTag(t,"end");if(t.isError(a))return a;var o=n.decode(t,"der",r);if(t.isError(o)&&a)break;i.push(o)}return i},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 i="",a=0;a<r.length/2;a++)i+=String.fromCharCode(r.readUInt16BE(2*a));return i}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,i=[],a=0,o=0;!t.isEmpty();)a<<=7,a|=127&(o=t.readUInt8()),0==(128&o)&&(i.push(a),a=0);128&o&&i.push(a);var s=i[0]/40|0,u=i[0]%40;if(r=n?i:[s,u].concat(i.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,i,a,o,s,u=t.raw().toString();if("gentime"===e)n=0|u.slice(0,4),r=0|u.slice(4,6),i=0|u.slice(6,8),a=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),i=0|u.slice(4,6),a=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,i,a,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 i(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){var r=n(58),i=n(5).Buffer;function a(t){var e=i.allocUnsafe(4);return e.writeUInt32BE(t,0),e}t.exports=function(t,e){for(var n,o=i.alloc(0),s=0;o.length<e;)n=a(s++),o=i.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),i=n(5).Buffer;t.exports=function(t,e){return i.from(t.toRed(r.mont(e.modulus)).redPow(new r(e.publicExponent)).fromRed().toArray())}},function(t,e,n){"use strict";(function(e,r){var i;t.exports=C,C.ReadableState=_;n(20).EventEmitter;var a=function(t,e){return t.listeners(e).length},o=n(201),s=n(4).Buffer,u=(void 0!==e?e:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){};var c,f=n(423);c=f&&f.debuglog?f.debuglog("stream"):function(){};var l,p,d,h=n(424),y=n(202),A=n(203).getHighWaterMark,b=n(51).codes,g=b.ERR_INVALID_ARG_TYPE,m=b.ERR_STREAM_PUSH_AFTER_EOF,v=b.ERR_METHOD_NOT_IMPLEMENTED,w=b.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;n(3)(C,o);var I=y.errorOrDestroy,E=["error","close","destroy","pause","resume"];function _(t,e,r){i=i||n(52),t=t||{},"boolean"!=typeof r&&(r=e instanceof i),this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=A(this,t,"readableHighWaterMark",r),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.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&&(l||(l=n(29).StringDecoder),this.decoder=new l(t.encoding),this.encoding=t.encoding)}function C(t){if(i=i||n(52),!(this instanceof C))return new C(t);var e=this instanceof i;this._readableState=new _(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,i){c("readableAddChunk",e);var a,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,Q(t)))}(t,o);else if(i||(a=function(t,e){var n;r=e,s.isBuffer(r)||r instanceof u||"string"==typeof e||void 0===e||t.objectMode||(n=new g("chunk",["string","Buffer","Uint8Array"],e));var r;return n}(o,e)),a)I(t,a);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?I(t,new w):B(t,o,e,!0);else if(o.ended)I(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?B(t,o,e,!1):M(t,o)):B(t,o,e,!1)}else r||(o.reading=!1,M(t,o));return!o.ended&&(o.length<o.highWaterMark||0===o.length)}function B(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(C.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(t){this._readableState&&(this._readableState.destroyed=t)}}),C.prototype.destroy=y.destroy,C.prototype._undestroy=y.undestroy,C.prototype._destroy=function(t,e){e(t)},C.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)},C.prototype.unshift=function(t){return k(this,t,null,!0,!1)},C.prototype.isPaused=function(){return!1===this._readableState.flowing},C.prototype.setEncoding=function(t){l||(l=n(29).StringDecoder);var e=new l(t);this._readableState.decoder=e,this._readableState.encoding=this._readableState.decoder.encoding;for(var r=this._readableState.buffer.head,i="";null!==r;)i+=e.write(r.data),r=r.next;return this._readableState.buffer.clear(),""!==i&&this._readableState.buffer.push(i),this._readableState.length=i.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(Q,t))}function Q(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,P(t)}function M(t,e){e.readingMore||(e.readingMore=!0,r.nextTick(R,t,e))}function R(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 O(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 j(t){c("readable nexttick read 0"),t.read(0)}function T(t,e){c("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),P(t),e.flowing&&!e.reading&&t.read(0)}function P(t){var e=t._readableState;for(c("flow",e.flowing);e.flowing&&null!==t.read(););}function D(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 N(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}C.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?N(this):S(this),null;if(0===(t=x(t,e))&&e.ended)return 0===e.length&&N(this),null;var r,i=e.needReadable;return c("need readable",i),(0===e.length||e.length-t<e.highWaterMark)&&c("length less than watermark",i=!0),e.ended||e.reading?c("reading or ended",i=!1):i&&(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?D(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&&N(this)),null!==r&&this.emit("data",r),r},C.prototype._read=function(t){I(this,new v("_read()"))},C.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,c("pipe count=%d opts=%j",i.pipesCount,e);var o=(!e||!1!==e.end)&&t!==r.stdout&&t!==r.stderr?u:A;function s(e,r){c("onunpipe"),e===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,c("cleanup"),t.removeListener("close",h),t.removeListener("finish",y),t.removeListener("drain",f),t.removeListener("error",d),t.removeListener("unpipe",s),n.removeListener("end",u),n.removeListener("end",A),n.removeListener("data",p),l=!0,!i.awaitDrain||t._writableState&&!t._writableState.needDrain||f())}function u(){c("onend"),t.end()}i.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&&a(t,"data")&&(e.flowing=!0,P(t))}}(n);t.on("drain",f);var l=!1;function p(e){c("ondata");var r=t.write(e);c("dest.write",r),!1===r&&((1===i.pipesCount&&i.pipes===t||i.pipesCount>1&&-1!==F(i.pipes,t))&&!l&&(c("false write response, pause",i.awaitDrain),i.awaitDrain++),n.pause())}function d(e){c("onerror",e),A(),t.removeListener("error",d),0===a(t,"error")&&I(t,e)}function h(){t.removeListener("finish",y),A()}function y(){c("onfinish"),t.removeListener("close",h),A()}function A(){c("unpipe"),n.unpipe(t)}return n.on("data",p),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",d),t.once("close",h),t.once("finish",y),t.emit("pipe",n),i.flowing||(c("pipe resume"),n.resume()),t},C.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,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var a=0;a<i;a++)r[a].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},C.prototype.on=function(t,e){var n=o.prototype.on.call(this,t,e),i=this._readableState;return"data"===t?(i.readableListening=this.listenerCount("readable")>0,!1!==i.flowing&&this.resume()):"readable"===t&&(i.endEmitted||i.readableListening||(i.readableListening=i.needReadable=!0,i.flowing=!1,i.emittedReadable=!1,c("on readable",i.length,i.reading),i.length?S(this):i.reading||r.nextTick(j,this))),n},C.prototype.addListener=C.prototype.on,C.prototype.removeListener=function(t,e){var n=o.prototype.removeListener.call(this,t,e);return"readable"===t&&r.nextTick(O,this),n},C.prototype.removeAllListeners=function(t){var e=o.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||r.nextTick(O,this),e},C.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(T,t,e))}(this,t)),t.paused=!1,this},C.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},C.prototype.wrap=function(t){var e=this,n=this._readableState,r=!1;for(var i 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(i){(c("wrapped data"),n.decoder&&(i=n.decoder.write(i)),n.objectMode&&null==i)||(n.objectMode||i&&i.length)&&(e.push(i)||(r=!0,t.pause()))})),t)void 0===this[i]&&"function"==typeof t[i]&&(this[i]=function(e){return function(){return t[e].apply(t,arguments)}}(i));for(var a=0;a<E.length;a++)t.on(E[a],this.emit.bind(this,E[a]));return this._read=function(e){c("wrapped _read",e),r&&(r=!1,t.resume())},this},"function"==typeof Symbol&&(C.prototype[Symbol.asyncIterator]=function(){return void 0===p&&(p=n(426)),p(this)}),Object.defineProperty(C.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(C.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(C.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(t){this._readableState&&(this._readableState.flowing=t)}}),C._fromList=D,Object.defineProperty(C.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),"function"==typeof Symbol&&(C.from=function(t,e){return void 0===d&&(d=n(427)),d(C,t,e)})}).call(this,n(8),n(6))},function(t,e,n){t.exports=n(20).EventEmitter},function(t,e,n){"use strict";(function(e){function n(t,e){i(t,e),r(t)}function r(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit("close")}function i(t,e){t.emit("error",e)}t.exports={destroy:function(t,a){var o=this,s=this._readableState&&this._readableState.destroyed,u=this._writableState&&this._writableState.destroyed;return s||u?(a?a(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,e.nextTick(i,this,t)):e.nextTick(i,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,(function(t){!a&&t?o._writableState?o._writableState.errorEmitted?e.nextTick(r,o):(o._writableState.errorEmitted=!0,e.nextTick(n,o,t)):e.nextTick(n,o,t):a?(e.nextTick(r,o),a(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(6))},function(t,e,n){"use strict";var r=n(51).codes.ERR_INVALID_OPT_VALUE;t.exports={getHighWaterMark:function(t,e,n,i){var a=function(t,e,n){return null!=t.highWaterMark?t.highWaterMark:e?t[n]:null}(e,i,n);if(null!=a){if(!isFinite(a)||Math.floor(a)!==a||a<0)throw new r(i?n:"highWaterMark",a);return Math.floor(a)}return t.objectMode?16:16384}}},function(t,e,n){"use strict";(function(e,r){function i(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 i=r.callback;e.pendingcb--,i(n),r=r.next}e.corkedRequestsFree.next=t}(e,t)}}var a;t.exports=C,C.WritableState=_;var o={deprecate:n(71)},s=n(201),u=n(4).Buffer,c=(void 0!==e?e:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){};var f,l=n(202),p=n(203).getHighWaterMark,d=n(51).codes,h=d.ERR_INVALID_ARG_TYPE,y=d.ERR_METHOD_NOT_IMPLEMENTED,A=d.ERR_MULTIPLE_CALLBACK,b=d.ERR_STREAM_CANNOT_PIPE,g=d.ERR_STREAM_DESTROYED,m=d.ERR_STREAM_NULL_VALUES,v=d.ERR_STREAM_WRITE_AFTER_END,w=d.ERR_UNKNOWN_ENCODING,I=l.errorOrDestroy;function E(){}function _(t,e,o){a=a||n(52),t=t||{},"boolean"!=typeof o&&(o=e instanceof a),this.objectMode=!!t.objectMode,o&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=p(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,i=n.sync,a=n.writecb;if("function"!=typeof a)throw new A;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(n),e)!function(t,e,n,i,a){--e.pendingcb,n?(r.nextTick(a,i),r.nextTick(M,t,e),t._writableState.errorEmitted=!0,I(t,i)):(a(i),t._writableState.errorEmitted=!0,I(t,i),M(t,e))}(t,n,i,e,a);else{var o=S(n)||t.destroyed;o||n.corked||n.bufferProcessing||!n.bufferedRequest||x(t,n),i?r.nextTick(B,t,n,o,a):B(t,n,o,a)}}(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 i(this)}function C(t){var e=this instanceof(a=a||n(52));if(!e&&!f.call(C,this))return new C(t);this._writableState=new _(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,i,a,o){e.writelen=r,e.writecb=o,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new g("write")):n?t._writev(i,e.onwrite):t._write(i,a,e.onwrite),e.sync=!1}function B(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,a=new Array(r),o=e.corkedRequestsFree;o.entry=n;for(var s=0,u=!0;n;)a[s]=n,n.isBuf||(u=!1),n=n.next,s+=1;a.allBuffers=u,k(t,e,!0,e.length,a,"",o.finish),e.pendingcb++,e.lastBufferedRequest=null,o.next?(e.corkedRequestsFree=o.next,o.next=null):e.corkedRequestsFree=new i(e),e.bufferedRequestCount=0}else{for(;n;){var c=n.chunk,f=n.encoding,l=n.callback;if(k(t,e,!1,e.objectMode?1:c.length,c,f,l),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 Q(t,e){t._final((function(n){e.pendingcb--,n&&I(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(Q,t,e)))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit("finish"),e.autoDestroy))){var i=t._readableState;(!i||i.autoDestroy&&i.endEmitted)&&t.destroy()}return n}n(3)(C,s),_.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(_.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(C,Symbol.hasInstance,{value:function(t){return!!f.call(this,t)||this===C&&(t&&t._writableState instanceof _)}})):f=function(t){return t instanceof this},C.prototype.pipe=function(){I(this,new b)},C.prototype.write=function(t,e,n){var i,a=this._writableState,o=!1,s=!a.objectMode&&(i=t,u.isBuffer(i)||i 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=a.defaultEncoding),"function"!=typeof n&&(n=E),a.ending?function(t,e){var n=new v;I(t,n),r.nextTick(e,n)}(this,n):(s||function(t,e,n,i){var a;return null===n?a=new m:"string"==typeof n||e.objectMode||(a=new h("chunk",["string","Buffer"],n)),!a||(I(t,a),r.nextTick(i,a),!1)}(this,a,t,n))&&(a.pendingcb++,o=function(t,e,n,r,i,a){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,i);r!==o&&(n=!0,i="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:i,isBuf:n,callback:a,next:null},f?f.next=e.lastBufferedRequest:e.bufferedRequest=e.lastBufferedRequest,e.bufferedRequestCount+=1}else k(t,e,!1,s,r,i,a);return c}(this,a,s,t,e,n)),o},C.prototype.cork=function(){this._writableState.corked++},C.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,t.writing||t.corked||t.bufferProcessing||!t.bufferedRequest||x(this,t))},C.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 w(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(C.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(C.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),C.prototype._write=function(t,e,n){n(new y("_write()"))},C.prototype._writev=null,C.prototype.end=function(t,e,n){var i=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),i.corked&&(i.corked=1,this.uncork()),i.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,i,n),this},Object.defineProperty(C.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(C.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),C.prototype.destroy=l.destroy,C.prototype._undestroy=l.undestroy,C.prototype._destroy=function(t,e){e(t)}}).call(this,n(8),n(6))},function(t,e,n){"use strict";t.exports=f;var r=n(51).codes,i=r.ERR_METHOD_NOT_IMPLEMENTED,a=r.ERR_MULTIPLE_CALLBACK,o=r.ERR_TRANSFORM_ALREADY_TRANSFORMING,s=r.ERR_TRANSFORM_WITH_LENGTH_0,u=n(52);function c(t,e){var n=this._transformState;n.transforming=!1;var r=n.writecb;if(null===r)return this.emit("error",new a);n.writechunk=null,n.writecb=null,null!=e&&this.push(e),r(t);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.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",l)}function l(){var t=this;"function"!=typeof this._flush||this._readableState.destroyed?p(this,null,null):this._flush((function(e,n){p(t,e,n)}))}function p(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 i("_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 i=this._readableState;(r.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.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){(function(t){var r=n(36),i=n(17),a=n(9),o=n(10);function s(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 u(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?s(Object(n),!0).forEach((function(e){i(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):s(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}var c,f=n(28);f.Platform()===f.PLATFORM_NODE&&(globalThis.Response=n(82).Response,c=n(207));var l=n(30),p=n(31),d=p.ValidatePresence,h=p.ValidateWriteToken,y=p.ValidatePartHash,A=p.ValidateParameters;e.ListFiles=function(){var t=o(a.mark((function t(e){var n,r,i,o;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.versionHash,A({libraryId:n,objectId:r,versionHash:i}),i&&(r=this.utils.DecodeVersionHash(i).objectId),o=l("q",i||r,"meta","files"),t.t0=this.utils,t.t1=this.HttpClient,t.next=8,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,versionHash:i});case 8:return t.t2=t.sent,t.t3=o,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.UploadFilesFromS3=function(){var e=o(a.mark((function e(n){var r,i,o,s,c,f,l,p,d,y,b,g,m,v,w,I,E,_,C,k,B,x,S,Q,M,R,O,j,T;return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.libraryId,i=n.objectId,o=n.writeToken,s=n.region,c=n.bucket,f=n.fileInfo,l=n.accessKey,p=n.secret,d=n.signedUrl,y=n.encryption,b=void 0===y?"none":y,g=n.copy,m=void 0!==g&&g,v=n.callback,A({libraryId:r,objectId:i}),h(o),w=/^s3:\/\/([^/]+)\//i,I=0;case 5:if(!(I<f.length)){e.next=18;break}if(E=f[I].source,!(_=w.exec(E))){e.next=15;break}if(_[1]===c){e.next=14;break}throw Error('Full S3 file path "'+E+"\" specified, but does not match provided bucket name '"+c+"'");case 14:f[I].source=E.replace(w,"");case 15:I++,e.next=5;break;case 18:if(this.Log("Uploading files from S3: ".concat(r," ").concat(i," ").concat(o)),"cgck"!==b){e.next=25;break}return e.next=22,this.EncryptionConk({libraryId:r,objectId:i,writeToken:o});case 22:k=u(u({},k=e.sent),{},{secret_key:""}),C="kp__".concat(this.utils.B58(t.from(JSON.stringify(k))));case 25:return B={access_key_id:l,secret_access_key:p},d&&(B={signed_url:d}),x={encryption_key:C,access:{protocol:"s3",platform:"aws",path:c,storage_endpoint:{region:s},cloud_credentials:B}},S=f.map((function(t){return m?{op:"ingest-copy",path:t.path,encryption:{scheme:"cgck"===b?"cgck":"none"},ingest:{type:"key",path:t.source}}:{op:"add-reference",path:t.path,reference:{type:"key",path:t.source}}})),e.next=31,this.CreateFileUploadJob({libraryId:r,objectId:i,writeToken:o,ops:S,defaults:x});case 31:Q=e.sent,M=Q.id;case 33:return e.next=36,new Promise((function(t){return setTimeout(t,1e3)}));case 36:return e.next=38,this.UploadStatus({libraryId:r,objectId:i,writeToken:o,uploadId:M});case 38:if(!((R=e.sent).errors&&R.errors.length>1)){e.next=43;break}throw R.errors.join("\n");case 43:if(!R.error){e.next=48;break}throw this.Log("S3 file upload failed:\n".concat(JSON.stringify(R,null,2))),R.error;case 48:if("failed"!==R.status.toLowerCase()){e.next=50;break}throw"File upload failed";case 50:if(O=!1,m?(O=R.ingest_copy.done,v&&(j=R.ingest_copy.progress,v({done:O,uploaded:j.bytes.completed,total:j.bytes.total,uploadedFiles:j.files.completed,totalFiles:j.files.total,fileStatus:j.files.details}))):(O=R.add_reference.done,v&&(T=R.add_reference.progress,v({done:O,uploadedFiles:T.completed,totalFiles:T.total}))),!O){e.next=54;break}return e.abrupt("break",56);case 54:e.next=33;break;case 56:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),e.UploadFiles=function(){var e=o(a.mark((function e(n){var r,i,s,f,l,p,y,b,g,m,v,w,I,E,_,C,k,B,x,S,Q,M,R,O,j,T,P,D,N,L=this;return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=n.libraryId,i=n.objectId,s=n.writeToken,f=n.fileInfo,l=n.encryption,p=void 0===l?"none":l,y=n.callback,A({libraryId:r,objectId:i}),h(s),d("fileInfo",f),this.Log("Uploading files: ".concat(r," ").concat(i," ").concat(s)),"cgck"!==p){e.next=9;break}return e.next=8,this.EncryptionConk({libraryId:r,objectId:i,writeToken:s});case 8:b=e.sent;case 9:for(g={},m={},v=f,f=[],w=0;w<v.length;w++)(I=u(u({},v[w]),{},{data:void 0})).path=I.path.replace(/^\/+/,""),"cgck"===p&&(I.encryption={scheme:"cgck"}),m[I.path]=v[w].data,I.type="file",g[I.path]={uploaded:0,total:I.size},f.push(I);return this.Log(f),y&&y(g),e.next=18,this.CreateFileUploadJob({libraryId:r,objectId:i,writeToken:s,ops:f,encryption:p});case 18:E=e.sent,_=E.id,C=E.jobs,this.Log("Upload ID: ".concat(_)),this.Log(C),524288e3,k=[],B=0,x=0,S=function(){var e=o(a.mark((function e(){var n,o,u,f,l,d;return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=0;case 1:if(!(n<C.length)){e.next=31;break}case 2:if(!(B-x>524288e3)){e.next=7;break}return e.next=5,new Promise((function(t){return setTimeout(t,500)}));case 5:e.next=2;break;case 7:return o=C[n],e.next=10,L.UploadJobStatus({libraryId:r,objectId:i,writeToken:s,uploadId:_,jobId:o});case 10:u=e.sent,f=0;case 12:if(!(f<u.files.length)){e.next=25;break}if(l=u.files[f],d=void 0,"number"==typeof m[l.path]?(d=t.alloc(l.len),c.readSync(m[l.path],d,0,l.len,l.off)):d=m[l.path].slice(l.off,l.off+l.len),"cgck"!==p){e.next=20;break}return e.next=19,L.Crypto.Encrypt(b,d);case 19:d=e.sent;case 20:u.files[f].data=d,B+=l.len;case 22:f++,e.next=12;break;case 25:return k[n]=u,e.next=28,new Promise((function(t){return setTimeout(t,50)}));case 28:n++,e.next=1;break;case 31:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),Q=function(){var t=o(a.mark((function t(e,n){var o,c,f,l;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(k[n]){t.next=5;break}return t.next=3,new Promise((function(t){return setTimeout(t,500)}));case 3:t.next=0;break;case 5:o=k[n],c=o.files,f=a.mark((function t(){var o,f,d;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:o=c[l],f=0,d=!1;case 3:return t.prev=3,t.next=6,L.UploadFileData({libraryId:r,objectId:i,writeToken:s,uploadId:_,jobId:e,filePath:o.path,fileData:o.data,encryption:p});case 6:d=!0,t.next=17;break;case 9:if(t.prev=9,t.t0=t.catch(3),L.Log(t.t0,!0),!((f+=1)>=10)){t.next=15;break}throw t.t0;case 15:return t.next=17,new Promise((function(t){return setTimeout(t,10*f*1e3)}));case 17:if(!d&&f<10){t.next=3;break}case 18:delete k[n].files[l].data,x+=o.len,y&&(g[o.path]=u(u({},g[o.path]),{},{uploaded:g[o.path].uploaded+o.len}),y(g));case 21:case"end":return t.stop()}}),t,null,[[3,9]])})),l=0;case 9:if(!(l<c.length)){t.next=14;break}return t.delegateYield(f(),"t0",11);case 11:l++,t.next=9;break;case 14:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}(),S().catch((function(t){throw t})),M=Math.min(3,C.length),R=[],O=0;case 33:if(!(O<M)){e.next=43;break}return j=(new Date).getTime(),e.next=37,Q(C[O],O);case 37:T=((new Date).getTime()-j)/1e3,P=k[O].files.map((function(t){return t.len})).reduce((function(t,e){return t+e}),0),R.push(P/T/1048576);case 40:O++,e.next=33;break;case 43:return D=R.reduce((function(t,e){return t+e}),0)/M,N=Math.min(5,Math.ceil(D/2)),e.next=47,this.utils.LimitedMap(N,C,function(){var t=o(a.mark((function t(e,n){return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(n<M)){t.next=2;break}return t.abrupt("return");case 2:return t.next=4,Q(e,n);case 4:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}());case 47:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),e.CreateFileUploadJob=function(){var t=o(a.mark((function t(e){var n,r,i,o,s,u,c,f,p,d;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.writeToken,o=e.ops,s=e.defaults,u=void 0===s?{}:s,c=e.encryption,f=void 0===c?"none":c,A({libraryId:n,objectId:r}),h(i),this.Log("Creating file upload job: ".concat(n," ").concat(r," ").concat(i)),this.Log(o),"cgck"===f&&(u.encryption={scheme:"cgck"}),p={seq:0,seq_complete:!0,defaults:u,ops:o},d=l("q",i,"file_jobs"),t.t0=this.utils,t.t1=this.HttpClient,t.next=12,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,update:!0,encryption:f});case 12:return t.t2=t.sent,t.t3=d,t.t4=p,t.t5={headers:t.t2,method:"POST",path:t.t3,body:t.t4,allowFailover:!1},t.t6=t.t1.Request.call(t.t1,t.t5),t.abrupt("return",t.t0.ResponseToJson.call(t.t0,t.t6));case 18:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.UploadStatus=function(){var t=o(a.mark((function t(e){var n,r,i,o,s;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.writeToken,o=e.uploadId,A({libraryId:n,objectId:r}),h(i),s=l("q",i,"file_jobs",o),t.t0=this.utils,t.t1=this.HttpClient,t.next=8,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,update:!0});case 8:return t.t2=t.sent,t.t3=s,t.t4={headers:t.t2,method:"GET",path:t.t3,allowFailover:!1},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.UploadJobStatus=function(){var t=o(a.mark((function t(e){var n,i,o,s,u,c,f,p;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,i=e.objectId,o=e.writeToken,s=e.uploadId,u=e.jobId,A({libraryId:n,objectId:i}),h(o),c=l("q",o,"file_jobs",s,"uploads",u),t.t0=this.utils,t.t1=this.HttpClient,t.next=8,this.authClient.AuthorizationHeader({libraryId:n,objectId:i,update:!0});case 8:return t.t2=t.sent,t.t3=c,t.t4={start:0,limit:1e4},t.t5={headers:t.t2,method:"GET",path:t.t3,allowFailover:!1,queryParams:t.t4},t.t6=t.t1.Request.call(t.t1,t.t5),t.next=15,t.t0.ResponseToJson.call(t.t0,t.t6);case 15:f=t.sent;case 16:if(!(f.next!==f.total&&f.next>=0)){t.next=33;break}return t.t7=this.utils,t.t8=this.HttpClient,t.next=21,this.authClient.AuthorizationHeader({libraryId:n,objectId:i,update:!0});case 21:return t.t9=t.sent,t.t10=c,t.t11={start:f.next},t.t12={headers:t.t9,method:"GET",path:t.t10,allowFailover:!1,queryParams:t.t11},t.t13=t.t8.Request.call(t.t8,t.t12),t.next=28,t.t7.ResponseToJson.call(t.t7,t.t13);case 28:p=t.sent,f.files=[].concat(r(f.files),r(p.files)),f.next=p.next,t.next=16;break;case 33:return t.abrupt("return",f);case 34:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.UploadFileData=function(){var t=o(a.mark((function t(e){var n,r,i,o,s,c,f,p,d,y,b;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.writeToken,o=e.encryption,s=e.uploadId,c=e.jobId,f=e.filePath,p=e.fileData,A({libraryId:n,objectId:r}),h(i),t.next=5,this.UploadJobStatus({libraryId:n,objectId:r,writeToken:i,uploadId:s,jobId:c});case 5:if(d=t.sent,y=d.files.find((function(t){return t.path==f})),o&&"none"!==o&&(y=y.encrypted),0!==y.rem){t.next=12;break}return t.abrupt("return");case 12:y.skip&&(p=p.slice(y.skip));case 13:return b=l("q",i,"file_jobs",s,c),t.t0=this.utils,t.t1=this.HttpClient,t.t2=b,t.t3=p,t.t4=u,t.t5={"Content-type":"application/octet-stream"},t.next=22,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,update:!0});case 22:return t.t6=t.sent,t.t7=(0,t.t4)(t.t5,t.t6),t.t8={method:"POST",path:t.t2,body:t.t3,bodyType:"BINARY",headers:t.t7,allowFailover:!1,allowRetry:!1},t.t9=t.t1.Request.call(t.t1,t.t8),t.next=28,t.t0.ResponseToJson.call(t.t0,t.t9);case 28:return t.abrupt("return",t.sent);case 29:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.FinalizeUploadJob=function(){var t=o(a.mark((function t(e){var n,r,i,o;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.writeToken,A({libraryId:n,objectId:r}),h(i),this.Log("Finalizing upload job: ".concat(n," ").concat(r," ").concat(i)),o=l("q",i,"files"),t.t0=this.HttpClient,t.t1=o,t.next=9,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,update:!0});case 9:return t.t2=t.sent,t.t3={method:"POST",path:t.t1,bodyType:"BINARY",headers:t.t2,allowFailover:!1},t.next=13,t.t0.Request.call(t.t0,t.t3);case 13:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.CreateFileDirectories=function(){var t=o(a.mark((function t(e){var n,r,i,o,s;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.writeToken,o=e.filePaths,A({libraryId:n,objectId:r}),h(i),this.Log("Creating Directories: ".concat(n," ").concat(r," ").concat(i)),this.Log(o),s=o.map((function(t){return{op:"add",type:"directory",path:t}})),t.next=8,this.CreateFileUploadJob({libraryId:n,objectId:r,writeToken:i,ops:s});case 8:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.MoveFiles=function(){var t=o(a.mark((function t(e){var n,r,i,o,s;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.writeToken,o=e.filePaths,A({libraryId:n,objectId:r}),h(i),this.Log("Moving Files: ".concat(n," ").concat(r," ").concat(i)),this.Log(o),s=o.map((function(t){return{op:"move",copy_move_source_path:t.path,path:t.to}})),t.next=8,this.CreateFileUploadJob({libraryId:n,objectId:r,writeToken:i,ops:s});case 8:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.DeleteFiles=function(){var t=o(a.mark((function t(e){var n,r,i,o,s;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.writeToken,o=e.filePaths,A({libraryId:n,objectId:r}),h(i),this.Log("Deleting Files: ".concat(n," ").concat(r," ").concat(i)),this.Log(o),s=o.map((function(t){return{op:"del",path:t}})),t.next=8,this.CreateFileUploadJob({libraryId:n,objectId:r,writeToken:i,ops:s});case 8:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.DownloadFile=function(){var t=o(a.mark((function t(e){var n,r,i,o,s,c,f,p,h,y,b,g,m,v,w,I,E,_,C,k,B,x=arguments;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.versionHash,o=e.writeToken,s=e.filePath,c=e.format,f=void 0===c?"arrayBuffer":c,p=e.chunked,h=void 0!==p&&p,y=e.chunkSize,b=e.clientSideDecryption,g=void 0!==b&&b,m=e.callback,A({libraryId:n,objectId:r,versionHash:i}),d("filePath",s),i&&(r=this.utils.DecodeVersionHash(i).objectId),t.next=6,this.ContentObjectMetadata({libraryId:n,objectId:r,versionHash:i,writeToken:o,metadataSubtree:l("files",s)});case 6:return v=t.sent,w=v&&v["."].encryption&&"cgck"===v["."].encryption.scheme,I=w?"cgck":void 0,E=w&&!g?l("q",o||i||r,"rep","files_download",s):l("q",o||i||r,"files",s),t.next=12,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,versionHash:i,encryption:I,makeAccessRequest:"cgck"===I});case 12:return(_=t.sent).Accept="*/*",C="eluv.caps.iusr".concat(this.utils.AddressToHash(this.signer.address)),t.next=17,this.ContentObjectMetadata({libraryId:n,objectId:r,versionHash:i,metadataSubtree:C});case 17:if(k=t.sent,t.t1=w,!t.t1){t.next=26;break}return t.t2=this.utils,t.t3=this.signer.address,t.next=24,this.ContentObjectOwner({objectId:r});case 24:t.t4=t.sent,t.t1=!t.t2.EqualAddress.call(t.t2,t.t3,t.t4);case 26:if(t.t0=t.t1,!t.t0){t.next=29;break}t.t0=!k;case 29:if(!t.t0){t.next=31;break}_["X-Content-Fabric-Decryption-Mode"]="reencrypt";case 31:if(w&&!g&&(_["X-Content-Fabric-Decryption-Mode"]="decrypt",y=Number.MAX_SAFE_INTEGER),B=v["."].size,!w||!g){t.next=51;break}return t.t5=this,t.next=37,this.EncryptionConk({libraryId:n,objectId:r,versionHash:i,download:!0});case 37:return t.t6=t.sent,t.t7=E,t.t8=B,t.t9=_,t.t10=m,t.t11=f,t.t12=g,t.t13=h,t.t14={conk:t.t6,downloadPath:t.t7,bytesTotal:t.t8,headers:t.t9,callback:t.t10,format:t.t11,clientSideDecryption:t.t12,chunked:t.t13},t.next=48,t.t5.DownloadEncrypted.call(t.t5,t.t14);case 48:return t.abrupt("return",t.sent);case 51:return y||(y=1e7),t.prev=52,t.next=55,this.Download({downloadPath:E,bytesTotal:B,headers:_,callback:m,format:f,chunked:h,chunkSize:y});case 55:return t.abrupt("return",t.sent);case 58:if(t.prev=58,t.t15=t.catch(52),!w||g){t.next=62;break}return t.abrupt("return",this.DownloadFile(u(u({},x[0]),{},{clientSideDecryption:!0})));case 62:throw t.t15;case 63:case"end":return t.stop()}}),t,this,[[52,58]])})));return function(e){return t.apply(this,arguments)}}(),e.ContentParts=function(){var t=o(a.mark((function t(e){var n,r,i,o,s;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.versionHash,A({libraryId:n,objectId:r,versionHash:i}),this.Log("Retrieving parts: ".concat(n," ").concat(r||i)),i&&(r=this.utils.DecodeVersionHash(i).objectId),o=l("q",i||r,"parts"),t.t0=this.utils,t.t1=this.HttpClient,t.next=9,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,versionHash:i});case 9:return t.t2=t.sent,t.t3=o,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 s=t.sent,t.abrupt("return",s.parts);case 17:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.ContentPart=function(){var t=o(a.mark((function t(e){var n,r,i,o,s;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.versionHash,o=e.partHash,A({libraryId:n,objectId:r,versionHash:i}),y(o),this.Log("Retrieving part: ".concat(n," ").concat(r||i," ").concat(o)),i&&(r=this.utils.DecodeVersionHash(i).objectId),s=l("q",i||r,"parts",o),t.t0=this.utils,t.t1=this.HttpClient,t.next=10,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,versionHash:i});case 10: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=16,t.t0.ResponseToJson.call(t.t0,t.t5);case 16:return t.abrupt("return",t.sent);case 17:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.DownloadPart=function(){var t=o(a.mark((function t(e){var n,r,i,o,s,u,c,f,p,d,h,b,g,m,v,w,I;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.versionHash,o=e.writeToken,s=e.partHash,u=e.format,c=void 0===u?"arrayBuffer":u,f=e.chunked,p=void 0!==f&&f,d=e.chunkSize,h=void 0===d?1e7:d,b=e.callback,A({libraryId:n,objectId:r,versionHash:i}),y(s),i&&(r=this.utils.DecodeVersionHash(i).objectId),g=s.startsWith("hqpe"),m=g?"cgck":void 0,v=l("q",o||i||r,"data",s),t.next=9,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,versionHash:i,encryption:m,makeAccessRequest:!0});case 9:return w=t.sent,t.next=12,this.ContentPart({libraryId:n,objectId:r,versionHash:i,partHash:s});case 12:if(I=t.sent.part.size,!g){t.next=37;break}return t.t0=this.utils,t.t1=this.signer.address,t.next=18,this.ContentObjectOwner({objectId:r});case 18:if(t.t2=t.sent,t.t0.EqualAddress.call(t.t0,t.t1,t.t2)){t.next=21;break}w["X-Content-Fabric-Decryption-Mode"]="reencrypt";case 21:return t.t3=this,t.next=24,this.EncryptionConk({libraryId:n,objectId:r,download:!0});case 24:return t.t4=t.sent,t.t5=v,t.t6=I,t.t7=w,t.t8=b,t.t9=c,t.t10=p,t.t11={conk:t.t4,downloadPath:t.t5,bytesTotal:t.t6,headers:t.t7,callback:t.t8,format:t.t9,chunked:t.t10},t.next=34,t.t3.DownloadEncrypted.call(t.t3,t.t11);case 34:return t.abrupt("return",t.sent);case 37:return t.next=39,this.Download({downloadPath:v,bytesTotal:I,headers:w,callback:b,format:c,chunked:p,chunkSize:h});case 39:return t.abrupt("return",t.sent);case 40:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.Download=function(){var e=o(a.mark((function e(n){var r,i,o,s,u,c,f,l,p,d,h,y,A,b,g;return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=n.downloadPath,i=n.headers,o=n.bytesTotal,s=n.chunked,u=void 0!==s&&s,c=n.chunkSize,f=void 0===c?2e6:c,l=n.callback,p=n.format,d=void 0===p?"arrayBuffer":p,!u||l){e.next=3;break}throw Error("No callback specified for chunked download");case 3:u||(h=[]),y=0,A=Math.ceil(o/f),b=0;case 7:if(!(b<A)){e.next=35;break}return i.Range="bytes=".concat(y,"-").concat(y+f-1),e.next=11,this.HttpClient.Request({path:r,headers:i,method:"GET"});case 11:if(g=e.sent,y=Math.min(y+f,o),!u){e.next=24;break}return e.t0=l,e.t1=y,e.t2=o,e.next=19,this.utils.ResponseToFormat(d,g);case 19:e.t3=e.sent,e.t4={bytesFinished:e.t1,bytesTotal:e.t2,chunk:e.t3},(0,e.t0)(e.t4),e.next=32;break;case 24:return e.t5=h,e.t6=t,e.next=28,g.arrayBuffer();case 28:e.t7=e.sent,e.t8=e.t6.from.call(e.t6,e.t7),e.t5.push.call(e.t5,e.t8),l&&l({bytesFinished:y,bytesTotal:o});case 32:b++,e.next=7;break;case 35:if(u){e.next=39;break}return e.next=38,this.utils.ResponseToFormat(d,new Response(t.concat(h)));case 38:return e.abrupt("return",e.sent);case 39:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),e.DownloadEncrypted=function(){var e=o(a.mark((function e(n){var r,i,s,u,c,f,l,p,d,h,y,A,b,g,m,v,w,I=this;return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=n.conk,i=n.downloadPath,s=n.bytesTotal,u=n.headers,c=n.callback,f=n.format,l=void 0===f?"arrayBuffer":f,p=n.chunked,!(d=void 0!==p&&p)||c){e.next=3;break}throw Error("No callback specified for chunked download");case 3:return h=r.public_key.startsWith("ktpk"),y=this.Crypto.EncryptedBlockSize(1e6,h),A=0,l=l.toLowerCase(),b=[],e.next=10,this.Crypto.OpenDecryptionStream(r);case 10:(g=e.sent).on("data",function(){var t=o(a.mark((function t(e){var n;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!d){t.next=13;break}if("buffer"===l){t.next=10;break}if(n=e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength),"arraybuffer"!==l){t.next=7;break}e=n,t.next=10;break;case 7:return t.next=9,I.utils.ResponseToFormat(l,new Response(n));case 9:e=t.sent;case 10:c({bytesFinished:A,bytesTotal:s,chunk:e}),t.next=15;break;case 13:c&&c({bytesFinished:A,bytesTotal:s}),b.push(e);case 15:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),m=Math.ceil(s/y),v=0;case 14:if(!(v<m)){e.next=30;break}return u.Range="bytes=".concat(A,"-").concat(A+y-1),e.next=18,this.HttpClient.Request({headers:u,method:"GET",path:i});case 18:return w=e.sent,A=Math.min(A+y,s),e.t0=g,e.t1=Uint8Array,e.next=24,w.arrayBuffer();case 24:e.t2=e.sent,e.t3=new e.t1(e.t2),e.t0.write.call(e.t0,e.t3);case 27:v++,e.next=14;break;case 30:return g.end(),e.next=33,new Promise((function(t){return g.on("finish",(function(){t()}))}));case 33:if(d){e.next=37;break}return e.next=36,this.utils.ResponseToFormat(l,new Response(t.concat(b)));case 36:return e.abrupt("return",e.sent);case 37:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),e.CreatePart=function(){var t=o(a.mark((function t(e){var n,r,i,o,s,u;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.writeToken,o=e.encryption,A({libraryId:n,objectId:r}),h(i),s=l("q",i,"parts"),t.t0=this.utils,t.t1=this.HttpClient,t.next=8,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,update:!0,encryption:o});case 8:return t.t2=t.sent,t.t3=s,t.t4={headers:t.t2,method:"POST",path:t.t3,bodyType:"BINARY",body:"",allowFailover:!1},t.t5=t.t1.Request.call(t.t1,t.t4),t.next=14,t.t0.ResponseToJson.call(t.t0,t.t5);case 14:return u=t.sent,t.abrupt("return",u.part.write_token);case 16:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.UploadPartChunk=function(){var t=o(a.mark((function t(e){var n,r,i,o,s,u,c,f;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,i=e.writeToken,o=e.partWriteToken,s=e.chunk,u=e.encryption,A({libraryId:n,objectId:r}),h(i),!u||"none"===u){t.next=10;break}return t.next=6,this.EncryptionConk({libraryId:n,objectId:r,writeToken:i});case 6:return c=t.sent,t.next=9,this.Crypto.Encrypt(c,s);case 9:s=t.sent;case 10:return f=l("q",i,"parts"),t.t0=this.utils,t.t1=this.HttpClient,t.next=15,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,update:!0,encryption:u});case 15:return t.t2=t.sent,t.t3=l(f,o),t.t4=s,t.t5={headers:t.t2,method:"POST",path:t.t3,body:t.t4,bodyType:"BINARY",allowFailover:!1},t.t6=t.t1.Request.call(t.t1,t.t5),t.next=22,t.t0.ResponseToJson.call(t.t0,t.t6);case 22:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.FinalizePart=function(){var t=o(a.mark((function t(e){var n,r,i,o,s,u;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.writeToken,o=e.partWriteToken,s=e.encryption,A({libraryId:n,objectId:r}),h(i),u=l("q",i,"parts"),t.t0=this.utils,t.t1=this.HttpClient,t.next=8,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,update:!0,encryption:s});case 8:return t.t2=t.sent,t.t3=l(u,o),t.t4={headers:t.t2,method:"POST",path:t.t3,bodyType:"BINARY",body:"",allowFailover:!1},t.next=13,t.t1.Request.call(t.t1,t.t4);case 13:return t.t5=t.sent,t.next=16,t.t0.ResponseToJson.call(t.t0,t.t5);case 16:return t.abrupt("return",t.sent);case 17:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.UploadPart=function(){var t=o(a.mark((function t(e){var n,r,i,o,s,u,c,f,l,p,d,y,b;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.writeToken,o=e.data,s=e.encryption,u=void 0===s?"none":s,c=e.chunkSize,f=void 0===c?1e7:c,l=e.callback,A({libraryId:n,objectId:r}),h(i),t.next=5,this.CreatePart({libraryId:n,objectId:r,writeToken:i,encryption:u});case 5:p=t.sent,d=o.length||o.byteLength||o.size,l&&l({bytesFinished:0,bytesTotal:d}),y=0;case 9:if(!(y<d)){t.next=17;break}return b=o.slice(y,y+f),t.next=13,this.UploadPartChunk({libraryId:n,objectId:r,writeToken:i,partWriteToken:p,chunk:b,encryption:u});case 13:l&&l({bytesFinished:Math.min(y+f,d),bytesTotal:d});case 14:y+=f,t.next=9;break;case 17:return t.next=19,this.FinalizePart({libraryId:n,objectId:r,writeToken:i,partWriteToken:p,encryption:u});case 19:return t.abrupt("return",t.sent);case 20:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.DeletePart=function(){var t=o(a.mark((function t(e){var n,r,i,o,s;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.writeToken,o=e.partHash,A({libraryId:n,objectId:r}),h(i),y(o),s=l("q",i,"parts",o),t.t0=this.HttpClient,t.next=8,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,update:!0});case 8:return t.t1=t.sent,t.t2=s,t.t3={headers:t.t1,method:"DELETE",path:t.t2,allowFailover:!1},t.next=13,t.t0.Request.call(t.t0,t.t3);case 13:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}()}).call(this,n(4).Buffer)},function(t,e){},function(t,e,n){"use strict";(function(t){n.d(e,"a",(function(){return G}));var r=n(2),i=n.n(r),a=n(12),o=n.n(a);function s(t){return(s="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)}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==t||"undefined"!=typeof self&&self;function u(t,e,n){return t(n={path:e,exports:{},require:function(t,e){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==e&&n.path)}},n.exports),n.exports}var c=f;function f(t,e){if(!t)throw new Error(e||"Assertion failed")}f.equal=function(t,e,n){if(t!=e)throw new Error(n||"Assertion failed: "+t+" != "+e)};var l=u((function(t,e){var n=e;function r(t){return 1===t.length?"0"+t:t}function i(t){for(var e="",n=0;n<t.length;n++)e+=r(t[n].toString(16));return e}n.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 i=t.charCodeAt(r),a=i>>8,o=255&i;a?n.push(a,o):n.push(o)}return n},n.zero2=r,n.toHex=i,n.encode=function(t,e){return"hex"===e?i(t):t}})),p=u((function(t,e){var n=e;n.assert=c,n.toArray=l.toArray,n.zero2=l.zero2,n.toHex=l.toHex,n.encode=l.encode,n.getNAF=function(t,e,n){var r=new Array(Math.max(t.bitLength(),n)+1);r.fill(0);for(var i=1<<e+1,a=t.clone(),o=0;o<r.length;o++){var s,u=a.andln(i-1);a.isOdd()?(s=u>(i>>1)-1?(i>>1)-u:u,a.isubn(s)):s=0,r[o]=s,a.iushrn(1)}return r},n.getJSF=function(t,e){var n=[[],[]];t=t.clone(),e=e.clone();for(var r,i=0,a=0;t.cmpn(-i)>0||e.cmpn(-a)>0;){var o,s,u=t.andln(3)+i&3,c=e.andln(3)+a&3;3===u&&(u=-1),3===c&&(c=-1),o=0==(1&u)?0:3!==(r=t.andln(7)+i&7)&&5!==r||2!==c?u:-u,n[0].push(o),s=0==(1&c)?0:3!==(r=e.andln(7)+a&7)&&5!==r||2!==u?c:-c,n[1].push(s),2*i===o+1&&(i=1-i),2*a===s+1&&(a=1-a),t.iushrn(1),e.iushrn(1)}return n},n.cachedProperty=function(t,e,n){var r="_"+e;t.prototype[e]=function(){return void 0!==this[r]?this[r]:this[r]=n.call(this)}},n.parseBytes=function(t){return"string"==typeof t?n.toArray(t,"hex"):t},n.intFromLE=function(t){return new i.a(t,"hex","le")}})),d=p.getNAF,h=p.getJSF,y=p.assert;function A(t,e){this.type=t,this.p=new i.a(e.p,16),this.red=e.prime?i.a.red(e.prime):i.a.mont(this.p),this.zero=new i.a(0).toRed(this.red),this.one=new i.a(1).toRed(this.red),this.two=new i.a(2).toRed(this.red),this.n=e.n&&new i.a(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var n=this.n&&this.p.div(this.n);!n||n.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var b=A;function g(t,e){this.curve=t,this.type=e,this.precomputed=null}A.prototype.point=function(){throw new Error("Not implemented")},A.prototype.validate=function(){throw new Error("Not implemented")},A.prototype._fixedNafMul=function(t,e){y(t.precomputed);var n=t._getDoubles(),r=d(e,1,this._bitLength),i=(1<<n.step+1)-(n.step%2==0?2:1);i/=3;var a,o,s=[];for(a=0;a<r.length;a+=n.step){o=0;for(var u=a+n.step-1;u>=a;u--)o=(o<<1)+r[u];s.push(o)}for(var c=this.jpoint(null,null,null),f=this.jpoint(null,null,null),l=i;l>0;l--){for(a=0;a<s.length;a++)(o=s[a])===l?f=f.mixedAdd(n.points[a]):o===-l&&(f=f.mixedAdd(n.points[a].neg()));c=c.add(f)}return c.toP()},A.prototype._wnafMul=function(t,e){var n=4,r=t._getNAFPoints(n);n=r.wnd;for(var i=r.points,a=d(e,n,this._bitLength),o=this.jpoint(null,null,null),s=a.length-1;s>=0;s--){for(var u=0;s>=0&&0===a[s];s--)u++;if(s>=0&&u++,o=o.dblp(u),s<0)break;var c=a[s];y(0!==c),o="affine"===t.type?c>0?o.mixedAdd(i[c-1>>1]):o.mixedAdd(i[-c-1>>1].neg()):c>0?o.add(i[c-1>>1]):o.add(i[-c-1>>1].neg())}return"affine"===t.type?o.toP():o},A.prototype._wnafMulAdd=function(t,e,n,r,i){var a,o,s,u=this._wnafT1,c=this._wnafT2,f=this._wnafT3,l=0;for(a=0;a<r;a++){var p=(s=e[a])._getNAFPoints(t);u[a]=p.wnd,c[a]=p.points}for(a=r-1;a>=1;a-=2){var y=a-1,A=a;if(1===u[y]&&1===u[A]){var b=[e[y],null,null,e[A]];0===e[y].y.cmp(e[A].y)?(b[1]=e[y].add(e[A]),b[2]=e[y].toJ().mixedAdd(e[A].neg())):0===e[y].y.cmp(e[A].y.redNeg())?(b[1]=e[y].toJ().mixedAdd(e[A]),b[2]=e[y].add(e[A].neg())):(b[1]=e[y].toJ().mixedAdd(e[A]),b[2]=e[y].toJ().mixedAdd(e[A].neg()));var g=[-3,-1,-5,-7,0,7,5,1,3],m=h(n[y],n[A]);for(l=Math.max(m[0].length,l),f[y]=new Array(l),f[A]=new Array(l),o=0;o<l;o++){var v=0|m[0][o],w=0|m[1][o];f[y][o]=g[3*(v+1)+(w+1)],f[A][o]=0,c[y]=b}}else f[y]=d(n[y],u[y],this._bitLength),f[A]=d(n[A],u[A],this._bitLength),l=Math.max(f[y].length,l),l=Math.max(f[A].length,l)}var I=this.jpoint(null,null,null),E=this._wnafT4;for(a=l;a>=0;a--){for(var _=0;a>=0;){var C=!0;for(o=0;o<r;o++)E[o]=0|f[o][a],0!==E[o]&&(C=!1);if(!C)break;_++,a--}if(a>=0&&_++,I=I.dblp(_),a<0)break;for(o=0;o<r;o++){var k=E[o];0!==k&&(k>0?s=c[o][k-1>>1]:k<0&&(s=c[o][-k-1>>1].neg()),I="affine"===s.type?I.mixedAdd(s):I.add(s))}}for(a=0;a<r;a++)c[a]=null;return i?I:I.toP()},A.BasePoint=g,g.prototype.eq=function(){throw new Error("Not implemented")},g.prototype.validate=function(){return this.curve.validate(this)},A.prototype.decodePoint=function(t,e){t=p.toArray(t,e);var n=this.p.byteLength();if((4===t[0]||6===t[0]||7===t[0])&&t.length-1==2*n)return 6===t[0]?y(t[t.length-1]%2==0):7===t[0]&&y(t[t.length-1]%2==1),this.point(t.slice(1,1+n),t.slice(1+n,1+2*n));if((2===t[0]||3===t[0])&&t.length-1===n)return this.pointFromX(t.slice(1,1+n),3===t[0]);throw new Error("Unknown point format")},g.prototype.encodeCompressed=function(t){return this.encode(t,!0)},g.prototype._encode=function(t){var e=this.curve.p.byteLength(),n=this.getX().toArray("be",e);return t?[this.getY().isEven()?2:3].concat(n):[4].concat(n,this.getY().toArray("be",e))},g.prototype.encode=function(t,e){return p.encode(this._encode(e),t)},g.prototype.precompute=function(t){if(this.precomputed)return this;var e={doubles:null,naf:null,beta:null};return e.naf=this._getNAFPoints(8),e.doubles=this._getDoubles(4,t),e.beta=this._getBeta(),this.precomputed=e,this},g.prototype._hasDoubles=function(t){if(!this.precomputed)return!1;var e=this.precomputed.doubles;return!!e&&e.points.length>=Math.ceil((t.bitLength()+1)/e.step)},g.prototype._getDoubles=function(t,e){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var n=[this],r=this,i=0;i<e;i+=t){for(var a=0;a<t;a++)r=r.dbl();n.push(r)}return{step:t,points:n}},g.prototype._getNAFPoints=function(t){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var e=[this],n=(1<<t)-1,r=1===n?null:this.dbl(),i=1;i<n;i++)e[i]=e[i-1].add(r);return{wnd:t,points:e}},g.prototype._getBeta=function(){return null},g.prototype.dblp=function(t){for(var e=this,n=0;n<t;n++)e=e.dbl();return e};var m=u((function(t){"function"==typeof Object.create?t.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(t,e){if(e){t.super_=e;var n=function(){};n.prototype=e.prototype,t.prototype=new n,t.prototype.constructor=t}}})),v=p.assert;function w(t){b.call(this,"short",t),this.a=new i.a(t.a,16).toRed(this.red),this.b=new i.a(t.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(t),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}m(w,b);var I=w;function E(t,e,n,r){b.BasePoint.call(this,t,"affine"),null===e&&null===n?(this.x=null,this.y=null,this.inf=!0):(this.x=new i.a(e,16),this.y=new i.a(n,16),r&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function _(t,e,n,r){b.BasePoint.call(this,t,"jacobian"),null===e&&null===n&&null===r?(this.x=this.curve.one,this.y=this.curve.one,this.z=new i.a(0)):(this.x=new i.a(e,16),this.y=new i.a(n,16),this.z=new i.a(r,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}w.prototype._getEndomorphism=function(t){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var e,n;if(t.beta)e=new i.a(t.beta,16).toRed(this.red);else{var r=this._getEndoRoots(this.p);e=(e=r[0].cmp(r[1])<0?r[0]:r[1]).toRed(this.red)}if(t.lambda)n=new i.a(t.lambda,16);else{var a=this._getEndoRoots(this.n);0===this.g.mul(a[0]).x.cmp(this.g.x.redMul(e))?n=a[0]:(n=a[1],v(0===this.g.mul(n).x.cmp(this.g.x.redMul(e))))}return{beta:e,lambda:n,basis:t.basis?t.basis.map((function(t){return{a:new i.a(t.a,16),b:new i.a(t.b,16)}})):this._getEndoBasis(n)}}},w.prototype._getEndoRoots=function(t){var e=t===this.p?this.red:i.a.mont(t),n=new i.a(2).toRed(e).redInvm(),r=n.redNeg(),a=new i.a(3).toRed(e).redNeg().redSqrt().redMul(n);return[r.redAdd(a).fromRed(),r.redSub(a).fromRed()]},w.prototype._getEndoBasis=function(t){for(var e,n,r,a,o,s,u,c,f,l=this.n.ushrn(Math.floor(this.n.bitLength()/2)),p=t,d=this.n.clone(),h=new i.a(1),y=new i.a(0),A=new i.a(0),b=new i.a(1),g=0;0!==p.cmpn(0);){var m=d.div(p);c=d.sub(m.mul(p)),f=A.sub(m.mul(h));var v=b.sub(m.mul(y));if(!r&&c.cmp(l)<0)e=u.neg(),n=h,r=c.neg(),a=f;else if(r&&2==++g)break;u=c,d=p,p=c,A=h,h=f,b=y,y=v}o=c.neg(),s=f;var w=r.sqr().add(a.sqr());return o.sqr().add(s.sqr()).cmp(w)>=0&&(o=e,s=n),r.negative&&(r=r.neg(),a=a.neg()),o.negative&&(o=o.neg(),s=s.neg()),[{a:r,b:a},{a:o,b:s}]},w.prototype._endoSplit=function(t){var e=this.endo.basis,n=e[0],r=e[1],i=r.b.mul(t).divRound(this.n),a=n.b.neg().mul(t).divRound(this.n),o=i.mul(n.a),s=a.mul(r.a),u=i.mul(n.b),c=a.mul(r.b);return{k1:t.sub(o).sub(s),k2:u.add(c).neg()}},w.prototype.pointFromX=function(t,e){(t=new i.a(t,16)).red||(t=t.toRed(this.red));var n=t.redSqr().redMul(t).redIAdd(t.redMul(this.a)).redIAdd(this.b),r=n.redSqrt();if(0!==r.redSqr().redSub(n).cmp(this.zero))throw new Error("invalid point");var a=r.fromRed().isOdd();return(e&&!a||!e&&a)&&(r=r.redNeg()),this.point(t,r)},w.prototype.validate=function(t){if(t.inf)return!0;var e=t.x,n=t.y,r=this.a.redMul(e),i=e.redSqr().redMul(e).redIAdd(r).redIAdd(this.b);return 0===n.redSqr().redISub(i).cmpn(0)},w.prototype._endoWnafMulAdd=function(t,e,n){for(var r=this._endoWnafT1,i=this._endoWnafT2,a=0;a<t.length;a++){var o=this._endoSplit(e[a]),s=t[a],u=s._getBeta();o.k1.negative&&(o.k1.ineg(),s=s.neg(!0)),o.k2.negative&&(o.k2.ineg(),u=u.neg(!0)),r[2*a]=s,r[2*a+1]=u,i[2*a]=o.k1,i[2*a+1]=o.k2}for(var c=this._wnafMulAdd(1,r,i,2*a,n),f=0;f<2*a;f++)r[f]=null,i[f]=null;return c},m(E,b.BasePoint),w.prototype.point=function(t,e,n){return new E(this,t,e,n)},w.prototype.pointFromJSON=function(t,e){return E.fromJSON(this,t,e)},E.prototype._getBeta=function(){if(this.curve.endo){var t=this.precomputed;if(t&&t.beta)return t.beta;var e=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(t){var n=this.curve,r=function(t){return n.point(t.x.redMul(n.endo.beta),t.y)};t.beta=e,e.precomputed={beta:null,naf:t.naf&&{wnd:t.naf.wnd,points:t.naf.points.map(r)},doubles:t.doubles&&{step:t.doubles.step,points:t.doubles.points.map(r)}}}return e}},E.prototype.toJSON=function(){return this.precomputed?[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]:[this.x,this.y]},E.fromJSON=function(t,e,n){"string"==typeof e&&(e=JSON.parse(e));var r=t.point(e[0],e[1],n);if(!e[2])return r;function i(e){return t.point(e[0],e[1],n)}var a=e[2];return r.precomputed={beta:null,doubles:a.doubles&&{step:a.doubles.step,points:[r].concat(a.doubles.points.map(i))},naf:a.naf&&{wnd:a.naf.wnd,points:[r].concat(a.naf.points.map(i))}},r},E.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+">"},E.prototype.isInfinity=function(){return this.inf},E.prototype.add=function(t){if(this.inf)return t;if(t.inf)return this;if(this.eq(t))return this.dbl();if(this.neg().eq(t))return this.curve.point(null,null);if(0===this.x.cmp(t.x))return this.curve.point(null,null);var e=this.y.redSub(t.y);0!==e.cmpn(0)&&(e=e.redMul(this.x.redSub(t.x).redInvm()));var n=e.redSqr().redISub(this.x).redISub(t.x),r=e.redMul(this.x.redSub(n)).redISub(this.y);return this.curve.point(n,r)},E.prototype.dbl=function(){if(this.inf)return this;var t=this.y.redAdd(this.y);if(0===t.cmpn(0))return this.curve.point(null,null);var e=this.curve.a,n=this.x.redSqr(),r=t.redInvm(),i=n.redAdd(n).redIAdd(n).redIAdd(e).redMul(r),a=i.redSqr().redISub(this.x.redAdd(this.x)),o=i.redMul(this.x.redSub(a)).redISub(this.y);return this.curve.point(a,o)},E.prototype.getX=function(){return this.x.fromRed()},E.prototype.getY=function(){return this.y.fromRed()},E.prototype.mul=function(t){return t=new i.a(t,16),this.isInfinity()?this:this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve.endo?this.curve._endoWnafMulAdd([this],[t]):this.curve._wnafMul(this,t)},E.prototype.mulAdd=function(t,e,n){var r=[this,e],i=[t,n];return this.curve.endo?this.curve._endoWnafMulAdd(r,i):this.curve._wnafMulAdd(1,r,i,2)},E.prototype.jmulAdd=function(t,e,n){var r=[this,e],i=[t,n];return this.curve.endo?this.curve._endoWnafMulAdd(r,i,!0):this.curve._wnafMulAdd(1,r,i,2,!0)},E.prototype.eq=function(t){return this===t||this.inf===t.inf&&(this.inf||0===this.x.cmp(t.x)&&0===this.y.cmp(t.y))},E.prototype.neg=function(t){if(this.inf)return this;var e=this.curve.point(this.x,this.y.redNeg());if(t&&this.precomputed){var n=this.precomputed,r=function(t){return t.neg()};e.precomputed={naf:n.naf&&{wnd:n.naf.wnd,points:n.naf.points.map(r)},doubles:n.doubles&&{step:n.doubles.step,points:n.doubles.points.map(r)}}}return e},E.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},m(_,b.BasePoint),w.prototype.jpoint=function(t,e,n){return new _(this,t,e,n)},_.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var t=this.z.redInvm(),e=t.redSqr(),n=this.x.redMul(e),r=this.y.redMul(e).redMul(t);return this.curve.point(n,r)},_.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},_.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.z.redSqr(),n=this.z.redSqr(),r=this.x.redMul(e),i=t.x.redMul(n),a=this.y.redMul(e.redMul(t.z)),o=t.y.redMul(n.redMul(this.z)),s=r.redSub(i),u=a.redSub(o);if(0===s.cmpn(0))return 0!==u.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=s.redSqr(),f=c.redMul(s),l=r.redMul(c),p=u.redSqr().redIAdd(f).redISub(l).redISub(l),d=u.redMul(l.redISub(p)).redISub(a.redMul(f)),h=this.z.redMul(t.z).redMul(s);return this.curve.jpoint(p,d,h)},_.prototype.mixedAdd=function(t){if(this.isInfinity())return t.toJ();if(t.isInfinity())return this;var e=this.z.redSqr(),n=this.x,r=t.x.redMul(e),i=this.y,a=t.y.redMul(e).redMul(this.z),o=n.redSub(r),s=i.redSub(a);if(0===o.cmpn(0))return 0!==s.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=o.redSqr(),c=u.redMul(o),f=n.redMul(u),l=s.redSqr().redIAdd(c).redISub(f).redISub(f),p=s.redMul(f.redISub(l)).redISub(i.redMul(c)),d=this.z.redMul(o);return this.curve.jpoint(l,p,d)},_.prototype.dblp=function(t){if(0===t)return this;if(this.isInfinity())return this;if(!t)return this.dbl();var e;if(this.curve.zeroA||this.curve.threeA){var n=this;for(e=0;e<t;e++)n=n.dbl();return n}var r=this.curve.a,i=this.curve.tinv,a=this.x,o=this.y,s=this.z,u=s.redSqr().redSqr(),c=o.redAdd(o);for(e=0;e<t;e++){var f=a.redSqr(),l=c.redSqr(),p=l.redSqr(),d=f.redAdd(f).redIAdd(f).redIAdd(r.redMul(u)),h=a.redMul(l),y=d.redSqr().redISub(h.redAdd(h)),A=h.redISub(y),b=d.redMul(A);b=b.redIAdd(b).redISub(p);var g=c.redMul(s);e+1<t&&(u=u.redMul(p)),a=y,s=g,c=b}return this.curve.jpoint(a,c.redMul(i),s)},_.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},_.prototype._zeroDbl=function(){var t,e,n;if(this.zOne){var r=this.x.redSqr(),i=this.y.redSqr(),a=i.redSqr(),o=this.x.redAdd(i).redSqr().redISub(r).redISub(a);o=o.redIAdd(o);var s=r.redAdd(r).redIAdd(r),u=s.redSqr().redISub(o).redISub(o),c=a.redIAdd(a);c=(c=c.redIAdd(c)).redIAdd(c),t=u,e=s.redMul(o.redISub(u)).redISub(c),n=this.y.redAdd(this.y)}else{var f=this.x.redSqr(),l=this.y.redSqr(),p=l.redSqr(),d=this.x.redAdd(l).redSqr().redISub(f).redISub(p);d=d.redIAdd(d);var h=f.redAdd(f).redIAdd(f),y=h.redSqr(),A=p.redIAdd(p);A=(A=A.redIAdd(A)).redIAdd(A),t=y.redISub(d).redISub(d),e=h.redMul(d.redISub(t)).redISub(A),n=(n=this.y.redMul(this.z)).redIAdd(n)}return this.curve.jpoint(t,e,n)},_.prototype._threeDbl=function(){var t,e,n;if(this.zOne){var r=this.x.redSqr(),i=this.y.redSqr(),a=i.redSqr(),o=this.x.redAdd(i).redSqr().redISub(r).redISub(a);o=o.redIAdd(o);var s=r.redAdd(r).redIAdd(r).redIAdd(this.curve.a),u=s.redSqr().redISub(o).redISub(o);t=u;var c=a.redIAdd(a);c=(c=c.redIAdd(c)).redIAdd(c),e=s.redMul(o.redISub(u)).redISub(c),n=this.y.redAdd(this.y)}else{var f=this.z.redSqr(),l=this.y.redSqr(),p=this.x.redMul(l),d=this.x.redSub(f).redMul(this.x.redAdd(f));d=d.redAdd(d).redIAdd(d);var h=p.redIAdd(p),y=(h=h.redIAdd(h)).redAdd(h);t=d.redSqr().redISub(y),n=this.y.redAdd(this.z).redSqr().redISub(l).redISub(f);var A=l.redSqr();A=(A=(A=A.redIAdd(A)).redIAdd(A)).redIAdd(A),e=d.redMul(h.redISub(t)).redISub(A)}return this.curve.jpoint(t,e,n)},_.prototype._dbl=function(){var t=this.curve.a,e=this.x,n=this.y,r=this.z,i=r.redSqr().redSqr(),a=e.redSqr(),o=n.redSqr(),s=a.redAdd(a).redIAdd(a).redIAdd(t.redMul(i)),u=e.redAdd(e),c=(u=u.redIAdd(u)).redMul(o),f=s.redSqr().redISub(c.redAdd(c)),l=c.redISub(f),p=o.redSqr();p=(p=(p=p.redIAdd(p)).redIAdd(p)).redIAdd(p);var d=s.redMul(l).redISub(p),h=n.redAdd(n).redMul(r);return this.curve.jpoint(f,d,h)},_.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var t=this.x.redSqr(),e=this.y.redSqr(),n=this.z.redSqr(),r=e.redSqr(),i=t.redAdd(t).redIAdd(t),a=i.redSqr(),o=this.x.redAdd(e).redSqr().redISub(t).redISub(r),s=(o=(o=(o=o.redIAdd(o)).redAdd(o).redIAdd(o)).redISub(a)).redSqr(),u=r.redIAdd(r);u=(u=(u=u.redIAdd(u)).redIAdd(u)).redIAdd(u);var c=i.redIAdd(o).redSqr().redISub(a).redISub(s).redISub(u),f=e.redMul(c);f=(f=f.redIAdd(f)).redIAdd(f);var l=this.x.redMul(s).redISub(f);l=(l=l.redIAdd(l)).redIAdd(l);var p=this.y.redMul(c.redMul(u.redISub(c)).redISub(o.redMul(s)));p=(p=(p=p.redIAdd(p)).redIAdd(p)).redIAdd(p);var d=this.z.redAdd(o).redSqr().redISub(n).redISub(s);return this.curve.jpoint(l,p,d)},_.prototype.mul=function(t,e){return t=new i.a(t,e),this.curve._wnafMul(this,t)},_.prototype.eq=function(t){if("affine"===t.type)return this.eq(t.toJ());if(this===t)return!0;var e=this.z.redSqr(),n=t.z.redSqr();if(0!==this.x.redMul(n).redISub(t.x.redMul(e)).cmpn(0))return!1;var r=e.redMul(this.z),i=n.redMul(t.z);return 0===this.y.redMul(i).redISub(t.y.redMul(r)).cmpn(0)},_.prototype.eqXToP=function(t){var e=this.z.redSqr(),n=t.toRed(this.curve.red).redMul(e);if(0===this.x.cmp(n))return!0;for(var r=t.clone(),i=this.curve.redN.redMul(e);;){if(r.iadd(this.curve.n),r.cmp(this.curve.p)>=0)return!1;if(n.redIAdd(i),0===this.x.cmp(n))return!0}},_.prototype.inspect=function(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"},_.prototype.isInfinity=function(){return 0===this.z.cmpn(0)};var C=u((function(t,e){var n=e;n.base=b,n.short=I,n.mont=null,n.edwards=null})),k=u((function(t,e){var n,r=e,i=p.assert;function a(t){"short"===t.type?this.curve=new C.short(t):"edwards"===t.type?this.curve=new C.edwards(t):this.curve=new C.mont(t),this.g=this.curve.g,this.n=this.curve.n,this.hash=t.hash,i(this.g.validate(),"Invalid curve"),i(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function s(t,e){Object.defineProperty(r,t,{configurable:!0,enumerable:!0,get:function(){var n=new a(e);return Object.defineProperty(r,t,{configurable:!0,enumerable:!0,value:n}),n}})}r.PresetCurve=a,s("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:o.a.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),s("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:o.a.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),s("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:o.a.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),s("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:o.a.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),s("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:o.a.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),s("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.a.sha256,gRed:!1,g:["9"]}),s("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.a.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{n=null.crash()}catch(t){n=void 0}s("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:o.a.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",n]})}));function B(t){if(!(this instanceof B))return new B(t);this.hash=t.hash,this.predResist=!!t.predResist,this.outLen=this.hash.outSize,this.minEntropy=t.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=l.toArray(t.entropy,t.entropyEnc||"hex"),n=l.toArray(t.nonce,t.nonceEnc||"hex"),r=l.toArray(t.pers,t.persEnc||"hex");c(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,n,r)}var x=B;B.prototype._init=function(t,e,n){var r=t.concat(e).concat(n);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i<this.V.length;i++)this.K[i]=0,this.V[i]=1;this._update(r),this._reseed=1,this.reseedInterval=281474976710656},B.prototype._hmac=function(){return new o.a.hmac(this.hash,this.K)},B.prototype._update=function(t){var e=this._hmac().update(this.V).update([0]);t&&(e=e.update(t)),this.K=e.digest(),this.V=this._hmac().update(this.V).digest(),t&&(this.K=this._hmac().update(this.V).update([1]).update(t).digest(),this.V=this._hmac().update(this.V).digest())},B.prototype.reseed=function(t,e,n,r){"string"!=typeof e&&(r=n,n=e,e=null),t=l.toArray(t,e),n=l.toArray(n,r),c(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(t.concat(n||[])),this._reseed=1},B.prototype.generate=function(t,e,n,r){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof e&&(r=n,n=e,e=null),n&&(n=l.toArray(n,r||"hex"),this._update(n));for(var i=[];i.length<t;)this.V=this._hmac().update(this.V).digest(),i=i.concat(this.V);var a=i.slice(0,t);return this._update(n),this._reseed++,l.encode(a,e)};var S=p.assert;function Q(t,e){this.ec=t,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}var M=Q;Q.fromPublic=function(t,e,n){return e instanceof Q?e:new Q(t,{pub:e,pubEnc:n})},Q.fromPrivate=function(t,e,n){return e instanceof Q?e:new Q(t,{priv:e,privEnc:n})},Q.prototype.validate=function(){var t=this.getPublic();return t.isInfinity()?{result:!1,reason:"Invalid public key"}:t.validate()?t.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},Q.prototype.getPublic=function(t,e){return"string"==typeof t&&(e=t,t=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),e?this.pub.encode(e,t):this.pub},Q.prototype.getPrivate=function(t){return"hex"===t?this.priv.toString(16,2):this.priv},Q.prototype._importPrivate=function(t,e){this.priv=new i.a(t,e||16),this.priv=this.priv.umod(this.ec.curve.n)},Q.prototype._importPublic=function(t,e){if(t.x||t.y)return"mont"===this.ec.curve.type?S(t.x,"Need x coordinate"):"short"!==this.ec.curve.type&&"edwards"!==this.ec.curve.type||S(t.x&&t.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(t.x,t.y));this.pub=this.ec.curve.decodePoint(t,e)},Q.prototype.derive=function(t){return t.validate()||S(t.validate(),"public point not validated"),t.mul(this.priv).getX()},Q.prototype.sign=function(t,e,n){return this.ec.sign(t,this,e,n)},Q.prototype.verify=function(t,e){return this.ec.verify(t,e,this)},Q.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"};var R=p.assert;function O(t,e){if(t instanceof O)return t;this._importDER(t,e)||(R(t.r&&t.s,"Signature without r or s"),this.r=new i.a(t.r,16),this.s=new i.a(t.s,16),void 0===t.recoveryParam?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}var j=O;function T(){this.place=0}function P(t,e){var n=t[e.place++];if(!(128&n))return n;var r=15&n;if(0===r||r>4)return!1;for(var i=0,a=0,o=e.place;a<r;a++,o++)i<<=8,i|=t[o],i>>>=0;return!(i<=127)&&(e.place=o,i)}function D(t){for(var e=0,n=t.length-1;!t[e]&&!(128&t[e+1])&&e<n;)e++;return 0===e?t:t.slice(e)}function N(t,e){if(e<128)t.push(e);else{var n=1+(Math.log(e)/Math.LN2>>>3);for(t.push(128|n);--n;)t.push(e>>>(n<<3)&255);t.push(e)}}O.prototype._importDER=function(t,e){t=p.toArray(t,e);var n=new T;if(48!==t[n.place++])return!1;var r=P(t,n);if(!1===r)return!1;if(r+n.place!==t.length)return!1;if(2!==t[n.place++])return!1;var a=P(t,n);if(!1===a)return!1;var o=t.slice(n.place,a+n.place);if(n.place+=a,2!==t[n.place++])return!1;var s=P(t,n);if(!1===s)return!1;if(t.length!==s+n.place)return!1;var u=t.slice(n.place,s+n.place);if(0===o[0]){if(!(128&o[1]))return!1;o=o.slice(1)}if(0===u[0]){if(!(128&u[1]))return!1;u=u.slice(1)}return this.r=new i.a(o),this.s=new i.a(u),this.recoveryParam=null,!0},O.prototype.toDER=function(t){var e=this.r.toArray(),n=this.s.toArray();for(128&e[0]&&(e=[0].concat(e)),128&n[0]&&(n=[0].concat(n)),e=D(e),n=D(n);!(n[0]||128&n[1]);)n=n.slice(1);var r=[2];N(r,e.length),(r=r.concat(e)).push(2),N(r,n.length);var i=r.concat(n),a=[48];return N(a,i.length),a=a.concat(i),p.encode(a,t)};var L=function(){throw new Error("unsupported")},F=p.assert;function U(t){if(!(this instanceof U))return new U(t);"string"==typeof t&&(F(Object.prototype.hasOwnProperty.call(k,t),"Unknown curve "+t),t=k[t]),t instanceof k.PresetCurve&&(t={curve:t}),this.curve=t.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=t.curve.g,this.g.precompute(t.curve.n.bitLength()+1),this.hash=t.hash||t.curve.hash}var H=U;U.prototype.keyPair=function(t){return new M(this,t)},U.prototype.keyFromPrivate=function(t,e){return M.fromPrivate(this,t,e)},U.prototype.keyFromPublic=function(t,e){return M.fromPublic(this,t,e)},U.prototype.genKeyPair=function(t){t||(t={});for(var e=new x({hash:this.hash,pers:t.pers,persEnc:t.persEnc||"utf8",entropy:t.entropy||L(this.hash.hmacStrength),entropyEnc:t.entropy&&t.entropyEnc||"utf8",nonce:this.n.toArray()}),n=this.n.byteLength(),r=this.n.sub(new i.a(2));;){var a=new i.a(e.generate(n));if(!(a.cmp(r)>0))return a.iaddn(1),this.keyFromPrivate(a)}},U.prototype._truncateToN=function(t,e){var n=8*t.byteLength()-this.n.bitLength();return n>0&&(t=t.ushrn(n)),!e&&t.cmp(this.n)>=0?t.sub(this.n):t},U.prototype.sign=function(t,e,n,r){"object"===s(n)&&(r=n,n=null),r||(r={}),e=this.keyFromPrivate(e,n),t=this._truncateToN(new i.a(t,16));for(var a=this.n.byteLength(),o=e.getPrivate().toArray("be",a),u=t.toArray("be",a),c=new x({hash:this.hash,entropy:o,nonce:u,pers:r.pers,persEnc:r.persEnc||"utf8"}),f=this.n.sub(new i.a(1)),l=0;;l++){var p=r.k?r.k(l):new i.a(c.generate(this.n.byteLength()));if(!((p=this._truncateToN(p,!0)).cmpn(1)<=0||p.cmp(f)>=0)){var d=this.g.mul(p);if(!d.isInfinity()){var h=d.getX(),y=h.umod(this.n);if(0!==y.cmpn(0)){var A=p.invm(this.n).mul(y.mul(e.getPrivate()).iadd(t));if(0!==(A=A.umod(this.n)).cmpn(0)){var b=(d.getY().isOdd()?1:0)|(0!==h.cmp(y)?2:0);return r.canonical&&A.cmp(this.nh)>0&&(A=this.n.sub(A),b^=1),new j({r:y,s:A,recoveryParam:b})}}}}}},U.prototype.verify=function(t,e,n,r){t=this._truncateToN(new i.a(t,16)),n=this.keyFromPublic(n,r);var a=(e=new j(e,"hex")).r,o=e.s;if(a.cmpn(1)<0||a.cmp(this.n)>=0)return!1;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var s,u=o.invm(this.n),c=u.mul(t).umod(this.n),f=u.mul(a).umod(this.n);return this.curve._maxwellTrick?!(s=this.g.jmulAdd(c,n.getPublic(),f)).isInfinity()&&s.eqXToP(a):!(s=this.g.mulAdd(c,n.getPublic(),f)).isInfinity()&&0===s.getX().umod(this.n).cmp(a)},U.prototype.recoverPubKey=function(t,e,n,r){F((3&n)===n,"The recovery param is more than two bits"),e=new j(e,r);var a=this.n,o=new i.a(t),s=e.r,u=e.s,c=1&n,f=n>>1;if(s.cmp(this.curve.p.umod(this.curve.n))>=0&&f)throw new Error("Unable to find sencond key candinate");s=f?this.curve.pointFromX(s.add(this.curve.n),c):this.curve.pointFromX(s,c);var l=e.r.invm(a),p=a.sub(o).mul(l).umod(a),d=u.mul(l).umod(a);return this.g.mulAdd(p,s,d)},U.prototype.getKeyRecoveryParam=function(t,e,n,r){if(null!==(e=new j(e,r)).recoveryParam)return e.recoveryParam;for(var i=0;i<4;i++){var a;try{a=this.recoverPubKey(t,e,i)}catch(t){continue}if(a.eq(n))return i}throw new Error("Unable to find valid recovery factor")};var G=u((function(t,e){var n=e;n.version="6.5.4",n.utils=p,n.rand=function(){throw new Error("unsupported")},n.curve=C,n.curves=k,n.ec=H,n.eddsa=null})).ec}).call(this,n(8))},function(t,e,n){(function(t,r,i){var a;function o(t){return(o="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)}
50
50
  /**
51
51
  * [js-sha3]{@link https://github.com/emn178/js-sha3}
52
52
  *
@@ -65,4 +65,4 @@ e.read=function(t,e,n,r,i){var a,o,s=8*i-r-1,u=(1<<s)-1,c=u>>1,f=-7,l=n?i-1:0,p=
65
65
  * Copyright (c) 2023, Robert Eisele (robert@raw.org)
66
66
  * Dual licensed under the MIT or GPL Version 2 licenses.
67
67
  **/
68
- !function(n){"use strict";var r={s:1,n:0,d:1};function i(t,e){if(isNaN(t=parseInt(t,10)))throw l();return t*e}function a(t,e){if(0===e)throw f();var n=Object.create(c.prototype);n.s=t<0?-1:1;var r=u(t=t<0?-t:t,e);return n.n=t/r,n.d=e/r,n}function o(t){for(var e={},n=t,r=2,i=4;i<=n;){for(;n%r==0;)n/=r,e[r]=(e[r]||0)+1;i+=1+2*r++}return n!==t?n>1&&(e[n]=(e[n]||0)+1):e[t]=(e[t]||0)+1,e}var s=function(t,e){var n,a=0,o=1,s=1,u=0,c=0,d=0,h=1,y=1,A=0,b=1,g=1,m=1,v=1e7;if(null==t);else if(void 0!==e){if(s=(a=t)*(o=e),a%1!=0||o%1!=0)throw p()}else switch(typeof t){case"object":if("d"in t&&"n"in t)a=t.n,o=t.d,"s"in t&&(a*=t.s);else{if(!(0 in t))throw l();a=t[0],1 in t&&(o=t[1])}s=a*o;break;case"number":if(t<0&&(s=t,t=-t),t%1==0)a=t;else if(t>0){for(t>=1&&(t/=y=Math.pow(10,Math.floor(1+Math.log(t)/Math.LN10)));b<=v&&m<=v;){if(t===(n=(A+g)/(b+m))){b+m<=v?(a=A+g,o=b+m):m>b?(a=g,o=m):(a=A,o=b);break}t>n?(A+=g,b+=m):(g+=A,m+=b),b>v?(a=g,o=m):(a=A,o=b)}a*=y}else(isNaN(t)||isNaN(e))&&(o=a=NaN);break;case"string":if(null===(b=t.match(/\d+|./g)))throw l();if("-"===b[A]?(s=-1,A++):"+"===b[A]&&A++,b.length===A+1?c=i(b[A++],s):"."===b[A+1]||"."===b[A]?("."!==b[A]&&(u=i(b[A++],s)),(++A+1===b.length||"("===b[A+1]&&")"===b[A+3]||"'"===b[A+1]&&"'"===b[A+3])&&(c=i(b[A],s),h=Math.pow(10,b[A].length),A++),("("===b[A]&&")"===b[A+2]||"'"===b[A]&&"'"===b[A+2])&&(d=i(b[A+1],s),y=Math.pow(10,b[A+1].length)-1,A+=3)):"/"===b[A+1]||":"===b[A+1]?(c=i(b[A],s),h=i(b[A+2],1),A+=3):"/"===b[A+3]&&" "===b[A+1]&&(u=i(b[A],s),c=i(b[A+2],s),h=i(b[A+4],1),A+=5),b.length<=A){s=a=d+(o=h*y)*u+y*c;break}default:throw l()}if(0===o)throw f();r.s=s<0?-1:1,r.n=Math.abs(a),r.d=Math.abs(o)};function u(t,e){if(!t)return e;if(!e)return t;for(;;){if(!(t%=e))return e;if(!(e%=t))return t}}function c(t,e){if(s(t,e),!(this instanceof c))return a(r.s*r.n,r.d);t=u(r.d,r.n),this.s=r.s,this.n=r.n/t,this.d=r.d/t}var f=function(){return new Error("Division by Zero")},l=function(){return new Error("Invalid argument")},p=function(){return new Error("Parameters must be integer")};c.prototype={s:1,n:0,d:1,abs:function(){return a(this.n,this.d)},neg:function(){return a(-this.s*this.n,this.d)},add:function(t,e){return s(t,e),a(this.s*this.n*r.d+r.s*this.d*r.n,this.d*r.d)},sub:function(t,e){return s(t,e),a(this.s*this.n*r.d-r.s*this.d*r.n,this.d*r.d)},mul:function(t,e){return s(t,e),a(this.s*r.s*this.n*r.n,this.d*r.d)},div:function(t,e){return s(t,e),a(this.s*r.s*this.n*r.d,this.d*r.n)},clone:function(){return a(this.s*this.n,this.d)},mod:function(t,e){if(isNaN(this.n)||isNaN(this.d))return new c(NaN);if(void 0===t)return a(this.s*this.n%this.d,1);if(s(t,e),0===r.n&&0===this.d)throw f();return a(this.s*(r.d*this.n)%(r.n*this.d),r.d*this.d)},gcd:function(t,e){return s(t,e),a(u(r.n,this.n)*u(r.d,this.d),r.d*this.d)},lcm:function(t,e){return s(t,e),0===r.n&&0===this.n?a(0,1):a(r.n*this.n,u(r.n,this.n)*u(r.d,this.d))},ceil:function(t){return t=Math.pow(10,t||0),isNaN(this.n)||isNaN(this.d)?new c(NaN):a(Math.ceil(t*this.s*this.n/this.d),t)},floor:function(t){return t=Math.pow(10,t||0),isNaN(this.n)||isNaN(this.d)?new c(NaN):a(Math.floor(t*this.s*this.n/this.d),t)},round:function(t){return t=Math.pow(10,t||0),isNaN(this.n)||isNaN(this.d)?new c(NaN):a(Math.round(t*this.s*this.n/this.d),t)},roundTo:function(t,e){return s(t,e),a(this.s*Math.round(this.n*r.d/(this.d*r.n))*r.n,r.d)},inverse:function(){return a(this.s*this.d,this.n)},pow:function(t,e){if(s(t,e),1===r.d)return r.s<0?a(Math.pow(this.s*this.d,r.n),Math.pow(this.n,r.n)):a(Math.pow(this.s*this.n,r.n),Math.pow(this.d,r.n));if(this.s<0)return null;var n=o(this.n),i=o(this.d),u=1,c=1;for(var f in n)if("1"!==f){if("0"===f){u=0;break}if(n[f]*=r.n,n[f]%r.d!=0)return null;n[f]/=r.d,u*=Math.pow(f,n[f])}for(var f in i)if("1"!==f){if(i[f]*=r.n,i[f]%r.d!=0)return null;i[f]/=r.d,c*=Math.pow(f,i[f])}return r.s<0?a(c,u):a(u,c)},equals:function(t,e){return s(t,e),this.s*this.n*r.d==r.s*r.n*this.d},compare:function(t,e){s(t,e);var n=this.s*this.n*r.d-r.s*r.n*this.d;return(0<n)-(n<0)},simplify:function(t){if(isNaN(this.n)||isNaN(this.d))return this;t=t||.001;for(var e=this.abs(),n=e.toContinued(),r=1;r<n.length;r++){for(var i=a(n[r-1],1),o=r-2;o>=0;o--)i=i.inverse().add(n[o]);if(Math.abs(i.sub(e).valueOf())<t)return i.mul(this.s)}return this},divisible:function(t,e){return s(t,e),!(!(r.n*this.d)||this.n*r.d%(r.n*this.d))},valueOf:function(){return this.s*this.n/this.d},toFraction:function(t){var e,n="",r=this.n,i=this.d;return this.s<0&&(n+="-"),1===i?n+=r:(t&&(e=Math.floor(r/i))>0&&(n+=e,n+=" ",r%=i),n+=r,n+="/",n+=i),n},toLatex:function(t){var e,n="",r=this.n,i=this.d;return this.s<0&&(n+="-"),1===i?n+=r:(t&&(e=Math.floor(r/i))>0&&(n+=e,r%=i),n+="\\frac{",n+=r,n+="}{",n+=i,n+="}"),n},toContinued:function(){var t,e=this.n,n=this.d,r=[];if(isNaN(e)||isNaN(n))return r;do{r.push(Math.floor(e/n)),t=e%n,e=n,n=t}while(1!==e);return r},toString:function(t){var e=this.n,n=this.d;if(isNaN(e)||isNaN(n))return"NaN";t=t||15;var r=function(t,e){for(;e%2==0;e/=2);for(;e%5==0;e/=5);if(1===e)return 0;for(var n=10%e,r=1;1!==n;r++)if(n=10*n%e,r>2e3)return 0;return r}(0,n),i=function(t,e,n){for(var r=1,i=function(t,e,n){for(var r=1;e>0;t=t*t%n,e>>=1)1&e&&(r=r*t%n);return r}(10,n,e),a=0;a<300;a++){if(r===i)return a;r=10*r%e,i=10*i%e}return 0}(0,n,r),a=this.s<0?"-":"";if(a+=e/n|0,e%=n,(e*=10)&&(a+="."),r){for(var o=i;o--;)a+=e/n|0,e%=n,e*=10;a+="(";for(o=r;o--;)a+=e/n|0,e%=n,e*=10;a+=")"}else for(o=t;e&&o--;)a+=e/n|0,e%=n,e*=10;return a}},Object.defineProperty(e,"__esModule",{value:!0}),e.default=c,t.exports=c}()},function(t,e){t.exports={drm_optional:!1,store_clear:!1,ladder_specs:{'{"media_type":"audio","channels":1}':{rung_specs:[{bit_rate:128e3,media_type:"audio",pregenerate:!0}]},'{"media_type":"audio","channels":2}':{rung_specs:[{bit_rate:128e3,media_type:"audio",pregenerate:!0}]},'{"media_type":"video","aspect_ratio_height":273,"aspect_ratio_width":640}':{rung_specs:[{bit_rate:95e5,height:1080,media_type:"video",pregenerate:!0,width:2538},{bit_rate:6e6,height:720,media_type:"video",pregenerate:!1,width:1692},{bit_rate:264e4,height:540,media_type:"video",pregenerate:!1,width:1270},{bit_rate:145e4,height:432,media_type:"video",pregenerate:!1,width:1016},{bit_rate:107e4,height:360,media_type:"video",pregenerate:!1,width:846},{bit_rate:69e4,height:360,media_type:"video",pregenerate:!1,width:846}]},'{"media_type":"video","aspect_ratio_height":267,"aspect_ratio_width":640}':{rung_specs:[{bit_rate:95e5,height:1080,media_type:"video",pregenerate:!0,width:2538},{bit_rate:6e6,height:720,media_type:"video",pregenerate:!1,width:1692},{bit_rate:264e4,height:540,media_type:"video",pregenerate:!1,width:1270},{bit_rate:145e4,height:432,media_type:"video",pregenerate:!1,width:1016},{bit_rate:107e4,height:360,media_type:"video",pregenerate:!1,width:846},{bit_rate:69e4,height:360,media_type:"video",pregenerate:!1,width:846}]},'{"media_type":"video","aspect_ratio_height":729,"aspect_ratio_width":1280}':{rung_specs:[{bit_rate:95e5,height:1080,media_type:"video",pregenerate:!0,width:1920},{bit_rate:45e5,height:720,media_type:"video",pregenerate:!1,width:1280},{bit_rate:2e6,height:540,media_type:"video",pregenerate:!1,width:960},{bit_rate:11e5,height:432,media_type:"video",pregenerate:!1,width:768},{bit_rate:81e4,height:360,media_type:"video",pregenerate:!1,width:640},{bit_rate:52e4,height:360,media_type:"video",pregenerate:!1,width:640}]},'{"media_type":"video","aspect_ratio_height":1,"aspect_ratio_width":2}':{rung_specs:[{bit_rate:95e5,height:1080,media_type:"video",pregenerate:!0,width:2160},{bit_rate:5e6,height:720,media_type:"video",pregenerate:!1,width:1440},{bit_rate:225e4,height:540,media_type:"video",pregenerate:!1,width:1080},{bit_rate:12e5,height:432,media_type:"video",pregenerate:!1,width:864},{bit_rate:91e4,height:360,media_type:"video",pregenerate:!1,width:720},{bit_rate:58e4,height:360,media_type:"video",pregenerate:!1,width:720}]},'{"media_type":"video","aspect_ratio_height":67,"aspect_ratio_width":120}':{rung_specs:[{bit_rate:95e5,height:1080,media_type:"video",pregenerate:!0,width:1920},{bit_rate:45e5,height:720,media_type:"video",pregenerate:!1,width:1280},{bit_rate:2e6,height:540,media_type:"video",pregenerate:!1,width:960},{bit_rate:11e5,height:432,media_type:"video",pregenerate:!1,width:768},{bit_rate:81e4,height:360,media_type:"video",pregenerate:!1,width:640},{bit_rate:52e4,height:360,media_type:"video",pregenerate:!1,width:640}]},'{"media_type":"video","aspect_ratio_height":539,"aspect_ratio_width":960}':{rung_specs:[{bit_rate:95e5,height:1080,media_type:"video",pregenerate:!0,width:1920},{bit_rate:45e5,height:720,media_type:"video",pregenerate:!1,width:1280},{bit_rate:2e6,height:540,media_type:"video",pregenerate:!1,width:960},{bit_rate:11e5,height:432,media_type:"video",pregenerate:!1,width:768},{bit_rate:81e4,height:360,media_type:"video",pregenerate:!1,width:640},{bit_rate:52e4,height:360,media_type:"video",pregenerate:!1,width:640}]},'{"media_type":"video","aspect_ratio_height":11,"aspect_ratio_width":15}':{rung_specs:[{bit_rate:49e5,height:1080,media_type:"video",pregenerate:!0,width:1452},{bit_rate:3375e3,height:720,media_type:"video",pregenerate:!1,width:968},{bit_rate:15e5,height:540,media_type:"video",pregenerate:!1,width:726},{bit_rate:825e3,height:432,media_type:"video",pregenerate:!1,width:580},{bit_rate:61e4,height:360,media_type:"video",pregenerate:!1,width:484},{bit_rate:39e4,height:360,media_type:"video",pregenerate:!1,width:484}]},'{"media_type":"video","aspect_ratio_height":11,"aspect_ratio_width":20}':{rung_specs:[{bit_rate:95e5,height:1080,media_type:"video",pregenerate:!0,width:1920},{bit_rate:45e5,height:720,media_type:"video",pregenerate:!1,width:1280},{bit_rate:2e6,height:540,media_type:"video",pregenerate:!1,width:960},{bit_rate:11e5,height:432,media_type:"video",pregenerate:!1,width:768},{bit_rate:81e4,height:360,media_type:"video",pregenerate:!1,width:640},{bit_rate:52e4,height:360,media_type:"video",pregenerate:!1,width:640}]},'{"media_type":"video","aspect_ratio_height":12296,"aspect_ratio_width":21851}':{rung_specs:[{bit_rate:95e5,height:1080,media_type:"video",pregenerate:!0,width:1920},{bit_rate:45e5,height:720,media_type:"video",pregenerate:!1,width:1280},{bit_rate:2e6,height:540,media_type:"video",pregenerate:!1,width:960},{bit_rate:11e5,height:432,media_type:"video",pregenerate:!1,width:768},{bit_rate:81e4,height:360,media_type:"video",pregenerate:!1,width:640},{bit_rate:52e4,height:360,media_type:"video",pregenerate:!1,width:640}]},'{"media_type":"video","aspect_ratio_height":131072,"aspect_ratio_width":192165}':{rung_specs:[{bit_rate:55e5,height:1080,media_type:"video",pregenerate:!0,width:1620},{bit_rate:24e5,height:720,media_type:"video",pregenerate:!1,width:1080},{bit_rate:14e5,height:540,media_type:"video",pregenerate:!1,width:810},{bit_rate:9e5,height:432,media_type:"video",pregenerate:!1,width:648},{bit_rate:68e4,height:360,media_type:"video",pregenerate:!1,width:540},{bit_rate:44e4,height:360,media_type:"video",pregenerate:!1,width:540}]},'{"media_type":"video","aspect_ratio_height":135,"aspect_ratio_width":176}':{rung_specs:[{bit_rate:49e5,height:1080,media_type:"video",pregenerate:!0,width:1452},{bit_rate:3375e3,height:720,media_type:"video",pregenerate:!1,width:968},{bit_rate:15e5,height:540,media_type:"video",pregenerate:!1,width:726},{bit_rate:825e3,height:432,media_type:"video",pregenerate:!1,width:580},{bit_rate:61e4,height:360,media_type:"video",pregenerate:!1,width:484},{bit_rate:39e4,height:360,media_type:"video",pregenerate:!1,width:484}]},'{"media_type":"video","aspect_ratio_height":135,"aspect_ratio_width":316}':{rung_specs:[{bit_rate:95e5,height:1080,media_type:"video",pregenerate:!0,width:2528},{bit_rate:6e6,height:720,media_type:"video",pregenerate:!1,width:1692},{bit_rate:264e4,height:540,media_type:"video",pregenerate:!1,width:1270},{bit_rate:145e4,height:432,media_type:"video",pregenerate:!1,width:1016},{bit_rate:107e4,height:360,media_type:"video",pregenerate:!1,width:846},{bit_rate:69e4,height:360,media_type:"video",pregenerate:!1,width:846}]},'{"media_type":"video","aspect_ratio_height":135,"aspect_ratio_width":76}':{rung_specs:[{bit_rate:95e5,height:1920,media_type:"video",pregenerate:!0,width:1080},{bit_rate:45e5,height:1280,media_type:"video",pregenerate:!1,width:720},{bit_rate:2e6,height:960,media_type:"video",pregenerate:!1,width:540},{bit_rate:11e5,height:768,media_type:"video",pregenerate:!1,width:432},{bit_rate:81e4,height:360,media_type:"video",pregenerate:!1,width:640},{bit_rate:52e4,height:360,media_type:"video",pregenerate:!1,width:640}]},'{"media_type":"video","aspect_ratio_height":16,"aspect_ratio_width":9}':{rung_specs:[{bit_rate:95e5,height:1920,media_type:"video",pregenerate:!0,width:1080},{bit_rate:45e5,height:1280,media_type:"video",pregenerate:!1,width:720},{bit_rate:2e6,height:960,media_type:"video",pregenerate:!1,width:540},{bit_rate:11e5,height:768,media_type:"video",pregenerate:!1,width:432},{bit_rate:81e4,height:360,media_type:"video",pregenerate:!1,width:640},{bit_rate:52e4,height:360,media_type:"video",pregenerate:!1,width:640}]},'{"media_type":"video","aspect_ratio_height":17,"aspect_ratio_width":40}':{rung_specs:[{bit_rate:95e5,height:1080,media_type:"video",pregenerate:!0,width:2538},{bit_rate:6e6,height:720,media_type:"video",pregenerate:!1,width:1692},{bit_rate:264e4,height:540,media_type:"video",pregenerate:!1,width:1270},{bit_rate:145e4,height:432,media_type:"video",pregenerate:!1,width:1016},{bit_rate:107e4,height:360,media_type:"video",pregenerate:!1,width:846},{bit_rate:69e4,height:360,media_type:"video",pregenerate:!1,width:846}]},'{"media_type":"video","aspect_ratio_height":173,"aspect_ratio_width":320}':{rung_specs:[{bit_rate:95e5,height:1036,media_type:"video",pregenerate:!0,width:1920},{bit_rate:47e5,height:720,media_type:"video",pregenerate:!1,width:1334},{bit_rate:208e4,height:540,media_type:"video",pregenerate:!1,width:1e3},{bit_rate:1145e3,height:432,media_type:"video",pregenerate:!1,width:800},{bit_rate:843e3,height:360,media_type:"video",pregenerate:!1,width:666},{bit_rate:541e3,height:360,media_type:"video",pregenerate:!1,width:666}]},'{"media_type":"video","aspect_ratio_height":2,"aspect_ratio_width":3}':{rung_specs:[{bit_rate:55e5,height:1080,media_type:"video",pregenerate:!0,width:1620},{bit_rate:24e5,height:720,media_type:"video",pregenerate:!1,width:1080},{bit_rate:14e5,height:540,media_type:"video",pregenerate:!1,width:810},{bit_rate:9e5,height:432,media_type:"video",pregenerate:!1,width:648},{bit_rate:68e4,height:360,media_type:"video",pregenerate:!1,width:540},{bit_rate:44e4,height:360,media_type:"video",pregenerate:!1,width:540}]},'{"media_type":"video","aspect_ratio_height":20,"aspect_ratio_width":27}':{rung_specs:[{bit_rate:49e5,height:1080,media_type:"video",pregenerate:!0,width:1452},{bit_rate:3375e3,height:720,media_type:"video",pregenerate:!1,width:968},{bit_rate:15e5,height:540,media_type:"video",pregenerate:!1,width:726},{bit_rate:825e3,height:432,media_type:"video",pregenerate:!1,width:580},{bit_rate:61e4,height:360,media_type:"video",pregenerate:!1,width:484},{bit_rate:39e4,height:360,media_type:"video",pregenerate:!1,width:484}]},'{"media_type":"video","aspect_ratio_height":240,"aspect_ratio_width":427}':{rung_specs:[{bit_rate:95e5,height:1080,media_type:"video",pregenerate:!0,width:1920},{bit_rate:45e5,height:720,media_type:"video",pregenerate:!1,width:1280},{bit_rate:2e6,height:540,media_type:"video",pregenerate:!1,width:960},{bit_rate:11e5,height:432,media_type:"video",pregenerate:!1,width:768},{bit_rate:81e4,height:360,media_type:"video",pregenerate:!1,width:640},{bit_rate:52e4,height:360,media_type:"video",pregenerate:!1,width:640}]},'{"media_type":"video","aspect_ratio_height":243,"aspect_ratio_width":320}':{rung_specs:[{bit_rate:49e5,height:1080,media_type:"video",pregenerate:!0,width:1452},{bit_rate:3375e3,height:720,media_type:"video",pregenerate:!1,width:968},{bit_rate:15e5,height:540,media_type:"video",pregenerate:!1,width:726},{bit_rate:825e3,height:432,media_type:"video",pregenerate:!1,width:580},{bit_rate:61e4,height:360,media_type:"video",pregenerate:!1,width:484},{bit_rate:39e4,height:360,media_type:"video",pregenerate:!1,width:484}]},'{"media_type":"video","aspect_ratio_height":259,"aspect_ratio_width":480}':{rung_specs:[{bit_rate:95e5,height:1036,media_type:"video",pregenerate:!0,width:1920},{bit_rate:47e5,height:720,media_type:"video",pregenerate:!1,width:1334},{bit_rate:208e4,height:540,media_type:"video",pregenerate:!1,width:1e3},{bit_rate:1145e3,height:432,media_type:"video",pregenerate:!1,width:800},{bit_rate:843e3,height:360,media_type:"video",pregenerate:!1,width:666},{bit_rate:541e3,height:360,media_type:"video",pregenerate:!1,width:666}]},'{"media_type":"video","aspect_ratio_height":262144,"aspect_ratio_width":319905}':{rung_specs:[{bit_rate:49e5,height:1080,media_type:"video",pregenerate:!0,width:1280},{bit_rate:3375e3,height:720,media_type:"video",pregenerate:!1,width:853},{bit_rate:15e5,height:540,media_type:"video",pregenerate:!1,width:640},{bit_rate:825e3,height:432,media_type:"video",pregenerate:!1,width:512},{bit_rate:54e4,height:360,media_type:"video",pregenerate:!1,width:426},{bit_rate:35e4,height:360,media_type:"video",pregenerate:!1,width:426}]},'{"media_type":"video","aspect_ratio_height":27,"aspect_ratio_width":32}':{rung_specs:[{bit_rate:49e5,height:1080,media_type:"video",pregenerate:!0,width:1280},{bit_rate:3375e3,height:720,media_type:"video",pregenerate:!1,width:853},{bit_rate:15e5,height:540,media_type:"video",pregenerate:!1,width:640},{bit_rate:825e3,height:432,media_type:"video",pregenerate:!1,width:512},{bit_rate:54e4,height:360,media_type:"video",pregenerate:!1,width:426},{bit_rate:35e4,height:360,media_type:"video",pregenerate:!1,width:426}]},'{"media_type":"video","aspect_ratio_height":27,"aspect_ratio_width":40}':{rung_specs:[{bit_rate:55e5,height:1080,media_type:"video",pregenerate:!0,width:1620},{bit_rate:24e5,height:720,media_type:"video",pregenerate:!1,width:1080},{bit_rate:14e5,height:540,media_type:"video",pregenerate:!1,width:810},{bit_rate:9e5,height:432,media_type:"video",pregenerate:!1,width:648},{bit_rate:68e4,height:360,media_type:"video",pregenerate:!1,width:540},{bit_rate:44e4,height:360,media_type:"video",pregenerate:!1,width:540}]},'{"media_type":"video","aspect_ratio_height":297,"aspect_ratio_width":400}':{rung_specs:[{bit_rate:49e5,height:1080,media_type:"video",pregenerate:!0,width:1452},{bit_rate:3375e3,height:720,media_type:"video",pregenerate:!1,width:968},{bit_rate:15e5,height:540,media_type:"video",pregenerate:!1,width:726},{bit_rate:825e3,height:432,media_type:"video",pregenerate:!1,width:580},{bit_rate:61e4,height:360,media_type:"video",pregenerate:!1,width:484},{bit_rate:39e4,height:360,media_type:"video",pregenerate:!1,width:484}]},'{"media_type":"video","aspect_ratio_height":3,"aspect_ratio_width":4}':{rung_specs:[{bit_rate:49e5,height:1080,media_type:"video",pregenerate:!0,width:1452},{bit_rate:3375e3,height:720,media_type:"video",pregenerate:!1,width:968},{bit_rate:15e5,height:540,media_type:"video",pregenerate:!1,width:726},{bit_rate:825e3,height:432,media_type:"video",pregenerate:!1,width:580},{bit_rate:61e4,height:360,media_type:"video",pregenerate:!1,width:484},{bit_rate:39e4,height:360,media_type:"video",pregenerate:!1,width:484}]},'{"media_type":"video","aspect_ratio_height":30,"aspect_ratio_width":53}':{rung_specs:[{bit_rate:95e5,height:1080,media_type:"video",pregenerate:!0,width:1920},{bit_rate:45e5,height:720,media_type:"video",pregenerate:!1,width:1280},{bit_rate:2e6,height:540,media_type:"video",pregenerate:!1,width:960},{bit_rate:11e5,height:432,media_type:"video",pregenerate:!1,width:768},{bit_rate:81e4,height:360,media_type:"video",pregenerate:!1,width:640},{bit_rate:52e4,height:360,media_type:"video",pregenerate:!1,width:640}]},'{"media_type":"video","aspect_ratio_height":40,"aspect_ratio_width":71}':{rung_specs:[{bit_rate:95e5,height:1080,media_type:"video",pregenerate:!0,width:1920},{bit_rate:45e5,height:720,media_type:"video",pregenerate:!1,width:1280},{bit_rate:2e6,height:540,media_type:"video",pregenerate:!1,width:960},{bit_rate:11e5,height:432,media_type:"video",pregenerate:!1,width:768},{bit_rate:81e4,height:360,media_type:"video",pregenerate:!1,width:640},{bit_rate:52e4,height:360,media_type:"video",pregenerate:!1,width:640}]},'{"media_type":"video","aspect_ratio_height":429,"aspect_ratio_width":1024}':{rung_specs:[{bit_rate:95e5,height:1080,media_type:"video",pregenerate:!0,width:2538},{bit_rate:6e6,height:720,media_type:"video",pregenerate:!1,width:1692},{bit_rate:264e4,height:540,media_type:"video",pregenerate:!1,width:1270},{bit_rate:145e4,height:432,media_type:"video",pregenerate:!1,width:1016},{bit_rate:107e4,height:360,media_type:"video",pregenerate:!1,width:846},{bit_rate:69e4,height:360,media_type:"video",pregenerate:!1,width:846}]},'{"media_type":"video","aspect_ratio_height":466577,"aspect_ratio_width":912058}':{rung_specs:[{bit_rate:95e5,height:1036,media_type:"video",pregenerate:!0,width:1920},{bit_rate:47e5,height:720,media_type:"video",pregenerate:!1,width:1334},{bit_rate:208e4,height:540,media_type:"video",pregenerate:!1,width:1e3},{bit_rate:1145e3,height:432,media_type:"video",pregenerate:!1,width:800},{bit_rate:843e3,height:360,media_type:"video",pregenerate:!1,width:666},{bit_rate:541e3,height:360,media_type:"video",pregenerate:!1,width:666}]},'{"media_type":"video","aspect_ratio_height":480,"aspect_ratio_width":853}':{rung_specs:[{bit_rate:95e5,height:1080,media_type:"video",pregenerate:!0,width:1920},{bit_rate:45e5,height:720,media_type:"video",pregenerate:!1,width:1280},{bit_rate:2e6,height:540,media_type:"video",pregenerate:!1,width:960},{bit_rate:11e5,height:432,media_type:"video",pregenerate:!1,width:768},{bit_rate:81e4,height:360,media_type:"video",pregenerate:!1,width:640},{bit_rate:52e4,height:360,media_type:"video",pregenerate:!1,width:640}]},'{"media_type":"video","aspect_ratio_height":486,"aspect_ratio_width":853}':{rung_specs:[{bit_rate:95e5,height:1080,media_type:"video",pregenerate:!0,width:1920},{bit_rate:45e5,height:720,media_type:"video",pregenerate:!1,width:1280},{bit_rate:2e6,height:540,media_type:"video",pregenerate:!1,width:960},{bit_rate:11e5,height:432,media_type:"video",pregenerate:!1,width:768},{bit_rate:81e4,height:360,media_type:"video",pregenerate:!1,width:640},{bit_rate:52e4,height:360,media_type:"video",pregenerate:!1,width:640}]},'{"media_type":"video","aspect_ratio_height":5,"aspect_ratio_width":12}':{rung_specs:[{bit_rate:95e5,height:1080,media_type:"video",pregenerate:!0,width:2538},{bit_rate:6e6,height:720,media_type:"video",pregenerate:!1,width:1692},{bit_rate:264e4,height:540,media_type:"video",pregenerate:!1,width:1270},{bit_rate:145e4,height:432,media_type:"video",pregenerate:!1,width:1016},{bit_rate:107e4,height:360,media_type:"video",pregenerate:!1,width:846},{bit_rate:69e4,height:360,media_type:"video",pregenerate:!1,width:846}]},'{"media_type":"video","aspect_ratio_height":582543,"aspect_ratio_width":776720}':{rung_specs:[{bit_rate:49e5,height:1080,media_type:"video",pregenerate:!0,width:1452},{bit_rate:3375e3,height:720,media_type:"video",pregenerate:!1,width:968},{bit_rate:15e5,height:540,media_type:"video",pregenerate:!1,width:726},{bit_rate:825e3,height:432,media_type:"video",pregenerate:!1,width:580},{bit_rate:61e4,height:360,media_type:"video",pregenerate:!1,width:484},{bit_rate:39e4,height:360,media_type:"video",pregenerate:!1,width:484}]},'{"media_type":"video","aspect_ratio_height":639,"aspect_ratio_width":889}':{rung_specs:[{bit_rate:49e5,height:1080,media_type:"video",pregenerate:!0,width:1452},{bit_rate:3375e3,height:720,media_type:"video",pregenerate:!1,width:968},{bit_rate:15e5,height:540,media_type:"video",pregenerate:!1,width:726},{bit_rate:825e3,height:432,media_type:"video",pregenerate:!1,width:580},{bit_rate:61e4,height:360,media_type:"video",pregenerate:!1,width:484},{bit_rate:39e4,height:360,media_type:"video",pregenerate:!1,width:484}]},'{"media_type":"video","aspect_ratio_height":65536,"aspect_ratio_width":87381}':{rung_specs:[{bit_rate:49e5,height:1080,media_type:"video",pregenerate:!0,width:1452},{bit_rate:3375e3,height:720,media_type:"video",pregenerate:!1,width:968},{bit_rate:15e5,height:540,media_type:"video",pregenerate:!1,width:726},{bit_rate:825e3,height:432,media_type:"video",pregenerate:!1,width:580},{bit_rate:61e4,height:360,media_type:"video",pregenerate:!1,width:484},{bit_rate:39e4,height:360,media_type:"video",pregenerate:!1,width:484}]},'{"media_type":"video","aspect_ratio_height":81,"aspect_ratio_width":128}':{rung_specs:[{bit_rate:55e5,height:1080,media_type:"video",pregenerate:!0,width:1620},{bit_rate:24e5,height:720,media_type:"video",pregenerate:!1,width:1080},{bit_rate:14e5,height:540,media_type:"video",pregenerate:!1,width:810},{bit_rate:9e5,height:432,media_type:"video",pregenerate:!1,width:648},{bit_rate:68e4,height:360,media_type:"video",pregenerate:!1,width:540},{bit_rate:44e4,height:360,media_type:"video",pregenerate:!1,width:540}]},'{"media_type":"video","aspect_ratio_height":8192,"aspect_ratio_width":12015}':{rung_specs:[{bit_rate:55e5,height:1080,media_type:"video",pregenerate:!0,width:1620},{bit_rate:24e5,height:720,media_type:"video",pregenerate:!1,width:1080},{bit_rate:14e5,height:540,media_type:"video",pregenerate:!1,width:810},{bit_rate:9e5,height:432,media_type:"video",pregenerate:!1,width:648},{bit_rate:68e4,height:360,media_type:"video",pregenerate:!1,width:540},{bit_rate:44e4,height:360,media_type:"video",pregenerate:!1,width:540}]},'{"media_type":"video","aspect_ratio_height":891,"aspect_ratio_width":1600}':{rung_specs:[{bit_rate:95e5,height:1080,media_type:"video",pregenerate:!0,width:1920},{bit_rate:45e5,height:720,media_type:"video",pregenerate:!1,width:1280},{bit_rate:2e6,height:540,media_type:"video",pregenerate:!1,width:960},{bit_rate:11e5,height:432,media_type:"video",pregenerate:!1,width:768},{bit_rate:81e4,height:360,media_type:"video",pregenerate:!1,width:640},{bit_rate:52e4,height:360,media_type:"video",pregenerate:!1,width:640}]},'{"media_type":"video","aspect_ratio_height":9,"aspect_ratio_width":16}':{rung_specs:[{bit_rate:95e5,height:1080,media_type:"video",pregenerate:!0,width:1920},{bit_rate:45e5,height:720,media_type:"video",pregenerate:!1,width:1280},{bit_rate:2e6,height:540,media_type:"video",pregenerate:!1,width:960},{bit_rate:11e5,height:432,media_type:"video",pregenerate:!1,width:768},{bit_rate:81e4,height:360,media_type:"video",pregenerate:!1,width:640},{bit_rate:52e4,height:360,media_type:"video",pregenerate:!1,width:640}]}},playout_formats:{"hls-fairplay":{drm:{enc_scheme_name:"cbcs",license_servers:[],type:"DrmFairplay"},protocol:{type:"ProtoHls"}},"hls-sample-aes":{drm:{enc_scheme_name:"cbcs",type:"DrmSampleAes"},protocol:{type:"ProtoHls"}},"hls-aes128":{drm:{enc_scheme_name:"aes-128",type:"DrmAes128"},protocol:{type:"ProtoHls"}}},segment_specs:{audio:{segs_per_chunk:15,target_dur:2},video:{segs_per_chunk:15,target_dur:2}}}},function(t,e,n){(function(t){var r=n(18),i=n(17),a=n(9),o=n(10);function s(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 u(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?s(Object(n),!0).forEach((function(e){i(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):s(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}var c=n(30),f=n(35),l=n(83),p=n(31),d=p.ValidateLibrary,h=p.ValidateObject,y=p.ValidateVersion,A=p.ValidateWriteToken,b=p.ValidateParameters,g=p.ValidatePresence;e.SetVisibility=function(){var t=o(a.mark((function t(e){var n,r,i;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.id,r=e.visibility,this.Log("Setting visibility ".concat(r," on ").concat(n)),t.next=4,this.authClient.ContractHasMethod({contractAddress:this.utils.HashToAddress(n),methodName:"setVisibility"});case 4:if(t.sent){t.next=7;break}return t.abrupt("return");case 7:return t.next=9,this.CallContractMethodAndWait({contractAddress:this.utils.HashToAddress(n),methodName:"setVisibility",methodArgs:[r]});case 9:return i=t.sent,t.next=12,new Promise((function(t){return setTimeout(t,5e3)}));case 12:return t.abrupt("return",i);case 13:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.SetPermission=function(){var t=o(a.mark((function t(e){var n,r,i,s,u,c,f,l,p,d,y=this;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.objectId,r=e.permission,i=e.writeToken,h(n),g("permission",r),s=this.permissionLevels[r]){t.next=6;break}throw Error("Unknown permission level: "+r);case 6:return t.next=8,this.AccessType({id:n});case 8:if(t.t0=t.sent,t.t1=this.authClient.ACCESS_TYPES.OBJECT,t.t0===t.t1){t.next=12;break}throw Error("Permission only valid for normal content objects: "+n);case 12:return u=s.settings,t.next=15,this.ContentObjectLibraryId({objectId:n});case 15:return c=t.sent,t.next=18,this.SetVisibility({id:n,visibility:u.visibility});case 18:return t.next=20,this.CallContractMethod({contractAddress:this.utils.HashToAddress(n),methodName:"statusCode"});case 20:if(t.sent===u.statusCode){t.next=29;break}if(!(u.statusCode<0)){t.next=27;break}return t.next=25,this.CallContractMethod({contractAddress:this.utils.HashToAddress(n),methodName:"setStatusCode",methodArgs:[-1]});case 25:t.next=29;break;case 27:return t.next=29,this.CallContractMethod({contractAddress:this.utils.HashToAddress(n),methodName:"publish"});case 29:return t.next=31,this.CallContractMethod({contractAddress:this.utils.HashToAddress(n),methodName:"addressKMS"});case 31:return f=t.sent,l="eluv.caps.ikms".concat(this.utils.AddressToHash(f)),t.next=35,this.ContentObjectMetadata({libraryId:c,objectId:n,metadataSubtree:l});case 35:if(!(p=t.sent)||u.kmsConk){t.next=41;break}return t.next=39,this.EditAndFinalizeContentObject({libraryId:c,objectId:n,commitMessage:"Remove encryption conk",callback:function(){var t=o(a.mark((function t(e){var r;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.writeToken,t.next=3,y.DeleteMetadata({libraryId:c,objectId:n,writeToken:r,metadataSubtree:l});case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()});case 39:t.next=52;break;case 41:if(p||!u.kmsConk){t.next=52;break}if(d=!i,i){t.next=47;break}return t.next=46,this.EditContentObject({libraryId:c,objectId:n});case 46:i=t.sent.writeToken;case 47:return t.next=49,this.CreateEncryptionConk({libraryId:c,objectId:n,writeToken:i,createKMSConk:!0});case 49:if(!d){t.next=52;break}return t.next=52,this.FinalizeContentObject({libraryId:c,objectId:n,writeToken:i,commitMessage:"Set permissions to ".concat(r)});case 52:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.CreateContentType=function(){var t=o(a.mark((function t(e){var n,r,i,o,s,f,l,p,d,h,y,A,b;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.name,r=e.metadata,i=void 0===r?{}:r,o=e.bitcode,this.Log("Creating content type: ".concat(n)),i.name=n,i.public=u({name:n},i.public||{}),t.next=6,this.authClient.CreateContentType();case 6:return s=t.sent,f=s.contractAddress,l=this.utils.AddressToObjectId(f),t.next=11,this.SetVisibility({id:l,visibility:1});case 11:return p=c("qlibs",this.contentSpaceLibraryId,"qid",l),this.Log("Created type: ".concat(f," ").concat(l)),t.t0=this.HttpClient,t.next=16,this.authClient.AuthorizationHeader({libraryId:this.contentSpaceLibraryId,objectId:l,update:!0});case 16:return t.t1=t.sent,t.t2=p,t.t3={headers:t.t1,method:"POST",path:t.t2},t.next=21,t.t0.Request.call(t.t0,t.t3);case 21:return d=t.sent,h=new URL(d.url).origin,t.next=25,this.utils.ResponseToJson(d);case 25:return y=t.sent,this.RecordWriteToken({writeToken:y.write_token,fabricNodeUrl:h}),t.next=29,this.ReplaceMetadata({libraryId:this.contentSpaceLibraryId,objectId:l,writeToken:y.write_token,metadata:i});case 29:if(!o){t.next=35;break}return t.next=32,this.UploadPart({libraryId:this.contentSpaceLibraryId,objectId:l,writeToken:y.write_token,data:o,encrypted:!1});case 32:return A=t.sent,t.next=35,this.ReplaceMetadata({libraryId:this.contentSpaceLibraryId,objectId:l,writeToken:y.write_token,metadataSubtree:"bitcode_part",metadata:A.part.hash});case 35:return t.next=37,this.FinalizeContentObject({libraryId:this.contentSpaceLibraryId,objectId:l,writeToken:y.write_token,commitMessage:"Create content type"});case 37:return t.next=39,this.userProfileClient.TenantContractId();case 39:if(!(b=t.sent)){t.next=44;break}return t.next=43,this.SetTenantContractId({contractAddress:f,tenantContractId:b});case 43:this.Log("tenant_contract_id set for ".concat(l));case 44:return t.abrupt("return",l);case 45:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.CreateContentLibrary=function(){var t=o(a.mark((function t(e){var n,r,i,o,s,c,f,l,p,d,h,y,A;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.name,r=e.description,i=e.image,o=e.imageName,s=e.metadata,c=void 0===s?{}:s,f=e.kmsId,l=e.tenantContractId,f){t.next=9;break}return t.t0="ikms",t.t1=this.utils,t.next=6,this.DefaultKMSAddress();case 6:t.t2=t.sent,t.t3=t.t1.AddressToHash.call(t.t1,t.t2),f=t.t0.concat.call(t.t0,t.t3);case 9:return this.Log("Creating content library"),this.Log("KMS ID: ".concat(f)),t.next=13,this.authClient.CreateContentLibrary({kmsId:f});case 13:return p=t.sent,d=p.contractAddress,c=u(u({},c),{},{name:n,description:r,public:{name:n,description:r}}),h=this.utils.AddressToLibraryId(d),this.Log("Library ID: ".concat(h)),this.Log("Contract address: ".concat(d)),y=h.replace("ilib","iq__"),t.next=22,this.EditContentObject({libraryId:h,objectId:y});case 22:return A=t.sent,t.next=25,this.ReplaceMetadata({libraryId:h,objectId:y,metadata:c,writeToken:A.write_token});case 25:return t.next=27,this.FinalizeContentObject({libraryId:h,objectId:y,writeToken:A.write_token,commitMessage:"Create library"});case 27:if(!i){t.next=30;break}return t.next=30,this.SetContentLibraryImage({libraryId:h,image:i,imageName:o});case 30:if(l){t.next=34;break}return t.next=33,this.userProfileClient.TenantContractId();case 33:l=t.sent;case 34:if(!l){t.next=38;break}return t.next=37,this.SetTenantContractId({contractAddress:d,tenantContractId:l});case 37:this.Log("tenant_contract_id set for ".concat(d));case 38:return this.Log("Library ".concat(h," created")),t.abrupt("return",h);case 40:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.SetContentLibraryImage=function(){var t=o(a.mark((function t(e){var n,r,i,o,s;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.writeToken,i=e.image,o=e.imageName,d(n),s=n.replace("ilib","iq__"),t.abrupt("return",this.SetContentObjectImage({libraryId:n,objectId:s,writeToken:r,image:i,imageName:o}));case 4:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.SetContentObjectImage=function(){var t=o(a.mark((function t(e){var n,i,o,s,u,c,f;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,i=e.objectId,o=e.writeToken,s=e.image,u=e.imageName,c=e.imagePath,f=void 0===c?"public/display_image":c,b({libraryId:n,objectId:i}),A(o),g("image",s),u=u||"display_image","object"!==r(s)){t.next=9;break}return t.next=8,new Response(s).arrayBuffer();case 8:s=t.sent;case 9:return t.next=11,this.UploadFiles({libraryId:n,objectId:i,writeToken:o,encrypted:!1,fileInfo:[{path:u,mime_type:"image/*",size:s.size||s.length||s.byteLength,data:s}]});case 11:return t.next=13,this.ReplaceMetadata({libraryId:n,objectId:i,writeToken:o,metadataSubtree:f,metadata:{"/":"./files/".concat(u)}});case 13:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.DeleteContentLibrary=function(){var t=o(a.mark((function t(e){var n,r;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:throw n=e.libraryId,Error("Not supported");case 6:return r=t.sent,t.next=9,this.CallContractMethodAndWait({contractAddress:this.utils.HashToAddress(n),methodName:"kill",methodArgs:[]});case 9:return t.next=11,this.HttpClient.Request({headers:r,method:"DELETE",path:void 0});case 11:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.AddLibraryContentType=function(){var t=o(a.mark((function t(e){var n,r,i,o,s,u,c,f;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.typeId,i=e.typeName,o=e.typeHash,s=e.customContractAddress,d(n),this.Log("Adding library content type to ".concat(n,": ").concat(r||o||i)),o&&(r=this.utils.DecodeVersionHash(o).objectId),r){t.next=9;break}return t.next=7,this.ContentType({name:i});case 7:u=t.sent,r=u.id;case 9:return this.Log("Type ID: ".concat(r)),c=this.utils.HashToAddress(r),s=s||this.utils.nullAddress,t.next=14,this.ethClient.CallContractMethodAndWait({contractAddress:this.utils.HashToAddress(n),methodName:"addContentType",methodArgs:[c,s]});case 14:return f=t.sent,t.abrupt("return",f.transactionHash);case 16:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.RemoveLibraryContentType=function(){var t=o(a.mark((function t(e){var n,r,i,o,s,u,c;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.typeId,i=e.typeName,o=e.typeHash,d(n),this.Log("Removing library content type from ".concat(n,": ").concat(r||o||i)),o&&(r=this.utils.DecodeVersionHash(o).objectId),r){t.next=9;break}return t.next=7,this.ContentType({name:i});case 7:s=t.sent,r=s.id;case 9:return this.Log("Type ID: ".concat(r)),u=this.utils.HashToAddress(r),t.next=13,this.ethClient.CallContractMethodAndWait({contractAddress:this.utils.HashToAddress(n),methodName:"removeContentType",methodArgs:[u]});case 13:return c=t.sent,t.abrupt("return",c.transactionHash);case 15:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.CreateContentObject=function(){var t=o(a.mark((function t(e){var n,r,i,o,s,u,f,l,p,y,A,b,g;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,i=e.options,o=void 0===i?{}:i,d(n),r&&h(r),this.Log("Creating content object: ".concat(n," ").concat(r||"")),!o.type){t.next=26;break}if(this.Log("Type specified: ".concat(o.type)),!(u=o.type).startsWith("hq__")){t.next=13;break}return t.next=10,this.ContentType({versionHash:u});case 10:u=t.sent,t.next=22;break;case 13:if(!u.startsWith("iq__")){t.next=19;break}return t.next=16,this.ContentType({typeId:u});case 16:u=t.sent,t.next=22;break;case 19:return t.next=21,this.ContentType({name:u});case 21:u=t.sent;case 22:if(u){t.next=24;break}throw Error("Unable to find content type '".concat(o.type,"'"));case 24:s=u.id,o.type=u.hash;case 26:if(r){t.next=44;break}return t.next=29,this.CurrentAccountAddress();case 29:return f=t.sent,t.next=32,this.CallContractMethod({contractAddress:this.utils.HashToAddress(n),methodName:"canContribute",methodArgs:[f]});case 32:if(t.sent){t.next=35;break}throw Error("Current user does not have permission to create content in library ".concat(n));case 35:return this.Log("Deploying contract..."),t.next=38,this.authClient.CreateContentObject({libraryId:n,typeId:s});case 38:l=t.sent,p=l.contractAddress,r=this.utils.AddressToObjectId(p),this.Log("Contract deployed: ".concat(p," ").concat(r)),t.next=51;break;case 44:return t.t0=this,t.t1="Contract already deployed for contract type: ",t.next=48,this.AccessType({id:r});case 48:t.t2=t.sent,t.t3=t.t1.concat.call(t.t1,t.t2),t.t0.Log.call(t.t0,t.t3);case 51:if(!o.visibility){t.next=55;break}return this.Log("Setting visibility to ".concat(o.visibility)),t.next=55,this.SetVisibility({id:r,visibility:o.visibility});case 55:return y=c("qid",r),t.t4=this.HttpClient,t.next=59,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,update:!0});case 59:return t.t5=t.sent,t.t6=y,t.t7=o,t.t8={headers:t.t5,method:"POST",path:t.t6,body:t.t7},t.next=65,t.t4.Request.call(t.t4,t.t8);case 65:return A=t.sent,b=new URL(A.url).origin,t.next=69,this.utils.ResponseToJson(A);case 69:return g=t.sent,this.RecordWriteToken({writeToken:g.write_token,fabricNodeUrl:b}),g.writeToken=g.write_token,g.objectId=g.id,g.nodeUrl=b,t.abrupt("return",g);case 75:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.CopyContentObject=function(){var t=o(a.mark((function t(e){var n,r,i,s,u,c,f,l,p,h,A,b,g=this;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.originalVersionHash,i=e.options,s=void 0===i?{}:i,d(n),y(r),s.copy_from=r,t.next=6,this.CreateContentObject({libraryId:n,options:s});case 6:return u=t.sent,c=u.objectId,f=u.writeToken,l=this.utils.DecodeVersionHash(r).objectId,t.next=12,this.ContentObjectMetadata({versionHash:r});case 12:return p=t.sent,t.next=15,this.Permission({objectId:l});case 15:if(h=t.sent,A="eluv.caps.iusr".concat(this.utils.AddressToHash(this.signer.address)),!p[A]){t.next=33;break}return t.next=20,this.Crypto.DecryptCap(p[A],this.signer._signingKey().privateKey);case 20:return(b=t.sent).qid=c,t.t0=this,t.t1=n,t.t2=c,t.t3=f,t.t4=A,t.next=29,this.Crypto.EncryptConk(b,this.signer._signingKey().publicKey);case 29:return t.t5=t.sent,t.t6={libraryId:t.t1,objectId:t.t2,writeToken:t.t3,metadataSubtree:t.t4,metadata:t.t5},t.next=33,t.t0.ReplaceMetadata.call(t.t0,t.t6);case 33:return t.next=35,Promise.all(Object.keys(p).filter((function(t){return t.startsWith("eluv.caps.ikms")})).map(function(){var t=o(a.mark((function t(e){return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,g.DeleteMetadata({libraryId:n,objectId:c,writeToken:f,metadataSubtree:e});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()));case 35:if("owner"===h){t.next=38;break}return t.next=38,this.CreateEncryptionConk({libraryId:n,objectId:c,writeToken:f,createKMSConk:!0});case 38:return t.next=40,this.FinalizeContentObject({libraryId:n,objectId:c,writeToken:f});case 40:return t.abrupt("return",t.sent);case 41:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.CreateNonOwnerCap=function(){var t=o(a.mark((function t(e){var n,r,i,o,s,u,c,f,l,p,d;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.objectId,r=e.libraryId,i=e.publicKey,o=e.writeToken,s="eluv.caps.iusr".concat(this.utils.AddressToHash(this.signer.address)),t.next=4,this.ContentObjectMetadata({objectId:n,libraryId:r,metadataSubtree:s});case 4:if(u=t.sent){t.next=7;break}throw Error("No user cap found for current user");case 7:return t.next=9,this.Crypto.DecryptCap(u,this.signer._signingKey().privateKey);case 9:return c=t.sent,f=this.utils.PublicKeyToAddress(i),l="eluv.caps.iusr".concat(this.utils.AddressToHash(f)),t.next=14,this.Crypto.EncryptConk(c,i);case 14:if(p=t.sent,d=!o,o){t.next=20;break}return t.next=19,this.EditContentObject({libraryId:r,objectId:n}).writeToken;case 19:o=t.sent;case 20:if(this.ReplaceMetadata({libraryId:r,objectId:n,writeToken:o,metadataSubtree:l,metadata:p}),!d){t.next=24;break}return t.next=24,this.FinalizeContentObject({libraryId:r,objectId:n,writeToken:o,commitMessage:"Create non-owner cap"});case 24:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.EditContentObject=function(){var t=o(a.mark((function t(e){var n,r,i,o,s,u,f,l;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,i=e.options,o=void 0===i?{}:i,b({libraryId:n,objectId:r}),this.Log("Opening content draft: ".concat(n," ").concat(r)),!("type"in o)||!o.type){t.next=23;break}if(!o.type.startsWith("hq__")){t.next=10;break}return t.next=7,this.ContentType({versionHash:o.type});case 7:o.type=t.sent.hash,t.next=23;break;case 10:if(!o.type.startsWith("iq__")){t.next=16;break}return t.next=13,this.ContentType({typeId:o.type});case 13:o.type=t.sent.hash,t.next=23;break;case 16:if(!o.type){t.next=22;break}return t.next=19,this.ContentType({name:o.type});case 19:o.type=t.sent.hash,t.next=23;break;case 22:o.type="";case 23:return s=c("qid",r),t.t0=this.HttpClient,t.next=27,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,update:!0});case 27:return t.t1=t.sent,t.t2=s,t.t3=o,t.t4={headers:t.t1,method:"POST",path:t.t2,body:t.t3},t.next=33,t.t0.Request.call(t.t0,t.t4);case 33:return u=t.sent,f=new URL(u.url).origin,t.next=37,this.utils.ResponseToJson(u);case 37:return l=t.sent,this.RecordWriteToken({writeToken:l.write_token,fabricNodeUrl:f}),l.writeToken=l.write_token,l.objectId=l.id,l.nodeUrl=f,t.abrupt("return",l);case 43:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.CreateAndFinalizeContentObject=function(){var t=o(a.mark((function t(e){var n,r,i,o,s,u,c,f,l,p,d,h,y;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.callback,i=e.options,o=void 0===i?{}:i,s=e.commitMessage,u=void 0===s?"":s,c=e.publish,f=void 0===c||c,l=e.awaitCommitConfirmation,p=void 0===l||l,t.next=3,this.CreateContentObject({libraryId:n,options:o});case 3:if(d=t.sent,h=d.id,y=d.writeToken,!r){t.next=8;break}return t.next=8,r({objectId:h,writeToken:y});case 8:return t.next=10,this.FinalizeContentObject({libraryId:n,objectId:h,writeToken:y,commitMessage:u,publish:f,awaitCommitConfirmation:p});case 10:return t.abrupt("return",t.sent);case 11:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.EditAndFinalizeContentObject=function(){var t=o(a.mark((function t(e){var n,r,i,o,s,u,c,f,l,p,d,h,y;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.callback,o=e.options,s=void 0===o?{}:o,u=e.commitMessage,c=void 0===u?"":u,f=e.publish,l=void 0===f||f,p=e.awaitCommitConfirmation,d=void 0===p||p,t.next=3,this.EditContentObject({libraryId:n,objectId:r,options:s});case 3:if(h=t.sent,y=h.writeToken,!i){t.next=8;break}return t.next=8,i({writeToken:y});case 8:return t.next=10,this.FinalizeContentObject({libraryId:n,objectId:r,writeToken:y,commitMessage:c,publish:l,awaitCommitConfirmation:d});case 10:return t.abrupt("return",t.sent);case 11:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.AwaitPending=function(){var t=o(a.mark((function t(e){var n,r,i,s,u=this;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=function(){var t=o(a.mark((function t(){return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,u.CallContractMethod({contractAddress:u.utils.HashToAddress(e),methodName:"pendingHash"});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),this.Log("Checking for pending commit"),t.next=4,n();case 4:if(t.sent){t.next=7;break}return t.abrupt("return");case 7:return t.next=9,this.authClient.AccessType(e);case 9:t.t0=t.sent,t.t1=this.authClient.ACCESS_TYPES.WALLET,r=t.t0===t.t1,i=r?3:10,this.Log("Waiting for pending commit to clear for ".concat(e)),s=0;case 15:if(!(s<i)){t.next=25;break}return t.next=18,new Promise((function(t){return setTimeout(t,1e3)}));case 18:return t.next=20,n();case 20:if(t.sent){t.next=22;break}return t.abrupt("return");case 22:s++,t.next=15;break;case 25:if(!r){t.next=31;break}return this.Log("Clearing stuck wallet commit",!0),t.next=29,this.CallContractMethodAndWait({contractAddress:this.utils.HashToAddress(e),methodName:"clearPending"});case 29:t.next=32;break;case 31:throw Error("Unable to finalize ".concat(e," - Another commit is pending"));case 32:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.FinalizeContentObject=function(){var t=o(a.mark((function t(e){var n,r,i,o,s,u,f,l,p,d,h;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.writeToken,o=e.commitMessage,s=void 0===o?"":o,u=e.publish,f=void 0===u||u,l=e.awaitCommitConfirmation,p=void 0===l||l,b({libraryId:n,objectId:r}),A(i),t.t0=this,t.t1=n,t.t2=r,t.t3=i,t.t4=s,t.next=10,this.userProfileClient.UserMetadata({metadataSubtree:"public/name"});case 10:if(t.t5=t.sent,t.t5){t.next=13;break}t.t5=this.CurrentAccountAddress();case 13:return t.t6=t.t5,t.t7=this.CurrentAccountAddress(),t.t8=(new Date).toISOString(),t.t9={message:t.t4,author:t.t6,author_address:t.t7,timestamp:t.t8},t.t10={libraryId:t.t1,objectId:t.t2,writeToken:t.t3,metadataSubtree:"commit",metadata:t.t9},t.next=20,t.t0.ReplaceMetadata.call(t.t0,t.t10);case 20:return this.Log("Finalizing content draft: ".concat(n," ").concat(r," ").concat(i)),t.next=23,this.AwaitPending(r);case 23:return d=c("q",i),t.t11=this.utils,t.t12=this.HttpClient,t.next=28,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,update:!0});case 28:return t.t13=t.sent,t.t14=d,t.t15={headers:t.t13,method:"POST",path:t.t14,allowFailover:!1},t.t16=t.t12.Request.call(t.t12,t.t15),t.next=34,t.t11.ResponseToJson.call(t.t11,t.t16);case 34:if(h=t.sent,this.Log("Finalized: ".concat(h.hash)),!f){t.next=39;break}return t.next=39,this.PublishContentVersion({objectId:r,versionHash:h.hash,awaitCommitConfirmation:p});case 39:return delete this.contentTypes[r],t.abrupt("return",h);case 41:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.PublishContentVersion=function(){var t=o(a.mark((function t(e){var n,r,i,o,s,u,c,f,l,p,d;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.objectId,r=e.versionHash,i=e.awaitCommitConfirmation,o=void 0===i||i,r?y(r):h(n),this.Log("Publishing: ".concat(n||r)),r&&(n=this.utils.DecodeVersionHash(r).objectId),t.next=6,this.ethClient.CommitContent({contentObjectAddress:this.utils.HashToAddress(n),versionHash:r,signer:this.signer});case 6:return s=t.sent,t.next=9,this.ContractAbi({id:n});case 9:return u=t.sent,c=s.blockNumber+1,t.next=13,this.ExtractValueFromEvent({abi:u,event:s,eventName:"CommitPending",eventValue:"objectHash"});case 13:return f=t.sent,t.next=16,this.CallContractMethod({contractAddress:this.utils.HashToAddress(n),methodName:"pendingHash"});case 16:if(!(l=t.sent)||l===f){t.next=19;break}throw Error("Pending version hash mismatch on ".concat(n,": expected ").concat(f,", currently ").concat(l));case 19:if(!o){t.next=34;break}this.Log("Awaiting commit confirmation for ".concat(f)),p=this.ethClient.Provider().pollingInterval||500;case 22:return t.next=25,new Promise((function(t){return setTimeout(t,p)}));case 25:return t.next=27,this.ContractEvents({contractAddress:this.utils.HashToAddress(n),abi:u,fromBlock:c,count:1e3});case 27:if(d=t.sent,!d.find((function(t){return t.find((function(t){return f===(t&&t.args&&t.args.objectHash)}))}))){t.next=32;break}return this.Log("Commit confirmed: ".concat(f)),t.abrupt("break",34);case 32:t.next=22;break;case 34:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.DeleteContentVersion=function(){var t=o(a.mark((function t(e){var n,r,i;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.versionHash,y(n),this.Log("Deleting content version: ".concat(n)),r=this.utils.DecodeVersionHash(n),i=r.objectId,t.next=6,this.CallContractMethodAndWait({contractAddress:this.utils.HashToAddress(i),methodName:"deleteVersion",methodArgs:[n]});case 6:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.DeleteContentObject=function(){var t=o(a.mark((function t(e){var n,r;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,b({libraryId:n,objectId:r}),this.Log("Deleting content version: ".concat(n," ").concat(r)),t.next=5,this.CallContractMethodAndWait({contractAddress:this.utils.HashToAddress(n),methodName:"deleteContent",methodArgs:[this.utils.HashToAddress(r)]});case 5:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.MergeMetadata=function(){var t=o(a.mark((function t(e){var n,r,i,o,s,u,f,l;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.writeToken,o=e.metadataSubtree,s=void 0===o?"/":o,u=e.metadata,f=void 0===u?{}:u,b({libraryId:n,objectId:r}),A(i),this.Log("Merging metadata: ".concat(n," ").concat(r," ").concat(i,"\n Subtree: ").concat(s)),this.Log(f),l=c("q",i,"meta",s),t.t0=this.HttpClient,t.next=9,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,update:!0});case 9:return t.t1=t.sent,t.t2=l,t.t3=f,t.t4={headers:t.t1,method:"POST",path:t.t2,body:t.t3,allowFailover:!1},t.next=15,t.t0.Request.call(t.t0,t.t4);case 15:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.ReplaceMetadata=function(){var t=o(a.mark((function t(e){var n,r,i,o,s,u,f,l;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.writeToken,o=e.metadataSubtree,s=void 0===o?"/":o,u=e.metadata,f=void 0===u?{}:u,b({libraryId:n,objectId:r}),A(i),this.Log("Replacing metadata: ".concat(n," ").concat(r," ").concat(i,"\n Subtree: ").concat(s)),this.Log(f),l=c("q",i,"meta",s),t.t0=this.HttpClient,t.next=9,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,update:!0});case 9:return t.t1=t.sent,t.t2=l,t.t3=f,t.t4={headers:t.t1,method:"PUT",path:t.t2,body:t.t3,allowFailover:!1},t.next=15,t.t0.Request.call(t.t0,t.t4);case 15:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.DeleteMetadata=function(){var t=o(a.mark((function t(e){var n,r,i,o,s,u;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.writeToken,o=e.metadataSubtree,s=void 0===o?"/":o,b({libraryId:n,objectId:r}),A(i),this.Log("Deleting metadata: ".concat(n," ").concat(r," ").concat(i,"\n Subtree: ").concat(s)),this.Log("Subtree: ".concat(s)),u=c("q",i,"meta",s),t.t0=this.HttpClient,t.next=9,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,update:!0});case 9:return t.t1=t.sent,t.t2=u,t.t3={headers:t.t1,method:"DELETE",path:t.t2,allowFailover:!1},t.next=14,t.t0.Request.call(t.t0,t.t3);case 14:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.SetAccessCharge=function(){var t=o(a.mark((function t(e){var n,r;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.objectId,r=e.accessCharge,h(n),this.Log("Setting access charge: ".concat(n," ").concat(r)),t.next=5,this.ethClient.CallContractMethodAndWait({contractAddress:this.utils.HashToAddress(n),methodName:"setAccessCharge",methodArgs:[this.utils.EtherToWei(r).toString()]});case 5:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.UpdateContentObjectGraph=function(){var t=o(a.mark((function t(e){var n,r,i,s,u,c,f,l,p=this;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=e.libraryId,r=e.objectId,i=e.versionHash,s=e.callback,b({libraryId:n,objectId:r,versionHash:i}),this.Log("Updating content object graph: ".concat(n||""," ").concat(r||i)),i&&(r=this.utils.DecodeVersionHash(i).objectId),c=0,f=a.mark((function t(){var e,f,l,d,h,y,A,b,g,m,v;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,p.ContentObjectGraph({libraryId:n,objectId:r,versionHash:i,autoUpdate:!0,select:["name","public/name","public/asset_metadata/display_title"]});case 2:if(e=t.sent,0!==Object.keys(e.auto_updates).length){t.next=6;break}return p.Log("No more updates required"),t.abrupt("return",{v:void 0});case 6:return u||(u=e.auto_updates.order.length),f=e.auto_updates.order[0],l=e.auto_updates.links[f],d=e.details[f].meta||{},h=d.public&&d.public.asset_metadata&&d.public.asset_metadata.display_title||d.public&&d.public.name||d.name||i||r,t.next=13,p.ContentObjectLibraryId({versionHash:f});case 13:return y=t.sent,A=p.utils.DecodeVersionHash(f).objectId,s&&s({completed:c,total:u,action:"Updating ".concat(h," (").concat(A,")...")}),p.Log("Updating links for ".concat(h," (").concat(A," / ").concat(f,")")),t.next=19,p.EditContentObject({libraryId:y,objectId:A});case 19:return b=t.sent,g=b.write_token,t.next=23,Promise.all(l.map(function(){var t=o(a.mark((function t(e){var n,r;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.path,r=e.updated,t.next=3,p.ReplaceMetadata({libraryId:y,objectId:A,writeToken:g,metadataSubtree:n,metadata:r});case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()));case 23:return t.next=25,p.FinalizeContentObject({libraryId:y,objectId:A,writeToken:g,commitMessage:"Update links"});case 25:m=t.sent,v=m.hash,f===i&&(i=v),c+=1;case 29:case"end":return t.stop()}}),t)}));case 6:return t.delegateYield(f(),"t0",8);case 8:if(!(l=t.t0)){t.next=11;break}return t.abrupt("return",l.v);case 11:t.next=6;break;case 13:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.GenerateSignedLinkToken=function(){var e=o(a.mark((function e(n){var r,i,o,s,u,c,p,d,y,A,b;return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=n.containerId,i=n.versionHash,o=n.link,s=n.duration,h(r),e.next=4,this.CallContractMethod({contractAddress:this.utils.HashToAddress(r),methodName:"canEdit"});case 4:if(u=e.sent,c=this.utils.DecodeVersionHash(i),p=c.objectId,u){e.next=8;break}throw Error("Current user does not have permission to edit content object ".concat(p));case 8:return d=this.CurrentAccountAddress(),e.t0=this.utils.B64(d.replace("0x",""),"hex"),e.next=12,this.ContentSpaceId();case 12:return e.t1=e.sent,e.next=15,this.ContentObjectLibraryId({objectId:p});case 15:return e.t2=e.sent,e.t3=p,e.t4="iusr".concat(this.utils.AddressToHash(d)),e.t5=Date.now(),e.t6=s?Date.now()+s:void 0,e.t7={elv:{lnk:o,src:r}},y={adr:e.t0,spc:e.t1,lib:e.t2,qid:e.t3,sub:e.t4,gra:"read",iat:e.t5,exp:e.t6,ctx:e.t7},A=l.deflateRaw(t.from(JSON.stringify(y),"utf-8")),e.next=25,this.authClient.Sign(f.utils.keccak256(A));case 25:return b=e.sent,e.abrupt("return","aslsjc".concat(this.utils.B58(t.concat([t.from(b.replace(/^0x/,""),"hex"),t.from(A)]))));case 27:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),e.CreateLinks=function(){var t=o(a.mark((function t(e){var n,r,i,s,u,c=this;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.writeToken,s=e.links,u=void 0===s?[]:s,b({libraryId:n,objectId:r}),A(i),t.next=5,this.utils.LimitedMap(10,u,function(){var t=o(a.mark((function t(e){var o,s,u,f,l,p;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(o=e.path.replace(/^(\/|\.)+/,""),"metadata"===(s="file"===(e.type||"file")?"files":e.type)&&(s="meta"),u=f=e.target.replace(/^(\/|\.)+/,""),u=e.targetHash?"/qfab/".concat(e.targetHash,"/").concat(s,"/").concat(u):"./".concat(s,"/").concat(u),l={"/":u},e.autoUpdate&&(l["."]={auto_update:{tag:"latest"}}),!e.authContainer){t.next=17;break}return t.next=10,c.ContentObjectMetadata({libraryId:n,objectId:r,metadataSubtree:o});case 10:if((p=t.sent)&&(l=p),l["."]||(l["."]={}),p["."].authorization){t.next=17;break}return t.next=16,c.GenerateSignedLinkToken({containerId:e.authContainer,versionHash:e.targetHash,link:"./".concat(s,"/").concat(f)});case 16:l["."].authorization=t.sent;case 17:return t.next=19,c.ReplaceMetadata({libraryId:n,objectId:r,writeToken:i,metadataSubtree:o,metadata:l});case 19:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}());case 5:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.InitializeAuthPolicy=function(){var t=o(a.mark((function t(e){var n,r,i,o,s,u,l,p,d,h,y;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.writeToken,o=e.target,s=void 0===o?"auth_policy_spec":o,u=e.body,l=e.version,p=e.description,d=e.id,h={type:"epl-ast",version:l,body:u,data:{"/":c(".","meta",s)},signer:"iusr".concat(this.utils.AddressToHash(this.signer.address)),description:p||"",id:d||""},y="".concat(h.type,"|").concat(h.version,"|").concat(h.body,"|").concat(h.data["/"]),t.t0=this.utils,t.next=6,this.authClient.Sign(f.utils.keccak256(f.utils.toUtf8Bytes(y)));case 6:return t.t1=t.sent,h.signature=t.t0.FormatSignature.call(t.t0,t.t1),t.next=10,this.ReplaceMetadata({libraryId:n,objectId:r,writeToken:i,metadataSubtree:"auth_policy",metadata:h});case 10:return t.next=12,this.SetAuthPolicy({objectId:r,policyId:r});case 12:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.SetAuthPolicy=function(){var t=o(a.mark((function t(e){var n,r;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.objectId,r=e.policyId,t.next=3,this.MergeContractMetadata({contractAddress:this.utils.HashToAddress(n),metadataKey:"_AUTH_CONTEXT",metadata:{"elv:delegation-id":r}});case 3:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.DeleteWriteToken=function(){var t=o(a.mark((function t(e){var n,r,i,o;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.writeToken,r=e.libraryId,A(n),d(r),i=c("qlibs",r,"q",n),t.next=6,this.authClient.AuthorizationHeader({libraryId:r,update:!0});case 6:return o=t.sent,t.next=9,this.HttpClient.Request({headers:o,method:"DELETE",path:i,allowFailover:!1});case 9:return t.next=11,this.HttpClient.ClearWriteToken({writeToken:n});case 11:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}()}).call(this,n(4).Buffer)},function(t,e,n){var r=n(9),i=n(10),a=n(30),o=n(35),s=n(31),u=s.ValidateAddress,c=s.ValidateDate,f=s.ValidateObject,l=s.ValidatePresence,p=function(t){var e=t.pm||{},n={ntpId:t.id,ntpClass:"Class ".concat(t.de),tenantId:t.ti,kmsId:t.ki,objectId:e.qid,updatedAt:parseInt(t.ts),startTime:parseInt(e.vat),endTime:parseInt(e.exp),ticketLength:e.sen,maxRedemptions:e.ntp,maxTickets:t.mx};return void 0!==t.cnt&&(n.issuedTickets=t.cnt),n};e.CreateNTPInstance=function(){var t=i(r.mark((function t(e){var n,i,a,o,s,p,d,h,y,A,b,g,m,v,w,I=this;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.tenantId,i=e.objectId,a=e.groupAddresses,o=e.ntpClass,s=void 0===o?4:o,p=e.maxTickets,d=void 0===p?0:p,h=e.maxRedemptions,y=void 0===h?100:h,A=e.startTime,b=e.endTime,g=e.ticketLength,m=void 0===g?6:g,l("tenantId",n),l("objectId or groupAddresses",i||a),i&&f(i),a&&a.forEach((function(t){return u(t)})),A=c(A),b=c(b),v=["ntp:".concat(parseInt(y)),"sen:".concat(parseInt(m))],i?v.push("qid:".concat(i)):a&&(w=a.map((function(t){return"igrp".concat(I.utils.AddressToHash(t))})),v.push("gid:".concat(w.join(",")))),A&&v.push("vat:".concat(A)),b&&v.push("exp:".concat(b)),t.next=13,this.authClient.MakeKMSCall({tenantId:n,methodName:"elv_createOTPInstance",params:[n,s,JSON.stringify(v),parseInt(d),Date.now()],paramTypes:["string","int","string","int","int"]});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.UpdateNTPInstance=function(){var t=i(r.mark((function t(e){var n,i,a,o,s,u,f,d,h,y,A;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.tenantId,i=e.ntpId,a=e.maxTickets,o=void 0===a?0:a,s=e.maxRedemptions,u=void 0===s?100:s,f=e.startTime,d=e.endTime,l("tenantId",n),l("ntpId",i),f=c(f),d=c(d),h=[],u&&h.push("ntp:".concat(parseInt(u))),f&&h.push("vat:".concat(f)),d&&h.push("exp:".concat(d)),o&&h.push("max:".concat(parseInt(o))),t.next=12,this.authClient.MakeKMSCall({tenantId:n,methodName:"elv_updateOTPInstance",params:[n,i,"update",JSON.stringify(h),Date.now()],paramTypes:["string","string","string","string","int"]});case 12:return y=t.sent,A=y.Ret,t.abrupt("return",p(JSON.parse(A)));case 15:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.SuspendNTPInstance=function(){var t=i(r.mark((function t(e){var n,i;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.tenantId,i=e.ntpId,l("tenantId",n),l("ntpId",i),t.next=5,this.authClient.MakeKMSCall({tenantId:n,methodName:"elv_updateOTPInstance",params:[n,i,"cancel","[]",Date.now()],paramTypes:["string","string","string","string","int"]});case 5:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.DeleteNTPInstance=function(){var t=i(r.mark((function t(e){var n,i;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.tenantId,i=e.ntpId,l("tenantId",n),l("ntpId",i),t.next=5,this.authClient.MakeKMSCall({tenantId:n,methodName:"elv_updateOTPInstance",params:[n,i,"delete","[]",Date.now()],paramTypes:["string","string","string","string","int"]});case 5:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.ListNTPInstances=function(){var t=i(r.mark((function t(e){var n,i,a,o,s,u,c,f;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.tenantId,i=e.count,a=void 0===i?10:i,o=e.offset,s=void 0===o?0:o,l("tenantId",n),t.next=4,this.authClient.MakeKMSCall({tenantId:n,methodName:"elv_listOTPInfo",params:[n,s,a],paramTypes:["string","int","int"],signature:!1});case 4:return u=t.sent,c=u.Defs,f=u.Total,t.abrupt("return",{ntpInstances:Object.values(c||{}).map(p),start:s,end:Math.min(f,s+a),total:f});case 8:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.NTPInstance=function(){var t=i(r.mark((function t(e){var n,i;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.tenantId,i=e.ntpId,l("tenantId",n),l("ntpId",i),t.t0=p,t.next=6,this.authClient.MakeKMSCall({tenantId:n,methodName:"elv_getOTPInfo",params:[n,i],paramTypes:["string","string"],signature:!1});case 6:return t.t1=t.sent,t.abrupt("return",(0,t.t0)(t.t1));case 8:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.IssueNTPCode=function(){var t=i(r.mark((function t(e){var n,i,a,o,s,u,c;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.tenantId,i=e.ntpId,a=e.email,o=e.maxRedemptions,l("tenantId",n),l("ntpId",i),s=[],a&&s.push("eml:".concat(a)),o&&s.push("cnt:".concat(parseInt(o))),u=[n,i,JSON.stringify(s),Date.now()],c=["string","string","string","uint"],t.next=10,this.authClient.MakeKMSCall({methodName:"elv_issueOTPCode",params:u,paramTypes:c});case 10:return t.abrupt("return",t.sent);case 11:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.IssueSignedNTPCode=function(){var t=i(r.mark((function t(e){var n,i,a,s,u,c,f;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.tenantId,i=e.ntpId,a=e.email,s=e.maxRedemptions,t.next=3,this.IssueNTPCode({tenantId:n,ntpId:i,email:a,maxRedemptions:s});case 3:if(!(u=t.sent).token){t.next=10;break}return t.next=7,this.authClient.Sign(o.utils.keccak256(o.utils.toUtf8Bytes(u.token)));case 7:c=t.sent,f=this.utils.FormatSignature(c),u.token="".concat(u.token,".").concat(this.utils.B64(f));case 10:return t.abrupt("return",u);case 11:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.RedeemCode=function(){var t=i(r.mark((function t(e){var n,i,o,s,u,c,p,d,h,y,A,b,g,m,v,w,I,E;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.issuer,i=e.tenantId,o=e.ntpId,s=e.code,u=e.email,c=e.includeNTPId,p=void 0!==c&&c,d=this.GenerateWallet(),n=n||"",this.signer||this.SetSigner({signer:d.AddAccountFromMnemonic({mnemonic:d.GenerateMnemonic()})}),!n.startsWith("iq__")){t.next=8;break}f(n),t.next=28;break;case 8:if(!n||n.replace(/^\//,"").startsWith("otp/ntp/iten")){t.next=12;break}throw Error("Invalid issuer: "+n);case 12:return l("issuer or tenantId",n||i),n||(n=a("/otp","ntp",i,o||"")),t.prev=14,t.next=17,this.authClient.GenerateChannelContentToken({issuer:n,code:s,email:u});case 17:return h=t.sent,this.SetStaticToken({token:h}),y=JSON.parse(this.utils.FromB64(h)),t.abrupt("return",p?{objectId:y.qid,ntpId:y.oid}:y.qid);case 23:throw t.prev=23,t.t0=t.catch(14),this.Log("Failed to redeem code:",!0),this.Log(t.t0,!0),t.t0;case 28:return A=n,t.next=31,this.ContentObjectLibraryId({objectId:A});case 31:return b=t.sent,g=function(t){var e=t.split("").map((function(t){return t.charCodeAt(0)}));return e.reduce((function(t,n,r){return e[r+1]?2*t+n*e[r+1]*(r+1):t+n}),0).toString()}(s),t.next=36,this.ContentObjectMetadata({libraryId:b,objectId:A,metadataSubtree:"public/codes/".concat(g)});case 36:if(m=t.sent){t.next=40;break}throw this.Log("Code redemption failed:\n\t".concat(n,"\n\t").concat(s)),Error("Invalid code: "+s);case 40:return v=m.ak,w=m.sites,I=m.info,t.next=43,d.AddAccountFromEncryptedPK({encryptedPrivateKey:this.utils.FromB64(v),password:s});case 43:return E=t.sent,this.SetSigner({signer:E}),t.next=47,this.userProfileClient.WalletAddress();case 47:return t.abrupt("return",{addr:this.utils.FormatAddress(E.address),sites:w,info:I||{}});case 48:case"end":return t.stop()}}),t,this,[[14,23]])})));return function(e){return t.apply(this,arguments)}}()},function(t,e,n){var r=n(9),i=n(17),a=n(10);function o(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 s(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?o(Object(n),!0).forEach((function(e){i(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}var u=n(449),c=n(30),f=n(31),l=f.ValidateAddress,p=f.ValidateObject,d=f.ValidatePresence;e.MintNFT=function(){var t=a(r.mark((function t(e){var n,i,a,o,f,h,y,A,b;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.tenantId,i=e.address,a=e.marketplaceId,o=e.items,f=e.extraData,h=void 0===f?{}:f,d("tenantId",n),d("address",i),d("marketplaceId",a),d("items",o),p(a),l(i),y={tickets:null,products:o.map((function(t){return{sku:t.sku,quant:t.quantity||1,extra:t.tokenId?s(s({},t.extraData||{}),{},{token_id:t.tokenId}):s({},t.extraData||{})}})),ident:i,cust_name:i,extra:s(s({},h),{},{elv_addr:i})},A=this.utils.B58(u.parse(u.v4())),y.ts=Date.now(),y.trans_id=A,t.next=13,this.Sign(JSON.stringify(y));case 13:return b=t.sent,t.next=16,this.authClient.MakeAuthServiceRequest({method:"POST",path:c("/as/tnt/trans/base",n,a),body:y,headers:{Authorization:"Bearer ".concat(b)}});case 16:return t.abrupt("return",{address:i,transactionId:A});case 17:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.CollectionTransactions=function(){var t=a(r.mark((function t(e){var n,i,a,o,s,u,f,l,p;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.tenantId,i=e.collectionId,a=e.filterOptions,o=void 0===a?{}:a,s=Date.now(),u={ts:s},f={email:"email",fromOrdinal:"from_ord",max:"max",status:"status",transactionId:"trans_id"},Object.keys(f).forEach((function(t){o[t]&&(u[f[t]]=o[t])})),l=this.AuthHttpClient.BaseURI().path(c("/tnt","trans",n,i)).query(u).hash("").resource(),t.next=8,this.Sign(l);case 8:return p=t.sent,t.next=11,this.utils.ResponseToJson(this.authClient.MakeAuthServiceRequest({method:"GET",path:c("as","tnt","trans",n,i),queryParams:u,headers:{Authorization:"Bearer ".concat(p)}}));case 11:return t.abrupt("return",t.sent);case 12:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}()},function(t,e,n){"use strict";n.r(e),n.d(e,"F",(function(){return r})),n.d(e,"T",(function(){return i})),n.d(e,"__",(function(){return a})),n.d(e,"add",(function(){return f})),n.d(e,"addIndex",(function(){return y})),n.d(e,"adjust",(function(){return b})),n.d(e,"all",(function(){return _})),n.d(e,"allPass",(function(){return et})),n.d(e,"always",(function(){return nt})),n.d(e,"and",(function(){return rt})),n.d(e,"any",(function(){return at})),n.d(e,"anyPass",(function(){return ot})),n.d(e,"ap",(function(){return st})),n.d(e,"aperture",(function(){return ft})),n.d(e,"append",(function(){return lt})),n.d(e,"apply",(function(){return pt})),n.d(e,"applySpec",(function(){return yt})),n.d(e,"applyTo",(function(){return At})),n.d(e,"ascend",(function(){return bt})),n.d(e,"assoc",(function(){return gt})),n.d(e,"assocPath",(function(){return vt})),n.d(e,"binary",(function(){return It})),n.d(e,"bind",(function(){return R})),n.d(e,"both",(function(){return kt})),n.d(e,"call",(function(){return xt})),n.d(e,"chain",(function(){return Mt})),n.d(e,"clamp",(function(){return Rt})),n.d(e,"clone",(function(){return Pt})),n.d(e,"comparator",(function(){return Dt})),n.d(e,"complement",(function(){return Lt})),n.d(e,"compose",(function(){return Yt})),n.d(e,"composeK",(function(){return zt})),n.d(e,"composeP",(function(){return Vt})),n.d(e,"composeWith",(function(){return ee})),n.d(e,"concat",(function(){return _e})),n.d(e,"cond",(function(){return Ce})),n.d(e,"construct",(function(){return Be})),n.d(e,"constructN",(function(){return ke})),n.d(e,"contains",(function(){return xe})),n.d(e,"converge",(function(){return Se})),n.d(e,"countBy",(function(){return Re})),n.d(e,"curry",(function(){return Bt})),n.d(e,"curryN",(function(){return h})),n.d(e,"dec",(function(){return Oe})),n.d(e,"defaultTo",(function(){return je})),n.d(e,"descend",(function(){return Te})),n.d(e,"difference",(function(){return Le})),n.d(e,"differenceWith",(function(){return Fe})),n.d(e,"dissoc",(function(){return Ue})),n.d(e,"dissocPath",(function(){return qe})),n.d(e,"divide",(function(){return Ke})),n.d(e,"drop",(function(){return ze})),n.d(e,"dropLast",(function(){return Xe})),n.d(e,"dropLastWhile",(function(){return en})),n.d(e,"dropRepeats",(function(){return sn})),n.d(e,"dropRepeatsWith",(function(){return on})),n.d(e,"dropWhile",(function(){return cn})),n.d(e,"either",(function(){return ln})),n.d(e,"empty",(function(){return pn})),n.d(e,"endsWith",(function(){return hn})),n.d(e,"eqBy",(function(){return yn})),n.d(e,"eqProps",(function(){return An})),n.d(e,"equals",(function(){return ue})),n.d(e,"evolve",(function(){return gn})),n.d(e,"filter",(function(){return me})),n.d(e,"find",(function(){return vn})),n.d(e,"findIndex",(function(){return In})),n.d(e,"findLast",(function(){return _n})),n.d(e,"findLastIndex",(function(){return kn})),n.d(e,"flatten",(function(){return Bn})),n.d(e,"flip",(function(){return xn})),n.d(e,"forEach",(function(){return Sn})),n.d(e,"forEachObjIndexed",(function(){return Qn})),n.d(e,"fromPairs",(function(){return Mn})),n.d(e,"groupBy",(function(){return Rn})),n.d(e,"groupWith",(function(){return On})),n.d(e,"gt",(function(){return jn})),n.d(e,"gte",(function(){return Tn})),n.d(e,"has",(function(){return Dn})),n.d(e,"hasIn",(function(){return Nn})),n.d(e,"hasPath",(function(){return Pn})),n.d(e,"head",(function(){return Zt})),n.d(e,"identical",(function(){return Ln})),n.d(e,"identity",(function(){return $t})),n.d(e,"ifElse",(function(){return Fn})),n.d(e,"inc",(function(){return Un})),n.d(e,"includes",(function(){return Hn})),n.d(e,"indexBy",(function(){return Gn})),n.d(e,"indexOf",(function(){return qn})),n.d(e,"init",(function(){return Kn})),n.d(e,"innerJoin",(function(){return Yn})),n.d(e,"insert",(function(){return zn})),n.d(e,"insertAll",(function(){return Jn})),n.d(e,"intersection",(function(){return Zn})),n.d(e,"intersperse",(function(){return Xn})),n.d(e,"into",(function(){return ar})),n.d(e,"invert",(function(){return or})),n.d(e,"invertObj",(function(){return sr})),n.d(e,"invoker",(function(){return ur})),n.d(e,"is",(function(){return cr})),n.d(e,"isEmpty",(function(){return fr})),n.d(e,"isNil",(function(){return mt})),n.d(e,"join",(function(){return lr})),n.d(e,"juxt",(function(){return pr})),n.d(e,"keys",(function(){return Y})),n.d(e,"keysIn",(function(){return dr})),n.d(e,"last",(function(){return an})),n.d(e,"lastIndexOf",(function(){return hr})),n.d(e,"length",(function(){return Ar})),n.d(e,"lens",(function(){return br})),n.d(e,"lensIndex",(function(){return gr})),n.d(e,"lensPath",(function(){return mr})),n.d(e,"lensProp",(function(){return vr})),n.d(e,"lift",(function(){return Ct})),n.d(e,"liftN",(function(){return _t})),n.d(e,"lt",(function(){return wr})),n.d(e,"lte",(function(){return Ir})),n.d(e,"map",(function(){return z})),n.d(e,"mapAccum",(function(){return Er})),n.d(e,"mapAccumRight",(function(){return _r})),n.d(e,"mapObjIndexed",(function(){return Cr})),n.d(e,"match",(function(){return kr})),n.d(e,"mathMod",(function(){return Br})),n.d(e,"max",(function(){return C})),n.d(e,"maxBy",(function(){return xr})),n.d(e,"mean",(function(){return Qr})),n.d(e,"median",(function(){return Mr})),n.d(e,"memoizeWith",(function(){return Rr})),n.d(e,"merge",(function(){return Or})),n.d(e,"mergeAll",(function(){return jr})),n.d(e,"mergeDeepLeft",(function(){return Dr})),n.d(e,"mergeDeepRight",(function(){return Nr})),n.d(e,"mergeDeepWith",(function(){return Lr})),n.d(e,"mergeDeepWithKey",(function(){return Pr})),n.d(e,"mergeLeft",(function(){return Fr})),n.d(e,"mergeRight",(function(){return Ur})),n.d(e,"mergeWith",(function(){return Hr})),n.d(e,"mergeWithKey",(function(){return Tr})),n.d(e,"min",(function(){return Gr})),n.d(e,"minBy",(function(){return qr})),n.d(e,"modulo",(function(){return Kr})),n.d(e,"move",(function(){return Yr})),n.d(e,"multiply",(function(){return zr})),n.d(e,"nAry",(function(){return wt})),n.d(e,"negate",(function(){return Jr})),n.d(e,"none",(function(){return Wr})),n.d(e,"not",(function(){return Nt})),n.d(e,"nth",(function(){return W})),n.d(e,"nthArg",(function(){return Vr})),n.d(e,"o",(function(){return Zr})),n.d(e,"objOf",(function(){return tr})),n.d(e,"of",(function(){return $r})),n.d(e,"omit",(function(){return ti})),n.d(e,"once",(function(){return ei})),n.d(e,"or",(function(){return fn})),n.d(e,"otherwise",(function(){return ri})),n.d(e,"over",(function(){return ii})),n.d(e,"pair",(function(){return ai})),n.d(e,"partial",(function(){return si})),n.d(e,"partialRight",(function(){return ui})),n.d(e,"partition",(function(){return ci})),n.d(e,"path",(function(){return Z})),n.d(e,"paths",(function(){return V})),n.d(e,"pathEq",(function(){return fi})),n.d(e,"pathOr",(function(){return li})),n.d(e,"pathSatisfies",(function(){return pi})),n.d(e,"pick",(function(){return di})),n.d(e,"pickAll",(function(){return hi})),n.d(e,"pickBy",(function(){return yi})),n.d(e,"pipe",(function(){return qt})),n.d(e,"pipeK",(function(){return Ai})),n.d(e,"pipeP",(function(){return Wt})),n.d(e,"pipeWith",(function(){return te})),n.d(e,"pluck",(function(){return $})),n.d(e,"prepend",(function(){return bi})),n.d(e,"product",(function(){return gi})),n.d(e,"project",(function(){return vi})),n.d(e,"prop",(function(){return X})),n.d(e,"propEq",(function(){return wi})),n.d(e,"propIs",(function(){return Ii})),n.d(e,"propOr",(function(){return Ei})),n.d(e,"propSatisfies",(function(){return _i})),n.d(e,"props",(function(){return Ci})),n.d(e,"range",(function(){return ki})),n.d(e,"reduce",(function(){return tt})),n.d(e,"reduceBy",(function(){return Me})),n.d(e,"reduceRight",(function(){return Bi})),n.d(e,"reduceWhile",(function(){return xi})),n.d(e,"reduced",(function(){return Si})),n.d(e,"reject",(function(){return ve})),n.d(e,"remove",(function(){return He})),n.d(e,"repeat",(function(){return Mi})),n.d(e,"replace",(function(){return Ri})),n.d(e,"reverse",(function(){return Kt})),n.d(e,"scan",(function(){return Oi})),n.d(e,"sequence",(function(){return ji})),n.d(e,"set",(function(){return Ti})),n.d(e,"slice",(function(){return Ht})),n.d(e,"sort",(function(){return Pi})),n.d(e,"sortBy",(function(){return Di})),n.d(e,"sortWith",(function(){return Ni})),n.d(e,"split",(function(){return Li})),n.d(e,"splitAt",(function(){return Fi})),n.d(e,"splitEvery",(function(){return Ui})),n.d(e,"splitWhen",(function(){return Hi})),n.d(e,"startsWith",(function(){return Gi})),n.d(e,"subtract",(function(){return qi})),n.d(e,"sum",(function(){return Sr})),n.d(e,"symmetricDifference",(function(){return Ki})),n.d(e,"symmetricDifferenceWith",(function(){return Yi})),n.d(e,"tail",(function(){return Gt})),n.d(e,"take",(function(){return We})),n.d(e,"takeLast",(function(){return dn})),n.d(e,"takeLastWhile",(function(){return zi})),n.d(e,"takeWhile",(function(){return Wi})),n.d(e,"tap",(function(){return Zi})),n.d(e,"test",(function(){return Xi})),n.d(e,"andThen",(function(){return $i})),n.d(e,"times",(function(){return Qi})),n.d(e,"toLower",(function(){return ta})),n.d(e,"toPairs",(function(){return ea})),n.d(e,"toPairsIn",(function(){return na})),n.d(e,"toString",(function(){return Ee})),n.d(e,"toUpper",(function(){return ra})),n.d(e,"transduce",(function(){return ia})),n.d(e,"transpose",(function(){return aa})),n.d(e,"traverse",(function(){return oa})),n.d(e,"trim",(function(){return ua})),n.d(e,"tryCatch",(function(){return ca})),n.d(e,"type",(function(){return jt})),n.d(e,"unapply",(function(){return fa})),n.d(e,"unary",(function(){return la})),n.d(e,"uncurryN",(function(){return pa})),n.d(e,"unfold",(function(){return da})),n.d(e,"union",(function(){return ha})),n.d(e,"unionWith",(function(){return Aa})),n.d(e,"uniq",(function(){return Vn})),n.d(e,"uniqBy",(function(){return Wn})),n.d(e,"uniqWith",(function(){return ya})),n.d(e,"unless",(function(){return ba})),n.d(e,"unnest",(function(){return ga})),n.d(e,"until",(function(){return ma})),n.d(e,"update",(function(){return Ge})),n.d(e,"useWith",(function(){return mi})),n.d(e,"values",(function(){return dt})),n.d(e,"valuesIn",(function(){return va})),n.d(e,"view",(function(){return Ia})),n.d(e,"when",(function(){return Ea})),n.d(e,"where",(function(){return _a})),n.d(e,"whereEq",(function(){return Ca})),n.d(e,"without",(function(){return ka})),n.d(e,"xor",(function(){return Ba})),n.d(e,"xprod",(function(){return xa})),n.d(e,"zip",(function(){return Sa})),n.d(e,"zipObj",(function(){return Qa})),n.d(e,"zipWith",(function(){return Ma})),n.d(e,"thunkify",(function(){return Ra}));var r=function(){return!1},i=function(){return!0},a={"@@functional/placeholder":!0};function o(t){return(o="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)}function s(t){return null!=t&&"object"===o(t)&&!0===t["@@functional/placeholder"]}function u(t){return function e(n){return 0===arguments.length||s(n)?e:t.apply(this,arguments)}}function c(t){return function e(n,r){switch(arguments.length){case 0:return e;case 1:return s(n)?e:u((function(e){return t(n,e)}));default:return s(n)&&s(r)?e:s(n)?u((function(e){return t(e,r)})):s(r)?u((function(e){return t(n,e)})):t(n,r)}}}var f=c((function(t,e){return Number(t)+Number(e)}));function l(t,e){var n;e=e||[];var r=(t=t||[]).length,i=e.length,a=[];for(n=0;n<r;)a[a.length]=t[n],n+=1;for(n=0;n<i;)a[a.length]=e[n],n+=1;return a}function p(t,e){switch(t){case 0:return function(){return e.apply(this,arguments)};case 1:return function(t){return e.apply(this,arguments)};case 2:return function(t,n){return e.apply(this,arguments)};case 3:return function(t,n,r){return e.apply(this,arguments)};case 4:return function(t,n,r,i){return e.apply(this,arguments)};case 5:return function(t,n,r,i,a){return e.apply(this,arguments)};case 6:return function(t,n,r,i,a,o){return e.apply(this,arguments)};case 7:return function(t,n,r,i,a,o,s){return e.apply(this,arguments)};case 8:return function(t,n,r,i,a,o,s,u){return e.apply(this,arguments)};case 9:return function(t,n,r,i,a,o,s,u,c){return e.apply(this,arguments)};case 10:return function(t,n,r,i,a,o,s,u,c,f){return e.apply(this,arguments)};default:throw new Error("First argument to _arity must be a non-negative integer no greater than ten")}}function d(t,e,n){return function(){for(var r=[],i=0,a=t,o=0;o<e.length||i<arguments.length;){var u;o<e.length&&(!s(e[o])||i>=arguments.length)?u=e[o]:(u=arguments[i],i+=1),r[o]=u,s(u)||(a-=1),o+=1}return a<=0?n.apply(this,r):p(a,d(t,r,n))}}var h=c((function(t,e){return 1===t?u(e):p(t,d(t,[],e))})),y=u((function(t){return h(t.length,(function(){var e=0,n=arguments[0],r=arguments[arguments.length-1],i=Array.prototype.slice.call(arguments,0);return i[0]=function(){var t=n.apply(this,l(arguments,[e,r]));return e+=1,t},t.apply(this,i)}))}));function A(t){return function e(n,r,i){switch(arguments.length){case 0:return e;case 1:return s(n)?e:c((function(e,r){return t(n,e,r)}));case 2:return s(n)&&s(r)?e:s(n)?c((function(e,n){return t(e,r,n)})):s(r)?c((function(e,r){return t(n,e,r)})):u((function(e){return t(n,r,e)}));default:return s(n)&&s(r)&&s(i)?e:s(n)&&s(r)?c((function(e,n){return t(e,n,i)})):s(n)&&s(i)?c((function(e,n){return t(e,r,n)})):s(r)&&s(i)?c((function(e,r){return t(n,e,r)})):s(n)?u((function(e){return t(e,r,i)})):s(r)?u((function(e){return t(n,e,i)})):s(i)?u((function(e){return t(n,r,e)})):t(n,r,i)}}}var b=A((function(t,e,n){if(t>=n.length||t<-n.length)return n;var r=(t<0?n.length:0)+t,i=l(n);return i[r]=e(n[r]),i})),g=Array.isArray||function(t){return null!=t&&t.length>=0&&"[object Array]"===Object.prototype.toString.call(t)};function m(t){return null!=t&&"function"==typeof t["@@transducer/step"]}function v(t,e,n){return function(){if(0===arguments.length)return n();var r=Array.prototype.slice.call(arguments,0),i=r.pop();if(!g(i)){for(var a=0;a<t.length;){if("function"==typeof i[t[a]])return i[t[a]].apply(i,r);a+=1}if(m(i)){var o=e.apply(null,r);return o(i)}}return n.apply(this,arguments)}}function w(t){return t&&t["@@transducer/reduced"]?t:{"@@transducer/value":t,"@@transducer/reduced":!0}}var I={init:function(){return this.xf["@@transducer/init"]()},result:function(t){return this.xf["@@transducer/result"](t)}},E=function(){function t(t,e){this.xf=e,this.f=t,this.all=!0}return t.prototype["@@transducer/init"]=I.init,t.prototype["@@transducer/result"]=function(t){return this.all&&(t=this.xf["@@transducer/step"](t,!0)),this.xf["@@transducer/result"](t)},t.prototype["@@transducer/step"]=function(t,e){return this.f(e)||(this.all=!1,t=w(this.xf["@@transducer/step"](t,!1))),t},t}(),_=c(v(["all"],c((function(t,e){return new E(t,e)})),(function(t,e){for(var n=0;n<e.length;){if(!t(e[n]))return!1;n+=1}return!0}))),C=c((function(t,e){return e>t?e:t}));function k(t,e){for(var n=0,r=e.length,i=Array(r);n<r;)i[n]=t(e[n]),n+=1;return i}function B(t){return"[object String]"===Object.prototype.toString.call(t)}function x(t){return(x="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 S=u((function(t){return!!g(t)||!!t&&("object"===x(t)&&(!B(t)&&(1===t.nodeType?!!t.length:0===t.length||t.length>0&&(t.hasOwnProperty(0)&&t.hasOwnProperty(t.length-1)))))})),Q=function(){function t(t){this.f=t}return t.prototype["@@transducer/init"]=function(){throw new Error("init not implemented on XWrap")},t.prototype["@@transducer/result"]=function(t){return t},t.prototype["@@transducer/step"]=function(t,e){return this.f(t,e)},t}();function M(t){return new Q(t)}var R=c((function(t,e){return p(t.length,(function(){return t.apply(e,arguments)}))}));function O(t,e,n){for(var r=n.next();!r.done;){if((e=t["@@transducer/step"](e,r.value))&&e["@@transducer/reduced"]){e=e["@@transducer/value"];break}r=n.next()}return t["@@transducer/result"](e)}function j(t,e,n,r){return t["@@transducer/result"](n[r](R(t["@@transducer/step"],t),e))}var T="undefined"!=typeof Symbol?Symbol.iterator:"@@iterator";function P(t,e,n){if("function"==typeof t&&(t=M(t)),S(n))return function(t,e,n){for(var r=0,i=n.length;r<i;){if((e=t["@@transducer/step"](e,n[r]))&&e["@@transducer/reduced"]){e=e["@@transducer/value"];break}r+=1}return t["@@transducer/result"](e)}(t,e,n);if("function"==typeof n["fantasy-land/reduce"])return j(t,e,n,"fantasy-land/reduce");if(null!=n[T])return O(t,e,n[T]());if("function"==typeof n.next)return O(t,e,n);if("function"==typeof n.reduce)return j(t,e,n,"reduce");throw new TypeError("reduce: list must be array or iterable")}var D=function(){function t(t,e){this.xf=e,this.f=t}return t.prototype["@@transducer/init"]=I.init,t.prototype["@@transducer/result"]=I.result,t.prototype["@@transducer/step"]=function(t,e){return this.xf["@@transducer/step"](t,this.f(e))},t}(),N=c((function(t,e){return new D(t,e)}));function L(t,e){return Object.prototype.hasOwnProperty.call(e,t)}var F=Object.prototype.toString,U=function(){return"[object Arguments]"===F.call(arguments)?function(t){return"[object Arguments]"===F.call(t)}:function(t){return L("callee",t)}}(),H=!{toString:null}.propertyIsEnumerable("toString"),G=["constructor","valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"],q=function(){return arguments.propertyIsEnumerable("length")}(),K=function(t,e){for(var n=0;n<t.length;){if(t[n]===e)return!0;n+=1}return!1},Y="function"!=typeof Object.keys||q?u((function(t){if(Object(t)!==t)return[];var e,n,r=[],i=q&&U(t);for(e in t)!L(e,t)||i&&"length"===e||(r[r.length]=e);if(H)for(n=G.length-1;n>=0;)L(e=G[n],t)&&!K(r,e)&&(r[r.length]=e),n-=1;return r})):u((function(t){return Object(t)!==t?[]:Object.keys(t)})),z=c(v(["fantasy-land/map","map"],N,(function(t,e){switch(Object.prototype.toString.call(e)){case"[object Function]":return h(e.length,(function(){return t.call(this,e.apply(this,arguments))}));case"[object Object]":return P((function(n,r){return n[r]=t(e[r]),n}),{},Y(e));default:return k(t,e)}}))),J=Number.isInteger||function(t){return t<<0===t},W=c((function(t,e){var n=t<0?e.length+t:t;return B(e)?e.charAt(n):e[n]})),V=c((function(t,e){return t.map((function(t){for(var n,r=e,i=0;i<t.length;){if(null==r)return;n=t[i],r=J(n)?W(n,r):r[n],i+=1}return r}))})),Z=c((function(t,e){return V([t],e)[0]})),X=c((function(t,e){return Z([t],e)})),$=c((function(t,e){return z(X(t),e)})),tt=A(P),et=u((function(t){return h(tt(C,0,$("length",t)),(function(){for(var e=0,n=t.length;e<n;){if(!t[e].apply(this,arguments))return!1;e+=1}return!0}))})),nt=u((function(t){return function(){return t}})),rt=c((function(t,e){return t&&e})),it=function(){function t(t,e){this.xf=e,this.f=t,this.any=!1}return t.prototype["@@transducer/init"]=I.init,t.prototype["@@transducer/result"]=function(t){return this.any||(t=this.xf["@@transducer/step"](t,!1)),this.xf["@@transducer/result"](t)},t.prototype["@@transducer/step"]=function(t,e){return this.f(e)&&(this.any=!0,t=w(this.xf["@@transducer/step"](t,!0))),t},t}(),at=c(v(["any"],c((function(t,e){return new it(t,e)})),(function(t,e){for(var n=0;n<e.length;){if(t(e[n]))return!0;n+=1}return!1}))),ot=u((function(t){return h(tt(C,0,$("length",t)),(function(){for(var e=0,n=t.length;e<n;){if(t[e].apply(this,arguments))return!0;e+=1}return!1}))})),st=c((function(t,e){return"function"==typeof e["fantasy-land/ap"]?e["fantasy-land/ap"](t):"function"==typeof t.ap?t.ap(e):"function"==typeof t?function(n){return t(n)(e(n))}:P((function(t,n){return l(t,z(n,e))}),[],t)}));function ut(t,e){for(var n=0,r=e.length-(t-1),i=new Array(r>=0?r:0);n<r;)i[n]=Array.prototype.slice.call(e,n,n+t),n+=1;return i}var ct=function(){function t(t,e){this.xf=e,this.pos=0,this.full=!1,this.acc=new Array(t)}return t.prototype["@@transducer/init"]=I.init,t.prototype["@@transducer/result"]=function(t){return this.acc=null,this.xf["@@transducer/result"](t)},t.prototype["@@transducer/step"]=function(t,e){return this.store(e),this.full?this.xf["@@transducer/step"](t,this.getCopy()):t},t.prototype.store=function(t){this.acc[this.pos]=t,this.pos+=1,this.pos===this.acc.length&&(this.pos=0,this.full=!0)},t.prototype.getCopy=function(){return l(Array.prototype.slice.call(this.acc,this.pos),Array.prototype.slice.call(this.acc,0,this.pos))},t}(),ft=c(v([],c((function(t,e){return new ct(t,e)})),ut)),lt=c((function(t,e){return l(e,[t])})),pt=c((function(t,e){return t.apply(this,e)})),dt=u((function(t){for(var e=Y(t),n=e.length,r=[],i=0;i<n;)r[i]=t[e[i]],i+=1;return r}));function ht(t,e){return Y(e).reduce((function(n,r){return n[r]=t(e[r]),n}),{})}var yt=u((function t(e){return e=ht((function(e){return"function"==typeof e?e:t(e)}),e),h(tt(C,0,$("length",dt(e))),(function(){var t=arguments;return ht((function(e){return pt(e,t)}),e)}))})),At=c((function(t,e){return e(t)})),bt=A((function(t,e,n){var r=t(e),i=t(n);return r<i?-1:r>i?1:0})),gt=A((function(t,e,n){var r={};for(var i in n)r[i]=n[i];return r[t]=e,r})),mt=u((function(t){return null==t})),vt=A((function t(e,n,r){if(0===e.length)return n;var i=e[0];if(e.length>1){var a=!mt(r)&&L(i,r)?r[i]:J(e[1])?[]:{};n=t(Array.prototype.slice.call(e,1),n,a)}if(J(i)&&g(r)){var o=[].concat(r);return o[i]=n,o}return gt(i,n,r)})),wt=c((function(t,e){switch(t){case 0:return function(){return e.call(this)};case 1:return function(t){return e.call(this,t)};case 2:return function(t,n){return e.call(this,t,n)};case 3:return function(t,n,r){return e.call(this,t,n,r)};case 4:return function(t,n,r,i){return e.call(this,t,n,r,i)};case 5:return function(t,n,r,i,a){return e.call(this,t,n,r,i,a)};case 6:return function(t,n,r,i,a,o){return e.call(this,t,n,r,i,a,o)};case 7:return function(t,n,r,i,a,o,s){return e.call(this,t,n,r,i,a,o,s)};case 8:return function(t,n,r,i,a,o,s,u){return e.call(this,t,n,r,i,a,o,s,u)};case 9:return function(t,n,r,i,a,o,s,u,c){return e.call(this,t,n,r,i,a,o,s,u,c)};case 10:return function(t,n,r,i,a,o,s,u,c,f){return e.call(this,t,n,r,i,a,o,s,u,c,f)};default:throw new Error("First argument to nAry must be a non-negative integer no greater than ten")}})),It=u((function(t){return wt(2,t)}));function Et(t){var e=Object.prototype.toString.call(t);return"[object Function]"===e||"[object AsyncFunction]"===e||"[object GeneratorFunction]"===e||"[object AsyncGeneratorFunction]"===e}var _t=c((function(t,e){var n=h(t,e);return h(t,(function(){return P(st,z(n,arguments[0]),Array.prototype.slice.call(arguments,1))}))})),Ct=u((function(t){return _t(t.length,t)})),kt=c((function(t,e){return Et(t)?function(){return t.apply(this,arguments)&&e.apply(this,arguments)}:Ct(rt)(t,e)})),Bt=u((function(t){return h(t.length,t)})),xt=Bt((function(t){return t.apply(this,Array.prototype.slice.call(arguments,1))}));function St(t){return function e(n){for(var r,i,a,o=[],s=0,u=n.length;s<u;){if(S(n[s]))for(a=0,i=(r=t?e(n[s]):n[s]).length;a<i;)o[o.length]=r[a],a+=1;else o[o.length]=n[s];s+=1}return o}}var Qt=function(t){var e=function(t){return{"@@transducer/init":I.init,"@@transducer/result":function(e){return t["@@transducer/result"](e)},"@@transducer/step":function(e,n){var r=t["@@transducer/step"](e,n);return r["@@transducer/reduced"]?{"@@transducer/value":r,"@@transducer/reduced":!0}:r}}}(t);return{"@@transducer/init":I.init,"@@transducer/result":function(t){return e["@@transducer/result"](t)},"@@transducer/step":function(t,n){return S(n)?P(e,t,n):P(e,t,[n])}}},Mt=c(v(["fantasy-land/chain","chain"],c((function(t,e){return z(t,Qt(e))})),(function(t,e){return"function"==typeof e?function(n){return t(e(n))(n)}:St(!1)(z(t,e))}))),Rt=A((function(t,e,n){if(t>e)throw new Error("min must not be greater than max in clamp(min, max, value)");return n<t?t:n>e?e:n}));function Ot(t){return new RegExp(t.source,(t.global?"g":"")+(t.ignoreCase?"i":"")+(t.multiline?"m":"")+(t.sticky?"y":"")+(t.unicode?"u":""))}var jt=u((function(t){return null===t?"Null":void 0===t?"Undefined":Object.prototype.toString.call(t).slice(8,-1)}));function Tt(t,e,n,r){var i=function(i){for(var a=e.length,o=0;o<a;){if(t===e[o])return n[o];o+=1}for(var s in e[o+1]=t,n[o+1]=i,t)i[s]=r?Tt(t[s],e,n,!0):t[s];return i};switch(jt(t)){case"Object":return i({});case"Array":return i([]);case"Date":return new Date(t.valueOf());case"RegExp":return Ot(t);default:return t}}var Pt=u((function(t){return null!=t&&"function"==typeof t.clone?t.clone():Tt(t,[],[],!0)})),Dt=u((function(t){return function(e,n){return t(e,n)?-1:t(n,e)?1:0}})),Nt=u((function(t){return!t})),Lt=Ct(Nt);function Ft(t,e){return function(){return e.call(this,t.apply(this,arguments))}}function Ut(t,e){return function(){var n=arguments.length;if(0===n)return e();var r=arguments[n-1];return g(r)||"function"!=typeof r[t]?e.apply(this,arguments):r[t].apply(r,Array.prototype.slice.call(arguments,0,n-1))}}var Ht=A(Ut("slice",(function(t,e,n){return Array.prototype.slice.call(n,t,e)}))),Gt=u(Ut("tail",Ht(1,1/0)));function qt(){if(0===arguments.length)throw new Error("pipe requires at least one argument");return p(arguments[0].length,tt(Ft,arguments[0],Gt(arguments)))}var Kt=u((function(t){return B(t)?t.split("").reverse().join(""):Array.prototype.slice.call(t,0).reverse()}));function Yt(){if(0===arguments.length)throw new Error("compose requires at least one argument");return qt.apply(this,Kt(arguments))}function zt(){if(0===arguments.length)throw new Error("composeK requires at least one argument");var t=Array.prototype.slice.call(arguments),e=t.pop();return Yt(Yt.apply(this,z(Mt,t)),e)}function Jt(t,e){return function(){var n=this;return t.apply(n,arguments).then((function(t){return e.call(n,t)}))}}function Wt(){if(0===arguments.length)throw new Error("pipeP requires at least one argument");return p(arguments[0].length,tt(Jt,arguments[0],Gt(arguments)))}function Vt(){if(0===arguments.length)throw new Error("composeP requires at least one argument");return Wt.apply(this,Kt(arguments))}var Zt=W(0);function Xt(t){return t}var $t=u(Xt),te=c((function(t,e){if(e.length<=0)return $t;var n=Zt(e),r=Gt(e);return p(n.length,(function(){return P((function(e,n){return t.call(this,n,e)}),n.apply(this,arguments),r)}))})),ee=c((function(t,e){return te.apply(this,[t,Kt(e)])}));function ne(t){for(var e,n=[];!(e=t.next()).done;)n.push(e.value);return n}function re(t,e,n){for(var r=0,i=n.length;r<i;){if(t(e,n[r]))return!0;r+=1}return!1}var ie="function"==typeof Object.is?Object.is:function(t,e){return t===e?0!==t||1/t==1/e:t!=t&&e!=e};function ae(t){return(ae="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)}function oe(t,e,n,r){var i=ne(t);function a(t,e){return se(t,e,n.slice(),r.slice())}return!re((function(t,e){return!re(a,e,t)}),ne(e),i)}function se(t,e,n,r){if(ie(t,e))return!0;var i=jt(t);if(i!==jt(e))return!1;if(null==t||null==e)return!1;if("function"==typeof t["fantasy-land/equals"]||"function"==typeof e["fantasy-land/equals"])return"function"==typeof t["fantasy-land/equals"]&&t["fantasy-land/equals"](e)&&"function"==typeof e["fantasy-land/equals"]&&e["fantasy-land/equals"](t);if("function"==typeof t.equals||"function"==typeof e.equals)return"function"==typeof t.equals&&t.equals(e)&&"function"==typeof e.equals&&e.equals(t);switch(i){case"Arguments":case"Array":case"Object":if("function"==typeof t.constructor&&"Promise"===function(t){var e=String(t).match(/^function (\w*)/);return null==e?"":e[1]}(t.constructor))return t===e;break;case"Boolean":case"Number":case"String":if(ae(t)!==ae(e)||!ie(t.valueOf(),e.valueOf()))return!1;break;case"Date":if(!ie(t.valueOf(),e.valueOf()))return!1;break;case"Error":return t.name===e.name&&t.message===e.message;case"RegExp":if(t.source!==e.source||t.global!==e.global||t.ignoreCase!==e.ignoreCase||t.multiline!==e.multiline||t.sticky!==e.sticky||t.unicode!==e.unicode)return!1}for(var a=n.length-1;a>=0;){if(n[a]===t)return r[a]===e;a-=1}switch(i){case"Map":return t.size===e.size&&oe(t.entries(),e.entries(),n.concat([t]),r.concat([e]));case"Set":return t.size===e.size&&oe(t.values(),e.values(),n.concat([t]),r.concat([e]));case"Arguments":case"Array":case"Object":case"Boolean":case"Number":case"String":case"Date":case"Error":case"RegExp":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"ArrayBuffer":break;default:return!1}var o=Y(t);if(o.length!==Y(e).length)return!1;var s=n.concat([t]),u=r.concat([e]);for(a=o.length-1;a>=0;){var c=o[a];if(!L(c,e)||!se(e[c],t[c],s,u))return!1;a-=1}return!0}var ue=c((function(t,e){return se(t,e,[],[])}));function ce(t){return(ce="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)}function fe(t,e,n){var r,i;if("function"==typeof t.indexOf)switch(ce(e)){case"number":if(0===e){for(r=1/e;n<t.length;){if(0===(i=t[n])&&1/i===r)return n;n+=1}return-1}if(e!=e){for(;n<t.length;){if("number"==typeof(i=t[n])&&i!=i)return n;n+=1}return-1}return t.indexOf(e,n);case"string":case"boolean":case"function":case"undefined":return t.indexOf(e,n);case"object":if(null===e)return t.indexOf(e,n)}for(;n<t.length;){if(ue(t[n],e))return n;n+=1}return-1}function le(t,e){return fe(e,t,0)>=0}function pe(t){return'"'+t.replace(/\\/g,"\\\\").replace(/[\b]/g,"\\b").replace(/\f/g,"\\f").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t").replace(/\v/g,"\\v").replace(/\0/g,"\\0").replace(/"/g,'\\"')+'"'}var de=function(t){return(t<10?"0":"")+t},he="function"==typeof Date.prototype.toISOString?function(t){return t.toISOString()}:function(t){return t.getUTCFullYear()+"-"+de(t.getUTCMonth()+1)+"-"+de(t.getUTCDate())+"T"+de(t.getUTCHours())+":"+de(t.getUTCMinutes())+":"+de(t.getUTCSeconds())+"."+(t.getUTCMilliseconds()/1e3).toFixed(3).slice(2,5)+"Z"};function ye(t){return function(){return!t.apply(this,arguments)}}function Ae(t,e){for(var n=0,r=e.length,i=[];n<r;)t(e[n])&&(i[i.length]=e[n]),n+=1;return i}function be(t){return"[object Object]"===Object.prototype.toString.call(t)}var ge=function(){function t(t,e){this.xf=e,this.f=t}return t.prototype["@@transducer/init"]=I.init,t.prototype["@@transducer/result"]=I.result,t.prototype["@@transducer/step"]=function(t,e){return this.f(e)?this.xf["@@transducer/step"](t,e):t},t}(),me=c(v(["filter"],c((function(t,e){return new ge(t,e)})),(function(t,e){return be(e)?P((function(n,r){return t(e[r])&&(n[r]=e[r]),n}),{},Y(e)):Ae(t,e)}))),ve=c((function(t,e){return me(ye(t),e)}));function we(t){return(we="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)}function Ie(t,e){var n=function(n){var r=e.concat([t]);return le(n,r)?"<Circular>":Ie(n,r)},r=function(t,e){return k((function(e){return pe(e)+": "+n(t[e])}),e.slice().sort())};switch(Object.prototype.toString.call(t)){case"[object Arguments]":return"(function() { return arguments; }("+k(n,t).join(", ")+"))";case"[object Array]":return"["+k(n,t).concat(r(t,ve((function(t){return/^\d+$/.test(t)}),Y(t)))).join(", ")+"]";case"[object Boolean]":return"object"===we(t)?"new Boolean("+n(t.valueOf())+")":t.toString();case"[object Date]":return"new Date("+(isNaN(t.valueOf())?n(NaN):pe(he(t)))+")";case"[object Null]":return"null";case"[object Number]":return"object"===we(t)?"new Number("+n(t.valueOf())+")":1/t==-1/0?"-0":t.toString(10);case"[object String]":return"object"===we(t)?"new String("+n(t.valueOf())+")":pe(t);case"[object Undefined]":return"undefined";default:if("function"==typeof t.toString){var i=t.toString();if("[object Object]"!==i)return i}return"{"+r(t,Y(t)).join(", ")+"}"}}var Ee=u((function(t){return Ie(t,[])})),_e=c((function(t,e){if(g(t)){if(g(e))return t.concat(e);throw new TypeError(Ee(e)+" is not an array")}if(B(t)){if(B(e))return t+e;throw new TypeError(Ee(e)+" is not a string")}if(null!=t&&Et(t["fantasy-land/concat"]))return t["fantasy-land/concat"](e);if(null!=t&&Et(t.concat))return t.concat(e);throw new TypeError(Ee(t)+' does not have a method named "concat" or "fantasy-land/concat"')})),Ce=u((function(t){return p(tt(C,0,z((function(t){return t[0].length}),t)),(function(){for(var e=0;e<t.length;){if(t[e][0].apply(this,arguments))return t[e][1].apply(this,arguments);e+=1}}))})),ke=c((function(t,e){if(t>10)throw new Error("Constructor with greater than ten arguments");return 0===t?function(){return new e}:Bt(wt(t,(function(t,n,r,i,a,o,s,u,c,f){switch(arguments.length){case 1:return new e(t);case 2:return new e(t,n);case 3:return new e(t,n,r);case 4:return new e(t,n,r,i);case 5:return new e(t,n,r,i,a);case 6:return new e(t,n,r,i,a,o);case 7:return new e(t,n,r,i,a,o,s);case 8:return new e(t,n,r,i,a,o,s,u);case 9:return new e(t,n,r,i,a,o,s,u,c);case 10:return new e(t,n,r,i,a,o,s,u,c,f)}})))})),Be=u((function(t){return ke(t.length,t)})),xe=c(le),Se=c((function(t,e){return h(tt(C,0,$("length",e)),(function(){var n=arguments,r=this;return t.apply(r,k((function(t){return t.apply(r,n)}),e))}))})),Qe=function(){function t(t,e,n,r){this.valueFn=t,this.valueAcc=e,this.keyFn=n,this.xf=r,this.inputs={}}return t.prototype["@@transducer/init"]=I.init,t.prototype["@@transducer/result"]=function(t){var e;for(e in this.inputs)if(L(e,this.inputs)&&(t=this.xf["@@transducer/step"](t,this.inputs[e]))["@@transducer/reduced"]){t=t["@@transducer/value"];break}return this.inputs=null,this.xf["@@transducer/result"](t)},t.prototype["@@transducer/step"]=function(t,e){var n=this.keyFn(e);return this.inputs[n]=this.inputs[n]||[n,this.valueAcc],this.inputs[n][1]=this.valueFn(this.inputs[n][1],e),t},t}(),Me=d(4,[],v([],d(4,[],(function(t,e,n,r){return new Qe(t,e,n,r)})),(function(t,e,n,r){return P((function(r,i){var a=n(i);return r[a]=t(L(a,r)?r[a]:Tt(e,[],[],!1),i),r}),{},r)}))),Re=Me((function(t,e){return t+1}),0),Oe=f(-1),je=c((function(t,e){return null==e||e!=e?t:e})),Te=A((function(t,e,n){var r=t(e),i=t(n);return r>i?-1:r<i?1:0}));function Pe(t){return(Pe="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)}function De(t,e,n){var r,i=Pe(t);switch(i){case"string":case"number":return 0===t&&1/t==-1/0?!!n._items["-0"]||(e&&(n._items["-0"]=!0),!1):null!==n._nativeSet?e?(r=n._nativeSet.size,n._nativeSet.add(t),n._nativeSet.size===r):n._nativeSet.has(t):i in n._items?t in n._items[i]||(e&&(n._items[i][t]=!0),!1):(e&&(n._items[i]={},n._items[i][t]=!0),!1);case"boolean":if(i in n._items){var a=t?1:0;return!!n._items[i][a]||(e&&(n._items[i][a]=!0),!1)}return e&&(n._items[i]=t?[!1,!0]:[!0,!1]),!1;case"function":return null!==n._nativeSet?e?(r=n._nativeSet.size,n._nativeSet.add(t),n._nativeSet.size===r):n._nativeSet.has(t):i in n._items?!!le(t,n._items[i])||(e&&n._items[i].push(t),!1):(e&&(n._items[i]=[t]),!1);case"undefined":return!!n._items[i]||(e&&(n._items[i]=!0),!1);case"object":if(null===t)return!!n._items.null||(e&&(n._items.null=!0),!1);default:return(i=Object.prototype.toString.call(t))in n._items?!!le(t,n._items[i])||(e&&n._items[i].push(t),!1):(e&&(n._items[i]=[t]),!1)}}var Ne=function(){function t(){this._nativeSet="function"==typeof Set?new Set:null,this._items={}}return t.prototype.add=function(t){return!De(t,!0,this)},t.prototype.has=function(t){return De(t,!1,this)},t}(),Le=c((function(t,e){for(var n=[],r=0,i=t.length,a=e.length,o=new Ne,s=0;s<a;s+=1)o.add(e[s]);for(;r<i;)o.add(t[r])&&(n[n.length]=t[r]),r+=1;return n})),Fe=A((function(t,e,n){for(var r=[],i=0,a=e.length;i<a;)re(t,e[i],n)||re(t,e[i],r)||r.push(e[i]),i+=1;return r})),Ue=c((function(t,e){var n={};for(var r in e)n[r]=e[r];return delete n[t],n})),He=A((function(t,e,n){var r=Array.prototype.slice.call(n,0);return r.splice(t,e),r})),Ge=A((function(t,e,n){return b(t,nt(e),n)})),qe=c((function t(e,n){switch(e.length){case 0:return n;case 1:return J(e[0])&&g(n)?He(e[0],1,n):Ue(e[0],n);default:var r=e[0],i=Array.prototype.slice.call(e,1);return null==n[r]?n:J(r)&&g(n)?Ge(r,t(i,n[r]),n):gt(r,t(i,n[r]),n)}})),Ke=c((function(t,e){return t/e})),Ye=function(){function t(t,e){this.xf=e,this.n=t}return t.prototype["@@transducer/init"]=I.init,t.prototype["@@transducer/result"]=I.result,t.prototype["@@transducer/step"]=function(t,e){return this.n>0?(this.n-=1,t):this.xf["@@transducer/step"](t,e)},t}(),ze=c(v(["drop"],c((function(t,e){return new Ye(t,e)})),(function(t,e){return Ht(Math.max(0,t),1/0,e)}))),Je=function(){function t(t,e){this.xf=e,this.n=t,this.i=0}return t.prototype["@@transducer/init"]=I.init,t.prototype["@@transducer/result"]=I.result,t.prototype["@@transducer/step"]=function(t,e){this.i+=1;var n=0===this.n?t:this.xf["@@transducer/step"](t,e);return this.n>=0&&this.i>=this.n?w(n):n},t}(),We=c(v(["take"],c((function(t,e){return new Je(t,e)})),(function(t,e){return Ht(0,t<0?1/0:t,e)})));function Ve(t,e){return We(t<e.length?e.length-t:0,e)}var Ze=function(){function t(t,e){this.xf=e,this.pos=0,this.full=!1,this.acc=new Array(t)}return t.prototype["@@transducer/init"]=I.init,t.prototype["@@transducer/result"]=function(t){return this.acc=null,this.xf["@@transducer/result"](t)},t.prototype["@@transducer/step"]=function(t,e){return this.full&&(t=this.xf["@@transducer/step"](t,this.acc[this.pos])),this.store(e),t},t.prototype.store=function(t){this.acc[this.pos]=t,this.pos+=1,this.pos===this.acc.length&&(this.pos=0,this.full=!0)},t}(),Xe=c(v([],c((function(t,e){return new Ze(t,e)})),Ve));function $e(t,e){for(var n=e.length-1;n>=0&&t(e[n]);)n-=1;return Ht(0,n+1,e)}var tn=function(){function t(t,e){this.f=t,this.retained=[],this.xf=e}return t.prototype["@@transducer/init"]=I.init,t.prototype["@@transducer/result"]=function(t){return this.retained=null,this.xf["@@transducer/result"](t)},t.prototype["@@transducer/step"]=function(t,e){return this.f(e)?this.retain(t,e):this.flush(t,e)},t.prototype.flush=function(t,e){return t=P(this.xf["@@transducer/step"],t,this.retained),this.retained=[],this.xf["@@transducer/step"](t,e)},t.prototype.retain=function(t,e){return this.retained.push(e),t},t}(),en=c(v([],c((function(t,e){return new tn(t,e)})),$e)),nn=function(){function t(t,e){this.xf=e,this.pred=t,this.lastValue=void 0,this.seenFirstValue=!1}return t.prototype["@@transducer/init"]=I.init,t.prototype["@@transducer/result"]=I.result,t.prototype["@@transducer/step"]=function(t,e){var n=!1;return this.seenFirstValue?this.pred(this.lastValue,e)&&(n=!0):this.seenFirstValue=!0,this.lastValue=e,n?t:this.xf["@@transducer/step"](t,e)},t}(),rn=c((function(t,e){return new nn(t,e)})),an=W(-1),on=c(v([],rn,(function(t,e){var n=[],r=1,i=e.length;if(0!==i)for(n[0]=e[0];r<i;)t(an(n),e[r])||(n[n.length]=e[r]),r+=1;return n}))),sn=u(v([],rn(ue),on(ue))),un=function(){function t(t,e){this.xf=e,this.f=t}return t.prototype["@@transducer/init"]=I.init,t.prototype["@@transducer/result"]=I.result,t.prototype["@@transducer/step"]=function(t,e){if(this.f){if(this.f(e))return t;this.f=null}return this.xf["@@transducer/step"](t,e)},t}(),cn=c(v(["dropWhile"],c((function(t,e){return new un(t,e)})),(function(t,e){for(var n=0,r=e.length;n<r&&t(e[n]);)n+=1;return Ht(n,1/0,e)}))),fn=c((function(t,e){return t||e})),ln=c((function(t,e){return Et(t)?function(){return t.apply(this,arguments)||e.apply(this,arguments)}:Ct(fn)(t,e)})),pn=u((function(t){return null!=t&&"function"==typeof t["fantasy-land/empty"]?t["fantasy-land/empty"]():null!=t&&null!=t.constructor&&"function"==typeof t.constructor["fantasy-land/empty"]?t.constructor["fantasy-land/empty"]():null!=t&&"function"==typeof t.empty?t.empty():null!=t&&null!=t.constructor&&"function"==typeof t.constructor.empty?t.constructor.empty():g(t)?[]:B(t)?"":be(t)?{}:U(t)?function(){return arguments}():void 0})),dn=c((function(t,e){return ze(t>=0?e.length-t:0,e)})),hn=c((function(t,e){return ue(dn(t.length,e),t)})),yn=A((function(t,e,n){return ue(t(e),t(n))})),An=A((function(t,e,n){return ue(e[t],n[t])}));function bn(t){return(bn="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 gn=c((function t(e,n){var r,i,a,o=n instanceof Array?[]:{};for(i in n)a=bn(r=e[i]),o[i]="function"===a?r(n[i]):r&&"object"===a?t(r,n[i]):n[i];return o})),mn=function(){function t(t,e){this.xf=e,this.f=t,this.found=!1}return t.prototype["@@transducer/init"]=I.init,t.prototype["@@transducer/result"]=function(t){return this.found||(t=this.xf["@@transducer/step"](t,void 0)),this.xf["@@transducer/result"](t)},t.prototype["@@transducer/step"]=function(t,e){return this.f(e)&&(this.found=!0,t=w(this.xf["@@transducer/step"](t,e))),t},t}(),vn=c(v(["find"],c((function(t,e){return new mn(t,e)})),(function(t,e){for(var n=0,r=e.length;n<r;){if(t(e[n]))return e[n];n+=1}}))),wn=function(){function t(t,e){this.xf=e,this.f=t,this.idx=-1,this.found=!1}return t.prototype["@@transducer/init"]=I.init,t.prototype["@@transducer/result"]=function(t){return this.found||(t=this.xf["@@transducer/step"](t,-1)),this.xf["@@transducer/result"](t)},t.prototype["@@transducer/step"]=function(t,e){return this.idx+=1,this.f(e)&&(this.found=!0,t=w(this.xf["@@transducer/step"](t,this.idx))),t},t}(),In=c(v([],c((function(t,e){return new wn(t,e)})),(function(t,e){for(var n=0,r=e.length;n<r;){if(t(e[n]))return n;n+=1}return-1}))),En=function(){function t(t,e){this.xf=e,this.f=t}return t.prototype["@@transducer/init"]=I.init,t.prototype["@@transducer/result"]=function(t){return this.xf["@@transducer/result"](this.xf["@@transducer/step"](t,this.last))},t.prototype["@@transducer/step"]=function(t,e){return this.f(e)&&(this.last=e),t},t}(),_n=c(v([],c((function(t,e){return new En(t,e)})),(function(t,e){for(var n=e.length-1;n>=0;){if(t(e[n]))return e[n];n-=1}}))),Cn=function(){function t(t,e){this.xf=e,this.f=t,this.idx=-1,this.lastIdx=-1}return t.prototype["@@transducer/init"]=I.init,t.prototype["@@transducer/result"]=function(t){return this.xf["@@transducer/result"](this.xf["@@transducer/step"](t,this.lastIdx))},t.prototype["@@transducer/step"]=function(t,e){return this.idx+=1,this.f(e)&&(this.lastIdx=this.idx),t},t}(),kn=c(v([],c((function(t,e){return new Cn(t,e)})),(function(t,e){for(var n=e.length-1;n>=0;){if(t(e[n]))return n;n-=1}return-1}))),Bn=u(St(!0)),xn=u((function(t){return h(t.length,(function(e,n){var r=Array.prototype.slice.call(arguments,0);return r[0]=n,r[1]=e,t.apply(this,r)}))})),Sn=c(Ut("forEach",(function(t,e){for(var n=e.length,r=0;r<n;)t(e[r]),r+=1;return e}))),Qn=c((function(t,e){for(var n=Y(e),r=0;r<n.length;){var i=n[r];t(e[i],i,e),r+=1}return e})),Mn=u((function(t){for(var e={},n=0;n<t.length;)e[t[n][0]]=t[n][1],n+=1;return e})),Rn=c(Ut("groupBy",Me((function(t,e){return null==t&&(t=[]),t.push(e),t}),null))),On=c((function(t,e){for(var n=[],r=0,i=e.length;r<i;){for(var a=r+1;a<i&&t(e[a-1],e[a]);)a+=1;n.push(e.slice(r,a)),r=a}return n})),jn=c((function(t,e){return t>e})),Tn=c((function(t,e){return t>=e})),Pn=c((function(t,e){if(0===t.length||mt(e))return!1;for(var n=e,r=0;r<t.length;){if(mt(n)||!L(t[r],n))return!1;n=n[t[r]],r+=1}return!0})),Dn=c((function(t,e){return Pn([t],e)})),Nn=c((function(t,e){return t in e})),Ln=c(ie),Fn=A((function(t,e,n){return h(Math.max(t.length,e.length,n.length),(function(){return t.apply(this,arguments)?e.apply(this,arguments):n.apply(this,arguments)}))})),Un=f(1),Hn=c(le),Gn=Me((function(t,e){return e}),null),qn=c((function(t,e){return"function"!=typeof e.indexOf||g(e)?fe(e,t,0):e.indexOf(t)})),Kn=Ht(0,-1),Yn=A((function(t,e,n){return Ae((function(e){return re(t,e,n)}),e)})),zn=A((function(t,e,n){t=t<n.length&&t>=0?t:n.length;var r=Array.prototype.slice.call(n,0);return r.splice(t,0,e),r})),Jn=A((function(t,e,n){return t=t<n.length&&t>=0?t:n.length,[].concat(Array.prototype.slice.call(n,0,t),e,Array.prototype.slice.call(n,t))})),Wn=c((function(t,e){for(var n,r,i=new Ne,a=[],o=0;o<e.length;)n=t(r=e[o]),i.add(n)&&a.push(r),o+=1;return a})),Vn=Wn($t),Zn=c((function(t,e){var n,r;return t.length>e.length?(n=t,r=e):(n=e,r=t),Vn(Ae(xn(le)(n),r))})),Xn=c(Ut("intersperse",(function(t,e){for(var n=[],r=0,i=e.length;r<i;)r===i-1?n.push(e[r]):n.push(e[r],t),r+=1;return n})));var $n="function"==typeof Object.assign?Object.assign:function(t){if(null==t)throw new TypeError("Cannot convert undefined or null to object");for(var e=Object(t),n=1,r=arguments.length;n<r;){var i=arguments[n];if(null!=i)for(var a in i)L(a,i)&&(e[a]=i[a]);n+=1}return e},tr=c((function(t,e){var n={};return n[t]=e,n}));function er(t){return(er="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 nr={"@@transducer/init":Array,"@@transducer/step":function(t,e){return t.push(e),t},"@@transducer/result":Xt},rr={"@@transducer/init":String,"@@transducer/step":function(t,e){return t+e},"@@transducer/result":Xt},ir={"@@transducer/init":Object,"@@transducer/step":function(t,e){return $n(t,S(e)?tr(e[0],e[1]):e)},"@@transducer/result":Xt};var ar=A((function(t,e,n){return m(t)?P(e(t),t["@@transducer/init"](),n):P(e(function(t){if(m(t))return t;if(S(t))return nr;if("string"==typeof t)return rr;if("object"===er(t))return ir;throw new Error("Cannot create transformer for "+t)}(t)),Tt(t,[],[],!1),n)})),or=u((function(t){for(var e=Y(t),n=e.length,r=0,i={};r<n;){var a=e[r],o=t[a],s=L(o,i)?i[o]:i[o]=[];s[s.length]=a,r+=1}return i})),sr=u((function(t){for(var e=Y(t),n=e.length,r=0,i={};r<n;){var a=e[r];i[t[a]]=a,r+=1}return i})),ur=c((function(t,e){return h(t+1,(function(){var n=arguments[t];if(null!=n&&Et(n[e]))return n[e].apply(n,Array.prototype.slice.call(arguments,0,t));throw new TypeError(Ee(n)+' does not have a method named "'+e+'"')}))})),cr=c((function(t,e){return null!=e&&e.constructor===t||e instanceof t})),fr=u((function(t){return null!=t&&ue(t,pn(t))})),lr=ur(1,"join"),pr=u((function(t){return Se((function(){return Array.prototype.slice.call(arguments,0)}),t)})),dr=u((function(t){var e,n=[];for(e in t)n[n.length]=e;return n})),hr=c((function(t,e){if("function"!=typeof e.lastIndexOf||g(e)){for(var n=e.length-1;n>=0;){if(ue(e[n],t))return n;n-=1}return-1}return e.lastIndexOf(t)}));function yr(t){return"[object Number]"===Object.prototype.toString.call(t)}var Ar=u((function(t){return null!=t&&yr(t.length)?t.length:NaN})),br=c((function(t,e){return function(n){return function(r){return z((function(t){return e(t,r)}),n(t(r)))}}})),gr=u((function(t){return br(W(t),Ge(t))})),mr=u((function(t){return br(Z(t),vt(t))})),vr=u((function(t){return br(X(t),gt(t))})),wr=c((function(t,e){return t<e})),Ir=c((function(t,e){return t<=e})),Er=A((function(t,e,n){for(var r=0,i=n.length,a=[],o=[e];r<i;)o=t(o[0],n[r]),a[r]=o[1],r+=1;return[o[0],a]})),_r=A((function(t,e,n){for(var r=n.length-1,i=[],a=[e];r>=0;)a=t(a[0],n[r]),i[r]=a[1],r-=1;return[a[0],i]})),Cr=c((function(t,e){return P((function(n,r){return n[r]=t(e[r],r,e),n}),{},Y(e))})),kr=c((function(t,e){return e.match(t)||[]})),Br=c((function(t,e){return J(t)?!J(e)||e<1?NaN:(t%e+e)%e:NaN})),xr=A((function(t,e,n){return t(n)>t(e)?n:e})),Sr=tt(f,0),Qr=u((function(t){return Sr(t)/t.length})),Mr=u((function(t){var e=t.length;if(0===e)return NaN;var n=2-e%2,r=(e-n)/2;return Qr(Array.prototype.slice.call(t,0).sort((function(t,e){return t<e?-1:t>e?1:0})).slice(r,r+n))})),Rr=c((function(t,e){var n={};return p(e.length,(function(){var r=t.apply(this,arguments);return L(r,n)||(n[r]=e.apply(this,arguments)),n[r]}))})),Or=c((function(t,e){return $n({},t,e)})),jr=u((function(t){return $n.apply(null,[{}].concat(t))})),Tr=A((function(t,e,n){var r,i={};for(r in e)L(r,e)&&(i[r]=L(r,n)?t(r,e[r],n[r]):e[r]);for(r in n)L(r,n)&&!L(r,i)&&(i[r]=n[r]);return i})),Pr=A((function t(e,n,r){return Tr((function(n,r,i){return be(r)&&be(i)?t(e,r,i):e(n,r,i)}),n,r)})),Dr=c((function(t,e){return Pr((function(t,e,n){return e}),t,e)})),Nr=c((function(t,e){return Pr((function(t,e,n){return n}),t,e)})),Lr=A((function(t,e,n){return Pr((function(e,n,r){return t(n,r)}),e,n)})),Fr=c((function(t,e){return $n({},e,t)})),Ur=c((function(t,e){return $n({},t,e)})),Hr=A((function(t,e,n){return Tr((function(e,n,r){return t(n,r)}),e,n)})),Gr=c((function(t,e){return e<t?e:t})),qr=A((function(t,e,n){return t(n)<t(e)?n:e})),Kr=c((function(t,e){return t%e})),Yr=A((function(t,e,n){var r=n.length,i=n.slice(),a=t<0?r+t:t,o=e<0?r+e:e,s=i.splice(a,1);return a<0||a>=n.length||o<0||o>=n.length?n:[].concat(i.slice(0,o)).concat(s).concat(i.slice(o,n.length))})),zr=c((function(t,e){return t*e})),Jr=u((function(t){return-t})),Wr=c((function(t,e){return _(ye(t),e)})),Vr=u((function(t){return h(t<0?1:t+1,(function(){return W(t,arguments)}))})),Zr=A((function(t,e,n){return t(e(n))}));function Xr(t){return[t]}var $r=u(Xr),ti=c((function(t,e){for(var n={},r={},i=0,a=t.length;i<a;)r[t[i]]=1,i+=1;for(var o in e)r.hasOwnProperty(o)||(n[o]=e[o]);return n})),ei=u((function(t){var e,n=!1;return p(t.length,(function(){return n?e:(n=!0,e=t.apply(this,arguments))}))}));function ni(t,e){if(null==e||!Et(e.then))throw new TypeError("`"+t+"` expected a Promise, received "+Ie(e,[]))}var ri=c((function(t,e){return ni("otherwise",e),e.then(null,t)})),ii=A((function(t,e,n){return t((function(t){return function t(e){return{value:e,map:function(n){return t(n(e))}}}(e(t))}))(n).value})),ai=c((function(t,e){return[t,e]}));function oi(t){return c((function(e,n){return p(Math.max(0,e.length-n.length),(function(){return e.apply(this,t(n,arguments))}))}))}var si=oi(l),ui=oi(xn(l)),ci=pr([me,ve]),fi=A((function(t,e,n){return ue(Z(t,n),e)})),li=A((function(t,e,n){return je(t,Z(e,n))})),pi=A((function(t,e,n){return t(Z(e,n))})),di=c((function(t,e){for(var n={},r=0;r<t.length;)t[r]in e&&(n[t[r]]=e[t[r]]),r+=1;return n})),hi=c((function(t,e){for(var n={},r=0,i=t.length;r<i;){var a=t[r];n[a]=e[a],r+=1}return n})),yi=c((function(t,e){var n={};for(var r in e)t(e[r],r,e)&&(n[r]=e[r]);return n}));function Ai(){if(0===arguments.length)throw new Error("pipeK requires at least one argument");return zt.apply(this,Kt(arguments))}var bi=c((function(t,e){return l([t],e)})),gi=tt(zr,1),mi=c((function(t,e){return h(e.length,(function(){for(var n=[],r=0;r<e.length;)n.push(e[r].call(this,arguments[r])),r+=1;return t.apply(this,n.concat(Array.prototype.slice.call(arguments,e.length)))}))})),vi=mi(k,[hi,$t]),wi=A((function(t,e,n){return ue(e,n[t])})),Ii=A((function(t,e,n){return cr(t,n[e])})),Ei=A((function(t,e,n){return li(t,[e],n)})),_i=A((function(t,e,n){return t(n[e])})),Ci=c((function(t,e){return t.map((function(t){return Z([t],e)}))})),ki=c((function(t,e){if(!yr(t)||!yr(e))throw new TypeError("Both arguments to range must be numbers");for(var n=[],r=t;r<e;)n.push(r),r+=1;return n})),Bi=A((function(t,e,n){for(var r=n.length-1;r>=0;)e=t(n[r],e),r-=1;return e})),xi=d(4,[],(function(t,e,n,r){return P((function(n,r){return t(n,r)?e(n,r):w(n)}),n,r)})),Si=u(w),Qi=c((function(t,e){var n,r=Number(e),i=0;if(r<0||isNaN(r))throw new RangeError("n must be a non-negative number");for(n=new Array(r);i<r;)n[i]=t(i),i+=1;return n})),Mi=c((function(t,e){return Qi(nt(t),e)})),Ri=A((function(t,e,n){return n.replace(t,e)})),Oi=A((function(t,e,n){for(var r=0,i=n.length,a=[e];r<i;)e=t(e,n[r]),a[r+1]=e,r+=1;return a})),ji=c((function(t,e){return"function"==typeof e.sequence?e.sequence(t):Bi((function(t,e){return st(z(bi,t),e)}),t([]),e)})),Ti=A((function(t,e,n){return ii(t,nt(e),n)})),Pi=c((function(t,e){return Array.prototype.slice.call(e,0).sort(t)})),Di=c((function(t,e){return Array.prototype.slice.call(e,0).sort((function(e,n){var r=t(e),i=t(n);return r<i?-1:r>i?1:0}))})),Ni=c((function(t,e){return Array.prototype.slice.call(e,0).sort((function(e,n){for(var r=0,i=0;0===r&&i<t.length;)r=t[i](e,n),i+=1;return r}))})),Li=ur(1,"split"),Fi=c((function(t,e){return[Ht(0,t,e),Ht(t,Ar(e),e)]})),Ui=c((function(t,e){if(t<=0)throw new Error("First argument to splitEvery must be a positive integer");for(var n=[],r=0;r<e.length;)n.push(Ht(r,r+=t,e));return n})),Hi=c((function(t,e){for(var n=0,r=e.length,i=[];n<r&&!t(e[n]);)i.push(e[n]),n+=1;return[i,Array.prototype.slice.call(e,n)]})),Gi=c((function(t,e){return ue(We(t.length,e),t)})),qi=c((function(t,e){return Number(t)-Number(e)})),Ki=c((function(t,e){return _e(Le(t,e),Le(e,t))})),Yi=A((function(t,e,n){return _e(Fe(t,e,n),Fe(t,n,e))})),zi=c((function(t,e){for(var n=e.length-1;n>=0&&t(e[n]);)n-=1;return Ht(n+1,1/0,e)})),Ji=function(){function t(t,e){this.xf=e,this.f=t}return t.prototype["@@transducer/init"]=I.init,t.prototype["@@transducer/result"]=I.result,t.prototype["@@transducer/step"]=function(t,e){return this.f(e)?this.xf["@@transducer/step"](t,e):w(t)},t}(),Wi=c(v(["takeWhile"],c((function(t,e){return new Ji(t,e)})),(function(t,e){for(var n=0,r=e.length;n<r&&t(e[n]);)n+=1;return Ht(0,n,e)}))),Vi=function(){function t(t,e){this.xf=e,this.f=t}return t.prototype["@@transducer/init"]=I.init,t.prototype["@@transducer/result"]=I.result,t.prototype["@@transducer/step"]=function(t,e){return this.f(e),this.xf["@@transducer/step"](t,e)},t}(),Zi=c(v([],c((function(t,e){return new Vi(t,e)})),(function(t,e){return t(e),e})));var Xi=c((function(t,e){if(n=t,"[object RegExp]"!==Object.prototype.toString.call(n))throw new TypeError("‘test’ requires a value of type RegExp as its first argument; received "+Ee(t));var n;return Ot(t).test(e)})),$i=c((function(t,e){return ni("andThen",e),e.then(t)})),ta=ur(0,"toLowerCase"),ea=u((function(t){var e=[];for(var n in t)L(n,t)&&(e[e.length]=[n,t[n]]);return e})),na=u((function(t){var e=[];for(var n in t)e[e.length]=[n,t[n]];return e})),ra=ur(0,"toUpperCase"),ia=h(4,(function(t,e,n,r){return P(t("function"==typeof e?M(e):e),n,r)})),aa=u((function(t){for(var e=0,n=[];e<t.length;){for(var r=t[e],i=0;i<r.length;)void 0===n[i]&&(n[i]=[]),n[i].push(r[i]),i+=1;e+=1}return n})),oa=A((function(t,e,n){return"function"==typeof n["fantasy-land/traverse"]?n["fantasy-land/traverse"](e,t):ji(t,z(e,n))})),sa="\t\n\v\f\r                 \u2028\u2029\ufeff",ua=u("function"==typeof String.prototype.trim&&!sa.trim()&&"​".trim()?function(t){return t.trim()}:function(t){var e=new RegExp("^["+sa+"]["+sa+"]*"),n=new RegExp("["+sa+"]["+sa+"]*$");return t.replace(e,"").replace(n,"")}),ca=c((function(t,e){return p(t.length,(function(){try{return t.apply(this,arguments)}catch(t){return e.apply(this,l([t],arguments))}}))})),fa=u((function(t){return function(){return t(Array.prototype.slice.call(arguments,0))}})),la=u((function(t){return wt(1,t)})),pa=c((function(t,e){return h(t,(function(){for(var n,r=1,i=e,a=0;r<=t&&"function"==typeof i;)n=r===t?arguments.length:a+i.length,i=i.apply(this,Array.prototype.slice.call(arguments,a,n)),r+=1,a=n;return i}))})),da=c((function(t,e){for(var n=t(e),r=[];n&&n.length;)r[r.length]=n[0],n=t(n[1]);return r})),ha=c(Yt(Vn,l)),ya=c((function(t,e){for(var n,r=0,i=e.length,a=[];r<i;)re(t,n=e[r],a)||(a[a.length]=n),r+=1;return a})),Aa=A((function(t,e,n){return ya(t,l(e,n))})),ba=A((function(t,e,n){return t(n)?n:e(n)})),ga=Mt(Xt),ma=A((function(t,e,n){for(var r=n;!t(r);)r=e(r);return r})),va=u((function(t){var e,n=[];for(e in t)n[n.length]=t[e];return n})),wa=function(t){return{value:t,"fantasy-land/map":function(){return this}}},Ia=c((function(t,e){return t(wa)(e).value})),Ea=A((function(t,e,n){return t(n)?e(n):n})),_a=c((function(t,e){for(var n in t)if(L(n,t)&&!t[n](e[n]))return!1;return!0})),Ca=c((function(t,e){return _a(z(ue,t),e)})),ka=c((function(t,e){return ve(xn(le)(t),e)})),Ba=c((function(t,e){return Boolean(!t^!e)})),xa=c((function(t,e){for(var n,r=0,i=t.length,a=e.length,o=[];r<i;){for(n=0;n<a;)o[o.length]=[t[r],e[n]],n+=1;r+=1}return o})),Sa=c((function(t,e){for(var n=[],r=0,i=Math.min(t.length,e.length);r<i;)n[r]=[t[r],e[r]],r+=1;return n})),Qa=c((function(t,e){for(var n=0,r=Math.min(t.length,e.length),i={};n<r;)i[t[n]]=e[n],n+=1;return i})),Ma=A((function(t,e,n){for(var r=[],i=0,a=Math.min(e.length,n.length);i<a;)r[i]=t(e[i],n[i]),i+=1;return r})),Ra=u((function(t){return h(t.length,(function(){var e=arguments;return function(){return t.apply(this,e)}}))}))},function(t,e,n){"use strict";var r;n.r(e),n.d(e,"v1",(function(){return y})),n.d(e,"v3",(function(){return C})),n.d(e,"v4",(function(){return k})),n.d(e,"v5",(function(){return S})),n.d(e,"NIL",(function(){return Q})),n.d(e,"version",(function(){return M})),n.d(e,"validate",(function(){return s})),n.d(e,"stringify",(function(){return p})),n.d(e,"parse",(function(){return A}));var i=new Uint8Array(16);function a(){if(!r&&!(r="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return r(i)}var o=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;for(var s=function(t){return"string"==typeof t&&o.test(t)},u=[],c=0;c<256;++c)u.push((c+256).toString(16).substr(1));var f,l,p=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(u[t[e+0]]+u[t[e+1]]+u[t[e+2]]+u[t[e+3]]+"-"+u[t[e+4]]+u[t[e+5]]+"-"+u[t[e+6]]+u[t[e+7]]+"-"+u[t[e+8]]+u[t[e+9]]+"-"+u[t[e+10]]+u[t[e+11]]+u[t[e+12]]+u[t[e+13]]+u[t[e+14]]+u[t[e+15]]).toLowerCase();if(!s(n))throw TypeError("Stringified UUID is invalid");return n},d=0,h=0;var y=function(t,e,n){var r=e&&n||0,i=e||new Array(16),o=(t=t||{}).node||f,s=void 0!==t.clockseq?t.clockseq:l;if(null==o||null==s){var u=t.random||(t.rng||a)();null==o&&(o=f=[1|u[0],u[1],u[2],u[3],u[4],u[5]]),null==s&&(s=l=16383&(u[6]<<8|u[7]))}var c=void 0!==t.msecs?t.msecs:Date.now(),y=void 0!==t.nsecs?t.nsecs:h+1,A=c-d+(y-h)/1e4;if(A<0&&void 0===t.clockseq&&(s=s+1&16383),(A<0||c>d)&&void 0===t.nsecs&&(y=0),y>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");d=c,h=y,l=s;var b=(1e4*(268435455&(c+=122192928e5))+y)%4294967296;i[r++]=b>>>24&255,i[r++]=b>>>16&255,i[r++]=b>>>8&255,i[r++]=255&b;var g=c/4294967296*1e4&268435455;i[r++]=g>>>8&255,i[r++]=255&g,i[r++]=g>>>24&15|16,i[r++]=g>>>16&255,i[r++]=s>>>8|128,i[r++]=255&s;for(var m=0;m<6;++m)i[r+m]=o[m];return e||p(i)};var A=function(t){if(!s(t))throw TypeError("Invalid UUID");var e,n=new Uint8Array(16);return n[0]=(e=parseInt(t.slice(0,8),16))>>>24,n[1]=e>>>16&255,n[2]=e>>>8&255,n[3]=255&e,n[4]=(e=parseInt(t.slice(9,13),16))>>>8,n[5]=255&e,n[6]=(e=parseInt(t.slice(14,18),16))>>>8,n[7]=255&e,n[8]=(e=parseInt(t.slice(19,23),16))>>>8,n[9]=255&e,n[10]=(e=parseInt(t.slice(24,36),16))/1099511627776&255,n[11]=e/4294967296&255,n[12]=e>>>24&255,n[13]=e>>>16&255,n[14]=e>>>8&255,n[15]=255&e,n};var b=function(t,e,n){function r(t,r,i,a){if("string"==typeof t&&(t=function(t){t=unescape(encodeURIComponent(t));for(var e=[],n=0;n<t.length;++n)e.push(t.charCodeAt(n));return e}(t)),"string"==typeof r&&(r=A(r)),16!==r.length)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var o=new Uint8Array(16+t.length);if(o.set(r),o.set(t,r.length),(o=n(o))[6]=15&o[6]|e,o[8]=63&o[8]|128,i){a=a||0;for(var s=0;s<16;++s)i[a+s]=o[s];return i}return p(o)}try{r.name=t}catch(t){}return r.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8",r.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8",r};function g(t){return 14+(t+64>>>9<<4)+1}function m(t,e){var n=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(n>>16)<<16|65535&n}function v(t,e,n,r,i,a){return m((o=m(m(e,t),m(r,a)))<<(s=i)|o>>>32-s,n);var o,s}function w(t,e,n,r,i,a,o){return v(e&n|~e&r,t,e,i,a,o)}function I(t,e,n,r,i,a,o){return v(e&r|n&~r,t,e,i,a,o)}function E(t,e,n,r,i,a,o){return v(e^n^r,t,e,i,a,o)}function _(t,e,n,r,i,a,o){return v(n^(e|~r),t,e,i,a,o)}var C=b("v3",48,(function(t){if("string"==typeof t){var e=unescape(encodeURIComponent(t));t=new Uint8Array(e.length);for(var n=0;n<e.length;++n)t[n]=e.charCodeAt(n)}return function(t){for(var e=[],n=32*t.length,r=0;r<n;r+=8){var i=t[r>>5]>>>r%32&255,a=parseInt("0123456789abcdef".charAt(i>>>4&15)+"0123456789abcdef".charAt(15&i),16);e.push(a)}return e}(function(t,e){t[e>>5]|=128<<e%32,t[g(e)-1]=e;for(var n=1732584193,r=-271733879,i=-1732584194,a=271733878,o=0;o<t.length;o+=16){var s=n,u=r,c=i,f=a;n=w(n,r,i,a,t[o],7,-680876936),a=w(a,n,r,i,t[o+1],12,-389564586),i=w(i,a,n,r,t[o+2],17,606105819),r=w(r,i,a,n,t[o+3],22,-1044525330),n=w(n,r,i,a,t[o+4],7,-176418897),a=w(a,n,r,i,t[o+5],12,1200080426),i=w(i,a,n,r,t[o+6],17,-1473231341),r=w(r,i,a,n,t[o+7],22,-45705983),n=w(n,r,i,a,t[o+8],7,1770035416),a=w(a,n,r,i,t[o+9],12,-1958414417),i=w(i,a,n,r,t[o+10],17,-42063),r=w(r,i,a,n,t[o+11],22,-1990404162),n=w(n,r,i,a,t[o+12],7,1804603682),a=w(a,n,r,i,t[o+13],12,-40341101),i=w(i,a,n,r,t[o+14],17,-1502002290),r=w(r,i,a,n,t[o+15],22,1236535329),n=I(n,r,i,a,t[o+1],5,-165796510),a=I(a,n,r,i,t[o+6],9,-1069501632),i=I(i,a,n,r,t[o+11],14,643717713),r=I(r,i,a,n,t[o],20,-373897302),n=I(n,r,i,a,t[o+5],5,-701558691),a=I(a,n,r,i,t[o+10],9,38016083),i=I(i,a,n,r,t[o+15],14,-660478335),r=I(r,i,a,n,t[o+4],20,-405537848),n=I(n,r,i,a,t[o+9],5,568446438),a=I(a,n,r,i,t[o+14],9,-1019803690),i=I(i,a,n,r,t[o+3],14,-187363961),r=I(r,i,a,n,t[o+8],20,1163531501),n=I(n,r,i,a,t[o+13],5,-1444681467),a=I(a,n,r,i,t[o+2],9,-51403784),i=I(i,a,n,r,t[o+7],14,1735328473),r=I(r,i,a,n,t[o+12],20,-1926607734),n=E(n,r,i,a,t[o+5],4,-378558),a=E(a,n,r,i,t[o+8],11,-2022574463),i=E(i,a,n,r,t[o+11],16,1839030562),r=E(r,i,a,n,t[o+14],23,-35309556),n=E(n,r,i,a,t[o+1],4,-1530992060),a=E(a,n,r,i,t[o+4],11,1272893353),i=E(i,a,n,r,t[o+7],16,-155497632),r=E(r,i,a,n,t[o+10],23,-1094730640),n=E(n,r,i,a,t[o+13],4,681279174),a=E(a,n,r,i,t[o],11,-358537222),i=E(i,a,n,r,t[o+3],16,-722521979),r=E(r,i,a,n,t[o+6],23,76029189),n=E(n,r,i,a,t[o+9],4,-640364487),a=E(a,n,r,i,t[o+12],11,-421815835),i=E(i,a,n,r,t[o+15],16,530742520),r=E(r,i,a,n,t[o+2],23,-995338651),n=_(n,r,i,a,t[o],6,-198630844),a=_(a,n,r,i,t[o+7],10,1126891415),i=_(i,a,n,r,t[o+14],15,-1416354905),r=_(r,i,a,n,t[o+5],21,-57434055),n=_(n,r,i,a,t[o+12],6,1700485571),a=_(a,n,r,i,t[o+3],10,-1894986606),i=_(i,a,n,r,t[o+10],15,-1051523),r=_(r,i,a,n,t[o+1],21,-2054922799),n=_(n,r,i,a,t[o+8],6,1873313359),a=_(a,n,r,i,t[o+15],10,-30611744),i=_(i,a,n,r,t[o+6],15,-1560198380),r=_(r,i,a,n,t[o+13],21,1309151649),n=_(n,r,i,a,t[o+4],6,-145523070),a=_(a,n,r,i,t[o+11],10,-1120210379),i=_(i,a,n,r,t[o+2],15,718787259),r=_(r,i,a,n,t[o+9],21,-343485551),n=m(n,s),r=m(r,u),i=m(i,c),a=m(a,f)}return[n,r,i,a]}(function(t){if(0===t.length)return[];for(var e=8*t.length,n=new Uint32Array(g(e)),r=0;r<e;r+=8)n[r>>5]|=(255&t[r/8])<<r%32;return n}(t),8*t.length))}));var k=function(t,e,n){var r=(t=t||{}).random||(t.rng||a)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,e){n=n||0;for(var i=0;i<16;++i)e[n+i]=r[i];return e}return p(r)};function B(t,e,n,r){switch(t){case 0:return e&n^~e&r;case 1:return e^n^r;case 2:return e&n^e&r^n&r;case 3:return e^n^r}}function x(t,e){return t<<e|t>>>32-e}var S=b("v5",80,(function(t){var e=[1518500249,1859775393,2400959708,3395469782],n=[1732584193,4023233417,2562383102,271733878,3285377520];if("string"==typeof t){var r=unescape(encodeURIComponent(t));t=[];for(var i=0;i<r.length;++i)t.push(r.charCodeAt(i))}else Array.isArray(t)||(t=Array.prototype.slice.call(t));t.push(128);for(var a=t.length/4+2,o=Math.ceil(a/16),s=new Array(o),u=0;u<o;++u){for(var c=new Uint32Array(16),f=0;f<16;++f)c[f]=t[64*u+4*f]<<24|t[64*u+4*f+1]<<16|t[64*u+4*f+2]<<8|t[64*u+4*f+3];s[u]=c}s[o-1][14]=8*(t.length-1)/Math.pow(2,32),s[o-1][14]=Math.floor(s[o-1][14]),s[o-1][15]=8*(t.length-1)&4294967295;for(var l=0;l<o;++l){for(var p=new Uint32Array(80),d=0;d<16;++d)p[d]=s[l][d];for(var h=16;h<80;++h)p[h]=x(p[h-3]^p[h-8]^p[h-14]^p[h-16],1);for(var y=n[0],A=n[1],b=n[2],g=n[3],m=n[4],v=0;v<80;++v){var w=Math.floor(v/20),I=x(y,5)+B(w,A,b,g)+m+e[w]+p[v]>>>0;m=g,g=b,b=x(A,30)>>>0,A=y,y=I}n[0]=n[0]+y>>>0,n[1]=n[1]+A>>>0,n[2]=n[2]+b>>>0,n[3]=n[3]+g>>>0,n[4]=n[4]+m>>>0}return[n[0]>>24&255,n[0]>>16&255,n[0]>>8&255,255&n[0],n[1]>>24&255,n[1]>>16&255,n[1]>>8&255,255&n[1],n[2]>>24&255,n[2]>>16&255,n[2]>>8&255,255&n[2],n[3]>>24&255,n[3]>>16&255,n[3]>>8&255,255&n[3],n[4]>>24&255,n[4]>>16&255,n[4]>>8&255,255&n[4]]})),Q="00000000-0000-0000-0000-000000000000";var M=function(t){if(!s(t))throw TypeError("Invalid UUID");return parseInt(t.substr(14,1),16)}},function(t,e,n){"use strict";(function(t){n.d(e,"a",(function(){return c}));var r=n(0),i=n(1),a=n(210),o=new i.b(a.a);var s=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==t)return t;throw new Error("unable to locate global object")}(),u=s.crypto||s.msCrypto;function c(t){(t<=0||t>1024||t%1||t!=t)&&o.throwArgumentError("invalid length","length",t);var e=new Uint8Array(t);return u.getRandomValues(e),Object(r.a)(e)}u&&u.getRandomValues||(o.warn("WARNING: Missing strong random number source"),u={getRandomValues:function(t){return o.throwError("no secure random source avaialble",i.b.errors.UNSUPPORTED_OPERATION,{operation:"crypto.getRandomValues"})}})}).call(this,n(8))}])}));
68
+ !function(n){"use strict";var r={s:1,n:0,d:1};function i(t,e){if(isNaN(t=parseInt(t,10)))throw l();return t*e}function a(t,e){if(0===e)throw f();var n=Object.create(c.prototype);n.s=t<0?-1:1;var r=u(t=t<0?-t:t,e);return n.n=t/r,n.d=e/r,n}function o(t){for(var e={},n=t,r=2,i=4;i<=n;){for(;n%r==0;)n/=r,e[r]=(e[r]||0)+1;i+=1+2*r++}return n!==t?n>1&&(e[n]=(e[n]||0)+1):e[t]=(e[t]||0)+1,e}var s=function(t,e){var n,a=0,o=1,s=1,u=0,c=0,d=0,h=1,y=1,A=0,b=1,g=1,m=1,v=1e7;if(null==t);else if(void 0!==e){if(s=(a=t)*(o=e),a%1!=0||o%1!=0)throw p()}else switch(typeof t){case"object":if("d"in t&&"n"in t)a=t.n,o=t.d,"s"in t&&(a*=t.s);else{if(!(0 in t))throw l();a=t[0],1 in t&&(o=t[1])}s=a*o;break;case"number":if(t<0&&(s=t,t=-t),t%1==0)a=t;else if(t>0){for(t>=1&&(t/=y=Math.pow(10,Math.floor(1+Math.log(t)/Math.LN10)));b<=v&&m<=v;){if(t===(n=(A+g)/(b+m))){b+m<=v?(a=A+g,o=b+m):m>b?(a=g,o=m):(a=A,o=b);break}t>n?(A+=g,b+=m):(g+=A,m+=b),b>v?(a=g,o=m):(a=A,o=b)}a*=y}else(isNaN(t)||isNaN(e))&&(o=a=NaN);break;case"string":if(null===(b=t.match(/\d+|./g)))throw l();if("-"===b[A]?(s=-1,A++):"+"===b[A]&&A++,b.length===A+1?c=i(b[A++],s):"."===b[A+1]||"."===b[A]?("."!==b[A]&&(u=i(b[A++],s)),(++A+1===b.length||"("===b[A+1]&&")"===b[A+3]||"'"===b[A+1]&&"'"===b[A+3])&&(c=i(b[A],s),h=Math.pow(10,b[A].length),A++),("("===b[A]&&")"===b[A+2]||"'"===b[A]&&"'"===b[A+2])&&(d=i(b[A+1],s),y=Math.pow(10,b[A+1].length)-1,A+=3)):"/"===b[A+1]||":"===b[A+1]?(c=i(b[A],s),h=i(b[A+2],1),A+=3):"/"===b[A+3]&&" "===b[A+1]&&(u=i(b[A],s),c=i(b[A+2],s),h=i(b[A+4],1),A+=5),b.length<=A){s=a=d+(o=h*y)*u+y*c;break}default:throw l()}if(0===o)throw f();r.s=s<0?-1:1,r.n=Math.abs(a),r.d=Math.abs(o)};function u(t,e){if(!t)return e;if(!e)return t;for(;;){if(!(t%=e))return e;if(!(e%=t))return t}}function c(t,e){if(s(t,e),!(this instanceof c))return a(r.s*r.n,r.d);t=u(r.d,r.n),this.s=r.s,this.n=r.n/t,this.d=r.d/t}var f=function(){return new Error("Division by Zero")},l=function(){return new Error("Invalid argument")},p=function(){return new Error("Parameters must be integer")};c.prototype={s:1,n:0,d:1,abs:function(){return a(this.n,this.d)},neg:function(){return a(-this.s*this.n,this.d)},add:function(t,e){return s(t,e),a(this.s*this.n*r.d+r.s*this.d*r.n,this.d*r.d)},sub:function(t,e){return s(t,e),a(this.s*this.n*r.d-r.s*this.d*r.n,this.d*r.d)},mul:function(t,e){return s(t,e),a(this.s*r.s*this.n*r.n,this.d*r.d)},div:function(t,e){return s(t,e),a(this.s*r.s*this.n*r.d,this.d*r.n)},clone:function(){return a(this.s*this.n,this.d)},mod:function(t,e){if(isNaN(this.n)||isNaN(this.d))return new c(NaN);if(void 0===t)return a(this.s*this.n%this.d,1);if(s(t,e),0===r.n&&0===this.d)throw f();return a(this.s*(r.d*this.n)%(r.n*this.d),r.d*this.d)},gcd:function(t,e){return s(t,e),a(u(r.n,this.n)*u(r.d,this.d),r.d*this.d)},lcm:function(t,e){return s(t,e),0===r.n&&0===this.n?a(0,1):a(r.n*this.n,u(r.n,this.n)*u(r.d,this.d))},ceil:function(t){return t=Math.pow(10,t||0),isNaN(this.n)||isNaN(this.d)?new c(NaN):a(Math.ceil(t*this.s*this.n/this.d),t)},floor:function(t){return t=Math.pow(10,t||0),isNaN(this.n)||isNaN(this.d)?new c(NaN):a(Math.floor(t*this.s*this.n/this.d),t)},round:function(t){return t=Math.pow(10,t||0),isNaN(this.n)||isNaN(this.d)?new c(NaN):a(Math.round(t*this.s*this.n/this.d),t)},roundTo:function(t,e){return s(t,e),a(this.s*Math.round(this.n*r.d/(this.d*r.n))*r.n,r.d)},inverse:function(){return a(this.s*this.d,this.n)},pow:function(t,e){if(s(t,e),1===r.d)return r.s<0?a(Math.pow(this.s*this.d,r.n),Math.pow(this.n,r.n)):a(Math.pow(this.s*this.n,r.n),Math.pow(this.d,r.n));if(this.s<0)return null;var n=o(this.n),i=o(this.d),u=1,c=1;for(var f in n)if("1"!==f){if("0"===f){u=0;break}if(n[f]*=r.n,n[f]%r.d!=0)return null;n[f]/=r.d,u*=Math.pow(f,n[f])}for(var f in i)if("1"!==f){if(i[f]*=r.n,i[f]%r.d!=0)return null;i[f]/=r.d,c*=Math.pow(f,i[f])}return r.s<0?a(c,u):a(u,c)},equals:function(t,e){return s(t,e),this.s*this.n*r.d==r.s*r.n*this.d},compare:function(t,e){s(t,e);var n=this.s*this.n*r.d-r.s*r.n*this.d;return(0<n)-(n<0)},simplify:function(t){if(isNaN(this.n)||isNaN(this.d))return this;t=t||.001;for(var e=this.abs(),n=e.toContinued(),r=1;r<n.length;r++){for(var i=a(n[r-1],1),o=r-2;o>=0;o--)i=i.inverse().add(n[o]);if(Math.abs(i.sub(e).valueOf())<t)return i.mul(this.s)}return this},divisible:function(t,e){return s(t,e),!(!(r.n*this.d)||this.n*r.d%(r.n*this.d))},valueOf:function(){return this.s*this.n/this.d},toFraction:function(t){var e,n="",r=this.n,i=this.d;return this.s<0&&(n+="-"),1===i?n+=r:(t&&(e=Math.floor(r/i))>0&&(n+=e,n+=" ",r%=i),n+=r,n+="/",n+=i),n},toLatex:function(t){var e,n="",r=this.n,i=this.d;return this.s<0&&(n+="-"),1===i?n+=r:(t&&(e=Math.floor(r/i))>0&&(n+=e,r%=i),n+="\\frac{",n+=r,n+="}{",n+=i,n+="}"),n},toContinued:function(){var t,e=this.n,n=this.d,r=[];if(isNaN(e)||isNaN(n))return r;do{r.push(Math.floor(e/n)),t=e%n,e=n,n=t}while(1!==e);return r},toString:function(t){var e=this.n,n=this.d;if(isNaN(e)||isNaN(n))return"NaN";t=t||15;var r=function(t,e){for(;e%2==0;e/=2);for(;e%5==0;e/=5);if(1===e)return 0;for(var n=10%e,r=1;1!==n;r++)if(n=10*n%e,r>2e3)return 0;return r}(0,n),i=function(t,e,n){for(var r=1,i=function(t,e,n){for(var r=1;e>0;t=t*t%n,e>>=1)1&e&&(r=r*t%n);return r}(10,n,e),a=0;a<300;a++){if(r===i)return a;r=10*r%e,i=10*i%e}return 0}(0,n,r),a=this.s<0?"-":"";if(a+=e/n|0,e%=n,(e*=10)&&(a+="."),r){for(var o=i;o--;)a+=e/n|0,e%=n,e*=10;a+="(";for(o=r;o--;)a+=e/n|0,e%=n,e*=10;a+=")"}else for(o=t;e&&o--;)a+=e/n|0,e%=n,e*=10;return a}},Object.defineProperty(e,"__esModule",{value:!0}),e.default=c,t.exports=c}()},function(t,e){t.exports={drm_optional:!1,store_clear:!1,ladder_specs:{'{"media_type":"audio","channels":1}':{rung_specs:[{bit_rate:128e3,media_type:"audio",pregenerate:!0}]},'{"media_type":"audio","channels":2}':{rung_specs:[{bit_rate:128e3,media_type:"audio",pregenerate:!0}]},'{"media_type":"video","aspect_ratio_height":273,"aspect_ratio_width":640}':{rung_specs:[{bit_rate:95e5,height:1080,media_type:"video",pregenerate:!0,width:2538},{bit_rate:6e6,height:720,media_type:"video",pregenerate:!1,width:1692},{bit_rate:264e4,height:540,media_type:"video",pregenerate:!1,width:1270},{bit_rate:145e4,height:432,media_type:"video",pregenerate:!1,width:1016},{bit_rate:107e4,height:360,media_type:"video",pregenerate:!1,width:846},{bit_rate:69e4,height:360,media_type:"video",pregenerate:!1,width:846}]},'{"media_type":"video","aspect_ratio_height":267,"aspect_ratio_width":640}':{rung_specs:[{bit_rate:95e5,height:1080,media_type:"video",pregenerate:!0,width:2538},{bit_rate:6e6,height:720,media_type:"video",pregenerate:!1,width:1692},{bit_rate:264e4,height:540,media_type:"video",pregenerate:!1,width:1270},{bit_rate:145e4,height:432,media_type:"video",pregenerate:!1,width:1016},{bit_rate:107e4,height:360,media_type:"video",pregenerate:!1,width:846},{bit_rate:69e4,height:360,media_type:"video",pregenerate:!1,width:846}]},'{"media_type":"video","aspect_ratio_height":729,"aspect_ratio_width":1280}':{rung_specs:[{bit_rate:95e5,height:1080,media_type:"video",pregenerate:!0,width:1920},{bit_rate:45e5,height:720,media_type:"video",pregenerate:!1,width:1280},{bit_rate:2e6,height:540,media_type:"video",pregenerate:!1,width:960},{bit_rate:11e5,height:432,media_type:"video",pregenerate:!1,width:768},{bit_rate:81e4,height:360,media_type:"video",pregenerate:!1,width:640},{bit_rate:52e4,height:360,media_type:"video",pregenerate:!1,width:640}]},'{"media_type":"video","aspect_ratio_height":1,"aspect_ratio_width":2}':{rung_specs:[{bit_rate:95e5,height:1080,media_type:"video",pregenerate:!0,width:2160},{bit_rate:5e6,height:720,media_type:"video",pregenerate:!1,width:1440},{bit_rate:225e4,height:540,media_type:"video",pregenerate:!1,width:1080},{bit_rate:12e5,height:432,media_type:"video",pregenerate:!1,width:864},{bit_rate:91e4,height:360,media_type:"video",pregenerate:!1,width:720},{bit_rate:58e4,height:360,media_type:"video",pregenerate:!1,width:720}]},'{"media_type":"video","aspect_ratio_height":67,"aspect_ratio_width":120}':{rung_specs:[{bit_rate:95e5,height:1080,media_type:"video",pregenerate:!0,width:1920},{bit_rate:45e5,height:720,media_type:"video",pregenerate:!1,width:1280},{bit_rate:2e6,height:540,media_type:"video",pregenerate:!1,width:960},{bit_rate:11e5,height:432,media_type:"video",pregenerate:!1,width:768},{bit_rate:81e4,height:360,media_type:"video",pregenerate:!1,width:640},{bit_rate:52e4,height:360,media_type:"video",pregenerate:!1,width:640}]},'{"media_type":"video","aspect_ratio_height":539,"aspect_ratio_width":960}':{rung_specs:[{bit_rate:95e5,height:1080,media_type:"video",pregenerate:!0,width:1920},{bit_rate:45e5,height:720,media_type:"video",pregenerate:!1,width:1280},{bit_rate:2e6,height:540,media_type:"video",pregenerate:!1,width:960},{bit_rate:11e5,height:432,media_type:"video",pregenerate:!1,width:768},{bit_rate:81e4,height:360,media_type:"video",pregenerate:!1,width:640},{bit_rate:52e4,height:360,media_type:"video",pregenerate:!1,width:640}]},'{"media_type":"video","aspect_ratio_height":11,"aspect_ratio_width":15}':{rung_specs:[{bit_rate:49e5,height:1080,media_type:"video",pregenerate:!0,width:1452},{bit_rate:3375e3,height:720,media_type:"video",pregenerate:!1,width:968},{bit_rate:15e5,height:540,media_type:"video",pregenerate:!1,width:726},{bit_rate:825e3,height:432,media_type:"video",pregenerate:!1,width:580},{bit_rate:61e4,height:360,media_type:"video",pregenerate:!1,width:484},{bit_rate:39e4,height:360,media_type:"video",pregenerate:!1,width:484}]},'{"media_type":"video","aspect_ratio_height":11,"aspect_ratio_width":20}':{rung_specs:[{bit_rate:95e5,height:1080,media_type:"video",pregenerate:!0,width:1920},{bit_rate:45e5,height:720,media_type:"video",pregenerate:!1,width:1280},{bit_rate:2e6,height:540,media_type:"video",pregenerate:!1,width:960},{bit_rate:11e5,height:432,media_type:"video",pregenerate:!1,width:768},{bit_rate:81e4,height:360,media_type:"video",pregenerate:!1,width:640},{bit_rate:52e4,height:360,media_type:"video",pregenerate:!1,width:640}]},'{"media_type":"video","aspect_ratio_height":12296,"aspect_ratio_width":21851}':{rung_specs:[{bit_rate:95e5,height:1080,media_type:"video",pregenerate:!0,width:1920},{bit_rate:45e5,height:720,media_type:"video",pregenerate:!1,width:1280},{bit_rate:2e6,height:540,media_type:"video",pregenerate:!1,width:960},{bit_rate:11e5,height:432,media_type:"video",pregenerate:!1,width:768},{bit_rate:81e4,height:360,media_type:"video",pregenerate:!1,width:640},{bit_rate:52e4,height:360,media_type:"video",pregenerate:!1,width:640}]},'{"media_type":"video","aspect_ratio_height":131072,"aspect_ratio_width":192165}':{rung_specs:[{bit_rate:55e5,height:1080,media_type:"video",pregenerate:!0,width:1620},{bit_rate:24e5,height:720,media_type:"video",pregenerate:!1,width:1080},{bit_rate:14e5,height:540,media_type:"video",pregenerate:!1,width:810},{bit_rate:9e5,height:432,media_type:"video",pregenerate:!1,width:648},{bit_rate:68e4,height:360,media_type:"video",pregenerate:!1,width:540},{bit_rate:44e4,height:360,media_type:"video",pregenerate:!1,width:540}]},'{"media_type":"video","aspect_ratio_height":135,"aspect_ratio_width":176}':{rung_specs:[{bit_rate:49e5,height:1080,media_type:"video",pregenerate:!0,width:1452},{bit_rate:3375e3,height:720,media_type:"video",pregenerate:!1,width:968},{bit_rate:15e5,height:540,media_type:"video",pregenerate:!1,width:726},{bit_rate:825e3,height:432,media_type:"video",pregenerate:!1,width:580},{bit_rate:61e4,height:360,media_type:"video",pregenerate:!1,width:484},{bit_rate:39e4,height:360,media_type:"video",pregenerate:!1,width:484}]},'{"media_type":"video","aspect_ratio_height":135,"aspect_ratio_width":316}':{rung_specs:[{bit_rate:95e5,height:1080,media_type:"video",pregenerate:!0,width:2528},{bit_rate:6e6,height:720,media_type:"video",pregenerate:!1,width:1692},{bit_rate:264e4,height:540,media_type:"video",pregenerate:!1,width:1270},{bit_rate:145e4,height:432,media_type:"video",pregenerate:!1,width:1016},{bit_rate:107e4,height:360,media_type:"video",pregenerate:!1,width:846},{bit_rate:69e4,height:360,media_type:"video",pregenerate:!1,width:846}]},'{"media_type":"video","aspect_ratio_height":135,"aspect_ratio_width":76}':{rung_specs:[{bit_rate:95e5,height:1920,media_type:"video",pregenerate:!0,width:1080},{bit_rate:45e5,height:1280,media_type:"video",pregenerate:!1,width:720},{bit_rate:2e6,height:960,media_type:"video",pregenerate:!1,width:540},{bit_rate:11e5,height:768,media_type:"video",pregenerate:!1,width:432},{bit_rate:81e4,height:360,media_type:"video",pregenerate:!1,width:640},{bit_rate:52e4,height:360,media_type:"video",pregenerate:!1,width:640}]},'{"media_type":"video","aspect_ratio_height":16,"aspect_ratio_width":9}':{rung_specs:[{bit_rate:95e5,height:1920,media_type:"video",pregenerate:!0,width:1080},{bit_rate:45e5,height:1280,media_type:"video",pregenerate:!1,width:720},{bit_rate:2e6,height:960,media_type:"video",pregenerate:!1,width:540},{bit_rate:11e5,height:768,media_type:"video",pregenerate:!1,width:432},{bit_rate:81e4,height:360,media_type:"video",pregenerate:!1,width:640},{bit_rate:52e4,height:360,media_type:"video",pregenerate:!1,width:640}]},'{"media_type":"video","aspect_ratio_height":17,"aspect_ratio_width":40}':{rung_specs:[{bit_rate:95e5,height:1080,media_type:"video",pregenerate:!0,width:2538},{bit_rate:6e6,height:720,media_type:"video",pregenerate:!1,width:1692},{bit_rate:264e4,height:540,media_type:"video",pregenerate:!1,width:1270},{bit_rate:145e4,height:432,media_type:"video",pregenerate:!1,width:1016},{bit_rate:107e4,height:360,media_type:"video",pregenerate:!1,width:846},{bit_rate:69e4,height:360,media_type:"video",pregenerate:!1,width:846}]},'{"media_type":"video","aspect_ratio_height":173,"aspect_ratio_width":320}':{rung_specs:[{bit_rate:95e5,height:1036,media_type:"video",pregenerate:!0,width:1920},{bit_rate:47e5,height:720,media_type:"video",pregenerate:!1,width:1334},{bit_rate:208e4,height:540,media_type:"video",pregenerate:!1,width:1e3},{bit_rate:1145e3,height:432,media_type:"video",pregenerate:!1,width:800},{bit_rate:843e3,height:360,media_type:"video",pregenerate:!1,width:666},{bit_rate:541e3,height:360,media_type:"video",pregenerate:!1,width:666}]},'{"media_type":"video","aspect_ratio_height":2,"aspect_ratio_width":3}':{rung_specs:[{bit_rate:55e5,height:1080,media_type:"video",pregenerate:!0,width:1620},{bit_rate:24e5,height:720,media_type:"video",pregenerate:!1,width:1080},{bit_rate:14e5,height:540,media_type:"video",pregenerate:!1,width:810},{bit_rate:9e5,height:432,media_type:"video",pregenerate:!1,width:648},{bit_rate:68e4,height:360,media_type:"video",pregenerate:!1,width:540},{bit_rate:44e4,height:360,media_type:"video",pregenerate:!1,width:540}]},'{"media_type":"video","aspect_ratio_height":20,"aspect_ratio_width":27}':{rung_specs:[{bit_rate:49e5,height:1080,media_type:"video",pregenerate:!0,width:1452},{bit_rate:3375e3,height:720,media_type:"video",pregenerate:!1,width:968},{bit_rate:15e5,height:540,media_type:"video",pregenerate:!1,width:726},{bit_rate:825e3,height:432,media_type:"video",pregenerate:!1,width:580},{bit_rate:61e4,height:360,media_type:"video",pregenerate:!1,width:484},{bit_rate:39e4,height:360,media_type:"video",pregenerate:!1,width:484}]},'{"media_type":"video","aspect_ratio_height":240,"aspect_ratio_width":427}':{rung_specs:[{bit_rate:95e5,height:1080,media_type:"video",pregenerate:!0,width:1920},{bit_rate:45e5,height:720,media_type:"video",pregenerate:!1,width:1280},{bit_rate:2e6,height:540,media_type:"video",pregenerate:!1,width:960},{bit_rate:11e5,height:432,media_type:"video",pregenerate:!1,width:768},{bit_rate:81e4,height:360,media_type:"video",pregenerate:!1,width:640},{bit_rate:52e4,height:360,media_type:"video",pregenerate:!1,width:640}]},'{"media_type":"video","aspect_ratio_height":243,"aspect_ratio_width":320}':{rung_specs:[{bit_rate:49e5,height:1080,media_type:"video",pregenerate:!0,width:1452},{bit_rate:3375e3,height:720,media_type:"video",pregenerate:!1,width:968},{bit_rate:15e5,height:540,media_type:"video",pregenerate:!1,width:726},{bit_rate:825e3,height:432,media_type:"video",pregenerate:!1,width:580},{bit_rate:61e4,height:360,media_type:"video",pregenerate:!1,width:484},{bit_rate:39e4,height:360,media_type:"video",pregenerate:!1,width:484}]},'{"media_type":"video","aspect_ratio_height":259,"aspect_ratio_width":480}':{rung_specs:[{bit_rate:95e5,height:1036,media_type:"video",pregenerate:!0,width:1920},{bit_rate:47e5,height:720,media_type:"video",pregenerate:!1,width:1334},{bit_rate:208e4,height:540,media_type:"video",pregenerate:!1,width:1e3},{bit_rate:1145e3,height:432,media_type:"video",pregenerate:!1,width:800},{bit_rate:843e3,height:360,media_type:"video",pregenerate:!1,width:666},{bit_rate:541e3,height:360,media_type:"video",pregenerate:!1,width:666}]},'{"media_type":"video","aspect_ratio_height":262144,"aspect_ratio_width":319905}':{rung_specs:[{bit_rate:49e5,height:1080,media_type:"video",pregenerate:!0,width:1280},{bit_rate:3375e3,height:720,media_type:"video",pregenerate:!1,width:853},{bit_rate:15e5,height:540,media_type:"video",pregenerate:!1,width:640},{bit_rate:825e3,height:432,media_type:"video",pregenerate:!1,width:512},{bit_rate:54e4,height:360,media_type:"video",pregenerate:!1,width:426},{bit_rate:35e4,height:360,media_type:"video",pregenerate:!1,width:426}]},'{"media_type":"video","aspect_ratio_height":27,"aspect_ratio_width":32}':{rung_specs:[{bit_rate:49e5,height:1080,media_type:"video",pregenerate:!0,width:1280},{bit_rate:3375e3,height:720,media_type:"video",pregenerate:!1,width:853},{bit_rate:15e5,height:540,media_type:"video",pregenerate:!1,width:640},{bit_rate:825e3,height:432,media_type:"video",pregenerate:!1,width:512},{bit_rate:54e4,height:360,media_type:"video",pregenerate:!1,width:426},{bit_rate:35e4,height:360,media_type:"video",pregenerate:!1,width:426}]},'{"media_type":"video","aspect_ratio_height":27,"aspect_ratio_width":40}':{rung_specs:[{bit_rate:55e5,height:1080,media_type:"video",pregenerate:!0,width:1620},{bit_rate:24e5,height:720,media_type:"video",pregenerate:!1,width:1080},{bit_rate:14e5,height:540,media_type:"video",pregenerate:!1,width:810},{bit_rate:9e5,height:432,media_type:"video",pregenerate:!1,width:648},{bit_rate:68e4,height:360,media_type:"video",pregenerate:!1,width:540},{bit_rate:44e4,height:360,media_type:"video",pregenerate:!1,width:540}]},'{"media_type":"video","aspect_ratio_height":297,"aspect_ratio_width":400}':{rung_specs:[{bit_rate:49e5,height:1080,media_type:"video",pregenerate:!0,width:1452},{bit_rate:3375e3,height:720,media_type:"video",pregenerate:!1,width:968},{bit_rate:15e5,height:540,media_type:"video",pregenerate:!1,width:726},{bit_rate:825e3,height:432,media_type:"video",pregenerate:!1,width:580},{bit_rate:61e4,height:360,media_type:"video",pregenerate:!1,width:484},{bit_rate:39e4,height:360,media_type:"video",pregenerate:!1,width:484}]},'{"media_type":"video","aspect_ratio_height":3,"aspect_ratio_width":4}':{rung_specs:[{bit_rate:49e5,height:1080,media_type:"video",pregenerate:!0,width:1452},{bit_rate:3375e3,height:720,media_type:"video",pregenerate:!1,width:968},{bit_rate:15e5,height:540,media_type:"video",pregenerate:!1,width:726},{bit_rate:825e3,height:432,media_type:"video",pregenerate:!1,width:580},{bit_rate:61e4,height:360,media_type:"video",pregenerate:!1,width:484},{bit_rate:39e4,height:360,media_type:"video",pregenerate:!1,width:484}]},'{"media_type":"video","aspect_ratio_height":30,"aspect_ratio_width":53}':{rung_specs:[{bit_rate:95e5,height:1080,media_type:"video",pregenerate:!0,width:1920},{bit_rate:45e5,height:720,media_type:"video",pregenerate:!1,width:1280},{bit_rate:2e6,height:540,media_type:"video",pregenerate:!1,width:960},{bit_rate:11e5,height:432,media_type:"video",pregenerate:!1,width:768},{bit_rate:81e4,height:360,media_type:"video",pregenerate:!1,width:640},{bit_rate:52e4,height:360,media_type:"video",pregenerate:!1,width:640}]},'{"media_type":"video","aspect_ratio_height":40,"aspect_ratio_width":71}':{rung_specs:[{bit_rate:95e5,height:1080,media_type:"video",pregenerate:!0,width:1920},{bit_rate:45e5,height:720,media_type:"video",pregenerate:!1,width:1280},{bit_rate:2e6,height:540,media_type:"video",pregenerate:!1,width:960},{bit_rate:11e5,height:432,media_type:"video",pregenerate:!1,width:768},{bit_rate:81e4,height:360,media_type:"video",pregenerate:!1,width:640},{bit_rate:52e4,height:360,media_type:"video",pregenerate:!1,width:640}]},'{"media_type":"video","aspect_ratio_height":429,"aspect_ratio_width":1024}':{rung_specs:[{bit_rate:95e5,height:1080,media_type:"video",pregenerate:!0,width:2538},{bit_rate:6e6,height:720,media_type:"video",pregenerate:!1,width:1692},{bit_rate:264e4,height:540,media_type:"video",pregenerate:!1,width:1270},{bit_rate:145e4,height:432,media_type:"video",pregenerate:!1,width:1016},{bit_rate:107e4,height:360,media_type:"video",pregenerate:!1,width:846},{bit_rate:69e4,height:360,media_type:"video",pregenerate:!1,width:846}]},'{"media_type":"video","aspect_ratio_height":466577,"aspect_ratio_width":912058}':{rung_specs:[{bit_rate:95e5,height:1036,media_type:"video",pregenerate:!0,width:1920},{bit_rate:47e5,height:720,media_type:"video",pregenerate:!1,width:1334},{bit_rate:208e4,height:540,media_type:"video",pregenerate:!1,width:1e3},{bit_rate:1145e3,height:432,media_type:"video",pregenerate:!1,width:800},{bit_rate:843e3,height:360,media_type:"video",pregenerate:!1,width:666},{bit_rate:541e3,height:360,media_type:"video",pregenerate:!1,width:666}]},'{"media_type":"video","aspect_ratio_height":480,"aspect_ratio_width":853}':{rung_specs:[{bit_rate:95e5,height:1080,media_type:"video",pregenerate:!0,width:1920},{bit_rate:45e5,height:720,media_type:"video",pregenerate:!1,width:1280},{bit_rate:2e6,height:540,media_type:"video",pregenerate:!1,width:960},{bit_rate:11e5,height:432,media_type:"video",pregenerate:!1,width:768},{bit_rate:81e4,height:360,media_type:"video",pregenerate:!1,width:640},{bit_rate:52e4,height:360,media_type:"video",pregenerate:!1,width:640}]},'{"media_type":"video","aspect_ratio_height":486,"aspect_ratio_width":853}':{rung_specs:[{bit_rate:95e5,height:1080,media_type:"video",pregenerate:!0,width:1920},{bit_rate:45e5,height:720,media_type:"video",pregenerate:!1,width:1280},{bit_rate:2e6,height:540,media_type:"video",pregenerate:!1,width:960},{bit_rate:11e5,height:432,media_type:"video",pregenerate:!1,width:768},{bit_rate:81e4,height:360,media_type:"video",pregenerate:!1,width:640},{bit_rate:52e4,height:360,media_type:"video",pregenerate:!1,width:640}]},'{"media_type":"video","aspect_ratio_height":5,"aspect_ratio_width":12}':{rung_specs:[{bit_rate:95e5,height:1080,media_type:"video",pregenerate:!0,width:2538},{bit_rate:6e6,height:720,media_type:"video",pregenerate:!1,width:1692},{bit_rate:264e4,height:540,media_type:"video",pregenerate:!1,width:1270},{bit_rate:145e4,height:432,media_type:"video",pregenerate:!1,width:1016},{bit_rate:107e4,height:360,media_type:"video",pregenerate:!1,width:846},{bit_rate:69e4,height:360,media_type:"video",pregenerate:!1,width:846}]},'{"media_type":"video","aspect_ratio_height":582543,"aspect_ratio_width":776720}':{rung_specs:[{bit_rate:49e5,height:1080,media_type:"video",pregenerate:!0,width:1452},{bit_rate:3375e3,height:720,media_type:"video",pregenerate:!1,width:968},{bit_rate:15e5,height:540,media_type:"video",pregenerate:!1,width:726},{bit_rate:825e3,height:432,media_type:"video",pregenerate:!1,width:580},{bit_rate:61e4,height:360,media_type:"video",pregenerate:!1,width:484},{bit_rate:39e4,height:360,media_type:"video",pregenerate:!1,width:484}]},'{"media_type":"video","aspect_ratio_height":639,"aspect_ratio_width":889}':{rung_specs:[{bit_rate:49e5,height:1080,media_type:"video",pregenerate:!0,width:1452},{bit_rate:3375e3,height:720,media_type:"video",pregenerate:!1,width:968},{bit_rate:15e5,height:540,media_type:"video",pregenerate:!1,width:726},{bit_rate:825e3,height:432,media_type:"video",pregenerate:!1,width:580},{bit_rate:61e4,height:360,media_type:"video",pregenerate:!1,width:484},{bit_rate:39e4,height:360,media_type:"video",pregenerate:!1,width:484}]},'{"media_type":"video","aspect_ratio_height":65536,"aspect_ratio_width":87381}':{rung_specs:[{bit_rate:49e5,height:1080,media_type:"video",pregenerate:!0,width:1452},{bit_rate:3375e3,height:720,media_type:"video",pregenerate:!1,width:968},{bit_rate:15e5,height:540,media_type:"video",pregenerate:!1,width:726},{bit_rate:825e3,height:432,media_type:"video",pregenerate:!1,width:580},{bit_rate:61e4,height:360,media_type:"video",pregenerate:!1,width:484},{bit_rate:39e4,height:360,media_type:"video",pregenerate:!1,width:484}]},'{"media_type":"video","aspect_ratio_height":81,"aspect_ratio_width":128}':{rung_specs:[{bit_rate:55e5,height:1080,media_type:"video",pregenerate:!0,width:1620},{bit_rate:24e5,height:720,media_type:"video",pregenerate:!1,width:1080},{bit_rate:14e5,height:540,media_type:"video",pregenerate:!1,width:810},{bit_rate:9e5,height:432,media_type:"video",pregenerate:!1,width:648},{bit_rate:68e4,height:360,media_type:"video",pregenerate:!1,width:540},{bit_rate:44e4,height:360,media_type:"video",pregenerate:!1,width:540}]},'{"media_type":"video","aspect_ratio_height":8192,"aspect_ratio_width":12015}':{rung_specs:[{bit_rate:55e5,height:1080,media_type:"video",pregenerate:!0,width:1620},{bit_rate:24e5,height:720,media_type:"video",pregenerate:!1,width:1080},{bit_rate:14e5,height:540,media_type:"video",pregenerate:!1,width:810},{bit_rate:9e5,height:432,media_type:"video",pregenerate:!1,width:648},{bit_rate:68e4,height:360,media_type:"video",pregenerate:!1,width:540},{bit_rate:44e4,height:360,media_type:"video",pregenerate:!1,width:540}]},'{"media_type":"video","aspect_ratio_height":891,"aspect_ratio_width":1600}':{rung_specs:[{bit_rate:95e5,height:1080,media_type:"video",pregenerate:!0,width:1920},{bit_rate:45e5,height:720,media_type:"video",pregenerate:!1,width:1280},{bit_rate:2e6,height:540,media_type:"video",pregenerate:!1,width:960},{bit_rate:11e5,height:432,media_type:"video",pregenerate:!1,width:768},{bit_rate:81e4,height:360,media_type:"video",pregenerate:!1,width:640},{bit_rate:52e4,height:360,media_type:"video",pregenerate:!1,width:640}]},'{"media_type":"video","aspect_ratio_height":9,"aspect_ratio_width":16}':{rung_specs:[{bit_rate:95e5,height:1080,media_type:"video",pregenerate:!0,width:1920},{bit_rate:45e5,height:720,media_type:"video",pregenerate:!1,width:1280},{bit_rate:2e6,height:540,media_type:"video",pregenerate:!1,width:960},{bit_rate:11e5,height:432,media_type:"video",pregenerate:!1,width:768},{bit_rate:81e4,height:360,media_type:"video",pregenerate:!1,width:640},{bit_rate:52e4,height:360,media_type:"video",pregenerate:!1,width:640}]}},playout_formats:{"hls-fairplay":{drm:{enc_scheme_name:"cbcs",license_servers:[],type:"DrmFairplay"},protocol:{type:"ProtoHls"}},"hls-sample-aes":{drm:{enc_scheme_name:"cbcs",type:"DrmSampleAes"},protocol:{type:"ProtoHls"}},"hls-aes128":{drm:{enc_scheme_name:"aes-128",type:"DrmAes128"},protocol:{type:"ProtoHls"}}},segment_specs:{audio:{segs_per_chunk:15,target_dur:2},video:{segs_per_chunk:15,target_dur:2}}}},function(t,e,n){(function(t){var r=n(18),i=n(17),a=n(9),o=n(10);function s(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 u(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?s(Object(n),!0).forEach((function(e){i(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):s(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}var c=n(30),f=n(35),l=n(83),p=n(31),d=p.ValidateLibrary,h=p.ValidateObject,y=p.ValidateVersion,A=p.ValidateWriteToken,b=p.ValidateParameters,g=p.ValidatePresence;e.SetVisibility=function(){var t=o(a.mark((function t(e){var n,r,i;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.id,r=e.visibility,this.Log("Setting visibility ".concat(r," on ").concat(n)),t.next=4,this.authClient.ContractHasMethod({contractAddress:this.utils.HashToAddress(n),methodName:"setVisibility"});case 4:if(t.sent){t.next=7;break}return t.abrupt("return");case 7:return t.next=9,this.CallContractMethodAndWait({contractAddress:this.utils.HashToAddress(n),methodName:"setVisibility",methodArgs:[r]});case 9:return i=t.sent,t.next=12,new Promise((function(t){return setTimeout(t,5e3)}));case 12:return t.abrupt("return",i);case 13:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.SetPermission=function(){var t=o(a.mark((function t(e){var n,r,i,s,u,c,f,l,p,d,y=this;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.objectId,r=e.permission,i=e.writeToken,h(n),g("permission",r),s=this.permissionLevels[r]){t.next=6;break}throw Error("Unknown permission level: "+r);case 6:return t.next=8,this.AccessType({id:n});case 8:if(t.t0=t.sent,t.t1=this.authClient.ACCESS_TYPES.OBJECT,t.t0===t.t1){t.next=12;break}throw Error("Permission only valid for normal content objects: "+n);case 12:return u=s.settings,t.next=15,this.ContentObjectLibraryId({objectId:n});case 15:return c=t.sent,t.next=18,this.SetVisibility({id:n,visibility:u.visibility});case 18:return t.next=20,this.CallContractMethod({contractAddress:this.utils.HashToAddress(n),methodName:"statusCode"});case 20:if(t.sent===u.statusCode){t.next=29;break}if(!(u.statusCode<0)){t.next=27;break}return t.next=25,this.CallContractMethod({contractAddress:this.utils.HashToAddress(n),methodName:"setStatusCode",methodArgs:[-1]});case 25:t.next=29;break;case 27:return t.next=29,this.CallContractMethod({contractAddress:this.utils.HashToAddress(n),methodName:"publish"});case 29:return t.next=31,this.CallContractMethod({contractAddress:this.utils.HashToAddress(n),methodName:"addressKMS"});case 31:return f=t.sent,l="eluv.caps.ikms".concat(this.utils.AddressToHash(f)),t.next=35,this.ContentObjectMetadata({libraryId:c,objectId:n,metadataSubtree:l});case 35:if(!(p=t.sent)||u.kmsConk){t.next=41;break}return t.next=39,this.EditAndFinalizeContentObject({libraryId:c,objectId:n,commitMessage:"Remove encryption conk",callback:function(){var t=o(a.mark((function t(e){var r;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.writeToken,t.next=3,y.DeleteMetadata({libraryId:c,objectId:n,writeToken:r,metadataSubtree:l});case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()});case 39:t.next=52;break;case 41:if(p||!u.kmsConk){t.next=52;break}if(d=!i,i){t.next=47;break}return t.next=46,this.EditContentObject({libraryId:c,objectId:n});case 46:i=t.sent.writeToken;case 47:return t.next=49,this.CreateEncryptionConk({libraryId:c,objectId:n,writeToken:i,createKMSConk:!0});case 49:if(!d){t.next=52;break}return t.next=52,this.FinalizeContentObject({libraryId:c,objectId:n,writeToken:i,commitMessage:"Set permissions to ".concat(r)});case 52:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.CreateContentType=function(){var t=o(a.mark((function t(e){var n,r,i,o,s,f,l,p,d,h,y,A,b;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.name,r=e.metadata,i=void 0===r?{}:r,o=e.bitcode,this.Log("Creating content type: ".concat(n)),i.name=n,i.public=u({name:n},i.public||{}),t.next=6,this.authClient.CreateContentType();case 6:return s=t.sent,f=s.contractAddress,l=this.utils.AddressToObjectId(f),t.next=11,this.SetVisibility({id:l,visibility:1});case 11:return p=c("qlibs",this.contentSpaceLibraryId,"qid",l),this.Log("Created type: ".concat(f," ").concat(l)),t.t0=this.HttpClient,t.next=16,this.authClient.AuthorizationHeader({libraryId:this.contentSpaceLibraryId,objectId:l,update:!0});case 16:return t.t1=t.sent,t.t2=p,t.t3={headers:t.t1,method:"POST",path:t.t2},t.next=21,t.t0.Request.call(t.t0,t.t3);case 21:return d=t.sent,h=new URL(d.url).origin,t.next=25,this.utils.ResponseToJson(d);case 25:return y=t.sent,this.RecordWriteToken({writeToken:y.write_token,fabricNodeUrl:h}),t.next=29,this.ReplaceMetadata({libraryId:this.contentSpaceLibraryId,objectId:l,writeToken:y.write_token,metadata:i});case 29:if(!o){t.next=35;break}return t.next=32,this.UploadPart({libraryId:this.contentSpaceLibraryId,objectId:l,writeToken:y.write_token,data:o,encrypted:!1});case 32:return A=t.sent,t.next=35,this.ReplaceMetadata({libraryId:this.contentSpaceLibraryId,objectId:l,writeToken:y.write_token,metadataSubtree:"bitcode_part",metadata:A.part.hash});case 35:return t.next=37,this.FinalizeContentObject({libraryId:this.contentSpaceLibraryId,objectId:l,writeToken:y.write_token,commitMessage:"Create content type"});case 37:return t.next=39,this.userProfileClient.TenantContractId();case 39:if(!(b=t.sent)){t.next=44;break}return t.next=43,this.SetTenantContractId({contractAddress:f,tenantContractId:b});case 43:this.Log("tenant_contract_id set for ".concat(l));case 44:return t.abrupt("return",l);case 45:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.CreateContentLibrary=function(){var t=o(a.mark((function t(e){var n,r,i,o,s,c,f,l,p,d,h,y,A;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.name,r=e.description,i=e.image,o=e.imageName,s=e.metadata,c=void 0===s?{}:s,f=e.kmsId,l=e.tenantContractId,f){t.next=9;break}return t.t0="ikms",t.t1=this.utils,t.next=6,this.DefaultKMSAddress();case 6:t.t2=t.sent,t.t3=t.t1.AddressToHash.call(t.t1,t.t2),f=t.t0.concat.call(t.t0,t.t3);case 9:return this.Log("Creating content library"),this.Log("KMS ID: ".concat(f)),t.next=13,this.authClient.CreateContentLibrary({kmsId:f});case 13:return p=t.sent,d=p.contractAddress,c=u(u({},c),{},{name:n,description:r,public:{name:n,description:r}}),h=this.utils.AddressToLibraryId(d),this.Log("Library ID: ".concat(h)),this.Log("Contract address: ".concat(d)),y=h.replace("ilib","iq__"),t.next=22,this.EditContentObject({libraryId:h,objectId:y});case 22:return A=t.sent,t.next=25,this.ReplaceMetadata({libraryId:h,objectId:y,metadata:c,writeToken:A.write_token});case 25:return t.next=27,this.FinalizeContentObject({libraryId:h,objectId:y,writeToken:A.write_token,commitMessage:"Create library"});case 27:if(!i){t.next=30;break}return t.next=30,this.SetContentLibraryImage({libraryId:h,image:i,imageName:o});case 30:if(l){t.next=34;break}return t.next=33,this.userProfileClient.TenantContractId();case 33:l=t.sent;case 34:if(!l){t.next=38;break}return t.next=37,this.SetTenantContractId({contractAddress:d,tenantContractId:l});case 37:this.Log("tenant_contract_id set for ".concat(d));case 38:return this.Log("Library ".concat(h," created")),t.abrupt("return",h);case 40:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.SetContentLibraryImage=function(){var t=o(a.mark((function t(e){var n,r,i,o,s;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.writeToken,i=e.image,o=e.imageName,d(n),s=n.replace("ilib","iq__"),t.abrupt("return",this.SetContentObjectImage({libraryId:n,objectId:s,writeToken:r,image:i,imageName:o}));case 4:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.SetContentObjectImage=function(){var t=o(a.mark((function t(e){var n,i,o,s,u,c,f;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,i=e.objectId,o=e.writeToken,s=e.image,u=e.imageName,c=e.imagePath,f=void 0===c?"public/display_image":c,b({libraryId:n,objectId:i}),A(o),g("image",s),u=u||"display_image","object"!==r(s)){t.next=9;break}return t.next=8,new Response(s).arrayBuffer();case 8:s=t.sent;case 9:return t.next=11,this.UploadFiles({libraryId:n,objectId:i,writeToken:o,encrypted:!1,fileInfo:[{path:u,mime_type:"image/*",size:s.size||s.length||s.byteLength,data:s}]});case 11:return t.next=13,this.ReplaceMetadata({libraryId:n,objectId:i,writeToken:o,metadataSubtree:f,metadata:{"/":"./files/".concat(u)}});case 13:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.DeleteContentLibrary=function(){var t=o(a.mark((function t(e){var n,r;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:throw n=e.libraryId,Error("Not supported");case 6:return r=t.sent,t.next=9,this.CallContractMethodAndWait({contractAddress:this.utils.HashToAddress(n),methodName:"kill",methodArgs:[]});case 9:return t.next=11,this.HttpClient.Request({headers:r,method:"DELETE",path:void 0});case 11:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.AddLibraryContentType=function(){var t=o(a.mark((function t(e){var n,r,i,o,s,u,c,f;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.typeId,i=e.typeName,o=e.typeHash,s=e.customContractAddress,d(n),this.Log("Adding library content type to ".concat(n,": ").concat(r||o||i)),o&&(r=this.utils.DecodeVersionHash(o).objectId),r){t.next=9;break}return t.next=7,this.ContentType({name:i});case 7:u=t.sent,r=u.id;case 9:return this.Log("Type ID: ".concat(r)),c=this.utils.HashToAddress(r),s=s||this.utils.nullAddress,t.next=14,this.ethClient.CallContractMethodAndWait({contractAddress:this.utils.HashToAddress(n),methodName:"addContentType",methodArgs:[c,s]});case 14:return f=t.sent,t.abrupt("return",f.transactionHash);case 16:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.RemoveLibraryContentType=function(){var t=o(a.mark((function t(e){var n,r,i,o,s,u,c;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.typeId,i=e.typeName,o=e.typeHash,d(n),this.Log("Removing library content type from ".concat(n,": ").concat(r||o||i)),o&&(r=this.utils.DecodeVersionHash(o).objectId),r){t.next=9;break}return t.next=7,this.ContentType({name:i});case 7:s=t.sent,r=s.id;case 9:return this.Log("Type ID: ".concat(r)),u=this.utils.HashToAddress(r),t.next=13,this.ethClient.CallContractMethodAndWait({contractAddress:this.utils.HashToAddress(n),methodName:"removeContentType",methodArgs:[u]});case 13:return c=t.sent,t.abrupt("return",c.transactionHash);case 15:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.CreateContentObject=function(){var t=o(a.mark((function t(e){var n,r,i,o,s,u,f,l,p,y,A,b,g;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,i=e.options,o=void 0===i?{}:i,d(n),r&&h(r),this.Log("Creating content object: ".concat(n," ").concat(r||"")),!o.type){t.next=26;break}if(this.Log("Type specified: ".concat(o.type)),!(u=o.type).startsWith("hq__")){t.next=13;break}return t.next=10,this.ContentType({versionHash:u});case 10:u=t.sent,t.next=22;break;case 13:if(!u.startsWith("iq__")){t.next=19;break}return t.next=16,this.ContentType({typeId:u});case 16:u=t.sent,t.next=22;break;case 19:return t.next=21,this.ContentType({name:u});case 21:u=t.sent;case 22:if(u){t.next=24;break}throw Error("Unable to find content type '".concat(o.type,"'"));case 24:s=u.id,o.type=u.hash;case 26:if(r){t.next=44;break}return t.next=29,this.CurrentAccountAddress();case 29:return f=t.sent,t.next=32,this.CallContractMethod({contractAddress:this.utils.HashToAddress(n),methodName:"canContribute",methodArgs:[f]});case 32:if(t.sent){t.next=35;break}throw Error("Current user does not have permission to create content in library ".concat(n));case 35:return this.Log("Deploying contract..."),t.next=38,this.authClient.CreateContentObject({libraryId:n,typeId:s});case 38:l=t.sent,p=l.contractAddress,r=this.utils.AddressToObjectId(p),this.Log("Contract deployed: ".concat(p," ").concat(r)),t.next=51;break;case 44:return t.t0=this,t.t1="Contract already deployed for contract type: ",t.next=48,this.AccessType({id:r});case 48:t.t2=t.sent,t.t3=t.t1.concat.call(t.t1,t.t2),t.t0.Log.call(t.t0,t.t3);case 51:if(!o.visibility){t.next=55;break}return this.Log("Setting visibility to ".concat(o.visibility)),t.next=55,this.SetVisibility({id:r,visibility:o.visibility});case 55:return y=c("qid",r),t.t4=this.HttpClient,t.next=59,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,update:!0});case 59:return t.t5=t.sent,t.t6=y,t.t7=o,t.t8={headers:t.t5,method:"POST",path:t.t6,body:t.t7},t.next=65,t.t4.Request.call(t.t4,t.t8);case 65:return A=t.sent,b=new URL(A.url).origin,t.next=69,this.utils.ResponseToJson(A);case 69:return g=t.sent,this.RecordWriteToken({writeToken:g.write_token,fabricNodeUrl:b}),g.writeToken=g.write_token,g.objectId=g.id,g.nodeUrl=b,t.abrupt("return",g);case 75:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.CopyContentObject=function(){var t=o(a.mark((function t(e){var n,r,i,s,u,c,f,l,p,h,A,b,g=this;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.originalVersionHash,i=e.options,s=void 0===i?{}:i,d(n),y(r),s.copy_from=r,t.next=6,this.CreateContentObject({libraryId:n,options:s});case 6:return u=t.sent,c=u.objectId,f=u.writeToken,l=this.utils.DecodeVersionHash(r).objectId,t.next=12,this.ContentObjectMetadata({versionHash:r});case 12:return p=t.sent,t.next=15,this.Permission({objectId:l});case 15:if(h=t.sent,A="eluv.caps.iusr".concat(this.utils.AddressToHash(this.signer.address)),!p[A]){t.next=33;break}return t.next=20,this.Crypto.DecryptCap(p[A],this.signer._signingKey().privateKey);case 20:return(b=t.sent).qid=c,t.t0=this,t.t1=n,t.t2=c,t.t3=f,t.t4=A,t.next=29,this.Crypto.EncryptConk(b,this.signer._signingKey().publicKey);case 29:return t.t5=t.sent,t.t6={libraryId:t.t1,objectId:t.t2,writeToken:t.t3,metadataSubtree:t.t4,metadata:t.t5},t.next=33,t.t0.ReplaceMetadata.call(t.t0,t.t6);case 33:return t.next=35,Promise.all(Object.keys(p).filter((function(t){return t.startsWith("eluv.caps.ikms")})).map(function(){var t=o(a.mark((function t(e){return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,g.DeleteMetadata({libraryId:n,objectId:c,writeToken:f,metadataSubtree:e});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()));case 35:if("owner"===h){t.next=38;break}return t.next=38,this.CreateEncryptionConk({libraryId:n,objectId:c,writeToken:f,createKMSConk:!0});case 38:return t.next=40,this.FinalizeContentObject({libraryId:n,objectId:c,writeToken:f});case 40:return t.abrupt("return",t.sent);case 41:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.CreateNonOwnerCap=function(){var t=o(a.mark((function t(e){var n,r,i,o,s,u,c,f,l,p,d;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.objectId,r=e.libraryId,i=e.publicKey,o=e.writeToken,s="eluv.caps.iusr".concat(this.utils.AddressToHash(this.signer.address)),t.next=4,this.ContentObjectMetadata({objectId:n,libraryId:r,metadataSubtree:s});case 4:if(u=t.sent){t.next=7;break}throw Error("No user cap found for current user");case 7:return t.next=9,this.Crypto.DecryptCap(u,this.signer._signingKey().privateKey);case 9:return c=t.sent,f=this.utils.PublicKeyToAddress(i),l="eluv.caps.iusr".concat(this.utils.AddressToHash(f)),t.next=14,this.Crypto.EncryptConk(c,i);case 14:if(p=t.sent,d=!o,o){t.next=20;break}return t.next=19,this.EditContentObject({libraryId:r,objectId:n}).writeToken;case 19:o=t.sent;case 20:if(this.ReplaceMetadata({libraryId:r,objectId:n,writeToken:o,metadataSubtree:l,metadata:p}),!d){t.next=24;break}return t.next=24,this.FinalizeContentObject({libraryId:r,objectId:n,writeToken:o,commitMessage:"Create non-owner cap"});case 24:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.EditContentObject=function(){var t=o(a.mark((function t(e){var n,r,i,o,s,u,f,l;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.libraryId,r=e.objectId,i=e.options,o=void 0===i?{}:i,b({libraryId:n,objectId:r}),this.Log("Opening content draft: ".concat(n," ").concat(r)),!("type"in o)||!o.type){t.next=23;break}if(!o.type.startsWith("hq__")){t.next=10;break}return t.next=7,this.ContentType({versionHash:o.type});case 7:o.type=t.sent.hash,t.next=23;break;case 10:if(!o.type.startsWith("iq__")){t.next=16;break}return t.next=13,this.ContentType({typeId:o.type});case 13:o.type=t.sent.hash,t.next=23;break;case 16:if(!o.type){t.next=22;break}return t.next=19,this.ContentType({name:o.type});case 19:o.type=t.sent.hash,t.next=23;break;case 22:o.type="";case 23:return s=c("qid",r),t.t0=this.HttpClient,t.next=27,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,update:!0});case 27:return t.t1=t.sent,t.t2=s,t.t3=o,t.t4={headers:t.t1,method:"POST",path:t.t2,body:t.t3},t.next=33,t.t0.Request.call(t.t0,t.t4);case 33:return u=t.sent,f=new URL(u.url).origin,t.next=37,this.utils.ResponseToJson(u);case 37:return l=t.sent,this.RecordWriteToken({writeToken:l.write_token,fabricNodeUrl:f}),l.writeToken=l.write_token,l.objectId=l.id,l.nodeUrl=f,t.abrupt("return",l);case 43:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.CreateAndFinalizeContentObject=function(){var t=o(a.mark((function t(e){var n,r,i,o,s,u,c,f,l,p,d,h,y;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.callback,i=e.options,o=void 0===i?{}:i,s=e.commitMessage,u=void 0===s?"":s,c=e.publish,f=void 0===c||c,l=e.awaitCommitConfirmation,p=void 0===l||l,t.next=3,this.CreateContentObject({libraryId:n,options:o});case 3:if(d=t.sent,h=d.id,y=d.writeToken,!r){t.next=8;break}return t.next=8,r({objectId:h,writeToken:y});case 8:return t.next=10,this.FinalizeContentObject({libraryId:n,objectId:h,writeToken:y,commitMessage:u,publish:f,awaitCommitConfirmation:p});case 10:return t.abrupt("return",t.sent);case 11:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.EditAndFinalizeContentObject=function(){var t=o(a.mark((function t(e){var n,r,i,o,s,u,c,f,l,p,d,h,y;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.callback,o=e.options,s=void 0===o?{}:o,u=e.commitMessage,c=void 0===u?"":u,f=e.publish,l=void 0===f||f,p=e.awaitCommitConfirmation,d=void 0===p||p,t.next=3,this.EditContentObject({libraryId:n,objectId:r,options:s});case 3:if(h=t.sent,y=h.writeToken,!i){t.next=8;break}return t.next=8,i({writeToken:y});case 8:return t.next=10,this.FinalizeContentObject({libraryId:n,objectId:r,writeToken:y,commitMessage:c,publish:l,awaitCommitConfirmation:d});case 10:return t.abrupt("return",t.sent);case 11:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.AwaitPending=function(){var t=o(a.mark((function t(e){var n,r,i,s,u=this;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=function(){var t=o(a.mark((function t(){return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,u.CallContractMethod({contractAddress:u.utils.HashToAddress(e),methodName:"pendingHash"});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),this.Log("Checking for pending commit"),t.next=4,n();case 4:if(t.sent){t.next=7;break}return t.abrupt("return");case 7:return t.next=9,this.authClient.AccessType(e);case 9:t.t0=t.sent,t.t1=this.authClient.ACCESS_TYPES.WALLET,r=t.t0===t.t1,i=r?3:10,this.Log("Waiting for pending commit to clear for ".concat(e)),s=0;case 15:if(!(s<i)){t.next=25;break}return t.next=18,new Promise((function(t){return setTimeout(t,1e3)}));case 18:return t.next=20,n();case 20:if(t.sent){t.next=22;break}return t.abrupt("return");case 22:s++,t.next=15;break;case 25:if(!r){t.next=31;break}return this.Log("Clearing stuck wallet commit",!0),t.next=29,this.CallContractMethodAndWait({contractAddress:this.utils.HashToAddress(e),methodName:"clearPending"});case 29:t.next=32;break;case 31:throw Error("Unable to finalize ".concat(e," - Another commit is pending"));case 32:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.FinalizeContentObject=function(){var t=o(a.mark((function t(e){var n,r,i,o,s,u,f,l,p,d,h;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.writeToken,o=e.commitMessage,s=void 0===o?"":o,u=e.publish,f=void 0===u||u,l=e.awaitCommitConfirmation,p=void 0===l||l,b({libraryId:n,objectId:r}),A(i),t.t0=this,t.t1=n,t.t2=r,t.t3=i,t.t4=s,t.next=10,this.userProfileClient.UserMetadata({metadataSubtree:"public/name"});case 10:if(t.t5=t.sent,t.t5){t.next=13;break}t.t5=this.CurrentAccountAddress();case 13:return t.t6=t.t5,t.t7=this.CurrentAccountAddress(),t.t8=(new Date).toISOString(),t.t9={message:t.t4,author:t.t6,author_address:t.t7,timestamp:t.t8},t.t10={libraryId:t.t1,objectId:t.t2,writeToken:t.t3,metadataSubtree:"commit",metadata:t.t9},t.next=20,t.t0.ReplaceMetadata.call(t.t0,t.t10);case 20:return this.Log("Finalizing content draft: ".concat(n," ").concat(r," ").concat(i)),t.next=23,this.AwaitPending(r);case 23:return d=c("q",i),t.t11=this.utils,t.t12=this.HttpClient,t.next=28,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,update:!0});case 28:return t.t13=t.sent,t.t14=d,t.t15={headers:t.t13,method:"POST",path:t.t14,allowFailover:!1},t.t16=t.t12.Request.call(t.t12,t.t15),t.next=34,t.t11.ResponseToJson.call(t.t11,t.t16);case 34:if(h=t.sent,this.Log("Finalized: ".concat(h.hash)),!f){t.next=39;break}return t.next=39,this.PublishContentVersion({objectId:r,versionHash:h.hash,awaitCommitConfirmation:p});case 39:return delete this.contentTypes[r],t.abrupt("return",h);case 41:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.PublishContentVersion=function(){var t=o(a.mark((function t(e){var n,r,i,o,s,u,c,f,l,p,d,A,b;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.objectId,r=e.versionHash,i=e.awaitCommitConfirmation,o=void 0===i||i,r?y(r):h(n),this.Log("Publishing: ".concat(n||r)),r&&(n=this.utils.DecodeVersionHash(r).objectId),t.next=6,this.ethClient.CommitContent({contentObjectAddress:this.utils.HashToAddress(n),versionHash:r,signer:this.signer});case 6:return s=t.sent,t.next=9,this.ContractAbi({id:n});case 9:return u=t.sent,c=s.blockNumber+1,t.next=13,this.ExtractValueFromEvent({abi:u,event:s,eventName:"CommitPending",eventValue:"objectHash"});case 13:return f=t.sent,t.next=16,this.CallContractMethod({contractAddress:this.utils.HashToAddress(n),methodName:"pendingHash"});case 16:if(!(l=t.sent)||l===f){t.next=19;break}throw Error("Pending version hash mismatch on ".concat(n,": expected ").concat(f,", currently ").concat(l));case 19:if(!o){t.next=34;break}this.Log("Awaiting commit confirmation for ".concat(f)),p=this.ethClient.Provider().pollingInterval||500;case 22:return t.next=25,new Promise((function(t){return setTimeout(t,p)}));case 25:return t.next=27,this.ContractEvents({contractAddress:this.utils.HashToAddress(n),abi:u,fromBlock:c,count:1e3});case 27:if(d=t.sent,!d.find((function(t){return t.find((function(t){return f===(t&&t.args&&t.args.objectHash)}))}))){t.next=32;break}return this.Log("Commit confirmed on chain: ".concat(f)),t.abrupt("break",34);case 32:t.next=22;break;case 34:if(!o){t.next=48;break}A=500,b=20;case 37:if(!(b>0)){t.next=48;break}return t.next=40,this.LatestVersionHashV2({objectId:n});case 40:if(t.sent!=r){t.next=44;break}return this.Log("Commit confirmed on fabric node: ".concat(r)),t.abrupt("break",48);case 44:return t.next=46,new Promise((function(t){return setTimeout(t,A)}));case 46:t.next=37;break;case 48:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.DeleteContentVersion=function(){var t=o(a.mark((function t(e){var n,r,i;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.versionHash,y(n),this.Log("Deleting content version: ".concat(n)),r=this.utils.DecodeVersionHash(n),i=r.objectId,t.next=6,this.CallContractMethodAndWait({contractAddress:this.utils.HashToAddress(i),methodName:"deleteVersion",methodArgs:[n]});case 6:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.DeleteContentObject=function(){var t=o(a.mark((function t(e){var n,r;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,b({libraryId:n,objectId:r}),this.Log("Deleting content version: ".concat(n," ").concat(r)),t.next=5,this.CallContractMethodAndWait({contractAddress:this.utils.HashToAddress(n),methodName:"deleteContent",methodArgs:[this.utils.HashToAddress(r)]});case 5:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.MergeMetadata=function(){var t=o(a.mark((function t(e){var n,r,i,o,s,u,f,l;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.writeToken,o=e.metadataSubtree,s=void 0===o?"/":o,u=e.metadata,f=void 0===u?{}:u,b({libraryId:n,objectId:r}),A(i),this.Log("Merging metadata: ".concat(n," ").concat(r," ").concat(i,"\n Subtree: ").concat(s)),this.Log(f),l=c("q",i,"meta",s),t.t0=this.HttpClient,t.next=9,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,update:!0});case 9:return t.t1=t.sent,t.t2=l,t.t3=f,t.t4={headers:t.t1,method:"POST",path:t.t2,body:t.t3,allowFailover:!1},t.next=15,t.t0.Request.call(t.t0,t.t4);case 15:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.ReplaceMetadata=function(){var t=o(a.mark((function t(e){var n,r,i,o,s,u,f,l;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.writeToken,o=e.metadataSubtree,s=void 0===o?"/":o,u=e.metadata,f=void 0===u?{}:u,b({libraryId:n,objectId:r}),A(i),this.Log("Replacing metadata: ".concat(n," ").concat(r," ").concat(i,"\n Subtree: ").concat(s)),this.Log(f),l=c("q",i,"meta",s),t.t0=this.HttpClient,t.next=9,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,update:!0});case 9:return t.t1=t.sent,t.t2=l,t.t3=f,t.t4={headers:t.t1,method:"PUT",path:t.t2,body:t.t3,allowFailover:!1},t.next=15,t.t0.Request.call(t.t0,t.t4);case 15:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.DeleteMetadata=function(){var t=o(a.mark((function t(e){var n,r,i,o,s,u;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.writeToken,o=e.metadataSubtree,s=void 0===o?"/":o,b({libraryId:n,objectId:r}),A(i),this.Log("Deleting metadata: ".concat(n," ").concat(r," ").concat(i,"\n Subtree: ").concat(s)),this.Log("Subtree: ".concat(s)),u=c("q",i,"meta",s),t.t0=this.HttpClient,t.next=9,this.authClient.AuthorizationHeader({libraryId:n,objectId:r,update:!0});case 9:return t.t1=t.sent,t.t2=u,t.t3={headers:t.t1,method:"DELETE",path:t.t2,allowFailover:!1},t.next=14,t.t0.Request.call(t.t0,t.t3);case 14:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.SetAccessCharge=function(){var t=o(a.mark((function t(e){var n,r;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.objectId,r=e.accessCharge,h(n),this.Log("Setting access charge: ".concat(n," ").concat(r)),t.next=5,this.ethClient.CallContractMethodAndWait({contractAddress:this.utils.HashToAddress(n),methodName:"setAccessCharge",methodArgs:[this.utils.EtherToWei(r).toString()]});case 5:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.UpdateContentObjectGraph=function(){var t=o(a.mark((function t(e){var n,r,i,s,u,c,f,l,p=this;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=e.libraryId,r=e.objectId,i=e.versionHash,s=e.callback,b({libraryId:n,objectId:r,versionHash:i}),this.Log("Updating content object graph: ".concat(n||""," ").concat(r||i)),i&&(r=this.utils.DecodeVersionHash(i).objectId),c=0,f=a.mark((function t(){var e,f,l,d,h,y,A,b,g,m,v;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,p.ContentObjectGraph({libraryId:n,objectId:r,versionHash:i,autoUpdate:!0,select:["name","public/name","public/asset_metadata/display_title"]});case 2:if(e=t.sent,0!==Object.keys(e.auto_updates).length){t.next=6;break}return p.Log("No more updates required"),t.abrupt("return",{v:void 0});case 6:return u||(u=e.auto_updates.order.length),f=e.auto_updates.order[0],l=e.auto_updates.links[f],d=e.details[f].meta||{},h=d.public&&d.public.asset_metadata&&d.public.asset_metadata.display_title||d.public&&d.public.name||d.name||i||r,t.next=13,p.ContentObjectLibraryId({versionHash:f});case 13:return y=t.sent,A=p.utils.DecodeVersionHash(f).objectId,s&&s({completed:c,total:u,action:"Updating ".concat(h," (").concat(A,")...")}),p.Log("Updating links for ".concat(h," (").concat(A," / ").concat(f,")")),t.next=19,p.EditContentObject({libraryId:y,objectId:A});case 19:return b=t.sent,g=b.write_token,t.next=23,Promise.all(l.map(function(){var t=o(a.mark((function t(e){var n,r;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.path,r=e.updated,t.next=3,p.ReplaceMetadata({libraryId:y,objectId:A,writeToken:g,metadataSubtree:n,metadata:r});case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()));case 23:return t.next=25,p.FinalizeContentObject({libraryId:y,objectId:A,writeToken:g,commitMessage:"Update links"});case 25:m=t.sent,v=m.hash,f===i&&(i=v),c+=1;case 29:case"end":return t.stop()}}),t)}));case 6:return t.delegateYield(f(),"t0",8);case 8:if(!(l=t.t0)){t.next=11;break}return t.abrupt("return",l.v);case 11:t.next=6;break;case 13:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.GenerateSignedLinkToken=function(){var e=o(a.mark((function e(n){var r,i,o,s,u,c,p,d,y,A,b;return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=n.containerId,i=n.versionHash,o=n.link,s=n.duration,h(r),e.next=4,this.CallContractMethod({contractAddress:this.utils.HashToAddress(r),methodName:"canEdit"});case 4:if(u=e.sent,c=this.utils.DecodeVersionHash(i),p=c.objectId,u){e.next=8;break}throw Error("Current user does not have permission to edit content object ".concat(p));case 8:return d=this.CurrentAccountAddress(),e.t0=this.utils.B64(d.replace("0x",""),"hex"),e.next=12,this.ContentSpaceId();case 12:return e.t1=e.sent,e.next=15,this.ContentObjectLibraryId({objectId:p});case 15:return e.t2=e.sent,e.t3=p,e.t4="iusr".concat(this.utils.AddressToHash(d)),e.t5=Date.now(),e.t6=s?Date.now()+s:void 0,e.t7={elv:{lnk:o,src:r}},y={adr:e.t0,spc:e.t1,lib:e.t2,qid:e.t3,sub:e.t4,gra:"read",iat:e.t5,exp:e.t6,ctx:e.t7},A=l.deflateRaw(t.from(JSON.stringify(y),"utf-8")),e.next=25,this.authClient.Sign(f.utils.keccak256(A));case 25:return b=e.sent,e.abrupt("return","aslsjc".concat(this.utils.B58(t.concat([t.from(b.replace(/^0x/,""),"hex"),t.from(A)]))));case 27:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),e.CreateLinks=function(){var t=o(a.mark((function t(e){var n,r,i,s,u,c=this;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.writeToken,s=e.links,u=void 0===s?[]:s,b({libraryId:n,objectId:r}),A(i),t.next=5,this.utils.LimitedMap(10,u,function(){var t=o(a.mark((function t(e){var o,s,u,f,l,p;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(o=e.path.replace(/^(\/|\.)+/,""),"metadata"===(s="file"===(e.type||"file")?"files":e.type)&&(s="meta"),u=f=e.target.replace(/^(\/|\.)+/,""),u=e.targetHash?"/qfab/".concat(e.targetHash,"/").concat(s,"/").concat(u):"./".concat(s,"/").concat(u),l={"/":u},e.autoUpdate&&(l["."]={auto_update:{tag:"latest"}}),!e.authContainer){t.next=17;break}return t.next=10,c.ContentObjectMetadata({libraryId:n,objectId:r,metadataSubtree:o});case 10:if((p=t.sent)&&(l=p),l["."]||(l["."]={}),p["."].authorization){t.next=17;break}return t.next=16,c.GenerateSignedLinkToken({containerId:e.authContainer,versionHash:e.targetHash,link:"./".concat(s,"/").concat(f)});case 16:l["."].authorization=t.sent;case 17:return t.next=19,c.ReplaceMetadata({libraryId:n,objectId:r,writeToken:i,metadataSubtree:o,metadata:l});case 19:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}());case 5:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.InitializeAuthPolicy=function(){var t=o(a.mark((function t(e){var n,r,i,o,s,u,l,p,d,h,y;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.libraryId,r=e.objectId,i=e.writeToken,o=e.target,s=void 0===o?"auth_policy_spec":o,u=e.body,l=e.version,p=e.description,d=e.id,h={type:"epl-ast",version:l,body:u,data:{"/":c(".","meta",s)},signer:"iusr".concat(this.utils.AddressToHash(this.signer.address)),description:p||"",id:d||""},y="".concat(h.type,"|").concat(h.version,"|").concat(h.body,"|").concat(h.data["/"]),t.t0=this.utils,t.next=6,this.authClient.Sign(f.utils.keccak256(f.utils.toUtf8Bytes(y)));case 6:return t.t1=t.sent,h.signature=t.t0.FormatSignature.call(t.t0,t.t1),t.next=10,this.ReplaceMetadata({libraryId:n,objectId:r,writeToken:i,metadataSubtree:"auth_policy",metadata:h});case 10:return t.next=12,this.SetAuthPolicy({objectId:r,policyId:r});case 12:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.SetAuthPolicy=function(){var t=o(a.mark((function t(e){var n,r;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.objectId,r=e.policyId,t.next=3,this.MergeContractMetadata({contractAddress:this.utils.HashToAddress(n),metadataKey:"_AUTH_CONTEXT",metadata:{"elv:delegation-id":r}});case 3:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.DeleteWriteToken=function(){var t=o(a.mark((function t(e){var n,r,i,o;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.writeToken,r=e.libraryId,A(n),d(r),i=c("qlibs",r,"q",n),t.next=6,this.authClient.AuthorizationHeader({libraryId:r,update:!0});case 6:return o=t.sent,t.next=9,this.HttpClient.Request({headers:o,method:"DELETE",path:i,allowFailover:!1});case 9:return t.next=11,this.HttpClient.ClearWriteToken({writeToken:n});case 11:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}()}).call(this,n(4).Buffer)},function(t,e,n){var r=n(9),i=n(10),a=n(30),o=n(35),s=n(31),u=s.ValidateAddress,c=s.ValidateDate,f=s.ValidateObject,l=s.ValidatePresence,p=function(t){var e=t.pm||{},n={ntpId:t.id,ntpClass:"Class ".concat(t.de),tenantId:t.ti,kmsId:t.ki,objectId:e.qid,updatedAt:parseInt(t.ts),startTime:parseInt(e.vat),endTime:parseInt(e.exp),ticketLength:e.sen,maxRedemptions:e.ntp,maxTickets:t.mx};return void 0!==t.cnt&&(n.issuedTickets=t.cnt),n};e.CreateNTPInstance=function(){var t=i(r.mark((function t(e){var n,i,a,o,s,p,d,h,y,A,b,g,m,v,w,I=this;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.tenantId,i=e.objectId,a=e.groupAddresses,o=e.ntpClass,s=void 0===o?4:o,p=e.maxTickets,d=void 0===p?0:p,h=e.maxRedemptions,y=void 0===h?100:h,A=e.startTime,b=e.endTime,g=e.ticketLength,m=void 0===g?6:g,l("tenantId",n),l("objectId or groupAddresses",i||a),i&&f(i),a&&a.forEach((function(t){return u(t)})),A=c(A),b=c(b),v=["ntp:".concat(parseInt(y)),"sen:".concat(parseInt(m))],i?v.push("qid:".concat(i)):a&&(w=a.map((function(t){return"igrp".concat(I.utils.AddressToHash(t))})),v.push("gid:".concat(w.join(",")))),A&&v.push("vat:".concat(A)),b&&v.push("exp:".concat(b)),t.next=13,this.authClient.MakeKMSCall({tenantId:n,methodName:"elv_createOTPInstance",params:[n,s,JSON.stringify(v),parseInt(d),Date.now()],paramTypes:["string","int","string","int","int"]});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.UpdateNTPInstance=function(){var t=i(r.mark((function t(e){var n,i,a,o,s,u,f,d,h,y,A;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.tenantId,i=e.ntpId,a=e.maxTickets,o=void 0===a?0:a,s=e.maxRedemptions,u=void 0===s?100:s,f=e.startTime,d=e.endTime,l("tenantId",n),l("ntpId",i),f=c(f),d=c(d),h=[],u&&h.push("ntp:".concat(parseInt(u))),f&&h.push("vat:".concat(f)),d&&h.push("exp:".concat(d)),o&&h.push("max:".concat(parseInt(o))),t.next=12,this.authClient.MakeKMSCall({tenantId:n,methodName:"elv_updateOTPInstance",params:[n,i,"update",JSON.stringify(h),Date.now()],paramTypes:["string","string","string","string","int"]});case 12:return y=t.sent,A=y.Ret,t.abrupt("return",p(JSON.parse(A)));case 15:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.SuspendNTPInstance=function(){var t=i(r.mark((function t(e){var n,i;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.tenantId,i=e.ntpId,l("tenantId",n),l("ntpId",i),t.next=5,this.authClient.MakeKMSCall({tenantId:n,methodName:"elv_updateOTPInstance",params:[n,i,"cancel","[]",Date.now()],paramTypes:["string","string","string","string","int"]});case 5:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.DeleteNTPInstance=function(){var t=i(r.mark((function t(e){var n,i;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.tenantId,i=e.ntpId,l("tenantId",n),l("ntpId",i),t.next=5,this.authClient.MakeKMSCall({tenantId:n,methodName:"elv_updateOTPInstance",params:[n,i,"delete","[]",Date.now()],paramTypes:["string","string","string","string","int"]});case 5:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.ListNTPInstances=function(){var t=i(r.mark((function t(e){var n,i,a,o,s,u,c,f;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.tenantId,i=e.count,a=void 0===i?10:i,o=e.offset,s=void 0===o?0:o,l("tenantId",n),t.next=4,this.authClient.MakeKMSCall({tenantId:n,methodName:"elv_listOTPInfo",params:[n,s,a],paramTypes:["string","int","int"],signature:!1});case 4:return u=t.sent,c=u.Defs,f=u.Total,t.abrupt("return",{ntpInstances:Object.values(c||{}).map(p),start:s,end:Math.min(f,s+a),total:f});case 8:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.NTPInstance=function(){var t=i(r.mark((function t(e){var n,i;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.tenantId,i=e.ntpId,l("tenantId",n),l("ntpId",i),t.t0=p,t.next=6,this.authClient.MakeKMSCall({tenantId:n,methodName:"elv_getOTPInfo",params:[n,i],paramTypes:["string","string"],signature:!1});case 6:return t.t1=t.sent,t.abrupt("return",(0,t.t0)(t.t1));case 8:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.IssueNTPCode=function(){var t=i(r.mark((function t(e){var n,i,a,o,s,u,c;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.tenantId,i=e.ntpId,a=e.email,o=e.maxRedemptions,l("tenantId",n),l("ntpId",i),s=[],a&&s.push("eml:".concat(a)),o&&s.push("cnt:".concat(parseInt(o))),u=[n,i,JSON.stringify(s),Date.now()],c=["string","string","string","uint"],t.next=10,this.authClient.MakeKMSCall({methodName:"elv_issueOTPCode",params:u,paramTypes:c});case 10:return t.abrupt("return",t.sent);case 11:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.IssueSignedNTPCode=function(){var t=i(r.mark((function t(e){var n,i,a,s,u,c,f;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.tenantId,i=e.ntpId,a=e.email,s=e.maxRedemptions,t.next=3,this.IssueNTPCode({tenantId:n,ntpId:i,email:a,maxRedemptions:s});case 3:if(!(u=t.sent).token){t.next=10;break}return t.next=7,this.authClient.Sign(o.utils.keccak256(o.utils.toUtf8Bytes(u.token)));case 7:c=t.sent,f=this.utils.FormatSignature(c),u.token="".concat(u.token,".").concat(this.utils.B64(f));case 10:return t.abrupt("return",u);case 11:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.RedeemCode=function(){var t=i(r.mark((function t(e){var n,i,o,s,u,c,p,d,h,y,A,b,g,m,v,w,I,E;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.issuer,i=e.tenantId,o=e.ntpId,s=e.code,u=e.email,c=e.includeNTPId,p=void 0!==c&&c,d=this.GenerateWallet(),n=n||"",this.signer||this.SetSigner({signer:d.AddAccountFromMnemonic({mnemonic:d.GenerateMnemonic()})}),!n.startsWith("iq__")){t.next=8;break}f(n),t.next=28;break;case 8:if(!n||n.replace(/^\//,"").startsWith("otp/ntp/iten")){t.next=12;break}throw Error("Invalid issuer: "+n);case 12:return l("issuer or tenantId",n||i),n||(n=a("/otp","ntp",i,o||"")),t.prev=14,t.next=17,this.authClient.GenerateChannelContentToken({issuer:n,code:s,email:u});case 17:return h=t.sent,this.SetStaticToken({token:h}),y=JSON.parse(this.utils.FromB64(h)),t.abrupt("return",p?{objectId:y.qid,ntpId:y.oid}:y.qid);case 23:throw t.prev=23,t.t0=t.catch(14),this.Log("Failed to redeem code:",!0),this.Log(t.t0,!0),t.t0;case 28:return A=n,t.next=31,this.ContentObjectLibraryId({objectId:A});case 31:return b=t.sent,g=function(t){var e=t.split("").map((function(t){return t.charCodeAt(0)}));return e.reduce((function(t,n,r){return e[r+1]?2*t+n*e[r+1]*(r+1):t+n}),0).toString()}(s),t.next=36,this.ContentObjectMetadata({libraryId:b,objectId:A,metadataSubtree:"public/codes/".concat(g)});case 36:if(m=t.sent){t.next=40;break}throw this.Log("Code redemption failed:\n\t".concat(n,"\n\t").concat(s)),Error("Invalid code: "+s);case 40:return v=m.ak,w=m.sites,I=m.info,t.next=43,d.AddAccountFromEncryptedPK({encryptedPrivateKey:this.utils.FromB64(v),password:s});case 43:return E=t.sent,this.SetSigner({signer:E}),t.next=47,this.userProfileClient.WalletAddress();case 47:return t.abrupt("return",{addr:this.utils.FormatAddress(E.address),sites:w,info:I||{}});case 48:case"end":return t.stop()}}),t,this,[[14,23]])})));return function(e){return t.apply(this,arguments)}}()},function(t,e,n){var r=n(9),i=n(17),a=n(10);function o(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 s(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?o(Object(n),!0).forEach((function(e){i(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}var u=n(449),c=n(30),f=n(31),l=f.ValidateAddress,p=f.ValidateObject,d=f.ValidatePresence;e.MintNFT=function(){var t=a(r.mark((function t(e){var n,i,a,o,f,h,y,A,b;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.tenantId,i=e.address,a=e.marketplaceId,o=e.items,f=e.extraData,h=void 0===f?{}:f,d("tenantId",n),d("address",i),d("marketplaceId",a),d("items",o),p(a),l(i),y={tickets:null,products:o.map((function(t){return{sku:t.sku,quant:t.quantity||1,extra:t.tokenId?s(s({},t.extraData||{}),{},{token_id:t.tokenId}):s({},t.extraData||{})}})),ident:i,cust_name:i,extra:s(s({},h),{},{elv_addr:i})},A=this.utils.B58(u.parse(u.v4())),y.ts=Date.now(),y.trans_id=A,t.next=13,this.Sign(JSON.stringify(y));case 13:return b=t.sent,t.next=16,this.authClient.MakeAuthServiceRequest({method:"POST",path:c("/as/tnt/trans/base",n,a),body:y,headers:{Authorization:"Bearer ".concat(b)}});case 16:return t.abrupt("return",{address:i,transactionId:A});case 17:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.CollectionTransactions=function(){var t=a(r.mark((function t(e){var n,i,a,o,s,u,f,l,p;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.tenantId,i=e.collectionId,a=e.filterOptions,o=void 0===a?{}:a,s=Date.now(),u={ts:s},f={email:"email",fromOrdinal:"from_ord",max:"max",status:"status",transactionId:"trans_id"},Object.keys(f).forEach((function(t){o[t]&&(u[f[t]]=o[t])})),l=this.AuthHttpClient.BaseURI().path(c("/tnt","trans",n,i)).query(u).hash("").resource(),t.next=8,this.Sign(l);case 8:return p=t.sent,t.next=11,this.utils.ResponseToJson(this.authClient.MakeAuthServiceRequest({method:"GET",path:c("as","tnt","trans",n,i),queryParams:u,headers:{Authorization:"Bearer ".concat(p)}}));case 11:return t.abrupt("return",t.sent);case 12:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}()},function(t,e,n){"use strict";n.r(e),n.d(e,"F",(function(){return r})),n.d(e,"T",(function(){return i})),n.d(e,"__",(function(){return a})),n.d(e,"add",(function(){return f})),n.d(e,"addIndex",(function(){return y})),n.d(e,"adjust",(function(){return b})),n.d(e,"all",(function(){return _})),n.d(e,"allPass",(function(){return et})),n.d(e,"always",(function(){return nt})),n.d(e,"and",(function(){return rt})),n.d(e,"any",(function(){return at})),n.d(e,"anyPass",(function(){return ot})),n.d(e,"ap",(function(){return st})),n.d(e,"aperture",(function(){return ft})),n.d(e,"append",(function(){return lt})),n.d(e,"apply",(function(){return pt})),n.d(e,"applySpec",(function(){return yt})),n.d(e,"applyTo",(function(){return At})),n.d(e,"ascend",(function(){return bt})),n.d(e,"assoc",(function(){return gt})),n.d(e,"assocPath",(function(){return vt})),n.d(e,"binary",(function(){return It})),n.d(e,"bind",(function(){return R})),n.d(e,"both",(function(){return kt})),n.d(e,"call",(function(){return xt})),n.d(e,"chain",(function(){return Mt})),n.d(e,"clamp",(function(){return Rt})),n.d(e,"clone",(function(){return Pt})),n.d(e,"comparator",(function(){return Dt})),n.d(e,"complement",(function(){return Lt})),n.d(e,"compose",(function(){return Yt})),n.d(e,"composeK",(function(){return zt})),n.d(e,"composeP",(function(){return Vt})),n.d(e,"composeWith",(function(){return ee})),n.d(e,"concat",(function(){return _e})),n.d(e,"cond",(function(){return Ce})),n.d(e,"construct",(function(){return Be})),n.d(e,"constructN",(function(){return ke})),n.d(e,"contains",(function(){return xe})),n.d(e,"converge",(function(){return Se})),n.d(e,"countBy",(function(){return Re})),n.d(e,"curry",(function(){return Bt})),n.d(e,"curryN",(function(){return h})),n.d(e,"dec",(function(){return Oe})),n.d(e,"defaultTo",(function(){return je})),n.d(e,"descend",(function(){return Te})),n.d(e,"difference",(function(){return Le})),n.d(e,"differenceWith",(function(){return Fe})),n.d(e,"dissoc",(function(){return Ue})),n.d(e,"dissocPath",(function(){return qe})),n.d(e,"divide",(function(){return Ke})),n.d(e,"drop",(function(){return ze})),n.d(e,"dropLast",(function(){return Xe})),n.d(e,"dropLastWhile",(function(){return en})),n.d(e,"dropRepeats",(function(){return sn})),n.d(e,"dropRepeatsWith",(function(){return on})),n.d(e,"dropWhile",(function(){return cn})),n.d(e,"either",(function(){return ln})),n.d(e,"empty",(function(){return pn})),n.d(e,"endsWith",(function(){return hn})),n.d(e,"eqBy",(function(){return yn})),n.d(e,"eqProps",(function(){return An})),n.d(e,"equals",(function(){return ue})),n.d(e,"evolve",(function(){return gn})),n.d(e,"filter",(function(){return me})),n.d(e,"find",(function(){return vn})),n.d(e,"findIndex",(function(){return In})),n.d(e,"findLast",(function(){return _n})),n.d(e,"findLastIndex",(function(){return kn})),n.d(e,"flatten",(function(){return Bn})),n.d(e,"flip",(function(){return xn})),n.d(e,"forEach",(function(){return Sn})),n.d(e,"forEachObjIndexed",(function(){return Qn})),n.d(e,"fromPairs",(function(){return Mn})),n.d(e,"groupBy",(function(){return Rn})),n.d(e,"groupWith",(function(){return On})),n.d(e,"gt",(function(){return jn})),n.d(e,"gte",(function(){return Tn})),n.d(e,"has",(function(){return Dn})),n.d(e,"hasIn",(function(){return Nn})),n.d(e,"hasPath",(function(){return Pn})),n.d(e,"head",(function(){return Zt})),n.d(e,"identical",(function(){return Ln})),n.d(e,"identity",(function(){return $t})),n.d(e,"ifElse",(function(){return Fn})),n.d(e,"inc",(function(){return Un})),n.d(e,"includes",(function(){return Hn})),n.d(e,"indexBy",(function(){return Gn})),n.d(e,"indexOf",(function(){return qn})),n.d(e,"init",(function(){return Kn})),n.d(e,"innerJoin",(function(){return Yn})),n.d(e,"insert",(function(){return zn})),n.d(e,"insertAll",(function(){return Jn})),n.d(e,"intersection",(function(){return Zn})),n.d(e,"intersperse",(function(){return Xn})),n.d(e,"into",(function(){return ar})),n.d(e,"invert",(function(){return or})),n.d(e,"invertObj",(function(){return sr})),n.d(e,"invoker",(function(){return ur})),n.d(e,"is",(function(){return cr})),n.d(e,"isEmpty",(function(){return fr})),n.d(e,"isNil",(function(){return mt})),n.d(e,"join",(function(){return lr})),n.d(e,"juxt",(function(){return pr})),n.d(e,"keys",(function(){return Y})),n.d(e,"keysIn",(function(){return dr})),n.d(e,"last",(function(){return an})),n.d(e,"lastIndexOf",(function(){return hr})),n.d(e,"length",(function(){return Ar})),n.d(e,"lens",(function(){return br})),n.d(e,"lensIndex",(function(){return gr})),n.d(e,"lensPath",(function(){return mr})),n.d(e,"lensProp",(function(){return vr})),n.d(e,"lift",(function(){return Ct})),n.d(e,"liftN",(function(){return _t})),n.d(e,"lt",(function(){return wr})),n.d(e,"lte",(function(){return Ir})),n.d(e,"map",(function(){return z})),n.d(e,"mapAccum",(function(){return Er})),n.d(e,"mapAccumRight",(function(){return _r})),n.d(e,"mapObjIndexed",(function(){return Cr})),n.d(e,"match",(function(){return kr})),n.d(e,"mathMod",(function(){return Br})),n.d(e,"max",(function(){return C})),n.d(e,"maxBy",(function(){return xr})),n.d(e,"mean",(function(){return Qr})),n.d(e,"median",(function(){return Mr})),n.d(e,"memoizeWith",(function(){return Rr})),n.d(e,"merge",(function(){return Or})),n.d(e,"mergeAll",(function(){return jr})),n.d(e,"mergeDeepLeft",(function(){return Dr})),n.d(e,"mergeDeepRight",(function(){return Nr})),n.d(e,"mergeDeepWith",(function(){return Lr})),n.d(e,"mergeDeepWithKey",(function(){return Pr})),n.d(e,"mergeLeft",(function(){return Fr})),n.d(e,"mergeRight",(function(){return Ur})),n.d(e,"mergeWith",(function(){return Hr})),n.d(e,"mergeWithKey",(function(){return Tr})),n.d(e,"min",(function(){return Gr})),n.d(e,"minBy",(function(){return qr})),n.d(e,"modulo",(function(){return Kr})),n.d(e,"move",(function(){return Yr})),n.d(e,"multiply",(function(){return zr})),n.d(e,"nAry",(function(){return wt})),n.d(e,"negate",(function(){return Jr})),n.d(e,"none",(function(){return Wr})),n.d(e,"not",(function(){return Nt})),n.d(e,"nth",(function(){return W})),n.d(e,"nthArg",(function(){return Vr})),n.d(e,"o",(function(){return Zr})),n.d(e,"objOf",(function(){return tr})),n.d(e,"of",(function(){return $r})),n.d(e,"omit",(function(){return ti})),n.d(e,"once",(function(){return ei})),n.d(e,"or",(function(){return fn})),n.d(e,"otherwise",(function(){return ri})),n.d(e,"over",(function(){return ii})),n.d(e,"pair",(function(){return ai})),n.d(e,"partial",(function(){return si})),n.d(e,"partialRight",(function(){return ui})),n.d(e,"partition",(function(){return ci})),n.d(e,"path",(function(){return Z})),n.d(e,"paths",(function(){return V})),n.d(e,"pathEq",(function(){return fi})),n.d(e,"pathOr",(function(){return li})),n.d(e,"pathSatisfies",(function(){return pi})),n.d(e,"pick",(function(){return di})),n.d(e,"pickAll",(function(){return hi})),n.d(e,"pickBy",(function(){return yi})),n.d(e,"pipe",(function(){return qt})),n.d(e,"pipeK",(function(){return Ai})),n.d(e,"pipeP",(function(){return Wt})),n.d(e,"pipeWith",(function(){return te})),n.d(e,"pluck",(function(){return $})),n.d(e,"prepend",(function(){return bi})),n.d(e,"product",(function(){return gi})),n.d(e,"project",(function(){return vi})),n.d(e,"prop",(function(){return X})),n.d(e,"propEq",(function(){return wi})),n.d(e,"propIs",(function(){return Ii})),n.d(e,"propOr",(function(){return Ei})),n.d(e,"propSatisfies",(function(){return _i})),n.d(e,"props",(function(){return Ci})),n.d(e,"range",(function(){return ki})),n.d(e,"reduce",(function(){return tt})),n.d(e,"reduceBy",(function(){return Me})),n.d(e,"reduceRight",(function(){return Bi})),n.d(e,"reduceWhile",(function(){return xi})),n.d(e,"reduced",(function(){return Si})),n.d(e,"reject",(function(){return ve})),n.d(e,"remove",(function(){return He})),n.d(e,"repeat",(function(){return Mi})),n.d(e,"replace",(function(){return Ri})),n.d(e,"reverse",(function(){return Kt})),n.d(e,"scan",(function(){return Oi})),n.d(e,"sequence",(function(){return ji})),n.d(e,"set",(function(){return Ti})),n.d(e,"slice",(function(){return Ht})),n.d(e,"sort",(function(){return Pi})),n.d(e,"sortBy",(function(){return Di})),n.d(e,"sortWith",(function(){return Ni})),n.d(e,"split",(function(){return Li})),n.d(e,"splitAt",(function(){return Fi})),n.d(e,"splitEvery",(function(){return Ui})),n.d(e,"splitWhen",(function(){return Hi})),n.d(e,"startsWith",(function(){return Gi})),n.d(e,"subtract",(function(){return qi})),n.d(e,"sum",(function(){return Sr})),n.d(e,"symmetricDifference",(function(){return Ki})),n.d(e,"symmetricDifferenceWith",(function(){return Yi})),n.d(e,"tail",(function(){return Gt})),n.d(e,"take",(function(){return We})),n.d(e,"takeLast",(function(){return dn})),n.d(e,"takeLastWhile",(function(){return zi})),n.d(e,"takeWhile",(function(){return Wi})),n.d(e,"tap",(function(){return Zi})),n.d(e,"test",(function(){return Xi})),n.d(e,"andThen",(function(){return $i})),n.d(e,"times",(function(){return Qi})),n.d(e,"toLower",(function(){return ta})),n.d(e,"toPairs",(function(){return ea})),n.d(e,"toPairsIn",(function(){return na})),n.d(e,"toString",(function(){return Ee})),n.d(e,"toUpper",(function(){return ra})),n.d(e,"transduce",(function(){return ia})),n.d(e,"transpose",(function(){return aa})),n.d(e,"traverse",(function(){return oa})),n.d(e,"trim",(function(){return ua})),n.d(e,"tryCatch",(function(){return ca})),n.d(e,"type",(function(){return jt})),n.d(e,"unapply",(function(){return fa})),n.d(e,"unary",(function(){return la})),n.d(e,"uncurryN",(function(){return pa})),n.d(e,"unfold",(function(){return da})),n.d(e,"union",(function(){return ha})),n.d(e,"unionWith",(function(){return Aa})),n.d(e,"uniq",(function(){return Vn})),n.d(e,"uniqBy",(function(){return Wn})),n.d(e,"uniqWith",(function(){return ya})),n.d(e,"unless",(function(){return ba})),n.d(e,"unnest",(function(){return ga})),n.d(e,"until",(function(){return ma})),n.d(e,"update",(function(){return Ge})),n.d(e,"useWith",(function(){return mi})),n.d(e,"values",(function(){return dt})),n.d(e,"valuesIn",(function(){return va})),n.d(e,"view",(function(){return Ia})),n.d(e,"when",(function(){return Ea})),n.d(e,"where",(function(){return _a})),n.d(e,"whereEq",(function(){return Ca})),n.d(e,"without",(function(){return ka})),n.d(e,"xor",(function(){return Ba})),n.d(e,"xprod",(function(){return xa})),n.d(e,"zip",(function(){return Sa})),n.d(e,"zipObj",(function(){return Qa})),n.d(e,"zipWith",(function(){return Ma})),n.d(e,"thunkify",(function(){return Ra}));var r=function(){return!1},i=function(){return!0},a={"@@functional/placeholder":!0};function o(t){return(o="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)}function s(t){return null!=t&&"object"===o(t)&&!0===t["@@functional/placeholder"]}function u(t){return function e(n){return 0===arguments.length||s(n)?e:t.apply(this,arguments)}}function c(t){return function e(n,r){switch(arguments.length){case 0:return e;case 1:return s(n)?e:u((function(e){return t(n,e)}));default:return s(n)&&s(r)?e:s(n)?u((function(e){return t(e,r)})):s(r)?u((function(e){return t(n,e)})):t(n,r)}}}var f=c((function(t,e){return Number(t)+Number(e)}));function l(t,e){var n;e=e||[];var r=(t=t||[]).length,i=e.length,a=[];for(n=0;n<r;)a[a.length]=t[n],n+=1;for(n=0;n<i;)a[a.length]=e[n],n+=1;return a}function p(t,e){switch(t){case 0:return function(){return e.apply(this,arguments)};case 1:return function(t){return e.apply(this,arguments)};case 2:return function(t,n){return e.apply(this,arguments)};case 3:return function(t,n,r){return e.apply(this,arguments)};case 4:return function(t,n,r,i){return e.apply(this,arguments)};case 5:return function(t,n,r,i,a){return e.apply(this,arguments)};case 6:return function(t,n,r,i,a,o){return e.apply(this,arguments)};case 7:return function(t,n,r,i,a,o,s){return e.apply(this,arguments)};case 8:return function(t,n,r,i,a,o,s,u){return e.apply(this,arguments)};case 9:return function(t,n,r,i,a,o,s,u,c){return e.apply(this,arguments)};case 10:return function(t,n,r,i,a,o,s,u,c,f){return e.apply(this,arguments)};default:throw new Error("First argument to _arity must be a non-negative integer no greater than ten")}}function d(t,e,n){return function(){for(var r=[],i=0,a=t,o=0;o<e.length||i<arguments.length;){var u;o<e.length&&(!s(e[o])||i>=arguments.length)?u=e[o]:(u=arguments[i],i+=1),r[o]=u,s(u)||(a-=1),o+=1}return a<=0?n.apply(this,r):p(a,d(t,r,n))}}var h=c((function(t,e){return 1===t?u(e):p(t,d(t,[],e))})),y=u((function(t){return h(t.length,(function(){var e=0,n=arguments[0],r=arguments[arguments.length-1],i=Array.prototype.slice.call(arguments,0);return i[0]=function(){var t=n.apply(this,l(arguments,[e,r]));return e+=1,t},t.apply(this,i)}))}));function A(t){return function e(n,r,i){switch(arguments.length){case 0:return e;case 1:return s(n)?e:c((function(e,r){return t(n,e,r)}));case 2:return s(n)&&s(r)?e:s(n)?c((function(e,n){return t(e,r,n)})):s(r)?c((function(e,r){return t(n,e,r)})):u((function(e){return t(n,r,e)}));default:return s(n)&&s(r)&&s(i)?e:s(n)&&s(r)?c((function(e,n){return t(e,n,i)})):s(n)&&s(i)?c((function(e,n){return t(e,r,n)})):s(r)&&s(i)?c((function(e,r){return t(n,e,r)})):s(n)?u((function(e){return t(e,r,i)})):s(r)?u((function(e){return t(n,e,i)})):s(i)?u((function(e){return t(n,r,e)})):t(n,r,i)}}}var b=A((function(t,e,n){if(t>=n.length||t<-n.length)return n;var r=(t<0?n.length:0)+t,i=l(n);return i[r]=e(n[r]),i})),g=Array.isArray||function(t){return null!=t&&t.length>=0&&"[object Array]"===Object.prototype.toString.call(t)};function m(t){return null!=t&&"function"==typeof t["@@transducer/step"]}function v(t,e,n){return function(){if(0===arguments.length)return n();var r=Array.prototype.slice.call(arguments,0),i=r.pop();if(!g(i)){for(var a=0;a<t.length;){if("function"==typeof i[t[a]])return i[t[a]].apply(i,r);a+=1}if(m(i)){var o=e.apply(null,r);return o(i)}}return n.apply(this,arguments)}}function w(t){return t&&t["@@transducer/reduced"]?t:{"@@transducer/value":t,"@@transducer/reduced":!0}}var I={init:function(){return this.xf["@@transducer/init"]()},result:function(t){return this.xf["@@transducer/result"](t)}},E=function(){function t(t,e){this.xf=e,this.f=t,this.all=!0}return t.prototype["@@transducer/init"]=I.init,t.prototype["@@transducer/result"]=function(t){return this.all&&(t=this.xf["@@transducer/step"](t,!0)),this.xf["@@transducer/result"](t)},t.prototype["@@transducer/step"]=function(t,e){return this.f(e)||(this.all=!1,t=w(this.xf["@@transducer/step"](t,!1))),t},t}(),_=c(v(["all"],c((function(t,e){return new E(t,e)})),(function(t,e){for(var n=0;n<e.length;){if(!t(e[n]))return!1;n+=1}return!0}))),C=c((function(t,e){return e>t?e:t}));function k(t,e){for(var n=0,r=e.length,i=Array(r);n<r;)i[n]=t(e[n]),n+=1;return i}function B(t){return"[object String]"===Object.prototype.toString.call(t)}function x(t){return(x="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 S=u((function(t){return!!g(t)||!!t&&("object"===x(t)&&(!B(t)&&(1===t.nodeType?!!t.length:0===t.length||t.length>0&&(t.hasOwnProperty(0)&&t.hasOwnProperty(t.length-1)))))})),Q=function(){function t(t){this.f=t}return t.prototype["@@transducer/init"]=function(){throw new Error("init not implemented on XWrap")},t.prototype["@@transducer/result"]=function(t){return t},t.prototype["@@transducer/step"]=function(t,e){return this.f(t,e)},t}();function M(t){return new Q(t)}var R=c((function(t,e){return p(t.length,(function(){return t.apply(e,arguments)}))}));function O(t,e,n){for(var r=n.next();!r.done;){if((e=t["@@transducer/step"](e,r.value))&&e["@@transducer/reduced"]){e=e["@@transducer/value"];break}r=n.next()}return t["@@transducer/result"](e)}function j(t,e,n,r){return t["@@transducer/result"](n[r](R(t["@@transducer/step"],t),e))}var T="undefined"!=typeof Symbol?Symbol.iterator:"@@iterator";function P(t,e,n){if("function"==typeof t&&(t=M(t)),S(n))return function(t,e,n){for(var r=0,i=n.length;r<i;){if((e=t["@@transducer/step"](e,n[r]))&&e["@@transducer/reduced"]){e=e["@@transducer/value"];break}r+=1}return t["@@transducer/result"](e)}(t,e,n);if("function"==typeof n["fantasy-land/reduce"])return j(t,e,n,"fantasy-land/reduce");if(null!=n[T])return O(t,e,n[T]());if("function"==typeof n.next)return O(t,e,n);if("function"==typeof n.reduce)return j(t,e,n,"reduce");throw new TypeError("reduce: list must be array or iterable")}var D=function(){function t(t,e){this.xf=e,this.f=t}return t.prototype["@@transducer/init"]=I.init,t.prototype["@@transducer/result"]=I.result,t.prototype["@@transducer/step"]=function(t,e){return this.xf["@@transducer/step"](t,this.f(e))},t}(),N=c((function(t,e){return new D(t,e)}));function L(t,e){return Object.prototype.hasOwnProperty.call(e,t)}var F=Object.prototype.toString,U=function(){return"[object Arguments]"===F.call(arguments)?function(t){return"[object Arguments]"===F.call(t)}:function(t){return L("callee",t)}}(),H=!{toString:null}.propertyIsEnumerable("toString"),G=["constructor","valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"],q=function(){return arguments.propertyIsEnumerable("length")}(),K=function(t,e){for(var n=0;n<t.length;){if(t[n]===e)return!0;n+=1}return!1},Y="function"!=typeof Object.keys||q?u((function(t){if(Object(t)!==t)return[];var e,n,r=[],i=q&&U(t);for(e in t)!L(e,t)||i&&"length"===e||(r[r.length]=e);if(H)for(n=G.length-1;n>=0;)L(e=G[n],t)&&!K(r,e)&&(r[r.length]=e),n-=1;return r})):u((function(t){return Object(t)!==t?[]:Object.keys(t)})),z=c(v(["fantasy-land/map","map"],N,(function(t,e){switch(Object.prototype.toString.call(e)){case"[object Function]":return h(e.length,(function(){return t.call(this,e.apply(this,arguments))}));case"[object Object]":return P((function(n,r){return n[r]=t(e[r]),n}),{},Y(e));default:return k(t,e)}}))),J=Number.isInteger||function(t){return t<<0===t},W=c((function(t,e){var n=t<0?e.length+t:t;return B(e)?e.charAt(n):e[n]})),V=c((function(t,e){return t.map((function(t){for(var n,r=e,i=0;i<t.length;){if(null==r)return;n=t[i],r=J(n)?W(n,r):r[n],i+=1}return r}))})),Z=c((function(t,e){return V([t],e)[0]})),X=c((function(t,e){return Z([t],e)})),$=c((function(t,e){return z(X(t),e)})),tt=A(P),et=u((function(t){return h(tt(C,0,$("length",t)),(function(){for(var e=0,n=t.length;e<n;){if(!t[e].apply(this,arguments))return!1;e+=1}return!0}))})),nt=u((function(t){return function(){return t}})),rt=c((function(t,e){return t&&e})),it=function(){function t(t,e){this.xf=e,this.f=t,this.any=!1}return t.prototype["@@transducer/init"]=I.init,t.prototype["@@transducer/result"]=function(t){return this.any||(t=this.xf["@@transducer/step"](t,!1)),this.xf["@@transducer/result"](t)},t.prototype["@@transducer/step"]=function(t,e){return this.f(e)&&(this.any=!0,t=w(this.xf["@@transducer/step"](t,!0))),t},t}(),at=c(v(["any"],c((function(t,e){return new it(t,e)})),(function(t,e){for(var n=0;n<e.length;){if(t(e[n]))return!0;n+=1}return!1}))),ot=u((function(t){return h(tt(C,0,$("length",t)),(function(){for(var e=0,n=t.length;e<n;){if(t[e].apply(this,arguments))return!0;e+=1}return!1}))})),st=c((function(t,e){return"function"==typeof e["fantasy-land/ap"]?e["fantasy-land/ap"](t):"function"==typeof t.ap?t.ap(e):"function"==typeof t?function(n){return t(n)(e(n))}:P((function(t,n){return l(t,z(n,e))}),[],t)}));function ut(t,e){for(var n=0,r=e.length-(t-1),i=new Array(r>=0?r:0);n<r;)i[n]=Array.prototype.slice.call(e,n,n+t),n+=1;return i}var ct=function(){function t(t,e){this.xf=e,this.pos=0,this.full=!1,this.acc=new Array(t)}return t.prototype["@@transducer/init"]=I.init,t.prototype["@@transducer/result"]=function(t){return this.acc=null,this.xf["@@transducer/result"](t)},t.prototype["@@transducer/step"]=function(t,e){return this.store(e),this.full?this.xf["@@transducer/step"](t,this.getCopy()):t},t.prototype.store=function(t){this.acc[this.pos]=t,this.pos+=1,this.pos===this.acc.length&&(this.pos=0,this.full=!0)},t.prototype.getCopy=function(){return l(Array.prototype.slice.call(this.acc,this.pos),Array.prototype.slice.call(this.acc,0,this.pos))},t}(),ft=c(v([],c((function(t,e){return new ct(t,e)})),ut)),lt=c((function(t,e){return l(e,[t])})),pt=c((function(t,e){return t.apply(this,e)})),dt=u((function(t){for(var e=Y(t),n=e.length,r=[],i=0;i<n;)r[i]=t[e[i]],i+=1;return r}));function ht(t,e){return Y(e).reduce((function(n,r){return n[r]=t(e[r]),n}),{})}var yt=u((function t(e){return e=ht((function(e){return"function"==typeof e?e:t(e)}),e),h(tt(C,0,$("length",dt(e))),(function(){var t=arguments;return ht((function(e){return pt(e,t)}),e)}))})),At=c((function(t,e){return e(t)})),bt=A((function(t,e,n){var r=t(e),i=t(n);return r<i?-1:r>i?1:0})),gt=A((function(t,e,n){var r={};for(var i in n)r[i]=n[i];return r[t]=e,r})),mt=u((function(t){return null==t})),vt=A((function t(e,n,r){if(0===e.length)return n;var i=e[0];if(e.length>1){var a=!mt(r)&&L(i,r)?r[i]:J(e[1])?[]:{};n=t(Array.prototype.slice.call(e,1),n,a)}if(J(i)&&g(r)){var o=[].concat(r);return o[i]=n,o}return gt(i,n,r)})),wt=c((function(t,e){switch(t){case 0:return function(){return e.call(this)};case 1:return function(t){return e.call(this,t)};case 2:return function(t,n){return e.call(this,t,n)};case 3:return function(t,n,r){return e.call(this,t,n,r)};case 4:return function(t,n,r,i){return e.call(this,t,n,r,i)};case 5:return function(t,n,r,i,a){return e.call(this,t,n,r,i,a)};case 6:return function(t,n,r,i,a,o){return e.call(this,t,n,r,i,a,o)};case 7:return function(t,n,r,i,a,o,s){return e.call(this,t,n,r,i,a,o,s)};case 8:return function(t,n,r,i,a,o,s,u){return e.call(this,t,n,r,i,a,o,s,u)};case 9:return function(t,n,r,i,a,o,s,u,c){return e.call(this,t,n,r,i,a,o,s,u,c)};case 10:return function(t,n,r,i,a,o,s,u,c,f){return e.call(this,t,n,r,i,a,o,s,u,c,f)};default:throw new Error("First argument to nAry must be a non-negative integer no greater than ten")}})),It=u((function(t){return wt(2,t)}));function Et(t){var e=Object.prototype.toString.call(t);return"[object Function]"===e||"[object AsyncFunction]"===e||"[object GeneratorFunction]"===e||"[object AsyncGeneratorFunction]"===e}var _t=c((function(t,e){var n=h(t,e);return h(t,(function(){return P(st,z(n,arguments[0]),Array.prototype.slice.call(arguments,1))}))})),Ct=u((function(t){return _t(t.length,t)})),kt=c((function(t,e){return Et(t)?function(){return t.apply(this,arguments)&&e.apply(this,arguments)}:Ct(rt)(t,e)})),Bt=u((function(t){return h(t.length,t)})),xt=Bt((function(t){return t.apply(this,Array.prototype.slice.call(arguments,1))}));function St(t){return function e(n){for(var r,i,a,o=[],s=0,u=n.length;s<u;){if(S(n[s]))for(a=0,i=(r=t?e(n[s]):n[s]).length;a<i;)o[o.length]=r[a],a+=1;else o[o.length]=n[s];s+=1}return o}}var Qt=function(t){var e=function(t){return{"@@transducer/init":I.init,"@@transducer/result":function(e){return t["@@transducer/result"](e)},"@@transducer/step":function(e,n){var r=t["@@transducer/step"](e,n);return r["@@transducer/reduced"]?{"@@transducer/value":r,"@@transducer/reduced":!0}:r}}}(t);return{"@@transducer/init":I.init,"@@transducer/result":function(t){return e["@@transducer/result"](t)},"@@transducer/step":function(t,n){return S(n)?P(e,t,n):P(e,t,[n])}}},Mt=c(v(["fantasy-land/chain","chain"],c((function(t,e){return z(t,Qt(e))})),(function(t,e){return"function"==typeof e?function(n){return t(e(n))(n)}:St(!1)(z(t,e))}))),Rt=A((function(t,e,n){if(t>e)throw new Error("min must not be greater than max in clamp(min, max, value)");return n<t?t:n>e?e:n}));function Ot(t){return new RegExp(t.source,(t.global?"g":"")+(t.ignoreCase?"i":"")+(t.multiline?"m":"")+(t.sticky?"y":"")+(t.unicode?"u":""))}var jt=u((function(t){return null===t?"Null":void 0===t?"Undefined":Object.prototype.toString.call(t).slice(8,-1)}));function Tt(t,e,n,r){var i=function(i){for(var a=e.length,o=0;o<a;){if(t===e[o])return n[o];o+=1}for(var s in e[o+1]=t,n[o+1]=i,t)i[s]=r?Tt(t[s],e,n,!0):t[s];return i};switch(jt(t)){case"Object":return i({});case"Array":return i([]);case"Date":return new Date(t.valueOf());case"RegExp":return Ot(t);default:return t}}var Pt=u((function(t){return null!=t&&"function"==typeof t.clone?t.clone():Tt(t,[],[],!0)})),Dt=u((function(t){return function(e,n){return t(e,n)?-1:t(n,e)?1:0}})),Nt=u((function(t){return!t})),Lt=Ct(Nt);function Ft(t,e){return function(){return e.call(this,t.apply(this,arguments))}}function Ut(t,e){return function(){var n=arguments.length;if(0===n)return e();var r=arguments[n-1];return g(r)||"function"!=typeof r[t]?e.apply(this,arguments):r[t].apply(r,Array.prototype.slice.call(arguments,0,n-1))}}var Ht=A(Ut("slice",(function(t,e,n){return Array.prototype.slice.call(n,t,e)}))),Gt=u(Ut("tail",Ht(1,1/0)));function qt(){if(0===arguments.length)throw new Error("pipe requires at least one argument");return p(arguments[0].length,tt(Ft,arguments[0],Gt(arguments)))}var Kt=u((function(t){return B(t)?t.split("").reverse().join(""):Array.prototype.slice.call(t,0).reverse()}));function Yt(){if(0===arguments.length)throw new Error("compose requires at least one argument");return qt.apply(this,Kt(arguments))}function zt(){if(0===arguments.length)throw new Error("composeK requires at least one argument");var t=Array.prototype.slice.call(arguments),e=t.pop();return Yt(Yt.apply(this,z(Mt,t)),e)}function Jt(t,e){return function(){var n=this;return t.apply(n,arguments).then((function(t){return e.call(n,t)}))}}function Wt(){if(0===arguments.length)throw new Error("pipeP requires at least one argument");return p(arguments[0].length,tt(Jt,arguments[0],Gt(arguments)))}function Vt(){if(0===arguments.length)throw new Error("composeP requires at least one argument");return Wt.apply(this,Kt(arguments))}var Zt=W(0);function Xt(t){return t}var $t=u(Xt),te=c((function(t,e){if(e.length<=0)return $t;var n=Zt(e),r=Gt(e);return p(n.length,(function(){return P((function(e,n){return t.call(this,n,e)}),n.apply(this,arguments),r)}))})),ee=c((function(t,e){return te.apply(this,[t,Kt(e)])}));function ne(t){for(var e,n=[];!(e=t.next()).done;)n.push(e.value);return n}function re(t,e,n){for(var r=0,i=n.length;r<i;){if(t(e,n[r]))return!0;r+=1}return!1}var ie="function"==typeof Object.is?Object.is:function(t,e){return t===e?0!==t||1/t==1/e:t!=t&&e!=e};function ae(t){return(ae="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)}function oe(t,e,n,r){var i=ne(t);function a(t,e){return se(t,e,n.slice(),r.slice())}return!re((function(t,e){return!re(a,e,t)}),ne(e),i)}function se(t,e,n,r){if(ie(t,e))return!0;var i=jt(t);if(i!==jt(e))return!1;if(null==t||null==e)return!1;if("function"==typeof t["fantasy-land/equals"]||"function"==typeof e["fantasy-land/equals"])return"function"==typeof t["fantasy-land/equals"]&&t["fantasy-land/equals"](e)&&"function"==typeof e["fantasy-land/equals"]&&e["fantasy-land/equals"](t);if("function"==typeof t.equals||"function"==typeof e.equals)return"function"==typeof t.equals&&t.equals(e)&&"function"==typeof e.equals&&e.equals(t);switch(i){case"Arguments":case"Array":case"Object":if("function"==typeof t.constructor&&"Promise"===function(t){var e=String(t).match(/^function (\w*)/);return null==e?"":e[1]}(t.constructor))return t===e;break;case"Boolean":case"Number":case"String":if(ae(t)!==ae(e)||!ie(t.valueOf(),e.valueOf()))return!1;break;case"Date":if(!ie(t.valueOf(),e.valueOf()))return!1;break;case"Error":return t.name===e.name&&t.message===e.message;case"RegExp":if(t.source!==e.source||t.global!==e.global||t.ignoreCase!==e.ignoreCase||t.multiline!==e.multiline||t.sticky!==e.sticky||t.unicode!==e.unicode)return!1}for(var a=n.length-1;a>=0;){if(n[a]===t)return r[a]===e;a-=1}switch(i){case"Map":return t.size===e.size&&oe(t.entries(),e.entries(),n.concat([t]),r.concat([e]));case"Set":return t.size===e.size&&oe(t.values(),e.values(),n.concat([t]),r.concat([e]));case"Arguments":case"Array":case"Object":case"Boolean":case"Number":case"String":case"Date":case"Error":case"RegExp":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"ArrayBuffer":break;default:return!1}var o=Y(t);if(o.length!==Y(e).length)return!1;var s=n.concat([t]),u=r.concat([e]);for(a=o.length-1;a>=0;){var c=o[a];if(!L(c,e)||!se(e[c],t[c],s,u))return!1;a-=1}return!0}var ue=c((function(t,e){return se(t,e,[],[])}));function ce(t){return(ce="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)}function fe(t,e,n){var r,i;if("function"==typeof t.indexOf)switch(ce(e)){case"number":if(0===e){for(r=1/e;n<t.length;){if(0===(i=t[n])&&1/i===r)return n;n+=1}return-1}if(e!=e){for(;n<t.length;){if("number"==typeof(i=t[n])&&i!=i)return n;n+=1}return-1}return t.indexOf(e,n);case"string":case"boolean":case"function":case"undefined":return t.indexOf(e,n);case"object":if(null===e)return t.indexOf(e,n)}for(;n<t.length;){if(ue(t[n],e))return n;n+=1}return-1}function le(t,e){return fe(e,t,0)>=0}function pe(t){return'"'+t.replace(/\\/g,"\\\\").replace(/[\b]/g,"\\b").replace(/\f/g,"\\f").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t").replace(/\v/g,"\\v").replace(/\0/g,"\\0").replace(/"/g,'\\"')+'"'}var de=function(t){return(t<10?"0":"")+t},he="function"==typeof Date.prototype.toISOString?function(t){return t.toISOString()}:function(t){return t.getUTCFullYear()+"-"+de(t.getUTCMonth()+1)+"-"+de(t.getUTCDate())+"T"+de(t.getUTCHours())+":"+de(t.getUTCMinutes())+":"+de(t.getUTCSeconds())+"."+(t.getUTCMilliseconds()/1e3).toFixed(3).slice(2,5)+"Z"};function ye(t){return function(){return!t.apply(this,arguments)}}function Ae(t,e){for(var n=0,r=e.length,i=[];n<r;)t(e[n])&&(i[i.length]=e[n]),n+=1;return i}function be(t){return"[object Object]"===Object.prototype.toString.call(t)}var ge=function(){function t(t,e){this.xf=e,this.f=t}return t.prototype["@@transducer/init"]=I.init,t.prototype["@@transducer/result"]=I.result,t.prototype["@@transducer/step"]=function(t,e){return this.f(e)?this.xf["@@transducer/step"](t,e):t},t}(),me=c(v(["filter"],c((function(t,e){return new ge(t,e)})),(function(t,e){return be(e)?P((function(n,r){return t(e[r])&&(n[r]=e[r]),n}),{},Y(e)):Ae(t,e)}))),ve=c((function(t,e){return me(ye(t),e)}));function we(t){return(we="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)}function Ie(t,e){var n=function(n){var r=e.concat([t]);return le(n,r)?"<Circular>":Ie(n,r)},r=function(t,e){return k((function(e){return pe(e)+": "+n(t[e])}),e.slice().sort())};switch(Object.prototype.toString.call(t)){case"[object Arguments]":return"(function() { return arguments; }("+k(n,t).join(", ")+"))";case"[object Array]":return"["+k(n,t).concat(r(t,ve((function(t){return/^\d+$/.test(t)}),Y(t)))).join(", ")+"]";case"[object Boolean]":return"object"===we(t)?"new Boolean("+n(t.valueOf())+")":t.toString();case"[object Date]":return"new Date("+(isNaN(t.valueOf())?n(NaN):pe(he(t)))+")";case"[object Null]":return"null";case"[object Number]":return"object"===we(t)?"new Number("+n(t.valueOf())+")":1/t==-1/0?"-0":t.toString(10);case"[object String]":return"object"===we(t)?"new String("+n(t.valueOf())+")":pe(t);case"[object Undefined]":return"undefined";default:if("function"==typeof t.toString){var i=t.toString();if("[object Object]"!==i)return i}return"{"+r(t,Y(t)).join(", ")+"}"}}var Ee=u((function(t){return Ie(t,[])})),_e=c((function(t,e){if(g(t)){if(g(e))return t.concat(e);throw new TypeError(Ee(e)+" is not an array")}if(B(t)){if(B(e))return t+e;throw new TypeError(Ee(e)+" is not a string")}if(null!=t&&Et(t["fantasy-land/concat"]))return t["fantasy-land/concat"](e);if(null!=t&&Et(t.concat))return t.concat(e);throw new TypeError(Ee(t)+' does not have a method named "concat" or "fantasy-land/concat"')})),Ce=u((function(t){return p(tt(C,0,z((function(t){return t[0].length}),t)),(function(){for(var e=0;e<t.length;){if(t[e][0].apply(this,arguments))return t[e][1].apply(this,arguments);e+=1}}))})),ke=c((function(t,e){if(t>10)throw new Error("Constructor with greater than ten arguments");return 0===t?function(){return new e}:Bt(wt(t,(function(t,n,r,i,a,o,s,u,c,f){switch(arguments.length){case 1:return new e(t);case 2:return new e(t,n);case 3:return new e(t,n,r);case 4:return new e(t,n,r,i);case 5:return new e(t,n,r,i,a);case 6:return new e(t,n,r,i,a,o);case 7:return new e(t,n,r,i,a,o,s);case 8:return new e(t,n,r,i,a,o,s,u);case 9:return new e(t,n,r,i,a,o,s,u,c);case 10:return new e(t,n,r,i,a,o,s,u,c,f)}})))})),Be=u((function(t){return ke(t.length,t)})),xe=c(le),Se=c((function(t,e){return h(tt(C,0,$("length",e)),(function(){var n=arguments,r=this;return t.apply(r,k((function(t){return t.apply(r,n)}),e))}))})),Qe=function(){function t(t,e,n,r){this.valueFn=t,this.valueAcc=e,this.keyFn=n,this.xf=r,this.inputs={}}return t.prototype["@@transducer/init"]=I.init,t.prototype["@@transducer/result"]=function(t){var e;for(e in this.inputs)if(L(e,this.inputs)&&(t=this.xf["@@transducer/step"](t,this.inputs[e]))["@@transducer/reduced"]){t=t["@@transducer/value"];break}return this.inputs=null,this.xf["@@transducer/result"](t)},t.prototype["@@transducer/step"]=function(t,e){var n=this.keyFn(e);return this.inputs[n]=this.inputs[n]||[n,this.valueAcc],this.inputs[n][1]=this.valueFn(this.inputs[n][1],e),t},t}(),Me=d(4,[],v([],d(4,[],(function(t,e,n,r){return new Qe(t,e,n,r)})),(function(t,e,n,r){return P((function(r,i){var a=n(i);return r[a]=t(L(a,r)?r[a]:Tt(e,[],[],!1),i),r}),{},r)}))),Re=Me((function(t,e){return t+1}),0),Oe=f(-1),je=c((function(t,e){return null==e||e!=e?t:e})),Te=A((function(t,e,n){var r=t(e),i=t(n);return r>i?-1:r<i?1:0}));function Pe(t){return(Pe="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)}function De(t,e,n){var r,i=Pe(t);switch(i){case"string":case"number":return 0===t&&1/t==-1/0?!!n._items["-0"]||(e&&(n._items["-0"]=!0),!1):null!==n._nativeSet?e?(r=n._nativeSet.size,n._nativeSet.add(t),n._nativeSet.size===r):n._nativeSet.has(t):i in n._items?t in n._items[i]||(e&&(n._items[i][t]=!0),!1):(e&&(n._items[i]={},n._items[i][t]=!0),!1);case"boolean":if(i in n._items){var a=t?1:0;return!!n._items[i][a]||(e&&(n._items[i][a]=!0),!1)}return e&&(n._items[i]=t?[!1,!0]:[!0,!1]),!1;case"function":return null!==n._nativeSet?e?(r=n._nativeSet.size,n._nativeSet.add(t),n._nativeSet.size===r):n._nativeSet.has(t):i in n._items?!!le(t,n._items[i])||(e&&n._items[i].push(t),!1):(e&&(n._items[i]=[t]),!1);case"undefined":return!!n._items[i]||(e&&(n._items[i]=!0),!1);case"object":if(null===t)return!!n._items.null||(e&&(n._items.null=!0),!1);default:return(i=Object.prototype.toString.call(t))in n._items?!!le(t,n._items[i])||(e&&n._items[i].push(t),!1):(e&&(n._items[i]=[t]),!1)}}var Ne=function(){function t(){this._nativeSet="function"==typeof Set?new Set:null,this._items={}}return t.prototype.add=function(t){return!De(t,!0,this)},t.prototype.has=function(t){return De(t,!1,this)},t}(),Le=c((function(t,e){for(var n=[],r=0,i=t.length,a=e.length,o=new Ne,s=0;s<a;s+=1)o.add(e[s]);for(;r<i;)o.add(t[r])&&(n[n.length]=t[r]),r+=1;return n})),Fe=A((function(t,e,n){for(var r=[],i=0,a=e.length;i<a;)re(t,e[i],n)||re(t,e[i],r)||r.push(e[i]),i+=1;return r})),Ue=c((function(t,e){var n={};for(var r in e)n[r]=e[r];return delete n[t],n})),He=A((function(t,e,n){var r=Array.prototype.slice.call(n,0);return r.splice(t,e),r})),Ge=A((function(t,e,n){return b(t,nt(e),n)})),qe=c((function t(e,n){switch(e.length){case 0:return n;case 1:return J(e[0])&&g(n)?He(e[0],1,n):Ue(e[0],n);default:var r=e[0],i=Array.prototype.slice.call(e,1);return null==n[r]?n:J(r)&&g(n)?Ge(r,t(i,n[r]),n):gt(r,t(i,n[r]),n)}})),Ke=c((function(t,e){return t/e})),Ye=function(){function t(t,e){this.xf=e,this.n=t}return t.prototype["@@transducer/init"]=I.init,t.prototype["@@transducer/result"]=I.result,t.prototype["@@transducer/step"]=function(t,e){return this.n>0?(this.n-=1,t):this.xf["@@transducer/step"](t,e)},t}(),ze=c(v(["drop"],c((function(t,e){return new Ye(t,e)})),(function(t,e){return Ht(Math.max(0,t),1/0,e)}))),Je=function(){function t(t,e){this.xf=e,this.n=t,this.i=0}return t.prototype["@@transducer/init"]=I.init,t.prototype["@@transducer/result"]=I.result,t.prototype["@@transducer/step"]=function(t,e){this.i+=1;var n=0===this.n?t:this.xf["@@transducer/step"](t,e);return this.n>=0&&this.i>=this.n?w(n):n},t}(),We=c(v(["take"],c((function(t,e){return new Je(t,e)})),(function(t,e){return Ht(0,t<0?1/0:t,e)})));function Ve(t,e){return We(t<e.length?e.length-t:0,e)}var Ze=function(){function t(t,e){this.xf=e,this.pos=0,this.full=!1,this.acc=new Array(t)}return t.prototype["@@transducer/init"]=I.init,t.prototype["@@transducer/result"]=function(t){return this.acc=null,this.xf["@@transducer/result"](t)},t.prototype["@@transducer/step"]=function(t,e){return this.full&&(t=this.xf["@@transducer/step"](t,this.acc[this.pos])),this.store(e),t},t.prototype.store=function(t){this.acc[this.pos]=t,this.pos+=1,this.pos===this.acc.length&&(this.pos=0,this.full=!0)},t}(),Xe=c(v([],c((function(t,e){return new Ze(t,e)})),Ve));function $e(t,e){for(var n=e.length-1;n>=0&&t(e[n]);)n-=1;return Ht(0,n+1,e)}var tn=function(){function t(t,e){this.f=t,this.retained=[],this.xf=e}return t.prototype["@@transducer/init"]=I.init,t.prototype["@@transducer/result"]=function(t){return this.retained=null,this.xf["@@transducer/result"](t)},t.prototype["@@transducer/step"]=function(t,e){return this.f(e)?this.retain(t,e):this.flush(t,e)},t.prototype.flush=function(t,e){return t=P(this.xf["@@transducer/step"],t,this.retained),this.retained=[],this.xf["@@transducer/step"](t,e)},t.prototype.retain=function(t,e){return this.retained.push(e),t},t}(),en=c(v([],c((function(t,e){return new tn(t,e)})),$e)),nn=function(){function t(t,e){this.xf=e,this.pred=t,this.lastValue=void 0,this.seenFirstValue=!1}return t.prototype["@@transducer/init"]=I.init,t.prototype["@@transducer/result"]=I.result,t.prototype["@@transducer/step"]=function(t,e){var n=!1;return this.seenFirstValue?this.pred(this.lastValue,e)&&(n=!0):this.seenFirstValue=!0,this.lastValue=e,n?t:this.xf["@@transducer/step"](t,e)},t}(),rn=c((function(t,e){return new nn(t,e)})),an=W(-1),on=c(v([],rn,(function(t,e){var n=[],r=1,i=e.length;if(0!==i)for(n[0]=e[0];r<i;)t(an(n),e[r])||(n[n.length]=e[r]),r+=1;return n}))),sn=u(v([],rn(ue),on(ue))),un=function(){function t(t,e){this.xf=e,this.f=t}return t.prototype["@@transducer/init"]=I.init,t.prototype["@@transducer/result"]=I.result,t.prototype["@@transducer/step"]=function(t,e){if(this.f){if(this.f(e))return t;this.f=null}return this.xf["@@transducer/step"](t,e)},t}(),cn=c(v(["dropWhile"],c((function(t,e){return new un(t,e)})),(function(t,e){for(var n=0,r=e.length;n<r&&t(e[n]);)n+=1;return Ht(n,1/0,e)}))),fn=c((function(t,e){return t||e})),ln=c((function(t,e){return Et(t)?function(){return t.apply(this,arguments)||e.apply(this,arguments)}:Ct(fn)(t,e)})),pn=u((function(t){return null!=t&&"function"==typeof t["fantasy-land/empty"]?t["fantasy-land/empty"]():null!=t&&null!=t.constructor&&"function"==typeof t.constructor["fantasy-land/empty"]?t.constructor["fantasy-land/empty"]():null!=t&&"function"==typeof t.empty?t.empty():null!=t&&null!=t.constructor&&"function"==typeof t.constructor.empty?t.constructor.empty():g(t)?[]:B(t)?"":be(t)?{}:U(t)?function(){return arguments}():void 0})),dn=c((function(t,e){return ze(t>=0?e.length-t:0,e)})),hn=c((function(t,e){return ue(dn(t.length,e),t)})),yn=A((function(t,e,n){return ue(t(e),t(n))})),An=A((function(t,e,n){return ue(e[t],n[t])}));function bn(t){return(bn="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 gn=c((function t(e,n){var r,i,a,o=n instanceof Array?[]:{};for(i in n)a=bn(r=e[i]),o[i]="function"===a?r(n[i]):r&&"object"===a?t(r,n[i]):n[i];return o})),mn=function(){function t(t,e){this.xf=e,this.f=t,this.found=!1}return t.prototype["@@transducer/init"]=I.init,t.prototype["@@transducer/result"]=function(t){return this.found||(t=this.xf["@@transducer/step"](t,void 0)),this.xf["@@transducer/result"](t)},t.prototype["@@transducer/step"]=function(t,e){return this.f(e)&&(this.found=!0,t=w(this.xf["@@transducer/step"](t,e))),t},t}(),vn=c(v(["find"],c((function(t,e){return new mn(t,e)})),(function(t,e){for(var n=0,r=e.length;n<r;){if(t(e[n]))return e[n];n+=1}}))),wn=function(){function t(t,e){this.xf=e,this.f=t,this.idx=-1,this.found=!1}return t.prototype["@@transducer/init"]=I.init,t.prototype["@@transducer/result"]=function(t){return this.found||(t=this.xf["@@transducer/step"](t,-1)),this.xf["@@transducer/result"](t)},t.prototype["@@transducer/step"]=function(t,e){return this.idx+=1,this.f(e)&&(this.found=!0,t=w(this.xf["@@transducer/step"](t,this.idx))),t},t}(),In=c(v([],c((function(t,e){return new wn(t,e)})),(function(t,e){for(var n=0,r=e.length;n<r;){if(t(e[n]))return n;n+=1}return-1}))),En=function(){function t(t,e){this.xf=e,this.f=t}return t.prototype["@@transducer/init"]=I.init,t.prototype["@@transducer/result"]=function(t){return this.xf["@@transducer/result"](this.xf["@@transducer/step"](t,this.last))},t.prototype["@@transducer/step"]=function(t,e){return this.f(e)&&(this.last=e),t},t}(),_n=c(v([],c((function(t,e){return new En(t,e)})),(function(t,e){for(var n=e.length-1;n>=0;){if(t(e[n]))return e[n];n-=1}}))),Cn=function(){function t(t,e){this.xf=e,this.f=t,this.idx=-1,this.lastIdx=-1}return t.prototype["@@transducer/init"]=I.init,t.prototype["@@transducer/result"]=function(t){return this.xf["@@transducer/result"](this.xf["@@transducer/step"](t,this.lastIdx))},t.prototype["@@transducer/step"]=function(t,e){return this.idx+=1,this.f(e)&&(this.lastIdx=this.idx),t},t}(),kn=c(v([],c((function(t,e){return new Cn(t,e)})),(function(t,e){for(var n=e.length-1;n>=0;){if(t(e[n]))return n;n-=1}return-1}))),Bn=u(St(!0)),xn=u((function(t){return h(t.length,(function(e,n){var r=Array.prototype.slice.call(arguments,0);return r[0]=n,r[1]=e,t.apply(this,r)}))})),Sn=c(Ut("forEach",(function(t,e){for(var n=e.length,r=0;r<n;)t(e[r]),r+=1;return e}))),Qn=c((function(t,e){for(var n=Y(e),r=0;r<n.length;){var i=n[r];t(e[i],i,e),r+=1}return e})),Mn=u((function(t){for(var e={},n=0;n<t.length;)e[t[n][0]]=t[n][1],n+=1;return e})),Rn=c(Ut("groupBy",Me((function(t,e){return null==t&&(t=[]),t.push(e),t}),null))),On=c((function(t,e){for(var n=[],r=0,i=e.length;r<i;){for(var a=r+1;a<i&&t(e[a-1],e[a]);)a+=1;n.push(e.slice(r,a)),r=a}return n})),jn=c((function(t,e){return t>e})),Tn=c((function(t,e){return t>=e})),Pn=c((function(t,e){if(0===t.length||mt(e))return!1;for(var n=e,r=0;r<t.length;){if(mt(n)||!L(t[r],n))return!1;n=n[t[r]],r+=1}return!0})),Dn=c((function(t,e){return Pn([t],e)})),Nn=c((function(t,e){return t in e})),Ln=c(ie),Fn=A((function(t,e,n){return h(Math.max(t.length,e.length,n.length),(function(){return t.apply(this,arguments)?e.apply(this,arguments):n.apply(this,arguments)}))})),Un=f(1),Hn=c(le),Gn=Me((function(t,e){return e}),null),qn=c((function(t,e){return"function"!=typeof e.indexOf||g(e)?fe(e,t,0):e.indexOf(t)})),Kn=Ht(0,-1),Yn=A((function(t,e,n){return Ae((function(e){return re(t,e,n)}),e)})),zn=A((function(t,e,n){t=t<n.length&&t>=0?t:n.length;var r=Array.prototype.slice.call(n,0);return r.splice(t,0,e),r})),Jn=A((function(t,e,n){return t=t<n.length&&t>=0?t:n.length,[].concat(Array.prototype.slice.call(n,0,t),e,Array.prototype.slice.call(n,t))})),Wn=c((function(t,e){for(var n,r,i=new Ne,a=[],o=0;o<e.length;)n=t(r=e[o]),i.add(n)&&a.push(r),o+=1;return a})),Vn=Wn($t),Zn=c((function(t,e){var n,r;return t.length>e.length?(n=t,r=e):(n=e,r=t),Vn(Ae(xn(le)(n),r))})),Xn=c(Ut("intersperse",(function(t,e){for(var n=[],r=0,i=e.length;r<i;)r===i-1?n.push(e[r]):n.push(e[r],t),r+=1;return n})));var $n="function"==typeof Object.assign?Object.assign:function(t){if(null==t)throw new TypeError("Cannot convert undefined or null to object");for(var e=Object(t),n=1,r=arguments.length;n<r;){var i=arguments[n];if(null!=i)for(var a in i)L(a,i)&&(e[a]=i[a]);n+=1}return e},tr=c((function(t,e){var n={};return n[t]=e,n}));function er(t){return(er="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 nr={"@@transducer/init":Array,"@@transducer/step":function(t,e){return t.push(e),t},"@@transducer/result":Xt},rr={"@@transducer/init":String,"@@transducer/step":function(t,e){return t+e},"@@transducer/result":Xt},ir={"@@transducer/init":Object,"@@transducer/step":function(t,e){return $n(t,S(e)?tr(e[0],e[1]):e)},"@@transducer/result":Xt};var ar=A((function(t,e,n){return m(t)?P(e(t),t["@@transducer/init"](),n):P(e(function(t){if(m(t))return t;if(S(t))return nr;if("string"==typeof t)return rr;if("object"===er(t))return ir;throw new Error("Cannot create transformer for "+t)}(t)),Tt(t,[],[],!1),n)})),or=u((function(t){for(var e=Y(t),n=e.length,r=0,i={};r<n;){var a=e[r],o=t[a],s=L(o,i)?i[o]:i[o]=[];s[s.length]=a,r+=1}return i})),sr=u((function(t){for(var e=Y(t),n=e.length,r=0,i={};r<n;){var a=e[r];i[t[a]]=a,r+=1}return i})),ur=c((function(t,e){return h(t+1,(function(){var n=arguments[t];if(null!=n&&Et(n[e]))return n[e].apply(n,Array.prototype.slice.call(arguments,0,t));throw new TypeError(Ee(n)+' does not have a method named "'+e+'"')}))})),cr=c((function(t,e){return null!=e&&e.constructor===t||e instanceof t})),fr=u((function(t){return null!=t&&ue(t,pn(t))})),lr=ur(1,"join"),pr=u((function(t){return Se((function(){return Array.prototype.slice.call(arguments,0)}),t)})),dr=u((function(t){var e,n=[];for(e in t)n[n.length]=e;return n})),hr=c((function(t,e){if("function"!=typeof e.lastIndexOf||g(e)){for(var n=e.length-1;n>=0;){if(ue(e[n],t))return n;n-=1}return-1}return e.lastIndexOf(t)}));function yr(t){return"[object Number]"===Object.prototype.toString.call(t)}var Ar=u((function(t){return null!=t&&yr(t.length)?t.length:NaN})),br=c((function(t,e){return function(n){return function(r){return z((function(t){return e(t,r)}),n(t(r)))}}})),gr=u((function(t){return br(W(t),Ge(t))})),mr=u((function(t){return br(Z(t),vt(t))})),vr=u((function(t){return br(X(t),gt(t))})),wr=c((function(t,e){return t<e})),Ir=c((function(t,e){return t<=e})),Er=A((function(t,e,n){for(var r=0,i=n.length,a=[],o=[e];r<i;)o=t(o[0],n[r]),a[r]=o[1],r+=1;return[o[0],a]})),_r=A((function(t,e,n){for(var r=n.length-1,i=[],a=[e];r>=0;)a=t(a[0],n[r]),i[r]=a[1],r-=1;return[a[0],i]})),Cr=c((function(t,e){return P((function(n,r){return n[r]=t(e[r],r,e),n}),{},Y(e))})),kr=c((function(t,e){return e.match(t)||[]})),Br=c((function(t,e){return J(t)?!J(e)||e<1?NaN:(t%e+e)%e:NaN})),xr=A((function(t,e,n){return t(n)>t(e)?n:e})),Sr=tt(f,0),Qr=u((function(t){return Sr(t)/t.length})),Mr=u((function(t){var e=t.length;if(0===e)return NaN;var n=2-e%2,r=(e-n)/2;return Qr(Array.prototype.slice.call(t,0).sort((function(t,e){return t<e?-1:t>e?1:0})).slice(r,r+n))})),Rr=c((function(t,e){var n={};return p(e.length,(function(){var r=t.apply(this,arguments);return L(r,n)||(n[r]=e.apply(this,arguments)),n[r]}))})),Or=c((function(t,e){return $n({},t,e)})),jr=u((function(t){return $n.apply(null,[{}].concat(t))})),Tr=A((function(t,e,n){var r,i={};for(r in e)L(r,e)&&(i[r]=L(r,n)?t(r,e[r],n[r]):e[r]);for(r in n)L(r,n)&&!L(r,i)&&(i[r]=n[r]);return i})),Pr=A((function t(e,n,r){return Tr((function(n,r,i){return be(r)&&be(i)?t(e,r,i):e(n,r,i)}),n,r)})),Dr=c((function(t,e){return Pr((function(t,e,n){return e}),t,e)})),Nr=c((function(t,e){return Pr((function(t,e,n){return n}),t,e)})),Lr=A((function(t,e,n){return Pr((function(e,n,r){return t(n,r)}),e,n)})),Fr=c((function(t,e){return $n({},e,t)})),Ur=c((function(t,e){return $n({},t,e)})),Hr=A((function(t,e,n){return Tr((function(e,n,r){return t(n,r)}),e,n)})),Gr=c((function(t,e){return e<t?e:t})),qr=A((function(t,e,n){return t(n)<t(e)?n:e})),Kr=c((function(t,e){return t%e})),Yr=A((function(t,e,n){var r=n.length,i=n.slice(),a=t<0?r+t:t,o=e<0?r+e:e,s=i.splice(a,1);return a<0||a>=n.length||o<0||o>=n.length?n:[].concat(i.slice(0,o)).concat(s).concat(i.slice(o,n.length))})),zr=c((function(t,e){return t*e})),Jr=u((function(t){return-t})),Wr=c((function(t,e){return _(ye(t),e)})),Vr=u((function(t){return h(t<0?1:t+1,(function(){return W(t,arguments)}))})),Zr=A((function(t,e,n){return t(e(n))}));function Xr(t){return[t]}var $r=u(Xr),ti=c((function(t,e){for(var n={},r={},i=0,a=t.length;i<a;)r[t[i]]=1,i+=1;for(var o in e)r.hasOwnProperty(o)||(n[o]=e[o]);return n})),ei=u((function(t){var e,n=!1;return p(t.length,(function(){return n?e:(n=!0,e=t.apply(this,arguments))}))}));function ni(t,e){if(null==e||!Et(e.then))throw new TypeError("`"+t+"` expected a Promise, received "+Ie(e,[]))}var ri=c((function(t,e){return ni("otherwise",e),e.then(null,t)})),ii=A((function(t,e,n){return t((function(t){return function t(e){return{value:e,map:function(n){return t(n(e))}}}(e(t))}))(n).value})),ai=c((function(t,e){return[t,e]}));function oi(t){return c((function(e,n){return p(Math.max(0,e.length-n.length),(function(){return e.apply(this,t(n,arguments))}))}))}var si=oi(l),ui=oi(xn(l)),ci=pr([me,ve]),fi=A((function(t,e,n){return ue(Z(t,n),e)})),li=A((function(t,e,n){return je(t,Z(e,n))})),pi=A((function(t,e,n){return t(Z(e,n))})),di=c((function(t,e){for(var n={},r=0;r<t.length;)t[r]in e&&(n[t[r]]=e[t[r]]),r+=1;return n})),hi=c((function(t,e){for(var n={},r=0,i=t.length;r<i;){var a=t[r];n[a]=e[a],r+=1}return n})),yi=c((function(t,e){var n={};for(var r in e)t(e[r],r,e)&&(n[r]=e[r]);return n}));function Ai(){if(0===arguments.length)throw new Error("pipeK requires at least one argument");return zt.apply(this,Kt(arguments))}var bi=c((function(t,e){return l([t],e)})),gi=tt(zr,1),mi=c((function(t,e){return h(e.length,(function(){for(var n=[],r=0;r<e.length;)n.push(e[r].call(this,arguments[r])),r+=1;return t.apply(this,n.concat(Array.prototype.slice.call(arguments,e.length)))}))})),vi=mi(k,[hi,$t]),wi=A((function(t,e,n){return ue(e,n[t])})),Ii=A((function(t,e,n){return cr(t,n[e])})),Ei=A((function(t,e,n){return li(t,[e],n)})),_i=A((function(t,e,n){return t(n[e])})),Ci=c((function(t,e){return t.map((function(t){return Z([t],e)}))})),ki=c((function(t,e){if(!yr(t)||!yr(e))throw new TypeError("Both arguments to range must be numbers");for(var n=[],r=t;r<e;)n.push(r),r+=1;return n})),Bi=A((function(t,e,n){for(var r=n.length-1;r>=0;)e=t(n[r],e),r-=1;return e})),xi=d(4,[],(function(t,e,n,r){return P((function(n,r){return t(n,r)?e(n,r):w(n)}),n,r)})),Si=u(w),Qi=c((function(t,e){var n,r=Number(e),i=0;if(r<0||isNaN(r))throw new RangeError("n must be a non-negative number");for(n=new Array(r);i<r;)n[i]=t(i),i+=1;return n})),Mi=c((function(t,e){return Qi(nt(t),e)})),Ri=A((function(t,e,n){return n.replace(t,e)})),Oi=A((function(t,e,n){for(var r=0,i=n.length,a=[e];r<i;)e=t(e,n[r]),a[r+1]=e,r+=1;return a})),ji=c((function(t,e){return"function"==typeof e.sequence?e.sequence(t):Bi((function(t,e){return st(z(bi,t),e)}),t([]),e)})),Ti=A((function(t,e,n){return ii(t,nt(e),n)})),Pi=c((function(t,e){return Array.prototype.slice.call(e,0).sort(t)})),Di=c((function(t,e){return Array.prototype.slice.call(e,0).sort((function(e,n){var r=t(e),i=t(n);return r<i?-1:r>i?1:0}))})),Ni=c((function(t,e){return Array.prototype.slice.call(e,0).sort((function(e,n){for(var r=0,i=0;0===r&&i<t.length;)r=t[i](e,n),i+=1;return r}))})),Li=ur(1,"split"),Fi=c((function(t,e){return[Ht(0,t,e),Ht(t,Ar(e),e)]})),Ui=c((function(t,e){if(t<=0)throw new Error("First argument to splitEvery must be a positive integer");for(var n=[],r=0;r<e.length;)n.push(Ht(r,r+=t,e));return n})),Hi=c((function(t,e){for(var n=0,r=e.length,i=[];n<r&&!t(e[n]);)i.push(e[n]),n+=1;return[i,Array.prototype.slice.call(e,n)]})),Gi=c((function(t,e){return ue(We(t.length,e),t)})),qi=c((function(t,e){return Number(t)-Number(e)})),Ki=c((function(t,e){return _e(Le(t,e),Le(e,t))})),Yi=A((function(t,e,n){return _e(Fe(t,e,n),Fe(t,n,e))})),zi=c((function(t,e){for(var n=e.length-1;n>=0&&t(e[n]);)n-=1;return Ht(n+1,1/0,e)})),Ji=function(){function t(t,e){this.xf=e,this.f=t}return t.prototype["@@transducer/init"]=I.init,t.prototype["@@transducer/result"]=I.result,t.prototype["@@transducer/step"]=function(t,e){return this.f(e)?this.xf["@@transducer/step"](t,e):w(t)},t}(),Wi=c(v(["takeWhile"],c((function(t,e){return new Ji(t,e)})),(function(t,e){for(var n=0,r=e.length;n<r&&t(e[n]);)n+=1;return Ht(0,n,e)}))),Vi=function(){function t(t,e){this.xf=e,this.f=t}return t.prototype["@@transducer/init"]=I.init,t.prototype["@@transducer/result"]=I.result,t.prototype["@@transducer/step"]=function(t,e){return this.f(e),this.xf["@@transducer/step"](t,e)},t}(),Zi=c(v([],c((function(t,e){return new Vi(t,e)})),(function(t,e){return t(e),e})));var Xi=c((function(t,e){if(n=t,"[object RegExp]"!==Object.prototype.toString.call(n))throw new TypeError("‘test’ requires a value of type RegExp as its first argument; received "+Ee(t));var n;return Ot(t).test(e)})),$i=c((function(t,e){return ni("andThen",e),e.then(t)})),ta=ur(0,"toLowerCase"),ea=u((function(t){var e=[];for(var n in t)L(n,t)&&(e[e.length]=[n,t[n]]);return e})),na=u((function(t){var e=[];for(var n in t)e[e.length]=[n,t[n]];return e})),ra=ur(0,"toUpperCase"),ia=h(4,(function(t,e,n,r){return P(t("function"==typeof e?M(e):e),n,r)})),aa=u((function(t){for(var e=0,n=[];e<t.length;){for(var r=t[e],i=0;i<r.length;)void 0===n[i]&&(n[i]=[]),n[i].push(r[i]),i+=1;e+=1}return n})),oa=A((function(t,e,n){return"function"==typeof n["fantasy-land/traverse"]?n["fantasy-land/traverse"](e,t):ji(t,z(e,n))})),sa="\t\n\v\f\r                 \u2028\u2029\ufeff",ua=u("function"==typeof String.prototype.trim&&!sa.trim()&&"​".trim()?function(t){return t.trim()}:function(t){var e=new RegExp("^["+sa+"]["+sa+"]*"),n=new RegExp("["+sa+"]["+sa+"]*$");return t.replace(e,"").replace(n,"")}),ca=c((function(t,e){return p(t.length,(function(){try{return t.apply(this,arguments)}catch(t){return e.apply(this,l([t],arguments))}}))})),fa=u((function(t){return function(){return t(Array.prototype.slice.call(arguments,0))}})),la=u((function(t){return wt(1,t)})),pa=c((function(t,e){return h(t,(function(){for(var n,r=1,i=e,a=0;r<=t&&"function"==typeof i;)n=r===t?arguments.length:a+i.length,i=i.apply(this,Array.prototype.slice.call(arguments,a,n)),r+=1,a=n;return i}))})),da=c((function(t,e){for(var n=t(e),r=[];n&&n.length;)r[r.length]=n[0],n=t(n[1]);return r})),ha=c(Yt(Vn,l)),ya=c((function(t,e){for(var n,r=0,i=e.length,a=[];r<i;)re(t,n=e[r],a)||(a[a.length]=n),r+=1;return a})),Aa=A((function(t,e,n){return ya(t,l(e,n))})),ba=A((function(t,e,n){return t(n)?n:e(n)})),ga=Mt(Xt),ma=A((function(t,e,n){for(var r=n;!t(r);)r=e(r);return r})),va=u((function(t){var e,n=[];for(e in t)n[n.length]=t[e];return n})),wa=function(t){return{value:t,"fantasy-land/map":function(){return this}}},Ia=c((function(t,e){return t(wa)(e).value})),Ea=A((function(t,e,n){return t(n)?e(n):n})),_a=c((function(t,e){for(var n in t)if(L(n,t)&&!t[n](e[n]))return!1;return!0})),Ca=c((function(t,e){return _a(z(ue,t),e)})),ka=c((function(t,e){return ve(xn(le)(t),e)})),Ba=c((function(t,e){return Boolean(!t^!e)})),xa=c((function(t,e){for(var n,r=0,i=t.length,a=e.length,o=[];r<i;){for(n=0;n<a;)o[o.length]=[t[r],e[n]],n+=1;r+=1}return o})),Sa=c((function(t,e){for(var n=[],r=0,i=Math.min(t.length,e.length);r<i;)n[r]=[t[r],e[r]],r+=1;return n})),Qa=c((function(t,e){for(var n=0,r=Math.min(t.length,e.length),i={};n<r;)i[t[n]]=e[n],n+=1;return i})),Ma=A((function(t,e,n){for(var r=[],i=0,a=Math.min(e.length,n.length);i<a;)r[i]=t(e[i],n[i]),i+=1;return r})),Ra=u((function(t){return h(t.length,(function(){var e=arguments;return function(){return t.apply(this,e)}}))}))},function(t,e,n){"use strict";var r;n.r(e),n.d(e,"v1",(function(){return y})),n.d(e,"v3",(function(){return C})),n.d(e,"v4",(function(){return k})),n.d(e,"v5",(function(){return S})),n.d(e,"NIL",(function(){return Q})),n.d(e,"version",(function(){return M})),n.d(e,"validate",(function(){return s})),n.d(e,"stringify",(function(){return p})),n.d(e,"parse",(function(){return A}));var i=new Uint8Array(16);function a(){if(!r&&!(r="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return r(i)}var o=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;for(var s=function(t){return"string"==typeof t&&o.test(t)},u=[],c=0;c<256;++c)u.push((c+256).toString(16).substr(1));var f,l,p=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(u[t[e+0]]+u[t[e+1]]+u[t[e+2]]+u[t[e+3]]+"-"+u[t[e+4]]+u[t[e+5]]+"-"+u[t[e+6]]+u[t[e+7]]+"-"+u[t[e+8]]+u[t[e+9]]+"-"+u[t[e+10]]+u[t[e+11]]+u[t[e+12]]+u[t[e+13]]+u[t[e+14]]+u[t[e+15]]).toLowerCase();if(!s(n))throw TypeError("Stringified UUID is invalid");return n},d=0,h=0;var y=function(t,e,n){var r=e&&n||0,i=e||new Array(16),o=(t=t||{}).node||f,s=void 0!==t.clockseq?t.clockseq:l;if(null==o||null==s){var u=t.random||(t.rng||a)();null==o&&(o=f=[1|u[0],u[1],u[2],u[3],u[4],u[5]]),null==s&&(s=l=16383&(u[6]<<8|u[7]))}var c=void 0!==t.msecs?t.msecs:Date.now(),y=void 0!==t.nsecs?t.nsecs:h+1,A=c-d+(y-h)/1e4;if(A<0&&void 0===t.clockseq&&(s=s+1&16383),(A<0||c>d)&&void 0===t.nsecs&&(y=0),y>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");d=c,h=y,l=s;var b=(1e4*(268435455&(c+=122192928e5))+y)%4294967296;i[r++]=b>>>24&255,i[r++]=b>>>16&255,i[r++]=b>>>8&255,i[r++]=255&b;var g=c/4294967296*1e4&268435455;i[r++]=g>>>8&255,i[r++]=255&g,i[r++]=g>>>24&15|16,i[r++]=g>>>16&255,i[r++]=s>>>8|128,i[r++]=255&s;for(var m=0;m<6;++m)i[r+m]=o[m];return e||p(i)};var A=function(t){if(!s(t))throw TypeError("Invalid UUID");var e,n=new Uint8Array(16);return n[0]=(e=parseInt(t.slice(0,8),16))>>>24,n[1]=e>>>16&255,n[2]=e>>>8&255,n[3]=255&e,n[4]=(e=parseInt(t.slice(9,13),16))>>>8,n[5]=255&e,n[6]=(e=parseInt(t.slice(14,18),16))>>>8,n[7]=255&e,n[8]=(e=parseInt(t.slice(19,23),16))>>>8,n[9]=255&e,n[10]=(e=parseInt(t.slice(24,36),16))/1099511627776&255,n[11]=e/4294967296&255,n[12]=e>>>24&255,n[13]=e>>>16&255,n[14]=e>>>8&255,n[15]=255&e,n};var b=function(t,e,n){function r(t,r,i,a){if("string"==typeof t&&(t=function(t){t=unescape(encodeURIComponent(t));for(var e=[],n=0;n<t.length;++n)e.push(t.charCodeAt(n));return e}(t)),"string"==typeof r&&(r=A(r)),16!==r.length)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var o=new Uint8Array(16+t.length);if(o.set(r),o.set(t,r.length),(o=n(o))[6]=15&o[6]|e,o[8]=63&o[8]|128,i){a=a||0;for(var s=0;s<16;++s)i[a+s]=o[s];return i}return p(o)}try{r.name=t}catch(t){}return r.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8",r.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8",r};function g(t){return 14+(t+64>>>9<<4)+1}function m(t,e){var n=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(n>>16)<<16|65535&n}function v(t,e,n,r,i,a){return m((o=m(m(e,t),m(r,a)))<<(s=i)|o>>>32-s,n);var o,s}function w(t,e,n,r,i,a,o){return v(e&n|~e&r,t,e,i,a,o)}function I(t,e,n,r,i,a,o){return v(e&r|n&~r,t,e,i,a,o)}function E(t,e,n,r,i,a,o){return v(e^n^r,t,e,i,a,o)}function _(t,e,n,r,i,a,o){return v(n^(e|~r),t,e,i,a,o)}var C=b("v3",48,(function(t){if("string"==typeof t){var e=unescape(encodeURIComponent(t));t=new Uint8Array(e.length);for(var n=0;n<e.length;++n)t[n]=e.charCodeAt(n)}return function(t){for(var e=[],n=32*t.length,r=0;r<n;r+=8){var i=t[r>>5]>>>r%32&255,a=parseInt("0123456789abcdef".charAt(i>>>4&15)+"0123456789abcdef".charAt(15&i),16);e.push(a)}return e}(function(t,e){t[e>>5]|=128<<e%32,t[g(e)-1]=e;for(var n=1732584193,r=-271733879,i=-1732584194,a=271733878,o=0;o<t.length;o+=16){var s=n,u=r,c=i,f=a;n=w(n,r,i,a,t[o],7,-680876936),a=w(a,n,r,i,t[o+1],12,-389564586),i=w(i,a,n,r,t[o+2],17,606105819),r=w(r,i,a,n,t[o+3],22,-1044525330),n=w(n,r,i,a,t[o+4],7,-176418897),a=w(a,n,r,i,t[o+5],12,1200080426),i=w(i,a,n,r,t[o+6],17,-1473231341),r=w(r,i,a,n,t[o+7],22,-45705983),n=w(n,r,i,a,t[o+8],7,1770035416),a=w(a,n,r,i,t[o+9],12,-1958414417),i=w(i,a,n,r,t[o+10],17,-42063),r=w(r,i,a,n,t[o+11],22,-1990404162),n=w(n,r,i,a,t[o+12],7,1804603682),a=w(a,n,r,i,t[o+13],12,-40341101),i=w(i,a,n,r,t[o+14],17,-1502002290),r=w(r,i,a,n,t[o+15],22,1236535329),n=I(n,r,i,a,t[o+1],5,-165796510),a=I(a,n,r,i,t[o+6],9,-1069501632),i=I(i,a,n,r,t[o+11],14,643717713),r=I(r,i,a,n,t[o],20,-373897302),n=I(n,r,i,a,t[o+5],5,-701558691),a=I(a,n,r,i,t[o+10],9,38016083),i=I(i,a,n,r,t[o+15],14,-660478335),r=I(r,i,a,n,t[o+4],20,-405537848),n=I(n,r,i,a,t[o+9],5,568446438),a=I(a,n,r,i,t[o+14],9,-1019803690),i=I(i,a,n,r,t[o+3],14,-187363961),r=I(r,i,a,n,t[o+8],20,1163531501),n=I(n,r,i,a,t[o+13],5,-1444681467),a=I(a,n,r,i,t[o+2],9,-51403784),i=I(i,a,n,r,t[o+7],14,1735328473),r=I(r,i,a,n,t[o+12],20,-1926607734),n=E(n,r,i,a,t[o+5],4,-378558),a=E(a,n,r,i,t[o+8],11,-2022574463),i=E(i,a,n,r,t[o+11],16,1839030562),r=E(r,i,a,n,t[o+14],23,-35309556),n=E(n,r,i,a,t[o+1],4,-1530992060),a=E(a,n,r,i,t[o+4],11,1272893353),i=E(i,a,n,r,t[o+7],16,-155497632),r=E(r,i,a,n,t[o+10],23,-1094730640),n=E(n,r,i,a,t[o+13],4,681279174),a=E(a,n,r,i,t[o],11,-358537222),i=E(i,a,n,r,t[o+3],16,-722521979),r=E(r,i,a,n,t[o+6],23,76029189),n=E(n,r,i,a,t[o+9],4,-640364487),a=E(a,n,r,i,t[o+12],11,-421815835),i=E(i,a,n,r,t[o+15],16,530742520),r=E(r,i,a,n,t[o+2],23,-995338651),n=_(n,r,i,a,t[o],6,-198630844),a=_(a,n,r,i,t[o+7],10,1126891415),i=_(i,a,n,r,t[o+14],15,-1416354905),r=_(r,i,a,n,t[o+5],21,-57434055),n=_(n,r,i,a,t[o+12],6,1700485571),a=_(a,n,r,i,t[o+3],10,-1894986606),i=_(i,a,n,r,t[o+10],15,-1051523),r=_(r,i,a,n,t[o+1],21,-2054922799),n=_(n,r,i,a,t[o+8],6,1873313359),a=_(a,n,r,i,t[o+15],10,-30611744),i=_(i,a,n,r,t[o+6],15,-1560198380),r=_(r,i,a,n,t[o+13],21,1309151649),n=_(n,r,i,a,t[o+4],6,-145523070),a=_(a,n,r,i,t[o+11],10,-1120210379),i=_(i,a,n,r,t[o+2],15,718787259),r=_(r,i,a,n,t[o+9],21,-343485551),n=m(n,s),r=m(r,u),i=m(i,c),a=m(a,f)}return[n,r,i,a]}(function(t){if(0===t.length)return[];for(var e=8*t.length,n=new Uint32Array(g(e)),r=0;r<e;r+=8)n[r>>5]|=(255&t[r/8])<<r%32;return n}(t),8*t.length))}));var k=function(t,e,n){var r=(t=t||{}).random||(t.rng||a)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,e){n=n||0;for(var i=0;i<16;++i)e[n+i]=r[i];return e}return p(r)};function B(t,e,n,r){switch(t){case 0:return e&n^~e&r;case 1:return e^n^r;case 2:return e&n^e&r^n&r;case 3:return e^n^r}}function x(t,e){return t<<e|t>>>32-e}var S=b("v5",80,(function(t){var e=[1518500249,1859775393,2400959708,3395469782],n=[1732584193,4023233417,2562383102,271733878,3285377520];if("string"==typeof t){var r=unescape(encodeURIComponent(t));t=[];for(var i=0;i<r.length;++i)t.push(r.charCodeAt(i))}else Array.isArray(t)||(t=Array.prototype.slice.call(t));t.push(128);for(var a=t.length/4+2,o=Math.ceil(a/16),s=new Array(o),u=0;u<o;++u){for(var c=new Uint32Array(16),f=0;f<16;++f)c[f]=t[64*u+4*f]<<24|t[64*u+4*f+1]<<16|t[64*u+4*f+2]<<8|t[64*u+4*f+3];s[u]=c}s[o-1][14]=8*(t.length-1)/Math.pow(2,32),s[o-1][14]=Math.floor(s[o-1][14]),s[o-1][15]=8*(t.length-1)&4294967295;for(var l=0;l<o;++l){for(var p=new Uint32Array(80),d=0;d<16;++d)p[d]=s[l][d];for(var h=16;h<80;++h)p[h]=x(p[h-3]^p[h-8]^p[h-14]^p[h-16],1);for(var y=n[0],A=n[1],b=n[2],g=n[3],m=n[4],v=0;v<80;++v){var w=Math.floor(v/20),I=x(y,5)+B(w,A,b,g)+m+e[w]+p[v]>>>0;m=g,g=b,b=x(A,30)>>>0,A=y,y=I}n[0]=n[0]+y>>>0,n[1]=n[1]+A>>>0,n[2]=n[2]+b>>>0,n[3]=n[3]+g>>>0,n[4]=n[4]+m>>>0}return[n[0]>>24&255,n[0]>>16&255,n[0]>>8&255,255&n[0],n[1]>>24&255,n[1]>>16&255,n[1]>>8&255,255&n[1],n[2]>>24&255,n[2]>>16&255,n[2]>>8&255,255&n[2],n[3]>>24&255,n[3]>>16&255,n[3]>>8&255,255&n[3],n[4]>>24&255,n[4]>>16&255,n[4]>>8&255,255&n[4]]})),Q="00000000-0000-0000-0000-000000000000";var M=function(t){if(!s(t))throw TypeError("Invalid UUID");return parseInt(t.substr(14,1),16)}},function(t,e,n){"use strict";(function(t){n.d(e,"a",(function(){return c}));var r=n(0),i=n(1),a=n(210),o=new i.b(a.a);var s=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==t)return t;throw new Error("unable to locate global object")}(),u=s.crypto||s.msCrypto;function c(t){(t<=0||t>1024||t%1||t!=t)&&o.throwArgumentError("invalid length","length",t);var e=new Uint8Array(t);return u.getRandomValues(e),Object(r.a)(e)}u&&u.getRandomValues||(o.warn("WARNING: Missing strong random number source"),u={getRandomValues:function(t){return o.throwError("no secure random source avaialble",i.b.errors.UNSUPPORTED_OPERATION,{operation:"crypto.getRandomValues"})}})}).call(this,n(8))}])}));