"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2901],{84663:function(a,b,c){c.d(b,{"$":function(){return e6},A:function(){return aK},B:function(){return bw},C:function(){return ac},D:function(){return bc},E:function(){return aF},F:function(){return n},G:function(){return gA},H:function(){return gD},I:function(){return eV},J:function(){return ei},K:function(){return eu},L:function(){return ab},M:function(){return ek},N:function(){return eh},O:function(){return en},P:function(){return u},Q:function(){return e$},R:function(){return e_},S:function(){return W},T:function(){return ez},U:function(){return eZ},V:function(){return fY},W:function(){return bi},X:function(){return e1},Y:function(){return eJ},Z:function(){return bh},"_":function(){return i},a:function(){return K},"a$":function(){return ba},a0:function(){return bA},a1:function(){return F},a2:function(){return N},a3:function(){return $},a4:function(){return s},a5:function(){return L},a6:function(){return bs},a7:function(){return fB},a8:function(){return t},a9:function(){return w},aA:function(){return gr},aB:function(){return gu},aC:function(){return gv},aD:function(){return gs},aE:function(){return gt},aF:function(){return ge},aI:function(){return gh},aJ:function(){return aO},aK:function(){return eK},aL:function(){return J},aM:function(){return eU},aN:function(){return bj},aO:function(){return a7},aP:function(){return f1},aQ:function(){return R},aR:function(){return an},aS:function(){return a9},aT:function(){return bD},aU:function(){return fa},aV:function(){return bC},aW:function(){return aP},aX:function(){return bH},aY:function(){return gg},aZ:function(){return a8},a_:function(){return aT},ab:function(){return fP},ac:function(){return aa},ad:function(){return x},ae:function(){return r},af:function(){return er},ah:function(){return fS},ai:function(){return ad},ak:function(){return eq},am:function(){return bq},an:function(){return br},ao:function(){return aS},ap:function(){return gf},aq:function(){return fZ},ar:function(){return ai},at:function(){return af},au:function(){return ag},av:function(){return ak},aw:function(){return aj},ax:function(){return al},ay:function(){return gx},az:function(){return gq},b:function(){return j},b0:function(){return ah},b1:function(){return gc},b2:function(){return aW},b3:function(){return eG},b4:function(){return S},b5:function(){return bE},b6:function(){return f9},b7:function(){return X},b8:function(){return h},b9:function(){return O},bE:function(){return a6},ba:function(){return P},bb:function(){return f4},bc:function(){return f5},bd:function(){return f3},be:function(){return f8},bf:function(){return f7},bg:function(){return f6},bh:function(){return f2},bi:function(){return a0},bj:function(){return ao},bk:function(){return aH},bl:function(){return fE},bm:function(){return aX},bo:function(){return ae},bp:function(){return U},bq:function(){return aQ},br:function(){return Q},bs:function(){return eo},bt:function(){return bF},bu:function(){return ga},bv:function(){return f0},bw:function(){return fc},bx:function(){return a5},by:function(){return a4},bz:function(){return gb},c:function(){return f},d:function(){return g},e:function(){return a3},f:function(){return aI},g:function(){return aJ},h:function(){return be},i:function(){return T},j:function(){return bf},k:function(){return aM},l:function(){return aV},m:function(){return aU},n:function(){return aY},o:function(){return a1},p:function(){return eW},q:function(){return G},r:function(){return bx},s:function(){return m},t:function(){return l},u:function(){return aD},v:function(){return p},w:function(){return ed},x:function(){return k},y:function(){return v},z:function(){return bo}});var d=c(92952).Buffer,e=function(a,b){return(e=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function(a,b){a.__proto__=b}||function(a,b){for(var c in b)Object.prototype.hasOwnProperty.call(b,c)&&(a[c]=b[c])})(a,b)};function f(a,b){if("function"!=typeof b&&null!==b)throw TypeError("Class extends value "+String(b)+" is not a constructor or null");function c(){this.constructor=a}e(a,b),a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)}var g=function(){return(g=Object.assign||function(a){for(var b,c=1,d=arguments.length;cb.indexOf(d)&&(c[d]=a[d]);if(null!=a&&"function"==typeof Object.getOwnPropertySymbols){var e=0;for(d=Object.getOwnPropertySymbols(a);eb.indexOf(d[e])&&Object.prototype.propertyIsEnumerable.call(a,d[e])&&(c[d[e]]=a[d[e]])}return c}function i(a,b,c,d){return new(c||(c=Promise))(function(e,f){function g(a){try{i(d.next(a))}catch(b){f(b)}}function h(a){try{i(d.throw(a))}catch(b){f(b)}}function i(a){var b;a.done?e(a.value):((b=a.value)instanceof c?b:new c(function(a){a(b)})).then(g,h)}i((d=d.apply(a,b||[])).next())})}function j(a,b){var c,d,e,f={label:0,sent:function(){if(1&e[0])throw e[1];return e[1]},trys:[],ops:[]},g=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return g.next=h(0),g.throw=h(1),g.return=h(2),"function"==typeof Symbol&&(g[Symbol.iterator]=function(){return this}),g;function h(h){return function(i){return function(h){if(c)throw TypeError("Generator is already executing.");for(;g&&(g=0,h[0]&&(f=0)),f;)try{if(c=1,d&&(e=2&h[0]?d.return:h[0]?d.throw||((e=d.return)&&e.call(d),0):d.next)&&!(e=e.call(d,h[1])).done)return e;switch(d=0,e&&(h=[2&h[0],e.value]),h[0]){case 0:case 1:e=h;break;case 4:return f.label++,{value:h[1],done:!1};case 5:f.label++,d=h[1],h=[0];continue;case 7:h=f.ops.pop(),f.trys.pop();continue;default:if(!(e=(e=f.trys).length>0&&e[e.length-1])&&(6===h[0]||2===h[0])){f=0;continue}if(3===h[0]&&(!e||h[1]>e[0]&&h[1]=a.length&&(a=void 0),{value:a&&a[d++],done:!a}}};throw TypeError(b?"Object is not iterable.":"Symbol.iterator is not defined.")}function l(a,b){var c="function"==typeof Symbol&&a[Symbol.iterator];if(!c)return a;var d,e,f=c.call(a),g=[];try{for(;(void 0===b||b-- >0)&&!(d=f.next()).done;)g.push(d.value)}catch(h){e={error:h}}finally{try{d&&!d.done&&(c=f.return)&&c.call(f)}finally{if(e)throw e.error}}return g}function m(a,b,c){if(c||2===arguments.length)for(var d,e=0,f=b.length;e=0&&a<=23},P=function(a,b){return void 0===b&&(b=!1),!(!b||!V(a))||"number"==typeof a&&Number.isInteger(a)&&a>=0&&a<=59},Q=function(a,b){return void 0===b&&(b=!1),!(!b||!V(a))||"number"==typeof a&&13===a.toString().length},R=function(a){return a>0&&H.indexOf(a)>=0},S=function(a){return a>0&&I.indexOf(a)>=0},T=function(a,b){if(void 0===b&&(b=!1),b&&V(a))return!0;var c="object"==typeof a&&null!==a&&a.hasOwnProperty("name")&&"string"==typeof a.name&&a.hasOwnProperty("uri")&&"string"==typeof a.uri&&a.hasOwnProperty("type")&&"string"==typeof a.type;if(!c){if("undefined"!=typeof Blob)return a instanceof Blob;if("undefined"!=typeof File)return a instanceof File}return c},U=function(a,b){if(a===b)return!0;if(null==a||null==b||a.length!==b.length)return!1;for(var c=m([],l(a),!1).sort(),d=m([],l(b),!1).sort(),e=0;e=1e3&&a<=9e3&&(this._typingIndicatorThrottle=a)},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"websocketResponseTimeout",{get:function(){return this._websocketResponseTimeout},set:function(a){K("number",a)&&a>=5e3&&a<=3e4&&(this._websocketResponseTimeout=a)},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"sessionTokenRefreshTimeout",{get:function(){return this._sessionTokenRefreshTimeout},set:function(a){K("number",a)&&(a<60?a=60:a>1800&&(a=1800),this._sessionTokenRefreshTimeout=a)},enumerable:!1,configurable:!0}),a}(),X={encrypt:function(a){return a},decrypt:function(a){return a}},Y=function(){function a(a){var b=a.store;this._preference=new Map,this._store=b}return a.prototype._savePreferenceKeys=function(){return i(this,void 0,void 0,function(){return j(this,function(a){switch(a.label){case 0:return[4,this._store.set({key:this._keysAddress,value:m([],l(this._preference.keys()),!1)})];case 1:return a.sent(),[2]}})})},a.prototype.init=function(a,b){var c;return void 0===b&&(b=1),i(this,void 0,void 0,function(){var d,e,f,g,h,i,l,m,n,o,p;return j(this,function(j){switch(j.label){case 0:return this._version=b,this._keysAddress=a,d="".concat(a,".metadata.version"),[4,this._store.get(d)];case 1:return e=j.sent(),[4,this._store.get(a)];case 2:return f=null!==(c=j.sent())&& void 0!==c?c:[],!e||e.versionb.channel.messageCollectionLastAccessedAt?1:-1},this._maxSize=Math.max(void 0===c?256:c,64),f?(this._clearOrder=e,this._customClearOrderComparator=f):this._clearOrder=x.MESSAGE_COLLECTION_ACCESSED_AT,this._enableAutoResend=void 0===g||g,this._enableRestoreDB=void 0!==h&&h}return Object.defineProperty(a.prototype,"maxSize",{get:function(){return this._maxSize},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"clearOrder",{get:function(){return this._clearOrder},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"enableRestoreDB",{get:function(){return this._enableRestoreDB},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"clearOrderComparator",{get:function(){var a;return this._clearOrder===x.MESSAGE_COLLECTION_ACCESSED_AT?this._clearOrderComparatorUseMessageCollectionAccessedAt:null!==(a=this._customClearOrderComparator)&& void 0!==a?a:this._clearOrderComparatorUseMessageCollectionAccessedAt},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"enableAutoResend",{get:function(){return this._enableAutoResend},enumerable:!1,configurable:!0}),a}();(_=$||($={})).FEED="feed",_.CHAT="chat",_.CHAT_API="chat_api";var ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an,ao,ap,aq,ar,as,at,au,av,aw,ax,ay,az,aA,aB,aC=function(){function a(){this.isRefreshing=!1}return Object.defineProperty(a.prototype,"hasSession",{get:function(){return!!this.sessionKey},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"hasChatServicePermission",{get:function(){var a;return!!(null===(a=this.services)|| void 0===a?void 0:a.includes($.CHAT))},enumerable:!1,configurable:!0}),a.prototype.clear=function(){this.authToken=void 0,this.sessionKey=void 0,this.services=[]},a}(),aD=function(){var a=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(b){var c=(a+16*Math.random())%16|0;return a=Math.floor(a/16),("x"===b?c:3&c|8).toString(16)})},aE=function(){function a(a){var b=a.container;this._container={},this._container=b,this.key=aD()}return a.prototype._register=function(a,b,c){var d;return a in this._container||(this._container[a]=new Map),null===(d=this._container[a])|| void 0===d||d.set(this.key,{occurence:b,handler:c}),this},a.prototype.on=function(a,b){return this._register(a,-1,b)},a.prototype.once=function(a,b){return this._register(a,1,b)},a.prototype.close=function(){var a=this;Object.keys(this._container).forEach(function(b){var c;null===(c=a._container[b])|| void 0===c||c.delete(a.key)})},a}(),aF=function(){function a(){this._container={}}return a.prototype.on=function(a,b){return new aE({container:this._container}).on(a,b)},a.prototype.once=function(a,b){return new aE({container:this._container}).once(a,b)},a.prototype.dispatch=function(a,b){var c,d,e=this._container[a];if(e){var f=[];try{for(var g=k(e.keys()),h=g.next();!h.done;h=g.next()){var i=h.value,j=e.get(i);j.handler(b),j.occurence>0&&(j.occurence--,0===j.occurence&&f.push(i))}}catch(l){c={error:l}}finally{try{h&&!h.done&&(d=g.return)&&d.call(g)}finally{if(c)throw c.error}}f.forEach(function(a){return e.delete(a)})}},a}(),aG=function(){function a(){this._dispatcher=new aF}return a.prototype.on=function(a){return this._dispatcher.on("event",a)},a.prototype.once=function(a){return this._dispatcher.once("event",a)},a.prototype.dispatch=function(a){this._dispatcher.dispatch("event",a)},a}(),aH=function(){},aI=function(a){var b={};return a&&Object.keys(a).forEach(function(c){void 0===a[c]||Number.isNaN(a[c])||null===a[c]||(b[c]=a[c])}),b},aJ=function(a){if(null!=a){if("object"==typeof a){if(Array.isArray(a)){for(var b=m([],l(a),!1),c=0;c0)return"react";if(window.__NUXT__)return"vue(SSR)";if(window.__NEXT_DATA__||window.__NEXT_P||window.__NEXT_F)return"nextjs"}return""},b.sendbirdSdkUserAgentWithExtension=function(b){var c=bx()?br.REACT_NATIVE:br.JS,d={main_sdk_info:"chat/".concat(c,"/").concat(q.SDK_VERSION),device_os_platform:by()?"mobile-web":"web",os_version:q.OS_VERSION};if(b){var e=b.sendbirdExtensions,f=b.deviceOS,h=b.customData,i=void 0===h?{}:h;f.version&&(d.os_version=f.version),f.platform&&(d.device_os_platform=f.platform),e.length>0&&(d.extension_sdk_info=e.map(function(a){var b=a.product,c=a.platform,d=a.version;return"".concat(b,"/").concat(c,"/").concat(d)}).join(",")),Object.keys(d).forEach(function(a){return delete i[a]}),Object.keys(i).length>0&&(d=g(g({},d),i))}var j=a._getFrameWork();return j&&(d.javascript_framework=j),Object.entries(d).map(function(a){var b=l(a,2),c=b[0],d=b[1];return"".concat(c,"=").concat(d)}).join("&")},b.userAgentWithExtension=function(a){var b=bx()?"reactnative":"JS",c=a.sb_syncmanager?"s".concat(a.sb_syncmanager):"",d=a.sb_uikit?"u".concat(a.sb_uikit):"",e=a["device-os-platform"]?"o".concat(a["device-os-platform"]):by()?"omobile-web":"oweb";return"".concat(b,"/c").concat(q.SDK_VERSION,"/").concat(c,"/").concat(d,"/").concat(e)},b}(),bC=function(){var a=this;this.promise=new Promise(function(b,c){a.resolve=b,a.reject=function(a){c(a)}})},bD=function(a){function b(b){var c=a.call(this)||this;return c.requestId=b.requestId,c}return f(b,a),b}(aH),bE=function(a){function b(b){var c=a.call(this)||this;return c.method=aK.DELETE,c.path="".concat(a7(b.channelType),"/").concat(b.channelUrl,"/messages/").concat(b.messageId),b.messageToken&&(c.params=aI({mesg_token:b.messageToken})),c}return f(b,a),b}(be);f(function(){return null!==bz&&bz.apply(this,arguments)||this},bz=bf);var bF=function(a){function b(b,c,d){var e,f=this;return(f=a.call(this,b,"DELM",d)||this).channelUrl=d.channel_url,f.channelType=d.channel_type,f.messageId=Number(d.msg_id),f.silent=d.silent,f.messageCreatedAt=d.message_created_at?Number(d.message_created_at):-1,f.senderId=null!==(e=d.sender_id)&& void 0!==e?e:void 0,f}return f(b,a),b}(bi),bG=function(){function a(a,b){var c=b.session,d=b.sdkState,e=b.dispatcher,f=b.logger,g=b.useFetchCompat,h=this;this._abortControl=new Map,this._shouldImportFetchCompat=!1,this._iid=a,this._session=c,this._sdkState=d,this._dispatcher=e,this._dispatcher.on(function(a){a instanceof bg&&h.cancel(a.requestId,a.cause)}),this._logger=f,this._shouldImportFetchCompat=void 0!==g&&g}return a.prototype._createHeader=function(a,b){var c=this._sdkState,d=c.appId,e=c.appVersion,f=c.sendbirdRuntimeEnvironment,h=g(g({},a.headers),{SendBird:"JS,".concat(q.OS_VERSION,",").concat(q.SDK_VERSION,",").concat(d).concat(e?",".concat(e):""),"SB-User-Agent":bB.userAgentWithExtension(this._sdkState.extensions),"Request-Sent-Timestamp":Date.now().toString(),"SB-SDK-User-Agent":bB.sendbirdSdkUserAgentWithExtension(f)});return b||(h["Content-Type"]="application/json; charset=utf-8"),h["App-Id"]=d,a.requireAuth?!a.hasSessionKey&&this._session.hasSession&&(h["Session-key"]=this._session.sessionKey):this._session.authToken&&(h["Access-token"]=this._session.authToken),h},a.prototype._toSendbirdError=function(a){return a instanceof G?a:"AbortError"===(null==a?void 0:a.name)?G.requestCanceled:G.networkError},a.prototype._statLogApiResult=function(a,b,c,d){if(!a.path.includes("/sdk/statistics")){var e=void 0===c?void 0:this._toSendbirdError(c),f=(null==e?void 0:e.code)===n.REQUEST_CANCELED?d:void 0,g=f?"cause=".concat(f):null==c?void 0:c.message;this._dispatcher.dispatch(new bo(new bw({type:bc.API_RESULT,data:{endpoint:a.path,method:a.method,success:!c,latency:Date.now()-b,error_code:null==e?void 0:e.code,error_description:g}})))}},a.prototype._isBodyRequired=function(a){var b=a.method;return b!==aK.GET&&(b!==aK.DELETE||a instanceof bE)},a.prototype._shouldUseXMLHttpRequest=function(a){return bx()&&a instanceof FormData},a.prototype._resendOnSessionError=function(a,b){if(b.isSessionExpiredError){if(this._dispatcher.dispatch(new bh({reason:b.code,message:b.message})),!(a instanceof bk)){var c=new bC;return this._dispatcher.dispatch(new bp({request:a,deferred:c,error:b})),c.promise}}else b.isSessionInvalidatedError&&this._dispatcher.dispatch(new bh({reason:b.code,message:b.message}));return null},a.prototype.send=function(a){return i(this,void 0,void 0,function(){var b,d,e,f,g,h,i,k,l,m,o,p,q,r,s,t,u,v,w;return j(this,function(j){switch(j.label){case 0:b=a.path,d=a.method,e=a.uploadProgressHandler,f=this._isBodyRequired(a),g=this._sdkState.api,h="".concat(g.host).concat(b).concat(f?"":a.query),i=f?a.payload:null,k=this._createHeader(a,i instanceof FormData?i:void 0),l={controller:new AbortController},m=l.controller.signal,this._abortControl.set(a.requestId,l),o=Date.now(),j.label=1;case 1:return j.trys.push([1,13,14,15]),e||this._shouldUseXMLHttpRequest(i)?[4,c.e(2911).then(c.bind(c,42911))]:[3,6];case 2:p=j.sent().xmlHttpRequest,j.label=3;case 3:return j.trys.push([3,5,,6]),[4,p(this._iid,{requestId:a.requestId,method:a.method,url:h,headers:k,data:null!=i?i:void 0,uploadProgressHandler:e})];case 4:return q=j.sent(),this._logger.debug("receive api response",a.requestId),this._statLogApiResult(a,o),[2,q];case 5:if(!((r=j.sent())instanceof G&&r.code===n.XMLHTTPREQUEST_NOT_SUPPORTED)){if(r instanceof G&&(v=this._resendOnSessionError(a,r)))return[2,v];throw r}return this._logger.debug("XMLHttpRequest is not available in this environment. progressHandler is ignored."),[3,6];case 6:return this._shouldImportFetchCompat&&(this._shouldImportFetchCompat=!1,("undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||"undefined"!=typeof global&&global||{fetch:null}).fetch=null),"undefined"!=typeof AbortController?[3,8]:[4,c.e(3588).then(c.bind(c,13588))];case 7:j.sent(),j.label=8;case 8:return"function"==typeof fetch?[3,10]:[4,c.e(9098).then(c.bind(c,29098))];case 9:j.sent(),j.label=10;case 10:return[4,fetch(h,{method:d,body:i,headers:k,signal:m})];case 11:return[4,(s=j.sent()).json()];case 12:if(t=j.sent(),s.ok||s.redirected)return this._logger.debug("receive api response",a.requestId),this._statLogApiResult(a,o),[2,new bf(this._iid,t)];if(t){if(u=new G(t),v=this._resendOnSessionError(a,u))return[2,v];throw u}throw G.requestFailed;case 13:throw w=j.sent(),this._statLogApiResult(a,o,w,l.cause),this._logger.debug("fail api request",w),this._toSendbirdError(w);case 14:return this._abortControl.delete(a.requestId),[7];case 15:return[2]}})})},a.prototype.cancel=function(a,b){var c=this._abortControl.get(a);c&&(c.cause=b,c.controller.abort(),this._abortControl.delete(a)),this._dispatcher.dispatch(new bD({requestId:a}))},a.prototype.cancelAll=function(a){var b,c;try{for(var d=k(this._abortControl.values()),e=d.next();!e.done;e=d.next()){var f=e.value;f.cause=a,f.controller.abort()}}catch(g){b={error:g}}finally{try{e&&!e.done&&(c=d.return)&&c.call(d)}finally{if(b)throw b.error}}this._abortControl.clear(),this._dispatcher.dispatch(new bD({}))},a}(),bH=function(){};function bI(a){let b=a.length;for(;--b>=0;)a[b]=0}let bJ=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),bK=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),bL=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),bM=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),bN=Array(576);bI(bN);let bO=Array(60);bI(bO);let bP=Array(512);bI(bP);let bQ=Array(256);bI(bQ);let bR=Array(29);bI(bR);let bS=Array(30);function bT(a,b,c,d,e){this.static_tree=a,this.extra_bits=b,this.extra_base=c,this.elems=d,this.max_length=e,this.has_stree=a&&a.length}let bU,bV,bW;function bX(a,b){this.dyn_tree=a,this.max_code=0,this.stat_desc=b}bI(bS);let bY=a=>a<256?bP[a]:bP[256+(a>>>7)],bZ=(a,b)=>{a.pending_buf[a.pending++]=255&b,a.pending_buf[a.pending++]=b>>>8&255},b$=(a,b,c)=>{a.bi_valid>16-c?(a.bi_buf|=b<>16-a.bi_valid,a.bi_valid+=c-16):(a.bi_buf|=b<{b$(a,c[2*b],c[2*b+1])},b0=(a,b)=>{let c=0;do c|=1&a,a>>>=1,c<<=1;while(--b>0)return c>>>1},b1=(a,b,c)=>{let d=Array(16),e,f,g=0;for(e=1;e<=15;e++)g=g+c[e-1]<<1,d[e]=g;for(f=0;f<=b;f++){let h=a[2*f+1];0!==h&&(a[2*f]=b0(d[h]++,h))}},b2=a=>{let b;for(b=0;b<286;b++)a.dyn_ltree[2*b]=0;for(b=0;b<30;b++)a.dyn_dtree[2*b]=0;for(b=0;b<19;b++)a.bl_tree[2*b]=0;a.dyn_ltree[512]=1,a.opt_len=a.static_len=0,a.sym_next=a.matches=0},b3=a=>{a.bi_valid>8?bZ(a,a.bi_buf):a.bi_valid>0&&(a.pending_buf[a.pending++]=a.bi_buf),a.bi_buf=0,a.bi_valid=0},b4=(a,b,c,d)=>{let e=2*b,f=2*c;return a[e]{let d=a.heap[c],e=c<<1;for(;e<=a.heap_len&&(e{let d,e,f,g,h=0;if(0!==a.sym_next)do d=255&a.pending_buf[a.sym_buf+h++],d+=(255&a.pending_buf[a.sym_buf+h++])<<8,e=a.pending_buf[a.sym_buf+h++],0===d?b_(a,e,b):(b_(a,(f=bQ[e])+256+1,b),0!==(g=bJ[f])&&b$(a,e-=bR[f],g),f=bY(--d),b_(a,f,c),0!==(g=bK[f])&&b$(a,d-=bS[f],g));while(h{let c=b.dyn_tree,d=b.stat_desc.static_tree,e=b.stat_desc.has_stree,f=b.stat_desc.elems,g,h,i,j=-1;for(a.heap_len=0,a.heap_max=573,g=0;g>1;g>=1;g--)b5(a,c,g);i=f;do g=a.heap[1],a.heap[1]=a.heap[a.heap_len--],b5(a,c,1),h=a.heap[1],a.heap[--a.heap_max]=g,a.heap[--a.heap_max]=h,c[2*i]=c[2*g]+c[2*h],a.depth[i]=(a.depth[g]>=a.depth[h]?a.depth[g]:a.depth[h])+1,c[2*g+1]=c[2*h+1]=i,a.heap[1]=i++,b5(a,c,1);while(a.heap_len>=2)a.heap[--a.heap_max]=a.heap[1],((a,b)=>{let c=b.dyn_tree,d=b.max_code,e=b.stat_desc.static_tree,f=b.stat_desc.has_stree,g=b.stat_desc.extra_bits,h=b.stat_desc.extra_base,i=b.stat_desc.max_length,j,k,l,m,n,o,p=0;for(m=0;m<=15;m++)a.bl_count[m]=0;for(c[2*a.heap[a.heap_max]+1]=0,j=a.heap_max+1;j<573;j++)(m=c[2*c[2*(k=a.heap[j])+1]+1]+1)>i&&(m=i,p++),c[2*k+1]=m,k>d||(a.bl_count[m]++,n=0,k>=h&&(n=g[k-h]),o=c[2*k],a.opt_len+=o*(m+n),f&&(a.static_len+=o*(e[2*k+1]+n)));if(0!==p){do{for(m=i-1;0===a.bl_count[m];)m--;a.bl_count[m]--,a.bl_count[m+1]+=2,a.bl_count[i]--,p-=2}while(p>0)for(m=i;0!==m;m--)for(k=a.bl_count[m];0!==k;)(l=a.heap[--j])>d||(c[2*l+1]!==m&&(a.opt_len+=(m-c[2*l+1])*c[2*l],c[2*l+1]=m),k--)}})(a,b),b1(c,j,a.bl_count)},b8=(a,b,c)=>{let d,e,f=-1,g=b[1],h=0,i=7,j=4;for(0===g&&(i=138,j=3),b[2*(c+1)+1]=65535,d=0;d<=c;d++)e=g,g=b[2*(d+1)+1],++h{let d,e,f=-1,g=b[1],h=0,i=7,j=4;for(0===g&&(i=138,j=3),d=0;d<=c;d++)if(e=g,g=b[2*(d+1)+1],!(++h{b$(a,0+(d?1:0),3),b3(a),bZ(a,c),bZ(a,~c),c&&a.pending_buf.set(a.window.subarray(b,b+c),a.pending),a.pending+=c};var cc=(a,b,c,d)=>{let e,f,g=0;a.level>0?(2===a.strm.data_type&&(a.strm.data_type=(a=>{let b,c=4093624447;for(b=0;b<=31;b++,c>>>=1)if(1&c&&0!==a.dyn_ltree[2*b])return 0;if(0!==a.dyn_ltree[18]||0!==a.dyn_ltree[20]||0!==a.dyn_ltree[26])return 1;for(b=32;b<256;b++)if(0!==a.dyn_ltree[2*b])return 1;return 0})(a)),b7(a,a.l_desc),b7(a,a.d_desc),g=(a=>{let b;for(b8(a,a.dyn_ltree,a.l_desc.max_code),b8(a,a.dyn_dtree,a.d_desc.max_code),b7(a,a.bl_desc),b=18;b>=3&&0===a.bl_tree[2*bM[b]+1];b--);return a.opt_len+=3*(b+1)+5+5+4,b})(a),e=a.opt_len+3+7>>>3,f=a.static_len+3+7>>>3,f<=e&&(e=f)):e=f=c+5,c+4<=e&& -1!==b?cb(a,b,c,d):4===a.strategy||f===e?(b$(a,2+(d?1:0),3),b6(a,bN,bO)):(b$(a,4+(d?1:0),3),((a,b,c,d)=>{let e;for(b$(a,b-257,5),b$(a,c-1,5),b$(a,d-4,4),e=0;e{let a,b,c,d,e,f=Array(16);for(c=0,d=0;d<28;d++)for(bR[d]=c,a=0;a<1<>=7;d<30;d++)for(bS[d]=e<<7,a=0;a<1<(a.pending_buf[a.sym_buf+a.sym_next++]=b,a.pending_buf[a.sym_buf+a.sym_next++]=b>>8,a.pending_buf[a.sym_buf+a.sym_next++]=c,0===b?a.dyn_ltree[2*c]++:(a.matches++,b--,a.dyn_ltree[2*(bQ[c]+256+1)]++,a.dyn_dtree[2*bY(b)]++),a.sym_next===a.sym_end),_tr_align(a){var b;b$(a,2,3),b_(a,256,bN),16===(b=a).bi_valid?(bZ(b,b.bi_buf),b.bi_buf=0,b.bi_valid=0):b.bi_valid>=8&&(b.pending_buf[b.pending++]=255&b.bi_buf,b.bi_buf>>=8,b.bi_valid-=8)}},ce=(a,b,c,d)=>{let e=65535&a,f=a>>>16&65535,g=0;for(;0!==c;){g=c>2e3?2e3:c,c-=g;do f=f+(e=e+b[d++]|0)|0;while(--g)e%=65521,f%=65521}return e|f<<16};let cf=new Uint32Array((()=>{let a,b=[];for(var c=0;c<256;c++){a=c;for(var d=0;d<8;d++)a=1&a?3988292384^a>>>1:a>>>1;b[c]=a}return b})());var cg=(a,b,c,d)=>{let e=cf,f=d+c;a^=-1;for(let g=d;g>>8^e[255&(a^b[g])];return~a},ch={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},ci={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};let{_tr_init:cj,_tr_stored_block:ck,_tr_flush_block:cl,_tr_tally:cm,_tr_align:cn}=cd,{Z_NO_FLUSH:co,Z_PARTIAL_FLUSH:cp,Z_FULL_FLUSH:cq,Z_FINISH:cr,Z_BLOCK:cs,Z_OK:ct,Z_STREAM_END:cu,Z_STREAM_ERROR:cv,Z_DATA_ERROR:cw,Z_BUF_ERROR:cx,Z_DEFAULT_COMPRESSION:cy,Z_FILTERED:cz,Z_HUFFMAN_ONLY:cA,Z_RLE:cB,Z_FIXED:cC,Z_DEFAULT_STRATEGY:cD,Z_UNKNOWN:cE,Z_DEFLATED:cF}=ci,cG=258,cH=262,cI=(a,b)=>(a.msg=ch[b],b),cJ=a=>2*a-(a>4?9:0),cK=a=>{let b=a.length;for(;--b>=0;)a[b]=0},cL=a=>{let b,c,d,e=a.w_size;d=b=a.hash_size;do c=a.head[--d],a.head[d]=c>=e?c-e:0;while(--b)d=b=e;do c=a.prev[--d],a.prev[d]=c>=e?c-e:0;while(--b)},cM=(a,b,c)=>(b<{let b=a.state,c=b.pending;c>a.avail_out&&(c=a.avail_out),0!==c&&(a.output.set(b.pending_buf.subarray(b.pending_out,b.pending_out+c),a.next_out),a.next_out+=c,b.pending_out+=c,a.total_out+=c,a.avail_out-=c,b.pending-=c,0===b.pending&&(b.pending_out=0))},cO=(a,b)=>{cl(a,a.block_start>=0?a.block_start:-1,a.strstart-a.block_start,b),a.block_start=a.strstart,cN(a.strm)},cP=(a,b)=>{a.pending_buf[a.pending++]=b},cQ=(a,b)=>{a.pending_buf[a.pending++]=b>>>8&255,a.pending_buf[a.pending++]=255&b},cR=(a,b,c,d)=>{let e=a.avail_in;return e>d&&(e=d),0===e?0:(a.avail_in-=e,b.set(a.input.subarray(a.next_in,a.next_in+e),c),1===a.state.wrap?a.adler=ce(a.adler,b,e,c):2===a.state.wrap&&(a.adler=cg(a.adler,b,e,c)),a.next_in+=e,a.total_in+=e,e)},cS=(a,b)=>{let c,d,e=a.max_chain_length,f=a.strstart,g=a.prev_length,h=a.nice_match,i=a.strstart>a.w_size-cH?a.strstart-(a.w_size-cH):0,j=a.window,k=a.w_mask,l=a.prev,m=a.strstart+cG,n=j[f+g-1],o=j[f+g];a.prev_length>=a.good_match&&(e>>=2),h>a.lookahead&&(h=a.lookahead);do if(j[(c=b)+g]===o&&j[c+g-1]===n&&j[c]===j[f]&&j[++c]===j[f+1]){f+=2,c++;do;while(j[++f]===j[++c]&&j[++f]===j[++c]&&j[++f]===j[++c]&&j[++f]===j[++c]&&j[++f]===j[++c]&&j[++f]===j[++c]&&j[++f]===j[++c]&&j[++f]===j[++c]&&fg){if(a.match_start=b,g=d,d>=h)break;n=j[f+g-1],o=j[f+g]}}while((b=l[b&k])>i&&0!= --e)return g<=a.lookahead?g:a.lookahead},cT=a=>{let b=a.w_size,c,d,e;do{if(d=a.window_size-a.lookahead-a.strstart,a.strstart>=b+(b-cH)&&(a.window.set(a.window.subarray(b,b+b-d),0),a.match_start-=b,a.strstart-=b,a.block_start-=b,a.insert>a.strstart&&(a.insert=a.strstart),cL(a),d+=b),0===a.strm.avail_in)break;if(c=cR(a.strm,a.window,a.strstart+a.lookahead,d),a.lookahead+=c,a.lookahead+a.insert>=3)for(e=a.strstart-a.insert,a.ins_h=a.window[e],a.ins_h=cM(a,a.ins_h,a.window[e+1]);a.insert&&(a.ins_h=cM(a,a.ins_h,a.window[e+3-1]),a.prev[e&a.w_mask]=a.head[a.ins_h],a.head[a.ins_h]=e,e++,a.insert--,!(a.lookahead+a.insert<3)););}while(a.lookahead{let c,d,e,f=a.pending_buf_size-5>a.w_size?a.w_size:a.pending_buf_size-5,g=0,h=a.strm.avail_in;do{if(c=65535,e=a.bi_valid+42>>3,a.strm.avail_outd+a.strm.avail_in&&(c=d+a.strm.avail_in),c>e&&(c=e),c>8,a.pending_buf[a.pending-2]=~c,a.pending_buf[a.pending-1]=~c>>8,cN(a.strm),d&&(d>c&&(d=c),a.strm.output.set(a.window.subarray(a.block_start,a.block_start+d),a.strm.next_out),a.strm.next_out+=d,a.strm.avail_out-=d,a.strm.total_out+=d,a.block_start+=d,c-=d),c&&(cR(a.strm,a.strm.output,a.strm.next_out,c),a.strm.next_out+=c,a.strm.avail_out-=c,a.strm.total_out+=c)}while(0===g)return(h-=a.strm.avail_in)&&(h>=a.w_size?(a.matches=2,a.window.set(a.strm.input.subarray(a.strm.next_in-a.w_size,a.strm.next_in),0),a.strstart=a.w_size,a.insert=a.strstart):(a.window_size-a.strstart<=h&&(a.strstart-=a.w_size,a.window.set(a.window.subarray(a.w_size,a.w_size+a.strstart),0),a.matches<2&&a.matches++,a.insert>a.strstart&&(a.insert=a.strstart)),a.window.set(a.strm.input.subarray(a.strm.next_in-h,a.strm.next_in),a.strstart),a.strstart+=h,a.insert+=h>a.w_size-a.insert?a.w_size-a.insert:h),a.block_start=a.strstart),a.high_watere&&a.block_start>=a.w_size&&(a.block_start-=a.w_size,a.strstart-=a.w_size,a.window.set(a.window.subarray(a.w_size,a.w_size+a.strstart),0),a.matches<2&&a.matches++,e+=a.w_size,a.insert>a.strstart&&(a.insert=a.strstart)),e>a.strm.avail_in&&(e=a.strm.avail_in),e&&(cR(a.strm,a.window,a.strstart,e),a.strstart+=e,a.insert+=e>a.w_size-a.insert?a.w_size-a.insert:e),a.high_water>3,e=a.pending_buf_size-e>65535?65535:a.pending_buf_size-e,f=e>a.w_size?a.w_size:e,d=a.strstart-a.block_start,(d>=f||(d||b===cr)&&b!==co&&0===a.strm.avail_in&&d<=e)&&(c=d>e?e:d,g=b===cr&&0===a.strm.avail_in&&c===d?1:0,ck(a,a.block_start,c,g),a.block_start+=c,cN(a.strm)),g?3:1)},cV=(a,b)=>{let c,d;for(;;){if(a.lookahead=3&&(a.ins_h=cM(a,a.ins_h,a.window[a.strstart+3-1]),c=a.prev[a.strstart&a.w_mask]=a.head[a.ins_h],a.head[a.ins_h]=a.strstart),0!==c&&a.strstart-c<=a.w_size-cH&&(a.match_length=cS(a,c)),a.match_length>=3){if(d=cm(a,a.strstart-a.match_start,a.match_length-3),a.lookahead-=a.match_length,a.match_length<=a.max_lazy_match&&a.lookahead>=3){a.match_length--;do a.strstart++,a.ins_h=cM(a,a.ins_h,a.window[a.strstart+3-1]),c=a.prev[a.strstart&a.w_mask]=a.head[a.ins_h],a.head[a.ins_h]=a.strstart;while(0!= --a.match_length)a.strstart++}else a.strstart+=a.match_length,a.match_length=0,a.ins_h=a.window[a.strstart],a.ins_h=cM(a,a.ins_h,a.window[a.strstart+1])}else d=cm(a,0,a.window[a.strstart]),a.lookahead--,a.strstart++;if(d&&(cO(a,!1),0===a.strm.avail_out))return 1}return a.insert=a.strstart<2?a.strstart:2,b===cr?(cO(a,!0),0===a.strm.avail_out?3:4):a.sym_next&&(cO(a,!1),0===a.strm.avail_out)?1:2},cW=(a,b)=>{let c,d,e;for(;;){if(a.lookahead=3&&(a.ins_h=cM(a,a.ins_h,a.window[a.strstart+3-1]),c=a.prev[a.strstart&a.w_mask]=a.head[a.ins_h],a.head[a.ins_h]=a.strstart),a.prev_length=a.match_length,a.prev_match=a.match_start,a.match_length=2,0!==c&&a.prev_length4096)&&(a.match_length=2)),a.prev_length>=3&&a.match_length<=a.prev_length){e=a.strstart+a.lookahead-3,d=cm(a,a.strstart-1-a.prev_match,a.prev_length-3),a.lookahead-=a.prev_length-1,a.prev_length-=2;do++a.strstart<=e&&(a.ins_h=cM(a,a.ins_h,a.window[a.strstart+3-1]),c=a.prev[a.strstart&a.w_mask]=a.head[a.ins_h],a.head[a.ins_h]=a.strstart);while(0!= --a.prev_length)if(a.match_available=0,a.match_length=2,a.strstart++,d&&(cO(a,!1),0===a.strm.avail_out))return 1}else if(a.match_available){if((d=cm(a,0,a.window[a.strstart-1]))&&cO(a,!1),a.strstart++,a.lookahead--,0===a.strm.avail_out)return 1}else a.match_available=1,a.strstart++,a.lookahead--}return a.match_available&&(d=cm(a,0,a.window[a.strstart-1]),a.match_available=0),a.insert=a.strstart<2?a.strstart:2,b===cr?(cO(a,!0),0===a.strm.avail_out?3:4):a.sym_next&&(cO(a,!1),0===a.strm.avail_out)?1:2};function cX(a,b,c,d,e){this.good_length=a,this.max_lazy=b,this.nice_length=c,this.max_chain=d,this.func=e}let cY=[new cX(0,0,0,0,cU),new cX(4,4,8,4,cV),new cX(4,5,16,8,cV),new cX(4,6,32,32,cV),new cX(4,4,16,16,cW),new cX(8,16,32,32,cW),new cX(8,16,128,128,cW),new cX(8,32,128,256,cW),new cX(32,128,258,1024,cW),new cX(32,258,258,4096,cW)];function cZ(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=cF,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),cK(this.dyn_ltree),cK(this.dyn_dtree),cK(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),cK(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),cK(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}let c$=a=>{if(!a)return 1;let b=a.state;return b&&b.strm===a&&(42===b.status||57===b.status||69===b.status||73===b.status||91===b.status||103===b.status||113===b.status||666===b.status)?0:1},c_=a=>{if(c$(a))return cI(a,cv);a.total_in=a.total_out=0,a.data_type=cE;let b=a.state;return b.pending=0,b.pending_out=0,b.wrap<0&&(b.wrap=-b.wrap),b.status=2===b.wrap?57:b.wrap?42:113,a.adler=2===b.wrap?0:1,b.last_flush=-2,cj(b),ct},c0=a=>{var b;let c=c_(a);return c===ct&&((b=a.state).window_size=2*b.w_size,cK(b.head),b.max_lazy_match=cY[b.level].max_lazy,b.good_match=cY[b.level].good_length,b.nice_match=cY[b.level].nice_length,b.max_chain_length=cY[b.level].max_chain,b.strstart=0,b.block_start=0,b.lookahead=0,b.insert=0,b.match_length=b.prev_length=2,b.match_available=0,b.ins_h=0),c},c1=(a,b,c,d,e,f)=>{if(!a)return cv;let g=1;if(b===cy&&(b=6),d<0?(g=0,d=-d):d>15&&(g=2,d-=16),e<1||e>9||c!==cF||d<8||d>15||b<0||b>9||f<0||f>cC||8===d&&1!==g)return cI(a,cv);8===d&&(d=9);let h=new cZ;return a.state=h,h.strm=a,h.status=42,h.wrap=g,h.gzhead=null,h.w_bits=d,h.w_size=1<c1(a,b,cF,15,8,cD),deflateInit2:c1,deflateReset:c0,deflateResetKeep:c_,deflateSetHeader:(a,b)=>c$(a)||2!==a.state.wrap?cv:(a.state.gzhead=b,ct),deflate(a,b){if(c$(a)||b>cs||b<0)return a?cI(a,cv):cv;let c=a.state;if(!a.output||0!==a.avail_in&&!a.input||666===c.status&&b!==cr)return cI(a,0===a.avail_out?cx:cv);let d=c.last_flush;if(c.last_flush=b,0!==c.pending){if(cN(a),0===a.avail_out)return c.last_flush=-1,ct}else if(0===a.avail_in&&cJ(b)<=cJ(d)&&b!==cr)return cI(a,cx);if(666===c.status&&0!==a.avail_in)return cI(a,cx);if(42===c.status&&0===c.wrap&&(c.status=113),42===c.status){let e=cF+(c.w_bits-8<<4)<<8,f=-1;if(e|=(c.strategy>=cA||c.level<2?0:c.level<6?1:6===c.level?2:3)<<6,0!==c.strstart&&(e|=32),e+=31-e%31,cQ(c,e),0!==c.strstart&&(cQ(c,a.adler>>>16),cQ(c,65535&a.adler)),a.adler=1,c.status=113,cN(a),0!==c.pending)return c.last_flush=-1,ct}if(57===c.status){if(a.adler=0,cP(c,31),cP(c,139),cP(c,8),c.gzhead)cP(c,(c.gzhead.text?1:0)+(c.gzhead.hcrc?2:0)+(c.gzhead.extra?4:0)+(c.gzhead.name?8:0)+(c.gzhead.comment?16:0)),cP(c,255&c.gzhead.time),cP(c,c.gzhead.time>>8&255),cP(c,c.gzhead.time>>16&255),cP(c,c.gzhead.time>>24&255),cP(c,9===c.level?2:c.strategy>=cA||c.level<2?4:0),cP(c,255&c.gzhead.os),c.gzhead.extra&&c.gzhead.extra.length&&(cP(c,255&c.gzhead.extra.length),cP(c,c.gzhead.extra.length>>8&255)),c.gzhead.hcrc&&(a.adler=cg(a.adler,c.pending_buf,c.pending,0)),c.gzindex=0,c.status=69;else if(cP(c,0),cP(c,0),cP(c,0),cP(c,0),cP(c,0),cP(c,9===c.level?2:c.strategy>=cA||c.level<2?4:0),cP(c,3),c.status=113,cN(a),0!==c.pending)return c.last_flush=-1,ct}if(69===c.status){if(c.gzhead.extra){let g=c.pending,h=(65535&c.gzhead.extra.length)-c.gzindex;for(;c.pending+h>c.pending_buf_size;){let i=c.pending_buf_size-c.pending;if(c.pending_buf.set(c.gzhead.extra.subarray(c.gzindex,c.gzindex+i),c.pending),c.pending=c.pending_buf_size,c.gzhead.hcrc&&c.pending>g&&(a.adler=cg(a.adler,c.pending_buf,c.pending-g,g)),c.gzindex+=i,cN(a),0!==c.pending)return c.last_flush=-1,ct;g=0,h-=i}let j=new Uint8Array(c.gzhead.extra);c.pending_buf.set(j.subarray(c.gzindex,c.gzindex+h),c.pending),c.pending+=h,c.gzhead.hcrc&&c.pending>g&&(a.adler=cg(a.adler,c.pending_buf,c.pending-g,g)),c.gzindex=0}c.status=73}if(73===c.status){if(c.gzhead.name){let k,l=c.pending;do{if(c.pending===c.pending_buf_size){if(c.gzhead.hcrc&&c.pending>l&&(a.adler=cg(a.adler,c.pending_buf,c.pending-l,l)),cN(a),0!==c.pending)return c.last_flush=-1,ct;l=0}k=c.gzindexl&&(a.adler=cg(a.adler,c.pending_buf,c.pending-l,l)),c.gzindex=0}c.status=91}if(91===c.status){if(c.gzhead.comment){let m,n=c.pending;do{if(c.pending===c.pending_buf_size){if(c.gzhead.hcrc&&c.pending>n&&(a.adler=cg(a.adler,c.pending_buf,c.pending-n,n)),cN(a),0!==c.pending)return c.last_flush=-1,ct;n=0}m=c.gzindexn&&(a.adler=cg(a.adler,c.pending_buf,c.pending-n,n))}c.status=103}if(103===c.status){if(c.gzhead.hcrc){if(c.pending+2>c.pending_buf_size&&(cN(a),0!==c.pending))return c.last_flush=-1,ct;cP(c,255&a.adler),cP(c,a.adler>>8&255),a.adler=0}if(c.status=113,cN(a),0!==c.pending)return c.last_flush=-1,ct}if(0!==a.avail_in||0!==c.lookahead||b!==co&&666!==c.status){let o=0===c.level?cU(c,b):c.strategy===cA?((a,b)=>{let c;for(;;){if(0===a.lookahead&&(cT(a),0===a.lookahead)){if(b===co)return 1;break}if(a.match_length=0,c=cm(a,0,a.window[a.strstart]),a.lookahead--,a.strstart++,c&&(cO(a,!1),0===a.strm.avail_out))return 1}return a.insert=0,b===cr?(cO(a,!0),0===a.strm.avail_out?3:4):a.sym_next&&(cO(a,!1),0===a.strm.avail_out)?1:2})(c,b):c.strategy===cB?((a,b)=>{let c,d,e,f,g=a.window;for(;;){if(a.lookahead<=cG){if(cT(a),a.lookahead<=cG&&b===co)return 1;if(0===a.lookahead)break}if(a.match_length=0,a.lookahead>=3&&a.strstart>0&&(d=g[e=a.strstart-1])===g[++e]&&d===g[++e]&&d===g[++e]){f=a.strstart+cG;do;while(d===g[++e]&&d===g[++e]&&d===g[++e]&&d===g[++e]&&d===g[++e]&&d===g[++e]&&d===g[++e]&&d===g[++e]&&ea.lookahead&&(a.match_length=a.lookahead)}if(a.match_length>=3?(c=cm(a,1,a.match_length-3),a.lookahead-=a.match_length,a.strstart+=a.match_length,a.match_length=0):(c=cm(a,0,a.window[a.strstart]),a.lookahead--,a.strstart++),c&&(cO(a,!1),0===a.strm.avail_out))return 1}return a.insert=0,b===cr?(cO(a,!0),0===a.strm.avail_out?3:4):a.sym_next&&(cO(a,!1),0===a.strm.avail_out)?1:2})(c,b):cY[c.level].func(c,b);if(3!==o&&4!==o||(c.status=666),1===o||3===o)return 0===a.avail_out&&(c.last_flush=-1),ct;if(2===o&&(b===cp?cn(c):b!==cs&&(ck(c,0,0,!1),b===cq&&(cK(c.head),0===c.lookahead&&(c.strstart=0,c.block_start=0,c.insert=0))),cN(a),0===a.avail_out))return c.last_flush=-1,ct}return b!==cr?ct:c.wrap<=0?cu:(2===c.wrap?(cP(c,255&a.adler),cP(c,a.adler>>8&255),cP(c,a.adler>>16&255),cP(c,a.adler>>24&255),cP(c,255&a.total_in),cP(c,a.total_in>>8&255),cP(c,a.total_in>>16&255),cP(c,a.total_in>>24&255)):(cQ(c,a.adler>>>16),cQ(c,65535&a.adler)),cN(a),c.wrap>0&&(c.wrap=-c.wrap),0!==c.pending?ct:cu)},deflateEnd(a){if(c$(a))return cv;let b=a.state.status;return a.state=null,113===b?cI(a,cw):ct},deflateSetDictionary(a,b){let c=b.length;if(c$(a))return cv;let d=a.state,e=d.wrap;if(2===e||1===e&&42!==d.status||d.lookahead)return cv;if(1===e&&(a.adler=ce(a.adler,b,c,0)),d.wrap=0,c>=d.w_size){0===e&&(cK(d.head),d.strstart=0,d.block_start=0,d.insert=0);let f=new Uint8Array(d.w_size);f.set(b.subarray(c-d.w_size,c),0),b=f,c=d.w_size}let g=a.avail_in,h=a.next_in,i=a.input;for(a.avail_in=c,a.next_in=0,a.input=b,cT(d);d.lookahead>=3;){let j=d.strstart,k=d.lookahead-2;do d.ins_h=cM(d,d.ins_h,d.window[j+3-1]),d.prev[j&d.w_mask]=d.head[d.ins_h],d.head[d.ins_h]=j,j++;while(--k)d.strstart=j,d.lookahead=2,cT(d)}return d.strstart+=d.lookahead,d.block_start=d.strstart,d.insert=d.lookahead,d.lookahead=0,d.match_length=d.prev_length=2,d.match_available=0,a.next_in=h,a.input=i,a.avail_in=g,d.wrap=e,ct},deflateInfo:"pako deflate (from Nodeca project)"};let c3=(a,b)=>Object.prototype.hasOwnProperty.call(a,b);var c4=function(a){let b=Array.prototype.slice.call(arguments,1);for(;b.length;){let c=b.shift();if(c){if("object"!=typeof c)throw TypeError(c+"must be non-object");for(let d in c)c3(c,d)&&(a[d]=c[d])}}return a},c5=a=>{let b=0;for(let c=0,d=a.length;c=252?6:c9>=248?5:c9>=240?4:c9>=224?3:c9>=192?2:1;c8[254]=c8[254]=1;var da=a=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(a);let b,c,d,e,f,g=a.length,h=0;for(e=0;e>>6,b[f++]=128|63&c):c<65536?(b[f++]=224|c>>>12,b[f++]=128|c>>>6&63,b[f++]=128|63&c):(b[f++]=240|c>>>18,b[f++]=128|c>>>12&63,b[f++]=128|c>>>6&63,b[f++]=128|63&c);return b},db=(a,b)=>{let c=b||a.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(a.subarray(0,b));let d,e,f=Array(2*c);for(e=0,d=0;d4)f[e++]=65533,d+=h-1;else{for(g&=2===h?31:3===h?15:7;h>1&&d1?f[e++]=65533:g<65536?f[e++]=g:(g-=65536,f[e++]=55296|g>>10&1023,f[e++]=56320|1023&g)}}return((a,b)=>{if(b<65534&&a.subarray&&c6)return String.fromCharCode.apply(null,a.length===b?a:a.subarray(0,b));let c="";for(let d=0;d{(b=b||a.length)>a.length&&(b=a.length);let c=b-1;for(;c>=0&&128==(192&a[c]);)c--;return c<0||0===c?b:c+c8[a[c]]>b?c:b},dd=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};let de=Object.prototype.toString,{Z_NO_FLUSH:df,Z_SYNC_FLUSH:dg,Z_FULL_FLUSH:dh,Z_FINISH:di,Z_OK:dj,Z_STREAM_END:dk,Z_DEFAULT_COMPRESSION:dl,Z_DEFAULT_STRATEGY:dm,Z_DEFLATED:dn}=ci;function dp(a){this.options=c4({level:dl,method:dn,chunkSize:16384,windowBits:15,memLevel:8,strategy:dm},a||{});let b=this.options;b.raw&&b.windowBits>0?b.windowBits=-b.windowBits:b.gzip&&b.windowBits>0&&b.windowBits<16&&(b.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new dd,this.strm.avail_out=0;let c=c2.deflateInit2(this.strm,b.level,b.method,b.windowBits,b.memLevel,b.strategy);if(c!==dj)throw Error(ch[c]);if(b.header&&c2.deflateSetHeader(this.strm,b.header),b.dictionary){let d;if(d="string"==typeof b.dictionary?da(b.dictionary):"[object ArrayBuffer]"===de.call(b.dictionary)?new Uint8Array(b.dictionary):b.dictionary,(c=c2.deflateSetDictionary(this.strm,d))!==dj)throw Error(ch[c]);this._dict_set=!0}}function dq(a,b){let c=new dp(b);if(c.push(a,!0),c.err)throw c.msg||ch[c.err];return c.result}dp.prototype.push=function(a,b){let c=this.strm,d=this.options.chunkSize,e,f;if(this.ended)return!1;for(f=b=== ~~b?b:!0===b?di:df,"string"==typeof a?c.input=da(a):"[object ArrayBuffer]"===de.call(a)?c.input=new Uint8Array(a):c.input=a,c.next_in=0,c.avail_in=c.input.length;;)if(0===c.avail_out&&(c.output=new Uint8Array(d),c.next_out=0,c.avail_out=d),(f===dg||f===dh)&&c.avail_out<=6)this.onData(c.output.subarray(0,c.next_out)),c.avail_out=0;else{if((e=c2.deflate(c,f))===dk)return c.next_out>0&&this.onData(c.output.subarray(0,c.next_out)),e=c2.deflateEnd(this.strm),this.onEnd(e),this.ended=!0,e===dj;if(0!==c.avail_out){if(f>0&&c.next_out>0)this.onData(c.output.subarray(0,c.next_out)),c.avail_out=0;else if(0===c.avail_in)break}else this.onData(c.output)}return!0},dp.prototype.onData=function(a){this.chunks.push(a)},dp.prototype.onEnd=function(a){a===dj&&(this.result=c5(this.chunks)),this.chunks=[],this.err=a,this.msg=this.strm.msg};var dr=function(a,b){let c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A=a.state;c=a.next_in,y=a.input,d=c+(a.avail_in-5),e=a.next_out,z=a.output,f=e-(b-a.avail_out),g=e+(a.avail_out-257),h=A.dmax,i=A.wsize,j=A.whave,k=A.wnext,l=A.window,m=A.hold,n=A.bits,o=A.lencode,p=A.distcode,q=(1<>>=t=s>>>24,n-=t,t=s>>>16&255,0===t)z[e++]=65535&s;else{if(!(16&t)){if(64&t){if(32&t){A.mode=16191;break e}a.msg="invalid literal/length code",A.mode=16209;break e}s=o[(65535&s)+(m&(1<>>=t,n-=t),n<15&&(m+=y[c++]<>>=t=s>>>24,n-=t,t=s>>>16&255,16&t){if(v=65535&s,n<(t&=15)&&(m+=y[c++]<h){a.msg="invalid distance too far back",A.mode=16209;break e}if(m>>>=t,n-=t,t=e-f,v>t){if((t=v-t)>j&&A.sane){a.msg="invalid distance too far back",A.mode=16209;break e}if(w=0,x=l,0===k){if(w+=i-t,t2;)z[e++]=x[w++],z[e++]=x[w++],z[e++]=x[w++],u-=3;u&&(z[e++]=x[w++],u>1&&(z[e++]=x[w++]))}else{w=e-v;do z[e++]=z[w++],z[e++]=z[w++],z[e++]=z[w++],u-=3;while(u>2)u&&(z[e++]=z[w++],u>1&&(z[e++]=z[w++]))}break}if(64&t){a.msg="invalid distance code",A.mode=16209;break e}s=p[(65535&s)+(m&(1<>3,n-=u<<3,m&=(1<{let i=h.bits,j,k,l,m,n,o,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=null,A=new Uint16Array(16),B=new Uint16Array(16),C,D,E,F=null;for(p=0;p<=15;p++)A[p]=0;for(q=0;q=1&&0===A[s];s--);if(t>s&&(t=s),0===s)return e[f++]=20971520,e[f++]=20971520,h.bits=1,0;for(r=1;r0&&(0===a||1!==s))return -1;for(B[1]=0,p=1;p<15;p++)B[p+1]=B[p]+A[p];for(q=0;q852||2===a&&x>592)return 1;for(;;){C=p-v,g[q]+1=o?(D=F[g[q]-o],E=z[g[q]-o]):(D=96,E=0),j=1<>v)+(k-=j)]=C<<24|D<<16|E;while(0!==k)for(j=1<>=1;if(0!==j?(y&=j-1,y+=j):y=0,q++,0== --A[p]){if(p===s)break;p=b[c+g[q]]}if(p>t&&(y&m)!==l){for(0===v&&(v=t),n+=r,w=1<<(u=p-v);u+v852||2===a&&x>592)return 1;e[l=y&m]=t<<24|u<<16|n-f}}return 0!==y&&(e[n+y]=p-v<<24|4194304),h.bits=t,0};let{Z_FINISH:dx,Z_BLOCK:dy,Z_TREES:dz,Z_OK:dA,Z_STREAM_END:dB,Z_NEED_DICT:dC,Z_STREAM_ERROR:dD,Z_DATA_ERROR:dE,Z_MEM_ERROR:dF,Z_BUF_ERROR:dG,Z_DEFLATED:dH}=ci,dI=a=>(a>>>24&255)+(a>>>8&65280)+((65280&a)<<8)+((255&a)<<24);function dJ(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}let dK=a=>{if(!a)return 1;let b=a.state;return!b||b.strm!==a||b.mode<16180||b.mode>16211?1:0},dL=a=>{if(dK(a))return dD;let b=a.state;return a.total_in=a.total_out=b.total=0,a.msg="",b.wrap&&(a.adler=1&b.wrap),b.mode=16180,b.last=0,b.havedict=0,b.flags=-1,b.dmax=32768,b.head=null,b.hold=0,b.bits=0,b.lencode=b.lendyn=new Int32Array(852),b.distcode=b.distdyn=new Int32Array(592),b.sane=1,b.back=-1,dA},dM=a=>{if(dK(a))return dD;let b=a.state;return b.wsize=0,b.whave=0,b.wnext=0,dL(a)},dN=(a,b)=>{let c;if(dK(a))return dD;let d=a.state;return b<0?(c=0,b=-b):(c=5+(b>>4),b<48&&(b&=15)),b&&(b<8||b>15)?dD:(null!==d.window&&d.wbits!==b&&(d.window=null),d.wrap=c,d.wbits=b,dM(a))},dO=(a,b)=>{if(!a)return dD;let c=new dJ;a.state=c,c.strm=a,c.window=null,c.mode=16180;let d=dN(a,b);return d!==dA&&(a.state=null),d},dP,dQ,dR=!0,dS=a=>{if(dR){dP=new Int32Array(512),dQ=new Int32Array(32);let b=0;for(;b<144;)a.lens[b++]=8;for(;b<256;)a.lens[b++]=9;for(;b<280;)a.lens[b++]=7;for(;b<288;)a.lens[b++]=8;for(dw(1,a.lens,0,288,dP,0,a.work,{bits:9}),b=0;b<32;)a.lens[b++]=5;dw(2,a.lens,0,32,dQ,0,a.work,{bits:5}),dR=!1}a.lencode=dP,a.lenbits=9,a.distcode=dQ,a.distbits=5},dT=(a,b,c,d)=>{let e,f=a.state;return null===f.window&&(f.wsize=1<=f.wsize?(f.window.set(b.subarray(c-f.wsize,c),0),f.wnext=0,f.whave=f.wsize):((e=f.wsize-f.wnext)>d&&(e=d),f.window.set(b.subarray(c-d,c-d+e),f.wnext),(d-=e)?(f.window.set(b.subarray(c-d,c),0),f.wnext=d,f.whave=f.wsize):(f.wnext+=e,f.wnext===f.wsize&&(f.wnext=0),f.whavedO(a,15),inflateInit2:dO,inflate(a,b){let c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y=0,z=new Uint8Array(4),A,B,C=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(dK(a)||!a.output|| !a.input&&0!==a.avail_in)return dD;16191===(c=a.state).mode&&(c.mode=16192),g=a.next_out,e=a.output,i=a.avail_out,f=a.next_in,d=a.input,h=a.avail_in,j=c.hold,k=c.bits,l=h,m=i,x=dA;e:for(;;)switch(c.mode){case 16180:if(0===c.wrap){c.mode=16192;break}for(;k<16;){if(0===h)break e;h--,j+=d[f++]<>>8&255,c.check=cg(c.check,z,2,0),j=0,k=0,c.mode=16181;break}if(c.head&&(c.head.done=!1),!(1&c.wrap)||(((255&j)<<8)+(j>>8))%31){a.msg="incorrect header check",c.mode=16209;break}if((15&j)!==dH){a.msg="unknown compression method",c.mode=16209;break}if(j>>>=4,k-=4,w=8+(15&j),0===c.wbits&&(c.wbits=w),w>15||w>c.wbits){a.msg="invalid window size",c.mode=16209;break}c.dmax=1<>8&1),512&c.flags&&4&c.wrap&&(z[0]=255&j,z[1]=j>>>8&255,c.check=cg(c.check,z,2,0)),j=0,k=0,c.mode=16182;case 16182:for(;k<32;){if(0===h)break e;h--,j+=d[f++]<>>8&255,z[2]=j>>>16&255,z[3]=j>>>24&255,c.check=cg(c.check,z,4,0)),j=0,k=0,c.mode=16183;case 16183:for(;k<16;){if(0===h)break e;h--,j+=d[f++]<>8),512&c.flags&&4&c.wrap&&(z[0]=255&j,z[1]=j>>>8&255,c.check=cg(c.check,z,2,0)),j=0,k=0,c.mode=16184;case 16184:if(1024&c.flags){for(;k<16;){if(0===h)break e;h--,j+=d[f++]<>>8&255,c.check=cg(c.check,z,2,0)),j=0,k=0}else c.head&&(c.head.extra=null);c.mode=16185;case 16185:if(1024&c.flags&&((n=c.length)>h&&(n=h),n&&(c.head&&(w=c.head.extra_len-c.length,c.head.extra||(c.head.extra=new Uint8Array(c.head.extra_len)),c.head.extra.set(d.subarray(f,f+n),w)),512&c.flags&&4&c.wrap&&(c.check=cg(c.check,d,n,f)),h-=n,f+=n,c.length-=n),c.length))break e;c.length=0,c.mode=16186;case 16186:if(2048&c.flags){if(0===h)break e;n=0;do w=d[f+n++],c.head&&w&&c.length<65536&&(c.head.name+=String.fromCharCode(w));while(w&&n>9&1,c.head.done=!0),a.adler=c.check=0,c.mode=16191;break;case 16189:for(;k<32;){if(0===h)break e;h--,j+=d[f++]<>>=7&k,k-=7&k,c.mode=16206;break}for(;k<3;){if(0===h)break e;h--,j+=d[f++]<>>=1)){case 0:c.mode=16193;break;case 1:if(dS(c),c.mode=16199,b===dz){j>>>=2,k-=2;break e}break;case 2:c.mode=16196;break;case 3:a.msg="invalid block type",c.mode=16209}j>>>=2,k-=2;break;case 16193:for(j>>>=7&k,k-=7&k;k<32;){if(0===h)break e;h--,j+=d[f++]<>>16^65535)){a.msg="invalid stored block lengths",c.mode=16209;break}if(c.length=65535&j,j=0,k=0,c.mode=16194,b===dz)break e;case 16194:c.mode=16195;case 16195:if(n=c.length){if(n>h&&(n=h),n>i&&(n=i),0===n)break e;e.set(d.subarray(f,f+n),g),h-=n,f+=n,i-=n,g+=n,c.length-=n;break}c.mode=16191;break;case 16196:for(;k<14;){if(0===h)break e;h--,j+=d[f++]<>>=5,k-=5,c.ndist=1+(31&j),j>>>=5,k-=5,c.ncode=4+(15&j),j>>>=4,k-=4,c.nlen>286||c.ndist>30){a.msg="too many length or distance symbols",c.mode=16209;break}c.have=0,c.mode=16197;case 16197:for(;c.have>>=3,k-=3}for(;c.have<19;)c.lens[C[c.have++]]=0;if(c.lencode=c.lendyn,c.lenbits=7,A={bits:c.lenbits},x=dw(0,c.lens,0,19,c.lencode,0,c.work,A),c.lenbits=A.bits,x){a.msg="invalid code lengths set",c.mode=16209;break}c.have=0,c.mode=16198;case 16198:for(;c.have>>24,r=y>>>16&255,s=65535&y,!(q<=k);){if(0===h)break e;h--,j+=d[f++]<>>=q,k-=q,c.lens[c.have++]=s;else{if(16===s){for(B=q+2;k>>=q,k-=q,0===c.have){a.msg="invalid bit length repeat",c.mode=16209;break}w=c.lens[c.have-1],n=3+(3&j),j>>>=2,k-=2}else if(17===s){for(B=q+3;k>>=q,k-=q,w=0,n=3+(7&j),j>>>=3,k-=3}else{for(B=q+7;k>>=q,k-=q,w=0,n=11+(127&j),j>>>=7,k-=7}if(c.have+n>c.nlen+c.ndist){a.msg="invalid bit length repeat",c.mode=16209;break}for(;n--;)c.lens[c.have++]=w}}if(16209===c.mode)break;if(0===c.lens[256]){a.msg="invalid code -- missing end-of-block",c.mode=16209;break}if(c.lenbits=9,A={bits:c.lenbits},x=dw(1,c.lens,0,c.nlen,c.lencode,0,c.work,A),c.lenbits=A.bits,x){a.msg="invalid literal/lengths set",c.mode=16209;break}if(c.distbits=6,c.distcode=c.distdyn,A={bits:c.distbits},x=dw(2,c.lens,c.nlen,c.ndist,c.distcode,0,c.work,A),c.distbits=A.bits,x){a.msg="invalid distances set",c.mode=16209;break}if(c.mode=16199,b===dz)break e;case 16199:c.mode=16200;case 16200:if(h>=6&&i>=258){a.next_out=g,a.avail_out=i,a.next_in=f,a.avail_in=h,c.hold=j,c.bits=k,dr(a,m),g=a.next_out,e=a.output,i=a.avail_out,f=a.next_in,d=a.input,h=a.avail_in,j=c.hold,k=c.bits,16191===c.mode&&(c.back=-1);break}for(c.back=0;q=(y=c.lencode[j&(1<>>24,r=y>>>16&255,s=65535&y,!(q<=k);){if(0===h)break e;h--,j+=d[f++]<>t)])>>>24,r=y>>>16&255,s=65535&y,!(t+q<=k);){if(0===h)break e;h--,j+=d[f++]<>>=t,k-=t,c.back+=t}if(j>>>=q,k-=q,c.back+=q,c.length=s,0===r){c.mode=16205;break}if(32&r){c.back=-1,c.mode=16191;break}if(64&r){a.msg="invalid literal/length code",c.mode=16209;break}c.extra=15&r,c.mode=16201;case 16201:if(c.extra){for(B=c.extra;k>>=c.extra,k-=c.extra,c.back+=c.extra}c.was=c.length,c.mode=16202;case 16202:for(;q=(y=c.distcode[j&(1<>>24,r=y>>>16&255,s=65535&y,!(q<=k);){if(0===h)break e;h--,j+=d[f++]<>t)])>>>24,r=y>>>16&255,s=65535&y,!(t+q<=k);){if(0===h)break e;h--,j+=d[f++]<>>=t,k-=t,c.back+=t}if(j>>>=q,k-=q,c.back+=q,64&r){a.msg="invalid distance code",c.mode=16209;break}c.offset=s,c.extra=15&r,c.mode=16203;case 16203:if(c.extra){for(B=c.extra;k>>=c.extra,k-=c.extra,c.back+=c.extra}if(c.offset>c.dmax){a.msg="invalid distance too far back",c.mode=16209;break}c.mode=16204;case 16204:if(0===i)break e;if(n=m-i,c.offset>n){if((n=c.offset-n)>c.whave&&c.sane){a.msg="invalid distance too far back",c.mode=16209;break}n>c.wnext?(n-=c.wnext,o=c.wsize-n):o=c.wnext-n,n>c.length&&(n=c.length),p=c.window}else p=e,o=g-c.offset,n=c.length;n>i&&(n=i),i-=n,c.length-=n;do e[g++]=p[o++];while(--n)0===c.length&&(c.mode=16200);break;case 16205:if(0===i)break e;e[g++]=c.length,i--,c.mode=16200;break;case 16206:if(c.wrap){for(;k<32;){if(0===h)break e;h--,j|=d[f++]<=0&&b.windowBits<16&&(b.windowBits=-b.windowBits,0===b.windowBits&&(b.windowBits=-15)),!(b.windowBits>=0&&b.windowBits<16)||a&&a.windowBits||(b.windowBits+=32),b.windowBits>15&&b.windowBits<48&&(15&b.windowBits||(b.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new dd,this.strm.avail_out=0;let c=dU.inflateInit2(this.strm,b.windowBits);if(c!==dZ||(this.header=new dV,dU.inflateGetHeader(this.strm,this.header),b.dictionary&&("string"==typeof b.dictionary?b.dictionary=da(b.dictionary):"[object ArrayBuffer]"===dW.call(b.dictionary)&&(b.dictionary=new Uint8Array(b.dictionary)),b.raw&&(c=dU.inflateSetDictionary(this.strm,b.dictionary))!==dZ)))throw Error(ch[c])}function d4(a,b){let c=new d3(b);if(c.push(a),c.err)throw c.msg||ch[c.err];return c.result}d3.prototype.push=function(a,b){let c=this.strm,d=this.options.chunkSize,e=this.options.dictionary,f,g,h;if(this.ended)return!1;for(g=b=== ~~b?b:!0===b?dY:dX,"[object ArrayBuffer]"===dW.call(a)?c.input=new Uint8Array(a):c.input=a,c.next_in=0,c.avail_in=c.input.length;;){for(0===c.avail_out&&(c.output=new Uint8Array(d),c.next_out=0,c.avail_out=d),(f=dU.inflate(c,g))===d_&&e&&((f=dU.inflateSetDictionary(c,e))===dZ?f=dU.inflate(c,g):f===d1&&(f=d_));c.avail_in>0&&f===d$&&c.state.wrap>0&&0!==a[c.next_in];)dU.inflateReset(c),f=dU.inflate(c,g);switch(f){case d0:case d1:case d_:case d2:return this.onEnd(f),this.ended=!0,!1}if(h=c.avail_out,c.next_out&&(0===c.avail_out||f===d$)){if("string"===this.options.to){let i=dc(c.output,c.next_out),j=c.next_out-i,k=db(c.output,i);c.next_out=j,c.avail_out=d-j,j&&c.output.set(c.output.subarray(i,i+j),0),this.onData(k)}else this.onData(c.output.length===c.next_out?c.output:c.output.subarray(0,c.next_out))}if(f!==dZ||0!==h){if(f===d$)return f=dU.inflateEnd(this.strm),this.onEnd(f),this.ended=!0,!0;if(0===c.avail_in)break}}return!0},d3.prototype.onData=function(a){this.chunks.push(a)},d3.prototype.onEnd=function(a){a===dZ&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=c5(this.chunks)),this.chunks=[],this.err=a,this.msg=this.strm.msg};let{Deflate:d5,deflate:d6,deflateRaw:d7,gzip:d8}={Deflate:dp,deflate:dq,deflateRaw:function(a,b){return(b=b||{}).raw=!0,dq(a,b)},gzip:function(a,b){return(b=b||{}).gzip=!0,dq(a,b)},constants:ci},{Inflate:d9,inflate:ea,inflateRaw:eb,ungzip:ec}={Inflate:d3,inflate:d4,inflateRaw:function(a,b){return(b=b||{}).raw=!0,d4(a,b)},ungzip:d4,constants:ci};var ed,ee,ef={Deflate:d5,deflate:d6,deflateRaw:d7,gzip:d8,Inflate:d9,inflate:ea,inflateRaw:eb,ungzip:ec,constants:ci},eg=function(a){return i(void 0,void 0,void 0,function(){var b,c;return j(this,function(d){if(b=ef.ungzip(a),"undefined"!=typeof TextDecoder)try{return[2,new TextDecoder("utf-8").decode(new Uint8Array(b))]}catch(e){}return c=8192,[2,Array.from({length:Math.ceil(b.length/c)},function(a,d){var e=d*c,f=b.slice(e,e+c);return String.fromCharCode.apply(null,f)}).join("")]})})},eh=function(a){return i(void 0,void 0,void 0,function(){var b;return j(this,function(c){switch(c.label){case 0:return c.trys.push([0,2,,3]),[4,a()];case 1:return c.sent(),[3,3];case 2:if(!((b=c.sent())instanceof G))throw b;return b.throwOutside(),[3,3];case 3:return[2]}})})},ei=function(a){return i(void 0,void 0,void 0,function(){return j(this,function(b){switch(b.label){case 0:return b.trys.push([0,2,,3]),[4,a()];case 1:case 2:return b.sent(),[3,3];case 3:return[2]}})})},ej=function(a){function b(b){var c=a.call(this)||this;return c.retryAfterTime=1e3*b.retry_after,c.reasonCode=b.reason_code,c.message=b.message,c}return f(b,a),b}(aH);(ee=ed||(ed={})).CONNECTING="CONNECTING",ee.OPEN="OPEN",ee.CLOSED="CLOSED";var ek,el,em=function(a){function b(b,c){var d=c.sdkState,e=c.dispatcher,f=c.logger,g=a.call(this)||this;return g.lastActive=0,g._iid=b,g._sdkState=d,g._dispatcher=e,g._logger=f,g}return f(b,a),Object.defineProperty(b.prototype,"isOpen",{get:function(){return this.connectionState===ed.OPEN},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"connectionState",{get:function(){if(this._ws)switch(this._ws.readyState){case 0:return ed.CONNECTING;case 1:return ed.OPEN}return ed.CLOSED},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"ws",{get:function(){var a;return null!==(a=this._ws)&& void 0!==a?a:null},enumerable:!1,configurable:!0}),b.prototype._handleMessage=function(a){var b=this;a.split("\n").forEach(function(a){if(a){var c=bi.createFromRawMessage(b._iid,a);if(b._logger.debug("receive websocket event",c),"LOGI"===c.code)b.dispatch("message",c);else if("PONG"===c.code)b.dispatch("pong");else if("EXPR"===c.code){if(c.payload){var d=new bh(c.payload);d.expiresIn>=0&&b._dispatcher.dispatch(d)}}else if("BUSY"===c.code){if(c.payload){var e=new ej(c.payload);b._dispatcher.dispatch(e)}}else"NOOP"===c.code||b.dispatch("message",c)}})},b.prototype.connect=function(a,b){return void 0===b&&(b=""),i(this,void 0,void 0,function(){var e=this;return j(this,function(f){switch(f.label){case 0:return"function"==typeof fetch?[3,2]:[4,c.e(9098).then(c.bind(c,29098))];case 1:f.sent(),f.label=2;case 2:return ei(function(){return i(e,void 0,void 0,function(){return j(this,function(a){return fetch(this._sdkState.api.host).catch(function(){}),[2]})})}),this._ws=new WebSocket(a,encodeURIComponent(b)),this._ws.onopen=function(){e._logger.debug("websocket open"),e.dispatch("open")},this._ws.onmessage=function(a){return i(e,void 0,void 0,function(){var b,c,e,f,g,h,k,l=this;return j(this,function(m){switch(m.label){case 0:return(null===(k=this._sdkState.websocket)|| void 0===k?void 0:k.compression)?a.data instanceof Blob?((b=new FileReader).readAsArrayBuffer(a.data),b.onloadend=function(){return i(l,void 0,void 0,function(){var a,c;return j(this,function(d){switch(d.label){case 0:return d.trys.push([0,2,,3]),[4,eg(b.result)];case 1:return a=d.sent(),this._handleMessage(a),[3,3];case 2:return c=d.sent(),this.error(c),[3,3];case 3:return[2]}})})},[3,12]):[3,1]:[3,13];case 1:if(!(a.data instanceof ArrayBuffer))return[3,6];m.label=2;case 2:return m.trys.push([2,4,,5]),[4,eg(new Uint8Array(a.data))];case 3:return g=m.sent(),this._handleMessage(g),[3,5];case 4:return c=m.sent(),this.error(c),[3,5];case 5:return[3,12];case 6:if(!(void 0!==d&&a.data instanceof d))return[3,11];m.label=7;case 7:return m.trys.push([7,9,,10]),[4,eg(f=(e=a.data).buffer.slice(e.byteOffset,e.byteOffset+e.byteLength))];case 8:return g=m.sent(),this._handleMessage(g),[3,10];case 9:return h=m.sent(),this.error(h),[3,10];case 10:return[3,12];case 11:"string"==typeof a.data&&this._handleMessage(a.data),m.label=12;case 12:return[3,14];case 13:this._handleMessage(a.data),m.label=14;case 14:return[2]}})})},this._ws.onerror=function(){e._logger.debug("websocket error"),e.dispatch("error",G.networkError)},this._ws.onclose=function(a){e._logger.debug("websocket close",a.code,a.reason),e.cleanUpWebSocket(),e.dispatch("close")},this.lastActive=Date.now(),[2]}})})},b.prototype.cleanUpWebSocket=function(){this._ws&&(this._ws.onopen=bH,this._ws.onmessage=bH,this._ws.onerror=bH,this._ws.onclose=bH,this.connectionState!==ed.CLOSED&&this._ws.close(1e3,"Normal Closure"),this._ws=void 0)},b.prototype.disconnect=function(){var a=this;return new Promise(function(b){if(a._ws){if(a.connectionState===ed.CLOSED)return a.cleanUpWebSocket(),void b();a._ws.onclose=null,a._ws.onclose=function(){a.cleanUpWebSocket(),a.dispatch("close"),b()},a._ws.close()}else b()})},b.prototype.forceClose=function(a){void 0===a&&(a=!0),this.cleanUpWebSocket(),a&&this.dispatch("close")},b.prototype.send=function(a){if(!this._ws)throw G.connectionClosed;"PING"!==a.code?this.dispatch("ping-refresh"):this._logger.debug("send ping",a),this._ws.send(a.convertToMessage())},b.prototype.error=function(a){this._logger.debug("websocket error",a),this.dispatch("error",a)},b}(aF),en=function(a){function b(b){var c=b.all,d=b.feed,e=b.custom_types,f=b.ts,g=a.call(this)||this;return g.all=c,g.feed=d,g.customTypes=e,g.ts=f,g}return f(b,a),b}(aH),eo=function(a){function b(b){var c=b.previousMessageId,d=b.messageCreatedAt,e=b.channelUrl,f=a.call(this)||this;return f.previousMessageId=c,f.messageCreatedAt=d,f.channelUrl=e,f}return f(b,a),b}(aH),ep=function(){function a(a,b){var c=b.session,d=b.sdkState,e=b.dispatcher,f=b.logger,g=b.useFetchCompat,h=this;this._ackStateMap=new Map,this._batchableCommandAckStateMap=new Map,this._redundantActionCommands=new Map,this._sdkState=d,this._dispatcher=e,this._logger=f,this.apiClient=new bG(a,{session:c,sdkState:d,dispatcher:e,logger:f,useFetchCompat:void 0!==g&&g}),this.websocketClient=new em(a,{sdkState:d,dispatcher:e,logger:f}),this.websocketClient.on("message",function(a){var b,c;if(a.payload.unread_cnt&&h._dispatcher.dispatch(new en(a.payload.unread_cnt)),("MESG"===a.code||"FILE"===a.code||"ADMM"===a.code||"BRDM"===a.code)&&a.payload.channel_type===ac.GROUP&&a.payload.previous_message_id&&h._dispatcher.dispatch(new eo({previousMessageId:a.payload.previous_message_id,messageCreatedAt:a.payload.ts,channelUrl:a.payload.channel_url})),a.requestId){if(h._ackStateMap.has(a.requestId)){var d=h._ackStateMap.get(a.requestId);"EROR"!==a.code?d.resolve(a):d.reject(new G({code:a.payload.code,message:a.payload.message}))}else if(h._batchableCommandAckStateMap.has(a.requestId)){var e=Date.now();try{for(var f=k(h._batchableCommandAckStateMap.entries()),g=f.next();!g.done;g=f.next()){var i=l(g.value,2),j=(i[0],i[1]);j.channelUrl===a.payload.channel_url&&j.requestTime0?1e3*Math.min(a*Math.pow(c,d-1),b):10}}),d.appInfo=this.appInfo,d.sessionManager.currentUser=this.user,d.connectedAt=this.connectedAt,this.firstConnectedAt||(d.firstConnectedAt=this.connectedAt),d.maxSuperGroupChannelUnreadCount=this.maxUnreadCountOnSuperGroup,d.concurrentCallLimit=this.concurrentCallLimit,d.backOffDelay=this.backOffDelay,d.requestDeduplicator.requestDedupInterval=this.appInfo.requestDedupIntervalMs,d.dispatcher.dispatch(new e$({userProfile:this}))},a}(),e0=function(a){function b(b){var c=b.request,d=b.features,e=b.options,f=b.statConfigInfo,h=a.call(this)||this;return h.request=void 0===c||c,h.features=g({localCache:!0,notification:!0,aiAgent:!0,aiAgentAssertion:!0},void 0===d?{}:d),h.options=g({ingestion:!0},void 0===e?{}:e),h.statConfigInfo=f,h}return f(b,a),b}(aH),e1=function(a){function b(b){var c=a.call(this)||this;return c.configSyncNeeded=!1,c.configSyncNeeded=b,c}return f(b,a),b}(aH),e2=function(a){function b(b,c,d){var e,f,g,h,i=this;return(i=a.call(this,b,c,d)||this).error=null,i.services=[],i.userProfile=new e_(b,d),i.deviceTokenLastDeletedAt=null!==(e=d.device_token_last_deleted_at)&& void 0!==e?e:0,i.key=null!==(f=d.key)&& void 0!==f?f:"",i.ekey=null!==(g=d.ekey)&& void 0!==g?g:"",i.error=d.error?new G(d):null,i.services=null!==(h=d.services)&& void 0!==h?h:[],i.isSessionRefresh="new_key"in d,i}return f(b,a),b.asError=function(a){return new b("","LOGI",g({user_id:"",error:!0},a))},b.prototype.applyTo=function(a){return i(this,void 0,void 0,function(){var b,c,d;return j(this,function(e){switch(e.label){case 0:return this.isSessionRefresh?[2]:this.error?[3,4]:(b=fY.of(a))?(c=b.sessionManager,d=b.dispatcher,[4,c.login(this)]):[3,2];case 1:return e.sent(),this.userProfile.apply(),d.dispatch(new e1(this.userProfile.appInfo.configSyncNeeded)),d.dispatch(new e0({request:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_request_log_publish"),features:{localCache:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_feature_local_cache_log_publish"),notification:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_noti_stats_log_publish"),aiAgent:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_ai_agent_stats_log_publish"),aiAgentAssertion:this.userProfile.appInfo.applicationAttributes.includes("allow_sdk_ai_agent_assertion_log_publish")},options:{ingestion:this.userProfile.appInfo.allowSdkStatsUpload},statConfigInfo:this.userProfile.appInfo.statConfigInfo})),[3,3];case 2:throw G.lostInstance;case 3:return[3,5];case 4:throw this.error;case 5:return[2]}})})},b}(bi),e3=function(){function a(){this.type=ek.NONE,this.name="none"}return a.prototype.run=function(a){return i(this,void 0,void 0,function(){return j(this,function(a){return[2]})})},a.prototype.onConnect=function(a,b){return i(this,void 0,void 0,function(){return j(this,function(a){return[2]})})},a.prototype.onReconnect=function(a,b){return b.resetReconnectCount,i(this,void 0,void 0,function(){return j(this,function(a){return[2]})})},a.prototype.onDisconnect=function(a,b){return b.error,b.autoReconnect,b.cause,i(this,void 0,void 0,function(){return j(this,function(a){return[2]})})},a.prototype.onDisconnectWebSocket=function(a,b){return i(this,void 0,void 0,function(){return j(this,function(a){return[2]})})},a.prototype.onLogout=function(a,b){return i(this,void 0,void 0,function(){return j(this,function(a){return[2]})})},a.prototype.onDelayedConnecting=function(a,b){return b.retryAfterTime,b.reasonCode,b.message,i(this,void 0,void 0,function(){return j(this,function(a){return[2]})})},a}(),e4=function(a){function b(b){void 0===b&&(b={});var c,d=this;return(d=a.call(this)||this).type=ek.LOGOUT,d.name="logout",d._wasPreviouslyConnected=null===(c=b.wasPreviouslyConnected)|| void 0===c||c,d}return f(b,a),b.prototype.run=function(a){return i(this,void 0,void 0,function(){var b,c,d=this;return j(this,function(e){switch(e.label){case 0:return b=Date.now(),c=a.sdkState.userId,[4,a.logout()];case 1:return e.sent(),[4,a.changeState(new fj,b)];case 2:return e.sent(),this._wasPreviouslyConnected&&eh(function(){return i(d,void 0,void 0,function(){return j(this,function(b){return a.connectionHandlers.forEach(function(a){var b;null===(b=a.onDisconnected)|| void 0===b||b.call(a,c)}),[2]})})}),[2]}})})},b}(e3),e5=function(a){function b(b){var c=(void 0===b?{}:b).isAlreadyDisconnected,d=a.call(this)||this;return d.type=ek.EXTERNAL_DISCONNECTED,d.name="externaldisconnected",d._isAlreadyDisconnected=void 0!==c&&c,d}return f(b,a),b.prototype.run=function(a){return i(this,void 0,void 0,function(){var b=this;return j(this,function(c){return a.forceClose(),this._isAlreadyDisconnected||eh(function(){return i(b,void 0,void 0,function(){return j(this,function(b){return a.connectionHandlers.forEach(function(a){var b;null===(b=a.onConnectionLost)|| void 0===b||b.call(a)}),[2]})})}),[2]})})},b.prototype.onConnect=function(a,b){return i(this,void 0,void 0,function(){var c;return j(this,function(d){switch(d.label){case 0:return c=Date.now(),[4,a.disconnect()];case 1:return d.sent(),[4,a.changeState(new ff({authToken:b}),c)];case 2:return d.sent(),[2]}})})},b.prototype.onReconnect=function(a){return i(this,void 0,void 0,function(){var b;return j(this,function(c){switch(c.label){case 0:return b=Date.now(),[4,a.changeState(new fd,b)];case 1:return c.sent(),[2]}})})},b.prototype.onLogout=function(a){return i(this,void 0,void 0,function(){var b;return j(this,function(c){switch(c.label){case 0:return b=Date.now(),[4,a.changeState(new e4,b)];case 1:return c.sent(),[2]}})})},b}(e3),e6=function(a){function b(b){var c=b.event,d=b.reason,e=a.call(this)||this;return e.event=c,e.reason=d,e}return f(b,a),b}(aH);(eY=eX||(eX={})).ExternalSetBackground="ExternalSetBackground",eY.ExternalDisconnectWebSocket="ExternalDisconnectWebSocket",eY.MaxReconnectRetry="MaxReconnectRetry";var e7=function(){function a(a,b){var c=b.sdkState,d=b.cacheContext,e=b.connectionHandlers,f=b.sessionManager,g=b.websocketClient,h=b.dispatcher,i=b.logger,j=b.disableWebSocketCloseEventHandling,k=b.appStateToggleEnabled,l=this;this._disableWebSocketCloseEventHandling=!1,this._appStateToggleEnabled=!0,this._webSocketClosedCause=null,this._logger=i,this._disableWebSocketCloseEventHandling=void 0!==j&&j,this._appStateToggleEnabled=void 0===k||k,this._context=new fn(a,{sdkState:c,cacheContext:d,connectionHandlers:e,sessionManager:f,websocketClient:g,dispatcher:h,logger:i}),this._sdkState=c,this._sessionManager=f,this._websocketClient=g,this._commandDispatcher=h,this._commandDispatcher.on(function(a){var b=l._context.currentState;if(a instanceof ej&&b.type===ek.CONNECTED){var c=a.retryAfterTime,d=a.reasonCode,e=a.message;b.onDelayedConnecting(l._context,{retryAfterTime:c,reasonCode:d,message:e})}})}return a.prototype._registerEventDispatcher=function(){var a=this;this._disableWebSocketCloseEventHandling||(this._clearEventDispatcher(),this._sessionEventDispatcherContext=this._sessionManager.on("refresh",function(){a._webSocketClosedCause===eX.ExternalDisconnectWebSocket||a.isConnecting||a.isConnected||(a._logger.debug("try reconnect by session key refresh"),ei(function(){return i(a,void 0,void 0,function(){return j(this,function(a){switch(a.label){case 0:return[4,this.reconnect()];case 1:return a.sent(),[2]}})})}))}),this._websocketEventDispatcherContext=this._websocketClient.on("close",function(){"foreground"!==a._sdkState.appState||a._webSocketClosedCause||ei(function(){return i(a,void 0,void 0,function(){return j(this,function(a){switch(a.label){case 0:return this._context.currentState.type!==ek.RECONNECTING?[3,3]:this._isPageHidden?(this._logger.debug("ws closed while reconnecting & page hidden; halt reconnect until foreground"),[4,this._context.currentState.onDisconnect(this._context,{autoReconnect:!1})]):[3,2];case 1:a.sent(),a.label=2;case 2:return[2];case 3:return this._sdkState.isAppActive?this._isPageHidden?(this._logger.debug("ws closed while page hidden; disconnect without reconnect until foreground"),[4,this._context.currentState.onDisconnect(this._context,{autoReconnect:!1})]):[3,5]:(this._commandDispatcher.dispatch(new e6({event:"pause",reason:"app is not active"})),[2]);case 4:return a.sent(),[2];case 5:return this._sessionManager.isSessionKeyRefreshing?[3,7]:(this._logger.debug("try reconnect by websocket connection closed"),[4,this.reconnect()]);case 6:return a.sent(),[3,9];case 7:return[4,this.disconnectWebSocket()];case 8:a.sent(),a.label=9;case 9:return[2]}})})})}))},Object.defineProperty(a.prototype,"_isPageHidden",{get:function(){return this._appStateToggleEnabled&&"undefined"!=typeof document&&"hidden"===document.visibilityState},enumerable:!1,configurable:!0}),a.prototype._clearEventDispatcher=function(){this._sessionEventDispatcherContext&&(this._sessionEventDispatcherContext.close(),this._sessionEventDispatcherContext=void 0),this._websocketEventDispatcherContext&&(this._websocketEventDispatcherContext.close(),this._websocketEventDispatcherContext=void 0)},Object.defineProperty(a.prototype,"isConnected",{get:function(){return this._context.currentState.type===ek.CONNECTED},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"isConnecting",{get:function(){var a=this._context.currentState;return a.type===ek.CONNECTING||a.type===ek.RECONNECTING},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"websocketClient",{get:function(){return this._websocketClient},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"shouldReconnectOnForeground",{get:function(){return!this.isConnected&&!this.isConnecting&&!this._sessionManager.isSessionKeyRefreshing&&this._webSocketClosedCause!==eX.ExternalDisconnectWebSocket},enumerable:!1,configurable:!0}),a.prototype.connect=function(a){return i(this,void 0,void 0,function(){var b;return j(this,function(c){switch(c.label){case 0:return b=this._context.currentState,this._webSocketClosedCause=null,[4,b.onConnect(this._context,a)];case 1:return c.sent(),this._registerEventDispatcher(),[2]}})})},a.prototype.reconnect=function(){return i(this,void 0,void 0,function(){var a;return j(this,function(b){switch(b.label){case 0:return a=this._context.currentState,this._webSocketClosedCause=null,[4,a.onReconnect(this._context,{})];case 1:return b.sent(),[2]}})})},a.prototype.resetAndReconnect=function(){return i(this,void 0,void 0,function(){var a;return j(this,function(b){switch(b.label){case 0:return a=this._context.currentState,this._webSocketClosedCause=null,[4,a.onReconnect(this._context,{resetReconnectCount:!0})];case 1:return b.sent(),[2]}})})},a.prototype.background=function(){return i(this,void 0,void 0,function(){var a;return j(this,function(b){switch(b.label){case 0:return a=this._context.currentState,this._webSocketClosedCause=eX.ExternalSetBackground,[4,a.onDisconnect(this._context,{autoReconnect:!1,cause:this._webSocketClosedCause})];case 1:return b.sent(),[2]}})})},a.prototype.disconnect=function(a){return i(this,void 0,void 0,function(){return j(this,function(b){switch(b.label){case 0:return[4,this._context.currentState.onDisconnect(this._context,{error:a,autoReconnect:!0,cause:this._webSocketClosedCause})];case 1:return b.sent(),[2]}})})},a.prototype.disconnectWebSocket=function(a){return void 0===a&&(a=!1),i(this,void 0,void 0,function(){var b;return j(this,function(c){switch(c.label){case 0:return b=this._context.currentState,a&&(this._webSocketClosedCause=eX.ExternalDisconnectWebSocket),[4,b.onDisconnectWebSocket(this._context,{cause:this._webSocketClosedCause})];case 1:return c.sent(),[2]}})})},a.prototype.logout=function(a){return i(this,void 0,void 0,function(){var b;return j(this,function(c){switch(c.label){case 0:return b=this._context.currentState,this._clearEventDispatcher(),[4,b.onLogout(this._context,a)];case 1:return c.sent(),[2]}})})},a}(),e8=function(a){function b(b){var c=b.retryAfterTime,d=b.reasonCode,e=b.message,f=b.authToken,g=a.call(this)||this;return g.type=ek.DELAYED_CONNECTING,g.name="delayedconnecting",g._timerStartTime=0,g._retryAfterTime=c,g._reasonCode=d,g._message=e,g._authToken=f,g}return f(b,a),b.prototype._clearDelayConnectTimer=function(){this._delayConnectTimer&&(clearTimeout(this._delayConnectTimer),this._delayConnectTimer=void 0),this._timerStartTime=0},b.prototype._startDelayedConnectTimer=function(a){var b=this;this._clearDelayConnectTimer(),this._timerStartTime=Date.now(),this._delayConnectTimer=setTimeout(function(){var c=Date.now();clearTimeout(b._delayConnectTimer),b._delayConnectTimer=void 0,b._timerStartTime=0,a.changeState(new fd({authToken:b._authToken,isSoftRateLimited:!0}),c).catch(function(){})},this._retryAfterTime),a.connectionHandlers.forEach(function(a){var c;null===(c=a.onConnectionDelayed)|| void 0===c||c.call(a,Math.ceil(b._retryAfterTime/1e3))})},b.prototype._calculateRemainDelayConnectTime=function(){this._delayConnectTimer&&(this._retryAfterTime=this._retryAfterTime-(Date.now()-this._timerStartTime))},b.prototype._throwDelayedConnectingError=function(){var a=new G({code:n.DELAYED_CONNECTING,message:this._message});throw a.setDetail(JSON.stringify({retry_after:Math.ceil(this._retryAfterTime/1e3),reason_code:this._reasonCode,message:this._message})),a},b.prototype.run=function(a){return i(this,void 0,void 0,function(){return j(this,function(b){return this._startDelayedConnectTimer(a),[2]})})},b.prototype.onConnect=function(a,b){return i(this,void 0,void 0,function(){return j(this,function(b){return this._delayConnectTimer&&(this._calculateRemainDelayConnectTime(),this._startDelayedConnectTimer(a),this._throwDelayedConnectingError()),[2]})})},b.prototype.onReconnect=function(a){return i(this,void 0,void 0,function(){return j(this,function(b){return this._delayConnectTimer&&(this._calculateRemainDelayConnectTime(),this._startDelayedConnectTimer(a),this._throwDelayedConnectingError()),[2]})})},b.prototype.onDelayedConnecting=function(a,b){var c=b.retryAfterTime,d=b.reasonCode,e=b.message;return i(this,void 0,void 0,function(){return j(this,function(b){return this._retryAfterTime=c,this._reasonCode=d,this._message=e,this._startDelayedConnectTimer(a),[2]})})},b.prototype.onDisconnect=function(a,b){var c=b.autoReconnect,d=void 0!==c&&c,e=b.cause,f=void 0===e?null:e;return i(this,void 0,void 0,function(){var b;return j(this,function(c){switch(c.label){case 0:return b=Date.now(),this._clearDelayConnectTimer(),f!==eX.ExternalSetBackground?[3,2]:[4,a.changeState(new e9({autoReconnect:d,retryAfterTime:this._retryAfterTime,disconnectedTime:b,reasonCode:this._reasonCode,message:this._message}),b)];case 1:case 3:return c.sent(),[3,6];case 2:return a.hasSession?[4,a.changeState(new e9({autoReconnect:d}),b)]:[3,4];case 4:return[4,a.changeState(new e4,b)];case 5:c.sent(),c.label=6;case 6:return[2]}})})},b.prototype.onDisconnectWebSocket=function(a){return i(this,void 0,void 0,function(){var b;return j(this,function(c){switch(c.label){case 0:return b=Date.now(),this._clearDelayConnectTimer(),[4,a.changeState(new e5,b)];case 1:return c.sent(),[2]}})})},b.prototype.onLogout=function(a){return i(this,void 0,void 0,function(){var b;return j(this,function(c){switch(c.label){case 0:return b=Date.now(),this._clearDelayConnectTimer(),[4,a.changeState(new e4,b)];case 1:return c.sent(),[2]}})})},b}(e3),e9=function(a){function b(b){var c=a.call(this)||this;return c.type=ek.INTERNAL_DISCONNECTED,c.name="internaldisconnected",c._autoReconnect=!1,c._autoReconnect=b.autoReconnect,c._retryAfter=b.retryAfterTime,c._disconnectedTime=b.disconnectedTime,c._reasonCode=b.reasonCode,c._message=b.message,c}return f(b,a),b.prototype._getDelayedConnectTime=function(a){return this._retryAfter&&this._disconnectedTime?Math.ceil((this._retryAfter-(a-this._disconnectedTime))/1e3):-1},b.prototype.run=function(a){return i(this,void 0,void 0,function(){var b,c=this;return j(this,function(d){switch(d.label){case 0:return b=Date.now(),[4,a.disconnect()];case 1:return d.sent(),eh(function(){return i(c,void 0,void 0,function(){return j(this,function(b){return a.connectionHandlers.forEach(function(a){var b;null===(b=a.onConnectionLost)|| void 0===b||b.call(a)}),[2]})})}),this._autoReconnect?[4,a.changeState(new fd,b)]:[3,3];case 2:d.sent(),d.label=3;case 3:return[2]}})})},b.prototype.onConnect=function(a,b){return i(this,void 0,void 0,function(){var c;return j(this,function(d){switch(d.label){case 0:return c=Date.now(),[4,a.disconnect()];case 1:return d.sent(),[4,a.changeState(new ff({authToken:b}),c)];case 2:return d.sent(),[2]}})})},b.prototype.onReconnect=function(a){return i(this,void 0,void 0,function(){var b,c;return j(this,function(d){switch(d.label){case 0:return b=Date.now(),(c=this._getDelayedConnectTime(b))>0?[4,a.changeState(new e8({retryAfterTime:c,reasonCode:this._reasonCode,message:this._message}),b)]:[3,2];case 1:return d.sent(),[3,4];case 2:return[4,a.changeState(new fd,b)];case 3:d.sent(),d.label=4;case 4:return[2]}})})},b.prototype.onDisconnectWebSocket=function(a){return i(this,void 0,void 0,function(){var b;return j(this,function(c){switch(c.label){case 0:return b=Date.now(),[4,a.changeState(new e5({isAlreadyDisconnected:!0}),b)];case 1:return c.sent(),[2]}})})},b.prototype.onLogout=function(a){return i(this,void 0,void 0,function(){var b;return j(this,function(c){switch(c.label){case 0:return b=Date.now(),[4,a.changeState(new e4,b)];case 1:return c.sent(),[2]}})})},b}(e3),fa=function(a){return i(void 0,void 0,void 0,function(){return j(this,function(b){return[2,new Promise(function(b){return setTimeout(b,a)})]})})},fb=function(){function a(){}return a.prototype.calcTimeout=function(){return 0},a}(),fc=function(a,b,c){return void 0===c&&(c=new fb),i(void 0,void 0,void 0,function(){var d,e,f,g,h,i;return j(this,function(j){switch(j.label){case 0:d=0,e=null,f=function(a){return e=null!=a?a:Error("Halted")},g=function(){d=0},j.label=1;case 1:if(!(-1===b||d=this._stateUpdatedAt?(this._currentState=a,this._stateUpdatedAt=b,this._dispatcher.dispatch(new eu({stateType:a.type})),this._logger.debug("connection state changes to ".concat(a.name)),[4,this._currentState.run(this)]):[3,2];case 1:return c.sent(),[2,!0];case 2:return[2,!1]}})})},b.prototype._tryResolveConnectionRequest=function(){var a;return i(this,void 0,void 0,function(){var b;return j(this,function(c){switch(c.label){case 0:return b=this._unresolvedLogi,this._websocketClient.isOpen&&b?(this._unresolvedLogi=void 0,this._logiReceivedAt=Date.now(),b.error?[3,2]:[4,b.applyTo(this._iid)]):[3,3];case 1:return c.sent(),this._statLogConnection(),null===(a=this._pinger)|| void 0===a||a.start(),this._connectionRequestQueue.forEach(function(a){return a.resolve()}),this._connectionRequestQueue=[],this.sdkState.appState="foreground",[3,3];case 2:this._logger.warn("login failed: ".concat(b.error)),this._rejectConnectionRequest(b.error),c.label=3;case 3:return[2]}})})},b.prototype._rejectConnectionRequest=function(a){var b;if(null===(b=this._pinger)|| void 0===b||b.stop(),this.clearLoginTimer(),this._connectionRequestQueue.length>0){var c=this._connectionRequestQueue;this._connectionRequestQueue=[],c.forEach(function(b){return b.reject(a)}),this._statLogConnection(a)}},b.prototype._url=function(a){var b,c=a.configTs,d=this.sdkState,e=d.appId,f=d.appVersion,g=d.userId,h=d.extensions,i=d.sendbirdRuntimeEnvironment,j=this.cacheContext.localCacheEnabled,k=this._sessionManager.session,l=null===(b=this.sdkState.websocket)|| void 0===b?void 0:b.compression,m=!!(null!=h?h:{}).sb_uikit,n=bB.userAgentWithExtension(h);return"".concat(this.sdkState.websocket.host,"/?p=JS&pv=").concat(encodeURIComponent(q.OS_VERSION),"&sv=").concat(encodeURIComponent(q.SDK_VERSION),"&ai=").concat(e).concat(f?"&av=".concat(f):"").concat(k.hasSession?"":"&user_id=".concat(encodeURIComponent(g)),"&pmce=").concat(l?1:0,"&active=1&device_token_types=").concat(encodeURIComponent("gcm,huawei,apns"),"&SB-User-Agent=").concat(n,"&SB-SDK-User-Agent=").concat(encodeURIComponent(bB.sendbirdSdkUserAgentWithExtension(i)),"&Request-Sent-Timestamp=").concat(Date.now().toString(),"&include_extra_data=").concat(encodeURIComponent(String(fm))).concat(this._sessionManager.handler?"&expiring_session=1":"","&use_local_cache=").concat(j?1:0,"&include_poll_details=1").concat(m?"&uikit_config=1":"","&config_ts=").concat(c)},b.prototype._statLogConnection=function(a){var b,c;this._dispatcher.dispatch(new bo(new bw({type:bc.WEBSOCKET_CONNECT,data:{host_url:null===(b=this.sdkState.websocket)|| void 0===b?void 0:b.host,success:!a,latency:this._connectedAt>0?this._connectedAt-this._connectingAt:Date.now()-this._connectingAt,logi_latency:this._logiReceivedAt>0?this._logiReceivedAt-this._connectingAt:void 0,connection_id:this._currentConnectionKey,accum_trial:this._currentConnectionRetryCount,is_soft_rate_limited:null!==(c=this._isSoftRateLimited)&& void 0!==c?c:void 0,error_code:null==a?void 0:a.code,error_description:(null==a?void 0:a.code)===n.DELAYED_CONNECTING?null==a?void 0:a.detail:null==a?void 0:a.message}})))},b.prototype.connect=function(a){var b;return void 0===a&&(a={}),i(this,void 0,void 0,function(){var c,d,e,f,g,h,i,k,l,m,n,o,p=this;return j(this,function(j){switch(j.label){case 0:return this._unresolvedLogi=void 0,this._logiProcessingTimer&&(clearTimeout(this._logiProcessingTimer),this._logiProcessingTimer=void 0,this._rejectConnectionRequest(G.connectionCanceled)),c=new bC,e=void 0===(d=a.authToken)?"":d,f=a.connectionKey,g=void 0===f?aD():f,h=a.connectionRetryCount,i=void 0===h?1:h,k=a.isSoftRateLimited,this._connectionRequestQueue.push(c),1!==this._connectionRequestQueue.length?[3,2]:(this._currentConnectionKey=g,this._currentConnectionRetryCount=i,this._isSoftRateLimited=k,this._connectingAt=Date.now(),this._connectedAt=0,this._logiReceivedAt=0,this._loginTimer=setTimeout(function(){p._loginTimer=void 0,p._rejectConnectionRequest(G.loginTimeout)},null===(b=this.sdkState.websocket)|| void 0===b?void 0:b.responseTimeout),l=this._sessionManager.session,e&&(l.authToken=e,l.sessionKey=void 0),m=0,[4,this.cacheContext.preference.get(eJ(this.sdkState.appId))]);case 1:(n=j.sent())&&(m=n.configTs),o=this._url({configTs:m}),l.sessionKey||l.authToken?this._websocketClient.connect(o,JSON.stringify(l.hasSession?{auth:l.sessionKey}:{token:l.authToken})):this._websocketClient.connect(o,JSON.stringify({})),j.label=2;case 2:return[2,c.promise]}})})},b.prototype.cancelConnectForRetry=function(){this._dispatcher.dispatch(e2.asError(G.connectionRenew))},b.prototype.disconnect=function(){return i(this,void 0,void 0,function(){return j(this,function(a){switch(a.label){case 0:return this._unresolvedLogi=void 0,[4,this._websocketClient.disconnect()];case 1:return a.sent(),[2]}})})},b.prototype.forceClose=function(){var a;this._unresolvedLogi=void 0,null===(a=this._pinger)|| void 0===a||a.stop(),this._websocketClient.ws&&this._websocketClient.forceClose()},b.prototype.logout=function(){return i(this,void 0,void 0,function(){return j(this,function(a){switch(a.label){case 0:return this.sdkState.userId=void 0,this.forceClose(),[4,this._sessionManager.clear()];case 1:return a.sent(),[2]}})})},b.prototype.clearLoginTimer=function(){this._loginTimer&&(clearTimeout(this._loginTimer),this._loginTimer=void 0)},b}(aF),fo=function(a){function b(b){var c=b.appId,d=b.userId,e=b.includeUIKitConfig,f=b.localCacheEnabled,g=b.expiringSession,h=b.configTs,i=a.call(this)||this;return i.path="".concat(aN,"/").concat(encodeURIComponent(d),"/authentication"),i.method=aK.POST,i.params=aI({expiring_session:!!(void 0===g||g),include_logi:!0,include_extra_data:String(fm),uikit_config:void 0!==e&&e,use_local_cache:void 0===f||f,app_id:c,config_ts:void 0===h?0:h}),i.requireAuth=!1,i}return f(b,a),b}(be),fp=function(a){function b(b,c){var d=a.call(this,b,c)||this;return d.logi=new e2(b,"LOGI",c),d}return f(b,a),b}(bf);(fi=fh||(fh={}))[fi.ALL=0]="ALL",fi[fi.WEBSOCKET=1]="WEBSOCKET",fi[fi.API=2]="API";var fq,fr,fs,ft,fu=[bk,fo],fv=function(){function a(a,b){var c=b.session,d=b.sdkState,e=b.dispatcher,f=b.logger,g=b.useFetchCompat,h=this;this._currentConnectionStateType=ek.INITIALIZED,this._lazyCallQueue=[],this.commandRouter=new ep(a,{session:c,sdkState:d,dispatcher:e,logger:f,useFetchCompat:void 0!==g&&g}),this._session=c,this._logger=f,this._dispatcher=e,this._dispatcher.on(function(a){var b,c,d;if(a instanceof eu){var e=a.stateType;switch(h._currentConnectionStateType=e,e){case ek.CONNECTED:h._resolveLazyCallQueue();break;case ek.INITIALIZED:case ek.INTERNAL_DISCONNECTED:case ek.EXTERNAL_DISCONNECTED:case ek.LOGOUT:h._session.isRefreshing||h._rejectLazyCallQueue((null===(d=h._session)|| void 0===d?void 0:d.hasSession)?G.connectionClosed:G.connectionRequired)}}else if(a instanceof ev)h._resolveLazyCallQueue(h._session.hasChatServicePermission?fh.ALL:fh.API);else if(a instanceof ew||a instanceof ex)h._rejectLazyCallQueue(G.connectionClosed);else if(a instanceof bp){var f=a.request,g=a.deferred,i=a.error;try{for(var j=k(fu),l=j.next();!l.done;l=j.next())if(f instanceof l.value)return void g.reject(i)}catch(m){b={error:m}}finally{try{l&&!l.done&&(c=j.return)&&c.call(j)}finally{if(b)throw b.error}}h._lazyCallQueue.push({command:f,deferred:g})}})}return Object.defineProperty(a.prototype,"isReady",{get:function(){return this._currentConnectionStateType===ek.CONNECTED},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"isLazyCallActivated",{get:function(){return this._currentConnectionStateType===ek.CONNECTING||this._currentConnectionStateType===ek.RECONNECTING||this._session.isRefreshing},enumerable:!1,configurable:!0}),a.prototype._classifyLazyCallQueueByScope=function(a){var b,c=[],d=[];switch(a){case fh.ALL:b=null;break;case fh.WEBSOCKET:b=bj;break;case fh.API:b=be}var e=!1;return this._lazyCallQueue.forEach(function(a){!b||a.command instanceof b||(e=!0),e?d.push(a):c.push(a)}),[c,d]},a.prototype._mergeLazyCallScope=function(a,b){return void 0===a?b:a===b?a:fh.ALL},a.prototype._clearWebSocketOpenFlushWait=function(){var a,b=null!==(a=this._waitingForWebSocketOpenFlushScope)&& void 0!==a?a:fh.ALL;return this._webSocketOpenFlushContext&&(this._webSocketOpenFlushContext.close(),this._webSocketOpenFlushContext=void 0),this._webSocketOpenFlushTimeout&&(clearTimeout(this._webSocketOpenFlushTimeout),this._webSocketOpenFlushTimeout=void 0),this._waitingForWebSocketOpenFlushScope=void 0,b},a.prototype._resolveLazyCallQueueAfterWebSocketOpen=function(){var a=this._clearWebSocketOpenFlushWait();this._resolveLazyCallQueue(a)},a.prototype._waitForWebSocketOpenToResolveLazyQueue=function(a){var b=this;this._waitingForWebSocketOpenFlushScope=this._mergeLazyCallScope(this._waitingForWebSocketOpenFlushScope,a),this.commandRouter.websocketClient.isOpen?this._resolveLazyCallQueueAfterWebSocketOpen():this._webSocketOpenFlushContext||(this._webSocketOpenFlushContext=this.commandRouter.websocketClient.once("open",function(){b._resolveLazyCallQueueAfterWebSocketOpen()}),this._webSocketOpenFlushTimeout=setTimeout(function(){var a=b._clearWebSocketOpenFlushWait();b._resolveLazyCallQueue(a)},1e4),this.commandRouter.websocketClient.isOpen&&this._resolveLazyCallQueueAfterWebSocketOpen())},a.prototype._resolveLazyCallQueue=function(a){var b=this;void 0===a&&(a=fh.ALL);var c=l(this._classifyLazyCallQueueByScope(a),2),d=c[0],e=c[1];this._lazyCallQueue=e;var f=[];d.forEach(function(a){return i(b,void 0,void 0,function(){var b,c,d,e,g,h=this;return j(this,function(i){switch(i.label){case 0:if(b=a.command,c=a.deferred,d=a.timeout,b instanceof bj&&!this.commandRouter.websocketClient.isOpen)return a.timeout||(a.timeout=setTimeout(function(){return h.timeout(b.requestId)},1e4)),f.push(a),[2];d&&clearTimeout(d),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.send(b)];case 2:return e=i.sent(),c.resolve(e),[3,4];case 3:return g=i.sent(),c.reject(g),[3,4];case 4:return[2]}})})}),f.length>0&&(this._lazyCallQueue=f.concat(this._lazyCallQueue),this._waitForWebSocketOpenToResolveLazyQueue(a))},a.prototype._rejectLazyCallQueue=function(a,b){var c=this;void 0===b&&(b=fh.ALL),b!==fh.API&&this._clearWebSocketOpenFlushWait();var d=l(this._classifyLazyCallQueueByScope(b),2),e=d[0],f=d[1];this._lazyCallQueue=f,e.forEach(function(b){return i(c,void 0,void 0,function(){var c,d;return j(this,function(e){return c=b.deferred,d=b.timeout,clearTimeout(d),c.reject(a),[2]})})})},a.prototype.send=function(a){return i(this,void 0,void 0,function(){var b,c,d=this;return j(this,function(e){switch(e.label){case 0:return a instanceof bj?this.isReady?(this._logger.debug("send websocket request",a),[4,this.commandRouter.send(a)]):[3,2]:[3,4];case 1:case 5:case 7:return[2,e.sent()];case 2:if(this.isLazyCallActivated)return this._logger.debug("wait websocket request",a),b=new bC,this._lazyCallQueue.push({command:a,deferred:b,timeout:setTimeout(function(){return d.timeout(a.requestId)},1e4)}),[2,b.promise];throw this._logger.debug("fail websocket request"),G.connectionRequired;case 3:case 9:return[3,11];case 4:return a instanceof be?this._session.hasSession?(this._logger.debug("send api request",a),[4,this.commandRouter.send(a)]):[3,6]:[3,10];case 6:return a.hasSessionKey?(this._logger.debug("send api request with tmp session key",a),[4,this.commandRouter.send(a)]):[3,8];case 8:if(this.isLazyCallActivated)return this._logger.debug("wait api request",a),b=new bC,this._lazyCallQueue.push({command:a,deferred:b,timeout:setTimeout(function(){return d.timeout(a.requestId)},1e4)}),[2,b.promise];throw c=G.connectionRequired,this._logger.debug("fail api request",c),c;case 10:throw G.invalidCommand;case 11:return[2]}})})},a.prototype.forceSend=function(a){return i(this,void 0,void 0,function(){return j(this,function(b){switch(b.label){case 0:return this._logger.debug("send forced request",a),a instanceof bj||a instanceof be?[4,this.commandRouter.send(a)]:[3,2];case 1:return[2,b.sent()];case 2:throw G.invalidCommand}})})},a.prototype.timeout=function(a){this._logger.debug("timeout request",a);var b=this._lazyCallQueue.findIndex(function(b){return b.command.requestId===a});b> -1&&(this._lazyCallQueue[b].deferred.reject(G.connectionRequired),this._lazyCallQueue.splice(b,1))},a.prototype.cancel=function(a,b){this._logger.debug("cancel api request",a),this.commandRouter.cancel(a,b)},a.prototype.cancelAll=function(a){this._logger.debug("cancel all api requests"),this.commandRouter.cancelAll(a)},a}(),fw="sendbird@devicetokens",fx=function(){function a(a){var b=a.type,c=a.token,d=a.device_os,e=a.device_manufacturer,f=a.system_push_enabled;this.type=b,this.token=c,this.deviceOS=d,this.deviceManufacturer=e,this.systemPushEnabled=f}return a.payloadify=function(a){return aI(aJ({type:a.type,token:a.token,device_os:a.deviceOS,device_manufacturer:a.deviceManufacturer,system_push_enabled:a.systemPushEnabled}))},a}(),fy=new WeakMap,fz=function(a){function b(b){var c=b._iid,d=b.session,e=b.cacheContext,f=b.sdkState,g=b.dispatcher,h=b.requestQueue,i=b.logger,j=b.pushNotificationAckManager,k=a.call(this)||this;return k._currentConnectionStateType=ek.INITIALIZED,k._isRefreshingAuthToken=!1,k.currentUser=null,k.session=d,k._iid=c,k._cacheContext=e,k._sdkState=f,k._dispatcher=g,k._requestQueue=h,k._logger=i,k._pushNotificationAckManager=j,k._deviceTokens=[],k._dispatcher.on(function(a){var b,c,d,e,f;if(a instanceof eu){var g=a.stateType;k._currentConnectionStateType=g}else if(a instanceof bh&&!k.isSessionKeyRefreshing){if(k._currentConnectionStateType===ek.CONNECTING)return;(null===(b=a.error)|| void 0===b?void 0:b.isSessionInvalidatedError)?k.clear():((null===(c=a.error)|| void 0===c?void 0:c.isSessionTokenExpiredError)&&k.refreshAuthToken().catch(function(a){if(F(a)&&"foreground"===k._sdkState.appState)throw a}),(null===(d=a.error)|| void 0===d?void 0:d.isSessionKeyExpiredError)&&(k._logger.debug("session expired"),null===(f=null===(e=k.handler)|| void 0===e?void 0:e.onSessionExpired)|| void 0===f||f.call(e),k._currentConnectionStateType===ek.CONNECTED&&k._dispatcher.dispatch(new bo(new bw({type:bc.WEBSOCKET_DISCONNECT,data:{success:!0,error_code:n.SESSION_KEY_EXPIRED,error_description:"cause=session_expired"}}))),k.refreshSessionKey().catch(function(a){if(F(a)&&"foreground"===k._sdkState.appState)throw a})))}}),k}return f(b,a),Object.defineProperty(b.prototype,"ekey",{get:function(){return fy.get(this)},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"deviceTokens",{get:function(){return this._deviceTokens},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"deviceTokenLastDeletedAt",{get:function(){return this._deviceTokenLastDeletedAt},enumerable:!1,configurable:!0}),b.prototype.indexOfDeviceToken=function(a,b){return this._deviceTokens.findIndex(function(c){return c.type===a&&c.token===b})},b.prototype.hasDeviceToken=function(a,b){return this.indexOfDeviceToken(a,b)>=0},b.prototype.createRefreshWebsocketCommand=function(a,b){return new bl({authToken:a,expiringSession:!0,requestId:b})},b.prototype._refreshSessionKeyByWebSocket=function(a){return i(this,void 0,void 0,function(){var b,c,d,e,f;return j(this,function(g){switch(g.label){case 0:return b=this.createRefreshWebsocketCommand(a),[4,this._requestQueue.forceSend(b)];case 1:if(e=(d=(c=g.sent()).as(bn)).newKey,f=d.error)throw f;return this.session.sessionKey=null!=e?e:this.session.sessionKey,[2]}})})},b.prototype._refreshSessionKeyByApi=function(a){return i(this,void 0,void 0,function(){var b,c=this;return j(this,function(d){switch(d.label){case 0:return b=new bk({userId:this._sdkState.userId,authToken:a,services:this.session.services&&this.session.services.length>0?this.session.services:void 0,expiringSession:!0}),[4,fc(function(a){return i(c,void 0,void 0,function(){var c,d,e,f,g;return j(this,function(h){switch(h.label){case 0:return h.trys.push([0,2,,3]),[4,this._requestQueue.forceSend(b)];case 1:return e=(d=(c=h.sent()).as(bm)).key,f=d.services,this.session.sessionKey=e,this.session.services=f,[3,3];case 2:if(g=h.sent(),!this._isSessionRelatedError(g))throw g;return a(g),[3,3];case 3:return[2]}})})},3)];case 1:return d.sent(),[2]}})})},b.prototype._refreshSessionKey=function(a,b){return void 0===b&&(b=!0),i(this,void 0,void 0,function(){var c,d;return j(this,function(e){switch(e.label){case 0:if(this._currentConnectionStateType!==ek.CONNECTED)return[3,8];e.label=1;case 1:return e.trys.push([1,3,,8]),[4,this._refreshSessionKeyByWebSocket(a)];case 2:return e.sent(),this.complete(),[2];case 3:c=e.sent(),e.label=4;case 4:return e.trys.push([4,6,,7]),[4,this._handleSessionRefreshError(c,b)];case 5:return e.sent(),[2];case 6:return e.sent(),[3,7];case 7:return[3,8];case 8:return e.trys.push([8,10,,12]),[4,this._refreshSessionKeyByApi(a)];case 9:return e.sent(),this.complete(),[3,12];case 10:return d=e.sent(),[4,this._handleSessionRefreshError(d,b)];case 11:return e.sent(),[3,12];case 12:return[2]}})})},b.prototype._receiveNewAuthToken=function(){var a,b=this,c=new bC;if(this._isRefreshingAuthToken=!0,this.session.sessionKey=void 0,this.session.authToken=void 0,null===(a=this.handler)|| void 0===a?void 0:a.onSessionTokenRequired){var d=null,e=function(){d&&(clearTimeout(d),d=null)},f=function(a){e(),b._isRefreshingAuthToken&&(b._isRefreshingAuthToken=!1,c.resolve(a))},g=function(a){e(),b._isRefreshingAuthToken&&(b._isRefreshingAuthToken=!1,c.reject(a))};d=setTimeout(function(){return g()},1e3*this._sdkState.sessionTokenRefreshTimeout),eh(function(){return i(b,void 0,void 0,function(){var a;return j(this,function(b){return(null===(a=this.handler)|| void 0===a?void 0:a.onSessionTokenRequired)&&this.handler.onSessionTokenRequired(f,g),[2]})})})}else this._isRefreshingAuthToken=!1,c.resolve(null);return c.promise},b.prototype._handleSessionRefreshError=function(a,b){return void 0===b&&(b=!1),i(this,void 0,void 0,function(){var c;return j(this,function(d){switch(d.label){case 0:return a instanceof G&&(a.isSessionTokenExpiredError||a.code===n.APPLICATION_NOT_FOUND)?(this.session.authToken=void 0,b?[4,this._receiveNewAuthToken()]:[3,6]):[3,6];case 1:return(c=d.sent())?(this.session.authToken=c,[4,this._refreshSessionKey(this.session.authToken,!1)]):[3,3];case 2:return d.sent(),[3,5];case 3:return[4,this.clear()];case 4:d.sent(),d.label=5;case 5:return[2];case 6:throw a}})})},b.prototype._isSessionRelatedError=function(a){return a instanceof G&&(a.isSessionExpiredError||a.isSessionInvalidatedError)},Object.defineProperty(b.prototype,"isSessionKeyRefreshing",{get:function(){return this.session.isRefreshing},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"isRefreshingAuthToken",{get:function(){return this._isRefreshingAuthToken},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"isSessionExpiring",{get:function(){return!!this.handler},enumerable:!1,configurable:!0}),b.prototype.authenticate=function(a,b){var c;return i(this,void 0,void 0,function(){var d,e,f,g,h;return j(this,function(i){switch(i.label){case 0:return this.session.authToken=b,d=0,[4,this._cacheContext.preference.get(eJ(this._sdkState.appId))];case 1:return(e=i.sent())&&(d=e.configTs),f=new fo({appId:this._sdkState.appId,userId:a,includeUIKitConfig:!!(null!==(c=this._sdkState.extensions)&& void 0!==c?c:{}).sb_uikit,localCacheEnabled:this._cacheContext.localCacheEnabled,expiringSession:this.isSessionExpiring,configTs:d}),[4,this._requestQueue.commandRouter.send(f)];case 2:return(h=(g=i.sent()).as(fp).logi).error?[3,5]:this.session.hasChatServicePermission?[3,4]:[4,h.applyTo(this._iid)];case 3:i.sent(),i.label=4;case 4:return[3,6];case 5:throw h.error;case 6:return[2]}})})},b.prototype.login=function(a){var b;return i(this,void 0,void 0,function(){var c,d,e,f,g,h,i,k;return j(this,function(j){switch(j.label){case 0:return c=a.key,d=a.ekey,e=a.services,f=a.userProfile,g=a.deviceTokenLastDeletedAt,h=void 0===g?0:g,this.session.sessionKey=c,this.session.services=e,fy.set(this,d),this._deviceTokenCacheEnabled=null===(b=null==f?void 0:f.appInfo)|| void 0===b?void 0:b.deviceTokenCache,i=this._cacheContext.preference,this._deviceTokenCacheEnabled?[4,i.get(fw)]:[3,5];case 1:return(k=j.sent())&&!(k.lastDeletedAt0&&(this.queue=this.queue.concat(this.flushWaitQueue),this.flushWaitQueue=[])},a.prototype._isDuplicateStat=function(a){var b=this._sentLogStats.find(function(b){var c;return b.channelUrl===a.data.channel_url&&b.messageId===(null!==(c=a.data.notificationId)&& void 0!==c?c:a.data.message_id)&&b.action===a.data.action});return b||this._sentLogStats.push({channelUrl:a.data.channel_url,messageId:a.data.message_id,action:a.data.action}),!!b},a.prototype._save=function(){return i(this,void 0,void 0,function(){var a;return j(this,function(b){switch(b.label){case 0:return a=m(m([],l(this.queue),!1),l(this.flushWaitQueue),!1),[4,this.cacheContext.preference.set(this.key,{deviceId:this.logInfo.deviceId,statLogs:a.map(function(a){return bw.payloadify(a)}),generation:this.logInfo.generation++,lastFlushedAt:this.logInfo.lastFlushedAt})];case 1:return b.sent(),[2]}})})},a.prototype.clear=function(){return i(this,void 0,void 0,function(){return j(this,function(a){return this.queue=[],this.flushWaitQueue=[],this.logInfo.generation=1,this._save(),[2]})})},a}(),fE=function(a){function b(b){var c,d,e,f,g=b.type,h=b.data,i=b.ts,j=void 0===i?Date.now():i,k=a.call(this,{type:g,data:h,ts:j})||this;return k.date=new Date(j),k.key="".concat((d=(c=k.date).getFullYear(),e=String(c.getMonth()+1).padStart(2,"0"),f=String(c.getDate()).padStart(2,"0"),"".concat(d).concat(e).concat(f)),"_").concat(g),k}return f(b,a),b}(bw),fF=function(a){function b(b){var c=b.deviceId,d=b.statLogs,e=a.call(this)||this;return e.method=aK.POST,e.path="".concat(aZ),e.params={device_id:c,log_entries:d.map(function(a){return bw.payloadify(a)})},e}return f(b,a),b}(be),fG=function(a){function b(b){var c=b.deviceId,d=b.cacheContext,e=b.requestQueue;return a.call(this,{deviceId:c,cacheContext:d,requestQueue:e})||this}return f(b,a),Object.defineProperty(b.prototype,"_isSendable",{get:function(){return 0!==this.queue.length&&Date.now()-this.logInfo.lastFlushedAt>=this.statConfig.minInterval},enumerable:!1,configurable:!0}),b.prototype.init=function(b){return i(this,void 0,void 0,function(){return j(this,function(c){switch(c.label){case 0:return[4,a.prototype.init.call(this,b+".daily")];case 1:return c.sent(),this.queue=this.logInfo.statLogs.map(function(a){return new bw({type:a.stat_type,ts:a.ts,data:a.data})}),[2]}})})},b.prototype.setConfig=function(a,b){return i(this,void 0,void 0,function(){var c,d,e,f;return j(this,function(g){switch(g.label){case 0:return this.statConfig=a,this._mergeQueue(),b.localCacheStat?(this.enabledState=b.enabledStat?fq.ENABLED:fq.COLLECT_ONLY,[3,3]):[3,1];case 1:return this.enabledState=fq.DISABLED,[4,this.clear()];case 2:g.sent(),g.label=3;case 3:return this.isEnabled&&this._isSendable?[4,this._getUploadStats()]:[3,9];case 4:c=g.sent(),d=Math.max(Math.floor(Math.random()*this.statConfig.requestDelayRange),100),e=0,g.label=5;case 5:return e0))return[3,10];if(this.isFlushing)return[3,9];this.isFlushing=!0,f.label=1;case 1:return f.trys.push([1,4,8,9]),c=m([],l(a),!1).slice(0,Math.min(this.limit,this.statConfig.maxStatCountPerRequest)),d=new fF({deviceId:this.deviceId,statLogs:c}),[4,this.requestQueue.send(d)];case 2:return f.sent(),this.queue=m([],l(a),!1).slice(c.length).concat(this.flushWaitQueue),this.flushWaitQueue=[],this.limit=100,this.logInfo.lastFlushedAt=Date.now(),[4,this._save()];case 3:return f.sent(),[3,9];case 4:return(e=f.sent())instanceof G?e.code!==n.NON_AUTHORIZED?[3,6]:[4,this.clear()]:[3,7];case 5:return f.sent(),this.enabledState=fq.DISABLED,[3,7];case 6:e.code===n.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=fq.COLLECT_ONLY),f.label=7;case 7:return this.limit=this.limit+20,b=!1,[3,9];case 8:return this.isFlushing=!1,[7];case 9:return[3,11];case 10:this.isFlushing=!1,f.label=11;case 11:return[2,b]}})})},b}(fD),fH=function(a){function b(b){var c=b.deviceId,d=b.cacheContext,e=b.requestQueue;return a.call(this,{deviceId:c,cacheContext:d,requestQueue:e})||this}return f(b,a),b.prototype._isSendable=function(a){if(void 0===a&&(a=!1),this.queue.length0))return[3,10];if(this.isFlushing)return[3,9];this.isFlushing=!0,f.label=1;case 1:return f.trys.push([1,4,8,9]),c=m([],l(a),!1).slice(0,Math.min(this.limit,this.statConfig.maxStatCountPerRequest)),d=new fF({deviceId:this.deviceId,statLogs:c}),[4,this.requestQueue.send(d)];case 2:return f.sent(),this.queue=m([],l(a),!1).slice(c.length).concat(this.flushWaitQueue),this.flushWaitQueue=[],this.limit=100,this.logInfo.lastFlushedAt=Date.now(),[4,this._save()];case 3:return f.sent(),[3,9];case 4:return(e=f.sent())instanceof G?e.code!==n.NON_AUTHORIZED?[3,6]:[4,this.clear()]:[3,7];case 5:return f.sent(),this.enabledState=fq.DISABLED,[3,7];case 6:e.code===n.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=fq.COLLECT_ONLY),f.label=7;case 7:return this.limit=this.limit+20,b=!1,[3,9];case 8:return this.isFlushing=!1,[7];case 9:return[3,11];case 10:this.isFlushing=!1,f.label=11;case 11:return[2,b]}})})},b}(fD),fI=function(a){function b(b){var c=b.deviceId,d=b.statLogs,e=a.call(this)||this;return e.method=aK.POST,e.path="".concat(a$),e.params={device_id:c,log_entries:d.map(function(a){return bw.payloadify(a)})},e}return f(b,a),b}(be),fJ=function(a){function b(b){var c=b.deviceId,d=b.cacheContext,e=b.requestQueue;return a.call(this,{deviceId:c,cacheContext:d,requestQueue:e})||this}return f(b,a),Object.defineProperty(b.prototype,"_isSendable",{get:function(){return this.queue.length>=this.statConfig.minStatCount&&this.queue.length>this.statConfig.lowerThreshold||this.logInfo.lastFlushedAt>0&&Date.now()-this.logInfo.lastFlushedAt>=this.statConfig.minInterval},enumerable:!1,configurable:!0}),b.prototype.init=function(b){return i(this,void 0,void 0,function(){return j(this,function(c){switch(c.label){case 0:return[4,a.prototype.init.call(this,b+".realtime")];case 1:return c.sent(),this.queue=this.logInfo.statLogs.map(function(a){var b;return a.data=aI(g(g({},a.data),{message_id:null!==(b=a.data.notificationId)&& void 0!==b?b:a.data.message_id,notificationId:void 0})),new bw({type:a.stat_type,ts:a.ts,data:a.data})}),this._sentLogStats=this.queue.map(function(a){var b;return{channelUrl:a.data.channelUrl,messageId:null!==(b=a.data.notificationId)&& void 0!==b?b:a.data.message_id,action:a.data.action}}),[2]}})})},b.prototype.setConfig=function(a,b){return i(this,void 0,void 0,function(){var c;return j(this,function(d){switch(d.label){case 0:return this.statConfig=a,this._mergeQueue(),b.notificationStat?(this.enabledState=b.enabledStat?fq.ENABLED:fq.COLLECT_ONLY,[3,3]):[3,1];case 1:return this.enabledState=fq.DISABLED,[4,this.clear()];case 2:d.sent(),d.label=3;case 3:return this.isEnabled&&this._isSendable?[4,fa(c=Math.max(Math.floor(Math.random()*this.statConfig.requestDelayRange),100))]:[3,6];case 4:return d.sent(),[4,this._flush(this.queue)];case 5:d.sent(),d.label=6;case 6:return[2]}})})},b.prototype.put=function(a){return i(this,void 0,void 0,function(){var b;return j(this,function(c){switch(c.label){case 0:return this.enabledState===fq.DISABLED?[2,!0]:(b=this.enabledState===fq.PENDING||this.isFlushing?this.flushWaitQueue:this.queue,this._isDuplicateStat(a)?[2,!0]:(b.push(a),this.enabledState===fq.PENDING?[3,2]:[4,this._save()]));case 1:c.sent(),c.label=2;case 2:return this.isEnabled?(this._mergeQueue(),this.isEnabled&&this._isSendable?[4,this._flush(b)]:[3,4]):[3,4];case 3:return[2,c.sent()];case 4:return[2,!0]}})})},b.prototype._flush=function(a){return i(this,void 0,void 0,function(){var b,c,d,e;return j(this,function(f){switch(f.label){case 0:if(b=!0,!(a.length>0))return[3,10];if(this.isFlushing)return[3,9];this.isFlushing=!0,f.label=1;case 1:return f.trys.push([1,4,8,9]),c=m([],l(a),!1).slice(0,Math.min(this.limit,this.statConfig.maxStatCountPerRequest)),d=new fI({deviceId:this.deviceId,statLogs:c}),[4,this.requestQueue.send(d)];case 2:return f.sent(),this.queue=m([],l(a),!1).slice(c.length).concat(this.flushWaitQueue),this.flushWaitQueue=[],this.limit=100,this.logInfo.lastFlushedAt=Date.now(),[4,this._save()];case 3:return f.sent(),[3,9];case 4:return(e=f.sent())instanceof G?e.code!==n.NON_AUTHORIZED?[3,6]:[4,this.clear()]:[3,7];case 5:return f.sent(),this.enabledState=fq.DISABLED,[3,7];case 6:e.code===n.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=fq.COLLECT_ONLY),f.label=7;case 7:return this.limit=this.limit+20,b=!1,[3,9];case 8:return this.isFlushing=!1,[7];case 9:return[3,11];case 10:this.isFlushing=!1,f.label=11;case 11:return[2,b]}})})},b}(fD),fK=function(a){function b(b){var c=b.deviceId,d=b.statLogs,e=a.call(this)||this;return e.method=aK.POST,e.path="".concat(a_),e.params={device_id:c,log_entries:d.map(function(a){return bw.payloadify(a)})},e}return f(b,a),b}(be),fL=function(a){function b(b){var c=b.deviceId,d=b.cacheContext,e=b.requestQueue;return a.call(this,{deviceId:c,cacheContext:d,requestQueue:e})||this}return f(b,a),Object.defineProperty(b.prototype,"storageSuffix",{get:function(){return".aiagent"},enumerable:!1,configurable:!0}),b.prototype.isCollectorEnabled=function(a){return!!a.aiAgentStat},b.prototype._isSendable=function(a){if(void 0===a&&(a=!1),this.queue.length0))return[3,10];if(this.isFlushing)return[3,9];this.isFlushing=!0,f.label=1;case 1:return f.trys.push([1,4,8,9]),c=m([],l(a),!1).slice(0,Math.min(this.limit,this.statConfig.maxStatCountPerRequest)),d=new fK({deviceId:this.deviceId,statLogs:c}),[4,this.requestQueue.send(d)];case 2:return f.sent(),this.queue=m([],l(a),!1).slice(c.length).concat(this.flushWaitQueue),this.flushWaitQueue=[],this.limit=100,this.logInfo.lastFlushedAt=Date.now(),[4,this._save()];case 3:return f.sent(),[3,9];case 4:return(e=f.sent())instanceof G?e.code!==n.NON_AUTHORIZED?[3,6]:[4,this.clear()]:[3,7];case 5:return f.sent(),this.enabledState=fq.DISABLED,[3,7];case 6:e.code===n.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=fq.COLLECT_ONLY),f.label=7;case 7:return this.limit=this.limit+20,b=!1,[3,9];case 8:return this.isFlushing=!1,[7];case 9:return[3,11];case 10:this.isFlushing=!1,f.label=11;case 11:return[2,b]}})})},b}(fD),fM=function(a){function b(){return null!==a&&a.apply(this,arguments)||this}return f(b,a),Object.defineProperty(b.prototype,"storageSuffix",{get:function(){return".aiagentassertion"},enumerable:!1,configurable:!0}),b.prototype.isCollectorEnabled=function(a){return!!a.aiAgentAssertionStat},b}(fL),fN=function(){function a(a){var b=a.cacheContext,c=a.requestQueue,d=a.dispatcher,e=a.logger;this._collectRequestStat=!0,this._collectFeatureLocalCacheStat=!0,this._collectionNotificationStat=!0,this._collectAIAgentStat=!0,this._collectAIAgentAssertionStat=!0,this._retryCount=0,this.deviceId=aD(),this.cacheContext=b,this.requestQueue=c,this.dispatcher=d,this.logger=e,this._dailyStatCollector=new fG({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue}),this._defaultStatCollector=new fH({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue}),this._notificationStatCollector=new fJ({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue}),this._aiAgentStatCollector=new fL({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue}),this._aiAgentAssertionStatCollector=new fM({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue})}return a.prototype._migration=function(){return i(this,void 0,void 0,function(){var a,b,c,d;return j(this,function(e){switch(e.label){case 0:return[4,this.cacheContext.preference.get(this.key)];case 1:return(a=e.sent())?(b=[],a.statLogs.forEach(function(a){a.stat_type===bc.FEATURE_LOCALCACHE&&b.push(new bw({type:a.stat_type,ts:a.ts,data:a.data}))}),[4,this.cacheContext.preference.set(this.key+".daily",{deviceId:a.deviceId,statLogs:b.map(function(a){return bw.payloadify(a)}),generation:a.generation,lastFlushedAt:a.lastFlushedAt})]):[3,6];case 2:return e.sent(),c=[],a.statLogs.forEach(function(a){a.stat_type!==bc.FEATURE_LOCALCACHE&&a.stat_type!==bc.NOTIFICATION&&(a.stat_type===bc.FEATURE_LOCALCACHE_EVENT&&(a.data=g({message_init_policy:"",starting_point:0},a.data)),c.push(new bw({type:a.stat_type,ts:a.ts,data:a.data})))}),[4,this.cacheContext.preference.set(this.key+".default",{deviceId:a.deviceId,statLogs:c.map(function(a){return bw.payloadify(a)}),generation:a.generation,lastFlushedAt:a.lastFlushedAt})];case 3:return e.sent(),d=[],a.statLogs.forEach(function(a){var b;a.stat_type===bc.NOTIFICATION&&(a.data=aI(g(g({},a.data),{message_id:null!==(b=a.data.notificationId)&& void 0!==b?b:a.data.message_id,notificationId:void 0})),d.push(new bw({type:a.stat_type,ts:a.ts,data:a.data})))}),[4,this.cacheContext.preference.set(this.key+".realtime",{deviceId:a.deviceId,statLogs:d.map(function(a){return bw.payloadify(a)}),generation:a.generation,lastFlushedAt:a.lastFlushedAt})];case 4:return e.sent(),[4,this.cacheContext.preference.remove(this.key)];case 5:e.sent(),e.label=6;case 6:return[2]}})})},a.prototype.init=function(a){return i(this,void 0,void 0,function(){var b=this;return j(this,function(c){switch(c.label){case 0:return this.key=a,[4,this._migration()];case 1:return c.sent(),[4,this._dailyStatCollector.init(this.key)];case 2:return c.sent(),[4,this._defaultStatCollector.init(this.key)];case 3:return c.sent(),[4,this._notificationStatCollector.init(this.key)];case 4:return c.sent(),[4,this._aiAgentStatCollector.init(this.key)];case 5:return c.sent(),[4,this._aiAgentAssertionStatCollector.init(this.key)];case 6:return c.sent(),this.commandEventContext||(this.commandEventContext=this.dispatcher.on(function(a){return i(b,void 0,void 0,function(){var b,c,d,e,f,g,h,i;return j(this,function(j){return a instanceof bo?(b=a.statLog,this.put(b)):a instanceof e0&&(c=a.request,d=a.features,e=a.options,f=a.statConfigInfo,this._retryCount=0,this._collectRequestStat=c,this._collectFeatureLocalCacheStat=null==d?void 0:d.localCache,this._collectionNotificationStat=null==d?void 0:d.notification,this._collectAIAgentStat=null==d?void 0:d.aiAgent,this._statConfig=f,this._collectAIAgentAssertionStat=(null==d?void 0:d.aiAgentAssertion)&&!!this._statConfig.aiAgentAssertion,this._dailyStatCollector.setConfig(this._statConfig.daily,{localCacheStat:this._collectFeatureLocalCacheStat,enabledStat:e.ingestion}),this._defaultStatCollector.setConfig(this._statConfig.default,{requestStat:this._collectRequestStat,localCacheStat:this._collectFeatureLocalCacheStat,enabledStat:e.ingestion}),this._notificationStatCollector.setConfig(null!==(g=this._statConfig.realTime)&& void 0!==g?g:this._statConfig.default,{notificationStat:this._collectionNotificationStat,enabledStat:e.ingestion}),this._aiAgentStatCollector.setConfig(null!==(h=this._statConfig.aiAgentStats)&& void 0!==h?h:this._statConfig.default,{aiAgentStat:this._collectAIAgentStat,enabledStat:e.ingestion}),this._aiAgentAssertionStatCollector.setConfig(null!==(i=this._statConfig.aiAgentAssertion)&& void 0!==i?i:this._statConfig.default,{aiAgentAssertionStat:this._collectAIAgentAssertionStat,enabledStat:e.ingestion})),[2]})})})),[2]}})})},a.prototype.put=function(a){return i(this,void 0,void 0,function(){var b;return j(this,function(c){switch(c.label){case 0:return b=!0,a instanceof fE?this._collectFeatureLocalCacheStat?[4,this._dailyStatCollector.put(a)]:[3,2]:[3,3];case 1:b=c.sent(),c.label=2;case 2:return[3,19];case 3:switch(a.type){case bc.API_RESULT:case bc.WEBSOCKET_CONNECT:case bc.WEBSOCKET_DISCONNECT:return[3,4];case bc.FEATURE_LOCALCACHE:case bc.FEATURE_LOCALCACHE_EVENT:return[3,7];case bc.NOTIFICATION:return[3,10];case bc.AI_AGENT_SDK_STATS:return[3,13];case bc.AI_AGENT_ASSERTION:return[3,16]}return[3,19];case 4:return this._collectRequestStat?[4,this._defaultStatCollector.put(a)]:[3,6];case 5:b=c.sent(),c.label=6;case 6:return[3,19];case 7:return this._collectFeatureLocalCacheStat?[4,this._defaultStatCollector.put(a)]:[3,9];case 8:b=c.sent(),c.label=9;case 9:return[3,19];case 10:return this._collectionNotificationStat?[4,this._notificationStatCollector.put(a)]:[3,12];case 11:b=c.sent(),c.label=12;case 12:return[3,19];case 13:return this._collectAIAgentStat?[4,this._aiAgentStatCollector.put(a)]:[3,15];case 14:b=c.sent(),c.label=15;case 15:return[3,19];case 16:return this._collectAIAgentAssertionStat?[4,this._aiAgentAssertionStatCollector.put(a)]:[3,18];case 17:b=c.sent(),c.label=18;case 18:return[3,19];case 19:return b?this._retryCount=0:(this._retryCount++,this._retryCount>20&&(this._dailyStatCollector.enabledState=fq.COLLECT_ONLY,this._defaultStatCollector.enabledState=fq.COLLECT_ONLY,this._notificationStatCollector.enabledState=fq.COLLECT_ONLY,this._aiAgentStatCollector.enabledState=fq.COLLECT_ONLY,this._aiAgentAssertionStatCollector.enabledState=fq.COLLECT_ONLY,this.logger.debug(G.statLogUploadLimitExceededError))),[2]}})})},a.prototype.appendStat=function(a,b,c){if(a===bc.AI_AGENT_SDK_STATS&&!this._collectAIAgentStat||a===bc.AI_AGENT_ASSERTION&&!this._collectAIAgentAssertionStat||a===bc.NOTIFICATION&&!this._collectionNotificationStat||(a===bc.API_RESULT||a===bc.WEBSOCKET_CONNECT||a===bc.WEBSOCKET_DISCONNECT)&&!this._collectRequestStat||(a===bc.FEATURE_LOCALCACHE||a===bc.FEATURE_LOCALCACHE_EVENT)&&!this._collectFeatureLocalCacheStat)return!1;var d=new bw({type:a,ts:Date.now(),data:b,runtimeId:c});return this.put(d),!0},a.prototype.close=function(){this.commandEventContext&&(this.commandEventContext.close(),this.commandEventContext=void 0)},a}(),fO=function(){function a(a){var b=a.limit;this.workersByKey={},this.limit=void 0===b?5:b}return a.prototype.run=function(a,b){return i(this,void 0,void 0,function(){var c;return j(this,function(d){switch(d.label){case 0:return this.workersByKey[a]||(this.workersByKey[a]=[]),this.workersByKey[a].length0}).map(function(a){return a.id})),this.allowUserSuggestion=null!==(h=a.allow_user_suggestion)&& void 0!==h?h:this.allowUserSuggestion,this.allowMultipleVotes=null!==(i=a.allow_multiple_votes)&& void 0!==i?i:this.allowMultipleVotes},b.payloadify=function(b){return aI(aJ(g(g({},a.payloadify.call(this,b)),{id:b.id,title:b.title,created_at:b.createdAt,updated_at:b.updatedAt,close_at:b.closeAt,status:b.status,message_id:b.messageId,data:b.data,voter_count:b.voterCount,options:b.options.map(function(a){return gd.payloadify(a)}),created_by:b.createdBy,allow_user_suggestion:b.allowUserSuggestion,allow_multiple_votes:b.allowMultipleVotes,voted_option_ids:b.votedPollOptionIds})))},b.prototype.applyPollUpdateEvent=function(a){var b=a._payload.poll;return!(!b||this.id!==b.id||b.updated_at -1){var f=b[d];e>=f._lastVotedAt&&(f.voteCount=a.vote_count,f._lastVotedAt=e)}}),d.req_id&&d.voted_option_ids&&(this.votedPollOptionIds=d.voted_option_ids),"number"==typeof d.voter_count&&(this.voterCount=d.voter_count),!0},b.prototype.serialize=function(){return eU(this)},b}(eK),gf=function(){function a(a,b){var c;this.limit=20,this._isLoading=!1,this._hasNext=!0,this._token="",this._iid=a,this.limit=null!==(c=b.limit)&& void 0!==c?c:20}return Object.defineProperty(a.prototype,"hasNext",{get:function(){return this._hasNext},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"isLoading",{get:function(){return this._isLoading},enumerable:!1,configurable:!0}),a.prototype._validate=function(){return K("number",this.limit)&&this.limit>0},a}(),gg=function(a){function b(b,c,d,e){var f=a.call(this,b,e)||this;return f.channelUrl=c,f.channelType=d,f}return f(b,a),b.prototype._validate=function(){return a.prototype._validate.call(this)&&K("string",this.channelUrl)&&L(ac,this.channelType)},b}(gf),gh=function(a){this.pollId=0,this.messageId=0,this.pollId=a.poll_id,this.messageId=a.message_id,this._payload=a},gi=function(a){function b(b){var c=b.title,d=b.optionTexts,e=b.data,f=b.allowUserSuggestion,g=b.allowMultipleVotes,h=b.closeAt,i=a.call(this)||this;return i.method=aK.POST,i.path=aW,i.params={title:c,options:d,data:e,allow_user_suggestion:f,allow_multiple_votes:g,close_at:h},i}return f(b,a),b}(be),gj=function(a){function b(b,c){var d=a.call(this,b,c)||this;return d.poll=new ge(b,c),d}return f(b,a),b}(bf),gk=function(a){function b(b){var c=b.channelUrl,d=b.channelType,e=b.pollId,f=a.call(this)||this;return f.method=aK.GET,f.path="".concat(aW,"/").concat(encodeURIComponent(e)),f.params={channel_url:c,channel_type:d},f}return f(b,a),b}(be),gl=function(a){function b(b,c){var d=a.call(this,b,c)||this;return d.poll=new ge(b,c),d}return f(b,a),b}(bf),gm=function(a){function b(b){var c=b.channelUrl,d=b.channelType,e=b.pollId,f=b.pollOptionId,g=a.call(this)||this;return g.method=aK.GET,g.path="".concat(aW,"/").concat(encodeURIComponent(e),"/options/").concat(encodeURIComponent(f)),g.params={channel_url:c,channel_type:d},g}return f(b,a),b}(be),gn=function(a){function b(b,c){var d=a.call(this,b,c)||this;return d.pollOption=new gd(b,c),d}return f(b,a),b}(bf),go=function(a){function b(b){var c=b.channelType,d=b.channelUrl,e=b.timestamp,f=b.token,g=a.call(this)||this;return g.method=aK.GET,g.path="".concat(a7(c),"/").concat(encodeURIComponent(d),"/polls/changelogs"),g.params=aI({change_ts:e,token:f}),g}return f(b,a),b}(be),gp=function(a){function b(b,c){var d=a.call(this,b,c)||this;return d.updatedPolls=c.updated.map(function(a){var c,d;return c=b,d=a,new ge(c,d)}),d.deletedPollIds=c.deleted.map(function(a){return a}),d.hasMore=c.has_more,d.nextToken=c.next,d}return f(b,a),b}(bf),gq={title:"",optionTexts:[],data:void 0,allowUserSuggestion:void 0,allowMultipleVotes:void 0,closeAt:-1},gr=function(a){var b;return K("string",a.title)&&N("string",b=a.optionTexts)&&b.every(function(a){return""!==a.trim()})&&gc(a.data)&&K("boolean",a.allowUserSuggestion,!0)&&K("boolean",a.allowMultipleVotes,!0)&&K("number",a.closeAt,!0)},gs={channelUrl:"",channelType:ac.BASE,pollId:0,pollOptionId:0},gt=function(a){return K("string",a.channelUrl)&&""!==a.channelUrl&&L(ac,a.channelType)&&K("number",a.pollId)&&a.pollId>0&&K("number",a.pollOptionId)&&a.pollOptionId>0},gu={channelUrl:"",channelType:ac.BASE,pollId:0},gv=function(a){return K("string",a.channelUrl)&&""!==a.channelUrl&&L(ac,a.channelType)&&K("number",a.pollId)},gw={},gx=function(){function a(a,b){var c=b.sdkState,d=b.dispatcher,e=b.sessionManager,f=b.requestQueue,g=b.logger;this._iid=a,this._sdkState=c,this._sessionManager=e,this._requestQueue=f,this._dispatcher=d,this._logger=g,gw[a]=this}return a.of=function(a){return gw[a]},a.prototype.buildPollFromSerializedData=function(a){var b=eV(a);return new ge(this._iid,ge.payloadify(b))},a.prototype.get=function(a){return i(this,void 0,void 0,function(){var b,c;return j(this,function(d){switch(d.label){case 0:return eW(gv(a)).throw(G.invalidParameters),b=new gk(g({},a)),[4,this._requestQueue.send(b)];case 1:return[2,(c=d.sent()).as(gl).poll]}})})},a.prototype.create=function(a){return i(this,void 0,void 0,function(){var b,c;return j(this,function(d){switch(d.label){case 0:return eW(gr(a)).throw(G.invalidParameters),b=new gi(g({},a)),[4,this._requestQueue.send(b)];case 1:return[2,(c=d.sent()).as(gj).poll]}})})},a.prototype.getOption=function(a){return i(this,void 0,void 0,function(){var b,c;return j(this,function(d){switch(d.label){case 0:return eW(gt(a)).throw(G.invalidParameters),b=new gm(g({},a)),[4,this._requestQueue.send(b)];case 1:return[2,(c=d.sent()).as(gn).pollOption]}})})},a.prototype.getPollChangeLogs=function(a,b,c,d){return void 0===d&&(d=fP.SYNC_POLL_CHANGELOGS),i(this,void 0,void 0,function(){var e,f,g,h,i,k,l;return j(this,function(j){switch(j.label){case 0:return e=new go(aJ({channelType:b,channelUrl:a,timestamp:"number"==typeof c?c:null,token:"string"==typeof c?c:null})),[4,this._requestQueue.send(e)];case 1:return h=(g=(f=j.sent()).as(gp)).updatedPolls,i=g.deletedPollIds,k=g.hasMore,l=g.nextToken,h.length>0&&this._dispatcher.dispatch(new f7({polls:h,source:d})),[2,{updatedPolls:h,deletedPollIds:i,hasMore:k,token:l}]}})})},a}(),gy=function(a){function b(b){var c=b.channelUrl,d=b.channelType,e=b.token,f=b.limit,g=a.call(this)||this;return g.method=aK.GET,g.path=aW,g.params={channel_url:c,channel_type:d,token:e,limit:f},g}return f(b,a),b}(be),gz=function(a){function b(b,c){var d,e=this;return(e=a.call(this,b,c)||this).polls=(null!==(d=c.polls)&& void 0!==d?d:[]).map(function(a){return new ge(b,a)}),e.token=c.next,e}return f(b,a),b}(bf),gA=function(a){function b(b,c){return a.call(this,b,c.channelUrl,c.channelType,c)||this}return f(b,a),b.prototype.next=function(){return i(this,void 0,void 0,function(){var a,b,c,d,e,f;return j(this,function(h){switch(h.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,a=fY.of(this._iid).requestQueue,b=new gy(g(g({},this),{token:this._token})),[4,a.send(b)]):[3,2]:[3,5];case 1:return e=(d=(c=h.sent()).as(gz)).polls,f=d.token,this._token=f,this._hasNext=!!f,this._isLoading=!1,[2,e];case 2:return[2,[]];case 3:throw G.queryInProgress;case 4:return[3,6];case 5:throw G.invalidParameters;case 6:return[2]}})})},b}(gg),gB=function(a){function b(b){var c=b.channelUrl,d=b.channelType,e=b.pollId,f=b.pollOptionId,g=b.token,h=b.limit,i=a.call(this)||this;return i.method=aK.GET,i.path="".concat(aW,"/").concat(encodeURIComponent(e),"/options/").concat(encodeURIComponent(f),"/voters"),i.params={channel_url:c,channel_type:d,token:g,limit:h},i}return f(b,a),b}(be),gC=function(a){function b(b,c){var d,e=this;return(e=a.call(this,b,c)||this).voters=(null!==(d=c.voters)&& void 0!==d?d:[]).map(function(a){return new eZ(b,a)}),e.token=c.next,e}return f(b,a),b}(bf),gD=function(a){function b(b,c){var d=a.call(this,b,c.channelUrl,c.channelType,c)||this;return d.pollId=c.pollId,d.pollOptionId=c.pollOptionId,d}return f(b,a),b.prototype._validate=function(){return a.prototype._validate.call(this)&&K("number",this.pollId)&&K("number",this.pollOptionId)},b.prototype.next=function(){return i(this,void 0,void 0,function(){var a,b,c,d,e,f;return j(this,function(h){switch(h.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,a=fY.of(this._iid).requestQueue,b=new gB(g(g({},this),{pollId:this.pollId,pollOptionId:this.pollOptionId,token:this._token})),[4,a.send(b)]):[3,2]:[3,5];case 1:return e=(d=(c=h.sent()).as(gC)).voters,f=d.token,this._token=f,this._hasNext=!!f,this._isLoading=!1,[2,e];case 2:return[2,[]];case 3:throw G.queryInProgress;case 4:return[3,6];case 5:throw G.invalidParameters;case 6:return[2]}})})},b}(gg)}}]) //# sourceMappingURL=bf7c8dff.45ded6819001c56f.js.map