UNPKG

@arealtimetech/adk-js

Version:

JavaScript ADK to interact with the A Realtime Tech Platform.

1 lines 89.5 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={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]),d=t([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),u=t([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),p=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,d=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,u=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,p=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,_=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,w=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,b=s,A=o,I=a,k=c,E=h,C=l,S=d,T=u,x=p,P=f,R=y,M=g,O=m,U=v,D=_,L=w,N=0;N<20;N+=2)b^=(i=(O^=(i=(x^=(i=(E^=(i=b+O|0)<<7|i>>>25)+b|0)<<9|i>>>23)+E|0)<<13|i>>>19)+x|0)<<18|i>>>14,C^=(i=(A^=(i=(U^=(i=(P^=(i=C+A|0)<<7|i>>>25)+C|0)<<9|i>>>23)+P|0)<<13|i>>>19)+U|0)<<18|i>>>14,R^=(i=(S^=(i=(I^=(i=(D^=(i=R+S|0)<<7|i>>>25)+R|0)<<9|i>>>23)+D|0)<<13|i>>>19)+I|0)<<18|i>>>14,L^=(i=(M^=(i=(T^=(i=(k^=(i=L+M|0)<<7|i>>>25)+L|0)<<9|i>>>23)+k|0)<<13|i>>>19)+T|0)<<18|i>>>14,b^=(i=(k^=(i=(I^=(i=(A^=(i=b+k|0)<<7|i>>>25)+b|0)<<9|i>>>23)+A|0)<<13|i>>>19)+I|0)<<18|i>>>14,C^=(i=(E^=(i=(T^=(i=(S^=(i=C+E|0)<<7|i>>>25)+C|0)<<9|i>>>23)+S|0)<<13|i>>>19)+T|0)<<18|i>>>14,R^=(i=(P^=(i=(x^=(i=(M^=(i=R+P|0)<<7|i>>>25)+R|0)<<9|i>>>23)+M|0)<<13|i>>>19)+x|0)<<18|i>>>14,L^=(i=(D^=(i=(U^=(i=(O^=(i=L+D|0)<<7|i>>>25)+L|0)<<9|i>>>23)+O|0)<<13|i>>>19)+U|0)<<18|i>>>14;b=b+s|0,A=A+o|0,I=I+a|0,k=k+c|0,E=E+h|0,C=C+l|0,S=S+d|0,T=T+u|0,x=x+p|0,P=P+f|0,R=R+y|0,M=M+g|0,O=O+m|0,U=U+v|0,D=D+_|0,L=L+w|0,e[0]=b>>>0&255,e[1]=b>>>8&255,e[2]=b>>>16&255,e[3]=b>>>24&255,e[4]=A>>>0&255,e[5]=A>>>8&255,e[6]=A>>>16&255,e[7]=A>>>24&255,e[8]=I>>>0&255,e[9]=I>>>8&255,e[10]=I>>>16&255,e[11]=I>>>24&255,e[12]=k>>>0&255,e[13]=k>>>8&255,e[14]=k>>>16&255,e[15]=k>>>24&255,e[16]=E>>>0&255,e[17]=E>>>8&255,e[18]=E>>>16&255,e[19]=E>>>24&255,e[20]=C>>>0&255,e[21]=C>>>8&255,e[22]=C>>>16&255,e[23]=C>>>24&255,e[24]=S>>>0&255,e[25]=S>>>8&255,e[26]=S>>>16&255,e[27]=S>>>24&255,e[28]=T>>>0&255,e[29]=T>>>8&255,e[30]=T>>>16&255,e[31]=T>>>24&255,e[32]=x>>>0&255,e[33]=x>>>8&255,e[34]=x>>>16&255,e[35]=x>>>24&255,e[36]=P>>>0&255,e[37]=P>>>8&255,e[38]=P>>>16&255,e[39]=P>>>24&255,e[40]=R>>>0&255,e[41]=R>>>8&255,e[42]=R>>>16&255,e[43]=R>>>24&255,e[44]=M>>>0&255,e[45]=M>>>8&255,e[46]=M>>>16&255,e[47]=M>>>24&255,e[48]=O>>>0&255,e[49]=O>>>8&255,e[50]=O>>>16&255,e[51]=O>>>24&255,e[52]=U>>>0&255,e[53]=U>>>8&255,e[54]=U>>>16&255,e[55]=U>>>24&255,e[56]=D>>>0&255,e[57]=D>>>8&255,e[58]=D>>>16&255,e[59]=D>>>24&255,e[60]=L>>>0&255,e[61]=L>>>8&255,e[62]=L>>>16&255,e[63]=L>>>24&255}(e,t,n,r)}function _(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,d=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,u=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,p=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,_=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,w=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,b=0;b<20;b+=2)s^=(i=(m^=(i=(p^=(i=(h^=(i=s+m|0)<<7|i>>>25)+s|0)<<9|i>>>23)+h|0)<<13|i>>>19)+p|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=(d^=(i=(a^=(i=(_^=(i=y+d|0)<<7|i>>>25)+y|0)<<9|i>>>23)+_|0)<<13|i>>>19)+a|0)<<18|i>>>14,w^=(i=(g^=(i=(u^=(i=(c^=(i=w+g|0)<<7|i>>>25)+w|0)<<9|i>>>23)+c|0)<<13|i>>>19)+u|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=(u^=(i=(d^=(i=l+h|0)<<7|i>>>25)+l|0)<<9|i>>>23)+d|0)<<13|i>>>19)+u|0)<<18|i>>>14,y^=(i=(f^=(i=(p^=(i=(g^=(i=y+f|0)<<7|i>>>25)+y|0)<<9|i>>>23)+g|0)<<13|i>>>19)+p|0)<<18|i>>>14,w^=(i=(_^=(i=(v^=(i=(m^=(i=w+_|0)<<7|i>>>25)+w|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]=w>>>0&255,e[13]=w>>>8&255,e[14]=w>>>16&255,e[15]=w>>>24&255,e[16]=d>>>0&255,e[17]=d>>>8&255,e[18]=d>>>16&255,e[19]=d>>>24&255,e[20]=u>>>0&255,e[21]=u>>>8&255,e[22]=u>>>16&255,e[23]=u>>>24&255,e[24]=p>>>0&255,e[25]=p>>>8&255,e[26]=p>>>16&255,e[27]=p>>>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 w=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function b(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,w),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,w),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,w),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,w),o=0;o<n;o++)e[t+o]=c[o];return 0}function I(e,t,n,r,i){var s=new Uint8Array(32);_(s,r,i,w);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);_(a,s,o,w);for(var c=new Uint8Array(8),h=0;h<8;h++)c[h]=s[h+16];return b(e,t,n,r,i,c,a)}var E=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 C(e,t,n,r,i,s){var o=new E(s);return o.update(n,r,i),o.finish(e,t),0}function S(e,t,n,r,i,s){var o=new Uint8Array(16);return C(o,0,n,r,i,s),g(e,t,o,0)}function T(e,t,n,r,i){var s;if(n<32)return-1;for(k(e,0,t,0,n,r,i),C(e,16,e,32,n-32,e),s=0;s<16;s++)e[s]=0;return 0}function x(e,t,n,r,i){var s,o=new Uint8Array(32);if(n<32)return-1;if(I(o,0,32,r,i),0!==S(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 P(e,t){var n;for(n=0;n<16;n++)e[n]=0|t[n]}function R(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 M(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 O(e,n){var r,i,s,o=t(),a=t();for(r=0;r<16;r++)a[r]=n[r];for(R(a),R(a),R(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,M(a,o,1-s)}for(r=0;r<16;r++)e[2*r]=255&a[r],e[2*r+1]=a[r]>>8}function U(e,t){var n=new Uint8Array(32),r=new Uint8Array(32);return O(n,e),O(r,t),m(n,0,r,0)}function D(e){var t=new Uint8Array(32);return O(t,e),1&t[0]}function L(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 j(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,d=0,u=0,p=0,f=0,y=0,g=0,m=0,v=0,_=0,w=0,b=0,A=0,I=0,k=0,E=0,C=0,S=0,T=0,x=0,P=0,R=0,M=0,O=0,U=0,D=0,L=n[0],N=n[1],j=n[2],K=n[3],$=n[4],B=n[5],F=n[6],H=n[7],J=n[8],q=n[9],W=n[10],Y=n[11],z=n[12],X=n[13],G=n[14],Z=n[15];s+=(r=t[0])*L,o+=r*N,a+=r*j,c+=r*K,h+=r*$,l+=r*B,d+=r*F,u+=r*H,p+=r*J,f+=r*q,y+=r*W,g+=r*Y,m+=r*z,v+=r*X,_+=r*G,w+=r*Z,o+=(r=t[1])*L,a+=r*N,c+=r*j,h+=r*K,l+=r*$,d+=r*B,u+=r*F,p+=r*H,f+=r*J,y+=r*q,g+=r*W,m+=r*Y,v+=r*z,_+=r*X,w+=r*G,b+=r*Z,a+=(r=t[2])*L,c+=r*N,h+=r*j,l+=r*K,d+=r*$,u+=r*B,p+=r*F,f+=r*H,y+=r*J,g+=r*q,m+=r*W,v+=r*Y,_+=r*z,w+=r*X,b+=r*G,A+=r*Z,c+=(r=t[3])*L,h+=r*N,l+=r*j,d+=r*K,u+=r*$,p+=r*B,f+=r*F,y+=r*H,g+=r*J,m+=r*q,v+=r*W,_+=r*Y,w+=r*z,b+=r*X,A+=r*G,I+=r*Z,h+=(r=t[4])*L,l+=r*N,d+=r*j,u+=r*K,p+=r*$,f+=r*B,y+=r*F,g+=r*H,m+=r*J,v+=r*q,_+=r*W,w+=r*Y,b+=r*z,A+=r*X,I+=r*G,k+=r*Z,l+=(r=t[5])*L,d+=r*N,u+=r*j,p+=r*K,f+=r*$,y+=r*B,g+=r*F,m+=r*H,v+=r*J,_+=r*q,w+=r*W,b+=r*Y,A+=r*z,I+=r*X,k+=r*G,E+=r*Z,d+=(r=t[6])*L,u+=r*N,p+=r*j,f+=r*K,y+=r*$,g+=r*B,m+=r*F,v+=r*H,_+=r*J,w+=r*q,b+=r*W,A+=r*Y,I+=r*z,k+=r*X,E+=r*G,C+=r*Z,u+=(r=t[7])*L,p+=r*N,f+=r*j,y+=r*K,g+=r*$,m+=r*B,v+=r*F,_+=r*H,w+=r*J,b+=r*q,A+=r*W,I+=r*Y,k+=r*z,E+=r*X,C+=r*G,S+=r*Z,p+=(r=t[8])*L,f+=r*N,y+=r*j,g+=r*K,m+=r*$,v+=r*B,_+=r*F,w+=r*H,b+=r*J,A+=r*q,I+=r*W,k+=r*Y,E+=r*z,C+=r*X,S+=r*G,T+=r*Z,f+=(r=t[9])*L,y+=r*N,g+=r*j,m+=r*K,v+=r*$,_+=r*B,w+=r*F,b+=r*H,A+=r*J,I+=r*q,k+=r*W,E+=r*Y,C+=r*z,S+=r*X,T+=r*G,x+=r*Z,y+=(r=t[10])*L,g+=r*N,m+=r*j,v+=r*K,_+=r*$,w+=r*B,b+=r*F,A+=r*H,I+=r*J,k+=r*q,E+=r*W,C+=r*Y,S+=r*z,T+=r*X,x+=r*G,P+=r*Z,g+=(r=t[11])*L,m+=r*N,v+=r*j,_+=r*K,w+=r*$,b+=r*B,A+=r*F,I+=r*H,k+=r*J,E+=r*q,C+=r*W,S+=r*Y,T+=r*z,x+=r*X,P+=r*G,R+=r*Z,m+=(r=t[12])*L,v+=r*N,_+=r*j,w+=r*K,b+=r*$,A+=r*B,I+=r*F,k+=r*H,E+=r*J,C+=r*q,S+=r*W,T+=r*Y,x+=r*z,P+=r*X,R+=r*G,M+=r*Z,v+=(r=t[13])*L,_+=r*N,w+=r*j,b+=r*K,A+=r*$,I+=r*B,k+=r*F,E+=r*H,C+=r*J,S+=r*q,T+=r*W,x+=r*Y,P+=r*z,R+=r*X,M+=r*G,O+=r*Z,_+=(r=t[14])*L,w+=r*N,b+=r*j,A+=r*K,I+=r*$,k+=r*B,E+=r*F,C+=r*H,S+=r*J,T+=r*q,x+=r*W,P+=r*Y,R+=r*z,M+=r*X,O+=r*G,U+=r*Z,w+=(r=t[15])*L,o+=38*(A+=r*j),a+=38*(I+=r*K),c+=38*(k+=r*$),h+=38*(E+=r*B),l+=38*(C+=r*F),d+=38*(S+=r*H),u+=38*(T+=r*J),p+=38*(x+=r*q),f+=38*(P+=r*W),y+=38*(R+=r*Y),g+=38*(M+=r*z),m+=38*(O+=r*X),v+=38*(U+=r*G),_+=38*(D+=r*Z),s=(r=(s+=38*(b+=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)),d=(r=d+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)),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)),_=(r=_+i+65535)-65536*(i=Math.floor(r/65536)),w=(r=w+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)),d=(r=d+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)),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)),_=(r=_+i+65535)-65536*(i=Math.floor(r/65536)),w=(r=w+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]=d,e[7]=u,e[8]=p,e[9]=f,e[10]=y,e[11]=g,e[12]=m,e[13]=v,e[14]=_,e[15]=w}function $(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--)$(i,i),2!==r&&4!==r&&K(i,i,n);for(r=0;r<16;r++)e[r]=i[r]}function F(e,n){var r,i=t();for(r=0;r<16;r++)i[r]=n[r];for(r=250;r>=0;r--)$(i,i),1!==r&&K(i,i,n);for(r=0;r<16;r++)e[r]=i[r]}function H(e,n,r){var i,s,o=new Uint8Array(32),a=new Float64Array(80),h=t(),l=t(),d=t(),u=t(),p=t(),f=t();for(s=0;s<31;s++)o[s]=n[s];for(o[31]=127&n[31]|64,o[0]&=248,L(a,r),s=0;s<16;s++)l[s]=a[s],u[s]=h[s]=d[s]=0;for(h[0]=u[0]=1,s=254;s>=0;--s)M(h,l,i=o[s>>>3]>>>(7&s)&1),M(d,u,i),N(p,h,d),j(h,h,d),N(d,l,u),j(l,l,u),$(u,p),$(f,h),K(h,d,h),K(d,l,p),N(p,h,d),j(h,h,d),$(l,h),j(d,u,f),K(h,d,c),N(h,h,u),K(d,d,h),K(h,u,f),K(u,l,a),$(l,p),M(h,l,i),M(d,u,i);for(s=0;s<16;s++)a[s+16]=h[s],a[s+32]=d[s],a[s+48]=l[s],a[s+64]=u[s];var y=a.subarray(32),g=a.subarray(16);return B(y,y),K(g,g,y),O(e,g),0}function J(e,t){return H(e,t,s)}function q(e,t){return r(t,32),J(e,t)}function W(e,t,n){var r=new Uint8Array(32);return H(r,n,t),_(e,i,r,w)}E.prototype.blocks=function(e,t,n){for(var r,i,s,o,a,c,h,l,d,u,p,f,y,g,m,v,_,w,b,A=this.fin?0:2048,I=this.h[0],k=this.h[1],E=this.h[2],C=this.h[3],S=this.h[4],T=this.h[5],x=this.h[6],P=this.h[7],R=this.h[8],M=this.h[9],O=this.r[0],U=this.r[1],D=this.r[2],L=this.r[3],N=this.r[4],j=this.r[5],K=this.r[6],$=this.r[7],B=this.r[8],F=this.r[9];n>=16;)u=d=0,u+=(I+=8191&(r=255&e[t+0]|(255&e[t+1])<<8))*O,u+=(k+=8191&(r>>>13|(i=255&e[t+2]|(255&e[t+3])<<8)<<3))*(5*F),u+=(E+=8191&(i>>>10|(s=255&e[t+4]|(255&e[t+5])<<8)<<6))*(5*B),u+=(C+=8191&(s>>>7|(o=255&e[t+6]|(255&e[t+7])<<8)<<9))*(5*$),d=(u+=(S+=8191&(o>>>4|(a=255&e[t+8]|(255&e[t+9])<<8)<<12))*(5*K))>>>13,u&=8191,u+=(T+=a>>>1&8191)*(5*j),u+=(x+=8191&(a>>>14|(c=255&e[t+10]|(255&e[t+11])<<8)<<2))*(5*N),u+=(P+=8191&(c>>>11|(h=255&e[t+12]|(255&e[t+13])<<8)<<5))*(5*L),u+=(R+=8191&(h>>>8|(l=255&e[t+14]|(255&e[t+15])<<8)<<8))*(5*D),p=d+=(u+=(M+=l>>>5|A)*(5*U))>>>13,p+=I*U,p+=k*O,p+=E*(5*F),p+=C*(5*B),d=(p+=S*(5*$))>>>13,p&=8191,p+=T*(5*K),p+=x*(5*j),p+=P*(5*N),p+=R*(5*L),d+=(p+=M*(5*D))>>>13,p&=8191,f=d,f+=I*D,f+=k*U,f+=E*O,f+=C*(5*F),d=(f+=S*(5*B))>>>13,f&=8191,f+=T*(5*$),f+=x*(5*K),f+=P*(5*j),f+=R*(5*N),y=d+=(f+=M*(5*L))>>>13,y+=I*L,y+=k*D,y+=E*U,y+=C*O,d=(y+=S*(5*F))>>>13,y&=8191,y+=T*(5*B),y+=x*(5*$),y+=P*(5*K),y+=R*(5*j),g=d+=(y+=M*(5*N))>>>13,g+=I*N,g+=k*L,g+=E*D,g+=C*U,d=(g+=S*O)>>>13,g&=8191,g+=T*(5*F),g+=x*(5*B),g+=P*(5*$),g+=R*(5*K),m=d+=(g+=M*(5*j))>>>13,m+=I*j,m+=k*N,m+=E*L,m+=C*D,d=(m+=S*U)>>>13,m&=8191,m+=T*O,m+=x*(5*F),m+=P*(5*B),m+=R*(5*$),v=d+=(m+=M*(5*K))>>>13,v+=I*K,v+=k*j,v+=E*N,v+=C*L,d=(v+=S*D)>>>13,v&=8191,v+=T*U,v+=x*O,v+=P*(5*F),v+=R*(5*B),_=d+=(v+=M*(5*$))>>>13,_+=I*$,_+=k*K,_+=E*j,_+=C*N,d=(_+=S*L)>>>13,_&=8191,_+=T*D,_+=x*U,_+=P*O,_+=R*(5*F),w=d+=(_+=M*(5*B))>>>13,w+=I*B,w+=k*$,w+=E*K,w+=C*j,d=(w+=S*N)>>>13,w&=8191,w+=T*L,w+=x*D,w+=P*U,w+=R*O,b=d+=(w+=M*(5*F))>>>13,b+=I*F,b+=k*B,b+=E*$,b+=C*K,d=(b+=S*j)>>>13,b&=8191,b+=T*N,b+=x*L,b+=P*D,b+=R*U,I=u=8191&(d=(d=((d+=(b+=M*O)>>>13)<<2)+d|0)+(u&=8191)|0),k=p+=d>>>=13,E=f&=8191,C=y&=8191,S=g&=8191,T=m&=8191,x=v&=8191,P=_&=8191,R=w&=8191,M=b&=8191,t+=16,n-=16;this.h[0]=I,this.h[1]=k,this.h[2]=E,this.h[3]=C,this.h[4]=S,this.h[5]=T,this.h[6]=x,this.h[7]=P,this.h[8]=R,this.h[9]=M},E.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},E.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 Y=T,z=x,X=[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 G(e,t,n,r){for(var i,s,o,a,c,h,l,d,u,p,f,y,g,m,v,_,w,b,A,I,k,E,C,S,T,x,P=new Int32Array(16),R=new Int32Array(16),M=e[0],O=e[1],U=e[2],D=e[3],L=e[4],N=e[5],j=e[6],K=e[7],$=t[0],B=t[1],F=t[2],H=t[3],J=t[4],q=t[5],W=t[6],Y=t[7],z=0;r>=128;){for(A=0;A<16;A++)I=8*A+z,P[A]=n[I+0]<<24|n[I+1]<<16|n[I+2]<<8|n[I+3],R[A]=n[I+4]<<24|n[I+5]<<16|n[I+6]<<8|n[I+7];for(A=0;A<80;A++)if(i=M,s=O,o=U,a=D,c=L,h=N,l=j,u=$,p=B,f=F,y=H,g=J,m=q,v=W,C=65535&(E=Y),S=E>>>16,T=65535&(k=K),x=k>>>16,C+=65535&(E=(J>>>14|L<<18)^(J>>>18|L<<14)^(L>>>9|J<<23)),S+=E>>>16,T+=65535&(k=(L>>>14|J<<18)^(L>>>18|J<<14)^(J>>>9|L<<23)),x+=k>>>16,C+=65535&(E=J&q^~J&W),S+=E>>>16,T+=65535&(k=L&N^~L&j),x+=k>>>16,C+=65535&(E=X[2*A+1]),S+=E>>>16,T+=65535&(k=X[2*A]),x+=k>>>16,k=P[A%16],S+=(E=R[A%16])>>>16,T+=65535&k,x+=k>>>16,T+=(S+=(C+=65535&E)>>>16)>>>16,C=65535&(E=b=65535&C|S<<16),S=E>>>16,T=65535&(k=w=65535&T|(x+=T>>>16)<<16),x=k>>>16,C+=65535&(E=($>>>28|M<<4)^(M>>>2|$<<30)^(M>>>7|$<<25)),S+=E>>>16,T+=65535&(k=(M>>>28|$<<4)^($>>>2|M<<30)^($>>>7|M<<25)),x+=k>>>16,S+=(E=$&B^$&F^B&F)>>>16,T+=65535&(k=M&O^M&U^O&U),x+=k>>>16,d=65535&(T+=(S+=(C+=65535&E)>>>16)>>>16)|(x+=T>>>16)<<16,_=65535&C|S<<16,C=65535&(E=y),S=E>>>16,T=65535&(k=a),x=k>>>16,S+=(E=b)>>>16,T+=65535&(k=w),x+=k>>>16,O=i,U=s,D=o,L=a=65535&(T+=(S+=(C+=65535&E)>>>16)>>>16)|(x+=T>>>16)<<16,N=c,j=h,K=l,M=d,B=u,F=p,H=f,J=y=65535&C|S<<16,q=g,W=m,Y=v,$=_,A%16==15)for(I=0;I<16;I++)k=P[I],C=65535&(E=R[I]),S=E>>>16,T=65535&k,x=k>>>16,k=P[(I+9)%16],C+=65535&(E=R[(I+9)%16]),S+=E>>>16,T+=65535&k,x+=k>>>16,w=P[(I+1)%16],C+=65535&(E=((b=R[(I+1)%16])>>>1|w<<31)^(b>>>8|w<<24)^(b>>>7|w<<25)),S+=E>>>16,T+=65535&(k=(w>>>1|b<<31)^(w>>>8|b<<24)^w>>>7),x+=k>>>16,w=P[(I+14)%16],S+=(E=((b=R[(I+14)%16])>>>19|w<<13)^(w>>>29|b<<3)^(b>>>6|w<<26))>>>16,T+=65535&(k=(w>>>19|b<<13)^(b>>>29|w<<3)^w>>>6),x+=k>>>16,x+=(T+=(S+=(C+=65535&E)>>>16)>>>16)>>>16,P[I]=65535&T|x<<16,R[I]=65535&C|S<<16;C=65535&(E=$),S=E>>>16,T=65535&(k=M),x=k>>>16,k=e[0],S+=(E=t[0])>>>16,T+=65535&k,x+=k>>>16,x+=(T+=(S+=(C+=65535&E)>>>16)>>>16)>>>16,e[0]=M=65535&T|x<<16,t[0]=$=65535&C|S<<16,C=65535&(E=B),S=E>>>16,T=65535&(k=O),x=k>>>16,k=e[1],S+=(E=t[1])>>>16,T+=65535&k,x+=k>>>16,x+=(T+=(S+=(C+=65535&E)>>>16)>>>16)>>>16,e[1]=O=65535&T|x<<16,t[1]=B=65535&C|S<<16,C=65535&(E=F),S=E>>>16,T=65535&(k=U),x=k>>>16,k=e[2],S+=(E=t[2])>>>16,T+=65535&k,x+=k>>>16,x+=(T+=(S+=(C+=65535&E)>>>16)>>>16)>>>16,e[2]=U=65535&T|x<<16,t[2]=F=65535&C|S<<16,C=65535&(E=H),S=E>>>16,T=65535&(k=D),x=k>>>16,k=e[3],S+=(E=t[3])>>>16,T+=65535&k,x+=k>>>16,x+=(T+=(S+=(C+=65535&E)>>>16)>>>16)>>>16,e[3]=D=65535&T|x<<16,t[3]=H=65535&C|S<<16,C=65535&(E=J),S=E>>>16,T=65535&(k=L),x=k>>>16,k=e[4],S+=(E=t[4])>>>16,T+=65535&k,x+=k>>>16,x+=(T+=(S+=(C+=65535&E)>>>16)>>>16)>>>16,e[4]=L=65535&T|x<<16,t[4]=J=65535&C|S<<16,C=65535&(E=q),S=E>>>16,T=65535&(k=N),x=k>>>16,k=e[5],S+=(E=t[5])>>>16,T+=65535&k,x+=k>>>16,x+=(T+=(S+=(C+=65535&E)>>>16)>>>16)>>>16,e[5]=N=65535&T|x<<16,t[5]=q=65535&C|S<<16,C=65535&(E=W),S=E>>>16,T=65535&(k=j),x=k>>>16,k=e[6],S+=(E=t[6])>>>16,T+=65535&k,x+=k>>>16,x+=(T+=(S+=(C+=65535&E)>>>16)>>>16)>>>16,e[6]=j=65535&T|x<<16,t[6]=W=65535&C|S<<16,C=65535&(E=Y),S=E>>>16,T=65535&(k=K),x=k>>>16,k=e[7],S+=(E=t[7])>>>16,T+=65535&k,x+=k>>>16,x+=(T+=(S+=(C+=65535&E)>>>16)>>>16)>>>16,e[7]=K=65535&T|x<<16,t[7]=Y=65535&C|S<<16,z+=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,G(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),G(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(),d=t(),u=t();j(r,e[1],e[0]),j(u,n[1],n[0]),K(r,r,u),N(i,e[0],e[1]),N(u,n[0],n[1]),K(i,i,u),K(s,e[3],n[3]),K(s,s,l),K(o,e[2],n[2]),N(o,o,o),j(a,i,r),j(c,o,s),N(h,o,s),N(d,i,r),K(e[0],a,c),K(e[1],d,h),K(e[2],h,c),K(e[3],a,d)}function Q(e,t,n){var r;for(r=0;r<4;r++)M(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),O(e,i),e[31]^=D(r)<<7}function te(e,t,n){var r,i;for(P(e[0],o),P(e[1],a),P(e[2],a),P(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()];P(r[0],d),P(r[1],u),P(r[2],a),K(r[3],d,u),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),d=[t(),t(),t(),t()];Z(a,i,32),a[0]&=248,a[31]&=127,a[31]|=64;var u=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(d,h),ee(e,d),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),u}function ce(e,n,r,i){var s,c=new Uint8Array(32),l=new Uint8Array(64),d=[t(),t(),t(),t()],u=[t(),t(),t(),t()];if(r<64)return-1;if(function(e,n){var r=t(),i=t(),s=t(),c=t(),l=t(),d=t(),u=t();return P(e[2],a),L(e[1],n),$(s,e[1]),K(c,s,h),j(s,s,e[2]),N(c,e[2],c),$(l,c),$(d,l),K(u,d,l),K(r,u,s),K(r,r,c),F(r,r),K(r,r,s),K(r,r,c),K(r,r,c),K(e[0],r,c),$(i,e[0]),K(i,i,c),U(i,s)&&K(e[0],e[0],p),$(i,e[0]),K(i,i,c),U(i,s)?-1:(D(e[0])===n[31]>>7&&j(e[0],o,e[0]),K(e[3],e[0],e[1]),0)}(u,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(d,u,l),ne(u,n.subarray(32)),V(d,u),ee(c,d),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=64,le=32,de=64;function ue(e,t){if(32!==e.length)throw new Error("bad key size");if(24!==t.length)throw new Error("bad nonce size")}function pe(){for(var e=0;e<arguments.length;e++)if(!(arguments[e]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function fe(e){for(var t=0;t<e.length;t++)e[t]=0}e.lowlevel={crypto_core_hsalsa20:_,crypto_stream_xor:k,crypto_stream:I,crypto_stream_salsa20_xor:b,crypto_stream_salsa20:A,crypto_onetimeauth:C,crypto_onetimeauth_verify:S,crypto_verify_16:g,crypto_verify_32:m,crypto_secretbox:T,crypto_secretbox_open:x,crypto_scalarmult:H,crypto_scalarmult_base:J,crypto_box_beforenm:W,crypto_box_afternm:Y,crypto_box:function(e,t,n,r,i,s){var o=new Uint8Array(32);return W(o,i,s),Y(e,t,n,r,o)},crypto_box_open:function(e,t,n,r,i,s){var o=new Uint8Array(32);return W(o,i,s),z(e,t,n,r,o)},crypto_box_keypair:q,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:he,crypto_sign_PUBLICKEYBYTES:le,crypto_sign_SECRETKEYBYTES:de,crypto_sign_SEEDBYTES:32,crypto_hash_BYTES:64,gf:t,D:h,L:ie,pack25519:O,unpack25519:L,M:K,A:N,S:$,Z:j,pow2523:F,add:V,set25519:P,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){pe(e,t,n),ue(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 T(i,r,r.length,t,n),i.subarray(16)},e.secretbox.open=function(e,t,n){pe(e,t,n),ue(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!==x(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(pe(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 H(n,e,t),n},e.scalarMult.base=function(e){if(pe(e),32!==e.length)throw new Error("bad n size");var t=new Uint8Array(32);return J(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){pe(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 W(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 q(e,t),{publicKey:e,secretKey:t}},e.box.keyPair.fromSecretKey=function(e){if(pe(e),32!==e.length)throw new Error("bad secret key size");var t=new Uint8Array(32);return J(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(pe(e,t),t.length!==de)throw new Error("bad secret key size");var n=new Uint8Array(he+e.length);return ae(n,e,e.length,t),n},e.sign.open=function(e,t){if(pe(e,t),t.length!==le)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(he),s=0;s<i.length;s++)i[s]=r[s];return i},e.sign.detached.verify=function(e,t,n){if(pe(e,t,n),t.length!==he)throw new Error("bad signature size");if(n.length!==le)throw new Error("bad public key size");var r,i=new Uint8Array(he+e.length),s=new Uint8Array(he+e.length);for(r=0;r<he;r++)i[r]=t[r];for(r=0;r<e.length;r++)i[r+he]=e[r];return ce(s,i,i.length,n)>=0},e.sign.keyPair=function(){var e=new Uint8Array(le),t=new Uint8Array(de);return re(e,t),{publicKey:e,secretKey:t}},e.sign.keyPair.fromSecretKey=function(e){if(pe(e),e.length!==de)throw new Error("bad secret key size");for(var t=new Uint8Array(le),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(pe(e),32!==e.length)throw new Error("bad seed size");for(var t=new Uint8Array(le),n=new Uint8Array(de),r=0;r<32;r++)n[r]=e[r];return re(t,n,!0),{publicKey:t,secretKey:n}},e.sign.publicKeyLength=le,e.sign.secretKeyLength=de,e.sign.seedLength=32,e.sign.signatureLength=he,e.hash=function(e){pe(e);var t=new Uint8Array(64);return Z(t,e,e.length),t},e.hash.hashLength=64,e.verify=function(e,t){return pe(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},function(){var t="undefined"!=typeof self?self.crypto||self.msCrypto:null;t&&t.getRandomValues?e.setPRNG(function(e,n){var r,i=new Uint8Array(n);for(r=0;r<n;r+=65536)t.getRandomValues(i.subarray(r,r+Math.min(n-r,65536)));for(r=0;r<n;r++)e[r]=i[r];fe(i)}):(t=n(402))&&t.randomBytes&&e.setPRNG(function(e,n){var r,i=t.randomBytes(n);for(r=0;r<n;r++)e[r]=i[r];fe(i)})}()}(e.exports?e.exports:self.nacl=self.nacl||{})},402:()=>{},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],d=arguments.length;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),d){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(d-1);h<d;h++)c[h-1]=arguments[h];l.fn.apply(l.context,c)}else{var u,p=l.length;for(h=0;h<p;h++)switch(l[h].once&&this.removeListener(e,l[h].fn,void 0,!0),d){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(u=1,c=new Array(d-1);u<d;u++)c[u-1]=arguments[u];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}},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:()=>U});const e=new Set(["agent_output","agent_error","human_input_request","agent_wait","planner_correction"]);class t{constructor(e){this.thread=e,this.refId="",this.latestHumanInputRef=null,this.humanInputTimer=null,this.closed=!1,this.donePromise=new Promise((e,t)=>{this.resolveDone=e,this.rejectDone=t})}_setRefId(e){this.refId=e}_push(e){if(!this.closed)switch(e.event){case"human_input_request":{const t=e.content;this.latestHumanInputRef=t.ref_id||t.reply_to||null,this.clearHumanInputTimer();const n=t.timeout;"number"==typeof n&&n>0&&(this.humanInputTimer=setTimeout(()=>{if(this.closed)return;const e={type:"agent_error_response",status:"error",code:"HUMAN_INPUT_TIMEOUT",message:`No response received within ${n}s for human_input_request.`,details:{prompt:t.prompt,timeout:n},thread_id:t.thread_id||"",ref_id:"",agent_id:t.agent_id||"",reply_to:this.latestHumanInputRef||""};this.closed=!0,this.rejectDone(e),this.thread._closeRun(this)},1e3*n)),this.thread._fireRequestFeedback(t,this);break}case"agent_output":this.clearHumanInputTimer(),this.closed=!0,this.resolveDone(e.content),this.thread._closeRun(this);break;case"agent_error":this.clearHumanInputTimer(),this.closed=!0,this.rejectDone(e.content),this.thread._closeRun(this)}}clearHumanInputTimer(){null!==this.humanInputTimer&&(clearTimeout(this.humanInputTimer),this.humanInputTimer=null)}done(){return this.donePromise}async sendFeedback(e){const t=this.latestHumanInputRef;if(!t)throw new Error("Run.sendFeedback: no pending human_input_request to respond to.");this.latestHumanInputRef=null,this.clearHumanInputTimer(),await this.thread._sendReply(e,t)}_close(e="Run closed before terminal event"){this.closed||(this.clearHumanInputTimer(),this.closed=!0,this.rejectDone(new Error(e)))}isClosed(){return this.closed}}class i{constructor(e){this.userListeners=[],this.feedbackRequestHandlers=[],this.activeRun=null,this.agent=e,this.threadId=this.generateThreadId()}generateThreadId(){return"undefined"!=typeof crypto&&"function"==typeof crypto.randomUUID?crypto.randomUUID():`thread_${Date.now()}_${Math.random().toString(36).slice(2,10)}`}ensureMasterListener(){return this.masterListenerPromise||(this.masterListenerPromise=(async()=>{(await this.agent._getSubscription()).listen(e=>this._dispatch(e))})()),this.masterListenerPromise}_dispatch(t){var n,r,i;let s=t&&"object"==typeof t&&"event"in t&&"content"in t?t:{event:"agent_output",content:null!=t?t:{}};if("error"===s.event||"transport_error"===s.event){const e=null!==(n=s.content)&&void 0!==n?n:{};s={event:"agent_error",content:{type:"agent_error_response",status:"error",code:"TRANSPORT_ERROR",message:"object"==typeof e?null!==(i=null!==(r=e.message)&&void 0!==r?r:e.error)&&void 0!==i?i:"WebSocket error":String(e),details:e,thread_id:this.threadId,ref_id:"",agent_id:this.agent.agentId,reply_to:""}}}var o;if(o=s,e.has(o.event)||"undefined"==typeof console||console.warn(`[adk] unknown agent event "${s.event}" — passing through untyped. Add it to AGENT_EVENTS in agentic/events.ts to type it.`),this.activeRun)try{this.activeRun._push(s)}catch(o){"undefined"!=typeof console&&console.error("[adk] active run dispatch failed:",o)}for(const e of this.userListeners)try{e(s)}catch(o){"undefined"!=typeof console&&console.error("[adk] user listen callback threw:",o)}}async listen(e){await this.ensureMasterListener(),this.userListeners.push(e)}feedbackRequest(e){this.feedbackRequestHandlers.push(e)}_fireRequestFeedback(e,t){for(const n of this.feedbackRequestHandlers)try{const r=n(e,t);r&&"function"==typeof r.then&&r.catch(e=>{"undefined"!=typeof console&&console.error("[adk] onHumanInput handler rejected:",e)})}catch(e){"undefined"!=typeof console&&console.error("[adk] onHumanInput handler threw:",e)}}_closeRun(e){this.activeRun===e&&(this.activeRun=null)}async _sendReply(e,t){const n=await this.agent._getSubscription(),r={user_input:e,thread_id:this.threadId,reply_id:t},i=await n.push("user_reply",r);return"string"==typeof i?i:""}async run(e,n){await this.ensureMasterListener(),this.activeRun&&!this.activeRun.isClosed()&&("undefined"!=typeof console&&console.warn("[adk] starting new run while previous run is still active — closing previous"),this.activeRun._close("Superseded by new run on the same thread"));const r=new t(this);this.activeRun=r;const i=await this.agent._getSubscription(),s=(null==n?void 0:n.reply_id)?"user_reply":"user_input",o={user_input:e,thread_id:this.threadId};(null==n?void 0:n.reply_id)&&(o.reply_id=n.reply_id);const a=await i.push(s,o);return r._setRefId("string"==typeof a?a:""),r}}class s{constructor(e){this.socket=e}connect(){return this.subscribePromise||(this.subscribePromise=this.socket.subscribe(this.channelName()).then(e=>(this.subscription=e,this.subscription))),this}async _getSubscription(){return this.subscription?this.subscription:(this.subscribePromise||this.connect(),this.subscribePromise)}}class o extends s{constructor(e,t){super(t),this.agentId=e}channelName(){return`agent_com_${this.agentId}`}thread(){return new i(this)}}class a extends s{constructor(e,t){super(t),this.orchestratorId=e}channelName(){return`orch_com_${this.orchestratorId}`}async thread(e){return(await this._getSubscription())._threadUnchecked(e)}}class c{}c.ROOT="/",c.CONFIG_FILE_NAME="adk-services.json",c.BASE_URL="",c.WS_URL="/v1/connect",c.SSE_URL="/v1/connect/sse",c.LPOLL="/v1/longpoll",c.CONFIG_JSON_PATH="/adk-services.json";class h{constructor(e){this.credentials=e,this.authData={AccessToken:"",RefreshToken:""}}static getInstance(e){if(!h.instance){if(!e)throw Error("Forbidden");h.instance=new h(e)}return h.instance}async authenticate(e){if(!e&&this.authData.AccessToken&&!this.isTokenExpired(this.authData.AccessToken))return this.authData;const{OrgTitle:t,Environment:n,ProjectKey:r}=this.credentials;if(!t||!n||!r)throw new Error("OrgTitle, Environment, and ProjectKey are required for authentication.");return this.getRefreshTokenExpiryInfo(this.authData.RefreshToken).expired?await this.generateAuthToken():await this.refreshAuthToken()}async generateAuthToken(){var e,t;const{AccessToken:n,ClientID:r,ClientSecret:i,OrgTitle:s,Environment:o,ProjectKey:a}=this.credentials;if(!(n||r&&i))throw new Error("ClientID and ClientSecret are required when AccessToken is not present.");const h={"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&&(h["T-pass"]=this.credentials.AccessToken),(null===(e=this.credentials.config)||void 0===e?void 0:e.AuthToken)&&(h["X-pass"]=null===(t=this.credentials.config)||void 0===t?void 0:t.AuthToken);const l=await fetch(`${c.BASE_URL}/auth/token`,{method:"POST",headers:h});if(!l.ok){const e=await l.json().catch(()=>null),t=(null==e?void 0:e.message)||`HTTP ${l.status} ${l.statusText}`;throw new Error(t)}const{data:d}=await l.json();return this.authData={AccessToken:d.access_token,RefreshToken:d.refresh_token},this.authData}async refreshAuthToken(){var e,t;const{AccessToken:n,ClientID:r}=this.credentials;if(!n&&!r)throw new Error("ClientID is required when AccessToken is not present.");const i={"X-Org":this.credentials.OrgTitle,Environment:this.credentials.Environment,ProjectKey:this.credentials.ProjectKey};this.credentials.ClientID&&(i["Client-Id"]=this.credentials.ClientID),this.credentials.AccessToken&&(i["T-pass"]=this.credentials.AccessToken),(null===(e=this.credentials.config)||void 0===e?void 0:e.AuthToken)&&(i["X-pass"]=null===(t=this.credentials.config)||void 0===t?void 0:t.AuthToken);const s=await fetch(`${c.BASE_URL}/auth/token/refresh`,{method:"POST",headers:i,body:JSON.stringify({refresh_token:this.authData.RefreshToken})});if(!s.ok){let e=null;try{e=await s.json()}catch(t){e=null}if(500===s.status&&"Failed to get WebSocket backend"===(null==e?void 0:e.error))throw new Error((null==e?void 0:e.error)||"Internal server error");const t=await s.json().catch(()=>null),n=(null==t?void 0:t.message)||`HTTP ${s.status} ${s.statusText}`;throw new Error(n)}const{data:o}=await s.json();return this.authData={AccessToken:o.access_token,RefreshToken:o.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;if("undefined"!=typeof Buffer)r=Buffer.from(n,"base64").toString("utf8");else{if("undefined"==typeof window||"function"!=typeof window.atob)throw new Error("No base64 decoder available in this environment.");r=atob(n)}return 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}}getRefreshTokenExpiryInfo(e){const t=e.split(".")[1],n=Number(t);if(!n)return{expired:!0,exp:null,remaining:0};const r=Math.floor(Date.now()/1e3);return{expired:r>=n,exp:n,remaining:n-r}}}var l=n(52),d=n.n(l);class u{static generateKeyPair(){const e=d().box.keyPair();return{publicKey:u._encodeBase64(e.publicKey),privateKey:u._encodeBase64(e.secretKey)}}static async encrypt(e,t,n){const r=u._decodeBase64(t),i=u._decodeBase64(n);if(r.length!==d().box.publicKeyLength||i.length!==d().box.secretKeyLength)throw new Error("Invalid key length");const s=u._encodeUTF8(e),o=d().randomBytes(d().box.nonceLength),a=d().box(s,o,r,i),c=new Uint8Array(o.length+a.length);return c.set(o,0),c.set(a,o.length),u._encodeBase64(c)}static async decrypt(e,t,n){const r=u._decodeBase64(e);if(r.length<d().box.nonceLength)throw new Error("Data too short");const i=r.subarray(0,d().box.nonceLength),s=r.subarray(d().box.nonceLength),o=u._decodeBase64(t),a=u._decodeBase64(n),c=d().box.open(s,i,o,a);if(!c)throw new Error("Decryption failed: authentication check failed");return u._decodeUTF8(c)}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 p=n(735);const f=p;class y{constructor(e,t){this.attachedEvents=new Set,this.disposed=!1,this.subscription=e,this.threadId=null!=t?t:this.generateThreadId()}generateThreadId(){return"undefined"!=typeof crypto&&"function"==typeof crypto.randomUUID?crypto.randomUUID():`thread_${Date.now()}_${Math.random().toString(36).slice(2,10)}`}ensureActive(){if(this.disposed)throw new Error(`OrchestratorThread ${this.threadId} has been disposed`)}async push(e,t,n){this.ensureActive();const r={...null!=n?n:{},ThreadID:this.threadId};this.subscription.push(e,t,r)}listen(e){this.ensureActive(),this.subscription.attachThreadListener(this.threadId,e),this.attachedEvents.add("all")}bind(e,t){this.ensureActive(),this.subscription.attachThreadBind(this.threadId,e,t),this.attachedEvents.add(e)}remove(e,t){this.disposed||(this.subscription.detachThreadListener(this.threadId,e,t),t||this.attachedEvents.delete(e))}dispose(){if(!this.disposed){this.disposed=!0;for(const e of this.attachedEvents)this.subscription.detachThreadListener(this.threadId,e);this.attachedEvents.clear(),this.subscription._unregisterThread(this.threadId)}}isDisposed(){return this.disposed}getId(){return this.threadId}}async function g(e,t,n){return new Promise(async(r,i)=>{var s;await n.wait();try{const o="subscribe"==t?"channel-subscribe":"channel-presence",{data:a}=await n.pushForSecureLine(o,{channel:e},!0);"not-OK"==a.status&&i(a.error);let{channelConfig:c,snapshot:h,presenceUsers:l,channel:d,channelNamespace:u,subscriptionID:p}=a;c&&r({channelName:d,channelNamespace:u,channelType:c.TypeofChannel,snapshot:h,presenceUsers:l,subscriptionID:p,orchestratorEnabled:null!==(s=c.IsInterceptorEnabled)&&void 0!==s&&s})}catch(e){i(e)}})}async function m(e,t,n,r){return new Promise(async(i,s)=>{await r.wait();try{const o="subscribe"==n?"channel-unsubscribe":"presence-unsubscribe",{data:a}=await r.pushForSecureLine(o,{channel:e,subscriptionID:t},!0);"not-OK"==a.status&&s(a.error),i(!0)}catch(e){s(e)}})}class v extends p{constructor(e,t,n,r="subscribe"){super(),this.isSubscribed=!1,this.isListening=!1,this.messageBuffer=new Map,this.threadBuffers=new Map,this.pendingAcks=new Map,this.ACK_TIMEOUT=5e4,this.messageCount=0,this.presenceUsers=[],this.connectionID=e,this.websocketHandler=n,this.channelConfig=t,this.presenceUsers=this.channelConfig.presenceUsers,"subscribe"===r?this.isSubscribed=!0:"presence"===r&&(this.isListening=!0)}async validateSubscription(e){try{if(["art_config","art_secure"].includes(this.channelConfig.channelName))return;let t=this.channelConfig.channelName;this.channelConfig.channelNamespace&&(t+=":"+this.channelConfig.channelNamespace),await g(t,e,this.websocketHandler).then(t=>{this.channelConfig=t,"presence"===e&&(this.isListening=!0)}).catch(e=>{console.error(`${e}`)})}catch(e){console.error(`${e}`)}}async fetchPresence(e,t={unique:!0}){var n;let r=null!==(n=this.presenceUsers)&&void 0!==n?n:[];if(r.length>0&&e(r),await this.validateSubscription("presence"),!this.isListening)throw new Error("Not subscribed for presence");return this.on("art_presence",({usernames:n,error:i})=>{if(!i){r=n,this.presenceUsers=n;let i=[];(null==t?void 0:t.unique)?n.forEach(e=>{let[t,n]=e.split(":");i.indexOf(t)<0&&i.push(t)}):i=n,e(i)}}),this.push("art_presence",{}),{unsubscribe:async()=>{var e;await m(this.channelConfig.channelName,null!==(e=this.channelConfig.subscriptionID)&&void 0!==e?e:"","presence",this.websocketHandler).then(e=>{e||console.error(`Failed to unsubscribe from channel ${this.channelConfig.channelName}`)})}}}acknowledge(e,t){if("targeted"!==this.channelConfig.channelType&&"secure"!==this.channelConfig.channelType)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:d}=e;if(["art_config","art_secure","art_presence"].includes(i))return;const u={channel:i,namespace:s,id:n,ref_id:d,from:r,to_username:l,to:o,return_flag:t,pipeline_id:a,interceptor_name:h,attempt_id:c};this.websocketHandler.sendMessage(JSON.stringify(u))}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(){if(["art_config","art_secure"].includes(this.channelConfig.channelName))return async()=>{};this.isSubscribed=!0,await g(