/*! For license information please see jitsi.js.LICENSE.txt */ (()=>{var t={"./node_modules/events/events.js":t=>{"use strict";var e,r="object"==typeof Reflect?Reflect:null,n=r&&"function"==typeof r.apply?r.apply:function(t,e,r){return Function.prototype.apply.call(t,e,r)};e=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var i=Number.isNaN||function(t){return t!=t};function s(){s.init.call(this)}t.exports=s,t.exports.once=function(t,e){return new Promise(function(r,n){function i(r){t.removeListener(e,s),n(r)}function s(){"function"==typeof t.removeListener&&t.removeListener("error",i),r([].slice.call(arguments))}g(t,e,s,{once:!0}),"error"!==e&&function(t,e,r){"function"==typeof t.on&&g(t,"error",e,r)}(t,i,{once:!0})})},s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var a=10;function o(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function u(t){return void 0===t._maxListeners?s.defaultMaxListeners:t._maxListeners}function c(t,e,r,n){var i,s,a,c;if(o(r),void 0===(s=t._events)?(s=t._events=Object.create(null),t._eventsCount=0):(void 0!==s.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),s=t._events),a=s[e]),void 0===a)a=s[e]=r,++t._eventsCount;else if("function"==typeof a?a=s[e]=n?[r,a]:[a,r]:n?a.unshift(r):a.push(r),(i=u(t))>0&&a.length>i&&!a.warned){a.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=t,l.type=e,l.count=a.length,c=l,console&&console.warn&&console.warn(c)}return t}function l(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function h(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=l.bind(n);return i.listener=r,n.wrapFn=i,i}function f(t,e,r){var n=t._events;if(void 0===n)return[];var i=n[e];return void 0===i?[]:"function"==typeof i?r?[i.listener||i]:[i]:r?function(t){for(var e=new Array(t.length),r=0;r0&&(a=e[0]),a instanceof Error)throw a;var o=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw o.context=a,o}var u=s[t];if(void 0===u)return!1;if("function"==typeof u)n(u,this,e);else{var c=u.length,l=p(u,c);for(r=0;r=0;s--)if(r[s]===e||r[s].listener===e){a=r[s].listener,i=s;break}if(i<0)return this;0===i?r.shift():function(t,e){for(;e+1=0;n--)this.removeListener(t,e[n]);return this},s.prototype.listeners=function(t){return f(this,t,!0)},s.prototype.rawListeners=function(t){return f(this,t,!1)},s.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):d.call(t,e)},s.prototype.listenerCount=d,s.prototype.eventNames=function(){return this._eventsCount>0?e(this._events):[]}},"./node_modules/jsrsasign/lib/jsrsasign.js":(t,e)=>{var r,n,i,s,a,o,u,c,l,h,f,d={userAgent:!1},p={},g=g||(r=Math,i=(n={}).lib={},s=i.Base=function(){function t(){}return{extend:function(e){t.prototype=this;var r=new t;return e&&r.mixIn(e),r.hasOwnProperty("init")||(r.init=function(){r.$super.init.apply(this,arguments)}),r.init.prototype=r,r.$super=this,r},create:function(){var t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var e in t)t.hasOwnProperty(e)&&(this[e]=t[e]);t.hasOwnProperty("toString")&&(this.toString=t.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),a=i.WordArray=s.extend({init:function(t,e){t=this.words=t||[],this.sigBytes=null!=e?e:4*t.length},toString:function(t){return(t||u).stringify(this)},concat:function(t){var e=this.words,r=t.words,n=this.sigBytes,i=t.sigBytes;if(this.clamp(),n%4)for(var s=0;s>>2]>>>24-s%4*8&255;e[n+s>>>2]|=a<<24-(n+s)%4*8}else for(s=0;s>>2]=r[s>>>2];return this.sigBytes+=i,this},clamp:function(){var t=this.words,e=this.sigBytes;t[e>>>2]&=4294967295<<32-e%4*8,t.length=r.ceil(e/4)},clone:function(){var t=s.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){for(var e=[],n=0;n>>2]>>>24-i%4*8&255;n.push((s>>>4).toString(16)),n.push((15&s).toString(16))}return n.join("")},parse:function(t){for(var e=t.length,r=[],n=0;n>>3]|=parseInt(t.substr(n,2),16)<<24-n%8*4;return new a.init(r,e/2)}},c=o.Latin1={stringify:function(t){for(var e=t.words,r=t.sigBytes,n=[],i=0;i>>2]>>>24-i%4*8&255;n.push(String.fromCharCode(s))}return n.join("")},parse:function(t){for(var e=t.length,r=[],n=0;n>>2]|=(255&t.charCodeAt(n))<<24-n%4*8;return new a.init(r,e)}},l=o.Utf8={stringify:function(t){try{return decodeURIComponent(escape(c.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return c.parse(unescape(encodeURIComponent(t)))}},h=i.BufferedBlockAlgorithm=s.extend({reset:function(){this._data=new a.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=l.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(t){var e=this._data,n=e.words,i=e.sigBytes,s=this.blockSize,o=i/(4*s),u=(o=t?r.ceil(o):r.max((0|o)-this._minBufferSize,0))*s,c=r.min(4*u,i);if(u){for(var l=0;l>>2]}},t.BlockCipher=a.extend({cfg:a.cfg.extend({mode:o,padding:c}),reset:function(){a.reset.call(this);var t=(e=this.cfg).iv,e=e.mode;if(this._xformMode==this._ENC_XFORM_MODE)var r=e.createEncryptor;else r=e.createDecryptor,this._minBufferSize=1;this._mode=r.call(e,this,t&&t.words)},_doProcessBlock:function(t,e){this._mode.processBlock(t,e)},_doFinalize:function(){var t=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){t.pad(this._data,this.blockSize);var e=this._process(!0)}else e=this._process(!0),t.unpad(e);return e},blockSize:4});var l=t.CipherParams=e.extend({init:function(t){this.mixIn(t)},toString:function(t){return(t||this.formatter).stringify(this)}}),h=(o=(f.format={}).OpenSSL={stringify:function(t){var e=t.ciphertext;return((t=t.salt)?r.create([1398893684,1701076831]).concat(t).concat(e):e).toString(i)},parse:function(t){var e=(t=i.parse(t)).words;if(1398893684==e[0]&&1701076831==e[1]){var n=r.create(e.slice(2,4));e.splice(0,4),t.sigBytes-=16}return l.create({ciphertext:t,salt:n})}},t.SerializableCipher=e.extend({cfg:e.extend({format:o}),encrypt:function(t,e,r,n){n=this.cfg.extend(n);var i=t.createEncryptor(r,n);return e=i.finalize(e),i=i.cfg,l.create({ciphertext:e,key:r,iv:i.iv,algorithm:t,mode:i.mode,padding:i.padding,blockSize:t.blockSize,formatter:n.format})},decrypt:function(t,e,r,n){return n=this.cfg.extend(n),e=this._parse(e,n.format),t.createDecryptor(r,n).finalize(e.ciphertext)},_parse:function(t,e){return"string"==typeof t?e.parse(t,this):t}})),f=(f.kdf={}).OpenSSL={execute:function(t,e,n,i){return i||(i=r.random(8)),t=s.create({keySize:e+n}).compute(t,i),n=r.create(t.words.slice(e),4*n),t.sigBytes=4*e,l.create({key:t,iv:n,salt:i})}},d=t.PasswordBasedCipher=h.extend({cfg:h.cfg.extend({kdf:f}),encrypt:function(t,e,r,n){return r=(n=this.cfg.extend(n)).kdf.execute(r,t.keySize,t.ivSize),n.iv=r.iv,(t=h.encrypt.call(this,t,e,r.key,n)).mixIn(r),t},decrypt:function(t,e,r,n){return n=this.cfg.extend(n),e=this._parse(e,n.format),r=n.kdf.execute(r,t.keySize,t.ivSize,e.salt),n.iv=r.iv,h.decrypt.call(this,t,e,r.key,n)}})}(),function(){for(var t=g,e=t.lib.BlockCipher,r=t.algo,n=[],i=[],s=[],a=[],o=[],u=[],c=[],l=[],h=[],f=[],d=[],p=0;256>p;p++)d[p]=128>p?p<<1:p<<1^283;var v=0,y=0;for(p=0;256>p;p++){var m=(m=y^y<<1^y<<2^y<<3^y<<4)>>>8^255&m^99;n[v]=m,i[m]=v;var b=d[v],x=d[b],w=d[x],S=257*d[m]^16843008*m;s[v]=S<<24|S>>>8,a[v]=S<<16|S>>>16,o[v]=S<<8|S>>>24,u[v]=S,S=16843009*w^65537*x^257*b^16843008*v,c[m]=S<<24|S>>>8,l[m]=S<<16|S>>>16,h[m]=S<<8|S>>>24,f[m]=S,v?(v=b^d[d[d[w^b]]],y^=d[d[y]]):v=y=1}var E=[0,1,2,4,8,16,32,64,128,27,54];r=r.AES=e.extend({_doReset:function(){for(var t=(r=this._key).words,e=r.sigBytes/4,r=4*((this._nRounds=e+6)+1),i=this._keySchedule=[],s=0;s>>24]<<24|n[a>>>16&255]<<16|n[a>>>8&255]<<8|n[255&a]):(a=n[(a=a<<8|a>>>24)>>>24]<<24|n[a>>>16&255]<<16|n[a>>>8&255]<<8|n[255&a],a^=E[s/e|0]<<24),i[s]=i[s-e]^a}for(t=this._invKeySchedule=[],e=0;ee||4>=s?a:c[n[a>>>24]]^l[n[a>>>16&255]]^h[n[a>>>8&255]]^f[n[255&a]]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._keySchedule,s,a,o,u,n)},decryptBlock:function(t,e){var r=t[e+1];t[e+1]=t[e+3],t[e+3]=r,this._doCryptBlock(t,e,this._invKeySchedule,c,l,h,f,i),r=t[e+1],t[e+1]=t[e+3],t[e+3]=r},_doCryptBlock:function(t,e,r,n,i,s,a,o){for(var u=this._nRounds,c=t[e]^r[0],l=t[e+1]^r[1],h=t[e+2]^r[2],f=t[e+3]^r[3],d=4,p=1;p>>24]^i[l>>>16&255]^s[h>>>8&255]^a[255&f]^r[d++],v=n[l>>>24]^i[h>>>16&255]^s[f>>>8&255]^a[255&c]^r[d++],y=n[h>>>24]^i[f>>>16&255]^s[c>>>8&255]^a[255&l]^r[d++];f=n[f>>>24]^i[c>>>16&255]^s[l>>>8&255]^a[255&h]^r[d++],c=g,l=v,h=y}g=(o[c>>>24]<<24|o[l>>>16&255]<<16|o[h>>>8&255]<<8|o[255&f])^r[d++],v=(o[l>>>24]<<24|o[h>>>16&255]<<16|o[f>>>8&255]<<8|o[255&c])^r[d++],y=(o[h>>>24]<<24|o[f>>>16&255]<<16|o[c>>>8&255]<<8|o[255&l])^r[d++],f=(o[f>>>24]<<24|o[c>>>16&255]<<16|o[l>>>8&255]<<8|o[255&h])^r[d++],t[e]=g,t[e+1]=v,t[e+2]=y,t[e+3]=f},keySize:8});t.AES=e._createHelper(r)}(),function(){function t(t,e){var r=(this._lBlock>>>t^this._rBlock)&e;this._rBlock^=r,this._lBlock^=r<>>t^this._lBlock)&e;this._lBlock^=r,this._rBlock^=r<r;r++){var n=a[r]-1;e[r]=t[n>>>5]>>>31-n%32&1}for(t=this._subKeys=[],n=0;16>n;n++){var i=t[n]=[],s=u[n];for(r=0;24>r;r++)i[r/6|0]|=e[(o[r]-1+s)%28]<<31-r%6,i[4+(r/6|0)]|=e[28+(o[r+24]-1+s)%28]<<31-r%6;for(i[0]=i[0]<<1|i[0]>>>31,r=1;7>r;r++)i[r]>>>=4*(r-1)+3;i[7]=i[7]<<5|i[7]>>>27}for(e=this._invSubKeys=[],r=0;16>r;r++)e[r]=t[15-r]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._subKeys)},decryptBlock:function(t,e){this._doCryptBlock(t,e,this._invSubKeys)},_doCryptBlock:function(r,n,i){this._lBlock=r[n],this._rBlock=r[n+1],t.call(this,4,252645135),t.call(this,16,65535),e.call(this,2,858993459),e.call(this,8,16711935),t.call(this,1,1431655765);for(var s=0;16>s;s++){for(var a=i[s],o=this._lBlock,u=this._rBlock,h=0,f=0;8>f;f++)h|=c[f][((u^a[f])&l[f])>>>0];this._lBlock=u,this._rBlock=o^h}i=this._lBlock,this._lBlock=this._rBlock,this._rBlock=i,t.call(this,1,1431655765),e.call(this,8,16711935),e.call(this,2,858993459),t.call(this,16,65535),t.call(this,4,252645135),r[n]=this._lBlock,r[n+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});r.DES=i._createHelper(h),s=s.TripleDES=i.extend({_doReset:function(){var t=this._key.words;this._des1=h.createEncryptor(n.create(t.slice(0,2))),this._des2=h.createEncryptor(n.create(t.slice(2,4))),this._des3=h.createEncryptor(n.create(t.slice(4,6)))},encryptBlock:function(t,e){this._des1.encryptBlock(t,e),this._des2.decryptBlock(t,e),this._des3.encryptBlock(t,e)},decryptBlock:function(t,e){this._des3.decryptBlock(t,e),this._des2.encryptBlock(t,e),this._des1.decryptBlock(t,e)},keySize:6,ivSize:2,blockSize:2}),r.TripleDES=i._createHelper(s)}(),function(){var t=g,e=t.lib.WordArray;t.enc.Base64={stringify:function(t){var e=t.words,r=t.sigBytes,n=this._map;t.clamp(),t=[];for(var i=0;i>>2]>>>24-i%4*8&255)<<16|(e[i+1>>>2]>>>24-(i+1)%4*8&255)<<8|e[i+2>>>2]>>>24-(i+2)%4*8&255,a=0;4>a&&i+.75*a>>6*(3-a)&63));if(e=n.charAt(64))for(;t.length%4;)t.push(e);return t.join("")},parse:function(t){var r=t.length,n=this._map;(i=n.charAt(64))&&(-1!=(i=t.indexOf(i))&&(r=i));for(var i=[],s=0,a=0;a>>6-a%4*2;i[s>>>2]|=(o|u)<<24-s%4*8,s++}return e.create(i,s)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),function(t){function e(t,e,r,n,i,s,a){return((t=t+(e&r|~e&n)+i+a)<>>32-s)+e}function r(t,e,r,n,i,s,a){return((t=t+(e&n|r&~n)+i+a)<>>32-s)+e}function n(t,e,r,n,i,s,a){return((t=t+(e^r^n)+i+a)<>>32-s)+e}function i(t,e,r,n,i,s,a){return((t=t+(r^(e|~n))+i+a)<>>32-s)+e}for(var s=g,a=(u=s.lib).WordArray,o=u.Hasher,u=s.algo,c=[],l=0;64>l;l++)c[l]=4294967296*t.abs(t.sin(l+1))|0;u=u.MD5=o.extend({_doReset:function(){this._hash=new a.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(t,s){for(var a=0;16>a;a++){var o=t[u=s+a];t[u]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8)}a=this._hash.words;var u=t[s+0],l=(o=t[s+1],t[s+2]),h=t[s+3],f=t[s+4],d=t[s+5],p=t[s+6],g=t[s+7],v=t[s+8],y=t[s+9],m=t[s+10],b=t[s+11],x=t[s+12],w=t[s+13],S=t[s+14],E=t[s+15],F=e(F=a[0],D=a[1],C=a[2],A=a[3],u,7,c[0]),A=e(A,F,D,C,o,12,c[1]),C=e(C,A,F,D,l,17,c[2]),D=e(D,C,A,F,h,22,c[3]);F=e(F,D,C,A,f,7,c[4]),A=e(A,F,D,C,d,12,c[5]),C=e(C,A,F,D,p,17,c[6]),D=e(D,C,A,F,g,22,c[7]),F=e(F,D,C,A,v,7,c[8]),A=e(A,F,D,C,y,12,c[9]),C=e(C,A,F,D,m,17,c[10]),D=e(D,C,A,F,b,22,c[11]),F=e(F,D,C,A,x,7,c[12]),A=e(A,F,D,C,w,12,c[13]),C=e(C,A,F,D,S,17,c[14]),F=r(F,D=e(D,C,A,F,E,22,c[15]),C,A,o,5,c[16]),A=r(A,F,D,C,p,9,c[17]),C=r(C,A,F,D,b,14,c[18]),D=r(D,C,A,F,u,20,c[19]),F=r(F,D,C,A,d,5,c[20]),A=r(A,F,D,C,m,9,c[21]),C=r(C,A,F,D,E,14,c[22]),D=r(D,C,A,F,f,20,c[23]),F=r(F,D,C,A,y,5,c[24]),A=r(A,F,D,C,S,9,c[25]),C=r(C,A,F,D,h,14,c[26]),D=r(D,C,A,F,v,20,c[27]),F=r(F,D,C,A,w,5,c[28]),A=r(A,F,D,C,l,9,c[29]),C=r(C,A,F,D,g,14,c[30]),F=n(F,D=r(D,C,A,F,x,20,c[31]),C,A,d,4,c[32]),A=n(A,F,D,C,v,11,c[33]),C=n(C,A,F,D,b,16,c[34]),D=n(D,C,A,F,S,23,c[35]),F=n(F,D,C,A,o,4,c[36]),A=n(A,F,D,C,f,11,c[37]),C=n(C,A,F,D,g,16,c[38]),D=n(D,C,A,F,m,23,c[39]),F=n(F,D,C,A,w,4,c[40]),A=n(A,F,D,C,u,11,c[41]),C=n(C,A,F,D,h,16,c[42]),D=n(D,C,A,F,p,23,c[43]),F=n(F,D,C,A,y,4,c[44]),A=n(A,F,D,C,x,11,c[45]),C=n(C,A,F,D,E,16,c[46]),F=i(F,D=n(D,C,A,F,l,23,c[47]),C,A,u,6,c[48]),A=i(A,F,D,C,g,10,c[49]),C=i(C,A,F,D,S,15,c[50]),D=i(D,C,A,F,d,21,c[51]),F=i(F,D,C,A,x,6,c[52]),A=i(A,F,D,C,h,10,c[53]),C=i(C,A,F,D,m,15,c[54]),D=i(D,C,A,F,o,21,c[55]),F=i(F,D,C,A,v,6,c[56]),A=i(A,F,D,C,E,10,c[57]),C=i(C,A,F,D,p,15,c[58]),D=i(D,C,A,F,w,21,c[59]),F=i(F,D,C,A,f,6,c[60]),A=i(A,F,D,C,b,10,c[61]),C=i(C,A,F,D,l,15,c[62]),D=i(D,C,A,F,y,21,c[63]);a[0]=a[0]+F|0,a[1]=a[1]+D|0,a[2]=a[2]+C|0,a[3]=a[3]+A|0},_doFinalize:function(){var e=this._data,r=e.words,n=8*this._nDataBytes,i=8*e.sigBytes;r[i>>>5]|=128<<24-i%32;var s=t.floor(n/4294967296);for(r[15+(i+64>>>9<<4)]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),r[14+(i+64>>>9<<4)]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8),e.sigBytes=4*(r.length+1),this._process(),r=(e=this._hash).words,n=0;4>n;n++)i=r[n],r[n]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8);return e},clone:function(){var t=o.clone.call(this);return t._hash=this._hash.clone(),t}}),s.MD5=o._createHelper(u),s.HmacMD5=o._createHmacHelper(u)}(Math),function(){var t=g,e=(i=t.lib).WordArray,r=i.Hasher,n=[],i=t.algo.SHA1=r.extend({_doReset:function(){this._hash=new e.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var r=this._hash.words,i=r[0],s=r[1],a=r[2],o=r[3],u=r[4],c=0;80>c;c++){if(16>c)n[c]=0|t[e+c];else{var l=n[c-3]^n[c-8]^n[c-14]^n[c-16];n[c]=l<<1|l>>>31}l=(i<<5|i>>>27)+u+n[c],l=20>c?l+(1518500249+(s&a|~s&o)):40>c?l+(1859775393+(s^a^o)):60>c?l+((s&a|s&o|a&o)-1894007588):l+((s^a^o)-899497514),u=o,o=a,a=s<<30|s>>>2,s=i,i=l}r[0]=r[0]+i|0,r[1]=r[1]+s|0,r[2]=r[2]+a|0,r[3]=r[3]+o|0,r[4]=r[4]+u|0},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,n=8*t.sigBytes;return e[n>>>5]|=128<<24-n%32,e[14+(n+64>>>9<<4)]=Math.floor(r/4294967296),e[15+(n+64>>>9<<4)]=r,t.sigBytes=4*e.length,this._process(),this._hash},clone:function(){var t=r.clone.call(this);return t._hash=this._hash.clone(),t}});t.SHA1=r._createHelper(i),t.HmacSHA1=r._createHmacHelper(i)}(),function(t){for(var e=g,r=(i=e.lib).WordArray,n=i.Hasher,i=e.algo,s=[],a=[],o=function(t){return 4294967296*(t-(0|t))|0},u=2,c=0;64>c;){var l;t:{l=u;for(var h=t.sqrt(l),f=2;f<=h;f++)if(!(l%f)){l=!1;break t}l=!0}l&&(8>c&&(s[c]=o(t.pow(u,.5))),a[c]=o(t.pow(u,1/3)),c++),u++}var d=[];i=i.SHA256=n.extend({_doReset:function(){this._hash=new r.init(s.slice(0))},_doProcessBlock:function(t,e){for(var r=this._hash.words,n=r[0],i=r[1],s=r[2],o=r[3],u=r[4],c=r[5],l=r[6],h=r[7],f=0;64>f;f++){if(16>f)d[f]=0|t[e+f];else{var p=d[f-15],g=d[f-2];d[f]=((p<<25|p>>>7)^(p<<14|p>>>18)^p>>>3)+d[f-7]+((g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10)+d[f-16]}p=h+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&c^~u&l)+a[f]+d[f],g=((n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22))+(n&i^n&s^i&s),h=l,l=c,c=u,u=o+p|0,o=s,s=i,i=n,n=p+g|0}r[0]=r[0]+n|0,r[1]=r[1]+i|0,r[2]=r[2]+s|0,r[3]=r[3]+o|0,r[4]=r[4]+u|0,r[5]=r[5]+c|0,r[6]=r[6]+l|0,r[7]=r[7]+h|0},_doFinalize:function(){var e=this._data,r=e.words,n=8*this._nDataBytes,i=8*e.sigBytes;return r[i>>>5]|=128<<24-i%32,r[14+(i+64>>>9<<4)]=t.floor(n/4294967296),r[15+(i+64>>>9<<4)]=n,e.sigBytes=4*r.length,this._process(),this._hash},clone:function(){var t=n.clone.call(this);return t._hash=this._hash.clone(),t}});e.SHA256=n._createHelper(i),e.HmacSHA256=n._createHmacHelper(i)}(Math),function(){var t=g,e=t.lib.WordArray,r=(n=t.algo).SHA256,n=n.SHA224=r.extend({_doReset:function(){this._hash=new e.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var t=r._doFinalize.call(this);return t.sigBytes-=4,t}});t.SHA224=r._createHelper(n),t.HmacSHA224=r._createHmacHelper(n)}(),function(){function t(){return n.create.apply(n,arguments)}for(var e=g,r=e.lib.Hasher,n=(s=e.x64).Word,i=s.WordArray,s=e.algo,a=[t(1116352408,3609767458),t(1899447441,602891725),t(3049323471,3964484399),t(3921009573,2173295548),t(961987163,4081628472),t(1508970993,3053834265),t(2453635748,2937671579),t(2870763221,3664609560),t(3624381080,2734883394),t(310598401,1164996542),t(607225278,1323610764),t(1426881987,3590304994),t(1925078388,4068182383),t(2162078206,991336113),t(2614888103,633803317),t(3248222580,3479774868),t(3835390401,2666613458),t(4022224774,944711139),t(264347078,2341262773),t(604807628,2007800933),t(770255983,1495990901),t(1249150122,1856431235),t(1555081692,3175218132),t(1996064986,2198950837),t(2554220882,3999719339),t(2821834349,766784016),t(2952996808,2566594879),t(3210313671,3203337956),t(3336571891,1034457026),t(3584528711,2466948901),t(113926993,3758326383),t(338241895,168717936),t(666307205,1188179964),t(773529912,1546045734),t(1294757372,1522805485),t(1396182291,2643833823),t(1695183700,2343527390),t(1986661051,1014477480),t(2177026350,1206759142),t(2456956037,344077627),t(2730485921,1290863460),t(2820302411,3158454273),t(3259730800,3505952657),t(3345764771,106217008),t(3516065817,3606008344),t(3600352804,1432725776),t(4094571909,1467031594),t(275423344,851169720),t(430227734,3100823752),t(506948616,1363258195),t(659060556,3750685593),t(883997877,3785050280),t(958139571,3318307427),t(1322822218,3812723403),t(1537002063,2003034995),t(1747873779,3602036899),t(1955562222,1575990012),t(2024104815,1125592928),t(2227730452,2716904306),t(2361852424,442776044),t(2428436474,593698344),t(2756734187,3733110249),t(3204031479,2999351573),t(3329325298,3815920427),t(3391569614,3928383900),t(3515267271,566280711),t(3940187606,3454069534),t(4118630271,4000239992),t(116418474,1914138554),t(174292421,2731055270),t(289380356,3203993006),t(460393269,320620315),t(685471733,587496836),t(852142971,1086792851),t(1017036298,365543100),t(1126000580,2618297676),t(1288033470,3409855158),t(1501505948,4234509866),t(1607167915,987167468),t(1816402316,1246189591)],o=[],u=0;80>u;u++)o[u]=t();s=s.SHA512=r.extend({_doReset:function(){this._hash=new i.init([new n.init(1779033703,4089235720),new n.init(3144134277,2227873595),new n.init(1013904242,4271175723),new n.init(2773480762,1595750129),new n.init(1359893119,2917565137),new n.init(2600822924,725511199),new n.init(528734635,4215389547),new n.init(1541459225,327033209)])},_doProcessBlock:function(t,e){for(var r=(h=this._hash.words)[0],n=h[1],i=h[2],s=h[3],u=h[4],c=h[5],l=h[6],h=h[7],f=r.high,d=r.low,p=n.high,g=n.low,v=i.high,y=i.low,m=s.high,b=s.low,x=u.high,w=u.low,S=c.high,E=c.low,F=l.high,A=l.low,C=h.high,D=h.low,P=f,I=d,R=p,T=g,j=v,O=y,N=m,k=b,B=x,_=w,H=S,L=E,V=F,M=A,q=C,K=D,U=0;80>U;U++){var W=o[U];if(16>U)var G=W.high=0|t[e+2*U],z=W.low=0|t[e+2*U+1];else{G=((z=(G=o[U-15]).high)>>>1|(J=G.low)<<31)^(z>>>8|J<<24)^z>>>7;var J=(J>>>1|z<<31)^(J>>>8|z<<24)^(J>>>7|z<<25),$=((z=($=o[U-2]).high)>>>19|(X=$.low)<<13)^(z<<3|X>>>29)^z>>>6,X=(X>>>19|z<<13)^(X<<3|z>>>29)^(X>>>6|z<<26),Y=(z=o[U-7]).high,Z=(Q=o[U-16]).high,Q=Q.low;G=(G=(G=G+Y+((z=J+z.low)>>>0>>0?1:0))+$+((z=z+X)>>>0>>0?1:0))+Z+((z=z+Q)>>>0>>0?1:0);W.high=G,W.low=z}Y=B&H^~B&V,Q=_&L^~_&M,W=P&R^P&j^R&j;var tt=I&T^I&O^T&O,et=(J=(P>>>28|I<<4)^(P<<30|I>>>2)^(P<<25|I>>>7),$=(I>>>28|P<<4)^(I<<30|P>>>2)^(I<<25|P>>>7),(X=a[U]).high),rt=X.low;Z=q+((B>>>14|_<<18)^(B>>>18|_<<14)^(B<<23|_>>>9))+((X=K+((_>>>14|B<<18)^(_>>>18|B<<14)^(_<<23|B>>>9)))>>>0>>0?1:0),q=V,K=M,V=H,M=L,H=B,L=_,B=N+(Z=(Z=(Z=Z+Y+((X=X+Q)>>>0>>0?1:0))+et+((X=X+rt)>>>0>>0?1:0))+G+((X=X+z)>>>0>>0?1:0))+((_=k+X|0)>>>0>>0?1:0)|0,N=j,k=O,j=R,O=T,R=P,T=I,P=Z+(W=J+W+((z=$+tt)>>>0<$>>>0?1:0))+((I=X+z|0)>>>0>>0?1:0)|0}d=r.low=d+I,r.high=f+P+(d>>>0>>0?1:0),g=n.low=g+T,n.high=p+R+(g>>>0>>0?1:0),y=i.low=y+O,i.high=v+j+(y>>>0>>0?1:0),b=s.low=b+k,s.high=m+N+(b>>>0>>0?1:0),w=u.low=w+_,u.high=x+B+(w>>>0<_>>>0?1:0),E=c.low=E+L,c.high=S+H+(E>>>0>>0?1:0),A=l.low=A+M,l.high=F+V+(A>>>0>>0?1:0),D=h.low=D+K,h.high=C+q+(D>>>0>>0?1:0)},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,n=8*t.sigBytes;return e[n>>>5]|=128<<24-n%32,e[30+(n+128>>>10<<5)]=Math.floor(r/4294967296),e[31+(n+128>>>10<<5)]=r,t.sigBytes=4*e.length,this._process(),this._hash.toX32()},clone:function(){var t=r.clone.call(this);return t._hash=this._hash.clone(),t},blockSize:32}),e.SHA512=r._createHelper(s),e.HmacSHA512=r._createHmacHelper(s)}(),function(){var t=g,e=(i=t.x64).Word,r=i.WordArray,n=(i=t.algo).SHA512,i=i.SHA384=n.extend({_doReset:function(){this._hash=new r.init([new e.init(3418070365,3238371032),new e.init(1654270250,914150663),new e.init(2438529370,812702999),new e.init(355462360,4144912697),new e.init(1731405415,4290775857),new e.init(2394180231,1750603025),new e.init(3675008525,1694076839),new e.init(1203062813,3204075428)])},_doFinalize:function(){var t=n._doFinalize.call(this);return t.sigBytes-=16,t}});t.SHA384=n._createHelper(i),t.HmacSHA384=n._createHmacHelper(i)}(),function(){var t=g,e=(n=t.lib).WordArray,r=n.Hasher,n=t.algo,i=e.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),s=e.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),a=e.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),o=e.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),u=e.create([0,1518500249,1859775393,2400959708,2840853838]),c=e.create([1352829926,1548603684,1836072691,2053994217,0]);n=n.RIPEMD160=r.extend({_doReset:function(){this._hash=e.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var r=0;16>r;r++){var n=t[x=e+r];t[x]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8)}var l,h,f,d,p,g,v,y,m,b,x=this._hash.words,w=(n=u.words,c.words),S=i.words,E=s.words,F=a.words,A=o.words;g=l=x[0],v=h=x[1],y=f=x[2],m=d=x[3],b=p=x[4];var C;for(r=0;80>r;r+=1)C=l+t[e+S[r]]|0,C=16>r?C+((h^f^d)+n[0]):32>r?C+((h&f|~h&d)+n[1]):48>r?C+(((h|~f)^d)+n[2]):64>r?C+((h&d|f&~d)+n[3]):C+((h^(f|~d))+n[4]),C=(C=(C|=0)<>>32-F[r])+p|0,l=p,p=d,d=f<<10|f>>>22,f=h,h=C,C=g+t[e+E[r]]|0,C=16>r?C+((v^(y|~m))+w[0]):32>r?C+((v&m|y&~m)+w[1]):48>r?C+(((v|~y)^m)+w[2]):64>r?C+((v&y|~v&m)+w[3]):C+((v^y^m)+w[4]),C=(C=(C|=0)<>>32-A[r])+b|0,g=b,b=m,m=y<<10|y>>>22,y=v,v=C;C=x[1]+f+m|0,x[1]=x[2]+d+b|0,x[2]=x[3]+p+g|0,x[3]=x[4]+l+v|0,x[4]=x[0]+h+y|0,x[0]=C},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,n=8*t.sigBytes;for(e[n>>>5]|=128<<24-n%32,e[14+(n+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),t.sigBytes=4*(e.length+1),this._process(),e=(t=this._hash).words,r=0;5>r;r++)n=e[r],e[r]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8);return t},clone:function(){var t=r.clone.call(this);return t._hash=this._hash.clone(),t}});t.RIPEMD160=r._createHelper(n),t.HmacRIPEMD160=r._createHmacHelper(n)}(Math),function(){var t=g,e=t.enc.Utf8;t.algo.HMAC=t.lib.Base.extend({init:function(t,r){t=this._hasher=new t.init,"string"==typeof r&&(r=e.parse(r));var n=t.blockSize,i=4*n;r.sigBytes>i&&(r=t.finalize(r)),r.clamp();for(var s=this._oKey=r.clone(),a=this._iKey=r.clone(),o=s.words,u=a.words,c=0;c>6)+y.charAt(63&r);for(e+1==t.length?(r=parseInt(t.substring(e,e+1),16),n+=y.charAt(r<<2)):e+2==t.length&&(r=parseInt(t.substring(e,e+2),16),n+=y.charAt(r>>2)+y.charAt((3&r)<<4)),"=";(3&n.length)>0;)n+="=";return n}function b(t){var e,r,n,i="",s=0;for(e=0;e>2),r=3&n,s=1):1==s?(i+=D(r<<2|n>>4),r=15&n,s=2):2==s?(i+=D(r),i+=D(n>>2),r=3&n,s=3):(i+=D(r<<2|n>>4),i+=D(15&n),s=0));return 1==s&&(i+=D(r<<2)),i}function x(t){var e,r=b(t),n=new Array;for(e=0;2*e>15;--s>=0;){var u=32767&this[t],c=this[t++]>>15,l=o*u+c*a;i=((u=a*u+((32767&l)<<15)+r[n]+(1073741823&i))>>>30)+(l>>>15)+o*c+(i>>>30),r[n++]=1073741823&u}return i},v=30):"Netscape"!=d.appName?(w.prototype.am=function(t,e,r,n,i,s){for(;--s>=0;){var a=e*this[t++]+r[n]+i;i=Math.floor(a/67108864),r[n++]=67108863&a}return i},v=26):(w.prototype.am=function(t,e,r,n,i,s){for(var a=16383&e,o=e>>14;--s>=0;){var u=16383&this[t],c=this[t++]>>14,l=o*u+c*a;i=((u=a*u+((16383&l)<<14)+r[n]+i)>>28)+(l>>14)+o*c,r[n++]=268435455&u}return i},v=28),w.prototype.DB=v,w.prototype.DM=(1<>>16)&&(t=e,r+=16),0!=(e=t>>8)&&(t=e,r+=8),0!=(e=t>>4)&&(t=e,r+=4),0!=(e=t>>2)&&(t=e,r+=2),0!=(e=t>>1)&&(t=e,r+=1),r}function T(t){this.m=t}function j(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<>=16,e+=16),255&t||(t>>=8,e+=8),15&t||(t>>=4,e+=4),3&t||(t>>=2,e+=2),1&t||++e,e}function H(t){for(var e=0;0!=t;)t&=t-1,++e;return e}function L(){}function V(t){return t}function M(t){this.r2=S(),this.q3=S(),w.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}T.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},T.prototype.revert=function(t){return t},T.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},T.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},T.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},j.prototype.convert=function(t){var e=S();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(w.ZERO)>0&&this.m.subTo(e,e),e},j.prototype.revert=function(t){var e=S();return t.copyTo(e),this.reduce(e),e},j.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e>15)*this.mpl&this.um)<<15)&t.DM;for(t[r=e+this.m.t]+=this.m.am(0,n,t,e,0,this.m.t);t[r]>=t.DV;)t[r]-=t.DV,t[++r]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},j.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},j.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},w.prototype.copyTo=function(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s},w.prototype.fromInt=function(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+this.DV:this.t=0},w.prototype.fromString=function(t,e){var r;if(16==e)r=4;else if(8==e)r=3;else if(256==e)r=8;else if(2==e)r=1;else if(32==e)r=5;else{if(4!=e)return void this.fromRadix(t,e);r=2}this.t=0,this.s=0;for(var n=t.length,i=!1,s=0;--n>=0;){var a=8==r?255&t[n]:P(t,n);a<0?"-"==t.charAt(n)&&(i=!0):(i=!1,0==s?this[this.t++]=a:s+r>this.DB?(this[this.t-1]|=(a&(1<>this.DB-s):this[this.t-1]|=a<=this.DB&&(s-=this.DB))}8==r&&128&t[0]&&(this.s=-1,s>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==t;)--this.t},w.prototype.dlShiftTo=function(t,e){var r;for(r=this.t-1;r>=0;--r)e[r+t]=this[r];for(r=t-1;r>=0;--r)e[r]=0;e.t=this.t+t,e.s=this.s},w.prototype.drShiftTo=function(t,e){for(var r=t;r=0;--r)e[r+a+1]=this[r]>>i|o,o=(this[r]&s)<=0;--r)e[r]=0;e[a]=o,e.t=this.t+a+1,e.s=this.s,e.clamp()},w.prototype.rShiftTo=function(t,e){e.s=this.s;var r=Math.floor(t/this.DB);if(r>=this.t)e.t=0;else{var n=t%this.DB,i=this.DB-n,s=(1<>n;for(var a=r+1;a>n;n>0&&(e[this.t-r-1]|=(this.s&s)<>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n-=t.s}e.s=n<0?-1:0,n<-1?e[r++]=this.DV+n:n>0&&(e[r++]=n),e.t=r,e.clamp()},w.prototype.multiplyTo=function(t,e){var r=this.abs(),n=t.abs(),i=r.t;for(e.t=i+n.t;--i>=0;)e[i]=0;for(i=0;i=0;)t[r]=0;for(r=0;r=e.DV&&(t[r+e.t]-=e.DV,t[r+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(r,e[r],t,2*r,0,1)),t.s=0,t.clamp()},w.prototype.divRemTo=function(t,e,r){var n=t.abs();if(!(n.t<=0)){var i=this.abs();if(i.t0?(n.lShiftTo(u,s),i.lShiftTo(u,r)):(n.copyTo(s),i.copyTo(r));var c=s.t,l=s[c-1];if(0!=l){var h=l*(1<1?s[c-2]>>this.F2:0),f=this.FV/h,d=(1<=0&&(r[r.t++]=1,r.subTo(y,r)),w.ONE.dlShiftTo(c,y),y.subTo(s,s);s.t=0;){var m=r[--g]==l?this.DM:Math.floor(r[g]*f+(r[g-1]+p)*d);if((r[g]+=s.am(0,m,r,v,0,c))0&&r.rShiftTo(u,r),a<0&&w.ZERO.subTo(r,r)}}},w.prototype.invDigit=function(){if(this.t<1)return 0;var t=this[0];if(!(1&t))return 0;var e=3&t;return(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)>0?this.DV-e:-e},w.prototype.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},w.prototype.exp=function(t,e){if(t>4294967295||t<1)return w.ONE;var r=S(),n=S(),i=e.convert(this),s=R(t)-1;for(i.copyTo(r);--s>=0;)if(e.sqrTo(r,n),(t&1<0)e.mulTo(n,i,r);else{var a=r;r=n,n=a}return e.revert(r)},w.prototype.toString=function(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var r,n=(1<0)for(o>o)>0&&(i=!0,s=D(r));a>=0;)o>(o+=this.DB-e)):(r=this[a]>>(o-=e)&n,o<=0&&(o+=this.DB,--a)),r>0&&(i=!0),i&&(s+=D(r));return i?s:"0"},w.prototype.negate=function(){var t=S();return w.ZERO.subTo(this,t),t},w.prototype.abs=function(){return this.s<0?this.negate():this},w.prototype.compareTo=function(t){var e=this.s-t.s;if(0!=e)return e;var r=this.t;if(0!=(e=r-t.t))return this.s<0?-e:e;for(;--r>=0;)if(0!=(e=this[r]-t[r]))return e;return 0},w.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+R(this[this.t-1]^this.s&this.DM)},w.prototype.mod=function(t){var e=S();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(w.ZERO)>0&&t.subTo(e,e),e},w.prototype.modPowInt=function(t,e){var r;return r=t<256||e.isEven()?new T(e):new j(e),this.exp(t,r)},w.ZERO=I(0),w.ONE=I(1),L.prototype.convert=V,L.prototype.revert=V,L.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r)},L.prototype.sqrTo=function(t,e){t.squareTo(e)},M.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=S();return t.copyTo(e),this.reduce(e),e},M.prototype.revert=function(t){return t},M.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},M.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},M.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)};var q=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],K=(1<<26)/q[q.length-1];function U(){this.i=0,this.j=0,this.S=new Array}w.prototype.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},w.prototype.toRadix=function(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),r=Math.pow(t,e),n=I(r),i=S(),s=S(),a="";for(this.divRemTo(n,i,s);i.signum()>0;)a=(r+s.intValue()).toString(t).substr(1)+a,i.divRemTo(n,i,s);return s.intValue().toString(t)+a},w.prototype.fromRadix=function(t,e){this.fromInt(0),null==e&&(e=10);for(var r=this.chunkSize(e),n=Math.pow(e,r),i=!1,s=0,a=0,o=0;o=r&&(this.dMultiply(n),this.dAddOffset(a,0),s=0,a=0))}s>0&&(this.dMultiply(Math.pow(e,s)),this.dAddOffset(a,0)),i&&w.ZERO.subTo(this,this)},w.prototype.fromNumber=function(t,e,r){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo(w.ONE.shiftLeft(t-1),N,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(w.ONE.shiftLeft(t-1),this);else{var n=new Array,i=7&t;n.length=1+(t>>3),e.nextBytes(n),i>0?n[0]&=(1<>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n+=t.s}e.s=n<0?-1:0,n>0?e[r++]=n:n<-1&&(e[r++]=this.DV+n),e.t=r,e.clamp()},w.prototype.dMultiply=function(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},w.prototype.dAddOffset=function(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}},w.prototype.multiplyLowerTo=function(t,e,r){var n,i=Math.min(this.t+t.t,e);for(r.s=0,r.t=i;i>0;)r[--i]=0;for(n=r.t-this.t;i=0;)r[n]=0;for(n=Math.max(e-this.t,0);n0)if(0==e)r=this[0]%t;else for(var n=this.t-1;n>=0;--n)r=(e*r+this[n])%t;return r},w.prototype.millerRabin=function(t){var e=this.subtract(w.ONE),r=e.getLowestSetBit();if(r<=0)return!1;var n=e.shiftRight(r);(t=t+1>>1)>q.length&&(t=q.length);for(var i=S(),s=0;s>24},w.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},w.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},w.prototype.toByteArray=function(){var t=this.t,e=new Array;e[0]=this.s;var r,n=this.DB-t*this.DB%8,i=0;if(t-- >0)for(n>n)!=(this.s&this.DM)>>n&&(e[i++]=r|this.s<=0;)n<8?(r=(this[t]&(1<>(n+=this.DB-8)):(r=this[t]>>(n-=8)&255,n<=0&&(n+=this.DB,--t)),128&r&&(r|=-256),0==i&&(128&this.s)!=(128&r)&&++i,(i>0||r!=this.s)&&(e[i++]=r);return e},w.prototype.equals=function(t){return 0==this.compareTo(t)},w.prototype.min=function(t){return this.compareTo(t)<0?this:t},w.prototype.max=function(t){return this.compareTo(t)>0?this:t},w.prototype.and=function(t){var e=S();return this.bitwiseTo(t,O,e),e},w.prototype.or=function(t){var e=S();return this.bitwiseTo(t,N,e),e},w.prototype.xor=function(t){var e=S();return this.bitwiseTo(t,k,e),e},w.prototype.andNot=function(t){var e=S();return this.bitwiseTo(t,B,e),e},w.prototype.not=function(){for(var t=S(),e=0;e=this.t?0!=this.s:!!(this[e]&1<1){var l=S();for(n.sqrTo(a[1],l);o<=c;)a[o]=S(),n.mulTo(l,a[o-2],a[o]),o+=2}var h,f,d=t.t-1,p=!0,g=S();for(i=R(t[d])-1;d>=0;){for(i>=u?h=t[d]>>i-u&c:(h=(t[d]&(1<0&&(h|=t[d-1]>>this.DB+i-u)),o=r;!(1&h);)h>>=1,--o;if((i-=o)<0&&(i+=this.DB,--d),p)a[h].copyTo(s),p=!1;else{for(;o>1;)n.sqrTo(s,g),n.sqrTo(g,s),o-=2;o>0?n.sqrTo(s,g):(f=s,s=g,g=f),n.mulTo(g,a[h],s)}for(;d>=0&&!(t[d]&1<=0?(r.subTo(n,r),e&&i.subTo(a,i),s.subTo(o,s)):(n.subTo(r,n),e&&a.subTo(i,a),o.subTo(s,o))}return 0!=n.compareTo(w.ONE)?w.ZERO:o.compareTo(t)>=0?o.subtract(t):o.signum()<0?(o.addTo(t,o),o.signum()<0?o.add(t):o):o},w.prototype.pow=function(t){return this.exp(t,new L)},w.prototype.gcd=function(t){var e=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(e.compareTo(r)<0){var n=e;e=r,r=n}var i=e.getLowestSetBit(),s=r.getLowestSetBit();if(s<0)return e;for(i0&&(e.rShiftTo(s,e),r.rShiftTo(s,r));e.signum()>0;)(i=e.getLowestSetBit())>0&&e.rShiftTo(i,e),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),e.compareTo(r)>=0?(e.subTo(r,e),e.rShiftTo(1,e)):(r.subTo(e,r),r.rShiftTo(1,r));return s>0&&r.lShiftTo(s,r),r},w.prototype.isProbablePrime=function(t){var e,r=this.abs();if(1==r.t&&r[0]<=q[q.length-1]){for(e=0;e>8&255,G[z++]^=t>>16&255,G[z++]^=t>>24&255,z>=256&&(z-=256)}((new Date).getTime())}if(null==G){var $;if(G=new Array,z=0,void 0!==p&&(void 0!==p.crypto||void 0!==p.msCrypto)){var X=p.crypto||p.msCrypto;if(X.getRandomValues){var Y=new Uint8Array(32);for(X.getRandomValues(Y),$=0;$<32;++$)G[z++]=Y[$]}else if("Netscape"==d.appName&&d.appVersion<"5"){var Z=p.crypto.random(32);for($=0;$>>8,G[z++]=255&$;z=0,J()}function Q(){if(null==W){for(J(),(W=new U).init(G),z=0;z0&&e.length>0))throw"Invalid RSA public key";this.n=et(t,16),this.e=parseInt(e,16)}},rt.prototype.type="RSA",rt.prototype.doPrivate=function(t){if(null==this.p||null==this.q)return t.modPow(this.d,this.n);for(var e=t.mod(this.p).modPow(this.dmp1,this.p),r=t.mod(this.q).modPow(this.dmq1,this.q);e.compareTo(r)<0;)e=e.add(this.p);return e.subtract(r).multiply(this.coeff).mod(this.p).multiply(this.q).add(r)},rt.prototype.setPrivate=function(t,e,r){if(this.isPrivate=!0,"string"!=typeof t)this.n=t,this.e=e,this.d=r;else{if(!(null!=t&&null!=e&&t.length>0&&e.length>0))throw"Invalid RSA private key";this.n=et(t,16),this.e=parseInt(e,16),this.d=et(r,16)}},rt.prototype.setPrivateEx=function(t,e,r,n,i,s,a,o){if(this.isPrivate=!0,this.isPublic=!1,null==t)throw"RSASetPrivateEx N == null";if(null==e)throw"RSASetPrivateEx E == null";if(0==t.length)throw"RSASetPrivateEx N.length == 0";if(0==e.length)throw"RSASetPrivateEx E.length == 0";if(!(null!=t&&null!=e&&t.length>0&&e.length>0))throw"Invalid RSA private key in RSASetPrivateEx";this.n=et(t,16),this.e=parseInt(e,16),this.d=et(r,16),this.p=et(n,16),this.q=et(i,16),this.dmp1=et(s,16),this.dmq1=et(a,16),this.coeff=et(o,16)},rt.prototype.generate=function(t,e){var r=new tt,n=t>>1;this.e=parseInt(e,16);for(var i=new w(e,16),s=t/2-100,a=w.ONE.shiftLeft(s);;){for(;this.p=new w(t-n,1,r),0!=this.p.subtract(w.ONE).gcd(i).compareTo(w.ONE)||!this.p.isProbablePrime(10););for(;this.q=new w(n,1,r),0!=this.q.subtract(w.ONE).gcd(i).compareTo(w.ONE)||!this.q.isProbablePrime(10););if(this.p.compareTo(this.q)<=0){var o=this.p;this.p=this.q,this.q=o}var u=this.q.subtract(this.p).abs();if(!(u.bitLength()0;--e){s=s.twice();var l=n.testBit(e);l!=r.testBit(e)&&(s=s.add(l?this:i))}for(e=o.bitLength()-2;e>0;--e){u=u.twice();var h=o.testBit(e);h!=a.testBit(e)&&(u=u.add(h?u:c))}return s},it.prototype.multiplyTwo=function(t,e,r){var n;n=t.bitLength()>r.bitLength()?t.bitLength()-1:r.bitLength()-1;for(var i=this.curve.getInfinity(),s=this.add(e);n>=0;)i=i.twice(),t.testBit(n)?i=r.testBit(n)?i.add(s):i.add(this):r.testBit(n)&&(i=i.add(e)),--n;return i},st.prototype.getQ=function(){return this.q},st.prototype.getA=function(){return this.a},st.prototype.getB=function(){return this.b},st.prototype.equals=function(t){return t==this||this.q.equals(t.q)&&this.a.equals(t.a)&&this.b.equals(t.b)},st.prototype.getInfinity=function(){return this.infinity},st.prototype.fromBigInteger=function(t){return new nt(this.q,t)},st.prototype.decodePointHex=function(t){switch(parseInt(t.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:var e=t.substr(0,2),r=(t.substr(2),this.fromBigInteger(new w(o,16))),n=this.getA(),i=this.getB(),s=r.square().add(n).multiply(r).add(i).sqrt();return"03"==e&&(s=s.negate()),new it(this,r,s);case 4:case 6:case 7:var a=(t.length-2)/2,o=t.substr(2,a),u=t.substr(a+2,a);return new it(this,this.fromBigInteger(new w(o,16)),this.fromBigInteger(new w(u,16)));default:return null}},nt.prototype.getByteLength=function(){return Math.floor((this.toBigInteger().bitLength()+7)/8)},it.prototype.getEncoded=function(t){var e=function(t,e){var r=t.toByteArrayUnsigned();if(er.length;)r.unshift(0);return r},r=this.getX().toBigInteger(),n=this.getY().toBigInteger(),i=e(r,32);return t?n.isEven()?i.unshift(2):i.unshift(3):(i.unshift(4),i=i.concat(e(n,32))),i},it.decodeFrom=function(t,e){e[0];var r=e.length-1,n=e.slice(1,1+r/2),i=e.slice(1+r/2,1+r);n.unshift(0),i.unshift(0);var s=new w(n),a=new w(i);return new it(t,t.fromBigInteger(s),t.fromBigInteger(a))},it.decodeFromHex=function(t,e){e.substr(0,2);var r=e.length-2,n=e.substr(2,r/2),i=e.substr(2+r/2,r/2),s=new w(n,16),a=new w(i,16);return new it(t,t.fromBigInteger(s),t.fromBigInteger(a))},it.prototype.add2D=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;if(this.x.equals(t.x))return this.y.equals(t.y)?this.twice():this.curve.getInfinity();var e=t.x.subtract(this.x),r=t.y.subtract(this.y).divide(e),n=r.square().subtract(this.x).subtract(t.x),i=r.multiply(this.x.subtract(n)).subtract(this.y);return new it(this.curve,n,i)},it.prototype.twice2D=function(){if(this.isInfinity())return this;if(0==this.y.toBigInteger().signum())return this.curve.getInfinity();var t=this.curve.fromBigInteger(w.valueOf(2)),e=this.curve.fromBigInteger(w.valueOf(3)),r=this.x.square().multiply(e).add(this.curve.a).divide(this.y.multiply(t)),n=r.square().subtract(this.x.multiply(t)),i=r.multiply(this.x.subtract(n)).subtract(this.y);return new it(this.curve,n,i)},it.prototype.multiply2D=function(t){if(this.isInfinity())return this;if(0==t.signum())return this.curve.getInfinity();var e,r=t,n=r.multiply(new w("3")),i=this.negate(),s=this;for(e=n.bitLength()-2;e>0;--e){s=s.twice();var a=n.testBit(e);a!=r.testBit(e)&&(s=s.add2D(a?this:i))}return s},it.prototype.isOnCurve=function(){var t=this.getX().toBigInteger(),e=this.getY().toBigInteger(),r=this.curve.getA().toBigInteger(),n=this.curve.getB().toBigInteger(),i=this.curve.getQ(),s=e.multiply(e).mod(i),a=t.multiply(t).multiply(t).add(r.multiply(t)).add(n).mod(i);return s.equals(a)},it.prototype.toString=function(){return"("+this.getX().toBigInteger().toString()+","+this.getY().toBigInteger().toString()+")"},it.prototype.validate=function(){var t=this.curve.getQ();if(this.isInfinity())throw new Error("Point is at infinity.");var e=this.getX().toBigInteger(),r=this.getY().toBigInteger();if(e.compareTo(w.ONE)<0||e.compareTo(t.subtract(w.ONE))>0)throw new Error("x coordinate out of bounds");if(r.compareTo(w.ONE)<0||r.compareTo(t.subtract(w.ONE))>0)throw new Error("y coordinate out of bounds");if(!this.isOnCurve())throw new Error("Point is not on the curve.");if(this.multiply(t).isInfinity())throw new Error("Point is not a scalar multiple of G.");return!0};var at=function(){var t=new RegExp('(?:false|true|null|[\\{\\}\\[\\]]|(?:-?\\b(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\\b)|(?:"(?:[^\\0-\\x08\\x0a-\\x1f"\\\\]|\\\\(?:["/\\\\bfnrt]|u[0-9A-Fa-f]{4}))*"))',"g"),e=new RegExp("\\\\(?:([^u])|u(.{4}))","g"),r={'"':'"',"/":"/","\\":"\\",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"};function n(t,e,n){return e?r[e]:String.fromCharCode(parseInt(n,16))}var i=new String(""),s=Object.hasOwnProperty;return function(r,a){var o,u,c=r.match(t),l=c[0],h=!1;"{"===l?o={}:"["===l?o=[]:(o=[],h=!0);for(var f=[o],d=1-h,p=c.length;d=0;)delete r[n[u]]}return a.call(t,e,r)};o=v({"":o},"")}return o}}();void 0!==ot&&ot||(ot={}),void 0!==ot.asn1&&ot.asn1||(ot.asn1={}),ot.asn1.ASN1Util=new function(){this.integerToByteHex=function(t){var e=t.toString(16);return e.length%2==1&&(e="0"+e),e},this.bigIntToMinTwosComplementsHex=function(t){return Jt(t)},this.getPEMStringFromHex=function(t,e){return Dt(t,e)},this.newObject=function(t){var e=ot.asn1,r=e.ASN1Object,n=e.DERBoolean,i=e.DERInteger,s=e.DERBitString,a=e.DEROctetString,o=e.DERNull,u=e.DERObjectIdentifier,c=e.DEREnumerated,l=e.DERUTF8String,h=e.DERNumericString,f=e.DERPrintableString,d=e.DERTeletexString,p=e.DERIA5String,g=e.DERUTCTime,v=e.DERGeneralizedTime,y=e.DERVisibleString,m=e.DERBMPString,b=e.DERSequence,x=e.DERSet,w=e.DERTaggedObject,S=e.ASN1Util.newObject;if(t instanceof e.ASN1Object)return t;var E=Object.keys(t);if(1!=E.length)throw new Error("key of param shall be only one.");var F=E[0];if(-1==":asn1:bool:int:bitstr:octstr:null:oid:enum:utf8str:numstr:prnstr:telstr:ia5str:utctime:gentime:visstr:bmpstr:seq:set:tag:".indexOf(":"+F+":"))throw new Error("undefined key: "+F);if("bool"==F)return new n(t[F]);if("int"==F)return new i(t[F]);if("bitstr"==F)return new s(t[F]);if("octstr"==F)return new a(t[F]);if("null"==F)return new o(t[F]);if("oid"==F)return new u(t[F]);if("enum"==F)return new c(t[F]);if("utf8str"==F)return new l(t[F]);if("numstr"==F)return new h(t[F]);if("prnstr"==F)return new f(t[F]);if("telstr"==F)return new d(t[F]);if("ia5str"==F)return new p(t[F]);if("utctime"==F)return new g(t[F]);if("gentime"==F)return new v(t[F]);if("visstr"==F)return new y(t[F]);if("bmpstr"==F)return new m(t[F]);if("asn1"==F)return new r(t[F]);if("seq"==F){for(var A=t[F],C=[],D=0;D15)throw new Error("ASN.1 length too long to represent by 8x: n = "+t.toString(16));return(128+r).toString(16)+e},this.tohex=function(){return(null==this.hTLV||this.isModified)&&(this.hV=this.getFreshValueHex(),this.hL=this.getLengthHexFromValue(),this.hTLV=this.hT+this.hL+this.hV,this.isModified=!1),this.hTLV},this.getEncodedHex=function(){return this.tohex()},this.getValueHex=function(){return this.tohex(),this.hV},this.getFreshValueHex=function(){return""},this.setByParam=function(t){this.params=t},null!=t&&null!=t.tlv&&(this.hTLV=t.tlv,this.isModified=!1)},ot.asn1.DERAbstractString=function(t){ot.asn1.DERAbstractString.superclass.constructor.call(this);this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=bt(this.s).toLowerCase()},this.setStringHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t?this.setString(t):void 0!==t.str?this.setString(t.str):void 0!==t.hex&&this.setStringHex(t.hex))},ee(ot.asn1.DERAbstractString,ot.asn1.ASN1Object),ot.asn1.DERAbstractTime=function(t){ot.asn1.DERAbstractTime.superclass.constructor.call(this);this.localDateToUTC=function(t){var e=t.getTime()+6e4*t.getTimezoneOffset();return new Date(e)},this.formatDate=function(t,e,r){var n=this.zeroPadding,i=this.localDateToUTC(t),s=String(i.getFullYear());"utc"==e&&(s=s.substr(2,2));var a=s+n(String(i.getMonth()+1),2)+n(String(i.getDate()),2)+n(String(i.getHours()),2)+n(String(i.getMinutes()),2)+n(String(i.getSeconds()),2);if(!0===r){var o=i.getMilliseconds();if(0!=o){var u=n(String(o),3);a=a+"."+(u=u.replace(/[0]+$/,""))}}return a+"Z"},this.zeroPadding=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},this.setByParam=function(t){this.hV=null,this.hTLV=null,this.params=t},this.getString=function(){},this.setString=function(t){this.hTLV=null,this.isModified=!0,null==this.params&&(this.params={}),this.params.str=t},this.setByDate=function(t){this.hTLV=null,this.isModified=!0,null==this.params&&(this.params={}),this.params.date=t},this.setByDateValue=function(t,e,r,n,i,s){var a=new Date(Date.UTC(t,e-1,r,n,i,s,0));this.setByDate(a)},this.getFreshValueHex=function(){return this.hV}},ee(ot.asn1.DERAbstractTime,ot.asn1.ASN1Object),ot.asn1.DERAbstractStructured=function(t){ot.asn1.DERAbstractString.superclass.constructor.call(this);this.setByASN1ObjectArray=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array=t},this.appendASN1Object=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array.push(t)},this.asn1Array=new Array,void 0!==t&&void 0!==t.array&&(this.asn1Array=t.array)},ee(ot.asn1.DERAbstractStructured,ot.asn1.ASN1Object),ot.asn1.DERBoolean=function(t){ot.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV=0==t?"010100":"0101ff"},ee(ot.asn1.DERBoolean,ot.asn1.ASN1Object),ot.asn1.DERInteger=function(t){ot.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.params=null;var e=Jt;this.setByBigInteger=function(t){this.isModified=!0,this.params={bigint:t}},this.setByInteger=function(t){this.isModified=!0,this.params=t},this.setValueHex=function(t){this.isModified=!0,this.params={hex:t}},this.getFreshValueHex=function(){var t=this.params,r=null;if(null==t)throw new Error("value not set");if("object"==typeof t&&null!=t.hex)return this.hV=t.hex,this.hV;if("number"==typeof t)r=new w(String(t),10);else if(null!=t.int)r=new w(String(t.int),10);else{if(null==t.bigint)throw new Error("wrong parameter");r=t.bigint}return this.hV=e(r),this.hV},null!=t&&(this.params=t)},ee(ot.asn1.DERInteger,ot.asn1.ASN1Object),ot.asn1.DERBitString=function(t){if(void 0!==t&&void 0!==t.obj){var e=ot.asn1.ASN1Util.newObject(t.obj);t.hex="00"+e.tohex()}ot.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(t){this.hTLV=null,this.isModified=!0,this.hV=t},this.setUnusedBitsAndHexValue=function(t,e){if(t<0||7>6).toString(16)+n.toString(16))}n=128|(15&e)<<2|(192&r)>>6;var i=128|63&r;return xt((224|(240&e)>>4).toString(16)+n.toString(16)+i.toString(16))});return e.join("")}function Mt(t){for(var e=encodeURIComponent(t),r="",n=0;n"7"?"00"+t:t}lt.getLblen=function(t,e){if("8"!=t.substr(e+2,1))return 1;var r=parseInt(t.substr(e+3,1));return 0==r?-1:0=n)break}return a},lt.getNthChildIdx=function(t,e,r){return lt.getChildIdx(t,e)[r]},lt.getIdxbyList=function(t,e,r,n){var i,s,a=lt;return 0==r.length?void 0!==n&&t.substr(e,2)!==n?-1:e:(i=r.shift())>=(s=a.getChildIdx(t,e)).length?-1:a.getIdxbyList(t,s[i],r,n)},lt.getIdxbyListEx=function(t,e,r,n){var i,s,a=lt;if(0==r.length)return void 0!==n&&t.substr(e,2)!==n?-1:e;i=r.shift(),s=a.getChildIdx(t,e);for(var o=0,u=0;u=t.length?null:i.getTLV(t,s)},lt.getTLVbyListEx=function(t,e,r,n){var i=lt,s=i.getIdxbyListEx(t,e,r,n);return-1==s?null:i.getTLV(t,s)},lt.getVbyList=function(t,e,r,n,i){var s,a,o=lt;return-1==(s=o.getIdxbyList(t,e,r,n))||s>=t.length?null:(a=o.getV(t,s),!0===i&&(a=a.substr(2)),a)},lt.getVbyListEx=function(t,e,r,n,i){var s,a,o=lt;return-1==(s=o.getIdxbyListEx(t,e,r,n))?null:(a=o.getV(t,s),"03"==t.substr(s,2)&&!1!==i&&(a=a.substr(2)),a)},lt.getInt=function(t,e,r){null==r&&(r=-1);try{var n=t.substr(e,2);if("02"!=n&&"03"!=n)return r;var i=lt.getV(t,e);return"02"==n?parseInt(i,16):Xt(i)}catch(t){return r}},lt.getOID=function(t,e,r){null==r&&(r=null);try{return"06"!=t.substr(e,2)?r:Gt(lt.getV(t,e))}catch(t){return r}},lt.getOIDName=function(t,e,r){null==r&&(r=null);try{var n=lt.getOID(t,e,r);if(n==r)return r;var i=ot.asn1.x509.OID.oid2name(n);return""==i?n:i}catch(t){return r}},lt.getString=function(t,e,r){null==r&&(r=null);try{return St(lt.getV(t,e))}catch(t){return r}},lt.hextooidstr=function(t){var e=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},r=[],n=t.substr(0,2),i=parseInt(n,16);r[0]=new String(Math.floor(i/40)),r[1]=new String(i%40);for(var s=t.substr(2),a=[],o=0;o0&&(l=l+"."+u.join(".")),l},lt.dump=function(t,e,r,n){var i=lt,s=i.getV,a=i.dump,o=i.getChildIdx,u=t;t instanceof ot.asn1.ASN1Object&&(u=t.tohex());var c=function(t,e){return t.length<=2*e?t:t.substr(0,e)+"..(total "+t.length/2+"bytes).."+t.substr(t.length-e,e)};void 0===e&&(e={ommit_long_octet:32}),void 0===r&&(r=0),void 0===n&&(n="");var l,h=e.ommit_long_octet;if("01"==(l=u.substr(r,2)))return"00"==(f=s(u,r))?n+"BOOLEAN FALSE\n":n+"BOOLEAN TRUE\n";if("02"==l)return n+"INTEGER "+c(f=s(u,r),h)+"\n";if("03"==l){var f=s(u,r);if(i.isASN1HEX(f.substr(2))){var d=n+"BITSTRING, encapsulates\n";return d+=a(f.substr(2),e,0,n+" ")}return n+"BITSTRING "+c(f,h)+"\n"}if("04"==l){f=s(u,r);if(i.isASN1HEX(f)){d=n+"OCTETSTRING, encapsulates\n";return d+=a(f,e,0,n+" ")}return n+"OCTETSTRING "+c(f,h)+"\n"}if("05"==l)return n+"NULL\n";if("06"==l){var p=s(u,r),g=ot.asn1.ASN1Util.oidHexToInt(p),v=ot.asn1.x509.OID.oid2name(g),y=g.replace(/\./g," ");return""!=v?n+"ObjectIdentifier "+v+" ("+y+")\n":n+"ObjectIdentifier ("+y+")\n"}if("0a"==l)return n+"ENUMERATED "+parseInt(s(u,r))+"\n";if("0c"==l)return n+"UTF8String '"+xt(s(u,r))+"'\n";if("13"==l)return n+"PrintableString '"+xt(s(u,r))+"'\n";if("14"==l)return n+"TeletexString '"+xt(s(u,r))+"'\n";if("16"==l)return n+"IA5String '"+xt(s(u,r))+"'\n";if("17"==l)return n+"UTCTime "+xt(s(u,r))+"\n";if("18"==l)return n+"GeneralizedTime "+xt(s(u,r))+"\n";if("1a"==l)return n+"VisualString '"+xt(s(u,r))+"'\n";if("1e"==l)return n+"BMPString '"+Vt(s(u,r))+"'\n";if("30"==l){if("3000"==u.substr(r,4))return n+"SEQUENCE {}\n";d=n+"SEQUENCE\n";var m=e;if((2==(w=o(u,r)).length||3==w.length)&&"06"==u.substr(w[0],2)&&"04"==u.substr(w[w.length-1],2)){v=i.oidname(s(u,w[0]));var b=JSON.parse(JSON.stringify(e));b.x509ExtName=v,m=b}for(var x=0;x4?{enum:{hex:v}}:{enum:parseInt(v,16)};if("30"==p||"31"==p)return g[d[p]]=function(t){for(var e=[],n=a(t,0),i=0;i31)&&(128==(192&r)&&(31&r)==n))}catch(t){return!1}},lt.isASN1HEX=function(t){var e=lt;if(t.length%2==1)return!1;var r=e.getVblen(t,0),n=t.substr(0,2),i=e.getL(t,0);return t.length-n.length-i.length==2*r},lt.checkStrictDER=function(t,e,r,n,i){var s=lt;if(void 0===r){if("string"!=typeof t)throw new Error("not hex string");if(t=t.toLowerCase(),!ot.lang.String.isHex(t))throw new Error("not hex string");r=t.length,i=(n=t.length/2)<128?1:Math.ceil(n.toString(16))+1}if(s.getL(t,e).length>2*i)throw new Error("L of TLV too long: idx="+e);var a=s.getVblen(t,e);if(a>n)throw new Error("value of L too long than hex: idx="+e);var o=s.getTLV(t,e),u=o.length-2-s.getL(t,e).length;if(u!==2*a)throw new Error("V string length and L's value not the same:"+u+"/"+2*a);if(0===e&&t.length!=o.length)throw new Error("total length and TLV length unmatch:"+t.length+"!="+o.length);var c=t.substr(e,2);if("02"===c){var l=s.getVidx(t,e);if("00"==t.substr(l,2)&&t.charCodeAt(l+2)<56)throw new Error("not least zeros for DER INTEGER")}if(32&parseInt(c,16)){for(var h=s.getVblen(t,e),f=0,d=s.getChildIdx(t,e),p=0;p0&&t.push(new n({tag:"a3",obj:new c(e.ext)})),new ot.asn1.DERSequence({array:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},ee(ot.asn1.x509.TBSCertificate,ot.asn1.ASN1Object),ot.asn1.x509.Extensions=function(t){ot.asn1.x509.Extensions.superclass.constructor.call(this);var e=ot.asn1,r=e.DERSequence,n=e.x509;this.aParam=[],this.setByParam=function(t){this.aParam=t},this.tohex=function(){for(var t=[],e=0;e-1&&t.push(new n({int:this.pathLen}));var e=new i({array:t});return this.asn1ExtnValue=e,this.asn1ExtnValue.tohex()},this.oid="2.5.29.19",this.cA=!1,this.pathLen=-1,void 0!==t&&(void 0!==t.cA&&(this.cA=t.cA),void 0!==t.pathLen&&(this.pathLen=t.pathLen))},ee(ot.asn1.x509.BasicConstraints,ot.asn1.x509.Extension),ot.asn1.x509.CRLDistributionPoints=function(t){ot.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,t);var e=ot.asn1,r=e.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()},this.setByDPArray=function(t){for(var n=[],i=0;i0&&t.push(new r({array:e}))}return new r({array:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&(this.params=t)},ee(ot.asn1.x509.PolicyInformation,ot.asn1.ASN1Object),ot.asn1.x509.PolicyQualifierInfo=function(t){ot.asn1.x509.PolicyQualifierInfo.superclass.constructor.call(this,t);var e=ot.asn1,r=e.DERSequence,n=e.DERIA5String,i=e.DERObjectIdentifier,s=e.x509.UserNotice;this.params=null,this.tohex=function(){return void 0!==this.params.cps?new r({array:[new i({oid:"1.3.6.1.5.5.7.2.1"}),new n({str:this.params.cps})]}).tohex():null!=this.params.unotice?new r({array:[new i({oid:"1.3.6.1.5.5.7.2.2"}),new s(this.params.unotice)]}).tohex():void 0},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&(this.params=t)},ee(ot.asn1.x509.PolicyQualifierInfo,ot.asn1.ASN1Object),ot.asn1.x509.UserNotice=function(t){ot.asn1.x509.UserNotice.superclass.constructor.call(this,t);var e=ot.asn1.DERSequence,r=(ot.asn1.DERInteger,ot.asn1.x509.DisplayText),n=ot.asn1.x509.NoticeReference;this.params=null,this.tohex=function(){var t=[];return void 0!==this.params.noticeref&&t.push(new n(this.params.noticeref)),void 0!==this.params.exptext&&t.push(new r(this.params.exptext)),new e({array:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&(this.params=t)},ee(ot.asn1.x509.UserNotice,ot.asn1.ASN1Object),ot.asn1.x509.NoticeReference=function(t){ot.asn1.x509.NoticeReference.superclass.constructor.call(this,t);var e=ot.asn1.DERSequence,r=ot.asn1.DERInteger,n=ot.asn1.x509.DisplayText;this.params=null,this.tohex=function(){var t=[];if(void 0!==this.params.org&&t.push(new n(this.params.org)),void 0!==this.params.noticenum){for(var i=[],s=this.params.noticenum,a=0;a0)for(var t=0;t0;i++){var s=e.shift();if(!0===r){var a=(n.pop()+","+s).replace(/\\,/g,",");n.push(a),r=!1}else n.push(s);"\\"===s.substr(-1,1)&&(r=!0)}return n=n.map(function(t){return t.replace("/","\\/")}),n.reverse(),"/"+n.join("/")},ot.asn1.x509.X500Name.ldapToOneline=function(t){return ot.asn1.x509.X500Name.ldapToCompat(t)},ot.asn1.x509.RDN=function(t){ot.asn1.x509.RDN.superclass.constructor.call(this),this.asn1Array=[],this.paramArray=[],this.sRule="utf8";var e=ot.asn1.x509.AttributeTypeAndValue;this.setByParam=function(t){void 0!==t.rule&&(this.sRule=t.rule),void 0!==t.str&&this.addByMultiValuedString(t.str),void 0!==t.array&&(this.paramArray=t.array)},this.addByString=function(t){this.asn1Array.push(new ot.asn1.x509.AttributeTypeAndValue({str:t,rule:this.sRule}))},this.addByMultiValuedString=function(t){for(var e=ot.asn1.x509.RDN.parseString(t),r=0;r0)for(var t=0;t0;i++){var s=e.shift();if(!0===r){var a=(n.pop()+"+"+s).replace(/\\\+/g,"+");n.push(a),r=!1}else n.push(s);"\\"===s.substr(-1,1)&&(r=!0)}var o=!1,u=[];for(i=0;n.length>0;i++){s=n.shift();if(!0===o){var c=u.pop();if(s.match(/"$/)){a=(c+"+"+s).replace(/^([^=]+)="(.*)"$/,"$1=$2");u.push(a),o=!1}else u.push(c+"+"+s)}else u.push(s);s.match(/^[^=]+="/)&&(o=!0)}return u},ot.asn1.x509.AttributeTypeAndValue=function(t){ot.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this),this.sRule="utf8",this.sType=null,this.sValue=null,this.dsType=null;var e=ot,r=e.asn1,n=r.DERSequence,i=r.DERUTF8String,s=r.DERPrintableString,a=r.DERTeletexString,o=r.DERIA5String,u=r.DERVisibleString,c=r.DERBMPString,l=e.lang.String.isMail,h=e.lang.String.isPrintable;this.setByParam=function(t){if(void 0!==t.rule&&(this.sRule=t.rule),void 0!==t.ds&&(this.dsType=t.ds),void 0===t.value&&void 0!==t.str){var e=t.str.match(/^([^=]+)=(.+)$/);if(!e)throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr);this.sType=e[1],this.sValue=e[2]}else this.sType=t.type,this.sValue=t.value},this.setByString=function(t,e){void 0!==e&&(this.sRule=e);var r=t.match(/^([^=]+)=(.+)$/);if(!r)throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr);this.setByAttrTypeAndValueStr(r[1],r[2])},this._getDsType=function(){var t=this.sType,e=this.sValue,r=this.sRule;return"prn"===r?"CN"==t&&l(e)?"ia5":h(e)?"prn":"utf8":"utf8"===r?"CN"==t&&l(e)?"ia5":"C"==t?"prn":"utf8":"utf8"},this.setByAttrTypeAndValueStr=function(t,e,r){void 0!==r&&(this.sRule=r),this.sType=t,this.sValue=e},this.getValueObj=function(t,e){if("utf8"==t)return new i({str:e});if("prn"==t)return new s({str:e});if("tel"==t)return new a({str:e});if("ia5"==t)return new o({str:e});if("vis"==t)return new u({str:e});if("bmp"==t)return new c({str:e});throw new Error("unsupported directory string type: type="+t+" value="+e)},this.tohex=function(){null==this.dsType&&(this.dsType=this._getDsType());var t=ot.asn1.x509.OID.atype2obj(this.sType),e=this.getValueObj(this.dsType,this.sValue),r=new n({array:[t,e]});return this.TLV=r.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},ee(ot.asn1.x509.AttributeTypeAndValue,ot.asn1.ASN1Object),ot.asn1.x509.SubjectPublicKeyInfo=function(t){ot.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var e=ot,r=e.asn1,n=r.DERInteger,i=r.DERBitString,s=r.DERObjectIdentifier,a=r.DERSequence,o=r.ASN1Util.newObject,u=r.x509.AlgorithmIdentifier,c=e.crypto;c.ECDSA,c.DSA;this.getASN1Object=function(){if(null==this.asn1AlgId||null==this.asn1SubjPKey)throw"algId and/or subjPubKey not set";return new a({array:[this.asn1AlgId,this.asn1SubjPKey]})},this.tohex=function(){var t=this.getASN1Object();return this.hTLV=t.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},this.setPubKey=function(t){try{if(t instanceof rt){var e=o({seq:[{int:{bigint:t.n}},{int:{int:t.e}}]}).tohex();this.asn1AlgId=new u({name:"rsaEncryption"}),this.asn1SubjPKey=new i({hex:"00"+e})}}catch(t){}try{if(t instanceof ot.crypto.ECDSA){var r=new s({name:t.curveName});this.asn1AlgId=new u({name:"ecPublicKey",asn1params:r}),this.asn1SubjPKey=new i({hex:"00"+t.pubKeyHex})}}catch(t){}try{if(t instanceof ot.crypto.DSA){r=new o({seq:[{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}}]});this.asn1AlgId=new u({name:"dsa",asn1params:r});var a=new n({bigint:t.y});this.asn1SubjPKey=new i({hex:"00"+a.tohex()})}}catch(t){}},void 0!==t&&this.setPubKey(t)},ee(ot.asn1.x509.SubjectPublicKeyInfo,ot.asn1.ASN1Object),ot.asn1.x509.Time=function(t){ot.asn1.x509.Time.superclass.constructor.call(this);var e=ot.asn1,r=e.DERUTCTime,n=e.DERGeneralizedTime;this.params=null,this.type=null,this.setTimeParams=function(t){this.timeParams=t},this.setByParam=function(t){this.params=t},this.getType=function(t){return t.match(/^[0-9]{12}Z$/)?"utc":t.match(/^[0-9]{14}Z$/)?"gen":t.match(/^[0-9]{12}\.[0-9]+Z$/)?"utc":t.match(/^[0-9]{14}\.[0-9]+Z$/)?"gen":null},this.tohex=function(){var t=this.params,e=null;if("string"==typeof t&&(t={str:t}),null==t||!t.str||null!=t.type&&null!=t.type||(t.type=this.getType(t.str)),null!=t&&t.str?("utc"==t.type&&(e=new r(t.str)),"gen"==t.type&&(e=new n(t.str))):e="gen"==this.type?new n:new r,null==e)throw new Error("wrong setting for Time");return this.TLV=e.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},ot.asn1.x509.Time_bak=function(t){ot.asn1.x509.Time_bak.superclass.constructor.call(this);var e=ot.asn1,r=e.DERUTCTime,n=e.DERGeneralizedTime;this.setTimeParams=function(t){this.timeParams=t},this.tohex=function(){var t=null;return t=null!=this.timeParams?"utc"==this.type?new r(this.timeParams):new n(this.timeParams):"utc"==this.type?new r:new n,this.TLV=t.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},this.type="utc",void 0!==t&&(void 0!==t.type?this.type=t.type:void 0!==t.str&&(t.str.match(/^[0-9]{12}Z$/)&&(this.type="utc"),t.str.match(/^[0-9]{14}Z$/)&&(this.type="gen")),this.timeParams=t)},ee(ot.asn1.x509.Time,ot.asn1.ASN1Object),ot.asn1.x509.AlgorithmIdentifier=function(t){ot.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this),this.nameAlg=null,this.asn1Alg=null,this.asn1Params=null,this.paramEmpty=!1;var e=ot.asn1,r=e.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV;if(this.tohex=function(){if(null===this.nameAlg&&null===this.asn1Alg)throw new Error("algorithm not specified");if(null!==this.nameAlg){var t=null;for(var n in r)n===this.nameAlg&&(t=r[n]);if(null!==t)return this.hTLV=t,this.hTLV}null!==this.nameAlg&&null===this.asn1Alg&&(this.asn1Alg=e.x509.OID.name2obj(this.nameAlg));var i=[this.asn1Alg];null!==this.asn1Params&&i.push(this.asn1Params);var s=new e.DERSequence({array:i});return this.hTLV=s.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&(void 0!==t.name&&(this.nameAlg=t.name),void 0!==t.asn1params&&(this.asn1Params=t.asn1params),void 0!==t.paramempty&&(this.paramEmpty=t.paramempty)),null===this.asn1Params&&!1===this.paramEmpty&&null!==this.nameAlg){void 0!==this.nameAlg.name&&(this.nameAlg=this.nameAlg.name);var n=this.nameAlg.toLowerCase();"withdsa"!==n.substr(-7,7)&&"withecdsa"!==n.substr(-9,9)&&(this.asn1Params=new e.DERNull)}},ee(ot.asn1.x509.AlgorithmIdentifier,ot.asn1.ASN1Object),ot.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV={SHAwithRSAandMGF1:"300d06092a864886f70d01010a3000",SHA256withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040201a11a301806092a864886f70d010108300b0609608648016503040201a203020120",SHA384withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040202a11a301806092a864886f70d010108300b0609608648016503040202a203020130",SHA512withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040203a11a301806092a864886f70d010108300b0609608648016503040203a203020140"},ot.asn1.x509.GeneralName=function(t){ot.asn1.x509.GeneralName.superclass.constructor.call(this);var e=ot.asn1,r=e.x509,n=r.X500Name,i=r.OtherName,s=e.DERIA5String,a=(e.DERPrintableString,e.DEROctetString),o=e.DERTaggedObject,u=e.ASN1Object,c=Error;this.params=null,this.setByParam=function(t){this.params=t},this.tohex=function(){var t,e,r=this.params,l=!1;if(void 0!==r.other)t="a0",e=new i(r.other);else if(void 0!==r.rfc822)t="81",e=new s({str:r.rfc822});else if(void 0!==r.dns)t="82",e=new s({str:r.dns});else if(void 0!==r.dn)t="a4",l=!0,e="string"==typeof r.dn?new n({str:r.dn}):r.dn instanceof ot.asn1.x509.X500Name?r.dn:new n(r.dn);else if(void 0!==r.ldapdn)t="a4",l=!0,e=new n({ldapstr:r.ldapdn});else if(void 0!==r.certissuer||void 0!==r.certsubj){var h,f;t="a4",l=!0;var d=null;if(void 0!==r.certsubj?(h=!1,f=r.certsubj):(h=!0,f=r.certissuer),f.match(/^[0-9A-Fa-f]+$/),-1!=f.indexOf("-----BEGIN ")&&(d=Pt(f)),null==d)throw new Error("certsubj/certissuer not cert");var p,g=new ae;g.hex=d,p=h?g.getIssuerHex():g.getSubjectHex(),(e=new u).hTLV=p}else if(void 0!==r.uri)t="86",e=new s({str:r.uri});else{if(void 0===r.ip)throw new c("improper params");var v;t="87";var y=r.ip;try{if(y.match(/^[0-9a-f]+$/)){var m=y.length;if(8!=m&&16!=m&&32!=m&&64!=m)throw"err";v=y}else v=Ht(y)}catch(t){throw new c("malformed IP address: "+r.ip+":"+t.message)}e=new a({hex:v})}return new o({tag:t,explicit:l,obj:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},ee(ot.asn1.x509.GeneralName,ot.asn1.ASN1Object),ot.asn1.x509.GeneralNames=function(t){ot.asn1.x509.GeneralNames.superclass.constructor.call(this);var e=ot.asn1;this.setByParamArray=function(t){for(var r=0;r0){for(var r=s(t.valhex,e[0]),n=l(r,0),i=[],a=0;a1){var c=s(t.valhex,e[1]);t.polhex=c}delete t.valhex},this.setSignaturePolicyIdentifier=function(t){var r=l(t.valhex,0);if(r.length>0){var a=n.getOID(t.valhex,r[0]);t.oid=a}if(r.length>1){var o=new e,u=l(t.valhex,r[1]),c=s(t.valhex,u[0]),h=o.getAlgorithmIdentifierName(c);t.alg=h;var f=i(t.valhex,u[1]);t.hash=f}delete t.valhex},this.setSigningCertificateV2=function(t){var e=l(t.valhex,0);if(e.length>0){for(var r=s(t.valhex,e[0]),n=l(r,0),i=[],a=0;a1){var c=s(t.valhex,e[1]);t.polhex=c}delete t.valhex},this.getESSCertID=function(t){var e={},r=l(t,0);if(r.length>0){var n=i(t,r[0]);e.hash=n}if(r.length>1){var a=s(t,r[1]),o=this.getIssuerSerial(a);null!=o.serial&&(e.serial=o.serial),null!=o.issuer&&(e.issuer=o.issuer)}return e},this.getESSCertIDv2=function(e){var n={},a=l(e,0);if(a.length<1||3o+1){var h=s(e,a[o+1]),f=this.getIssuerSerial(h);n.issuer=f.issuer,n.serial=f.serial}return n},this.getIssuerSerial=function(t){var e={},n=l(t,0),a=s(t,n[0]),o=r.getGeneralNames(a)[0].dn;e.issuer=o;var u=i(t,n[1]);return e.serial={hex:u},e},this.getCertificateSet=function(t){for(var e=l(t,0),r=[],n=0;n=0;a--)i+=n[a];return i}if("string"==typeof t&&null!=s[t])return Qt([t],s);if("object"==typeof t&&null!=t.length)return Qt(t,s);throw new e("wrong params")},this.tohex=function(){this.params;var t=this.getBinValue();return new n({bin:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},ee(ot.asn1.tsp.PKIFailureInfo,ot.asn1.ASN1Object),ot.asn1.tsp.AbstractTSAAdapter=function(t){this.getTSTHex=function(t,e){throw"not implemented yet"}},ot.asn1.tsp.SimpleTSAAdapter=function(t){var e=ot,r=e.asn1.tsp,n=e.crypto.Util.hashHex;r.SimpleTSAAdapter.superclass.constructor.call(this),this.params=null,this.serial=0,this.getTSTHex=function(t,e){var i=n(t,e);this.params.econtent.content.messageImprint={alg:e,hash:i},this.params.econtent.content.serial={int:this.serial++};var s=Math.floor(1e9*Math.random());return this.params.econtent.content.nonce={int:s},new r.TimeStampToken(this.params).getContentInfoEncodedHex()},void 0!==t&&(this.params=t)},ee(ot.asn1.tsp.SimpleTSAAdapter,ot.asn1.tsp.AbstractTSAAdapter),ot.asn1.tsp.FixedTSAAdapter=function(t){var e=ot,r=e.asn1.tsp,n=e.crypto.Util.hashHex;r.FixedTSAAdapter.superclass.constructor.call(this),this.params=null,this.getTSTHex=function(t,e){var i=n(t,e);return this.params.econtent.content.messageImprint={alg:e,hash:i},new r.TimeStampToken(this.params).getContentInfoEncodedHex()},void 0!==t&&(this.params=t)},ee(ot.asn1.tsp.FixedTSAAdapter,ot.asn1.tsp.AbstractTSAAdapter),ot.asn1.tsp.TSPUtil=new function(){},ot.asn1.tsp.TSPUtil.newTimeStampToken=function(t){return new ot.asn1.tsp.TimeStampToken(t)},ot.asn1.tsp.TSPUtil.parseTimeStampReq=function(t){return(new ot.asn1.tsp.TSPParser).getTimeStampReq(t)},ot.asn1.tsp.TSPUtil.parseMessageImprint=function(t){return(new ot.asn1.tsp.TSPParser).getMessageImprint(t)},ot.asn1.tsp.TSPParser=function(){Error;var t=new ae,e=lt,r=e.getV,n=e.getTLV,i=e.getIdxbyList,s=(e.getTLVbyListEx,e.getChildIdx),a=["granted","grantedWithMods","rejection","waiting","revocationWarning","revocationNotification"],o={0:"badAlg",2:"badRequest",5:"badDataFormat",14:"timeNotAvailable",15:"unacceptedPolicy",16:"unacceptedExtension",17:"addInfoNotAvailable",25:"systemFailure"};this.getResponse=function(t){var e=s(t,0);if(1==e.length)return this.getPKIStatusInfo(n(t,e[0]));if(e.length>1){var r=this.getPKIStatusInfo(n(t,e[0])),i=n(t,e[1]),a=this.getToken(i);return a.statusinfo=r,a}},this.getToken=function(t){var e=(new ot.asn1.cms.CMSParser).getCMSSignedData(t);return this.setTSTInfo(e),e},this.setTSTInfo=function(t){var e=t.econtent;if("tstinfo"==e.type){var r=e.content.hex,n=this.getTSTInfo(r);e.content=n}},this.getTSTInfo=function(e){var i={},a=s(e,0),o=r(e,a[1]);i.policy=Gt(o);var u=n(e,a[2]);i.messageImprint=this.getMessageImprint(u);var c=r(e,a[3]);i.serial={hex:c};var l=r(e,a[4]);i.genTime={str:xt(l)};var h=0;if(a.length>5&&"30"==e.substr(a[5],2)){var f=n(e,a[5]);i.accuracy=this.getAccuracy(f),h++}a.length>5+h&&"01"==e.substr(a[5+h],2)&&("ff"==r(e,a[5+h])&&(i.ordering=!0),h++);if(a.length>5+h&&"02"==e.substr(a[5+h],2)){var d=r(e,a[5+h]);i.nonce={hex:d},h++}if(a.length>5+h&&"a0"==e.substr(a[5+h],2)){var p=n(e,a[5+h]);p="30"+p.substr(2),pGeneralNames=t.getGeneralNames(p);var g=pGeneralNames[0].dn;i.tsa=g,h++}if(a.length>5+h&&"a1"==e.substr(a[5+h],2)){var v=n(e,a[5+h]);v="30"+v.substr(2);var y=t.getExtParamArray(v);i.ext=y,h++}return i},this.getAccuracy=function(t){for(var e={},n=s(t,0),i=0;i1&&"30"==t.substr(i[1],2)){var l=n(t,i[1]);e.statusstr=this.getPKIFreeText(l),o++}if(i.length>o&&"03"==t.substr(i[1+o],2)){var h=n(t,i[1+o]);e.failinfo=this.getPKIFailureInfo(h)}return e},this.getPKIFreeText=function(t){for(var r=[],n=s(t,0),i=0;i0&&(c=c+"."+o.join(".")),c}catch(t){return null}}function zt(t){return Jt(new w(String(t),10))}function Jt(t){var e=t.toString(16);if("-"!=e.substr(0,1))return e.length%2==1?e="0"+e:e.match(/^[0-7]/)||(e="00"+e),e;var r=e.substr(1).length;r%2==1?r+=1:e.match(/^[0-7]/)||(r+=2);for(var n="",i=0;i=e?t:new Array(e-t.length+1).join(r)+t};function Xt(t){if(t.length%2!=0)return-1;if(null==(t=t.toLowerCase()).match(/^[0-9a-f]+$/))return-1;try{var e=t.substr(0,2);if("00"==e)return parseInt(t.substr(2),16);var r=parseInt(e,16);if(r>7)return-1;var n=t.substr(2),i=parseInt(n,16).toString(2);"0"==i&&(i="00000000"),i=i.slice(0,0-r);var s=parseInt(i,2);return NaN==s?-1:s}catch(t){return-1}}function Yt(t){if("number"!=typeof t)return null;if(t<0)return null;var e=Number(t).toString(2),r=8-e.length%8;8==r&&(r=0),e+=$t("",r,"0");var n=parseInt(e,2).toString(16);return n.length%2==1&&(n="0"+n),"0"+r+n}function Zt(t){if("string"!=typeof t)return null;if(t.length%2!=0)return null;if(!t.match(/^[0-9a-f]+$/))return null;try{var e=parseInt(t.substr(0,2),16);if(e<0||7=0;n--)s+=i[n];return s}function te(t,e,r){if("object"==typeof t){e=String(e).split(".");for(var n=0;ni)throw"key is too short for SigAlg: keylen="+r+","+e;for(var s="0001",a="00"+n,o="",u=i-4-a.length,c=0;c=0)return!1;if(n.compareTo(r.ONE)<0||n.compareTo(s)>=0)return!1;var o=n.modInverse(s),u=t.multiply(o).mod(s),c=e.multiply(o).mod(s);return a.multiply(u).add(i.multiply(c)).getX().toBigInteger().mod(s).equals(e)},this.serializeSig=function(t,e){var r=t.toByteArraySigned(),n=e.toByteArraySigned(),i=[];return i.push(2),i.push(r.length),(i=i.concat(r)).push(2),i.push(n.length),(i=i.concat(n)).unshift(i.length),i.unshift(48),i},this.parseSig=function(t){var e;if(48!=t[0])throw new Error("Signature not a valid DERSequence");if(2!=t[e=2])throw new Error("First element in signature must be a DERInteger");var n=t.slice(e+2,e+2+t[e+1]);if(2!=t[e+=2+t[e+1]])throw new Error("Second element in signature must be a DERInteger");var i=t.slice(e+2,e+2+t[e+1]);return e+=2+t[e+1],{r:r.fromByteArrayUnsigned(n),s:r.fromByteArrayUnsigned(i)}},this.parseSigCompact=function(t){if(65!==t.length)throw"Signature has the wrong length";var e=t[0]-27;if(e<0||e>7)throw"Invalid signature type";var n=this.ecparams.n;return{r:r.fromByteArrayUnsigned(t.slice(1,33)).mod(n),s:r.fromByteArrayUnsigned(t.slice(33,65)).mod(n),i:e}},this.readPKCS5PrvKeyHex=function(t){if(!1===c(t))throw new Error("not ASN.1 hex string");var e,r,n;try{e=u(t,0,["[0]",0],"06"),r=u(t,0,[1],"04");try{n=u(t,0,["[1]",0],"03")}catch(t){}}catch(t){throw new Error("malformed PKCS#1/5 plain ECC private key")}if(this.curveName=a(e),void 0===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(n),this.setPrivateKeyHex(r),this.isPublic=!1},this.readPKCS8PrvKeyHex=function(t){if(!1===c(t))throw new e("not ASN.1 hex string");var r,n,i;try{u(t,0,[1,0],"06"),r=u(t,0,[1,1],"06"),n=u(t,0,[2,0,1],"04");try{i=u(t,0,[2,0,"[1]",0],"03")}catch(t){}}catch(t){throw new e("malformed PKCS#8 plain ECC private key")}if(this.curveName=a(r),void 0===this.curveName)throw new e("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(i),this.setPrivateKeyHex(n),this.isPublic=!1},this.readPKCS8PubKeyHex=function(t){if(!1===c(t))throw new e("not ASN.1 hex string");var r,n;try{u(t,0,[0,0],"06"),r=u(t,0,[0,1],"06"),n=u(t,0,[1],"03")}catch(t){throw new e("malformed PKCS#8 ECC public key")}if(this.curveName=a(r),null===this.curveName)throw new e("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(n)},this.readCertPubKeyHex=function(t,r){if(!1===c(t))throw new e("not ASN.1 hex string");var n,i;try{n=u(t,0,[0,5,0,1],"06"),i=u(t,0,[0,5,1],"03")}catch(t){throw new e("malformed X.509 certificate ECC public key")}if(this.curveName=a(n),null===this.curveName)throw new e("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(i)},void 0!==t&&void 0!==t.curve&&(this.curveName=t.curve),void 0===this.curveName&&(this.curveName="secp256r1"),this.setNamedCurve(this.curveName),void 0!==t&&(void 0!==t.prv&&this.setPrivateKeyHex(t.prv),void 0!==t.pub&&this.setPublicKeyHex(t.pub))},ot.crypto.ECDSA.parseSigHex=function(t){var e=ot.crypto.ECDSA.parseSigHexInHexRS(t);return{r:new w(e.r,16),s:new w(e.s,16)}},ot.crypto.ECDSA.parseSigHexInHexRS=function(t){var e=lt,r=e.getChildIdx,n=e.getV;if(e.checkStrictDER(t,0),"30"!=t.substr(0,2))throw new Error("signature is not a ASN.1 sequence");var i=r(t,0);if(2!=i.length)throw new Error("signature shall have two elements");var s=i[0],a=i[1];if("02"!=t.substr(s,2))throw new Error("1st item not ASN.1 integer");if("02"!=t.substr(a,2))throw new Error("2nd item not ASN.1 integer");return{r:n(t,s),s:n(t,a)}},ot.crypto.ECDSA.asn1SigToConcatSig=function(t){var e=ot.crypto.ECDSA.parseSigHexInHexRS(t),r=e.r,n=e.s;if(r.length>=130&&r.length<=134){if(r.length%2!=0)throw Error("unknown ECDSA sig r length error");if(n.length%2!=0)throw Error("unknown ECDSA sig s length error");"00"==r.substr(0,2)&&(r=r.substr(2)),"00"==n.substr(0,2)&&(n=n.substr(2));var i=Math.max(r.length,n.length);return(r=("000000"+r).slice(-i))+(n=("000000"+n).slice(-i))}if("00"==r.substr(0,2)&&r.length%32==2&&(r=r.substr(2)),"00"==n.substr(0,2)&&n.length%32==2&&(n=n.substr(2)),r.length%32==30&&(r="00"+r),n.length%32==30&&(n="00"+n),r.length%32!=0)throw Error("unknown ECDSA sig r length error");if(n.length%32!=0)throw Error("unknown ECDSA sig s length error");return r+n},ot.crypto.ECDSA.concatSigToASN1Sig=function(t){if(t.length%4!=0)throw Error("unknown ECDSA concatinated r-s sig length error");var e=t.substr(0,t.length/2),r=t.substr(t.length/2);return ot.crypto.ECDSA.hexRSSigToASN1Sig(e,r)},ot.crypto.ECDSA.hexRSSigToASN1Sig=function(t,e){var r=new w(t,16),n=new w(e,16);return ot.crypto.ECDSA.biRSSigToASN1Sig(r,n)},ot.crypto.ECDSA.biRSSigToASN1Sig=function(t,e){var r=ot.asn1,n=new r.DERInteger({bigint:t}),i=new r.DERInteger({bigint:e});return new r.DERSequence({array:[n,i]}).tohex()},ot.crypto.ECDSA.getName=function(t){return"2b8104001f"===t?"secp192k1":"2a8648ce3d030107"===t?"secp256r1":"2b8104000a"===t?"secp256k1":"2b81040021"===t?"secp224r1":"2b81040022"===t?"secp384r1":"2b81040023"===t?"secp521r1":-1!=="|secp256r1|NIST P-256|P-256|prime256v1|".indexOf(t)?"secp256r1":-1!=="|secp256k1|".indexOf(t)?"secp256k1":-1!=="|secp224r1|NIST P-224|P-224|".indexOf(t)?"secp224r1":-1!=="|secp384r1|NIST P-384|P-384|".indexOf(t)?"secp384r1":-1!=="|secp521r1|NIST P-521|P-521|".indexOf(t)?"secp521r1":null},void 0!==ot&&ot||(ot={}),void 0!==ot.crypto&&ot.crypto||(ot.crypto={}),ot.crypto.ECParameterDB=new function(){var t={},e={};function r(t){return new w(t,16)}this.getByName=function(r){var n=r;if(void 0!==e[n]&&(n=e[r]),void 0!==t[n])return t[n];throw"unregistered EC curve name: "+n},this.regist=function(n,i,s,a,o,u,c,l,h,f,d,p){t[n]={};var g=r(s),v=r(a),y=r(o),m=r(u),b=r(c),x=new st(g,v,y),w=x.decodePointHex("04"+l+h);t[n].name=n,t[n].keylen=i,t[n].keycharlen=2*Math.ceil(i/8),t[n].curve=x,t[n].G=w,t[n].n=m,t[n].h=b,t[n].oid=d,t[n].info=p;for(var S=0;S1?new w(n,16):null,c=new w(i,16),this.setPrivate(s,a,o,u,c)},this.setPublic=function(t,e,r,n){this.isPublic=!0,this.p=t,this.q=e,this.g=r,this.y=n,this.x=null},this.setPublicHex=function(t,e,r,n){var i,s,a,o;i=new w(t,16),s=new w(e,16),a=new w(r,16),o=new w(n,16),this.setPublic(i,s,a,o)},this.signWithMessageHash=function(t){var e=this.p,r=this.q,n=this.g,i=(this.y,this.x),s=ot.crypto.Util.getRandomBigIntegerMinToMax(w.ONE.add(w.ONE),r.subtract(w.ONE)),a=new w(t.substr(0,r.bitLength()/4),16),o=n.modPow(s,e).mod(r),u=s.modInverse(r).multiply(a.add(i.multiply(o))).mod(r);return ot.asn1.ASN1Util.jsonToASN1HEX({seq:[{int:{bigint:o}},{int:{bigint:u}}]})},this.verifyWithMessageHash=function(t,e){var r=this.p,n=this.q,i=this.g,s=this.y,a=this.parseASN1Signature(e),o=a[0],u=a[1],c=new w(t.substr(0,n.bitLength()/4),16);if(w.ZERO.compareTo(o)>0||o.compareTo(n)>0)throw"invalid DSA signature";if(w.ZERO.compareTo(u)>=0||u.compareTo(n)>0)throw"invalid DSA signature";var l=u.modInverse(n),h=c.multiply(l).mod(n),f=o.multiply(l).mod(n);return 0==i.modPow(h,r).multiply(s.modPow(f,r)).mod(r).mod(n).compareTo(o)},this.parseASN1Signature=function(t){try{return[new n(e(t,0,[0],"02"),16),new n(e(t,0,[1],"02"),16)]}catch(t){throw new Error("malformed ASN.1 DSA signature")}},this.readPKCS5PrvKeyHex=function(t){var n,i,s,a,o;if(!1===r(t))throw new Error("not ASN.1 hex string");try{n=e(t,0,[1],"02"),i=e(t,0,[2],"02"),s=e(t,0,[3],"02"),a=e(t,0,[4],"02"),o=e(t,0,[5],"02")}catch(t){throw new Error("malformed PKCS#1/5 plain DSA private key")}this.setPrivateHex(n,i,s,a,o)},this.readPKCS8PrvKeyHex=function(t){var n,i,s,a;if(!1===r(t))throw new Error("not ASN.1 hex string");try{n=e(t,0,[1,1,0],"02"),i=e(t,0,[1,1,1],"02"),s=e(t,0,[1,1,2],"02"),a=e(t,0,[2,0],"02")}catch(t){throw new Error("malformed PKCS#8 plain DSA private key")}this.setPrivateHex(n,i,s,null,a)},this.readPKCS8PubKeyHex=function(t){var n,i,s,a;if(!1===r(t))throw new Error("not ASN.1 hex string");try{n=e(t,0,[0,1,0],"02"),i=e(t,0,[0,1,1],"02"),s=e(t,0,[0,1,2],"02"),a=e(t,0,[1,0],"02")}catch(t){throw new Error("malformed PKCS#8 DSA public key")}this.setPublicHex(n,i,s,a)},this.readCertPubKeyHex=function(t,n){var i,s,a,o;if(!1===r(t))throw new Error("not ASN.1 hex string");try{i=e(t,0,[0,5,0,1,0],"02"),s=e(t,0,[0,5,0,1,1],"02"),a=e(t,0,[0,5,0,1,2],"02"),o=e(t,0,[0,5,1,0],"02")}catch(t){throw new Error("malformed X.509 certificate DSA public key")}this.setPublicHex(i,s,a,o)}};var re=function(){var t=function(t,r,n){return e(g.AES,t,r,n)},e=function(t,e,r,n){var i=g.enc.Hex.parse(e),s=g.enc.Hex.parse(r),a=g.enc.Hex.parse(n),o={};o.key=s,o.iv=a,o.ciphertext=i;var u=t.decrypt(o,s,{iv:a});return g.enc.Hex.stringify(u)},r=function(t,e,r){return n(g.AES,t,e,r)},n=function(t,e,r,n){var i=g.enc.Hex.parse(e),s=g.enc.Hex.parse(r),a=g.enc.Hex.parse(n),o=t.encrypt(i,s,{iv:a}),u=g.enc.Hex.parse(o.toString());return g.enc.Base64.stringify(u)},i={"AES-256-CBC":{proc:t,eproc:r,keylen:32,ivlen:16},"AES-192-CBC":{proc:t,eproc:r,keylen:24,ivlen:16},"AES-128-CBC":{proc:t,eproc:r,keylen:16,ivlen:16},"DES-EDE3-CBC":{proc:function(t,r,n){return e(g.TripleDES,t,r,n)},eproc:function(t,e,r){return n(g.TripleDES,t,e,r)},keylen:24,ivlen:8},"DES-CBC":{proc:function(t,r,n){return e(g.DES,t,r,n)},eproc:function(t,e,r){return n(g.DES,t,e,r)},keylen:8,ivlen:8}},s=function(t){var e={},r=t.match(new RegExp("DEK-Info: ([^,]+),([0-9A-Fa-f]+)","m"));r&&(e.cipher=r[1],e.ivsalt=r[2]);var n=t.match(new RegExp("-----BEGIN ([A-Z]+) PRIVATE KEY-----"));n&&(e.type=n[1]);var i=-1,s=0;-1!=t.indexOf("\r\n\r\n")&&(i=t.indexOf("\r\n\r\n"),s=2),-1!=t.indexOf("\n\n")&&(i=t.indexOf("\n\n"),s=1);var a=t.indexOf("-----END");if(-1!=i&&-1!=a){var o=t.substring(i+2*s,a-s);o=o.replace(/\s+/g,""),e.data=o}return e},a=function(t,e,r){for(var n=r.substring(0,16),s=g.enc.Hex.parse(n),a=g.enc.Utf8.parse(e),o=i[t].keylen+i[t].ivlen,u="",c=null;;){var l=g.algo.MD5.create();if(null!=c&&l.update(c),l.update(a),l.update(s),c=l.finalize(),(u+=g.enc.Hex.stringify(c)).length>=2*o)break}var h={};return h.keyhex=u.substr(0,2*i[t].keylen),h.ivhex=u.substr(2*i[t].keylen,2*i[t].ivlen),h},o=function(t,e,r,n){var s=g.enc.Base64.parse(t),a=g.enc.Hex.stringify(s);return(0,i[e].proc)(a,r,n)};return{version:"1.0.0",parsePKCS5PEM:function(t){return s(t)},getKeyAndUnusedIvByPasscodeAndIvsalt:function(t,e,r){return a(t,e,r)},decryptKeyB64:function(t,e,r,n){return o(t,e,r,n)},getDecryptedKeyHex:function(t,e){var r=s(t),n=(r.type,r.cipher),i=r.ivsalt,u=r.data,c=a(n,e,i).keyhex;return o(u,n,c,i)},getEncryptedPKCS5PEMFromPrvKeyHex:function(t,e,r,n,s){var o="";if(void 0!==n&&null!=n||(n="AES-256-CBC"),void 0===i[n])throw new Error("KEYUTIL unsupported algorithm: "+n);if(void 0===s||null==s){var u=function(t){var e=g.lib.WordArray.random(t);return g.enc.Hex.stringify(e)}(i[n].ivlen);s=u.toUpperCase()}var c=function(t,e,r,n){return(0,i[e].eproc)(t,r,n)}(e,n,a(n,r,s).keyhex,s);o="-----BEGIN "+t+" PRIVATE KEY-----\r\n";return o+="Proc-Type: 4,ENCRYPTED\r\n",o+="DEK-Info: "+n+","+s+"\r\n",o+="\r\n",o+=c.replace(/(.{64})/g,"$1\r\n"),o+="\r\n-----END "+t+" PRIVATE KEY-----\r\n"},getEncryptedPKCS8PEM:function(t,e,r){return Dt(this.getEncryptedPKCS8Hex(t,e,r),"ENCRYPTED PRIVATE KEY")},getEncryptedPKCS8Hex:function(t,e,r){var n;(n=null==r||null==r?{}:JSON.parse(JSON.stringify(r))).plain=t,this.initPBES2Param(n),this.encryptPBES2Param(n,e);var i=this.generatePBES2ASN1Param(n);return ot.asn1.ASN1Util.newObject(i).tohex()},initPBES2Param:function(t){var e;(null==te(t,"encalg")&&(t.encalg="aes256-CBC"),null==te(t,"iter")&&(t.iter=2048),null==te(t,"prf")&&(t.prf="hmacWithSHA256"),null==te(t,"salt")&&(t.salt=g.enc.Hex.stringify(g.lib.WordArray.random(8))),null==te(t,"enciv"))&&("des-EDE3-CBC"==t.encalg&&(e=8),"aes128-CBC"==t.encalg&&(e=16),"aes256-CBC"==t.encalg&&(e=16),t.enciv=g.enc.Hex.stringify(g.lib.WordArray.random(e)))},encryptPBES2Param:function(t,e){var r=re.getDKFromPBES2Param(t,e);try{var n=ot.crypto.Cipher.encrypt(t.plain,r,t.encalg,{iv:t.enciv})}catch(e){throw new Error("encrypt error: "+t.plain+" "+r+" "+t.encalg+" "+t.enciv)}t.enc=n},generatePBES2ASN1Param:function(t){var e={seq:[{seq:[{oid:"pkcs5PBES2"},{seq:[{seq:[{oid:"pkcs5PBKDF2"},{seq:[{octstr:{hex:t.salt}},{int:{hex:zt(t.iter)}}]}]},{seq:[{oid:t.encalg},{octstr:{hex:t.enciv}}]}]}]},{octstr:{hex:t.enc}}]};return"hmacWithSHA1"!=t.prf&&e.seq[0].seq[1].seq[0].seq[1].seq.push({seq:[{oid:t.prf},{null:""}]}),e},parseHexOfEncryptedPKCS8:function(t){var e=lt,r=e.getChildIdx,n=e.getV,i={},s=r(t,0);if(2!=s.length)throw new Error("malformed format: SEQUENCE(0).items != 2: "+s.length);i.ciphertext=n(t,s[1]);var a=r(t,s[0]);if(2!=a.length)throw new Error("malformed format: SEQUENCE(0.0).items != 2: "+a.length);if("2a864886f70d01050d"!=n(t,a[0]))throw new Error("this only supports pkcs5PBES2");var o=r(t,a[1]);if(2!=a.length)throw new Error("malformed format: SEQUENCE(0.0.1).items != 2: "+o.length);var u=r(t,o[1]);if(2!=u.length)throw new Error("malformed format: SEQUENCE(0.0.1.1).items != 2: "+u.length);if("2a864886f70d0307"!=n(t,u[0]))throw"this only supports TripleDES";i.encryptionSchemeAlg="TripleDES",i.encryptionSchemeIV=n(t,u[1]);var c=r(t,o[0]);if(2!=c.length)throw new Error("malformed format: SEQUENCE(0.0.1.0).items != 2: "+c.length);if("2a864886f70d01050c"!=n(t,c[0]))throw new Error("this only supports pkcs5PBKDF2");var l=r(t,c[1]);if(l.length<2)throw new Error("malformed format: SEQUENCE(0.0.1.0.1).items < 2: "+l.length);i.pbkdf2Salt=n(t,l[0]);var h=n(t,l[1]);try{i.pbkdf2Iter=parseInt(h,16)}catch(t){throw new Error("malformed format pbkdf2Iter: "+h)}return i},getPBKDF2KeyHexFromParam:function(t,e){var r=g.enc.Hex.parse(t.pbkdf2Salt),n=t.pbkdf2Iter,i=g.PBKDF2(e,r,{keySize:6,iterations:n});return g.enc.Hex.stringify(i)},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(t,e){var r=Pt(t,"ENCRYPTED PRIVATE KEY"),n=this.parseHexOfEncryptedPKCS8(r),i=re.getPBKDF2KeyHexFromParam(n,e),s={};s.ciphertext=g.enc.Hex.parse(n.ciphertext);var a=g.enc.Hex.parse(i),o=g.enc.Hex.parse(n.encryptionSchemeIV),u=g.TripleDES.decrypt(s,a,{iv:o});return g.enc.Hex.stringify(u)},parsePBES2:function(t){var e=lt.parse(t);if("pkcs5PBES2"!=te(e,"seq.0.seq.0.oid")||"pkcs5PBKDF2"!=te(e,"seq.0.seq.1.seq.0.seq.0.oid"))throw new Error("not pkcs5PBES2 and pkcs5PBKDF2 used");var r=te(e,"seq.0.seq.1.seq.0.seq.1.seq");if(null==r)throw new Error("PBKDF2 parameter not found");var n=te(r,"0.octstr.hex"),i=te(r,"1.int.hex"),s=te(r,"2.seq.0.oid","hmacWithSHA1"),a=-1;try{a=parseInt(i,16)}catch(t){throw new Error("iter not proper value")}var o=te(e,"seq.0.seq.1.seq.1.seq.0.oid"),u=te(e,"seq.0.seq.1.seq.1.seq.1.octstr.hex"),c=te(e,"seq.1.octstr.hex");if(null==o||null==u||null==c)throw new Error("encalg, enciv or enc is undefined");return{salt:n,iter:a,prf:s,encalg:o,enciv:u,enc:c}},getDKFromPBES2Param:function(t,e){var r={hmacWithSHA1:g.algo.SHA1,hmacWithSHA224:g.algo.SHA224,hmacWithSHA256:g.algo.SHA256,hmacWithSHA384:g.algo.SHA384,hmacWithSHA512:g.algo.SHA512}[t.prf];if(null==r)throw new Error("unsupported prf");var n={"des-EDE3-CBC":6,"aes128-CBC":4,"aes256-CBC":8}[t.encalg];if(null==n)throw new Error("unsupported encalg");var i=g.enc.Hex.parse(t.salt),s=t.iter;try{var a=g.PBKDF2(e,i,{keySize:n,iterations:s,hasher:r});return g.enc.Hex.stringify(a)}catch(r){throw new Error("PBKDF2 error: "+r+" "+JSON.stringify(t)+" "+e)}},getPlainHexFromEncryptedPKCS8PEM:function(t,e){if(-1==t.indexOf("BEGIN ENCRYPTED PRIVATE KEY"))throw new Error("not Encrypted PKCS#8 PEM string");var r,n=Pt(t);try{r=re.parsePBES2(n)}catch(t){throw new Error("malformed PBES2 format: "+t.message)}var i=re.getDKFromPBES2Param(r,e);return ot.crypto.Cipher.decrypt(r.enc,i,r.encalg,{iv:r.enciv})},getKeyFromEncryptedPKCS8PEM:function(t,e){var r=this.getPlainHexFromEncryptedPKCS8PEM(t,e);return this.getKeyFromPlainPrivatePKCS8Hex(r)},parsePlainPrivatePKCS8Hex:function(t){var e=lt,r=e.getChildIdx,n=e.getV,i={algparam:null};if("30"!=t.substr(0,2))throw new Error("malformed plain PKCS8 private key(code:001)");var s=r(t,0);if(s.length<3)throw new Error("malformed plain PKCS8 private key(code:002)");if("30"!=t.substr(s[1],2))throw new Error("malformed PKCS8 private key(code:003)");var a=r(t,s[1]);if(2!=a.length)throw new Error("malformed PKCS8 private key(code:004)");if("06"!=t.substr(a[0],2))throw new Error("malformed PKCS8 private key(code:005)");if(i.algoid=n(t,a[0]),"06"==t.substr(a[1],2)&&(i.algparam=n(t,a[1])),"04"!=t.substr(s[2],2))throw new Error("malformed PKCS8 private key(code:006)");return i.keyidx=e.getVidx(t,s[2]),i},getKeyFromPlainPrivatePKCS8PEM:function(t){var e=Pt(t,"PRIVATE KEY");return this.getKeyFromPlainPrivatePKCS8Hex(e)},getKeyFromPlainPrivatePKCS8Hex:function(t){var e,r=this.parsePlainPrivatePKCS8Hex(t);if("2a864886f70d010101"==r.algoid)e=new rt;else if("2a8648ce380401"==r.algoid)e=new ot.crypto.DSA;else{if("2a8648ce3d0201"!=r.algoid)throw new Error("unsupported private key algorithm");e=new ot.crypto.ECDSA}return e.readPKCS8PrvKeyHex(t),e},_getKeyFromPublicPKCS8Hex:function(t){var e,r=lt.getVbyList(t,0,[0,0],"06");if("2a864886f70d010101"===r)e=new rt;else if("2a8648ce380401"===r)e=new ot.crypto.DSA;else{if("2a8648ce3d0201"!==r)throw new Error("unsupported PKCS#8 public key hex");e=new ot.crypto.ECDSA}return e.readPKCS8PubKeyHex(t),e},parsePublicRawRSAKeyHex:function(t){var e=lt,r=e.getChildIdx,n=e.getV,i={};if("30"!=t.substr(0,2))throw new Error("malformed RSA key(code:001)");var s=r(t,0);if(2!=s.length)throw new Error("malformed RSA key(code:002)");if("02"!=t.substr(s[0],2))throw new Error("malformed RSA key(code:003)");if(i.n=n(t,s[0]),"02"!=t.substr(s[1],2))throw new Error("malformed RSA key(code:004)");return i.e=n(t,s[1]),i},parsePublicPKCS8Hex:function(t){var e=lt,r=e.getChildIdx,n=e.getV,i={algparam:null},s=r(t,0);if(2!=s.length)throw new Error("outer DERSequence shall have 2 elements: "+s.length);var a=s[0];if("30"!=t.substr(a,2))throw new Error("malformed PKCS8 public key(code:001)");var o=r(t,a);if(2!=o.length)throw new Error("malformed PKCS8 public key(code:002)");if("06"!=t.substr(o[0],2))throw new Error("malformed PKCS8 public key(code:003)");if(i.algoid=n(t,o[0]),"06"==t.substr(o[1],2)?i.algparam=n(t,o[1]):"30"==t.substr(o[1],2)&&(i.algparam={},i.algparam.p=e.getVbyList(t,o[1],[0],"02"),i.algparam.q=e.getVbyList(t,o[1],[1],"02"),i.algparam.g=e.getVbyList(t,o[1],[2],"02")),"03"!=t.substr(s[1],2))throw new Error("malformed PKCS8 public key(code:004)");return i.key=n(t,s[1]).substr(2),i}}}();re.getKey=function(t,e,r){var n=(v=lt).getChildIdx,i=(v.getV,v.getVbyList),s=ot.crypto,a=s.ECDSA,o=s.DSA,u=rt,c=Pt,l=re;if(void 0!==u&&t instanceof u)return t;if(void 0!==a&&t instanceof a)return t;if(void 0!==o&&t instanceof o)return t;if(void 0!==t.curve&&void 0!==t.xy&&void 0===t.d)return new a({pub:t.xy,curve:t.curve});if(void 0!==t.curve&&void 0!==t.d)return new a({prv:t.d,curve:t.curve});if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0===t.d)return(P=new u).setPublic(t.n,t.e),P;if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0!==t.p&&void 0!==t.q&&void 0!==t.dp&&void 0!==t.dq&&void 0!==t.co&&void 0===t.qi)return(P=new u).setPrivateEx(t.n,t.e,t.d,t.p,t.q,t.dp,t.dq,t.co),P;if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0===t.p)return(P=new u).setPrivate(t.n,t.e,t.d),P;if(void 0!==t.p&&void 0!==t.q&&void 0!==t.g&&void 0!==t.y&&void 0===t.x)return(P=new o).setPublic(t.p,t.q,t.g,t.y),P;if(void 0!==t.p&&void 0!==t.q&&void 0!==t.g&&void 0!==t.y&&void 0!==t.x)return(P=new o).setPrivate(t.p,t.q,t.g,t.y,t.x),P;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0===t.d)return(P=new u).setPublic(mt(t.n),mt(t.e)),P;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0!==t.p&&void 0!==t.q&&void 0!==t.dp&&void 0!==t.dq&&void 0!==t.qi)return(P=new u).setPrivateEx(mt(t.n),mt(t.e),mt(t.d),mt(t.p),mt(t.q),mt(t.dp),mt(t.dq),mt(t.qi)),P;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d)return(P=new u).setPrivate(mt(t.n),mt(t.e),mt(t.d)),P;if("EC"===t.kty&&void 0!==t.crv&&void 0!==t.x&&void 0!==t.y&&void 0===t.d){var h=(D=new a({curve:t.crv})).ecparams.keycharlen,f="04"+("0000000000"+mt(t.x)).slice(-h)+("0000000000"+mt(t.y)).slice(-h);return D.setPublicKeyHex(f),D}if("EC"===t.kty&&void 0!==t.crv&&void 0!==t.x&&void 0!==t.y&&void 0!==t.d){h=(D=new a({curve:t.crv})).ecparams.keycharlen,f="04"+("0000000000"+mt(t.x)).slice(-h)+("0000000000"+mt(t.y)).slice(-h);var d=("0000000000"+mt(t.d)).slice(-h);return D.setPublicKeyHex(f),D.setPrivateKeyHex(d),D}if("pkcs5prv"===r){var p,g=t,v=lt;if(9===(p=n(g,0)).length)(P=new u).readPKCS5PrvKeyHex(g);else if(6===p.length)(P=new o).readPKCS5PrvKeyHex(g);else{if(!(p.length>2&&"04"===g.substr(p[1],2)))throw new Error("unsupported PKCS#1/5 hexadecimal key");(P=new a).readPKCS5PrvKeyHex(g)}return P}if("pkcs8prv"===r)return P=l.getKeyFromPlainPrivatePKCS8Hex(t);if("pkcs8pub"===r)return l._getKeyFromPublicPKCS8Hex(t);if("x509pub"===r)return ae.getPublicKeyFromCertHex(t);if(-1!=t.indexOf("-END CERTIFICATE-",0)||-1!=t.indexOf("-END X509 CERTIFICATE-",0)||-1!=t.indexOf("-END TRUSTED CERTIFICATE-",0))return ae.getPublicKeyFromCertPEM(t);if(-1!=t.indexOf("-END PUBLIC KEY-")){var y=Pt(t,"PUBLIC KEY");return l._getKeyFromPublicPKCS8Hex(y)}if(-1!=t.indexOf("-END RSA PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){var m=c(t,"RSA PRIVATE KEY");return l.getKey(m,null,"pkcs5prv")}if(-1!=t.indexOf("-END DSA PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){var b=i(T=c(t,"DSA PRIVATE KEY"),0,[1],"02"),x=i(T,0,[2],"02"),S=i(T,0,[3],"02"),E=i(T,0,[4],"02"),F=i(T,0,[5],"02");return(P=new o).setPrivate(new w(b,16),new w(x,16),new w(S,16),new w(E,16),new w(F,16)),P}if(-1!=t.indexOf("-END EC PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){m=c(t,"EC PRIVATE KEY");return l.getKey(m,null,"pkcs5prv")}if(-1!=t.indexOf("-END PRIVATE KEY-"))return l.getKeyFromPlainPrivatePKCS8PEM(t);if(-1!=t.indexOf("-END RSA PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var A=l.getDecryptedKeyHex(t,e),C=new rt;return C.readPKCS5PrvKeyHex(A),C}if(-1!=t.indexOf("-END EC PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var D,P=i(T=l.getDecryptedKeyHex(t,e),0,[1],"04"),I=i(T,0,[2,0],"06"),R=i(T,0,[3,0],"03").substr(2);if(void 0===ot.crypto.OID.oidhex2name[I])throw new Error("undefined OID(hex) in KJUR.crypto.OID: "+I);return(D=new a({curve:ot.crypto.OID.oidhex2name[I]})).setPublicKeyHex(R),D.setPrivateKeyHex(P),D.isPublic=!1,D}if(-1!=t.indexOf("-END DSA PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var T;b=i(T=l.getDecryptedKeyHex(t,e),0,[1],"02"),x=i(T,0,[2],"02"),S=i(T,0,[3],"02"),E=i(T,0,[4],"02"),F=i(T,0,[5],"02");return(P=new o).setPrivate(new w(b,16),new w(x,16),new w(S,16),new w(E,16),new w(F,16)),P}if(-1!=t.indexOf("-END ENCRYPTED PRIVATE KEY-"))return l.getKeyFromEncryptedPKCS8PEM(t,e);throw new Error("not supported argument")},re.generateKeypair=function(t,e){if("RSA"==t){var r=e;(a=new rt).generate(r,"10001"),a.isPrivate=!0,a.isPublic=!0;var n=new rt,i=a.n.toString(16),s=a.e.toString(16);return n.setPublic(i,s),n.isPrivate=!1,n.isPublic=!0,(o={}).prvKeyObj=a,o.pubKeyObj=n,o}if("EC"==t){var a,o,u=e,c=new ot.crypto.ECDSA({curve:u}).generateKeyPairHex();return(a=new ot.crypto.ECDSA({curve:u})).setPublicKeyHex(c.ecpubhex),a.setPrivateKeyHex(c.ecprvhex),a.isPrivate=!0,a.isPublic=!1,(n=new ot.crypto.ECDSA({curve:u})).setPublicKeyHex(c.ecpubhex),n.isPrivate=!1,n.isPublic=!0,(o={}).prvKeyObj=a,o.pubKeyObj=n,o}throw new Error("unknown algorithm: "+t)},re.getPEM=function(t,e,r,n,i,s){var a=ot,o=a.asn1,u=o.DERObjectIdentifier,c=o.DERInteger,l=o.ASN1Util.newObject,h=o.x509.SubjectPublicKeyInfo,f=a.crypto,d=f.DSA,p=f.ECDSA,g=rt;function v(t){return l({seq:[{int:0},{int:{bigint:t.n}},{int:t.e},{int:{bigint:t.d}},{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.dmp1}},{int:{bigint:t.dmq1}},{int:{bigint:t.coeff}}]})}function y(t){return l({seq:[{int:1},{octstr:{hex:t.prvKeyHex}},{tag:["a0",!0,{oid:{name:t.curveName}}]},{tag:["a1",!0,{bitstr:{hex:"00"+t.pubKeyHex}}]}]})}function m(t){return l({seq:[{int:0},{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}},{int:{bigint:t.y}},{int:{bigint:t.x}}]})}if((void 0!==g&&t instanceof g||void 0!==d&&t instanceof d||void 0!==p&&t instanceof p)&&1==t.isPublic&&(void 0===e||"PKCS8PUB"==e))return Dt(S=new h(t).tohex(),"PUBLIC KEY");if("PKCS1PRV"==e&&void 0!==g&&t instanceof g&&(void 0===r||null==r)&&1==t.isPrivate)return Dt(S=v(t).tohex(),"RSA PRIVATE KEY");if("PKCS1PRV"==e&&void 0!==p&&t instanceof p&&(void 0===r||null==r)&&1==t.isPrivate){var b=new u({name:t.curveName}).tohex(),x=y(t).tohex(),w="";return w+=Dt(b,"EC PARAMETERS"),w+=Dt(x,"EC PRIVATE KEY")}if("PKCS1PRV"==e&&void 0!==d&&t instanceof d&&(void 0===r||null==r)&&1==t.isPrivate)return Dt(S=m(t).tohex(),"DSA PRIVATE KEY");if("PKCS5PRV"==e&&void 0!==g&&t instanceof g&&void 0!==r&&null!=r&&1==t.isPrivate){var S=v(t).tohex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("RSA",S,r,n,s)}if("PKCS5PRV"==e&&void 0!==p&&t instanceof p&&void 0!==r&&null!=r&&1==t.isPrivate){S=y(t).tohex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("EC",S,r,n,s)}if("PKCS5PRV"==e&&void 0!==d&&t instanceof d&&void 0!==r&&null!=r&&1==t.isPrivate){S=m(t).tohex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("DSA",S,r,n,s)}var E=function(t,e){if("string"==typeof e)return re.getEncryptedPKCS8PEM(t,e);if("object"==typeof e&&null!=te(e,"passcode")){var r=JSON.parse(JSON.stringify(e)),n=r.passcode;return delete r.passcode,re.getEncryptedPKCS8PEM(t,n,r)}};if("PKCS8PRV"==e&&null!=g&&t instanceof g&&1==t.isPrivate){var F=v(t).tohex();S=l({seq:[{int:0},{seq:[{oid:{name:"rsaEncryption"}},{null:!0}]},{octstr:{hex:F}}]}).tohex();return void 0===r||null==r?Dt(S,"PRIVATE KEY"):E(S,r)}if("PKCS8PRV"==e&&void 0!==p&&t instanceof p&&1==t.isPrivate){var A={seq:[{int:1},{octstr:{hex:t.prvKeyHex}}]};"string"==typeof t.pubKeyHex&&A.seq.push({tag:["a1",!0,{bitstr:{hex:"00"+t.pubKeyHex}}]});F=new l(A).tohex(),S=l({seq:[{int:0},{seq:[{oid:{name:"ecPublicKey"}},{oid:{name:t.curveName}}]},{octstr:{hex:F}}]}).tohex();return void 0===r||null==r?Dt(S,"PRIVATE KEY"):E(S,r)}if("PKCS8PRV"==e&&void 0!==d&&t instanceof d&&1==t.isPrivate){F=new c({bigint:t.x}).tohex(),S=l({seq:[{int:0},{seq:[{oid:{name:"dsa"}},{seq:[{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}}]}]},{octstr:{hex:F}}]}).tohex();return void 0===r||null==r?Dt(S,"PRIVATE KEY"):E(S,r)}throw new Error("unsupported object nor format")},re.getKeyFromCSRPEM=function(t){var e=Pt(t,"CERTIFICATE REQUEST");return re.getKeyFromCSRHex(e)},re.getKeyFromCSRHex=function(t){var e=re.parseCSRHex(t);return re.getKey(e.p8pubkeyhex,null,"pkcs8pub")},re.parseCSRHex=function(t){var e=lt,r=e.getChildIdx,n=e.getTLV,i={},s=t;if("30"!=s.substr(0,2))throw new Error("malformed CSR(code:001)");var a=r(s,0);if(a.length<1)throw new Error("malformed CSR(code:002)");if("30"!=s.substr(a[0],2))throw new Error("malformed CSR(code:003)");var o=r(s,a[0]);if(o.length<3)throw new Error("malformed CSR(code:004)");return i.p8pubkeyhex=n(s,o[2]),i},re.getKeyID=function(t){var e=re,r=lt;"string"==typeof t&&-1!=t.indexOf("BEGIN ")&&(t=e.getKey(t));var n=Pt(e.getPEM(t)),i=r.getIdxbyList(n,0,[1]),s=r.getV(n,i).substring(2);return ot.crypto.Util.hashHex(s,"sha1")},re.getJWK=function(t,e,r,n,i){var s,a,o={},u=ot.crypto.Util.hashHex;if("string"==typeof t)s=re.getKey(t),-1!=t.indexOf("CERTIFICATE")&&(a=Pt(t));else{if("object"!=typeof t)throw new Error("unsupported keyinfo type");t instanceof ae?(s=t.getPublicKey(),a=t.hex):s=t}if(s instanceof rt&&s.isPrivate)o.kty="RSA",o.n=yt(s.n.toString(16)),o.e=yt(s.e.toString(16)),o.d=yt(s.d.toString(16)),o.p=yt(s.p.toString(16)),o.q=yt(s.q.toString(16)),o.dp=yt(s.dmp1.toString(16)),o.dq=yt(s.dmq1.toString(16)),o.qi=yt(s.coeff.toString(16));else if(s instanceof rt&&s.isPublic)o.kty="RSA",o.n=yt(s.n.toString(16)),o.e=yt(s.e.toString(16));else if(s instanceof ot.crypto.ECDSA&&s.isPrivate){if("P-256"!==(l=s.getShortNISTPCurveName())&&"P-384"!==l&&"P-521"!==l)throw new Error("unsupported curve name for JWT: "+l);var c=s.getPublicKeyXYHex();o.kty="EC",o.crv=l,o.x=yt(c.x),o.y=yt(c.y),o.d=yt(s.prvKeyHex)}else if(s instanceof ot.crypto.ECDSA&&s.isPublic){var l;if("P-256"!==(l=s.getShortNISTPCurveName())&&"P-384"!==l&&"P-521"!==l)throw new Error("unsupported curve name for JWT: "+l);c=s.getPublicKeyXYHex();o.kty="EC",o.crv=l,o.x=yt(c.x),o.y=yt(c.y)}if(null==o.kty)throw new Error("unsupported keyinfo");return s.isPrivate||1==e||(o.kid=ot.jws.JWS.getJWKthumbprint(o)),null!=a&&1!=r&&(o.x5c=[m(a)]),null!=a&&1!=n&&(o.x5t=gt(m(u(a,"sha1")))),null!=a&&1!=i&&(o["x5t#S256"]=gt(m(u(a,"sha256")))),o},re.getJWKFromKey=function(t){return re.getJWK(t,!0,!0,!0,!0)},rt.getPosArrayOfChildrenFromHex=function(t){return lt.getChildIdx(t,0)},rt.getHexValueArrayOfChildrenFromHex=function(t){var e,r=lt.getV,n=r(t,(e=rt.getPosArrayOfChildrenFromHex(t))[0]),i=r(t,e[1]),s=r(t,e[2]),a=r(t,e[3]),o=r(t,e[4]),u=r(t,e[5]),c=r(t,e[6]),l=r(t,e[7]),h=r(t,e[8]);return(e=new Array).push(n,i,s,a,o,u,c,l,h),e},rt.prototype.readPrivateKeyFromPEMString=function(t){var e=Pt(t),r=rt.getHexValueArrayOfChildrenFromHex(e);this.setPrivateEx(r[1],r[2],r[3],r[4],r[5],r[6],r[7],r[8])},rt.prototype.readPKCS5PrvKeyHex=function(t){var e=rt.getHexValueArrayOfChildrenFromHex(t);this.setPrivateEx(e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8])},rt.prototype.readPKCS8PrvKeyHex=function(t){var e,r,n,i,s,a,o,u,c=lt,l=c.getVbyListEx;if(!1===c.isASN1HEX(t))throw new Error("not ASN.1 hex string");try{e=l(t,0,[2,0,1],"02"),r=l(t,0,[2,0,2],"02"),n=l(t,0,[2,0,3],"02"),i=l(t,0,[2,0,4],"02"),s=l(t,0,[2,0,5],"02"),a=l(t,0,[2,0,6],"02"),o=l(t,0,[2,0,7],"02"),u=l(t,0,[2,0,8],"02")}catch(t){throw new Error("malformed PKCS#8 plain RSA private key")}this.setPrivateEx(e,r,n,i,s,a,o,u)},rt.prototype.readPKCS5PubKeyHex=function(t){var e=lt,r=e.getV;if(!1===e.isASN1HEX(t))throw new Error("keyHex is not ASN.1 hex string");var n=e.getChildIdx(t,0);if(2!==n.length||"02"!==t.substr(n[0],2)||"02"!==t.substr(n[1],2))throw new Error("wrong hex for PKCS#5 public key");var i=r(t,n[0]),s=r(t,n[1]);this.setPublic(i,s)},rt.prototype.readPKCS8PubKeyHex=function(t){var e=lt;if(!1===e.isASN1HEX(t))throw new Error("not ASN.1 hex string");if("06092a864886f70d010101"!==e.getTLVbyListEx(t,0,[0,0]))throw new Error("not PKCS8 RSA public key");var r=e.getTLVbyListEx(t,0,[1,0]);this.readPKCS5PubKeyHex(r)},rt.prototype.readCertPubKeyHex=function(t,e){var r,n;(r=new ae).readCertHex(t),n=r.getPublicKeyHex(),this.readPKCS8PubKeyHex(n)};function ne(t,e){for(var r="",n=e/4-t.length,i=0;i>24,(16711680&i)>>16,(65280&i)>>8,255&i])))),i+=1;return n}function se(t){for(var e in ot.crypto.Util.DIGESTINFOHEAD){var r=ot.crypto.Util.DIGESTINFOHEAD[e],n=r.length;if(t.substring(0,n)==r)return[e,t.substring(n)]}return[]}function ae(t){var e,r=lt,n=r.getChildIdx,i=r.getV,s=(r.dump,r.parse),a=r.getTLV,o=r.getVbyList,u=r.getVbyListEx,c=r.getTLVbyList,l=r.getTLVbyListEx,h=r.getIdxbyList,f=r.getIdxbyListEx,d=r.getVidx,p=r.getInt,g=r.oidname,v=r.hextooidstr,y=Pt,m=Error;try{e=ot.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV}catch(t){}this.HEX2STAG={"0c":"utf8",13:"prn",16:"ia5","1a":"vis","1e":"bmp"},this.hex=null,this.version=0,this.foffset=0,this.aExtInfo=null,this.getVersion=function(){if(null===this.hex||0!==this.version)return this.version;var t=c(this.hex,0,[0,0]);if("a0"==t.substr(0,2)){var e=c(t,0,[0]),r=p(e,0);if(r<0||20?e:void 0}catch(t){return}},this._asn1ToNoticeRef=function(t){try{for(var e={},r=te(t,"seq"),n=0;n0?e:void 0}catch(t){return}},this._asn1ToNoticeNum=function(t){try{for(var e=te(t,"seq"),r=[],n=0;n1){var o=a(t,s[1]),u=this.getGeneralName(o);null!=u.uri&&(i.uri=u.uri)}if(s.length>2){var c=a(t,s[2]);"0101ff"==c&&(i.reqauth=!0),"010100"==c&&(i.reqauth=!1)}return i},this.getExtSubjectDirectoryAttributes=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("subjectDirectoryAttributes");if(void 0===r)return;t=a(this.hex,r.vidx),e=r.critical}var n={extname:"subjectDirectoryAttributes"};e&&(n.critical=!0);try{for(var i=s(t),o=[],u=0;u0&&(e.ext=this.getExtParamArray()),e.sighex=this.getSignatureValueHex(),1==t.tbshex&&(e.tbshex=c(this.hex,0,[0])),1==t.nodnarray&&(delete e.issuer.array,delete e.subject.array),e},this.getExtParamArray=function(t){null==t&&(-1!=f(this.hex,0,[0,"[3]"])&&(t=l(this.hex,0,[0,"[3]",0],"30")));for(var e=[],r=n(t,0),i=0;i0&&(c=new Array(r),(new tt).nextBytes(c),c=String.fromCharCode.apply(String,c));var l=St(u(Et("\0\0\0\0\0\0\0\0"+i+c))),h=[];for(n=0;n>8*o-a&255;for(p[0]&=~g,n=0;nn)return!1;var i=this.doPublic(r).toString(16);if(i.length+3!=n/4)return!1;var s=se(i.replace(/^1f+00/,""));if(0==s.length)return!1;var a=s[0],o=s[1],u=function(t){return ot.crypto.Util.hashString(t,a)}(t);return o==u},rt.prototype.verifyWithMessageHash=function(t,e){if(e.length!=Math.ceil(this.n.bitLength()/4))return!1;var r=et(e,16);if(r.bitLength()>this.n.bitLength())return 0;var n=se(this.doPublic(r).toString(16).replace(/^1f+00/,""));if(0==n.length)return!1;n[0];return n[1]==t},rt.prototype.verifyPSS=function(t,e,r,n){var i,s=(i=Et(t),ot.crypto.Util.hashHex(i,r));return void 0===n&&(n=-1),this.verifyWithMessageHashPSS(s,e,r,n)},rt.prototype.verifyWithMessageHashPSS=function(t,e,r,n){if(e.length!=Math.ceil(this.n.bitLength()/4))return!1;var i,s=new w(e,16),a=function(t){return ot.crypto.Util.hashHex(t,r)},o=St(t),u=o.length,c=this.n.bitLength()-1,l=Math.ceil(c/8);if(-1===n||void 0===n)n=u;else if(-2===n)n=l-u-2;else if(n<-2)throw new Error("invalid salt length");if(l>8*l-c&255;if(0!==(f.charCodeAt(0)&p))throw new Error("bits beyond keysize not zero");var g=ie(d,f.length,a),v=[];for(i=0;i0)&&-1==(":"+r.join(":")+":").indexOf(":"+g+":"))throw"algorithm '"+g+"' not accepted in the list";if("none"!=g&&null===e)throw"key shall be specified to verify.";if("string"==typeof e&&-1!=e.indexOf("-----BEGIN ")&&(e=re.getKey(e)),!("RS"!=v&&"PS"!=v||e instanceof n))throw"key shall be a RSAKey obj for RS* and PS* algs";if("ES"==v&&!(e instanceof u))throw"key shall be a ECDSA obj for ES* algs";var y=null;if(void 0===s.jwsalg2sigalg[p.alg])throw"unsupported alg name: "+g;if("none"==(y=s.jwsalg2sigalg[g]))throw"not supported";if("Hmac"==y.substr(0,4)){if(void 0===e)throw"hexadecimal key shall be specified for HMAC";var m=new c({alg:y,pass:e});return m.updateString(f),d==m.doFinal()}if(-1!=y.indexOf("withECDSA")){var b,x=null;try{x=u.concatSigToASN1Sig(d)}catch(t){return!1}return(b=new l({alg:y})).init(e),b.updateString(f),b.verify(x)}return(b=new l({alg:y})).init(e),b.updateString(f),b.verify(d)},ot.jws.JWS.parse=function(t){var e,r,n,i=t.split("."),s={};if(2!=i.length&&3!=i.length)throw"malformed sJWS: wrong number of '.' splitted elements";return e=i[0],r=i[1],3==i.length&&(n=i[2]),s.headerObj=ot.jws.JWS.readSafeJSONString(ct(e)),s.payloadObj=ot.jws.JWS.readSafeJSONString(ct(r)),s.headerPP=JSON.stringify(s.headerObj,null," "),null==s.payloadObj?s.payloadPP=ct(r):s.payloadPP=JSON.stringify(s.payloadObj,null," "),void 0!==n&&(s.sigHex=mt(n)),s},ot.jws.JWS.verifyJWT=function(t,e,r){var n=ot.jws,i=n.JWS,s=i.readSafeJSONString,a=i.inArray,o=i.includedArray;if(!Kt(t))return!1;var u=t.split(".");if(3!=u.length)return!1;var c=u[0],l=u[1],h=(mt(u[2]),s(ct(c))),f=s(ct(l));if(void 0===h.alg)return!1;if(void 0===r.alg)throw"acceptField.alg shall be specified";if(!a(h.alg,r.alg))return!1;if(void 0!==f.iss&&"object"==typeof r.iss&&!a(f.iss,r.iss))return!1;if(void 0!==f.sub&&"object"==typeof r.sub&&!a(f.sub,r.sub))return!1;if(void 0!==f.aud&&"object"==typeof r.aud)if("string"==typeof f.aud){if(!a(f.aud,r.aud))return!1}else if("object"==typeof f.aud&&!o(f.aud,r.aud))return!1;var d=n.IntDate.getNow();return void 0!==r.verifyAt&&"number"==typeof r.verifyAt&&(d=r.verifyAt),void 0!==r.gracePeriod&&"number"==typeof r.gracePeriod||(r.gracePeriod=0),!(void 0!==f.exp&&"number"==typeof f.exp&&f.exp+r.gracePeriodi&&this.aHeader.pop(),this.aSignature.length>i&&this.aSignature.pop(),"addSignature failed: "+t}},this.verifyAll=function(t){if(this.aHeader.length!==t.length||this.aSignature.length!==t.length)return!1;for(var e=0;e0))throw"malformed header";if(this.aHeader=t.headers,"string"!=typeof t.payload)throw"malformed signatures";if(this.sPayload=t.payload,!(t.signatures.length>0))throw"malformed signatures";this.aSignature=t.signatures}catch(t){throw"malformed JWS-JS JSON object: "+t}},this.getJSON=function(){return{headers:this.aHeader,payload:this.sPayload,signatures:this.aSignature}},this.isEmpty=function(){return 0==this.aHeader.length?1:0}},ot.crypto.ECDSA,ot.crypto.DSA,ot.crypto.Signature,ot.crypto.MessageDigest,ot.crypto.Mac,e.pj=ot,ot.crypto,ot.asn1,ot.jws,ot.lang},"./node_modules/loglevel/lib/loglevel.js":function(t,e,r){var n,i;!function(){"use strict";n=function(){var t=function(){},e="undefined",r=typeof window!==e&&typeof window.navigator!==e&&/Trident\/|MSIE /.test(window.navigator.userAgent),n=["trace","debug","info","warn","error"],i={},s=null;function a(t,e){var r=t[e];if("function"==typeof r.bind)return r.bind(t);try{return Function.prototype.bind.call(r,t)}catch(e){return function(){return Function.prototype.apply.apply(r,[t,arguments])}}}function o(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function u(n){return"debug"===n&&(n="log"),typeof console!==e&&("trace"===n&&r?o:void 0!==console[n]?a(console,n):void 0!==console.log?a(console,"log"):t)}function c(){for(var r=this.getLevel(),i=0;i=0&&e<=l.levels.SILENT)return e;throw new TypeError("log.setLevel() called with invalid level: "+t)}"string"==typeof t?f+=":"+t:"symbol"==typeof t&&(f=void 0),l.name=t,l.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},l.methodFactory=r||h,l.getLevel=function(){return null!=u?u:null!=o?o:a},l.setLevel=function(t,e){return u=v(t),!1!==e&&d(u),c.call(l)},l.setDefaultLevel=function(t){o=v(t),p()||l.setLevel(t,!1)},l.resetLevel=function(){u=null,g(),c.call(l)},l.enableAll=function(t){l.setLevel(l.levels.TRACE,t)},l.disableAll=function(t){l.setLevel(l.levels.SILENT,t)},l.rebuild=function(){if(s!==l&&(a=v(s.getLevel())),c.call(l),s===l)for(var t in i)i[t].rebuild()},a=v(s?s.getLevel():"WARN");var y=p();null!=y&&(u=v(y)),c.call(l)}(s=new f).getLogger=function(t){if("symbol"!=typeof t&&"string"!=typeof t||""===t)throw new TypeError("You must supply a name when creating a logger.");var e=i[t];return e||(e=i[t]=new f(t,s.methodFactory)),e};var d=typeof window!==e?window.log:void 0;return s.noConflict=function(){return typeof window!==e&&window.log===s&&(window.log=d),s},s.getLoggers=function(){return i},s.default=s,s},void 0===(i="function"==typeof n?n.call(e,r,e,t):n)||(t.exports=i)}()},"./node_modules/matrix-widget-api/lib/ClientWidgetApi.js":(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ClientWidgetApi=void 0;var n=r("./node_modules/events/events.js"),i=r("./node_modules/matrix-widget-api/lib/transport/PostmessageTransport.js"),s=r("./node_modules/matrix-widget-api/lib/interfaces/WidgetApiDirection.js"),a=r("./node_modules/matrix-widget-api/lib/interfaces/WidgetApiAction.js"),o=r("./node_modules/matrix-widget-api/lib/interfaces/Capabilities.js"),u=r("./node_modules/matrix-widget-api/lib/interfaces/ApiVersion.js"),c=r("./node_modules/matrix-widget-api/lib/models/WidgetEventCapability.js"),l=r("./node_modules/matrix-widget-api/lib/interfaces/GetOpenIDAction.js"),h=r("./node_modules/matrix-widget-api/lib/util/SimpleObservable.js"),f=r("./node_modules/matrix-widget-api/lib/Symbols.js"),d=r("./node_modules/matrix-widget-api/lib/interfaces/UpdateDelayedEventAction.js");function p(t){return p="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},p(t)}function g(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function v(t){for(var e=1;e=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}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 s,a=!0,o=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){o=!0,s=t},f:function(){try{a||null==r.return||r.return()}finally{if(o)throw s}}}}function m(t){return function(t){if(Array.isArray(t))return x(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||b(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function b(t,e){if(t){if("string"==typeof t)return x(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?x(t,e):void 0}}function x(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--i){var s=this.tryEntries[i],a=s.completion;if("root"===s.tryLoc)return n("end");if(s.tryLoc<=this.prev){var o=r.call(s,"catchLoc"),u=r.call(s,"finallyLoc");if(o&&u){if(this.prev=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),C(r),h}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;C(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:P(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},t}function S(t,e,r,n,i,s,a){try{var o=t[s](a),u=o.value}catch(t){return void r(t)}o.done?e(u):Promise.resolve(u).then(n,i)}function E(t){return function(){var e=this,r=arguments;return new Promise(function(n,i){var s=t.apply(e,r);function a(t){S(s,n,i,a,o,"next",t)}function o(t){S(s,n,i,a,o,"throw",t)}a(void 0)})}}function F(t,e){for(var r=0;r1&&void 0!==arguments[1]?arguments[1]:null;return this.allowedEvents.some(function(r){return r.matchesAsRoomEvent(c.EventDirection.Send,t,e)})}},{key:"canSendStateEvent",value:function(t,e){return this.allowedEvents.some(function(r){return r.matchesAsStateEvent(c.EventDirection.Send,t,e)})}},{key:"canSendToDeviceEvent",value:function(t){return this.allowedEvents.some(function(e){return e.matchesAsToDeviceEvent(c.EventDirection.Send,t)})}},{key:"canReceiveRoomEvent",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return this.allowedEvents.some(function(r){return r.matchesAsRoomEvent(c.EventDirection.Receive,t,e)})}},{key:"canReceiveStateEvent",value:function(t,e){return this.allowedEvents.some(function(r){return r.matchesAsStateEvent(c.EventDirection.Receive,t,e)})}},{key:"canReceiveToDeviceEvent",value:function(t){return this.allowedEvents.some(function(e){return e.matchesAsToDeviceEvent(c.EventDirection.Receive,t)})}},{key:"canReceiveRoomAccountData",value:function(t){return this.allowedEvents.some(function(e){return e.matchesAsRoomAccountData(c.EventDirection.Receive,t)})}},{key:"stop",value:function(){this.isStopped=!0,this.transport.stop()}},{key:"getWidgetVersions",value:(V=E(w().mark(function t(){var e;return w().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(!Array.isArray(this.cachedWidgetVersions)){t.next=2;break}return t.abrupt("return",Promise.resolve(this.cachedWidgetVersions));case 2:return t.prev=2,t.next=5,this.transport.send(a.WidgetApiToWidgetAction.SupportedApiVersions,{});case 5:return e=t.sent,this.cachedWidgetVersions=e.supported_versions,t.abrupt("return",e.supported_versions);case 10:return t.prev=10,t.t0=t.catch(2),console.warn("non-fatal error getting supported widget versions: ",t.t0),t.abrupt("return",[]);case 14:case"end":return t.stop()}},t,this,[[2,10]])})),function(){return V.apply(this,arguments)})},{key:"beginCapabilities",value:function(){var t,e=this;this.emit("preparing"),this.transport.send(a.WidgetApiToWidgetAction.Capabilities,{}).then(function(r){return t=r.capabilities,e.driver.validateCapabilities(new Set(r.capabilities))}).then(function(r){e.allowCapabilities(m(r),t),e.emit("ready")}).catch(function(t){e.emit("error:preparing",t)})}},{key:"allowCapabilities",value:function(t,e){var r,n=this;console.log("Widget ".concat(this.widget.id," is allowed capabilities:"),t);var i,s=y(t);try{for(s.s();!(i=s.n()).done;){var u=i.value;this.allowedCapabilities.add(u)}}catch(t){s.e(t)}finally{s.f()}var l=c.WidgetEventCapability.findEventCapabilities(t);(r=this.allowedEvents).push.apply(r,m(l)),this.transport.send(a.WidgetApiToWidgetAction.NotifyCapabilities,{requested:e,approved:Array.from(this.allowedCapabilities)}).catch(function(t){console.warn("non-fatal error notifying widget of approved capabilities:",t)}).then(function(){n.emit("capabilitiesNotified")});var h,d=y(t);try{for(d.s();!(h=d.n()).done;){var p=h.value;if((0,o.isTimelineCapability)(p)){var g=(0,o.getTimelineRoomIDFromCapability)(p);if(g===f.Symbols.AnyRoom){var v,b=y(this.driver.getKnownRooms());try{for(b.s();!(v=b.n()).done;){var x=v.value;this.pushRoomState(x)}}catch(t){b.e(t)}finally{b.f()}}else this.pushRoomState(g)}}}catch(t){d.e(t)}finally{d.f()}l.length>0&&null!==this.viewedRoomId&&!this.canUseRoomTimeline(this.viewedRoomId)&&this.pushRoomState(this.viewedRoomId)}},{key:"onIframeLoad",value:function(t){this.widget.waitForIframeLoad?this.beginCapabilities():(console.log("waitForIframeLoad is false: waiting for widget to send contentLoaded"),this.contentLoadedWaitTimer=setTimeout(function(){console.error("Widget specified waitForIframeLoad=false but timed out waiting for contentLoaded event!")},1e4),this.contentLoadedActionSent=!1)}},{key:"handleContentLoadedAction",value:function(t){if(void 0!==this.contentLoadedWaitTimer&&(clearTimeout(this.contentLoadedWaitTimer),this.contentLoadedWaitTimer=void 0),this.contentLoadedActionSent)throw new Error("Improper sequence: ContentLoaded Action can only be sent once after the widget loaded and should only be used if waitForIframeLoad is false (default=true)");this.widget.waitForIframeLoad?this.transport.reply(t,{error:{message:"Improper sequence: not expecting ContentLoaded event if waitForIframeLoad is true (default=true)"}}):(this.transport.reply(t,{}),this.beginCapabilities()),this.contentLoadedActionSent=!0}},{key:"replyVersions",value:function(t){this.transport.reply(t,{supported_versions:u.CurrentApiVersions})}},{key:"supportsUpdateState",value:(L=E(w().mark(function t(){return w().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getWidgetVersions();case 2:return t.abrupt("return",t.sent.includes(u.UnstableApiVersion.MSC2762_UPDATE_STATE));case 3:case"end":return t.stop()}},t,this)})),function(){return L.apply(this,arguments)})},{key:"handleCapabilitiesRenegotiate",value:function(t){var e,r=this;this.transport.reply(t,{});var n=(null===(e=t.data)||void 0===e?void 0:e.capabilities)||[],i=new Set(n.filter(function(t){return!r.hasCapability(t)}));0===i.size&&this.allowCapabilities([],[]),this.driver.validateCapabilities(i).then(function(t){return r.allowCapabilities(m(t),m(i))})}},{key:"handleNavigate",value:function(t){var e,r,n=this;if(!this.hasCapability(o.MatrixCapabilities.MSC2931Navigate))return this.transport.reply(t,{error:{message:"Missing capability"}});if(null===(e=t.data)||void 0===e||!e.uri||null===(r=t.data)||void 0===r||!r.uri.toString().startsWith("https://matrix.to/#"))return this.transport.reply(t,{error:{message:"Invalid matrix.to URI"}});var i=function(e){console.error("[ClientWidgetApi] Failed to handle navigation: ",e),n.handleDriverError(e,t,"Error handling navigation")};try{this.driver.navigate(t.data.uri.toString()).catch(function(t){return i(t)}).then(function(){return n.transport.reply(t,{})})}catch(t){return i(t)}}},{key:"handleOIDC",value:function(t){var e=this,r=1,n=function(n,i){return i=i||{},r>1?e.transport.send(a.WidgetApiToWidgetAction.OpenIDCredentials,v({state:n,original_request_id:t.requestId},i)):e.transport.reply(t,v({state:n},i))},i=function(i){return console.error("[ClientWidgetApi] Failed to handle OIDC: ",i),r>1?n(l.OpenIDRequestState.Blocked):e.transport.reply(t,{error:{message:i}})},s=new h.SimpleObservable(function(t){return t.state===l.OpenIDRequestState.PendingUserConfirmation&&r>1?(s.close(),i("client provided out-of-phase response to OIDC flow")):t.state===l.OpenIDRequestState.PendingUserConfirmation?(n(t.state),void r++):t.state!==l.OpenIDRequestState.Allowed||t.token?(t.state===l.OpenIDRequestState.Blocked&&(t.token=void 0),s.close(),n(t.state,t.token)):i("client provided invalid OIDC token for an allowed request")});this.driver.askOpenID(s)}},{key:"handleReadRoomAccountData",value:function(t){var e=this,r=Promise.resolve([]);return r=this.driver.readRoomAccountData(t.data.type),this.canReceiveRoomAccountData(t.data.type)?r.then(function(r){e.transport.reply(t,{events:r})}):this.transport.reply(t,{error:{message:"Cannot read room account data of this type"}})}},{key:"handleReadEvents",value:(H=E(w().mark(function t(e){var r,n,i,s,a,o,u,c,l,h,d=this;return w().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(e.data.type){t.next=2;break}return t.abrupt("return",this.transport.reply(e,{error:{message:"Invalid request - missing event type"}}));case 2:if(void 0===e.data.limit||e.data.limit&&!(e.data.limit<0)){t.next=4;break}return t.abrupt("return",this.transport.reply(e,{error:{message:"Invalid request - limit out of range"}}));case 4:if(void 0!==e.data.room_ids){t.next=8;break}r=null===this.viewedRoomId?[]:[this.viewedRoomId],t.next=30;break;case 8:if(e.data.room_ids!==f.Symbols.AnyRoom){t.next=12;break}r=this.driver.getKnownRooms().filter(function(t){return d.canUseRoomTimeline(t)}),t.next=30;break;case 12:r=e.data.room_ids,n=y(r),t.prev=14,n.s();case 16:if((i=n.n()).done){t.next=22;break}if(s=i.value,this.canUseRoomTimeline(s)){t.next=20;break}return t.abrupt("return",this.transport.reply(e,{error:{message:"Unable to access room timeline: ".concat(s)}}));case 20:t.next=16;break;case 22:t.next=27;break;case 24:t.prev=24,t.t0=t.catch(14),n.e(t.t0);case 27:return t.prev=27,n.f(),t.finish(27);case 30:if(a=e.data.limit||0,o=e.data.since,u=void 0,c=void 0,void 0===e.data.state_key){t.next=40;break}if(u=!0===e.data.state_key?void 0:e.data.state_key.toString(),this.canReceiveStateEvent(e.data.type,null!==(l=u)&&void 0!==l?l:null)){t.next=38;break}return t.abrupt("return",this.transport.reply(e,{error:{message:"Cannot read state events of this type"}}));case 38:t.next=43;break;case 40:if(c=e.data.msgtype,this.canReceiveRoomEvent(e.data.type,c)){t.next=43;break}return t.abrupt("return",this.transport.reply(e,{error:{message:"Cannot read room events of this type"}}));case 43:if(void 0!==e.data.room_ids||0!==r.length){t.next=50;break}return console.warn("The widgetDriver uses deprecated behaviour:\n It does not set the viewedRoomId using `setViewedRoomId`"),t.next=47,void 0===e.data.state_key?this.driver.readRoomEvents(e.data.type,c,a,null,o):this.driver.readStateEvents(e.data.type,u,a,null);case 47:h=t.sent,t.next=68;break;case 50:return t.next=52,this.supportsUpdateState();case 52:if(!t.sent){t.next=58;break}return t.next=55,Promise.all(r.map(function(t){return d.driver.readRoomTimeline(t,e.data.type,c,u,a,o)}));case 55:h=t.sent.flat(1),t.next=68;break;case 58:if(void 0!==e.data.state_key){t.next=64;break}return t.next=61,Promise.all(r.map(function(t){return d.driver.readRoomTimeline(t,e.data.type,c,u,a,o)}));case 61:t.t1=t.sent,t.next=67;break;case 64:return t.next=66,Promise.all(r.map(function(t){return d.driver.readRoomState(t,e.data.type,u)}));case 66:t.t1=t.sent;case 67:h=t.t1.flat(1);case 68:this.transport.reply(e,{events:h});case 69:case"end":return t.stop()}},t,this,[[14,24,27,30]])})),function(t){return H.apply(this,arguments)})},{key:"handleSendEvent",value:function(t){var e=this;if(!t.data.type)return this.transport.reply(t,{error:{message:"Invalid request - missing event type"}});if(t.data.room_id&&!this.canUseRoomTimeline(t.data.room_id))return this.transport.reply(t,{error:{message:"Unable to access room timeline: ".concat(t.data.room_id)}});var r,n=void 0!==t.data.delay||void 0!==t.data.parent_delay_id;if(n&&!this.hasCapability(o.MatrixCapabilities.MSC4157SendDelayedEvent))return this.transport.reply(t,{error:{message:"Missing capability"}});if(void 0!==t.data.state_key){if(!this.canSendStateEvent(t.data.type,t.data.state_key))return this.transport.reply(t,{error:{message:"Cannot send state events of this type"}});var i,s;r=n?this.driver.sendDelayedEvent(null!==(i=t.data.delay)&&void 0!==i?i:null,null!==(s=t.data.parent_delay_id)&&void 0!==s?s:null,t.data.type,t.data.content||{},t.data.state_key,t.data.room_id):this.driver.sendEvent(t.data.type,t.data.content||{},t.data.state_key,t.data.room_id)}else{var a,u,c=t.data.content||{},l=c.msgtype;if(!this.canSendRoomEvent(t.data.type,l))return this.transport.reply(t,{error:{message:"Cannot send room events of this type"}});r=n?this.driver.sendDelayedEvent(null!==(a=t.data.delay)&&void 0!==a?a:null,null!==(u=t.data.parent_delay_id)&&void 0!==u?u:null,t.data.type,c,null,t.data.room_id):this.driver.sendEvent(t.data.type,c,null,t.data.room_id)}r.then(function(r){return e.transport.reply(t,v({room_id:r.roomId},"eventId"in r?{event_id:r.eventId}:{delay_id:r.delayId}))}).catch(function(r){console.error("error sending event: ",r),e.handleDriverError(r,t,"Error sending event")})}},{key:"handleUpdateDelayedEvent",value:function(t){var e=this;if(!t.data.delay_id)return this.transport.reply(t,{error:{message:"Invalid request - missing delay_id"}});if(!this.hasCapability(o.MatrixCapabilities.MSC4157UpdateDelayedEvent))return this.transport.reply(t,{error:{message:"Missing capability"}});switch(t.data.action){case d.UpdateDelayedEventAction.Cancel:case d.UpdateDelayedEventAction.Restart:case d.UpdateDelayedEventAction.Send:this.driver.updateDelayedEvent(t.data.delay_id,t.data.action).then(function(){return e.transport.reply(t,{})}).catch(function(r){console.error("error updating delayed event: ",r),e.handleDriverError(r,t,"Error updating delayed event")});break;default:return this.transport.reply(t,{error:{message:"Invalid request - unsupported action"}})}}},{key:"handleSendToDevice",value:(_=E(w().mark(function t(e){return w().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(e.data.type){t.next=5;break}return t.next=3,this.transport.reply(e,{error:{message:"Invalid request - missing event type"}});case 3:t.next=31;break;case 5:if(e.data.messages){t.next=10;break}return t.next=8,this.transport.reply(e,{error:{message:"Invalid request - missing event contents"}});case 8:t.next=31;break;case 10:if("boolean"==typeof e.data.encrypted){t.next=15;break}return t.next=13,this.transport.reply(e,{error:{message:"Invalid request - missing encryption flag"}});case 13:t.next=31;break;case 15:if(this.canSendToDeviceEvent(e.data.type)){t.next=20;break}return t.next=18,this.transport.reply(e,{error:{message:"Cannot send to-device events of this type"}});case 18:t.next=31;break;case 20:return t.prev=20,t.next=23,this.driver.sendToDevice(e.data.type,e.data.encrypted,e.data.messages);case 23:return t.next=25,this.transport.reply(e,{});case 25:t.next=31;break;case 27:t.prev=27,t.t0=t.catch(20),console.error("error sending to-device event",t.t0),this.handleDriverError(t.t0,e,"Error sending event");case 31:case"end":return t.stop()}},t,this,[[20,27]])})),function(t){return _.apply(this,arguments)})},{key:"pollTurnServers",value:(B=E(w().mark(function t(e,r){var n,i,s,o,u,c;return w().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this.transport.send(a.WidgetApiToWidgetAction.UpdateTurnServers,r);case 3:n=!1,i=!1,t.prev=5,o=T(e);case 7:return t.next=9,o.next();case 9:if(!(n=!(u=t.sent).done)){t.next=16;break}return c=u.value,t.next=13,this.transport.send(a.WidgetApiToWidgetAction.UpdateTurnServers,c);case 13:n=!1,t.next=7;break;case 16:t.next=22;break;case 18:t.prev=18,t.t0=t.catch(5),i=!0,s=t.t0;case 22:if(t.prev=22,t.prev=23,!n||null==o.return){t.next=27;break}return t.next=27,o.return();case 27:if(t.prev=27,!i){t.next=30;break}throw s;case 30:return t.finish(27);case 31:return t.finish(22);case 32:t.next=37;break;case 34:t.prev=34,t.t1=t.catch(0),console.error("error polling for TURN servers",t.t1);case 37:case"end":return t.stop()}},t,this,[[0,34],[5,18,22,32],[23,,27,31]])})),function(t,e){return B.apply(this,arguments)})},{key:"handleWatchTurnServers",value:(k=E(w().mark(function t(e){var r,n,i,s;return w().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.hasCapability(o.MatrixCapabilities.MSC3846TurnServers)){t.next=5;break}return t.next=3,this.transport.reply(e,{error:{message:"Missing capability"}});case 3:case 8:t.next=30;break;case 5:if(!this.turnServers){t.next=10;break}return t.next=8,this.transport.reply(e,{});case 10:return t.prev=10,r=this.driver.getTurnServers(),t.next=14,r.next();case 14:if(n=t.sent,i=n.done,s=n.value,!i){t.next=19;break}throw new Error("Client refuses to provide any TURN servers");case 19:return t.next=21,this.transport.reply(e,{});case 21:this.pollTurnServers(r,s),this.turnServers=r,t.next=30;break;case 25:return t.prev=25,t.t0=t.catch(10),console.error("error getting first TURN server results",t.t0),t.next=30,this.transport.reply(e,{error:{message:"TURN servers not available"}});case 30:case"end":return t.stop()}},t,this,[[10,25]])})),function(t){return k.apply(this,arguments)})},{key:"handleUnwatchTurnServers",value:(N=E(w().mark(function t(e){return w().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.hasCapability(o.MatrixCapabilities.MSC3846TurnServers)){t.next=5;break}return t.next=3,this.transport.reply(e,{error:{message:"Missing capability"}});case 3:case 8:t.next=15;break;case 5:if(this.turnServers){t.next=10;break}return t.next=8,this.transport.reply(e,{});case 10:return t.next=12,this.turnServers.return(void 0);case 12:return this.turnServers=null,t.next=15,this.transport.reply(e,{});case 15:case"end":return t.stop()}},t,this)})),function(t){return N.apply(this,arguments)})},{key:"handleReadRelations",value:(O=E(w().mark(function t(e){var r,n,i=this;return w().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(e.data.event_id){t.next=2;break}return t.abrupt("return",this.transport.reply(e,{error:{message:"Invalid request - missing event ID"}}));case 2:if(!(void 0!==e.data.limit&&e.data.limit<0)){t.next=4;break}return t.abrupt("return",this.transport.reply(e,{error:{message:"Invalid request - limit out of range"}}));case 4:if(void 0===e.data.room_id||this.canUseRoomTimeline(e.data.room_id)){t.next=6;break}return t.abrupt("return",this.transport.reply(e,{error:{message:"Unable to access room timeline: ".concat(e.data.room_id)}}));case 6:return t.prev=6,t.next=9,this.driver.readEventRelations(e.data.event_id,e.data.room_id,e.data.rel_type,e.data.event_type,e.data.from,e.data.to,e.data.limit,e.data.direction);case 9:return r=t.sent,n=r.chunk.filter(function(t){return void 0!==t.state_key?i.canReceiveStateEvent(t.type,t.state_key):i.canReceiveRoomEvent(t.type,t.content.msgtype)}),t.abrupt("return",this.transport.reply(e,{chunk:n,prev_batch:r.prevBatch,next_batch:r.nextBatch}));case 14:t.prev=14,t.t0=t.catch(6),console.error("error getting the relations",t.t0),this.handleDriverError(t.t0,e,"Unexpected error while reading relations");case 18:case"end":return t.stop()}},t,this,[[6,14]])})),function(t){return O.apply(this,arguments)})},{key:"handleUserDirectorySearch",value:(j=E(w().mark(function t(e){var r;return w().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.hasCapability(o.MatrixCapabilities.MSC3973UserDirectorySearch)){t.next=2;break}return t.abrupt("return",this.transport.reply(e,{error:{message:"Missing capability"}}));case 2:if("string"==typeof e.data.search_term){t.next=4;break}return t.abrupt("return",this.transport.reply(e,{error:{message:"Invalid request - missing search term"}}));case 4:if(!(void 0!==e.data.limit&&e.data.limit<0)){t.next=6;break}return t.abrupt("return",this.transport.reply(e,{error:{message:"Invalid request - limit out of range"}}));case 6:return t.prev=6,t.next=9,this.driver.searchUserDirectory(e.data.search_term,e.data.limit);case 9:return r=t.sent,t.abrupt("return",this.transport.reply(e,{limited:r.limited,results:r.results.map(function(t){return{user_id:t.userId,display_name:t.displayName,avatar_url:t.avatarUrl}})}));case 13:t.prev=13,t.t0=t.catch(6),console.error("error searching in the user directory",t.t0),this.handleDriverError(t.t0,e,"Unexpected error while searching in the user directory");case 17:case"end":return t.stop()}},t,this,[[6,13]])})),function(t){return j.apply(this,arguments)})},{key:"handleGetMediaConfig",value:(R=E(w().mark(function t(e){var r;return w().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.hasCapability(o.MatrixCapabilities.MSC4039UploadFile)){t.next=2;break}return t.abrupt("return",this.transport.reply(e,{error:{message:"Missing capability"}}));case 2:return t.prev=2,t.next=5,this.driver.getMediaConfig();case 5:return r=t.sent,t.abrupt("return",this.transport.reply(e,r));case 9:t.prev=9,t.t0=t.catch(2),console.error("error while getting the media configuration",t.t0),this.handleDriverError(t.t0,e,"Unexpected error while getting the media configuration");case 13:case"end":return t.stop()}},t,this,[[2,9]])})),function(t){return R.apply(this,arguments)})},{key:"handleUploadFile",value:(P=E(w().mark(function t(e){var r;return w().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.hasCapability(o.MatrixCapabilities.MSC4039UploadFile)){t.next=2;break}return t.abrupt("return",this.transport.reply(e,{error:{message:"Missing capability"}}));case 2:return t.prev=2,t.next=5,this.driver.uploadFile(e.data.file);case 5:return r=t.sent,t.abrupt("return",this.transport.reply(e,{content_uri:r.contentUri}));case 9:t.prev=9,t.t0=t.catch(2),console.error("error while uploading a file",t.t0),this.handleDriverError(t.t0,e,"Unexpected error while uploading a file");case 13:case"end":return t.stop()}},t,this,[[2,9]])})),function(t){return P.apply(this,arguments)})},{key:"handleDownloadFile",value:(S=E(w().mark(function t(e){var r;return w().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.hasCapability(o.MatrixCapabilities.MSC4039DownloadFile)){t.next=2;break}return t.abrupt("return",this.transport.reply(e,{error:{message:"Missing capability"}}));case 2:return t.prev=2,t.next=5,this.driver.downloadFile(e.data.content_uri);case 5:return r=t.sent,t.abrupt("return",this.transport.reply(e,{file:r.file}));case 9:t.prev=9,t.t0=t.catch(2),console.error("error while downloading a file",t.t0),this.handleDriverError(t.t0,e,"Unexpected error while downloading a file");case 13:case"end":return t.stop()}},t,this,[[2,9]])})),function(t){return S.apply(this,arguments)})},{key:"handleDriverError",value:function(t,e,r){var n=this.driver.processError(t);this.transport.reply(e,{error:v({message:r},n)})}},{key:"handleMessage",value:function(t){if(!this.isStopped){var e=new CustomEvent("action:".concat(t.detail.action),{detail:t.detail,cancelable:!0});if(this.emit("action:".concat(t.detail.action),e),!e.defaultPrevented)switch(t.detail.action){case a.WidgetApiFromWidgetAction.ContentLoaded:return this.handleContentLoadedAction(t.detail);case a.WidgetApiFromWidgetAction.SupportedApiVersions:return this.replyVersions(t.detail);case a.WidgetApiFromWidgetAction.SendEvent:return this.handleSendEvent(t.detail);case a.WidgetApiFromWidgetAction.SendToDevice:return this.handleSendToDevice(t.detail);case a.WidgetApiFromWidgetAction.GetOpenIDCredentials:return this.handleOIDC(t.detail);case a.WidgetApiFromWidgetAction.MSC2931Navigate:return this.handleNavigate(t.detail);case a.WidgetApiFromWidgetAction.MSC2974RenegotiateCapabilities:return this.handleCapabilitiesRenegotiate(t.detail);case a.WidgetApiFromWidgetAction.MSC2876ReadEvents:return this.handleReadEvents(t.detail);case a.WidgetApiFromWidgetAction.WatchTurnServers:return this.handleWatchTurnServers(t.detail);case a.WidgetApiFromWidgetAction.UnwatchTurnServers:return this.handleUnwatchTurnServers(t.detail);case a.WidgetApiFromWidgetAction.MSC3869ReadRelations:return this.handleReadRelations(t.detail);case a.WidgetApiFromWidgetAction.MSC3973UserDirectorySearch:return this.handleUserDirectorySearch(t.detail);case a.WidgetApiFromWidgetAction.BeeperReadRoomAccountData:return this.handleReadRoomAccountData(t.detail);case a.WidgetApiFromWidgetAction.MSC4039GetMediaConfigAction:return this.handleGetMediaConfig(t.detail);case a.WidgetApiFromWidgetAction.MSC4039UploadFileAction:return this.handleUploadFile(t.detail);case a.WidgetApiFromWidgetAction.MSC4039DownloadFileAction:return this.handleDownloadFile(t.detail);case a.WidgetApiFromWidgetAction.MSC4157UpdateDelayedEvent:return this.handleUpdateDelayedEvent(t.detail);default:return this.transport.reply(t.detail,{error:{message:"Unknown or unsupported action: "+t.detail.action}})}}}},{key:"updateTheme",value:function(t){return this.transport.send(a.WidgetApiToWidgetAction.ThemeChange,t)}},{key:"updateLanguage",value:function(t){return this.transport.send(a.WidgetApiToWidgetAction.LanguageChange,{lang:t})}},{key:"takeScreenshot",value:function(){return this.transport.send(a.WidgetApiToWidgetAction.TakeScreenshot,{})}},{key:"updateVisibility",value:function(t){return this.transport.send(a.WidgetApiToWidgetAction.UpdateVisibility,{visible:t})}},{key:"sendWidgetConfig",value:function(t){return this.transport.send(a.WidgetApiToWidgetAction.WidgetConfig,t).then()}},{key:"notifyModalWidgetButtonClicked",value:function(t){return this.transport.send(a.WidgetApiToWidgetAction.ButtonClicked,{id:t}).then()}},{key:"notifyModalWidgetClose",value:function(t){return this.transport.send(a.WidgetApiToWidgetAction.CloseModalWidget,t).then()}},{key:"feedEvent",value:(x=E(w().mark(function t(e,r){var n;return w().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(void 0!==r&&this.setViewedRoomId(r),e.room_id===this.viewedRoomId||this.canUseRoomTimeline(e.room_id)){t.next=3;break}return t.abrupt("return");case 3:if(void 0===e.state_key||null===e.state_key){t.next=8;break}if(this.canReceiveStateEvent(e.type,e.state_key)){t.next=6;break}return t.abrupt("return");case 6:t.next=10;break;case 8:if(this.canReceiveRoomEvent(e.type,null===(n=e.content)||void 0===n?void 0:n.msgtype)){t.next=10;break}return t.abrupt("return");case 10:return t.next=12,this.transport.send(a.WidgetApiToWidgetAction.SendEvent,e);case 12:case"end":return t.stop()}},t,this)})),function(t,e){return x.apply(this,arguments)})},{key:"feedToDevice",value:(b=E(w().mark(function t(e,r){return w().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.canReceiveToDeviceEvent(e.type)){t.next=3;break}return t.next=3,this.transport.send(a.WidgetApiToWidgetAction.SendToDevice,v(v({},e),{},{encrypted:r}));case 3:case"end":return t.stop()}},t,this)})),function(t,e){return b.apply(this,arguments)})},{key:"setViewedRoomId",value:function(t){this.viewedRoomId=t,null===t||this.canUseRoomTimeline(t)||this.pushRoomState(t)}},{key:"flushRoomState",value:(g=E(w().mark(function t(){var e,r,n,i,s,o,c;return w().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:t.prev=0;case 1:return t.next=3,Promise.all(m(this.pushRoomStateTasks));case 3:if(this.pushRoomStateTasks.size>0){t.next=1;break}case 4:e=[],r=y(this.pushRoomStateResult.values());try{for(r.s();!(n=r.n()).done;){i=n.value,s=y(i.values());try{for(s.s();!(o=s.n()).done;)c=o.value,e.push.apply(e,m(c.values()))}catch(t){s.e(t)}finally{s.f()}}}catch(t){r.e(t)}finally{r.f()}return t.next=9,this.getWidgetVersions();case 9:if(!t.sent.includes(u.UnstableApiVersion.MSC2762_UPDATE_STATE)){t.next=12;break}return t.next=12,this.transport.send(a.WidgetApiToWidgetAction.UpdateState,{state:e});case 12:return t.prev=12,this.flushRoomStateTask=null,t.finish(12);case 15:case"end":return t.stop()}},t,this,[[0,,12,15]])})),function(){return g.apply(this,arguments)})},{key:"pushRoomState",value:function(t){var e,r=this,n=y(this.allowedEvents);try{var i=function(){var n=e.value;if(n.kind===c.EventKind.State&&n.direction===c.EventDirection.Receive){var i,s,a=r.driver.readRoomState(t,n.eventType,null!==(i=n.keyStr)&&void 0!==i?i:void 0).then(function(e){var i,s=y(e);try{for(s.s();!(i=s.n()).done;){var a=i.value,o=r.pushRoomStateResult.get(t);void 0===o&&(o=new Map,r.pushRoomStateResult.set(t,o));var u=o.get(n.eventType);void 0===u&&(u=new Map,o.set(n.eventType,u)),u.has(a.state_key)||u.set(a.state_key,a)}}catch(t){s.e(t)}finally{s.f()}},function(e){return console.error("Failed to read room state for ".concat(t," (").concat(n.eventType,", ").concat(n.keyStr,")"),e)}).then(function(){r.pushRoomStateTasks.delete(a)});r.pushRoomStateTasks.add(a),null!==(s=r.flushRoomStateTask)&&void 0!==s||(r.flushRoomStateTask=r.flushRoomState()),r.flushRoomStateTask.catch(function(t){return console.error("Failed to push room state",t)})}};for(n.s();!(e=n.n()).done;)i()}catch(t){n.e(t)}finally{n.f()}}},{key:"feedStateUpdate",value:(p=E(w().mark(function t(e){var r,n;return w().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(void 0!==e.state_key){t.next=2;break}throw new Error("Not a state event");case 2:if(e.room_id!==this.viewedRoomId&&!this.canUseRoomTimeline(e.room_id)||!this.canReceiveStateEvent(e.type,e.state_key)){t.next=21;break}if(0!==this.pushRoomStateTasks.size){t.next=11;break}return t.next=6,this.getWidgetVersions();case 6:if(!t.sent.includes(u.UnstableApiVersion.MSC2762_UPDATE_STATE)){t.next=9;break}return t.next=9,this.transport.send(a.WidgetApiToWidgetAction.UpdateState,{state:[e]});case 9:t.next=21;break;case 11:void 0===(r=this.pushRoomStateResult.get(e.room_id))&&(r=new Map,this.pushRoomStateResult.set(e.room_id,r)),void 0===(n=r.get(e.type))&&(n=new Map,r.set(e.type,n)),n.has(e.type)||n.set(e.state_key,e);case 16:return t.next=18,Promise.all(m(this.pushRoomStateTasks));case 18:if(this.pushRoomStateTasks.size>0){t.next=16;break}case 19:return t.next=21,this.flushRoomStateTask;case 21:case"end":return t.stop()}},t,this)})),function(t){return p.apply(this,arguments)})}],r&&F(e.prototype,r),n&&F(e,n),Object.defineProperty(e,"prototype",{writable:!1}),q}(n.EventEmitter);e.ClientWidgetApi=O},"./node_modules/matrix-widget-api/lib/Symbols.js":(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Symbols=void 0;var r=function(t){return t.AnyRoom="*",t}({});e.Symbols=r},"./node_modules/matrix-widget-api/lib/WidgetApi.js":(t,e,r)=>{"use strict";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},n(t)}Object.defineProperty(e,"__esModule",{value:!0}),e.WidgetApiResponseError=e.WidgetApi=void 0;var i=r("./node_modules/events/events.js"),s=r("./node_modules/matrix-widget-api/lib/interfaces/WidgetApiDirection.js"),a=r("./node_modules/matrix-widget-api/lib/interfaces/ApiVersion.js"),o=r("./node_modules/matrix-widget-api/lib/transport/PostmessageTransport.js"),u=r("./node_modules/matrix-widget-api/lib/interfaces/WidgetApiAction.js"),c=r("./node_modules/matrix-widget-api/lib/interfaces/GetOpenIDAction.js"),l=r("./node_modules/matrix-widget-api/lib/interfaces/WidgetType.js"),h=r("./node_modules/matrix-widget-api/lib/interfaces/ModalWidgetActions.js"),f=r("./node_modules/matrix-widget-api/lib/models/WidgetEventCapability.js"),d=r("./node_modules/matrix-widget-api/lib/Symbols.js");function p(){p=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},s="function"==typeof Symbol?Symbol:{},a=s.iterator||"@@iterator",o=s.asyncIterator||"@@asyncIterator",u=s.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var s=e&&e.prototype instanceof d?e:d,a=Object.create(s.prototype),o=new D(n||[]);return i(a,"_invoke",{value:E(t,r,o)}),a}function h(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=l;var f={};function d(){}function g(){}function v(){}var y={};c(y,a,function(){return this});var m=Object.getPrototypeOf,b=m&&m(m(P([])));b&&b!==e&&r.call(b,a)&&(y=b);var x=v.prototype=d.prototype=Object.create(y);function w(t){["next","throw","return"].forEach(function(e){c(t,e,function(t){return this._invoke(e,t)})})}function S(t,e){function s(i,a,o,u){var c=h(t[i],t,a);if("throw"!==c.type){var l=c.arg,f=l.value;return f&&"object"==n(f)&&r.call(f,"__await")?e.resolve(f.__await).then(function(t){s("next",t,o,u)},function(t){s("throw",t,o,u)}):e.resolve(f).then(function(t){l.value=t,o(l)},function(t){return s("throw",t,o,u)})}u(c.arg)}var a;i(this,"_invoke",{value:function(t,r){function n(){return new e(function(e,n){s(t,r,e,n)})}return a=a?a.then(n,n):n()}})}function E(t,e,r){var n="suspendedStart";return function(i,s){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw s;return I()}for(r.method=i,r.arg=s;;){var a=r.delegate;if(a){var o=F(a,r);if(o){if(o===f)continue;return o}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=h(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===f)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}function F(t,e){var r=e.method,n=t.iterator[r];if(void 0===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=void 0,F(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),f;var i=h(n,t.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,f;var s=i.arg;return s?s.done?(e[t.resultName]=s.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,f):s:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,f)}function A(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 C(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function D(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function P(t){if(t){var e=t[a];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n=0;--i){var s=this.tryEntries[i],a=s.completion;if("root"===s.tryLoc)return n("end");if(s.tryLoc<=this.prev){var o=r.call(s,"catchLoc"),u=r.call(s,"finallyLoc");if(o&&u){if(this.prev=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),C(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;C(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:P(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function g(t,e,r,n,i,s,a){try{var o=t[s](a),u=o.value}catch(t){return void r(t)}o.done?e(u):Promise.resolve(u).then(n,i)}function v(t){return function(){var e=this,r=arguments;return new Promise(function(n,i){var s=t.apply(e,r);function a(t){g(s,n,i,a,o,"next",t)}function o(t){g(s,n,i,a,o,"throw",t)}a(void 0)})}}function y(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function m(t){for(var e=1;e0&&void 0!==arguments[0]?arguments[0]:null,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(E(this,x),(t=y.call(this)).clientOrigin=r,b(C(t),"transport",void 0),b(C(t),"capabilitiesFinished",!1),b(C(t),"supportsMSC2974Renegotiate",!1),b(C(t),"requestedCapabilities",[]),b(C(t),"approvedCapabilities",void 0),b(C(t),"cachedClientVersions",void 0),b(C(t),"turnServerWatchers",0),!window.parent)throw new Error("No parent window. This widget doesn't appear to be embedded properly.");return t.transport=new o.PostmessageTransport(s.WidgetApiDirection.FromWidget,e,window.parent,window),t.transport.targetOrigin=r,t.transport.on("message",t.handleMessage.bind(C(t))),t}return w(x,[{key:"hasCapability",value:function(t){return Array.isArray(this.approvedCapabilities)?this.approvedCapabilities.includes(t):this.requestedCapabilities.includes(t)}},{key:"requestCapability",value:function(t){if(this.capabilitiesFinished&&!this.supportsMSC2974Renegotiate)throw new Error("Capabilities have already been negotiated");this.requestedCapabilities.push(t)}},{key:"requestCapabilities",value:function(t){var e=this;t.forEach(function(t){return e.requestCapability(t)})}},{key:"requestCapabilityForRoomTimeline",value:function(t){this.requestCapability("org.matrix.msc2762.timeline:".concat(t))}},{key:"requestCapabilityToSendState",value:function(t,e){this.requestCapability(f.WidgetEventCapability.forStateEvent(f.EventDirection.Send,t,e).raw)}},{key:"requestCapabilityToReceiveState",value:function(t,e){this.requestCapability(f.WidgetEventCapability.forStateEvent(f.EventDirection.Receive,t,e).raw)}},{key:"requestCapabilityToSendToDevice",value:function(t){this.requestCapability(f.WidgetEventCapability.forToDeviceEvent(f.EventDirection.Send,t).raw)}},{key:"requestCapabilityToReceiveToDevice",value:function(t){this.requestCapability(f.WidgetEventCapability.forToDeviceEvent(f.EventDirection.Receive,t).raw)}},{key:"requestCapabilityToSendEvent",value:function(t){this.requestCapability(f.WidgetEventCapability.forRoomEvent(f.EventDirection.Send,t).raw)}},{key:"requestCapabilityToReceiveEvent",value:function(t){this.requestCapability(f.WidgetEventCapability.forRoomEvent(f.EventDirection.Receive,t).raw)}},{key:"requestCapabilityToSendMessage",value:function(t){this.requestCapability(f.WidgetEventCapability.forRoomMessageEvent(f.EventDirection.Send,t).raw)}},{key:"requestCapabilityToReceiveMessage",value:function(t){this.requestCapability(f.WidgetEventCapability.forRoomMessageEvent(f.EventDirection.Receive,t).raw)}},{key:"requestCapabilityToReceiveRoomAccountData",value:function(t){this.requestCapability(f.WidgetEventCapability.forRoomAccountData(f.EventDirection.Receive,t).raw)}},{key:"requestOpenIDConnectToken",value:function(){var t=this;return new Promise(function(e,r){t.transport.sendComplete(u.WidgetApiFromWidgetAction.GetOpenIDCredentials,{}).then(function(n){var i=n.response;if(i.state===c.OpenIDRequestState.Allowed)e(i);else if(i.state===c.OpenIDRequestState.Blocked)r(new Error("User declined to verify their identity"));else if(i.state===c.OpenIDRequestState.PendingUserConfirmation){t.on("action:".concat(u.WidgetApiToWidgetAction.OpenIDCredentials),function s(a){a.preventDefault();var o=a.detail;o.data.original_request_id===n.requestId&&(o.data.state===c.OpenIDRequestState.Allowed?(e(o.data),t.transport.reply(o,{})):o.data.state===c.OpenIDRequestState.Blocked?(r(new Error("User declined to verify their identity")),t.transport.reply(o,{})):(r(new Error("Invalid state on reply: "+i.state)),t.transport.reply(o,{error:{message:"Invalid state"}})),t.off("action:".concat(u.WidgetApiToWidgetAction.OpenIDCredentials),s))})}else r(new Error("Invalid state: "+i.state))}).catch(r)})}},{key:"updateRequestedCapabilities",value:function(){return this.transport.send(u.WidgetApiFromWidgetAction.MSC2974RenegotiateCapabilities,{capabilities:this.requestedCapabilities}).then()}},{key:"sendContentLoaded",value:function(){return this.transport.send(u.WidgetApiFromWidgetAction.ContentLoaded,{}).then()}},{key:"sendSticker",value:function(t){return this.transport.send(u.WidgetApiFromWidgetAction.SendSticker,t).then()}},{key:"setAlwaysOnScreen",value:function(t){return this.transport.send(u.WidgetApiFromWidgetAction.UpdateAlwaysOnScreen,{value:t}).then(function(t){return t.success})}},{key:"openModalWidget",value:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:l.MatrixWidgetType.Custom;return this.transport.send(u.WidgetApiFromWidgetAction.OpenModalWidget,{type:i,url:t,name:e,buttons:r,data:n}).then()}},{key:"closeModalWidget",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.transport.send(u.WidgetApiFromWidgetAction.CloseModalWidget,t).then()}},{key:"sendRoomEvent",value:function(t,e,r,n,i){return this.sendEvent(t,void 0,e,r,n,i)}},{key:"sendStateEvent",value:function(t,e,r,n,i,s){return this.sendEvent(t,e,r,n,i,s)}},{key:"sendEvent",value:function(t,e,r,n,i,s){return this.transport.send(u.WidgetApiFromWidgetAction.SendEvent,m(m(m(m({type:t,content:r},void 0!==e&&{state_key:e}),void 0!==n&&{room_id:n}),void 0!==i&&{delay:i}),void 0!==s&&{parent_delay_id:s}))}},{key:"updateDelayedEvent",value:function(t,e){return this.transport.send(u.WidgetApiFromWidgetAction.MSC4157UpdateDelayedEvent,{delay_id:t,action:e})}},{key:"sendToDevice",value:function(t,e,r){return this.transport.send(u.WidgetApiFromWidgetAction.SendToDevice,{type:t,encrypted:e,messages:r})}},{key:"readRoomAccountData",value:function(t,e){var r={type:t};return e&&(e.includes(d.Symbols.AnyRoom)?r.room_ids=d.Symbols.AnyRoom:r.room_ids=e),this.transport.send(u.WidgetApiFromWidgetAction.BeeperReadRoomAccountData,r).then(function(t){return t.events})}},{key:"readRoomEvents",value:function(t,e,r,n,i){var s={type:t,msgtype:r};return void 0!==e&&(s.limit=e),n&&(n.includes(d.Symbols.AnyRoom)?s.room_ids=d.Symbols.AnyRoom:s.room_ids=n),i&&(s.since=i),this.transport.send(u.WidgetApiFromWidgetAction.MSC2876ReadEvents,s).then(function(t){return t.events})}},{key:"readEventRelations",value:(g=v(p().mark(function t(e,r,n,i,s,o,c,l){var h;return p().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getClientVersions();case 2:if(t.sent.includes(a.UnstableApiVersion.MSC3869)){t.next=5;break}throw new Error("The read_relations action is not supported by the client.");case 5:return h={event_id:e,rel_type:n,event_type:i,room_id:r,to:c,from:o,limit:s,direction:l},t.abrupt("return",this.transport.send(u.WidgetApiFromWidgetAction.MSC3869ReadRelations,h));case 7:case"end":return t.stop()}},t,this)})),function(t,e,r,n,i,s,a,o){return g.apply(this,arguments)})},{key:"readStateEvents",value:function(t,e,r,n){var i={type:t,state_key:void 0===r||r};return void 0!==e&&(i.limit=e),n&&(n.includes(d.Symbols.AnyRoom)?i.room_ids=d.Symbols.AnyRoom:i.room_ids=n),this.transport.send(u.WidgetApiFromWidgetAction.MSC2876ReadEvents,i).then(function(t){return t.events})}},{key:"setModalButtonEnabled",value:function(t,e){if(t===h.BuiltInModalButtonID.Close)throw new Error("The close button cannot be disabled");return this.transport.send(u.WidgetApiFromWidgetAction.SetModalButtonEnabled,{button:t,enabled:e}).then()}},{key:"navigateTo",value:function(t){if(!t||!t.startsWith("https://matrix.to/#"))throw new Error("Invalid matrix.to URI");return this.transport.send(u.WidgetApiFromWidgetAction.MSC2931Navigate,{uri:t}).then()}},{key:"getTurnServers",value:function(){var t,e=this;return(t=p().mark(function t(){var r,n;return p().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(n=function(){var t=v(p().mark(function t(n){return p().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return n.preventDefault(),r(n.detail.data),t.next=4,e.transport.reply(n.detail,{});case 4:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}(),e.on("action:".concat(u.WidgetApiToWidgetAction.UpdateTurnServers),n),0!==e.turnServerWatchers){t.next=12;break}return t.prev=3,t.next=6,j(e.transport.send(u.WidgetApiFromWidgetAction.WatchTurnServers,{}));case 6:t.next=12;break;case 8:throw t.prev=8,t.t0=t.catch(3),e.off("action:".concat(u.WidgetApiToWidgetAction.UpdateTurnServers),n),t.t0;case 12:e.turnServerWatchers++,t.prev=13;case 14:return t.next=17,j(new Promise(function(t){return r=t}));case 17:return t.next=19,t.sent;case 19:t.next=14;break;case 21:if(t.prev=21,e.off("action:".concat(u.WidgetApiToWidgetAction.UpdateTurnServers),n),e.turnServerWatchers--,0!==e.turnServerWatchers){t.next=27;break}return t.next=27,j(e.transport.send(u.WidgetApiFromWidgetAction.UnwatchTurnServers,{}));case 27:return t.finish(21);case 28:case"end":return t.stop()}},t,null,[[3,8],[13,,21,28]])}),function(){return new O(t.apply(this,arguments))})()}},{key:"searchUserDirectory",value:(i=v(p().mark(function t(e,r){var n;return p().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getClientVersions();case 2:if(t.sent.includes(a.UnstableApiVersion.MSC3973)){t.next=5;break}throw new Error("The user_directory_search action is not supported by the client.");case 5:return n={search_term:e,limit:r},t.abrupt("return",this.transport.send(u.WidgetApiFromWidgetAction.MSC3973UserDirectorySearch,n));case 7:case"end":return t.stop()}},t,this)})),function(t,e){return i.apply(this,arguments)})},{key:"getMediaConfig",value:(n=v(p().mark(function t(){var e;return p().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getClientVersions();case 2:if(t.sent.includes(a.UnstableApiVersion.MSC4039)){t.next=5;break}throw new Error("The get_media_config action is not supported by the client.");case 5:return e={},t.abrupt("return",this.transport.send(u.WidgetApiFromWidgetAction.MSC4039GetMediaConfigAction,e));case 7:case"end":return t.stop()}},t,this)})),function(){return n.apply(this,arguments)})},{key:"uploadFile",value:(r=v(p().mark(function t(e){var r;return p().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getClientVersions();case 2:if(t.sent.includes(a.UnstableApiVersion.MSC4039)){t.next=5;break}throw new Error("The upload_file action is not supported by the client.");case 5:return r={file:e},t.abrupt("return",this.transport.send(u.WidgetApiFromWidgetAction.MSC4039UploadFileAction,r));case 7:case"end":return t.stop()}},t,this)})),function(t){return r.apply(this,arguments)})},{key:"downloadFile",value:(e=v(p().mark(function t(e){var r;return p().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getClientVersions();case 2:if(t.sent.includes(a.UnstableApiVersion.MSC4039)){t.next=5;break}throw new Error("The download_file action is not supported by the client.");case 5:return r={content_uri:e},t.abrupt("return",this.transport.send(u.WidgetApiFromWidgetAction.MSC4039DownloadFileAction,r));case 7:case"end":return t.stop()}},t,this)})),function(t){return e.apply(this,arguments)})},{key:"start",value:function(){var t=this;this.transport.start(),this.getClientVersions().then(function(e){e.includes(a.UnstableApiVersion.MSC2974)&&(t.supportsMSC2974Renegotiate=!0)})}},{key:"handleMessage",value:function(t){var e=new CustomEvent("action:".concat(t.detail.action),{detail:t.detail,cancelable:!0});if(this.emit("action:".concat(t.detail.action),e),!e.defaultPrevented)switch(t.detail.action){case u.WidgetApiToWidgetAction.SupportedApiVersions:return this.replyVersions(t.detail);case u.WidgetApiToWidgetAction.Capabilities:return this.handleCapabilities(t.detail);case u.WidgetApiToWidgetAction.UpdateVisibility:case u.WidgetApiToWidgetAction.NotifyCapabilities:return this.transport.reply(t.detail,{});default:return this.transport.reply(t.detail,{error:{message:"Unknown or unsupported action: "+t.detail.action}})}}},{key:"replyVersions",value:function(t){this.transport.reply(t,{supported_versions:a.CurrentApiVersions})}},{key:"getClientVersions",value:function(){var t=this;return Array.isArray(this.cachedClientVersions)?Promise.resolve(this.cachedClientVersions):this.transport.send(u.WidgetApiFromWidgetAction.SupportedApiVersions,{}).then(function(e){return t.cachedClientVersions=e.supported_versions,e.supported_versions}).catch(function(t){return console.warn("non-fatal error getting supported client versions: ",t),[]})}},{key:"handleCapabilities",value:function(t){var e=this;return this.capabilitiesFinished?this.transport.reply(t,{error:{message:"Capability negotiation already completed"}}):this.getClientVersions().then(function(r){return r.includes(a.UnstableApiVersion.MSC2871)?e.once("action:".concat(u.WidgetApiToWidgetAction.NotifyCapabilities),function(t){e.approvedCapabilities=t.detail.data.approved,e.emit("ready")}):e.emit("ready"),e.capabilitiesFinished=!0,e.transport.reply(t,{capabilities:e.requestedCapabilities})})}}]),x}(i.EventEmitter);e.WidgetApi=B},"./node_modules/matrix-widget-api/lib/driver/WidgetDriver.js":(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.WidgetDriver=void 0;var n=r("./node_modules/matrix-widget-api/lib/index.js");function i(t){return i="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},i(t)}function s(t,e){for(var r=0;r{"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r("./node_modules/matrix-widget-api/lib/WidgetApi.js");Object.keys(n).forEach(function(t){"default"!==t&&"__esModule"!==t&&(t in e&&e[t]===n[t]||Object.defineProperty(e,t,{enumerable:!0,get:function(){return n[t]}}))});var i=r("./node_modules/matrix-widget-api/lib/ClientWidgetApi.js");Object.keys(i).forEach(function(t){"default"!==t&&"__esModule"!==t&&(t in e&&e[t]===i[t]||Object.defineProperty(e,t,{enumerable:!0,get:function(){return i[t]}}))});var s=r("./node_modules/matrix-widget-api/lib/Symbols.js");Object.keys(s).forEach(function(t){"default"!==t&&"__esModule"!==t&&(t in e&&e[t]===s[t]||Object.defineProperty(e,t,{enumerable:!0,get:function(){return s[t]}}))});var a=r("./node_modules/matrix-widget-api/lib/transport/PostmessageTransport.js");Object.keys(a).forEach(function(t){"default"!==t&&"__esModule"!==t&&(t in e&&e[t]===a[t]||Object.defineProperty(e,t,{enumerable:!0,get:function(){return a[t]}}))});var o=r("./node_modules/matrix-widget-api/lib/interfaces/WidgetType.js");Object.keys(o).forEach(function(t){"default"!==t&&"__esModule"!==t&&(t in e&&e[t]===o[t]||Object.defineProperty(e,t,{enumerable:!0,get:function(){return o[t]}}))});var u=r("./node_modules/matrix-widget-api/lib/interfaces/IWidgetApiErrorResponse.js");Object.keys(u).forEach(function(t){"default"!==t&&"__esModule"!==t&&(t in e&&e[t]===u[t]||Object.defineProperty(e,t,{enumerable:!0,get:function(){return u[t]}}))});var c=r("./node_modules/matrix-widget-api/lib/interfaces/WidgetApiAction.js");Object.keys(c).forEach(function(t){"default"!==t&&"__esModule"!==t&&(t in e&&e[t]===c[t]||Object.defineProperty(e,t,{enumerable:!0,get:function(){return c[t]}}))});var l=r("./node_modules/matrix-widget-api/lib/interfaces/WidgetApiDirection.js");Object.keys(l).forEach(function(t){"default"!==t&&"__esModule"!==t&&(t in e&&e[t]===l[t]||Object.defineProperty(e,t,{enumerable:!0,get:function(){return l[t]}}))});var h=r("./node_modules/matrix-widget-api/lib/interfaces/ApiVersion.js");Object.keys(h).forEach(function(t){"default"!==t&&"__esModule"!==t&&(t in e&&e[t]===h[t]||Object.defineProperty(e,t,{enumerable:!0,get:function(){return h[t]}}))});var f=r("./node_modules/matrix-widget-api/lib/interfaces/Capabilities.js");Object.keys(f).forEach(function(t){"default"!==t&&"__esModule"!==t&&(t in e&&e[t]===f[t]||Object.defineProperty(e,t,{enumerable:!0,get:function(){return f[t]}}))});var d=r("./node_modules/matrix-widget-api/lib/interfaces/GetOpenIDAction.js");Object.keys(d).forEach(function(t){"default"!==t&&"__esModule"!==t&&(t in e&&e[t]===d[t]||Object.defineProperty(e,t,{enumerable:!0,get:function(){return d[t]}}))});var p=r("./node_modules/matrix-widget-api/lib/interfaces/WidgetKind.js");Object.keys(p).forEach(function(t){"default"!==t&&"__esModule"!==t&&(t in e&&e[t]===p[t]||Object.defineProperty(e,t,{enumerable:!0,get:function(){return p[t]}}))});var g=r("./node_modules/matrix-widget-api/lib/interfaces/ModalButtonKind.js");Object.keys(g).forEach(function(t){"default"!==t&&"__esModule"!==t&&(t in e&&e[t]===g[t]||Object.defineProperty(e,t,{enumerable:!0,get:function(){return g[t]}}))});var v=r("./node_modules/matrix-widget-api/lib/interfaces/ModalWidgetActions.js");Object.keys(v).forEach(function(t){"default"!==t&&"__esModule"!==t&&(t in e&&e[t]===v[t]||Object.defineProperty(e,t,{enumerable:!0,get:function(){return v[t]}}))});var y=r("./node_modules/matrix-widget-api/lib/interfaces/UpdateDelayedEventAction.js");Object.keys(y).forEach(function(t){"default"!==t&&"__esModule"!==t&&(t in e&&e[t]===y[t]||Object.defineProperty(e,t,{enumerable:!0,get:function(){return y[t]}}))});var m=r("./node_modules/matrix-widget-api/lib/models/WidgetEventCapability.js");Object.keys(m).forEach(function(t){"default"!==t&&"__esModule"!==t&&(t in e&&e[t]===m[t]||Object.defineProperty(e,t,{enumerable:!0,get:function(){return m[t]}}))});var b=r("./node_modules/matrix-widget-api/lib/models/validation/url.js");Object.keys(b).forEach(function(t){"default"!==t&&"__esModule"!==t&&(t in e&&e[t]===b[t]||Object.defineProperty(e,t,{enumerable:!0,get:function(){return b[t]}}))});var x=r("./node_modules/matrix-widget-api/lib/models/validation/utils.js");Object.keys(x).forEach(function(t){"default"!==t&&"__esModule"!==t&&(t in e&&e[t]===x[t]||Object.defineProperty(e,t,{enumerable:!0,get:function(){return x[t]}}))});var w=r("./node_modules/matrix-widget-api/lib/models/Widget.js");Object.keys(w).forEach(function(t){"default"!==t&&"__esModule"!==t&&(t in e&&e[t]===w[t]||Object.defineProperty(e,t,{enumerable:!0,get:function(){return w[t]}}))});var S=r("./node_modules/matrix-widget-api/lib/models/WidgetParser.js");Object.keys(S).forEach(function(t){"default"!==t&&"__esModule"!==t&&(t in e&&e[t]===S[t]||Object.defineProperty(e,t,{enumerable:!0,get:function(){return S[t]}}))});var E=r("./node_modules/matrix-widget-api/lib/templating/url-template.js");Object.keys(E).forEach(function(t){"default"!==t&&"__esModule"!==t&&(t in e&&e[t]===E[t]||Object.defineProperty(e,t,{enumerable:!0,get:function(){return E[t]}}))});var F=r("./node_modules/matrix-widget-api/lib/util/SimpleObservable.js");Object.keys(F).forEach(function(t){"default"!==t&&"__esModule"!==t&&(t in e&&e[t]===F[t]||Object.defineProperty(e,t,{enumerable:!0,get:function(){return F[t]}}))});var A=r("./node_modules/matrix-widget-api/lib/driver/WidgetDriver.js");Object.keys(A).forEach(function(t){"default"!==t&&"__esModule"!==t&&(t in e&&e[t]===A[t]||Object.defineProperty(e,t,{enumerable:!0,get:function(){return A[t]}}))})},"./node_modules/matrix-widget-api/lib/interfaces/ApiVersion.js":(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.UnstableApiVersion=e.MatrixApiVersion=e.CurrentApiVersions=void 0;var r=function(t){return t.Prerelease1="0.0.1",t.Prerelease2="0.0.2",t}({});e.MatrixApiVersion=r;var n=function(t){return t.MSC2762="org.matrix.msc2762",t.MSC2762_UPDATE_STATE="org.matrix.msc2762_update_state",t.MSC2871="org.matrix.msc2871",t.MSC2873="org.matrix.msc2873",t.MSC2931="org.matrix.msc2931",t.MSC2974="org.matrix.msc2974",t.MSC2876="org.matrix.msc2876",t.MSC3819="org.matrix.msc3819",t.MSC3846="town.robin.msc3846",t.MSC3869="org.matrix.msc3869",t.MSC3973="org.matrix.msc3973",t.MSC4039="org.matrix.msc4039",t}({});e.UnstableApiVersion=n;var i=[r.Prerelease1,r.Prerelease2,n.MSC2762,n.MSC2762_UPDATE_STATE,n.MSC2871,n.MSC2873,n.MSC2931,n.MSC2974,n.MSC2876,n.MSC3819,n.MSC3846,n.MSC3869,n.MSC3973,n.MSC4039];e.CurrentApiVersions=i},"./node_modules/matrix-widget-api/lib/interfaces/Capabilities.js":(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.VideoConferenceCapabilities=e.StickerpickerCapabilities=e.MatrixCapabilities=void 0,e.getTimelineRoomIDFromCapability=function(t){return t.substring(t.indexOf(":")+1)},e.isTimelineCapability=function(t){return null==t?void 0:t.startsWith("org.matrix.msc2762.timeline:")},e.isTimelineCapabilityFor=function(t,e){return t==="org.matrix.msc2762.timeline:".concat(e)};var r=function(t){return t.Screenshots="m.capability.screenshot",t.StickerSending="m.sticker",t.AlwaysOnScreen="m.always_on_screen",t.RequiresClient="io.element.requires_client",t.MSC2931Navigate="org.matrix.msc2931.navigate",t.MSC3846TurnServers="town.robin.msc3846.turn_servers",t.MSC3973UserDirectorySearch="org.matrix.msc3973.user_directory_search",t.MSC4039UploadFile="org.matrix.msc4039.upload_file",t.MSC4039DownloadFile="org.matrix.msc4039.download_file",t.MSC4157SendDelayedEvent="org.matrix.msc4157.send.delayed_event",t.MSC4157UpdateDelayedEvent="org.matrix.msc4157.update_delayed_event",t}({});e.MatrixCapabilities=r;var n=[r.StickerSending];e.StickerpickerCapabilities=n;var i=[r.AlwaysOnScreen];e.VideoConferenceCapabilities=i},"./node_modules/matrix-widget-api/lib/interfaces/GetOpenIDAction.js":(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.OpenIDRequestState=void 0;var r=function(t){return t.Allowed="allowed",t.Blocked="blocked",t.PendingUserConfirmation="request",t}({});e.OpenIDRequestState=r},"./node_modules/matrix-widget-api/lib/interfaces/IWidgetApiErrorResponse.js":(t,e)=>{"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},r(t)}Object.defineProperty(e,"__esModule",{value:!0}),e.isErrorResponse=function(t){var e=t.error;return"object"===r(e)&&null!==e&&"message"in e&&"string"==typeof e.message}},"./node_modules/matrix-widget-api/lib/interfaces/ModalButtonKind.js":(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ModalButtonKind=void 0;var r=function(t){return t.Primary="m.primary",t.Secondary="m.secondary",t.Warning="m.warning",t.Danger="m.danger",t.Link="m.link",t}({});e.ModalButtonKind=r},"./node_modules/matrix-widget-api/lib/interfaces/ModalWidgetActions.js":(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.BuiltInModalButtonID=void 0;var r=function(t){return t.Close="m.close",t}({});e.BuiltInModalButtonID=r},"./node_modules/matrix-widget-api/lib/interfaces/UpdateDelayedEventAction.js":(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.UpdateDelayedEventAction=void 0;var r=function(t){return t.Cancel="cancel",t.Restart="restart",t.Send="send",t}({});e.UpdateDelayedEventAction=r},"./node_modules/matrix-widget-api/lib/interfaces/WidgetApiAction.js":(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.WidgetApiToWidgetAction=e.WidgetApiFromWidgetAction=void 0;var r=function(t){return t.SupportedApiVersions="supported_api_versions",t.Capabilities="capabilities",t.NotifyCapabilities="notify_capabilities",t.ThemeChange="theme_change",t.LanguageChange="language_change",t.TakeScreenshot="screenshot",t.UpdateVisibility="visibility",t.OpenIDCredentials="openid_credentials",t.WidgetConfig="widget_config",t.CloseModalWidget="close_modal",t.ButtonClicked="button_clicked",t.SendEvent="send_event",t.SendToDevice="send_to_device",t.UpdateState="update_state",t.UpdateTurnServers="update_turn_servers",t}({});e.WidgetApiToWidgetAction=r;var n=function(t){return t.SupportedApiVersions="supported_api_versions",t.ContentLoaded="content_loaded",t.SendSticker="m.sticker",t.UpdateAlwaysOnScreen="set_always_on_screen",t.GetOpenIDCredentials="get_openid",t.CloseModalWidget="close_modal",t.OpenModalWidget="open_modal",t.SetModalButtonEnabled="set_button_enabled",t.SendEvent="send_event",t.SendToDevice="send_to_device",t.WatchTurnServers="watch_turn_servers",t.UnwatchTurnServers="unwatch_turn_servers",t.BeeperReadRoomAccountData="com.beeper.read_room_account_data",t.MSC2876ReadEvents="org.matrix.msc2876.read_events",t.MSC2931Navigate="org.matrix.msc2931.navigate",t.MSC2974RenegotiateCapabilities="org.matrix.msc2974.request_capabilities",t.MSC3869ReadRelations="org.matrix.msc3869.read_relations",t.MSC3973UserDirectorySearch="org.matrix.msc3973.user_directory_search",t.MSC4039GetMediaConfigAction="org.matrix.msc4039.get_media_config",t.MSC4039UploadFileAction="org.matrix.msc4039.upload_file",t.MSC4039DownloadFileAction="org.matrix.msc4039.download_file",t.MSC4157UpdateDelayedEvent="org.matrix.msc4157.update_delayed_event",t}({});e.WidgetApiFromWidgetAction=n},"./node_modules/matrix-widget-api/lib/interfaces/WidgetApiDirection.js":(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.WidgetApiDirection=void 0,e.invertedDirection=function(t){if(t===r.ToWidget)return r.FromWidget;if(t===r.FromWidget)return r.ToWidget;throw new Error("Invalid direction")};var r=function(t){return t.ToWidget="toWidget",t.FromWidget="fromWidget",t}({});e.WidgetApiDirection=r},"./node_modules/matrix-widget-api/lib/interfaces/WidgetKind.js":(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.WidgetKind=void 0;var r=function(t){return t.Room="room",t.Account="account",t.Modal="modal",t}({});e.WidgetKind=r},"./node_modules/matrix-widget-api/lib/interfaces/WidgetType.js":(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.MatrixWidgetType=void 0;var r=function(t){return t.Custom="m.custom",t.JitsiMeet="m.jitsi",t.Stickerpicker="m.stickerpicker",t}({});e.MatrixWidgetType=r},"./node_modules/matrix-widget-api/lib/models/Widget.js":(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Widget=void 0;var n=r("./node_modules/matrix-widget-api/lib/models/validation/utils.js"),i=r("./node_modules/matrix-widget-api/lib/index.js");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},s(t)}function a(t,e){for(var r=0;r{"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},r(t)}function n(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return i(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return i(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,s=function(){};return{s,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:s}}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 a,o=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){u=!0,a=t},f:function(){try{o||null==r.return||r.return()}finally{if(u)throw a}}}}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r2&&void 0!==arguments[2]?arguments[2]:null;return this.kind===o.Event&&this.direction===t&&this.eventType===e&&("m.room.message"!==this.eventType||null===this.keyStr||this.keyStr===r)}},{key:"matchesAsRoomAccountData",value:function(t,e){return this.kind===o.RoomAccount&&this.direction===t&&this.eventType===e}}],i=[{key:"forStateEvent",value:function(e,r,n){r=r.replace(/#/g,"\\#"),n=null!=n?"#".concat(n):"";var i="org.matrix.msc2762.".concat(e,".state_event:").concat(r).concat(n);return t.findEventCapabilities([i])[0]}},{key:"forToDeviceEvent",value:function(e,r){var n="org.matrix.msc3819.".concat(e,".to_device:").concat(r);return t.findEventCapabilities([n])[0]}},{key:"forRoomEvent",value:function(e,r){var n="org.matrix.msc2762.".concat(e,".event:").concat(r);return t.findEventCapabilities([n])[0]}},{key:"forRoomMessageEvent",value:function(e,r){r=null==r?"":r;var n="org.matrix.msc2762.".concat(e,".event:m.room.message#").concat(r);return t.findEventCapabilities([n])[0]}},{key:"forRoomAccountData",value:function(e,r){var n="com.beeper.capabilities.".concat(e,".room_account_data:").concat(r);return t.findEventCapabilities([n])[0]}},{key:"findEventCapabilities",value:function(e){var r,i=[],s=n(e);try{for(s.s();!(r=s.n()).done;){var a=r.value,c=null,l=void 0,h=null;if(a.startsWith("org.matrix.msc2762.send.event:")?(c=u.Send,h=o.Event,l=a.substring(30)):a.startsWith("org.matrix.msc2762.send.state_event:")?(c=u.Send,h=o.State,l=a.substring(36)):a.startsWith("org.matrix.msc3819.send.to_device:")?(c=u.Send,h=o.ToDevice,l=a.substring(34)):a.startsWith("org.matrix.msc2762.receive.event:")?(c=u.Receive,h=o.Event,l=a.substring(33)):a.startsWith("org.matrix.msc2762.receive.state_event:")?(c=u.Receive,h=o.State,l=a.substring(39)):a.startsWith("org.matrix.msc3819.receive.to_device:")?(c=u.Receive,h=o.ToDevice,l=a.substring(37)):a.startsWith("com.beeper.capabilities.receive.room_account_data:")&&(c=u.Receive,h=o.RoomAccount,l=a.substring(50)),null!==c&&null!==h&&void 0!==l){var f=l.startsWith("m.room.message#")||h===o.State,d=null;if(l.includes("#")&&f){var p=l.split("#"),g=p.findIndex(function(t){return!t.endsWith("\\")});l=p.slice(0,g+1).map(function(t){return t.endsWith("\\")?t.substring(0,t.length-1):t}).join("#"),d=p.slice(g+1).join("#")}i.push(new t(c,l,h,d,a))}}}catch(t){s.e(t)}finally{s.f()}return i}}],r&&s(e.prototype,r),i&&s(e,i),Object.defineProperty(e,"prototype",{writable:!1}),t}();e.WidgetEventCapability=c},"./node_modules/matrix-widget-api/lib/models/WidgetParser.js":(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.WidgetParser=void 0;var n=r("./node_modules/matrix-widget-api/lib/models/Widget.js"),i=r("./node_modules/matrix-widget-api/lib/models/validation/url.js");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},s(t)}function a(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return o(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return o(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}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 s,a=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,s=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw s}}}}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.isValidUrl=function(t){if(!t)return!1;try{var e=new URL(t);return"http"===e.protocol||"https"===e.protocol}catch(t){if(t instanceof TypeError)return!1;throw t}}},"./node_modules/matrix-widget-api/lib/models/validation/utils.js":(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.assertPresent=function(t,e){if(!t[e])throw new Error("".concat(String(e)," is required"))}},"./node_modules/matrix-widget-api/lib/templating/url-template.js":(t,e)=>{"use strict";function r(t){return null==t?"".concat(t):String(t)}Object.defineProperty(e,"__esModule",{value:!0}),e.runTemplate=function(t,e,n){for(var i=Object.assign({},e.data,{matrix_room_id:n.widgetRoomId||"",matrix_user_id:n.currentUserId,matrix_display_name:n.userDisplayName||n.currentUserId,matrix_avatar_url:n.userHttpAvatarUrl||"",matrix_widget_id:e.id,"org.matrix.msc2873.client_id":n.clientId||"","org.matrix.msc2873.client_theme":n.clientTheme||"","org.matrix.msc2873.client_language":n.clientLanguage||"","org.matrix.msc3819.matrix_device_id":n.deviceId||"","org.matrix.msc4039.matrix_base_url":n.baseUrl||""}),s=t,a=0,o=Object.keys(i);a{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.PostmessageTransport=void 0;var n=r("./node_modules/events/events.js"),i=r("./node_modules/matrix-widget-api/lib/index.js"),s=["message"];function a(t){return a="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},a(t)}function o(t,e){if(null==t)return{};var r,n,i=function(t,e){if(null==t)return{};var r,n,i={},s=Object.keys(t);for(n=0;n=0||(i[r]=t[r]);return i}(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(i[r]=t[r])}return i}function u(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function c(t){for(var e=1;e{"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},r(t)}function n(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return i(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return i(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,s=function(){};return{s,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:s}}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 a,o=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){u=!0,a=t},f:function(){try{o||null==r.return||r.return()}finally{if(u)throw a}}}}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r{"use strict";r.r(e)}},e={};function r(n){var i=e[n];if(void 0!==i)return i.exports;var s=e[n]={exports:{}};return t[n].call(s.exports,s,s.exports,r),s.exports}r.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return r.d(e,{a:e}),e},r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},(()=>{if(void 0!==r){var t=r.u,e=r.e,n={},i={};r.u=function(e){return t(e)+(n.hasOwnProperty(e)?"?"+n[e]:"")},r.e=function(s){return e(s).catch(function(e){var a=i.hasOwnProperty(s)?i[s]:3;if(a<1){var o=t(s);throw e.message="Loading chunk "+s+" failed after 3 retries.\n("+o+")",e.request=o,e}return new Promise(function(t){setTimeout(function(){var e=Date.now();n[s]=e,i[s]=a-1,t(r.e(s))},500)})})}}})(),(()=>{"use strict";var t=r("./node_modules/jsrsasign/lib/jsrsasign.js"),e=r("./node_modules/matrix-widget-api/lib/index.js"),n=r("./node_modules/loglevel/lib/loglevel.js"),i=r.n(n);i().methodFactory=function(t,e,r){return function(...e){this.prefix&&e.unshift(this.prefix);return"error"===t||"warn"===t||"trace"===t||"info"===t||"debug"===t?console[t](...e):console.log(...e)}};const s=function t(e){const r="matrix"+(void 0===e?"":`-${e}`),n=i().getLogger(r);return void 0===n.getChild&&(n.prefix=e,n.getChild=r=>{const i=t((null!=e?e:"")+r);return i.methodFactory=n.methodFactory,i.rebuild(),i},n.setLevel(i().levels.DEBUG,!1)),n}();let a=function(t){return t.JoinCall="io.element.join",t.HangupCall="im.vector.hangup",t.Close="io.element.close",t.CallParticipants="io.element.participants",t.StartLiveStream="im.vector.start_live_stream",t.TileLayout="io.element.tile_layout",t.SpotlightLayout="io.element.spotlight_layout",t.OpenIntegrationManager="integration_manager_open",t.ViewRoom="io.element.view_room",t.DeviceMute="io.element.device_mute",t}({});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},o(t)}function u(t){var e=function(t,e){if("object"!=o(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=o(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==o(e)?e:e+""}class c{constructor(t){var e,r,n;e=this,r="fallbackWarnings",n=new Set,(r=u(r))in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,this.obj=t}get(t,e){const r=this.obj[t];if(void 0!==r)return r;const n=null!=e?e:t.replace(/._./g,t=>`${t[0]}${t[2].toUpperCase()}`);const i=this.obj[n];return i&&!this.fallbackWarnings.has(n)&&(this.fallbackWarnings.add(n),console.warn(`Using deprecated camelCase config ${n}`),console.warn("See https://github.com/vector-im/element-web/blob/develop/docs/config.md#-deprecation-notice")),i}toJSON(){return this.obj}}let l=function(t){return t.CanChangeViewedRoom="io.element.view_room",t.RequiresClient="io.element.requires_client",t}({});async function h(t){const e=new URL(t,window.location.href);e.searchParams.set("cachebuster",Date.now().toString());const r=await fetch(e,{cache:"no-cache",method:"GET"});return 404===r.status||0===r.status?{}:r.ok?r.json():void 0}r("./src/vector/jitsi/index.pcss");let f,d,p,g,v,y,m,b,x,w,S,E,F,A,C,D,P=!1,I=!1;async function R(){if(!D)return[!1,!1];const[t,e]=(await Promise.all([D.isAudioMuted(),D.isVideoMuted()])).map(t=>!t);return[t,e]}const T=(async()=>{try{var t,r;const i=async function(t=""){""===t||t.endsWith("/")||(t+="/");let e=window.location.hostname.trimEnd();e.endsWith(".")&&(e=e.slice(0,-1));const r=h(`${t}config.${e}.json`),n=h(t+"config.json");try{const t=await r;if(!t||0===Object.keys(t).length)throw new Error;return t}catch{return n}}(),o=new URLSearchParams(window.location.hash.substring(1)),u=new URLSearchParams(window.location.search.substring(1)),P=(t,e=!1)=>{const r=o.has(t)?o.getAll(t):u.getAll(t);if(!e&&1!==r.length)throw new Error(`Expected singular ${t} in query string`);return r[0]},j=t=>{if(void 0!==t)return"true"===t},_=P("parentUrl",!0),H=P("widgetId",!0),V=P("theme",!0);let M;if(A=null!==(t=P("language",!0))&&void 0!==t?t:"en",V&&document.body.classList.add(`theme-${V.replace(" ","_")}`),_&&H){const t=new URL(P("parentUrl")).origin;C=new e.WidgetApi(P("widgetId"),t),M=new Promise(t=>C.once("ready",t)),C.requestCapabilities(e.VideoConferenceCapabilities),"openidtoken-jwt"===P("auth",!0)&&C.requestCapability(l.RequiresClient),C.start();const r=(t,e)=>{C.on(`action:${t}`,async t=>{let r;t.preventDefault(),await T;try{var n;r=null!==(n=await e(t.detail.data))&&void 0!==n?n:{}}catch(t){if(!(t instanceof Error))throw t;r={error:{message:t.message}}}C.transport.reply(t.detail,r)})};r(a.JoinCall,async({audioInput:t,videoInput:e})=>{L(t,e)}),r(a.HangupCall,async({force:t})=>{var e,r;!0===t?(null===(e=D)||void 0===e||e.dispose(),k(),D=void 0,B()):null===(r=D)||void 0===r||r.executeCommand("hangup")}),r(a.DeviceMute,async t=>{if(!D)return;const[e,r]=await R();return 0===Object.keys(t).length?{audio_enabled:e,video_enabled:r}:(t.audio_enabled!==e&&D.executeCommand("toggleAudio"),t.video_enabled!==r&&D.executeCommand("toggleVideo"),t)}),r(a.TileLayout,async()=>{var t;null===(t=D)||void 0===t||t.executeCommand("setTileView",!0)}),r(a.SpotlightLayout,async()=>{var t;null===(t=D)||void 0===t||t.executeCommand("setTileView",!1)}),r(a.StartLiveStream,async({rtmpStreamKey:t})=>{if(!D)throw new Error("Conference not joined");D.executeCommand("startRecording",{mode:"stream",youtubeStreamKey:t})})}else s.warn("No parent URL or no widget ID - assuming no widget API is available");f=P("conferenceDomain"),d=P("conferenceId"),p=P("displayName",!0),g=P("avatarUrl",!0),v=P("userId"),y=P("auth",!0),m=P("roomId",!0),b=P("roomName",!0),x="true"===P("isAudioOnly",!0),w=j(P("startWithAudioMuted",!0)),S=j(P("startWithVideoMuted",!0)),E="true"===P("isVideoChannel",!0),F="true"===P("supportsScreensharing",!0);const q=new c(null!==(r=await i)&&void 0!==r?r:{}).get("jitsi_widget");var n;if(q)I=null!==(n=new c(q).get("skip_built_in_welcome_screen"))&&void 0!==n&&n;O(I),C&&await M,I&&N(),document.getElementById("joinButton").onclick=()=>L()}catch(t){s.error("Error setting up Jitsi widget",t),document.getElementById("widgetActionContainer").innerText="Failed to load Jitsi widget"}})();function j(){P=!P,I||O(P)}function O(t){document.getElementById("jitsiContainer").style.visibility=t?"unset":"hidden",document.getElementById("joinButtonContainer").style.visibility=t?"hidden":"unset"}function N(){L()}async function k(t){if(C)try{await C.transport.send(a.HangupCall,{errorMessage:t})}finally{await C.setAlwaysOnScreen(!1)}}function B(){j(),document.getElementById("jitsiContainer").innerHTML="",I&&N()}function _(t){const[e,r]=t.replace("_","-").split("-");return r&&e!==r?e+r.toUpperCase():e}function H(t){switch(t){case"en":return"enGB";case"enUS":return"en";default:return t}}async function L(e,r){var n;let i;if("openidtoken-jwt"===y){var a;const e=await(null===(a=C)||void 0===a?void 0:a.requestOpenIDConnectToken());if(s.log("Got OpenID Connect token"),null==e||!e.access_token)return s.warn("Expected to have an OpenID credential, cannot initialize widget."),void(document.getElementById("widgetActionContainer").innerText="Failed to load Jitsi widget");i=function(e){const r={iss:f,sub:f,aud:`https://${f}`,room:"*",context:{matrix:{token:e.access_token,room_id:m,server_name:e.matrix_server_name},user:{avatar:g,name:p}}};return t.pj.jws.JWS.sign("HS256",JSON.stringify({alg:"HS256",typ:"JWT"}),JSON.stringify(r),"notused")}(e)}j(),s.warn("[Jitsi Widget] The next few errors about failing to parse URL parameters are fine if they mention 'external_api' or 'jitsi' in the stack. They're just Jitsi Meet trying to parse our fragment values and not recognizing the options.");const o={width:"100%",height:"100%",parentNode:null!==(n=document.querySelector("#jitsiContainer"))&&void 0!==n?n:void 0,roomName:d,devices:{audioInput:e,videoInput:r},userInfo:{displayName:p,email:v},interfaceConfigOverwrite:{SHOW_JITSI_WATERMARK:!1,SHOW_WATERMARK_FOR_GUESTS:!1,MAIN_TOOLBAR_BUTTONS:[],VIDEO_LAYOUT_FIT:"height"},configOverwrite:{subject:b,startAudioOnly:x,startWithAudioMuted:null===e||w,startWithVideoMuted:null===r||S,apiLogLevels:["warn","error"]},jwt:i,lang:H(_(A))};E&&(o.configOverwrite.prejoinConfig={enabled:!0},o.configOverwrite.toolbarButtons=["microphone","camera","tileview","hangup"],F&&o.configOverwrite.toolbarButtons.splice(2,0,"desktop"),o.configOverwrite.conferenceInfo={autoHide:[]},o.configOverwrite.disableSelfViewSettings=!0),D=new JitsiMeetExternalAPI(f,o),D.on("videoConferenceJoined",V),D.on("videoConferenceLeft",M),D.on("readyToClose",B),D.on("errorOccurred",q),D.on("audioMuteStatusChanged",K),D.on("videoMuteStatusChanged",U),["videoConferenceJoined","participantJoined","participantLeft"].forEach(t=>{D.on(t,W)}),D.on("log",G)}const V=()=>{var t,e,r;p&&(null===(t=D)||void 0===t||t.executeCommand("displayName",p)),g&&(null===(e=D)||void 0===e||e.executeCommand("avatarUrl",g)),C&&(C.setAlwaysOnScreen(!0),C.transport.send(a.JoinCall,{})),E&&(null===(r=D)||void 0===r||r.executeCommand("setTileView",!0))},M=()=>{k(),D=void 0},q=({error:t})=>{t.isFatal&&(k(t.message),D=void 0,B())},K=async()=>{var t;if(!D)return;const[e,r]=await R();null===(t=C)||void 0===t||t.transport.send(a.DeviceMute,{audio_enabled:e,video_enabled:r})},U=({muted:t})=>{t?setTimeout(()=>K,200):K()},W=()=>{var t,e;null===(t=C)||void 0===t||t.transport.send(a.CallParticipants,{participants:null===(e=D)||void 0===e?void 0:e.getParticipantsInfo()})},G=({logLevel:t,args:e})=>{var r;return null===(r=parent.mx_rage_logger)||void 0===r?void 0:r.log(t,...e)}})()})(); //# sourceMappingURL=jitsi.js.map