UNPKG

@arealtimetech/adk-js

Version:

JavaScript ADK to interact with the A Realtime Tech Platform.

1 lines 75.8 kB
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Adk=t():e.Adk=t()}(globalThis,(()=>(()=>{var e={735:e=>{"use strict";var t=Object.prototype.hasOwnProperty,n="~";function r(){}function i(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function s(e,t,r,s,o){if("function"!=typeof r)throw new TypeError("The listener must be a function");var a=new i(r,s||e,o),c=n?n+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],a]:e._events[c].push(a):(e._events[c]=a,e._eventsCount++),e}function o(e,t){0==--e._eventsCount?e._events=new r:delete e._events[t]}function a(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),a.prototype.eventNames=function(){var e,r,i=[];if(0===this._eventsCount)return i;for(r in e=this._events)t.call(e,r)&&i.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},a.prototype.listeners=function(e){var t=n?n+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var i=0,s=r.length,o=new Array(s);i<s;i++)o[i]=r[i].fn;return o},a.prototype.listenerCount=function(e){var t=n?n+e:e,r=this._events[t];return r?r.fn?1:r.length:0},a.prototype.emit=function(e,t,r,i,s,o){var a=n?n+e:e;if(!this._events[a])return!1;var c,h,l=this._events[a],u=arguments.length;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),u){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,r),!0;case 4:return l.fn.call(l.context,t,r,i),!0;case 5:return l.fn.call(l.context,t,r,i,s),!0;case 6:return l.fn.call(l.context,t,r,i,s,o),!0}for(h=1,c=new Array(u-1);h<u;h++)c[h-1]=arguments[h];l.fn.apply(l.context,c)}else{var p,d=l.length;for(h=0;h<d;h++)switch(l[h].once&&this.removeListener(e,l[h].fn,void 0,!0),u){case 1:l[h].fn.call(l[h].context);break;case 2:l[h].fn.call(l[h].context,t);break;case 3:l[h].fn.call(l[h].context,t,r);break;case 4:l[h].fn.call(l[h].context,t,r,i);break;default:if(!c)for(p=1,c=new Array(u-1);p<u;p++)c[p-1]=arguments[p];l[h].fn.apply(l[h].context,c)}}return!0},a.prototype.on=function(e,t,n){return s(this,e,t,n,!1)},a.prototype.once=function(e,t,n){return s(this,e,t,n,!0)},a.prototype.removeListener=function(e,t,r,i){var s=n?n+e:e;if(!this._events[s])return this;if(!t)return o(this,s),this;var a=this._events[s];if(a.fn)a.fn!==t||i&&!a.once||r&&a.context!==r||o(this,s);else{for(var c=0,h=[],l=a.length;c<l;c++)(a[c].fn!==t||i&&!a[c].once||r&&a[c].context!==r)&&h.push(a[c]);h.length?this._events[s]=1===h.length?h[0]:h:o(this,s)}return this},a.prototype.removeAllListeners=function(e){var t;return e?(t=n?n+e:e,this._events[t]&&o(this,t)):(this._events=new r,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=n,a.EventEmitter=a,e.exports=a},52:(e,t,n)=>{!function(e){"use strict";var t=function(e){var t,n=new Float64Array(16);if(e)for(t=0;t<e.length;t++)n[t]=e[t];return n},r=function(){throw new Error("no PRNG")},i=new Uint8Array(16),s=new Uint8Array(32);s[0]=9;var o=t(),a=t([1]),c=t([56129,1]),h=t([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),l=t([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),u=t([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),p=t([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),d=t([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function f(e,t,n,r){e[t]=n>>24&255,e[t+1]=n>>16&255,e[t+2]=n>>8&255,e[t+3]=255&n,e[t+4]=r>>24&255,e[t+5]=r>>16&255,e[t+6]=r>>8&255,e[t+7]=255&r}function y(e,t,n,r,i){var s,o=0;for(s=0;s<i;s++)o|=e[t+s]^n[r+s];return(1&o-1>>>8)-1}function g(e,t,n,r){return y(e,t,n,r,16)}function m(e,t,n,r){return y(e,t,n,r,32)}function v(e,t,n,r){!function(e,t,n,r){for(var i,s=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,o=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,c=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,h=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,l=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,u=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,p=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,d=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,f=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,y=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,g=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,m=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,v=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,w=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,b=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,_=s,A=o,S=a,k=c,C=h,E=l,I=u,x=p,P=d,T=f,M=y,O=g,L=m,R=v,U=w,j=b,N=0;N<20;N+=2)_^=(i=(L^=(i=(P^=(i=(C^=(i=_+L|0)<<7|i>>>25)+_|0)<<9|i>>>23)+C|0)<<13|i>>>19)+P|0)<<18|i>>>14,E^=(i=(A^=(i=(R^=(i=(T^=(i=E+A|0)<<7|i>>>25)+E|0)<<9|i>>>23)+T|0)<<13|i>>>19)+R|0)<<18|i>>>14,M^=(i=(I^=(i=(S^=(i=(U^=(i=M+I|0)<<7|i>>>25)+M|0)<<9|i>>>23)+U|0)<<13|i>>>19)+S|0)<<18|i>>>14,j^=(i=(O^=(i=(x^=(i=(k^=(i=j+O|0)<<7|i>>>25)+j|0)<<9|i>>>23)+k|0)<<13|i>>>19)+x|0)<<18|i>>>14,_^=(i=(k^=(i=(S^=(i=(A^=(i=_+k|0)<<7|i>>>25)+_|0)<<9|i>>>23)+A|0)<<13|i>>>19)+S|0)<<18|i>>>14,E^=(i=(C^=(i=(x^=(i=(I^=(i=E+C|0)<<7|i>>>25)+E|0)<<9|i>>>23)+I|0)<<13|i>>>19)+x|0)<<18|i>>>14,M^=(i=(T^=(i=(P^=(i=(O^=(i=M+T|0)<<7|i>>>25)+M|0)<<9|i>>>23)+O|0)<<13|i>>>19)+P|0)<<18|i>>>14,j^=(i=(U^=(i=(R^=(i=(L^=(i=j+U|0)<<7|i>>>25)+j|0)<<9|i>>>23)+L|0)<<13|i>>>19)+R|0)<<18|i>>>14;_=_+s|0,A=A+o|0,S=S+a|0,k=k+c|0,C=C+h|0,E=E+l|0,I=I+u|0,x=x+p|0,P=P+d|0,T=T+f|0,M=M+y|0,O=O+g|0,L=L+m|0,R=R+v|0,U=U+w|0,j=j+b|0,e[0]=_>>>0&255,e[1]=_>>>8&255,e[2]=_>>>16&255,e[3]=_>>>24&255,e[4]=A>>>0&255,e[5]=A>>>8&255,e[6]=A>>>16&255,e[7]=A>>>24&255,e[8]=S>>>0&255,e[9]=S>>>8&255,e[10]=S>>>16&255,e[11]=S>>>24&255,e[12]=k>>>0&255,e[13]=k>>>8&255,e[14]=k>>>16&255,e[15]=k>>>24&255,e[16]=C>>>0&255,e[17]=C>>>8&255,e[18]=C>>>16&255,e[19]=C>>>24&255,e[20]=E>>>0&255,e[21]=E>>>8&255,e[22]=E>>>16&255,e[23]=E>>>24&255,e[24]=I>>>0&255,e[25]=I>>>8&255,e[26]=I>>>16&255,e[27]=I>>>24&255,e[28]=x>>>0&255,e[29]=x>>>8&255,e[30]=x>>>16&255,e[31]=x>>>24&255,e[32]=P>>>0&255,e[33]=P>>>8&255,e[34]=P>>>16&255,e[35]=P>>>24&255,e[36]=T>>>0&255,e[37]=T>>>8&255,e[38]=T>>>16&255,e[39]=T>>>24&255,e[40]=M>>>0&255,e[41]=M>>>8&255,e[42]=M>>>16&255,e[43]=M>>>24&255,e[44]=O>>>0&255,e[45]=O>>>8&255,e[46]=O>>>16&255,e[47]=O>>>24&255,e[48]=L>>>0&255,e[49]=L>>>8&255,e[50]=L>>>16&255,e[51]=L>>>24&255,e[52]=R>>>0&255,e[53]=R>>>8&255,e[54]=R>>>16&255,e[55]=R>>>24&255,e[56]=U>>>0&255,e[57]=U>>>8&255,e[58]=U>>>16&255,e[59]=U>>>24&255,e[60]=j>>>0&255,e[61]=j>>>8&255,e[62]=j>>>16&255,e[63]=j>>>24&255}(e,t,n,r)}function w(e,t,n,r){!function(e,t,n,r){for(var i,s=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,o=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,c=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,h=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,l=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,u=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,p=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,d=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,f=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,y=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,g=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,m=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,v=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,w=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,b=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,_=0;_<20;_+=2)s^=(i=(m^=(i=(d^=(i=(h^=(i=s+m|0)<<7|i>>>25)+s|0)<<9|i>>>23)+h|0)<<13|i>>>19)+d|0)<<18|i>>>14,l^=(i=(o^=(i=(v^=(i=(f^=(i=l+o|0)<<7|i>>>25)+l|0)<<9|i>>>23)+f|0)<<13|i>>>19)+v|0)<<18|i>>>14,y^=(i=(u^=(i=(a^=(i=(w^=(i=y+u|0)<<7|i>>>25)+y|0)<<9|i>>>23)+w|0)<<13|i>>>19)+a|0)<<18|i>>>14,b^=(i=(g^=(i=(p^=(i=(c^=(i=b+g|0)<<7|i>>>25)+b|0)<<9|i>>>23)+c|0)<<13|i>>>19)+p|0)<<18|i>>>14,s^=(i=(c^=(i=(a^=(i=(o^=(i=s+c|0)<<7|i>>>25)+s|0)<<9|i>>>23)+o|0)<<13|i>>>19)+a|0)<<18|i>>>14,l^=(i=(h^=(i=(p^=(i=(u^=(i=l+h|0)<<7|i>>>25)+l|0)<<9|i>>>23)+u|0)<<13|i>>>19)+p|0)<<18|i>>>14,y^=(i=(f^=(i=(d^=(i=(g^=(i=y+f|0)<<7|i>>>25)+y|0)<<9|i>>>23)+g|0)<<13|i>>>19)+d|0)<<18|i>>>14,b^=(i=(w^=(i=(v^=(i=(m^=(i=b+w|0)<<7|i>>>25)+b|0)<<9|i>>>23)+m|0)<<13|i>>>19)+v|0)<<18|i>>>14;e[0]=s>>>0&255,e[1]=s>>>8&255,e[2]=s>>>16&255,e[3]=s>>>24&255,e[4]=l>>>0&255,e[5]=l>>>8&255,e[6]=l>>>16&255,e[7]=l>>>24&255,e[8]=y>>>0&255,e[9]=y>>>8&255,e[10]=y>>>16&255,e[11]=y>>>24&255,e[12]=b>>>0&255,e[13]=b>>>8&255,e[14]=b>>>16&255,e[15]=b>>>24&255,e[16]=u>>>0&255,e[17]=u>>>8&255,e[18]=u>>>16&255,e[19]=u>>>24&255,e[20]=p>>>0&255,e[21]=p>>>8&255,e[22]=p>>>16&255,e[23]=p>>>24&255,e[24]=d>>>0&255,e[25]=d>>>8&255,e[26]=d>>>16&255,e[27]=d>>>24&255,e[28]=f>>>0&255,e[29]=f>>>8&255,e[30]=f>>>16&255,e[31]=f>>>24&255}(e,t,n,r)}var b=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function _(e,t,n,r,i,s,o){var a,c,h=new Uint8Array(16),l=new Uint8Array(64);for(c=0;c<16;c++)h[c]=0;for(c=0;c<8;c++)h[c]=s[c];for(;i>=64;){for(v(l,h,o,b),c=0;c<64;c++)e[t+c]=n[r+c]^l[c];for(a=1,c=8;c<16;c++)a=a+(255&h[c])|0,h[c]=255&a,a>>>=8;i-=64,t+=64,r+=64}if(i>0)for(v(l,h,o,b),c=0;c<i;c++)e[t+c]=n[r+c]^l[c];return 0}function A(e,t,n,r,i){var s,o,a=new Uint8Array(16),c=new Uint8Array(64);for(o=0;o<16;o++)a[o]=0;for(o=0;o<8;o++)a[o]=r[o];for(;n>=64;){for(v(c,a,i,b),o=0;o<64;o++)e[t+o]=c[o];for(s=1,o=8;o<16;o++)s=s+(255&a[o])|0,a[o]=255&s,s>>>=8;n-=64,t+=64}if(n>0)for(v(c,a,i,b),o=0;o<n;o++)e[t+o]=c[o];return 0}function S(e,t,n,r,i){var s=new Uint8Array(32);w(s,r,i,b);for(var o=new Uint8Array(8),a=0;a<8;a++)o[a]=r[a+16];return A(e,t,n,o,s)}function k(e,t,n,r,i,s,o){var a=new Uint8Array(32);w(a,s,o,b);for(var c=new Uint8Array(8),h=0;h<8;h++)c[h]=s[h+16];return _(e,t,n,r,i,c,a)}var C=function(e){var t,n,r,i,s,o,a,c;this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.leftover=0,this.fin=0,t=255&e[0]|(255&e[1])<<8,this.r[0]=8191&t,n=255&e[2]|(255&e[3])<<8,this.r[1]=8191&(t>>>13|n<<3),r=255&e[4]|(255&e[5])<<8,this.r[2]=7939&(n>>>10|r<<6),i=255&e[6]|(255&e[7])<<8,this.r[3]=8191&(r>>>7|i<<9),s=255&e[8]|(255&e[9])<<8,this.r[4]=255&(i>>>4|s<<12),this.r[5]=s>>>1&8190,o=255&e[10]|(255&e[11])<<8,this.r[6]=8191&(s>>>14|o<<2),a=255&e[12]|(255&e[13])<<8,this.r[7]=8065&(o>>>11|a<<5),c=255&e[14]|(255&e[15])<<8,this.r[8]=8191&(a>>>8|c<<8),this.r[9]=c>>>5&127,this.pad[0]=255&e[16]|(255&e[17])<<8,this.pad[1]=255&e[18]|(255&e[19])<<8,this.pad[2]=255&e[20]|(255&e[21])<<8,this.pad[3]=255&e[22]|(255&e[23])<<8,this.pad[4]=255&e[24]|(255&e[25])<<8,this.pad[5]=255&e[26]|(255&e[27])<<8,this.pad[6]=255&e[28]|(255&e[29])<<8,this.pad[7]=255&e[30]|(255&e[31])<<8};function E(e,t,n,r,i,s){var o=new C(s);return o.update(n,r,i),o.finish(e,t),0}function I(e,t,n,r,i,s){var o=new Uint8Array(16);return E(o,0,n,r,i,s),g(e,t,o,0)}function x(e,t,n,r,i){var s;if(n<32)return-1;for(k(e,0,t,0,n,r,i),E(e,16,e,32,n-32,e),s=0;s<16;s++)e[s]=0;return 0}function P(e,t,n,r,i){var s,o=new Uint8Array(32);if(n<32)return-1;if(S(o,0,32,r,i),0!==I(t,16,t,32,n-32,o))return-1;for(k(e,0,t,0,n,r,i),s=0;s<32;s++)e[s]=0;return 0}function T(e,t){var n;for(n=0;n<16;n++)e[n]=0|t[n]}function M(e){var t,n,r=1;for(t=0;t<16;t++)n=e[t]+r+65535,r=Math.floor(n/65536),e[t]=n-65536*r;e[0]+=r-1+37*(r-1)}function O(e,t,n){for(var r,i=~(n-1),s=0;s<16;s++)r=i&(e[s]^t[s]),e[s]^=r,t[s]^=r}function L(e,n){var r,i,s,o=t(),a=t();for(r=0;r<16;r++)a[r]=n[r];for(M(a),M(a),M(a),i=0;i<2;i++){for(o[0]=a[0]-65517,r=1;r<15;r++)o[r]=a[r]-65535-(o[r-1]>>16&1),o[r-1]&=65535;o[15]=a[15]-32767-(o[14]>>16&1),s=o[15]>>16&1,o[14]&=65535,O(a,o,1-s)}for(r=0;r<16;r++)e[2*r]=255&a[r],e[2*r+1]=a[r]>>8}function R(e,t){var n=new Uint8Array(32),r=new Uint8Array(32);return L(n,e),L(r,t),m(n,0,r,0)}function U(e){var t=new Uint8Array(32);return L(t,e),1&t[0]}function j(e,t){var n;for(n=0;n<16;n++)e[n]=t[2*n]+(t[2*n+1]<<8);e[15]&=32767}function N(e,t,n){for(var r=0;r<16;r++)e[r]=t[r]+n[r]}function D(e,t,n){for(var r=0;r<16;r++)e[r]=t[r]-n[r]}function K(e,t,n){var r,i,s=0,o=0,a=0,c=0,h=0,l=0,u=0,p=0,d=0,f=0,y=0,g=0,m=0,v=0,w=0,b=0,_=0,A=0,S=0,k=0,C=0,E=0,I=0,x=0,P=0,T=0,M=0,O=0,L=0,R=0,U=0,j=n[0],N=n[1],D=n[2],K=n[3],F=n[4],B=n[5],$=n[6],J=n[7],H=n[8],W=n[9],Y=n[10],z=n[11],q=n[12],G=n[13],X=n[14],Z=n[15];s+=(r=t[0])*j,o+=r*N,a+=r*D,c+=r*K,h+=r*F,l+=r*B,u+=r*$,p+=r*J,d+=r*H,f+=r*W,y+=r*Y,g+=r*z,m+=r*q,v+=r*G,w+=r*X,b+=r*Z,o+=(r=t[1])*j,a+=r*N,c+=r*D,h+=r*K,l+=r*F,u+=r*B,p+=r*$,d+=r*J,f+=r*H,y+=r*W,g+=r*Y,m+=r*z,v+=r*q,w+=r*G,b+=r*X,_+=r*Z,a+=(r=t[2])*j,c+=r*N,h+=r*D,l+=r*K,u+=r*F,p+=r*B,d+=r*$,f+=r*J,y+=r*H,g+=r*W,m+=r*Y,v+=r*z,w+=r*q,b+=r*G,_+=r*X,A+=r*Z,c+=(r=t[3])*j,h+=r*N,l+=r*D,u+=r*K,p+=r*F,d+=r*B,f+=r*$,y+=r*J,g+=r*H,m+=r*W,v+=r*Y,w+=r*z,b+=r*q,_+=r*G,A+=r*X,S+=r*Z,h+=(r=t[4])*j,l+=r*N,u+=r*D,p+=r*K,d+=r*F,f+=r*B,y+=r*$,g+=r*J,m+=r*H,v+=r*W,w+=r*Y,b+=r*z,_+=r*q,A+=r*G,S+=r*X,k+=r*Z,l+=(r=t[5])*j,u+=r*N,p+=r*D,d+=r*K,f+=r*F,y+=r*B,g+=r*$,m+=r*J,v+=r*H,w+=r*W,b+=r*Y,_+=r*z,A+=r*q,S+=r*G,k+=r*X,C+=r*Z,u+=(r=t[6])*j,p+=r*N,d+=r*D,f+=r*K,y+=r*F,g+=r*B,m+=r*$,v+=r*J,w+=r*H,b+=r*W,_+=r*Y,A+=r*z,S+=r*q,k+=r*G,C+=r*X,E+=r*Z,p+=(r=t[7])*j,d+=r*N,f+=r*D,y+=r*K,g+=r*F,m+=r*B,v+=r*$,w+=r*J,b+=r*H,_+=r*W,A+=r*Y,S+=r*z,k+=r*q,C+=r*G,E+=r*X,I+=r*Z,d+=(r=t[8])*j,f+=r*N,y+=r*D,g+=r*K,m+=r*F,v+=r*B,w+=r*$,b+=r*J,_+=r*H,A+=r*W,S+=r*Y,k+=r*z,C+=r*q,E+=r*G,I+=r*X,x+=r*Z,f+=(r=t[9])*j,y+=r*N,g+=r*D,m+=r*K,v+=r*F,w+=r*B,b+=r*$,_+=r*J,A+=r*H,S+=r*W,k+=r*Y,C+=r*z,E+=r*q,I+=r*G,x+=r*X,P+=r*Z,y+=(r=t[10])*j,g+=r*N,m+=r*D,v+=r*K,w+=r*F,b+=r*B,_+=r*$,A+=r*J,S+=r*H,k+=r*W,C+=r*Y,E+=r*z,I+=r*q,x+=r*G,P+=r*X,T+=r*Z,g+=(r=t[11])*j,m+=r*N,v+=r*D,w+=r*K,b+=r*F,_+=r*B,A+=r*$,S+=r*J,k+=r*H,C+=r*W,E+=r*Y,I+=r*z,x+=r*q,P+=r*G,T+=r*X,M+=r*Z,m+=(r=t[12])*j,v+=r*N,w+=r*D,b+=r*K,_+=r*F,A+=r*B,S+=r*$,k+=r*J,C+=r*H,E+=r*W,I+=r*Y,x+=r*z,P+=r*q,T+=r*G,M+=r*X,O+=r*Z,v+=(r=t[13])*j,w+=r*N,b+=r*D,_+=r*K,A+=r*F,S+=r*B,k+=r*$,C+=r*J,E+=r*H,I+=r*W,x+=r*Y,P+=r*z,T+=r*q,M+=r*G,O+=r*X,L+=r*Z,w+=(r=t[14])*j,b+=r*N,_+=r*D,A+=r*K,S+=r*F,k+=r*B,C+=r*$,E+=r*J,I+=r*H,x+=r*W,P+=r*Y,T+=r*z,M+=r*q,O+=r*G,L+=r*X,R+=r*Z,b+=(r=t[15])*j,o+=38*(A+=r*D),a+=38*(S+=r*K),c+=38*(k+=r*F),h+=38*(C+=r*B),l+=38*(E+=r*$),u+=38*(I+=r*J),p+=38*(x+=r*H),d+=38*(P+=r*W),f+=38*(T+=r*Y),y+=38*(M+=r*z),g+=38*(O+=r*q),m+=38*(L+=r*G),v+=38*(R+=r*X),w+=38*(U+=r*Z),s=(r=(s+=38*(_+=r*N))+(i=1)+65535)-65536*(i=Math.floor(r/65536)),o=(r=o+i+65535)-65536*(i=Math.floor(r/65536)),a=(r=a+i+65535)-65536*(i=Math.floor(r/65536)),c=(r=c+i+65535)-65536*(i=Math.floor(r/65536)),h=(r=h+i+65535)-65536*(i=Math.floor(r/65536)),l=(r=l+i+65535)-65536*(i=Math.floor(r/65536)),u=(r=u+i+65535)-65536*(i=Math.floor(r/65536)),p=(r=p+i+65535)-65536*(i=Math.floor(r/65536)),d=(r=d+i+65535)-65536*(i=Math.floor(r/65536)),f=(r=f+i+65535)-65536*(i=Math.floor(r/65536)),y=(r=y+i+65535)-65536*(i=Math.floor(r/65536)),g=(r=g+i+65535)-65536*(i=Math.floor(r/65536)),m=(r=m+i+65535)-65536*(i=Math.floor(r/65536)),v=(r=v+i+65535)-65536*(i=Math.floor(r/65536)),w=(r=w+i+65535)-65536*(i=Math.floor(r/65536)),b=(r=b+i+65535)-65536*(i=Math.floor(r/65536)),s=(r=(s+=i-1+37*(i-1))+(i=1)+65535)-65536*(i=Math.floor(r/65536)),o=(r=o+i+65535)-65536*(i=Math.floor(r/65536)),a=(r=a+i+65535)-65536*(i=Math.floor(r/65536)),c=(r=c+i+65535)-65536*(i=Math.floor(r/65536)),h=(r=h+i+65535)-65536*(i=Math.floor(r/65536)),l=(r=l+i+65535)-65536*(i=Math.floor(r/65536)),u=(r=u+i+65535)-65536*(i=Math.floor(r/65536)),p=(r=p+i+65535)-65536*(i=Math.floor(r/65536)),d=(r=d+i+65535)-65536*(i=Math.floor(r/65536)),f=(r=f+i+65535)-65536*(i=Math.floor(r/65536)),y=(r=y+i+65535)-65536*(i=Math.floor(r/65536)),g=(r=g+i+65535)-65536*(i=Math.floor(r/65536)),m=(r=m+i+65535)-65536*(i=Math.floor(r/65536)),v=(r=v+i+65535)-65536*(i=Math.floor(r/65536)),w=(r=w+i+65535)-65536*(i=Math.floor(r/65536)),b=(r=b+i+65535)-65536*(i=Math.floor(r/65536)),s+=i-1+37*(i-1),e[0]=s,e[1]=o,e[2]=a,e[3]=c,e[4]=h,e[5]=l,e[6]=u,e[7]=p,e[8]=d,e[9]=f,e[10]=y,e[11]=g,e[12]=m,e[13]=v,e[14]=w,e[15]=b}function F(e,t){K(e,t,t)}function B(e,n){var r,i=t();for(r=0;r<16;r++)i[r]=n[r];for(r=253;r>=0;r--)F(i,i),2!==r&&4!==r&&K(i,i,n);for(r=0;r<16;r++)e[r]=i[r]}function $(e,n){var r,i=t();for(r=0;r<16;r++)i[r]=n[r];for(r=250;r>=0;r--)F(i,i),1!==r&&K(i,i,n);for(r=0;r<16;r++)e[r]=i[r]}function J(e,n,r){var i,s,o=new Uint8Array(32),a=new Float64Array(80),h=t(),l=t(),u=t(),p=t(),d=t(),f=t();for(s=0;s<31;s++)o[s]=n[s];for(o[31]=127&n[31]|64,o[0]&=248,j(a,r),s=0;s<16;s++)l[s]=a[s],p[s]=h[s]=u[s]=0;for(h[0]=p[0]=1,s=254;s>=0;--s)O(h,l,i=o[s>>>3]>>>(7&s)&1),O(u,p,i),N(d,h,u),D(h,h,u),N(u,l,p),D(l,l,p),F(p,d),F(f,h),K(h,u,h),K(u,l,d),N(d,h,u),D(h,h,u),F(l,h),D(u,p,f),K(h,u,c),N(h,h,p),K(u,u,h),K(h,p,f),K(p,l,a),F(l,d),O(h,l,i),O(u,p,i);for(s=0;s<16;s++)a[s+16]=h[s],a[s+32]=u[s],a[s+48]=l[s],a[s+64]=p[s];var y=a.subarray(32),g=a.subarray(16);return B(y,y),K(g,g,y),L(e,g),0}function H(e,t){return J(e,t,s)}function W(e,t){return r(t,32),H(e,t)}function Y(e,t,n){var r=new Uint8Array(32);return J(r,n,t),w(e,i,r,b)}C.prototype.blocks=function(e,t,n){for(var r,i,s,o,a,c,h,l,u,p,d,f,y,g,m,v,w,b,_,A=this.fin?0:2048,S=this.h[0],k=this.h[1],C=this.h[2],E=this.h[3],I=this.h[4],x=this.h[5],P=this.h[6],T=this.h[7],M=this.h[8],O=this.h[9],L=this.r[0],R=this.r[1],U=this.r[2],j=this.r[3],N=this.r[4],D=this.r[5],K=this.r[6],F=this.r[7],B=this.r[8],$=this.r[9];n>=16;)p=u=0,p+=(S+=8191&(r=255&e[t+0]|(255&e[t+1])<<8))*L,p+=(k+=8191&(r>>>13|(i=255&e[t+2]|(255&e[t+3])<<8)<<3))*(5*$),p+=(C+=8191&(i>>>10|(s=255&e[t+4]|(255&e[t+5])<<8)<<6))*(5*B),p+=(E+=8191&(s>>>7|(o=255&e[t+6]|(255&e[t+7])<<8)<<9))*(5*F),u=(p+=(I+=8191&(o>>>4|(a=255&e[t+8]|(255&e[t+9])<<8)<<12))*(5*K))>>>13,p&=8191,p+=(x+=a>>>1&8191)*(5*D),p+=(P+=8191&(a>>>14|(c=255&e[t+10]|(255&e[t+11])<<8)<<2))*(5*N),p+=(T+=8191&(c>>>11|(h=255&e[t+12]|(255&e[t+13])<<8)<<5))*(5*j),p+=(M+=8191&(h>>>8|(l=255&e[t+14]|(255&e[t+15])<<8)<<8))*(5*U),d=u+=(p+=(O+=l>>>5|A)*(5*R))>>>13,d+=S*R,d+=k*L,d+=C*(5*$),d+=E*(5*B),u=(d+=I*(5*F))>>>13,d&=8191,d+=x*(5*K),d+=P*(5*D),d+=T*(5*N),d+=M*(5*j),u+=(d+=O*(5*U))>>>13,d&=8191,f=u,f+=S*U,f+=k*R,f+=C*L,f+=E*(5*$),u=(f+=I*(5*B))>>>13,f&=8191,f+=x*(5*F),f+=P*(5*K),f+=T*(5*D),f+=M*(5*N),y=u+=(f+=O*(5*j))>>>13,y+=S*j,y+=k*U,y+=C*R,y+=E*L,u=(y+=I*(5*$))>>>13,y&=8191,y+=x*(5*B),y+=P*(5*F),y+=T*(5*K),y+=M*(5*D),g=u+=(y+=O*(5*N))>>>13,g+=S*N,g+=k*j,g+=C*U,g+=E*R,u=(g+=I*L)>>>13,g&=8191,g+=x*(5*$),g+=P*(5*B),g+=T*(5*F),g+=M*(5*K),m=u+=(g+=O*(5*D))>>>13,m+=S*D,m+=k*N,m+=C*j,m+=E*U,u=(m+=I*R)>>>13,m&=8191,m+=x*L,m+=P*(5*$),m+=T*(5*B),m+=M*(5*F),v=u+=(m+=O*(5*K))>>>13,v+=S*K,v+=k*D,v+=C*N,v+=E*j,u=(v+=I*U)>>>13,v&=8191,v+=x*R,v+=P*L,v+=T*(5*$),v+=M*(5*B),w=u+=(v+=O*(5*F))>>>13,w+=S*F,w+=k*K,w+=C*D,w+=E*N,u=(w+=I*j)>>>13,w&=8191,w+=x*U,w+=P*R,w+=T*L,w+=M*(5*$),b=u+=(w+=O*(5*B))>>>13,b+=S*B,b+=k*F,b+=C*K,b+=E*D,u=(b+=I*N)>>>13,b&=8191,b+=x*j,b+=P*U,b+=T*R,b+=M*L,_=u+=(b+=O*(5*$))>>>13,_+=S*$,_+=k*B,_+=C*F,_+=E*K,u=(_+=I*D)>>>13,_&=8191,_+=x*N,_+=P*j,_+=T*U,_+=M*R,S=p=8191&(u=(u=((u+=(_+=O*L)>>>13)<<2)+u|0)+(p&=8191)|0),k=d+=u>>>=13,C=f&=8191,E=y&=8191,I=g&=8191,x=m&=8191,P=v&=8191,T=w&=8191,M=b&=8191,O=_&=8191,t+=16,n-=16;this.h[0]=S,this.h[1]=k,this.h[2]=C,this.h[3]=E,this.h[4]=I,this.h[5]=x,this.h[6]=P,this.h[7]=T,this.h[8]=M,this.h[9]=O},C.prototype.finish=function(e,t){var n,r,i,s,o=new Uint16Array(10);if(this.leftover){for(s=this.leftover,this.buffer[s++]=1;s<16;s++)this.buffer[s]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(n=this.h[1]>>>13,this.h[1]&=8191,s=2;s<10;s++)this.h[s]+=n,n=this.h[s]>>>13,this.h[s]&=8191;for(this.h[0]+=5*n,n=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=n,n=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=n,o[0]=this.h[0]+5,n=o[0]>>>13,o[0]&=8191,s=1;s<10;s++)o[s]=this.h[s]+n,n=o[s]>>>13,o[s]&=8191;for(o[9]-=8192,r=(1^n)-1,s=0;s<10;s++)o[s]&=r;for(r=~r,s=0;s<10;s++)this.h[s]=this.h[s]&r|o[s];for(this.h[0]=65535&(this.h[0]|this.h[1]<<13),this.h[1]=65535&(this.h[1]>>>3|this.h[2]<<10),this.h[2]=65535&(this.h[2]>>>6|this.h[3]<<7),this.h[3]=65535&(this.h[3]>>>9|this.h[4]<<4),this.h[4]=65535&(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14),this.h[5]=65535&(this.h[6]>>>2|this.h[7]<<11),this.h[6]=65535&(this.h[7]>>>5|this.h[8]<<8),this.h[7]=65535&(this.h[8]>>>8|this.h[9]<<5),i=this.h[0]+this.pad[0],this.h[0]=65535&i,s=1;s<8;s++)i=(this.h[s]+this.pad[s]|0)+(i>>>16)|0,this.h[s]=65535&i;e[t+0]=this.h[0]>>>0&255,e[t+1]=this.h[0]>>>8&255,e[t+2]=this.h[1]>>>0&255,e[t+3]=this.h[1]>>>8&255,e[t+4]=this.h[2]>>>0&255,e[t+5]=this.h[2]>>>8&255,e[t+6]=this.h[3]>>>0&255,e[t+7]=this.h[3]>>>8&255,e[t+8]=this.h[4]>>>0&255,e[t+9]=this.h[4]>>>8&255,e[t+10]=this.h[5]>>>0&255,e[t+11]=this.h[5]>>>8&255,e[t+12]=this.h[6]>>>0&255,e[t+13]=this.h[6]>>>8&255,e[t+14]=this.h[7]>>>0&255,e[t+15]=this.h[7]>>>8&255},C.prototype.update=function(e,t,n){var r,i;if(this.leftover){for((i=16-this.leftover)>n&&(i=n),r=0;r<i;r++)this.buffer[this.leftover+r]=e[t+r];if(n-=i,t+=i,this.leftover+=i,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(n>=16&&(i=n-n%16,this.blocks(e,t,i),t+=i,n-=i),n){for(r=0;r<n;r++)this.buffer[this.leftover+r]=e[t+r];this.leftover+=n}};var z=x,q=P,G=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function X(e,t,n,r){for(var i,s,o,a,c,h,l,u,p,d,f,y,g,m,v,w,b,_,A,S,k,C,E,I,x,P,T=new Int32Array(16),M=new Int32Array(16),O=e[0],L=e[1],R=e[2],U=e[3],j=e[4],N=e[5],D=e[6],K=e[7],F=t[0],B=t[1],$=t[2],J=t[3],H=t[4],W=t[5],Y=t[6],z=t[7],q=0;r>=128;){for(A=0;A<16;A++)S=8*A+q,T[A]=n[S+0]<<24|n[S+1]<<16|n[S+2]<<8|n[S+3],M[A]=n[S+4]<<24|n[S+5]<<16|n[S+6]<<8|n[S+7];for(A=0;A<80;A++)if(i=O,s=L,o=R,a=U,c=j,h=N,l=D,p=F,d=B,f=$,y=J,g=H,m=W,v=Y,E=65535&(C=z),I=C>>>16,x=65535&(k=K),P=k>>>16,E+=65535&(C=(H>>>14|j<<18)^(H>>>18|j<<14)^(j>>>9|H<<23)),I+=C>>>16,x+=65535&(k=(j>>>14|H<<18)^(j>>>18|H<<14)^(H>>>9|j<<23)),P+=k>>>16,E+=65535&(C=H&W^~H&Y),I+=C>>>16,x+=65535&(k=j&N^~j&D),P+=k>>>16,E+=65535&(C=G[2*A+1]),I+=C>>>16,x+=65535&(k=G[2*A]),P+=k>>>16,k=T[A%16],I+=(C=M[A%16])>>>16,x+=65535&k,P+=k>>>16,x+=(I+=(E+=65535&C)>>>16)>>>16,E=65535&(C=_=65535&E|I<<16),I=C>>>16,x=65535&(k=b=65535&x|(P+=x>>>16)<<16),P=k>>>16,E+=65535&(C=(F>>>28|O<<4)^(O>>>2|F<<30)^(O>>>7|F<<25)),I+=C>>>16,x+=65535&(k=(O>>>28|F<<4)^(F>>>2|O<<30)^(F>>>7|O<<25)),P+=k>>>16,I+=(C=F&B^F&$^B&$)>>>16,x+=65535&(k=O&L^O&R^L&R),P+=k>>>16,u=65535&(x+=(I+=(E+=65535&C)>>>16)>>>16)|(P+=x>>>16)<<16,w=65535&E|I<<16,E=65535&(C=y),I=C>>>16,x=65535&(k=a),P=k>>>16,I+=(C=_)>>>16,x+=65535&(k=b),P+=k>>>16,L=i,R=s,U=o,j=a=65535&(x+=(I+=(E+=65535&C)>>>16)>>>16)|(P+=x>>>16)<<16,N=c,D=h,K=l,O=u,B=p,$=d,J=f,H=y=65535&E|I<<16,W=g,Y=m,z=v,F=w,A%16==15)for(S=0;S<16;S++)k=T[S],E=65535&(C=M[S]),I=C>>>16,x=65535&k,P=k>>>16,k=T[(S+9)%16],E+=65535&(C=M[(S+9)%16]),I+=C>>>16,x+=65535&k,P+=k>>>16,b=T[(S+1)%16],E+=65535&(C=((_=M[(S+1)%16])>>>1|b<<31)^(_>>>8|b<<24)^(_>>>7|b<<25)),I+=C>>>16,x+=65535&(k=(b>>>1|_<<31)^(b>>>8|_<<24)^b>>>7),P+=k>>>16,b=T[(S+14)%16],I+=(C=((_=M[(S+14)%16])>>>19|b<<13)^(b>>>29|_<<3)^(_>>>6|b<<26))>>>16,x+=65535&(k=(b>>>19|_<<13)^(_>>>29|b<<3)^b>>>6),P+=k>>>16,P+=(x+=(I+=(E+=65535&C)>>>16)>>>16)>>>16,T[S]=65535&x|P<<16,M[S]=65535&E|I<<16;E=65535&(C=F),I=C>>>16,x=65535&(k=O),P=k>>>16,k=e[0],I+=(C=t[0])>>>16,x+=65535&k,P+=k>>>16,P+=(x+=(I+=(E+=65535&C)>>>16)>>>16)>>>16,e[0]=O=65535&x|P<<16,t[0]=F=65535&E|I<<16,E=65535&(C=B),I=C>>>16,x=65535&(k=L),P=k>>>16,k=e[1],I+=(C=t[1])>>>16,x+=65535&k,P+=k>>>16,P+=(x+=(I+=(E+=65535&C)>>>16)>>>16)>>>16,e[1]=L=65535&x|P<<16,t[1]=B=65535&E|I<<16,E=65535&(C=$),I=C>>>16,x=65535&(k=R),P=k>>>16,k=e[2],I+=(C=t[2])>>>16,x+=65535&k,P+=k>>>16,P+=(x+=(I+=(E+=65535&C)>>>16)>>>16)>>>16,e[2]=R=65535&x|P<<16,t[2]=$=65535&E|I<<16,E=65535&(C=J),I=C>>>16,x=65535&(k=U),P=k>>>16,k=e[3],I+=(C=t[3])>>>16,x+=65535&k,P+=k>>>16,P+=(x+=(I+=(E+=65535&C)>>>16)>>>16)>>>16,e[3]=U=65535&x|P<<16,t[3]=J=65535&E|I<<16,E=65535&(C=H),I=C>>>16,x=65535&(k=j),P=k>>>16,k=e[4],I+=(C=t[4])>>>16,x+=65535&k,P+=k>>>16,P+=(x+=(I+=(E+=65535&C)>>>16)>>>16)>>>16,e[4]=j=65535&x|P<<16,t[4]=H=65535&E|I<<16,E=65535&(C=W),I=C>>>16,x=65535&(k=N),P=k>>>16,k=e[5],I+=(C=t[5])>>>16,x+=65535&k,P+=k>>>16,P+=(x+=(I+=(E+=65535&C)>>>16)>>>16)>>>16,e[5]=N=65535&x|P<<16,t[5]=W=65535&E|I<<16,E=65535&(C=Y),I=C>>>16,x=65535&(k=D),P=k>>>16,k=e[6],I+=(C=t[6])>>>16,x+=65535&k,P+=k>>>16,P+=(x+=(I+=(E+=65535&C)>>>16)>>>16)>>>16,e[6]=D=65535&x|P<<16,t[6]=Y=65535&E|I<<16,E=65535&(C=z),I=C>>>16,x=65535&(k=K),P=k>>>16,k=e[7],I+=(C=t[7])>>>16,x+=65535&k,P+=k>>>16,P+=(x+=(I+=(E+=65535&C)>>>16)>>>16)>>>16,e[7]=K=65535&x|P<<16,t[7]=z=65535&E|I<<16,q+=128,r-=128}return r}function Z(e,t,n){var r,i=new Int32Array(8),s=new Int32Array(8),o=new Uint8Array(256),a=n;for(i[0]=1779033703,i[1]=3144134277,i[2]=1013904242,i[3]=2773480762,i[4]=1359893119,i[5]=2600822924,i[6]=528734635,i[7]=1541459225,s[0]=4089235720,s[1]=2227873595,s[2]=4271175723,s[3]=1595750129,s[4]=2917565137,s[5]=725511199,s[6]=4215389547,s[7]=327033209,X(i,s,t,n),n%=128,r=0;r<n;r++)o[r]=t[a-n+r];for(o[n]=128,o[(n=256-128*(n<112?1:0))-9]=0,f(o,n-8,a/536870912|0,a<<3),X(i,s,o,n),r=0;r<8;r++)f(e,8*r,i[r],s[r]);return 0}function V(e,n){var r=t(),i=t(),s=t(),o=t(),a=t(),c=t(),h=t(),u=t(),p=t();D(r,e[1],e[0]),D(p,n[1],n[0]),K(r,r,p),N(i,e[0],e[1]),N(p,n[0],n[1]),K(i,i,p),K(s,e[3],n[3]),K(s,s,l),K(o,e[2],n[2]),N(o,o,o),D(a,i,r),D(c,o,s),N(h,o,s),N(u,i,r),K(e[0],a,c),K(e[1],u,h),K(e[2],h,c),K(e[3],a,u)}function Q(e,t,n){var r;for(r=0;r<4;r++)O(e[r],t[r],n)}function ee(e,n){var r=t(),i=t(),s=t();B(s,n[2]),K(r,n[0],s),K(i,n[1],s),L(e,i),e[31]^=U(r)<<7}function te(e,t,n){var r,i;for(T(e[0],o),T(e[1],a),T(e[2],a),T(e[3],o),i=255;i>=0;--i)Q(e,t,r=n[i/8|0]>>(7&i)&1),V(t,e),V(e,e),Q(e,t,r)}function ne(e,n){var r=[t(),t(),t(),t()];T(r[0],u),T(r[1],p),T(r[2],a),K(r[3],u,p),te(e,r,n)}function re(e,n,i){var s,o=new Uint8Array(64),a=[t(),t(),t(),t()];for(i||r(n,32),Z(o,n,32),o[0]&=248,o[31]&=127,o[31]|=64,ne(a,o),ee(e,a),s=0;s<32;s++)n[s+32]=e[s];return 0}var ie=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function se(e,t){var n,r,i,s;for(r=63;r>=32;--r){for(n=0,i=r-32,s=r-12;i<s;++i)t[i]+=n-16*t[r]*ie[i-(r-32)],n=Math.floor((t[i]+128)/256),t[i]-=256*n;t[i]+=n,t[r]=0}for(n=0,i=0;i<32;i++)t[i]+=n-(t[31]>>4)*ie[i],n=t[i]>>8,t[i]&=255;for(i=0;i<32;i++)t[i]-=n*ie[i];for(r=0;r<32;r++)t[r+1]+=t[r]>>8,e[r]=255&t[r]}function oe(e){var t,n=new Float64Array(64);for(t=0;t<64;t++)n[t]=e[t];for(t=0;t<64;t++)e[t]=0;se(e,n)}function ae(e,n,r,i){var s,o,a=new Uint8Array(64),c=new Uint8Array(64),h=new Uint8Array(64),l=new Float64Array(64),u=[t(),t(),t(),t()];Z(a,i,32),a[0]&=248,a[31]&=127,a[31]|=64;var p=r+64;for(s=0;s<r;s++)e[64+s]=n[s];for(s=0;s<32;s++)e[32+s]=a[32+s];for(Z(h,e.subarray(32),r+32),oe(h),ne(u,h),ee(e,u),s=32;s<64;s++)e[s]=i[s];for(Z(c,e,r+64),oe(c),s=0;s<64;s++)l[s]=0;for(s=0;s<32;s++)l[s]=h[s];for(s=0;s<32;s++)for(o=0;o<32;o++)l[s+o]+=c[s]*a[o];return se(e.subarray(32),l),p}function ce(e,n,r,i){var s,c=new Uint8Array(32),l=new Uint8Array(64),u=[t(),t(),t(),t()],p=[t(),t(),t(),t()];if(r<64)return-1;if(function(e,n){var r=t(),i=t(),s=t(),c=t(),l=t(),u=t(),p=t();return T(e[2],a),j(e[1],n),F(s,e[1]),K(c,s,h),D(s,s,e[2]),N(c,e[2],c),F(l,c),F(u,l),K(p,u,l),K(r,p,s),K(r,r,c),$(r,r),K(r,r,s),K(r,r,c),K(r,r,c),K(e[0],r,c),F(i,e[0]),K(i,i,c),R(i,s)&&K(e[0],e[0],d),F(i,e[0]),K(i,i,c),R(i,s)?-1:(U(e[0])===n[31]>>7&&D(e[0],o,e[0]),K(e[3],e[0],e[1]),0)}(p,i))return-1;for(s=0;s<r;s++)e[s]=n[s];for(s=0;s<32;s++)e[s+32]=i[s];if(Z(l,e,r),oe(l),te(u,p,l),ne(p,n.subarray(32)),V(u,p),ee(c,u),r-=64,m(n,0,c,0)){for(s=0;s<r;s++)e[s]=0;return-1}for(s=0;s<r;s++)e[s]=n[s+64];return r}var he,le=64,ue=32,pe=64;function de(e,t){if(32!==e.length)throw new Error("bad key size");if(24!==t.length)throw new Error("bad nonce size")}function fe(){for(var e=0;e<arguments.length;e++)if(!(arguments[e]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function ye(e){for(var t=0;t<e.length;t++)e[t]=0}e.lowlevel={crypto_core_hsalsa20:w,crypto_stream_xor:k,crypto_stream:S,crypto_stream_salsa20_xor:_,crypto_stream_salsa20:A,crypto_onetimeauth:E,crypto_onetimeauth_verify:I,crypto_verify_16:g,crypto_verify_32:m,crypto_secretbox:x,crypto_secretbox_open:P,crypto_scalarmult:J,crypto_scalarmult_base:H,crypto_box_beforenm:Y,crypto_box_afternm:z,crypto_box:function(e,t,n,r,i,s){var o=new Uint8Array(32);return Y(o,i,s),z(e,t,n,r,o)},crypto_box_open:function(e,t,n,r,i,s){var o=new Uint8Array(32);return Y(o,i,s),q(e,t,n,r,o)},crypto_box_keypair:W,crypto_hash:Z,crypto_sign:ae,crypto_sign_keypair:re,crypto_sign_open:ce,crypto_secretbox_KEYBYTES:32,crypto_secretbox_NONCEBYTES:24,crypto_secretbox_ZEROBYTES:32,crypto_secretbox_BOXZEROBYTES:16,crypto_scalarmult_BYTES:32,crypto_scalarmult_SCALARBYTES:32,crypto_box_PUBLICKEYBYTES:32,crypto_box_SECRETKEYBYTES:32,crypto_box_BEFORENMBYTES:32,crypto_box_NONCEBYTES:24,crypto_box_ZEROBYTES:32,crypto_box_BOXZEROBYTES:16,crypto_sign_BYTES:le,crypto_sign_PUBLICKEYBYTES:ue,crypto_sign_SECRETKEYBYTES:pe,crypto_sign_SEEDBYTES:32,crypto_hash_BYTES:64,gf:t,D:h,L:ie,pack25519:L,unpack25519:j,M:K,A:N,S:F,Z:D,pow2523:$,add:V,set25519:T,modL:se,scalarmult:te,scalarbase:ne},e.randomBytes=function(e){var t=new Uint8Array(e);return r(t,e),t},e.secretbox=function(e,t,n){fe(e,t,n),de(n,t);for(var r=new Uint8Array(32+e.length),i=new Uint8Array(r.length),s=0;s<e.length;s++)r[s+32]=e[s];return x(i,r,r.length,t,n),i.subarray(16)},e.secretbox.open=function(e,t,n){fe(e,t,n),de(n,t);for(var r=new Uint8Array(16+e.length),i=new Uint8Array(r.length),s=0;s<e.length;s++)r[s+16]=e[s];return r.length<32||0!==P(i,r,r.length,t,n)?null:i.subarray(32)},e.secretbox.keyLength=32,e.secretbox.nonceLength=24,e.secretbox.overheadLength=16,e.scalarMult=function(e,t){if(fe(e,t),32!==e.length)throw new Error("bad n size");if(32!==t.length)throw new Error("bad p size");var n=new Uint8Array(32);return J(n,e,t),n},e.scalarMult.base=function(e){if(fe(e),32!==e.length)throw new Error("bad n size");var t=new Uint8Array(32);return H(t,e),t},e.scalarMult.scalarLength=32,e.scalarMult.groupElementLength=32,e.box=function(t,n,r,i){var s=e.box.before(r,i);return e.secretbox(t,n,s)},e.box.before=function(e,t){fe(e,t),function(e,t){if(32!==e.length)throw new Error("bad public key size");if(32!==t.length)throw new Error("bad secret key size")}(e,t);var n=new Uint8Array(32);return Y(n,e,t),n},e.box.after=e.secretbox,e.box.open=function(t,n,r,i){var s=e.box.before(r,i);return e.secretbox.open(t,n,s)},e.box.open.after=e.secretbox.open,e.box.keyPair=function(){var e=new Uint8Array(32),t=new Uint8Array(32);return W(e,t),{publicKey:e,secretKey:t}},e.box.keyPair.fromSecretKey=function(e){if(fe(e),32!==e.length)throw new Error("bad secret key size");var t=new Uint8Array(32);return H(t,e),{publicKey:t,secretKey:new Uint8Array(e)}},e.box.publicKeyLength=32,e.box.secretKeyLength=32,e.box.sharedKeyLength=32,e.box.nonceLength=24,e.box.overheadLength=e.secretbox.overheadLength,e.sign=function(e,t){if(fe(e,t),t.length!==pe)throw new Error("bad secret key size");var n=new Uint8Array(le+e.length);return ae(n,e,e.length,t),n},e.sign.open=function(e,t){if(fe(e,t),t.length!==ue)throw new Error("bad public key size");var n=new Uint8Array(e.length),r=ce(n,e,e.length,t);if(r<0)return null;for(var i=new Uint8Array(r),s=0;s<i.length;s++)i[s]=n[s];return i},e.sign.detached=function(t,n){for(var r=e.sign(t,n),i=new Uint8Array(le),s=0;s<i.length;s++)i[s]=r[s];return i},e.sign.detached.verify=function(e,t,n){if(fe(e,t,n),t.length!==le)throw new Error("bad signature size");if(n.length!==ue)throw new Error("bad public key size");var r,i=new Uint8Array(le+e.length),s=new Uint8Array(le+e.length);for(r=0;r<le;r++)i[r]=t[r];for(r=0;r<e.length;r++)i[r+le]=e[r];return ce(s,i,i.length,n)>=0},e.sign.keyPair=function(){var e=new Uint8Array(ue),t=new Uint8Array(pe);return re(e,t),{publicKey:e,secretKey:t}},e.sign.keyPair.fromSecretKey=function(e){if(fe(e),e.length!==pe)throw new Error("bad secret key size");for(var t=new Uint8Array(ue),n=0;n<t.length;n++)t[n]=e[32+n];return{publicKey:t,secretKey:new Uint8Array(e)}},e.sign.keyPair.fromSeed=function(e){if(fe(e),32!==e.length)throw new Error("bad seed size");for(var t=new Uint8Array(ue),n=new Uint8Array(pe),r=0;r<32;r++)n[r]=e[r];return re(t,n,!0),{publicKey:t,secretKey:n}},e.sign.publicKeyLength=ue,e.sign.secretKeyLength=pe,e.sign.seedLength=32,e.sign.signatureLength=le,e.hash=function(e){fe(e);var t=new Uint8Array(64);return Z(t,e,e.length),t},e.hash.hashLength=64,e.verify=function(e,t){return fe(e,t),0!==e.length&&0!==t.length&&e.length===t.length&&0===y(e,0,t,0,e.length)},e.setPRNG=function(e){r=e},(he="undefined"!=typeof self?self.crypto||self.msCrypto:null)&&he.getRandomValues?e.setPRNG((function(e,t){var n,r=new Uint8Array(t);for(n=0;n<t;n+=65536)he.getRandomValues(r.subarray(n,n+Math.min(t-n,65536)));for(n=0;n<t;n++)e[n]=r[n];ye(r)})):(he=n(402))&&he.randomBytes&&e.setPRNG((function(e,t){var n,r=he.randomBytes(t);for(n=0;n<t;n++)e[n]=r[n];ye(r)}))}(e.exports?e.exports:self.nacl=self.nacl||{})},402:()=>{}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var s=t[r]={exports:{}};return e[r](s,s.exports,n),s.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var r={};return(()=>{"use strict";n.d(r,{default:()=>E});class e{}e.ROOT="/",e.CONFIG_FILE_NAME="adk-services.json",e.BASE_URL="",e.WS_URL="/v1/connect",e.SSE_URL="/v1/connect/sse",e.LPOLL="/v1/longpoll",e.CONFIG_JSON_PATH="/adk-services.json";class t{constructor(e){this.credentials=e,this.authData={AccessToken:"",RefreshToken:""}}static getInstance(e){if(!t.instance){if(!e)throw Error("Forbidden");t.instance=new t(e)}return t.instance}async authenticate(t){var n,r;if(!t&&this.authData.AccessToken&&!this.isTokenExpired(this.authData.AccessToken))return this.authData;if(this.credentials.getCredentials){const e=this.credentials.getCredentials();this.credentials.AccessToken=e.AccessToken,this.credentials.ClientID=e.ClientID,this.credentials.ClientSecret=e.ClientSecret,this.credentials.OrgTitle=e.OrgTitle,this.credentials.Environment=e.Environment,this.credentials.ProjectKey=e.ProjectKey}const{AccessToken:i,ClientID:s,ClientSecret:o,OrgTitle:a,Environment:c,ProjectKey:h}=this.credentials;if(!a||!c||!h)throw new Error("OrgTitle, Environment, and ProjectKey are required for authentication.");if(!(i||s&&o))throw new Error("ClientID and ClientSecret are required when AccessToken is not present.");const l={"Client-Id":this.credentials.ClientID,"Client-Secret":this.credentials.ClientSecret,"X-Org":this.credentials.OrgTitle,Environment:this.credentials.Environment,ProjectKey:this.credentials.ProjectKey};this.credentials.AccessToken&&(l["T-pass"]=this.credentials.AccessToken),(null===(n=this.credentials.config)||void 0===n?void 0:n.AuthToken)&&(l["X-pass"]=null===(r=this.credentials.config)||void 0===r?void 0:r.AuthToken);const u=await fetch(`${e.BASE_URL}/auth/token`,{method:"POST",headers:l});if(!u.ok){const e=await u.json().catch((()=>null)),t=(null==e?void 0:e.message)||`HTTP ${u.status} ${u.statusText}`;throw new Error(t)}const{data:p}=await u.json();return this.authData={AccessToken:p.access_token,RefreshToken:p.refresh_token},this.authData}getAuthData(){return this.authData}getCredentials(){return this.credentials}decodeJwtPayload(e){const[,t=""]=e.split("."),n=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"=");let r;return r="undefined"!=typeof window&&"function"==typeof window.atob?atob(n):Buffer.from(n,"base64").toString("utf8"),JSON.parse(r)}isTokenExpired(e){try{const{exp:t}=this.decodeJwtPayload(e);return"number"!=typeof t||t<Math.floor(Date.now()/1e3)-100}catch(e){return!0}}}var i=n(52),s=n.n(i);class o{static generateKeyPair(){const e=s().box.keyPair();return{publicKey:o._encodeBase64(e.publicKey),privateKey:o._encodeBase64(e.secretKey)}}static async encrypt(e,t,n){const r=o._decodeBase64(t),i=o._decodeBase64(n);if(r.length!==s().box.publicKeyLength||i.length!==s().box.secretKeyLength)throw new Error("Invalid key length");const a=o._encodeUTF8(e),c=s().randomBytes(s().box.nonceLength),h=s().box(a,c,r,i),l=new Uint8Array(c.length+h.length);return l.set(c,0),l.set(h,c.length),o._encodeBase64(l)}static async decrypt(e,t,n){const r=o._decodeBase64(e);if(r.length<s().box.nonceLength)throw new Error("Data too short");const i=r.subarray(0,s().box.nonceLength),a=r.subarray(s().box.nonceLength),c=o._decodeBase64(t),h=o._decodeBase64(n),l=s().box.open(a,i,c,h);if(!l)throw new Error("Decryption failed: authentication check failed");return o._decodeUTF8(l)}static _encodeBase64(e){let t="";for(let n=0;n<e.byteLength;n++)t+=String.fromCharCode(e[n]);return btoa(t)}static _decodeBase64(e){const t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}static _encodeUTF8(e){return(new TextEncoder).encode(e)}static _decodeUTF8(e){return(new TextDecoder).decode(e)}}var a=n(735);const c=a;async function h(e,t,n){return new Promise((async(r,i)=>{await n.wait();try{const s="subscribe"==t?"channel-subscribe":"channel-presence";n.pushForSecureLine(s,{channel:e});let{channelConfig:o,snapshot:a,channelNamespace:c}=await n.listenForSecureLine(s,(e=>("not-OK"==e.status&&i(e.error),!0)));o&&r({channelName:e,channelNamespace:c,channelType:o.TypeofChannel,snapshot:a})}catch(e){i(e)}}))}class l extends a{constructor(e,t,n="subscribe"){super(),this.isSubscribed=!1,this.isListening=!1,this.messageBuffer=new Map,this.pendingAcks=new Map,this.ACK_TIMEOUT=5e4,this.messageCount=0,this.websocketHandler=t,this.channelConfig=e,"subscribe"===n?this.isSubscribed=!0:"presence"===n&&(this.isListening=!0)}async validateSubscription(e){try{if(["art_config","art_secure"].includes(this.channelConfig.channelName))return;await h(this.channelConfig.channelName,e,this.websocketHandler).then((e=>{this.channelConfig=e})).catch((e=>{console.error(`${e}`)}))}catch(e){console.error(`${e}`)}}async fetchPresence(e){if(await this.presence(),!this.isListening)throw new Error("Not subscribed for presence");let t=null;this.on("art_presence",(({usernames:n,error:r})=>{r||(t=n,e(n))})),e(t)}acknowledge(e,t){if("targeted"!==this.channelConfig.channelType||"secure"!==this.channelConfig.channelName)return;const{id:n,from:r,channel:i,namespace:s,to:o,pipeline_id:a,attempt_id:c,interceptor_name:h,to_username:l,ref_id:u}=e;if(["art_config","art_secure","art_presence"].includes(i))return;const p={channel:i,namespace:s,id:n,ref_id:u,from:r,to_username:l,to:o,return_flag:t,pipeline_id:a,interceptor_name:h,attempt_id:c};this.websocketHandler.sendMessage(JSON.stringify(p))}async handleMessageAcks(e,t,n){if("SA"===t&&n.ref_id){const e=this.pendingAcks.get(n.ref_id);if(e)return clearTimeout(e.timer),e.resolve(n.ref_id),void this.pendingAcks.delete(n.ref_id)}}async subscribe(){["art_config","art_secure"].includes(this.channelConfig.channelName)||(this.isSubscribed=!0,await h(this.channelConfig.channelName,"subscribe",this.websocketHandler).then((e=>{this.channelConfig=e})).catch((e=>{console.error(`${e}`),this.isSubscribed=!1})))}reconnect(){"art_config"!==this.channelConfig.channelName&&"art_secure"!==this.channelConfig.channelName&&(this.isListening&&(this.validateSubscription("presence"),this.presence()),this.isSubscribed&&this.subscribe())}async presence(){["art_config","art_secure"].includes(this.channelConfig.channelName)||(this.isListening=!0,await h(this.channelConfig.channelName,"presence",this.websocketHandler).then((e=>{this.channelConfig=e,this.push("art_presence",{})})).catch((e=>{throw this.isListening=!1,new Error(`${e}`)})))}async push(e,t,n){var r,i,s;await this.websocketHandler.wait();const o=this.websocketHandler.getConnection();let a,c=null!==(r=null==n?void 0:n.to)&&void 0!==r?r:[],h=JSON.stringify(t);if(!("secure"!=this.channelConfig.channelType&&"targeted"!=this.channelConfig.channelType||c&&1===c.length||"art_presence"===e))throw new Error("Exactly one user must be specified for sending message.");if("secure"==this.channelConfig.channelType&&"art_presence"!==e){this.websocketHandler.pushForSecureLine("secured_public_key",{username:c[0]});let e=await this.websocketHandler.listenForSecureLine("secured_public_key",(e=>{if(e.username!==c[0])return!1;if("unsuccessfull"==e.status)throw Error(e.error);return!0}));h=await this.websocketHandler.encrypt(h,e.public_key)}let l=Promise.resolve(void 0);["art_config","art_secure","art_presence"].includes(this.channelConfig.channelName)||(this.messageCount++,a=`${null===(i=this.websocketHandler.getConnection())||void 0===i?void 0:i.ConnectionId}_${this.channelConfig.channelName}_${this.messageCount}`,l=new Promise(((e,t)=>{const n=setTimeout((()=>{this.pendingAcks.delete(a),t(new Error("ACK timeout"))}),this.ACK_TIMEOUT);"targeted"===this.channelConfig.channelType||"secure"===this.channelConfig.channelName?this.pendingAcks.set(a,{resolve:e,reject:t,timer:n}):e(a)})));const u={from:null!==(s=null==o?void 0:o.ConnectionId)&&void 0!==s?s:"",to:c,channel:this.channelConfig.channelName+(this.channelConfig.channelNamespace?`:${this.channelConfig.channelNamespace}`:""),event:e,content:h,ref_id:a};return this.websocketHandler.sendMessage(JSON.stringify(u)),l}handleMessage(e,t){}}class u extends l{constructor(e,t,n="subscribe"){super(e,t,n)}listen(e){this.messageBuffer.forEach(((t,n)=>t.forEach((t=>{e({event:n,content:t.content}),this.acknowledge(t,"CA")})))),this.messageBuffer.clear(),this.on("all",e)}bind(e,t){(this.messageBuffer.get(e)||[]).forEach((e=>{t(e.content),this.acknowledge(e,"CA")})),this.messageBuffer.delete(e),this.on(e,t)}remove(e,t){t?this.off(e,t):this.removeAllListeners(e),this.messageBuffer.delete(e)}async push(e,t,n){return super.push(e,t,n)}async handleMessage(e,t){const{return_flag:n}=t;if("SA"==n)return void this.handleMessageAcks(e,n,t);if(this.acknowledge(t,"MA"),"secure"==this.channelConfig.channelType){this.websocketHandler.pushForSecureLine("secured_public_key",{username:t.from_username});let e=await this.websocketHandler.listenForSecureLine("secured_public_key",(e=>{if(e.username!==t.from_username)return!1;if("unsuccessfull"==e.status)throw Error(e.error);return!0}));t.data=await this.websocketHandler.decrypt(t.data,e.public_key)}let r={};if(r=t.hasOwnProperty("data")?JSON.parse(t.data):JSON.parse(t),"art_presence"===e)this.emit("art_presence",r);else if(this.isSubscribed&&"art_presence"!=e){const n=this.listeners(e).length>0,i=this.listeners("all").length>0;if(n||i)n&&this.emit(e,r),i&&this.emit("all",{event:e,content:r}),this.acknowledge(t,"CA");else{const n=this.messageBuffer.get(e)||[],{id:i,from:s,channel:o,to:a,pipeline_id:c,attempt_id:h,interceptor_name:l,to_username:u}=t;n.push({id:i,from:s,channel:o,to:a,pipeline_id:c,attempt_id:h,interceptor_name:l,to_username:u,content:r}),this.messageBuffer.set(e,n)}}}}class p extends a{constructor(e,t,n){super(),this.interceptor=e,this.fn=t,this.websocketHandler=n}async validateInterception(){return await async function(e,t){return new Promise((async(n,r)=>{await t.wait();try{t.pushForSecureLine("interceptor-subscribe",{interceptor:e});let{interceptorConfig:i}=await t.listenForSecureLine("interceptor-subscribe",(e=>("not-OK"==e.status&&r(e.error),!0)));n(i)}catch(e){r(e)}}))}(this.interceptor,this.websocketHandler).then((e=>{this.interceptorData=e})).catch((e=>{throw e}))}reconnect(){console.log("reconnecting interceptor "+this.interceptor),this.validateInterception()}createResponse(e,t,n,r,i,s,o,a,c,h,l){return{...e,channel:r,namespace:i,event:s,id:t,ref_id:n,return_flag:h,pipeline_id:o,interceptor_name:a,attempt_id:c,content:JSON.stringify(l)}}execute(e){this.acknowledge(e);const{id:t,channel:n,namespace:r,from:i,to:s,event:o,interceptor_name:a,pipeline_id:c,attempt_id:h,ref_id:l,data:u}=e,p={channel:n,namespace:r,event:o,interceptor_name:a,from:i,to:s};this.fn(e,(e=>{var i;if(null===e||"object"!=typeof e)return void console.error("Invalid data: Expected a JSON object or array of objects.",e);(e.hasOwnProperty("attempt_id")||e.hasOwnProperty("pipeline_id"))&&(e=null!==(i=e.data)&&void 0!==i?i:{});const s=this.createResponse(p,t,l,n,r,o,c,a,h,"resolve",e);this.websocketHandler.sendMessage(JSON.stringify(s))}),(e=>{if("string"!=typeof e)throw new Error("Error must be a string");const i={rawData:u,error:e},s=this.createResponse(p,t,l,n,r,o,c,a,h,"reject",i);this.websocketHandler.sendMessage(JSON.stringify(s))}))}acknowledge(e){const{id:t,from:n,channel:r,namespace:i,to:s,pipeline_id:o,attempt_id:a,interceptor_name:c,ref_id:h,data:l}=e,u={channel:r,namespace:i,id:t,ref_id:h,from:n,to:s,return_flag:"IA",pipeline_id:o,interceptor_name:c,attempt_id:a,content:JSON.stringify(l)};this.websocketHandler.sendMessage(JSON.stringify(u))}async handleMessage(e,t){try{t.data=JSON.parse(t.data),this.execute(t)}catch(e){throw e}}}class d{constructor(e){var t,n,r,i;this.isRunning=!1,this.endpoint=e.endpoint,this.connectionId=e.initialConnectionId,this.onMessages=e.onMessages,this.onError=e.onError,this.retryDelayMs=null!==(t=e.retryDelayMs)&&void 0!==t?t:1e3,this.connectionId=e.initialConnectionId,this.getAuthHeaders=e.getAuthHeaders,this.onMessages=e.onMessages,this.onError=e.onError,this.retryDelayMs=null!==(n=e.retryDelayMs)&&void 0!==n?n:1e3,this.emptyPollDelayMs=null!==(r=e.emptyPollDelayMs)&&void 0!==r?r:500,this.maxEmptyPollDelayMs=null!==(i=e.maxEmptyPollDelayMs)&&void 0!==i?i:5e3}start(e){this.isRunning||(e&&(this.connectionId=e),this.isRunning=!0,this.pollLoop())}stop(){var e;this.isRunning=!1,null===(e=this.abortController)||void 0===e||e.abort()}async pollLoop(){var t;let n=this.emptyPollDelayMs;for(;this.isRunning;){this.abortController=new AbortController;const r=this.abortController.signal;try{const t=new URL(e.LPOLL,window.location.origin);this.connectionId&&t.searchParams.set("connection_id",this.connectionId);const i=await this.getAuthHeaders(),s=await fetch(t.toString(),{signal:r,headers:i});if(204===s.status){await this.delay(n),n=Math.min(2*n,this.maxEmptyPollDelayMs);continue}if(!s.ok)throw new Error(`Longpoll error ${s.status}`);n=this.emptyPollDelayMs;const o=await s.json();this.connectionId||(this.connectionId=o.connection_id),o.messages&&o.messages.length&&this.onMessages(o.messages)}catch(e){if("AbortError"===e.name)return;null===(t=this.onError)||void 0===t||t.call(this,e),await this.delay(this.retryDelayMs)}}}delay(e){return new Promise((t=>setTimeout(t,e)))}}function f(e){return e&&"object"==typeof e&&"id"in e&&"meta"in e}function y(e){if(e&&"object"==typeof e){if("index"in e)return e;if("entries"in e)return e}throw new Error("Value is not a container")}function g(){return`${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function m(e){return"string"==typeof e?"string":"number"==typeof e?"number":"boolean"==typeof e?"boolean":Array.isArray(e)?"array":"object"}function v(e="client"){return{updatedAt:Date.now(),version:1,replicaId:e}}function w(e,t="client"){if("string"==typeof e||"number"==typeof e||"boolean"==typeof e)return e;if(Array.isArray(e)){const n={entries:{},head:null,meta:v(t)};let r=null;for(const i of e){const e=g(),s={id:e,key:e,type:m(i),value:w(i,t),meta:{...v(t),after:r}};n.entries[e]=s,r=e}return n.head=function(e){const t=Object.keys(e.entries).filter((t=>{var n;return null===(null!==(n=e.entries[t].meta.after)&&void 0!==n?n:null)}));return 0===t.length?null:(t.sort(),t[0])}(n),n}const n={};for(const[r,i]of Object.entries(e))n[r]={id:g(),key:r,type:m(i),value:w(i,t),meta:v(t)};return{index:n,meta:v(t)}}const b=e=>"string"==typeof e&&/^\d+$/.test(e);function _(e,t){return e.meta.updatedAt!==t.meta.updatedAt?e.meta.updatedAt-t.meta.updatedAt:e.meta.replicaId!==t.meta.replicaId?e.meta.replicaId<t.meta.replicaId?-1:1:e.id<t.id?-1:e.id>t.id?1:0}function A(e){var t;const n=new Map;for(const r in e.entries){const i=e.entries[r],s=null!==(t=i.meta.after)&&void 0!==t?t:null;n.has(s)||n.set(s,[]),