1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/__bundle-190d20e5-BE1hJmf8.js","assets/react-CydE4nCL.js","assets/__bundle-46d64517-BN90M5Zk.js"])))=>i.map(i=>d[i]); 2(function(){try{var n=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};n.SENTRY_RELEASE={id:"a156a80817bcc286d094871909811f8803ba8360"};var t=new n.Error().stack;t&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[t]="bffcb2e0-4109-49e1-9fc2-cbe28e9b9f1c",n._sentryDebugIdIdentifier="sentry-dbid-bffcb2e0-4109-49e1-9fc2-cbe28e9b9f1c")}catch(e){}})();const Tu=(function(){const t=typeof document<"u"&&document.createElement("link").relList;return t&&t.supports&&t.supports("modulepreload")?"modulepreload":"preload"})(),Su=function(n){return"/build/"+n},Ss={},Tr=function(t,e,r){let i=Promise.resolve();if(e&&e.length>0){let u=function(c){return Promise.all(c.map(l=>Promise.resolve(l).then(d=>({status:"fulfilled",value:d}),d=>({status:"rejected",reason:d}))))};document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),o=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));i=u(e.map(c=>{if(c=Su(c),c in Ss)return;Ss[c]=!0;const l=c.endsWith(".css"),d=l?'[rel="stylesheet"]':"";if(document.querySelector('link[href="'.concat(c,'"]').concat(d)))return;const _=document.createElement("link");if(_.rel=l?"stylesheet":Tu,l||(_.as="script"),_.crossOrigin="",_.href=c,o&&_.setAttribute("nonce",o),document.head.appendChild(_),l)return new Promise((h,v)=>{_.addEventListener("load",h),_.addEventListener("error",()=>v(new Error("Unable to preload CSS for ".concat(c))))})}))}function s(a){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a}return i.then(a=>{for(const o of a||[])o.status==="rejected"&&s(o.reason);return t().catch(s)})};var Fi=function(n,t){return Fi=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])},Fi(n,t)};function g(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function e(){this.constructor=n}Fi(n,t),n.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var E=function(){return E=Object.assign||function(n){for(var t,e=1,r=arguments.length;e<r;e++)for(var i in t=arguments[e])Object.prototype.hasOwnProperty.call(t,i)&&(n[i]=t[i]);return n},E.apply(this,arguments)};function Cu(n,t){var e={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&t.indexOf(r)<0&&(e[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function"){var i=0;for(r=Object.getOwnPropertySymbols(n);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(n,r[i])&&(e[r[i]]=n[r[i]])}return e}function f(n,t,e,r){return new(e||(e=Promise))((function(i,s){function a(c){try{u(r.next(c))}catch(l){s(l)}}function o(c){try{u(r.throw(c))}catch(l){s(l)}}function u(c){var l;c.done?i(c.value):(l=c.value,l instanceof e?l:new e((function(d){d(l)}))).then(a,o)}u((r=r.apply(n,[])).next())}))}function p(n,t){var e,r,i,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return a.next=o(0),a.throw=o(1),a.return=o(2),typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function o(u){return function(c){return(function(l){if(e)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(s=0)),s;)try{if(e=1,r&&(i=2&l[0]?r.return:l[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,l[1])).done)return i;switch(r=0,i&&(l=[2&l[0],i.value]),l[0]){case 0:case 1:i=l;break;case 4:return s.label++,{value:l[1],done:!1};case 5:s.label++,r=l[1],l=[0];continue;case 7:l=s.ops.pop(),s.trys.pop();continue;default:if(i=s.trys,!((i=i.length>0&&i[i.length-1])||l[0]!==6&&l[0]!==2)){s=0;continue}if(l[0]===3&&(!i||l[1]>i[0]&&l[1]<i[3])){s.label=l[1];break}if(l[0]===6&&s.label<i[1]){s.label=i[1],i=l;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(l);break}i[2]&&s.ops.pop(),s.trys.pop();continue}l=t.call(n,s)}catch(d){l=[6,d],r=0}finally{e=i=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}})([u,c])}}}function z(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],r=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&r>=n.length&&(n=void 0),{value:n&&n[r++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function K(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var r,i,s=e.call(n),a=[];try{for(;(t===void 0||t-- >0)&&!(r=s.next()).done;)a.push(r.value)}catch(o){i={error:o}}finally{try{r&&!r.done&&(e=s.return)&&e.call(s)}finally{if(i)throw i.error}}return a}function V(n,t,e){if(arguments.length===2)for(var r,i=0,s=t.length;i<s;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return n.concat(r||Array.prototype.slice.call(t))}var L,io="4.22.11",Rt=(function(){function n(){}return Object.defineProperty(n,"OS_VERSION",{get:function(){return typeof navigator<"u"&&navigator.userAgent?navigator.userAgent.replace(/,/g,"."):"noAgent"}
2,enumerable:!1,configurable:!0}),Object.defineProperty(n,"SDK_VERSION",{get:function(){return io},enumerable:!1,configurable:!0}),Object.defineProperty(n,"SDK_MAJOR_VERSION",{get:function(){return n.SDK_VERSION.split(".")[0]},enumerable:!1,configurable:!0}),Object.defineProperty(n,"DEFAULT_MAX_UNREAD_COUNT_OF_SUPER_GROUP_CHANNEL",{get:function(){return 100},enumerable:!1,configurable:!0}),Object.defineProperty(n,"INTERNAL_CALL",{get:function(){return"ic"},enumerable:!1,configurable:!0}),n})();(function(n){n[n.NON_AUTHORIZED=400108]="NON_AUTHORIZED",n[n.INVALID_TOKEN=400111]="INVALID_TOKEN",n[n.NOT_FOUND_IN_DATABASE=400201]="NOT_FOUND_IN_DATABASE",n[n.USER_AUTH_DEACTIVATED=400300]="USER_AUTH_DEACTIVATED",n[n.USER_AUTH_DELETED_OR_NOT_FOUND=400301]="USER_AUTH_DELETED_OR_NOT_FOUND",n[n.SESSION_TOKEN_EXPIRED=400302]="SESSION_TOKEN_EXPIRED",n[n.APPLICATION_NOT_FOUND=400304]="APPLICATION_NOT_FOUND",n[n.SESSION_KEY_EXPIRED=400309]="SESSION_KEY_EXPIRED",n[n.SESSION_REVOKED=400310]="SESSION_REVOKED",n[n.INVALID_SESSION_TYPE=400312]="INVALID_SESSION_TYPE",n[n.INVALID_AUTH_FOR_SERVICE=400313]="INVALID_AUTH_FOR_SERVICE",n[n.STAT_UPLOAD_NOT_ALLOWED=403200]="STAT_UPLOAD_NOT_ALLOWED",n[n.NOT_SUPPORTED_PINNED_MESSAGE_IN_REVIEW_MESSAGE=400940]="NOT_SUPPORTED_PINNED_MESSAGE_IN_REVIEW_MESSAGE",n[n.INTERNAL_SERVER_ERROR=500901]="INTERNAL_SERVER_ERROR",n[n.RATE_LIMIT_EXCEEDED=500910]="RATE_LIMIT_EXCEEDED",n[n.INVALID_REQUIRED_FORM_VALUE=400105]="INVALID_REQUIRED_FORM_VALUE",n[n.UNKNOWN_SERVER_ERROR=900200]="UNKNOWN_SERVER_ERROR",n[n.NOT_SUPPORTED_FEATURE_IN_IN_REVIEW_MESSAGE=901500]="NOT_SUPPORTED_FEATURE_IN_IN_REVIEW_MESSAGE",n[n.ERR_DUPLICATED_DATA=400202]="ERR_DUPLICATED_DATA",n[n.DEBUG_MODE_REQUIRED=7e5]="DEBUG_MODE_REQUIRED",n[n.LOST_INSTANCE=700100]="LOST_INSTANCE",n[n.CONNECTION_RENEW=700102]="CONNECTION_RENEW",n[n.INVALID_CONNECTION_STATE_TRANSITION=700200]="INVALID_CONNECTION_STATE_TRANSITION",n[n.INVALID_COMMAND=700700]="INVALID_COMMAND",n[n.XMLHTTPREQUEST_NOT_SUPPORTED=700800]="XMLHTTPREQUEST_NOT_SUPPORTED",n[n.UNKNOWN_ERROR=77e4]="UNKNOWN_ERROR",n[n.INVALID_INITIALIZATION=800100]="INVALID_INITIALIZATION",n[n.CONNECTION_REQUIRED=800101]="CONNECTION_REQUIRED",n[n.CONNECTION_CANCELED=800102]="CONNECTION_CANCELED",n[n.INVALID_PARAMETER=800110]="INVALID_PARAMETER",n[n.NOT_SUPPORTED_ERROR=800111]="NOT_SUPPORTED_ERROR",n[n.NETWORK_ERROR=800120]="NETWORK_ERROR",n[n.NETWORK_ROUTING_ERROR=800121]="NETWORK_ROUTING_ERROR",n[n.MALFORMED_DATA=800130]="MALFORMED_DATA",n[n.MALFORMED_ERROR_DATA=800140]="MALFORMED_ERROR_DATA",n[n.WRONG_CHANNEL_TYPE=800150]="WRONG_CHANNEL_TYPE",n[n.MARK_AS_READ_RATE_LIMIT_EXCEEDED=800160]="MARK_AS_READ_RATE_LIMIT_EXCEEDED",n[n.QUERY_IN_PROGRESS=800170]="QUERY_IN_PROGRESS",n[n.ACK_TIMEOUT=800180]="ACK_TIMEOUT",n[n.LOGIN_TIMEOUT=800190]="LOGIN_TIMEOUT",n[n.WEBSOCKET_CONNECTION_CLOSED=800200]="WEBSOCKET_CONNECTION_CLOSED",n[n.WEBSOCKET_CONNECTION_FAILED=800210]="WEBSOCKET_CONNECTION_FAILED",n[n.REQUEST_FAILED=800220]="REQUEST_FAILED",n[n.DELAYED_CONNECTING=800221]="DELAYED_CONNECTING",n[n.FILE_UPLOAD_CANCEL_FAILED=800230]="FILE_UPLOAD_CANCEL_FAILED",n[n.REQUEST_CANCELED=800240]="REQUEST_CANCELED",n[n.REQUEST_DUPLICATED=800250]="REQUEST_DUPLICATED",n[n.FILE_SIZE_LIMIT_EXCEEDED=800260]="FILE_SIZE_LIMIT_EXCEEDED",n[n.ERR_UPLOAD_STAT_RETRY_COUNT_EXCEEDED=800270]="ERR_UPLOAD_STAT_RETRY_COUNT_EXCEEDED",n[n.SESSION_TOKEN_REQUEST_FAILED=800500]="SESSION_TOKEN_REQUEST_FAILED",n[n.SESSION_TOKEN_REFRESHED=800501]="SESSION_TOKEN_REFRESHED",n[n.SESSION_TOKEN_REFRESH_FAILED=800502]="SESSION_TOKEN_REFRESH_FAILED",n[n.COLLECTION_DISPOSED=800600]="COLLECTION_DISPOSED",n[n.DATABASE_ERROR=800700]="DATABASE_ERROR",n[n.USER_DEACTIVATED=900021]="USER_DEACTIVATED",n[n.CHANNEL_IS_FROZEN=900050]="CHANNEL_IS_FROZEN",n[n.RECEIVER_USER_DEACTIVATED=900081]="RECEIVER_USER_DEACTIVATED"})(L||(L={}));var bt,me,qi,Ce,Or,zi,On,tt=function(n){return!(n instanceof T&&!n.shouldThrowOutside)},T=(function(n){function t(e){var r=e.code,i=r===void 0?0:r,s=e.message,a=s===void 0?"":s,o=n.call(this,a)||this;return o.shouldThrowOutside=!1,o._detail="",o.name="SendbirdError",o.
2code=i,Object.setPrototypeOf(o,t.prototype),o}return g(t,n),Object.defineProperty(t.prototype,"detail",{get:function(){return this._detail},enumerable:!1,configurable:!0}),t.prototype.setDetail=function(e){this._detail=e},Object.defineProperty(t.prototype,"isInvalidTokenError",{get:function(){return this.code===L.INVALID_TOKEN},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isSessionExpiredError",{get:function(){return this.isSessionTokenExpiredError||this.isSessionKeyExpiredError},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isSessionTokenExpiredError",{get:function(){return this.code===L.SESSION_TOKEN_EXPIRED},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isSessionKeyExpiredError",{get:function(){return this.code===L.SESSION_KEY_EXPIRED},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isSessionInvalidatedError",{get:function(){return this.isSessionRevokedError||this.isUserAuthDeactivedError||this.isUserAuthDeletedOrNotFoundError},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isSessionRevokedError",{get:function(){return this.code===L.SESSION_REVOKED},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isUserAuthDeactivedError",{get:function(){return this.code===L.USER_AUTH_DEACTIVATED},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isUserAuthDeletedOrNotFoundError",{get:function(){return this.code===L.USER_AUTH_DELETED_OR_NOT_FOUND},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isNetworkError",{get:function(){return this.code===L.NETWORK_ERROR||this.code===L.NETWORK_ROUTING_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(t,"debugModeRequired",{get:function(){return new t({code:L.DEBUG_MODE_REQUIRED,message:"Cannot run this operation in production mode."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"lostInstance",{get:function(){return new t({code:L.LOST_INSTANCE,message:"Instance ID is missing. It should belong to an instance."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"invalidCommand",{get:function(){return new t({code:L.INVALID_COMMAND,message:"Cannot send invalid command."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"unknown",{get:function(){return new t({code:L.UNKNOWN_ERROR,message:"Unknown error occurred."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"connectionRenew",{get:function(){return new t({code:L.CONNECTION_RENEW,message:"Connection restarts."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"invalidConnectionStateTransition",{get:function(){return new t({code:L.INVALID_CONNECTION_STATE_TRANSITION,message:"Invalid connection state transition."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"xmlHttpRequestNotSupported",{get:function(){return new t({code:L.XMLHTTPREQUEST_NOT_SUPPORTED,message:"Cannot upload file. XMLHttpRequest is not defined in this environment."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"connectionRequired",{get:function(){return new t({code:L.CONNECTION_REQUIRED,message:"Connection is required."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"connectionCanceled",{get:function(){return new t({code:L.CONNECTION_CANCELED,message:"Connection is canceled."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"invalidParameters",{get:function(){return new t({code:L.INVALID_PARAMETER,message:"Invalid parameters."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"notSupportedError",{get:function(){return new t({code:L.NOT_SUPPORTED_ERROR,message:"Given parameters are not supported."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"channelTypeNotSupportedError",{get:function(){return new t({code:L.NOT_SUPPORTED_ERROR,message:"Called method is not supported in the current channel's channel type."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"legacyChatbotFeatureNotSupported",{get:function(){return new t({code:L.NOT_SUPPORTED_ERROR,message:"This is a legacy chatbot feature that is no longer supported. Use AI Agent instead."})}
2,enumerable:!1,configurable:!0}),Object.defineProperty(t,"networkError",{get:function(){return new t({code:L.NETWORK_ERROR,message:"There was a network error."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"markAsReadAllRateLimitExceeded",{get:function(){return new t({code:L.MARK_AS_READ_RATE_LIMIT_EXCEEDED,message:"markAsRead rate limit exceeded."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"queryInProgress",{get:function(){return new t({code:L.QUERY_IN_PROGRESS,message:"Query in progress."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"noAckTimeout",{get:function(){return new t({code:L.ACK_TIMEOUT,message:"Command received no ack."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"loginTimeout",{get:function(){return new t({code:L.LOGIN_TIMEOUT,message:"Connection timeout."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"connectionClosed",{get:function(){return new t({code:L.WEBSOCKET_CONNECTION_CLOSED,message:"Connection is closed. Please reconnect."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"requestFailed",{get:function(){return new t({code:L.REQUEST_FAILED,message:"Request failed."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"tooManyRequests",{get:function(){return new t({code:L.REQUEST_DUPLICATED,message:"Too many requests."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"alreadyConnectedAsAnotherUser",{get:function(){return new t({code:L.REQUEST_FAILED,message:"Already logged in as a different user. Call disconnect() first."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"fileUploadCanceled",{get:function(){return new t({code:L.FILE_UPLOAD_CANCEL_FAILED,message:"File upload has been canceled."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"requestCanceled",{get:function(){return new t({code:L.REQUEST_CANCELED,message:"Request has been canceled."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"sessionTokenRefreshFailed",{get:function(){return new t({code:L.SESSION_TOKEN_REFRESH_FAILED,message:"Failed to refresh the session key."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"sessionTokenRequestFailed",{get:function(){return new t({code:L.SESSION_TOKEN_REQUEST_FAILED,message:"Failed to get the session token."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"databaseError",{get:function(){return new t({code:L.DATABASE_ERROR,message:"Database error."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"fileSizeLimitExceededError",{get:function(){return new t({code:L.FILE_SIZE_LIMIT_EXCEEDED,message:"File size exceeds the file size limit."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"statLogUploadLimitExceededError",{get:function(){return new t({code:L.ERR_UPLOAD_STAT_RETRY_COUNT_EXCEEDED,message:"The upload request failed due to the retry count being exceeded."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"malformedDataError",{get:function(){return new t({code:L.MALFORMED_DATA,message:"Malformed data."})},enumerable:!1,configurable:!0}),t.prototype.throwOutside=function(){throw this.shouldThrowOutside=!0,this},t})(Error),Au=[L.CONNECTION_REQUIRED,L.NETWORK_ERROR,L.ACK_TIMEOUT,L.WEBSOCKET_CONNECTION_CLOSED,L.WEBSOCKET_CONNECTION_FAILED,L.FILE_UPLOAD_CANCEL_FAILED,L.REQUEST_CANCELED,L.INTERNAL_SERVER_ERROR,L.RATE_LIMIT_EXCEEDED,L.UNKNOWN_SERVER_ERROR,L.USER_DEACTIVATED,L.CHANNEL_IS_FROZEN,L.RECEIVER_USER_DEACTIVATED],Nu=[L.WEBSOCKET_CONNECTION_CLOSED,L.WEBSOCKET_CONNECTION_FAILED,L.CONNECTION_REQUIRED],so=function(n,t){if(n!==t){var e=E({},n),r=E({},t);return(!e.hasOwnProperty("messageId")||!r.hasOwnProperty("messageId")||e.messageId===r.messageId)&&(!e.hasOwnProperty("reqId")||!r.hasOwnProperty("reqId")||e.reqId===r.reqId)&&(e.hasOwnProperty("messageId")&&delete e.messageId,e.hasOwnProperty("reqId")&&delete e.reqId,r.hasOwnProperty("messageId")&&delete r.messageId,r.hasOwnProperty("reqId")&&delete r.reqId,JSON.stringify(e)===JSON.stringify(r))}return!0},S=function(n,t,e){return e===void 0&&(e=!1),!(!e||!rn(t))||(typeof n!="str
2ing"?typeof n=="object"?ie(n,t):ku(n,t):typeof t===n)},ie=function(n,t,e){return e===void 0&&(e=!1),!(!e||!rn(t))||Object.values(n).includes(t)},ku=function(n,t){return t instanceof n},J=function(n,t,e){return e===void 0&&(e=!1),!(!e||!rn(t))||Array.isArray(t)&&t.every((function(r){return S(n,r)}))},Cs=function(n,t){return t===void 0&&(t=!1),!(!t||!rn(n))||typeof n=="number"&&Number.isInteger(n)&&n>=0&&n<=23},As=function(n,t){return t===void 0&&(t=!1),!(!t||!rn(n))||typeof n=="number"&&Number.isInteger(n)&&n>=0&&n<=59},i_=function(n,t){return!!rn(n)||typeof n=="number"&&n.toString().length===13},Ou=function(n){return n>0&&Au.indexOf(n)>=0},Dr=function(n){return n>0&&Nu.indexOf(n)>=0},rt=function(n,t){if(t===void 0&&(t=!1),t&&rn(n))return!0;var e=typeof n=="object"&&n!==null&&n.hasOwnProperty("name")&&typeof n.name=="string"&&n.hasOwnProperty("uri")&&typeof n.uri=="string"&&n.hasOwnProperty("type")&&typeof n.type=="string";if(!e){if(typeof Blob<"u")return n instanceof Blob;if(typeof File<"u")return n instanceof File}return e},s_=function(n,t){if(n===t)return!0;if(n==null||t==null||n.length!==t.length)return!1;for(var e=V([],K(n),!1).sort(),r=V([],K(t),!1).sort(),i=0;i<e.length;++i)if(e[i]!==r[i])return!1;return!0},rn=function(n){return n==null},ao=(function(){function n(t){var e=t===void 0?{}:t,r=e.useMemberInfoInMessage,i=r===void 0||r,s=e.typingIndicatorInvalidateTime,a=s===void 0?1e4:s,o=e.typingIndicatorThrottle,u=o===void 0?1e3:o,c=e.websocketResponseTimeout,l=c===void 0?1e4:c,d=e.websocketPayloadDecompression,_=d===void 0||d,h=e.sessionTokenRefreshTimeout,v=h===void 0?60:h;this._useMemberInfoInMessage=!0,this._typingIndicatorInvalidateTime=1e4,this._typingIndicatorThrottle=1e3,this._websocketResponseTimeout=1e4,this._sessionTokenRefreshTimeout=60,this._useMemberInfoInMessage=i,this._typingIndicatorInvalidateTime=a,this._typingIndicatorThrottle=u,this._websocketResponseTimeout=l,this._sessionTokenRefreshTimeout=v,this.websocketPayloadDecompression=_}return Object.defineProperty(n.prototype,"useMemberInfoInMessage",{get:function(){return this._useMemberInfoInMessage},set:function(t){S("boolean",t)&&(this._useMemberInfoInMessage=t)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"typingIndicatorInvalidateTime",{get:function(){return this._typingIndicatorInvalidateTime},set:function(t){S("number",t)&&(this._typingIndicatorInvalidateTime=t)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"typingIndicatorThrottle",{get:function(){return this._typingIndicatorThrottle},set:function(t){S("number",t)&&t>=1e3&&t<=9e3&&(this._typingIndicatorThrottle=t)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"websocketResponseTimeout",{get:function(){return this._websocketResponseTimeout},set:function(t){S("number",t)&&t>=5e3&&t<=3e4&&(this._websocketResponseTimeout=t)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"sessionTokenRefreshTimeout",{get:function(){return this._sessionTokenRefreshTimeout},set:function(t){S("number",t)&&(t<60?t=60:t>1800&&(t=1800),this._sessionTokenRefreshTimeout=t)},enumerable:!1,configurable:!0}),n})(),oo={encrypt:function(n){return n},decrypt:function(n){return n}},Ns=(function(){function n(t){var e=t.store;this._preference=new Map,this._store=e}return n.prototype._savePreferenceKeys=function(){return f(this,void 0,void 0,(function(){return p(this,(function(t){switch(t.label){case 0:return[4,this._store.set({key:this._keysAddress,value:V([],K(this._preference.keys()),!1)})];case 1:return t.sent(),[2]}}))}))},n.prototype.init=function(t,e){var r;return e===void 0&&(e=1),f(this,void 0,void 0,(function(){var i,s,a,o,u,c,l,d,_,h,v;return p(this,(function(m){switch(m.label){case 0:return this._version=e,this._keysAddress=t,i="".concat(t,".metadata.version"),[4,this._store.get(i)];case 1:return s=m.sent(),[4,this._store.get(t)];case 2:return a=(r=m.sent())!==null&&r!==void 0?r:[],!s||s.version<this._version?this._version===9?[3,3]:[3,6]:[3,10];case 3:return o=a.find((function(y){return y.includes("groupchannel/sync.meta")})),o?[4,this._store.remove(o)]:[3,5];case 4:m.sent(),m.label=5;case 5:return[3,8];case 6:return[4,this._resetPreferenceData(a)];case 7:m.sent(),m.label=8;case 8:return[4,this._updatePreferenceVersionInfo(i)];case 9:return m.sent(),[3,17];case 10:m.trys.push([10,15,16,17]),u=z(a),c=u.next(),m.label=11;case 11:return c.done?[3,14]:(l=c.value,[4,this._store.get(l)]);case 12:(d=m.sent())&&this._preference.set(l,d),m.label=13;case 13:return c=u.next(),[3,11];case 14:return[3,17];case 15:return _=m.sent(),h={error:_},[3,17];case 16:try{c&&!c.done&&(v=u.return)&&v.call(u)}finally{if(h)throw h.error}
2return[7];case 17:return[2]}}))}))},n.prototype._updatePreferenceVersionInfo=function(t){return f(this,void 0,void 0,(function(){return p(this,(function(e){switch(e.label){case 0:return[4,this._store.set({key:t,value:{version:this._version}})];case 1:return e.sent(),[2]}}))}))},n.prototype._resetPreferenceData=function(t){return f(this,void 0,void 0,(function(){return p(this,(function(e){switch(e.label){case 0:return this._preference=new Map,[4,this._store.removeMany(t)];case 1:return e.sent(),[2]}}))}))},n.prototype.get=function(t){return f(this,void 0,void 0,(function(){return p(this,(function(e){return[2,this._preference.get(t)]}))}))},n.prototype.set=function(t,e){return f(this,void 0,void 0,(function(){var r;return p(this,(function(i){switch(i.label){case 0:return r=!this._preference.has(t),[4,this._store.set({key:t,value:e})];case 1:return i.sent(),this._preference.set(t,e),r?[4,this._savePreferenceKeys()]:[3,3];case 2:i.sent(),i.label=3;case 3:return[2]}}))}))},n.prototype.remove=function(t){return f(this,void 0,void 0,(function(){return p(this,(function(e){switch(e.label){case 0:return[4,this._store.remove(t)];case 1:return e.sent(),this._preference.delete(t),[4,this._savePreferenceKeys()];case 2:return e.sent(),[2]}}))}))},n.prototype.clear=function(){return f(this,void 0,void 0,(function(){return p(this,(function(t){switch(t.label){case 0:return[4,this._store.removeMany(V([],K(this._preference.keys()),!1))];case 1:return t.sent(),this._preference.clear(),[4,this._savePreferenceKeys()];case 2:return t.sent(),[2]}}))}))},n})(),Du=(function(){function n(t){var e=t.encryption,r=t.store,i=t.localCacheEnabled,s=t.localCacheConfig;this.store=r,this.preference=new Ns({store:r}),this.encryption=e!=null?e:oo,this.localCacheEnabled=i,this.localCacheConfig=s}return n.prototype.replaceStore=function(t){this.store=t,this.preference=new Ns({store:t})},n})();(function(n){n.SUNDAY="sunday",n.MONDAY="monday",n.TUESDAY="tuesday",n.WEDNESDAY="wednesday",n.THURSDAY="thursday",n.FRIDAY="friday",n.SATURDAY="saturday"})(bt||(bt={})),(function(n){n.SUCCESS="success",n.PENDING="pending",n.ERROR="error"})(me||(me={})),(function(n){n.DEFAULT="default",n.ALL="all",n.MENTION_ONLY="mention_only",n.OFF="off"})(qi||(qi={})),(function(n){n.FCM="gcm",n.APNS="apns",n.UNKNOWN="unknown"})(Ce||(Ce={})),(function(n){n.SESSION_TOKEN="session_token",n.ACCESS_TOKEN="access_token"})(Or||(Or={})),(function(n){n.ALTERNATIVE="alternative",n.DEFAULT="default"})(zi||(zi={})),(function(n){n.CUSTOM="custom",n.MESSAGE_COLLECTION_ACCESSED_AT="messagecollection_accessed_at"})(On||(On={}));var Rr,a_=(function(){function n(t){var e=t.channel,r=t.cachedMessageCount;this._cachedMessageCount=0,this._channel=e,this._cachedMessageCount=r}return Object.defineProperty(n.prototype,"channel",{get:function(){return this._channel},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"cachedMessageCount",{get:function(){return this._cachedMessageCount},enumerable:!1,configurable:!0}),n})(),uo=(function(){function n(t){var e=t===void 0?{}:t,r=e.maxSize,i=r===void 0?256:r,s=e.clearOrder,a=s===void 0?On.MESSAGE_COLLECTION_ACCESSED_AT:s,o=e.customClearOrderComparator,u=e.enableAutoResend,c=u===void 0||u,l=e.enableRestoreDB,d=l!==void 0&&l;this._clearOrderComparatorUseMessageCollectionAccessedAt=function(_,h){return _.channel.messageCollectionLastAccessedAt===h.channel.messageCollectionLastAccessedAt?_.channel.lastMessage&&!h.channel.lastMessage?1:!_.channel.lastMessage&&h.channel.lastMessage?-1:_.channel.lastMessage||h.channel.lastMessage?_.channel.lastMessage.createdAt-h.channel.lastMessage.createdAt:0:_.channel.messageCollectionLastAccessedAt>h.channel.messageCollectionLastAccessedAt?1:-1},this._maxSize=Math.max(i,64),o?(this._clearOrder=a,this._customClearOrderComparator=o):this._clearOrder=On.MESSAGE_COLLECTION_ACCESSED_AT,this._enableAutoResend=c,this._enableRestoreDB=d}return Object.defineProperty(n.prototype,"maxSize",{get:function(){return this._maxSize},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"clearOrder",{get:function(){return this._clearOrder}
2,enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"enableRestoreDB",{get:function(){return this._enableRestoreDB},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"clearOrderComparator",{get:function(){var t;return this._clearOrder===On.MESSAGE_COLLECTION_ACCESSED_AT?this._clearOrderComparatorUseMessageCollectionAccessedAt:(t=this._customClearOrderComparator)!==null&&t!==void 0?t:this._clearOrderComparatorUseMessageCollectionAccessedAt},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"enableAutoResend",{get:function(){return this._enableAutoResend},enumerable:!1,configurable:!0}),n})();(function(n){n.FEED="feed",n.CHAT="chat",n.CHAT_API="chat_api"})(Rr||(Rr={}));var oe,Lr,ks,ee,Ve,Ur,Re,ze,it,ae,Os,Bi,ji,Ru=(function(){function n(){this.isRefreshing=!1}return Object.defineProperty(n.prototype,"hasSession",{get:function(){return!!this.sessionKey},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"hasChatServicePermission",{get:function(){var t;return!!(!((t=this.services)===null||t===void 0)&&t.includes(Rr.CHAT))},enumerable:!1,configurable:!0}),n.prototype.clear=function(){this.authToken=void 0,this.sessionKey=void 0,this.services=[]},n})(),st=function(){var n=new Date().getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var e=(n+16*Math.random())%16|0;return n=Math.floor(n/16),(t==="x"?e:3&e|8).toString(16)}))},Ds=(function(){function n(t){var e=t.container;this._container={},this._container=e,this.key=st()}return n.prototype._register=function(t,e,r){var i;return t in this._container||(this._container[t]=new Map),(i=this._container[t])===null||i===void 0||i.set(this.key,{occurence:e,handler:r}),this},n.prototype.on=function(t,e){return this._register(t,-1,e)},n.prototype.once=function(t,e){return this._register(t,1,e)},n.prototype.close=function(){var t=this;Object.keys(this._container).forEach((function(e){var r;(r=t._container[e])===null||r===void 0||r.delete(t.key)}))},n})(),mn=(function(){function n(){this._container={}}return n.prototype.on=function(t,e){return new Ds({container:this._container}).on(t,e)},n.prototype.once=function(t,e){return new Ds({container:this._container}).once(t,e)},n.prototype.dispatch=function(t,e){var r,i,s=this._container[t];if(s){var a=[];try{for(var o=z(s.keys()),u=o.next();!u.done;u=o.next()){var c=u.value,l=s.get(c);l.handler(e),l.occurence>0&&(l.occurence--,l.occurence===0&&a.push(c))}}catch(d){r={error:d}}finally{try{u&&!u.done&&(i=o.return)&&i.call(o)}finally{if(r)throw r.error}}a.forEach((function(d){return s.delete(d)}))}},n})(),Lu=(function(){function n(){this._dispatcher=new mn}return n.prototype.on=function(t){return this._dispatcher.on("event",t)},n.prototype.once=function(t){return this._dispatcher.once("event",t)},n.prototype.dispatch=function(t){this._dispatcher.dispatch("event",t)},n})(),Z=function(){},M=function(n){var t={};return n&&Object.keys(n).forEach((function(e){n[e]===void 0||Number.isNaN(n[e])||n[e]===null||(t[e]=n[e])})),t},B=function(n){if(n!=null){if(typeof n=="object"){if(Array.isArray(n)){for(var t=V([],K(n),!1),e=0;e<t.length;e++)t[e]=B(t[e]);return t}return Object.keys(n).forEach((function(r){n[r]===null&&delete n[r]})),n}return n}};(function(n){n.BASE="base",n.GROUP="group",n.OPEN="open",n.FEED="feed"})(oe||(oe={})),(function(n){n.OPERATOR="operator",n.NONE="none"})(Lr||(Lr={})),(function(n){n.MUTED="muted",n.UNMUTED="unmuted"})(ks||(ks={})),(function(n){n.BASE="base",n.USER="user",n.FILE="file",n.ADMIN="admin"})(ee||(ee={})),(function(n){n.ALL="",n.USER="MESG",n.FILE="FILE",n.ADMIN="ADMM"})(Ve||(Ve={})),(function(n){n.USER="MESG",n.FILE="FILE",n.ADMIN="ADMM"})(Ur||(Ur={})),(function(n){n.USERS="users",n.CHANNEL="channel"})(Re||(Re={})),(function(n){n.ALL="all",n.NONE="none",n.ONLY_REPLY_TO_CHANNEL="only_reply_to_channel"})(ze||(ze={})),(function(n){n.DEFAULT="default",n.SUPPRESS="suppress"})(it||(it={})),(function(n){n.PENDING="pending",n.SCHEDULED="scheduled",n.SUCCEEDED="succeeded",n.FAILED="failed",n.CANCELED="canceled"})(ae||(ae={})),(function(n){n.INREVIEW="InReview",n.APPROVED="Approved"})(Os||(Os={})),(function(n){n.HIGH="high",n.NORMAL="normal",n.LOW="low"})(Bi||(Bi={})),(function(n){n.CREATED_AT="created_at",n.UPDATED_AT="updated_at"})(ji||(ji={}));var k,pe="v3",W="/".concat(pe,"/users"),Uu="/".concat(pe,"/sdk/users"),Mu="/".concat(pe,"/storage/file"),co="/".concat(pe,"/group_channels"),o_="/".concat(pe,"/sdk/group_channels"),Pu="/".concat(pe,"/open_channels"),xu="/".concat(pe,"/search"),Ki="/".concat(pe,"/report"),Fu="/".concat(pe,"/emojis"),lo="/".concat(pe,"/emoji_categories"),at="/".concat(pe,"/polls"),u_="/".concat(pe,"/scheduled_messages"),qu="/".concat(pe,"/sdk/ui_kit/configuration"),zu="/".concat(pe,"/sdk/statistics"),Bu="/".concat(pe,"/sdk/notification_statistics"),ju="/".concat(pe,"/sdk/ai_agent_statistics"),ho="/".concat(pe,"/message_templates"),Ku="/".concat(pe,"/sdk/push_delivery"),Hu="/".concat(pe,"/report_category"),Vu="/".concat(pe,"/sdk/applications/settings"),c_="/".concat(pe,"/ai_agent"),l_="/".concat(pe,"/ai_agent/group_channels"),Y=function(n){switch(n){case oe.FEED:case oe.GROUP:return co;case oe.OPEN:return Pu;default:return null}},fo=function(n){switch(n){case oe.GROUP:return"".concat(Ki,"/group_channels");case oe.OPEN:return"".concat(Ki,"/open_channels");default:return null}},Gn=function(n,t,e){var r,i;switch(n){case Re.CHANNEL:return!0;case Re.USERS:if(t)try{for(var s=z(t),a=s.next();!a.done;a=s.next())if(a.value===e)return!0}catch(o){r={error:o}}finally{try{a&&!a.done&&(i=s.return)&&i.call(s)}finally{if(r)throw r.error}}}return!1},po=function(n,t,e){var r,i,s,a,o=Gn((r=n.mentionType)!==null&&r!==void 0?r:null,(i=n.mentionedUserIds)!==null&&i!==void 0?i:[],e),u=Gn((s=t.mentionType)!==null&&s!==void 0?s:null,(a=t.mentionedUserIds)!==null&&a!==void 0?a:[],e);return!o&&u?1:o&&!u?-1:0},_o=function(n,t,e){var r,i=t||new FormData;for(var s in n)if(n.hasOwnProperty(s)){var a=n[s],o=e?"".concat(e,"[").concat(s,"]"):s;rt(a)?i.append(o,a,(r=a.name)!==null&&r!==void 0?r:"filename"):typeof a!="object"||a===null||Array.isArray(a)||a instanceof Blob?i.append(o,String(a)):i=_o(a,i,o)}return i};(function(n){n.GET="GET",n.POST="POST",n.PUT="PUT",n.DELETE="DELETE",n.PATCH="PATCH"})(k||(k={}));var te,O=(function(n){function t(){var e=n!==null&&n.apply(this,arguments)||this;return e.params={},e.requireAuth=!0,e.headers={},e.requestId=st(),e}return g(t,n),t.prototype.encodeParams=function(e){var r=this;return e==null||e===""?encodeURIComponent(""):Array.isArray(e)?e.map((function(i){return r.encodeParams(i)})).join(","):encodeURIComponent(typeof e=="object"?JSON.stringify(e):String(e))},Object.defineProperty(t.prototype,"query",{get:function(){var e=this,r=M(this.params);return"?".concat(Object.keys(r).map((function(i){return"".concat(encodeURIComponent(i),"=").concat(e.encodeParams(r[i]))})).join("&"))}
2,enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"payload",{get:function(){var e=M(this.params);return Object.keys(e).some((function(r){return rt(e[r])}))?_o(e):JSON.stringify(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasSessionKey",{get:function(){return this.headers["Session-Key"]!==void 0},enumerable:!1,configurable:!0}),t})(Z),U=(function(n){function t(e,r){var i=n.call(this)||this;return i._iid=e,i._payload=r,i}return g(t,n),Object.defineProperty(t.prototype,"payload",{get:function(){return E({},this._payload)},enumerable:!1,configurable:!0}),t.prototype.as=function(e){return new e(this._iid,this.payload)},t})(Z),Gu=(function(n){function t(e,r){var i=n.call(this)||this;return i.requestId=e,i.cause=r,i}return g(t,n),t})(Z),dn=(function(n){function t(e){var r=e.expires_in,i=e.reason,s=i===void 0?L.SESSION_KEY_EXPIRED:i,a=e.message,o=a===void 0?"":a,u=n.call(this)||this;switch(u.expiresIn=r!=null?r:0,s){case L.SESSION_KEY_EXPIRED:case L.SESSION_TOKEN_EXPIRED:case L.SESSION_REVOKED:case L.USER_AUTH_DEACTIVATED:case L.USER_AUTH_DELETED_OR_NOT_FOUND:u.error=new T({code:s,message:o})}return u}return g(t,n),Object.defineProperty(t.prototype,"invalidateSessionToken",{get:function(){var e;return!!(!((e=this.error)===null||e===void 0)&&e.isSessionTokenExpiredError)},enumerable:!1,configurable:!0}),t})(Z),we=(function(n){function t(e,r,i,s){s===void 0&&(s="");var a,o=this;return(o=n.call(this)||this)._iid=e,o.code=r,o.payload=i,o.requestId=(a=i.req_id)!==null&&a!==void 0?a:s,o}return g(t,n),t.createFromRawMessage=function(e,r){var i=r.substring(0,4),s={};try{s=JSON.parse(r.substring(4))}catch(a){i="NOOP"}finally{return new t(e,i,s)}},t.prototype.convertToMessage=function(){return"".concat(this.code).concat(JSON.stringify(this.payload),"\n")},t.prototype.as=function(e){return new e(this._iid,this.code,this.payload)},t})(Z),qe=(function(n){function t(e){var r,i=e.code,s=e.ackRequired,a=e.payload,o=a===void 0?{}:a,u=this;return(u=n.call(this)||this).code=i,u.payload=o,u.requestId=(r=u.payload.req_id)!==null&&r!==void 0?r:st(),u.ackRequired=s,u.payload.req_id=u.requestId,u}return g(t,n),t.prototype.convertToMessage=function(){return"".concat(this.code).concat(JSON.stringify(this.payload),"\n")},t})(Z),os=(function(n){function t(e){var r=e.userId,i=e.authToken,s=e.services,a=e.expiringSession,o=a===void 0||a,u=n.call(this)||this;return u.path="".concat(W,"/").concat(encodeURIComponent(r),"/session_key"),u.method=k.POST,u.params=M({token:i,services:s,expiring_session:!!o}),u.requireAuth=!1,u}return g(t,n),t})(O),Qu=(function(n){function t(e){var r=e.authToken,i=e.expiringSession,s=i===void 0||i,a=e.requestId,o=a===void 0?void 0:a;return n.call(this,{code:"LOGI",payload:M({token:r,expiring_session:s?1:0,req_id:o}),ackRequired:!0})||this}return g(t,n),t})(qe),$u=(function(n){function t(e,r){var i=n.call(this,e,r)||this,s=r.key,a=r.expires_at,o=r.services;return i.key=s,i.expiresAt=a,i.services=o,i}return g(t,n),t})(U),Wu=(function(n){function t(e,r,i){var s,a=this;return(a=n.call(this,e,"LOGI",i)||this).error=null,a.newKey=null,a.newKey=(s=i.new_key)!==null&&s!==void 0?s:null,a.error=i.error?new T(i):null,a}return g(t,n),t})(we),St=(function(n){function t(e){var r=n.call(this)||this;return r.statLog=e,r}return g(t,n),t})(Z),vo=(function(n){function t(e){var r=e.request,i=e.deferred,s=e.error,a=s===void 0?T.requestFailed:s,o=n.call(this)||this;return o.request=r,o.deferred=i,o.error=a,o}return g(t,n),t})(Z);(function(n){n.FEATURE_LOCALCACHE="feature:local_cache",n.FEATURE_LOCALCACHE_EVENT="feature:local_cache_event",n.NOTIFICATION="noti:stats",n.WEBSOCKET_CONNECT="ws:connect",n.WEBSOCKET_DISCONNECT="ws:disconnect",n.API_RESULT="api:result",n.AI_AGENT_SDK_STATS="ai_agent:stats",n.AI_AGENT_ASSERTION="ai_agent:assertion"})(te||(te={}));var Rs,Mr,an,de=(function(){function n(t){var e=t.type,r=t.data,i=t.ts,s=i===void 0?Date.now():i,a=t.runtimeId;this.type=e,this.createdAt=s,this.runtimeId=a,this.data=r}return n.payloadify=function(t){return M({stat_type:t.type,ts:t.createdAt,runtime_id:t.runtimeId,data:M(t.data)})},n})(),Pr=function(){return typeof document>"u"&&typeof navigator<"u"&&navigator.product=="ReactNative"},Ls=function(){return!(typeof navigator>"u"||!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Windows Phone/i.test(navigator.userAgent))};
2(function(n){n.CHAT="chat",n.CALLS="calls",n.DESK="desk",n.LIVE="live",n.UIKIT_CHAT="uikit-chat",n.UIKIT_LIVE="uikit-live",n.AI_AGENT="ai-agent"})(Rs||(Rs={})),(function(n){n.ANDROID="android",n.IOS="ios",n.JS="js",n.UNREAL="unreal",n.UNITY="unity",n.REACT_NATIVE="react-native",n.FLUTTER="flutter"})(Mr||(Mr={})),(function(n){n.ANDROID="android",n.IOS="ios",n.WEB="web",n.MOBILE_WEB="mobile_web",n.WINDOWS="windows"})(an||(an={}));var Yu="^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$",xr=(function(){function n(){}var t;return t=n,n._getFrameWork=function(){if(typeof window<"u"){if(window.__REACT__)return"react";if(window.__VUE__)return"vue";var e=window.__REACT_DEVTOOLS_GLOBAL_HOOK__;if(e&&e.getFiberRoots&&e.getFiberRoots(1).size>0)return"react";if(window.__NUXT__)return"vue(SSR)";if(window.__NEXT_DATA__||window.__NEXT_P||window.__NEXT_F)return"nextjs"}return""},n.sendbirdSdkUserAgentWithExtension=function(e){var r=Pr()?Mr.REACT_NATIVE:Mr.JS,i={main_sdk_info:"chat/".concat(r,"/").concat(Rt.SDK_VERSION),device_os_platform:Ls()?"mobile-web":"web",os_version:Rt.OS_VERSION};if(e){var s=e.sendbirdExtensions,a=e.deviceOS,o=e.customData,u=o===void 0?{}:o;a.version&&(i.os_version=a.version),a.platform&&(i.device_os_platform=a.platform),s.length>0&&(i.extension_sdk_info=s.map((function(l){var d=l.product,_=l.platform,h=l.version;return"".concat(d,"/").concat(_,"/").concat(h)}
2)).join(",")),Object.keys(i).forEach((function(l){return delete u[l]})),Object.keys(u).length>0&&(i=E(E({},i),u))}var c=t._getFrameWork();return c&&(i.javascript_framework=c),Object.entries(i).map((function(l){var d=K(l,2),_=d[0],h=d[1];return"".concat(_,"=").concat(h)})).join("&")},n.userAgentWithExtension=function(e){var r=Pr()?"reactnative":"JS",i=e.sb_syncmanager?"s".concat(e.sb_syncmanager):"",s=e.sb_uikit?"u".concat(e.sb_uikit):"",a=e["device-os-platform"]?"o".concat(e["device-os-platform"]):Ls()?"omobile-web":"oweb";return"".concat(r,"/c").concat(Rt.SDK_VERSION,"/").concat(i,"/").concat(s,"/").concat(a)},n})(),De=function(){var n=this;this.promise=new Promise((function(t,e){n.resolve=t,n.reject=function(r){e(r)}}))},Fr=(function(n){function t(e){var r=n.call(this)||this;return r.requestId=e.requestId,r}return g(t,n),t})(Z),mo=(function(n){function t(e){var r=n.call(this)||this;return r.method=k.DELETE,r.path="".concat(Y(e.channelType),"/").concat(e.channelUrl,"/messages/").concat(e.messageId),e.messageToken&&(r.params=M({mesg_token:e.messageToken})),r}return g(t,n),t})(O);(function(n){function t(){return n!==null&&n.apply(this,arguments)||this}g(t,n)})(U);var d_=(function(n){function t(e,r,i){var s,a=this;return(a=n.call(this,e,"DELM",i)||this).channelUrl=i.channel_url,a.channelType=i.channel_type,a.messageId=Number(i.msg_id),a.silent=i.silent,a.messageCreatedAt=i.message_created_at?Number(i.message_created_at):-1,a.senderId=(s=i.sender_id)!==null&&s!==void 0?s:void 0,a}return g(t,n),t})(we),Zu=(function(){function n(t,e){var r=e.session,i=e.sdkState,s=e.dispatcher,a=e.logger,o=e.useFetchCompat,u=o!==void 0&&o,c=this;this._abortControl=new Map,this._shouldImportFetchCompat=!1,this._iid=t,this._session=r,this._sdkState=i,this._dispatcher=s,this._dispatcher.on((function(l){l instanceof Gu&&c.cancel(l.requestId,l.cause)})),this._logger=a,this._shouldImportFetchCompat=u}return n.prototype._createHeader=function(t,e){var r=this._sdkState,i=r.appId,s=r.appVersion,a=r.sendbirdRuntimeEnvironment,o=E(E({},t.headers),{SendBird:"JS,".concat(Rt.OS_VERSION,",").concat(Rt.SDK_VERSION,",").concat(i).concat(s?",".concat(s):""),"SB-User-Agent":xr.userAgentWithExtension(this._sdkState.extensions),"Request-Sent-Timestamp":Date.now().toString(),"SB-SDK-User-Agent":xr.sendbirdSdkUserAgentWithExtension(a)});return e||(o["Content-Type"]="application/json; charset=utf-8"),o["App-Id"]=i,t.requireAuth?!t.hasSessionKey&&this._session.hasSession&&(o["Session-key"]=this._session.sessionKey):this._session.authToken&&(o["Access-token"]=this._session.authToken),o},n.prototype._toSendbirdError=function(t){return t instanceof T?t:(t==null?void 0:t.name)==="AbortError"?T.requestCanceled:T.networkError},n.prototype._statLogApiResult=function(t,e,r,i){if(!t.path.includes("/sdk/statistics")){var s=r===void 0?void 0:this._toSendbirdError(r),a=(s==null?void 0:s.code)===L.REQUEST_CANCELED?i:void 0,o=a?"cause=".concat(a):r==null?void 0:r.message;this._dispatcher.dispatch(new St(new de({type:te.API_RESULT,data:{endpoint:t.path,method:t.method,success:!r,latency:Date.now()-e,error_code:s==null?void 0:s.code,error_description:o}})))}},n.prototype._isBodyRequired=function(t){var e=t.method;return e!==k.GET&&(e!==k.DELETE||t instanceof mo)},n.prototype._shouldUseXMLHttpRequest=function(t){return Pr()&&t instanceof FormData},n.prototype._resendOnSessionError=function(t,e){if(e.isSessionExpiredError){if(this._dispatcher.dispatch(new dn({reason:e.code,message:e.message})),!(t instanceof os)){var r=new De;return this._dispatcher.dispatch(new vo({request:t,deferred:r,error:e})),r.promise}}else e.isSessionInvalidatedError&&this._dispatcher.dispatch(new dn({reason:e.code,message:e.message}));return null},n.prototype.send=function(t){return f(this,void 0,void 0,(function(){var e,r,i,s,a,o,u,c,l,d,_,h,v,m,y,b,w,I,A;return p(this,(function(D){switch(D.label){case 0:e=t.path,r=t.method,i=t.uploadProgressHandler,s=this._isBodyRequired(t),a=this._sdkState.api,o="".concat(a.host).concat(e).concat(s?"":t.query),u=s?t.payload:null,c=this._createHeader(t,u instanceof FormData?u:void 0),l={controller:new AbortController},d=l.controller.signal,this._abortControl.set(t.requestId,l),_=Date.now(),D.label=1;case 1:return D.trys.push([1,13,14,15]),i||this._shouldUseXMLHttpRequest(u)?[4,Tr(()=>import("./__bundle-723d4f4a-CJjuJ9s2.js"),[])]:[3,6];case 2:h=D.sent().xmlHttpRequest,D.label=3;case 3:return D.trys.push([3,5,,6]),[4,h(this._iid,{requestId:t.requestId,method:t.method,url:o,headers:c,data:u!=null?u:void 0,uploadProgressHandler:i})];case 4:return v=D.sent(),this._logger.debug("receive api response",t.requestId),this._statLogApiResult(t,_),[2,v];case 5:if(!((m=D.sent())instanceof T&&m.code===L.XMLHTTPREQUEST_NOT_SUPPORTED)){if(m instanceof T){if(I=this._resendOnSessionError(t,m))return[2,I];throw m}throw m}return this._logger.debug("XMLHttpRequest is not available in this environment. progressHandler is ignored."),[3,6];case 6:return this._shouldImportFetchCompat&&(this._shouldImportFetchCompat=!1,(typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof global<"u"&&global||{fetch:null}).fetch=null),typeof AbortController<"u"?[3,8]:[4,Tr(()=>import("./__bundle-190d20e5-BE1hJmf8.js").then(N=>N._),__vite__mapDeps([0,1]))];case 7:D.sent(),D.label=8;case 8:return typeof fetch=="function"?[3,10]:[4,Tr(()=>import("./__bundle-46d64517-BN90M5Zk.js").then(N=>
2N._),__vite__mapDeps([2,1]))];case 9:D.sent(),D.label=10;case 10:return[4,fetch(o,{method:r,body:u,headers:c,signal:d})];case 11:return[4,(y=D.sent()).json()];case 12:if(b=D.sent(),y.ok||y.redirected)return this._logger.debug("receive api response",t.requestId),this._statLogApiResult(t,_),[2,new U(this._iid,b)];if(b){if(w=new T(b),I=this._resendOnSessionError(t,w))return[2,I];throw w}throw T.requestFailed;case 13:throw A=D.sent(),this._statLogApiResult(t,_,A,l.cause),this._logger.debug("fail api request",A),this._toSendbirdError(A);case 14:return this._abortControl.delete(t.requestId),[7];case 15:return[2]}}))}))},n.prototype.cancel=function(t,e){var r=this._abortControl.get(t);r&&(r.cause=e,r.controller.abort(),this._abortControl.delete(t)),this._dispatcher.dispatch(new Fr({requestId:t}))},n.prototype.cancelAll=function(t){var e,r;try{for(var i=z(this._abortControl.values()),s=i.next();!s.done;s=i.next()){var a=s.value;a.cause=t,a.controller.abort()}}catch(o){e={error:o}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}this._abortControl.clear(),this._dispatcher.dispatch(new Fr({}))},n})(),fe=function(){};function gn(n){let t=n.length;for(;--t>=0;)n[t]=0}const us=256,go=286,Dn=30,Rn=15,Hi=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]),Sr=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]),Xu=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),Us=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Et=new Array(576);gn(Et);const Ln=new Array(60);gn(Ln);const Qn=new Array(512);gn(Qn);const Un=new Array(256);gn(Un);const cs=new Array(29);gn(cs);const qr=new Array(Dn);function ui(n,t,e,r,i){this.static_tree=n,this.extra_bits=t,this.extra_base=e,this.elems=r,this.max_length=i,this.has_stree=n&&n.length}let Ms,Ps,xs;function ci(n,t){this.dyn_tree=n,this.max_code=0,this.stat_desc=t}gn(qr);const yo=n=>n<256?Qn[n]:Qn[256+(n>>>7)],$n=(n,t)=>{n.pending_buf[n.pending++]=255&t,n.pending_buf[n.pending++]=t>>>8&255},Fe=(n,t,e)=>{n.bi_valid>16-e?(n.bi_buf|=t<<n.bi_valid&65535,$n(n,n.bi_buf),n.bi_buf=t>>16-n.bi_valid,n.bi_valid+=e-16):(n.bi_buf|=t<<n.bi_valid&65535,n.bi_valid+=e)},ft=(n,t,e)=>{Fe(n,e[2*t],e[2*t+1])},bo=(n,t)=>{let e=0;do e|=1&n,n>>>=1,e<<=1;while(--t>0);return e>>>1},Eo=(n,t,e)=>{const r=new Array(16);let i,s,a=0;for(i=1;i<=Rn;i++)a=a+e[i-1]<<1,r[i]=a;for(s=0;s<=t;s++){let o=n[2*s+1];o!==0&&(n[2*s]=bo(r[o]++,o))}},wo=n=>{let t;for(t=0;t<go;t++)n.dyn_ltree[2*t]=0;for(t=0;t<Dn;t++)n.dyn_dtree[2*t]=0;for(t=0;t<19;t++)n.bl_tree[2*t]=0;n.dyn_ltree[512]=1,n.opt_len=n.static_len=0,n.sym_next=n.matches=0},Io=n=>{n.bi_valid>8?$n(n,n.bi_buf):n.bi_valid>0&&(n.pending_buf[n.pending++]=n.bi_buf),n.bi_buf=0,n.bi_valid=0},Fs=(n,t,e,r)=>{const i=2*t,s=2*e;return n[i]<n[s]||n[i]===n[s]&&r[t]<=r[e]},li=(n,t,e)=>{const r=n.heap[e];let i=e<<1;for(;i<=n.heap_len&&(i<n.heap_len&&Fs(t,n.heap[i+1],n.heap[i],n.depth)&&i++,!Fs(t,r,n.heap[i],n.depth));)n.heap[e]=n.heap[i],e=i,i<<=1;n.heap[e]=r},qs=(n,t,e)=>{let r,i,s,a,o=0;if(n.sym_next!==0)do r=255&n.pending_buf[n.sym_buf+o++],r+=(255&n.pending_buf[n.sym_buf+o++])<<8,i=n.pending_buf[n.sym_buf+o++],r===0?ft(n,i,t):(s=Un[i],ft(n,s+us+1,t),a=Hi[s],a!==0&&(i-=cs[s],Fe(n,i,a)),r--,s=yo(r),ft(n,s,e),a=Sr[s],a!==0&&(r-=qr[s],Fe(n,r,a)));while(o<n.sym_next);ft(n,256,t)},di=(n,t)=>{const e=t.dyn_tree,r=t.stat_desc.static_tree,i=t.stat_desc.has_stree,s=t.stat_desc.elems;let a,o,u,c=-1;for(n.heap_len=0,n.heap_max=573,a=0;a<s;a++)e[2*a]!==0?(n.heap[++n.heap_len]=c=a,n.depth[a]=0):e[2*a+1]=0;for(;n.heap_len<2;)u=n.heap[++n.heap_len]=c<2?++c:0,e[2*u]=1,n.depth[u]=0,n.opt_len--,i&&(n.static_len-=r[2*u+1]);for(t.max_code=c,a=n.heap_len>>1;a>=1;a--)li(n,e,a);u=s;do a=n.heap[1],n.heap[1]=n.heap[n.heap_len--],li(n,e,1),o=n.heap[1],n.heap[--n.heap_max]=a,n.heap[--n.heap_max]=o,e[2*u]=e[2*a]+e[2*o],n.depth[u]=(n.depth[a]>=n.depth[o]?n.depth[a]:n.depth[o])+1,e[2*a+1]=e[2*o+1]=u,n.heap[1]=u++,li(n,e,1);while(n.heap_len>=2);n.heap[--n.heap_max]=n.heap[1],((l,d)=>{const _=d.dyn_tree,h=d.max_code,v=d.stat_desc.static_tree,m=d.stat_desc.has_stree,y=d.stat_desc.extra_bits,b=d.stat_desc.extra_base,w=d.stat_desc.max_length;let I,A,D,N,F,q,x=0;for(N=0;N<=Rn;N++)l.bl_count[N]=0;for(_[2*l.heap[l.heap_max]+1]=0,I=l.heap_max+1;I<573;I++)A=l.heap[I],N=_[2*_[2*A+1]+1]+1,N>w&&(N=w,x++),_[2*A+1]=N,A>
2h||(l.bl_count[N]++,F=0,A>=b&&(F=y[A-b]),q=_[2*A],l.opt_len+=q*(N+F),m&&(l.static_len+=q*(v[2*A+1]+F)));if(x!==0){do{for(N=w-1;l.bl_count[N]===0;)N--;l.bl_count[N]--,l.bl_count[N+1]+=2,l.bl_count[w]--,x-=2}while(x>0);for(N=w;N!==0;N--)for(A=l.bl_count[N];A!==0;)D=l.heap[--I],D>h||(_[2*D+1]!==N&&(l.opt_len+=(N-_[2*D+1])*_[2*D],_[2*D+1]=N),A--)}})(n,t),Eo(e,c,n.bl_count)},zs=(n,t,e)=>{let r,i,s=-1,a=t[1],o=0,u=7,c=4;for(a===0&&(u=138,c=3),t[2*(e+1)+1]=65535,r=0;r<=e;r++)i=a,a=t[2*(r+1)+1],++o<u&&i===a||(o<c?n.bl_tree[2*i]+=o:i!==0?(i!==s&&n.bl_tree[2*i]++,n.bl_tree[32]++):o<=10?n.bl_tree[34]++:n.bl_tree[36]++,o=0,s=i,a===0?(u=138,c=3):i===a?(u=6,c=3):(u=7,c=4))},Bs=(n,t,e)=>{let r,i,s=-1,a=t[1],o=0,u=7,c=4;for(a===0&&(u=138,c=3),r=0;r<=e;r++)if(i=a,a=t[2*(r+1)+1],!(++o<u&&i===a)){if(o<c)do ft(n,i,n.bl_tree);while(--o!=0);else i!==0?(i!==s&&(ft(n,i,n.bl_tree),o--),ft(n,16,n.bl_tree),Fe(n,o-3,2)):o<=10?(ft(n,17,n.bl_tree),Fe(n,o-3,3)):(ft(n,18,n.bl_tree),Fe(n,o-11,7));o=0,s=i,a===0?(u=138,c=3):i===a?(u=6,c=3):(u=7,c=4)}};let js=!1;const To=(n,t,e,r)=>{Fe(n,0+(r?1:0),3),Io(n),$n(n,e),$n(n,~e),e&&n.pending_buf.set(n.window.subarray(t,t+e),n.pending),n.pending+=e};var Ju=(n,t,e,r)=>{let i,s,a=0;n.level>0?(n.strm.data_type===2&&(n.strm.data_type=(o=>{let u,c=4093624447;for(u=0;u<=31;u++,c>>>=1)if(1&c&&o.dyn_ltree[2*u]!==0)return 0;if(o.dyn_ltree[18]!==0||o.dyn_ltree[20]!==0||o.dyn_ltree[26]!==0)return 1;for(u=32;u<us;u++)if(o.dyn_ltree[2*u]!==0)return 1;return 0})(n)),di(n,n.l_desc),di(n,n.d_desc),a=(o=>{let u;for(zs(o,o.dyn_ltree,o.l_desc.max_code),zs(o,o.dyn_dtree,o.d_desc.max_code),di(o,o.bl_desc),u=18;u>=3&&o.bl_tree[2*Us[u]+1]===0;u--);return o.opt_len+=3*(u+1)+5+5+4,u})(n),i=n.opt_len+3+7>>>3,s=n.static_len+3+7>>>3,s<=i&&(i=s)):i=s=e+5,e+4<=i&&t!==-1?To(n,t,e,r):n.strategy===4||s===i?(Fe(n,2+(r?1:0),3),qs(n,Et,Ln)):(Fe(n,4+(r?1:0),3),((o,u,c,l)=>{let d;for(Fe(o,u-257,5),Fe(o,c-1,5),Fe(o,l-4,4),d=0;d<l;d++)Fe(o,o.bl_tree[2*Us[d]+1],3);Bs(o,o.dyn_ltree,u-1),Bs(o,o.dyn_dtree,c-1)})(n,n.l_desc.max_code+1,n.d_desc.max_code+1,a+1),qs(n,n.dyn_ltree,n.dyn_dtree)),wo(n),r&&Io(n)},ec={_tr_init:n=>{js||((()=>{let t,e,r,i,s;const a=new Array(16);for(r=0,i=0;i<28;i++)for(cs[i]=r,t=0;t<1<<Hi[i];t++)Un[r++]=i;for(Un[r-1]=i,s=0,i=0;i<16;i++)for(qr[i]=s,t=0;t<1<<Sr[i];t++)Qn[s++]=i;for(s>>=7;i<Dn;i++)for(qr[i]=s<<7,t=0;t<1<<Sr[i]-7;t++)Qn[256+s++]=i;for(e=0;e<=Rn;e++)a[e]=0;for(t=0;t<=143;)Et[2*t+1]=8,t++,a[8]++;for(;t<=255;)Et[2*t+1]=9,t++,a[9]++;for(;t<=279;)Et[2*t+1]=7,t++,a[7]++;for(;t<=287;)Et[2*t+1]=8,t++,a[8]++;for(Eo(Et,287,a),t=0;t<Dn;t++)Ln[2*t+1]=5,Ln[2*t]=bo(t,5);Ms=new ui(Et,Hi,257,go,Rn),Ps=new ui(Ln,Sr,0,Dn,Rn),xs=new ui(new Array(0),Xu,0,19,7)})(),js=!0),n.l_desc=new ci(n.dyn_ltree,Ms),n.d_desc=new ci(n.dyn_dtree,Ps),n.bl_desc=new ci(n.bl_tree,xs),n.bi_buf=0,n.bi_valid=0,wo(n)},_tr_stored_block:To,_tr_flush_block:Ju,_tr_tally:(n,t,e)=>(n.pending_buf[n.sym_buf+n.sym_next++]=t,n.pending_buf[n.sym_buf+n.sym_next++]=t>>8,n.pending_buf[n.sym_buf+n.sym_next++]=e,t===0?n.dyn_ltree[2*e]++:(n.matches++,t--,n.dyn_ltree[2*(Un[e]+us+1)]++,n.dyn_dtree[2*yo(t)]++),n.sym_next===n.sym_end),_tr_align:n=>{Fe(n,2,3),ft(n,256,Et),(t=>{t.bi_valid===16?($n(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)})(n)}},Mn=(n,t,e,r)=>{let i=65535&n,s=n>>>16&65535,a=0;for(;e!==0;){a=e>2e3?2e3:e,e-=a;do i=i+t[r++]|0,s=s+i|0;while(--a);i%=65521,s%=65521}return i|s<<16};const tc=new Uint32Array((()=>{let n,t=[];for(var e=0;e<256;e++){n=e;for(var r=0;r<8;r++)n=1&n?3988292384^n>>>1:n>>>1;t[e]=n}return t})());var Ie=(n,t,e,r)=>{const i=tc,s=r+e;n^=-1;for(let a=r;a<s;a++)n=n>>>8^i[255&(n^t[a])];return~n},en={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"},Jn={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};const{_tr_init:nc,_tr_stored_block:Vi,_tr_flush_block:rc,_tr_tally:Lt,_tr_align:ic}=ec,{Z_NO_FLUSH:Ut,Z_PARTIAL_FLUSH:sc,Z_FULL_FLUSH:ac,Z_FINISH:Ze,Z_BLOCK:Ks,Z_OK:Te,Z_STREAM_END:Hs,Z_STREAM_ERROR:lt,Z_DATA_ERROR:oc,Z_BUF_ER
2ROR:hi,Z_DEFAULT_COMPRESSION:uc,Z_FILTERED:cc,Z_HUFFMAN_ONLY:or,Z_RLE:lc,Z_FIXED:dc,Z_DEFAULT_STRATEGY:hc,Z_UNKNOWN:fc,Z_DEFLATED:zr}=Jn,Gt=258,_t=262,cn=42,jt=113,Cn=666,Kt=(n,t)=>(n.msg=en[t],t),Vs=n=>2*n-(n>4?9:0),Dt=n=>{let t=n.length;for(;--t>=0;)n[t]=0},pc=n=>{let t,e,r,i=n.w_size;t=n.hash_size,r=t;do e=n.head[--r],n.head[r]=e>=i?e-i:0;while(--t);t=i,r=t;do e=n.prev[--r],n.prev[r]=e>=i?e-i:0;while(--t)};let Mt=(n,t,e)=>(t<<n.hash_shift^e)&n.hash_mask;const Be=n=>{const t=n.state;let e=t.pending;e>n.avail_out&&(e=n.avail_out),e!==0&&(n.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+e),n.next_out),n.next_out+=e,t.pending_out+=e,n.total_out+=e,n.avail_out-=e,t.pending-=e,t.pending===0&&(t.pending_out=0))},Ke=(n,t)=>{rc(n,n.block_start>=0?n.block_start:-1,n.strstart-n.block_start,t),n.block_start=n.strstart,Be(n.strm)},re=(n,t)=>{n.pending_buf[n.pending++]=t},In=(n,t)=>{n.pending_buf[n.pending++]=t>>>8&255,n.pending_buf[n.pending++]=255&t},Gi=(n,t,e,r)=>{let i=n.avail_in;return i>r&&(i=r),i===0?0:(n.avail_in-=i,t.set(n.input.subarray(n.next_in,n.next_in+i),e),n.state.wrap===1?n.adler=Mn(n.adler,t,i,e):n.state.wrap===2&&(n.adler=Ie(n.adler,t,i,e)),n.next_in+=i,n.total_in+=i,i)},So=(n,t)=>{let e,r,i=n.max_chain_length,s=n.strstart,a=n.prev_length,o=n.nice_match;const u=n.strstart>n.w_size-_t?n.strstart-(n.w_size-_t):0,c=n.window,l=n.w_mask,d=n.prev,_=n.strstart+Gt;let h=c[s+a-1],v=c[s+a];n.prev_length>=n.good_match&&(i>>=2),o>n.lookahead&&(o=n.lookahead);do if(e=t,c[e+a]===v&&c[e+a-1]===h&&c[e]===c[s]&&c[++e]===c[s+1]){s+=2,e++;do;while(c[++s]===c[++e]&&c[++s]===c[++e]&&c[++s]===c[++e]&&c[++s]===c[++e]&&c[++s]===c[++e]&&c[++s]===c[++e]&&c[++s]===c[++e]&&c[++s]===c[++e]&&s<_);if(r=Gt-(_-s),s=_-Gt,r>a){if(n.match_start=t,a=r,r>=o)break;h=c[s+a-1],v=c[s+a]}}while((t=d[t&l])>u&&--i!=0);return a<=n.lookahead?a:n.lookahead},on=n=>{const t=n.w_size;let e,r,i;do{if(r=n.window_size-n.lookahead-n.strstart,n.strstart>=t+(t-_t)&&(n.window.set(n.window.subarray(t,t+t-r),0),n.match_start-=t,n.strstart-=t,n.block_start-=t,n.insert>n.strstart&&(n.insert=n.strstart),pc(n),r+=t),n.strm.avail_in===0)break;if(e=Gi(n.strm,n.window,n.strstart+n.lookahead,r),n.lookahead+=e,n.lookahead+n.insert>=3)for(i=n.strstart-n.insert,n.ins_h=n.window[i],n.ins_h=Mt(n,n.ins_h,n.window[i+1]);n.insert&&(n.ins_h=Mt(n,n.ins_h,n.window[i+3-1]),n.prev[i&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=i,i++,n.insert--,!(n.lookahead+n.insert<3)););}while(n.lookahead<_t&&n.strm.avail_in!==0)},Co=(n,t)=>{let e,r,i,s=n.pending_buf_size-5>n.w_size?n.w_size:n.pending_buf_size-5,a=0,o=n.strm.avail_in;do{if(e=65535,i=n.bi_valid+42>>3,n.strm.avail_out<i||(i=n.strm.avail_out-i,r=n.strstart-n.block_start,e>r+n.strm.avail_in&&(e=r+n.strm.avail_in),e>i&&(e=i),e<s&&(e===0&&t!==Ze||t===Ut||e!==r+n.strm.avail_in)))break;a=t===Ze&&e===r+n.strm.avail_in?1:0,Vi(n,0,0,a),n.pending_buf[n.pending-4]=e,n.pending_buf[n.pending-3]=e>>8,n.pending_buf[n.pending-2]=~e,n.pending_buf[n.pending-1]=~e>>8,Be(n.strm),r&&(r>e&&(r=e),n.strm.output.set(n.window.subarray(n.block_start,n.block_start+r),n.strm.next_out),n.strm.next_out+=r,n.strm.avail_out-=r,n.strm.total_out+=r,n.block_start+=r,e-=r),e&&(Gi(n.strm,n.strm.output,n.strm.next_out,e),n.strm.next_out+=e,n.strm.avail_out-=e,n.strm.total_out+=e)}while(a===0);return o-=n.strm.avail_in,o&&(o>=n.w_size?(n.matches=2,n.window.set(n.strm.input.subarray(n.strm.next_in-n.w_size,n.strm.next_in),0),n.strstart=n.w_size,n.insert=n.strstart):(n.window_size-n.strstart<=o&&(n.strstart-=n.w_size,n.window.set(n.window.subarray(n.w_size,n.w_size+n.strstart),0),n.matches<2&&n.matches++,n.insert>n.strstart&&(n.insert=n.strstart)),n.window.set(n.strm.input.subarray(n.strm.next_in-o,n.strm.next_in),n.strstart),n.strstart+=o,n.insert+=o>n.w_size-n.insert?n.w_size-n.insert:o),n.block_start=n.strstart),n.high_water<n.strstart&&(n.high_water=n.strstart),a?4:t!==Ut&&t!==Ze&&n.strm.avail_in===0&&n.strstart===n.block_start?2:(i=n.window_size-n.strstart,n.strm.avail_in>i&&n.block_start>=n.w_size&&(n.block_start-=n.w_size,n.strstart-=n.w_size,n.window.set(n.window.subarray(n.w_size,n.w_size+n.strstart),0),n.matches<2&&n.matches++,i+=n.w_size,n.insert>n.strstart&&(n.insert=n.strstart)),i>n.strm.avail_in&&(i=n.strm.avail_in),i&&(Gi(n.strm,n.window,n.strstart,i),n.strstart+=i,n.insert+=i>n.w_size-n.insert?n.w_size-n.insert:i),n.high_water<n.strstart&&(n.high_water=n.strstart),i=n.bi_valid+42>>3,i=n.pending_buf_size-i>65535?65535:n.pending_buf_size-i,s=i>n.w_size?n.w_size:i,r=n.strstart-n.block_start,(r>=s||(r||t===Ze)&&t!==Ut&&n.strm.avail_in===0&&r<=i)&&(e=r>i?i:r,a=t===Ze&&n.strm.avail_in===0&&e===r?1:0,Vi(n,n.block_start,e,a),n.block_start+=e,Be(n.strm)),a?3:1)},fi=(n,t)=>{let e,r;for(;;){if(n.lookahead<_t){if(on(n),n.lookahead<_t&&t===Ut)return 1;if(n.lookahead===0)break}if(e=0,n.lookahead>=3&&(n.ins_h=Mt(n,n.ins_h,n.window[n.strstart+3-1]),e=n.prev[n.strstart&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=n.strstart),e!==0&&n.strstart-e<=n.w_size-_t&&(n.match_length=So(n,e)),n.match_length>=3)if(r=Lt(n,n.strstart-n.match_start,n.match_length-3),n.lookahead-=n.match_length,n.match_length<=n.max_lazy_match&&n.lookahead>=3){n.match_length--;do n.strstart++,n.ins_h=Mt(n,n.ins_h,n.window[n.strstart+3-1]),e=n.prev[n.strstart&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=n.strstart;while(--n.match_length!=0);n.strstart++}else n.strstart+=n.match_length,n.match_length=0,n.ins_h=n.window[n.strstart],n.ins_h=Mt(n,n.ins_h,n.window[n.strstart+1]);else r=Lt(n,0,n.window[n.strstart]),n.lookahead--,n.strstart++;if(r&&(Ke(n,!1),n.strm.avail_out===0))return 1}return n.insert=n.strstart<2?n.strstart:2,t===Ze?(Ke(n,!0),n.strm.avail_out===0?3:4):n.sym_next&&(Ke(n,!1),n.strm.avail_out===0)?1:2},sn=(n,t)=>{let e,r,i;for(;;){if(n.lookahead<_t){if(on(n),n.lookahead<_t&&t===Ut)return 1;if(n.lookahead===0)break}if(e=0,n.lookahead>=3&&(n.ins_h=Mt(n,n.ins_h,n.window[n.strstart+3-1]),e=n.prev[n.strstart&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=n.strstart),n.prev_length=n.match_length,n.prev_match=n.match_start,n.match_length=2,e!==0&&n.prev_length<n.max_lazy_match&&n.strstart-e<=n.w_size-_t&&(n.match_length=So(n,e),n.match_length<=5&&(n.strategy===cc||n.match_length===3&&n.strstart-n.match_start>4096)&&(n.match_length=2)),n.prev_length>=3&&n.match_length<=n.prev_length){i=n.strstart+n.lookahead-3,r=Lt(n,n.strstart-1-n.prev_match,n.prev_length-3),n.lookahead-=n.prev_length-1,n.prev_length-=2;do++n.strstart<=i&&(n.ins_h=Mt(n,n.ins_h,n.window[n.strstart+3-1]),e=n.prev[n.strstart&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=n.strstart);while(--n.prev_length!=0);if(n.match_available=0,n.match_length=2,n.strstart++,r&&(Ke(n,!1),n.strm.avail_out===0))return 1}else if(n.match_available){if(r=Lt(n,0,n.window[n.strstart-1]),r&&Ke(n,!1),n.strstart++,n.lookahead--,n.strm.avail_out===0)return 1}else n.match_available=1,n.strstart++,n.lookahead--}return n.match_available&&(r=Lt(n,0,n.window[n.strstart-1]),n.match_available=0),n.insert=n.strstart<2?n.strstart:2,t===Ze?(Ke(n,!0),n.strm.avail_out===0?3:4):n.sym_next&&(Ke(n,!1),n.strm.avail_out===0)?1:2};function ut(n,t,e,r,i){this.good_length=n,this.max_lazy=t,this.nice_length=e,this.max_chain=r,this.func=i}const An=[new ut(0,0,0,0,Co),new ut(4,4,8,4,fi),new ut(4,5,16,8,fi),new ut(4,6,32,32,fi),new ut(4,4,16,16,sn),new ut(8,16,32,32,sn),new ut(8,16,128,128,sn),new ut(8,32,128,256,sn),new ut(32,128,258,1024,sn),new ut(32,258,258,4096,sn)];function _c(){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=zr,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),Dt(this.dyn_ltree),Dt(this.dyn_dtree),Dt(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),Dt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),Dt(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}const Nn=n=>{if(!n)return 1;const t=n.state;return!t||t.strm!==n||t.status!==cn&&t.status!==57&&t.status!==69&&t.status!==73&&t.status!==91&&t.status!==103&&t.status!==jt&&t.status!==Cn?1:0},Ao=n=>{if(Nn(n))return Kt(n,lt);n.total_in=n.total_out=0,n.data_type=fc;const t=n.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap===2?57:t.wrap?cn:jt,n.adler=t.wrap===2?0:1,t.last_flush=-2,nc(t),Te},No=n=>{const t=Ao(n);var e;return t===Te&&((e=n.state).window_size=2*e.w_size,Dt(e.head),e.max_lazy_match=An[e.level].max_lazy,e.good_match=An[e.level].good_length,e.nice_match=An[e.level].nice_length,e.max_chain_length=An[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=2,e.match_available=0,e.ins_h=0),t},Gs=(n,t,e,r,i,s)=>{if(!n)return lt;let a=1;if(t===uc&&(t=6),r<0?(a=0,r=-r):r>
215&&(a=2,r-=16),i<1||i>9||e!==zr||r<8||r>15||t<0||t>9||s<0||s>dc||r===8&&a!==1)return Kt(n,lt);r===8&&(r=9);const o=new _c;return n.state=o,o.strm=n,o.status=cn,o.wrap=a,o.gzhead=null,o.w_bits=r,o.w_size=1<<o.w_bits,o.w_mask=o.w_size-1,o.hash_bits=i+7,o.hash_size=1<<o.hash_bits,o.hash_mask=o.hash_size-1,o.hash_shift=~~((o.hash_bits+3-1)/3),o.window=new Uint8Array(2*o.w_size),o.head=new Uint16Array(o.hash_size),o.prev=new Uint16Array(o.w_size),o.lit_bufsize=1<<i+6,o.pending_buf_size=4*o.lit_bufsize,o.pending_buf=new Uint8Array(o.pending_buf_size),o.sym_buf=o.lit_bufsize,o.sym_end=3*(o.lit_bufsize-1),o.level=t,o.strategy=s,o.method=e,No(n)};var Pn={deflateInit:(n,t)=>Gs(n,t,zr,15,8,hc),deflateInit2:Gs,deflateReset:No,deflateResetKeep:Ao,deflateSetHeader:(n,t)=>Nn(n)||n.state.wrap!==2?lt:(n.state.gzhead=t,Te),deflate:(n,t)=>{if(Nn(n)||t>Ks||t<0)return n?Kt(n,lt):lt;const e=n.state;if(!n.output||n.avail_in!==0&&!n.input||e.status===Cn&&t!==Ze)return Kt(n,n.avail_out===0?hi:lt);const r=e.last_flush;if(e.last_flush=t,e.pending!==0){if(Be(n),n.avail_out===0)return e.last_flush=-1,Te}else if(n.avail_in===0&&Vs(t)<=Vs(r)&&t!==Ze)return Kt(n,hi);if(e.status===Cn&&n.avail_in!==0)return Kt(n,hi);if(e.status===cn&&e.wrap===0&&(e.status=jt),e.status===cn){let i=zr+(e.w_bits-8<<4)<<8,s=-1;if(s=e.strategy>=or||e.level<2?0:e.level<6?1:e.level===6?2:3,i|=s<<6,e.strstart!==0&&(i|=32),i+=31-i%31,In(e,i),e.strstart!==0&&(In(e,n.adler>>>16),In(e,65535&n.adler)),n.adler=1,e.status=jt,Be(n),e.pending!==0)return e.last_flush=-1,Te}if(e.status===57){if(n.adler=0,re(e,31),re(e,139),re(e,8),e.gzhead)re(e,(e.gzhead.text?1:0)+(e.gzhead.hcrc?2:0)+(e.gzhead.extra?4:0)+(e.gzhead.name?8:0)+(e.gzhead.comment?16:0)),re(e,255&e.gzhead.time),re(e,e.gzhead.time>>8&255),re(e,e.gzhead.time>>16&255),re(e,e.gzhead.time>>24&255),re(e,e.level===9?2:e.strategy>=or||e.level<2?4:0),re(e,255&e.gzhead.os),e.gzhead.extra&&e.gzhead.extra.length&&(re(e,255&e.gzhead.extra.length),re(e,e.gzhead.extra.length>>8&255)),e.gzhead.hcrc&&(n.adler=Ie(n.adler,e.pending_buf,e.pending,0)),e.gzindex=0,e.status=69;else if(re(e,0),re(e,0),re(e,0),re(e,0),re(e,0),re(e,e.level===9?2:e.strategy>=or||e.level<2?4:0),re(e,3),e.status=jt,Be(n),e.pending!==0)return e.last_flush=-1,Te}if(e.status===69){if(e.gzhead.extra){let i=e.pending,s=(65535&e.gzhead.extra.length)-e.gzindex;for(;e.pending+s>e.pending_buf_size;){let o=e.pending_buf_size-e.pending;if(e.pending_buf.set(e.gzhead.extra.subarray(e.gzindex,e.gzindex+o),e.pending),e.pending=e.pending_buf_size,e.gzhead.hcrc&&e.pending>i&&(n.adler=Ie(n.adler,e.pending_buf,e.pending-i,i)),e.gzindex+=o,Be(n),e.pending!==0)return e.last_flush=-1,Te;i=0,s-=o}let a=new Uint8Array(e.gzhead.extra);e.pending_buf.set(a.subarray(e.gzindex,e.gzindex+s),e.pending),e.pending+=s,e.gzhead.hcrc&&e.pending>i&&(n.adler=Ie(n.adler,e.pending_buf,e.pending-i,i)),e.gzindex=0}e.status=73}if(e.status===73){if(e.gzhead.name){let i,s=e.pending;do{if(e.pending===e.pending_buf_size){if(e.gzhead.hcrc&&e.pending>s&&(n.adler=Ie(n.adler,e.pending_buf,e.pending-s,s)),Be(n),e.pending!==0)return e.last_flush=-1,Te;s=0}i=e.gzindex<e.gzhead.name.length?255&e.gzhead.name.charCodeAt(e.gzindex++):0,re(e,i)}while(i!==0);e.gzhead.hcrc&&e.pending>s&&(n.adler=Ie(n.adler,e.pending_buf,e.pending-s,s)),e.gzindex=0}e.status=91}if(e.status===91){if(e.gzhead.comment){let i,s=e.pending;do{if(e.pending===e.pending_buf_size){if(e.gzhead.hcrc&&e.pending>s&&(n.adler=Ie(n.adler,e.pending_buf,e.pending-s,s)),Be(n),e.pending!==0)return e.last_flush=-1,Te;s=0}i=e.gzindex<e.gzhead.comment.length?255&e.gzhead.comment.charCodeAt(e.gzindex++):0,re(e,i)}while(i!==0);e.gzhead.hcrc&&e.pending>s&&(n.adler=Ie(n.adler,e.pending_buf,e.pending-s,s))}e.status=103}if(e.status===103){if(e.gzhead.hcrc){if(e.pending+2>e.pending_buf_size&&(Be(n),e.pending!==0))return e.last_flush=-1,Te;re(e,255&n.adler),re(e,n.adler>>8&255),n.adler=0}if(e.status=jt,Be(n),e.pending!==0)return e.last_flush=-1,Te}if(n.avail_in!==0||e.lookahead!==0||t!==Ut&&e.status!==Cn){let i=e.level===0?Co(e,t):e.strategy===or?((s,a)=>{let o;for(;;){if(s.lookahead===0&&(on(s),s.lookahead===0)){if(a===Ut)return 1;break}if(s.match_length=0,o=Lt(s,0,s.window[s.strstart]),s.lookahead--,s.strstart++,o&&(Ke(s,!1),s.strm.avail_out===0))return 1}return s.insert=0,a===Ze?(Ke(s,!0),s.strm.avail_out===0?3:4):s.sym_next&&(Ke(s,!1),s.strm.avail_out===0)?1:2})(e,t):e.strategy===lc?((s,a)=>{let o,u,c,l;const d=s.window;for(;;){if(s.lookahead<=Gt){if(on(s),s.lookahead<=Gt&&a===Ut)return 1;if(s.lookahead===0)break}if(s.match_length=0,s.lookahead>=3&&s.strstart>0&&(c=s.strstart-1,u=d[c],u===d[++c]&&u===d[++c]&&u===d[++c])){l=s.strstart+Gt;do;while(u===d[++c]&&u===d[++c]&&u===d[++c]&&u===d[++c]&&u===d[++c]&&u===d[++c]&&u===d[++c]&&u===d[++c]&&c<l);s.match_length=Gt-(l-c),s.match_length>s.lookahead&&(s.match_length=s.lookahead)}if(s.match_length>=3?(o=Lt(s,1,s.match_length-3),s.lookahead-=s.match_length,s.strstart+=s.match_length,s.match_length=0):(o=Lt(s,0,s.window[s.strstart]),s.lookahead--,s.strstart++),o&&(Ke(s,!1),s.strm.avail_out===0))return 1}return s.insert=0,a===Ze?(Ke(s,!0),s.strm.avail_out===0?3:4):s.sym_next&&(Ke(s,!1),s.strm.avail_out===0)?1:2})(e,t):An[e.level].func(e,t);if(i!==3&&i!==4||(e.status=Cn),i===1||i===3)return n.avail_out===0&&(e.last_flush=-1),Te;if(i===2&&(t===sc?ic(e):t!==Ks&&(Vi(e,0,0,!1),t===ac&&(Dt(e.head),e.lookahead===0&&(e.strstart=0,e.block_start=0,e.insert=0))),Be(n),n.avail_out===0))return e.last_flush=-1,Te}return t!==Ze?Te:e.wrap<=0?Hs:(e.wrap===2?(re(e,255&n.adler),re(e,n.adler>>8&255),re(e,n.adler>>16&255),re(e,n.adler>>24&255),re(e,255&n.total_in),re(e,n.total_in>>8&255),re(e,n.total_in>>16&255),re(e,n.total_in>>24&255)):(In(e,n.adler>>>16),In(e,65535&n.adler)),Be(n),e.wrap>0&&(e.wrap=-e.wrap),e.pending!==0?Te:Hs)},deflateEnd:n=>{if(Nn(n))return lt;const t=n.state.status;return n.state=null,t===jt?Kt(n,oc):Te},deflateSetDictionary:(n,t)=>{let e=t.length;if(Nn(n))return lt;const r=n.state,i=r.wrap;if(i===2||i===1&&r.status!==cn||r.lookahead)return lt;
2if(i===1&&(n.adler=Mn(n.adler,t,e,0)),r.wrap=0,e>=r.w_size){i===0&&(Dt(r.head),r.strstart=0,r.block_start=0,r.insert=0);let u=new Uint8Array(r.w_size);u.set(t.subarray(e-r.w_size,e),0),t=u,e=r.w_size}const s=n.avail_in,a=n.next_in,o=n.input;for(n.avail_in=e,n.next_in=0,n.input=t,on(r);r.lookahead>=3;){let u=r.strstart,c=r.lookahead-2;do r.ins_h=Mt(r,r.ins_h,r.window[u+3-1]),r.prev[u&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=u,u++;while(--c);r.strstart=u,r.lookahead=2,on(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=2,r.match_available=0,n.next_in=a,n.input=o,n.avail_in=s,r.wrap=i,Te},deflateInfo:"pako deflate (from Nodeca project)"};const vc=(n,t)=>Object.prototype.hasOwnProperty.call(n,t);var ko=function(n){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const e=t.shift();if(e){if(typeof e!="object")throw new TypeError(e+"must be non-object");for(const r in e)vc(e,r)&&(n[r]=e[r])}}return n},Oo=n=>{let t=0;for(let r=0,i=n.length;r<i;r++)t+=n[r].length;const e=new Uint8Array(t);for(let r=0,i=0,s=n.length;r<s;r++){let a=n[r];e.set(a,i),i+=a.length}return e};let Do=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(n){Do=!1}const Wn=new Uint8Array(256);for(let n=0;n<256;n++)Wn[n]=n>=252?6:n>=248?5:n>=240?4:n>=224?3:n>=192?2:1;Wn[254]=Wn[254]=1;var ls=n=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(n);let t,e,r,i,s,a=n.length,o=0;for(i=0;i<a;i++)e=n.charCodeAt(i),(64512&e)==55296&&i+1<a&&(r=n.charCodeAt(i+1),(64512&r)==56320&&(e=65536+(e-55296<<10)+(r-56320),i++)),o+=e<128?1:e<2048?2:e<65536?3:4;for(t=new Uint8Array(o),s=0,i=0;s<o;i++)e=n.charCodeAt(i),(64512&e)==55296&&i+1<a&&(r=n.charCodeAt(i+1),(64512&r)==56320&&(e=65536+(e-55296<<10)+(r-56320),i++)),e<128?t[s++]=e:e<2048?(t[s++]=192|e>>>6,t[s++]=128|63&e):e<65536?(t[s++]=224|e>>>12,t[s++]=128|e>>>6&63,t[s++]=128|63&e):(t[s++]=240|e>>>18,t[s++]=128|e>>>12&63,t[s++]=128|e>>>6&63,t[s++]=128|63&e);return t},mc=(n,t)=>{const e=t||n.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(n.subarray(0,t));let r,i;const s=new Array(2*e);for(i=0,r=0;r<e;){let a=n[r++];if(a<128){s[i++]=a;continue}let o=Wn[a];if(o>4)s[i++]=65533,r+=o-1;else{for(a&=o===2?31:o===3?15:7;o>1&&r<e;)a=a<<6|63&n[r++],o--;o>1?s[i++]=65533:a<65536?s[i++]=a:(a-=65536,s[i++]=55296|a>>10&1023,s[i++]=56320|1023&a)}}return((a,o)=>{if(o<65534&&a.subarray&&Do)return String.fromCharCode.apply(null,a.length===o?a:a.subarray(0,o));let u="";for(let c=0;c<o;c++)u+=String.fromCharCode(a[c]);return u})(s,i)},gc=(n,t)=>{(t=t||n.length)>n.length&&(t=n.length);let e=t-1;for(;e>=0&&(192&n[e])==128;)e--;return e<0||e===0?t:e+Wn[n[e]]>t?e:t},Ro=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};const Lo=Object.prototype.toString,{Z_NO_FLUSH:yc,Z_SYNC_FLUSH:bc,Z_FULL_FLUSH:Ec,Z_FINISH:wc,Z_OK:Br,Z_STREAM_END:Ic,Z_DEFAULT_COMPRESSION:Tc,Z_DEFAULT_STRATEGY:Sc,Z_DEFLATED:Cc}=Jn;function xn(n){this.options=ko({level:Tc,method:Cc,chunkSize:16384,windowBits:15,memLevel:8,strategy:Sc},n||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Ro,this.strm.avail_out=0;let e=Pn.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(e!==Br)throw new Error(en[e]);if(t.header&&Pn.deflateSetHeader(this.strm,t.header),t.dictionary){let r;if(r=typeof t.dictionary=="string"?ls(t.dictionary):Lo.call(t.dictionary)==="[object ArrayBuffer]"?new Uint8Array(t.dictionary):t.dictionary,e=Pn.deflateSetDictionary(this.strm,r),e!==Br)throw new Error(en[e]);this._dict_set=!0}}function pi(n,t){const e=new xn(t);if(e.push(n,!0),e.err)throw e.msg||en[e.err];return e.result}xn.prototype.push=function(n,t){const e=this.strm,r=this.options.chunkSize;let i,s;if(this.ended)return!1;for(s=t===~~t?t:t===!0?wc:yc,typeof n=="string"?e.input=ls(n):Lo.call(n)==="[object ArrayBuffer]"?e.input=new
2Uint8Array(n):e.input=n,e.next_in=0,e.avail_in=e.input.length;;)if(e.avail_out===0&&(e.output=new Uint8Array(r),e.next_out=0,e.avail_out=r),(s===bc||s===Ec)&&e.avail_out<=6)this.onData(e.output.subarray(0,e.next_out)),e.avail_out=0;else{if(i=Pn.deflate(e,s),i===Ic)return e.next_out>0&&this.onData(e.output.subarray(0,e.next_out)),i=Pn.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===Br;if(e.avail_out!==0){if(s>0&&e.next_out>0)this.onData(e.output.subarray(0,e.next_out)),e.avail_out=0;else if(e.avail_in===0)break}else this.onData(e.output)}return!0},xn.prototype.onData=function(n){this.chunks.push(n)},xn.prototype.onEnd=function(n){n===Br&&(this.result=Oo(this.chunks)),this.chunks=[],this.err=n,this.msg=this.strm.msg};var Ac={Deflate:xn,deflate:pi,deflateRaw:function(n,t){return(t=t||{}).raw=!0,pi(n,t)},gzip:function(n,t){return(t=t||{}).gzip=!0,pi(n,t)}};const ur=16209;var Nc=function(n,t){let e,r,i,s,a,o,u,c,l,d,_,h,v,m,y,b,w,I,A,D,N,F,q,x;const H=n.state;e=n.next_in,q=n.input,r=e+(n.avail_in-5),i=n.next_out,x=n.output,s=i-(t-n.avail_out),a=i+(n.avail_out-257),o=H.dmax,u=H.wsize,c=H.whave,l=H.wnext,d=H.window,_=H.hold,h=H.bits,v=H.lencode,m=H.distcode,y=(1<<H.lenbits)-1,b=(1<<H.distbits)-1;e:do{h<15&&(_+=q[e++]<<h,h+=8,_+=q[e++]<<h,h+=8),w=v[_&y];t:for(;;){if(I=w>>>24,_>>>=I,h-=I,I=w>>>16&255,I===0)x[i++]=65535&w;else{if(!(16&I)){if(64&I){if(32&I){H.mode=16191;break e}n.msg="invalid literal/length code",H.mode=ur;break e}w=v[(65535&w)+(_&(1<<I)-1)];continue t}for(A=65535&w,I&=15,I&&(h<I&&(_+=q[e++]<<h,h+=8),A+=_&(1<<I)-1,_>>>=I,h-=I),h<15&&(_+=q[e++]<<h,h+=8,_+=q[e++]<<h,h+=8),w=m[_&b];;){if(I=w>>>24,_>>>=I,h-=I,I=w>>>16&255,16&I){if(D=65535&w,I&=15,h<I&&(_+=q[e++]<<h,h+=8,h<I&&(_+=q[e++]<<h,h+=8)),D+=_&(1<<I)-1,D>o){n.msg="invalid distance too far back",H.mode=ur;break e}if(_>>>=I,h-=I,I=i-s,D>I){if(I=D-I,I>c&&H.sane){n.msg="invalid distance too far back",H.mode=ur;break e}if(N=0,F=d,l===0){if(N+=u-I,I<A){A-=I;do x[i++]=d[N++];while(--I);N=i-D,F=x}}else if(l<I){if(N+=u+l-I,I-=l,I<A){A-=I;do x[i++]=d[N++];while(--I);if(N=0,l<A){I=l,A-=I;do x[i++]=d[N++];while(--I);N=i-D,F=x}}}else if(N+=l-I,I<A){A-=I;do x[i++]=d[N++];while(--I);N=i-D,F=x}for(;A>2;)x[i++]=F[N++],x[i++]=F[N++],x[i++]=F[N++],A-=3;A&&(x[i++]=F[N++],A>1&&(x[i++]=F[N++]))}else{N=i-D;do x[i++]=x[N++],x[i++]=x[N++],x[i++]=x[N++],A-=3;while(A>2);A&&(x[i++]=x[N++],A>1&&(x[i++]=x[N++]))}break}if(64&I){n.msg="invalid distance code",H.mode=ur;break e}w=m[(65535&w)+(_&(1<<I)-1)]}}break}}while(e<r&&i<a);A=h>>3,e-=A,h-=A<<3,_&=(1<<h)-1,n.next_in=e,n.next_out=i,n.avail_in=e<r?r-e+5:5-(e-r),n.avail_out=i<a?a-i+257:257-(i-a),H.hold=_,H.bits=h};const cr=15,kc=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),Oc=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),Dc=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),Rc=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var Fn=(n,t,e,r,i,s,a,o)=>{const u=o.bits;let c,l,d,_,h,v,m=0,y=0,b=0,w=0,I=0,A=0,D=0,N=0,F=0,q=0,x=null;const H=new Uint16Array(16),j=new Uint16Array(16);let P,ce,Me,Pe=null;for(m=0;m<=cr;m++)H[m]=0;for(y=0;y<r;y++)H[t[e+y]]++;for(I=u,w=cr;w>=1&&H[w]===0;w--);if(I>w&&(I=w),w===0)return i[s++]=20971520,i[s++]=20971520,o.bits=1,0;for(b=1;b<w&&H[b]===0;b++);for(I<b&&(I=b),N=1,m=1;m<=cr;m++)if(N<<=1,N-=H[m],N<0)return-1;if(N>0&&(n===0||w!==1))return-1;for(j[1]=0,m=1;m<cr;m++)j[m+1]=j[m]+H[m];for(y=0;y<r;y++)t[e+y]!==0&&(a[j[t[e+y]]++]=y);if(n===0?(x=Pe=a,v=20):n===1?(x=kc,Pe=Oc,v=257):(x=Dc,Pe=Rc,v=0),q=0,y=0,m=b,h=s,A=I,D=0,d=-1,F=1<<I,_=F-1,n===1&&F>852||n===2&&F>592)return 1;for(;;){P=m-D,a[y]+1<v?(ce=0,Me=a[y]):a[y]>=v?(ce=Pe[a[y]-v],Me=x[a[y]-v]):(ce=96,Me=0),c=1<<m-D,l=1<<A,b=l;do l-=c,i[h+(q>>D)+l]=P<<24|ce<<16|Me;while(l!==0);for(c=1<<m-1;q&c;)c>>=1;if(c!==0?(q&=c-1,q+=c):q=0,y++,--H[m]==0){if(m===w)break;m=t[e+a[y]]}if(m>I&&(q&_)!==d){for(D===0&&(D=I),h+=b,A=m-D,N=1<<A;
2A+D<w&&(N-=H[A+D],!(N<=0));)A++,N<<=1;if(F+=1<<A,n===1&&F>852||n===2&&F>592)return 1;d=q&_,i[d]=I<<24|A<<16|h-s}}return q!==0&&(i[h+q]=m-D<<24|64<<16),o.bits=I,0};const{Z_FINISH:Qs,Z_BLOCK:Lc,Z_TREES:lr,Z_OK:Ht,Z_STREAM_END:Uc,Z_NEED_DICT:Mc,Z_STREAM_ERROR:Ye,Z_DATA_ERROR:$s,Z_MEM_ERROR:Ws,Z_BUF_ERROR:Pc,Z_DEFLATED:Ys}=Jn,Wr=16180,dr=16190,yt=16191,_i=16192,vi=16194,hr=16199,fr=16200,mi=16206,le=16209,Zs=n=>(n>>>24&255)+(n>>>8&65280)+((65280&n)<<8)+((255&n)<<24);function xc(){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}const Qt=n=>{if(!n)return 1;const t=n.state;return!t||t.strm!==n||t.mode<Wr||t.mode>16211?1:0},Uo=n=>{if(Qt(n))return Ye;const t=n.state;return n.total_in=n.total_out=t.total=0,n.msg="",t.wrap&&(n.adler=1&t.wrap),t.mode=Wr,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,Ht},Mo=n=>{if(Qt(n))return Ye;const t=n.state;return t.wsize=0,t.whave=0,t.wnext=0,Uo(n)},Po=(n,t)=>{let e;if(Qt(n))return Ye;const r=n.state;return t<0?(e=0,t=-t):(e=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?Ye:(r.window!==null&&r.wbits!==t&&(r.window=null),r.wrap=e,r.wbits=t,Mo(n))},Xs=(n,t)=>{if(!n)return Ye;const e=new xc;n.state=e,e.strm=n,e.window=null,e.mode=Wr;const r=Po(n,t);return r!==Ht&&(n.state=null),r};let gi,yi,Js=!0;const Fc=n=>{if(Js){gi=new Int32Array(512),yi=new Int32Array(32);let t=0;for(;t<144;)n.lens[t++]=8;for(;t<256;)n.lens[t++]=9;for(;t<280;)n.lens[t++]=7;for(;t<288;)n.lens[t++]=8;for(Fn(1,n.lens,0,288,gi,0,n.work,{bits:9}),t=0;t<32;)n.lens[t++]=5;Fn(2,n.lens,0,32,yi,0,n.work,{bits:5}),Js=!1}n.lencode=gi,n.lenbits=9,n.distcode=yi,n.distbits=5},ea=(n,t,e,r)=>{let i;const s=n.state;return s.window===null&&(s.wsize=1<<s.wbits,s.wnext=0,s.whave=0,s.window=new Uint8Array(s.wsize)),r>=s.wsize?(s.window.set(t.subarray(e-s.wsize,e),0),s.wnext=0,s.whave=s.wsize):(i=s.wsize-s.wnext,i>r&&(i=r),s.window.set(t.subarray(e-r,e-r+i),s.wnext),(r-=i)?(s.window.set(t.subarray(e-r,e),0),s.wnext=r,s.whave=s.wsize):(s.wnext+=i,s.wnext===s.wsize&&(s.wnext=0),s.whave<s.wsize&&(s.whave+=i))),0};var It={inflateReset:Mo,inflateReset2:Po,inflateResetKeep:Uo,inflateInit:n=>Xs(n,15),inflateInit2:Xs,inflate:(n,t)=>{let e,r,i,s,a,o,u,c,l,d,_,h,v,m,y,b,w,I,A,D,N,F,q=0;const x=new Uint8Array(4);let H,j;const P=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Qt(n)||!n.output||!n.input&&n.avail_in!==0)return Ye;e=n.state,e.mode===yt&&(e.mode=_i),a=n.next_out,i=n.output,u=n.avail_out,s=n.next_in,r=n.input,o=n.avail_in,c=e.hold,l=e.bits,d=o,_=u,F=Ht;e:for(;;)switch(e.mode){case Wr:if(e.wrap===0){e.mode=_i;break}for(;l<16;){if(o===0)break e;o--,c+=r[s++]<<l,l+=8}if(2&e.wrap&&c===35615){e.wbits===0&&(e.wbits=15),e.check=0,x[0]=255&c,x[1]=c>>>8&255,e.check=Ie(e.check,x,2,0),c=0,l=0,e.mode=16181;break}if(e.head&&(e.head.done=!1),!(1&e.wrap)||(((255&c)<<8)+(c>>8))%31){n.msg="incorrect header check",e.mode=le;break}if((15&c)!==Ys){n.msg="unknown compression method",e.mode=le;break}if(c>>>=4,l-=4,N=8+(15&c),e.wbits===0&&(e.wbits=N),N>15||N>e.wbits){n.msg="invalid window size",e.mode=le;break}e.dmax=1<<e.wbits,e.flags=0,n.adler=e.check=1,e.mode=512&c?16189:yt,c=0,l=0;break;case 16181:for(;l<16;){if(o===0)break e;o--,c+=r[s++]<<l,l+=8}if(e.flags=c,(255&e.flags)!==Ys){n.msg="unknown compression method",e.mode=le;break}if(57344&e.flags){n.msg="unknown header flags set",e.mode=le;break}e.head&&(e.head.text=c>>8&1),512&e.flags&&4&e.wrap&&(x[0]=255&c,x[1]=c>>>8&255,e.check=Ie(e.check,x,2,0)),c=0,l=0,e.mode=16182;case 16182:for(;l<32;){if(o===0)break e;o--,c+=r[s++]<<l,l+=8}e.head&&(e.head.time=c),512&e.flags&&4&e.wrap&&(x[0]=255&c,x[1]=c>>>8&255,x[2]=c>>>16&255,x[3]=c>>>24&255,e.check=Ie(e.check,x,4,0)),c=0,l=0,e.mode=16183;case 16183:for(;l<16;){if(o===0)break e;o--,c+=r[s++]<<l,l+=8}e.head&&(e.head.xflags=255&c,e.head.os=c>>8),512&e.flags&&4&e.wrap&&(x[0]=255&c,x[1]=c>>>8&255,e.check=Ie(e.check,x,2,0)),c=0,l=0,e.mode=16184;case 16184:if(1024&e.flags){for(;l<16;){if(o===0)break e;o--,c+=r[s++]<<l,l+=8}e.length=c,e.head&&(e.head.extra_len=c),512&e.flags&&4&e.wrap&&(x[0]=255&c,x[1]=c>>>8&255,e.check=Ie(e.check,x,2,0)),c=0,l=0}else e.head&&(e.head.extra=null);e.mode=16185;case 16185:if(1024&e.flags&&(h=e.length,h>o&&(h=o),h&&(e.head&&(N=e.head.extra_len-e.length,e.head.extra||(e.head.extra=new Uint8Array(e.head.extra_len)),e.head.extra.set(r.subarray(s,s+h),N)),512&e.flags&&4&e.wrap&&(e.check=Ie(e.check,r,h,s)),o-=h,s+=h,e.length-=h),e.length))break e;e.length=0,e.mode=16186;case 16186:if(2048&e.flags){if(o===0)break e;h=0;do N=r[s+h++],e.head&&N&&e.length<65536&&(e.head.name+=String.fromCharCode(N));while(N&&h<o);if(512&e.flags&&4&e.wrap&&(e.check=Ie(e.check,r,h,s)),o-=h,s+=h,N)break e}else e.head&&(e.head.name=null);e.length=0,e.mode=16187;case 16187:if(4096&e.flags){if(o===0)break e;h=0;do N=r[s+h++],e.head&&N&&e.length<65536&&(e.head.comment+=String.fromCharCode(N));while(N&&h<o);if(512&e.flags&&4&e.wrap&&(e.check=Ie(e.check,r,h,s)),o-=h,s+=h,N)break e}else e.head&&(e.head.comment=null);e.mode=16188;case 16188:if(512&e.flags){for(;l<16;){if(o===0)break e;o--,c+=r[s++]<<l,l+=8}if(4&e.wrap&&c!==(65535&e.check)){n.msg="header crc mismatch",e.mode=le;break}c=0,l=0}e.head&&(e.head.hcrc=e.flags>>9&1,e.head.done=!0),n.adler=e.check=0,e.mode=yt;break;case 16189:for(;l<32;){if(o===0)break e;o--,c+=r[s++]<<l,l+=8}
2n.adler=e.check=Zs(c),c=0,l=0,e.mode=dr;case dr:if(e.havedict===0)return n.next_out=a,n.avail_out=u,n.next_in=s,n.avail_in=o,e.hold=c,e.bits=l,Mc;n.adler=e.check=1,e.mode=yt;case yt:if(t===Lc||t===lr)break e;case _i:if(e.last){c>>>=7&l,l-=7&l,e.mode=mi;break}for(;l<3;){if(o===0)break e;o--,c+=r[s++]<<l,l+=8}switch(e.last=1&c,c>>>=1,l-=1,3&c){case 0:e.mode=16193;break;case 1:if(Fc(e),e.mode=hr,t===lr){c>>>=2,l-=2;break e}break;case 2:e.mode=16196;break;case 3:n.msg="invalid block type",e.mode=le}c>>>=2,l-=2;break;case 16193:for(c>>>=7&l,l-=7&l;l<32;){if(o===0)break e;o--,c+=r[s++]<<l,l+=8}if((65535&c)!=(c>>>16^65535)){n.msg="invalid stored block lengths",e.mode=le;break}if(e.length=65535&c,c=0,l=0,e.mode=vi,t===lr)break e;case vi:e.mode=16195;case 16195:if(h=e.length,h){if(h>o&&(h=o),h>u&&(h=u),h===0)break e;i.set(r.subarray(s,s+h),a),o-=h,s+=h,u-=h,a+=h,e.length-=h;break}e.mode=yt;break;case 16196:for(;l<14;){if(o===0)break e;o--,c+=r[s++]<<l,l+=8}if(e.nlen=257+(31&c),c>>>=5,l-=5,e.ndist=1+(31&c),c>>>=5,l-=5,e.ncode=4+(15&c),c>>>=4,l-=4,e.nlen>286||e.ndist>30){n.msg="too many length or distance symbols",e.mode=le;break}e.have=0,e.mode=16197;case 16197:for(;e.have<e.ncode;){for(;l<3;){if(o===0)break e;o--,c+=r[s++]<<l,l+=8}e.lens[P[e.have++]]=7&c,c>>>=3,l-=3}for(;e.have<19;)e.lens[P[e.have++]]=0;if(e.lencode=e.lendyn,e.lenbits=7,H={bits:e.lenbits},F=Fn(0,e.lens,0,19,e.lencode,0,e.work,H),e.lenbits=H.bits,F){n.msg="invalid code lengths set",e.mode=le;break}e.have=0,e.mode=16198;case 16198:for(;e.have<e.nlen+e.ndist;){for(;q=e.lencode[c&(1<<e.lenbits)-1],y=q>>>24,b=q>>>16&255,w=65535&q,!(y<=l);){if(o===0)break e;o--,c+=r[s++]<<l,l+=8}if(w<16)c>>>=y,l-=y,e.lens[e.have++]=w;else{if(w===16){for(j=y+2;l<j;){if(o===0)break e;o--,c+=r[s++]<<l,l+=8}if(c>>>=y,l-=y,e.have===0){n.msg="invalid bit length repeat",e.mode=le;break}N=e.lens[e.have-1],h=3+(3&c),c>>>=2,l-=2}else if(w===17){for(j=y+3;l<j;){if(o===0)break e;o--,c+=r[s++]<<l,l+=8}c>>>=y,l-=y,N=0,h=3+(7&c),c>>>=3,l-=3}else{for(j=y+7;l<j;){if(o===0)break e;o--,c+=r[s++]<<l,l+=8}c>>>=y,l-=y,N=0,h=11+(127&c),c>>>=7,l-=7}if(e.have+h>e.nlen+e.ndist){n.msg="invalid bit length repeat",e.mode=le;break}for(;h--;)e.lens[e.have++]=N}}if(e.mode===le)break;
2if(e.lens[256]===0){n.msg="invalid code -- missing end-of-block",e.mode=le;break}if(e.lenbits=9,H={bits:e.lenbits},F=Fn(1,e.lens,0,e.nlen,e.lencode,0,e.work,H),e.lenbits=H.bits,F){n.msg="invalid literal/lengths set",e.mode=le;break}if(e.distbits=6,e.distcode=e.distdyn,H={bits:e.distbits},F=Fn(2,e.lens,e.nlen,e.ndist,e.distcode,0,e.work,H),e.distbits=H.bits,F){n.msg="invalid distances set",e.mode=le;break}if(e.mode=hr,t===lr)break e;case hr:e.mode=fr;case fr:if(o>=6&&u>=258){n.next_out=a,n.avail_out=u,n.next_in=s,n.avail_in=o,e.hold=c,e.bits=l,Nc(n,_),a=n.next_out,i=n.output,u=n.avail_out,s=n.next_in,r=n.input,o=n.avail_in,c=e.hold,l=e.bits,e.mode===yt&&(e.back=-1);break}for(e.back=0;q=e.lencode[c&(1<<e.lenbits)-1],y=q>>>24,b=q>>>16&255,w=65535&q,!(y<=l);){if(o===0)break e;o--,c+=r[s++]<<l,l+=8}if(b&&!(240&b)){for(I=y,A=b,D=w;q=e.lencode[D+((c&(1<<I+A)-1)>>I)],y=q>>>24,b=q>>>16&255,w=65535&q,!(I+y<=l);){if(o===0)break e;o--,c+=r[s++]<<l,l+=8}c>>>=I,l-=I,e.back+=I}if(c>>>=y,l-=y,e.back+=y,e.length=w,b===0){e.mode=16205;break}if(32&b){e.back=-1,e.mode=yt;break}if(64&b){n.msg="invalid literal/length code",e.mode=le;break}e.extra=15&b,e.mode=16201;case 16201:if(e.extra){for(j=e.extra;l<j;){if(o===0)break e;o--,c+=r[s++]<<l,l+=8}e.length+=c&(1<<e.extra)-1,c>>>=e.extra,l-=e.extra,e.back+=e.extra}e.was=e.length,e.mode=16202;case 16202:for(;q=e.distcode[c&(1<<e.distbits)-1],y=q>>>24,b=q>>>16&255,w=65535&q,!(y<=l);){if(o===0)break e;o--,c+=r[s++]<<l,l+=8}if(!(240&b)){for(I=y,A=b,D=w;q=e.distcode[D+((c&(1<<I+A)-1)>>I)],y=q>>>24,b=q>>>16&255,w=65535&q,!(I+y<=l);){if(o===0)break e;o--,c+=r[s++]<<l,l+=8}c>>>=I,l-=I,e.back+=I}if(c>>>=y,l-=y,e.back+=y,64&b){n.msg="invalid distance code",e.mode=le;break}e.offset=w,e.extra=15&b,e.mode=16203;case 16203:if(e.extra){for(j=e.extra;l<j;){if(o===0)break e;o--,c+=r[s++]<<l,l+=8}e.offset+=c&(1<<e.extra)-1,c>>>=e.extra,l-=e.extra,e.back+=e.extra}if(e.offset>e.dmax){n.msg="invalid distance too far back",e.mode=le;break}e.mode=16204;case 16204:if(u===0)break e;if(h=_-u,e.offset>h){if(h=e.offset-h,h>e.whave&&e.sane){n.msg="invalid distance too far back",e.mode=le;break}h>e.wnext?(h-=e.wnext,v=e.wsize-h):v=e.wnext-h,h>e.length&&(h=e.length),m=e.window}else m=i,v=a-e.offset,h=e.length;h>u&&(h=u),u-=h,e.length-=h;do i[a++]=m[v++];while(--h);e.length===0&&(e.mode=fr);break;case 16205:if(u===0)break e;i[a++]=e.length,u--,e.mode=fr;break;case mi:if(e.wrap){for(;l<32;){if(o===0)break e;o--,c|=r[s++]<<l,l+=8}if(_-=u,n.total_out+=_,e.total+=_,4&e.wrap&&_&&(n.adler=e.check=e.flags?Ie(e.check,i,_,a-_):Mn(e.check,i,_,a-_)),_=u,4&e.wrap&&(e.flags?c:Zs(c))!==e.check){n.msg="incorrect data check",e.mode=le;break}c=0,l=0}e.mode=16207;case 16207:if(e.wrap&&e.flags){for(;l<32;){if(o===0)break e;o--,c+=r[s++]<<l,l+=8}if(4&e.wrap&&c!==(4294967295&e.total)){n.msg="incorrect length check",e.mode=le;break}c=0,l=0}e.mode=16208;case 16208:F=Uc;break e;case le:F=$s;break e;case 16210:return Ws;default:return Ye}return n.next_out=a,n.avail_out=u,n.next_in=s,n.avail_in=o,e.hold=c,e.bits=l,(e.wsize||_!==n.avail_out&&e.mode<le&&(e.mode<mi||t!==Qs))&&ea(n,n.output,n.next_out,_-n.avail_out),d-=n.avail_in,_-=n.avail_out,n.total_in+=d,n.total_out+=_,e.total+=_,4&e.wrap&&_&&(n.adler=e.check=e.flags?Ie(e.check,i,_,n.next_out-_):Mn(e.check,i,_,n.next_out-_)),n.data_type=e.bits+(e.last?64:0)+(e.mode===yt?128:0)+(e.mode===hr||e.mode===vi?256:0),(d===0&&_===0||t===Qs)&&F===Ht&&(F=Pc),F},inflateEnd:n=>{if(Qt(n))return Ye;let t=n.state;return t.window&&(t.window=null),n.state=null,Ht},inflateGetHeader:(n,t)=>{if(Qt(n))return Ye;const e=n.state;return 2&e.wrap?(e.head=t,t.done=!1,Ht):Ye},inflateSetDictionary:(n,t)=>{const e=t.length;let r,i,s;return Qt(n)?Ye:(r=n.state,r.wrap!==0&&r.mode!==dr?Ye:r.mode===dr&&(i=1,i=Mn(i,t,e,0),i!==r.check)?$s:(s=ea(n,t,e,e),s?(r.mode=16210,Ws):(r.havedict=1,Ht)))},inflateInfo:"pako inflate (from Nodeca project)"},qc=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const xo=Object.prototype.toString,{Z_NO_FLUSH:zc,Z_FINISH:Bc,Z_OK:qn,Z_STREAM_END:bi,Z_NEED_DICT:Ei,Z_STREAM_ERROR:jc,Z_DATA_ERROR:ta,Z_MEM_ERROR:Kc}
2=Jn;function zn(n){this.options=ko({chunkSize:65536,windowBits:15,to:""},n||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,t.windowBits===0&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||n&&n.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(15&t.windowBits||(t.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Ro,this.strm.avail_out=0;let e=It.inflateInit2(this.strm,t.windowBits);if(e!==qn)throw new Error(en[e]);if(this.header=new qc,It.inflateGetHeader(this.strm,this.header),t.dictionary&&(typeof t.dictionary=="string"?t.dictionary=ls(t.dictionary):xo.call(t.dictionary)==="[object ArrayBuffer]"&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(e=It.inflateSetDictionary(this.strm,t.dictionary),e!==qn)))throw new Error(en[e])}function wi(n,t){const e=new zn(t);if(e.push(n),e.err)throw e.msg||en[e.err];return e.result}zn.prototype.push=function(n,t){const e=this.strm,r=this.options.chunkSize,i=this.options.dictionary;let s,a,o;if(this.ended)return!1;for(a=t===~~t?t:t===!0?Bc:zc,xo.call(n)==="[object ArrayBuffer]"?e.input=new Uint8Array(n):e.input=n,e.next_in=0,e.avail_in=e.input.length;;){for(e.avail_out===0&&(e.output=new Uint8Array(r),e.next_out=0,e.avail_out=r),s=It.inflate(e,a),s===Ei&&i&&(s=It.inflateSetDictionary(e,i),s===qn?s=It.inflate(e,a):s===ta&&(s=Ei));e.avail_in>0&&s===bi&&e.state.wrap>0&&n[e.next_in]!==0;)It.inflateReset(e),s=It.inflate(e,a);switch(s){case jc:case ta:case Ei:case Kc:return this.onEnd(s),this.ended=!0,!1}if(o=e.avail_out,e.next_out&&(e.avail_out===0||s===bi))if(this.options.to==="string"){let u=gc(e.output,e.next_out),c=e.next_out-u,l=mc(e.output,u);e.next_out=c,e.avail_out=r-c,c&&e.output.set(e.output.subarray(u,u+c),0),this.onData(l)}else this.onData(e.output.length===e.next_out?e.output:e.output.subarray(0,e.next_out));if(s!==qn||o!==0){if(s===bi)return s=It.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(e.avail_in===0)break}}return!0},zn.prototype.onData=function(n){this.chunks.push(n)},zn.prototype.onEnd=function(n){n===qn&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=Oo(this.chunks)),this.chunks=[],this.err=n,this.msg=this.strm.msg};var Hc={Inflate:zn,inflate:wi,inflateRaw:function(n,t){return(t=t||{}).raw=!0,wi(n,t)},ungzip:wi};const{Deflate:Vc,deflate:Gc,deflateRaw:Qc,gzip:$c}=Ac,{Inflate:Wc,inflate:Yc,inflateRaw:Zc,ungzip:Xc}=Hc;var et,Jc={Deflate:Vc,deflate:Gc,deflateRaw:Qc,gzip:$c,Inflate:Wc,inflate:Yc,inflateRaw:Zc,ungzip:Xc,constants:Jn},Ii=function(n){return f(void 0,void 0,void 0,(function(){var t,e;return p(this,(function(r){if(t=Jc.ungzip(n),typeof TextDecoder<"u")try{return[2,new TextDecoder("utf-8").decode(new Uint8Array(t))]}catch(i){}return e=8192,[2,Array.from({length:Math.ceil(t.length/e)},(function(i,s){var a=s*e,o=t.slice(a,a+e);return String.fromCharCode.apply(null,o)})).join("")]}))}))},ue=function(n){return f(void 0,void 0,void 0,(function(){var t;return p(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,n()];case 1:return e.sent(),[3,3];case 2:if(!((t=e.sent())instanceof T))throw t;return t.throwOutside(),[3,3];case 3:return[2]}}
2))}))},ve=function(n){return f(void 0,void 0,void 0,(function(){return p(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,n()];case 1:case 2:return t.sent(),[3,3];case 3:return[2]}}))}))},ds=(function(n){function t(e){var r=n.call(this)||this;return r.retryAfterTime=1e3*e.retry_after,r.reasonCode=e.reason_code,r.message=e.message,r}return g(t,n),t})(Z);(function(n){n.CONNECTING="CONNECTING",n.OPEN="OPEN",n.CLOSED="CLOSED"})(et||(et={}));var X,el=(function(n){function t(e,r){var i=r.sdkState,s=r.dispatcher,a=r.logger,o=n.call(this)||this;return o.lastActive=0,o._iid=e,o._sdkState=i,o._dispatcher=s,o._logger=a,o}return g(t,n),Object.defineProperty(t.prototype,"isOpen",{get:function(){return this.connectionState===et.OPEN},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"connectionState",{get:function(){if(this._ws)switch(this._ws.readyState){case 0:return et.CONNECTING;case 1:return et.OPEN}return et.CLOSED},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"ws",{get:function(){var e;return(e=this._ws)!==null&&e!==void 0?e:null},enumerable:!1,configurable:!0}),t.prototype._handleMessage=function(e){var r=this;e.split("\n").forEach((function(i){if(i){var s=we.createFromRawMessage(r._iid,i);if(r._logger.debug("receive websocket event",s),s.code==="LOGI")r.dispatch("message",s);else if(s.code==="PONG")r.dispatch("pong");else if(s.code==="EXPR"){if(s.payload){var a=new dn(s.payload);a.expiresIn>=0&&r._dispatcher.dispatch(a)}}else if(s.code==="BUSY"){if(s.payload){var o=new ds(s.payload);r._dispatcher.dispatch(o)}}else s.code==="NOOP"||r.dispatch("message",s)}}))},t.prototype.connect=function(e,r){return r===void 0&&(r=""),f(this,void 0,void 0,(function(){var i=this;return p(this,(function(s){switch(s.label){case 0:return typeof fetch=="function"?[3,2]:[4,Tr(()=>import("./__bundle-46d64517-BN90M5Zk.js").then(a=>a._),__vite__mapDeps([2,1]))];case 1:s.sent(),s.label=2;case 2:return ve((function(){return f(i,void 0,void 0,(function(){return p(this,(function(a){return fetch(this._sdkState.api.host).catch((function(){})),[2]}))}))})),this._ws=new WebSocket(e,encodeURIComponent(r)),this._ws.onopen=function(){i._logger.debug("websocket open"),i.dispatch("open")},this._ws.onmessage=function(a){return f(i,void 0,void 0,(function(){var o,u,c,l,d,_,h,v=this;return p(this,(function(m){switch(m.label){case 0:return!((h=this._sdkState.websocket)===null||h===void 0)&&h.compression?a.data instanceof Blob?((o=new FileReader).readAsArrayBuffer(a.data),o.onloadend=function(){return f(v,void 0,void 0,(function(){var y,b;return p(this,(function(w){switch(w.label){case 0:return w.trys.push([0,2,,3]),[4,Ii(o.result)];case 1:return y=w.sent(),this._handleMessage(y),[3,3];case 2:return b=w.sent(),this.error(b),[3,3];case 3:return[2]}}
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,Ii(new Uint8Array(a.data))];case 3:return d=m.sent(),this._handleMessage(d),[3,5];case 4:return u=m.sent(),this.error(u),[3,5];case 5:return[3,12];case 6:if(!(typeof Buffer<"u"&&a.data instanceof Buffer))return[3,11];m.label=7;case 7:return m.trys.push([7,9,,10]),c=a.data,l=c.buffer.slice(c.byteOffset,c.byteOffset+c.byteLength),[4,Ii(l)];case 8:return d=m.sent(),this._handleMessage(d),[3,10];case 9:return _=m.sent(),this.error(_),[3,10];case 10:return[3,12];case 11:typeof a.data=="string"&&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(){i._logger.debug("websocket error"),i.dispatch("error",T.networkError)},this._ws.onclose=function(a){i._logger.debug("websocket close",a.code,a.reason),i.cleanUpWebSocket(),i.dispatch("close")},this.lastActive=Date.now(),[2]}}))}))},t.prototype.cleanUpWebSocket=function(){this._ws&&(this._ws.onopen=fe,this._ws.onmessage=fe,this._ws.onerror=fe,this._ws.onclose=fe,this.connectionState!==et.CLOSED&&this._ws.close(1e3,"Normal Closure"),this._ws=void 0)},t.prototype.disconnect=function(){var e=this;return new Promise((function(r){if(e._ws){if(e.connectionState===et.CLOSED)return e.cleanUpWebSocket(),void r();e._ws.onclose=null,e._ws.onclose=function(){e.cleanUpWebSocket(),e.dispatch("close"),r()},e._ws.close()}else r()}))},t.prototype.forceClose=function(e){e===void 0&&(e=!0),this.cleanUpWebSocket(),e&&this.dispatch("close")},t.prototype.send=function(e){if(!this._ws)throw T.connectionClosed;e.code!=="PING"?this.dispatch("ping-refresh"):this._logger.debug("send ping",e),this._ws.send(e.convertToMessage())},t.prototype.error=function(e){this._logger.debug("websocket error",e),this.dispatch("error",e)},t})(mn),Fo=(function(n){function t(e){var r=e.all,i=e.feed,s=e.custom_types,a=e.ts,o=n.call(this)||this;return o.all=r,o.feed=i,o.customTypes=s,o.ts=a,o}return g(t,n),t})(Z),tl=(function(n){function t(e){var r=e.previousMessageId,i=e.messageCreatedAt,s=e.channelUrl,a=n.call(this)||this;return a.previousMessageId=r,a.messageCreatedAt=i,a.channelUrl=s,a}return g(t,n),t})(Z),nl=(function(){function n(t,e){var r=e.session,i=e.sdkState,s=e.dispatcher,a=e.logger,o=e.useFetchCompat,u=o!==void 0&&o,c=this;this._ackStateMap=new Map,this._batchableCommandAckStateMap=new Map,this._redundantActionCommands=new Map,this._sdkState=i,this._dispatcher=s,this._logger=a,this.apiClient=new Zu(t,{session:r,sdkState:i,dispatcher:s,logger:a,useFetchCompat:u}),this.websocketClient=new el(t,{sdkState:i,dispatcher:s,logger:a}),this.websocketClient.on("message",(function(l){var d,_;if(l.payload.unread_cnt&&c._dispatcher.dispatch(new Fo(l.payload.unread_cnt)),l.code!=="MESG"&&l.code!=="FILE"&&l.code!=="ADMM"&&l.code!=="BRDM"||l.payload.channel_type!==oe.GROUP||!l.payload.previous_message_id||c._dispatcher.dispatch(new tl({previousMessageId:l.payload.previous_message_id,messageCreatedAt:l.payload.ts,channelUrl:l.payload.channel_url})),l.requestId){if(c._ackStateMap.has(l.requestId)){var h=c._ackStateMap.get(l.requestId);l.code!=="EROR"?h.resolve(l):h.reject(new T({code:l.payload.code,message:l.payload.message}))}else if(c._batchableCommandAckStateMap.has(l.requestId)){var v=Date.now();try{for(var m=z(c._batchableCommandAckStateMap.entries()),y=m.next();!y.done;y=m.next()){var b=K(y.value,2),w=(b[0],b[1]);w.channelUrl===l.payload.channel_url&&w.requestTime<v&&(h=w.ackState,l.code!=="EROR"?h.resolve(l):h.reject(new T({code:l.payload.code,message:l.payload.message})))}}catch(D){d={error:D}}finally{try{y&&!y.done&&(_=m.return)&&_.call(m)}finally{if(d)throw d.error}}}}else if(c._redundantActionCommands.has(l.payload.unique_id)){var I=c._redundantActionCommands.get(l.payload.unique_id),A=I==null?void 0:I.indexOf(l.code);A!==-1&&(I==null||I.splice(A,1)),I.length===0&&c._redundantActionCommands.delete(l.payload.unique_id)}else c._dispatcher.dispatch(l)})).on("close",(function(){c._rejectPendingAcks()}))}return n.prototype._sendApiRequest=function(t){return f(this,void 0,void 0,(function(){return p(this,(function(e){switch(e.label){case 0:return t.params.unique_id&&this._redundantActionCommands.set(t.params.unique_id,["SYEV","READ"]),[4,this.apiClient.send(t)];case 1:return[2,e.sent()]}}))}))},n.prototype._sendWebsocketRequest=function(t){return f(this,void 0,void 0,(function(){var e,r,i,s=this;
2return p(this,(function(a){if(!this._sdkState.websocket)throw T.connectionRequired;if(e=new De,t.ackRequired){i=function(o,u){var c=t.code==="READ"?s._batchableCommandAckStateMap:s._ackStateMap;c.has(t.requestId)&&(c.delete(t.requestId),r&&(clearTimeout(r),r=null),o?(s._logger.debug("fail websocket request",t.requestId,o),e.reject(o)):(s._logger.debug("receive websocket ack",t.requestId,t),s._logger.debug("receive websocket ack",u),e.resolve(u)))};try{r=setTimeout((function(){return i(T.noAckTimeout)}),this._sdkState.websocket.responseTimeout),t.code==="READ"?this._batchableCommandAckStateMap.set(t.requestId,{ackState:{resolve:function(o){return i(void 0,o)},reject:function(o){return i(o)}},channelUrl:t.payload.channel_url,requestTime:Date.now()}):this._ackStateMap.set(t.requestId,{resolve:function(o){return i(void 0,o)},reject:function(o){return i(o)}}),this.websocketClient.send(t)}catch(o){i(o)}}else try{this.websocketClient.send(t),e.resolve()}catch(o){e.reject(o)}return[2,e.promise]}))}))},n.prototype.send=function(t){return f(this,void 0,void 0,(function(){return p(this,(function(e){switch(e.label){case 0:return t instanceof O?[4,this._sendApiRequest(t)]:[3,2];case 1:case 3:return[2,e.sent()];case 2:return t instanceof qe?[4,this._sendWebsocketRequest(t)]:[3,4];case 4:throw T.invalidParameters}}))}))},n.prototype.cancel=function(t,e){this.apiClient.cancel(t,e)},n.prototype.cancelAll=function(t){this.apiClient.cancelAll(t),this._rejectPendingAcks()},n.prototype._rejectPendingAcks=function(){this._ackStateMap.forEach((function(t){t.reject(T.connectionClosed)})),this._ackStateMap.clear(),this._batchableCommandAckStateMap.clear(),this._redundantActionCommands.clear()},n})();(function(n){n[n.NONE=0]="NONE",n[n.INITIALIZED=1]="INITIALIZED",n[n.CONNECTING=2]="CONNECTING",n[n.CONNECTED=3]="CONNECTED",n[n.RECONNECTING=4]="RECONNECTING",n[n.INTERNAL_DISCONNECTED=5]="INTERNAL_DISCONNECTED",n[n.EXTERNAL_DISCONNECTED=6]="EXTERNAL_DISCONNECTED",n[n.LOGOUT=7]="LOGOUT",n[n.DELAYED_CONNECTING=8]="DELAYED_CONNECTING"})(X||(X={}));var Qi,$i,yn=(function(n){function t(e){var r=e.stateType,i=n.call(this)||this;return i.stateType=r,i}return g(t,n),t})(Z),qo=(function(n){function t(){return n!==null&&n.apply(this,arguments)||this}return g(t,n),t})(Z),Wi=(function(n){function t(){return n!==null&&n.apply(this,arguments)||this}return g(t,n),t})(Z),zo=(function(n){function t(){return n!==null&&n.apply(this,arguments)||this}return g(t,n),t})(Z),na=(function(){function n(t){var e,r,i,s;this.isEnabled=(e=t.enabled)!==null&&e!==void 0&&e,this.feedChannels=(r=t.feed_channels)!==null&&r!==void 0?r:{},this.templateListToken=(i=t.template_list_token)!==null&&i!==void 0?i:null,this.settingsUpdatedAt=(s=t.settings_updated_at)!==null&&s!==void 0?s:0}return n.payloadify=function(t){return M(B({enabled:t.isEnabled,feed_channels:t.feedChannels,template_list_token:t.templateListToken,settings_updated_at:t.settingsUpdatedAt}))},n})(),rl=function(n){return"sendbird@".concat(n,"/changelog_include_chat_notifications")},ra=(function(){function n(t){var e;this.lastUpdatedAt=(e=t.last_updated_at)!==null&&e!==void 0?e:0}return n.payloadify=function(t){return M(B({last_updated_at:t.lastUpdatedAt}))},n})(),ia=(function(){function n(t){var e;this.token=(e=t.template_list_token)!==null&&e!==void 0?e:""}return n.payloadify=function(t){return M(B({template_list_token:t.token}))},n})(),ct=(function(){function n(t){t===void 0&&(t={min_stat_count:100,min_interval:10800,max_stat_count_per_request:1e3,lower_threshold:10,request_delay_range:180}),this.minStatCount=t.min_stat_count,this.minInterval=1e3*t.min_interval,this.maxStatCountPerRequest=t.max_stat_count_per_request,this.lowerThreshold=t.lower_threshold,this.requestDelayRange=1e3*t.request_delay_range}return n.payloadify=function(t){return M(B({min_stat_count:t.minStatCount,min_interval:t.minInterval/1e3,max_stat_count_per_request:t.maxStatCountPerRequest,lower_threshold:t.lowerThreshold,request_delay_range:t.requestDelayRange/1e3}))},n})(),Yr=100,er=100,Ti=(function(){function n(t){t===void 0&&(t={default:{min_stat_count:100,min_interval:10800,max_stat_count_per_request:1e3,lower_threshold:10,request_delay_range:180}}),this.default=new ct(t.default),this.realTime=new ct(t.realtime),this.daily=new ct(E(E({},ct.payloadify(this.default)),{min_interval:86400,lower_threshold:10})),this.aiAgentStats=t.ai_agent_stats?new ct(t.ai_agent_stats):void 0,this.aiAgentAssertion=t.ai_agent_assertion?new ct(t.ai_agent_assertion):void 0}return n.payloadify=function(t){return M(B({default:ct.payloadify(t.default),realtime:ct.payloadify(t.realTime),ai_agent_stats:t.aiAgentStats?ct.payloadify(t.aiAgentStats):void 0,ai_agent_assertion:t.aiAgentAssertion?ct.payloadify(t.aiAgentAssertion):void 0}))},n})(),il=(function(){function n(t){var e;this.templateListToken=(e=t.template_list_token)!==null&&e!==void 0?e:null}return n.payloadify=function(t){return M(B({template_list_token:t.templateListToken}))},n})(),sa=(function(){function n(t){this.enabled=t.enabled,this.orderBy=t.order_by.type,this.excludeRecentHours=t.order_by.exclude_recent_hours,this.bufferRatio=t.buffer_ratio}return n.payloadify=function(t){return M(B({enabled:t.enabled,order_by:{type:t.orderBy,exclude_recent_hours:t.excludeRecentHours},buffer_ratio:t.bufferRatio}))},n})(),aa=1048576,sl=5;
2(function(n){n[n.NONE=0]="NONE",n[n.INCLUDE_REPLY=1]="INCLUDE_REPLY",n[n.EXCLUDE_REPLY=2]="EXCLUDE_REPLY",n[n.INCLUDE_REPLY_TO_CHANNEL=3]="INCLUDE_REPLY_TO_CHANNEL"})(Qi||(Qi={})),(function(n){n[n.NONE=0]="NONE",n[n.INCLUDE_REPLY=1]="INCLUDE_REPLY",n[n.EXCLUDE_REPLY=2]="EXCLUDE_REPLY",n[n.INCLUDE_REPLY_TO_CHANNEL=3]="INCLUDE_REPLY_TO_CHANNEL"})($i||($i={}));var oa=(function(){function n(t){var e,r,i,s,a,o,u,c,l,d,_;t===void 0&&(t={}),this.emojiHash=t.emoji_hash||"",this.uploadSizeLimit=t.file_upload_size_limit?t.file_upload_size_limit*aa:Number.MAX_SAFE_INTEGER,this.useReaction=!!t.use_reaction,this.applicationAttributes=(e=t.application_attributes)!==null&&e!==void 0?e:[],this.premiumFeatureList=(r=t.premium_feature_list)!==null&&r!==void 0?r:[],this.deviceTokenCache=this.applicationAttributes.includes("sdk_device_token_cache"),this.enabledChannelMemberShipHistory=this.applicationAttributes.includes("channel_membership_history"),this.multipleFilesMessageFileCountLimit=(i=t.multiple_file_send_max_size)!==null&&i!==void 0?i:5,this.allowSdkStatsUpload=(s=t.allow_sdk_log_ingestion)===null||s===void 0||s,this.unreadCountThreadingPolicy=(a=t.unread_cnt_threading_policy)!==null&&a!==void 0?a:Qi.NONE,this.lastMessageThreadingPolicy=(o=t.last_msg_threading_policy)!==null&&o!==void 0?o:$i.NONE,this.channelRotationInfo=t.channel_rotation?new sa(t.channel_rotation):null,this.uikitConfigInfo=new ra((u=t.uikit_config)!==null&&u!==void 0?u:{}),this.notificationInfo=t.notifications?new na(t.notifications):null,this.messageTemplateInfo=t.message_template?new ia(t.message_template):null,this.aiAgentInfo=t.ai_agent?new il(t.ai_agent):null,this.statConfigInfo=t.log_publish_config?new Ti(t.log_publish_config):new Ti,this.disableSuperGroupMack=(c=t.disable_supergroup_mack)!==null&&c!==void 0&&c,this.configSyncNeeded=(l=t.config_sync_needed)!==null&&l!==void 0&&l,this.requestDedupIntervalMs=(d=t.request_dedup_interval_ms)!==null&&d!==void 0?d:500,this.backgroundConnectionCloseTimeout=(_=t.sdk_background_connection_close_timeout)!==null&&_!==void 0?_:30}return n.payloadify=function(t){return M(B({emoji_hash:t.emojiHash,file_upload_size_limit:t.uploadSizeLimit/aa,application_attributes:t.applicationAttributes,premium_feature_list:t.premiumFeatureList,use_reaction:t.useReaction,allow_sdk_log_ingestion:t.allowSdkStatsUpload,unread_cnt_threading_policy:t.unreadCountThreadingPolicy,last_msg_threading_policy:t.lastMessageThreadingPolicy,channel_rotation:t.channelRotationInfo?sa.payloadify(t.channelRotationInfo):null,uikit_config:t.uikitConfigInfo?ra.payloadify(t.uikitConfigInfo):null,notifications:t.notificationInfo?na.payloadify(t.notificationInfo):null,message_template:t.messageTemplateInfo?ia.payloadify(t.messageTemplateInfo):null,log_publish_config:t.statConfigInfo?Ti.payloadify(t.statConfigInfo):null,disable_supergroup_mack:t.disableSuperGroupMack,config_sync_needed:t.configSyncNeeded,request_dedup_interval_ms:t.requestDedupIntervalMs,sdk_background_connection_close_timeout:t.backgroundConnectionCloseTimeout}))},n})(),jr=function(n){return"sendbird@".concat(n,"/app_configs_info")},be=(function(){function n(t){this._iid="",this._iid=t}return n.payloadify=function(t){return{}},n})(),al=(function(n){function t(e){var r=e.userId,i=e.metadata,s=n.call(this)||this;return s.method=k.POST,s.path="".concat(W,"/").concat(encodeURIComponent(r),"/metadata"),s.params={metadata:i},s}return g(t,n),t})(O),ol=(function(n){function t(e,r){var i=n.call(this,e,r)||this;return i.metaData=r,i}return g(t,n),t})(U),ul=(function(n){function t(e){var r=e.userId,i=e.metadata,s=e.upsert,a=n.call(this)||this;return a.method=k.PUT,a.path="".concat(W,"/").concat(encodeURIComponent(r),"/metadata"),a.params={metadata:i,upsert:s},a}return g(t,n),t})(O),cl=(function(n){function t(e,r){var i=n.call(this,e,r)||this;return i.metadata=r,i}return g(t,n),t})(U),ll=(function(n){function t(e){var r=e.userId,i=e.metadataKey,s=n.call(this)||this;return s.method=k.DELETE,s.path="".concat(W,"/").concat(encodeURIComponent(r),"/metadata/").concat(i),s}return g(t,n),t})(O);(function(n){function t(){return n!==null&&n.apply(this,arguments)||this}g(t,n)})(U);var dl=(function(n){function t(e){var r=e.userId,i=n.call(this)||this;return i.method=k.DELETE,i.path="".concat(W,"/").concat(encodeURIComponent(r),"/metadata"),i}return g(t,n),t})(O);(function(n){function t(){return n!==null&&n.apply(this,arguments)||this}g(t,n)})(U);var un,hs=function(n,t){var e=JSON.parse(JSON.stringify(n));return e._iid&&delete e._iid,t&&t(e),e},Yn=function(n,t){var e=JSON.parse(JSON.stringify(n));return e},R=function(n){return{do:function(t){n||t()},throw:function(t){if(!n)throw t}}};(function(n){n.ONLINE="online",n.OFFLINE="offline",n.NON_AVAILABLE="nonavailable"})(un||(un={}));var Pt,G=(function(n){function t(e,r){var i,s,a,o,u,c,l,d,_,h,v,m,y,b=this;return(b=n.call(this,e)||this).userId=(s=(i=r.guest_id)!==null&&i!==void 0?i:r.user_id)!==null&&s!==void 0?s:"",b.nickname=(o=(a=r.nickname)!==null&&a!==void 0?a:r.name)!==null&&o!==void 0?o:"",b.plainProfileUrl=(c=(u=r.profile_url)!==null&&u!==void 0?u:r.image)!==null&&c!==void 0?c:"",b.requireAuth=(l=r.require_auth_for_profile_image)!==null&&l!==void 0&&l,b.metaData=(d=r.metadata)!==null&&d!==void 0?d:{},b.connectionStatus=un.NON_AVAILABLE,ie(un,r.is_online)?b.connectionStatus=r.is_online:S("boolean",r.is_online)&&(b.connectionStatus=r.is_online?un.ONLINE:un.OFFLINE),b.isActive=(_=r.is_active)===null||_===void 0||_,b.lastSeenAt=(h=r.last_seen_at)!==null&&h!==void 0?h:null,b.preferredLanguages=r.preferred_languages?V([],K(r.preferred_languages),!1):null,b.friendDiscoveryKey=(v=r.friend_discovery_key)!==null&&v!==void 0?v:null,b.friendName=(m=r.friend_name)!==null&&m!==void 0?m:null,b._hashValue=b._generateHashValue(),b._updatedAt=(y=r.updatedat)!==null&&y!==void 0?y:0,b}return g(t,n),t.payloadify=function(e){return M(B(E(E({},n.payloadify.call(this,e)),{user_id:e.userId,nickname:e.nickname,profile_url:e.plainProfileUrl,require_auth_for_profile_image:e.requireAuth,metadata:e.metaData,is_online:e.connectionStatus,is_active:e.isActive,last_seen_at:e.lastSeenAt,preferred_languages:e.preferredLanguages,friend_discovery_key:e.friendDiscoveryKey,friend_name:e.friendName})))},t._buildUserFromSerializedData=function(e){var r=Yn(e);return new t(r._iid,t.payloadify(r))},t.prototype._generateHashValue=function(){for(var e,r=JSON.stringify({userId:this.userId,nickname:this.nickname,plainProfileUrl:this.plainProfileUrl,friendDiscoveryKey:this.friendDiscoveryKey,friendName:this.friendName,metaData:JSON.stringify(this.metaData),performanceLanguages:(e=this.preferredLanguages)===null||e===void 0?void 0:e.toString(),requireAuth:this.requireAuth}),i=0,s=0;s<r.length;s++)i=(i<<5)-i+r.charCodeAt(s),i|=0;return i}
2,Object.defineProperty(t.prototype,"profileUrl",{get:function(){var e=C.of(this._iid).sessionManager;return this.requireAuth&&e.ekey?"".concat(this.plainProfileUrl,"?auth=").concat(e.ekey):this.plainProfileUrl},enumerable:!1,configurable:!0}),t.prototype.serialize=function(){return hs(this)},t.prototype._isValidMetaData=function(e){return!Array.isArray(e)&&Object.keys(e).length>0&&Object.keys(e).map((function(r){return e[r]})).every((function(r){return S("string",r)}))},t.prototype._applyMetaData=function(e,r){var i=this;r===void 0&&(r=!1),Object.keys(e).forEach((function(s){r?delete i.metaData[s]:i.metaData[s]=e[s]}))},t.prototype.createMetaData=function(e){return f(this,void 0,void 0,(function(){var r,i,s,a,o,u;return p(this,(function(c){switch(c.label){case 0:return R(this._isValidMetaData(e)).throw(T.invalidParameters),r=C.of(this._iid),i=r.sdkState,s=r.requestQueue,a=new al({userId:i.userId,metadata:e}),[4,s.send(a)];case 1:return o=c.sent(),u=o.as(ol).metaData,this._applyMetaData(u),[2,this.metaData]}}))}))},t.prototype.updateMetaData=function(e,r){return r===void 0&&(r=!1),f(this,void 0,void 0,(function(){var i,s,a,o,u,c;return p(this,(function(l){switch(l.label){case 0:return R(this._isValidMetaData(e)).throw(T.invalidParameters),i=C.of(this._iid),s=i.sdkState,a=i.requestQueue,o=new ul({userId:s.userId,metadata:e,upsert:r}),[4,a.send(o)];case 1:return u=l.sent(),c=u.as(cl).metadata,this._applyMetaData(c),[2,this.metaData]}}))}))},t.prototype.deleteMetaData=function(e){return f(this,void 0,void 0,(function(){var r,i,s,a,o;return p(this,(function(u){switch(u.label){case 0:return R(S("string",e)).throw(T.invalidParameters),r=C.of(this._iid),i=r.sdkState,s=r.requestQueue,a=new ll({userId:i.userId,metadataKey:e}),[4,s.send(a)];case 1:return u.sent(),this._applyMetaData(((o={})[e]=!0,o),!0),[2,this.metaData]}}))}))},t.prototype.deleteAllMetaData=function(){return f(this,void 0,void 0,(function(){var e,r,i,s;return p(this,(function(a){switch(a.label){case 0:return e=C.of(this._iid),r=e.sdkState,i=e.requestQueue,s=new dl({userId:r.userId}),[4,i.send(s)];case 1:return a.sent(),this.metaData={},[2]}}))}))},t})(be),Bo=(function(n){function t(e){var r=e.userProfile,i=n.call(this)||this;return i.userProfile=r,i}return g(t,n),t})(Z),Yi=(function(){function n(t,e){var r,i,s,a,o,u,c,l,d,_,h,v,m,y;this._iid=t,this.appInfo=new oa(e),this.user=new G(t,e),this.connectedAt=(r=e.login_ts)!==null&&r!==void 0?r:0,this.firstConnectedAt=0,this.pingInterval=(i=e.ping_interval)!==null&&i!==void 0?i:15,this.pongTimeout=(s=e.pong_timeout)!==null&&s!==void 0?s:5,this.reconnectInterval=(o=(a=e.reconnect)===null||a===void 0?void 0:a.interval)!==null&&o!==void 0?o:3e3,this.reconnectMaxInterval=(c=(u=e.reconnect)===null||u===void 0?void 0:u.max_interval)!==null&&c!==void 0?c:6e4,this.reconnectRetryCount=(d=(l=e.reconnect)===null||l===void 0?void 0:l.retry_cnt)!==null&&d!==void 0?d:5,this.reconnectIntervalMultiple=(h=(_=e.reconnect)===null||_===void 0?void 0:_.mul)!==null&&h!==void 0?h:2,this.maxUnreadCountOnSuperGroup=(v=e.max_unread_cnt_on_super_group)!==null&&v!==void 0?v:100,this.profileImageEncryption=!!e.profile_image_encryption,this.concurrentCallLimit=(m=e.concurrent_call_limit)!==null&&m!==void 0?m:5,this.backOffDelay=(y=e.back_off_delay)!==null&&y!==void 0?y:100}return n.payloadify=function(t){return M(B(E(E(E({},G.payloadify(t.user)),oa.payloadify(t.appInfo)),{login_ts:t.connectedAt,ping_interval:t.pingInterval,pong_timeout:t.pongTimeout,reconnect:{interval:t.reconnectInterval,max_interval:t.reconnectMaxInterval,retry_cnt:t.reconnectRetryCount,mul:t.reconnectIntervalMultiple},max_unread_cnt_on_super_group:t.maxUnreadCountOnSuperGroup,profile_image_encryption:t.profileImageEncryption,concurrent_call_limit:t.concurrentCallLimit,back_off_delay:t.backOffDelay})))},n.prototype.apply=function(){var t=this.reconnectInterval,e=this.reconnectMaxInterval,r=this.reconnectIntervalMultiple,i=C.of(this._iid);i.sdkState.websocket&&(i.sdkState.websocket.pingInterval=1e3*this.pingInterval,i.sdkState.websocket.pongTimeout=1e3*this.pongTimeout,i.sdkState.websocket.reconnectMax
2Retry=this.reconnectRetryCount,i.sdkState.websocket.reconnectRetryStrategy={calcTimeout:function(s){return s>0?1e3*Math.min(t*Math.pow(r,s-1),e):10}}),i.appInfo=this.appInfo,i.sessionManager.currentUser=this.user,i.connectedAt=this.connectedAt,this.firstConnectedAt||(i.firstConnectedAt=this.connectedAt),i.maxSuperGroupChannelUnreadCount=this.maxUnreadCountOnSuperGroup,i.concurrentCallLimit=this.concurrentCallLimit,i.backOffDelay=this.backOffDelay,i.requestDeduplicator.requestDedupInterval=this.appInfo.requestDedupIntervalMs,i.dispatcher.dispatch(new Bo({userProfile:this}))},n})(),jo=(function(n){function t(e){var r=e.request,i=r===void 0||r,s=e.features,a=s===void 0?{}:s,o=e.options,u=o===void 0?{}:o,c=e.statConfigInfo,l=n.call(this)||this;return l.request=i,l.features=E({localCache:!0,notification:!0,aiAgent:!0,aiAgentAssertion:!0},a),l.options=E({ingestion:!0},u),l.statConfigInfo=c,l}return g(t,n),t})(Z),Ko=(function(n){function t(e){var r=n.call(this)||this;return r.configSyncNeeded=!1,r.configSyncNeeded=e,r}return g(t,n),t})(Z),Cr=(function(n){function t(e,r,i){var s,a,o,u,c=this;return(c=n.call(this,e,r,i)||this).error=null,c.services=[],c.userProfile=new Yi(e,i),c.deviceTokenLastDeletedAt=(s=i.device_token_last_deleted_at)!==null&&s!==void 0?s:0,c.key=(a=i.key)!==null&&a!==void 0?a:"",c.ekey=(o=i.ekey)!==null&&o!==void 0?o:"",c.error=i.error?new T(i):null,c.services=(u=i.services)!==null&&u!==void 0?u:[],c.isSessionRefresh="new_key"in i,c}return g(t,n),t.asError=function(e){return new t("","LOGI",E({user_id:"",error:!0},e))},t.prototype.applyTo=function(e){return f(this,void 0,void 0,(function(){var r,i,s;return p(this,(function(a){switch(a.label){case 0:return this.isSessionRefresh?[2]:this.error?[3,4]:(r=C.of(e))?(i=r.sessionManager,s=r.dispatcher,[4,i.login(this)]):[3,2];case 1:return a.sent(),this.userProfile.apply(),s.dispatch(new Ko(this.userProfile.appInfo.configSyncNeeded)),s.dispatch(new jo({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 T.lostInstance;case 3:return[3,5];case 4:throw this.error;case 5:return[2]}}
2))}))},t})(we),Ft=(function(){function n(){this.type=X.NONE,this.name="none"}return n.prototype.run=function(t){return f(this,void 0,void 0,(function(){return p(this,(function(e){return[2]}))}))},n.prototype.onConnect=function(t,e){return f(this,void 0,void 0,(function(){return p(this,(function(r){return[2]}))}))},n.prototype.onReconnect=function(t,e){return e.resetReconnectCount,f(this,void 0,void 0,(function(){return p(this,(function(r){return[2]}))}))},n.prototype.onDisconnect=function(t,e){return e.error,e.autoReconnect,e.cause,f(this,void 0,void 0,(function(){return p(this,(function(r){return[2]}))}))},n.prototype.onDisconnectWebSocket=function(t,e){return f(this,void 0,void 0,(function(){return p(this,(function(r){return[2]}))}))},n.prototype.onLogout=function(t,e){return f(this,void 0,void 0,(function(){return p(this,(function(r){return[2]}))}))},n.prototype.onDelayedConnecting=function(t,e){return e.retryAfterTime,e.reasonCode,e.message,f(this,void 0,void 0,(function(){return p(this,(function(r){return[2]}))}))},n})(),vt=(function(n){function t(e){e===void 0&&(e={});var r,i=this;return(i=n.call(this)||this).type=X.LOGOUT,i.name="logout",i._wasPreviouslyConnected=(r=e.wasPreviouslyConnected)===null||r===void 0||r,i}return g(t,n),t.prototype.run=function(e){return f(this,void 0,void 0,(function(){var r,i,s=this;return p(this,(function(a){switch(a.label){case 0:return r=Date.now(),i=e.sdkState.userId,[4,e.logout()];case 1:return a.sent(),[4,e.changeState(new ps,r)];case 2:return a.sent(),this._wasPreviouslyConnected&&ue((function(){return f(s,void 0,void 0,(function(){return p(this,(function(o){return e.connectionHandlers.forEach((function(u){var c;(c=u.onDisconnected)===null||c===void 0||c.call(u,i)})),[2]}))}))})),[2]}}))}))},t})(Ft),tr=(function(n){function t(e){var r=(e===void 0?{}:e).isAlreadyDisconnected,i=r!==void 0&&r,s=n.call(this)||this;return s.type=X.EXTERNAL_DISCONNECTED,s.name="externaldisconnected",s._isAlreadyDisconnected=i,s}return g(t,n),t.prototype.run=function(e){return f(this,void 0,void 0,(function(){var r=this;return p(this,(function(i){switch(i.label){case 0:return[4,e.disconnect()];case 1:return i.sent(),this._isAlreadyDisconnected||ue((function(){return f(r,void 0,void 0,(function(){return p(this,(function(s){return e.connectionHandlers.forEach((function(a){var o;(o=a.onConnectionLost)===null||o===void 0||o.call(a)})),[2]}))}))})),[2]}}))}))},t.prototype.onConnect=function(e,r){return f(this,void 0,void 0,(function(){var i;return p(this,(function(s){switch(s.label){case 0:return i=Date.now(),[4,e.disconnect()];case 1:return s.sent(),[4,e.changeState(new Zr({authToken:r}),i)];case 2:return s.sent(),[2]}}))}))},t.prototype.onReconnect=function(e){return f(this,void 0,void 0,(function(){var r;return p(this,(function(i){switch(i.label){case 0:return r=Date.now(),[4,e.changeState(new Zn,r)];case 1:return i.sent(),[2]}}))}))},t.prototype.onLogout=function(e){return f(this,void 0,void 0,(function(){var r;return p(this,(function(i){switch(i.label){case 0:return r=Date.now(),[4,e.changeState(new vt,r)];case 1:return i.sent(),[2]}}))}))},t})(Ft),Ho=(function(n){function t(e){var r=e.event,i=e.reason,s=n.call(this)||this;return s.event=r,s.reason=i,s}return g(t,n),t})(Z);(function(n){n.ExternalSetBackground="ExternalSetBackground",n.ExternalDisconnectWebSocket="ExternalDisconnectWebSocket",n.MaxReconnectRetry="MaxReconnectRetry"})(Pt||(Pt={}));var hl=(function(){function n(t,e){var r=e.sdkState,i=e.cacheContext,s=e.connectionHandlers,a=e.sessionManager,o=e.websocketClient,u=e.dispatcher,c=e.logger,l=e.disableWebSocketCloseEventHandling,d=l!==void 0&&l,_=e.appStateToggleEnabled,h=_===void 0||_,v=this;this._disableWebSocketCloseEventHandling=!1,this._appStateToggleEnabled=!0,this._webSocketClosedCause=null,this._logger=c,this._disableWebSocketCloseEventHandling=d,this._appStateToggleEnabled=h,this._context=new vl(t,{sdkState:r,cacheContext:i,connectionHandlers:s,sessionManager:a,websocketClient:o,dispatcher:u,logger:c}),this._sdkState=r,this._sessionManager=a,this._websocketClient=o,this._commandDispatcher=u,this._commandDispat
2cher.on((function(m){var y=v._context.currentState;if(m instanceof ds&&y.type===X.CONNECTED){var b=m.retryAfterTime,w=m.reasonCode,I=m.message;y.onDelayedConnecting(v._context,{retryAfterTime:b,reasonCode:w,message:I})}}))}return n.prototype._registerEventDispatcher=function(){var t=this;this._disableWebSocketCloseEventHandling||(this._clearEventDispatcher(),this._sessionEventDispatcherContext=this._sessionManager.on("refresh",(function(){t.isConnecting||t.isConnected||(t._logger.debug("try reconnect by session key refresh"),ve((function(){return f(t,void 0,void 0,(function(){return p(this,(function(e){switch(e.label){case 0:return[4,this.reconnect()];case 1:return e.sent(),[2]}}))}))})))})),this._websocketEventDispatcherContext=this._websocketClient.on("close",(function(){t._sdkState.appState!=="foreground"||t._webSocketClosedCause||ve((function(){return f(t,void 0,void 0,(function(){return p(this,(function(e){switch(e.label){case 0:return this._context.currentState.type!==X.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:e.sent(),e.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 Ho({event:"pause",reason:"app is not active"})),[2]);case 4:return e.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 e.sent(),[3,9];case 7:return[4,this.disconnectWebSocket()];case 8:e.sent(),e.label=9;case 9:return[2]}}
2))}))}))})))},Object.defineProperty(n.prototype,"_isPageHidden",{get:function(){return this._appStateToggleEnabled&&typeof document<"u"&&document.visibilityState==="hidden"},enumerable:!1,configurable:!0}),n.prototype._clearEventDispatcher=function(){this._sessionEventDispatcherContext&&(this._sessionEventDispatcherContext.close(),this._sessionEventDispatcherContext=void 0),this._websocketEventDispatcherContext&&(this._websocketEventDispatcherContext.close(),this._websocketEventDispatcherContext=void 0)},Object.defineProperty(n.prototype,"isConnected",{get:function(){return this._context.currentState.type===X.CONNECTED},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isConnecting",{get:function(){var t=this._context.currentState;return t.type===X.CONNECTING||t.type===X.RECONNECTING},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"websocketClient",{get:function(){return this._websocketClient},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"shouldReconnectOnForeground",{get:function(){return!this.isConnected&&!this.isConnecting&&!this._sessionManager.isSessionKeyRefreshing&&this._webSocketClosedCause!==Pt.ExternalDisconnectWebSocket},enumerable:!1,configurable:!0}),n.prototype.connect=function(t){return f(this,void 0,void 0,(function(){var e;return p(this,(function(r){switch(r.label){case 0:return e=this._context.currentState,this._webSocketClosedCause=null,[4,e.onConnect(this._context,t)];case 1:return r.sent(),this._registerEventDispatcher(),[2]}}))}))},n.prototype.reconnect=function(){return f(this,void 0,void 0,(function(){var t;return p(this,(function(e){switch(e.label){case 0:return t=this._context.currentState,this._webSocketClosedCause=null,[4,t.onReconnect(this._context,{})];case 1:return e.sent(),[2]}}))}))},n.prototype.resetAndReconnect=function(){return f(this,void 0,void 0,(function(){var t;return p(this,(function(e){switch(e.label){case 0:return t=this._context.currentState,this._webSocketClosedCause=null,[4,t.onReconnect(this._context,{resetReconnectCount:!0})];case 1:return e.sent(),[2]}}))}))},n.prototype.background=function(){return f(this,void 0,void 0,(function(){var t;return p(this,(function(e){switch(e.label){case 0:return t=this._context.currentState,this._webSocketClosedCause=Pt.ExternalSetBackground,[4,t.onDisconnect(this._context,{autoReconnect:!1,cause:this._webSocketClosedCause})];case 1:return e.sent(),[2]}}))}))},n.prototype.disconnect=function(t){return f(this,void 0,void 0,(function(){return p(this,(function(e){switch(e.label){case 0:return[4,this._context.currentState.onDisconnect(this._context,{error:t,autoReconnect:!0,cause:this._webSocketClosedCause})];case 1:return e.sent(),[2]}}))}))},n.prototype.disconnectWebSocket=function(t){return t===void 0&&(t=!1),f(this,void 0,void 0,(function(){var e;return p(this,(function(r){switch(r.label){case 0:return e=this._context.currentState,t&&(this._webSocketClosedCause=Pt.ExternalDisconnectWebSocket),[4,e.onDisconnectWebSocket(this._context,{cause:this._webSocketClosedCause})];case 1:return r.sent(),[2]}}))}))},n.prototype.logout=function(t){return f(this,void 0,void 0,(function(){var e;return p(this,(function(r){switch(r.label){case 0:return e=this._context.currentState,this._clearEventDispatcher(),[4,e.onLogout(this._context,t)];case 1:return r.sent(),[2]}}))}))},n})(),hn=(function(n){function t(e){var r=e.retryAfterTime,i=e.reasonCode,s=e.message,a=e.authToken,o=n.call(this)||this;return o.type=X.DELAYED_CONNECTING,o.name="delayedconnecting",o._timerStartTime=0,o._retryAfterTime=r,o._reasonCode=i,o._message=s,o._authToken=a,o}return g(t,n),t.prototype._clearDelayConnectTimer=function(){this._delayConnectTimer&&(clearTimeout(this._delayConnectTimer),this._delayConnectTimer=void 0),this._timerStartTime=0},t.prototype._startDelayedConnectTimer=function(e){var r=this;this._clearDelayConnectTimer(),this._timerStartTime=Date.now(),this._delayConnectTimer=setTimeout((function(){var i=Date.now();clearTimeout(r._delayConnectTimer),r._delayConnectTimer=void 0,r._timerStartTime=0,e.changeState(new Zn({authToken:r._authToken,isSoftRateLimited:!0}),i).catch((function(){}))}
2),this._retryAfterTime),e.connectionHandlers.forEach((function(i){var s;(s=i.onConnectionDelayed)===null||s===void 0||s.call(i,Math.ceil(r._retryAfterTime/1e3))}))},t.prototype._calculateRemainDelayConnectTime=function(){this._delayConnectTimer&&(this._retryAfterTime=this._retryAfterTime-(Date.now()-this._timerStartTime))},t.prototype._throwDelayedConnectingError=function(){var e=new T({code:L.DELAYED_CONNECTING,message:this._message});throw e.setDetail(JSON.stringify({retry_after:Math.ceil(this._retryAfterTime/1e3),reason_code:this._reasonCode,message:this._message})),e},t.prototype.run=function(e){return f(this,void 0,void 0,(function(){return p(this,(function(r){return this._startDelayedConnectTimer(e),[2]}))}))},t.prototype.onConnect=function(e,r){return f(this,void 0,void 0,(function(){return p(this,(function(i){return this._delayConnectTimer&&(this._calculateRemainDelayConnectTime(),this._startDelayedConnectTimer(e),this._throwDelayedConnectingError()),[2]}))}))},t.prototype.onReconnect=function(e){return f(this,void 0,void 0,(function(){return p(this,(function(r){return this._delayConnectTimer&&(this._calculateRemainDelayConnectTime(),this._startDelayedConnectTimer(e),this._throwDelayedConnectingError()),[2]}))}))},t.prototype.onDelayedConnecting=function(e,r){var i=r.retryAfterTime,s=r.reasonCode,a=r.message;return f(this,void 0,void 0,(function(){return p(this,(function(o){return this._retryAfterTime=i,this._reasonCode=s,this._message=a,this._startDelayedConnectTimer(e),[2]}))}))},t.prototype.onDisconnect=function(e,r){var i=r.autoReconnect,s=i!==void 0&&i,a=r.cause,o=a===void 0?null:a;return f(this,void 0,void 0,(function(){var u;return p(this,(function(c){switch(c.label){case 0:return u=Date.now(),this._clearDelayConnectTimer(),o!==Pt.ExternalSetBackground?[3,2]:[4,e.changeState(new fn({autoReconnect:s,retryAfterTime:this._retryAfterTime,disconnectedTime:u,reasonCode:this._reasonCode,message:this._message}),u)];case 1:return c.sent(),[3,6];case 2:return e.hasSession?[4,e.changeState(new fn({autoReconnect:s}),u)]:[3,4];case 3:return c.sent(),[3,6];case 4:return[4,e.changeState(new vt,u)];case 5:c.sent(),c.label=6;case 6:return[2]}}
2))}))},t.prototype.onDisconnectWebSocket=function(e){return f(this,void 0,void 0,(function(){var r;return p(this,(function(i){switch(i.label){case 0:return r=Date.now(),this._clearDelayConnectTimer(),[4,e.changeState(new tr,r)];case 1:return i.sent(),[2]}}))}))},t.prototype.onLogout=function(e){return f(this,void 0,void 0,(function(){var r;return p(this,(function(i){switch(i.label){case 0:return r=Date.now(),this._clearDelayConnectTimer(),[4,e.changeState(new vt,r)];case 1:return i.sent(),[2]}}))}))},t})(Ft),fn=(function(n){function t(e){var r=n.call(this)||this;return r.type=X.INTERNAL_DISCONNECTED,r.name="internaldisconnected",r._autoReconnect=!1,r._autoReconnect=e.autoReconnect,r._retryAfter=e.retryAfterTime,r._disconnectedTime=e.disconnectedTime,r._reasonCode=e.reasonCode,r._message=e.message,r}return g(t,n),t.prototype._getDelayedConnectTime=function(e){return this._retryAfter&&this._disconnectedTime?Math.ceil((this._retryAfter-(e-this._disconnectedTime))/1e3):-1},t.prototype.run=function(e){return f(this,void 0,void 0,(function(){var r,i=this;return p(this,(function(s){switch(s.label){case 0:return r=Date.now(),[4,e.disconnect()];case 1:return s.sent(),ue((function(){return f(i,void 0,void 0,(function(){return p(this,(function(a){return e.connectionHandlers.forEach((function(o){var u;(u=o.onConnectionLost)===null||u===void 0||u.call(o)})),[2]}))}))})),this._autoReconnect?[4,e.changeState(new Zn,r)]:[3,3];case 2:s.sent(),s.label=3;case 3:return[2]}}
2))}))},t.prototype.onConnect=function(e,r){return f(this,void 0,void 0,(function(){var i;return p(this,(function(s){switch(s.label){case 0:return i=Date.now(),[4,e.disconnect()];case 1:return s.sent(),[4,e.changeState(new Zr({authToken:r}),i)];case 2:return s.sent(),[2]}}))}))},t.prototype.onReconnect=function(e){return f(this,void 0,void 0,(function(){var r,i;return p(this,(function(s){switch(s.label){case 0:return r=Date.now(),(i=this._getDelayedConnectTime(r))>0?[4,e.changeState(new hn({retryAfterTime:i,reasonCode:this._reasonCode,message:this._message}),r)]:[3,2];case 1:return s.sent(),[3,4];case 2:return[4,e.changeState(new Zn,r)];case 3:s.sent(),s.label=4;case 4:return[2]}}))}))},t.prototype.onDisconnectWebSocket=function(e){return f(this,void 0,void 0,(function(){var r;return p(this,(function(i){switch(i.label){case 0:return r=Date.now(),[4,e.changeState(new tr({isAlreadyDisconnected:!0}),r)];case 1:return i.sent(),[2]}}))}))},t.prototype.onLogout=function(e){return f(this,void 0,void 0,(function(){var r;return p(this,(function(i){switch(i.label){case 0:return r=Date.now(),[4,e.changeState(new vt,r)];case 1:return i.sent(),[2]}}))}))},t})(Ft),Ue=function(n){return f(void 0,void 0,void 0,(function(){return p(this,(function(t){return[2,new Promise((function(e){return setTimeout(e,n)}))]}))}))},Vo=(function(){function n(){}return n.prototype.calcTimeout=function(){return 0},n})(),fs=function(n,t,e){return e===void 0&&(e=new Vo),f(void 0,void 0,void 0,(function(){var r,i,s,a,o,u;return p(this,(function(c){switch(c.label){case 0:r=0,i=null,s=function(l){return i=l!=null?l:new Error("Halted")},a=function(){r=0},c.label=1;case 1:if(!(t===-1||r<t))return[3,9];c.label=2;case 2:return c.trys.push([2,4,,8]),[4,n(s,a)];case 3:if(o=c.sent(),i)throw i;return[2,o];case 4:if(u=c.sent(),i)return[3,6];if(++r===t)throw u;return[4,Ue(e.calcTimeout(r))];case 5:return c.sent(),[3,7];case 6:throw i;case 7:return[3,8];case 8:return[3,1];case 9:throw"It should not happen."}}))}))},fl=(function(n){function t(e){var r=e===void 0?{}:e,i=r.authToken,s=r.isSoftRateLimited,a=n.call(this)||this;return a.type=X.RECONNECTING,a.name="reconnecting",a._callbacks=[],a._authToken=i,a._isSoftRateLimited=s!=null?s:void 0,a}return g(t,n),t.prototype._halt=function(e){this._haltConnect&&(this._haltConnect(e),this._haltConnect=void 0)},t.prototype._flushCallbacks=function(e){this._haltConnect=void 0,this._resetConnect=void 0,this._callbacks.forEach((function(r){return r(e)}))},t.prototype.run=function(e){return f(this,void 0,void 0,(function(){var r,i,s,a,o,u,c,l,d,_,h=this;return p(this,(function(v){switch(v.label){case 0:r=Date.now(),i=new De,this._callbacks.push((function(m){return m?i.reject(m):i.resolve()})),ue((function(){return f(h,void 0,void 0,(function(){return p(this,(function(m){return e.connectionHandlers.forEach((function(y){var b;(b=y.onReconnectStarted)===null||b===void 0||b.call(y)})),[2]}))}))})),s=e.dispatcher,v.label=1;case 1:return v.trys.push([1,4,,12]),a=st(),o=0,u=e.sdkState.websocket,c=u.reconnectMaxRetry,l=u.reconnectRetryStrategy,[4,fs((function(m,y){return f(h,void 0,void 0,(function(){var b;return p(this,(function(w){switch(w.label){case 0:this._haltConnect=m,this._resetConnect=y,w.label=1;case 1:return w.trys.push([1,3,,4]),o++,[4,e.connect({authToken:this._authToken,connectionKey:a,connectionRetryCount:o,isSoftRateLimited:this._isSoftRateLimited})];case 2:return w.sent(),[3,4];case 3:if(b=w.sent(),e.clearLoginTimer(),b instanceof T){switch(b.code){case L.CONNECTION_CANCELED:case L.DELAYED_CONNECTING:return m(b),[2]}if(b.isSessionExpiredError||b.isSessionInvalidatedError)return m(b),[2]}throw b;case 4:return[2]}}
2))}))}),c,l)];case 2:return v.sent(),[4,e.changeState(new Go,r)];case 3:return v.sent(),this._flushCallbacks(),ue((function(){return f(h,void 0,void 0,(function(){return p(this,(function(m){return e.connectionHandlers.forEach((function(y){var b;(b=y.onReconnectSucceeded)===null||b===void 0||b.call(y)})),[2]}))}))})),[3,12];case 4:return d=v.sent(),tt(d)?[3,10]:[4,e.disconnect()];case 5:return v.sent(),d instanceof T?d.code!==L.DELAYED_CONNECTING?[3,7]:(_=JSON.parse(d.detail),[4,e.changeState(new hn({retryAfterTime:1e3*_.retry_after,reasonCode:_.reason_code,message:_.message,authToken:this._authToken}),r)]):[3,9];case 6:return v.sent(),[3,9];case 7:return d.code===L.CONNECTION_CANCELED?[3,9]:[4,e.changeState(new fn({autoReconnect:!1}),r)];case 8:v.sent(),d.isSessionExpiredError&&s.dispatch(new dn({reason:d.code,message:d.message})),v.label=9;case 9:return this._flushCallbacks(d),ue((function(){return f(h,void 0,void 0,(function(){return p(this,(function(m){return e.connectionHandlers.forEach((function(y){var b;(b=y.onReconnectFailed)===null||b===void 0||b.call(y)})),[2]}))}))})),[3,11];case 10:throw d;case 11:return[3,12];case 12:return[2,i.promise]}}))}))},t.prototype.onConnect=function(e,r){return f(this,void 0,void 0,(function(){var i;return p(this,(function(s){return i=new De,this._halt(T.connectionCanceled),e.cancelConnectForRetry(),this._callbacks.push((function(){var a=Date.now();e.changeState(new Zr({authToken:r}),a).then((function(){i.resolve()})).catch((function(o){i.reject(o)}))})),[2,i.promise]}))}))},t.prototype.onReconnect=function(e,r){var i=r.resetReconnectCount,s=i!==void 0&&i;return f(this,void 0,void 0,(function(){var a;return p(this,(function(o){return a=new De,this._resetConnect&&s&&this._resetConnect(),this._callbacks.push((function(u){return u?a.reject(u):a.resolve()})),[2,a.promise]}))}))},t.prototype.onDisconnect=function(e,r){r._error;var i=r.autoReconnect,s=i===void 0||i;return f(this,void 0,void 0,(function(){var a;return p(this,(function(o){switch(o.label){case 0:return a=Date.now(),this._halt(T.connectionCanceled),[4,e.changeState(new fn({autoReconnect:s}),a)];case 1:return o.sent(),[2]}}))}))},t.prototype.onDisconnectWebSocket=function(e){return f(this,void 0,void 0,(function(){var r;return p(this,(function(i){switch(i.label){case 0:return r=Date.now(),this._halt(T.connectionCanceled),[4,e.changeState(new tr,r)];case 1:return i.sent(),[2]}}))}))},t.prototype.onLogout=function(e){return f(this,void 0,void 0,(function(){var r;return p(this,(function(i){switch(i.label){case 0:return r=Date.now(),this._halt(T.connectionCanceled),[4,e.changeState(new vt,r)];case 1:return i.sent(),[2]}}))}))},t.prototype.onDelayedConnecting=function(e,r){var i=r.retryAfterTime,s=r.reasonCode,a=r.message;return f(this,void 0,void 0,(function(){var o,u;return p(this,(function(c){switch(c.label){case 0:return o=Date.now(),(u=new T({code:L.DELAYED_CONNECTING,message:a})).setDetail(JSON.stringify({retry_after:i/1e3,reason_code:s,message:a})),this._halt(u),[4,e.changeState(new hn({retryAfterTime:i,reasonCode:s,message:a,authToken:this._authToken}),o)];case 1:return c.sent(),[2]}}))}))},t})(Ft),Zn=fl,Go=(function(n){function t(){var e=n!==null&&n.apply(this,arguments)||this;return e.type=X.CONNECTED,e.name="connected",e}return g(t,n),t.prototype.onReconnect=function(e){return f(this,void 0,void 0,(function(){var r;return p(this,(function(i){switch(i.label){case 0:return r=Date.now(),[4,e.disconnect()];case 1:return i.sent(),[4,e.changeState(new Zn,r)];case 2:return i.sent(),[2]}}))}))},t.prototype.onDisconnect=function(e,r){var i=r.autoReconnect;return f(this,void 0,void 0,(function(){var s;return p(this,(function(a){switch(a.label){case 0:return s=Date.now(),[4,e.changeState(new fn({autoReconnect:i}),s)];case 1:return a.sent(),[2]}}))}))},t.prototype.onDisconnectWebSocket=function(e){return f(this,void 0,void 0,(function(){var r;return p(this,(function(i){switch(i.label){case 0:return r=Date.now(),[4,e.changeState(new tr,r)];case 1:return i.sent(),[2]}}))}))},t.prototype.onLogout=function(e){return f(this,void 0,void 0,(function(){var r;return p(this,(function(i){switch(i.label){case 0:return r=Date.now(),[4,e.changeState(new vt,r)];case 1:return i.sent(),[2]}}))}))},t.prototype.onDelayedConnecting=function(e,r){var i=r.retryAfterTime,s=r.reasonCode,a=r.message;return f(this,void 0,void 0,(function(){var o;return p(this,(function(u){switch(u.label){case 0:return o=Date.now(),[4,e.changeState(new hn({retryAfterTime:i,reasonCode:s,message:a}),o)];case 1:return u.sent(),[2]}}))}))},t})(Ft),Zr=(function(n){function t(e){var r=e.authToken,i=n.call(this)||this;return i.type=X.CONNECTING,i.name="connecting",i._authToken="",i._callbacks=[],i._authToken=r,i}return g(t,n),t.prototype._halt=function(e){this._haltConnect&&(this._haltConnect(e),this._haltConnect=void 0)},t.prototype._flushCallbacks=function(e){this._haltConnect=void 0,this._callbacks.forEach((function(r){return r(e)}))},t.prototype.run=function(e){return f(this,void 0,void 0,(function(){var r,i,s,a,o,u,c=this;return p(this,(function(l){switch(l.label){case 0:r=Date.now(),i=new De,this._callbacks.push((function(d){return d?i.reject(d):i.resolve()})),l.label=1;case 1:return l.trys.push([1,4,,12]),s=st(),a=0,[4,fs((function(d){return f(c,void 0,void 0,(function(){var _;return p(this,(function(h){switch(h.label){case 0:this._haltConnect=d,h.label=1;case 1:return h.trys.push([1,3,,4]),a++,[4,e.connect({authToken:this._authToken,connectionKey:s,connectionRetryCount:a})];case 2:return h.sent(),[3,4];case 3:if(_=h.sent(),e.clearLoginTimer(),_ instanceof T)switch(_.code){case L.CONNECTION_CANCELED:case L.SESSION_KEY_EXPIRED:case L.SESSION_TOKEN_EXPIRED:case L.SESSION_REVOKED:case L.USER_AUTH_DEACTIVATED:case L.USER_AUTH_DELETED_OR_NOT_FOUND:case L.USER_DEACTIVATED:case L.DELAYED_CONNECTING:return d(_),[2]}throw _;case 4:return[2]}}
2))}))}),e.sdkState.websocket.connectMaxRetry)];case 2:return l.sent(),[4,e.changeState(new Go,r)];case 3:return l.sent(),ue((function(){return f(c,void 0,void 0,(function(){return p(this,(function(d){return this._flushCallbacks(),e.connectionHandlers.forEach((function(_){var h;(h=_.onConnected)===null||h===void 0||h.call(_,e.sdkState.userId)})),[2]}))}))})),[3,12];case 4:return o=l.sent(),tt(o)?[3,10]:[4,e.disconnect()];case 5:return l.sent(),o instanceof T?o.code!==L.DELAYED_CONNECTING?[3,7]:(u=JSON.parse(o.detail),[4,e.changeState(new hn({retryAfterTime:1e3*u.retry_after,reasonCode:u.reason_code,message:u.message,authToken:this._authToken}),r)]):[3,9];case 6:return l.sent(),[3,9];case 7:return o.code===L.CONNECTION_CANCELED?[3,9]:[4,e.changeState(new ps,r)];case 8:l.sent(),l.label=9;case 9:return ue((function(){return f(c,void 0,void 0,(function(){return p(this,(function(d){return this._flushCallbacks(o),[2]}))}))})),[3,11];case 10:throw o;case 11:return[3,12];case 12:return[2,i.promise]}}))}))},t.prototype.onConnect=function(e){return f(this,void 0,void 0,(function(){var r;return p(this,(function(i){return r=new De,this._callbacks.push((function(s){return s?r.reject(s):r.resolve()})),[2,r.promise]}))}))},t.prototype.onDisconnect=function(e,r){var i=r.error,s=i===void 0?null:i,a=r.autoReconnect,o=a!==void 0&&a,u=r.cause,c=u===void 0?null:u;return f(this,void 0,void 0,(function(){var l;return p(this,(function(d){switch(d.label){case 0:return l=Date.now(),this._halt(s!=null?s:ua(c)),e.hasSession?[4,e.changeState(new fn({autoReconnect:o}),l)]:[3,2];case 1:return d.sent(),[3,4];case 2:return[4,e.changeState(new vt,l)];case 3:d.sent(),d.label=4;case 4:return[2]}}
2))}))},t.prototype.onDisconnectWebSocket=function(e,r){return f(this,void 0,void 0,(function(){var i;return p(this,(function(s){switch(s.label){case 0:return this._halt(ua((r==null?void 0:r.cause)||null)),i=Date.now(),e.hasSession?[4,e.changeState(new tr,i)]:[3,2];case 1:return s.sent(),[3,4];case 2:return[4,e.changeState(new vt,i)];case 3:s.sent(),s.label=4;case 4:return[2]}}))}))},t.prototype.onLogout=function(e,r){return f(this,void 0,void 0,(function(){var i;return p(this,(function(s){switch(s.label){case 0:return i=Date.now(),this._halt(r!=null?r:T.connectionCanceled),[4,e.changeState(new vt,i)];case 1:return s.sent(),[2]}}))}))},t.prototype.onDelayedConnecting=function(e,r){var i=r.retryAfterTime,s=r.reasonCode,a=r.message;return f(this,void 0,void 0,(function(){var o;return p(this,(function(u){switch(u.label){case 0:return o=Date.now(),[4,e.changeState(new hn({retryAfterTime:i,reasonCode:s,message:a,authToken:this._authToken}),o)];case 1:return u.sent(),[2]}}))}))},t})(Ft);function ua(n){var t=T.connectionCanceled;if(n){var e=null;switch(n){case Pt.ExternalSetBackground:e="Connection has been canceled due to the application having externally moved to background while in ConnectingState.";break;case Pt.ExternalDisconnectWebSocket:e="Connection has been canceled because sb.disconnectWebSocket() was called while in ConnectingState."}e&&t.setDetail(e)}return t}var We,ps=(function(n){function t(){var e=n!==null&&n.apply(this,arguments)||this;return e.type=X.INITIALIZED,e.name="initialized",e}return g(t,n),t.prototype.onConnect=function(e,r){return f(this,void 0,void 0,(function(){var i;return p(this,(function(s){switch(s.label){case 0:return i=Date.now(),[4,e.changeState(new Zr({authToken:r}),i)];case 1:return s.sent(),[2]}}))}))},t.prototype.onLogout=function(e){return f(this,void 0,void 0,(function(){var r;return p(this,(function(i){switch(i.label){case 0:return r=Date.now(),[4,e.changeState(new vt({wasPreviouslyConnected:!1}),r)];case 1:return i.sent(),[2]}}))}))},t})(Ft),pl=(function(n){function t(){return n.call(this,{code:"PING",payload:{id:Date.now(),active:1},ackRequired:!1})||this}return g(t,n),t})(qe),_l=(function(){function n(t){var e=t.pingDelegate,r=t.sdkState,i=t.logger;this.pingDelegate=e,this.sdkState=r,this._logger=i}return Object.defineProperty(n.prototype,"isWaiting",{get:function(){return!!this._pingTimeoutTimer},enumerable:!1,configurable:!0}),n.prototype.ping=function(){var t,e=this;if(!this.sdkState.websocket)throw T.connectionRequired;var r=new pl;try{var i=(t=this.sdkState.websocket.pongTimeout)!==null&&t!==void 0?t:5e3;this._pingTimeoutTimer=setTimeout((function(){e._logger.debug("pinger.ping() timeout"),e.pingDelegate.error()}),i),this.pingDelegate.send(r),this._logger.debug("pinger.ping()")}catch(s){this._logger.debug("pinger.ping() error",s),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=void 0),this.pingDelegate.error()}return r},n.prototype.pong=function(){this._logger.debug("pinger.pong()"),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=void 0)},n.prototype.refreshTimer=function(){var t,e=this;if(!this.sdkState.websocket)throw T.connectionRequired;this._logger.debug("pinger.refreshTimer()");var r=(t=this.sdkState.websocket.pingInterval)!==null&&t!==void 0?t:15e3;this.stop(),this._pingTimer=setInterval((function(){e.ping()}),r)},n.prototype.start=function(){this._logger.debug("pinger.start()"),this.refreshTimer(),this.ping()},n.prototype.stop=function(){this._logger.debug("pinger.stop()"),this._pingTimer&&(clearInterval(this._pingTimer),this._pingTimer=void 0),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=void 0)},n})(),Qo=["premium_feature_list","file_upload_size_limit","application_attributes","emoji_hash","multiple_file_send_max_size","notifications","message_template","ai_agent"],vl=(function(n){function t(e,r){var i,s=r.sdkState,a=r.cacheContext,o=r.connectionHandlers,u=r.sessionManager,c=r.websocketClient,l=r.dispatcher,d=r.logger,_=r.entryState,h=_===void 0?new ps:_,v=this;return(v=n.call(this)||this)._currentConnectionRetryCount=0,v._stateUpdatedAt=0,v._connectingAt=0,v._connectedAt=0,v._logiReceivedAt=0,v._connectionRequestQueue=[],v._iid=e,v.sdkState=s,v.cacheContext=a,v.connectionHandlers=o,v._sessionManager=u,v._websocketClient=c,v._dispatcher=l,v._logger=
2d,v._currentState=h,!((i=v.sdkState.websocket)===null||i===void 0)&&i.pingerDisabled||(v._pinger=new _l({pingDelegate:{send:function(m){return v._websocketClient.send(m)},error:function(m){l.dispatch(new St(new de({type:te.WEBSOCKET_DISCONNECT,data:{success:!0,error_code:L.NETWORK_ERROR,error_description:"cause=ping_pong_timedout"}}))),v._websocketClient.error(m),v._websocketClient.isOpen&&v._websocketClient.forceClose()}},sdkState:v.sdkState,logger:d})),v._websocketClient.on("open",(function(){v._connectedAt=Date.now(),v._tryResolveConnectionRequest()})).on("message",(function(m){m.code==="LOGI"&&(v.clearLoginTimer(),v._dispatcher.dispatch(m.as(Cr)))})).on("ping-refresh",(function(){var m;return(m=v._pinger)===null||m===void 0?void 0:m.refreshTimer()})).on("pong",(function(){var m;return(m=v._pinger)===null||m===void 0?void 0:m.pong()})).on("error",(function(){var m;return(m=v._pinger)===null||m===void 0?void 0:m.stop()})).on("close",(function(){v._logiProcessingTimer=setTimeout((function(){v._logiProcessingTimer=void 0,v._unresolvedLogi||v._rejectConnectionRequest(T.networkError)}),500)})),v._dispatcher.on((function(m){if(m instanceof Cr)v._unresolvedLogi=m,v._tryResolveConnectionRequest();else if(m instanceof ds){var y=m.retryAfterTime,b=m.reasonCode,w=m.message,I=new T({code:L.DELAYED_CONNECTING,message:w});I.setDetail(JSON.stringify({retry_after:y/1e3,reason_code:b,message:w})),v._rejectConnectionRequest(I)}})),v}return g(t,n),Object.defineProperty(t.prototype,"currentState",{get:function(){return this._currentState},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasSession",{get:function(){return this._sessionManager.session.hasSession},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dispatcher",{get:function(){return this._dispatcher},enumerable:!1,configurable:!0}),t.prototype.changeState=function(e,r){return f(this,void 0,void 0,(function(){return p(this,(function(i){switch(i.label){case 0:return r>=this._stateUpdatedAt?(this._currentState=e,this._stateUpdatedAt=r,this._dispatcher.dispatch(new yn({stateType:e.type})),this._logger.debug("connection state changes to ".concat(e.name)),[4,this._currentState.run(this)]):[3,2];case 1:return i.sent(),[2,!0];case 2:return[2,!1]}}))}))},t.prototype._tryResolveConnectionRequest=function(){var e;return f(this,void 0,void 0,(function(){var r;return p(this,(function(i){switch(i.label){case 0:return r=this._unresolvedLogi,this._websocketClient.isOpen&&r?(this._unresolvedLogi=void 0,this._logiReceivedAt=Date.now(),r.error?[3,2]:[4,r.applyTo(this._iid)]):[3,3];case 1:return i.sent(),this._statLogConnection(),(e=this._pinger)===null||e===void 0||e.start(),this._connectionRequestQueue.forEach((function(s){return s.resolve()})),this._connectionRequestQueue=[],this.sdkState.appState="foreground",[3,3];case 2:this._logger.warn("login failed: ".concat(r.error)),this._rejectConnectionRequest(r.error),i.label=3;case 3:return[2]}}
2))}))},t.prototype._rejectConnectionRequest=function(e){var r;if((r=this._pinger)===null||r===void 0||r.stop(),this.clearLoginTimer(),this._connectionRequestQueue.length>0){var i=this._connectionRequestQueue;this._connectionRequestQueue=[],i.forEach((function(s){return s.reject(e)})),this._statLogConnection(e)}},t.prototype._url=function(e){var r,i=e.configTs,s=this.sdkState,a=s.appId,o=s.appVersion,u=s.userId,c=s.extensions,l=s.sendbirdRuntimeEnvironment,d=this.cacheContext.localCacheEnabled,_=this._sessionManager.session,h=(r=this.sdkState.websocket)===null||r===void 0?void 0:r.compression,v=!!(c!=null?c:{}).sb_uikit,m=xr.userAgentWithExtension(c);return"".concat(this.sdkState.websocket.host,"/?p=JS&pv=").concat(encodeURIComponent(Rt.OS_VERSION),"&sv=").concat(encodeURIComponent(Rt.SDK_VERSION),"&ai=").concat(a).concat(o?"&av=".concat(o):"").concat(_.hasSession?"":"&user_id=".concat(encodeURIComponent(u)),"&pmce=").concat(h?1:0,"&active=1&device_token_types=").concat(encodeURIComponent(["gcm","huawei","apns"].join(",")),"&SB-User-Agent=").concat(m,"&SB-SDK-User-Agent=").concat(encodeURIComponent(xr.sendbirdSdkUserAgentWithExtension(l)),"&Request-Sent-Timestamp=").concat(Date.now().toString(),"&include_extra_data=").concat(encodeURIComponent(String(Qo))).concat(this._sessionManager.handler?"&expiring_session=1":"","&use_local_cache=").concat(d?1:0,"&include_poll_details=1").concat(v?"&uikit_config=1":"","&config_ts=").concat(i)},t.prototype._statLogConnection=function(e){var r,i;this._dispatcher.dispatch(new St(new de({type:te.WEBSOCKET_CONNECT,data:{host_url:(r=this.sdkState.websocket)===null||r===void 0?void 0:r.host,success:!e,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:(i=this._isSoftRateLimited)!==null&&i!==void 0?i:void 0,error_code:e==null?void 0:e.code,error_description:(e==null?void 0:e.code)===L.DELAYED_CONNECTING?e==null?void 0:e.detail:e==null?void 0:e.message}})))},t.prototype.connect=function(e){var r;return e===void 0&&(e={}),f(this,void 0,void 0,(function(){var i,s,a,o,u,c,l,d,_,h,v,m,y=this;return p(this,(function(b){switch(b.label){case 0:return this._unresolvedLogi=void 0,this._logiProcessingTimer&&(clearTimeout(this._logiProcessingTimer),this._logiProcessingTimer=void 0,this._rejectConnectionRequest(T.connectionCanceled)),i=new De,s=e.authToken,a=s===void 0?"":s,o=e.connectionKey,u=o===void 0?st():o,c=e.connectionRetryCount,l=c===void 0?1:c,d=e.isSoftRateLimited,this._connectionRequestQueue.push(i),this._connectionRequestQueue.length!==1?[3,2]:(this._currentConnectionKey=u,this._currentConnectionRetryCount=l,this._isSoftRateLimited=d,this._connectingAt=Date.now(),this._connectedAt=0,this._logiReceivedAt=0,this._loginTimer=setTimeout((function(){y._loginTimer=void 0,y._rejectConnectionRequest(T.loginTimeout)}),(r=this.sdkState.websocket)===null||r===void 0?void 0:r.responseTimeout),_=this._sessionManager.session,a&&(_.authToken=a,_.sessionKey=void 0),h=0,[4,this.cacheContext.preference.get(jr(this.sdkState.appId))]);case 1:(v=b.sent())&&(h=v.configTs),m=this._url({configTs:h}),_.sessionKey||_.authToken?this._websocketClient.connect(m,JSON.stringify(_.hasSession?{auth:_.sessionKey}:{token:_.authToken})):this._websocketClient.connect(m,JSON.stringify({})),b.label=2;case 2:return[2,i.promise]}}))}))},t.prototype.cancelConnectForRetry=function(){this._dispatcher.dispatch(Cr.asError(T.connectionRenew))},t.prototype.disconnect=function(){return f(this,void 0,void 0,(function(){return p(this,(function(e){switch(e.label){case 0:return this._unresolvedLogi=void 0,[4,this._websocketClient.disconnect()];case 1:return e.sent(),[2]}}))}))},t.prototype.logout=function(){return f(this,void 0,void 0,(function(){return p(this,(function(e){switch(e.label){case 0:return this.sdkState.userId=void 0,this._unresolvedLogi=void 0,[4,this.disconnect()];case 1:return e.sent(),[4,this._sessionManager.clear()];case 2:return e.sent(),[2]}}))}))},t.prototype.clearLoginTimer=function(){this._loginTimer&&(clearTimeout(this._loginTimer),this._loginTimer=void 0)},t})(mn),$o=(function(n){function t(e){var r=e.appId,i=e.userId,s=e.includeUIKitConfig,a=s!==void 0&&s,o=e.localCacheEnabled,u=o===void 0||o,c=e.expiringSession,l=c===void 0||c,d=e.configTs,_=d===void 0?0:d,h=n.call(this)||this;return h.path="".concat(Uu,"/").concat(encodeURIComponent(i),"/authentication"),h.method=k.POST,h.params=M({expiring_session:!!l,include_logi:!0,include_extra_data:String(Qo),uikit_config:a,use_local_cache:u,app_id:r,config_ts:_}),h.requireAuth=!1,h}return g(t,n),t})(O),ml=(function(n){function t(e,r){var i=n.call(this,e,r)||this;return i.logi=new Cr(e,"LOGI",r),i}return g(t,n),t})(U),pr=1e4;
2(function(n){n[n.ALL=0]="ALL",n[n.WEBSOCKET=1]="WEBSOCKET",n[n.API=2]="API"})(We||(We={}));var Q,ca,gl=[os,$o],yl=(function(){function n(t,e){var r=e.session,i=e.sdkState,s=e.dispatcher,a=e.logger,o=e.useFetchCompat,u=o!==void 0&&o,c=this;this._currentConnectionStateType=X.INITIALIZED,this._lazyCallQueue=[],this.commandRouter=new nl(t,{session:r,sdkState:i,dispatcher:s,logger:a,useFetchCompat:u}),this._session=r,this._logger=a,this._dispatcher=s,this._dispatcher.on((function(l){var d,_,h;if(l instanceof yn){var v=l.stateType;switch(c._currentConnectionStateType=v,v){case X.CONNECTED:c._resolveLazyCallQueue();break;case X.INITIALIZED:case X.INTERNAL_DISCONNECTED:case X.EXTERNAL_DISCONNECTED:case X.LOGOUT:c._session.isRefreshing||c._rejectLazyCallQueue(!((h=c._session)===null||h===void 0)&&h.hasSession?T.connectionClosed:T.connectionRequired)}}else if(l instanceof qo)c._resolveLazyCallQueue(c._session.hasChatServicePermission?We.ALL:We.API);else if(l instanceof Wi||l instanceof zo)c._rejectLazyCallQueue(T.connectionClosed);else if(l instanceof vo){var m=l.request,y=l.deferred,b=l.error;try{for(var w=z(gl),I=w.next();!I.done;I=w.next())if(m instanceof I.value)return void y.reject(b)}catch(A){d={error:A}}finally{try{I&&!I.done&&(_=w.return)&&_.call(w)}finally{if(d)throw d.error}}c._lazyCallQueue.push({command:m,deferred:y})}}))}return Object.defineProperty(n.prototype,"isReady",{get:function(){return this._currentConnectionStateType===X.CONNECTED},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isLazyCallActivated",{get:function(){return this._currentConnectionStateType===X.CONNECTING||this._currentConnectionStateType===X.RECONNECTING||this._session.isRefreshing},enumerable:!1,configurable:!0}),n.prototype._classifyLazyCallQueueByScope=function(t){var e,r=[],i=[];switch(t){case We.ALL:e=null;break;case We.WEBSOCKET:e=qe;break;case We.API:e=O}var s=!1;return this._lazyCallQueue.forEach((function(a){!e||a.command instanceof e||(s=!0),s?i.push(a):r.push(a)})),[r,i]},n.prototype._mergeLazyCallScope=function(t,e){return t===void 0?e:t===e?t:We.ALL},n.prototype._clearWebSocketOpenFlushWait=function(){var t,e=(t=this._waitingForWebSocketOpenFlushScope)!==null&&t!==void 0?t:We.ALL;return this._webSocketOpenFlushContext&&(this._webSocketOpenFlushContext.close(),this._webSocketOpenFlushContext=void 0),this._webSocketOpenFlushTimeout&&(clearTimeout(this._webSocketOpenFlushTimeout),this._webSocketOpenFlushTimeout=void 0),this._waitingForWebSocketOpenFlushScope=void 0,e},n.prototype._resolveLazyCallQueueAfterWebSocketOpen=function(){var t=this._clearWebSocketOpenFlushWait();this._resolveLazyCallQueue(t)},n.prototype._waitForWebSocketOpenToResolveLazyQueue=function(t){var e=this;this._waitingForWebSocketOpenFlushScope=this._mergeLazyCallScope(this._waitingForWebSocketOpenFlushScope,t),this.commandRouter.websocketClient.isOpen?this._resolveLazyCallQueueAfterWebSocketOpen():this._webSocketOpenFlushContext||(this._webSocketOpenFlushContext=this.commandRouter.websocketClient.once("open",(function(){e._resolveLazyCallQueueAfterWebSocketOpen()})),this._webSocketOpenFlushTimeout=setTimeout((function(){var r=e._clearWebSocketOpenFlushWait();e._resolveLazyCallQueue(r)}),pr),this.commandRouter.websocketClient.isOpen&&this._resolveLazyCallQueueAfterWebSocketOpen())},n.prototype._resolveLazyCallQueue=function(t){var e=this;t===void 0&&(t=We.ALL);var r=K(this._classifyLazyCallQueueByScope(t),2),i=r[0],s=r[1];this._lazyCallQueue=s;var a=[];i.forEach((function(o){return f(e,void 0,void 0,(function(){var u,c,l,d,_,h=this;return p(this,(function(v){switch(v.label){case 0:if(u=o.command,c=o.deferred,l=o.timeout,u instanceof qe&&!this.commandRouter.websocketClient.isOpen)return o.timeout||(o.timeout=setTimeout((function(){return h.timeout(u.requestId)}),pr)),a.push(o),[2];l&&clearTimeout(l),v.label=1;case 1:return v.trys.push([1,3,,4]),[4,this.send(u)];case 2:return d=v.sent(),c.resolve(d),[3,4];case 3:return _=v.sent(),c.reject(_),[3,4];case 4:return[2]}}
2))}))})),a.length>0&&(this._lazyCallQueue=a.concat(this._lazyCallQueue),this._waitForWebSocketOpenToResolveLazyQueue(t))},n.prototype._rejectLazyCallQueue=function(t,e){var r=this;e===void 0&&(e=We.ALL),e!==We.API&&this._clearWebSocketOpenFlushWait();var i=K(this._classifyLazyCallQueueByScope(e),2),s=i[0],a=i[1];this._lazyCallQueue=a,s.forEach((function(o){return f(r,void 0,void 0,(function(){var u,c;return p(this,(function(l){return u=o.deferred,c=o.timeout,clearTimeout(c),u.reject(t),[2]}))}))}))},n.prototype.send=function(t){return f(this,void 0,void 0,(function(){var e,r,i=this;return p(this,(function(s){switch(s.label){case 0:return t instanceof qe?this.isReady?(this._logger.debug("send websocket request",t),[4,this.commandRouter.send(t)]):[3,2]:[3,4];case 1:case 5:case 7:return[2,s.sent()];case 2:if(this.isLazyCallActivated)return this._logger.debug("wait websocket request",t),e=new De,this._lazyCallQueue.push({command:t,deferred:e,timeout:setTimeout((function(){return i.timeout(t.requestId)}),pr)}),[2,e.promise];throw this._logger.debug("fail websocket request"),T.connectionRequired;case 3:case 9:return[3,11];case 4:return t instanceof O?this._session.hasSession?(this._logger.debug("send api request",t),[4,this.commandRouter.send(t)]):[3,6]:[3,10];case 6:return t.hasSessionKey?(this._logger.debug("send api request with tmp session key",t),[4,this.commandRouter.send(t)]):[3,8];case 8:if(this.isLazyCallActivated)return this._logger.debug("wait api request",t),e=new De,this._lazyCallQueue.push({command:t,deferred:e,timeout:setTimeout((function(){return i.timeout(t.requestId)}),pr)}),[2,e.promise];throw r=T.connectionRequired,this._logger.debug("fail api request",r),r;case 10:throw T.invalidCommand;case 11:return[2]}}
2))}))},n.prototype.forceSend=function(t){return f(this,void 0,void 0,(function(){return p(this,(function(e){switch(e.label){case 0:return this._logger.debug("send forced request",t),t instanceof qe||t instanceof O?[4,this.commandRouter.send(t)]:[3,2];case 1:return[2,e.sent()];case 2:throw T.invalidCommand}}))}))},n.prototype.timeout=function(t){this._logger.debug("timeout request",t);var e=this._lazyCallQueue.findIndex((function(r){return r.command.requestId===t}));e>-1&&(this._lazyCallQueue[e].deferred.reject(T.connectionRequired),this._lazyCallQueue.splice(e,1))},n.prototype.cancel=function(t,e){this._logger.debug("cancel api request",t),this.commandRouter.cancel(t,e)},n.prototype.cancelAll=function(t){this._logger.debug("cancel all api requests"),this.commandRouter.cancelAll(t)},n})(),Si="sendbird@devicetokens",Ci=(function(){function n(t){var e=t.type,r=t.token,i=t.device_os,s=t.device_manufacturer,a=t.system_push_enabled;this.type=e,this.token=r,this.deviceOS=i,this.deviceManufacturer=s,this.systemPushEnabled=a}return n.payloadify=function(t){return M(B({type:t.type,token:t.token,device_os:t.deviceOS,device_manufacturer:t.deviceManufacturer,system_push_enabled:t.systemPushEnabled}))},n})(),Ai=new WeakMap,bl=(function(n){function t(e){var r=e._iid,i=e.session,s=e.cacheContext,a=e.sdkState,o=e.dispatcher,u=e.requestQueue,c=e.logger,l=e.pushNotificationAckManager,d=n.call(this)||this;return d._currentConnectionStateType=X.INITIALIZED,d._isRefreshingAuthToken=!1,d.currentUser=null,d.session=i,d._iid=r,d._cacheContext=s,d._sdkState=a,d._dispatcher=o,d._requestQueue=u,d._logger=c,d._pushNotificationAckManager=l,d._deviceTokens=[],d._dispatcher.on((function(_){var h,v,m,y,b;if(_ instanceof yn){var w=_.stateType;d._currentConnectionStateType=w}else if(_ instanceof dn&&!d.isSessionKeyRefreshing){if(d._currentConnectionStateType===X.CONNECTING)return;!((h=_.error)===null||h===void 0)&&h.isSessionInvalidatedError?d.clear():(!((v=_.error)===null||v===void 0)&&v.isSessionTokenExpiredError&&d.refreshAuthToken().catch((function(I){if(tt(I)&&d._sdkState.appState==="foreground")throw I})),!((m=_.error)===null||m===void 0)&&m.isSessionKeyExpiredError&&(d._logger.debug("session expired"),(b=(y=d.handler)===null||y===void 0?void 0:y.onSessionExpired)===null||b===void 0||b.call(y),d._currentConnectionStateType===X.CONNECTED&&d._dispatcher.dispatch(new St(new de({type:te.WEBSOCKET_DISCONNECT,data:{success:!0,error_code:L.SESSION_KEY_EXPIRED,error_description:"cause=session_expired"}}))),d.refreshSessionKey().catch((function(I){if(tt(I)&&d._sdkState.appState==="foreground")throw I}))))}})),d}return g(t,n),Object.defineProperty(t.prototype,"ekey",{get:function(){return Ai.get(this)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"deviceTokens",{get:function(){return this._deviceTokens},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"deviceTokenLastDeletedAt",{get:function(){return this._deviceTokenLastDeletedAt},enumerable:!1,configurable:!0}),t.prototype.indexOfDeviceToken=function(e,r){return this._deviceTokens.findIndex((function(i){return i.type===e&&i.token===r}))},t.prototype.hasDeviceToken=function(e,r){return this.indexOfDeviceToken(e,r)>=0},t.prototype.createRefreshWebsocketCommand=function(e,r){return new Qu({authToken:e,expiringSession:!0,requestId:r})},t.prototype._refreshSessionKeyByWebSocket=function(e){return f(this,void 0,void 0,(function(){var r,i,s,a,o;return p(this,(function(u){switch(u.label){case 0:return r=this.createRefreshWebsocketCommand(e),[4,this._requestQueue.forceSend(r)];case 1:if(i=u.sent(),s=i.as(Wu),a=s.newKey,o=s.error)throw o;return this.session.sessionKey=a!=null?a:this.session.sessionKey,[2]}}))}))},t.prototype._refreshSessionKeyByApi=function(e){return f(this,void 0,void 0,(function(){var r,i=this;return p(this,(function(s){switch(s.label){case 0:return r=new os({userId:this._sdkState.userId,authToken:e,services:this.session.services&&this.session.services.length>0?this.session.services:void 0,expiringSession:!0}),[4,fs((function(a){return f(i,void 0,void 0,(function(){var o,u,c,l,d;return p(this,(function(_){switch(_.label){case 0:return _.trys.push([0,2,,3]),[4,this._requestQueue.forceSend(r)];case 1:return o=_.sent(),u=o.as($u),c=u.key,l=u.services,this.session.sessionKey=c,this.session.services=l,[3,3];case 2:if(d=_.sent(),!this._isSessionRelatedError(d))throw d;return a(d),[3,3];case 3:return[2]}}
2))}))}),3)];case 1:return s.sent(),[2]}}))}))},t.prototype._refreshSessionKey=function(e,r){return r===void 0&&(r=!0),f(this,void 0,void 0,(function(){var i,s;return p(this,(function(a){switch(a.label){case 0:if(this._currentConnectionStateType!==X.CONNECTED)return[3,8];a.label=1;case 1:return a.trys.push([1,3,,8]),[4,this._refreshSessionKeyByWebSocket(e)];case 2:return a.sent(),this.complete(),[2];case 3:i=a.sent(),a.label=4;case 4:return a.trys.push([4,6,,7]),[4,this._handleSessionRefreshError(i,r)];case 5:return a.sent(),[2];case 6:return a.sent(),[3,7];case 7:return[3,8];case 8:return a.trys.push([8,10,,12]),[4,this._refreshSessionKeyByApi(e)];case 9:return a.sent(),this.complete(),[3,12];case 10:return s=a.sent(),[4,this._handleSessionRefreshError(s,r)];case 11:return a.sent(),[3,12];case 12:return[2]}}))}))},t.prototype._receiveNewAuthToken=function(){var e,r=this,i=new De;if(this._isRefreshingAuthToken=!0,this.session.sessionKey=void 0,this.session.authToken=void 0,(e=this.handler)===null||e===void 0?void 0:e.onSessionTokenRequired){var s=null,a=function(){s&&(clearTimeout(s),s=null)},o=function(c){a(),r._isRefreshingAuthToken&&(r._isRefreshingAuthToken=!1,i.resolve(c))},u=function(c){a(),r._isRefreshingAuthToken&&(r._isRefreshingAuthToken=!1,i.reject(c))};s=setTimeout((function(){return u()}),1e3*this._sdkState.sessionTokenRefreshTimeout),ue((function(){return f(r,void 0,void 0,(function(){var c;return p(this,(function(l){return!((c=this.handler)===null||c===void 0)&&c.onSessionTokenRequired&&this.handler.onSessionTokenRequired(o,u),[2]}))}))}))}else this._isRefreshingAuthToken=!1,i.resolve(null);return i.promise},t.prototype._handleSessionRefreshError=function(e,r){return r===void 0&&(r=!1),f(this,void 0,void 0,(function(){var i;return p(this,(function(s){switch(s.label){case 0:return e instanceof T&&(e.isSessionTokenExpiredError||e.code===L.APPLICATION_NOT_FOUND)?(this.session.authToken=void 0,r?[4,this._receiveNewAuthToken()]:[3,6]):[3,6];case 1:return(i=s.sent())?(this.session.authToken=i,[4,this._refreshSessionKey(this.session.authToken,!1)]):[3,3];case 2:return s.sent(),[3,5];case 3:return[4,this.clear()];case 4:s.sent(),s.label=5;case 5:return[2];case 6:throw e}}))}))},t.prototype._isSessionRelatedError=function(e){return e instanceof T&&(e.isSessionExpiredError||e.isSessionInvalidatedError)},Object.defineProperty(t.prototype,"isSessionKeyRefreshing",{get:function(){return this.session.isRefreshing},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isRefreshingAuthToken",{get:function(){return this._isRefreshingAuthToken},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isSessionExpiring",{get:function(){return!!this.handler},enumerable:!1,configurable:!0}),t.prototype.authenticate=function(e,r){var i;return f(this,void 0,void 0,(function(){var s,a,o,u,c;return p(this,(function(l){switch(l.label){case 0:return this.session.authToken=r,s=0,[4,this._cacheContext.preference.get(jr(this._sdkState.appId))];case 1:return(a=l.sent())&&(s=a.configTs),o=new $o({appId:this._sdkState.appId,userId:e,includeUIKitConfig:!!((i=this._sdkState.extensions)!==null&&i!==void 0?i:{}).sb_uikit,localCacheEnabled:this._cacheContext.localCacheEnabled,expiringSession:this.isSessionExpiring,configTs:s}),[4,this._requestQueue.commandRouter.send(o)];case 2:return u=l.sent(),(c=u.as(ml).logi).error?[3,5]:this.session.hasChatServicePermission?[3,4]:[4,c.applyTo(this._iid)];case 3:l.sent(),l.label=4;case 4:return[3,6];case 5:throw c.error;case 6:return[2]}}
2))}))},t.prototype.login=function(e){var r;return f(this,void 0,void 0,(function(){var i,s,a,o,u,c,l,d;return p(this,(function(_){switch(_.label){case 0:return i=e.key,s=e.ekey,a=e.services,o=e.userProfile,u=e.deviceTokenLastDeletedAt,c=u===void 0?0:u,this.session.sessionKey=i,this.session.services=a,Ai.set(this,s),this._deviceTokenCacheEnabled=(r=o==null?void 0:o.appInfo)===null||r===void 0?void 0:r.deviceTokenCache,l=this._cacheContext.preference,this._deviceTokenCacheEnabled?[4,l.get(Si)]:[3,5];case 1:return!(d=_.sent())||d.lastDeletedAt<c?(this._deviceTokens=[],this._deviceTokenLastDeletedAt=c,[4,this.saveDeviceToken()]):[3,3];case 2:return _.sent(),[3,4];case 3:this._deviceTokens=d.tokens.map((function(h){return new Ci(Ci.payloadify(h))})),this._deviceTokenLastDeletedAt=d.lastDeletedAt,_.label=4;case 4:return[3,7];case 5:return[4,l.remove(Si)];case 6:_.sent(),_.label=7;case 7:return[2]}}))}))},t.prototype.complete=function(){var e=this;this.dispatch("refresh"),this._dispatcher.dispatch(new qo),ue((function(){return f(e,void 0,void 0,(function(){var r;return p(this,(function(i){return this._logger.debug("session refreshed"),!((r=this.handler)===null||r===void 0)&&r.onSessionRefreshed&&this.handler.onSessionRefreshed(),[2]}))}))}))},t.prototype.error=function(e){var r=this;ue((function(){return f(r,void 0,void 0,(function(){var i;return p(this,(function(s){return!((i=this.handler)===null||i===void 0)&&i.onSessionError&&this.handler.onSessionError(e),[2]}))}))}))},t.prototype.close=function(){var e=this;this.dispatch("close"),this._dispatcher.dispatch(new zo),ue((function(){return f(e,void 0,void 0,(function(){var r;return p(this,(function(i){return this._logger.debug("session closed"),!((r=this.handler)===null||r===void 0)&&r.onSessionClosed&&this.handler.onSessionClosed(),[2]}))}))}))},t.prototype.refreshAuthToken=function(){return f(this,void 0,void 0,(function(){var e,r;return p(this,(function(i){switch(i.label){case 0:if(e=null,this.session.isRefreshing)return[3,9];this.session.isRefreshing=!0,i.label=1;case 1:return i.trys.push([1,7,8,9]),[4,this._receiveNewAuthToken()];case 2:return(e=i.sent())?(this._logger.debug("session refreshing.."),this.session.authToken=e,[4,this._refreshSessionKey(this.session.authToken)]):[3,4];case 3:return i.sent(),[3,6];case 4:return[4,this.clear()];case 5:i.sent(),i.label=6;case 6:return[3,9];case 7:throw i.sent(),r=e?T.sessionTokenRefreshFailed:T.sessionTokenRequestFailed,this._dispatcher.dispatch(new Wi),this.error(r),this._logger.debug("refresh auth token error = ",r),r;case 8:return this.session.isRefreshing=!1,[7];case 9:return[2]}}
2))}))},t.prototype.refreshSessionKey=function(){return f(this,void 0,void 0,(function(){var e;return p(this,(function(r){switch(r.label){case 0:if(this.session.isRefreshing)return[3,5];this.session.isRefreshing=!0,r.label=1;case 1:return r.trys.push([1,3,4,5]),[4,this._refreshSessionKey(this.session.authToken)];case 2:return r.sent(),[3,5];case 3:throw r.sent(),e=T.sessionTokenRefreshFailed,this._dispatcher.dispatch(new Wi),this.error(e),e;case 4:return this.session.isRefreshing=!1,[7];case 5:return[2]}}))}))},t.prototype.setDeviceToken=function(e,r,i){if(this._deviceTokenCacheEnabled&&this.indexOfDeviceToken(e,r)<0){var s=new Ci({type:e,token:r,device_os:i==null?void 0:i.deviceOS,device_manufacturer:i==null?void 0:i.deviceManufacturer,system_push_enabled:i==null?void 0:i.systemPushEnabled});return this._deviceTokens.push(s),!0}return!1},t.prototype.unsetDeviceToken=function(e,r){if(this._deviceTokenCacheEnabled){var i=this.indexOfDeviceToken(e,r);i>=0&&this._deviceTokens.splice(i,1)}},t.prototype.unsetDeviceTokens=function(e){this._deviceTokenCacheEnabled&&(this._deviceTokens=e?this._deviceTokens.filter((function(r){return r.type!==e})):[])},t.prototype.setDeviceTokenDeletedAt=function(e){e>0&&(this._deviceTokenLastDeletedAt=e)},t.prototype.saveDeviceToken=function(){return f(this,void 0,void 0,(function(){return p(this,(function(e){switch(e.label){case 0:return this._deviceTokenCacheEnabled?[4,this._cacheContext.preference.set(Si,{tokens:this._deviceTokens,lastDeletedAt:this._deviceTokenLastDeletedAt})]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}
2))}))},t.prototype.clear=function(){return f(this,void 0,void 0,(function(){return p(this,(function(e){switch(e.label){case 0:return this.currentUser=null,this.session.clear(),this.close(),Ai.delete(this),this._deviceTokens=[],this._deviceTokenLastDeletedAt=0,[4,this.saveDeviceToken()];case 1:return e.sent(),this._pushNotificationAckManager.clear(),[2]}}))}))},t})(mn),Wo=function(n,t){var e,r;if(n!==null&&t!==null){var i=Object.keys(n),s=Object.keys(t),a=V([],K(new Set(V(V([],K(i),!1),K(s),!1))),!1),o={};try{for(var u=z(a),c=u.next();!c.done;c=u.next()){var l=c.value,d=typeof n[l],_=typeof t[l];d==="undefined"?o[l]=t[l]:_==="undefined"?o[l]=n[l]:d!==_?o[l]=t[l]:d==="object"&&n[l]&&t[l]?o[l]=Wo(n[l],t[l]):o[l]=t[l]}}catch(h){e={error:h}}finally{try{c&&!c.done&&(r=u.return)&&r.call(u)}finally{if(e)throw e.error}}return o}return t};(function(n){n[n.PENDING=0]="PENDING",n[n.COLLECT_ONLY=1]="COLLECT_ONLY",n[n.ENABLED=2]="ENABLED",n[n.DISABLED=3]="DISABLED"})(Q||(Q={})),(function(n){n.DAILY="daily",n.DEFAULT="default",n.REALTIME="realtime"})(ca||(ca={}));var Kr,Xr=(function(){function n(t){var e=t.deviceId,r=t.cacheContext,i=t.requestQueue;this.queue=[],this.flushWaitQueue=[],this.enabledState=Q.PENDING,this.isFlushing=!1,this._sentLogStats=[],this.deviceId=e,this.cacheContext=r,this.requestQueue=i,this.logInfo={deviceId:e,statLogs:[],generation:1,lastFlushedAt:0},this.limit=er}return Object.defineProperty(n.prototype,"isEnabled",{get:function(){return this.enabledState===Q.ENABLED},enumerable:!1,configurable:!0}),n.prototype.init=function(t){return f(this,void 0,void 0,(function(){var e;return p(this,(function(r){switch(r.label){case 0:return this.key=t,[4,this.cacheContext.preference.get(this.key)];case 1:return(e=r.sent())&&(this.logInfo=e),[2]}}))}))},n.prototype._mergeQueue=function(){this.flushWaitQueue.length>0&&(this.queue=this.queue.concat(this.flushWaitQueue),this.flushWaitQueue=[])},n.prototype._isDuplicateStat=function(t){var e=this._sentLogStats.find((function(r){var i;return r.channelUrl===t.data.channel_url&&r.messageId===((i=t.data.notificationId)!==null&&i!==void 0?i:t.data.message_id)&&r.action===t.data.action}));return e||this._sentLogStats.push({channelUrl:t.data.channel_url,messageId:t.data.message_id,action:t.data.action}),!!e},n.prototype._save=function(){return f(this,void 0,void 0,(function(){var t;return p(this,(function(e){switch(e.label){case 0:return t=V(V([],K(this.queue),!1),K(this.flushWaitQueue),!1),[4,this.cacheContext.preference.set(this.key,{deviceId:this.logInfo.deviceId,statLogs:t.map((function(r){return de.payloadify(r)})),generation:this.logInfo.generation++,lastFlushedAt:this.logInfo.lastFlushedAt})];case 1:return e.sent(),[2]}}))}))},n.prototype.clear=function(){return f(this,void 0,void 0,(function(){return p(this,(function(t){return this.queue=[],this.flushWaitQueue=[],this.logInfo.generation=1,this._save(),[2]}))}))},n})(),Zi=(function(n){function t(e){var r,i,s,a,o=e.type,u=e.data,c=e.ts,l=c===void 0?Date.now():c,d=n.call(this,{type:o,data:u,ts:l})||this;return d.date=new Date(l),d.key="".concat((r=d.date,i=r.getFullYear(),s=String(r.getMonth()+1).padStart(2,"0"),a=String(r.getDate()).padStart(2,"0"),"".concat(i).concat(s).concat(a)),"_").concat(o),d}return g(t,n),t})(de),Yo=(function(n){function t(e){var r=e.deviceId,i=e.statLogs,s=n.call(this)||this;return s.method=k.POST,s.path="".concat(zu),s.params={device_id:r,log_entries:i.map((function(a){return de.payloadify(a)}))},s}return g(t,n),t})(O),El=(function(n){function t(e){var r=e.deviceId,i=e.cacheContext,s=e.requestQueue;return n.call(this,{deviceId:r,cacheContext:i,requestQueue:s})||this}return g(t,n),Object.defineProperty(t.prototype,"_isSendable",{get:function(){return this.queue.length!==0&&Date.now()-this.logInfo.lastFlushedAt>=this.statConfig.minInterval},enumerable:!1,configurable:!0}),t.prototype.init=function(e){return f(this,void 0,void 0,(function(){return p(this,(function(r){switch(r.label){case 0:return[4,n.prototype.init.call(this,e+".daily")];case 1:return r.sent(),this.queue=this.logInfo.statLogs.map((function(i){return new de({type:i.stat_type,ts:i.ts,data:i.data})})),[2]}}))}))},t.prototype.setConfig=function(e,r){return f(this,void 0,void 0,(function(){var i,s,a,o;return p(this,(function(u){switch(u.label){case 0:return this.statConfig=e,this._mergeQueue(),r.localCacheStat?(this.enabledState=r.enabledStat?Q.ENABLED:Q.COLLECT_ONLY,[3,3]):[3,1];case 1:return this.enabledState=Q.DISABLED,[4,this.clear()];case 2:u.sent(),u.label=3;case 3:return this.isEnabled&&this._isSendable?[4,this._getUploadStats()]:[3,9];case 4:i=u.sent(),s=Math.max(Math.floor(Math.random()*this.statConfig.requestDelayRange),Yr),a=0,u.label=5;case 5:return a<i.length?(o=i.slice(a,1+this.statConfig.maxStatCountPerRequest),[4,Ue(s)]):[3,9];case 6:return u.sent(),[4,this._flush(o)];case 7:u.sent(),u.label=8;case 8:return a+=this.statConfig.maxStatCountPerRequest,[3,5];case 9:return[2]}}
2))}))},t.prototype.put=function(e){return f(this,void 0,void 0,(function(){var r,i,s,a;return p(this,(function(o){switch(o.label){case 0:return this.enabledState===Q.DISABLED?[2,!0]:(r=this.enabledState===Q.PENDING||this.isFlushing?this.flushWaitQueue:this.queue,i=K(r.filter((function(u){return u instanceof Zi&&u.key===e.key})),1),(s=i[0])?s.data=Wo(s.data,e.data):r.push(e),this.enabledState===Q.PENDING?[3,2]:[4,this._save()]);case 1:o.sent(),o.label=2;case 2:return this.isEnabled?(this._mergeQueue(),this._isSendable?[4,this._getUploadStats()]:[3,5]):[3,5];case 3:return a=o.sent(),[4,this._flush(a)];case 4:return[2,o.sent()];case 5:return[2,!0]}}))}))},t.prototype._getUploadStats=function(){return f(this,void 0,void 0,(function(){var e;return p(this,(function(r){return e=this.queue.filter((function(i){if(i instanceof Zi){var s=new Date,a=K([i.date.getFullYear(),s.getFullYear()],2),o=a[0],u=a[1];if(o<u)return!0;if(o===u){var c=K([i.date.getMonth(),s.getMonth()],2),l=c[0],d=c[1];if(l<d)return!0;if(l===d){var _=K([i.date.getDate(),s.getDate()],2);return _[0]<_[1]}}}return!1})),[2,e]}))}))},t.prototype._flush=function(e){return f(this,void 0,void 0,(function(){var r,i,s,a;return p(this,(function(o){switch(o.label){case 0:if(r=!0,!(e.length>0))return[3,10];if(this.isFlushing)return[3,9];this.isFlushing=!0,o.label=1;case 1:return o.trys.push([1,4,8,9]),i=V([],K(e),!1).slice(0,Math.min(this.limit,this.statConfig.maxStatCountPerRequest)),s=new Yo({deviceId:this.deviceId,statLogs:i}),[4,this.requestQueue.send(s)];case 2:return o.sent(),this.queue=V([],K(e),!1).slice(i.length).concat(this.flushWaitQueue),this.flushWaitQueue=[],this.limit=er,this.logInfo.lastFlushedAt=Date.now(),[4,this._save()];case 3:return o.sent(),[3,9];case 4:return(a=o.sent())instanceof T?a.code!==L.NON_AUTHORIZED?[3,6]:[4,this.clear()]:[3,7];case 5:return o.sent(),this.enabledState=Q.DISABLED,[3,7];case 6:a.code===L.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=Q.COLLECT_ONLY),o.label=7;case 7:return this.limit=this.limit+20,r=!1,[3,9];case 8:return this.isFlushing=!1,[7];case 9:return[3,11];case 10:this.isFlushing=!1,o.label=11;case 11:return[2,r]}}))}))},t})(Xr),wl=(function(n){function t(e){var r=e.deviceId,i=e.cacheContext,s=e.requestQueue;return n.call(this,{deviceId:r,cacheContext:i,requestQueue:s})||this}return g(t,n),t.prototype._isSendable=function(e){if(e===void 0&&(e=!1),this.queue.length<this.statConfig.lowerThreshold)return!1;if(e){if(Date.now()-this.logInfo.lastFlushedAt<this.statConfig.minInterval)return!1}else if(this.queue.length<this.statConfig.minStatCount)return!1;return!0},t.prototype._filterQueueByType=function(e,r){return f(this,void 0,void 0,(function(){return p(this,(function(i){return[2,r?e.filter((function(s){return s.type!==te.FEATURE_LOCALCACHE_EVENT})):e.filter((function(s){return s.type===te.FEATURE_LOCALCACHE_EVENT}))]}))}))},t.prototype.init=function(e){return f(this,void 0,void 0,(function(){return p(this,(function(r){switch(r.label){case 0:return[4,n.prototype.init.call(this,e+".default")];case 1:return r.sent(),this.queue=this.logInfo.statLogs.map((function(i){return i.data=E({message_init_policy:"",starting_point:0},i.data),new de({type:i.stat_type,ts:i.ts,data:i.data})})),[2]}}))}))},t.prototype.setConfig=function(e,r){return f(this,void 0,void 0,(function(){var i,s,a,o;return p(this,(function(u){switch(u.label){case 0:return this.statConfig=e,this._mergeQueue(),r.requestStat||r.localCacheStat?(this.enabledState=r.enabledStat?Q.ENABLED:Q.COLLECT_ONLY,i=void 0,r.requestStat||(i=!1),r.localCacheStat||(i=!0),i===void 0?[3,3]:(s=this,[4,this._filterQueueByType(this.queue,i)])):[3,4];case 1:return s.queue=u.sent(),a=this,[4,this._filterQueueByType(this.flushWaitQueue,i)];case 2:a.flushWaitQueue=u.sent(),this._save(),u.label=3;case 3:return[3,6];case 4:return this.enabledState=Q.DISABLED,[4,this.clear()];case 5:u.sent(),u.label=6;case 6:return this.isEnabled&&this._isSendable(!0)?(o=Math.max(Math.floor(Math.random()*this.statConfig.requestDelayRange),Yr),[4,Ue(o)]):[3,9];case 7:return u.sent(),[4,this._flush(this.queue)];case 8:u.sent(),u.label=9;case 9:return[2]}}
2))}))},t.prototype.put=function(e){return f(this,void 0,void 0,(function(){var r;return p(this,(function(i){switch(i.label){case 0:return this.enabledState===Q.DISABLED?[2,!0]:((r=this.enabledState===Q.PENDING||this.isFlushing?this.flushWaitQueue:this.queue).push(e),this.enabledState===Q.PENDING?[3,2]:[4,this._save()]);case 1:i.sent(),i.label=2;case 2:return this.isEnabled?(this._mergeQueue(),this._isSendable()?[4,this._flush(r)]:[3,4]):[3,4];case 3:return[2,i.sent()];case 4:return[2,!0]}}))}))},t.prototype._flush=function(e){return f(this,void 0,void 0,(function(){var r,i,s,a;return p(this,(function(o){switch(o.label){case 0:if(r=!0,!(e.length>0))return[3,10];if(this.isFlushing)return[3,9];this.isFlushing=!0,o.label=1;case 1:return o.trys.push([1,4,8,9]),i=V([],K(e),!1).slice(0,Math.min(this.limit,this.statConfig.maxStatCountPerRequest)),s=new Yo({deviceId:this.deviceId,statLogs:i}),[4,this.requestQueue.send(s)];case 2:return o.sent(),this.queue=V([],K(e),!1).slice(i.length).concat(this.flushWaitQueue),this.flushWaitQueue=[],this.limit=er,this.logInfo.lastFlushedAt=Date.now(),[4,this._save()];case 3:return o.sent(),[3,9];case 4:return(a=o.sent())instanceof T?a.code!==L.NON_AUTHORIZED?[3,6]:[4,this.clear()]:[3,7];case 5:return o.sent(),this.enabledState=Q.DISABLED,[3,7];case 6:a.code===L.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=Q.COLLECT_ONLY),o.label=7;case 7:return this.limit=this.limit+20,r=!1,[3,9];case 8:return this.isFlushing=!1,[7];case 9:return[3,11];case 10:this.isFlushing=!1,o.label=11;case 11:return[2,r]}}))}))},t})(Xr),Il=(function(n){function t(e){var r=e.deviceId,i=e.statLogs,s=n.call(this)||this;return s.method=k.POST,s.path="".concat(Bu),s.params={device_id:r,log_entries:i.map((function(a){return de.payloadify(a)}))},s}return g(t,n),t})(O),Tl=(function(n){function t(e){var r=e.deviceId,i=e.cacheContext,s=e.requestQueue;return n.call(this,{deviceId:r,cacheContext:i,requestQueue:s})||this}return g(t,n),Object.defineProperty(t.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}),t.prototype.init=function(e){return f(this,void 0,void 0,(function(){return p(this,(function(r){switch(r.label){case 0:return[4,n.prototype.init.call(this,e+".realtime")];case 1:return r.sent(),this.queue=this.logInfo.statLogs.map((function(i){var s;return i.data=M(E(E({},i.data),{message_id:(s=i.data.notificationId)!==null&&s!==void 0?s:i.data.message_id,notificationId:void 0})),new de({type:i.stat_type,ts:i.ts,data:i.data})})),this._sentLogStats=this.queue.map((function(i){var s;return{channelUrl:i.data.channelUrl,messageId:(s=i.data.notificationId)!==null&&s!==void 0?s:i.data.message_id,action:i.data.action}})),[2]}}))}))},t.prototype.setConfig=function(e,r){return f(this,void 0,void 0,(function(){var i;return p(this,(function(s){switch(s.label){case 0:return this.statConfig=e,this._mergeQueue(),r.notificationStat?(this.enabledState=r.enabledStat?Q.ENABLED:Q.COLLECT_ONLY,[3,3]):[3,1];case 1:return this.enabledState=Q.DISABLED,[4,this.clear()];case 2:s.sent(),s.label=3;case 3:return this.isEnabled&&this._isSendable?(i=Math.max(Math.floor(Math.random()*this.statConfig.requestDelayRange),Yr),[4,Ue(i)]):[3,6];case 4:return s.sent(),[4,this._flush(this.queue)];case 5:s.sent(),s.label=6;case 6:return[2]}}
2))}))},t.prototype.put=function(e){return f(this,void 0,void 0,(function(){var r;return p(this,(function(i){switch(i.label){case 0:return this.enabledState===Q.DISABLED?[2,!0]:(r=this.enabledState===Q.PENDING||this.isFlushing?this.flushWaitQueue:this.queue,this._isDuplicateStat(e)?[2,!0]:(r.push(e),this.enabledState===Q.PENDING?[3,2]:[4,this._save()]));case 1:i.sent(),i.label=2;case 2:return this.isEnabled?(this._mergeQueue(),this.isEnabled&&this._isSendable?[4,this._flush(r)]:[3,4]):[3,4];case 3:return[2,i.sent()];case 4:return[2,!0]}}))}))},t.prototype._flush=function(e){return f(this,void 0,void 0,(function(){var r,i,s,a;return p(this,(function(o){switch(o.label){case 0:if(r=!0,!(e.length>0))return[3,10];if(this.isFlushing)return[3,9];this.isFlushing=!0,o.label=1;case 1:return o.trys.push([1,4,8,9]),i=V([],K(e),!1).slice(0,Math.min(this.limit,this.statConfig.maxStatCountPerRequest)),s=new Il({deviceId:this.deviceId,statLogs:i}),[4,this.requestQueue.send(s)];case 2:return o.sent(),this.queue=V([],K(e),!1).slice(i.length).concat(this.flushWaitQueue),this.flushWaitQueue=[],this.limit=er,this.logInfo.lastFlushedAt=Date.now(),[4,this._save()];case 3:return o.sent(),[3,9];case 4:return(a=o.sent())instanceof T?a.code!==L.NON_AUTHORIZED?[3,6]:[4,this.clear()]:[3,7];case 5:return o.sent(),this.enabledState=Q.DISABLED,[3,7];case 6:a.code===L.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=Q.COLLECT_ONLY),o.label=7;case 7:return this.limit=this.limit+20,r=!1,[3,9];case 8:return this.isFlushing=!1,[7];case 9:return[3,11];case 10:this.isFlushing=!1,o.label=11;case 11:return[2,r]}}))}))},t})(Xr),Sl=(function(n){function t(e){var r=e.deviceId,i=e.statLogs,s=n.call(this)||this;return s.method=k.POST,s.path="".concat(ju),s.params={device_id:r,log_entries:i.map((function(a){return de.payloadify(a)}))},s}return g(t,n),t})(O),Zo=(function(n){function t(e){var r=e.deviceId,i=e.cacheContext,s=e.requestQueue;return n.call(this,{deviceId:r,cacheContext:i,requestQueue:s})||this}return g(t,n),Object.defineProperty(t.prototype,"storageSuffix",{get:function(){return".aiagent"},enumerable:!1,configurable:!0}),t.prototype.isCollectorEnabled=function(e){return!!e.aiAgentStat},t.prototype._isSendable=function(e){if(e===void 0&&(e=!1),this.queue.length<this.statConfig.lowerThreshold)return!1;if(e){if(Date.now()-this.logInfo.lastFlushedAt<this.statConfig.minInterval)return!1}else if(this.queue.length<this.statConfig.minStatCount)return!1;return!0},t.prototype.init=function(e){return f(this,void 0,void 0,(function(){return p(this,(function(r){switch(r.label){case 0:return[4,n.prototype.init.call(this,e+this.storageSuffix
2)];case 1:return r.sent(),this.queue=this.logInfo.statLogs.map((function(i){return new de({type:i.stat_type,ts:i.ts,data:i.data,runtimeId:i.runtime_id})})),[2]}}))}))},t.prototype.setConfig=function(e,r){return f(this,void 0,void 0,(function(){var i;return p(this,(function(s){switch(s.label){case 0:return this.statConfig=e,this._mergeQueue(),this.isCollectorEnabled(r)?(this.enabledState=r.enabledStat?Q.ENABLED:Q.COLLECT_ONLY,[3,3]):[3,1];case 1:return this.enabledState=Q.DISABLED,[4,this.clear()];case 2:s.sent(),s.label=3;case 3:return this.isEnabled&&this._isSendable(!0)?(i=Math.max(Math.floor(Math.random()*this.statConfig.requestDelayRange),Yr),[4,Ue(i)]):[3,6];case 4:return s.sent(),[4,this._flush(this.queue)];case 5:s.sent(),s.label=6;case 6:return[2]}}))}))},t.prototype.put=function(e){return f(this,void 0,void 0,(function(){var r;return p(this,(function(i){switch(i.label){case 0:return this.enabledState===Q.DISABLED?[2,!0]:((r=this.enabledState===Q.PENDING||this.isFlushing?this.flushWaitQueue:this.queue).push(e),this.enabledState===Q.PENDING?[3,2]:[4,this._save()]);case 1:i.sent(),i.label=2;case 2:return this.isEnabled?(this._mergeQueue(),this._isSendable()?[4,this._flush(r)]:[3,4]):[3,4];case 3:return[2,i.sent()];case 4:return[2,!0]}}))}))},t.prototype._flush=function(e){return f(this,void 0,void 0,(function(){var r,i,s,a;return p(this,(function(o){switch(o.label){case 0:if(r=!0,!(e.length>0))return[3,10];if(this.isFlushing)return[3,9];this.isFlushing=!0,o.label=1;case 1:return o.trys.push([1,4,8,9]),i=V([],K(e),!1).slice(0,Math.min(this.limit,this.statConfig.maxStatCountPerRequest)),s=new Sl({deviceId:this.deviceId,statLogs:i}),[4,this.requestQueue.send(s)];case 2:return o.sent(),this.queue=V([],K(e),!1).slice(i.length).concat(this.flushWaitQueue),this.flushWaitQueue=[],this.limit=er,this.logInfo.lastFlushedAt=Date.now(),[4,this._save()];case 3:return o.sent(),[3,9];case 4:return(a=o.sent())instanceof T?a.code!==L.NON_AUTHORIZED?[3,6]:[4,this.clear()]:[3,7];case 5:return o.sent(),this.enabledState=Q.DISABLED,[3,7];case 6:a.code===L.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=Q.COLLECT_ONLY),o.label=7;case 7:return this.limit=this.limit+20,r=!1,[3,9];case 8:return this.isFlushing=!1,[7];case 9:return[3,11];case 10:this.isFlushing=!1,o.label=11;case 11:return[2,r]}}))}))},t})(Xr),Cl=(function(n){function t(){return n!==null&&n.apply(this,arguments)||this}return g(t,n),Object.defineProperty(t.prototype,"storageSuffix",{get:function(){return".aiagentassertion"},enumerable:!1,configurable:!0}),t.prototype.isCollectorEnabled=function(e){return!!e.aiAgentAssertionStat},t})(Zo),Al=(function(){function n(t){var e=t.cacheContext,r=t.requestQueue,i=t.dispatcher,s=t.logger;this._collectRequestStat=!0,this._collectFeatureLocalCacheStat=!0,this._collectionNotificationStat=!0,this._collectAIAgentStat=!0,this._collectAIAgentAssertionStat=!0,this._retryCount=0,this.deviceId=st(),this.cacheContext=e,this.requestQueue=r,this.dispatcher=i,this.logger=s,this._dailyStatCollector=new El({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue}),this._defaultStatCollector=new wl({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue}),this._notificationStatCollector=new Tl({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue}),this._aiAgentStatCollector=new Zo({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue}),this._aiAgentAssertionStatCollector=new Cl({deviceId:this.deviceId,cacheContext:this.cacheContext,requestQueue:this.requestQueue})}return n.prototype._migration=function(){return f(this,void 0,void 0,(function(){var t,e,r,i;return p(this,(function(s){switch(s.label){case 0:return[4,this.cacheContext.preference.get(this.key)];case 1:return(t=s.sent())?(e=[],t.statLogs.forEach((function(a){a.stat_type===te.FEATURE_LOCALCACHE&&e.push(new de({type:a.stat_type,ts:a.ts,data:a.data}))})),[4,this.cacheContext.preference.set(this.key+".daily",{deviceId:t.deviceId,statLogs:e.map((function(a){return de.payloadify(a)})),generation:t.generation,lastFlushedAt:t.lastFlushedAt})]):[3,6];
2case 2:return s.sent(),r=[],t.statLogs.forEach((function(a){a.stat_type!==te.FEATURE_LOCALCACHE&&a.stat_type!==te.NOTIFICATION&&(a.stat_type===te.FEATURE_LOCALCACHE_EVENT&&(a.data=E({message_init_policy:"",starting_point:0},a.data)),r.push(new de({type:a.stat_type,ts:a.ts,data:a.data})))})),[4,this.cacheContext.preference.set(this.key+".default",{deviceId:t.deviceId,statLogs:r.map((function(a){return de.payloadify(a)})),generation:t.generation,lastFlushedAt:t.lastFlushedAt})];case 3:return s.sent(),i=[],t.statLogs.forEach((function(a){var o;a.stat_type===te.NOTIFICATION&&(a.data=M(E(E({},a.data),{message_id:(o=a.data.notificationId)!==null&&o!==void 0?o:a.data.message_id,notificationId:void 0})),i.push(new de({type:a.stat_type,ts:a.ts,data:a.data})))})),[4,this.cacheContext.preference.set(this.key+".realtime",{deviceId:t.deviceId,statLogs:i.map((function(a){return de.payloadify(a)})),generation:t.generation,lastFlushedAt:t.lastFlushedAt})];case 4:return s.sent(),[4,this.cacheContext.preference.remove(this.key)];case 5:s.sent(),s.label=6;case 6:return[2]}}
2))}))},n.prototype.init=function(t){return f(this,void 0,void 0,(function(){var e=this;return p(this,(function(r){switch(r.label){case 0:return this.key=t,[4,this._migration()];case 1:return r.sent(),[4,this._dailyStatCollector.init(this.key)];case 2:return r.sent(),[4,this._defaultStatCollector.init(this.key)];case 3:return r.sent(),[4,this._notificationStatCollector.init(this.key)];case 4:return r.sent(),[4,this._aiAgentStatCollector.init(this.key)];case 5:return r.sent(),[4,this._aiAgentAssertionStatCollector.init(this.key)];case 6:return r.sent(),this.commandEventContext||(this.commandEventContext=this.dispatcher.on((function(i){return f(e,void 0,void 0,(function(){var s,a,o,u,c,l,d,_;return p(this,(function(h){return i instanceof St?(s=i.statLog,this.put(s)):i instanceof jo&&(a=i.request,o=i.features,u=i.options,c=i.statConfigInfo,this._retryCount=0,this._collectRequestStat=a,this._collectFeatureLocalCacheStat=o==null?void 0:o.localCache,this._collectionNotificationStat=o==null?void 0:o.notification,this._collectAIAgentStat=o==null?void 0:o.aiAgent,this._statConfig=c,this._collectAIAgentAssertionStat=(o==null?void 0:o.aiAgentAssertion)&&!!this._statConfig.aiAgentAssertion,this._dailyStatCollector.setConfig(this._statConfig.daily,{localCacheStat:this._collectFeatureLocalCacheStat,enabledStat:u.ingestion}),this._defaultStatCollector.setConfig(this._statConfig.default,{requestStat:this._collectRequestStat,localCacheStat:this._collectFeatureLocalCacheStat,enabledStat:u.ingestion}),this._notificationStatCollector.setConfig((l=this._statConfig.realTime)!==null&&l!==void 0?l:this._statConfig.default,{notificationStat:this._collectionNotificationStat,enabledStat:u.ingestion}),this._aiAgentStatCollector.setConfig((d=this._statConfig.aiAgentStats)!==null&&d!==void 0?d:this._statConfig.default,{aiAgentStat:this._collectAIAgentStat,enabledStat:u.ingestion}),this._aiAgentAssertionStatCollector.setConfig((_=this._statConfig.aiAgentAssertion)!==null&&_!==void 0?_:this._statConfig.default,{aiAgentAssertionStat:this._collectAIAgentAssertionStat,enabledStat:u.ingestion})),[2]}))}))}))),[2]}}))}))},n.prototype.put=function(t){return f(this,void 0,void 0,(function(){var e;return p(this,(function(r){switch(r.label){case 0:return e=!0,t instanceof Zi?this._collectFeatureLocalCacheStat?[4,this._dailyStatCollector.put(t)]:[3,2]:[3,3];case 1:e=r.sent(),r.label=2;case 2:return[3,19];case 3:switch(t.type){case te.API_RESULT:case te.WEBSOCKET_CONNECT:case te.WEBSOCKET_DISCONNECT:return[3,4];case te.FEATURE_LOCALCACHE:case te.FEATURE_LOCALCACHE_EVENT:return[3,7];case te.NOTIFICATION:return[3,10];case te.AI_AGENT_SDK_STATS:return[3,13];case te.AI_AGENT_ASSERTION:return[3,16]}return[3,19];case 4:return this._collectRequestStat?[4,this._defaultStatCollector.put(t)]:[3,6];case 5:e=r.sent(),r.label=6;case 6:return[3,19];case 7:return this._collectFeatureLocalCacheStat?[4,this._defaultStatCollector.put(t)]:[3,9];case 8:e=r.sent(),r.label=9;case 9:return[3,19];case 10:return this._collectionNotificationStat?[4,this._notificationStatCollector.put(t)]:[3,12];case 11:e=r.sent(),r.label=12;case 12:return[3,19];case 13:return this._collectAIAgentStat?[4,this._aiAgentStatCollector.put(t)]:[3,15];case 14:e=r.sent(),r.label=15;case 15:return[3,19];case 16:return this._collectAIAgentAssertionStat?[4,this._aiAgentAssertionStatCollector.put(t)]:[3,18];case 17:e=r.sent(),r.label=18;case 18:return[3,19];case 19:return e?this._retryCount=0:(this._retryCount++,this._retryCount>20&&(this._dailyStatCollector.enabledState=Q.COLLECT_ONLY,this._defaultStatCollector.enabledState=Q.COLLECT_ONLY,this._notificationStatCollector.enabledState=Q.COLLECT_ONLY,this._aiAgentStatCollector.enabledState=Q.COLLECT_ONLY,this._aiAgentAssertionStatCollector.enabledState=Q.COLLECT_ONLY,this.logger.debug(T.statLogUploadLimitExceededError))),[2]}}))}))},n.prototype.appendStat=function(t,e,r){if(t===te.AI_AGENT_SDK_STATS&&!this._collectAIAgentStat||t===te.AI_AGENT_ASSERTION&&!this._collectAIAgentAssertionStat||t===te.NOTIFICATION&&!this._collectionNotificationStat||(t===te.API_RESULT||t===te.WEBSOCKET_CONNECT||t===te.WEBSOCKET_DISCONNECT)&&!this._collectRequestStat||(t===te.FEATURE_LOCALCACHE||t===te.FEATURE_LOCALCACHE_EVENT)&&!this._collectFeatureLocalCacheStat)return!1;var i=new de({type:t,ts:Date.now(),data:e,runtimeId:r});return this.put(i),!0},n.prototype.close=function(){this.commandEventContext&&(this.commandEventContext.close(),this.commandEventContext=void 0)},n})(),Nl=(function(){function n(t){var e=t.limit,r=e===void 0?5:e;this.workersByKey={},this.limit=r}return n.prototype.run=function(t,e){return f(this,void 0,void 0,(function(){var r;return p(this,(function(i){switch(i.label){case 0:return this.workersByKey[t]||(this.workersByKey[t]=[]),this.workersByKey[t].length<this.limit?(this.workersByKey[t].push(e),[4,e()]):[3,2];case 1:return r=i.sent(),this.workersByKey[t].pop(),[2,r];case 2:throw T.tooManyRequests}}))}))},n.prototype.clear=function(t){this.workersByKey[t]=[]},n})();(function(n){n.DELIVERY_RECEIPT="delivery_receipt",n.PUSH_ACKNOWLEDGEMENT="push_acknowledgement"})(Kr||(Kr={}));var ne,kl=(function(n){function t(){var e=n!==null&&n.apply(this,arguments)||this;return e._pushAckedCache={},e}return g(t,n),t.prototype.isAcked=function(e,r){var i,s="".concat(e,"_").concat(r);return(i=this._pushAckedCache[s])!==null&&i!==void 0&&i},t.prototype.markAsAcked=function(e,r){var i="".concat(e,"_").concat(r);this._pushAckedCache[i]=!0},t.prototype.clear=function(){C.of(this._iid).logger.debug("clear push acked cache"),this._pushAckedCache={}},t.prototype.parseData=function(e){var r,i,s,a,o=C.of(this._iid).logger,u=e.sendbird;if(typeof u=="string")try{u=JSON.parse(u)}catch(b){throw o.info("push notification payload does not contain sendbird payload in JSON format."),T.malformedDataError}if(!u||typeof u!="object")throw o.info("push notification payload does not contain sendbird payload in JSON format."),T.malformedDataError;var c=(r=u.push_tracking_id)!==null&&r!==void 0?r:"",l=u.notification_message_id,d=u.notification_channel_key,_=u.notification_template_key,h=u.notification_event_deadline,v=(i=u.session_key)!==null&&i!==void 0?i:{},m=(s=v==null?void 0:v.key)!==null&&s!==void 0?s:"",y=(a=v==null?void 0:v.topics)!==null&&a!==void 0?a:[];if(typeof c!="string"||c.length===0)throw o.info("push tracking id is not available"),T.malformedDataError;if(typeof l!="string"||l.length===0)throw o.info("message id is not available"),T.malformedDataError;return{pushTrackingId:c,sessionKey:m,sessionTopics:y,messageId:l,channelKe
2y:d,templateKey:_,notificationEventDeadline:h}},t})(be),ln=function(n){this.name=n.name,this._custom=n.custom,this._usedByModerationEngine=n.used_by_moderation_engine},Ol=(function(n){function t(){var e=n.call(this)||this;return e.method=k.GET,e.path=Hu,e}return g(t,n),t})(O),Dl=(function(n){function t(e,r){var i=n.call(this,e,r)||this;return i.reportCategories=r.categories,i}return g(t,n),t})(U),Rl=(function(n){function t(e){var r=n.call(this,e)||this;return r._categories=[],r}return g(t,n),t.prototype.categories=function(){return f(this,void 0,void 0,(function(){return p(this,(function(e){switch(e.label){case 0:return this._categories.length!==0?[3,2]:[4,this._fetchCategories()];case 1:e.sent(),e.label=2;case 2:return[2,this._categories]}}))}))},t.prototype._fetchCategories=function(){return f(this,void 0,void 0,(function(){var e,r,i,s,a;return p(this,(function(o){switch(o.label){case 0:return e=C.of(this._iid).requestQueue,r=new Ol,[4,e.send(r)];case 1:return i=o.sent(),(s=i.as(Dl).reportCategories)&&(a=this._categories).push.apply(a,V([],K(s.map((function(u){return new ln(u)}))),!1)),[2]}}))}))},t})(be),Ll=(function(){function n(){this._enabledRequestDedup=!0,this._requestCache=new Map,this._requestDedupInterval=500}return Object.defineProperty(n.prototype,"requestDedupInterval",{set:function(t){this._requestDedupInterval=t,this._requestDedupInterval<=0?this._enabledRequestDedup=!1:t<50&&(this._requestDedupInterval=50)},enumerable:!1,configurable:!0}),n.prototype.normalizePath=function(t){return t.replace("/v3/sdk/","/v3/")},n.prototype._generateCacheKey=function(t){var e=t.path,r=t.time,i=t.params,s=this.normalizePath(e),a=i?Object.entries(i).sort((function(u,c){var l=K(u,1)[0],d=K(c,1)[0];return l.localeCompare(d)})).map((function(u){var c=K(u,2),l=c[0],d=c[1];return"".concat(l,"=").concat(JSON.stringify(d))})).join("&"):"",o=r?"_".concat(r):"";return"".concat(s,"?").concat(a).concat(o)},n.prototype.requestGetChannel=function(t,e,r,i){var s,a,o=this;if(i===void 0&&(i=!0),!this._enabledRequestDedup)return e();var u=Date.now(),c=this._generateCacheKey({path:t,params:r});if(i)try{for(var l=z(this._requestCache.entries()),d=l.next();!d.done;d=l.next()){var _=K(d.value,2),h=_[0],v=_[1];if(h.startsWith(c)&&u-v.requestTime<=this._requestDedupInterval)return v.pendingResponse?Promise.resolve(v.pendingResponse):v.promise}}catch(w){s={error:w}}finally{try{d&&!d.done&&(a=l.return)&&a.call(l)}finally{if(s)throw s.error}}var m=i?this._generateCacheKey({path:t,time:u,params:r}):c,y=e().then((function(w){var I=o._requestCache.get(m);return I&&(I.pendingResponse=w,I.responseTime=Date.now()),Promise.resolve(w)})).catch((function(w){return Promise.reject(w)})).finally((function(){setTimeout((function(){o._requestCache.delete(m)}),o._requestDedupInterval)})),b={requestTime:u,responseTime:null,promise:y,pendingResponse:null};return this._requestCache.set(m,b),y},n.prototype.updatePendingResponse=function(t,e){var r,i;try{for(var s=z(this._requestCache.entries()),a=s.next();!a.done;a=s.next()){var o=K(a.value,2),u=o[0],c=o[1];if(u.includes(t.url)&&c.pendingResponse&&c.responseTime<e){var l=c.pendingResponse.payload,d=t.constructor.payloadify(t,!0),_=E(E({},l),d);c.pendingResponse=new U(t._iid,_);break}}}catch(h){r={error:h}}finally{try{a&&!a.done&&(i=s.return)&&i.call(s)}finally{if(r)throw r.error}}},n})(),Nt={},C=(function(){function n(t,e){var r,i,s,a,o,u,c,l,d,_,h;if(this.connectedAt=0,this.firstConnectedAt=0,this.connectionHandlers=new Map,this.userEventHandlers=new Map,!Nt[t]){Nt[t]=this;var v=(r=e.options)!==null&&r!==void 0?r:new ao,m=this.sdkState={appId:e.appId,appVersion:(i=e.appVersion)!==null&&i!==void 0?i:"",appState:"foreground",isAppActive:!0,userId:void 0,extensions:{},api:{host:(s=e.apiHost)!==null&&s!==void 0?s:"https://api-".concat(e.appId,".sendbird.com")},websocket:{host:(a=e.websocketHost)!==null&&a!==void 0?a:"wss://ws-".concat(e.appId,".sendbird.com"),pingerDisabled:!!e.noPingpong,pingInterval:void 0,pongTimeout:void 0,connectMaxRetry:2,compression:!0,reconnectMaxRetry:-1,reconnectRetryStrategy:new Vo,responseTimeout:v.websocketResponseTimeout},sessionTokenRefreshTimeout:v.sessionTokenRefreshTimeout};this.appInfo=void 0,this.subscribedUnreadMessageCount={all:0,feed:0,customTypes:{},ts:0};var y=this.logger=e.logger;this.connectedAt=0,this.firstConnectedAt=0,this.connectionHandlers=new Map,this.userEventHandlers=new Map,typeof e.localCacheEnabled=="str
2ing"&&(e.localCacheEnabled=e.localCacheEnabled==="true");var b=this.cacheContext=new Du({encryption:e.encryption,store:e.store,localCacheEnabled:(o=e.localCacheEnabled)!==null&&o!==void 0&&o,localCacheConfig:(u=e.localCacheConfig)!==null&&u!==void 0?u:new uo});this.debugMode=(c=e.debugMode)!==null&&c!==void 0&&c,this.maxSuperGroupChannelUnreadCount=Rt.DEFAULT_MAX_UNREAD_COUNT_OF_SUPER_GROUP_CHANNEL,this.useMemberInfoInMessage=v.useMemberInfoInMessage,this.typingIndicatorInvalidateTime=v.typingIndicatorInvalidateTime,this.typingIndicatorThrottle=v.typingIndicatorThrottle,this.concurrentCallLimit=void 0,this.backOffDelay=void 0;var w=this.dispatcher=new Lu,I=new Ru;this.requestQueue=new yl(t,{session:I,sdkState:m,dispatcher:w,logger:y,useFetchCompat:e.useFetchCompat}),this.pushNotificationAckManager=new kl(t),this.sessionManager=new bl({_iid:t,session:I,cacheContext:b,sdkState:m,dispatcher:w,requestQueue:this.requestQueue,logger:y,pushNotificationAckManager:this.pushNotificationAckManager}),this.connectionManager=new hl(t,{sdkState:m,cacheContext:this.cacheContext,connectionHandlers:this.connectionHandlers,dispatcher:w,sessionManager:this.sessionManager,websocketClient:this.requestQueue.commandRouter.websocketClient,disableWebSocketCloseEventHandling:(l=e.disableWebSocketCloseEventHandling)!==null&&l!==void 0&&l,appStateToggleEnabled:(d=e.appStateToggleEnabled)===null||d===void 0||d,logger:y}),this.statManager=new Al({cacheContext:this.cacheContext,requestQueue:this.requestQueue,dispatcher:this.dispatcher,logger:y}),this.appStateToggleEnabled=(_=e.appStateToggleEnabled)===null||_===void 0||_,this.supportMultipleTabs=(h=e.supportMultipleTabs)!==null&&h!==void 0&&h,this.messageBackgroun
2dSyncThrottleController=new Nl({limit:5}),this.reportCategoryManager=new Rl(t),this.requestDeduplicator=new Ll}return Nt[t]}return n.of=function(t){if(Nt[t])return Nt[t];throw T.lostInstance},n.clear=function(t){Nt[t]&&delete Nt[t]},n.exists=function(t){return!!Nt[t]},n.prototype.hasExtension=function(t){return this.sdkState.extensions&&this.sdkState.extensions[t]},n})(),Xo=(function(){function n(){}return n.prototype.init=function(t,e){var r=e.sdkState,i=e.dispatcher,s=e.sessionManager,a=e.requestQueue,o=e.logger;e.onlineDetector;var u=e.cacheContext;this._iid=t,this._cacheContext=u,this._sdkState=r,this._dispatcher=i,this._sessionManager=s,this._requestQueue=a,this._logger=o},n})();(function(n){n.UNKNOWN="UNKNOWN",n.EVENT_CHANNEL_CREATED="EVENT_CHANNEL_CREATED",n.EVENT_CHANNEL_UPDATED="EVENT_CHANNEL_UPDATED",n.EVENT_CHANNEL_DELETED="EVENT_CHANNEL_DELETED",n.EVENT_CHANNEL_READ="EVENT_CHANNEL_READ",n.EVENT_CHANNEL_UNREAD="EVENT_CHANNEL_UNREAD",n.EVENT_CHANNEL_DELIVERED="EVENT_CHANNEL_DELIVERED",n.EVENT_CHANNEL_INVITED="EVENT_CHANNEL_INVITED",n.EVENT_CHANNEL_JOINED="EVENT_CHANNEL_JOINED",n.EVENT_CHANNEL_LEFT="EVENT_CHANNEL_LEFT",n.EVENT_CHANNEL_ACCEPTED_INVITE="EVENT_CHANNEL_ACCEPTED_INVITE",n.EVENT_CHANNEL_DECLINED_INVITE="EVENT_CHANNEL_DECLINED_INVITE",n.EVENT_CHANNEL_OPERATOR_UPDATED="EVENT_CHANNEL_OPERATOR_UPDATED",n.EVENT_CHANNEL_BANNED="EVENT_CHANNEL_BANNED",n.EVENT_CHANNEL_UNBANNED="EVENT_CHANNEL_UNBANNED",n.EVENT_CHANNEL_MUTED="EVENT_CHANNEL_MUTED",n.EVENT_CHANNEL_UNMUTED="EVENT_CHANNEL_UNMUTED",n.EVENT_CHANNEL_FROZEN="EVENT_CHANNEL_FROZEN",n.EVENT_CHANNEL_UNFROZEN="EVENT_CHANNEL_UNFROZEN",n.EVENT_CHANNEL_HIDDEN="EVENT_CHANNEL_HIDDEN",n.EVENT_CHANNEL_UNHIDDEN="EVENT_CHANNEL_UNHIDDEN",n.EVENT_CHANNEL_RESET_HISTORY="EVENT_CHANNEL_RESET_HISTORY",n.EVENT_CHANNEL_TYPING_STATUS_UPDATE="EVENT_CHANNEL_TYPING_STATUS_UPDATE",n.EVENT_CHANNEL_MEMBER_COUNT_UPDATED="EVENT_CHANNEL_MEMBER_COUNT_UPDATED",n.EVENT_CHANNEL_METADATA_CREATED="EVENT_CHANNEL_METADATA_CREATED",n.EVENT_CHANNEL_METADATA_UPDATED="EVENT_CHANNEL_METADATA_UPDATED",n.EVENT_CHANNEL_METADATA_DELETED="EVENT_CHANNEL_METADATA_DELETED",n.EVENT_CHANNEL_METACOUNTER_CREATED="EVENT_CHANNEL_METACOUNTER_CREATED",n.EVENT_CHANNEL_METACOUNTER_UPDATED="EVENT_CHANNEL_METACOUNTER_UPDATED",n.EVENT_CHANNEL_METACOUNTER_DELETED="EVENT_CHANNEL_METACOUNTER_DELETED",n.EVENT_MESSAGE_SENT="EVENT_MESSAGE_SENT",n.EVENT_MESSAGE_RECEIVED="EVENT_MESSAGE_RECEIVED",n.EVENT_MESSAGE_UPDATED="EVENT_MESSAGE_UPDATED",n.EVENT_PINNED_MESSAGE_UPDATED="EVENT_PINNED_MESSAGE_UPDATED",n.REQUEST_CHANNEL="REQUEST_CHANNEL",n.REQUEST_CHANNEL_CHANGELOGS="REQUEST_CHANNEL_CHANGELOGS",n.REFRESH_CHANNEL="REFRESH_CHANNEL",n.CHANNEL_LASTACCESSEDAT_UPDATED="CHANNEL_LASTACCESSEDAT_UPDATED",n.SYNC_CHANNEL_BACKGROUND="SYNC_CHANNEL_BACKGROUND",n.SYNC_CHANNEL_CHANGELOGS="SYNC_CHANNEL_CHANGELOGS",n.EVENT_MESSAGE_SENT_SUCCESS="EVENT_MESSAGE_SENT_SUCCESS",n.EVENT_MESSAGE_SENT_FAILED="EVENT_MESSAGE_SENT_FAILED",n.EVENT_MESSAGE_SENT_PENDING="EVENT_MESSAGE_SENT_PENDING",n.EVENT_MESSAGE_DELETED="EVENT_MESSAGE_DELETED",n.EVENT_MESSAGE_FEEDBACK_ADDED="EVENT_MESSAGE_FEEDBACK_ADDED",n.EVENT_MESSAGE_FEEDBACK_UPDATED="EVENT_MESSAGE_FEEDBACK_UPDATED",n.EVENT_MESSAGE_FEEDBACK_DELETED="EVENT_MESSAGE_FEEDBACK_DELETED",n.EVENT_MESSAGE_READ="EVENT_MESSAGE_READ",n.EVENT_MESSAGE_DELIVERED="EVENT_MESSAGE_DELIVERED",n.EVENT_MESSAGE_REACTION_UPDATED="EVENT_MESSAGE_REACTION_UPDATED",n.EVENT_MESSAGE_THREADINFO_UPDATED="EVENT_MESSAGE_THREADINFO_UPDATED",n.EVENT_MESSAGE_OFFSET_UPDATED="EVENT_MESSAGE_OFFSET_UPDATED",n.REQUEST_MESSAGE="REQUEST_MESSAGE",n.EVENT_THREAD_INFO_UPDATED="EVENT_THREADINFO_UPDATED",n.EVENT_POLL_UPDATED="EVENT_POLL_UPDATED",n.EVENT_POLL_VOTED="EVENT_POLL_VOTED",n.SYNC_POLL_CHANGELOGS="SYNC_POLL_CHANGELOGS",n.EVENT_CHANNEL_CSAT_SUBMITTED="EVENT_CHANNEL_CSAT_SUBMITTED",n.EVENT_CHANNEL_CONVERSATION_HANDEDOFF="EVENT_CHANNEL_CONVERSATION_HANDEDOFF",n.REQUEST_RESEND_MESSAGE="REQUEST_RESEND_MESSAGE",n.REQUEST_THREADED_MESSAGE="REQUEST_THREADED_MESSAGE",n.REQUEST_MESSAGE_CHANGELOGS="REQUEST_MESSAGE_CHANGELOGS",n.SYNC_MESSAGE_FILL="SYNC_MESSAGE_FILL",n.SYNC_MESSAGE_BACKGROUND="SYNC_MESSAGE_BACKGROUND",n.SYNC_MESSAGE_CHANGELOGS="SYNC_MESSAGE_CHANGELOGS",n.LOCAL_MESSAGE_PENDING_CREATED="LOCAL_MESSAGE_PENDING_CREATED",n.LOCAL_MESSAGE_FAILED="LOCAL_MESSAGE_FAILED",n.LOCAL_MESSAGE_CANCELED="LOCAL_MESSAGE_CANCELED",n.LOCAL_MESSAGE_RESEND_STARTED="LOCAL_MESSAGE_RESEND_STARTED"})(ne||(ne={}));var pn;E({},ne);var h_=function(n){return n.startsWith("EVENT_")||n.startsWith("LOCAL_MESSAGE_")||n===ne.SYNC_MESSAGE_FILL||n===ne.SYNC_MESSAGE_CHANGELOGS||n===ne.SYNC_POLL_CHANGELOGS},ge=(function(n){function t(e){var r=e.messages,i=e.source,s=e.isWebSocketEventComing,a=s!==void 0&&s,o=n.call(this)||this;return o.messages=r,o.source=i,o.isWebSocketEventComing=a,o}return g(t,n),t})(Z),Jo=(function(n){function t(e){var r=e.messageIds,i=e.source,s=e.isWebSocketEventComing,a=s!==void 0&&s,o=n.call(this)||this;return o.messageIds=r,o.source=i,o.isWebSocketEventComing=a,o}return g(t,n),t})(Z),Ul=(function(n){function t(e){var r=e.messageDeletionTimestamp,i=e.channelUrl,s=e.source,a=n.call(this)||this;return a.messageDeletionTimestamp=r,a.channelUrl=i,a.source=s,a}return g(t,n),t})(Z),Ml=(function(n){function t(e){var r=e.event,i=e.source,s=e.isWebSocketEventComing,a=s!==void 0&&s,o=n.call(this)||this;return o.event=r,o.source=i,o.isWebSocketEventComing=a,o}return g(t,n),t})(Z),Pl=(function(n){function t(e){var r=e.event,i=e.source,s=e.isWebSocketEventComing,a=s!==void 0&&s,o=n.call(this)||this;return o.event=r,o.source=i,o.isWebSocketEventComing=a,o}return g(t,n),t})(Z),xl=(function(n){function t(e){var r=e.reqId,i=e.source,s=n.call(this)||this;return s.reqId=r,s.source=i,s}return g(t,n),t})(Z),eu=(function(n){function t(e){var r=e.polls,i=e.source,s=n.call(this)||this;return s.polls=r,s.source=i,s}return g(t,n),t})(Z),Fl=(function(n){function t(e){var r=e.event,i=e.source,s=n.call(this)||this;return s.event=r,s.source=i,s}return g(t,n),t})(Z),tu=(function(n){function t(e){var r=e.event,i=e.source,s=n.call(this)||this;return s.event=r,s.source=i,s}return g(t,n),t})(Z);(function(n){n.OPEN="open",n.CLOSED="closed"})(pn||(pn={}));var f_="removed",la=function(n){switch(n){case"open":return pn.OPEN;case"closed":return pn.CLOSED;default:return null}},nu=function(n){return!n||!!n.text&&S("string",n.text)},Ar=(function(n){function t(e,r){var i,s,a,o,u,c,l,d=this;return(d=n.call(this,e)||this).pollId=0,d.id=0,d.text=null,d.voteCount=0,d.createdBy=null,d.createdAt=0,d.updatedAt=0,d._lastVotedAt=0,d.pollId=(i=r.poll_id)!==null&&i!==void 0?i:0,d.id=(s=r.id)!==null&&s!==void 0?s:0,d.text=(a=r.text)!==null&&a!==void 0?a:null,d.voteCount=(o=r.vote_count)!==null&&o!==void 0?o:0,d.createdBy=(u=r.created_by)!==null&&u!==void 0?u:null,d.createdAt=(c=r.created_at)!==null&&c!==void 0?c:0,d.updatedAt=(l=r.updated_at)!==null&&l!==void 0?l:0,d}return g(t,n),t.payloadify=function(e){return M(B(E(E({},n.payloadify.call(this,e)),{vote_count:e.voteCount,poll_id:e.pollId,text:e.text,created_at:e.createdAt,id:e.id,created_by:e.createdBy,updated_at:e.updatedAt})))},t})(be),Xe=(function(n){function t(e,r){var i,s,a,o,u,c,l,d,_,h,v,m,y,b=this;return(b=n.call(this,e)||this).id=0,b.title=null,b.createdAt=0,b.updatedAt=0,b.closeAt=-1,b.status=pn.CLOSED,b.messageId=0,b.data=null,b.voterCount=-1,b.options=[],b.createdBy=null,b.allowUserSuggestion=!1,b.allowMultipleVotes=!1,b.votedPollOptionIds=[],b.id=(i=r.id)!==null&&i!==void 0?i:0,b.title=(s=r.title)!==null&&s!==void 0?s:null,b.createdAt=(a=r.created_at)!==null&&a!==void 0?a:0,b.updatedAt=(o=r.updated_at)!==null&&o!==void 0?o:0,b.closeAt=(u=r.close_at)!==null&&u!==void 0?u:-1,b.status=(c=la(r.status))!==null&&c!==void 0?c:pn.CLOSED,b.messageId=(l=r.message_id)!==null&&l!==void 0?l:0,b.data=(d=r.data)!==null&&d!==void 0?d:null,b.voterCount=(_=r.voter_count)!==null&&_!==void 0?_:-1,b.options=r.options?r.options.map((function(w){return new Ar(b._iid,w)})):[],b.createdBy=(h=r.created_by)!==null&&h!==void 0?h:null,b.allowUserSuggestion=(v=r.allow_user_suggestion)!==null&&v!==void 0&&v,b.allowMultipleVotes=(m
2=r.allow_multiple_votes)!==null&&m!==void 0&&m,b.votedPollOptionIds=(y=r.voted_option_ids)!==null&&y!==void 0?y:[],b}return g(t,n),t.prototype._applyPollUpdatePayload=function(e){var r,i,s,a,o,u,c,l,d=this;this.title=(r=e.title)!==null&&r!==void 0?r:this.title,this.updatedAt=(i=e.updated_at)!==null&&i!==void 0?i:this.updatedAt,this.closeAt=(s=e.close_at)!==null&&s!==void 0?s:this.closeAt,this.status=(a=la(e.status))!==null&&a!==void 0?a:this.status,this.data=(o=e.data)!==null&&o!==void 0?o:this.data,this.voterCount=(u=e.voter_count)!==null&&u!==void 0?u:this.voterCount,e.options&&(this.options=e.options.map((function(_){return new Ar(d._iid,_)})),this.votedPollOptionIds=e.options.filter((function(_){return _.vote_count>0})).map((function(_){return _.id}))),this.allowUserSuggestion=(c=e.allow_user_suggestion)!==null&&c!==void 0?c:this.allowUserSuggestion,this.allowMultipleVotes=(l=e.allow_multiple_votes)!==null&&l!==void 0?l:this.allowMultipleVotes},t.payloadify=function(e){return M(B(E(E({},n.payloadify.call(this,e)),{id:e.id,title:e.title,created_at:e.createdAt,updated_at:e.updatedAt,close_at:e.closeAt,status:e.status,message_id:e.messageId,data:e.data,voter_count:e.voterCount,options:e.options.map((function(r){return Ar.payloadify(r)})),created_by:e.createdBy,allow_user_suggestion:e.allowUserSuggestion,allow_multiple_votes:e.allowMultipleVotes,voted_option_ids:e.votedPollOptionIds})))},t.prototype.applyPollUpdateEvent=function(e){var r=e._payload.poll;return!(!r||this.id!==r.id||r.updated_at<this.updatedAt)&&(this._applyPollUpdatePayload(r),!0)},t.prototype.applyPollVoteEvent=function(e){if(this.id!==e.pollId)return!1;var r=this.options,i=r.map((function(o){return o.id})),s=e._payload,a=Math.floor(s.ts/1e3);return s.updated_vote_counts.forEach((function(o){var u=i.indexOf(o.option_id);if(u>-1){var c=r[u];a>=c._lastVotedAt&&(c.voteCount=o.vote_count,c._lastVotedAt=a)}})),s.req_id&&s.voted_option_ids&&(this.votedPollOptionIds=s.voted_option_ids),typeof s.voter_count=="number"&&(this.voterCount=s.voter_count),!0},t.prototype.serialize=function(){return hs(this)},t})(be),nr=(function(){function n(t,e){var r;this.limit=20,this._isLoading=!1,this._hasNext=!0,this._token="",this._iid=t,this.limit=(r=e.limit)!==null&&r!==void 0?r:20}return Object.defineProperty(n.prototype,"hasNext",{get:function(){return this._hasNext},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isLoading",{get:function(){return this._isLoading},enumerable:!1,configurable:!0}),n.prototype._validate=function(){return S("number",this.limit)&&this.limit>0},n})(),qt=(function(n){function t(e,r,i,s){var a=n.call(this,e,s)||this;return a.channelUrl=r,a.channelType=i,a}return g(t,n),t.prototype._validate=function(){return n.prototype._validate.call(this)&&S("string",this.channelUrl)&&ie(oe,this.channelType)},t})(nr),ql=function(n){this.pollId=0,this.messageId=0,this.pollId=n.poll_id,this.messageId=n.message_id,this._payload=n},zl=(function(n){function t(e){var r=e.title,i=e.optionTexts,s=e.data,a=e.allowUserSuggestion,o=e.allowMultipleVotes,u=e.closeAt,c=n.call(this)||this;return c.method=k.POST,c.path=at,c.params={title:r,options:i,data:s,allow_user_suggestion:a,allow_multiple_votes:o,close_at:u},c}return g(t,n),t})(O),Bl=(function(n){function t(e,r){var i=n.call(this,e,r)||this;return i.poll=new Xe(e,r),i}return g(t,n),t})(U),jl=(function(n){function t(e){var r=e.channelUrl,i=e.channelType,s=e.pollId,a=n.call(this)||this;return a.method=k.GET,a.path="".concat(at,"/").concat(encodeURIComponent(s)),a.params={channel_url:r,channel_type:i},a}return g(t,n),t})(O),Kl=(function(n){function t(e,r){var i=n.call(this,e,r)||this;return i.poll=new Xe(e,r),i}return g(t,n),t})(U),Hl=(function(n){function t(e){var r=e.channelUrl,i=e.channelType,s=e.pollId,a=e.pollOptionId,o=n.call(this)||this;return o.method=k.GET,o.path="".concat(at,"/").concat(encodeURIComponent(s),"/options/").concat(encodeURIComponent(a)),o.params={channel_url:r,channel_type:i},o}return g(t,n),t})(O),Vl=(function(n){function t(e,r){var i=n.call(this,e,r)||this;return i.pollOption=new Ar(e,r),i}return g(t,n),t})(U),Gl=(function(n){function t(e){var r=e.channelType,i=e.channelUrl,s=e.timestamp,a=e.token,o=n.call(this)||this;return o.method=k.GET,o.path="".concat(Y(r),"/").concat(encodeURIComponent(i),"/polls/changelogs"),o.params=M({change_ts:s,token:a}),o}return g(t,n),t})(O),Ql=(function(n){function t(e,r){var i=n.call(this,e,r)||this;return i.updatedPolls=r.updated.map((function(s){return(function(a,o){return new Xe(a,o)})(e,s)})),i.deletedPollIds=r.deleted.map((function(s){return s})),i.hasMore=r.has_more,i.nextToken=r.next,i}return g(t,n),t})(U),$l={title:"",optionTexts:[],data:void 0,allowUserSuggestion:void 0,allowMultipleVotes:void 0,closeAt:-1},ru=function(n){return S("string",n.title)&&(t=n.optionTexts,J("string",t)&&t.every((function(e){return e.trim()!==""})))&&nu(n.data)&&S("boolean",n.allowUserSuggestion,!0)&&S("boolean",n.allowMultipleVotes,!0)&&S("number",n.closeAt,!0);var t},Wl={channelUrl:"",channelType:oe.BASE,pollId:0,pollOptionId:0},iu=function(n){return S("string",n.channelUrl)&&n.channelUrl!==""&&ie(oe,n.channelType)&&S("number",n.pollId)&&n.pollId>0&&S("number",n.pollOptionId)&&n.pollOptionId>0},Yl={channelUrl:"",channelType:oe.BASE,pollId:0},su=function(n){return S("string",n.channelUrl)&&n.channelUrl!==""&&ie(oe,n.channelType)&&S("number",n.pollId)},da={},Xi=(function(){function n(t,e){var r=e.sdkState,i=e.dispatcher,s=e.sessionManager,a=e.requestQueue,o=e.logger;this._iid=t,this._sdkState=r,this._sessionManager=s,this._requestQueue=a,this._dispatcher=i,this._logger=o,da[t]=this}return n.of=function(t){return da[t]},n.prototype.buildPollFromSerializedData=function(t){var e=Yn(t);return new Xe(this._iid,Xe.payloadify(e))},n.prototype.get=function(t){return f(this,void 0,void 0,(function(){var e,r;return p(this,(function(i){switch(i.label){case 0:return R(su(t)).throw(T.invalidParameters),e=new jl(E({},t)),[4,this._requestQueue.send(e)];case 1:return r=i.sent(),[2,r.as(Kl).poll]}}))}))},n.prototype.create=function(t){return f(this,void 0,void 0,(function(){var e,r;return p(this,(function(i){switch(i.label){case 0:return R(ru(t)).throw(T.invalidParameters),e=new zl(E({},t)),[4,this._requestQueue.send(e)];case 1:return r=i.sent(),[2,r.as(Bl).poll]}}))}))},n.prototype.getOption=function(t){return f(this,void 0,void 0,(function(){var e,r;return p(this,(function(i){switch(i.label){case 0:return R(iu(t)).throw(T.invalidParameters),e=new Hl(E({},t)),[4,this._requestQueue.send(e)];case 1:return r=i.sent(),[2,r.as(Vl).pollOption]}}))}))},n.prototype.getPollChangeLogs=function(t,e,r,i){return i===void 0&&(i=ne.
2SYNC_POLL_CHANGELOGS),f(this,void 0,void 0,(function(){var s,a,o,u,c,l,d;return p(this,(function(_){switch(_.label){case 0:return s=new Gl(B({channelType:e,channelUrl:t,timestamp:typeof r=="number"?r:null,token:typeof r=="string"?r:null})),[4,this._requestQueue.send(s)];case 1:return a=_.sent(),o=a.as(Ql),u=o.updatedPolls,c=o.deletedPollIds,l=o.hasMore,d=o.nextToken,u.length>0&&this._dispatcher.dispatch(new eu({polls:u,source:i})),[2,{updatedPolls:u,deletedPollIds:c,hasMore:l,token:d}]}}))}))},n})(),Zl=(function(n){function t(e){var r=e.channelUrl,i=e.channelType,s=e.token,a=e.limit,o=n.call(this)||this;return o.method=k.GET,o.path=at,o.params={channel_url:r,channel_type:i,token:s,limit:a},o}return g(t,n),t})(O),Xl=(function(n){function t(e,r){var i,s=this;return(s=n.call(this,e,r)||this).polls=((i=r.polls)!==null&&i!==void 0?i:[]).map((function(a){return new Xe(e,a)})),s.token=r.next,s}return g(t,n),t})(U),au=(function(n){function t(e,r){return n.call(this,e,r.channelUrl,r.channelType,r)||this}return g(t,n),t.prototype.next=function(){return f(this,void 0,void 0,(function(){var e,r,i,s,a,o;return p(this,(function(u){switch(u.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=C.of(this._iid).requestQueue,r=new Zl(E(E({},this),{token:this._token})),[4,e.send(r)]):[3,2]:[3,5];case 1:return i=u.sent(),s=i.as(Xl),a=s.polls,o=s.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,a];case 2:return[2,[]];case 3:throw T.queryInProgress;case 4:return[3,6];case 5:throw T.invalidParameters;case 6:return[2]}}
2))}))},t})(qt),Jl=(function(n){function t(e){var r=e.channelUrl,i=e.channelType,s=e.pollId,a=e.pollOptionId,o=e.token,u=e.limit,c=n.call(this)||this;return c.method=k.GET,c.path="".concat(at,"/").concat(encodeURIComponent(s),"/options/").concat(encodeURIComponent(a),"/voters"),c.params={channel_url:r,channel_type:i,token:o,limit:u},c}return g(t,n),t})(O),ed=(function(n){function t(e,r){var i,s=this;return(s=n.call(this,e,r)||this).voters=((i=r.voters)!==null&&i!==void 0?i:[]).map((function(a){return new G(e,a)})),s.token=r.next,s}return g(t,n),t})(U),ou=(function(n){function t(e,r){var i=n.call(this,e,r.channelUrl,r.channelType,r)||this;return i.pollId=r.pollId,i.pollOptionId=r.pollOptionId,i}return g(t,n),t.prototype._validate=function(){return n.prototype._validate.call(this)&&S("number",this.pollId)&&S("number",this.pollOptionId)},t.prototype.next=function(){return f(this,void 0,void 0,(function(){var e,r,i,s,a,o;return p(this,(function(u){switch(u.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=C.of(this._iid).requestQueue,r=new Jl(E(E({},this),{pollId:this.pollId,pollOptionId:this.pollOptionId,token:this._token})),[4,e.send(r)]):[3,2]:[3,5];case 1:return i=u.sent(),s=i.as(ed),a=s.voters,o=s.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,a];case 2:return[2,[]];case 3:throw T.queryInProgress;case 4:return[3,6];case 5:throw T.invalidParameters;case 6:return[2]}}
2))}))},t})(qt),tn,zt=(function(){function n(t,e,r){var i,s;this.width=0,this.height=0,this.realWidth=0,this.realHeight=0,this._requireAuth=!1,this._iid=t,this.plainUrl=e.url,this.width=e.width,this.height=e.height,this.realWidth=(i=e.real_width)!==null&&i!==void 0?i:e.width,this.realHeight=(s=e.real_height)!==null&&s!==void 0?s:e.height,this._requireAuth=r}return n.payloadify=function(t){return M(B(t instanceof n?{url:t.plainUrl,width:t.width,height:t.height,real_width:t.realWidth,real_height:t.realHeight}:{url:"",width:t.maxWidth,height:t.maxHeight,real_width:0,real_height:0}))},Object.defineProperty(n.prototype,"url",{get:function(){var t=C.of(this._iid).sessionManager;return this._requireAuth&&t.ekey?"".concat(this.plainUrl,"?auth=").concat(t.ekey):this.plainUrl},enumerable:!1,configurable:!0}),n})(),Ji=(function(n){function t(e){var r=n.call(this)||this;if(r.method=k.POST,r.path="".concat(Mu),r.params=M({file:e.file,channel_url:e.channelUrl}),e.thumbnailSizes)for(var i=0;i<e.thumbnailSizes.length;i++){var s=e.thumbnailSizes[i],a=s.maxWidth,o=s.maxHeight;r.params["thumbnail".concat(i+1)]="".concat(a,",").concat(o)}return r.requestId=e.requestId,r}return g(t,n),t})(O),es=(function(n){function t(e,r){var i,s,a,o,u=this;return(u=n.call(this,e,r)||this).url=r.url,u.fileSize=(i=r.file_size)!==null&&i!==void 0?i:0,u.thumbnails=(a=(s=r.thumbnails)===null||s===void 0?void 0:s.map((function(c){return new zt(e,c,!1)})))!==null&&a!==void 0?a:[],u.requireAuth=(o=r.require_auth)!==null&&o!==void 0&&o,u}return g(t,n),t})(U),ts=(function(n){function t(e,r){var i,s,a,o,u,c=this;return(c=n.call(this,e)||this).replyCount=0,c.memberCount=0,c.lastRepliedAt=0,c.updatedAt=0,c.replyCount=(i=r.reply_count)!==null&&i!==void 0?i:0,c.memberCount=(s=r.member_count)!==null&&s!==void 0?s:0,c.mostRepliedUsers=r.most_replies&&J("object",r.most_replies)?r.most_replies.map((function(l){return new G(c._iid,l)})):[],c.unreadReplyCount=(a=r.unread_message_count)!==null&&a!==void 0?a:0,c.isPushNotificationEnabled=typeof r.push_enabled=="number"?r.push_enabled>0:void 0,c.lastRepliedAt=(o=r.last_replied_at)!==null&&o!==void 0?o:0,c.updatedAt=(u=r.updated_at)!==null&&u!==void 0?u:0,c}return g(t,n),t.payloadify=function(e){return M(B(E(E({},n.payloadify.call(this,e)),{reply_count:e.replyCount,unread_message_count:e.unreadReplyCount,member_count:e.memberCount,most_replies:Array.isArray(e.mostRepliedUsers)?e.mostRepliedUsers.map((function(r){return G.payloadify(r)})):[],push_enabled:typeof e.isPushNotificationEnabled=="boolean"?e.isPushNotificationEnabled?1:0:void 0,last_replied_at:e.lastRepliedAt,updated_at:e.updatedAt})))},Object.defineProperty(t.prototype,"_isUpdateRequired",{get:function(){return this.unreadReplyCount===void 0||this.isPushNotificationEnabled===void 0},enumerable:!1,configurable:!0}),t.prototype._updateFrom=function(e){var r,i;this.unreadReplyCount=(r=e.unreadReplyCount)!==null&&r!==void 0?r:this.unreadReplyCount,this.isPushNotificationEnabled=(i=e.isPushNotificationEnabled)!==null&&i!==void 0?i:this.isPushNotificationEnabled},t})(be);(function(n){n.ADD="add",n.DELETE="delete"})(tn||(tn={}));var uu=function(n){var t;this.messageId=0,this.operation=null,this.updatedAt=0;var e=S("string",n.msg_id)?parseInt(n.msg_id):n.msg_id,r=n.user_id,i=n.operation?n.operation.toLowerCase():null,s=n.reaction,a=n.updated_at,o=n.count,u=n.sampled_user_ids,c=(t=n.sampled_user_info)!==null&&t!==void 0?t:{};e&&S("string",r)&&S("string",i)&&ie(tn,i)&&S("string",s)&&s&&S("number",a)&&(this.messageId=e,this.userId=r,this.key=s,this.operation=i,this.updatedAt=a,this._count=o,this._sampledUserIds=u,this._sampledUserInfoList=c)},Ni=(function(n){function t(e,r,i){var s,a=this;return(a=n.call(this,e)||this).userId=r,a.nickname=i.nickname,a.plainProfileUrl=i.profile_url,a.requireAuth=(s=i.require_auth_for_profile_image)!==null&&s!==void 0&&s,a}return g(t,n),Object.defineProperty(t.prototype,"profileUrl",{get:function(){var e=C.of(this._iid).sessionManager;return this.requireAuth&&e.ekey?"".concat(this.plainProfileUrl,"?auth=").concat(e.ekey):this.plainProfileUrl}
2,enumerable:!1,configurable:!0}),t.payloadify=function(e){return{nickname:e.nickname,profile_url:e.plainProfileUrl,require_auth_for_profile_image:e.requireAuth}},t})(be),Tn=(function(n){function t(e,r){var i,s,a,o,u,c,l,d,_,h=this;(h=n.call(this,e)||this)._sampledUserInfoList=[],h._count=0,h._hasCurrentUserReacted=!1;var v=r.key,m=V([],K((o=(a=r.sampled_user_ids)!==null&&a!==void 0?a:r.user_ids)!==null&&o!==void 0?o:[]),!1),y=(c=(u=r.last_ts)!==null&&u!==void 0?u:r.updated_at)!==null&&c!==void 0?c:0,b=(l=r.is_self_included)!==null&&l!==void 0?l:m.includes(C.of(e).sdkState.userId),w=(d=r.sampled_user_info)!==null&&d!==void 0?d:{};S("string",v)&&v&&J("string",m)&&m.length>0&&S("number",y)&&(h.key=v,h._sampledUserIds=m,h._updatedAt=y,h._count=(_=r.count)!==null&&_!==void 0?_:m.length,h._hasCurrentUserReacted=b,Object.keys(w).forEach((function(N){h._sampledUserInfoList.push(new Ni(e,N,w[N]))})));var I={};try{for(var A=z(h.sampledUserIds),D=A.next();!D.done;D=A.next())I[D.value]=h.updatedAt}catch(N){i={error:N}}finally{try{D&&!D.done&&(s=A.return)&&s.call(A)}finally{if(i)throw i.error}}return h._version=I,h}return g(t,n),Object.defineProperty(t.prototype,"isEmpty",{get:function(){return this._count===0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"userIds",{get:function(){return this._sampledUserIds},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sampledUserIds",{get:function(){return this._sampledUserIds},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sampledUserInfoList",{get:function(){return this._sampledUserInfoList},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"count",{get:function(){return this._count},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"updatedAt",{get:function(){return this._updatedAt},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasCurrentUserReacted",{get:function(){return this._hasCurrentUserReacted},enumerable:!1,configurable:!0}),t.payloadify=function(e){var r={};return e._sampledUserInfoList.forEach((function(i){r[i.userId]=Ni.payloadify(i)})),M(B({key:e.key,sampled_user_ids:e._sampledUserIds,sampled_user_info:r,count:e._count,is_self_included:e._hasCurrentUserReacted,last_ts:e._updatedAt}))},t.prototype.applyEvent=function(e){var r=this;if(e.key===this.key&&this.updatedAt<=e.updatedAt)if(e._sampledUserIds)this._sampledUserIds=e._sampledUserIds,this._sampledUserInfoList=[],Object.keys(e._sampledUserInfoList).forEach((function(s){r._sampledUserInfoList.push(new Ni(r._iid,s,e._sampledUserInfoList[s]))})),this._count=e._count,e._hasCurrentUserReacted!==void 0?this._hasCurrentUserReacted=e._hasCurrentUserReacted:this._sampledUserIds.includes(C.of(this._iid).sdkState.userId)&&(this._hasCurrentUserReacted=!0),this._updatedAt=e.updatedAt;else{if(!this._version[e.userId]||this._version[e.userId]<=e.updatedAt){var i=this._sampledUserIds.indexOf(e.userId);switch(e.operation){case tn.ADD:i<0&&this._sampledUserIds.push(e.userId);break;case tn.DELETE:i>=0&&this._sampledUserIds.splice(i,1)}this._count=this._sampledUserIds.length,this._version[e.userId]=e.updatedAt}this._updatedAt=Math.max(this.updatedAt,e.updatedAt)}},t})(be),ha=(function(){function n(t){this.secureUrl=null,this.type=null,this.width=0,this.height=0,this.alt=null,this.url=t.url,t.secure_url&&(this.secureUrl=t.secure_url),t.type&&(this.type=t.type),t.width&&(this.width=t.width),t.height&&(this.height=t.height),t.alt&&(this.alt=t.alt)}return n.payloadify=function(t){var e,r;return M(B({url:t.url,secure_url:t.secureUrl,type:t.type,width:(e=t.width)!==null&&e!==void 0?e:0,height:(r=t.height)!==null&&r!==void 0?r:0,alt:t.alt}))},n})(),fa=(function(){function n(t){this.title=null,this.url=null,this.description=null,this.defaultImage=null,t["og:title"]&&(this.title=t["og:title"]),t["og:url"]&&(this.url=t["og:url"]),t["og:description"]&&(this.description=t["og:description"]),t["og:image"]&&(this.defaultImage=new ha(t["og:image"]))}return n.payloadify=function(t){return M(B({"og:title":t.title,"og:url":t.url,"og:description":t.description,"og:image":t.defaultImage?ha.payloadify(t.defaultImage):null}))},n})(),mt=(function(){function n(t){var e,r;this.volume=0,this.name=(e=t.name)!==null&&e!==void 0?e:"default",this.volume=(r=t.volume)!==null&&r!==void 0?r:1}return n.prototype.serialize=function(){return{name:this.name,volume:this.volume}},n.payloadify=function(t){return M(B({name:t.name,volume:t.volume}))},n})(),Yt=(function(n){function t(e,r){var i,s=this;return(s=n.call(this,e,r)||this).isBlockedByMe=!1,s.role=ie(Lr,r.role)?r.role:Lr.NONE,s.isBlockedByMe=(i=r.is_blocked_by_me)!==null&&i!==void 0&&i,s}return g(t,n),t.payloadify=function(e){return M(B(E(E({},n.payloadify.call(this,e)),{role:e.role,is_blocked_by_me:e.isBlockedByMe})))},t})(G),He=(function(){function n(t){this.key=t.key,this.value=J("string",t.value)?V([],K(t.value),!1):[]}return n.payloadify=function(t){var e;return M(B({key:t.key,value:(e=t.value)!==null&&e!==void 0?e:[]}))},n})(),cu=function(n){switch(n){case ee.BASE:return"";case ee.USER:return"MESG";case ee.FILE:return"FILE";case ee.ADMIN:return"ADMM"}},lu=(function(n){function t(e,r){var i,s,a,o,u,c,l,d,_,h=this;
2(h=n.call(this,e)||this).channelType=oe.BASE,h.messageType=ee.BASE,h.mentionType=null,h.mentionedUsers=null,h.mentionedUserIds=null,h.metaArrays=[],h.extendedMessage={},h.createdAt=0,h.updatedAt=0,h.channelUrl=r.channel_url,h.channelType=ie(oe,r.channel_type)?r.channel_type:oe.GROUP,r.channel&&(r.channel.channel_url&&(h.channelUrl=r.channel.channel_url),r.channel.channel_type&&(h.channelType=r.channel.channel_type)),h.data=(i=r.data)!==null&&i!==void 0?i:"",h.customType=(s=r.custom_type)!==null&&s!==void 0?s:"",h.mentionType=ie(Re,r.mention_type)?r.mention_type:null,h.mentionedUsers=r.mentioned_users?r.mentioned_users.map((function(w){return new G(h._iid,w)})):null,h.mentionedUserIds=(a=r.mentioned_user_ids)!==null&&a!==void 0?a:null,h.mentionedUsers&&!h.mentionedUserIds&&(h.mentionedUserIds=h.mentionedUsers.map((function(w){return w.userId})));var v=(o=r.metaarray)!==null&&o!==void 0?o:{},m=(u=r.metaarray_key_order)!==null&&u!==void 0?u:Object.keys(v).sort((function(w,I){return w.localeCompare(I)}));h.metaArrays=[];for(var y=0;y<m.length;y++){var b=m[y];h.metaArrays.push(new He({key:b,value:v[b]||[]}))}return r.sorted_metaarray&&(h.metaArrays=r.sorted_metaarray.map((function(w){return new He(w)}))),h.extendedMessage=(c=r.extended_message)!==null&&c!==void 0?c:{},h.extendedMessagePayload=r.extended_message_payload,h.createdAt=(d=(l=r.created_at)!==null&&l!==void 0?l:r.ts)!==null&&d!==void 0?d:0,h.updatedAt=(_=r.updated_at)!==null&&_!==void 0?_:0,h}return g(t,n),t.payloadify=function(e){var r,i;return M(B(E(E({},n.payloadify.call(this,e)),{channel_url:e.channelUrl,channel_type:e.channelType,type:cu(e.messageType),data:e.data,custom_type:e.customType,mention_type:e.mentionType,mentioned_user_ids:e.mentionedUserIds,mentioned_users:(r=e.mentionedUsers)===null||r===void 0?void 0:r.map((function(s){return G.payloadify(s)})),sorted_metaarray:(i=e.metaArrays)===null||i===void 0?void 0:i.map((function(s){return He.payloadify(s)})),extended_message:e.extendedMessage,extended_message_payload:e.extendedMessagePayload,created_at:e.createdAt,updated_at:e.updatedAt})))},t.prototype.isIdentical=function(e){return!0},t.prototype.isEqual=function(e){return so(this,e)},t.prototype.isUserMessage=function(){return this.messageType===ee.USER},t.prototype.isFileMessage=function(){return this.messageType===ee.FILE&&!Object.prototype.hasOwnProperty.call(this,"fileInfoList")},t.prototype.isMultipleFilesMessage=function(){return this.messageType===ee.FILE&&Object.prototype.hasOwnProperty.call(this,"fileInfoList")},t.prototype.isAdminMessage=function(){return this.messageType===ee.ADMIN},t.prototype.serialize=function(){return hs(this)},t.prototype.getMetaArraysByKeys=function(e){return this.metaArrays.filter((function(r){return e.includes(r.key)}))},t})(be),td=(function(n){function t(e,r){var i,s,a,o=this;return(o=n.call(this,e)||this).channelUrl=(i=r.channel_url)!==null&&i!==void 0?i:"",o.channelType=(s=r.channel_type)!==null&&s!==void 0?s:oe.GROUP,o.reader=new G(o._iid,r.user),o.readAt=r.ts,o.isExcluded=(a=r.is_excluded)!==null&&a!==void 0&&a,o}return g(t,n),t})(be),p_=(function(n){function t(e){var r=e.channelUrl;return n.call(this,{code:"READ",ackRequired:!0,payload:{channel_url:r}})||this}return g(t,n),t})(qe),__=(function(n){function t(e){var r=n.call(this)||this,i=e.channelUrl,s=e.channelType,a=e.userId,o=e.notificationIds,u=e.messageId,c=e.isExcluded,l=e.uniqueId;return r.method=k.PUT,r.path="".concat(Y(s),"/").concat(encodeURIComponent(i),"/messages/mark_as_read"),r.params=M(B({user_id:a,message_ids:o,message_id:u,is_excluded:c,unique_id:l})),r}return g(t,n),t})(O),v_=(function(n){function t(e,r,i){var s=n.call(this,e,"READ",i)||this;return s.readStatus=new td(e,i),s}return g(t,n),t})(we),m_=(function(n){function t(e,r){var i=n.call(this,e,r)||this;return i.readAt=r.ts,i.unreadMessageCount=r.unread_message_count,i.totalUnreadCount=r.total_unread_count,i.channelUrl=r.channel_url,i.userId=r.user_id,i.isExcluded=r.is_excluded,i.uniqueId=r.unique_id,i}return g(t,n),t})(U),nd=(function(n){function t(e){var r=e.channelUrl,i=e.messageId;return n.call(this,{code:"READ",ackRequired:!0,payload:{channel_url:r,parent_message_id:i}})||this}return g(t,n),t})(qe),rd=(function(n){function t(e){var r=e.channelType,i=e.channelUrl,s=e.messageId,a=e.pushEnabled,o=n.call(this)||this;return o.method=k.PUT,o.path="".concat(Y(r),"/").concat(encodeURIComponent(i),"/messages/").concat(s,"/thread_push"),o.params={push_enabled:a},o}return g(t,n),t})(O);(function(n){function t(e,r){return n.call(this,e,r)||this}g(t,n)})(U);var pa,Ot,ns=(function(n){function t(e,r){var i,s,a,o,u,c=this;return(c=n.call(this,e)||this).plainUrl="",c.fileName=null,c.mimeType=null,c.fileSize=0,c.thumbnails=[],c._requireAuth=!1,c.plainUrl=(i=r.url)!==null&&i!==void 0?i:"",c.fileName=(s=r.file_name)!==null&&s!==void 0?s:null,c.mimeType=(a=r.file_type)!==null&&a!==void 0?a:null,c.fileSize=(o=r.file_size)!==null&&o!==void 0?o:0,c._requireAuth=(u=r.require_auth)!==null&&u!==void 0&&u,c.thumbnails=r.thumbnails?r.thumbnails.map((function(l){var d;return new zt(c._iid,typeof l=="string"?{url:l,width:0,height:0}:E(E({},l),{url:((d=l.url)!==null&&d!==void 0?d:"").split("auth=")[0]}),c._requireAuth)})):[],c}return g(t,n),t.payloadify=function(e){var r;return M(B({url:e.plainUrl,file_name:e.fileName,file_type:e.mimeType,file_size:e.fileSize,thumbnails:(r=e.thumbnails)===null||r===void 0?void 0:r.map((function(i){var s;return{url:((s=i.plainUrl)!==null&&s!==void 0?s:"").split("auth=")[0],width:i.width,height:i.height,real_width:i.realWidth,real_height:i.realHeight}})),require_auth:e._requireAuth}))},Object.defineProperty(t.prototype,"url",{get:function(){var e=C.of(this._iid).sessionManager;return this._requireAuth&&e.ekey?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl}
2,enumerable:!1,configurable:!0}),t})(be),id=function(n){var t=n.channelUrl,e=n.channelType,r=n.parentMessage;this.channelUrl=t,this.channelType=e,this.parentMessage=r};(function(n){n.PENDING="pending",n.SENT="sent",n.FAILED="failed",n.CANCELED="canceled"})(pa||(pa={})),(function(n){n.PENDING="pending",n.IN_QUEUE="in_queue",n.SENT="sent",n.FAILED="failed",n.CANCELED="canceled",n.REMOVED="removed"})(Ot||(Ot={}));var $t,je=(function(n){function t(e,r){var i,s,a,o,u,c,l,d,_,h=this;return(h=n.call(this,e,r)||this).parentMessage=null,h.silent=!1,h.isOperatorMessage=!1,h.threadInfo=null,h.reactions=[],h.appleCriticalAlertOptions=null,h.scheduledInfo=null,h.suggestedReplies=null,h.myFeedback=null,h.myFeedbackStatus="NOT_APPLICABLE",h.messageForm=null,h._isContinuousMessages=!1,h._scheduledStatus=null,h._poll=null,h.messageId=(s=(i=r.msg_id)!==null&&i!==void 0?i:r.message_id)!==null&&s!==void 0?s:0,h.parentMessageId=(a=typeof r.parent_message_id=="string"?parseInt(r.parent_message_id):r.parent_message_id)!==null&&a!==void 0?a:0,h.threadInfo=r.thread_info?new ts(h._iid,r.thread_info):null,r.reactions_summary?h.reactions=r.reactions_summary.map((function(v){return new Tn(e,v)})):r.reactions?h.reactions=r.reactions.map((function(v){return new Tn(e,v)})):h.reactions=[],h.ogMetaData=r.og_tag?new fa(r.og_tag):null,h.silent=(o=r.silent)!==null&&o!==void 0&&o,h.isOperatorMessage=(u=r.is_op_msg)!==null&&u!==void 0&&u,h.appleCriticalAlertOptions=r.apple_critical_alert_options?new mt(r.apple_critical_alert_options):null,typeof r.scheduled_message_id=="number"&&typeof r.scheduled_at=="number"&&r.scheduled_status&&(h.scheduledInfo={scheduledMessageId:r.scheduled_message_id,scheduledAt:r.scheduled_at},h._scheduledStatus=r.scheduled_status),h._isContinuousMessages=(c=r.is_continuous_messages)!==null&&c!==void 0&&c,h.suggestedReplies=(d=(l=r.extended_message_payload)===null||l===void 0?void 0:l.suggested_replies)!==null&&d!==void 0?d:null,h.message=(_=r.message)!==null&&_!==void 0?_:"",h._poll=r.poll?new Xe(h._iid,r.poll):null,h}return g(t,n),t.payloadify=function(e){var r,i;return M(B(E(E({},n.payloadify.call(this,e)),{message_id:e.messageId,parent_message_id:e.parentMessageId,thread_info:e.threadInfo?ts.payloadify(e.threadInfo):null,reactions_summary:e.reactions.map((function(s){return Tn.payloadify(s)})),og_tag:e.ogMetaData?fa.payloadify(e.ogMetaData):null,silent:e.silent,is_op_msg:e.isOperatorMessage,apple_critical_alert_options:e.appleCriticalAlertOptions?mt.payloadify(e.appleCriticalAlertOptions):null,scheduled_message_id:(r=e.scheduledInfo)===null||r===void 0?void 0:r.scheduledMessageId,scheduled_at:(i=e.scheduledInfo)===null||i===void 0?void 0:i.scheduledAt,scheduled_status:e._scheduledStatus,message:e.message,poll:e._poll?Xe.payloadify(e._poll):null})))},t._getParentMessageInfoPayload=function(e){var r={type:cu(e.messageType),ts:e.createdAt,user:e.sender?Yt.payloadify(e.sender):null,message:e.message,data:e.data,custom_type:e.customType};switch(e.messageType){case ee.USER:return M(B(E(E({},r),{translations:e.translations})));case ee.FILE:return M(B(E(E({},r),{file:{url:e.plainUrl,name:e.name,type:e.type,require_auth:e.requireAuth},files:Array.isArray(e.fileInfoList)?e.fileInfoList.map((function(i){return ns.payloadify(i)})):null})));case ee.ADMIN:return M(B(E(E({},r),{translations:e.translations})));default:return M(B(E({},r)))}},t.prototype.isIdentical=function(e){return this.messageId===e.messageId},t.prototype.applyThreadInfoUpdateEvent=function(e){return this.messageId===e.targetMessageId&&(e.threadInfo._isUpdateRequired&&this.threadInfo&&e.threadInfo._updateFrom(this.threadInfo),this.threadInfo=e.threadInfo,!0)},t.prototype._findReactionIndex=function(e){for(var r=0;r<this.reactions.length;r++)if(this.reactions[r].key===e)return r;return-1},t.prototype.applyReactionEvent=function(e){var r=C.of(this._iid).sdkState;if(this.messageId===e.messageId)switch(e.operation){case tn.ADD:e.userId===r.userId&&(e._hasCurrentUserReacted=!0),(i=this._findReactionIndex(e.key))!==-1?this.reactions[i].applyEvent(e):e._sampledUserIds?this.reactions.push(new Tn(this._iid,{key:e.key,sampled_user_ids:e._sampledUserIds,sampled_user_info:e._sampledUserInfoList,count:e._count,is_self_included:e._hasCurrentUserReacted,last_ts:e.updatedAt})):this.reactions.push(new Tn(this._iid,{key:e.key,user_ids:[e.userId],updated_at:e.updatedAt}));break;case tn.DELETE:var i;(i=this._findReactionIndex(e.key))!==-1&&(e._sampledUserIds?e._count===0?this.reactions.splice(i,1):(e.userId===r.userId&&(e._hasCurrentUserReacted=!1),this.reactions[i].applyEvent(e)):(this.reactions[i].applyEvent(e),this.reactions[i].isEmpty&&this.reactions.splice(i,1)))}},t.prototype.applyParentMessage=function(e){if(!this.parentMessage)return this.parentMessage=e,!0;
2if(this.parentMessageId===e.messageId){var r=this.parentMessage.updatedAt;if(e.updatedAt>=r)return this.parentMessage=e,!0}return!1},t.prototype.applyPoll=function(e){return!(this._poll&&this._poll.id===e.id&&this._poll.updatedAt>e.updatedAt)&&(this._poll=e,!0)},Object.defineProperty(t.prototype,"poll",{get:function(){return this._poll},enumerable:!1,configurable:!0}),t.prototype._triggerThreadInfoUpdatedEvent=function(){return f(this,void 0,void 0,(function(){var e;return p(this,(function(r){return(e=C.of(this._iid).dispatcher).dispatch(new id({channelType:oe.GROUP,channelUrl:this.channelUrl,parentMessage:this})),e.dispatch(new ge({messages:[this],source:ne.EVENT_MESSAGE_THREADINFO_UPDATED})),[2]}))}))},t.prototype.markThreadAsRead=function(){return f(this,void 0,void 0,(function(){var e,r;return p(this,(function(i){switch(i.label){case 0:return e=C.of(this._iid).requestQueue,r=new nd({channelUrl:this.channelUrl,messageId:this.messageId}),[4,e.send(r)];case 1:return i.sent(),this.threadInfo&&this.threadInfo.unreadReplyCount!==0?(this.threadInfo.unreadReplyCount=0,[4,this._triggerThreadInfoUpdatedEvent()]):[3,3];case 2:i.sent(),i.label=3;case 3:return[2]}}
2))}))},t.prototype.setPushNotificationEnabled=function(e){return f(this,void 0,void 0,(function(){var r,i;return p(this,(function(s){switch(s.label){case 0:return r=C.of(this._iid).requestQueue,i=new rd({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,pushEnabled:e}),[4,r.send(i)];case 1:return s.sent(),this.threadInfo&&this.threadInfo.isPushNotificationEnabled!==e&&(this.threadInfo.isPushNotificationEnabled=e),[2]}}))}))},t.prototype.submitMessageForm=function(e){return f(this,void 0,void 0,(function(){return p(this,(function(r){throw T.legacyChatbotFeatureNotSupported}))}))},t.prototype.submitFeedback=function(e){return f(this,void 0,void 0,(function(){return p(this,(function(r){throw T.legacyChatbotFeatureNotSupported}))}))},t.prototype.updateFeedback=function(e){return f(this,void 0,void 0,(function(){return p(this,(function(r){throw T.legacyChatbotFeatureNotSupported}))}))},t.prototype.deleteFeedback=function(e){return f(this,void 0,void 0,(function(){return p(this,(function(r){throw T.legacyChatbotFeatureNotSupported}))}))},t})(lu),pt=(function(n){function t(e,r){var i,s,a,o,u=this;if((u=n.call(this,e,r)||this).reqId="",u.replyToChannel=!1,u.errorCode=0,r.user)u.sender=new Yt(u._iid,r.user);else{var c=typeof r.sender_id=="string"?r.sender_id:"";u.sender=new Yt(u._iid,{user_id:c})}if(u.reqId=(s=(i=r.req_id)!==null&&i!==void 0?i:r.request_id)!==null&&s!==void 0?s:"",u.replyToChannel=(a=r.is_reply_to_channel)!==null&&a!==void 0&&a,r.request_state&&ie(ae,r.request_state)&&(u.sendingStatus=r.request_state),!u.sendingStatus)if(u.messageId>0)u.sendingStatus=ae.SUCCEEDED;else if(u.scheduledInfo)switch(r.scheduled_status&&(u._scheduledStatus=r.scheduled_status),r.scheduled_status){case Ot.SENT:case Ot.IN_QUEUE:u.sendingStatus=ae.SUCCEEDED;break;case Ot.PENDING:u.sendingStatus=ae.SCHEDULED;break;case Ot.FAILED:case Ot.REMOVED:u.sendingStatus=ae.FAILED;break;case Ot.CANCELED:u.sendingStatus=ae.CANCELED}else u.sendingStatus=ae.PENDING;return u.errorCode=(o=r.error_code)!==null&&o!==void 0?o:0,u._messageToken=r.mesg_token,u}return g(t,n),t.payloadify=function(e){return M(B(E(E({},n.payloadify.call(this,e)),{user:Yt.payloadify(e.sender),req_id:e.reqId,is_reply_to_channel:e.replyToChannel,request_state:e.sendingStatus,error_code:e.errorCode,mesg_token:e._messageToken})))},Object.defineProperty(t.prototype,"isResendable",{get:function(){return(this.sendingStatus===ae.FAILED||this.sendingStatus===ae.CANCELED)&&Ou(this.errorCode)},enumerable:!1,configurable:!0}),t.prototype.isIdentical=function(e){return this.messageId>0&&e.messageId>0?this.messageId===e.messageId:this.reqId===e.reqId},t})(je),rr={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:Ve.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1},Jr=function(n){return S("number",n.prevResultSize)&&S("number",n.nextResultSize)&&S("boolean",n.isInclusive)&&S("boolean",n.reverse)&&S("string",n.messageTypeFilter)&&ie(Ve,n.messageTypeFilter)&&J("string",n.customTypesFilter,!0)&&J("string",n.senderUserIdsFilter,!0)&&S("boolean",n.includeMetaArray)&&S("boolean",n.includeReactions)&&S("boolean",n.includeParentMessageInfo)},Hr=(function(n){function t(e,r){var i,s,a,o=this;if((o=n.call(this,e,r)||this).translations={},o.messageType=ee.ADMIN,o.translations=(i=r.translations)!==null&&i!==void 0?i:{},r.parent_message_info){var u=r.parent_message_info;o.parentMessage=ot(e,M(B(E(E({},u),{message_id:o.parentMessageId,channel_url:o.channelUrl,channel_type:o.channelType,file:u.file,url:(s=u.file)===null||s===void 0?void 0:s.url,require_auth:(a=u.file)===null||a===void 0?void 0:a.require_auth}))))}return o}return g(t,n),t.payloadify=function(e){return M(B(E(E({},n.payloadify.call(this,e)),{translations:e.translations,parent_message_info:e.parentMessage?n._getParentMessageInfoPayload.call(this,e.parentMessage):null})))},t.prototype.getThreadedMessagesByTimestamp=function(e,r){return f(this,void 0,void 0,(function(){var i;return p(this,(function(s){switch(s.label){case 0:return i=E(E({},rr),r),R(this.messageId>0&&S("number",e)&&Jr(i)).throw(T.invalidParameters),[4,Ne.of(this._iid).getThreadedMessagesByTimestamp(this,e,i)];case 1:return[2,s.sent()]}}))}))},t})(je),_a=(function(){function n(t){var e,r;this.detail={},this.type=(e=t.type)!==null&&e!==void 0?e:"",this.vendor=(r=t.vendor)!==null&&r!==void 0?r:"",t.detail&&S("object",t.detail)&&!Array.isArray(t.detail)&&(this.detail=t.detail)}return n.payloadify=function(t){return M(B({type:t.type,vendor:t.vendor,detail
2:t.detail}))},n})(),va=(function(){function n(t){this.status=t.status,t.original_message_info&&(this.originalMessageInfo={createdAt:t.original_message_info.ts,messageId:t.original_message_info.id})}return n.payloadify=function(t){return M({status:t.status,original_message_info:t.originalMessageInfo?{id:t.originalMessageInfo.messageId,ts:t.originalMessageInfo.createdAt}:void 0})},n})(),ke=(function(n){function t(e,r){var i,s,a,o,u,c,l,d=this;if((d=n.call(this,e,r)||this).messageParams=null,d.mentionedMessageTemplate=void 0,d.translations={},d.translationTargetLanguages=[],d.messageSurvivalSeconds=-1,d.plugins=[],d.messageType=ee.USER,d.translations=(a=r.translations)!==null&&a!==void 0?a:{},d.translationTargetLanguages=(o=r.target_langs)!==null&&o!==void 0?o:[],Object.keys(d.translations).length===0&&d.translationTargetLanguages.length>0)try{for(var _=z(d.translationTargetLanguages),h=_.next();!h.done;h=_.next()){var v=h.value;d.translations[v]=""}}catch(y){i={error:y}}finally{try{h&&!h.done&&(s=_.return)&&s.call(_)}finally{if(i)throw i.error}}if(d.mentionedMessageTemplate=r.mentioned_message_template,d.messageSurvivalSeconds=(u=r.message_survival_seconds)!==null&&u!==void 0?u:-1,d.plugins=r.plugins?r.plugins.map((function(y){return new _a(y)})):[],r.parent_message_info){var m=r.parent_message_info;d.parentMessage=ot(e,M(B(E(E({},m),{created_at:m.ts,message_id:d.parentMessageId,channel_url:d.channelUrl,channel_type:d.channelType,file:m.file,url:(c=m.file)===null||c===void 0?void 0:c.url,require_auth:(l=m.file)===null||l===void 0?void 0:l.require_auth}))))}return r.review_info&&(d.messageReviewInfo=new va(r.review_info)),d}return g(t,n),t.payloadify=function(e){return M(B(E(E({},n.payloadify.call(this,e)),{translations:e.translations,message_survival_seconds:e.messageSurvivalSeconds,mentioned_message_template:e.mentionedMessageTemplate,plugins:e.plugins.map((function(r){return _a.payloadify(r)})),parent_message_info:e.parentMessage?n._getParentMessageInfoPayload.call(this,e.parentMessage):null,review_info:e.messageReviewInfo?va.payloadify(e.messageReviewInfo):void 0})))},t.prototype.getThreadedMessagesByTimestamp=function(e,r){return f(this,void 0,void 0,(function(){var i;return p(this,(function(s){switch(s.label){case 0:return i=E(E({},rr),r),R(this.messageId>0&&S("number",e)&&Jr(i)).throw(T.invalidParameters),[4,Ne.of(this._iid).getThreadedMessagesByTimestamp(this,e,i)];case 1:return[2,s.sent()]}}))}))},t})(pt),Ge=(function(n){function t(e,r){var i,s,a,o,u,c,l,d,_=this;if((_=n.call(this,e,r)||this).messageParams=null,_.fileInfoList=[],_.messageSurvivalSeconds=-1,_.messageType=ee.FILE,_.data=(a=(s=(i=r.file)===null||i===void 0?void 0:i.data)!==null&&s!==void 0?s:r.custom)!==null&&a!==void 0?a:"",_.fileInfoList=(u=(o=r.files)===null||o===void 0?void 0:o.map((function(v){return new ns(e,v)})))!==null&&u!==void 0?u:[],_.messageSurvivalSeconds=(c=r.message_survival_seconds)!==null&&c!==void 0?c:-1,r.parent_message_info){var h=r.parent_message_info;_.parentMessage=ot(e,M(B(E(E({},h),{created_at:h.ts,message_id:_.parentMessageId,channel_url:_.channelUrl,channel_type:_.channelType,file:h.file,url:(l=h.file)===null||l===void 0?void 0:l.url,require_auth:(d=h.file)===null||d===void 0?void 0:d.require_auth}))))}return _}return g(t,n),t.prototype.getThreadedMessagesByTimestamp=function(e,r){return f(this,void 0,void 0,(function(){var i;return p(this,(function(s){switch(s.label){case 0:return i=E(E({},rr),r),R(this.messageId>0&&S("number",e)&&Jr(i)).throw(T.invalidParameters),[4,Ne.of(this._iid).getThreadedMessagesByTimestamp(this,e,i)];case 1:return[2,s.sent()]}}))}))},t.payloadify=function(e){var r,i,s,a,o,u;return M(B(E(E({},n.payloadify.call(this,e)),{file:{name:(i=(r=e.fileInfoList[0])===null||r===void 0?void 0:r.fileName)!==null&&i!==void 0?i:"",size:(a=(s=e.fileInfoList[0])===null||s===void 0?void 0:s.fileSize)!==null&&a!==void 0?a:0,type:(u=(o=e.fileInfoList[0])===null||o===void 0?void 0:o.mimeType)!==null&&u!==void 0?u:"",data:e.data},files:Array.isArray(e.fileInfoList)?e.fileInfoList.map((function(c){return ns.payloadify(c)})):null,message_survival_seconds:e.messageSurvivalSeconds,parent_message_info:e.parentMessage?n._getParentMessageInfoPayload.call(this,e.parentMessage):null})))},t._isMultipleFilesMessagePayload=function(e){var r=e.files;return Array.isArray(r)&&r.length>=2},t._isMultipleFilesMessageSerializedData=function(e){var r=e.fileInfoList;return Array.isArray(r)},t})(pt);(function(n){n.SENT="SENT",n.READ="READ"})($t||($t={}));var _n=(function(n){function t(e,r){var i,s,a=this;if((a=n.call(this,e,r)||this).notificationData=null,a.notificationId=r.notification_message_id,a.messageType=ee.ADMIN,a.messageStatus=(i=r.message_status)!==null&&i!==void 0?i:$t.SENT,a.priority=(s=r.priority)!==null&&s!==void 0?s:Bi.NORMAL,a.notificationEventDeadline=r.notification_event_deadline,a.extendedMessage.sub_type===0)try{var o=JSON.parse(a.extendedMessage.sub_data),u=o.label,c=o.tags,l=c===void 0?[]:c,d=o.template_key,_=o.template_variables;a.notificationData={label:u,tags:l,templateKey:d,templateVariables:_}}catch(h){}return a}return g(t,n),t.payloadify=function(e){return M(B(E(E({},n.payloadify.call(this,e)),{notification_message_id:e.notificationId,message_status:e.messageStatus,priority:e.priority,notification_event_deadline:e.notificationEventDeadline})))},t.prototype.isIdentical=function(e){return this.notificationId===e.notificationId},t})(lu),g_=function(n){if(n.notificationId)return _n.payloadify(n);switch(n.messageType){case ee.USER:return ke.payloadify(n);case ee.FILE:return n.fileInfoList?Ge.payloadify(n):he.payloadify(n);case ee.ADMIN:return Hr.payloadify(n);default:throw T.unknown}},ot=function(n,t){if(t.notification_message_id)return new _n(n,t);switch(t.type){case"MESG":return new ke(n,t);case"FILE":return Ge._isMultipleFilesMessagePayload(t)?new Ge(n,t):new he(n,t);case"ADMM":case"BRDM":return new Hr(n,t);default:return null}},he=(function(n){function t(e,r){var i,s,a,o,u,c,l,d,_,h,v,m,y,b,w,I=this;(I=n.call(this,e,r)||this).messageParams=null,I.plainUrl="",I.requireAuth=!1,I.thumbnails=[],I.messageSurvivalSeconds=-1,I.messageType=ee.FILE;var A=r.file;if(I.plainUrl=((s=(i=A==null?void 0:A.url)!==null&&i!==void 0?i:r.url)!==null&&s!==void 0?s:"").split("?auth=")[0],I.name=(o=(a=A
2==null?void 0:A.name)!==null&&a!==void 0?a:r.name)!==null&&o!==void 0?o:"File",I.size=(c=(u=A==null?void 0:A.size)!==null&&u!==void 0?u:r.size)!==null&&c!==void 0?c:0,I.data=(_=(d=(l=A==null?void 0:A.data)!==null&&l!==void 0?l:r.custom)!==null&&d!==void 0?d:I.data)!==null&&_!==void 0?_:"",I.type=A?(h=A.type)!==null&&h!==void 0?h:"":(v=r.type)!==null&&v!==void 0?v:"",I.requireAuth=(m=r.require_auth)!==null&&m!==void 0&&m,I.thumbnails=r.thumbnails?r.thumbnails.map((function(N){var F;return new zt(I._iid,typeof N=="string"?{url:N,width:0,height:0}:E(E({},N),{url:((F=N.url)!==null&&F!==void 0?F:"").split("auth=")[0]}),I.requireAuth)})):[],I.messageSurvivalSeconds=(y=r.message_survival_seconds)!==null&&y!==void 0?y:-1,r.parent_message_info){var D=r.parent_message_info;I.parentMessage=ot(e,M(B(E(E({},D),{created_at:D.ts,message_id:I.parentMessageId,channel_url:I.channelUrl,channel_type:I.channelType,file:D.file,url:(b=D.file)===null||b===void 0?void 0:b.url,require_auth:(w=D.file)===null||w===void 0?void 0:w.require_auth}))))}return I}return g(t,n),t.payloadify=function(e){var r;return M(B(E(E({},n.payloadify.call(this,e)),{url:e.plainUrl,require_auth:e.requireAuth,file:{name:e.name,size:e.size,type:e.type,data:e.data},thumbnails:(r=e.thumbnails)===null||r===void 0?void 0:r.map((function(i){return{url:i.plainUrl,width:i.width,height:i.height,real_width:i.realWidth,real_height:i.realHeight}})),message_survival_seconds:e.messageSurvivalSeconds,parent_message_info:e.parentMessage?n._getParentMessageInfoPayload.call(this,e.parentMessage):null})))},Object.defineProperty(t.prototype,"url",{get:function(){var e=C.of(this._iid).sessionManager;return this.requireAuth&&e.ekey?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl},enumerable:!1,configurable:!0}),t.prototype.getThreadedMessagesByTimestamp=function(e,r){return f(this,void 0,void 0,(function(){var i;return p(this,(function(s){switch(s.label){case 0:return i=E(E({},rr),r),R(this.messageId>0&&S("number",e)&&Jr(i)).throw(T.invalidParameters),[4,Ne.of(this._iid).getThreadedMessagesByTimestamp(this,e,i)];case 1:return[2,s.sent()]}}))}))},t})(pt),Xn=(function(n){function t(e,r){var i=r.file,s=r.fileUrl,a=r.fileName,o=r.fileSize,u=r.mimeType,c=r.thumbnailSizes,l=r._uploadedMetaData,d=r._thumbnails,_=n.call(this,e)||this;return _._plainUrl=s,_.file=i,_.fileName=a,_.fileSize=o,_.mimeType=u,_.thumbnailSizes=c,_._uploadedMetaData=l,_._thumbnails=d,_}return g(t,n),t.getPlainUrl=function(e){return e instanceof t?e._plainUrl:e.fileUrl},Object.defineProperty(t.prototype,"fileUrl",{get:function(){var e,r=C.of(this._iid).sessionManager;return this._plainUrl&&(!((e=this._uploadedMetaData)===null||e===void 0)&&e.requireAuth)&&r.ekey?"".concat(this._plainUrl,"?auth=").concat(r.ekey):this._plainUrl},set:function(e){this._plainUrl=e},enumerable:!1,configurable:!0}),t.prototype.toJSON=function(){return{file:this.file,fileUrl:this._plainUrl,fileName:this.fileName,fileSize:this.fileSize,mimeType:this.mimeType,thumbnailSizes:this.thumbnailSizes,_thumbnails:this._thumbnails,_uploadedMetaData:this._uploadedMetaData}},t})(be),sd=(function(n){function t(e){var r,i,s,a,o=[];return e.mentionType===Re.USERS&&(e.mentionedUserIds?o=e.mentionedUserIds:e.mentionedUsers&&(o=e.mentionedUsers.map((function(u){return u.userId})))),n.call(this,{code:"FILE",ackRequired:!0,payload:M(B({channel_url:e.channelUrl,files:e.files?du(e.files):null,url:e.url,name:(r=e.fileName)!==null&&r!==void 0?r:"",type:(i=e.mimeType)!==null&&i!==void 0?i:"",size:(s=e.fileSize)!==null&&s!==void 0?s:0,custom:e.data,custom_type:e.customType,thumbnails:(a=e._thumbnails)===null||a===void 0?void 0:a.map((function(u){return zt.payloadify(u)})),require_auth:e.requireAuth,metaarray:e.metaArrays,mention_type:e.mentionType,mentioned_user_ids:o,push_option:e.pushNotificationDeliveryOption&&e.pushNotificationDeliveryOption!==it.DEFAULT?e.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:e.appleCriticalAlertOptions?mt.payloadify(e.appleCriticalAlertOptions):null,silent:e.silent,reply_to_channel:e.isReplyToChannel,parent_message_id:e.parentMessageId?e.parentMessageId:null,req_id:e.reqId,poll_id:e.pollId,pin_message:e.isPinnedMessage,message:e.message?e.message:void 0}))})||this}return g(t,n),t})(qe),ad=(function(n){function t(e){var r,i,s=this;s=n.call(this)||this;var a=[];return e.mentionType===Re.USERS&&(e.mentionedUserIds?a=e.mentionedUserIds:e.mentionedUsers&&(a=e.mentionedUsers.map((function(o){return o.userId})))),s.method=k.POST,s.path="".concat(Y(e.channelType),"/").concat(encodeURIComponent(e.channelUrl),"/messages"),s.params=M(B({message_type:ee.FILE,user_id:e.userId,files:e.files?du(e.files):null,url:e.fileUrl,mention_type:e.mentionType,mentioned_user_ids:a,file_name:e.fileName,file_size:e.fileSize,file_type:e.mimeType,data:e.data,custom_type:e.customType,thumbnails:(r=e._thumbnails)===null||r===void 0?void 0:r.map((function(o){return zt.payloadify(o)})),require_auth:e.requireAuth,sorted_metaarray:(i=e.metaArrays)===null||i===void 0?void 0:i.map((function(o){return He.payloadify(o)})),push_option:e.pushNotificationDeliveryOption,parent_message_id:e.parentMessageId?e.parentMessageId:null,apple_critical_alert_options:e.appleCriticalAlertOptions?mt.payloadify(e.appleCriticalAlertOptions):null,reply_to_channel:e.isReplyToChannel,req_id:e.reqId,poll_id:e.pollId,pin_message:e.isPinnedMessage})),s}return g(t,n),t})(O),od=(function(n){function t(e,r,i){var s,a,o,u,c=this;(c=n.call(this,e,"FILE",i)||this).message=i.files&&i.files.length>=2?new Ge(e,i):new he(e,i);var l=C.of(e).sdkState;return c.isMentioned=Gn(c.message.mentionType,(o=(s=c.message.mentionedUserIds)!==null&&s!==void 0?s:(a=c.message.mentionedUsers)===null||a===void 0?void 0:a.map((function(d){return d.userId}
2)))!==null&&o!==void 0?o:[],l.userId),c.forceUpdateLastMessage=(u=i.force_update_last_message)!==null&&u!==void 0&&u,c}return g(t,n),t})(we),ud=(function(n){function t(e,r){var i,s,a,o,u=this;(u=n.call(this,e,r)||this).message=r.files&&r.files.length>=2?new Ge(e,r):new he(e,r);var c=C.of(e).sdkState;return u.isMentioned=Gn(u.message.mentionType,(a=(i=u.message.mentionedUserIds)!==null&&i!==void 0?i:(s=u.message.mentionedUsers)===null||s===void 0?void 0:s.map((function(l){return l.userId})))!==null&&a!==void 0?a:[],c.userId),u.forceUpdateLastMessage=(o=r.force_update_last_message)!==null&&o!==void 0&&o,u}return g(t,n),t})(U);function du(n){return n.map((function(t){var e,r;return M(B({url:Xn.getPlainUrl(t),file_name:t.fileName,file_type:t.mimeType,file_size:t.fileSize,thumbnails:(e=t._thumbnails)===null||e===void 0?void 0:e.map((function(i){return zt.payloadify(i)})),require_auth:(r=t._uploadedMetaData)===null||r===void 0?void 0:r.requireAuth}))}))}var _e;(function(n){n[n.PENDING=0]="PENDING",n[n.UPLOADING=1]="UPLOADING",n[n.UPLOADED=2]="UPLOADED",n[n.SENDING=3]="SENDING",n[n.FAILED=4]="FAILED"})(_e||(_e={}));var cd=(function(){function n(t,e){var r=e.sdkState,i=e.dispatcher,s=e.requestQueue,a=e.onlineDetector,o=e.cacheContext,u=this;this._queueMap=new Map,this._iid=t,this._sdkState=r,this._requestQueue=s,this._cacheContext=o,this._dispatcher=i,this._dispatcher.on((function(c){c instanceof yn&&(u._connectionState=c.stateType)})),this._onlineDetector=a}return Object.defineProperty(n.prototype,"_shouldSendThroughWebSocket",{get:function(){return this._connectionState===X.CONNECTED||this._connectionState===X.CONNECTING||this._connectionState===X.RECONNECTING},enumerable:!1,configurable:!0}),n.prototype._sendFileMessage=function(t,e){return f(this,void 0,void 0,(function(){var r,i,s;return p(this,(function(a){switch(a.label){case 0:return r=this._createSendFileMessageRequestParam
2s(t,e),this._shouldSendThroughWebSocket?(i=new sd(r),[4,this._requestQueue.send(i)]):[3,2];case 1:return s=a.sent(),[2,s.as(od).message];case 2:return i=new ad(E(E({},r),{userId:this._sdkState.userId})),[4,this._requestQueue.send(i)];case 3:return s=a.sent(),[2,s.as(ud).message]}}))}))},n.prototype._createSendFileMessageRequestParams=function(t,e){var r=E(E({},e.params),{channelUrl:t.url,channelType:t.channelType,reqId:e.requestId,url:""});if(e.multipleFileUploadInfo){var i=e.params;r.files=i.fileInfoList}else i=e.params,r.url=i.fileUrl,r.requireAuth=i.requireAuth;return r},n.prototype._resolveMessageQueue=function(t){var e;return f(this,void 0,void 0,(function(){var r,i,s,a,o,u,c,l,d,_,h,v,m;return p(this,(function(y){switch(y.label){case 0:if(!(r=this._queueMap.get(t.url)))return[3,21];if(r.isResolving)return[3,20];r.isResolving=!0,i=[],s=!0,y.label=1;case 1:y.trys.push([1,15,16,17]),a=z(r.messageQueue),o=a.next(),y.label=2;case 2:if(o.done)return[3,14];switch(u=o.value,u.state){case _e.PENDING:case _e.UPLOADING:return[3,3];case _e.UPLOADED:return[3,4];case _e.FAILED:return[3,12]}return[3,13];case 3:return s=!1,i.push(u),[3,13];case 4:if(!s)return[3,10];y.label=5;case 5:return y.trys.push([5,8,,9]),u.state=_e.SENDING,[4,this._sendFileMessage(t,u)];case 6:return c=y.sent(),u.deferred.resolve(c),[4,Ue(100)];case 7:return y.sent(),[3,9];case 8:return l=y.sent(),u.deferred.reject(l),[3,9];case 9:return[3,11];case 10:i.push(u),y.label=11;case 11:return[3,13];case 12:return d=(e=u.error)!==null&&e!==void 0?e:T.unknown,u.deferred.reject(d.code===L.REQUEST_CANCELED?T.fileUploadCanceled:d),[3,13];case 13:return o=a.next(),[3,2];case 14:return[3,17];case 15:return _=y.sent(),v={error:_},[3,17];case 16:try{o&&!o.done&&(m=a.return)&&m.call(a)}finally{if(v)throw v.error}return[7];case 17:return h=r.isResolveRequestPending,r.messageQueue=i,r.isResolving=!1,r.isResolveRequestPending=!1,h?[4,this._resolveMessageQueue(t)]:[3,19];case 18:y.sent(),y.label=19;case 19:return[3,21];case 20:r.isResolveRequestPending=!0,y.label=21;case 21:return[2]}}
2))}))},n.prototype._uploadNextPendingItem=function(t){var e;return f(this,void 0,void 0,(function(){var r,i,s,a,o,u,c,l,d,_;return p(this,(function(h){switch(h.label){case 0:return(r=this._queueMap.get(t.url))&&(i=r.messageQueue.find((function(v){return v.state===_e.PENDING})))?i.multipleFileUploadInfo?(s=i.multipleFileUploadInfo,a=s.uploadIndex,o=s.uploadCount,u=s.requestHandler,_=i.params,c=_.fileInfoList[a],!rt(c.file)||!((e=c._uploadedMetaData)===null||e===void 0)&&e.isUploaded?[3,2]:[4,this._tryUploadNextItemAndUpdateItemState(t,r,i)]):[3,4]:[3,9];case 1:return h.sent(),[3,3];case 2:i.state=a<o-1?_e.PENDING:_e.UPLOADED,h.label=3;case 3:return l=_.fileInfoList[a],d=i.multipleFileUploadInfo.uploadIndex++,i.multipleFileUploadInfo.isCopy||u==null||u._triggerOnFileUploaded(i.requestId,d,l,i.error),[3,7];case 4:return _=i.params,rt(_.file)?[4,this._tryUploadNextItemAndUpdateItemState(t,r,i)]:[3,6];case 5:return h.sent(),[3,7];case 6:_.thumbnailSizes=[],i.state=_e.UPLOADED,h.label=7;case 7:return this._uploadNextPendingItem(t),[4,this._resolveMessageQueue(t)];case 8:h.sent(),h.label=9;case 9:return[2]}}
2))}))},n.prototype._tryUploadNextItemAndUpdateItemState=function(t,e,r){return f(this,void 0,void 0,(function(){var i,s,a,o,u,c;return p(this,(function(l){switch(l.label){case 0:return[4,this._onlineDetector.isOnline()];case 1:if(i=l.sent(),!C.of(this._iid).sessionManager.currentUser||!i)return r.error=T.connectionRequired,r.state=_e.FAILED,[2];if(!(e.uploadQueue.length<6))return[3,9];r.state=_e.UPLOADING,e.uploadQueue.push(r),l.label=2;case 2:return l.trys.push([2,7,,8]),r.multipleFileUploadInfo?(s=r.multipleFileUploadInfo,a=s.uploadIndex,o=s.uploadCount,u=r.params,[4,this._uploadNextFileForMultipleFilesItemAndUpdateParams(t,r,u)]):[3,4];case 3:return l.sent(),r.state=a<o-1?_e.PENDING:_e.UPLOADED,[3,6];case 4:return u=r.params,[4,this._uploadNextFileForSingleFileItemAndUpdateParams(t,r,u)];case 5:l.sent(),r.state=_e.UPLOADED,l.label=6;case 6:return[3,8];case 7:switch((c=l.sent()).code){case L.REQUEST_FAILED:r.error=new T({code:L.NETWORK_ERROR,message:"Failed to upload a file."});break;case L.REQUEST_CANCELED:r.error=T.fileUploadCanceled;break;default:r.error=c}return r.state=_e.FAILED,[3,8];case 8:this._dequeueUploadItem(e,r),l.label=9;case 9:return[2]}}
2))}))},n.prototype._dequeueUploadItem=function(t,e){var r=t.uploadQueue.findIndex((function(i){return i.requestId===e.requestId}));r>=0&&t.uploadQueue.splice(r,1)},n.prototype._uploadNextFileForSingleFileItemAndUpdateParams=function(t,e,r){var i,s,a;return f(this,void 0,void 0,(function(){var o,u,c,l,d,_,h,v,m,y;return p(this,(function(b){switch(b.label){case 0:return o=new Ji({file:r.file,channelUrl:t.url,thumbnailSizes:r.thumbnailSizes,requestId:e.requestId}),[4,this._requestQueue.send(o)];case 1:return u=b.sent(),c=u.as(es),l=c.url,d=c.fileSize,_=d===void 0?r.fileSize:d,h=c.thumbnails,v=h===void 0?[]:h,m=c.requireAuth,y=m!==void 0&&m,r.fileName=(i=r.fileName)!==null&&i!==void 0?i:r.file.name,r.mimeType=(s=r.mimeType)!==null&&s!==void 0?s:r.file.type,r.fileSize=(a=r.fileSize)!==null&&a!==void 0?a:r.file.size,r.fileUrl=l,r.fileSize=_,r.requireAuth=y,r._thumbnails=v,[2]}}))}))},n.prototype._uploadNextFileForMultipleFilesItemAndUpdateParams=function(t,e,r){var i,s,a;return f(this,void 0,void 0,(function(){var o,u,c,l,d,_,h,v,m,y,b;return p(this,(function(w){switch(w.label){case 0:return o=e.multipleFileUploadInfo.uploadIndex,u=r.fileInfoList[o],c=new Ji({file:u.file,channelUrl:t.url,thumbnailSizes:u.thumbnailSizes,requestId:e.requestId}),[4,this._requestQueue.send(c)];case 1:return l=w.sent(),d=l.as(es),_=d.url,h=d.fileSize,v=h===void 0?u.fileSize:h,m=d.thumbnails,y=d.requireAuth,b=y!==void 0&&y,u.fileName=(i=u.fileName)!==null&&i!==void 0?i:u.file.name,u.mimeType=(s=u.mimeType)!==null&&s!==void 0?s:u.file.type,u.fileSize=(a=u.fileSize)!==null&&a!==void 0?a:u.file.size,u.file=void 0,u.fileUrl=_,u.fileSize=v,u._thumbnails=m,u._uploadedMetaData=E(E({},u._uploadedMetaData),{requireAuth:b,isUploaded:!0}),u instanceof Xn||(r.fileInfoList[o]=new Xn(this._iid,u)),[2]}}))}))},n.prototype.request=function(t,e,r,i){return i===void 0&&(i={}),f(this,void 0,void 0,(function(){var s,a,o,u,c;return p(this,(function(l){return this._queueMap.has(t.url)||(s={messageQueue:[],uploadQueue:[],isResolving:!1,isResolveRequestPending:!1},this._queueMap.set(t.url,s)),a=this._queueMap.get(t.url),o=new De,u={requestId:e,params:r,state:_e.PENDING,deferred:o},(function(d){return"fileInfoList"in d})(r)&&(c=E({uploadIndex:0,uploadCount:r.fileInfoList.length},i),u.multipleFileUploadInfo=c),a.messageQueue.push(u),this._uploadNextPendingItem(t),[2,o.promise]}))}))},n.prototype.cancel=function(t,e){var r,i,s=this._queueMap.get(t.url);if(s){var a=e?[s.messageQueue.find((function(v){return v.requestId===e}))]:V([],K(s.messageQueue),!1);try{for(var o=z(a),u=o.next();!u.done;u=o.next()){var c=u.value;if(c)switch(c.state){case _e.PENDING:if(c.state=_e.FAILED,c.error=T.requestCanceled,c.multipleFileUploadInfo&&!c.multipleFileUploadInfo.isCopy){var l=c.multipleFileUploadInfo,d=l.uploadIndex,_=l.requestHandler,h=c.params.fileInfoList[d];_==null||_._triggerOnFileUploaded(c.requestId,d,h,T.fileUploadCanceled)}this._resolveMessageQueue(t);break;case _e.UPLOADING:this._requestQueue.cancel(c.requestId),this._dispatcher.dispatch(new Fr({requestId:c.requestId}))}}}catch(v){r={error:v}}finally{try{u&&!u.done&&(i=o.return)&&i.call(o)}finally{if(r)throw r.error}}}else e&&(this._requestQueue.cancel(e),this._dispatcher.dispatch(new Fr({requestId:e})))},n})(),ma,Vr,Bn={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:Ve.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,replyType:ze.NONE,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1,showSubchannelMessagesOnly:!1},ga=function(n){return S("number",n.prevResultSize)&&S("number",n.nextResultSize)&&S("boolean",n.isInclusive)&&S("boolean",n.reverse)&&S("string",n.messageTypeFilter)&&ie(Ve,n.messageTypeFilter)&&J("string",n.customTypesFilter,!0)&&J("string",n.senderUserIdsFilter,!0)&&ie(ze,n.replyType)&&S("boolean",n.includeMetaArray)&&S("boolean",n.includeReactions)&&S("boolean",n.includeParentMessageInfo)&&S("boolean",n.includeThreadInfo)&&S("boolean",n.showSubchannelMessagesOnly)},rs={replyType:ze.NONE,includeReactions:!1,includeThreadInfo:!1,includeMetaArray:!1,includeParentMessageInfo:!1},ya=function(n){return ie(ze,n.replyType)&&S("boolean",n.includeReactions)&&S("boolean",n.includeMetaArray)&&S("boolean",n.includeParentMessageInfo)&&S("boolean",n.includeThreadInfo)};(function(n){n.MESSAGE="message"})(ma||(ma={})),(function(n){n.INTERNAL_BACKSYNC="internal_backsync",n.INTERNAL_FILL_GAP="internal_fill_gap",n.EXTERNAL_LEGACY="external_legacy",n.EXTERNAL_COLLECTION="external_collection"})(Vr||(Vr={}));var is,ld=(function(n){function t(e){var r=e.channelType,i=e.channelUrl,s=e.messageId,a=e.includeMetaArray,o=e.includeReactions,u=e.includeThreadInfo,c=e.includeParentMessageInfo,l=n.call(this)||this;return l.method=k.GET,l.path="".concat(Y(r),"/").concat(encodeURIComponent(i),"/messages/").concat(encodeURIComponent(s)),l.params={is_sdk:!0,with_sorted_meta_array:a,include_reactions_summary:o!=null&&o,include_thread_info:u,include_parent_message_info:c,include_poll_details:!0},l}return g(t,n),t})(O),dd=(function(n){function t(e,r){var i=n.call(this,e,r)||this;return i.message=r?ot(e,E({},r)):null,i}return g(t,n),t})(U),_r=(function(n){function t(e){var r=e.channelType,i=e.channelUrl,s=e.timestamp,a=e.token,o=e.prevResultSize,u=e.nextResultSize,c=e.isInclusive,l=e.reverse,d=e.messageTypeFilter,_=e.customTypesFilter,h=e.senderUserIdsFilter,v=e.replyType,m=e.includeMetaArray,y=e.includeReactions,b=e.parentMessageId,w=e.includeThreadInfo,I=e.includeParentMessageInfo,A=e.showSubchannelMessagesOnly,D=e.checkingHasNext,N=e.checkingContinuousMessages,F=e.sdkSource,q=n.call(this)||this;return q.method=k.GET,q.path="".concat(Y(r),"/").concat(encodeURIComponent(i),"/messages"),q.params=M(B({is_s
2dk:!0,prev_limit:o,next_limit:u,include:c,reverse:l,message_ts:s,message_id:a,message_type:d!=null?d:null,custom_types:_,sender_ids:h,include_reply_type:v,with_sorted_meta_array:m,include_reactions_summary:y,parent_message_id:b,include_thread_info:w,include_parent_message_info:I,show_subchannel_message_only:A,include_poll_details:!0,checking_has_next:D,checking_continuous_messages:N,sdk_source:F})),q}return g(t,n),t})(O),vr=(function(n){function t(e,r){var i=n.call(this,e,r)||this;return r.is_continuous_messages!==void 0&&(i.isContinuousMessages=r.is_continuous_messages),r.has_next!==void 0&&(i.hasNext=r.has_next),i.messages=r.messages.map((function(s){return ot(e,s)})),i}return g(t,n),t})(U),hd=(function(n){function t(e){var r=e.channelType,i=e.channelUrl,s=e.timestamp,a=e.token,o=e.replyType,u=e.includeMetaArray,c=e.includeReactions,l=e.includeThreadInfo,d=e.includeParentMessageInfo,_=n.call(this)||this;return _.method=k.GET,_.path="".concat(Y(r),"/").concat(encodeURIComponent(i),"/messages/changelogs"),_.params={change_ts:s,token:a,with_sorted_meta_array:u,include_reactions_summary:c,include_thread_info:l,include_reply_type:o,include_parent_message_info:d,include_poll_details:!0},_}return g(t,n),t})(O),fd=(function(n){function t(e,r){var i=n.call(this,e,r)||this;return i.updatedMessages=r.updated.map((function(s){return ot(e,s)})),i.deletedMessagesInfo=r.deleted.map((function(s){return{messageId:s.message_id,deletedAt:s.deleted_at}})),i.hasMore=r.has_more,i.nextToken=r.next,i.forceUseNextToken=r.force_use_next_token||!1,i}return g(t,n),t})(U),pd=(function(n){function t(e){var r=e.channelUrl,i=e.scheduledMessageId,s=n.call(this)||this;return s.method=k.GET,s.path="".concat(co,"/").concat(encodeURIComponent(r),"/scheduled_messages/").concat(encodeURIComponent(i)),s.params={},s}return g(t,n),t})(O),_d=(function(n){function t(e,r){var i=n.call(this,e,r)||this;return i.message=r?ot(e,E({},r)):null,i}return g(t,n),t})(U);(function(n){n.MUTED="muted",n.BANNED="banned"})(is||(is={}));var ba=(function(){function n(t){var e,r,i,s;this.restrictionType=null,ie(is,t.restriction_type)&&(this.restrictionType=t.restriction_type),this.description=(e=t.description)!==null&&e!==void 0?e:null,this.endAt=(i=(r=t.end_at)!==null&&r!==void 0?r:t.muted_end_at)!==null&&i!==void 0?i:-1,this.remainingDuration=(s=t.remaining_duration)!==null&&s!==void 0?s:-1}return n.payloadify=function(t){return M(B({restriction_type:t.restrictionType,description:t.description,end_at:t.endAt,remaining_duration:t.remainingDuration}))},n})(),bn=(function(n){function t(e,r){var i=n.call(this,e,r)||this;return i.restrictionInfo=new ba(r),i}return g(t,n),t.payloadify=function(e){return M(B(E(E({},n.payloadify.call(this,e)),ba.payloadify(e.restrictionInfo))))},t})(G);(function(n){function t(e,r){var i,s=this;return(s=n.call(this,e,r)||this).isMuted=!1,s.isMuted=(i=r.is_muted)!==null&&i!==void 0&&i,s}return g(t,n),t})(G);var Nr=(function(){function n(){this._onPending=fe,this._onFailed=fe,this._onSucceeded=fe}return n.prototype._trigger=function(t){switch(t==null?void 0:t.sendingStatus){case ae.PENDING:t.errorCode===0&&this._onPending(t);break;case ae.SCHEDULED:case ae.SUCCEEDED:this._onSucceeded(t)}},n.prototype._triggerFailed=function(t,e){switch(e==null?void 0:e.sendingStatus){case ae.FAILED:case ae.CANCELED:this._onFailed(t,e.scheduledInfo?null:e)}},n.prototype.onPending=function(t){return this._onPending=t,this},n.prototype.onFailed=function(t){return this._onFailed=t,this},n.prototype.onSucceeded=function(t){return this._onSucceeded=t,this},n})(),ei={data:void 0,customType:void 0,mentionType:Re.USERS,mentionedUserIds:void 0,mentionedUsers:void 0,metaArrays:void 0,parentMessageId:void 0,isReplyToChannel:!1,pushNotificationDeliveryOption:void 0,appleCriticalAlertOptions:void 0,isPinnedMessage:!1,pollId:void 0},ti=function(n){return S("string",n.data,!0)&&S("string",n.customType,!0)&&ie(Re,n.mentionType)&&J("string",n.mentionedUserIds,!0)&&J(G,n.mentionedUsers,!0)&&J(He,n.metaArrays,!0)&&S("number",n.parentMessageId,!0)&&S("boolean",n.isReplyToChannel)&&ie(it,n.pushNotificationDeliveryOption,!0)&&S(mt,n.appleCriticalAlertOptions,!0)&&S("boolean",n.isPinnedMessage,!0)&&S("number",n.pollId,!0)},Ea=function(n){return{isReplyToChannel:n.isReplyToChannel,pushNotificationDeliveryOption:n.pushNotificationDeliveryOption,pollId:n.pollId}},hu=E(E({},ei),{message:"",mentionedMessageTemplate:void 0,translationTargetLanguages:void 0,extendedMessagePayload:void 0});function vd(n){var t,e,r;return(t=n.messageParams)!==null&&t!==void 0?t:B(E(E({},n),{mentionType:n.mentionType,mentionedUserIds:(e=n.mentionedUserIds)!==null&&e!==void 0?e:(r=n.mentionedUsers)===null||r===void 0?void 0:r.map((function(i){return i.userId})),mentionedMessageTemplate:n.mentionedMessageTemplate,translationTargetLanguages:Object.keys(n.translations),pushNotificationDeliveryOption:it.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1}))}var Zt,wa=function(n){var t;return M(B({data:n.data,customType:n.customType,mentionType:n.mentionType,mentionedUsers:n.mentionedUsers,mentionedUserIds:n.mentionedUserIds,mentionedMessageTemplate:n.mentionedMessageTemplate,metaArrays:n.metaArrays,pollId:(t=n.poll)===null||t===void 0?void 0:t.id,parentMessageId:n.parentMessageId,appleCriticalAlertOptions:n.appleCriticalAlertOptions,message:n.message,translationTargetLanguages:Object.keys(n.translations),extendedMessagePayload:n.extendedMessagePayload}))},fu=function(n){return ti(n)&&S("string",n.message)&&S("string",n.mentionedMessageTemplate,!0)&&J("string",n.translationTargetLanguages,!0)&&S("object",n.extendedMessagePayload,!0)};(function(n){n.FILE="file",n.BLOB="blob",n.BLOB_LIKE_OBJECT="blobLikeObject",n.URL="url"})(Zt||(Zt={}));var kr=function(n){return typeof window<"u"&&"Blob"in window&&typeof Blob<"u"&&n instanceof Blob},ki=function(n){return n===Zt.BLOB||n===Zt.FILE},Ia=function(n){return{file:n.file,fileKey:n.fileKey,fileType:n.fileType,isReplyToChannel:n.isReplyToChannel,pushNotificationDeliveryOption:n.pushNotificationDeliveryOption}},Ta=E(E({},ei),{file:void 0,fileKey:void 0,fileUrl:void 0,fileName:void 0,fileType:void 0,fileSize:void 0,mimeType:void 0,thumbnailSizes:void 0,requireAuth:!1,message:void 0});function md(n){var t,e,r,i;return(t=n.messageParams)!==null&&t!==void 0?t:B(E(E({},n),{fileUrl:n.plainUrl,fileName:n.name,fileSize:n.size,mimeType:n.type,mentionType:n.mentionType,mentionedUserIds:(e=n.mentionedUserIds)!==null&&e!==void 0?e:(r=n.mentionedUsers)===null||r===void 0?void 0:r.map((function(s){return s.userId})),pushNotificationDeliveryOption:it.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:(i=n.thumbnails)===null||i===void 0?void 0:i.map((function(s){return{maxWidth:s.width,maxHeight:s.height}})),requireAuth:n.requireAuth,isPinnedMessage:!1,_thumbnails:n.thumbnails,message:n.message}))}var jn,Sa=function(n,t){var e,r;return n.messageParams?(!n.url&&rt(t)&&(n.messageParams.file=t),n.messageParams):M(B({data:n.data,customType:n.customType,mentionType:n.mentionType,mentionedUsers:n.mentionedUsers,mentionedUserIds:n.mentionedUserIds,metaArrays:n.metaArrays,parentMessageId:n.parentMessageId,appleCriticalAlertOptions:n.appleCriticalAlertOptions,file:t,fileUrl:n.url,fileName:n.name,fileSize:n.size,mimeType:n.type,thumbnailSizes:(e=n.thumbnails)===null||e===void 0?void 0:e.map((function(i){return{maxWidth:i.width,maxHeight:i.height}})),message:n.message,pollId:(r=n.poll)===null||r===void 0?void 0:r.id}))},Ca=function(n){return ti(n)&&(rt(n.file)||S("string",n.fileUrl))&&S("string",n.fileName,!0)&&S("string",n.mimeType,!0)&&S("number",n.fileSize,!0)&&S("string",n.message,!0)&&(n.thumbnailSizes===null||n.thumbnailSizes===void 0||Array.isArray(n.thumbnailSizes)&&n.thumbnailSizes.every((function(t){return S("object",t)&&t.maxWidth>0&&t.maxHeight>0})))},pu={data:void 0,customType:void 0,mentionType:Re.USERS,mentionedUserIds:void 0,mentionedUsers:void 0,metaArrays:void 0,pushNotificationDeliveryOption:void 0,appleCriticalAlertOptions:void 0},_u=function(n){return S("string",n.data,!0)&&S("string",n.customType,!0)&&ie(Re,n.mentionType)&&J("string",n.mentionedUserIds,!0)&&J(G,n.mentionedUsers,!0)&&J(He,n.metaArrays,!0)&&ie(it,n.pushNotificationDeliveryOption,!0)&&S(mt,n.appleCriticalAlertOptions,!0)},gd=E(E({},pu),{message:void 0,mentionedMessageTemplate:void 0,translationTargetLanguages:void 0,pollId:void 0}),yd=function(n){return _u(n)&&S("string",n.mentionedMessageTemplate,!0)&&S("string",n.message,!0)&&J("string",n.translationTargetLanguages,!0)&&S("number",n.pollId,!0)},bd=E({},pu),Ed=(function(n){function t(e){var r=e.channelUrl,i=e.channelType,s=e.token,a=e.limit,o=n.call(this)||this;return o.method=k.GET,o.path="".concat(Y(i),"/").concat(encodeURIComponent(r),"/operators"),o.params={token:s,limit:a},o}return g(t,n),t})(O),wd=(function(n){function t(e,r){var i=n.call(this,e,r)||this;return i.operators=r.operators.map((function(s){return new G(e,s)})),i.token=r.next,i}return g(t,n),t})(U),Id=(function(n){function t(e,r,i,s){return n.call(this,e,r,i,s)||this}return g(t,n),t.prototype._validate=function(){return n.prototype._validate.call(this)},t.prototype.next=function(){return f(this,void 0,void 0,(function(){var e,r,i,s,a,o,u;return p(this,(function(c){switch(c.label){case 0:return this._val
2idate()?this._isLoading?[3,3]:(e=[],this._hasNext?(this._isLoading=!0,r=C.of(this._iid).requestQueue,i=new Ed(E(E({},this),{channelUrl:this.channelUrl,token:this._token})),[4,r.send(i)]):[3,2]):[3,5];case 1:return s=c.sent(),a=s.as(wd),o=a.operators,u=a.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,[2,o];case 2:return[2,e];case 3:throw T.queryInProgress;case 4:return[3,6];case 5:throw T.invalidParameters;case 6:return[2]}}))}))},t})(qt),Td=(function(n){function t(e,r,i,s){var a,o,u,c,l,d,_,h,v,m,y=this;return(y=n.call(this,e,r,i,s)||this).reverse=!1,y.messageTypeFilter=Ve.ALL,y.customTypesFilter=null,y.senderUserIdsFilter=null,y.replyType=ze.NONE,y.includeMetaArray=!1,y.includeReactions=!1,y.includeParentMessageInfo=!1,y.includeThreadInfo=!1,y.showSubchannelMessagesOnly=!1,y._edge=Number.MAX_SAFE_INTEGER,y.reverse=(a=s.reverse)!==null&&a!==void 0&&a,y.messageTypeFilter=(o=s.messageTypeFilter)!==null&&o!==void 0?o:Ve.ALL,y.customTypesFilter=(u=s.customTypesFilter)!==null&&u!==void 0?u:null,y.senderUserIdsFilter=(c=s.senderUserIdsFilter)!==null&&c!==void 0?c:null,y.replyType=(l=s.replyType)!==null&&l!==void 0?l:ze.NONE,y.includeMetaArray=(d=s.includeMetaArray)!==null&&d!==void 0&&d,y.includeReactions=(_=s.includeReactions)!==null&&_!==void 0&&_,y.includeParentMessageInfo=(h=s.includeParentMessageInfo)!==null&&h!==void 0&&h,y.includeThreadInfo=(v=s.includeThreadInfo)!==null&&v!==void 0&&v,y.showSubchannelMessagesOnly=(m=s.showSubchannelMessagesOnly)!==null&&m!==void 0&&m,y}return g(t,n),t.prototype._validate=function(){return n.prototype._validate.call(this)&&S("boolean",this.reverse)&&ie(Ve,this.messageTypeFilter)&&ie(ze,this.replyType)&&J("string",this.customTypesFilter,!0)&&J("string",this.senderUserIdsFilter,!0)&&S("boolean",this.includeMetaArray)&&S("boolean",this.includeReactions)&&S("boolean",this.includeParentMessageInfo)&&S("boolean",this.includeThreadInfo)&&S("boolean",this.showSubchannelMessagesOnly)},t.prototype.load=function(){return f(this,void 0,void 0,(function(){var e;return p(this,(function(r){switch(r.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,[4,Ne.of(this._iid).getMessagesByTimestamp(this.channelUrl,this.channelType,this._edge,B({prevResultSize:this.limit,nextResultSize:0,isInclusive:!1,reverse:this.reverse,messageTypeFilter:this.messageTypeFilter,customTypesFilter:this.customTypesFilter,replyType:this.replyType,senderUserIdsFilter:this.senderUserIdsFilter,includeReactions:this.includeReactions,includeMetaArray:this.includeMetaArray,includeParentMessageInfo:this.includeParentMessageInfo,includeThreadInfo:this.includeThreadInfo,showSubchannelMessagesOnly:this.showSubchannelMessagesOnly}))]):[3,2]:[3,5];case 1:return e=r.sent(),this._edge=Math.min.apply(Math,V([Number.MAX_SAFE_INTEGER],K(e.map((function(i){return i.createdAt}))),!1)),this._hasNext=e.length>=this.limit,this._isLoading=!1,[2,e];case 2:return[2,[]];case 3:throw T.queryInProgress;case 4:return[3,6];case 5:throw T.invalidParameters;case 6:return[2]}}
2))}))},t})(qt),Sd=(function(n){function t(e){var r=this,i=e.channelUrl,s=e.channelType,a=e.limit,o=e.token;return(r=n.call(this)||this).method=k.GET,r.path="".concat(Y(s),"/").concat(encodeURIComponent(i),"/mute"),r.params={limit:a,token:o},r}return g(t,n),t})(O),Cd=(function(n){function t(e,r){var i=n.call(this,e,r)||this;i.mutedUsers=[];var s=r.next,a=r.muted_list;return i.token=s,a&&a.length>0&&(i.mutedUsers=a.map((function(o){return new bn(e,o)}))),i}return g(t,n),t})(U),Ad=(function(n){function t(e,r,i,s){return n.call(this,e,r,i,s)||this}return g(t,n),t.prototype.next=function(){return f(this,void 0,void 0,(function(){var e,r,i,s,a,o;return p(this,(function(u){switch(u.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=C.of(this._iid).requestQueue,r=new Sd(E(E({},this),{token:this._token})),[4,e.send(r)]):[3,2]:[3,5];case 1:return i=u.sent(),s=i.as(Cd),a=s.mutedUsers,o=s.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,a];case 2:return[2,[]];case 3:throw T.queryInProgress;case 4:return[3,6];case 5:throw T.invalidParameters;case 6:return[2]}}
2))}))},t})(qt),Nd=(function(n){function t(e){var r=this,i=e.channelUrl,s=e.channelType,a=e.limit,o=e.token;return(r=n.call(this)||this).method=k.GET,r.path="".concat(Y(s),"/").concat(encodeURIComponent(i),"/ban"),r.params=M({limit:a,token:o}),r}return g(t,n),t})(O),kd=(function(n){function t(e,r){var i=n.call(this,e,r)||this;i.bannedUsers=[];var s=r.next,a=r.banned_list;return i.token=s,a&&a.length>0&&(i.bannedUsers=a.map((function(o){return new bn(e,o.user)}))),i}return g(t,n),t})(U),Od=(function(n){function t(e,r,i,s){return n.call(this,e,r,i,s)||this}return g(t,n),t.prototype._validate=function(){return n.prototype._validate.call(this)},t.prototype.next=function(){return f(this,void 0,void 0,(function(){var e,r,i,s,a,o;return p(this,(function(u){switch(u.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=C.of(this._iid).requestQueue,r=new Nd(E(E({},this),{token:this._token})),[4,e.send(r)]):[3,2]:[3,5];case 1:return i=u.sent(),s=i.as(kd),a=s.bannedUsers,o=s.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,a];case 2:return[2,[]];case 3:throw T.queryInProgress;case 4:return[3,6];case 5:throw T.invalidParameters;case 6:return[2]}}
2))}))},t})(qt);(function(n){n.SPAM="spam",n.HARASSING="harassing",n.SUSPICIOUS="suspicious",n.INAPPROPRIATE="inappropriate"})(jn||(jn={}));var Dd=(function(n){function t(e){var r=this,i=e.channelUrl,s=e.channelType,a=e.operatorUserIds;return(r=n.call(this)||this).method=k.POST,r.path="".concat(Y(s),"/").concat(encodeURIComponent(i),"/operators"),r.params={operator_ids:a},r}return g(t,n),t})(O);(function(n){function t(){return n!==null&&n.apply(this,arguments)||this}g(t,n)})(U);var Rd=(function(n){function t(e){var r=this,i=e.channelUrl,s=e.channelType,a=e.operatorUserIds;return(r=n.call(this)||this).method=k.DELETE,r.path="".concat(Y(s),"/").concat(encodeURIComponent(i),"/operators"),r.params={operator_ids:a},r}return g(t,n),t})(O);(function(n){function t(e,r){return n.call(this,e,r)||this}g(t,n)})(U);var Ld=(function(n){function t(e){var r=this,i=e.channelUrl,s=e.channelType,a=e.userId;return(r=n.call(this)||this).method=k.GET,r.path="".concat(Y(s),"/").concat(encodeURIComponent(i),"/mute/").concat(encodeURIComponent(a)),r}return g(t,n),t})(O),Ud=(function(n){function t(e,r){var i=n.call(this,e,r)||this;i.isMuted=!1,i.startAt=0,i.endAt=0;var s=r.is_muted,a=r.start_at,o=r.end_at,u=r.remaining_duration,c=r.description;return i.isMuted=s,i.startAt=a,i.endAt=o,i.remainingDuration=u,i.description=c,i}return g(t,n),t})(U),Aa=(function(n){function t(e){var r=this,i=e.channelUrl,s=e.channelType,a=e.keys;return(r=n.call(this)||this).method=k.GET,r.path="".concat(Y(s),"/").concat(encodeURIComponent(i),"/metadata"),r.params={keys:a,include_ts:!0},r}return g(t,n),t})(O),Na=(function(n){function t(e,r){var i=n.call(this,e,r)||this,s=r.metadata,a=r.ts;return i.metadata=s,i.ts=a,i}return g(t,n),t})(U),Md=(function(n){function t(e){var r=this,i=e.channelUrl,s=e.channelType,a=e.metadata;return(r=n.call(this)||this).method=k.POST,r.path="".concat(Y(s),"/").concat(encodeURIComponent(i),"/metadata"),r.params={metadata:a,include_ts:!0},r}return g(t,n),t})(O),Pd=(function(n){function t(e,r){var i,s,a=this;return(a=n.call(this,e,r)||this).metaData=(i=r.metadata)!==null&&i!==void 0?i:{},a.ts=(s=r.ts)!==null&&s!==void 0?s:null,a}return g(t,n),t})(U),xd=(function(n){function t(e){var r=this,i=e.channelUrl,s=e.channelType,a=e.metadata,o=e.upsert;return(r=n.call(this)||this).method=k.PUT,r.path="".concat(Y(s),"/").concat(encodeURIComponent(i),"/metadata"),r.params={metadata:a,include_ts:!0,upsert:o!=null&&o},r}return g(t,n),t})(O),Fd=(function(n){function t(e,r){var i=n.call(this,e,r)||this,s=r.metadata,a=r.ts;return i.metadata=s,i.ts=a,i}return g(t,n),t})(U),y_=(function(n){function t(e,r,i){var s=n.call(this,e,"SYEV",i)||this;return i.data&&(s.created=i.data.created,s.updated=i.data.updated,s.deleted=i.data.deleted),s}return g(t,n),t})(we),qd=(function(n){function t(e){var r=this,i=e.channelUrl,s=e.channelType,a=e.key;return(r=n.call(this)||this).method=k.DELETE,r.path="".concat(Y(s),"/").concat(encodeURIComponent(i),"/metadata/").concat(a),r.params={include_ts:!0},r}return g(t,n),t})(O),zd=(function(n){function t(e,r){var i=n.call(this,e,r)||this,s=r.ts;return i.ts=s,i}return g(t,n),t})(U),Bd=(function(n){function t(e){var r=this,i=e.channelUrl,s=e.channelType;return(r=n.call(this)||this).method=k.DELETE,r.path="".concat(Y(s),"/").concat(encodeURIComponent(i),"/metadata"),r.params={include_ts:!0},r}return g(t,n),t})(O),jd=(function(n){function t(e,r){var i=n.call(this,e,r)||this,s=r.ts;return i.ts=s,i}return g(t,n),t})(U),ka=(function(n){function t(e){var r=this,i=e.channelUrl,s=e.channelType,a=e.keys;return(r=n.call(this)||this).method=k.GET,r.path="".concat(Y(s),"/").concat(encodeURIComponent(i),"/metacounter"),r.params={keys:a},r}return g(t,n),t})(O),Oa=(function(n){function t(e,r){var i=n.call(this,e,r)||this;return i.metaCounter=r,i}return g(t,n),t})(U),Kd=(function(n){function t(e){var r=this,i=e.channelUrl,s=e.channelType,a=e.metaCounter;return(r=n.call(this)||this).method=k.POST,r.path="".concat(Y(s),"/").concat(encodeURIComponent(i),"/metacounter"),r.params={metacounter:a},r}return g(t,n),t})(O),Hd=(function(n){function t(e,r){var i=n.call(this,e,r)||this;return i.metaCounter=r,i}return g(t,n),t})(U),Oi=(function(n){function t(e){var r=this,i=e.channelUrl,s=e.channelType,a=e.metaCounter,o=e.upsert,u=o!==void 0&&o,c=e.mode,l=c===void 0?"set":c;return(r=n.call(this)||this).method=k.PUT,r.path="".concat(Y(s),"/").concat(encodeURIComponent(i),"/metacounter"),r.params={metacounter:a,upsert:u,mode:l},r}return g(t,n),t})(O),Di=(function(n){function t(e,r){var i=n.call(this,e,r)||this;return i.metaCounter=r,i}return g(t,n),t})(U),b_=(function(n){function t(e,r,i){var s=n.call(this,e,"SYEV",i)||this;return i.data&&(s.created=i.data.created,s.updated=i.data.updated,s.deleted=i.data.deleted),s}return g(t,n),t})(we),Vd=(function(n){function t(e){var r=this,i=e.channelUrl,s=e.channelType,a=e.key;return(r=n.call(this)||this).method=k.DELETE,r.path="".concat(Y(s),"/").concat(encodeURIComponent(i),"/metacounter/").concat(a),r.params={},r}return g(t,n),t})(O);(function(n){function t(e,r){return n.call(this,e,r)||this}g(t,n)})(U);var Gd=(function(n){function t(e){var r=this,i=e.channelUrl,s=e.channelType;return(r=n.call(this)||this).method=k.DELETE,r.path="".concat(Y(s),"/").concat(encodeURIComponent(i),"/metacounter"),r.params={},r}return g(t,n),t})(O);(function(n){function t(){return n!==null&&n.apply(this,arguments)||this}g(t,n)})(U);var Qd=(function(n){function t(e){var r=this,i=e.channelUrl,s=e.channelType,a=e.userId,o=e.seconds,u=e.description;return(r=n.call(this)||this).method=k.POST,r.path="".concat(Y(s),"/").concat(encodeURIComponent(i),"/mute"),r.params={user_id:a,seconds:o,description:u},r}return g(t,n),t})(O);(function(n){function t(e,r){return n.call(this,e,r)||this}g(t,n)})(U);var E_=(function(n){function t(e,r,i){var s=n.call(this,e,"SYEV",i)||this;return s.user=new bn(e,i.data),s}return g(t,n),t})(we),$d=(function(n){function t(e){var r=this,i=e.channelUrl,s=e.channelType,a=e.userId;return(r=n.call(this)||this).method=k.DELETE,r.path="".concat(Y(s),"/").concat(encodeURIComponent(i),"/mute/").concat(encodeURIComponent(a)),r}return g(t,n),t})(O);(function(n){function t(){return n!==null&&n.apply(this,arguments)||this}g(t,n)})(U);var w_=(function(n){function t(e,r,i){var s=n.call(this,e,"SYEV",i)||this;return s.user=new bn(e,i.data),s}return g(t,n),t})(we),Wd=(function(n){function t(e){var r=this,i=e.channelUrl,s=e.channelType,a=e.userId,o=e.seconds,u=e.description;return(r=n.call(this)||this).method=k.POST,r.path="".concat(Y(s),"/").concat(encodeURIComponent(i),"/ban"),r.params=M({user_id:a,seconds:o,description:u}),r}return g(t,n),t})(O);(function(n){function t(){return n!==null&&n.apply(this,arguments)||this}g(t,n)})(U);var I_=(function(n){function t(e,r,i){var s=n.call(this,e,"SYEV",i)||this;return s.user=new bn(e,i.data),i.data.member_count&&(s.memberCount=i.data.member_count),i.data.joined_member_count&&(s.joinedMemberCount=i.data.joined_member_count),s}return g(t,n),t})(we),Yd=(function(n){function t(e){var r=this,i=e.channelUrl,s=e.channelType,a=e.userId;return(r=n.call(this)||this).method=k.DELETE,r.path="".concat(Y(s),"/").concat(encodeURIComponent(i),"/ban/").concat(encodeURIComponent(a)),r}return g(t,n),t})(O);(function(n){function t(){return n!==null&&n.apply(this,arguments)||this}g(t,n)})(U);var T_=(function(n){function t(e,r,i){var s=n.call(this,e,"SYEV",i)||this;return s.user=new bn(e,i.data),s}return g(t,n),t})(we),Da=(function(n){function t(e){var r=this,i=e.channelUrl,s=e.channelType,a=e.freezing;return(r=n.call(this)||this).method=k.PUT,r.path="".concat(Y(s),"/").concat(encodeURIComponent(i),"/freeze"),r.params={freeze:a},r}return g(t,n),t})(O);(function(n){function t(){return n!==null&&n.apply(this,arguments)||this}g(t,n)})(U);var S_=(function(n){function t(e,r,i){var s=n.call(this,e,"SYEV",i)||this;return s.freeze=i.data.freeze,s}return g(t,n),t}
2)(we),_s=function(n){return n instanceof ln?n._custom?"custom":n.name:n},vs=function(n){if(n instanceof ln&&n._custom)return n.name},Zd=(function(n){function t(e){var r=this,i=e.channelUrl,s=e.channelType,a=e.category,o=e.userId,u=e.description;return(r=n.call(this)||this).method=k.POST,r.path="".concat(fo(s),"/").concat(encodeURIComponent(i)),r.params=M({report_category:_s(a),reporting_user_id:o,report_description:u,custom_report_category_name:vs(a)}),r}return g(t,n),t})(O),Xd=(function(n){function t(e){var r=this,i=e.channelUrl,s=e.channelType,a=e.category,o=e.userId,u=e.offendingUserId,c=e.description;return(r=n.call(this)||this).method=k.POST,r.path="".concat(Ki,"/users/").concat(u),r.params=M({channel_url:i,channel_type:s===oe.OPEN?"open_channels":"group_channels",report_category:_s(a),reporting_user_id:o,report_description:c,custom_report_category_name:vs(a)}),r}return g(t,n),t})(O),Jd=(function(n){function t(e){var r=this,i=e.channelUrl,s=e.channelType,a=e.category,o=e.userId,u=e.offendingUserId,c=e.messageId,l=e.description;return(r=n.call(this)||this).method=k.POST,r.path="".concat(fo(s),"/").concat(encodeURIComponent(i),"/messages/").concat(c),r.params=M({report_category:_s(a),reporting_user_id:o,report_description:l,offending_user_id:u,custom_report_category_name:vs(a)}),r}return g(t,n),t})(O),eh=(function(n){function t(e){var r=[];return e.mentionType===Re.USERS&&(e.mentionedUserIds?r=e.mentionedUserIds:e.mentionedUsers&&(r=e.mentionedUsers.map((function(i){return i.userId})))),n.call(this,{code:"MESG",ackRequired:!0,payload:M(B({channel_url:e.channelUrl,message:e.message,data:e.data,custom_type:e.customType,metaarray:e.metaArrays,mention_type:e.mentionType,mentioned_user_ids:r,mentioned_message_template:e.mentionedMessageTemplate,target_langs:e.translationTargetLanguages,push_option:e.pushNotificationDeliveryOption&&e.pushNotificationDeliveryOption!==it.DEFAULT?e.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:e.appleCriticalAlertOptions,silent:e.silent,reply_to_channel:e.isReplyToChannel,parent_message_id:e.parentMessageId?e.parentMessageId:null,req_id:e.reqId,poll_id:e.pollId,pin_message:e.isPinnedMessage,extended_message_payload:e.extendedMessagePayload}))})||this}return g(t,n),t})(qe),th=(function(n){function t(e,r,i){var s,a,o,u,c=this;(c=n.call(this,e,"MESG",i)||this).message=new ke(e,i);var l=C.of(e).sdkState;return c.isMentioned=Gn(c.message.mentionType,(o=(s=c.message.mentionedUserIds)!==null&&s!==void 0?s:(a=c.message.mentionedUsers)===null||a===void 0?void 0:a.map((function(d){return d.userId})))!==null&&o!==void 0?o:[],l.userId),c.forceUpdateLastMessage=(u=i.force_update_last_message)!==null&&u!==void 0&&u,c}return g(t,n),t})(we),Ra=(function(n){function t(e){var r=null;return e.mentionType===Re.USERS&&(e.mentionedUserIds?r=e.mentionedUserIds:e.mentionedUsers&&(r=e.mentionedUsers.map((function(i){return i.userId})))),n.call(this,{code:"MEDI",ackRequired:!0,payload:M(B({channel_url:e.channelUrl,msg_id:e.messageId,message:e.message,data:e.data,custom_type:e.customType,metaarray:e.metaArrayParams,mention_type:e.mentionType,mentioned_user_ids:r,mentioned_message_template:e.mentionedMessageTemplate,apple_critical_alert_options:e.appleCriticalAlertOptions?mt.payloadify(e.appleCriticalAlertOptions):null,poll_id:e.pollId}))})||this}return g(t,n),t})(qe),La=(function(n){function t(e,r,i){var s,a,o,u,c,l=this;(l=n.call(this,e,"MEDI",i)||this).message=new ke(e,i);var d=C.of(e).sdkState;return l.mentionCountChange=po({mentionType:(s=i.old_values)===null||s===void 0?void 0:s.mention_type,mentionedUserIds:(o=(a=i.old_values)===null||a===void 0?void 0:a.mentioned_user_ids)!==null&&o!==void 0?o:[]}
2,B({mentionType:l.message.mentionType,mentionedUserIds:(u=l.message.mentionedUserIds)!==null&&u!==void 0?u:(c=l.message.mentionedUsers)===null||c===void 0?void 0:c.map((function(_){return _.userId}))}),d.userId),l}return g(t,n),t})(we),Ua=(function(n){function t(e){var r=null;return e.mentionType===Re.USERS&&(e.mentionedUserIds?r=e.mentionedUserIds:e.mentionedUsers&&(r=e.mentionedUsers.map((function(i){return i.userId})))),n.call(this,{code:"FEDI",ackRequired:!0,payload:M(B({channel_url:e.channelUrl,msg_id:e.messageId,data:e.data,custom_type:e.customType,metaarray:e.metaArrayParams,mention_type:e.mentionType,mentioned_user_ids:r,apple_critical_alert_options:e.appleCriticalAlertOptions}))})||this}return g(t,n),t})(qe),Ma=(function(n){function t(e,r,i){var s,a,o,u,c,l=this;(l=n.call(this,e,"FEDI",i)||this).message=new he(e,i);var d=C.of(e).sdkState;return l.mentionCountChange=po({mentionType:(s=i.old_values)===null||s===void 0?void 0:s.mention_type,mentionedUserIds:(o=(a=i.old_values)===null||a===void 0?void 0:a.mentioned_user_ids)!==null&&o!==void 0?o:[]}
2,B({mentionType:l.message.mentionType,mentionedUserIds:(u=l.message.mentionedUserIds)!==null&&u!==void 0?u:(c=l.message.mentionedUsers)===null||c===void 0?void 0:c.map((function(_){return _.userId}))}),d.userId),l}return g(t,n),t})(we),nh=(function(n){function t(e){var r=e.channelType,i=e.channelUrl,s=e.messageId,a=e.reactionKey,o=n.call(this)||this;return o.method=k.POST,o.path="".concat(Y(r),"/").concat(encodeURIComponent(i),"/messages/").concat(s,"/reactions"),o.params={reaction:a},o}return g(t,n),t})(O),rh=(function(n){function t(e,r){var i=n.call(this,e,r)||this;return i.reactionEvent=new uu(r),i}return g(t,n),t})(U),ih=(function(n){function t(e){var r=e.channelType,i=e.channelUrl,s=e.messageId,a=e.reactionKey,o=n.call(this)||this;return o.method=k.DELETE,o.path="".concat(Y(r),"/").concat(encodeURIComponent(i),"/messages/").concat(s,"/reactions"),o.params={reaction:a},o}return g(t,n),t})(O),sh=(function(n){function t(e,r){var i=n.call(this,e,r)||this;return i.reactionEvent=new uu(E({},r)),i}return g(t,n),t})(U),ah=(function(n){function t(e){var r=e.channelType,i=e.channelUrl,s=e.messageId,a=e.translationTargetLanguages,o=n.call(this)||this;return o.method=k.POST,o.path="".concat(Y(r),"/").concat(encodeURIComponent(i),"/messages/").concat(encodeURIComponent(s),"/translation"),o.params={target_langs:a},o}return g(t,n),t})(O),oh=(function(n){function t(e,r){var i=n.call(this,e,r)||this;return i.message=new ke(e,r),i}return g(t,n),t})(U),uh=(function(n){function t(e){var r,i=this;i=n.call(this)||this;var s=[];e.mentionType===Re.USERS&&(e.mentionedUserIds?s=e.mentionedUserIds:e.mentionedUsers&&(s=e.mentionedUsers.map((function(u){return u.userId}))));var a=e.channelType,o=e.channelUrl;return i.method=k.POST,i.path="".concat(Y(a),"/").concat(encodeURIComponent(o),"/scheduled_messages"),i.params=M(B({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:Ur.USER,message:e.message,custom_type:e.customType,data:e.data,mention_type:e.mentionType,mentioned_user_ids:s,sorted_metaarray:(r=e.metaArrays)===null||r===void 0?void 0:r.map((function(u){return He.payloadify(u)})),apple_critical_alert_options:e.appleCriticalAlertOptions?mt.payloadify(e.appleCriticalAlertOptions):null,target_langs:e.translationTargetLanguages,push_option:e.pushNotificationDeliveryOption})),i}return g(t,n),t})(O),ch=(function(n){function t(e,r){var i=n.call(this,e,r)||this;return i.message=new ke(e,r),i}return g(t,n),t})(U),lh=(function(n){function t(e){var r,i,s=this;s=n.call(this)||this;var a=[];e.mentionType===Re.USERS&&(e.mentionedUserIds?a=e.mentionedUserIds:e.mentionedUsers&&(a=e.mentionedUsers.map((function(c){return c.userId}))));var o=e.channelType,u=e.channelUrl;return s.method=k.POST,s.path="".concat(Y(o),"/").concat(encodeURIComponent(u),"/scheduled_messages"),s.params=B({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:Ur.FILE,url:e.fileUrl,file_name:e.fileName,file_size:e.fileSize,file_type:e.mimeType,thumbnails:(r=e._thumbnails)===null||r===void 0?void 0:r.map((function(c){return zt.payloadify(c)})),custom_type:e.customType,data:e.data,require_auth:e.requireAuth,mention_type:e.mentionType,mentioned_user_ids:a,sorted_metaarray:(i=e.metaArrays)===null||i===void 0?void 0:i.map((function(c){return He.payloadify(c)})),apple_critical_alert_options:e.appleCriticalAlertOptions?mt.payloadify(e.appleCriticalAlertOptions):null,push_option:e.pushNotificationDeliveryOption}),s}return g(t,n),t})(O),dh=(function(n){function t(e,r){var i=n.call(this,e,r)||this;return i.message=new he(e,r),i}return g(t,n),t})(U),hh=(function(n){function t(e){var r=e.pollId,i=e.title,s=e.data,a=e.allowUserSuggestion,o=e.allowMultipleVotes,u=e.closeAt,c=n.call(this)||this;return c.method=k.PUT,c.path="".concat(at,"/").concat(encodeURIComponent(r)),c.params={title:i,data:s,allow_user_suggestion:a,allow_multiple_votes:o,close_at:u},c}return g(t,n),t})(O),fh=(function(n){function t(e,r){var i=n.call(this,e,r)||this;return i.poll=new Xe(e,r),i}return g(t,n),t})(U),ph=(function(n){function t(e){var r=e.pollId,i=n.call(this)||this;return i.method=k.DELETE,i.path="".concat(at,"/").concat(encodeURIComponent(r)),i}return g(t,n),t})(O);(function(n){function t(){return n!==null&&n.apply(this,arguments)||this}g(t,n)})(U);var _h=(function(n){function t(e){var r=e.pollId,i=n.call(this)||this;return i.method=k.PUT,i.path="".concat(at,"/").concat(encodeURIComponent(r),"/close"),i}return g(t,n),t})(O),vh=(function(n){function t(e,r){var i=n.call(this,e,r)||this;return i.poll=new Xe(e,r),i}return g(t,n),t})(U),mh=(function(n){function t(e){var r=e.channelUrl,i=e.channelType,s=e.pollId,a=e.optionText,o=n.call(this)||this;return o.method=k.POST,o.path="".concat(at,"/").concat(encodeURIComponent(s),"/options"),o.params={channel_url:r,channel_type:i,text:a},o}return g(t,n),t})(O),gh=(function(n){function t(e,r){var i=n.call(this,e,r)||this;return i.poll=new Xe(e,r),i}return g(t,n),t})(U),yh=(function(n){function t(e){var r=e.pollId,i=e.pollOptionId,s=e.optionText,a=n.call(this)||this;return a.method=k.PUT,a.path="".concat(at,"/").concat(encodeURIComponent(r),"/options/").concat(encodeURIComponent(i)),a.params={text:s},a}return g(t,n),t})(O),bh=(function(n){function t(e,r){var i=n.call(this,e,r)||this;return i.poll=new Xe(e,r),i}return g(t,n),t})(U),Eh=(function(n){function t(e){var r=e.pollId,i=e.pollOptionId,s=n.call(this)||this;return s.method=k.DELETE,s.path="".concat(at,"/").concat(encodeURIComponent(r),"/options/").concat(encodeURIComponent(i)),s}return g(t,n),t})(O);(function(n){function t(){return n!==null&&n.apply(this,arguments)||this}g(t,n)})(U);var wh=(function(n){function t(e){var r=e.reqId,i=e.channelType,s=e.channelUrl,a=e.pollId,o=e.pollOptionIds;return n.call(this,{code:"VOTE",ackRequired:!0,payload:M({req_id:r,channel_type:i===oe.OPEN?"open_channels":"group_channels",channel_url:s,poll_id:a,option_ids:o})})||this}return g(t,n),t})(qe),Ih=(function(n){function t(e,r,i){var s=n.call(this,e,"VOTE",i)||this;return s.event=new ql(i),s.channelUrl=i.channel_url,s.channelType=i.channel_type,s}return g(t,n),t})(we),C_=100,Th="GroupChannel",Sh="url",A_=100,ms="Message",Ch="messageId",vu="NotificationMessage",Ah="notificationId",Nh="Poll",kh="pollId",Oh="FeedChannel",Dh="url",mu="UserInfo",Rh="userId";function N_(n){var t,e,r;return(t=n.messageParams)!==null&&t!==void 0?t:B(E(E({},n),{isReplyToChannel:!1,mentionedUserIds:(e=n.mentionedUserIds)!==null&&e!==void 0?e:(r=n.mentionedUsers)===null||r===void 0?void 0:r.map((function(i){return i.userId})),pushNotificationDeliveryOption:it.DEFAULT,isPinnedMessage:!1,fileInfoList:n.fileInfoList.map((function(i){var s;return{fileUrl:i.plainUrl,fileName:i.fileName,fileSize:i.fileSize,mimeType:i.mimeType,thumbnailSizes:(s=i.thumbnails)===null||s===void 0?void 0:s.map((function(a){return{maxWidth:a.width,maxHeight:a.height}})),_thumbnails:i.thumbnails,_uploadedMetaData:{requireAuth:i._requireAuth,isUploaded:!0}}}))}))}var Lh=E(E({},ei),{fileInfoList:[],message:""}),Uh=function(n){return(rt(n.file)||S("string",n.fileUrl))&&S("string",n.fileName,!0)&&S("string",n.mimeType,!0)&&S("number",n.fileSize,!0)&&(n.thumbnailSizes===void 0||Array.isArray(n.thumbnailSizes)&&n.thumbnailSizes.every((function(t){return t.maxWidth>0&&t.maxHeight>0})))},Mh=(function(n){function t(){var e=n!==null&&n.apply(this,arguments)||this;return e._onFileUploaded=fe,e}return g(t,n),t.prototype._triggerOnFileUploaded=function(e,r,i,s){this._onFileUploaded(e,r,i,s)},t.prototype.onFileUploaded=function(e){return this._onFileUploaded=e,this},t.prototype.onPending=function(e){return n.prototype.onPending.call(this,e),this},t.prototype.onFailed=function(e){return n.prototype.onFailed.call(this,e),this},t.prototype.onSucceeded=function(e){return n.prototype.onSucceeded.call(this,e),this},t})(Nr),Ph=(function(n){function t(e,r){var i=n.call(this,e)||this;return i.message=null,i.message=ot(e,r.message),i}return g(t,n),t})(be),xh=(function(n){function t(e){var r=this,i=e.channelType,s=e.channelUrl,a=e.limit,o=e.token,u=e.includeReactions,c=e.includeMetaArray,l=e.includeParentMessageInfo,d=e.includeThreadInfo,_=e.includePollDetails;return(r=n.call(this)||this).method=k.GET,r.path="".concat(Y(i),"/").concat(encodeURIComponent(s),"/pinned_messages"),r.params=M({limit:a,token:o,include_reactions_summary:u,with_sorted_meta_array:c,include_thread_info:d,include_parent_message_info:l,include_poll_details:_}),r}return g(t,n),t})(O),Fh=(function(n){function t(e,r){var i=n.call(this,e,r)||this,s=r.pinned_messages,a=r.has_more,o=r.next;return i.pinnedMessages=s.map((function(u){return new Ph(e,u)})),i.hasMore=a,i.token=o,i}return g(t,n),t})(U),qh=(function(n){function t(e,r,i,s){var a=n.call(this,e,r,i,s)||this;return a.includeMetaArray=s.includeMetaArray,a.includeReactions=s.includeReactions,a.includeParentMessageInfo=s.includeParentMessageInfo,a.includeThreadInfo=s.includeThreadInfo,a.includePollDetails=s.includePollDetails,a}return g(t,n),t.prototype._validate=function(){return n.prototype._validate.call(this)&&S("boolean",this.includeMetaArray,!0)&&S("boolean",this.includeReactions,!0)&&S("boolean",this.includeParentMessageInfo,!0)&&S("boolean",this.includeThreadInfo,!0)&&S("boolean",this.includePollDetails,!0)},t.prototype.next=function(){return f(this,void 0,void 0,(function(){var e,r,i,s,a,o,u;return p(this,(function(c){switch(c.label){case 0:return this._val
2idate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=C.of(this._iid).requestQueue,r=new xh(E(E({},this),{token:this._token})),[4,e.send(r)]):[3,2]:[3,5];case 1:return i=c.sent(),s=i.as(Fh),a=s.pinnedMessages,o=s.hasMore,u=s.token,this._token=u,this._hasNext=!!o,this._isLoading=!1,[2,a];case 2:return[2,[]];case 3:throw T.queryInProgress;case 4:return[3,6];case 5:throw T.invalidParameters;case 6:return[2]}}))}))},t})(qt),zh=(function(n){function t(e){var r=e.channelType,i=e.channelUrl,s=e.messageId,a=n.call(this)||this;return a.method=k.POST,a.path="".concat(Y(r),"/").concat(encodeURIComponent(i),"/messages/").concat(s,"/pin"),a}return g(t,n),t})(O);(function(n){function t(e,r){return n.call(this,e,r)||this}g(t,n)})(U);var Bh=(function(n){function t(e){var r=e.channelType,i=e.channelUrl,s=e.messageId,a=n.call(this)||this;return a.method=k.DELETE,a.path="".concat(Y(r),"/").concat(encodeURIComponent(i),"/messages/").concat(s,"/pin"),a}return g(t,n),t})(O);(function(n){function t(e,r){return n.call(this,e,r)||this}g(t,n)})(U);var xe,k_=2;(function(n){n.SEND="send",n.RESEND="resend",n.COPY="copy"})(xe||(xe={}));var se,O_=(function(n){function t(e,r){var i,s,a,o,u,c,l,d=this;return(d=n.call(this,e)||this)._name="",d._createdAt=0,d.pinnedMessageIds=[],d.channelType=oe.BASE,d.coverUrl="",d.customType="",d.data="",d.isFrozen=!1,d.isEphemeral=!1,d.creator=null,d._messageCollectionLastAccessedAt=0,d._url=r.channel_url,d._name=(i=r.name)!==null&&i!==void 0?i:"",d._createdAt=1e3*r.created_at,d.coverUrl=(s=r.cover_url)!==null&&s!==void 0?s:"",d.customType=(a=r.custom_type)!==null&&a!==void 0?a:"",d.data=(o=r.data)!==null&&o!==void 0?o:"",d.isFrozen=(u=r.freeze)!==null&&u!==void 0&&u,d.isEphemeral=(c=r.is_ephemeral)!==null&&c!==void 0&&c,d.creator=r.created_by?new G(d._iid,r.created_by):null,r.metadata&&Object.keys(r.metadata).length>0&&r.ts?(d._cachedMetaData=new Map,Object.keys(r.metadata).forEach((function(_){d._cachedMetaData.set(_,{value:r.metadata[_],isRemoved:!1,updatedAt:r.ts})}))):typeof r.metadata=="string"&&(d._cachedMetaData=new Map(Object.entries(JSON.parse(r.metadata)))),d.pinnedMessageIds=(l=r.pinned_message_ids)!==null&&l!==void 0?l:[],d}return g(t,n),Object.defineProperty(t.prototype,"url",{get:function(){return this._url},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"name",{get:function(){return this._name},set:function(e){this._name=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"createdAt",{get:function(){return this._createdAt},enumerable:!1,configurable:!0}),t.prototype.toJSON=function(){return E(E({},this),{url:this._url,name:this._name,createdAt:this._createdAt})},t.payloadify=function(e,r){r===void 0&&(r=!1);var i=E(E({},n.payloadify.call(this,e)),{channel_url:e.url,name:e.name,cover_url:e.coverUrl,custom_type:e.customType,data:e.data,freeze:e.isFrozen,is_ephemeral:e.isEphemeral,created_by:e.creator?G.payloadify(e.creator):null,created_at:e.createdAt/1e3,metadata:e.cachedMetaData,pinned_message_ids:e.pinnedMessageIds});return r?i:M(B(i))},t.prototype.isGroupChannel=function(){return this.channelType===oe.GROUP},t.prototype.isOpenChannel=function(){return this.channelType===oe.OPEN},t.prototype.isFeedChannel=function(){return this.channelType===oe.FEED},Object.defineProperty(t.prototype,"cachedMetaData",{get:function(){var e={};return this._cachedMetaData&&this._cachedMetaData.forEach((function(r,i){r.isRemoved||(e[i]=r.value)})),e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"messageCollectionLastAccessedAt",{get:function(){return this._messageCollectionLastAccessedAt},enumerable:!1,configurable:!0}),t.prototype._serializeCachedMetaData=function(){return this._cachedMetaData?{cachedMetaData:JSON.stringify(Object.fromEntries(this._cachedMetaData))}:{}},t.prototype._updateMessageCollectionLastAccessedAt=function(){this._messageCollectionLastAccessedAt=Date.now()},t.prototype._update=function(e){Object.assign(this,e)},t.prototype._upsertCachedMetaData=function(e,r){var i=this;Object.keys(e).forEach((function(s){i._cachedMetaData||(i._cachedMetaData=new Map);var a=i._cachedMetaData.get(s);(!a||a.updatedAt<=r)&&i._cachedMetaData.set(s,{value:e[s],isRemoved:!1,updatedAt:r})}))},t.prototype._updateCachedMetaData=function(e,r){var i=this,s=!1;return this._cachedMetaData?this._cachedMetaData.forEach((function(a,o){var u;a.updatedAt<=r&&(i._cachedMetaData.set(o,{value:(u=e[o])!==null&&u!==void 0?u:a.value,isRemoved:!e[o],updatedAt:r}),s=!0)})):(this._cachedMetaData=new Map,Object.keys(e).forEach((function(a){i._c
2achedMetaData.set(a,{value:e[a],isRemoved:!1,updatedAt:r})})),s=!0),{isUpdated:s}},t.prototype._removeFromCachedMetaData=function(e,r){var i=this;this._cachedMetaData&&e.forEach((function(s){var a=i._cachedMetaData.get(s);a&&a.updatedAt<r&&(a.isRemoved=!0,a.updatedAt=r)}))},t.prototype._clearCachedMetaData=function(){this._cachedMetaData&&this._cachedMetaData.clear()},t.prototype._runIfHandleableWithGroupChannel=function(e){this.isGroupChannel()?e(this):this.isFeedChannel()&&e(this.groupChannel)},t.prototype._generateRequestId=function(){return"rq-".concat(st())},t.prototype.isIdentical=function(e){return e&&this.url===e.url},t.prototype.isEqual=function(e){return so(this,e)},t.prototype.createOperatorListQuery=function(e){return e===void 0&&(e={}),new Id(this._iid,this.url,this.channelType,e)},t.prototype.createMutedUserListQuery=function(e){return e===void 0&&(e={}),new Ad(this._iid,this.url,this.channelType,e)},t.prototype.createBannedUserListQuery=function(e){return e===void 0&&(e={}),new Od(this._iid,this.url,this.channelType,e)},t.prototype.createPreviousMessageListQuery=function(e){return e===void 0&&(e={}),new Td(this._iid,this.url,this.channelType,e)},t.prototype.createPinnedMessageListQuery=function(e){return e===void 0&&(e={}),new qh(this._iid,this.url,this.channelType,e)},t.prototype.addOperators=function(e){return f(this,void 0,void 0,(function(){var r,i;return p(this,(function(s){switch(s.label){case 0:return R(J("string",e)).throw(T.invalidParameters),r=C.of(this._iid).requestQueue,i=new Dd({channelUrl:this.url,channelType:this.channelType,operatorUserIds:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},t.prototype.removeOperators=function(e){return f(this,void 0,void 0,(function(){var r,i;return p(this,(function(s){switch(s.label){case 0:return R(J("string",e)).throw(T.invalidParameters),r=C.of(this._iid).requestQueue,i=new Rd({channelUrl:this.url,channelType:this.channelType,operatorUserIds:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},t.prototype.getMyMutedInfo=function(){return f(this,void 0,void 0,(function(){var e,r,i,s,a,o,u,c,l,d,_;return p(this,(function(h){switch(h.label){case 0:return e=C.of(this._iid),r=e.sdkState,i=e.requestQueue,s=new Ld({channelUrl:this.url,channelType:this.channelType,userId:r.userId}),[4,i.send(s)];case 1:return a=h.sent(),o=a.as(Ud),u=o.isMuted,c=o.startAt,l=o.endAt,d=o.remainingDuration,_=o.description,[2,{isMuted:u,startAt:c,endAt:l,remainingDuration:d,description:_}]}}))}))},t.prototype.getMetaData=function(e){return f(this,void 0,void 0,(function(){var r,i,s,a,o,u;return p(this,(function(c){switch(c.label){case 0:return R(J("string",e)).throw(T.invalidParameters),r=C.of(this._iid).requestQueue,i=new Aa({channelUrl:this.url,channelType:this.channelType,keys:e}),[4,r.send(i)];case 1:return s=c.sent(),a=s.as(Na),o=a.metadata,u=a.ts,this._upsertCachedMetaData(o,u),[2,o]}}))}))},t.prototype.getAllMetaData=function(){return f(this,void 0,void 0,(function(){var e,r,i,s,a,o;return p(this,(function(u){switch(u.label){case 0:return e=C.of(this._iid).requestQueue,r=new Aa({channelUrl:this.url,channelType:this.channelType,keys:[]}),[4,e.send(r)];case 1:return i=u.sent(),s=i.as(Na),a=s.metadata,o=s.ts,this._updateCachedMetaData(a,o),[2,a]}}))}))},t.prototype.createMetaData=function(e){return f(this,void 0,void 0,(function(){var r,i,s,a;return p(this,(function(o){switch(o.label){case 0:return r=C.of(this._iid).requestQueue,i=new Md({channelUrl:this.url,channelType:this.channelType,metadata:e}),[4,r.send(i)];case 1:return s=o.sent(),a=s.as(Pd).metaData,this._upsertCachedMetaData(a,0),[2,a]}}))}))},t.prototype.updateMetaData=function(e,r){return r===void 0&&(r=!1),f(this,void 0,void 0,(function(){var i,s,a,o,u,c;return p(this,(function(l){switch(l.label){case 0:return i=C.of(this._iid).requestQueue,s=new xd({channelUrl:this.url,channelType:this.channelType,metadata:e,upsert:r}),[4,i.send(s)];case 1:return a=l.sent(),o=a.as(Fd),u=o.metadata,c=o.ts,this._upsertCachedMetaData(u,c),[2,u]}}))}))},t.prototype.deleteMetaData=function(e){return f(this,void 0,void 0,(function(){var r,i,s,a;return p(this,(function(o){switch(o.label){case 0:return R(S("string",e)).throw(T.invalidParameters),r=C.of(this._iid).requestQueue,i=new qd({channelUrl:this.url,channelType:this.channelType,key:e}),[4,r.send(i)];case 1:return s=o.sent(),a=s.as(zd).ts,this._removeFromCachedMetaData([e],a),[2]}}))}))},t.prototype.deleteAllMetaData=function(){return f(this,void 0,void 0,(function(){var e,r,i,s;return p(this,(function(a){switch(a.label){case 0:return e=C.of(this._iid).requestQueue,r=new Bd({channelUrl:this.url,channelType:this.channelType}),[4,e.send(r)];case 1:return i=a.sent(),s=i.as(jd).ts,this._removeFromCachedMetaData(V([],K(this._cachedMetaData.keys()),!1),s),[2]}}))}))},t.prototype.getMetaCounters=function(e){return f(this,void 0,void 0,(function(){var r,i,s;return p(this,(function(a){switch(a.label){case 0:return R(J("string",e)).throw(T.invalidParameters),r=C.of(this._iid).requestQueue,i=new ka({channelUrl:this.url,channelType:this.channelType,keys:e}),[4,r.send(i)];case 1:return s=a.sent(),[2,s.as(Oa).metaCounter]}}))}))},t.prototype.getAllMetaCounters=function(){return f(this,void 0,void 0,(function(){var e,r,i;return p(this,(function(s){switch(s.label){case 0:return e=C.of(this._iid).requestQueue,r=new ka({channelUrl:this.url,channelType:this.channelType,keys:[]}),[4,e.send(r)];case 1:return i=s.sent(),[2,i.as(Oa).metaCounter]}}))}))},t.prototype.createMetaCounters=function(e){return f(this,void 0,void 0,(function(){var r,i,s;return p(this,(function(a){switch(a.label){case 0:return r=C.of(this._iid).requestQueue,i=new Kd({channelUrl:this.url,channelType:this.channelType,metaCounter:e}),[4,r.send(i)];case 1:return s=a.sent(),[2,s.as(Hd).metaCounter]}}))}))},t.prototype.updateMetaCounters=function(e,r){return r===void 0&&(r=!1),f(this,void 0,void 0,(function(){var i,s,a;return p(this,(function(o){switch(o.label){case 0:return i=C.of(this._iid).requestQueue,s=new Oi({channelUrl:this.url,channelType:this.channelType,metaCounter:e,upsert:r}),[4,i.send(s)];case 1:return a=o.sent(),[2,a.as(Di).metaCounter]}}))}))},t.prototype.increaseMetaCounters=function(e){return f(this,void 0,void 0,(function(){var r,i,s;return p(this,(function(a){switch(a.label){case 0:return r=C.of(this._iid).requestQueue,i=new Oi({channelUrl:this.url,channelType:this.channelType,metaCounter:e,upsert:!1,mode:"increase"}),[4,r.send(i)];case 1:return s=a.sent(),[2,s.as(Di).metaCounter]}}))}))},t.prototype.decreaseMetaCounters=function(e){return f(this,void 0,void 0,(function(){var r,i,s;return p(this,(function(a){switch(a.label){case 0:return r=C.of(this._iid).requestQueue,i=new Oi({channelUrl:this.url,channelType:this.channelType,metaCounter:e,upsert:!1,mode:"decrease"}),[4,r.send(i)];case 1:return s=a.sent(),[2,s.as(Di).metaCounter]}}))}))},t.prototype.deleteMetaCounter=function(e){return f(this,void 0,void 0,(function(){var r,i;return p(this,(function(s){switch(s.label){case 0:return R(S("string",e)).throw(T.invalidParameters),r=C.of(this._iid).requestQueue,i=new Vd({channelUrl:this.url,channelType:this.channelType,key:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},t.prototype.deleteAllMetaCounters=function(){return f(this,void 0,void 0,(function(){var e,r;return p(this,(function(i){switch(i.label){case 0:return e=C.of(this._iid).requestQueue,r=new Gd({channelUrl:this.url,channelType:this.channelType}),[4,e.send(r)];case 1:return i.sent(),[2]}}))}))},t.prototype.muteUser=function(e,r,i){return f(this,void 0,void 0,(function(){return p(this,(function(s){return[2,this.muteUserWithUserId(e.userId,r,i)]}))}))},t.prototype.muteUserWithUserId=function(e,r,i){return f(this,void 0,void 0,(function(){var s,a;return p(this,(function(o){switch(o.label){case 0:return R(S("string",e)&&S("number",r,!0)&&S("string",i,!0)).throw(T.invalidParameters),s=C.of(this._iid).requestQueue,a=new Qd({channelUrl:this.url,channelType:this.channelType,userId:e,seconds:r,description:i}),[4,s.send(a)];case 1:return o.sent(),[2]}}))}))},t.prototype.unmuteUser=function(e){return f(this,void 0,void 0,(function(){return p(this,(function(r){return[2,this.unmuteUserWithUserId(e.userId)]}))}))},t.prototype.unmuteUserWithUserId=function(e){return f(this,void 0,void 0,(function(){var r,i;return p(this,(function(s){switch(s.label){case 0:return R(S("string",e)).throw(T.invalidParameters),r=C.of(this._iid).requestQueue,i=new $d({channelUrl:this.url,channelType:this.channelType,userId:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},t.prototype.banUser=function(e,r,i){return f(this,void 0,void 0,(function(){return p(this,(function(s){return[2,this.banUserWithUserId(e.userId,r,i)]}))}))},t.prototype.banUserWithUserId=function(e,r,i){return f(this,void 0,void 0,(function(){var s,a;return p(this,(function(o){switch(o.label){case 0:return R(S("string",e)&&S("number",r,!0)&&S("string",i,!0)).throw(T.invalidParameters),s=C.of(this._iid).requestQueue,a=new Wd({channelUrl:this.url,channelType:this.channelType,userId:e,seconds:r,description:i}),[4,s.send(a)];case 1:return o.sent(),[2]}}))}))},t.prototype.unbanUser=function(e){return f(this,void 0,void 0,(function(){return p(this,(function(r){return[2,this.unbanUserWithUserId(e.userId)]}))}))},t.prototype.unbanUserWithUserId=function(e){return f(this,void 0,void 0,(function(){var r,i;return p(this,(function(s){switch(s.label){case 0:return R(S("string",e)).throw(T.invalidParameters),r=C.of(this._iid).requestQueue,i=new Yd({channelUrl:this.url,channelType:this.channelType,userId:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},t.prototype.freeze=function(){return f(this,void 0,void 0,(function(){var e,r;return p(this,(function(i){switch(i.label){case 0:return e=C.of(this._iid).requestQueue,r=new Da({channelUrl:this.url,channelType:this.channelType,freezing:!0}),[4,e.send(r)];case 1:return i.sent(),this.isFrozen=!0,[2]}}))}))},t.prototype.unfreeze=function(){return f(this,void 0,void 0,(function(){var e,r;return p(this,(function(i){switch(i.label){case 0:return e=C.of(this._iid).requestQueue,r=new Da({channelUrl:this.url,channelType:this.channelType,freezing:!1}),[4,e.send(r)];case 1:return i.sent(),this.isFrozen=!1,[2]}}))}))},t.prototype.getMessagesByMessageId=function(e,r){return f(this,void 0,void 0,(function(){var i;return p(this,(function(s){switch(s.label){case 0:return i=E(E({},Bn),r),R(S("number",e)&&ga(i)).throw(T.invalidParameters),[4,Ne.of(this._iid).getMessagesByMessageId(this.url,this.channelType,e,i)];case 1:return[2,s.sent()]}}))}))},t.prototype.getMessagesByTimestamp=function(e,r){return f(this,void 0,void 0,(function(){var i;return p(this,(function(s){switch(s.label){case 0:return i=E(E({},Bn),r),R(S("number",e)&&ga(i)).throw(T.invalidParameters),[4,Ne.of(this._iid).getMessagesByTimestamp(this.url,this.channelType,e,i)];case 1:return[2,s.sent()]}}))}))},t.prototype.getMessageChangeLogsSinceTimestamp=function(e,r){return r===void 0&&(r={}),f(this,void 0,void 0,(function(){var i;return p(this,(function(s){switch(s.label){case 0:return i=E(E({},rs),r),R(S("number",e)&&ya(i)).throw(T.invalidParameters),[4,Ne.of(this._iid).getMessageChangelogs(this.url,this.channelType,e,i)];case 1:return[2,s.sent()]}}))}))},t.prototype.getMessageChangeLogsSinceToken=function(e,r){return r===void 0&&(r={}),f(this,void 0,void 0,(function(){var i;return p(this,(function(s){switch(s.label){case 0:return i=E(E({},rs),r),R(S("string",e)&&ya(i)).throw(T.invalidParameters),[4,Ne.of(this._iid).getMessageChangelogs(this.url,this.channelType,e,i)];case 1:return[2,s.sent()]}}))}))},t.prototype._createPendingSendableMessagePayload=function(e,r,i){var s,a=C.of(this._iid).sessionManager;return M(B({channel_url:this.url,channel_type:this.channelType,msg_id:0,parent_message_id:e.parentMessageId,data:e.data,custom_type:e.customType,mention_type:e.mentionType,sorted_metaarray:e.metaArrays?e.metaArrays.map((function(o){return He.payloadify(o)})):null,apple_critical_alert_options:e.appleCriticalAlertOptions?mt.payloadify(e.appleCriticalAlertOptions):null,created_at:i,user:a.currentUser?Yt.payloadify(a.currentUser):null,req_id:r,request_state:ae.PENDING,mentioned_user_ids:e.mentionedUserIds,mentioned_users:(s=e.mentionedUsers)===null||s===void 0?void 0:s.map((function(o){return G.payloadify(o)}))}))},t.prototype._createPendingUserMessage=function(e,r,i){var s,a,o={};if(e.translationTargetLanguages)try{for(var u=z(e.translationTargetLanguages),c=u.next();!c.done;c=u.next())o[c.value]=""}catch(_){s={error:_}}finally{try{c&&!c.done&&(a=u.return)&&a.call(u)}finally{if(s)throw s.error}}var l=M(E(E({}
2,this._createPendingSendableMessagePayload(e,r,i)),{type:ee.USER,message:e.message,translations:o,extended_message_payload:e.extendedMessagePayload})),d=new ke(this._iid,l);return d.messageParams=e,d},t.prototype._createPendingScheduledUserMessage=function(e,r,i){var s=this._createPendingUserMessage(e,r,i);return s.scheduledInfo={scheduledMessageId:0,scheduledAt:e.scheduledAt,scheduledMessageParams:e},s},t.prototype._createPendingFileMessage=function(e,r,i){var s,a,o,u,c,l,d,_=M(E(E({},this._createPendingSendableMessagePayload(e,r,i)),{type:ee.FILE,url:e.fileUrl,file:{name:(s=e.fileName)!==null&&s!==void 0?s:(a=e.file)===null||a===void 0?void 0:a.name,size:(o=e.fileSize)!==null&&o!==void 0?o:(u=e.file)===null||u===void 0?void 0:u.size,type:(c=e.mimeType)!==null&&c!==void 0?c:(l=e.file)===null||l===void 0?void 0:l.type,data:e.data},thumbnails:(d=e._thumbnails)===null||d===void 0?void 0:d.map((function(v){return zt.payloadify(v)})),message:e.message})),h=new he(this._iid,_);return h.messageParams=e,h},t.prototype._createPendingMultipleFilesMessage=function(e,r,i){var s=M(E(E({},this._createPendingSendableMessagePayload(e,r,i)),{type:ee.FILE,file:e.fileInfoList.length>0?{name:e.fileInfoList[0].fileName,size:e.fileInfoList[0].fileSize,type:e.fileInfoList[0].mimeType,data:e.data}:void 0,message:e.message})),a=new Ge(this._iid,s);return a.messageParams=e,a},t.prototype._validateFailedFileMessageHasFile=function(e,r){var i;return!!e.url||rt(r)||rt((i=e.messageParams)===null||i===void 0?void 0:i.file)},t.prototype._createPendingScheduledFileMessage=function(e,r,i){var s=this._createPendingFileMessage(e,r,i);return s.scheduledInfo={scheduledMessageId:0,scheduledAt:e.scheduledAt,scheduledMessageParams:e},s},t.prototype._markMessageAsFailed=function(e,r,i){i===void 0&&(i=!1),e.errorCode=r.code,r.code===L.REQUEST_CANCELED||r.code===L.FILE_UPLOAD_CANCEL_FAILED?e.sendingStatus=ae.CANCELED:i||(e.sendingStatus=ae.FAILED)},t.prototype.sendUserMessage=function(e){var r=E(E({},hu),e);return R(fu(r)).throw(T.invalidParameters),this._sendUserMessage(r)},t.prototype._sendUserMessage=function(e,r,i){var s=this;r===void 0&&(r=xe.SEND);var a=C.of(this._iid),o=a.dispatcher,u=a.requestQueue,c=i!=null?i:this._generateRequestId(),l=Date.now(),d=new Nr;return Ue(2).then((function(){var _=s._createPendingUserMessage(e,c,l);o.dispatch(new ge({messages:[_],source:r===xe.RESEND?ne.LOCAL_MESSAGE_RESEND_STARTED:ne.EVENT_MESSAGE_SENT_PENDING})),ue((function(){return f(s,void 0,void 0,(function(){return p(this,(function(v){return[2,d._trigger(_)]}))}))}));var h=new eh(E(E({},e),{channelUrl:s.url,channelType:s.channelType,reqId:c}));
2u.send(h).then((function(v){var m=v.as(th).message;o.dispatch(new ge({messages:[m],source:ne.EVENT_MESSAGE_SENT_SUCCESS})),ue((function(){return f(s,void 0,void 0,(function(){return p(this,(function(y){return[2,d._trigger(m)]}))}))}))})).catch((function(v){if(tt(v))throw v;Ue(2).then((function(){var m=s._createPendingUserMessage(e,c,l),y=C.of(s._iid).cacheContext,b=y.localCacheEnabled&&y.localCacheConfig.enableAutoResend&&Dr(v.code);s._markMessageAsFailed(m,v,b),o.dispatch(new ge({messages:[m],source:m.sendingStatus===ae.PENDING?ne.REQUEST_RESEND_MESSAGE:ne.EVENT_MESSAGE_SENT_FAILED})),ue((function(){return f(s,void 0,void 0,(function(){return p(this,(function(w){return[2,d._triggerFailed(v,m)]}))}))}))}))}))})),d},t.prototype._autoResendUserMessage=function(e){return R(e instanceof ke&&!!e.messageParams).throw(T.invalidParameters),this._sendUserMessage(e.messageParams,xe.SEND,e.reqId)},t.prototype.resendUserMessage=function(e){var r;return f(this,void 0,void 0,(function(){var i,s;return p(this,(function(a){return R(e instanceof ke&&!e.scheduledInfo).throw(T.invalidParameters),i=new De,s=(r=e.messageParams)!==null&&r!==void 0?r:wa(e),this._sendUserMessage(s,xe.RESEND,e.reqId).onFailed((function(o){return i.reject(o)})).onSucceeded((function(o){return i.resolve(o)})),[2,i.promise]}))}))},t.prototype.updateUserMessage=function(e,r){return f(this,void 0,void 0,(function(){var i,s,a,o;return p(this,(function(u){switch(u.label){case 0:return i=E(E({},gd),r),R(S("number",e)&&yd(i)).throw(T.invalidParameters),s=C.of(this._iid).requestQueue,a=new Ra(E({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:i.metaArrays?{array:i.metaArrays,mode:"add",upsert:!0}:void 0},i)),[4,s.send(a)];case 1:return o=u.sent(),[2,o.as(La).message]}}))}))},t.prototype.copyUserMessage=function(e,r){var i,s,a;return f(this,void 0,void 0,(function(){var o,u;return p(this,(function(c){return R(e instanceof t&&r instanceof ke&&r.sendingStatus===ae.SUCCEEDED&&this.url===r.channelUrl&&!r.scheduledInfo).throw(T.invalidParameters),R(!r.poll).throw(T.notSupportedError),o=new De,u=(i=r.messageParams)!==null&&i!==void 0?i:B(E(E({},r),{mentionType:r.mentionType,mentionedUserIds:(s=r.mentionedUserIds)!==null&&s!==void 0?s:(a=r.mentionedUsers)===null||a===void 0?void 0:a.map((function(l){return l.userId})),translationTargetLanguages:Object.keys(r.translations),pushNotificationDeliveryOption:it.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1})),e._sendUserMessage(u).onSucceeded((function(l){o.resolve(l)})).onFailed((function(l){return o.reject(l)})),[2,o.promise]}))}))},t.prototype.translateUserMessage=function(e,r){return f(this,void 0,void 0,(function(){var i,s,a;return p(this,(function(o){switch(o.label){case 0:return R(e instanceof ke&&e.messageId>0&&J("string",r)).throw(T.invalidParameters),i=C.of(this._iid).requestQueue,s=new ah({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,translationTargetLanguages:r}),[4,i.send(s)];case 1:return a=o.sent(),[2,a.as(oh).message]}}))}))},t.prototype._createScheduledUserMessage=function(e,r){var i=this,s=C.of(this._iid).requestQueue,a=Date.now(),o=this._generateRequestId();Ue(2).then((function(){var c=i._createPendingScheduledUserMessage(e,o,a);ue((function(){return f(i,void 0,void 0,(function(){return p(this,(function(l){return[2,r._trigger(c)]}))}))}))}));var u=new uh(E({reqId:o,channelType:this.channelType,channelUrl:this.url},e));s.send(u).then((function(c){var l=c.as(ch).message;ue((function(){return f(i,void 0,void 0,(function(){return p(this,(function(d){return[2,r._trigger(l)]}))}))}))})).catch((function(c){if(tt(c))throw c;Ue(2).then((function(){var l=i._createPendingScheduledUserMessage(e,o,a);i._markMessageAsFailed(l,c),ue((function(){return f(i,void 0,void 0,(function(){return p(this,(function(d){return[2,r._triggerFailed(c,l)]}))}))}))}))}))},t.prototype.sendFileMessage=function(e){var r=E(E({},Ta),e);return R(Ca(r)).throw(T.invalidParameters),this._sendFileMessage(r)},t.prototype.sendMultipleFilesMessage=function(e){var r,i=E(E({},Lh),e),s=C.of(this._iid);R((function(o,u){return u===void 0&&(u=sl),ti(o)&&S("string",o.message,!0)&&Array.isArray(o.fileInfoList)&&o.fileInfoList.length>=2&&o.fileInfoList.length<=u&&o.fileInfoList.every((function(c){return Uh(c)}))})(i,(r=s.appInfo)===null||r===void 0?void 0:r.multipleFilesMessageFileCountLimit)).throw(T.invalidParameters);var a=!!e.fileInfoList.find((function(o){var u=s.appInfo.uploadSizeLimit;return o.file instanceof Blob&&o.file.size>u||o.fileSize>u}));return R(!a).throw(T.fileSizeLimitExceededError),this._sendMultipleFilesMessage(i)},t.prototype._sendFileMessage=function(e,r,i){var s=this;r===void 0&&(r=xe.SEND);var a=C.of(this._iid).dispatcher,o=Ne.of(this._iid).fileMessageQueue,u=i!=null?i:this._generateRequestId(),c=Date.now(),l=new Nr;return Ue(2).then((function(){var d=s._createPendingFileMessage(e,u,c);a.dispatch(new ge({messages:[d],source:r===xe.RESEND?ne.LOCAL_MESSAGE_RESEND_STARTED:ne.EVENT_MESSAGE_SENT_PENDING})),ue((function(){return f(s,void 0,void 0,(function(){return p(this,(function(_){return[2,l._trigger(d)]}))}))})),o.request(s,u,e).then((function(_){a.dispatch(new ge({messages:[_],source:ne.EVENT_MESSAGE_SENT_SUCCESS})),ue((function(){return f(s,void 0,void 0,(function(){return p(this,(function(h){return[2,l._trigger(_)]}))}))}))})).catch((function(_){if(tt(_))throw _;Ue(2).then((function(){var h=s._createPendingFileMessage(e,u,c),v=C.of(s._iid).cacheContext,m=v.localCacheEnabled&&v.localCacheConfig.enableAutoResend&&Dr(_.code);s._markMessageAsFailed(h,_,m),a.dispatch(new ge({messages:[h],source:h.sendingStatus===ae.PENDING?ne.REQUEST_RESEND_MESSAGE:_.code===L.FILE_UPLOAD_CANCEL_FAILED?ne.LOCAL_MESSAGE_CANCELED:ne.EVENT_MESSAGE_SENT_FAILED})),ue((function(){return f(s,void 0,void 0,(function(){return p(this,(function(y){return[2,l._triggerFailed(_,h)]}))}))}))}))}))})),l},t.prototype._autoResendFileMessage=function(e){R(e instanceof he&&!!e.messageParams).throw(T.invalidParameters);var r=C.of(this._iid).logger;return r.debug("autoResendFileMessage pending",e),this._sendFileMessage(e.messageParams,xe.SEND,e.reqId).onFailed((function(i){r.debug("autoResendFileMessage failed",i)})).onSucceeded((function(i){r.debug("autoResendFileMessage success",i)}))},t.prototype._sendMultipleFilesMessage=function(e,r,i){var s=this,a=C.of(this._iid).dispatcher,o=Ne.of(this._iid).fileMessageQueue,u=i!=null?i:this._generateRequestId(),c=Date.now(),l=new Mh;return Ue(2).then((function(){var d=s._createPendingMultipleFilesMessage(e,u,c);a.dispatch(new ge({messages:[d],source:r===xe.RESEND?ne.LOCAL_MESSAGE_RESEND_STARTED:ne.EVENT_MESSAGE_SENT_PENDING})),ue((function(){return f(s,void 0,void 0,(function(){return p(this,(function(_){return[2,l._trigger(d)]}))}))})),o.request(s,u,e,{requestHandler:l,isCopy:r===xe.COPY}).then((function(_){a.dispatch(new ge({messages:[_],source:ne.EVENT_MESSAGE_SENT_SUCCESS})),ue((function(){return f(s,void 0,void 0,(function(){return p(this,(function(h){return[2,l._trigger(_)]}))}))}))})).catch((function(_){if(tt(_))throw _;Ue(2).then((function(){var h=s._createPendingMultipleFilesMessage(e,u,c);s._markMessageAsFailed(h,_),a.dispatch(new ge({messages:[h],source:ne.EVENT_MESSAGE_SENT_FAILED})),ue((function(){return f(s,void 0,void 0,(function(){return p(this,(function(v){return[2,l._triggerFailed(_,h)]}))}))}))}))}))})),l},t.prototype._createScheduledFileMessage=function(e,r,i,s){var a=this,o=C.of(this._iid).requestQueue,u=new lh(E(E({reqId:i,channelType:this.channelType,channelUrl:this.url},e),{fileUrl:e.fileUrl,requireAuth:e.requireAuth}));o.send(u).then((function(c){var l=c.as(dh).message;ue((function(){return f(a,void 0,void 0,(function(){return p(this,(function(d){return[2,r._trigger(l)]}))}))}))})).catch((function(c){if(tt(c))throw c;Ue(2).then((function(){var l=a._createPendingScheduledFileMessage(e,i,s);a._markMessageAsFailed(l,c),ue((function(){return f(a,void 0,void 0,(function(){return p(this,(function(d){return[2,r._triggerFailed(c,l)]}))}))}))}))}))},t.prototype.sendFileMessages=function(e){var r,i;R(e.every((function(c){return Ca(E(E({},Ta),c))}))).throw(T.invalidParameters);var s=new Nr;try{for(var a=z(e),o=a.next();!o.done;o=a.next()){var u=o.value;this.sendFileMessage(u).onPending((function(c){return s._trigger(c)})).onFailed((function(c,l){return s._triggerFailed(c,l)})).onSucceeded((function(c){return s._trigger(c)}))}}catch(c){r={error:c}}finally{try{o&&!o.done&&(i=a.return)&&i.call(a)}finally{if(r)throw r.error}}return s},t.prototype.resendFileMessage=function(e,r){return f(this,void 0,void 0,(function(){var i,s,a;
2return p(this,(function(o){return i=this._validateFailedFileMessageHasFile(e,r),R(e instanceof he&&i&&!e.scheduledInfo).throw(T.invalidParameters),s=new De,a=Sa(e,r),this._sendFileMessage(a,xe.RESEND,e.reqId).onFailed((function(u){return s.reject(u)})).onSucceeded((function(u){return s.resolve(u)})),[2,s.promise]}))}))},t.prototype.resendMessage=function(e,r){var i,s;if(R(e instanceof pt&&!e.scheduledInfo&&e.isResendable).throw(T.invalidParameters),e.isUserMessage()){var a=(i=e.messageParams)!==null&&i!==void 0?i:wa(e);return this._sendUserMessage(a,xe.RESEND,e.reqId)}if(e.isFileMessage()){var o=this._validateFailedFileMessageHasFile(e,r);return R(o).throw(T.invalidParameters),a=(s=e.messageParams)!==null&&s!==void 0?s:Sa(e,r),this._sendFileMessage(a,xe.RESEND,e.reqId)}if(e.isMultipleFilesMessage())throw T.channelTypeNotSupportedError},t.prototype.updateFileMessage=function(e,r){return f(this,void 0,void 0,(function(){var i,s,a,o;return p(this,(function(u){switch(u.label){case 0:return i=E(E({},bd),r),R(S("number",e)&&(function(c){return _u(c)})(i)).throw(T.invalidParameters),s=C.of(this._iid).requestQueue,a=new Ua(E({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:i.metaArrays?{array:i.metaArrays,mode:"add",upsert:!0}:void 0},i)),[4,s.send(a)];case 1:return o=u.sent(),[2,o.as(Ma).message]}}))}))},t.prototype.uploadFile=function(e){return f(this,void 0,void 0,(function(){var r,i,s,a,o,u,c;return p(this,(function(l){switch(l.label){case 0:return r=C.of(this._iid).requestQueue,i=st(),(s=new Ji({file:e.file,channelUrl:this.url,thumbnailSizes:e.thumbnailSizes,requestId:i})).uploadProgressHandler=e.progressHandler,e.uploadStartedHandler&&e.uploadStartedHandler(i),[4,r.send(s)];case 1:return a=l.sent(),o=a.as(es),u=o.url,c=o.thumbnails,[2,{requestId:i,url:u,thumbnails:c}]}}))}))},t.prototype.cancelUploadingFileMessage=function(e){return f(this,void 0,void 0,(function(){return p(this,(function(r){return R(S("string",e)).throw(T.invalidParameters),Ne.of(this._iid).fileMessageQueue.cancel(this,e),[2,!0]}))}))},t.prototype.copyFileMessage=function(e,r){var i,s,a;return f(this,void 0,void 0,(function(){var o,u;return p(this,(function(c){return R(e instanceof t&&r instanceof he&&r.sendingStatus===ae.SUCCEEDED&&this.url===r.channelUrl&&!r.scheduledInfo).throw(T.invalidParameters),o=new De,u=B(E(E({},r),{fileUrl:r.url,fileName:r.name,fileSize:r.size,mimeType:r.type,mentionType:r.mentionType,mentionedUserIds:(i=r.mentionedUserIds)!==null&&i!==void 0?i:(s=r.mentionedUsers)===null||s===void 0?void 0:s.map((function(l){return l.userId})),pushNotificationDeliveryOption:it.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:(a=r.thumbnails)===null||a===void 0?void 0:a.map((function(l){return{maxWidth:l.width,maxHeight:l.height}})),requireAuth:r.requireAuth,isPinnedMessage:!1})),e._sendFileMessage(u).onSucceeded((function(l){return o.resolve(l)})).onFailed((function(l){return o.reject(l)})),[2,o.promise]}))}))},t.prototype.copyMessage=function(e,r){R(e instanceof t&&r instanceof pt&&r.sendingStatus===ae.SUCCEEDED&&this.url===r.channelUrl&&!r.scheduledInfo).throw(T.invalidParameters);var i=r,s=e;if(i.isUserMessage()){R(!i.poll).throw(T.notSupportedError);var a=vd(i);return s._sendUserMessage(a)}if(i.isFileMessage())return a=md(i),s._sendFileMessage(a);if(r.isMultipleFilesMessage())throw T.channelTypeNotSupportedError},t.prototype.deleteMessage=function(e){return f(this,void 0,void 0,(function(){var r,i;return p(this,(function(s){switch(s.label){case 0:return R(e instanceof je).throw(T.invalidParameters),e.messageId>0?(r=C.of(this._iid).requestQueue,i=new mo({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,messageToken:e instanceof pt?e._messageToken:void 0}),[4,r.send(i)]):[3,2];case 1:s.sent(),s.label=2;case 2:return[2]}}
2))}))},t.prototype.addReaction=function(e,r){return f(this,void 0,void 0,(function(){var i,s,a;return p(this,(function(o){switch(o.label){case 0:return R(e instanceof je&&e.messageId>0&&S("string",r)).throw(T.invalidParameters),i=C.of(this._iid).requestQueue,s=new nh({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:r}),[4,i.send(s)];case 1:return a=o.sent(),[2,a.as(rh).reactionEvent]}}))}))},t.prototype.deleteReaction=function(e,r){return f(this,void 0,void 0,(function(){var i,s,a;return p(this,(function(o){switch(o.label){case 0:return R(e instanceof je&&e.messageId>0&&S("string",r)).throw(T.invalidParameters),i=C.of(this._iid).requestQueue,s=new ih({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:r}),[4,i.send(s)];case 1:return a=o.sent(),[2,a.as(sh).reactionEvent]}}))}))},t.prototype._updateUserMessageMetaArray=function(e,r,i,s){return f(this,void 0,void 0,(function(){var a,o,u,c,l,d;return p(this,(function(_){switch(_.label){case 0:return a=C.of(this._iid),o=a.dispatcher,u=a.requestQueue,c=new Ra({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:{array:r,mode:i,upsert:s}}),[4,u.send(c)];case 1:return l=_.sent(),d=l.as(La).message,o.dispatch(new ge({messages:[d],source:ne.EVENT_MESSAGE_UPDATED})),[2,d]}}))}))},t.prototype._updateFileMessageMetaArray=function(e,r,i,s){return f(this,void 0,void 0,(function(){var a,o,u,c,l,d;return p(this,(function(_){switch(_.label){case 0:return a=C.of(this._iid),o=a.dispatcher,u=a.requestQueue,c=new Ua({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:{array:r,mode:i,upsert:s}}),[4,u.send(c)];case 1:return l=_.sent(),d=l.as(Ma).message,o.dispatch(new ge({messages:[d],source:ne.EVENT_MESSAGE_UPDATED})),[2,d]}}))}))},t.prototype.createMessageMetaArrayKeys=function(e,r){return f(this,void 0,void 0,(function(){var i;return p(this,(function(s){return R(e instanceof je&&e.messageId>0&&J("string",r)).throw(T.invalidParameters),i=r.map((function(a){return new He({key:a})})),e instanceof he?[2,this._updateFileMessageMetaArray(e.messageId,i,"add",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,i,"add",!0)]}))}))},t.prototype.deleteMessageMetaArrayKeys=function(e,r){return f(this,void 0,void 0,(function(){var i;return p(this,(function(s){return R(e instanceof je&&e.messageId>0&&J("string",r)).throw(T.invalidParameters),i=r.map((function(a){return new He({key:a})})),e instanceof he?[2,this._updateFileMessageMetaArray(e.messageId,i,"remove",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,i,"remove",!0)]}))}))},t.prototype.addMessageMetaArrayValues=function(e,r){return f(this,void 0,void 0,(function(){return p(this,(function(i){return R(e instanceof je&&e.messageId>0&&r.every((function(s){return s instanceof He}))).throw(T.invalidParameters),e instanceof he?[2,this._updateFileMessageMetaArray(e.messageId,r,"add",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,r,"add",!0)]}))}))},t.prototype.removeMessageMetaArrayValues=function(e,r){return f(this,void 0,void 0,(function(){return p(this,(function(i){return R(e instanceof je&&e.messageId>0&&r.every((function(s){return s instanceof He}))).throw(T.invalidParameters),e instanceof he?[2,this._updateFileMessageMetaArray(e.messageId,r,"remove",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,r,"remove",!0)]}))}))},t.prototype.report=function(e,r){return f(this,void 0,void 0,(function(){var i,s,a,o;return p(this,(function(u){switch(u.label){case 0:return R((ie(jn,e)||e instanceof ln)&&S("string",r)).throw(T.invalidParameters),i=C.of(this._iid),s=i.sdkState,a=i.requestQueue,o=new Zd({channelUrl:this.url,channelType:this.channelType,userId:s.userId,category:e,description:r}),[4,a.send(o)];case 1:return u.sent(),[2]}}))}))},t.prototype.reportUser=function(e,r,i){return f(this,void 0,void 0,(function(){var s,a,o,u;return p(this,(function(c){switch(c.label){case 0:return R(e instanceof G&&(ie(jn,r)||r instanceof ln)&&S("string",i)).throw(T.invalidParameters),s=C.of(this._iid),a=s.sdkState,o=s.requestQueue,u=new Xd({channelUrl:this.url,channelType:this.channelType,userId:a.userId,offendingUserId:e.userId,category:r,description:i}),[4,o.send(u)];case 1:return c.sent(),[2]}}))}))},t.prototype.reportMessage=function(e,r,i){return f(this,void 0,void 0,(function(){var s,a,o,u;return p(this,(function(c){switch(c.label){case 0:return R(e instanceof pt&&(ie(jn,r)||r instanceof ln)&&S("string",i)).throw(T.invalidParameters),s=C.of(this._iid),a=s.sdkState,o=s.requestQueue,u=new Jd({channelUrl:this.url,channelType:this.channelType,userId:a.userId,offendingUserId:e.sender.userId,messageId:e.messageId,category:r,description:i,messageToken:e._messageToken}),[4,o.send(u)];case 1:return c.sent(),[2]}}))}))},t.prototype.updatePoll=function(e,r){return f(this,void 0,void 0,(function(){var i,s,a;return p(this,(function(o){switch(o.label){case 0:return R(S("number",e)&&(function(u){return S("string",u.title,!0)&&nu(u.data)&&S("boolean",u.allowUserSuggestion,!0)&&S("boolean",u.allowMultipleVotes,!0)&&S("number",u.closeAt,!0)})(r)).throw(T.invalidParameters),i=C.of(this._iid).requestQueue,s=new hh(E({pollId:e},r)),[4,i.send(s)];case 1:return a=o.sent(),[2,a.as(fh).poll]}}))}))},t.prototype.deletePoll=function(e){return f(this,void 0,void 0,(function(){var r,i,s;return p(this,(function(a){switch(a.label){case 0:return r=S("number",e),R(r).throw(T.invalidParameters),i=C.of(this._iid).requestQueue,s=new ph({pollId:e}),[4,i.send(s)];case 1:return a.sent(),[2]}}))}))},t.prototype.closePoll=function(e){return f(this,void 0,void 0,(function(){var r,i,s,a;return p(this,(function(o){switch(o.label){case 0:return r=S("number",e),R(r).throw(T.invalidParameters),i=C.of(this._iid).requestQueue,s=new _h({pollId:e}),[4,i.send(s)];case 1:return a=o.sent(),[2,a.as(vh).poll]}}))}))},t.prototype.addPollOption=function(e,r){return f(this,void 0,void 0,(function(){var i,s,a,o;return p(this,(function(u){switch(u.label){case 0:return i=S("number",e)&&S("string",r)&&r.trim()!=="",R(i).throw(T.invalidParameters),s=C.of(this._iid).requestQueue,a=new mh({channelUrl:this.url,channelType:this.channelType,pollId:e,optionText:r}),[4,s.send(a)];case 1:return o=u.sent(),[2,o.as(gh).poll]}}))}))},t.prototype.updatePollOption=function(e,r,i){return f(this,void 0,void 0,(function(){var s,a,o,u;return p(this,(function(c){switch(c.label){case 0:return s=S("number",e)&&S("number",r)&&S("string",i)&&i.trim()!=="",R(s).throw(T.invalidParameters),a=C.of(this._iid).requestQueue,o=new yh({pollId:e,pollOptionId:r,optionText:i}),[4,a.send(o)];case 1:return u=c.sent(),[2,u.as(bh).poll]}}))}))},t.prototype.deletePollOption=function(e,r){return f(this,void 0,void 0,(function(){var i,s,a;return p(this,(function(o){switch(o.label){case 0:return i=S("number",e)&&S("number",r),R(i).throw(T.invalidParameters),s=C.of(this._iid).requestQueue,a=new Eh({pollId:e,pollOptionId:r}),[4,s.send(a)];case 1:return o.sent(),[2]}}))}))},t.prototype.votePoll=function(e,r){return f(this,void 0,void 0,(function(){var i,s,a,o,u,c,l;return p(this,(function(d){switch(d.label){case 0:return i=S("number",e)&&J("number",r),R(i).throw(T.invalidParameters),s=C.of(this._iid),a=s.requestQueue,o=s.dispatcher,u=new wh({reqId:this._generateRequestId(),channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionIds:r}),[4,a.send(u)];case 1:return c=d.sent(),l=c.as(Ih).event,o.dispatch(new tu({event:l,source:ne.EVENT_POLL_VOTED})),[2,l]}}))}))},t.prototype.getPollChangeLogsSinceTimestamp=function(e){return f(this,void 0,void 0,(function(){return p(this,(function(r){switch(r.label){case 0:return R(S("number",e)).throw(T.invalidParameters),[4,Xi.of(this._iid).getPollChangeLogs(this.url,this.channelType,e)];case 1:return[2,r.sent()]}}))}))},t.prototype.getPollChangeLogsSinceToken=function(e){return f(this,void 0,void 0,(function(){return p(this,(function(r){switch(r.label){case 0:return R(S("string",e,!0)),[4,Xi.of(this._iid).getPollChangeLogs(this.url,this.channelType,e)];case 1:return[2,r.sent()]}}))}))},t.prototype.createPollListQuery=function(e){return e===void 0&&(e=10),new au(this._iid,{channelUrl:this.url,channelType:this.channelType,limit:e})},t.prototype.createPollVoterListQuery=function(e,r,i){return i===void 0&&(i=20),new ou(this._iid,{channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionId:r,limit:i})},t.prototype.pinMessage=function(e){return f(this,void 0,void 0,(function(){var r,i;return p(this,(function(s){switch(s.label){case 0:return R(S("number",e)&&e>0).throw(T.invalidParameters),r=C.of(this._iid).requestQueue,i=new zh({channelType:this.channelType,channelUrl:this.url,messageId:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},t.prototype.unpinMessage=function(e){return f(this,void 0,void 0,(function(){var r,i;return p(this,(function(s){switch(s.label){case 0:return R(S("number",e)&&e>0).throw(T.invalidParameters),r=C.of(this._iid).requestQueue,i=new Bh({channelType:this.channelType,channelUrl:this.url,messageId:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},t})(be),jh=(function(n){function t(e){e===void 0&&(e={});var r=n.call(this)||this;return Object.keys(e).forEach((function(i){r.hasOwnProperty(i)&&(r[i]=e[i])})),r}return g(t,n),t})((function(){this.onConnected=fe,this.onReconnectStarted=fe,this.onReconnectSucceeded=fe,this.onReconnectFailed=fe,this.onConnectionLost=fe,this.onDisconnected=fe,this.onConnectionDelayed=fe})),Pa=(function(n){function t(e){e===void 0&&(e={});var r=n.call(this)||this;return Object.keys(e).forEach((function(i){r.hasOwnProperty(i)&&(r[i]=e[i])})),r}return g(t,n),t})((function(){this.onSessionExpired=fe,this.onSessionTokenRequired=function(n){return n(null)},this.onSessionError=fe,this.onSessionRefreshed=fe,this.onSessionClosed=fe})),Kh=(function(n){function t(e){e===void 0&&(e={});var r=n.call(this)||this;return Object.keys(e).forEach((function(i){r.hasOwnProperty(i)&&(r[i]=e[i])})),r}return g(t,n),t})((function(){this.onFriendsDiscovered=fe,this.onTotalUnreadMessageCountChanged=fe,this.onTotalUnreadMessageCountUpdated=fe})),Hh=(function(n){function t(e){var r=e.limit,i=e.token,s=e.userIdsFilter,a=e.metaDataKeyFilter,o=e.metaDataValuesFilter,u=e.nicknameStartsWithFilter,c=n.call(this)||this;return c.method=k.GET,c.path=W,c.params=M({limit:r,token:i,user_ids:s,metadatakey:a,metadatavalues_in:o,nickname_startswith:u}),c}return g(t,n),t})(O),Vh=(function(n){function t(e,r){var i=n.call(this,e,r)||this;return i.users=r.users.map((function(s){return new G(e,s)})),i.next=r.next,i}return g(t,n),t})(U),Gh=(function(n){function t(e,r){var i,s,a,o=this;return(o=n.call(this,e,r)||this).userIdsFilter=null,o.metaDataKeyFilter=null,o.metaDataValuesFilter=null,o.nicknameStartsWithFilter=null,o.userIdsFilter=(i=r.userIdsFilter)!==null&&i!==void 0?i:null,o.metaDataKeyFilter=(s=r.metaDataKeyFilter)!==null&&s!==void 0?s:null,o.metaDataValuesFilter=(a=r.metaDataValuesFilter)!==null&&a!==void 0?a:null,o.nicknameStartsWithFilter=r.nicknameStartsWithFilter||null,o}return g(t,n),t.prototype._validate=function(){return n.prototype._validate.call(this)&&J("string",this.userIdsFilter,!0)&&S("string",this.metaDataKeyFilter,!0)&&J("string",this.metaDataValuesFilter,!0)&&S("string",this.nicknameStartsWithFilter,!0)},t.prototype.next=function(){return f(this,void 0,void 0,(function(){var e,r,i,s,a,o;return p(this,(function(u){switch(u.label){case 0:return this._val
2idate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=C.of(this._iid).requestQueue,r=new Hh(B(E(E({},this),{token:this._token}))),[4,e.send(r)]):[3,2]:[3,5];case 1:return i=u.sent(),s=i.as(Vh),a=s.users,o=s.next,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,a];case 2:return[2,[]];case 3:throw T.queryInProgress;case 4:return[3,6];case 5:throw T.invalidParameters;case 6:return[2]}}))}))},t})(nr),Qh=(function(n){function t(e){var r=e.userId,i=e.limit,s=e.token,a=e.userIdsFilter,o=n.call(this)||this;return o.method=k.GET,o.path="".concat(W,"/").concat(encodeURIComponent(r),"/block"),o.params=M({limit:i,token:s,user_ids:a}),o}return g(t,n),t})(O),$h=(function(n){function t(e,r){var i=n.call(this,e,r)||this;return i.users=r.users.map((function(s){return new G(e,s)})),i.next=r.next,i}return g(t,n),t})(U),Wh=(function(n){function t(e,r){var i,s=this;return(s=n.call(this,e,r)||this).userIdsFilter=null,s.userIdsFilter=(i=r.userIdsFilter)!==null&&i!==void 0?i:null,s}return g(t,n),t.prototype._validate=function(){return n.prototype._validate.call(this)&&J("string",this.userIdsFilter,!0)},t.prototype.next=function(){return f(this,void 0,void 0,(function(){var e,r,i,s,a,o,u,c;return p(this,(function(l){switch(l.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=C.of(this._iid),r=e.sdkState,i=e.requestQueue,s=new Qh(B(E(E({},this),{userId:r.userId,token:this._token}))),[4,i.send(s)]):[3,2]:[3,5];case 1:return a=l.sent(),o=a.as($h),u=o.users,c=o.next,this._token=c,this._hasNext=!!c,this._isLoading=!1,[2,u];case 2:return[2,[]];case 3:throw T.queryInProgress;case 4:return[3,6];case 5:throw T.invalidParameters;case 6:return[2]}}
2))}))},t})(nr),Yh=(function(n){function t(e){var r=e.userId,i=e.limit,s=e.token,a=n.call(this)||this;return a.method=k.GET,a.path="".concat(W,"/").concat(encodeURIComponent(r),"/friends"),a.params={limit:i,token:s},a}return g(t,n),t})(O),Zh=(function(n){function t(e,r){var i=n.call(this,e,r)||this;return i.hasMore=r.has_more,i.users=r.users.map((function(s){return new G(e,s)})),i.next=r.next,i}return g(t,n),t})(U),Xh=(function(n){function t(){return n!==null&&n.apply(this,arguments)||this}return g(t,n),t.prototype._validate=function(){return n.prototype._validate.call(this)},t.prototype.next=function(){return f(this,void 0,void 0,(function(){var e,r,i,s,a,o,u,c,l;return p(this,(function(d){switch(d.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=C.of(this._iid),r=e.sdkState,i=e.requestQueue,s=new Yh(E(E({},this),{userId:r.userId,token:this._token})),[4,i.send(s)]):[3,2]:[3,5];case 1:return a=d.sent(),o=a.as(Zh),u=o.users,c=o.hasMore,l=o.next,this._token=l,this._hasNext=c,this._isLoading=!1,[2,u];case 2:return[2,[]];case 3:throw T.queryInProgress;case 4:return[3,6];case 5:throw T.invalidParameters;case 6:return[2]}}
2))}))},t})(nr),mr={},ir=(function(){function n(t){var e=t.dbname,r=t.itemSizeLimit,i=r===void 0?1048576:r,s=t.cacheLimit,a=s===void 0?256:s,o=t.blockHashBase,u=o===void 0?2:o,c=t.blockHashMultiplier,l=c===void 0?10:c,d=t.blockHashConstant,_=d===void 0?11:d,h=t.transactionApplyDelay,v=h===void 0?200:h,m=t.disableLogger,y=m!==void 0&&m;return mr[e]||(this.itemSizeLimit=i,this.cacheLimit=a,this.blockHashBase=u,this.blockHashMultiplier=l,this.blockHashConstant=_,this.transactionApplyDelay=v,this.disableLogger=y,mr[e]=this),mr[e]}return n.get=function(t){return mr[t]},n})();(function(n){n[n.UNKNOWN_ERROR=6e7]="UNKNOWN_ERROR",n[n.STORE_NOT_DEFINED=61001e3]="STORE_NOT_DEFINED",n[n.STORE_NOT_AVAILABLE=61001001]="STORE_NOT_AVAILABLE",n[n.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING=61001002]="STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING",n[n.STORE_IS_FULL=61001003]="STORE_IS_FULL",n[n.STORE_NOT_INITIALIZED=61001004]="STORE_NOT_INITIALIZED",n[n.STORE_INVALID_KEY_TYPE=61002e3]="STORE_INVALID_KEY_TYPE",n[n.STORE_BROKEN_INTEGRITY=61002001]="STORE_BROKEN_INTEGRITY",n[n.STORE_BROKEN_BLOB=61002002]="STORE_BROKEN_BLOB",n[n.STORE_ENCRYPTION_INVA
2LID=61002003]="STORE_ENCRYPTION_INVALID",n[n.STORE_ITEM_SIZE_LIMIT_EXCEEDED=61017e3]="STORE_ITEM_SIZE_LIMIT_EXCEEDED",n[n.STORE_READ_FAILED=61017001]="STORE_READ_FAILED",n[n.STORE_WRITE_FAILED=61017002]="STORE_WRITE_FAILED",n[n.DATABASE_SCHEMA_NOT_ON_UPGRADE=62002e3]="DATABASE_SCHEMA_NOT_ON_UPGRADE",n[n.COLLECTION_NOT_READY=63001e3]="COLLECTION_NOT_READY",n[n.COLLECTION_KEY_NOT_MATCH=63002e3]="COLLECTION_KEY_NOT_MATCH",n[n.COLLECTION_QUERY_NOT_VALID=63002001]="COLLECTION_QUERY_NOT_VALID",n[n.COLLECTION_KEY_NOT_FOUND=63004e3]="COLLECTION_KEY_NOT_FOUND",n[n.COLLECTION_KEY_NOT_GIVEN=63004001]="COLLECTION_KEY_NOT_GIVEN",n[n.COLLECTION_INSERT_DUPLICATE=63009e3]="COLLECTION_INSERT_DUPLICATE",n[n.COLLECTION_WRITE_FAILED=63017e3]="COLLECTION_WRITE_FAILED",n[n.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED=63017001]="COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED",n[n.INDEX_TABLE_IS_REQUIRED=65001e3]="INDEX_TABLE_IS_REQUIRED",n[n.INDEX_TYPE_NOT_MATCH=65002e3]="INDEX_TYPE_NOT_MATCH",n[n.COMPARE_TYPE_NOT_MATCH=69002001]="COMPARE_TYPE_NOT_MATCH",n[n.CIRCULAR_REFERENCE_FOUND=69002002]="CIRCULAR_REFERENCE_FOUND"})(se||(se={}));var Wt,$=(function(n){function t(e){var r=e.code,i=r===void 0?se.UNKNOWN_ERROR:r,s=e.message,a=s===void 0?"Unknown error occurred.":s,o=n.call(this,a)||this;return o.code=i,Object.setPrototypeOf(o,t.prototype),o}return g(t,n),Object.defineProperty(t,"storeNotDefined",{get:function(){return new t({code:se.STORE_NOT_DEFINED,message:"Store is not defined. Specify the store on NestDB()"})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeNotAvailable",{get:function(){return new t({code:se.STORE_NOT_AVAILABLE,message:"Store is not available. Check your environment settings."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeNotAvailableInPrivateBrowsing",{get:function(){return new t({code:se.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING,message:"Store is not available because it is in private browsing."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeIsFull",{get:function(){return new t({code:se.STORE_IS_FULL,message:"Store is full."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeNotInitialized",{get:function(){return new t({code:se.STORE_NOT_INITIALIZED,message:"Store is not initialized."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeKeyTypeIsInvalid",{get:function(){return new t({code:se.STORE_INVALID_KEY_TYPE,message:"Store key should be string type."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeBrokenIntegrity",{get:function(){return new t({code:se.STORE_BROKEN_INTEGRITY,message:"Data should be in a store but it does not. Integrity is broken."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeBrokenBlob",{get:function(){return new t({code:se.STORE_BROKEN_BLOB,message:"Data should be in a store but it does not. Blob data is broken."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeEncryptionInvalid",{get:function(){return new t({code:se.STORE_ENCRYPTION_INVA
2LID,message:"Encryption algorithm has changed. All the store should reset."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeItemSizeExceeded",{get:function(){return new t({code:se.STORE_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that the store allows."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeReadFailed",{get:function(){return new t({code:se.STORE_READ_FAILED,message:"Failed to read from store."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeWriteFailed",{get:function(){return new t({code:se.STORE_WRITE_FAILED,message:"Failed to write to store."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"databaseSchemaNotOnUpgrade",{get:function(){return new t({code:se.DATABASE_SCHEMA_NOT_ON_UPGRADE,message:"Committing schema is not allowed when upgrade is not running."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionNotReady",{get:function(){return new t({code:se.COLLECTION_NOT_READY,message:"Collection is not ready due to an error during initialization."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionKeyNotMatch",{get:function(){return new t({code:se.COLLECTION_KEY_NOT_MATCH,message:"keyName of collection could not change."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionQueryNotValid",{get:function(){return new t({code:se.COLLECTION_QUERY_NOT_VALID,message:"Query parameter is not a valid format."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionInsertDuplicate",{get:function(){return new t({code:se.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionKeyNotFound",{get:function(){return new t({code:se.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionKeyNotGiven",{get:function(){return new t({code:se.COLLECTION_KEY_NOT_GIVEN,message:"The item should contain [keyName] property."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionWriteFailed",{get:function(){return new t({code:se.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionItemSizeExceeded",{get:function(){return new t({code:se.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that a collection allows."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"indexTableIsRequired",{get:function(){return new t({code:se.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"indexTypesNotMatch",{get:function(){return new t({code:se.INDEX_TYPE_NOT_MATCH,message:"Indexed column should have primitive type."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"compareTypesNotMatch",{get:function(){return new t({code:se.COMPARE_TYPE_NOT_MATCH,message:"Values to compare have different types."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"circularReferenceFound",{get:function(){return new t({code:se.CIRCULAR_REFERENCE_FOUND,message:"Cannot handle circular referenced object."})},enumerable:!1,configurable:!0}),t})(Error);(function(n){n.INIT="init",n.READY="ready",n.CLOSED="closed"})(Wt||(Wt={}));var xa,Ae=function(n,t){if(t===void 0&&(t=new WeakMap),typeof n=="object"&&n!==null){if(t.has(n))throw $.circularReferenceFound;var e;return t.set(n,!0),Array.isArray(n)?e=n.map((function(r){return Ae(r,t)})):n instanceof RegExp||n instanceof Date?e=n:(e={},Object.keys(n).forEach((function(r){e[r]=Ae(n[r],t)}))),t.delete(n),e}return n},Ct=function(n,t){if(t==null)return 1;if(n==null)return-1;if(typeof n!=typeof t)throw $.compareTypesNotMatch;var e=0;switch(typeof n){case"boolean":case"number":e=n-t;break;case"string":e=n.localeCompare(t)}return e},Fa=function(n,t){for(var e=0,r=0;r<n.length;r++)e=n.charCodeAt(r)+(e<<6)+(e<<16)-e;return(e>>>0)%t},gr=function(n){return new Promise((function(t){setTimeout((function(){return t()}),n)}))},Xt=function(n,t){if(!t)return!1;if(typeof n!="function"){for(var e in n)if(["/and","&&"].includes(e)){if(n[e].some((function(u){return!Xt(u,t)})))return!1}else if(["/or","||"].includes(e)){if(n[e].every((function(u){return!Xt(u,t)})))return!1}else if(e==="/where"){if(!(0,n[e])(t))return!1}else{var r=e;if(typeof n[r]=="object"){var i=n[r];for(var s in i)switch(s){case"/eq":case"=":if((a=t[r])!==(o=i[s]))return!1;break;case"/neq":case"!=":if((a=t[r])===(o=i[s]))return!1;break;case"/gt":case">":var a=t[r],o=i[s];if(!(Ct(a,o)>0))return!1;break;case"/gte":case">=":if(a=t[r],o=i[s],!(Ct(a,o)>=0))return!1;break;case"/lt":case"<":if(a=t[r],o=i[s],!(Ct(a,o)<0))return!1;break;case"/lte":case"<=":if(a=t[r],o=i[s],!(Ct(a,o)<=0))return!1;break;case"/in":if(a=t[r],!(o=i[s]).includes(a))return!1;break;case"/nin":if(a=t[r],(o=i[s]).includes(a))return!1;break;case"/contain":if(a=t[r],o=i[s],!a.includes(o))return!1;break;case"/regex":if(a=t[r],!(o=i[s]).test(a))return!1;break;case"/where":if(a=t[r],!(0,i[s])(a))return!1}}else if(typeof n[r]=="function"){if(!n[r](t[r]))return!1}else if(n[r]!==t[r])return!1}return!0}return n(t)},kn=function(){},qa=function(){return Promise.resolve()},Jh=function(n){return n},za=function(n,t){t()};(function(n){n[n.FORWARD=0]="FORWARD",n[n.BACKWARD=1]="BACKWARD"}
2)(xa||(xa={}));var Jt,Ee,dt,ef=(function(){function n(t){var e=t.initialPrevValue,r=e===void 0?null:e,i=t.initialNextValue,s=i===void 0?null:i,a=t.iterator,o=t.map,u=o===void 0?Jh:o,c=t.backward,l=c===void 0?qa:c,d=t.forward,_=d===void 0?qa:d,h=t.complete,v=h===void 0?kn:h;this._prevValue=r,this._nextValue=s,this._error=null,this._map=u,this._backward=l,this._forward=_,this._iterator=a,this._complete=v}return Object.defineProperty(n.prototype,"prevValue",{get:function(){return this._map(this._prevValue)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"nextValue",{get:function(){return this._map(this._nextValue)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"error",{get:function(){return this._error},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"hasPrevious",{get:function(){return!!this._prevValue},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"hasNext",{get:function(){return!!this._nextValue},enumerable:!1,configurable:!0}),n.prototype.prev=function(){return f(this,void 0,void 0,(function(){var t,e,r;return p(this,(function(i){switch(i.label){case 0:if(!this.hasPrevious)return[3,6];i.label=1;case 1:return i.trys.push([1,3,,4]),t=this._prevValue,e=this,[4,this._backward()];case 2:return e._prevValue=i.sent()||null,this._nextValue=t,[3,4];case 3:return r=i.sent(),this._error=r,[3,4];case 4:return[4,this._iterator(this)];case 5:return[2,i.sent()];case 6:this._complete(),i.label=7;case 7:return[2]}}
2))}))},n.prototype.next=function(){return f(this,void 0,void 0,(function(){var t,e,r;return p(this,(function(i){switch(i.label){case 0:if(!this.hasNext)return[3,6];i.label=1;case 1:return i.trys.push([1,3,,4]),t=this._nextValue,e=this,[4,this._forward()];case 2:return e._nextValue=i.sent()||null,this._prevValue=t,[3,4];case 3:return r=i.sent(),this._error=r,[3,4];case 4:return[4,this._iterator(this)];case 5:return[2,i.sent()];case 6:this._complete(),i.label=7;case 7:return[2]}}))}))},n.prototype.stop=function(){this._prevValue=null,this._nextValue=null,this._complete()},n})(),ss=(function(){function n(t){var e=t.condition,r=e===void 0?{}:e,i=t.backward,s=i!==void 0&&i,a=t.blockManager,o=t.indexer;this.condition=r,this.backward=s,this._blockManager=a,this._indexer=o}return n.prototype.findOptimizedStartPosition=function(){var t=this,e=["=","/eq",">",">=","/gt","/gte"],r=["=","/eq","<","<=","/lt","/lte"];if(this.backward){var i=this._indexer.origin.length-1;if(typeof this.condition!="function")for(h=0;h<this._indexer.fields.length;h++){var s=this._indexer.fields[h],a=1;if(s[0]==="-"&&(s=s.slice(1),a=-1),this.condition[s]){if(typeof this.condition[s]=="object"){var o=a>0?r:e;for(var u in this.condition[s])if(o.includes(u)){for(var c=i;c>=0;c--)if(a*Ct(this._indexer.origin[c].columnValues[h],this.condition[s][u])<=0){i=c;break}}}else for(c=i;c>=0;c--)if(a*Ct(this._indexer.origin[c].columnValues[h],this.condition[s])<=0){i=c;break}}}return Math.min(i+1,this._indexer.origin.length-1)}var l=0;if(typeof this.condition!="function")for(var d=function(v){var m=_._indexer.fields[v],y=1;if(m[0]==="-"&&(m=m.slice(1),y=-1),_.condition[m]){if(typeof _.condition[m]=="object")Object.keys(_.condition[m]).forEach((function(w){if((y>0?e:r).includes(w)){for(var I=l;I<t._indexer.origin.length;I++)if(y*Ct(t._indexer.origin[I].columnValues[v],t.condition[m][w])>=0){l=I;break}}}));else for(var b=l;b<_._indexer.origin.length;b++)if(y*Ct(_._indexer.origin[b].columnValues[v],_.condition[m])>=0){l=b;break}}},_=this,h=0;h<this._indexer.fields.length;h++)d(h);return Math.max(l-1,0)},n.prototype.each=function(t){return f(this,void 0,void 0,(function(){var e,r,i,s,a,o,u,c=this;return p(this,(function(l){switch(l.label){case 0:if(e=this.findOptimizedStartPosition(),r=0,this.backward&&this._indexer.origin[e]&&(r=this._indexer.origin[e].keys.length-1),i=function(){if(c._indexer.origin[e]){if(!c._indexer.origin[e].keys[++r]){if(!c._indexer.origin[++e])return!1;r=0}return!0}return!1},s=function(){if(c._indexer.origin[e]){if(!c._indexer.origin[e].keys[--r]){if(!c._indexer.origin[--e])return!1;r=c._indexer.origin[e].keys.length-1}return!0}return!1},a=null,!this._indexer.origin[e])return[3,4];o=this.backward?s:i,l.label=1;case 1:return[4,this._blockManager.getFromBlock(this._indexer.origin[e].keys[r])];case 2:if((u=l.sent())&&Xt(this.condition,u))return a=u,[3,4];l.label=3;case 3:if(o())return[3,1];l.label=4;case 4:return[4,new Promise((function(d){var _=new ef({initialNextValue:Ae(a),iterator:t,forward:function(){return f(c,void 0,void 0,(function(){var h,v;return p(this,(function(m){switch(m.label){case 0:h=this.backward?s:i,m.label=1;case 1:return h()?[4,this._blockManager.getFromBlock(this._indexer.origin[e].keys[r])]:[3,3];case 2:return(v=m.sent())&&Xt(this.condition,v)?[2,Ae(v)]:[3,1];case 3:return[2,null]}}))}))},backward:function(){return f(c,void 0,void 0,(function(){var h,v;return p(this,(function(m){switch(m.label){case 0:h=this.backward?i:s,m.label=1;case 1:return h()?[4,this._blockManager.getFromBlock(this._indexer.origin[e].keys[r])]:[3,3];case 2:return(v=m.sent())&&Xt(this.condition,v)?[2,Ae(v)]:[3,1];case 3:return[2,null]}}))}))},complete:d});t(_)}))];case 5:return[2,l.sent()]}}))}))},n})(),tf=(function(){function n(t){var e=t.condition,r=e===void 0?{}:e,i=t.backward,s=i!==void 0&&i,a=t.mutex,o=t.blockManager,u=t.indexer;this._mutex=a,this._iterator=new ss({condition:r,backward:s,blockManager:o,indexer:u}),this._indexer=u}return Object.defineProperty(n.prototype,"indexer",{get:function(){return this._indexer},enumerable:!1,configurable:!0}),n.prototype.fetch=function(t){return t===void 0&&(t={}),f(this,void 0,void 0,(function(){var e,r,i,s,a=this;return p(this,(function(o){switch(o.label){case 0:if(e=Math.max(t.offset||0,0),(r=typeof t.limit=="number"?t.limit:Number.MAX_SAFE_INTEGER)===0)return[2,[]];if(r<0)throw $.collectionQueryNotValid;o.label=1;case 1:return o.trys.push([1,4,,5]),i=[],[4,this._mutex.lock()];case 2:return o.sent(),[4,this._iterator.each((function(u){return f(a,void 0,void 0,(function(){return p(this,(function(c){return u.error?u.stop():u.hasNext?e===0?(i.push(u.nextValue),0<r&&r<=i.length?u.stop():u.next()):(e--,u.next()):u.stop(),[2]}))}
2))}))];case 3:return o.sent(),this._mutex.unlock(),[2,i];case 4:throw s=o.sent(),this._mutex.unlock(),s;case 5:return[2]}}))}))},n.prototype.count=function(){return f(this,void 0,void 0,(function(){var t,e,r=this;return p(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),t=0,[4,this._mutex.lock()];case 1:return i.sent(),[4,this._iterator.each((function(s){return f(r,void 0,void 0,(function(){return p(this,(function(a){return s.error?s.stop():s.hasNext?(t++,s.next()):s.stop(),[2]}))}))}))];case 2:return i.sent(),this._mutex.unlock(),[2,t];case 3:throw e=i.sent(),this._mutex.unlock(),e;case 4:return[2]}}))}))},n})(),gs=function(n){return"".concat("nest","@").concat(n)},nn=function(n,t){return"".concat(gs(n),"/").concat(t)},Ri=function(n,t){return"".concat(nn(n,t),".metadata")},Gr=function(n,t){return"".concat(nn(n,t),"/block.")},Ba=function(n,t){return"".concat(nn(n,t),"/blob.")},nf=(function(){function n(t){var e=t.dbname,r=t.collectionName,i=t.store;this.dbname=e,this.collectionName=r,this.store=i}return n.prototype.get=function(t){return f(this,void 0,void 0,(function(){var e,r,i,s,a,o,u,c,l;return p(this,(function(d){switch(d.label){case 0:return[4,this.store.get(t)];case 1:return(e=d.sent())?(r=e.data,i=e.type,typeof fetch>"u"?[3,4]:[4,fetch(r)]):[3,5];case 2:return[4,d.sent().blob()];case 3:return[2,d.sent()];case 4:for(s=[],a=atob(r.split(",")[1]),o=0;o<a.length;o+=512){for(u=a.slice(o,o+512),c=new Array(u.length),l=0;l<u.length;l++)c[l]=u.charCodeAt(l);s.push(new Uint8Array(c))}return[2,new Blob(s,{type:i})];case 5:return[2,null]}}))}))},n.prototype.save=function(t,e){return e===void 0&&(e="".concat(Date.now())),f(this,void 0,void 0,(function(){var r,i,s,a,o=this;return p(this,(function(u){switch(u.label){case 0:return[4,new Promise((function(c){var l=(function(_,h,v,m){return m===void 0&&(m=0),"".concat(Ba(_,h)).concat(v,".").concat(m)})(o.dbname,o.collectionName,e),d=new FileReader;d.onload=function(){c({blobId:l,data:d.result,type:t.type})},d.readAsDataURL(t)}))];case 1:return r=u.sent(),i=r.blobId,s=r.data,a=r.type,[4,this.store.set({key:i,value:{data:s,type:a}})];case 2:return u.sent(),[2,i]}}))}))},n.prototype.remove=function(t){return f(this,void 0,void 0,(function(){return p(this,(function(e){switch(e.label){case 0:return[4,this.store.remove(t)];case 1:return e.sent(),[2]}}))}))},n.prototype.clear=function(){return f(this,void 0,void 0,(function(){var t,e,r=this;return p(this,(function(i){switch(i.label){case 0:return t=Ba(this.dbname,this.collectionName),[4,this.store.getAllKeys()];case 1:return e=i.sent(),[4,Promise.all(e.filter((function(s){return s.startsWith(t)})).map((function(s){return f(r,void 0,void 0,(function(){return p(this,(function(a){switch(a.label){case 0:return[4,this.store.remove(s)];case 1:return[2,a.sent()]}}))}))})))];case 2:return i.sent(),[2]}}))}))},n})();(function(n){n[n.COMMIT=0]="COMMIT",n[n.WRITE=1]="WRITE",n[n.ERROR=2]="ERROR"})(Jt||(Jt={})),(function(n){n.PENDING="pending",n.PERSISTENT="persistent",n.VOLATILE="volatile"})(Ee||(Ee={})),(function(n){n[n.NO_CACHE=0]="NO_CACHE",n[n.DEFAULT=1]="DEFAULT",n[n.PERSISTENT=2]="PERSISTENT"})(dt||(dt={}));var Kn,Se,ja=[Ee.PENDING,Ee.VOLATILE],yr={},Oe=(function(){function n(t){var e=t.dbname,r=t.limit,i=r===void 0?256:r;return yr[e]||(this.dbname=e,this._items=[],this._limit=i,yr[e]=this),yr[e]}return n.get=function(t){return yr[t]},Object.defineProperty(n.prototype,"items",{get:function(){return this._items},enumerable:!1,configurable:!0}),n.prototype.find=function(t,e,r){return r===void 0&&(r=dt.DEFAULT),f(this,void 0,void 0,(function(){var i,s;return p(this,(function(a){switch(a.label){case 0:return(i=this.get(e))?[3,2]:[4,t.get(e)];case 1:return(s=a.sent())&&(i={key:e,value:s,state:r===dt.PERSISTENT?Ee.PERSISTENT:Ee.VOLATILE},this.put(i)),[3,3];case 2:r===dt.PERSISTENT&&(i.state=Ee.PERSISTENT),a.label=3;case 3:return[2,i]}}))}))},n.prototype.get=function(t,e){e===void 0&&(e=dt.DEFAULT);var r=this._items.map((function(s){return s.key})).indexOf(t);if(r>-1){var i=this._items[r];return e===dt.PERSISTENT&&(i.state=Ee.PERSISTENT),e!==dt.NO_CACHE&&this.put(i),i}return null},n.prototype.put=function(t){var e,r;if(this._limit>0){var i=this._items.map((function(d){return d.key})).indexOf(t.key);if(i>-1)ja.includes(this._items[i].state)&&ja.includes(t.state)?(this._items.splice(i,1),this._items.push(t)):(this._items[i].state=t.state,this._items[i].value=t.value);else{this._items.push(t);var s=this._items.filter((function(d){return d.state===Ee.VOLATILE})),a=s.length-this._limit;if(a>0){var o=[];try{for(var u=z(this._items),c=u.next();!c.done;c=u.next()){var l=c.value;l.state===Ee.VOLATILE&&a>0?a--:o.push(l)}}catch(d){e={error:d}}finally{try{c&&!c.done&&(r=u.return)&&r.call(u)}finally{if(e)throw e.error}}this._items=o}}}},n.prototype.remove=function(t){var e=this._items.map((function(r){return r.key})).indexOf(t);e>-1&&this._items.splice(e,1)},n.prototype.clearByCondition=function(t){this._items=this._items.filter((function(e){return!t(e)}))},n.prototype.clearForDatabase=function(t){this.clearByCondition((function(e){return e.key.startsWith(gs(t))}))},n.prototype.clear=function(t){t===void 0&&(t=!1),this._items=t?[]:this._items.filter((function(e){return e.state!==Ee.VOLATILE}))},n})(),rf=(function(){function n(t){var e=t.dbname,r=t.collectionName,i=t.store;
2this._requests=[],this._onCommit=new Map,this._onWrite=new Map,this._onError=new Map,this.dbname=e,this.collectionName=r,this.metadataKey=(function(s,a){return"".concat(nn(s,a),"/trans.metadata")})(e,r),this.recordsetKey=(function(s,a){return"".concat(nn(s,a),"/trans.recordset")})(e,r),this._store=i}return Object.defineProperty(n.prototype,"generation",{get:function(){return this._metadata?this._metadata.generation:0},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"requestCount",{get:function(){return this._requests.length},enumerable:!1,configurable:!0}),n.prototype._getReducedRecordset=function(t){return t===void 0&&(t=[]),f(this,void 0,void 0,(function(){var e;return p(this,(function(r){switch(r.label){case 0:return[4,this._store.get(this.recordsetKey)];case 1:return(e=r.sent()||[]).push.apply(e,V([],K(t),!1)),[2,this._reduceRecordSet(e)]}}))}))},n.prototype._reduceRecordSet=function(t){for(var e=[],r={},i=t.length-1;i>=0;i--){for(var s=t[i],a=[],o=s.requests.length-1;o>=0;o--){var u=s.requests[o],c=u.data;r[c.key]||(a.unshift(u),r[c.key]=!0)}a.length>0&&(s.requests=a,e.unshift(s))}return e},n.prototype._applyRecord=function(t,e){return f(this,void 0,void 0,(function(){var r,i,s,a,o,u,c,l,d;return p(this,(function(_){switch(_.label){case 0:r=Oe.get(this.dbname),i=e.generation,s=e.requests,a=null,_.label=1;case 1:return _.trys.push([1,3,,4]),[4,this._store.setMany(s.map((function(h){return E(E({},h.data),{generation:i})})))];case 2:for(o=_.sent(),u=0;u<s.length;u++)o[u]instanceof Error&&(a||(a=o[u]),c=s[u].data,r.put(E(E({},c),{state:Ee.PERSISTENT})));return[3,4];case 3:return l=_.sent(),a=l,[3,4];case 4:return a?[3,6]:(d=t.filter((function(h){return h.generation!==i})),[4,this._store.set({key:this.recordsetKey,value:d})]);case 5:return _.sent(),this._onWrite.forEach((function(h){h(s.map((function(v){return v.data})))})),[3,7];case 6:this._onError.forEach((function(h){a&&h(a)})),_.label=7;case 7:return[2]}}
2))}))},n.prototype.init=function(){return f(this,void 0,void 0,(function(){var t,e,r,i,s,a,o,u;return p(this,(function(c){switch(c.label){case 0:return t=this,[4,this._store.get(this.metadataKey)];case 1:return t._metadata=c.sent()||{generation:1},[4,this._getReducedRecordset()];case 2:e=c.sent(),c.label=3;case 3:c.trys.push([3,8,9,10]),r=z(e),i=r.next(),c.label=4;case 4:return i.done?[3,7]:(s=i.value,[4,this._applyRecord(e,s)]);case 5:c.sent(),c.label=6;case 6:return i=r.next(),[3,4];case 7:return[3,10];case 8:return a=c.sent(),o={error:a},[3,10];case 9:try{i&&!i.done&&(u=r.return)&&u.call(r)}finally{if(o)throw o.error}return[7];case 10:return[2]}}))}))},n.prototype.on=function(t,e,r){switch(t){case Jt.COMMIT:this._onCommit.set(e,r);break;case Jt.WRITE:this._onWrite.set(e,r);break;case Jt.ERROR:this._onError.set(e,r)}},n.prototype.requestWrite=function(t,e){this._requests.push({data:t,options:e}),Oe.get(this.dbname).put(E({state:Ee.PENDING},t))},n.prototype.requestMultipleWrite=function(t,e){var r,i,s=Oe.get(this.dbname);try{for(var a=z(t),o=a.next();!o.done;o=a.next()){var u=o.value;this._requests.push({data:u,options:e}),s.put(E({state:Ee.PENDING},u))}}catch(c){r={error:c}}finally{try{o&&!o.done&&(i=a.return)&&i.call(a)}finally{if(r)throw r.error}}},n.prototype.clear=function(){return f(this,void 0,void 0,(function(){return p(this,(function(t){return Oe.get(this.dbname).clearByCondition((function(e){return e.state===Ee.PENDING})),this._requests=[],[2]}))}))},n.prototype.commit=function(){return f(this,void 0,void 0,(function(){var t,e,r,i,s,a,o,u,c,l,d,_,h=this;return p(this,(function(v){switch(v.label){case 0:if(!((t=this._requests).length>0))return[3,4];for(e=[],r={},u=t.length-1;u>=0;u--)i=t[u],l=i.data,r[l.key]||(r[l.key]=!0,e.unshift(i));return s={generation:this.generation,requests:e},[4,this._getReducedRecordset([s])];case 1:return a=v.sent(),[4,this._store.set({key:this.recordsetKey,value:a})];case 2:return v.sent(),this._metadata.generation++,[4,this._store.set({key:this.metadataKey,value:this._metadata})];case 3:for(v.sent(),o=Oe.get(this.dbname),u=0;u<e.length;u++)c=e[u],l=c.data,d=c.options,o.put(E(E({},l),{state:d&&d.persistent?Ee.PERSISTENT:Ee.VOLATILE}));this._requests=[],this._onCommit.forEach((function(m){m(t.map((function(y){return y.data})))})),_=ir.get(this.dbname),setTimeout((function(){try{h._applyRecord(a,s)}catch(m){h._onError.forEach((function(y){return y(m)}))}}),_.transactionApplyDelay),v.label=4;case 4:return[2]}}
2))}))},n})(),Hn=(function(){function n(t){var e=t.blockId,r=t.keyName,i=t.items,s=i===void 0?[]:i,a=t.limit;this.blockId=e,this.keyName=r,this.limit=a,this._items=V([],K(s),!1)}return n.createFromCacheItem=function(t){return t?new n(t.value):null},Object.defineProperty(n.prototype,"isEmpty",{get:function(){return this._items.length===0},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"items",{get:function(){return this._items},enumerable:!1,configurable:!0}),n.prototype.serialize=function(){return{blockId:this.blockId,keyName:this.keyName,limit:this.limit,items:this._items}},n.prototype.getItemByKey=function(t){var e=this,r=this._items.find((function(i){var s=i[e.keyName];return t===s}));return r!=null?r:null},n.prototype.has=function(t){var e=this;return this._items.map((function(r){return r[e.keyName]})).includes(t)},n.prototype.add=function(t){var e=this,r=this._items.map((function(i){return i[e.keyName]})).indexOf(t[this.keyName]);return r<0?this._items.length<this.limit&&(this._items.push(t),!0):(this._items[r]=t,!0)},n.prototype.remove=function(t){for(var e=0;e<this._items.length;e++)if(this._items[e][this.keyName]===t)return this._items.splice(e,1),!0;return!1},n.prototype.clear=function(){this._items=[]},n})(),sf=(function(){function n(t){var e=t.dbname,r=t.collectionName,i=t.metadata,s=t.hashFunction,a=s===void 0?Fa:s,o=t.transaction,u=t.store;this.dbname=e,this.collectionName=r,this.hashFunction=a,this.metadata=i,this._transaction=o,this._store=u}return Object.defineProperty(n.prototype,"keyName",{get:function(){return this.metadata.keyName},enumerable:!1,configurable:!0}),n.prototype.createBlockId=function(t,e){return e===void 0&&(e=this.metadata.blockLevel),r=this.dbname,i=this.collectionName,s=e,a="".concat((function(o,u,c){var l=c.base*Math.pow(c.multiplier,u)+c.constant;return(c.hashFunction||Fa)(o,l)})(t,e,{hashFunction:this.hashFunction,base:this.metadata.blockHashBase,multiplier:this.metadata.blockHashMultiplier,constant:this.metadata.blockHashConstant})),"".concat(Gr(r,i)).concat(s,".").concat(a);var r,i,s,a},n.prototype._findBlock=function(t){return f(this,void 0,void 0,(function(){var e,r,i,s,a;return p(this,(function(o){switch(o.label){case 0:e=Oe.get(this.dbname),r=this.metadata.blockLevel,o.label=1;case 1:return r>0?(i=this.createBlockId(t,r),[4,e.find(this._store,i)]):[3,4];case 2:if((s=o.sent())&&(a=Hn.createFromCacheItem(s),a==null?void 0:a.getItemByKey(t)))return[2,a];o.label=3;case 3:return r--,[3,1];case 4:return[2,null]}}))}))},n.prototype.getFromBlock=function(t){return f(this,void 0,void 0,(function(){var e;return p(this,(function(r){switch(r.label){case 0:return[4,this._findBlock(t)];case 1:return[2,(e=r.sent())?e.getItemByKey(t):null]}}))}))},n.prototype.putToBlock=function(t,e){return f(this,void 0,void 0,(function(){var r,i,s,a,o;return p(this,(function(u){switch(u.label){case 0:return r=ir.get(this.dbname),i=this.createBlockId(t),s=Math.floor(this._store.itemSizeLimit/r.itemSizeLimit),[4,Oe.get(this.dbname).find(this._store,i)];case 1:return a=u.sent(),(o=a?Hn.createFromCacheItem(a):new Hn({blockId:i,keyName:this.keyName,items:[],limit:s}))!=null&&o.add(e)?(this._transaction.requestWrite({key:o.blockId,value:o.serialize()}),[2,!0]):[2,!1]}}))}))},n.prototype.removeFromBlock=function(t){return f(this,void 0,void 0,(function(){var e;return p(this,(function(r){switch(r.label){case 0:return[4,this._findBlock(t)];case 1:return(e=r.sent())&&e.remove(t)?(this._transaction.requestWrite({key:e.blockId,value:e.serialize()}),[2,!0]):[2,!1]}}))}))},n.prototype.clearAllBlocks=function(){return f(this,void 0,void 0,(function(){var t,e,r;return p(this,(function(i){switch(i.label){case 0:return t=Gr(this.dbname,this.collectionName),[4,this._store.getAllKeys()];case 1:return e=i.sent(),r=e.filter((function(s){return s.startsWith(t)})),[4,this._store.removeMany(r)];case 2:return i.sent(),[4,this._transaction.clear()];case 3:return i.sent(),Oe.get(this.dbname).clearByCondition((function(s){return s.key.startsWith(t)})),[2]}}))}))},n})(),kt=(function(){function n(t){var e=t.dbname,r=t.collectionName,i=t.keyName,s=t.fields,a=t.transaction,o=t.store,u=t.mutex,c=this;this._origin=[],this._table=[],this.restoreInterval=1e3;var l=(function(d,_,h){return"".concat(nn(d,_),"/index.").concat(h)})(e,r,s.join(">"));this.dbname=e,this.collectionName=r,this.keyName=i,this.fields=s,this.indexerKey=l,this._store=o,this._transaction=a,this._transaction.on(Jt.COMMIT,this.indexerKey,(function(){return c.commit()})),this._transaction.on(Jt.ERROR,this.indexerKey,(function(){return c.abort()})),this._lastRestoreIndexerTime=0,this._isRestoringIndexer=!1,this._mutex=u}return n.createKey=function(t){return t.join(">")},n.parseKey=function(t){return t.split(">")},n.prototype._addItem=function(t){var e=t[this.keyName],r=this.getColumnValues(t),i=K(this.indexOf(r),2),s=i[0];return i[1]?!this._table[s].keys.includes(e)&&(this._table[s].keys.push(e),!0):(this._table.splice(s,0,{columnValues:r,keys:[e]}),!0)},n.prototype._removeItem=function(t){var e=t[this.keyName],r=this.getColumnValues(t),i=K(this.indexOf(r),2),s=i[0];if(i[1]){var a=this._table[s].keys.indexOf(e);if(a>-1)return this._table[s].keys.splice(a,1),this._table[s].keys.length===0&&this._table.splice(s,1),!0}return!1},Object.defineProperty(n.prototype,"origin",{get:function(){return this._origin}
2,enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"table",{get:function(){return this._table},enumerable:!1,configurable:!0}),n.prototype.getColumnValues=function(t){var e,r,i,s,a=[];try{for(var o=z(this.fields),u=o.next();!u.done;u=o.next()){var c=u.value;if(c[0]==="-"&&(c=c.slice(1)),i=t[c],s=void 0,s=typeof i,i!==null&&s!=="undefined"&&s!=="boolean"&&s!=="number"&&s!=="string")throw $.indexTypesNotMatch;a.push(t[c])}}catch(l){e={error:l}}finally{try{u&&!u.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}return a},n.prototype.diff=function(t,e){for(var r in this.fields){var i=this.fields[r][0]==="-"?-1:1,s=Ct(t[r],e[r]);if(s!==0)return i*s}return 0},n.prototype.indexOf=function(t){return this._indexOfInTable(this._table,t)},n.prototype._indexOfInTable=function(t,e){if(t.length>0){for(var r=0,i=t.length-1;r<=i;){var s=Math.floor((r+i)/2),a=this.diff(e,t[s].columnValues);if(a>0)r=s+1;else{if(!(a<0))return[s,!0];i=s-1}}return[r,!1]}return[0,!1]},n.prototype.ensure=function(){return f(this,void 0,void 0,(function(){var t,e,r,i,s,a,o,u,c,l,d,_,h,v,m,y,b;return p(this,(function(w){switch(w.label){case 0:return[4,(t=Oe.get(this.dbname)).find(this._store,this.indexerKey,dt.PERSISTENT)];case 1:return(e=w.sent())?[3,11]:(r=Gr(this.dbname,this.collectionName),[4,this._store.getAllKeys()]);case 2:i=w.sent(),w.label=3;case 3:w.trys.push([3,8,9,10]),s=z(i),a=s.next(),w.label=4;case 4:return a.done?[3,7]:(o=a.value).startsWith(r)?[4,t.find(this._store,o,dt.NO_CACHE)]:[3,6];case 5:if(u=w.sent(),c=Hn.createFromCacheItem(u))try{for(y=void 0,l=z(c.items),d=l.next();!d.done;d=l.next())_=d.value,this._addItem(_)}catch(I){y={error:I}}finally{try{d&&!d.done&&(b=l.return)&&b.call(l)}finally{if(y)throw y.error}}w.label=6;case 6:return a=s.next(),[3,4];case 7:return[3,10];case 8:return h=w.sent(),v={error:h},[3,10];case 9:try{a&&!a.done&&(m=s.return)&&m.call(s)}finally{if(v)throw v.error}return[7];case 10:return this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[3,12];case 11:this._origin=e.value,this._table=Ae(this._origin),w.label=12;case 12:return[2]}}
2))}))},n.prototype.restoreIndexer=function(){return f(this,void 0,void 0,(function(){var t,e,r,i,s,a,o,u,c,l,d,_,h,v,m,y,b,w,I,A,D,N,F,q,x,H,j,P,ce,Me,Pe,En,wn,At,bs,si,Es,ar,ws,ai,Is,oi,Ts;return p(this,(function(Qe){switch(Qe.label){case 0:if(t=Date.now(),this._isRestoringIndexer||t-this._lastRestoreIndexerTime<this.restoreInterval)return[2];Qe.label=1;case 1:return Qe.trys.push([1,,13,14]),this._mutex.lock(),this._isRestoringIndexer=!0,this._lastRestoreIndexerTime=t,[4,this._store.get(this.indexerKey)];case 2:(e=Qe.sent())?(this._origin=e,this._table=Ae(this._origin)):this._table=[],r=new Set;try{for(i=z(this._table),s=i.next();!s.done;s=i.next()){a=s.value;try{for(At=void 0,o=z(a.keys),u=o.next();!u.done;u=o.next())P=u.value,r.add(P)}catch(gt){At={error:gt}}finally{try{u&&!u.done&&(bs=o.return)&&bs.call(o)}finally{if(At)throw At.error}}}}catch(gt){En={error:gt}}finally{try{s&&!s.done&&(wn=i.return)&&wn.call(i)}finally{if(En)throw En.error}}return c=Gr(this.dbname,this.collectionName),[4,this._store.getAllKeys()];case 3:l=Qe.sent(),d=new Set,_=new Map,Qe.label=4;case 4:Qe.trys.push([4,9,10,11]),h=z(l),v=h.next(),Qe.label=5;case 5:return v.done?[3,8]:(P=v.value).startsWith(c)?[4,this._store.get(P)]:[3,7];case 6:if(m=Qe.sent(),y=m?Hn.createFromCacheItem({key:P,value:m,state:Ee.VOLATILE}):null)try{for(ar=void 0,b=z(y.items),w=b.next();!w.done;w=b.next())j=w.value,I=j[this.keyName],d.add(I),_.set(I,j)}catch(gt){ar={error:gt}}finally{try{w&&!w.done&&(ws=b.return)&&ws.call(b)}finally{if(ar)throw ar.error}}Qe.label=7;case 7:return v=h.next(),[3,5];case 8:return[3,11];case 9:return A=Qe.sent(),si={error:A},[3,11];case 10:try{v&&!v.done&&(Es=h.return)&&Es.call(h)}finally{if(si)throw si.error}return[7];case 11:if(d.size===0)return[2];D=!1,N=[];try{for(F=z(d),q=F.next();!q.done;q=F.next())P=q.value,r.has(P)||(D=!0,console.warn("Indexer restore: missed key detected - ".concat(P)),(j=_.get(P))&&N.push(j))}catch(gt){ai={error:gt}}finally{try{q&&!q.done&&(Is=F.return)&&Is.call(F)}finally{if(ai)throw ai.error}}if(!D)return[2];try{for(x=z(N),H=x.next();!H.done;H=x.next())j=H.value,P=j[this.keyName],ce=this.getColumnValues(j),Me=K(this._indexOfInTable(this._table,ce),2),Pe=Me[0],Me[1]?this._table[Pe].keys.includes(P)||this._table[Pe].keys.push(P):this._table.splice(Pe,0,{columnValues:ce,keys:[P]})}catch(gt){oi={error:gt}}finally{try{H&&!H.done&&(Ts=x.return)&&Ts.call(x)}finally{if(oi)throw oi.error}}return[4,this._store.set({key:this.indexerKey,value:this._table})];case 12:return Qe.sent(),Oe.get(this.dbname).put({key:this.indexerKey,value:this._table,state:Ee.PERSISTENT}),this._origin=Ae(this._table),[3,14];case 13:return this._isRestoringIndexer=!1,this._mutex.unlock(),[7];case 14:return[2]}}
2))}))},n.prototype.drop=function(){return f(this,void 0,void 0,(function(){return p(this,(function(t){switch(t.label){case 0:return Oe.get(this.dbname).remove(this.indexerKey),[4,this._store.remove(this.indexerKey)];case 1:return t.sent(),[2]}}))}))},n.prototype.addItem=function(t){return f(this,void 0,void 0,(function(){return p(this,(function(e){return this._addItem(t)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[2]}))}))},n.prototype.removeItem=function(t){return f(this,void 0,void 0,(function(){return p(this,(function(e){return this._removeItem(t)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[2]}))}))},n.prototype.clear=function(){return f(this,void 0,void 0,(function(){return p(this,(function(t){return this._table=[],this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[2]}))}))},n.prototype.commit=function(){this._origin=this._table,this._table=Ae(this._origin)},n.prototype.abort=function(){this._table=Ae(this._origin)},n})(),Qr=function(){return typeof document<"u"&&typeof navigator<"u"&&navigator.product!=="ReactNative"},Ka=function(){var n=new Date().getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var e=(n+16*Math.random())%16|0;return n=Math.floor(n/16),(t==="x"?e:3&e|8).toString(16)}))};(function(n){n[n.PROCESSING=0]="PROCESSING",n[n.DONE=1]="DONE"})(Kn||(Kn={})),(function(n){n.NEWNODE="newnode",n.REMOVENODE="removenode",n.CLAIM_HOST="claimhost",n.SYNC_HOST="synchost",n.REQUEST_LOCK="requestlock",n.ACQUIRE_LOCK="acquirelock",n.RELEASE_LOCK="releaselock"})(Se||(Se={}));var Je,Li={},ni=(function(){function n(t,e){e===void 0&&(e={});var r=this;return this._state=Kn.PROCESSING,this._queue=[],this._activationQueue=[],Li[t]&&!e.forceCreate||(this.nodeId=Ka(),this.key=t,Qr()&&(e.startAsInvisible?this.registerNode():document.visibilityState==="visible"?this.claimHost():this.registerNode(),document.addEventListener("visibilitychange",(function(){document.visibilityState==="visible"&&r.claimHost()})),window.addEventListener("message",(function(i){var s,a,o=i.data;if(o!=null&&o.isNestDbMessage){var u=o.nodeId,c=o.requestId,l=o.key,d=o.op,_=o.data;if(u!==r.nodeId&&l===r.key)switch(d){case Se.NEWNODE:r._sendSync();break;case Se.CLAIM_HOST:r._sendSync(),r._hostId=u;break;case Se.SYNC_HOST:if(!r.isInSync){r._activationTimeout&&clearTimeout(r._activationTimeout);var h=_,v=h.currentItemRequestId,m=h.queue,y=function(A){var D=r._queue.findIndex((function(N){return N.requestId===A.requestId}));D<0&&r._requestLock({isNestDbMessage:!0,nodeId:A.nodeId,requestId:A.requestId,key:r.key,op:Se.REQUEST_LOCK,ts:A.ts})};try{for(var b=z(m),w=b.next();!w.done;w=b.next())y(w.value)}catch(A){s={error:A}}finally{try{w&&!w.done&&(a=b.return)&&a.call(b)}finally{if(s)throw s.error}}r._currentItem=r._queue.find((function(A){return A.requestId===v})),r._completeSync()}break;case Se.REMOVENODE:r._queue=r._queue.filter((function(A){return A.nodeId!==o.nodeId})),r._currentItem&&r._currentItem.nodeId===o.nodeId&&(r._currentItem=void 0,r._acquire(r._queue[0]));break;case Se.REQUEST_LOCK:r._requestLock(o);break;case Se.ACQUIRE_LOCK:var I=r._queue.find((function(A){return A.requestId===c}));r._acquire(I);break;case Se.RELEASE_LOCK:r._release(c)}}})),window.addEventListener("beforeunload",(function(){r._send(Se.REMOVENODE)}))),Li[t]=this),Li[t]}return Object.defineProperty(n.prototype,"locked",{get:function(){return!!this._currentItem},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isHost",{get:function(){return this._hostId===this.nodeId},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isInSync",{get:function(){return this._state==Kn.DONE},enumerable:!1,configurable:!0}),n.prototype._send=function(t,e){var r;e===void 0&&(e={});var i={isNestDbMessage:!0,nodeId:this.nodeId,requestId:(r=e==null?void 0:e.requestId)!==null&&r!==void 0?r:Ka(),key:this.key,op:t,data:e.data,ts:Date.now()};return Qr()&&window.postMessage(i,"*"),i},n.prototype._acquire=function(t){t?(this._currentItem=t,this._currentItem.onAcquired&&this._currentItem.onAcquired(t.requestId)):this._currentItem=void 0},n.prototype._release=function(t){if(this._currentItem&&this._currentItem.requestId===t){var e=this._currentItem;this._currentItem=void 0,e.nodeId===this.nodeId&&this._send(Se.RELEASE_LOCK,{requestId:e.requestId});var r=this._queue.findIndex((function(i){return i.requestId===t}));r>-1&&this._queue.splice(r,1),e.onReleased&&e.onReleased(t)}},n.prototype._requestLock=function(t){var e=this;return new Promise((function(r){for(var i={nodeId:t.nodeId,requestId:t.requestId,ts:t.ts,onAcquired:function(o){e.isHost&&e._send(Se.ACQUIRE_LOCK,{requestId:o}),r()},onReleased:function(){e._acquire(e._queue[0])}},s=!1,a=0;a<e._queue.length;a++)if(e._queue[a].ts>i.ts){e._queue.splice(a,0,i),s=!0;break}s||e._queue.push(i),e._currentItem||e._acquire(e._queue[0])}))},n.prototype._sendSync=function(){var t;this.isHost&&this._send(Se.SYNC_HOST,{data:{currentItemRequestId:(t=this._currentItem)===null||t===void 0?void 0:t.requestId,queue:this._queue.map((function(e){return{nodeId:e.nodeId,requestId:e.requestId,ts:e.ts}}))}})},n.prototype._waitUntilSyncCompleted=function(){return f(this,void 0,void 0,(function(){var t=this;return p(this,(function(e){return this.isHost&&!this.isInSync?[2,new Promise((function(r){t._activationQueue.push(r)}))]:[2]}))}))},n.prototype._waitSync=function(){var t=this;this.isInSync||(this._activationTimeout=setTimeout((function(){t._completeSync()}),8))},n.prototype._completeSync=function(){this.isInSync||(this._state=Kn.DONE,this._activationQueue.forEach((function(t){return t()})),this._activationQueue=[])},n.prototype.registerNode=function(){this._send(Se.NEWNODE),this._waitSync()},n.prototype.claimHost=function(){this._hostId=this.nodeId,this._send(Se.CLAIM_HOST),this._waitSync()},n.prototype.lock=function(){return f(this,void 0,void 0,(function(){var t;return p(this,(function(e){switch(e.label){case 0:return[4,this._waitUntilSyncCompleted()];case 1:return e.sent(),t=this._send(Se.REQUEST_LOCK),[4,this._requestLock(t)];case 2:return e.sent(),[2]}}))}))},n.prototype.unlock=function(){var t;!((t=this._currentItem)===null||t===void 0)&&t.requestId&&this._release(this._currentItem.requestId)},n})(),Ui=(function(){function n(t){var e=t.dbname,r=t.collectionName,i=t.keyName,s=t.keyHash,a=t.indexes,o=t.store,u=this;this._state=Wt.INIT,this._indexers=[],this.dbname=e,this.name=r,this.keyName=i,this.indexes=V([[i]],K(a.filter((function(c){return kt.createKey(c)!==u.keyName}))),!1),this._keyHash=s,this._store=o,this._mutex=new ni((function(c,l){return"".concat(nn(c,l),".lock")})(e,r)),this._blobContainer=new nf({dbname:e,collectionName:r,store:o}),this._transaction=new rf({dbname:e,collectionName:r,store:o})}return n.metadataOf=function(t,e,r){return f(this,void 0,void 0,(function(){var i;return p(this,(function(s){switch(s.label){case 0:return i=Ri(t,e),[4,r.get(i)];case 1:return[2,s.sent()]}}))}))},Object.defineProperty(n.prototype,"state",{get:function(){return this._state}
2,enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isReady",{get:function(){return this._state===Wt.READY},enumerable:!1,configurable:!0}),n.prototype.init=function(){return f(this,void 0,void 0,(function(){var t,e,r,i,s,a,o,u,c,l,d,_,h,v,m=this;return p(this,(function(y){switch(y.label){case 0:return[4,this._mutex.lock()];case 1:y.sent(),y.label=2;case 2:return y.trys.push([2,9,,10]),t=ir.get(this.dbname),[4,n.metadataOf(this.dbname,this.name,this._store)];case 3:return e=y.sent(),this._metadata=e||{keyName:this.keyName,blockLevel:1,blockHashBase:t.blockHashBase,blockHashMultiplier:t.blockHashMultiplier,blockHashConstant:t.blockHashConstant,indexes:this.indexes},[4,this._transaction.init()];case 4:y.sent(),this._blockManager=new sf({dbname:this.dbname,collectionName:this.name,hashFunction:this._keyHash,metadata:this._metadata,transaction:this._transaction,store:this._store}),r=V([],K(this.indexes),!1),i=[],s=r.map((function(b){return kt.createKey(b)})),a=e?e.indexes.map((function(b){return kt.createKey(b)})):[];try{for(o=z(a),u=o.next();!u.done;u=o.next())c=u.value,s.includes(c)||i.push(kt.parseKey(c))}catch(b){h={error:b}}finally{try{u&&!u.done&&(v=o.return)&&v.call(o)}finally{if(h)throw h.error}}return(l=[]).push.apply(l,V([],K(r.map((function(b){var w=new kt({dbname:m.dbname,collectionName:m.name,keyName:m.keyName,fields:b,transaction:m._transaction,store:m._store,mutex:m._mutex});return m._indexers.push(w),w.ensure()}))),!1)),l.push.apply(l,V([],K(i.map((function(b){return new kt({dbname:m.dbname,collectionName:m.name,keyName:m.keyName,fields:b,transaction:m._transaction,store:m._store,mutex:m._mutex}).drop()}))),!1)),[4,Promise.all(l)];case 5:return y.sent(),[4,this._transaction.commit()];case 6:return y.sent(),s.sort().join(",")===a.sort().join(",")?[3,8]:(d=Ri(this.dbname,this.name),this._metadata.indexes=r,[4,this._store.set({key:d,value:this._metadata})]);case 7:y.sent(),y.label=8;case 8:return this._state=Wt.READY,this._mutex.unlock(),[3,10];case 9:throw _=y.sent(),this._mutex.unlock(),_;case 10:return[2]}}
2))}))},n.prototype.close=function(){this._state=Wt.CLOSED},n.prototype._hasPropertyOfKeyName=function(t){var e=t[this.keyName];return typeof e=="string"&&!!e},n.prototype._getIndexerBy=function(t){var e,r;t===void 0&&(t=null),t||(t=[this.keyName]);var i=kt.createKey(t);try{for(var s=z(this._indexers),a=s.next();!a.done;a=s.next()){var o=a.value;if(i===kt.createKey(o.fields))return o}}catch(u){e={error:u}}finally{try{a&&!a.done&&(r=s.return)&&r.call(s)}finally{if(e)throw e.error}}throw $.indexTableIsRequired},n.prototype._upgradeBlockLevel=function(){return f(this,void 0,void 0,(function(){var t;return p(this,(function(e){switch(e.label){case 0:return t=Ri(this.dbname,this.name),this._metadata.blockLevel++,[4,this._store.set({key:t,value:this._metadata})];case 1:return e.sent(),[2]}}))}))},n.prototype._requestInsert=function(t){return f(this,void 0,void 0,(function(){var e,r,i,s,a,o;return p(this,(function(u){switch(u.label){case 0:return e=t[this.keyName],[4,this._blockManager.getFromBlock(e)];case 1:return u.sent()?[3,13]:[4,this._blockManager.putToBlock(e,t)];case 2:return u.sent()?[3,5]:[4,this._upgradeBlockLevel()];case 3:return u.sent(),[4,this._blockManager.putToBlock(e,t)];case 4:u.sent(),u.label=5;case 5:u.trys.push([5,10,11,12]),r=z(this._indexers),i=r.next(),u.label=6;case 6:return i.done?[3,9]:[4,i.value.addItem(t)];case 7:u.sent(),u.label=8;case 8:return i=r.next(),[3,6];case 9:return[3,12];case 10:return s=u.sent(),a={error:s},[3,12];
2case 11:try{i&&!i.done&&(o=r.return)&&o.call(r)}finally{if(a)throw a.error}return[7];case 12:return[3,14];case 13:throw $.collectionInsertDuplicate;case 14:return[2]}}))}))},n.prototype._requestUpsert=function(t){return f(this,void 0,void 0,(function(){var e,r,i,s,a,o,u,c,l,d,_,h,v;return p(this,(function(m){switch(m.label){case 0:return e=t[this.keyName],[4,this._blockManager.getFromBlock(e)];case 1:return(r=m.sent())?[3,13]:[4,this._blockManager.putToBlock(e,t)];case 2:return m.sent()?[3,5]:[4,this._upgradeBlockLevel()];case 3:return m.sent(),[4,this._blockManager.putToBlock(e,t)];case 4:m.sent(),m.label=5;case 5:m.trys.push([5,10,11,12]),i=z(this._indexers),s=i.next(),m.label=6;case 6:return s.done?[3,9]:[4,(c=s.value).addItem(t)];case 7:m.sent(),m.label=8;case 8:return s=i.next(),[3,6];case 9:return[3,12];case 10:return a=m.sent(),d={error:a},[3,12];case 11:try{s&&!s.done&&(_=i.return)&&_.call(i)}finally{if(d)throw d.error}return[7];case 12:return[3,23];case 13:return[4,this._blockManager.putToBlock(e,t)];case 14:m.sent(),m.label=15;case 15:m.trys.push([15,21,22,23]),o=z(this._indexers),u=o.next(),m.label=16;case 16:return u.done?[3,20]:(c=u.value).diff(c.getColumnValues(r),c.getColumnValues(t))===0?[3,19]:[4,c.removeItem(r)];case 17:return m.sent(),[4,c.addItem(t)];case 18:m.sent(),m.label=19;case 19:return u=o.next(),[3,16];case 20:return[3,23];case 21:return l=m.sent(),h={error:l},[3,23];case 22:try{u&&!u.done&&(v=o.return)&&v.call(o)}finally{if(h)throw h.error}return[7];case 23:return[2]}}
2))}))},n.prototype._requestUpdate=function(t){return f(this,void 0,void 0,(function(){var e,r,i,s,a,o,u,c;return p(this,(function(l){switch(l.label){case 0:return e=t[this.keyName],[4,this._blockManager.getFromBlock(e)];case 1:return(r=l.sent())?[4,this._blockManager.putToBlock(e,t)]:[3,11];case 2:l.sent(),l.label=3;case 3:l.trys.push([3,9,10,11]),i=z(this._indexers),s=i.next(),l.label=4;case 4:return s.done?[3,8]:(a=s.value).diff(a.getColumnValues(r),a.getColumnValues(t))===0?[3,7]:[4,a.removeItem(r)];case 5:return l.sent(),[4,a.addItem(t)];case 6:l.sent(),l.label=7;case 7:return s=i.next(),[3,4];case 8:return[3,11];case 9:return o=l.sent(),u={error:o},[3,11];case 10:try{s&&!s.done&&(c=i.return)&&c.call(i)}finally{if(u)throw u.error}return[7];case 11:return[2]}}))}))},n.prototype._requestRemove=function(t){return f(this,void 0,void 0,(function(){var e,r,i,s,a,o;return p(this,(function(u){switch(u.label){case 0:return[4,this._blockManager.getFromBlock(t)];case 1:return(e=u.sent())?[4,this._blockManager.removeFromBlock(t)]:[3,10];case 2:u.sent(),u.label=3;case 3:u.trys.push([3,8,9,10]),r=z(this._indexers),i=r.next(),u.label=4;case 4:return i.done?[3,7]:[4,i.value.removeItem(e)];case 5:u.sent(),u.label=6;case 6:return i=r.next(),[3,4];case 7:return[3,10];case 8:return s=u.sent(),a={error:s},[3,10];
2case 9:try{i&&!i.done&&(o=r.return)&&o.call(r)}finally{if(a)throw a.error}return[7];case 10:return[2]}}))}))},n.prototype._requestClear=function(){return f(this,void 0,void 0,(function(){var t,e,r,i,s;return p(this,(function(a){switch(a.label){case 0:return[4,this._blockManager.clearAllBlocks()];case 1:a.sent(),a.label=2;case 2:a.trys.push([2,7,8,9]),t=z(this._indexers),e=t.next(),a.label=3;case 3:return e.done?[3,6]:[4,e.value.clear()];case 4:a.sent(),a.label=5;case 5:return e=t.next(),[3,3];case 6:return[3,9];case 7:return r=a.sent(),i={error:r},[3,9];case 8:try{e&&!e.done&&(s=t.return)&&s.call(t)}finally{if(i)throw i.error}return[7];case 9:return[2]}}))}))},n.prototype.getByKey=function(t){return f(this,void 0,void 0,(function(){var e,r;return p(this,(function(i){switch(i.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,6];case 1:i.sent(),i.label=2;case 2:return i.trys.push([2,4,,5]),[4,this._blockManager.getFromBlock(t)];case 3:return e=i.sent(),this._mutex.unlock(),[2,Ae(e)];case 4:throw r=i.sent(),this._mutex.unlock(),r;case 5:return[3,7];case 6:throw $.collectionNotReady;case 7:return[2]}}
2))}))},n.prototype.query=function(t){if(t===void 0&&(t={}),this.isReady)return new tf({condition:t.where,mutex:this._mutex,blockManager:this._blockManager,indexer:this._getIndexerBy(t.index),backward:!!t.backward});throw $.collectionNotReady},n.prototype.insertOne=function(t){return f(this,void 0,void 0,(function(){var e;return p(this,(function(r){switch(r.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,8];case 1:r.sent(),r.label=2;case 2:if(r.trys.push([2,5,,7]),!this._hasPropertyOfKeyName(t))throw $.collectionKeyNotGiven;return[4,this._requestInsert(Ae(t))];case 3:return r.sent(),[4,this._transaction.commit()];case 4:return r.sent(),this._mutex.unlock(),[2,t];case 5:return e=r.sent(),[4,this._transaction.clear()];case 6:throw r.sent(),this._mutex.unlock(),e;case 7:return[3,9];case 8:throw $.collectionNotReady;case 9:return[2]}}))}))},n.prototype.insertMany=function(t){return f(this,void 0,void 0,(function(){var e,r,i,s,a,o,u,c=this;return p(this,(function(l){switch(l.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:l.sent(),l.label=2;case 2:if(l.trys.push([2,12,,14]),t.some((function(d){return!c._hasPropertyOfKeyName(d)})))throw $.collectionKeyNotGiven;l.label=3;case 3:l.trys.push([3,8,9,10]),e=z(t),r=e.next(),l.label=4;case 4:return r.done?[3,7]:(i=r.value,[4,this._requestInsert(Ae(i))]);case 5:l.sent(),l.label=6;case 6:return r=e.next(),[3,4];case 7:return[3,10];case 8:return s=l.sent(),o={error:s},[3,10];case 9:try{r&&!r.done&&(u=e.return)&&u.call(e)}finally{if(o)throw o.error}return[7];case 10:return[4,this._transaction.commit()];case 11:return l.sent(),this._mutex.unlock(),[2,t];case 12:return a=l.sent(),[4,this._transaction.clear()];case 13:throw l.sent(),this._mutex.unlock(),a;case 14:return[3,16];case 15:throw $.collectionNotReady;case 16:return[2]}}
2))}))},n.prototype.upsertOne=function(t){return f(this,void 0,void 0,(function(){var e;return p(this,(function(r){switch(r.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,8];case 1:r.sent(),r.label=2;case 2:if(r.trys.push([2,5,,7]),!this._hasPropertyOfKeyName(t))throw $.collectionKeyNotGiven;return[4,this._requestUpsert(Ae(t))];case 3:return r.sent(),[4,this._transaction.commit()];case 4:return r.sent(),this._mutex.unlock(),[2,t];case 5:return e=r.sent(),[4,this._transaction.clear()];case 6:throw r.sent(),this._mutex.unlock(),e;case 7:return[3,9];case 8:throw $.collectionNotReady;case 9:return[2]}}))}))},n.prototype.upsertMany=function(t){return f(this,void 0,void 0,(function(){var e,r,i,s,a,o,u,c=this;return p(this,(function(l){switch(l.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:l.sent(),l.label=2;case 2:if(l.trys.push([2,12,,14]),t.some((function(d){return!c._hasPropertyOfKeyName(d)})))throw $.collectionKeyNotGiven;l.label=3;case 3:l.trys.push([3,8,9,10]),e=z(t),r=e.next(),l.label=4;case 4:return r.done?[3,7]:(i=r.value,[4,this._requestUpsert(Ae(i))]);case 5:l.sent(),l.label=6;case 6:return r=e.next(),[3,4];case 7:return[3,10];case 8:return s=l.sent(),o={error:s},[3,10];case 9:try{r&&!r.done&&(u=e.return)&&u.call(e)}finally{if(o)throw o.error}return[7];case 10:return[4,this._transaction.commit()];case 11:return l.sent(),this._mutex.unlock(),[2,t];case 12:return a=l.sent(),[4,this._transaction.clear()];case 13:throw l.sent(),this._mutex.unlock(),a;case 14:return[3,16];case 15:throw $.collectionNotReady;case 16:return[2]}}
2))}))},n.prototype.update=function(t){return f(this,void 0,void 0,(function(){var e;return p(this,(function(r){switch(r.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,8];case 1:r.sent(),r.label=2;case 2:if(r.trys.push([2,5,,7]),!this._hasPropertyOfKeyName(t))throw $.collectionKeyNotGiven;return[4,this._requestUpdate(Ae(t))];case 3:return r.sent(),[4,this._transaction.commit()];case 4:return r.sent(),this._mutex.unlock(),[2,t];case 5:return e=r.sent(),[4,this._transaction.clear()];case 6:throw r.sent(),this._mutex.unlock(),e;case 7:return[3,9];case 8:throw $.collectionNotReady;case 9:return[2]}}))}))},n.prototype.updateIf=function(t,e){return f(this,void 0,void 0,(function(){var r,i,s,a,o,u,c,l,d,_,h,v,m,y,b=this;return p(this,(function(w){switch(w.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,16];case 1:w.sent(),w.label=2;case 2:return w.trys.push([2,13,,15]),r=t.where,i=r===void 0?{}:r,s=t.index,a=s===void 0?null:s,o=t.backward,u=o!==void 0&&o,c=[],[4,new ss({condition:i,blockManager:this._blockManager,backward:u,indexer:this._getIndexerBy(a)}).each((function(I){return f(b,void 0,void 0,(function(){var A;return p(this,(function(D){if(I.error)throw I.stop(),I.error;return I.hasNext?(A=I.nextValue,Xt(i,A)&&e.set&&(typeof e.set!="function"?Object.keys(e.set).forEach((function(N){var F;A[N]=(F=e.set)===null||F===void 0?void 0:F[N]})):e.set(A),c.push(A)),I.next()):I.stop(),[2]}))}
2))}))];case 3:w.sent(),w.label=4;case 4:w.trys.push([4,9,10,11]),l=z(c),d=l.next(),w.label=5;case 5:return d.done?[3,8]:(_=d.value,[4,this._requestUpdate(Ae(_))]);case 6:w.sent(),w.label=7;case 7:return d=l.next(),[3,5];case 8:return[3,11];case 9:return h=w.sent(),m={error:h},[3,11];case 10:try{d&&!d.done&&(y=l.return)&&y.call(l)}finally{if(m)throw m.error}return[7];case 11:return[4,this._transaction.commit()];case 12:return w.sent(),this._mutex.unlock(),[2,c];case 13:return v=w.sent(),[4,this._transaction.clear()];case 14:throw w.sent(),this._mutex.unlock(),v;case 15:return[3,17];case 16:throw this._transaction.clear(),$.collectionNotReady;case 17:return[2]}}))}))},n.prototype.remove=function(t){return f(this,void 0,void 0,(function(){var e;return p(this,(function(r){switch(r.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,8];case 1:r.sent(),r.label=2;case 2:return r.trys.push([2,5,,7]),[4,this._requestRemove(t)];case 3:return r.sent(),[4,this._transaction.commit()];case 4:return r.sent(),this._mutex.unlock(),[3,7];case 5:return e=r.sent(),[4,this._transaction.clear()];case 6:throw r.sent(),this._mutex.unlock(),e;case 7:return[3,9];case 8:throw $.collectionNotReady;case 9:return[2]}}
2))}))},n.prototype.removeIf=function(t){return f(this,void 0,void 0,(function(){var e,r,i,s,a,o,u,c,l,d,_,h,v,m,y=this;return p(this,(function(b){switch(b.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:b.sent(),b.label=2;case 2:return b.trys.push([2,13,,14]),e=t.where,r=e===void 0?{}:e,i=t.index,s=i===void 0?null:i,a=t.backward,o=a!==void 0&&a,u=[],[4,new ss({condition:r,blockManager:this._blockManager,backward:o,indexer:this._getIndexerBy(s)}).each((function(w){return f(y,void 0,void 0,(function(){var I,A;return p(this,(function(D){if(w.error)throw w.stop(),w.error;return w.hasNext?(I=w.nextValue,Xt(r,I)&&(A=I[this.keyName],u.push(A)),w.next()):w.stop(),[2]}))}))}))];case 3:b.sent(),b.label=4;case 4:b.trys.push([4,9,10,11]),c=z(u),l=c.next(),b.label=5;case 5:return l.done?[3,8]:(d=l.value,[4,this._requestRemove(d)]);case 6:b.sent(),b.label=7;case 7:return l=c.next(),[3,5];case 8:return[3,11];case 9:return _=b.sent(),v={error:_},[3,11];case 10:try{l&&!l.done&&(m=c.return)&&m.call(c)}finally{if(v)throw v.error}return[7];case 11:return[4,this._transaction.commit()];case 12:return b.sent(),this._mutex.unlock(),[2,u];case 13:throw h=b.sent(),this._mutex.unlock(),h;case 14:return[3,16];case 15:throw this._transaction.clear(),$.collectionNotReady;case 16:return[2]}}
2))}))},n.prototype.clear=function(){return f(this,void 0,void 0,(function(){var t;return p(this,(function(e){switch(e.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,8];case 1:e.sent(),e.label=2;case 2:return e.trys.push([2,5,,7]),[4,this._requestClear()];case 3:return e.sent(),[4,this._transaction.commit()];case 4:return e.sent(),this._mutex.unlock(),[3,7];case 5:return t=e.sent(),[4,this._transaction.clear()];case 6:throw e.sent(),this._mutex.unlock(),t;case 7:return[3,9];case 8:throw $.collectionNotReady;case 9:return[2]}}))}))},n.prototype.getBlob=function(t){return f(this,void 0,void 0,(function(){return p(this,(function(e){switch(e.label){case 0:return[4,this._blobContainer.get(t)];case 1:return[2,e.sent()]}}))}))},n.prototype.saveBlob=function(t,e){return f(this,void 0,void 0,(function(){return p(this,(function(r){switch(r.label){case 0:return[4,this._blobContainer.save(t,e)];case 1:return[2,r.sent()]}}))}))},n.prototype.removeBlob=function(t){return f(this,void 0,void 0,(function(){return p(this,(function(e){switch(e.label){case 0:return[4,this._blobContainer.remove(t)];case 1:return e.sent(),[2]}}))}))},n.prototype.removeAllBlobs=function(){return f(this,void 0,void 0,(function(){return p(this,(function(t){switch(t.label){case 0:return[4,this._blobContainer.clear()];case 1:return t.sent(),[2]}}))}))},n})(),Mi="[NESTDB]",br=!0,Bt=(function(){function n(){}return n.off=function(){br=!1},n.log=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];br&&console.log.apply(console,V(["".concat(Mi,"[LOG]")],K(t),!1))},n.warning=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];br&&console.warn.apply(console,V(["".concat(Mi,"[WARNING]")],K(t),!1))},n.error=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];br&&console.error.apply(console,V(["".concat(Mi,"[ERROR]")],K(t),!1))},n})(),af=[{},{a:700400,n:"error"}],ri=(function(){function n(t){var e,r,i;this.encryption=(e=t.encryption)!==null&&e!==void 0?e:oo,this.itemSizeLimit=(r=t.itemSizeLimit)!==null&&r!==void 0?r:4194304,this.metadataBuffer=(i=t.metadataBuffer)!==null&&i!==void 0?i:256}return Object.defineProperty(n.prototype,"_usageCounterKey",{get:function(){return"".concat(this.dbname,".usage.metadata")},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"_usageLockKey",{get:function(){return"".concat(this.dbname,".usage.lock")},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"_encryptionCheckKey",{get:function(){return"".concat(this.dbname,".encrypt")},enumerable:!1,configurable:!0}),n.prototype._shouldAffectUsage=function(t){return!(t===this._encryptionCheckKey||t===this._usageCounterKey||/\/trans\.recordset(\.\d+)?$/.test(t))},n.prototype._getRawKey=function(t,e){return e===void 0&&(e=""),"".concat(t).concat(e)},n.prototype._generateShardPostfixArray=function(t){return t===void 0&&(t=1),V([],K(Array(t).keys()),!1)},n.prototype._getShardKeys=function(t,e){var r=this;return this._generateShardPostfixArray(e).map((function(i){return r._getRawKey(t,".".concat(i))}))},n.prototype._dedupeSetManyItems=function(t){for(var e=[],r=new Set,i=t.length-1;i>=0;i--){var s=t[i];r.has(s.key)||(r.add(s.key),e.unshift(s))}return e},n.prototype._dedupeRemoveManyKeys=function(t){return V([],K(new Set(t)),!1)},n.prototype._calculateRawSize=function(t){return JSON.stringify(t).length},n.prototype._shardify=function(t){var e=this,r=t.key,i=t.value,s=JSON.stringify(this.encryption.encrypt(i)),a=Math.ceil(s.length/this.adjustedItemSizeLimit);return this._generateShardPostfixArray(a).map((function(o){var u={key:e._getRawKey(r,".".concat(o)),data:s.substring(o*e.adjustedItemSizeLimit,(o+1)*e.adjustedItemSizeLimit)};return o===0&&(u.metadata={shards:a}),u}))},n.prototype._getExistingShardInfo=function(t){var e,r;return f(this,void 0,void 0,(function(){var i,s,a,o,u;return p(this,(function(c){switch(c.label){case 0:return[4,this._getRaw(this._getRawKey(t,".0"))];case 1:if(!(i=c.sent()))return[2,{size:0,shardCount:0}];s=(r=(e=i.metadata)===null||e===void 0?void 0:e.shards)!==null&&r!==void 0?r:1,a=this._calculateRawSize(i),o=1,c.label=2;case 2:return o<s?[4,this._getRaw(this._getRawKey(t,".".concat(o)))]:[3,5];case 3:(u=c.sent())&&(a+=this._calculateRawSize(u)),c.label=4;case 4:return o++,[3,2];case 5:return[2,{size:a,shardCount:s}]}}))}))},n.prototype._cleanupOrphanShards=function(t,e,r){return f(this,void 0,void 0,(function(){var i,s;return p(this,(function(a){switch(a.label){case 0:for(i=[],s=e;s<r;s++)i.push(this._getRawKey(t,".".concat(s)));return[4,this._removeRaw(i)];case 1:return a.sent(),[2]}}))}))},n.prototype._resetIfEncryptionChanged=function(){return f(this,void 0,void 0,(function(){var t,e,r,i,s,a,o,u,c,l=this;return p(this,(function(d){switch(d.label){case 0:return[4,this.get(this._encryptionCheckKey)];case 1:if(t=d.sent(),e={encrypted:af.map((function(_){var h;
2return(h=l.encryption)===null||h===void 0?void 0:h.encrypt(_)}))},!t)return[3,8];if(!t.encrypted||!Array.isArray(t.encrypted))return[3,6];for(s in r=t.encrypted,i=[],r)i.push(s);a=0,d.label=2;case 2:return a<i.length?(s=i[a])in r?(o=s,u=JSON.stringify(t.encrypted[o]),c=JSON.stringify(e.encrypted[o]),u===c?[3,4]:(Bt.warning("Encryption algorithm has changed. Stored data would be cleared."),[4,this.clear()])):[3,4]:[3,5];case 3:return d.sent(),[3,5];case 4:return a++,[3,2];case 5:return[3,8];case 6:return[4,this.clear()];case 7:d.sent(),d.label=8;case 8:return[4,this.set({key:this._encryptionCheckKey,value:e})];case 9:return d.sent(),[2]}}))}))},Object.defineProperty(n.prototype,"adjustedItemSizeLimit",{get:function(){return Math.max(this.itemSizeLimit-this.metadataBuffer,4)},enumerable:!1,configurable:!0}),n.prototype._withUsageLock=function(t){return f(this,void 0,void 0,(function(){var e;return p(this,(function(r){switch(r.label){case 0:return[4,(e=new ni(this._usageLockKey)).lock()];case 1:r.sent(),r.label=2;case 2:return r.trys.push([2,,4,5]),[4,t()];case 3:return[2,r.sent()];case 4:return e.unlock(),[7];case 5:return[2]}}
2))}))},n.prototype._readUsageCounter=function(){return f(this,void 0,void 0,(function(){var t,e;return p(this,(function(r){switch(r.label){case 0:return[4,this._getRaw(this._getRawKey(this._usageCounterKey,".0"))];case 1:if(t=r.sent())try{return[2,typeof(e=JSON.parse(t.data)).size=="number"?e.size:null]}catch(i){return[2,null]}return[2,null]}}))}))},n.prototype._rebuildUsageCounterLocked=function(){return f(this,void 0,void 0,(function(){var t,e,r,i,s,a,o,u,c,l;return p(this,(function(d){switch(d.label){case 0:return t=0,[4,this._getAllRawKeys()];case 1:e=d.sent(),d.label=2;case 2:d.trys.push([2,7,8,9]),r=z(e),i=r.next(),d.label=3;case 3:return i.done?[3,6]:(s=i.value,a=s.replace(/\.\d+$/,""),this._shouldAffectUsage(a)?[4,this._getRaw(s)]:[3,5]);case 4:(o=d.sent())&&(t+=this._calculateRawSize(o)),d.label=5;case 5:return i=r.next(),[3,3];case 6:return[3,9];case 7:return u=d.sent(),c={error:u},[3,9];case 8:try{i&&!i.done&&(l=r.return)&&l.call(r)}finally{if(c)throw c.error}return[7];case 9:return[4,this._saveUsageCounter(t)];case 10:return d.sent(),[2,t]}}))}))},n.prototype._getUsageLocked=function(){return f(this,void 0,void 0,(function(){var t,e;return p(this,(function(r){switch(r.label){case 0:return[4,this._readUsageCounter()];case 1:return(t=r.sent())===null?[3,2]:(e=t,[3,4]);case 2:return[4,this._rebuildUsageCounterLocked()];case 3:e=r.sent(),r.label=4;case 4:return[2,e]}}))}))},n.prototype._hasUsageCounterLocked=function(){return f(this,void 0,void 0,(function(){return p(this,(function(t){switch(t.label){case 0:return[4,this._readUsageCounter()];case 1:return[2,t.sent()!==null]}}))}))},n.prototype._saveUsageCounter=function(t){return f(this,void 0,void 0,(function(){var e;return p(this,(function(r){switch(r.label){case 0:return e={key:this._getRawKey(this._usageCounterKey,".0"),data:JSON.stringify({size:t}),metadata:{shards:1}},[4,this._setRaw([e])];case 1:return r.sent(),[2]}}))}))},n.prototype._applyUsageDeltaLocked=function(t){return f(this,void 0,void 0,(function(){var e;return p(this,(function(r){switch(r.label){case 0:return t===0?[2]:[4,this._getUsageLocked()];case 1:return e=r.sent(),[4,this._saveUsageCounter(Math.max(0,e+t))];case 2:return r.sent(),[2]}}))}))},n.prototype.usage=function(){return f(this,void 0,void 0,(function(){var t=this;return p(this,(function(e){switch(e.label){case 0:return[4,this._withUsageLock((function(){return f(t,void 0,void 0,(function(){return p(this,(function(r){switch(r.label){case 0:return[4,this._getUsageLocked()];case 1:return[2,r.sent()]}}))}))}))];case 1:return[2,e.sent()]}}))}))},n.prototype._getAllBaseKeys=function(){return f(this,void 0,void 0,(function(){return p(this,(function(t){switch(t.label){case 0:return[4,this._getAllRawKeys()];case 1:return[2,t.sent().filter((function(e){return e.endsWith(".0")})).map((function(e){return e.replace(/\.0$/,"")}))]}}))}))},n.prototype.getAllKeys=function(){return f(this,void 0,void 0,(function(){var t=this;return p(this,(function(e){switch(e.label){case 0:return[4,this._getAllRawKeys()];case 1:return[2,e.sent().filter((function(r){return r.endsWith(".0")})).map((function(r){return r.replace(/\.0$/,"")})).filter((function(r){return t._shouldAffectUsage(r)}))]}}))}))},n.prototype.get=function(t){return f(this,void 0,void 0,(function(){var e,r,i,s,a,o,u=this;return p(this,(function(c){switch(c.label){case 0:return e=this._getRawKey(t,".0"),[4,this._getRaw(e)];case 1:if(!(r=c.sent()))return[3,7];c.label=2;case 2:return c.trys.push([2,6,,7]),i=r.data,(s=r.metadata)!=null&&s.shards&&s.shards>1?[4,Promise.all(this._generateShardPostfixArray(s==null?void 0:s.shards).map((function(l){return f(u,void 0,void 0,(function(){var d,_;return p(this,(function(h){switch(h.label){case 0:return l>0?(d=this._getRawKey(t,".".concat(l)),[4,this._getRaw(d)]):[3,2];case 1:if(!(_=h.sent()))throw $.storeBrokenIntegrity;return[2,_.data];case 2:return[2,i]}}))}))})))]:[3,4];case 3:return o=c.sent(),[3,5];case 4:o=[i],c.label=5;case 5:return a=o,[2,this.encryption.decrypt(JSON.parse(a.join("")))];case 6:return c.sent(),[2,null];case 7:return[2,null]}}))}))},n.prototype.set=function(t){return f(this,void 0,void 0,(function(){var e=this;return p(this,(function(r){switch(r.label){case 0:return[4,this._withUsageLock((function(){return f(e,void 0,void 0,(function(){var i,s,a,o,u,c,l,d=this;return p(this,(function(_){switch(_.label){case 0:return i=this._shouldAffectUsage(t.key),(
2a=i)?[4,this._hasUsageCounterLocked()]:[3,2];case 1:a=_.sent(),_.label=2;case 2:return(s=a)?[4,this._getExistingShardInfo(t.key)]:[3,4];case 3:return u=_.sent(),[3,5];case 4:u={size:0,shardCount:0},_.label=5;case 5:return o=u,c=this._shardify(t),[4,this._setRaw(c)];case 6:return _.sent(),o.shardCount>c.length?[4,this._cleanupOrphanShards(t.key,c.length,o.shardCount)]:[3,8];case 7:_.sent(),_.label=8;case 8:return s?(l=c.reduce((function(h,v){return h+d._calculateRawSize(v)}),0),[4,this._applyUsageDeltaLocked(l-o.size)]):[3,10];case 9:_.sent(),_.label=10;case 10:return[2,E({},t.value)]}}))}))}))];case 1:return[2,r.sent()]}}))}))},n.prototype.setMany=function(t){return f(this,void 0,void 0,(function(){var e=this;return p(this,(function(r){switch(r.label){case 0:return[4,this._withUsageLock((function(){return f(e,void 0,void 0,(function(){var i,s,a,o,u,c,l,d,_,h,v,m,y,b,w,I,A,D,N,F,q,x,H=this;return p(this,(function(j){switch(j.label){case 0:return i=this._dedupeSetManyItems(t),s=0,a=[],o=[],[4,this._hasUsageCounterLocked()];case 1:u=j.sent(),j.label=2;case 2:j.trys.push([2,9,10,11]),c=z(i),l=c.next(),j.label=3;case 3:return l.done?[3,8]:(d=l.value,(_=this._shouldAffectUsage(d.key)&&u)?[4,this._getExistingShardInfo(d.key)]:[3,5]);case 4:return v=j.sent(),[3,6];case 5:v={size:0,shardCount:0},j.label=6;case 6:h=v,m=this._shardify(d),a.push.apply(a,V([],K(m),!1)),_&&(h.shardCount>m.length&&o.push({key:d.key,newCount:m.length,oldCount:h.shardCount}),y=m.reduce((function(P,ce){return P+H._calculateRawSize(ce)}),0),s+=y-h.size),j.label=7;case 7:return l=c.next(),[3,3];case 8:return[3,11];case 9:return b=j.sent(),N={error:b},[3,11];case 10:try{l&&!l.done&&(F=c.return)&&F.call(c)}finally{if(N)throw N.error}return[7];case 11:return[4,this._setRaw(a)];case 12:j.sent(),j.label=13;case 13:j.trys.push([13,18,19,20]),w=z(o),I=w.next(),j.label=14;case 14:return I.done?[3,17]:(A=I.value,[4,this._cleanupOrphanShards(A.key,A.newCount,A.oldCount)]);case 15:j.sent(),j.label=16;case 16:return I=w.next(),[3,14];case 17:return[3,20];case 18:return D=j.sent(),q={error:D},[3,20];case 19:try{I&&!I.done&&(x=w.return)&&x.call(w)}finally{if(q)throw q.error}return[7];case 20:return u?[4,this._applyUsageDeltaLocked(s)]:[3,22];case 21:j.sent(),j.label=22;case 22:return[2,t.map((function(P){return P.value}))]}}))}))}))];case 1:return[2,r.sent()]}}))}))},n.prototype.remove=function(t){return f(this,void 0,void 0,(function(){var e=this;return p(this,(function(r){switch(r.label){case 0:return[4,this._withUsageLock((function(){return f(e,void 0,void 0,(function(){var i,s,a,o,u;return p(this,(function(c){switch(c.label){case 0:return[4,this._hasUsageCounterLocked()];case 1:return i=c.sent(),[4,this._getExistingShardInfo(t)];case 2:return s=c.sent(),a=s.size,(o=s.shardCount)===0?[2,!1]:[4,this._removeRaw(this._getShardKeys(t,o))];case 3:return c.sent(),(u=Oe.get(this.dbname))==null||u.remove(t),i&&this._shouldAffectUsage(t)?[4,this._applyUsageDeltaLocked(-a)]:[3,5];case 4:c.sent(),c.label=5;case 5:return[2,!0]}}))}))}))];case 1:return[2,r.sent()]}}))}))},n.prototype.removeMany=function(t){return f(this,void 0,void 0,(function(){var e=this;return p(this,(function(r){switch(r.label){case 0:return[4,this._withUsageLock((function(){return f(e,void 0,void 0,(function(){var i,s,a,o,u,c,l,d,_,h,v,m,y,b;return p(this,(function(w){switch(w.label){case 0:return i=this._dedupeRemoveManyKeys(t),s=Oe.get(this.dbname),a=[],o=0,[4,this._hasUsageCounterLocked()];case 1:u=w.sent(),w.label=2;case 2:w.trys.push([2,7,8,9]),c=z(i),l=c.next(),w.label=3;case 3:return l.done?[3,6]:(d=l.value,[4,this._getExistingShardInfo(d)]);case 4:_=w.sent(),h=_.size,(v=_.shardCount)>0&&(a.push.apply(a,V([],K(this._getShardKeys(d,v)),!1)),u&&this._shouldAffectUsage(d)&&(o-=h)),s==null||s.remove(d),w.label=5;case 5:return l=c.next(),[3,3];case 6:return[3,9];case 7:return m=w.sent(),y={error:m},[3,9];case 8:try{l&&!l.done&&(b=c.return)&&b.call(c)}finally{if(y)throw y.error}return[7];case 9:return a.length>0?[4,this._removeRaw(a)]:[3,11];case 10:w.sent(),w.label=11;case 11:return u?[4,this._applyUsageDeltaLocked(o)]:[3,13];case 12:w.sent(),w.label=13;case 13:return[2,t]}}))}))}))];case 1:return[2,r.sent()]}}))}))},n.prototype.clear=function(){return f(this,void 0,void 0,(function(){var t;return p(this,(function(e){return(t=Oe.get(this.dbname))==null||t.clearForDatabase(this.dbname),[2]}))}
2))},n.prototype.trim=function(){},n})(),Le={},Vt=(function(n){function t(e){e===void 0&&(e={});var r,i=this;i=n.call(this,E(E({},e),{itemSizeLimit:(r=e.itemSizeLimit)!==null&&r!==void 0?r:4194304}))||this;var s=e.delay,a=s===void 0?1:s;return i.delay=a,i.observer={},i}return g(t,n),Object.defineProperty(t.prototype,"rawData",{get:function(){return Le[this.dbname]},set:function(e){Le[this.dbname]=e},enumerable:!1,configurable:!0}),t.prototype._getAllRawKeys=function(){return f(this,void 0,void 0,(function(){return p(this,(function(e){if(Le[this.dbname])return[2,Object.keys(Le[this.dbname])];throw $.storeNotAvailable}))}))},t.prototype._getRaw=function(e){return f(this,void 0,void 0,(function(){return p(this,(function(r){switch(r.label){case 0:return Le[this.dbname]?[4,gr(this.delay)]:[3,2];case 1:return r.sent(),[2,Le[this.dbname][e]?E({key:e},Le[this.dbname][e]):null];case 2:throw $.storeNotAvailable}}))}))},t.prototype._setRaw=function(e){return f(this,void 0,void 0,(function(){var r,i,s,a,o,u,c,l;return p(this,(function(d){switch(d.label){case 0:return Le[this.dbname]?[4,gr(this.delay)]:[3,2];case 1:d.sent();try{for(r=z(e),i=r.next();!i.done;i=r.next())s=i.value,a=s.key,o=s.data,u=s.metadata,Le[this.dbname][a]=Object.freeze({data:o,metadata:u})}catch(_){c={error:_}}finally{try{i&&!i.done&&(l=r.return)&&l.call(r)}finally{if(c)throw c.error}}return[3,3];case 2:throw $.storeNotAvailable;case 3:return[2]}}
2))}))},t.prototype._removeRaw=function(e){return f(this,void 0,void 0,(function(){var r,i,s,a,o;return p(this,(function(u){switch(u.label){case 0:return Le[this.dbname]?[4,gr(this.delay)]:[3,2];case 1:u.sent();try{for(r=z(e),i=r.next();!i.done;i=r.next())s=i.value,Le[this.dbname][s]&&delete Le[this.dbname][s]}catch(c){a={error:c}}finally{try{i&&!i.done&&(o=r.return)&&o.call(r)}finally{if(a)throw a.error}}return[3,3];case 2:throw $.storeNotAvailable;case 3:return[2]}}))}))},t.prototype.observe=function(e,r,i){var s=this;this.observer[e]||(this.observer[e]={}),r.forEach((function(a){return s.observer[e][a]=i}))},t.prototype.checkAvailability=function(){return f(this,void 0,void 0,(function(){return p(this,(function(e){return[2]}))}))},t.prototype.init=function(e){return f(this,void 0,void 0,(function(){return p(this,(function(r){switch(r.label){case 0:return this.dbname=e,Le[this.dbname]||(Le[this.dbname]={}),[4,this._resetIfEncryptionChanged()];case 1:return r.sent(),[2]}}))}))},t.prototype.set=function(e){return f(this,void 0,void 0,(function(){var r,i;return p(this,(function(s){if((r=this.observer[e.key])&&typeof r.set=="function"&&(i=r.set()))throw i;return[2,n.prototype.set.call(this,e)]}))}))},t.prototype.setMany=function(e){return f(this,void 0,void 0,(function(){var r,i,s,a,o,u,c;return p(this,(function(l){try{for(r=z(e),i=r.next();!i.done;i=r.next())if(s=i.value,(a=this.observer[s.key])&&typeof a.set=="function"&&(o=a.set()))throw o}catch(d){u={error:d}}finally{try{i&&!i.done&&(c=r.return)&&c.call(r)}finally{if(u)throw u.error}}return[2,n.prototype.setMany.call(this,e)]}))}))},t.prototype.clear=function(){return f(this,void 0,void 0,(function(){var e=this;return p(this,(function(r){switch(r.label){case 0:return[4,this._withUsageLock((function(){return f(e,void 0,void 0,(function(){return p(this,(function(i){switch(i.label){case 0:return[4,n.prototype.clear.call(this)];case 1:return i.sent(),[4,gr(this.delay)];case 2:return i.sent(),Le[this.dbname]={},[2]}}))}))}))];case 1:return r.sent(),[2]}}))}))},t})(ri),Ha="NestDBStore";(function(n){n[n.UNINITIALIZED=0]="UNINITIALIZED",n[n.OPENING=1]="OPENING",n[n.OPEN=2]="OPEN",n[n.CLOSED=3]="CLOSED"})(Je||(Je={}));var of=(function(n){function t(e){e===void 0&&(e={});var r,i=this;return(i=n.call(this,E(E({},e),{itemSizeLimit:(r=e.itemSizeLimit)!==null&&r!==void 0?r:104857600}))||this)._storeName=Ha,i._state=Je.UNINITIALIZED,i._openJobQueue=[],i._window=typeof window<"u"?window:void 0,i._indexedDb=i._window?i._window.indexedDB||i._window.mozIndexedDB||i._window.webkitIndexedDB||i._window.msIndexedDB:void 0,i}return g(t,n),Object.defineProperty(t.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),t.prototype.isTransactionInactiveError=function(e){return e instanceof Error&&e.message.includes("The transaction is inactive")},t.prototype._putToObjectStore=function(e,r){return f(this,void 0,void 0,(function(){return p(this,(function(i){return[2,new Promise((function(s,a){var o=e.put(r);o.addEventListener("success",(function(u){s(u.target.result)})),o.addEventListener("error",(function(u){a(u.target.error)}))}))]}))}))},t.prototype._deleteFromObjectStore=function(e,r){return f(this,void 0,void 0,(function(){return p(this,(function(i){return[2,new Promise((function(s,a){var o=e.delete(r);o.addEventListener("success",(function(){return s(r)})),o.addEventListener("error",(function(u){return a(u.target.error)}))}))]}))}))},t.prototype._openDatabase=function(e){var r=this;return new Promise((function(i,s){if(r._indexedDb){r._state=Je.OPENING;var a=r._indexedDb.open(e);a.addEventListener("upgradeneeded",(function(o){o.target.result.createObjectStore(Ha,{keyPath:"key"})})),a.addEventListener("success",(function(o){r._state=Je.OPEN,r._database=o.target.result,r._openJobQueue.forEach((function(u){return u()})),r._openJobQueue=[],r._database.onclose=function(){r._database=void 0,r._state=Je.OPENING,setTimeout((function(){r._openDatabase(e)}),5)},i(r._database)})),a.addEventListener("error",(function(o){r._state=Je.UNINITIALIZED,s(o.target.error)}))}else s($.storeNotAvailable)}))},t.prototype._getObjectStore=function(e){return f(this,void 0,void 0,(function(){var r,i=this;return p(this,(function(s){switch(s.label){case 0:return this._database?((r=this._database.transaction(this._storeName,e)).addEventListener("abort",(function(a){throw a.target.error})),[2,r.objectStore(this._storeName)]):[3,1];case 1:switch(this._state){case Je.UNINITIALIZED:case Je.OPEN:return[3,2];case Je.OPENING:case Je.CLOSED:return[3,3]}return[3,4];case 2:throw $.storeNotInitialized;case 3:return[2,new Promise((function(a){i._openJobQueue.push((function(){return a(i._getObjectStore(e))}))}))];case 4:return[4,this._getObjectStore(e)];case 5:return[2,s.sent()]}}))}))},t.prototype._getAllRawKeys=function(){return f(this,void 0,void 0,(function(){var e=this;return p(this,(function(r){switch(r.label){case 0:return[4,new Promise((function(i,s){return f(e,void 0,void 0,(function(){var a,o;return p(this,(function(u){switch(u.label){case 0:return[4,this._getObjectStore("readonly")];case 1:return a=u.sent(),(o=a.getAllKeys()).addEventListener("success",(function(c){i(c.target.result)})),o.addEventListener("error",(function(c){return s(c.target.error)})),[2]}}))}))}))];case 1:return[2,r.sent()]}}))}))},t.prototype._getRaw=function(e){return f(this,void 0,void 0,(function(){var r=this;return p(this,(function(i){switch(i.label){case 0:return[4,new Promise((function(s,a){return f(r,void 0,void 0,(function(){var o,u;return p(this,(function(c){switch(c.label){case 0:return[4,this._getObjectStore("readonly")];case 1:return o=c.sent(),(u=o.get(e)).addEventListener("success",(function(l){var d;s((d=l==null?void 0:l.target)===null||d===void 0?void 0:d.result)})),u.addEventListener("error",(function(l){return a(l.target.error)})),[2]}}))}))}))];case 1:return[2,i.sent()]}}))}))},t.prototype._setRaw=function(e){return f(this,void 0,void 0,(function(){var r,i,s,a,o,u,c,l,d,_=this;return p(this,(function(h){switch(h.label){case 0:return h.trys.push([0,3,,15]),[4,this._getObjectStore("readwrite")];case 1:return r=h.sent(),[4,Promise.all(e.map((function(v){return _._putToObjectStore(r,v)})))];case 2:return h.sent(),[3,15];case 3:return i=h.sent(),this.isTransactionInactiveError(i)?[4,this._getObjectStore("readwrite")]:[3,13];case 4:s=h.sent(),h.label=5;
2case 5:h.trys.push([5,10,11,12]),a=z(e),o=a.next(),h.label=6;case 6:return o.done?[3,9]:(u=o.value,[4,this._putToObjectStore(s,u)]);case 7:h.sent(),h.label=8;case 8:return o=a.next(),[3,6];case 9:return[3,12];case 10:return c=h.sent(),l={error:c},[3,12];case 11:try{o&&!o.done&&(d=a.return)&&d.call(a)}finally{if(l)throw l.error}return[7];case 12:return[3,14];case 13:throw i;case 14:return[3,15];case 15:return[2]}}))}))},t.prototype._removeRaw=function(e){return f(this,void 0,void 0,(function(){var r,i,s,a,o,u,c,l,d,_=this;return p(this,(function(h){switch(h.label){case 0:return h.trys.push([0,3,,15]),[4,this._getObjectStore("readwrite")];case 1:return r=h.sent(),[4,Promise.all(e.map((function(v){return _._deleteFromObjectStore(r,v)})))];case 2:return h.sent(),[3,15];case 3:return i=h.sent(),this.isTransactionInactiveError(i)?[4,this._getObjectStore("readwrite")]:[3,13];case 4:s=h.sent(),h.label=5;case 5:h.trys.push([5,10,11,12]),a=z(e),o=a.next(),h.label=6;case 6:return o.done?[3,9]:(u=o.value,[4,this._deleteFromObjectStore(s,u)]);case 7:h.sent(),h.label=8;case 8:return o=a.next(),[3,6];case 9:return[3,12];case 10:return c=h.sent(),l={error:c},[3,12];case 11:try{o&&!o.done&&(d=a.return)&&d.call(a)}finally{if(l)throw l.error}return[7];case 12:return[3,14];case 13:throw i;case 14:return[3,15];case 15:return[2]}}
2))}))},t.prototype._triggerDatabaseClose=function(){this._database&&this._database.onclose&&this._database.onclose(new Event("dummy"))},t.prototype.checkAvailability=function(){return f(this,void 0,void 0,(function(){var e,r=this;return p(this,(function(i){switch(i.label){case 0:if(!((e=typeof window<"u"?window:null)!=null&&e.indexedDB||e!=null&&e.mozIndexedDB||e!=null&&e.webkitIndexedDB||e!=null&&e.msIndexedDB))return[3,6];if(this._indexedDb=e.indexedDB||e.mozIndexedDB||e.webkitIndexedDB||e.msIndexedDB,!this._window||!Qr())return[3,4];if(!(Qr()&&navigator.userAgent&&navigator.userAgent.includes("Edge/")))return[3,1];if(!this._window.indexedDB&&(e.PointerEvent||e.MSPointerEvent))throw $.storeNotAvailableInPrivateBrowsing;return[3,3];case 1:return[4,new Promise((function(s,a){if(r._indexedDb)try{var o=r._indexedDb.open("_testMozilla");o.onerror=function(){return a($.storeNotAvailableInPrivateBrowsing)},o.onsuccess=function(u){if(u.target.result.close(),r._indexedDb){var c=r._indexedDb.deleteDatabase("_testMozilla");c.onerror=function(){return s()},c.onsuccess=function(){return s()}}else a($.storeNotAvailable)}}catch(u){a($.storeNotAvailableInPrivateBrowsing)}else a($.storeNotAvailable)}))];case 2:i.sent(),i.label=3;case 3:return[3,5];case 4:throw $.storeNotAvailable;case 5:return[3,7];case 6:throw $.storeNotAvailable;case 7:return[2]}}
2))}))},t.prototype.init=function(e){return f(this,void 0,void 0,(function(){return p(this,(function(r){switch(r.label){case 0:return this.dbname=e,[4,this.checkAvailability()];case 1:return r.sent(),[4,this._openDatabase(e)];case 2:return r.sent(),[4,this._resetIfEncryptionChanged()];case 3:return r.sent(),[2]}}))}))},t.prototype.clear=function(){return f(this,void 0,void 0,(function(){var e=this;return p(this,(function(r){switch(r.label){case 0:return[4,this._withUsageLock((function(){return f(e,void 0,void 0,(function(){var i=this;return p(this,(function(s){switch(s.label){case 0:return[4,n.prototype.clear.call(this)];case 1:return s.sent(),[4,new Promise((function(a,o){return f(i,void 0,void 0,(function(){var u,c;return p(this,(function(l){switch(l.label){case 0:return[4,this._getObjectStore("readwrite")];case 1:return u=l.sent(),(c=u.clear()).addEventListener("success",(function(){return a(void 0)})),c.addEventListener("error",(function(d){return o(d.target.error)})),[2]}}))}))}))];case 2:return s.sent(),[2]}}))}))}))];case 1:return r.sent(),[2]}}))}))},t})(ri),uf=(function(n){function t(e){var r=this,i=e.AsyncStorage,s=e.itemSizeLimit,a=s===void 0?2097152:s,o=Cu(e,["AsyncStorage","itemSizeLimit"]);return(r=n.call(this,E(E({},o),{itemSizeLimit:a}))||this)._asyncStorage=i,r}return g(t,n),t.prototype._isBelonging=function(e){return e.startsWith("".concat(this.dbname,"/"))},t.prototype._getActualKey=function(e){return"".concat(this.dbname,"/").concat(e)},t.prototype._getAllRawKeys=function(){return f(this,void 0,void 0,(function(){var e,r=this;return p(this,(function(i){switch(i.label){case 0:return[4,this._asyncStorage.getAllKeys()];case 1:return e=i.sent(),[2,e.filter((function(s){return r._isBelonging(s)})).map((function(s){return s.substring("".concat(r.dbname,"/").length)}))]}}))}))},t.prototype._getRaw=function(e){return f(this,void 0,void 0,(function(){var r;return p(this,(function(i){switch(i.label){case 0:return[4,this._asyncStorage.getItem(this._getActualKey(e))];case 1:return[2,(r=i.sent())?JSON.parse(r):null]}}))}))},t.prototype._setRaw=function(e){return f(this,void 0,void 0,(function(){var r,i,s,a,o,u,c;return p(this,(function(l){switch(l.label){case 0:r=[];try{for(i=z(e),s=i.next();!s.done;s=i.next())a=s.value,o=a.key,a.data.length<=this.adjustedItemSizeLimit&&r.push([this._getActualKey(o),JSON.stringify(a)])}catch(d){u={error:d}}finally{try{s&&!s.done&&(c=i.return)&&c.call(i)}finally{if(u)throw u.error}}return[4,this._asyncStorage.multiSet(r)];case 1:return l.sent(),[2]}}))}))},t.prototype._removeRaw=function(e){return f(this,void 0,void 0,(function(){var r=this;return p(this,(function(i){switch(i.label){case 0:return[4,this._asyncStorage.multiRemove(e.map((function(s){return r._getActualKey(s)})))];case 1:return i.sent(),[2]}}))}))},t.prototype.checkAvailability=function(){return f(this,void 0,void 0,(function(){return p(this,(function(e){if(!this._asyncStorage)throw $.storeNotAvailable;return[2]}))}))},t.prototype.init=function(e){return f(this,void 0,void 0,(function(){return p(this,(function(r){switch(r.label){case 0:return this.dbname=e,[4,this._resetIfEncryptionChanged()];case 1:return r.sent(),[2]}}))}))},t.prototype.clear=function(){return f(this,void 0,void 0,(function(){var e=this;return p(this,(function(r){switch(r.label){case 0:return[4,this._withUsageLock((function(){return f(e,void 0,void 0,(function(){var i;return p(this,(function(s){switch(s.label){case 0:return[4,n.prototype.clear.call(this)];case 1:return s.sent(),[4,this._getAllRawKeys()];case 2:return i=s.sent(),[4,this._removeRaw(i)];case 3:return s.sent(),[2]}}))}))}))];case 1:return r.sent(),[2]}}))}))},t})(ri),cf=(function(n){function t(e){var r,i,s=this;return(s=n.call(this,E(E({},e),{itemSizeLimit:(r=e.itemSizeLimit)!==null&&r!==void 0?r:6291456}))||this)._mmkv=(i=e.MMKV,{getString:function(a){return i.getString(a)},set:function(a,o){return i.set(a,o)},delete:function(a){return i.remove?i.remove(a):i.delete(a)},getAllKeys:function(){return i.getAllKeys()},clearAll:function(){var a;return(a=i.clearAll)===null||a===void 0?void 0:a.call(i)},trim:function(){if(i.trim)return i.trim()}}),s}return g(t,n),t.prototype._isBelonging=function(e){return e.startsWith("".concat(this.dbname,"/"))},t.prototype._getActualKey=function(e){return"".concat(this.dbname,"/").concat(e)},t.prototype._getAllRawKeys=function(){return f(this,void 0,void 0,(function(){var e,r=this;return p(this,(function(i){switch(i.label){case 0:return[4,this._mmkv.getAllKeys()];case 1:return e=i.sent(),[2,e.filter((function(s){return r._isBelonging(s)})).map((function(s){return s.substring("".concat(r.dbname,"/").length)}))]}}))}))},t.prototype._getRaw=function(e){return f(this,void 0,void 0,(function(){var r;return p(this,(function(i){switch(i.label){case 0:return[4,this._mmkv.getString(this._getActualKey(e))];case 1:return[2,(r=i.sent())?JSON.parse(r):null]}}))}))},t.prototype._setRaw=function(e){return f(this,void 0,void 0,(function(){var r,i,s,a,o,u;return p(this,(function(c){try{for(r=z(e),i=r.next();!i.done;i=r.next())s=i.value,a=s.key,s.data.length<=this.adjustedItemSizeLimit&&this._mmkv.set(this._getActualKey(a),JSON.stringify(s))}catch(l){o={error:l}}finally{try{i&&!i.done&&(u=r.return)&&u.call(r)}finally{if(o)throw o.error}}return[2]}))}))},t.prototype._removeRaw=function(e){return f(this,void 0,void 0,(function(){var r,i,s,a,o;return p(this,(function(u){try{for(r=z(e),i=r.next();!i.done;i=r.next())s=i.value,this._mmkv.delete(this._getActualKey(s))}catch(c){a={error:c}}
2finally{try{i&&!i.done&&(o=r.return)&&o.call(r)}finally{if(a)throw a.error}}return[2]}))}))},t.prototype.checkAvailability=function(){return f(this,void 0,void 0,(function(){return p(this,(function(e){if(!this._mmkv)throw $.storeNotAvailable;return[2]}))}))},t.prototype.init=function(e){return f(this,void 0,void 0,(function(){return p(this,(function(r){switch(r.label){case 0:return this.dbname=e,[4,this._resetIfEncryptionChanged()];case 1:return r.sent(),[2]}}))}))},t.prototype.clear=function(){return f(this,void 0,void 0,(function(){var e=this;return p(this,(function(r){switch(r.label){case 0:return[4,this._withUsageLock((function(){return f(e,void 0,void 0,(function(){var i;return p(this,(function(s){switch(s.label){case 0:return[4,n.prototype.clear.call(this)];case 1:return s.sent(),[4,this._getAllRawKeys()];case 2:return i=s.sent(),[4,this._removeRaw(i)];case 3:return s.sent(),this.trim(),[2]}}))}))}))];case 1:return r.sent(),[2]}}))}))},t.prototype.resetStorage=function(){var e;(e=this._mmkv)===null||e===void 0||e.clearAll()},t.prototype.trim=function(){var e;(e=this._mmkv)===null||e===void 0||e.trim()},t})(ri),ht;(function(n){n.INIT="INIT",n.OPENING="OPENING",n.OPENED="OPENED",n.CLOSED="CLOSED"})(ht||(ht={}));var Tt,lf=(function(){function n(t){var e=t.name,r=t.version,i=t.store,s=t.config;this.name=e,this._version=r,this._state=ht.INIT,this._config=s||new ir({dbname:e}),this._store=i,this._event={success:kn,error:kn,storeReplaced:kn,upgrade:za},this._collections=new Map,this._globalMutex=new ni("".concat(this.name,".lock")),this._config.disableLogger&&Bt.off(),new Oe({dbname:e,limit:this._config.cacheLimit})}return Object.defineProperty(n.prototype,"version",{get:function(){return this._version},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"store",{get:function(){return this._store},enumerable:!1,configurable:!0}),n.prototype._initializeCollection=function(t,e){var r;return f(this,void 0,void 0,(function(){var i,s,a;return p(this,(function(o){switch(o.label){case 0:return s=this._collections.get(t),e?(i=new Ui({dbname:this.name,collectionName:t,keyName:e.keyName,indexes:(r=e.index)!==null&&r!==void 0?r:[[e.keyName]],store:this._store}),[3,3]):[3,1];case 1:return s&&s.state===Wt.READY?[3,3]:[4,Ui.metadataOf(this.name,t,this._store)];case 2:(a=o.sent())&&(i=new Ui({dbname:this.name,collectionName:t,keyName:a.keyName,indexes:a.indexes,store:this._store})),o.label=3;case 3:return i?(this._collections.set(t,i),[4,i.init()]):[3,5];case 4:o.sent(),o.label=5;case 5:return[2]}}
2))}))},n.prototype.estimateUsage=function(){return f(this,void 0,void 0,(function(){return p(this,(function(t){switch(t.label){case 0:return[4,(e=this._store,f(void 0,void 0,void 0,(function(){return p(this,(function(r){switch(r.label){case 0:return[4,e.usage()];case 1:return[2,r.sent()]}}))})))];case 1:return[2,t.sent()]}var e}))}))},n.prototype.commitSchema=function(t){return f(this,void 0,void 0,(function(){var e=this;return p(this,(function(r){switch(r.label){case 0:return this._state!==ht.OPENING?[3,2]:[4,Promise.all(t.map((function(i){return f(e,void 0,void 0,(function(){return p(this,(function(s){switch(s.label){case 0:return[4,this._initializeCollection(i.collectionName,i)];case 1:return s.sent(),[2]}}))}))})))];case 1:return r.sent(),[3,3];case 2:throw $.databaseSchemaNotOnUpgrade;case 3:return[2]}}))}))},n.prototype.open=function(){var t;return f(this,void 0,void 0,(function(){var e,r,i,s,a,o,u,c,l,d,_=this;return p(this,(function(h){switch(h.label){case 0:return[4,this._globalMutex.lock()];case 1:if(h.sent(),this._state===ht.OPENED)return[3,20];this._state=ht.OPENING,h.label=2;case 2:return h.trys.push([2,13,,20]),[4,this._store.init(this.name)];case 3:return h.sent(),v=this.name,e="".concat(gs(v),".metadata"),r={version:0,collectionNames:[]},[4,this._store.get(e)];case 4:i=(t=h.sent())!==null&&t!==void 0?t:r,h.label=5;case 5:h.trys.push([5,10,11,12]),s=z(i.collectionNames),a=s.next(),h.label=6;case 6:return a.done?[3,9]:(o=a.value,[4,this._initializeCollection(o)]);case 7:h.sent(),h.label=8;case 8:return a=s.next(),[3,6];case 9:return[3,12];case 10:return u=h.sent(),l={error:u},[3,12];case 11:try{a&&!a.done&&(d=s.return)&&d.call(s)}finally{if(l)throw l.error}return[7];case 12:return[2,new Promise((function(m,y){var b=function(I){i.version<_._version?_._event.upgrade(i.version,(function(A){return f(_,void 0,void 0,(function(){var D;return p(this,(function(N){switch(N.label){case 0:if(A)return[3,5];i.version++,i.collectionNames=Array.from(this._collections.keys()),N.label=1;case 1:return N.trys.push([1,3,,4]),[4,this._store.set({key:e,value:i})];case 2:return N.sent(),I({continued:!0}),[3,4];case 3:return D=N.sent(),I({continued:!1,err:D}),[3,4];case 4:return[3,6];case 5:I({continued:!1,err:A}),N.label=6;case 6:return[2]}}
2))}))})):I({continued:!1})},w=function(I){var A=I.continued,D=A!==void 0&&A,N=I.err,F=N===void 0?null:N;D?setTimeout((function(){return b(w)}),10):F?(Bt.error(F.message),_._globalMutex.unlock(),_._event.error(F),y(F)):Promise.all(i.collectionNames.map((function(q){return _._initializeCollection(q)}))).then((function(){_._state=ht.OPENED,_._globalMutex.unlock(),_._event.success(),m()})).catch((function(q){Bt.error(q.message),_._globalMutex.unlock(),_._event.error(q),y(q)}))};b(w)}))];case 13:switch(c=h.sent(),c.code){case se.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING:return[3,14];case se.STORE_NOT_AVAILABLE:return[3,16]}return[3,18];case 14:return Bt.warning("Access to the local storage is not allowed. Switched to MemoryStore automatically."),this._store=new Vt({}),this._globalMutex.unlock(),this._event.error(c),this._event.storeReplaced(this._store),[4,this.open()];case 15:return h.sent(),[3,19];case 16:return Bt.warning("IndexedDB is not available in this environment. Switched to MemoryStore automatically. Consider using other store to save data persistently (e.g. AsyncStorage)."),this._store=new Vt({}),this._globalMutex.unlock(),this._event.error(c),this._event.storeReplaced(this._store),[4,this.open()];case 17:return h.sent(),[3,19];case 18:throw Bt.error(c.message),this._globalMutex.unlock(),this._event.error(c),c;case 19:return[3,20];case 20:return[2]}var v}))}))},n.prototype.close=function(){this._collections.forEach((function(t){return t.close()})),this._state=ht.CLOSED},n.prototype.clear=function(){return f(this,void 0,void 0,(function(){return p(this,(function(t){switch(t.label){case 0:return[4,Promise.all(Array.from(this._collections.values()).map((function(e){return e.clear()})))];case 1:return t.sent(),[2]}}))}))},n.prototype.reset=function(){return f(this,void 0,void 0,(function(){var t;return p(this,(function(e){switch(e.label){case 0:return(t=Oe.get(this.name))&&t.clearForDatabase(this.name),[4,this._store.clear()];case 1:return e.sent(),[2]}}))}))},n.prototype.on=function(t,e){this._event[t]=e},n.prototype.off=function(t){typeof this._event[t]=="function"&&(t==="upgrade"?this._event[t]=za:this._event[t]=kn)},n.prototype.collection=function(t){var e=this._collections.get(t);if(e)return e;throw $.collectionNotReady},n.prototype.trim=function(){var t;(t=this._store)===null||t===void 0||t.trim()},n})();(function(n){n[n.VERBOSE=0]="VERBOSE",n[n.DEBUG=1]="DEBUG",n[n.INFO=2]="INFO",n[n.WARN=3]="WARN",n[n.ERROR=4]="ERROR",n[n.NONE=5]="NONE"})(Tt||(Tt={}));var ye,gu=(function(){function n(){this.level=Tt.WARN}return n.prototype.verbose=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.level<=Tt.VERBOSE&&console.log.apply(console,V(["[verbose]"],K(t),!1))},n.prototype.debug=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.level<=Tt.DEBUG&&console.log.apply(console,V(["[debug]"],K(t),!1))},n.prototype.info=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.level<=Tt.INFO&&console.log.apply(console,V(["[info]"],K(t),!1))},n.prototype.warn=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.level<=Tt.WARN&&console.warn.apply(console,V(["[warn]"],K(t),!1))},n.prototype.error=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.level<=Tt.ERROR&&console.error.apply(console,V(["[error]"],K(t),!1))},n})(),df=function(n){return Cs(n.startHour)&&As(n.startMin)&&Cs(n.endHour)&&As(n.endMin)&&(n.startHour<n.endHour||n.startHour===n.endHour&&n.startMin<n.endMin)},ii=(function(){function n(t){this._dndSchedules=t!=null?t:{}}return n.prototype.setDayDndSchedule=function(t,e){return this._dndSchedules[t]=e,this._dndSchedules},n.prototype.getDayDndSchedule=function(t){return this._dndSchedules[t]},n.prototype.getDndSchedules=function(){return this._dndSchedules},n.prototype.setDndSchedules=function(t){return this._dndSchedules=t,this._dndSchedules},n.prototype.setWeekdays=function(t){return this._dndSchedules[bt.MONDAY]=V([],K(t),!1),this._dndSchedules[bt.TUESDAY]=V([],K(t),!1),this._dndSchedules[bt.WEDNESDAY]=V([],K(t),!1),this._dndSchedules[bt.THURSDAY]=V([],K(t),!1),this._dndSchedules[bt.FRIDAY]=V([],K(t),!1),this._dndSchedules},n.prototype.setWeekends=function(t){return this._dndSchedules[bt.SATURDAY]=V([],K(t),!1),this._dndSchedules[bt.SUNDAY]=V([],K(t),!1),this._dndSchedules},n.prototype.setFullDay=function(t){var e,r;try{for(var i=z(t),s=i.next();!s.done;s=i.next()){var a=s.value;this._dndSchedules[a]=[{startHour:0,startMin:0,endHour:23,endMin:59}]}}catch(o){e={error:o}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}return this._dndSchedules},n.prototype.isValid=function(){var t,e,r,i,s=Object.values(this._dndSchedules);if(s.length===0)return!1;try{for(var a=z(s),o=a.next();!o.done;o=a.next()){var u=o.value;if(!Array.isArray(u)||u.length===0)return!1;try{for(var c=(r=void 0,z(u)),l=c.next();!l.done;l=c.next()){var d=l.value;if(!df(d))return!1}}catch(_){r={error:_}}finally{try{l&&!l.done&&(i=c.return)&&i.call(c)}finally{if(r)throw r.error}}}}catch(_){t={error:_}}finally{try{o&&!o.done&&(e=a.return)&&e.call(a)}finally{if(t)throw t.error}}return!0},n.payloadify=function(t){return Object.entries(t.getDndSchedules()).map((function(e){var r=K(e,2);return{day_of_week:r[0],time_windows:r[1].map((function(i){return{start_hour:i.startHour,start_min:i.startMin,end_hour:i.endHour,end_min:i.endMin}}))}}))},n.buildDndScheduleFromPayload=function(t){var e,r,i={};try{for(var s=z(t),a=s.next();!a.done;a=s.next()){var o=a.value;i[o.day_of_week]=o.time_windows.map((function(u){return{startHour:u.start_hour,startMin:u.start_min,endHour:u.end_hour,endMin:u.end_min}}
2))}}catch(u){e={error:u}}finally{try{a&&!a.done&&(r=s.return)&&r.call(s)}finally{if(e)throw e.error}}return new n(i)},n})(),vn=(function(){function n(t){var e,r,i,s;this.messageTypeFilter=(e=t==null?void 0:t.messageTypeFilter)!==null&&e!==void 0?e:Ve.ALL,this.customTypesFilter=(r=t==null?void 0:t.customTypesFilter)!==null&&r!==void 0?r:null,this.senderUserIdsFilter=(i=t==null?void 0:t.senderUserIdsFilter)!==null&&i!==void 0?i:null,this.replyType=(s=t==null?void 0:t.replyType)!==null&&s!==void 0?s:ze.NONE}return n.prototype.clone=function(){var t=new n,e=JSON.parse(JSON.stringify(this));return Object.keys(e).forEach((function(r){t[r]=e[r]})),t},n.prototype.match=function(t){switch(this.messageTypeFilter){case Ve.USER:if(t.messageType!==ee.USER)return!1;break;case Ve.FILE:if(t.messageType!==ee.FILE)return!1;break;case Ve.ADMIN:if(t.messageType!==ee.ADMIN)return!1}if(this.customTypesFilter&&this.customTypesFilter.length>0&&!this.customTypesFilter.includes("*")&&!this.customTypesFilter.includes(t.customType)||this.senderUserIdsFilter&&this.senderUserIdsFilter.length>0&&(!(t instanceof pt)||!this.senderUserIdsFilter.includes(t.sender.userId)))return!1;if(t instanceof je)switch(this.replyType){case ze.NONE:if(t.parentMessageId>0)return!1;break;case ze.ONLY_REPLY_TO_CHANNEL:if(t instanceof pt&&t.parentMessageId>0&&!t.replyToChannel)return!1}return!0},n})();(function(n){n.CHANNEL_LATEST="channel_latest",n.NEWEST_CHILD_MESSAGE="newest_child_message"})(ye||(ye={}));var nt=function(n){switch(n){case ye.CHANNEL_LATEST:return["channelUrl","-createdAt","-messageId"];case ye.NEWEST_CHILD_MESSAGE:return["channelUrl","-parentMessageId","-createdAt","-messageId"]}},hf=function(){return["channelUrl","-createdAt","-notificationId"]},D_=E(E({},hu),{scheduledAt:void 0}),R_=function(n){return fu(n)&&S("number",n.scheduledAt,!0)},L_=E(E({},ei),{scheduledAt:0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),U_=function(n){return ti(n)&&S("number",n.scheduledAt)&&(rt(n.file)||S("string",n.fileUrl))&&S("string",n.fileName,!0)&&S("string",n.mimeType,!0)&&S("number",n.fileSize,!0)&&(n.thumbnailSizes===null||n.thumbnailSizes===void 0||n.thumbnailSizes.every((function(t){return S("object",t)&&t.maxWidth>0&&t.maxHeight>0})))},yu="UnsentMessage",ff="reqId",Er={},sr=(function(n){function t(e){var r=n.call(this,e)||this;return r._mutex=new ni("unsendmessagecache.lock"),Er[e]=r,r}return g(t,n),Object.defineProperty(t.prototype,"_cacheContext",{get:function(){return C.of(this._iid).cacheContext},enumerable:!1,configurable:!0}),t.of=function(e,r){return r===void 0&&(r=!1),Er[e]&&!r||(Er[e]=new t(e)),Er[e]},Object.defineProperty(t.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb,r=e==null?void 0:e.collection(yu);if(!r)throw T.databaseError;return r},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),t.prototype._serialize=function(e){if(e.messageId>0)throw T.invalidParameters;var r,i=E({},e.serialize());return e instanceof ke?(e.messageParams&&(i.messageParams=Ea(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(i.scheduledInfo.scheduledMessageParams=(r=e.scheduledInfo.scheduledMessageParams,E(E({},Ea(r)),{scheduledAt:r.scheduledAt})))):e instanceof he?(e.messageParams&&(i.messageParams=Ia(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(i.scheduledInfo.scheduledMessageParams=(function(s){return E(E({},Ia(s)),{scheduledAt:s.scheduledAt})})(e.scheduledInfo.scheduledMessageParams))):e instanceof Ge&&e.messageParams&&(i.messageParams=(function(s){return M({fileInfoList:s.fileInfoList.map((function(a){return{file:a.file,fileUrl:Xn.getPlainUrl(a),fileName:a.fileName,fileSize:a.fileSize,mimeType:a.mimeType,thumbnailSizes:a.thumbnailSizes,_thumbnails:a._thumbnails,_uploadedMetaData:a._uploadedMetaData}})),isReplyToChannel:s.isReplyToChannel,pushNotificationDeliveryOption:s.pushNotificationDeliveryOption})})(e.messageParams)),i},t.prototype._deserialize=function(e){return e=E(E({},e),{messageId:parseInt(e.messageId)}),Ne.of(this._iid).buildMessageFromSerializedData(e)},t.prototype._deserializeWithMessageCreateParams=function(e){var r,i,s;return f(this,void 0,void 0,(function(){var a,o,u,c,l,d,_=this;return p(this,(function(h){switch(h.label){case 0:return a=Ne.of(this._iid),o=this._deserialize(e),e.messageParams?o instanceof ke?(c=e.messageParams,o.messageParams=a.buildUserMessageCreateParamsFromSerializedData(c,o),[3,6]):[3,1]:[3,6];case 1:return o instanceof he?(c=e.messageParams).fileKey&&typeof c.fileKey=="string"&&ki((r=c.fileType)!==null&&r!==void 0?r:"")?(u=c,[4,this.collection.getBlob(c.fileKey)]):[3,3]:[3,4];case 2:u.file=(i=h.sent())!==null&&i!==void 0?i:void 0,h.label=3;case 3:return o.messageParams=a.buildFileMessageCreateParamsFromSerializedData(c,o),[3,6];case 4:return o instanceof Ge&&(c=e.messageParams)&&c.fileInfoList?(o.messageParams=a.buildMultipleFilesMessageCreateParamsFromSerializedData(c,o),[4,Promise.all(o.messageParams.fileInfoList.map((function(v){return f(_,void 0,void 0,(function(){var m,y,b,w,I;return p(this,(function(A){switch(A.label){case 0:return typeof((y=v._uploadedMetaData)===null||y===void 0?void 0:y.fileKey)=="string"&&ki((w=(b=v._uploadedMetaData)===null||b===void 0?void 0:b.fileType)!==null&&w!==void 0?w:"")?(m=v,[4,this.collection.getBlob(v._uploadedMetaData.fileKey)]):[3,2];case 1:m.file=(I=A.sent())!==null&&I!==void 0?I:void 0,A.label=2;case 2:return[2]}}
2))}))})))]):[3,6];case 5:h.sent(),h.label=6;case 6:return o.scheduledInfo&&e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams?o instanceof ke?(l=e.scheduledInfo.scheduledMessageParams,o.scheduledInfo.scheduledMessageParams=a.buildScheduledUserMessageCreateParamsFromSerializedData(l,o),[3,10]):[3,7]:[3,10];case 7:return o instanceof he?(l=e.scheduledInfo.scheduledMessageParams).fileKey&&typeof l.fileKey=="string"&&typeof l.fileType=="string"&&ki(l.fileType)?(d=l,[4,this.collection.getBlob(l.fileKey)]):[3,9]:[3,10];case 8:d.file=(s=h.sent())!==null&&s!==void 0?s:void 0,h.label=9;case 9:o.scheduledInfo.scheduledMessageParams=a.buildScheduledFileMessageCreateParamsFromSerializedData(l,o),h.label=10;case 10:return[2,o]}}))}))},t.prototype._getFileInfoBlobKey=function(e,r){return"".concat(e,".").concat(r)},t.prototype.get=function(e){return f(this,void 0,void 0,(function(){var r;return p(this,(function(i){switch(i.label){case 0:return this.localCacheEnabled?[4,this.collection.getByKey("".concat(e))]:[3,2];case 1:if(r=i.sent())return[2,this._deserializeWithMessageCreateParams(r)];i.label=2;case 2:return[2,void 0]}}))}))},t.prototype.fetch=function(e){var r=e.channelUrl,i=e.filter,s=i===void 0?new vn:i,a=e.order,o=a===void 0?ye.CHANNEL_LATEST:a,u=e.sendingStatus,c=e.backward,l=c!==void 0&&c,d=e.parentMessageId;return f(this,void 0,void 0,(function(){var _,h,v,m,y=this;return p(this,(function(b){switch(b.label){case 0:return this.localCacheEnabled?(_=nt(o),h={"/where":function(w){return!!(o!==ye.NEWEST_CHILD_MESSAGE||d&&w.parentMessageId!==0&&w.parentMessageId===d)&&s.match(y._deserialize(w))}},r&&(h.channelUrl=r),u&&(h.sendingStatus=u),v={where:h,index:_,backward:l},[4,this.collection.query(v)]):[3,3];case 1:return[4,b.sent().fetch({})];case 2:return m=b.sent(),[2,Promise.all(m.map((function(w){return f(y,void 0,void 0,(function(){return p(this,(function(I){switch(I.label){case 0:return[4,this._deserializeWithMessageCreateParams(w)];case 1:return[2,I.sent()]}}))}))})))];case 3:return[2,[]]}}))}))},t.prototype.getAllChildMessages=function(e,r){return r===void 0&&(r=new vn),f(this,void 0,void 0,(function(){return p(this,(function(i){switch(i.label){case 0:return[4,this.fetch({filter:r,order:ye.NEWEST_CHILD_MESSAGE,channelUrl:e.channelUrl,backward:!1,parentMessageId:e.messageId})];case 1:return[2,i.sent()]}}))}))},t.prototype.upsert=function(e){return f(this,void 0,void 0,(function(){var r=this;return p(this,(function(i){switch(i.label){case 0:return this.localCacheEnabled?[4,Promise.all(e.map((function(s){return f(r,void 0,void 0,(function(){var a;return p(this,(function(o){switch(o.label){case 0:return s instanceof he||s instanceof Ge?[4,this._mutex.lock()]:[3,4];case 1:return o.sent(),[4,this.saveBlob(s)];case 2:return o.sent(),[4,this._mutex.unlock()];case 3:o.sent(),o.label=4;case 4:return a=this._serialize(s),[4,this.collection.upsertOne(a)];case 5:return o.sent(),[2]}}))}))})))]:[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}}
2))}))},t.prototype.upsertChildMessages=function(e){return f(this,void 0,void 0,(function(){var r=this;return p(this,(function(i){switch(i.label){case 0:return this.localCacheEnabled?[4,Promise.all(e.map((function(s){return f(r,void 0,void 0,(function(){var a;return p(this,(function(o){switch(o.label){case 0:return a=[],s.threadInfo&&s.threadInfo.replyCount>0?[4,this.getAllChildMessages(s)]:[3,2];case 1:a=o.sent(),o.label=2;case 2:return a.length>0?(a.forEach((function(u){return u.applyParentMessage(s)})),[4,this.upsert(a)]):[3,4];case 3:o.sent(),o.label=4;case 4:return[2]}}))}))})))]:[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}}))}))},t.prototype.remove=function(e){return f(this,void 0,void 0,(function(){var r,i,s,a,o,u;return p(this,(function(c){switch(c.label){case 0:if(!this.localCacheEnabled)return[3,8];c.label=1;case 1:c.trys.push([1,6,7,8]),r=z(e),i=r.next(),c.label=2;case 2:return i.done?[3,5]:(s=i.value,[4,this.collection.remove(s)]);case 3:c.sent(),c.label=4;case 4:return i=r.next(),[3,2];case 5:return[3,8];case 6:return a=c.sent(),o={error:a},[3,8];case 7:try{i&&!i.done&&(u=r.return)&&u.call(r)}finally{if(o)throw o.error}return[7];case 8:return[2]}}
2))}))},t.prototype.removeMessagesOfChannel=function(e){return f(this,void 0,void 0,(function(){return p(this,(function(r){switch(r.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e}})]:[3,2];case 1:r.sent(),r.label=2;case 2:return[2]}}))}))},t.prototype.clear=function(){return f(this,void 0,void 0,(function(){return p(this,(function(e){switch(e.label){case 0:return this.localCacheEnabled?[4,this.collection.clear()]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},t.prototype.saveBlob=function(e){return f(this,void 0,void 0,(function(){var r,i,s,a=this;return p(this,(function(o){switch(o.label){case 0:return e instanceof he?e.messageParams&&(s=e.messageParams).file&&kr(s.file)?[4,this.collection.saveBlob(s.file,e.reqId)]:[3,2]:[3,5];case 1:i=o.sent(),s.fileKey=i,s.fileType=Zt.BLOB,o.label=2;case 2:return e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(r=e.scheduledInfo.scheduledMessageParams).file&&kr(r.file)?[4,this.collection.saveBlob(r.file,e.reqId)]:[3,4];case 3:i=o.sent(),r.fileKey=i,r.fileType=Zt.BLOB,o.label=4;case 4:return[3,7];case 5:return e instanceof Ge&&(s=e.messageParams)&&s.fileInfoList&&Array.isArray(s.fileInfoList)?[4,Promise.all(s.fileInfoList.map((function(u,c){return f(a,void 0,void 0,(function(){var l;return p(this,(function(d){switch(d.label){case 0:return u.file&&kr(u.file)?[4,this.collection.saveBlob(u.file,this._getFileInfoBlobKey(e.reqId,c))]:[3,2];case 1:l=d.sent(),u._uploadedMetaData||(u._uploadedMetaData={}),u._uploadedMetaData.fileKey=l,u._uploadedMetaData.fileType=Zt.BLOB,d.label=2;case 2:return[2]}}
2))}))})))]:[3,7];case 6:o.sent(),o.label=7;case 7:return[2]}}))}))},t})(be),wr={},ys=(function(n){function t(e){var r=n.call(this,e)||this;return wr[e]=r,r}return g(t,n),Object.defineProperty(t.prototype,"_sdkState",{get:function(){return C.of(this._iid).sdkState},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_cacheContext",{get:function(){return C.of(this._iid).cacheContext},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_unsentMessageCache",{get:function(){return sr.of(this._iid)},enumerable:!1,configurable:!0}),t.of=function(e,r){return r===void 0&&(r=!1),wr[e]&&!r||(wr[e]=new t(e)),wr[e]},Object.defineProperty(t.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return R(!!e).throw(T.databaseError),e.collection(ms)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),t.prototype._serialize=function(e){return E(E({},e.serialize()),{messageId:"".concat(e.messageId)})},t.prototype._deserialize=function(e){return e=E(E({},e),{messageId:parseInt(e.messageId)}),Ne.of(this._iid).buildMessageFromSerializedData(e)},t.prototype.get=function(e){return f(this,void 0,void 0,(function(){var r;return p(this,(function(i){switch(i.label){case 0:return this.localCacheEnabled?[4,this.collection.getByKey("".concat(e))]:[3,2];case 1:if(r=i.sent())return[2,this._deserialize(r)];i.label=2;case 2:return[2,void 0]}}))}))},t.prototype.fetch=function(e){var r=e.channelUrl,i=e.token,s=e.limit,a=s===void 0?100:s,o=e.filter,u=o===void 0?new vn:o,c=e.order,l=c===void 0?ye.CHANNEL_LATEST:c,d=e.backward,_=d!==void 0&&d,h=e.parentMessageId,v=e.isPollOnly,m=v!==void 0&&v,y=e.exactMatch,b=y!==void 0&&y,w=e.inclusive,I=w===void 0||w,A=e.isRestoreIndexedDB,D=A!==void 0&&A;return f(this,void 0,void 0,(function(){var N,F,q,x,H=this;return p(this,(function(j){switch(j.label){case 0:return this.localCacheEnabled?(N=nt(l),F={where:{channelUrl:r,"/where":function(P){if(i!=null&&i!=="")switch(l){case ye.CHANNEL_LATEST:if(b&&P.createdAt!==i)return!1;if(_){if(I&&P.createdAt<i||!I&&P.createdAt<=i)return!1}else if(I&&P.createdAt>i||!I&&P.createdAt>=i)return!1;break;case ye.NEWEST_CHILD_MESSAGE:if(!h||P.parentMessageId===0||P.parentMessageId!==h)return!1}return!(m&&!P._poll)&&u.match(H._deserialize(P))}},index:N,backward:_},[4,this.collection.query(F)]):[3,5];case 1:return q=j.sent(),this._cacheContext.localCacheConfig.enableRestoreDB&&D?[4,q.indexer.restoreIndexer()]:[3,3];case 2:j.sent(),j.label=3;case 3:return[4,q.fetch({limit:a!=null?a:void 0})];case 4:return x=j.sent(),[2,Promise.all(x.map((function(P){return f(H,void 0,void 0,(function(){return p(this,(function(ce){return[2,this._deserialize(P)]}))}))})))];case 5:return[2,[]]}}))}))},t.prototype.getAllChildMessages=function(e,r){return r===void 0&&(r=new vn),f(this,void 0,void 0,(function(){return p(this,(function(i){switch(i.label){case 0:return[4,this.fetch({channelUrl:e.channelUrl,token:Date.now(),limit:null,backward:!1,filter:r,order:ye.NEWEST_CHILD_MESSAGE,parentMessageId:e.messageId})];case 1:return[2,i.sent()]}}))}))},t.prototype.upsert=function(e){var r;return f(this,void 0,void 0,(function(){var i,s,a,o,u,c,l,d,_=this;return p(this,(function(h){switch(h.label){case 0:return this.localCacheEnabled?[4,this.saveBlobs(e)]:[3,13];case 1:h.sent(),h.label=2;case 2:h.trys.push([2,7,8,9]),i=z(e),s=i.next(),h.label=3;case 3:return s.done?[3,6]:(a=s.value,!((r=a.threadInfo)===null||r===void 0)&&r._isUpdateRequired?[4,this.get(a.messageId)]:[3,5]);case 4:(o=h.sent())!=null&&o.threadInfo&&a.threadInfo._updateFrom(o.threadInfo),h.label=5;case 5:return s=i.next(),[3,3];case 6:return[3,9];case 7:return u=h.sent(),l={error:u},[3,9];case 8:try{s&&!s.done&&(d=i.return)&&d.call(i)}finally{if(l)throw l.error}return[7];case 9:return c=e.map((function(v){return _._serialize(v)})),[4,this.collection.upsertMany(c)];case 10:return h.sent(),[4,this.upsertChildMessages(e)];case 11:return h.sent(),[4,this._unsentMessageCache.upsertChildMessages(e)];case 12:h.sent(),h.label=13;case 13:return[2]}}
2))}))},t.prototype.upsertChildMessages=function(e){return f(this,void 0,void 0,(function(){var r=this;return p(this,(function(i){switch(i.label){case 0:return this.localCacheEnabled?[4,Promise.all(e.map((function(s){return f(r,void 0,void 0,(function(){var a,o;return p(this,(function(u){switch(u.label){case 0:return a=[],!((o=s.threadInfo)===null||o===void 0)&&o.replyCount&&s.threadInfo.replyCount>0?[4,this.getAllChildMessages(s)]:[3,2];case 1:a=u.sent(),u.label=2;case 2:return a.length>0?(a.forEach((function(c){return c.applyParentMessage(s)})),[4,this.upsert(a)]):[3,4];case 3:u.sent(),u.label=4;case 4:return[2]}}))}))})))]:[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}}))}))},t.prototype.remove=function(e){return f(this,void 0,void 0,(function(){var r,i,s,a,o,u;return p(this,(function(c){switch(c.label){case 0:if(!this.localCacheEnabled)return[3,8];c.label=1;case 1:c.trys.push([1,6,7,8]),r=z(e),i=r.next(),c.label=2;case 2:return i.done?[3,5]:(s=i.value,[4,this.collection.remove("".concat(s))]);case 3:c.sent(),c.label=4;case 4:return i=r.next(),[3,2];case 5:return[3,8];case 6:return a=c.sent(),o={error:a},[3,8];case 7:try{i&&!i.done&&(u=r.return)&&u.call(r)}finally{if(o)throw o.error}return[7];case 8:return[2]}}
2))}))},t.prototype.removeMessagesOfChannel=function(e){return f(this,void 0,void 0,(function(){var r;return p(this,(function(i){switch(i.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e},index:nt(ye.CHANNEL_LATEST)})]:[3,6];case 1:return i.sent(),[4,(r=this._cacheContext.preference).remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"))];case 2:return i.sent(),[4,r.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"))];case 3:return i.sent(),[4,r.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"))];case 4:return i.sent(),[4,r.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"))];case 5:i.sent(),i.label=6;case 6:return[2]}}))}))},t.prototype.removeUnderOffset=function(e,r,i){return i===void 0&&(i=!1),f(this,void 0,void 0,(function(){return p(this,(function(s){switch(s.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e,createdAt:i?{"<=":r}:{"<":r}},index:nt(ye.CHANNEL_LATEST)})]:[3,2];case 1:s.sent(),s.label=2;case 2:return[2]}}
2))}))},t.prototype.clear=function(){return f(this,void 0,void 0,(function(){return p(this,(function(e){switch(e.label){case 0:return this.localCacheEnabled?[4,this.collection.clear()]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},t.prototype.countBetween=function(e,r,i){return f(this,void 0,void 0,(function(){var s,a=this;return p(this,(function(o){switch(o.label){case 0:return this.localCacheEnabled?(s=nt(ye.CHANNEL_LATEST),[4,this.collection.query({where:{channelUrl:e,"/where":function(u){var c=a._deserialize(u);return i.includes(c.createdAt)&&r.match(c)}},index:s}).count()]):[3,2];case 1:return[2,o.sent()];case 2:return[2,0]}}))}))},t.prototype.countByChannel=function(e){return f(this,void 0,void 0,(function(){var r;return p(this,(function(i){switch(i.label){case 0:return this.localCacheEnabled?(r=nt(ye.CHANNEL_LATEST),[4,this.collection.query({where:{channelUrl:e},index:r}).count()]):[3,2];case 1:return[2,i.sent()];case 2:return[2,0]}}))}))},t.prototype.saveBlobs=function(e){return f(this,void 0,void 0,(function(){var r=this;return p(this,(function(i){switch(i.label){case 0:return[4,Promise.all(e.map((function(s){return f(r,void 0,void 0,(function(){var a,o;return p(this,(function(u){switch(u.label){case 0:return s instanceof he&&s.messageParams&&(a=s.messageParams).file&&kr(a.file)?[4,this.collection.saveBlob(a.file,s.reqId)]:[3,2];case 1:o=u.sent(),a.fileKey=o,u.label=2;case 2:return[2]}}
2))}))})))];case 1:return i.sent(),[2]}}))}))},t.prototype._getGroupChannelPreferenceSize=function(e){return f(this,void 0,void 0,(function(){var r,i,s,a,o,u;return p(this,(function(c){switch(c.label){case 0:return r=0,[4,(i=this._cacheContext.preference).get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"))];case 1:return s=c.sent(),[4,i.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"))];case 2:return a=c.sent(),[4,i.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"))];case 3:return o=c.sent(),[4,i.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"))];case 4:return u=c.sent(),s&&(r+=JSON.stringify(s).length),a&&(r+=JSON.stringify(a).length),o&&(r+=JSON.stringify(o).length),u&&(r+=JSON.stringify(u).length),[2,r]}}))}))},t})(be),Ir={},pf=(function(n){function t(e){var r=n.call(this,e)||this;return Ir[e]=r,r}return g(t,n),Object.defineProperty(t.prototype,"_sdkState",{get:function(){return C.of(this._iid).sdkState},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_cacheContext",{get:function(){return C.of(this._iid).cacheContext},enumerable:!1,configurable:!0}),t.of=function(e,r){return r===void 0&&(r=!1),Ir[e]&&!r||(Ir[e]=new t(e)),Ir[e]},Object.defineProperty(t.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return R(!!e).throw(T.databaseError),e.collection(vu)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),t.prototype._serialize=function(e){return E({},e.serialize())},t.prototype._deserialize=function(e){return Ne.of(this._iid).buildMessageFromSerializedData(e)},t.prototype.get=function(e){return f(this,void 0,void 0,(function(){var r;return p(this,(function(i){switch(i.label){case 0:return this.localCacheEnabled?[4,this.collection.getByKey(e)]:[3,2];case 1:if(r=i.sent())return[2,this._deserialize(r)];i.label=2;case 2:return[2,void 0]}}))}))},t.prototype.fetch=function(e){var r=e.channelUrl,i=e.token,s=e.limit,a=s===void 0?100:s,o=e.filter,u=o===void 0?new vn:o,c=e.backward,l=c!==void 0&&c,d=e.exactMatch,_=d!==void 0&&d,h=e.inclusive,v=h===void 0||h;return f(this,void 0,void 0,(function(){var m,y=this;return p(this,(function(b){switch(b.label){case 0:return this.localCacheEnabled?(m={where:{channelUrl:r,"/where":function(w){if(i){if(_&&w.createdAt!==i)return!1;if(l){if(v&&w.createdAt<i||!v&&w.createdAt<=i)return!1}else if(v&&w.createdAt>i||!v&&w.createdAt>=i)return!1}return u.match(y._deserialize(w))}},index:["channelUrl","-createdAt","-notificationId"],backward:l},[4,this.collection.query(m)]):[3,3];case 1:return[4,b.sent().fetch({limit:a!=null?a:void 0})];case 2:return[2,b.sent().map((function(w){return y._deserialize(w)}))];case 3:return[2,[]]}}))}))},t.prototype.upsert=function(e){return f(this,void 0,void 0,(function(){var r,i=this;return p(this,(function(s){switch(s.label){case 0:return this.localCacheEnabled?(r=e.map((function(a){return i._serialize(a)})),[4,this.collection.upsertMany(r)]):[3,2];case 1:s.sent(),s.label=2;case 2:return[2]}}
2))}))},t.prototype.remove=function(e){return f(this,void 0,void 0,(function(){var r,i,s,a,o,u;return p(this,(function(c){switch(c.label){case 0:if(!this.localCacheEnabled)return[3,8];c.label=1;case 1:c.trys.push([1,6,7,8]),r=z(e),i=r.next(),c.label=2;case 2:return i.done?[3,5]:(s=i.value,[4,this.collection.remove(s)]);case 3:c.sent(),c.label=4;case 4:return i=r.next(),[3,2];case 5:return[3,8];case 6:return a=c.sent(),o={error:a},[3,8];case 7:try{i&&!i.done&&(u=r.return)&&u.call(r)}finally{if(o)throw o.error}return[7];case 8:return[2]}}))}))},t.prototype.markAsReadByTimestamp=function(e,r){return f(this,void 0,void 0,(function(){return p(this,(function(i){switch(i.label){case 0:return this.localCacheEnabled?[4,this.collection.updateIf({where:{channelUrl:e,messageStatus:$t.SENT,createdAt:{"<":r}}},{set:{messageStatus:$t.READ}})]:[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}}))}))},t.prototype.markAsReadByMessageIds=function(e,r){return f(this,void 0,void 0,(function(){return p(this,(function(i){switch(i.label){case 0:return this.localCacheEnabled?[4,this.collection.updateIf({where:{channelUrl:e,notificationId:{"/in":r},messageStatus:$t.SENT}},{set:{messageStatus:$t.READ}})]:[3,2];case 1:return[2,i.sent().length];case 2:return[2,0]}}))}))},t.prototype.removeMessagesOfChannel=function(e){return f(this,void 0,void 0,(function(){var r;return p(this,(function(i){switch(i.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e},index:["channelUrl","-createdAt","-notificationId"]})]:[3,6];case 1:return i.sent(),[4,(r=this._cacheContext.preference).remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"))];case 2:return i.sent(),[4,r.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"))];case 3:return i.sent(),[4,r.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"))];case 4:return i.sent(),[4,r.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"))];case 5:i.sent(),i.label=6;case 6:return[2]}}
2))}))},t.prototype.removeUnderOffset=function(e,r){return f(this,void 0,void 0,(function(){return p(this,(function(i){switch(i.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":r}},index:nt(ye.CHANNEL_LATEST)})]:[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}}))}))},t.prototype.clear=function(){return f(this,void 0,void 0,(function(){return p(this,(function(e){switch(e.label){case 0:return this.localCacheEnabled?[4,this.collection.clear()]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},t.prototype.countBetween=function(e,r,i){return f(this,void 0,void 0,(function(){var s,a=this;return p(this,(function(o){switch(o.label){case 0:return this.localCacheEnabled?(s=["channelUrl","-createdAt","-notificationId"],[4,this.collection.query({where:{channelUrl:e,"/where":function(u){var c=a._deserialize(u);return i.includes(c.createdAt)&&r.match(c)}},index:s}).count()]):[3,2];case 1:return[2,o.sent()];case 2:return[2,0]}}))}))},t})(be),Sn={},_f=(function(n){function t(e){var r=n.call(this,e)||this;return r._observers=new Map,r._dispatcherContext=r._dispatcher.on((function(i){return f(r,void 0,void 0,(function(){var s,a,o,u,c,l,d,_,h,v,m,y,b,w,I,A,D,N,F,q,x,H=this;return p(this,(function(j){switch(j.label){case 0:return i instanceof ge?(s=i.messages,x=i.source,l=i.isWebSocketEventComing,a=s.filter((function(P){return P instanceof je&&P.channelType!==oe.OPEN&&P.messageId>0})),o=s.filter((function(P){return P instanceof je&&P.channelType!==oe.OPEN&&P.messageId===0})),u=s.filter((function(P){return P instanceof _n})),a.length>0?[4,ve((function(){return f(H,void 0,void 0,(function(){return p(this,(function(P){switch(P.label){case 0:return[4,this._messageCache.upsert(a)];case 1:return P.sent(),[4,this._unsentMessageCache.remove(a.map((function(ce){return ce instanceof pt?ce.reqId:null})).filter((function(ce){return ce!==null})))];case 2:return P.sent(),[2]}}))}))}))]:[3,2]):[3,7];case 1:j.sent(),l||this._broadcastUpdateEvent(a,x),j.label=2;case 2:return o.length>0?[4,ve((function(){return f(H,void 0,void 0,(function(){return p(this,(function(P){switch(P.label){case 0:return[4,this._unsentMessageCache.upsert(o)];case 1:return P.sent(),[2]}}))}))}))]:[3,4];case 3:j.sent(),l||this._broadcastUpdateEvent(o,x),j.label=4;case 4:return u.length>0?[4,ve((function(){return f(H,void 0,void 0,(function(){return p(this,(function(P){switch(P.label){case 0:return[4,this._notificationCache.upsert(u)];case 1:return P.sent(),[2]}}))}))}))]:[3,6];case 5:j.sent(),l||this._broadcastUpdateEvent(u,x),j.label=6;case 6:return[3,24];case 7:return i instanceof Jo?(c=i.messageIds,x=i.source,l=i.isWebSocketEventComing,d=c.filter((function(P){return typeof P=="number"})),_=c.filter((function(P){return typeof P=="string"})),[4,ve((function(){return f(H,void 0,void 0,(function(){return p(this,(function(P){switch(P.label){case 0:return d.length>0?[4,this._messageCache.remove(d)]:[3,2];case 1:P.sent(),P.label=2;case 2:return _.length>0?[4,this._notificationCache.remove(_)]:[3,4];case 3:P.sent(),P.label=4;case 4:return[2]}}
2))}))}))]):[3,9];case 8:return j.sent(),l||this._broadcastRemoveEvent(c,x),[3,24];case 9:return i instanceof xl?(h=i.reqId,x=i.source,[4,ve((function(){return f(H,void 0,void 0,(function(){return p(this,(function(P){switch(P.label){case 0:return[4,this._unsentMessageCache.remove([h])];case 1:return P.sent(),[2]}}))}))}))]):[3,11];case 10:return j.sent(),this._broadcastRemoveUnsentEvent(h,x),[3,24];case 11:return i instanceof eu?(v=i.polls,x=i.source,this._cacheContext.localCacheEnabled?(m=v.map((function(P){return P.messageId})),[4,Promise.all(m.map((function(P){return H._messageCache.get(P)})))]):[3,14]):[3,15];case 12:return(y=j.sent().filter((function(P){return P}))).length>0&&v.forEach((function(P){var ce=y.find((function(Me){return Me.messageId===P.messageId}));ce&&ce.applyPoll(P)})),[4,ve((function(){return f(H,void 0,void 0,(function(){return p(this,(function(P){switch(P.label){case 0:return[4,this._messageCache.upsert(y)];case 1:return[2,P.sent()]}}))}))}))];case 13:j.sent(),j.label=14;case 14:return this._broadcastPollChangeLogEvent(v,x),[3,24];case 15:return i instanceof Fl?(b=i.event,x=i.source,[4,this._messageCache.get(b.messageId)]):[3,19];case 16:return(w=j.sent())&&w.isUserMessage()&&w.poll&&w.poll.applyPollUpdateEvent(b)?[4,ve((function(){return f(H,void 0,void 0,(function(){return p(this,(function(P){switch(P.label){case 0:return[4,this._messageCache.upsert([w])];case 1:return[2,P.sent()]}}))}))}))]:[3,18];case 17:j.sent(),j.label=18;case 18:return this._broadcastPollUpdateEvent(b,x),[3,24];case 19:return i instanceof tu?(I=i.event,x=i.source,[4,this._messageCache.get(I.messageId)]):[3,23];case 20:return(A=j.sent())&&A.isUserMessage()&&A.poll&&A.poll.applyPollVoteEvent(I)?[4,ve((function(){return f(H,void 0,void 0,(function(){return p(this,(function(P){switch(P.label){case 0:return[4,this._messageCache.upsert([A])];case 1:return[2,P.sent()]}}))}))}))]:[3,22];case 21:j.sent(),j.label=22;case 22:return this._broadcastPollVoteEvent(I,x),[3,24];case 23:i instanceof Ml?(D=i.event,x=i.source,D.messageId>0&&this._broadcastReactionUpdateEvent(D,x)):i instanceof Pl?(N=i.event,x=i.source,this._broadcastThreadUpdateEvent(N,x)):i instanceof Ul&&(F=i.messageDeletionTimestamp,q=i.channelUrl,x=i.source,this._broadcastMessageRetentionEvent(F,q,x)),j.label=24;case 24:return[2]}}
2))}))})),r}return g(t,n),Object.defineProperty(t.prototype,"_cacheContext",{get:function(){return C.of(this._iid).cacheContext},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_dispatcher",{get:function(){return C.of(this._iid).dispatcher},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_messageCache",{get:function(){return ys.of(this._iid)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_unsentMessageCache",{get:function(){return sr.of(this._iid)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_notificationCache",{get:function(){return pf.of(this._iid)},enumerable:!1,configurable:!0}),t.of=function(e,r){var i;return r===void 0&&(r=!1),Sn[e]&&!r||(Sn[e]&&((i=Sn[e]._dispatcherContext)===null||i===void 0||i.close()),Sn[e]=new t(e)),Sn[e]},t.prototype._broadcastUpdateEvent=function(e,r){var i,s;try{for(var a=z(this._observers.values()),o=a.next();!o.done;o=a.next()){var u=o.value;u.onUpdate&&u.onUpdate(e,r)}}catch(c){i={error:c}}finally{try{o&&!o.done&&(s=a.return)&&s.call(a)}finally{if(i)throw i.error}}},t.prototype._broadcastPollChangeLogEvent=function(e,r){var i,s;try{for(var a=z(this._observers.values()),o=a.next();!o.done;o=a.next()){var u=o.value;u.onPollChangeLogUpdate&&u.onPollChangeLogUpdate(e,r)}}catch(c){i={error:c}}finally{try{o&&!o.done&&(s=a.return)&&s.call(a)}finally{if(i)throw i.error}}},t.prototype._broadcastPollUpdateEvent=function(e,r){var i,s;try{for(var a=z(this._observers.values()),o=a.next();!o.done;o=a.next()){var u=o.value;u.onPollUpdate&&u.onPollUpdate(e,r)}}catch(c){i={error:c}}finally{try{o&&!o.done&&(s=a.return)&&s.call(a)}finally{if(i)throw i.error}}},t.prototype._broadcastPollVoteEvent=function(e,r){var i,s;try{for(var a=z(this._observers.values()),o=a.next();!o.done;o=a.next()){var u=o.value;u.onPollVote&&u.onPollVote(e,r)}}catch(c){i={error:c}}finally{try{o&&!o.done&&(s=a.return)&&s.call(a)}finally{if(i)throw i.error}}},t.prototype._broadcastRemoveEvent=function(e,r){var i,s;try{for(var a=z(this._observers.values()),o=a.next();!o.done;o=a.next()){var u=o.value;u.onRemove&&u.onRemove(e,r)}}catch(c){i={error:c}}finally{try{o&&!o.done&&(s=a.return)&&s.call(a)}finally{if(i)throw i.error}}},t.prototype._broadcastRemoveUnsentEvent=function(e,r){var i,s;try{for(var a=z(this._observers.values()),o=a.next();!o.done;o=a.next()){var u=o.value;u.onRemoveUnsent&&u.onRemoveUnsent(e,r)}}catch(c){i={error:c}}finally{try{o&&!o.done&&(s=a.return)&&s.call(a)}finally{if(i)throw i.error}}},t.prototype._broadcastReactionUpdateEvent=function(e,r){var i,s;try{for(var a=z(this._observers.values()),o=a.next();!o.done;o=a.next()){var u=o.value;u.onReactionUpdate&&u.onReactionUpdate(e,r)}}catch(c){i={error:c}}finally{try{o&&!o.done&&(s=a.return)&&s.call(a)}finally{if(i)throw i.error}}},t.prototype._broadcastThreadUpdateEvent=function(e,r){var i,s;try{for(var a=z(this._observers.values()),o=a.next();!o.done;o=a.next()){var u=o.value;u.onThreadInfoUpdate&&u.onThreadInfoUpdate(e,r)}}catch(c){i={error:c}}finally{try{o&&!o.done&&(s=a.return)&&s.call(a)}finally{if(i)throw i.error}}},t.prototype._broadcastMessageRetentionEvent=function(e,r,i){var s,a;try{for(var o=z(this._observers.values()),u=o.next();!u.done;u=o.next()){var c=u.value;c.onDeletedByRetentionPolicy&&c.onDeletedByRetentionPolicy(e,r,i)}}catch(l){s={error:l}}finally{try{u&&!u.done&&(a=o.return)&&a.call(o)}finally{if(s)throw s.error}}},t.prototype.subscribe=function(e,r){this._observers.set(e,r)},t.prototype.unsubscribe=function(e){this._observers.delete(e)},t.prototype.unsubscribeAll=function(){this._observers.clear()},t})(be),Va={},vf=(function(n){function t(e,r){var i=r.sdkState,s=r.cacheContext,a=n.call(this,e)||this;return a._users=new Map,a._sdkState=i,a._cacheContext=s,Va[e]=a,a}return g(t,n),t.of=function(e){return Va[e]},Object.defineProperty(t.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return R(!!e).throw(T.databaseError),e.collection(mu)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection}
2,enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"users",{get:function(){return V([],K(this._users.values()),!1)},enumerable:!1,configurable:!0}),t.prototype._serialize=function(e,r){return E(E({},e.serialize()),{updatedAt:r})},t.prototype._deserialize=function(e){return G._buildUserFromSerializedData(e)},t.prototype.isCachedInMemory=function(e){return this._users.has(e)},t.prototype.getUserInfoFromCache=function(e){if(this._users.has(e))return this._users.get(e)},t.prototype.get=function(e){return f(this,void 0,void 0,(function(){var r,i;return p(this,(function(s){switch(s.label){case 0:return this._users.has(e)?[3,3]:this.localCacheEnabled?[4,this.collection.getByKey(e)]:[3,2];case 1:if(r=s.sent())return i=this._deserialize(r),this._users.set(i.userId,i),[2,i];s.label=2;case 2:return[2,void 0];case 3:return[2,this._users.get(e)]}}))}))},t.prototype.fetch=function(e){var r=e.limit,i=r===void 0?100:r,s=e.backward,a=s!==void 0&&s;return f(this,void 0,void 0,(function(){var o,u,c,l=this;return p(this,(function(d){switch(d.label){case 0:if(!this.localCacheEnabled)return[2,[]];d.label=1;case 1:return d.trys.push([1,4,,5]),o={index:["-userId","-updatedAt"],backward:a},[4,this.collection.query(o)];case 2:return[4,d.sent().fetch({limit:i})];case 3:return u=d.sent(),(c=u.map((function(_){return l._deserialize(_)}))).forEach((function(_){l._users.has(_.userId)||l._users.set(_.userId,_)})),[2,c];case 4:return d.sent(),[2,[]];case 5:return[2]}}
2))}))},t.prototype.upsert=function(e,r){return f(this,void 0,void 0,(function(){var i,s;return p(this,(function(a){switch(a.label){case 0:if(!this.localCacheEnabled)return[3,2];if(i=this._serialize(e,r),s=this._users.get(e.userId)){if(s._hashValue===e._hashValue)return[2];if(s._updatedAt>r)return[2]}return this._users.set(e.userId,G._buildUserFromSerializedData(i)),[4,this.collection.upsertOne(i)];case 1:a.sent(),a.label=2;case 2:return[2]}}))}))},t.prototype.remove=function(e){return f(this,void 0,void 0,(function(){return p(this,(function(r){switch(r.label){case 0:return this._users.has(e)&&this._users.delete(e),this.localCacheEnabled?[4,this.collection.remove(e)]:[3,2];case 1:r.sent(),r.label=2;case 2:return[2]}}))}))},t.prototype.clearMemoryCache=function(){this._users.clear()},t.prototype.clear=function(){return f(this,void 0,void 0,(function(){return p(this,(function(e){switch(e.label){case 0:return this.clearMemoryCache(),this.localCacheEnabled?[4,this.collection.clear()]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}
2))}))},t})(be),mf=(function(n){function t(e){var r=this,i=e.reverse,s=i!==void 0&&i,a=e.limit,o=a===void 0?20:a,u=e.keys,c=e.token;return(r=n.call(this)||this).method=k.GET,r.path="".concat(ho),r.params=M({token:c,limit:o,reverse:s,order:ji.UPDATED_AT,show_ui_template:!0,show_color_variables:!0,keys:u}),r}return g(t,n),t})(O),gf=(function(n){function t(e,r){var i=n.call(this,e,r)||this,s=r.next,a=r.has_more,o=a!==void 0&&a,u=r.templates;return i.nextToken=s,i.hasMore=o,i.templates=u.map((function(c){return{template:JSON.stringify(c)}})),i}return g(t,n),t})(U),yf=(function(n){function t(e){var r=this,i=e.key;return(r=n.call(this)||this).method=k.GET,r.path="".concat(ho,"/").concat(i),r}return g(t,n),t})(O),bf=(function(n){function t(e,r){var i=n.call(this,e,r)||this;return i.template=JSON.stringify(r),i}return g(t,n),t})(U),Ga={},Ne=(function(){function n(t,e){var r=e.sdkState,i=e.dispatcher,s=e.requestQueue,a=e.onlineDetector,o=e.cacheContext;this._iid=t,this._sdkState=r,this._requestQueue=s,this._dispatcher=i,this._cacheContext=o,ys.of(t),sr.of(t),_f.of(t),this.fileMessageQueue=new cd(t,{sdkState:r,dispatcher:i,requestQueue:s,onlineDetector:a,cacheContext:o}),Ga[t]=this}return n.of=function(t){return Ga[t]},n.prototype._setSenderInfo=function(t){if(this._cacheContext.localCacheEnabled&&(t.messageType===ee.USER||t.messageType===ee.FILE)){var e=t.sender;if(e){var r=vf.of(this._iid),i=r.getUserInfoFromCache(e.userId);if(i){var s=E(E({},t.sender),{nickname:i.nickname,profileUrl:i.plainProfileUrl,requireAuth:i.requireAuth,metadata:i.metaData});t.sender=s}else r.upsert(new G(this._iid,G.payloadify(e)),t.createdAt)}}},n.prototype.buildMessageFromSerializedData=function(t){var e=Yn(t);if(e.notificationId)return new _n(this._iid,_n.payloadify(e));switch(this._setSenderInfo(e),e.messageType){case ee.USER:return new ke(this._iid,ke.payloadify(e));case ee.FILE:return Ge._isMultipleFilesMessageSerializedData(e)?new Ge(this._iid,Ge.payloadify(e)):new he(this._iid,he.payloadify(e));case ee.ADMIN:return new Hr(this._iid,Hr.payloadify(e))}throw T.invalidParameters},n.prototype.buildUserMessageCreateParamsFromSerializedData=function(t,e){return M(B({data:e.data,customType:e.customType,mentionType:e.mentionType,mentionedUserIds:e.mentionedUserIds,mentionedUsers:e.mentionedUsers,mentionedMessageTemplate:e.mentionedMessageTemplate,metaArrays:e.metaArrays,parentMessageId:e.parentMessageId,isReplyToChannel:t.isReplyToChannel,pushNotificationDeliveryOption:t.pushNotificationDeliveryOption,appleCriticalAlertOptions:e.appleCriticalAlertOptions,reqId:e.reqId,message:e.message,translationTargetLanguages:Object.keys(e.translations),pollId:t.pollId}))},n.prototype.buildFileMessageCreateParamsFromSerializedData=function(t,e){var r;return M(B({data:e.data,customType:e.customType,mentionType:e.mentionType,mentionedUserIds:e.mentionedUserIds,mentionedUsers:e.mentionedUsers,metaArrays:e.metaArrays,parentMessageId:e.parentMessageId,isReplyToChannel:t.isReplyToChannel,pushNotificationDeliveryOption:t.pushNotificationDeliveryOption,appleCriticalAlertOptions:e.appleCriticalAlertOptions,reqId:e.reqId,file:t.file,fileKey:t.fileKey,fileUrl:e.plainUrl,fileName:e.name,fileSize:e.size,mimeType:e.type,thumbnailSizes:(r=e.thumbnails)===null||r===void 0?void 0:r.map((function(i){return{maxWidth:i.width,maxHeight:i.height}})),fileType:t.fileType,requireAuth:e.requireAuth}))},n.prototype.buildMultipleFilesMessageCreateParamsFromSerializedData=function(t,e){var r=this;return M({data:e.data,customType:e.customType,mentionType:e.mentionType,mentionedUserIds:e.mentionedUserIds,mentionedUsers:e.mentionedUsers,metaArrays:e.metaArrays,parentMessageId:e.parentMessageId,isReplyToChannel:t.isReplyToChannel,pushNotificationDeliveryOption:t.pushNotificationDeliveryOption,appleCriticalAlertOptions:e.appleCriticalAlertOptions,reqId:e.reqId,fileInfoList:t.fileInfoList.map((function(i){return new Xn(r._iid,i)}))})},n.prototype.buildScheduledUserMessageCreateParamsFromSerializedData=function(t,e){return E(E({},this.buildUserMessageCreateParamsFromSerializedData(t,e)),{scheduledAt:t.scheduledAt})},n.prototype.buildScheduledFileMessageCreateParamsFromSerializedData=function(t,e){return E(E({},this.buildFileMessageCreateParamsFromSerializedData(t,e)),{scheduledAt:t.scheduledAt})},n.prototype.buildSenderFromSerializedData=function(t){var e=Yn(t);return new Yt(this._iid,Yt.payloadify(e))},n.prototype.getMessage=function(t){return f(this,void 0,void 0,(function(){var e,r;return p(this,(function(i){switch(i.label){case 0:return e=new ld(t),[4,this._requestQueue.send(e)];case 1:return r=i.sent(),[2,r.as(dd).message]}}))}))},n.prototype.getScheduledMessage=function(t){return f(this,void 0,void 0,(function(){var e,r;return p(this,(function(i){switch(i.label){case 0:return e=new pd(t),[4,this._requestQueue.send(e)];case 1:return r=i.sent(),[2,r.as(_d).message]}}))}))},n.prototype.getMessagesByMessageId=function(t,e,r,i,s){return s===void 0&&(s=ne.REQUEST_MESSAGE),f(this,void 0,void 0,(function(){var a,o,u;return p(this,(function(c){switch(c.label){case 0:return a=new _r(E(E(E({channelType:e,channelUrl:t,token:String(r)},Bn),i),{sdkSource:Vr.EXTERNAL_LEGACY})),[4,this._requestQueue.send(a)];case 1:return o=c.sent(),u=o.as(vr).messages,this._dispatcher.dispatch(new ge({messages:u,source:s})),[2,u]}}))}))},n.prototype.getMessagesByTimestamp=function(t,e,r,i,s){return s===void 0&&(s=ne.REQUEST_MESSAGE),f(this,void 0,void 0,(function(){var a,o,u;return p(this,(function(c){switch(c.label){case 0:return a=new _r(E(E(E({channelType:e,channelUrl:t,timestamp:r},Bn),i),{sdkSource:Vr.EXTERNAL_LEGACY})),[4,this._requestQueue.send(a)];case 1:return o=c.sent(),u=o.as(vr).messages,this._dispatcher.dispatch(new ge({messages:u,source:s})),[2,u]}}))}))},n.prototype._getMessagesByTimestampForCollection=function(t,e,r,i,s,a,o,u){return s===void 0&&(s=ne.REQUEST_MESSAGE),f(this,void 0,void 0,(function(){var c,l,d,_,h,v;return p(this,(function(m){switch(m.label){case 0:return c=new _r(E(E(E({channelType:e,channelUrl:t,timestamp:r},Bn),i),{checkingHasNext:a,checkingContinuousMessages:o,sdkSource:u})),[4,this._requestQueue.send(c)];case 1:return l=m.sent(),d=l.as(vr),_=d.messages,h=d.isContinuousMessages,v=d.hasNext,this._dispatcher.dispatch(new ge({messages:_,source:s})),[2,{messages:_,isContinuousMessages:h,hasNext:v}]}}))}))},n.prototype.getThreadedMessagesByTimestamp=function(t,e,r,i){return i===void 0&&(i=ne.REQUEST_THREADED_MESSAGE),f(this,void 0,void 0,(function(){var s,a,o,u;return p(this,(function(c){switch(c.label){case 0:return s=new _r(E(E(E({channelUrl:t.channelUrl,channelType:t.channelType,timestamp:e},rr),r),{replyType:ze.ALL,parentMessageId:t.messageId,includeThreadInfo:!0})),[4,this._requestQueue.send(s)];case 1:return a=c.sent(),o=a.as(vr).messages,(u=o.slice(1)).forEac
2h((function(l){l.parentMessage=t})),this._dispatcher.dispatch(new ge({messages:u,source:i})),[2,{parentMessage:o[0],threadedMessages:u}]}}))}))},n.prototype.getMessageTemplatesByToken=function(t,e){return e===void 0&&(e={}),f(this,void 0,void 0,(function(){var r,i,s,a,o,u;return p(this,(function(c){switch(c.label){case 0:return r=new mf(E({token:t},e)),[4,this._requestQueue.send(r)];case 1:return i=c.sent(),s=i.as(gf),a=s.hasMore,o=s.nextToken,u=s.templates,[2,{hasMore:a,token:o,templates:u}]}}))}))},n.prototype.getMessageTemplate=function(t){return f(this,void 0,void 0,(function(){var e,r;return p(this,(function(i){switch(i.label){case 0:return e=new yf({key:t}),[4,this._requestQueue.send(e)];case 1:return r=i.sent(),[2,{template:r.as(bf).template}]}}))}))},n.prototype.getMessageChangelogs=function(t,e,r,i,s){return s===void 0&&(s=ne.REQUEST_MESSAGE_CHANGELOGS),f(this,void 0,void 0,(function(){var a,o,u,c,l,d,_,h,v;return p(this,(function(m){switch(m.label){case 0:return a=new hd(M(B(E(E({channelType:e,channelUrl:t,timestamp:typeof r=="number"?r:null,token:typeof r=="string"?r:null},rs),i)))),[4,this._requestQueue.send(a)];case 1:return o=m.sent(),u=o.as(fd),c=u.updatedMessages,l=u.deletedMessagesInfo,d=u.hasMore,_=u.nextToken,h=u.forceUseNextToken,v=l.map((function(y){return y.messageId})),c.length>0&&this._dispatcher.dispatch(new ge({messages:c,source:s})),v.length>0&&this._dispatcher.dispatch(new Jo({messageIds:v,source:s})),[2,{updatedMessages:c,deletedMessageIds:v,hasMore:d,token:_,forceUseNextToken:h}]}}))}))},n})(),M_=(function(n){function t(e,r){var i=n.call(this,e)||this;i.targetMessageId=0;var s=r.thread_info,a=r.parent_message_id,o=r.channel_url,u=r.channel_type;return s&&S("object",s)&&S("number",a)&&S("string",o)&&S("string",u)&&(i.threadInfo=new ts(e,s),i.targetMessageId=a,i.channelUrl=o,i.channelType=u),i}return g(t,n),t})(be),Ef=(function(n){function t(e){var r=e.channelType,i=e.channelUrl,s=e.limit,a=e.token,o=n.call(this)||this;return o.method=k.GET,o.path="".concat(Y(r),"/").concat(encodeURIComponent(i),"/messages/parent_thread_message"),o.params=M(B({limit:s,token:a})),o}return g(t,n),t})(O),wf=(function(n){function t(e,r){var i=n.call(this,e,r)||this;return i.token=r.next,i.messages=r.messages.map((function(s){return ot(e,s)})),i}return g(t,n),t})(U),P_=(function(n){function t(e,r,i,s){var a=n.call(this,e,r,i,s)||this;return a._edge="",a}return g(t,n),t.prototype._validate=function(){return n.prototype._validate.call(this)},t.prototype.load=function(){return f(this,void 0,void 0,(function(){var e,r,i,s,a,o;return p(this,(function(u){switch(u.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=C.of(this._iid).requestQueue,r=new Ef({channelType:this.channelType,channelUrl:this.channelUrl,token:this._edge,limit:this.limit}),[4,e.send(r)]):[3,2]:[3,5];case 1:return i=u.sent(),s=i.as(wf),a=s.messages,o=s.token,this._edge=o,this._hasNext=!!o,this._isLoading=!1,[2,a];case 2:return[2,[]];case 3:throw T.queryInProgress;case 4:return[3,6];case 5:throw T.invalidParameters;case 6:return[2]}}
2))}))},t})(qt),Vn,If={channelUrl:"",channelType:oe.BASE,messageId:0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1},Tf=(function(n){function t(e){var r=e.channelCustomType,i=e.keyword,s=e.limit,a=e.reverse,o=e.exactMatch,u=e.channelUrl,c=e.order,l=e.messageTimestampFrom,d=e.messageTimestampTo,_=e.advancedQuery,h=e.targetFields,v=e.nextToken,m=n.call(this)||this;return m.method=k.GET,m.path="".concat(xu,"/messages"),m.params=M({custom_type:r,query:i,limit:s,reverse:a,exact_match:o,channel_url:u,message_ts_from:l,message_ts_to:d,sort_field:c,advanced_query:_,target_fields:h,after:v}),m}return g(t,n),t})(O),Sf=(function(n){function t(e,r){var i=n.call(this,e,r)||this;return i.messages=r.results.map((function(s){return ot(e,s)})),i.hasNext=r.has_next,i.nextToken=r.end_cursor,i.totalCount=r.total_count,i}return g(t,n),t})(U);(function(n){n.SCORE="score",n.TIMESTAMP="ts"})(Vn||(Vn={}));var Qa,Cf=(function(n){function t(e,r){var i,s,a,o,u,c,l,d,_,h=this;return(h=n.call(this,e,r)||this).keyword="",h.reverse=!1,h.exactMatch=!1,h.channelUrl=null,h.channelCustomType=null,h.messageTimestampFrom=null,h.messageTimestampTo=null,h.order=Vn.SCORE,h.advancedQuery=!1,h.targetFields=null,h._nextToken="",h.totalCount=-1,h.keyword=r.keyword,h.reverse=(i=r.reverse)!==null&&i!==void 0&&i,h.exactMatch=(s=r.exactMatch)!==null&&s!==void 0&&s,h.channelUrl=(a=r.channelUrl)!==null&&a!==void 0?a:null,h.channelCustomType=(o=r.channelCustomType)!==null&&o!==void 0?o:null,h.messageTimestampFrom=(u=r.messageTimestampFrom)!==null&&u!==void 0?u:null,h.messageTimestampTo=(c=r.messageTimestampTo)!==null&&c!==void 0?c:null,h.order=(l=r.order)!==null&&l!==void 0?l:Vn.SCORE,h.advancedQuery=(d=r.advancedQuery)!==null&&d!==void 0&&d,h.targetFields=(_=r.targetFields)!==null&&_!==void 0?_:null,h}return g(t,n),t.prototype._validate=function(){return n.prototype._validate.call(this)&&S("string",this.keyword)&&this.keyword.length>0&&S("boolean",this.reverse)&&S("boolean",this.exactMatch)&&S("string",this.channelUrl,!0)&&S("string",this.channelCustomType,!0)&&S("number",this.messageTimestampFrom,!0)&&S("number",this.messageTimestampTo,!0)&&ie(Vn,this.order)&&S("boolean",this.advancedQuery)&&J("string",this.targetFields,!0)},t.prototype.next=function(){return f(this,void 0,void 0,(function(){var e,r,i,s,a,o,u,c;return p(this,(function(l){switch(l.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=C.of(this._iid).requestQueue,r=new Tf(B(E(E({},this),{nextToken:this._nextToken?this._nextToken:null}))),[4,e.send(r)]):[3,2]:[3,5];case 1:return i=l.sent(),s=i.as(Sf),a=s.messages,o=s.hasNext,u=s.nextToken,c=s.totalCount,this._nextToken=u,this._hasNext=o,this._isLoading=!1,this.totalCount=c,[2,a];case 2:return[2,[]];case 3:throw T.queryInProgress;case 4:return[3,6];case 5:throw T.invalidParameters;case 6:return[2]}}
2))}))},t})(nr),Af={channelUrl:"",scheduledMessageId:0};(function(n){n.GOOD="good",n.BAD="bad"})(Qa||(Qa={}));var $a,Nf={reverse:!1,limit:20};(function(n){n.TEXT="text",n.TEXTAREA="textarea",n.NUMBER="number",n.PHONE="phone",n.EMAIL="email",n.CHIP="chip"})($a||($a={}));var kf=(function(n){function t(){var e=n!==null&&n.apply(this,arguments)||this;return e.name="message",e}return g(t,n),t.prototype.init=function(e,r){var i=r.sdkState,s=r.dispatcher,a=r.sessionManager,o=r.requestQueue,u=r.logger,c=r.onlineDetector,l=r.cacheContext;n.prototype.init.call(this,e,{sdkState:i,dispatcher:s,sessionManager:a,requestQueue:o,logger:u,onlineDetector:c,cacheContext:l}),this._manager=new Ne(e,{sdkState:i,dispatcher:s,requestQueue:o,onlineDetector:c,cacheContext:l})},t.prototype.buildMessageFromSerializedData=function(e){return this._manager.buildMessageFromSerializedData(e)},t.prototype.buildSenderFromSerializedData=function(e){return this._manager.buildSenderFromSerializedData(e)},t.prototype.getMessage=function(e){return f(this,void 0,void 0,(function(){var r,i;return p(this,(function(s){switch(s.label){case 0:return r=E(E({},If),e),R((function(a){return S("string",a.channelUrl)&&ie(oe,a.channelType)&&S("number",a.messageId)&&S("boolean",a.includeReactions,!0)&&S("boolean",a.includeMetaArray,!0)&&S("boolean",a.includeParentMessageInfo,!0)&&S("boolean",a.includeThreadInfo,!0)})(r)).throw(T.invalidParameters),[4,this._manager.getMessage(r)];case 1:if((i=s.sent())instanceof je||i instanceof _n||i===null)return[2,i];throw"Unknown message type is given."}}))}))},t.prototype.getScheduledMessage=function(e){return f(this,void 0,void 0,(function(){var r;return p(this,(function(i){return r=E(E({},Af),e),R((function(s){return S("string",s.channelUrl)&&s.channelUrl!==""&&S("number",s.scheduledMessageId)&&s.scheduledMessageId>0})(r)).throw(T.invalidParameters),[2,this._manager.getScheduledMessage(r)]}))}))},t.prototype.getMessageTemplatesByToken=function(e,r){return r===void 0&&(r={}),f(this,void 0,void 0,(function(){var i;return p(this,(function(s){return i=E(E({},Nf),r),R(S("string",e,!0)&&(function(a){return S("boolean",a.reverse,!0)&&S("number",a.limit,!0)&&J("string",a.keys,!0)})(i)).throw(T.invalidParameters),[2,this._manager.getMessageTemplatesByToken(e,i)]}))}))},t.prototype.getMessageTemplate=function(e){return f(this,void 0,void 0,(function(){return p(this,(function(r){return R(S("string",e)).throw(T.invalidParameters),[2,this._manager.getMessageTemplate(e)]}))}))},t})(Xo),x_=function(n,t){this.pollId=0,this.messageId=0,this.pollId=t.poll.id,this.messageId=t.poll.message_id,this._iid=n,this._payload=t},Of=(function(n){function t(){var e=n!==null&&n.apply(this,arguments)||this;return e.name="poll",e}return g(t,n),t.prototype.init=function(e,r){var i=r.sdkState,s=r.dispatcher,a=r.sessionManager,o=r.requestQueue,u=r.logger,c=r.onlineDetector,l=r.cacheContext;n.prototype.init.call(this,e,{sdkState:i,dispatcher:s,sessionManager:a,requestQueue:o,logger:u,onlineDetector:c,cacheContext:l}),this._manager=new Xi(e,{sdkState:i,dispatcher:s,sessionManager:a,requestQueue:o,logger:u,onlineDetector:c,cacheContext:l})},t.prototype.create=function(e){return f(this,void 0,void 0,(function(){var r;return p(this,(function(i){return r=E(E({},$l),e),R(ru(r)).throw(T.invalidParameters),[2,this._manager.create(r)]}))}))},t.prototype.get=function(e){return f(this,void 0,void 0,(function(){var r;return p(this,(function(i){return r=E(E({},Yl),e),R(su(r)).throw(T.invalidParameters),[2,this._manager.get(r)]}))}))},t.prototype.getOption=function(e){return f(this,void 0,void 0,(function(){var r;return p(this,(function(i){return r=E(E({},Wl),e),R(iu(r)).throw(T.invalidParameters),[2,this._manager.getOption(r)]}))}))},t.prototype.buildPollFromSerializedData=function(e){return this._manager.buildPollFromSerializedData(e)},t})(Xo),xt,Wa,Ya,Za;(function(n){n.LATEST_LAST_MESSAGE="latest_last_message",n.CHRONOLOGICAL="chronological",n.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",n.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical"})(xt||(xt={})),(function(n){n.CHRONOLOGICAL="chronological",n.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",n.METADATA_VALUE_ALPHABETICAL="metadata_value_alph
2abetical"})(Wa||(Wa={})),(function(n){n.LATEST="latest",n.OLDEST="oldest"})(Ya||(Ya={})),(function(n){n.CREATED_AT="created_at",n.SCHEDULED_AT="scheduled_at"})(Za||(Za={}));var as,Pi=function(n){switch(n){case xt.LATEST_LAST_MESSAGE:return["-lastMessageUpdatedAt","-createdAt","syncIndex"];case xt.CHRONOLOGICAL:return["-createdAt","syncIndex"];case xt.CHANNEL_NAME_ALPHABETICAL:return["name"];default:return["-lastMessageUpdatedAt","-createdAt","syncIndex"]}},Df=(function(n){function t(e){var r=e.message,i=n.call(this)||this;return i.message=r,i}return g(t,n),t})(Z),bu=(function(n){function t(e,r){var i=r.userId,s=n.call(this)||this;return s._iid=e,s.userId=i,s}return g(t,n),t})(Z),Rf=(function(n){function t(){return n.call(this)||this}return g(t,n),t})(Z),Xa={},Lf=(function(){function n(t,e){var r=e.localCacheEnabled,i=e.enableAutoResend,s=e.hasAiAgentModule,a=e.dispatcher,o=e.sdkState,u=e.logger,c=this;this._iid=t,Xa[t]=this,this._localCacheEnabled=r,this._enableAutoResend=i,this._hasAiAgentModule=s,this._changePendingMessageToFailOnFirstConnection=!1,this._isProcessingAutoResend=!1,this._autoResendQueue=[],this._dispatcher=a,this._logger=u,this._sdkState=o,this._localCacheEnabled&&a.on((function(l){if(l instanceof yn)switch(l.stateType){case X.CONNECTED:c._isProcessingAutoResend||c.processAutoResendRegisteredPendingMessages().then((function(){return c._processNextAutoResend()}));break;case X.INTERNAL_DISCONNECTED:case X.EXTERNAL_DISCONNECTED:c._isProcessingAutoResend=!1}else l instanceof bu&&c._hasAiAgentModule&&(c._changePendingMessageToFailOnFirstConnection=!0)}))}return n.of=function(t){return Xa[t]},n.prototype.processNonAutoResendRegisteredPendingMessages=function(){return f(this,void 0,void 0,(function(){var t=this;return p(this,(function(e){switch(e.label){case 0:return this._enableAutoResend?[4,ve((function(){return f(t,void 0,void 0,(function(){var r,i,s,a,o,u;return p(this,(function(c){switch(c.label){case 0:return[4,this._fetchAllCachedPendingMessages()];case 1:r=c.sent();try{for(i=z(r),s=i.next();!s.done;s=i.next())(a=s.value).errorCode===0&&(this._logger.debug("cached pending message is not auto-resend registered. changing its sending status to failed: ",a.reqId),a.sendingStatus=ae.FAILED,a.errorCode=L.ACK_TIMEOUT,this._dispatcher.dispatch(new ge({messages:[a],source:ne.LOCAL_MESSAGE_FAILED})))}catch(l){o={error:l}}finally{try{s&&!s.done&&(u=i.return)&&u.call(i)}finally{if(o)throw o.error}}return[2]}}
2))}))}))]:[2];case 1:return e.sent(),[2]}}))}))},n.prototype.processAutoResendRegisteredPendingMessages=function(){return f(this,void 0,void 0,(function(){var t=this;return p(this,(function(e){switch(e.label){case 0:return[4,ve((function(){return f(t,void 0,void 0,(function(){var r,i,s,a,o,u,c,l;return p(this,(function(d){switch(d.label){case 0:return[4,this._fetchAllCachedPendingMessages()];case 1:r=d.sent();try{for(i=z(r),s=i.next();!s.done;s=i.next())a=s.value,this._enableAutoResend&&a.errorCode&&Dr(a.errorCode)&&(o=new Date().getTime(),u=a.createdAt+2592e5,!this._changePendingMessageToFailOnFirstConnection&&o<=u?this._autoResendQueue.map((function(_){return _.reqId})).indexOf(a.reqId)<0&&this._autoResendQueue.push(a):(this._changePendingMessageToFailOnFirstConnection?this._logger.debug("auto-resend registered pending message is not resent because the AI Agent module is loaded. changing its sending status to failed: ",a.reqId):this._logger.debug("auto-resend registered pending messaged expired. expiration date: ",new Date(u).toLocaleString()),a.sendingStatus=ae.FAILED,this._dispatcher.dispatch(new ge({messages:[a],source:ne.LOCAL_MESSAGE_FAILED}))))}catch(_){c={error:_}}finally{try{s&&!s.done&&(l=i.return)&&l.call(i)}finally{if(c)throw c.error}}return this._changePendingMessageToFailOnFirstConnection=!1,[2]}}))}))}))];case 1:return e.sent(),[2]}}))}))},n.prototype.completeCurrentAndProcessNextAutoResend=function(t){if(this._localCacheEnabled&&this._enableAutoResend&&
2(t.sendingStatus===ae.SUCCEEDED||t.sendingStatus===ae.FAILED&&!Dr(t.errorCode))){var e=this.indexOf(t);e>=0&&this._autoResendQueue.splice(e,1),e===0&&this._processNextAutoResend()}},n.prototype._fetchAllCachedPendingMessages=function(){return f(this,void 0,void 0,(function(){var t,e;return p(this,(function(r){switch(r.label){case 0:return t=sr.of(this._iid),(e=new vn).replyType=ze.ALL,[4,t.fetch({sendingStatus:ae.PENDING,backward:!0,filter:e})];case 1:return[2,r.sent()]}}))}))},n.prototype.indexOf=function(t){return this._autoResendQueue.length>0?this._autoResendQueue.map((function(e){return e.reqId})).indexOf(t.reqId):-1},n.prototype._processNextAutoResend=function(){return f(this,void 0,void 0,(function(){var t;return p(this,(function(e){if(this._localCacheEnabled&&this._enableAutoResend&&this._sdkState.appState==="foreground")try{this._autoResendQueue.length>0?(this._isProcessingAutoResend||(this._logger.debug("auto-resend queue started."),this._isProcessingAutoResend=!0),t=this._autoResendQueue[0],this._dispatcher.dispatch(new Df({message:t})),this._logger.debug("processing auto-resend for message request id: ",t.reqId)):(this._logger.debug("auto-resend queue finished."),this._isProcessingAutoResend=!1)}catch(r){this._logger.warn("process auto-resend error: ",r),this._isProcessingAutoResend=!1}return[2]}))}))},n})();(function(n){n[n.USER_BLOCK=20001]="USER_BLOCK",n[n.USER_UNBLOCK=2e4]="USER_UNBLOCK",n[n.FRIEND_DISCOVERED=20900]="FRIEND_DISCOVERED"})(as||(as={}));var wt,Eu=(function(){function n(t){this.category=t.cat,this.data=t.data}return n.getDataAsUserBlockEvent=function(t,e){var r=e.data,i=r.blocker,s=r.blockee;return{blocker:new G(t,i),blockee:new G(t,s)}},n.getDataAsFriendDiscoveredEvent=function(t,e){var r=e.data.friend_discoveries;return{friendDiscoveries:Array.isArray(r)?r.map((function(i){return new G(t,i)})):[]}},n})(),Uf=(function(n){function t(e){var r=e.configTs,i=n.call(this)||this;return i.configTs=r,i}return g(t,n),t})(Z),Mf=(function(n){function t(e,r,i){var s=n.call(this,e,"USEV",i)||this;return s.event=new Eu(i),s}return g(t,n),t})(we),Pf=(function(n){function t(e){var r=e.appConfigsInfo,i=e.configTs,s=n.call(this)||this;return s.appConfigsInfo={},s.configTs=0,s.appConfigsInfo=r,s.configTs=i,s}return g(t,n),t})(Z),xf=(function(n){function t(){return n.call(this)||this}return g(t,n),t})(Z);(function(n){n[n.IDLE=0]="IDLE",n[n.RUNNING=1]="RUNNING",n[n.END=2]="END"})(wt||(wt={}));var Ff=(function(n){function t(e,r,i,s){var a=n.call(this)||this;return a._state=wt.IDLE,a._retryCount=0,a._retryLimit=3,a.priority=0,a._worker=r,a}return g(t,n),Object.defineProperty(t.prototype,"isIdle",{get:function(){return this._state===wt.IDLE},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isRunning",{get:function(){return this._state===wt.RUNNING},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isDone",{get:function(){return this._state===wt.END},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"retryCount",{get:function(){return this._retryCount},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"retryLimit",{get:function(){return this._retryLimit},enumerable:!1,configurable:!0}),t.prototype._run=function(e){return f(this,void 0,void 0,(function(){var r,i;return p(this,(function(s){switch(s.label){case 0:if(!this.isRunning)return[3,4];s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this._worker(e)];case 2:return r=s.sent(),this._retryCount=0,this.dispatch("progress",r),r.hasNext?this._run(r.nextToken):this.end(),[3,4];case 3:return i=s.sent(),this.dispatch("error",i),this._retryCount<this._retryLimit?(this._retryCount++,this._run(e)):this.stop(),[3,4];case 4:return[2]}}
2))}))},t.prototype.start=function(e){this.isRunning||(this._state=wt.RUNNING,this._run(e))},t.prototype.stop=function(){this._state=wt.IDLE,this.dispatch("stop")},t.prototype.end=function(){this._state=wt.END,this.dispatch("end")},t})(mn),qf=function(n){return["-lastMessageUpdatedAt","-createdAt","syncIndex"]},xi=(function(n){function t(){return n!==null&&n.apply(this,arguments)||this}return g(t,n),t})(Z),zf=(function(n){function t(){return n!==null&&n.apply(this,arguments)||this}return g(t,n),t})(Z),wu=function(n){this.key=n.key,this.url=n.url},Iu=function(n){this.id=n.id,this.name=n.name,this.url=n.url,this.emojis=n.emojis?n.emojis.map((function(t){return new wu(t)})):[]},Bf=function(n){this.emojiHash=n.emoji_hash||"",this.emojiCategories=n.emoji_categories?n.emoji_categories.map((function(t){return new Iu(t)})):[]},jf={profileImage:void 0,profileUrl:void 0,nickname:void 0},Ja=function(n){return{v2:function(){return f(void 0,void 0,void 0,(function(){return p(this,(function(t){switch(t.label){case 0:return[4,n.commitSchema([{collectionName:Th,keyName:Sh,index:[Pi(xt.LATEST_LAST_MESSAGE),Pi(xt.CHRONOLOGICAL),Pi(xt.CHANNEL_NAME_ALPHABETICAL)]},{collectionName:ms,keyName:Ch,index:[nt(ye.CHANNEL_LATEST),nt(ye.NEWEST_CHILD_MESSAGE)]},{collectionName:yu,keyName:ff,index:[nt(ye.CHANNEL_LATEST),nt(ye.NEWEST_CHILD_MESSAGE)]},{collectionName:Nh,keyName:kh}])];case 1:return[2,t.sent()]}}))}))},v3:function(){return f(void 0,void 0,void 0,(function(){return p(this,(function(t){switch(t.label){case 0:return[4,n.commitSchema([{collectionName:Oh,keyName:Dh,index:[qf()]}])];case 1:return[2,t.sent()]}}))}))},v4:function(){return f(void 0,void 0,void 0,(function(){return p(this,(function(t){switch(t.label){case 0:return[4,n.commitSchema([{collectionName:vu,keyName:Ah,index:[hf()]}])];case 1:return[2,t.sent()]}}))}))},v5:function(){return f(void 0,void 0,void 0,(function(){return p(this,(function(t){switch(t.label){case 0:return[4,n.commitSchema([{collectionName:mu,keyName:Rh,index:[["-userId","-updatedAt"]]}])];case 1:return[2,t.sent()]}}))}))}}},eo=function(n){var t=new gu;return function(e,r){return f(void 0,void 0,void 0,(function(){var i,s,a,o;return p(this,(function(u){switch(u.label){case 0:switch(e){case 1:case 2:case 3:case 4:return[3,1];case 5:return[3,2];case 6:return[3,4];case 7:return[3,11]}return[3,15];case 1:return r(),[3,16];case 2:return[4,n.reset()];case 3:return u.sent(),r(),[3,16];case 4:return u.trys.push([4,9,,10]),i=Ja(n),s=i.v2,a=i.v3,o=i.v4,[4,s()];case 5:return u.sent(),[4,a()];case 6:return u.sent(),[4,o()];case 7:return u.sent(),[4,n.collection(ms).removeIf({where:{channelType:oe.OPEN}})];case 8:return u.sent(),[3,10];case 9:return u.sent(),t.warn("Failed to migrate to v2, v3, v4"),[3,10];case 10:return r(),[3,16];case 11:return u.trys.push([11,13,,14]),[4,(0,Ja(n).v5)()];case 12:return u.sent(),[3,14];case 13:return u.sent(),t.warn("Failed to migrate to v5"),[3,14];case 14:return r(),[3,16];case 15:r(),u.label=16;case 16:return[2]}}
2))}))}},Kf=function(){return typeof document<"u"?document.visibilityState:"visible"},Hf=(function(n){function t(e){var r=e.getVisibilityState,i=r===void 0?Kf:r,s=e.initialState,a=s===void 0?"visible":s,o=e.isEnabled,u=o===void 0||o,c=e.pauseCheckDelay,l=e.supportMultipleTabs,d=l!==void 0&&l,_=e.localCacheEnabled,h=_!==void 0&&_,v=n.call(this)||this;return v._currentVisibility="visible",v._activeTimestamp=0,v._storageKey="",v._onMessage=function(m){if(v.isActive){var y=m.data;if(y.tabId!==v._tabId&&y.type==="SB_ACTIVE_APP"){if(y.timestamp<=v._activeTimestamp)return;v._changeAppStateToInactive()}}},v._onStorage=function(m){if(v.isActive&&m.key===v._storageKey&&m.newValue)try{var y=JSON.parse(m.newValue);if(y.tabId===v._tabId||y.timestamp<=v._activeTimestamp)return;v._changeAppStateToInactive()}catch(b){console.warn("failed to parse active tab info from storage",b)}},v._toggleFocusState=function(){v.isActive||v._currentVisibility==="visible"&&v._changeAppStateToActive()},v._toggleStateByVisibilityState=function(){var m=v._getVisibilityState();if(m==="visible"&&v.dispatch("page_visible"),m==="visible"){if(v._currentVisibility==="hidden"){if(v.isActive)return;v._changeAppStateToActive(),v._dispatchAppStateEvent()}}else if(m==="hidden"&&v._currentVisibility==="visible"){if(!v.isActive)return;v._changeAppStateToInactive()}v._currentVisibility=m},v._dispatchAppStateEvent=function(){v.isActive?v.dispatch("resume"):(v._clearPauseTimer(),v._pauseCheckDelay&&(v._pauseDelayTimer=setTimeout((function(){v._pauseDelayTimer=void 0,v.dispatch("pause")}),v._pauseCheckDelay)))},v._dispatchLocalCacheEvent=function(){v.isActive?v.dispatch("enable_local_cache"):v.dispatch("disable_local_cache")},v._changeAppStateToActive=function(){if(v._clearPauseTimer(),v._activeTimestamp=Date.now(),v._currentState="ACTIVE",!v._supportMultipleTabs&&v._pauseCheckDelay||v._dispatchLocalCacheEvent(),v._supportMultipleTabs){var m={tabId:v._tabId,timestamp:v._activeTimestamp};v._broadcastChannel?v._broadcastChannel.postMessage(E({type:"SB_ACTIVE_APP"},m)):localStorage.setItem(v._storageKey,JSON.stringify(m))}},v._changeAppStateToInactive=function(){var m=v._getVisibilityState();v._currentState="INACTIVE",!v._supportMultipleTabs&&v._pauseCheckDelay||v._dispatchLocalCacheEvent(),m==="hidden"&&v._dispatchAppStateEvent()},v._clearPauseTimer=function(){v._pauseDelayTimer&&(clearTimeout(v._pauseDelayTimer),v._pauseDelayTimer=void 0)},v._getVisibilityState=i,v._isEnabled=u,v._supportMultipleTabs=!!h&&d,v._pauseCheckDelay=c,v._currentVisibility=a,v}return g(t,n),Object.defineProperty(t.prototype,"isActive",{get:function(){return this._currentState==="ACTIVE"},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"currentVisibility",{get:function(){return this._currentVisibility},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isAvailableBroadCast",{get:function(){return typeof BroadcastChannel<"u"},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isAvailable",{get:function(){return typeof window<"u"&&!!window.addEventListener&&!!window.removeEventListener},enumerable:!1,configurable:!0}),t.prototype.start=function(e){var r=e.appId,i=e.userId,s=e.backgroundConnectionCloseTimeout;if(this._isEnabled&&this.isAvailable){if(s!==void 0&&s!==-1&&(this._pauseCheckDelay=s===0?10:1e3*s),this._supportMultipleTabs){var a="sendbird-".concat(r,"-").concat(i);if(this._tabId="".concat(a,"-").concat(st()),this._storageKey="".concat("sendbird-active-app:").concat(r,"-").concat(i),this.isAvailableBroadCast)try{this._broadcastChannel=new BroadcastChannel(a),this._broadcastChannel.onmessage=this._onMessage}catch(o){window.addEventListener("storage",this._onStorage,{capture:!0})}else window.addEventListener("storage",this._onStorage,{capture:!0});window.addEventListener("focus",this._toggleFocusState,{capture:!0}),window.addEventListener("pointerdown",this._toggleFocusState,{capture:!0})}window.addEventListener("visibilitychange",this._toggleStateByVisibilityState,{capture:!0}),this.currentVisibility!=="hidden"?this._changeAppStateToActive():this._currentState="INACTIVE"}},t.prototype.stop=function(){this._isEnabled&&this.isAvailable&&(this._clearPauseTimer(),this._supportMultipleTabs&&(this._broadcastChannel?(this._broadcastChannel.onmessage=null,this._broadcastChannel.close(),this._broadcastChannel=void 0):window.removeEventListener("storage",this._onStorage,{capture:!0}),window.removeEventListener("focus",this._toggleFocusState,{capture:!0}),window.removeEventListener("pointerdown",this._toggleFocusState,{capture:!0})),window.removeEventListener("visibilitychange",this._toggleStateByVisibilityState,{capture:!0}),this._tabId="",this._currentState="INACTIVE",this._activeTimestamp=0)},t})(mn),Vf=(function(){function n(t){var e=t.logger,r=t.connectionDelegate,i=r===void 0?null:r,s=this;this._onlineWorker=function(){var a;return(a=s.connectionDelegate)===null||a===void 0?void 0:a.reconnect()},this._offlineWorker=function(){var a;return(a=s.connectionDelegate)===null||a===void 0?void 0:a.disconnect()}
2,this.unsubscribes=[],this._onlineListener=function(a){if(s.isAvailableOnWeb)return window.addEventListener("online",a),function(){return window.removeEventListener("online",a,!1)}},this._offlineListener=function(a){if(s.isAvailableOnWeb)return window.addEventListener("offline",a),function(){return window.removeEventListener("offline",a,!1)}},this.logger=e,i&&(this.connectionDelegate=i)}return Object.defineProperty(n.prototype,"isAvailableOnWeb",{get:function(){return typeof window<"u"&&!!window.addEventListener&&"ononline"in window&&"onoffline"in window&&typeof navigator<"u"&&navigator.onLine!==void 0},enumerable:!1,configurable:!0}),n.prototype.setOnlineListener=function(t){t&&typeof t=="function"&&(this._onlineListener=t)},n.prototype.setOfflineListener=function(t){t&&typeof t=="function"&&(this._offlineListener=t)},n.prototype.start=function(){this.unsubscribes=[this._onlineListener(this._onlineWorker),this._offlineListener(this._offlineWorker)]},n.prototype.stop=function(){var t=this;this.unsubscribes.forEach((function(e){try{e==null||e()}catch(r){t.logger.warn(r.message)}})),this.unsubscribes=[]},n.prototype.isOnline=function(){return f(this,void 0,void 0,(function(){return p(this,(function(t){return this.isAvailableOnWeb?[2,navigator.onLine]:[2,new Promise((function(e){fetch("https://www.google.com",{method:k.GET,mode:"no-cors"}).then((function(){return e(!0)})).catch((function(){return e(!1)}))}))]}))}))},n})(),Gf=(function(n){function t(e){var r,i=this;return(i=n.call(this)||this).method=k.GET,i.path=Vu,i.params=M(B({ts:typeof e.token=="number"?e.token:void 0,token:typeof e.token=="string"?e.token:void 0,limit:(r=e.limit)!==null&&r!==void 0?r:100})),i}return g(t,n),t})(O),Qf=(function(n){function t(e,r){var i=n.call(this,e,r)||this;return i.configs=r.configs,i.hasMore=r.has_more,i.nextToken=r.next,i.ts=r.ts,i}return g(t,n),t})(U),$f="explicit_disconnect",Wf="explicit_disconnect_websocket",Yf="session_invalidated",Zf="app_id_changed",to=(function(n){function t(e){var r=e.userId,i=e.nickname,s=e.profileUrl,a=e.profileImage,o=e.preferredLanguages,u=n.call(this)||this;return u.method=k.PUT,u.path="".concat(W,"/").concat(encodeURIComponent(r)),u.params=M(B({nickname:i,profile_url:s,profile_file:a,preferred_languages:o})),u}return g(t,n),t})(O),no=(function(n){function t(e,r){var i=n.call(this,e,r)||this;return i.user=new G(e,E({},r)),i}return g(t,n),t})(U),Xf=(function(n){function t(e){var r=e.userId,i=e.token,s=e.deviceOS,a=e.deviceManufacturer,o=e.systemPushEnabled,u=e.unique,c=n.call(this)||this;return c.method=k.POST,c.path="".concat(W,"/").concat(encodeURIComponent(r),"/push/apns"),c.params=M({apns_device_token:i,always_push:!0,device_os:s,device_manufacturer:a,system_push_enabled:o,is_unique:u}),c}return g(t,n),t})(O),Jf=(function(n){function t(e,r){var i=n.call(this,e,r)||this;return i.lastDeletedAt=r.device_token_last_deleted_at,i}return g(t,n),t})(U),ep=(function(n){function t(e){var r=e.userId,i=e.token,s=e.deviceOS,a=e.deviceManufacturer,o=e.systemPushEnabled,u=e.unique,c=n.call(this)||this;return c.method=k.POST,c.path="".concat(W,"/").concat(encodeURIComponent(r),"/push/gcm"),c.params=M({gcm_reg_token:i,always_push:!0,device_os:s,device_manufacturer:a,system_push_enabled:o,is_unique:u}),c}return g(t,n),t})(O),tp=(function(n){function t(e,r){var i=n.call(this,e,r)||this;return i.lastDeletedAt=r.device_token_last_deleted_at,i}return g(t,n),t})(U),np=(function(n){function t(e){var r=e.userId,i=e.token,s=n.call(this)||this;return s.method=k.DELETE,s.path="".concat(W,"/").concat(encodeURIComponent(r),"/push/apns/").concat(encodeURIComponent(i)),s}return g(t,n),t})(O),rp=(function(n){function t(e,r){var i=n.call(this,e,r)||this;return i.token=r.token,i.user=new G(e,r.user),i.lastDeletedAt=r.device_token_last_deleted_at,i}return g(t,n),t})(U),ip=(function(n){function t(e){var r=e.userId,i=e.token,s=n.call(this)||this;return s.method=k.DELETE,s.path="".concat(W,"/").concat(encodeURIComponent(r),"/push/gcm/").concat(encodeURIComponent(i)),s}return g(t,n),t})(O),sp=(function(n){function t(e,r){var i=n.call(this,e,r)||this;return i.token=r.token,i.user=new G(e,r.user),i.lastDeletedAt=r.device_token_last_deleted_at,i}return g(t,n),t})(U),ap=(function(n){function t(e){var r=e.userId,i=n.call(this)||this;return i.method=k.DELETE,i.path="".concat(W,"/").concat(encodeURIComponent(r),"/push/apns"),i}return g(t,n),t})(O),op=(function(n){function t(e,r){var i=n.call(this,e,r)||this;return i.type=r.type?Ce[r.type.toLowerCase()]:Ce.UNKNOWN,i.user=new G(e,r.user),i.lastDeletedAt=r.device_token_last_deleted_at,i}return g(t,n),t})(U),up=(function(n){function t(e){var r=e.userId,i=n.call(this)||this;return i.method=k.DELETE,i.path="".concat(W,"/").concat(encodeURIComponent(r),"/push/gcm"),i}return g(t,n),t})(O),cp=(function(n){function t(e,r){var i=n.call(this,e,r)||this;return i.type=r.type?Ce[r.type.toLowerCase()]:Ce.UNKNOWN,i.user=new G(e,r.user),i.lastDeletedAt=r.device_token_last_deleted_at,i}return g(t,n),t})(U),lp=(function(n){function t(e){var r=e.userId,i=e.type,s=e.token,a=e.ts,o=n.call(this)||this;return o.method=k.GET,o.path="".concat(W,"/").concat(encodeURIComponent(r),"/push/").concat(encodeURIComponent(i),"/device_tokens"),o.params={created_ts:a,token:s},o}return g(t,n),t})(O),dp=(function(n){function t(e,r){var i=n.call(this,e,r)||this;return i.pushTokens={type:r.type?Ce[r.type.toLowerCase()]:Ce.UNKNOWN,deviceTokens:r.device_tokens,hasMore:r.has_more,token:r.token},i}return g(t,n),t})(U),hp=(function(n){function t(e){var r=e.userId,i=n.call(this)||this;return i.method=k.GET,i.path="".concat(W,"/").concat(encodeURIComponent(r),"/channel_invitation_preference"),i}return g(t,n),t})(O),fp=(function(n){function t(e,r){var i=n.call(this,e,r)||this;return i.autoAccept=r.auto_accept,i}return g(t,n),t})(U),pp=(function(n){function t(e){var r=e.userId,i=e.willAutoAccept,s=n.call(this)||this;return s.method=k.PUT,s.path="".concat(W,"/").concat(encodeURIComponent(r),"/channel_invitation_preference"),s.params={auto_accept:i},s}return g(t,n),t})(O),_p=(function(n){function t(e,r){var i=n.call(this,e,r)||this;return i.autoAccept=r.auto_accept,i}return g(t,n),t})(U),vp=(function(n){function t(e){var r=e.userId,i=n.call(this)||this;return i.method=k.GET,i.path="".concat(W,"/").concat(encodeURIComponent(r),"/push_preference"),i}return g(t,n),t})(O),mp=(function(n){function t(e,r){var i=n.call(this,e,r)||this;return i.preference={doNotDisturbOn:r.do_not_disturb,startHour:r.start_hour,startMin:r.start_min,endHour:r.end_hour,endMin:r.end_min,timezone:r.timezone},i}return g(t,n),t})(U),gp=(function(n){function t(e){var r=e.userId,i=e.doNotDisturbOn,s=e.startHour,a=e.startMin,o=e.endHour,u=e.endMin,c=e.timezone,l=n.call(this)||this;return l.method=k.PUT,l.path="".concat(W,"/").concat(encodeURIComponent(r),"/push_preference"),l.params={do_n
2ot_disturb:i,start_hour:s,start_min:a,end_hour:o,end_min:u,timezone:c},l}return g(t,n),t})(O),yp=(function(n){function t(e,r){var i=n.call(this,e,r)||this;return i.preference={doNotDisturbOn:r.do_not_disturb,startHour:r.start_hour,startMin:r.start_min,endHour:r.end_hour,endMin:r.end_min,timezone:r.timezone},i}return g(t,n),t})(U),bp=(function(n){function t(e){var r=e.userId,i=n.call(this)||this;return i.method=k.GET,i.path="".concat(W,"/").concat(encodeURIComponent(r),"/push_preference"),i}return g(t,n),t})(O),Ep=(function(n){function t(e,r){var i=n.call(this,e,r)||this;return i.snoozePeriod={isSnoozeOn:r.snooze_enabled},typeof r.snooze_start_ts=="number"&&(i.snoozePeriod.startTs=r.snooze_start_ts),typeof r.snooze_end_ts=="number"&&(i.snoozePeriod.endTs=r.snooze_end_ts),i}return g(t,n),t})(U),wp=(function(n){function t(e){var r=e.userId,i=e.snoozeOn,s=e.startTs,a=e.endTs,o=n.call(this)||this;return o.method=k.PUT,o.path="".concat(W,"/").concat(encodeURIComponent(r),"/push_preference"),o.params={snooze_enabled:i,snooze_start_ts:s,snooze_end_ts:a},o}return g(t,n),t})(O),Ip=(function(n){function t(e,r){var i=n.call(this,e,r)||this;return i.snoozePeriod={isSnoozeOn:r.snooze_enabled},typeof r.snooze_start_ts=="number"&&(i.snoozePeriod.startTs=r.snooze_start_ts),typeof r.snooze_end_ts=="number"&&(i.snoozePeriod.endTs=r.snooze_end_ts),i}return g(t,n),t})(U),Tp=(function(n){function t(e){var r=e.userId,i=e.blockedUserId,s=n.call(this)||this;return s.method=k.POST,s.path="".concat(W,"/").concat(encodeURIComponent(r),"/block"),s.params={target_id:i},s}return g(t,n),t})(O);(function(n){function t(e,r){var i=n.call(this,e,r)||this;return i.user=new G(e,r),i}g(t,n)})(U);var Sp=(function(n){function t(e){var r=e.userId,i=e.unblockedUserId,s=n.call(this)||this;return s.method=k.DELETE,s.path="".concat(W,"/").concat(encodeURIComponent(r),"/block/").concat(encodeURIComponent(i)),s}return g(t,n),t})(O);(function(n){function t(){return n!==null&&n.apply(this,arguments)||this}g(t,n)})(U);var Cp=(function(n){function t(e){var r=e.userId,i=n.call(this)||this;return i.method=k.GET,i.path="".concat(W,"/").concat(encodeURIComponent(r),"/push_preference"),i}return g(t,n),t})(O),Ap=(function(n){function t(e,r){var i=n.call(this,e,r)||this;return i.pushTriggerOption=r.push_trigger_option,i}return g(t,n),t})(U),Np=(function(n){function t(e){var r=e.userId,i=e.pushTriggerOption,s=n.call(this)||this;return s.method=k.PUT,s.path="".concat(W,"/").concat(encodeURIComponent(r),"/push_preference"),s.params={push_trigger_option:i},s}return g(t,n),t})(O),kp=(function(n){function t(e,r){var i=n.call(this,e,r)||this;return i.pushTriggerOption=r.push_trigger_option,i}return g(t,n),t})(U),Op=(function(n){function t(e){var r=e.userId,i=n.call(this)||this;return i.method=k.GET,i.path="".concat(W,"/").concat(encodeURIComponent(r),"/push/template"),i}return g(t,n),t})(O),Dp=(function(n){function t(e,r){var i=n.call(this,e,r)||this;return i.name=r.name,i}return g(t,n),t})(U),Rp=(function(n){function t(e){var r=e.userId,i=e.templateName,s=n.call(this)||this;return s.method=k.PUT,s.path="".concat(W,"/").concat(encodeURIComponent(r),"/push/template"),s.params={name:i},s}return g(t,n),t})(O),Lp=(function(n){function t(e,r){var i=n.call(this,e,r)||this;return i.name=r.name,i}return g(t,n),t})(U),Up=(function(n){function t(e){var r=e.userId,i=e.token,s=n.call(this)||this;return s.method=k.GET,s.path="".concat(W,"/").concat(encodeURIComponent(r),"/friends/changelogs"),s.params={token:i},s}return g(t,n),t})(O),Mp=(function(n){function t(e,r){var i=n.call(this,e,r)||this;return i.changelogs={addedUsers:r.added.map((function(s){return new G(e,s)})),updatedUsers:r.updated.map((function(s){return new G(e,s)})),deletedUserIds:r.deleted,hasMore:r.has_more,token:r.next},i}return g(t,n),t})(U),Pp=(function(n){function t(e){var r=e.userId,i=e.discoveries,s=n.call(this)||this;return s.method=k.PUT,s.path="".concat(W,"/").concat(encodeURIComponent(r),"/friend_discoveries"),s.params={friend_discoveries:i.map((function(a){return{friend_discovery_key:a.friendDiscoveryKey,friend_name:a.friendName}}))},s}return g(t,n),t})(O),xp=(function(n){function t(e,r){var i=n.call(this,e,r)||this;return i.friendDiscoveryRequestId=r.friend_discovery_request_id,i}return g(t,n),t})(U),Fp=(function(n){function t(e){var r=e.userId,i=e.discoveryKeys,s=n.call(this)||this;return s.method=k.DELETE,s.path="".concat(W,"/").concat(encodeURIComponent(r),"/friend_discoveries"),s.params={friend_discovery_keys:i},s}return g(t,n),t})(O);(function(n){function t(){return n!==null&&n.apply(this,arguments)||this}g(t,n)})(U);var qp=(function(n){function t(e){var r=e.userId,i=e.userIds,s=n.call(this)||this;return s.method=k.POST,s.path="".concat(W,"/").concat(encodeURIComponent(r),"/friends"),s.params={user_ids:i},s}return g(t,n),t})(O),zp=(function(n){function t(e,r){var i=n.call(this,e,r)||this;return i.users=r.users.map((function(s){return new G(e,s)})),i}return g(t,n),t})(U),Bp=(function(n){function t(e){var r=e.userId,i=e.userIds,s=n.call(this)||this;return s.method=k.DELETE,s.path="".concat(W,"/").concat(encodeURIComponent(r),"/friends"),s.params={user_ids:i},s}return g(t,n),t})(O);(function(n){function t(){return n!==null&&n.apply(this,arguments)||this}g(t,n)})(U);var jp=(function(n){function t(e){var r=e.userId,i=n.call(this)||this;return i.method=k.GET,i.path="".concat(W,"/").concat(encodeURIComponent(r),"/allow_friend_discovery"),i.params={},i}return g(t,n),t})(O),Kp=(function(n){function t(e,r){var i=n.call(this,e,r)||this;return i.allowFriendDiscovery=r.allow_friend_discovery,i}return g(t,n),t})(U),Hp=(function(n){function t(e){var r=e.userId,i=e.allowFriendDiscovery,s=n.call(this)||this;return s.method=k.PUT,s.path="".concat(W,"/").concat(encodeURIComponent(r),"/allow_friend_discovery"),s.params={allow_friend_discovery:i},s}return g(t,n),t})(O);(function(n){function t(){return n!==null&&n.apply(this,arguments)||this}g(t,n)})(U);var $r,Vp=(function(n){function t(e){var r=e.doNotDisturbOn,i=r===void 0||r,s=e.userId,a=e.weeklyDndSchedules,o=e.timezone,u=n.call(this)||this;return u.method=k.PUT,u.path="".concat(W,"/").concat(encodeURIComponent(s),"/push_preference"),u.params=M({do_not_disturb:i,dnd_schedules:a?ii.payloadify(a):[],timezone:o}),u}return g(t,n),t})(O),Gp=(function(n){function t(e,r){var i,s=this;return(s=n.call(this,e,r)||this).preference={doNotDisturbOn:r.do_not_disturb,dndSchedules:ii.buildDndScheduleFromPayload((i=r.dnd_schedules)!==null&&i!==void 0?i:[]),timezone:r.timezone},s}return g(t,n),t})(U),Qp=(function(n){function t(e){var r=e.userId,i=n.call(this)||this;return i.method=k.GET,i.path="".concat(W,"/").concat(encodeURIComponent(r),"/push_preference"),i}return g(t,n),t})(O),$p=(function(n){function t(e,r){var i,s=this;return(s=n.call(this,e,r)||this).preference={doNotDisturbOn:r.do_not_disturb,dndSchedules:ii.buildDndScheduleFromPayload((i=r.dnd_schedules)!==null&&i!==void 0?i:[]),timezone:r.timezone},s}return g(t,n),t})(U),Wp=(function(n){function t(e){var r=e.userId,i=n.call(this)||this;return i.method=k.DELETE,i.path="".concat(W,"/").concat(encodeURIComponent(r),"/push_preference"),i}return g(t,n),t})(O),Yp=(function(n){function t(){var e=n.call(this)||this;return e.method=k.GET,e.path=lo,e}return g(t,n),t})(O),Zp=(function(n){function t(e,r){var i=n.call(this,e,r)||this;return i.emojiContainer=new Bf(r),i}return g(t,n),t})(U),Xp=(function(n){function t(e){var r=e.categoryId,i=n.call(this)||this;return i.method=k.GET,i.path="".concat(lo,"/").concat(r),i}return g(t,n),t})(O),Jp=(function(n){function t(e,r){var i=n.call(this,e,r)||this;return i.emojiCategory=new Iu(r),i}return g(t,n),t})(U),e_=(function(n){function t(e){var r=e.key,i=n.call(this)||this;return i.method=k.GET,i.path="".concat(Fu,"/").concat(r),i}return g(t,n),t})(O),t_=(function(n){function t(e,r){var i=n.call(this,e,r)||this;return i.emoji=new wu(r),i}return g(t,n),t})(U),n_=(function(n){function t(){var e=n.call(this)||this;return e.method=k.GET,e.path="".concat(qu),e}return g(t,n),t})(O),r_=(function(n){function t(e,r){var i,s=this,a=r!=null?r:{};return(s=n.call(this,e,r)||this).uikitConfiguration={string:JSON.stringify(a),json:a},s.updatedAt=(i=r==null?void 0:r.updated_at)!==null&&i!==void 0?i:0,s}return g(t,n),t})(U);(function(n){n.DELIVERED="DELIVERED",n.CLICKED="CLICKED"})($r||($r={}));var $e,ro=(function(n){function t(e){var r=e.deviceToken,i=e.pushTrackingId,s=e.messageId,a=e.allowedPushNotification,o=e.channelKe
2y,u=e.templateKey,c=e.eventType,l=e.notificationEventDeadline,d=n.call(this)||this;return d.method=k.POST,d.path=Ku,d.params=M({device_token:r,push_tracking_id:i,message_id:s,allowed_push_notification:a,channel_key:o,template_key:u,event_type:c,notification_event_deadline:l}),d}return g(t,n),t})(O),F_=(function(){function n(t,e,r){var i=this;this._storeInitialized=!1,this._iid=t,this.options=e;var s=C.of(t),a=s.sdkState,o=s.cacheContext,u=s.dispatcher,c=s.sessionManager,l=s.requestQueue,d=s.logger,_=s.userEventHandlers,h=s.appStateToggleEnabled,v=s.supportMultipleTabs;this._onlineDetector=new Vf({logger:d,connectionDelegate:{reconnect:function(){return f(i,void 0,void 0,(function(){var y,b,w,I,A,D;return p(this,(function(N){switch(N.label){case 0:if(y=C.of(t),b=y.sdkState,w=y.connectionManager,(I=y.sessionManager).session.hasSession)return[3,5];N.label=1;case 1:return N.trys.push([1,3,,4]),[4,w.connect(I.session.authToken)];case 2:return N.sent(),[3,4];case 3:if(A=N.sent(),tt(A))throw A;return d.debug("connect failed by reconnect event = ",A),[3,4];case 4:return[3,9];case 5:if(b.appState!=="foreground")return[3,9];N.label=6;case 6:return N.trys.push([6,8,,9]),[4,w.resetAndReconnect()];case 7:return N.sent(),[3,9];case 8:if(D=N.sent(),tt(D))throw D;return d.debug("resetAndReconnect failed by reconnect event = ",D),[3,9];case 9:return u.dispatch(new xi),[2]}}))}))},disconnect:function(){ve((function(){return f(i,void 0,void 0,(function(){var y,b,w;return p(this,(function(I){switch(I.label){case 0:return y=C.of(t),b=y.connectionManager,w=y.dispatcher,[4,b.disconnect()];case 1:return I.sent(),w.dispatch(new St(new de({type:te.WEBSOCKET_DISCONNECT,data:{success:!0,error_code:L.NETWORK_ERROR,error_description:"cause=network_closed"}}))),[2]}}))}))}))}}});var m=new Lf(t,{localCacheEnabled:o.localCacheEnabled,enableAutoResend:o.localCacheConfig.enableAutoResend,hasAiAgentModule:r.some((function(y){return y.name==="aiAgent"})),dispatcher:u,sdkState:a,logger:d});r.forEach((function(y){y.init(t,{sdkState:a,cacheContext:o,dispatcher:u,sessionManager:c,requestQueue:l,logger:d,onlineDetector:i._onlineDetector}),i[y.name]=y})),this._appStateChangeDetector=new Hf({isEnabled:h,supportMultipleTabs:v,localCacheEnabled:o.localCacheEnabled}),this._appStateChangeDetector.on("resume",(function(){d.debug("the page resumes from freeze"),i.setForegroundState()})).on("pause",(function(){d.debug("the page freezes"),i.setBackgroundState()})).on("enable_local_cache",(function(){d.debug("the local cache is enabled because the page is active"),o.localCacheEnabled=!0,i._setAppActiveState(!0),a.appState==="foreground"&&u.dispatch(new xf)})).on("disable_local_cache",(function(){d.debug("the local cache is disabled because the page is inactive"),o.localCacheEnabled=!1,i._setAppActiveState(!1)})).on("page_visible",(function(){i.setForegroundState()})),u.on((function(y){var b;if(y instanceof yn)y.stateType===X.CONNECTED&&m.processNonAutoResendRegisteredPendingMessages();else if(y instanceof we){if(y.code==="USEV"){var w=y.as(Mf).event;if(w.category===as.FRIEND_DISCOVERED){var I=Eu.getDataAsFriendDiscoveredEvent(t,w).friendDiscoveries;ue((function(){return f(i,void 0,void 0,(function(){return p(this,(function(F){return[2,_.forEach((function(q){q.onFriendsDiscovered&&q.onFriendsDiscovered(I)}))]}))}))}))}}}else if(y instanceof Fo){var A=C.of(i._iid).subscribedUnreadMessageCount,D=!1,N=y.ts;typeof N=="number"&&N>A.ts&&(A.all!==y.all&&(D=!0),A.all=y.all>=0?y.all:0,y.customTypes&&Object.keys(y.customTypes).forEach((function(F){A.customTypes[F]!==y.customTypes[F]&&
2(D=!0),A.customTypes[F]=y.customTypes[F]})),D=D&&A.ts>0,A.ts=N),D&&ue((function(){return f(i,void 0,void 0,(function(){return p(this,(function(F){return[2,_.forEach((function(q){q.onTotalUnreadMessageCountChanged&&q.onTotalUnreadMessageCountChanged({groupChannelCount:A.all,feedChannelCount:A.feed,customTypeUnreadCount:A.customTypes}),q.onTotalUnreadMessageCountUpdated&&q.onTotalUnreadMessageCountUpdated(A.all,A.customTypes)}))]}))}))}))}else if(y instanceof Bo)o.preference.set(i._getUserProfileCacheKey(a.userId),Yi.payloadify(y.userProfile)),!((b=y.userProfile.appInfo.notificationInfo)===null||b===void 0)&&b.isEnabled&&o.preference.set(rl(i.appId),{value:!0});else if(y instanceof Ko)y.configSyncNeeded&&ve((function(){return f(i,void 0,void 0,(function(){return p(this,(function(F){switch(F.label){case 0:return[4,this._getAppConfigsInfo()];case 1:return F.sent(),[2]}}))}))}));else if(y instanceof Uf)o.preference.set(jr(i.appId),{configTs:y.configTs});else if(y instanceof dn)y.error&&y.error.isSessionInvalidatedError&&(d.debug("session revoked."),i._internalDisconnect(y.error));else if(y instanceof Ho)switch(y.event){case"resume":i.setForegroundState();break;case"pause":i.setBackgroundState()}}))}return n.init=function(t){var e=t.appId,r=t.appVersion,i=t.modules,s=i===void 0?[]:i,a=t.options,o=a===void 0?new ao:a,u=t.debugMode,c=u!==void 0&&u,l=t.customApiHost,d=t.customWebSocketHost,_=t.newInstance,h=_!==void 0&&_,v=t.logLevel,m=t.localCacheEnabled,y=m!==void 0&&m,b=t.localCacheConfig,w=b===void 0?new uo:b,I=t.localCacheEncryption,A=t.supportMultipleTabs,D=A!==void 0&&A,N=t.useAsyncStorageStore,F=N===void 0?null:N,q=t.useMMKVStorageStore,x=q===void 0?null:q,H=t.appStateToggleEnabled,j=H===void 0||H;if(R(S("string",e)&&e.length>0).throw(T.invalidParameters),$e&&!h&&$e.appId!==e&&$e._release(),!$e||h){var P="su-".concat(st()),ce=I!=null?I:{encrypt:function(At){return At},decrypt:function(At){return At}},Me=new gu;Me.level=v!=null?v:Tt.WARN;var Pe=new Vt({encryption:ce});c||(Pr()?x?Pe=new cf({MMKV:x,encryption:ce}):F&&(Pe=new uf({AsyncStorage:F,encryption:ce}),Me.warn("AsyncStorage store is deprecated due to the small size limit. Please use MMKVStorage store instead.")):Pe=new of({encryption:ce})),new C(P,{appId:e,appVersion:r,options:o,apiHost:l!=null?l:"https://api-".concat(e,".sendbird.com"),websocketHost:d!=null?d:"wss://ws-".concat(e,".sendbird.com"),store:Pe,encryption:ce,logger:Me,localCacheEnabled:y,localCacheConfig:w,debugMode:c,appStateToggleEnabled:j,supportMultipleTabs:D});var En=[new kf,new Of],wn=new n(P,o,V(V([],K(s),!1),K(En),!1));return $e||($e=wn),wn}return $e},Object.defineProperty(n,"instance",{get:function(){return $e},enumerable:!1,configurable:!0}),Object.defineProperty(n,"version",{get:function(){return io},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"appId",{get:function(){return C.of(this._iid).sdkState.appId},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"appInfo",{get:function(){var t=C.of(this._iid).appInfo;return t!=null?t:null},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"appVersion",{get:function(){var t;return(t=C.of(this._iid).sdkState.appVersion)!==null&&t!==void 0?t:""},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"debugMode",{get:function(){return!!C.of(this._iid).debugMode},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"logLevel",{get:function(){return C.of(this._iid).logger.level},set:function(t){C.of(this._iid).logger.level=t},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isCacheEnabled",{get:function(){return C.of(this._iid).cacheContext.localCacheEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"localCacheConfig",{get:function(){var t=C.of(this._iid).cacheContext;return t.localCacheEnabled?t.localCacheConfig:null},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"ekey",{get:function(){return C.of(this._iid).sessionManager.ekey},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"currentUser",{get:function(){var t;return(t=C.of(this._iid).sessionManager.currentUser)!==null&&t!==void 0?t:null}
2,enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"connectionState",{get:function(){var t=C.of(this._iid).connectionManager;return t.isConnected?et.OPEN:t.isConnecting?et.CONNECTING:et.CLOSED},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"lastConnectedAt",{get:function(){var t=C.of(this._iid),e=t.connectedAt;return t.connectionManager.isConnected?e:0},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"fcmPushToken",{get:function(){var t;return(t=this._fcmPushToken)!==null&&t!==void 0?t:null},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"apnsPushToken",{get:function(){var t;return(t=this._apnsPushToken)!==null&&t!==void 0?t:null},enumerable:!1,configurable:!0}),n.prototype._getNestDBVersion=function(){return 8},n.prototype._getPreferenceVersion=function(){return 9},n.prototype._getPreferenceCacheKey=function(t){return"sendbird@".concat(this.appId,"/").concat(t,".pref")},n.prototype._getUserProfileCacheKey=function(t){return"sendbird@".concat(this.appId,"/").concat(t,".profile")},n.prototype._internalDisconnect=function(t){return f(this,void 0,void 0,(function(){var e,r,i,s;return p(this,(function(a){switch(a.label){case 0:return e=C.of(this._iid),r=e.connectionManager,i=e.sdkState,s=e.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),s.cancelAll(t?Yf:$f),[4,r.logout(t)];case 1:return a.sent(),[4,this.clearCachedData()];case 2:return a.sent(),i.appState="foreground",i.isAppActive=!1,[2]}}))}))},n.prototype._getAppConfigsInfo=function(){return f(this,void 0,void 0,(function(){var t,e,r,i,s,a,o,u,c=this;return p(this,(function(l){switch(l.label){case 0:return t=C.of(this._iid),e=t.requestQueue,r=t.dispatcher,i=t.cacheContext,s=t.sdkState,a={}
2,[4,i.preference.get(jr(s.appId))];case 1:return(u=l.sent())&&(o=u.configTs),new Ff("appConfigsInfo",(function(d){return f(c,void 0,void 0,(function(){var _,h,v,m,y,b,w,I;return p(this,(function(A){switch(A.label){case 0:return _={hasNext:!0,nextToken:d},h=new Gf({token:d}),[4,e.send(h)];case 1:return v=A.sent(),m=v.as(Qf),y=m.configs,b=m.hasMore,w=m.nextToken,I=m.ts,Object.keys(y).forEach((function(D){a[D]=y[D]})),_.hasNext=b,_.nextToken=w,b||r.dispatch(new Pf({appConfigsInfo:a,configTs:I})),[2,_]}}))}))})).start(o),[2]}}))}))},n.prototype.getMemoryStoreForDebugging=function(){var t=C.of(this._iid),e=t.debugMode,r=t.cacheContext;if(e)return r.store instanceof Vt?r.store:null;throw T.debugModeRequired},n.prototype.addExtension=function(t,e){var r=C.of(this._iid).sdkState;["sb_uikit","sb_syncmanager","device-os-platform"].indexOf(t)>-1&&r.extensions&&(r.extensions[t]=e)},n.prototype.addSendbirdExtensions=function(t,e,r){var i,s,a=C.of(this._iid),o=a.logger,u=a.sdkState,c=new RegExp(Yu);if(t.length===0)return o.debug("sb.addSendbirdExtensions() has failed because the given sendbirdExtensions is empty."),!1;if(t.find((function(m){return!c.test(m.version)})))return o.debug("sb.addSendbirdExtensions() has failed because the given version did not satisfy the SemVer specification."),!1;if(r)try{for(var l=z(Object.entries(r)),d=l.next();!d.done;d=l.next()){var _=K(d.value,2),h=_[0],v=_[1];if(/&|=/.test(h)||/&|=/.test(v))return o.debug("sb.addSendbirdExtensions() has failed because the given customData includes at least one invalid character: = or &."),!1}}catch(m){i={error:m}}finally{try{d&&!d.done&&(s=l.return)&&s.call(l)}finally{if(i)throw i.error}}return u.sendbirdRuntimeEnvironment={sendbirdExtensions:t,deviceOS:e,customData:r},!0},n.prototype.setOnlineListener=function(t){this._onlineDetector.setOnlineListener(t)},n.prototype.setOfflineListener=function(t){this._onlineDetector.setOfflineListener(t)},n.prototype._safeInitializeStore=function(t){return f(this,void 0,void 0,(function(){var e;return p(this,(function(r){switch(r.label){case 0:e=C.of(this._iid).cacheContext,r.label=1;case 1:return r.trys.push([1,3,,5]),[4,e.store.init(t)];case 2:return r.sent(),this._storeInitialized=!0,[3,5];case 3:return r.sent(),e.replaceStore(new Vt),[4,this._safeInitializeStore(t)];case 4:return r.sent(),[3,5];case 5:return[2]}}
2))}))},n.prototype.initializeCache=function(t){return f(this,void 0,void 0,(function(){var e,r,i,s,a,o,u,c,l;return p(this,(function(d){switch(d.label){case 0:if(e=C.of(this._iid),r=e.sdkState,i=e.cacheContext,s=e.dispatcher,a=e.logger,r.userId&&r.userId===t)return[3,13];o="sendbird@".concat(r.appId,"/").concat(t,".db"),d.label=1;case 1:return d.trys.push([1,9,11,13]),i.localCacheEnabled?i.nestdb&&i.nestdb.state!==ht.CLOSED&&i.nestdb.name===o?[3,3]:(u="sendbird@".concat(r.appId,"/").concat(t,".db"),(c=i.nestdb=new lf({name:u,version:this._getNestDBVersion(),store:i.store,config:new ir({dbname:u,cacheLimit:64,itemSizeLimit:61440})})).on("upgrade",eo(c)),c.on("storeReplaced",(function(_){i.replaceStore(_),i.localCacheEnabled=!1,c.on("upgrade",eo(c))})),[4,c.open()]):[3,6];case 2:return d.sent(),this._storeInitialized=!0,s.dispatch(new bu(this._iid,{userId:t})),[3,5];case 3:return[4,this._safeInitializeStore(o)];case 4:d.sent(),d.label=5;case 5:return r.userId=t,[3,8];case 6:return[4,this._safeInitializeStore(o)];case 7:d.sent(),r.userId=t,d.label=8;case 8:return[3,13];case 9:return l=d.sent(),a.warn("Nest DB Open Failed. ",l),i.store instanceof Vt||(i.replaceStore(new Vt),i.localCacheEnabled=!1),[4,this._safeInitializeStore(o)];case 10:throw d.sent(),r.userId=t,T.databaseError;case 11:return[4,this._setupPreference(t)];case 12:return d.sent(),[7];case 13:return[2]}}
2))}))},n.prototype.getCacheDataSize=function(){return f(this,void 0,void 0,(function(){var t;return p(this,(function(e){switch(e.label){case 0:return(t=C.of(this._iid).cacheContext).localCacheEnabled&&t.nestdb?[4,t.nestdb.estimateUsage()]:[3,2];case 1:return[2,e.sent()];case 2:return[2,0]}}))}))},n.prototype.clearCachedData=function(){return f(this,void 0,void 0,(function(){var t;return p(this,(function(e){switch(e.label){case 0:return(t=C.of(this._iid).cacheContext).localCacheEnabled&&t.nestdb?[4,t.nestdb.clear()]:[3,2];case 1:e.sent(),t.nestdb.trim(),e.label=2;case 2:return this._storeInitialized?[4,t.preference.clear()]:[3,4];case 3:e.sent(),e.label=4;case 4:return[2]}}))}))},n.prototype.clearCachedMessages=function(t){return f(this,void 0,void 0,(function(){var e,r,i,s=this;return p(this,(function(a){switch(a.label){case 0:return R(J("string",t)).throw(T.invalidParameters),e=C.of(this._iid).cacheContext,r=ys.of(this._iid),i=sr.of(this._iid),r&&i?[4,Promise.all(t.map((function(o){return f(s,void 0,void 0,(function(){return p(this,(function(u){switch(u.label){case 0:return[4,r.removeMessagesOfChannel(o)];case 1:return u.sent(),[4,i.removeMessagesOfChannel(o)];case 2:return u.sent(),[2]}}))}))})))]:[3,2];case 1:a.sent(),a.label=2;case 2:return e.localCacheEnabled&&e.nestdb&&e.nestdb.trim(),[2]}}))}))},n.prototype._setupPreference=function(t){return f(this,void 0,void 0,(function(){var e,r,i,s,a;return p(this,(function(o){switch(o.label){case 0:return e=C.of(this._iid),r=e.sdkState,i=e.cacheContext,s=e.statManager,[4,i.preference.init(this._getPreferenceCacheKey(t),this._getPreferenceVersion())];case 1:return o.sent(),[4,i.preference.get(this._getUserProfileCacheKey(t))];case 2:return(a=o.sent())&&new Yi(this._iid,a).apply(),[4,s.init("sendbird@".concat(r.appId,"/").concat(t,".statlog"))];case 3:return o.sent(),[2]}}))}))},n.prototype._willReuseOpenedCacheDatabase=function(t){var e=C.of(this._iid),r=e.sdkState,i=e.cacheContext,s="sendbird@".concat(r.appId,"/").concat(t,".db");return!(!i.localCacheConfig||!i.nestdb||i.nestdb.state===ht.CLOSED||i.nestdb.name!==s)},n.prototype._ready=function(t,e,r){return r===void 0&&(r={}),f(this,void 0,void 0,(function(){var i,s,a,o,u,c,l,d;return p(this,(function(_){switch(_.label){case 0:return R(S("string",t)&&S("string",e,!0)).throw(T.invalidParameters),i=C.of(this._iid),s=i.sdkState,a=i.cacheContext,o=i.connectionManager,u=i.dispatcher,c=r.errorForOtherUser,s.userId&&s.userId!==t?c?[3,2]:[4,o.logout()]:[3,3];case 1:return _.sent(),[3,3];case 2:throw c;case 3:return _.trys.push([3,5,,6]),l=this._willReuseOpenedCacheDatabase(t),[4,this.initializeCache(t)];case 4:return _.sent(),a.localCacheEnabled&&l&&u.dispatch(new Rf),[3,6];case 5:return _.sent(),d=C.of(this._iid).logger,a.localCacheEnabled=!1,d.warn("Cache initialization failed - cache is not available."),[3,6];case 6:return[2]}}
2))}))},n.prototype.authenticateFeed=function(t,e){return f(this,void 0,void 0,(function(){return p(this,(function(r){switch(r.label){case 0:return[4,this.authenticate(t,e)];case 1:return[2,r.sent()]}}))}))},n.prototype.authenticate=function(t,e,r){var i;return r===void 0&&(r=Or.SESSION_TOKEN),f(this,void 0,void 0,(function(){var s,a,o;return p(this,(function(u){switch(u.label){case 0:return s=C.of(this._iid),a=s.sessionManager,o=s.connectionManager,[4,this._ready(t,e,{errorForOtherUser:o.isConnected?T.alreadyConnectedAsAnotherUser:void 0})];case 1:return u.sent(),!((i=a.session.services)===null||i===void 0)&&i.includes(Rr.CHAT)?[3,3]:(a.handler||e&&r!==Or.ACCESS_TOKEN||this.setSessionHandler(new Pa),[4,a.authenticate(t,e)]);case 2:u.sent(),u.label=3;case 3:return[2,this.currentUser]}}))}))},n.prototype.connect=function(t,e){var r;return f(this,void 0,void 0,(function(){return p(this,(function(i){switch(i.label){case 0:return[4,this._ready(t,e)];case 1:i.sent(),i.label=2;case 2:return i.trys.push([2,,4,5]),[4,C.of(this._iid).connectionManager.connect(e)];case 3:return i.sent(),[3,5];case 4:return this._onlineDetector.start(),this._appStateChangeDetector.start({appId:this.appId,userId:t,backgroundConnectionCloseTimeout:(r=this.appInfo)===null||r===void 0?void 0:r.backgroundConnectionCloseTimeout}),[7];case 5:return[2,this.currentUser]}}))}))},n.prototype.reconnect=function(){var t=C.of(this._iid),e=t.connectionManager,r=t.sdkState,i=t.sessionManager,s=t.dispatcher,a=i.session.hasSession;return a&&(s.dispatch(new St(new de({type:te.WEBSOCKET_DISCONNECT,data:{success:!0,error_code:0,error_description:"cause=explicit_reconnect"}}))),this._appStateChangeDetector.start({appId:this.appId,userId:this.currentUser.userId,backgroundConnectionCloseTimeout:this.appInfo.backgroundConnectionCloseTimeout}),this._onlineDetector.start(),e.resetAndReconnect().then((function(){r.appState="foreground"})).catch((function(){}))),a},n.prototype.disconnect=function(){return f(this,void 0,void 0,(function(){return p(this,(function(t){switch(t.label){case 0:return[4,this._internalDisconnect()];case 1:return t.sent(),[2]}}))}))},n.prototype.disconnectWebSocket=function(){return f(this,void 0,void 0,(function(){var t,e,r;return p(this,(function(i){switch(i.label){case 0:return t=C.of(this._iid),e=t.connectionManager,r=t.requestQueue,t.dispatcher.dispatch(new St(new de({type:te.WEBSOCKET_DISCONNECT,data:{success:!0,error_code:0,error_description:"cause=explicit_disconnect_websocket"}}))),this._appStateChangeDetector.stop(),this._onlineDetector.stop(),r.cancelAll(Wf),[4,e.disconnectWebSocket(!0)];case 1:return i.sent(),[2]}}))}))},n.prototype._release=function(){var t=this;if(C.exists(this._iid)){var e=C.of(this._iid),r=e.cacheContext,i=e.requestQueue,s=e.logger,a=i.commandRouter.websocketClient,o=function(u,c){try{c()}catch(l){s.debug("release: ".concat(u," failed = "),l)}};o("app state detector stop",(function(){return t._appStateChangeDetector.stop()})),o("online detector stop",(function(){return t._onlineDetector.stop()})),o("request cancellation",(function(){return i.cancelAll(Zf)})),o("websocket force close",(function(){a.ws&&a.forceClose(!1)})),o("nestdb close",(function(){var u;(u=r.nestdb)===null||u===void 0||u.close()})),C.clear(this._iid),$e===this&&($e=void 0)}else $e===this&&($e=void 0)},n.prototype.setBackgroundState=function(){var t=C.of(this._iid),e=t.connectionManager,r=t.sdkState,i=t.logger,s=t.dispatcher;r.appState==="foreground"&&(r.appState="background",r.isAppActive=!1,i.debug("going background state"),s.dispatch(new zf),s.dispatch(new St(new de({type:te.WEBSOCKET_DISCONNECT,data:{success:!0,error_code:L.WEBSOCKET_CONNECTION_CLOSED,error_description:"cause=background"}}))),e.background().catch((function(a){i.debug("setBackgroundState error = ",a)})))},n.prototype.setForegroundState=function(){var t=C.of(this._iid),e=t.connectionManager,r=t.sdkState,i=t.dispatcher,s=t.logger;r.appState==="background"?(r.appState="foreground",r.isAppActive=!0,s.debug("going foreground state"),e.resetAndReconnect().catch((function(a){s.debug("setForgroundState error = ",a)})),i.dispatch(new xi)):r.appState==="foreground"&&e.shouldReconnectOnForeground&&(s.debug("foreground resume: connection is not alive, reconnecting"),e.resetAndReconnect().catch((function(a){s.debug("setForegroundState (foreground reconnect) error = ",a)})),i.dispatch(new xi))},n.prototype._setAppActiveState=function(t){C.of(this._iid).sdkState.isAppActive=t},n.prototype.setSessionHandler=function(t){R(t instanceof Pa).throw(T.invalidParameters),C.of(this._iid).sessionManager.handler=t},n.prototype.addUserEventHandler=function(t,e){R(S("string",t)&&e instanceof Kh).throw(T.invalidParameters),C.of(this._iid).userEventHandlers.set(t,e)},n.prototype.removeUserEventHandler=function(t){C.of(this._iid).userEventHandlers.delete(t)},n.prototype.removeAllUserEventHandler=function(){C.of(this._iid).userEventHandlers.clear()},n.prototype.addConnectionHandler=function(t,e){R(S("string",t)&&e instanceof jh).throw(T.invalidParameters),C.of(this._iid).connectionHandlers.set(t,e)},n.prototype.removeConnectionHandler=function(t){C.of(this._iid).connectionHandlers.delete(t)},n.prototype.removeAllConnectionHandler=function(){C.of(this._iid).connectionHandlers.clear()},n.prototype.createApplicationUserListQuery=function(t){return t===void 0&&(t={}),new Gh(this._iid,t)},n.prototype.createBlockedUserListQuery=function(t){return t===void 0&&(t={}),new Wh(this._iid,t)},n.prototype.createFriendListQuery=function(t){return t===void 0&&(t={}),new Xh(this._iid,t)},n.prototype.createMessageSearchQuery=function(t){return new Cf(this._iid,t)},n.prototype.createPollListQuery=function(t){return new au(this._iid,E({},t))},n.prototype.createPollVoterListQuery=function(t){return new ou(this._iid,E({},t))},n.prototype.buildUserFromSerializedData=function(t){var e=Yn(t);return new G(this._iid,G.payloadify(e))},n.prototype.updateCurrentUserInfo=function(t){return t===void 0&&(t={}),f(this,void 0,void 0,(function(){var e,r,i,s,a,o,u;return p(this,(function(c){switch(c.label){case 0:return e=E(E({},jf),t),R((function(l){return rt(l.profileImage,!0)&&S("string",l.profileUrl,!0)&&S("string",l.nickname,!0)})(e)).throw(T.invalidParameters),this.currentUser?(r=C.of(this._iid),i=r.sdkState,s=r.requestQueue,a=new to(E({userId:i.userId},e)),[4,s.send(a)]):[3,2];case 1:return o=c.sent(),u=o.as(no).user,this.currentUser&&(e.nickname&&(this.currentUser.nickname=u.nickname),(e.profileUrl||e.profileImage)&&(this.currentUser.plainProfileUrl=u.profileUrl)),[2,u];case 2:throw T.connectionRequired}}))}))},n.prototype.updateCurrentUserInfoWithPreferredLanguages=function(t){return f(this,void 0,void 0,(function(){var e,r,i,s,a,o;return p(this,(function(u){switch(u.label){case 0:return R(J("string",t)).throw(T.invalidParameters),this.currentUser?(e=C.of(this._iid),r=e.sdkState,i=e.requestQueue,s=new to({userId:r.userId,preferredLanguages:t}),[4,i.send(s)]):[3,2];case 1:return a=u.sent(),o=a.as(no).user,this.currentUser&&(this.currentUser.preferredLanguages=o.preferredLanguages),[2,o];case 2:throw T.connectionRequired}}))}))},n.prototype.registerFCMPushTokenForCurrentUser=function(t,e){var r,i;return f(this,void 0,void 0,(function(){var s,a,o,u,c,l,d,_=this;return p(this,(function(h){switch(h.label){case 0:if(R(S("string",t)&&S("string",e==null?void 0:e.deviceManufacturer,!0)&&S("boolean",e==null?void 0:e.unique,!0)).throw(T.invalidParameters),t.trim().length===0)return C.of(this._iid).logger.warn("registerFCMPushTokenForCurrentUser() failed because the token is empty."),[2,me.ERROR];if(e!=null&&e.deviceOS&&R(ie(an,e.deviceOS.platform,!0)&&S("string",e.deviceOS.version,!0)).throw(T.invalidParameters),!this.currentUser)return[3,6];s={deviceOS:"".concat(((r=e==null?void 0:e.deviceOS)===null||r===void 0?void 0:r.platform)||an.AN
2DROID,"-").concat(((i=e==null?void 0:e.deviceOS)===null||i===void 0?void 0:i.version)||"unknown"),deviceManufacturer:e==null?void 0:e.deviceManufacturer,systemPushEnabled:e==null?void 0:e.systemPushEnabled},h.label=1;case 1:return h.trys.push([1,4,,5]),a=C.of(this._iid),o=a.sessionManager,u=a.sdkState,c=a.requestQueue,!(e!=null&&e.unique)&&o.hasDeviceToken(Ce.FCM,t)?[2,me.SUCCESS]:(l=new ep({userId:u.userId,token:t,deviceOS:s.deviceOS,deviceManufacturer:s.deviceManufacturer,systemPushEnabled:s.systemPushEnabled,unique:e==null?void 0:e.unique}),[4,c.send(l)]);case 2:return d=h.sent(),[4,ve((function(){return f(_,void 0,void 0,(function(){var v;return p(this,(function(m){switch(m.label){case 0:return v=d.as(tp).lastDeletedAt,e!=null&&e.unique&&typeof v=="number"&&(o.unsetDeviceTokens(),o.setDeviceTokenDeletedAt(v)),o.setDeviceToken(Ce.FCM,t,s),[4,o.saveDeviceToken()];case 1:return m.sent(),[2]}}))}))}))];case 3:return h.sent(),this._fcmPushToken="",[2,me.SUCCESS];case 4:return h.sent(),[2,me.ERROR];case 5:return[3,7];case 6:return this._fcmPushToken=t,[2,me.PENDING];case 7:return[2]}}
2))}))},n.prototype.unregisterFCMPushTokenForCurrentUser=function(t){return f(this,void 0,void 0,(function(){var e,r,i,s,a,o,u,c=this;return p(this,(function(l){switch(l.label){case 0:if(R(S("string",t)).throw(T.invalidParameters),t.trim().length===0)return C.of(this._iid).logger.warn("unregisterFCMPushTokenForCurrentUser() failed because the token is empty."),[2,me.ERROR];if(!this.currentUser)return[3,6];l.label=1;case 1:return l.trys.push([1,4,,5]),e=C.of(this._iid),r=e.sessionManager,i=e.sdkState,s=e.requestQueue,a=new ip({userId:i.userId,token:t}),[4,s.send(a)];case 2:return o=l.sent(),u=o.as(sp).lastDeletedAt,[4,ve((function(){return f(c,void 0,void 0,(function(){return p(this,(function(d){switch(d.label){case 0:return r.unsetDeviceToken(Ce.FCM,t),r.setDeviceTokenDeletedAt(u),[4,r.saveDeviceToken()];case 1:return d.sent(),[2]}}))}))}))];case 3:return l.sent(),this._fcmPushToken="",[2,me.SUCCESS];case 4:return l.sent(),[2,me.ERROR];case 5:return[3,7];case 6:return this._fcmPushToken=t,[2,me.PENDING];case 7:return[2]}}
2))}))},n.prototype.unregisterFCMPushTokenAllForCurrentUser=function(){return f(this,void 0,void 0,(function(){var t,e,r,i,s,a,o,u=this;return p(this,(function(c){switch(c.label){case 0:return this.currentUser?(t=C.of(this._iid),e=t.sessionManager,r=t.sdkState,i=t.requestQueue,s=new up({userId:r.userId}),[4,i.send(s)]):[3,3];case 1:return a=c.sent(),o=a.as(cp).lastDeletedAt,[4,ve((function(){return f(u,void 0,void 0,(function(){return p(this,(function(l){switch(l.label){case 0:return e.unsetDeviceTokens(Ce.FCM),e.setDeviceTokenDeletedAt(o),[4,e.saveDeviceToken()];case 1:return l.sent(),[2]}}))}))}))];case 2:c.sent(),c.label=3;case 3:return[2]}}))}))},n.prototype.registerAPNSPushTokenForCurrentUser=function(t,e){var r,i;return f(this,void 0,void 0,(function(){var s,a,o,u,c,l,d,_=this;return p(this,(function(h){switch(h.label){case 0:if(R(S("string",t)&&S("string",e==null?void 0:e.deviceManufacturer,!0)&&S("boolean",e==null?void 0:e.unique,!0)).throw(T.invalidParameters),t.trim().length===0)return C.of(this._iid).logger.warn("registerAPNSPushTokenForCurrentUser() failed because the token is empty."),[2,me.ERROR];if(e!=null&&e.deviceOS&&R(ie(an,e.deviceOS.platform,!0)&&S("string",e.deviceOS.version,!0)).throw(T.invalidParameters),!this.currentUser)return[3,6];s={deviceOS:"".concat(((r=e==null?void 0:e.deviceOS)===null||r===void 0?void 0:r.platform)||an.IOS,"-").concat(((i=e==null?void 0:e.deviceOS)===null||i===void 0?void 0:i.version)||"unknown"),deviceManufacturer:e==null?void 0:e.deviceManufacturer,systemPushEnabled:e==null?void 0:e.systemPushEnabled},h.label=1;case 1:return h.trys.push([1,4,,5]),a=C.of(this._iid),o=a.sessionManager,u=a.sdkState,c=a.requestQueue,!(e!=null&&e.unique)&&o.hasDeviceToken(Ce.APNS,t)?[2,me.SUCCESS]:(l=new Xf({userId:u.userId,token:t,deviceOS:s.deviceOS,deviceManufacturer:s.deviceManufacturer,systemPushEnabled:s.systemPushEnabled,unique:e==null?void 0:e.unique}),[4,c.send(l)]);case 2:return d=h.sent(),[4,ve((function(){return f(_,void 0,void 0,(function(){var v;return p(this,(function(m){switch(m.label){case 0:return v=d.as(Jf).lastDeletedAt,e!=null&&e.unique&&typeof v=="number"&&(o.unsetDeviceTokens(),o.setDeviceTokenDeletedAt(v)),o.setDeviceToken(Ce.APNS,t,s),[4,o.saveDeviceToken()];case 1:return m.sent(),[2]}}))}))}))];case 3:return h.sent(),this._apnsPushToken="",[2,me.SUCCESS];case 4:return h.sent(),[2,me.ERROR];case 5:return[3,7];case 6:return this._apnsPushToken=t,[2,me.PENDING];case 7:return[2]}}
2))}))},n.prototype.unregisterAPNSPushTokenForCurrentUser=function(t){return f(this,void 0,void 0,(function(){var e,r,i,s,a,o,u,c=this;return p(this,(function(l){switch(l.label){case 0:if(R(S("string",t)).throw(T.invalidParameters),t.trim().length===0)return C.of(this._iid).logger.warn("unregisterAPNSPushTokenForCurrentUser() failed because the token is empty."),[2,me.ERROR];if(!this.currentUser)return[3,6];l.label=1;case 1:return l.trys.push([1,4,,5]),e=C.of(this._iid),r=e.sessionManager,i=e.sdkState,s=e.requestQueue,a=new np({userId:i.userId,token:t}),[4,s.send(a)];case 2:return o=l.sent(),u=o.as(rp).lastDeletedAt,[4,ve((function(){return f(c,void 0,void 0,(function(){return p(this,(function(d){switch(d.label){case 0:return r.unsetDeviceToken(Ce.APNS,t),r.setDeviceTokenDeletedAt(u),[4,r.saveDeviceToken()];case 1:return d.sent(),[2]}}))}))}))];case 3:return l.sent(),this._apnsPushToken="",[2,me.SUCCESS];case 4:return l.sent(),[2,me.ERROR];case 5:return[3,7];case 6:return this._apnsPushToken=t,[2,me.PENDING];case 7:return[2]}}
2))}))},n.prototype.unregisterAPNSPushTokenAllForCurrentUser=function(){return f(this,void 0,void 0,(function(){var t,e,r,i,s,a,o,u=this;return p(this,(function(c){switch(c.label){case 0:return this.currentUser?(t=C.of(this._iid),e=t.sessionManager,r=t.sdkState,i=t.requestQueue,s=new ap({userId:r.userId}),[4,i.send(s)]):[3,3];case 1:return a=c.sent(),o=a.as(op).lastDeletedAt,[4,ve((function(){return f(u,void 0,void 0,(function(){return p(this,(function(l){switch(l.label){case 0:return e.unsetDeviceTokens(Ce.APNS),e.setDeviceTokenDeletedAt(o),[4,e.saveDeviceToken()];case 1:return l.sent(),[2]}}))}))}))];case 2:c.sent(),c.label=3;case 3:return[2]}}))}))},n.prototype.markPushNotificationAsDelivered=function(t,e){var r;return e===void 0&&(e=!0),f(this,void 0,void 0,(function(){var i,s,a,o,u,c,l,d,_,h,v,m,y,b,w,I,A,D,N;return p(this,(function(F){switch(F.label){case 0:if(i=C.of(this._iid),s=i.logger,a=i.sessionManager,o=i.requestQueue,u=i.pushNotificationAckManager,s.debug("markPushNotificationAsDelivered:",t),c=$r.DELIVERED,l=u.parseData(t),d=l.pushTrackingId,_=l.sessionTopics,h=l.sessionKey,v=l.messageId,m=l.channelKey,y=l.templateKey,b=l.notificationEventDeadline,!h||!_.includes(Kr.PUSH_ACKNOWLEDGEMENT))throw s.info("Can't use markPushNotificationAsDelivered() feature."),T.malformedDataError;if(u.isAcked(d,c))return s.info("already delivered push notification:",d),[2];w=!!m,I=e&&w,A=(r=a.deviceTokens[0])===null||r===void 0?void 0:r.token,D=new ro({deviceToken:A!=null?A:"",pushTrackingId:d,eventType:c,messageId:v,channelKey:m,templateKey:y,notificationEventDeadline:b,allowedPushNotification:I}),h&&(D.headers["Session-Key"]=h),F.label=1;case 1:return F.trys.push([1,3,,4]),[4,o.send(D)];case 2:return F.sent(),u.markAsAcked(d,c),[3,4];case 3:throw N=F.sent(),s.debug("failed to mark push notification as delivered. push tracking id: ".concat(d,". error: ").concat(N)),N;case 4:return[2]}}
2))}))},n.prototype.markPushNotificationAsClicked=function(t){var e;return f(this,void 0,void 0,(function(){var r,i,s,a,o,u,c,l,d,_,h,v,m,y,b,w,I;return p(this,(function(A){switch(A.label){case 0:if(r=C.of(this._iid),i=r.logger,s=r.sessionManager,a=r.requestQueue,o=r.pushNotificationAckManager,i.debug("markPushNotificationAsClicked:",t),u=$r.CLICKED,c=o.parseData(t),l=c.pushTrackingId,d=c.sessionTopics,_=c.sessionKey,h=c.messageId,v=c.channelKey,m=c.templateKey,y=c.notificationEventDeadline,!_||!d.includes(Kr.PUSH_ACKNOWLEDGEMENT))throw i.info("Can't use markPushNotificationAsClicked() feature."),T.malformedDataError;if(o.isAcked(l,u))return i.info("already clicked push notification:",l),[2];b=(e=s.deviceTokens[0])===null||e===void 0?void 0:e.token,w=new ro({deviceToken:b!=null?b:"",pushTrackingId:l,eventType:u,messageId:h,channelKey:v,templateKey:m,notificationEventDeadline:y}),_&&(w.headers["Session-Key"]=_),A.label=1;case 1:return A.trys.push([1,3,,4]),[4,a.send(w)];case 2:return A.sent(),o.markAsAcked(l,u),[3,4];case 3:throw I=A.sent(),i.debug("failed to mark push notification as clicked. push tracking id: ".concat(l,". error: ").concat(I)),I;case 4:return[2]}}
2))}))},n.prototype.getChannelInvitationPreference=function(){return f(this,void 0,void 0,(function(){var t,e,r,i,s;return p(this,(function(a){switch(a.label){case 0:return t=C.of(this._iid),e=t.sdkState,r=t.requestQueue,i=new hp({userId:e.userId}),[4,r.send(i)];case 1:return s=a.sent(),[2,{autoAccept:s.as(fp).autoAccept}]}}))}))},n.prototype.setChannelInvitationPreference=function(t){return f(this,void 0,void 0,(function(){var e,r,i,s,a;return p(this,(function(o){switch(o.label){case 0:return R(S("boolean",t)).throw(T.invalidParameters),e=C.of(this._iid),r=e.sdkState,i=e.requestQueue,s=new pp({userId:r.userId,willAutoAccept:t}),[4,i.send(s)];case 1:return a=o.sent(),[2,{autoAccept:a.as(_p).autoAccept}]}}))}))},n.prototype.getDoNotDisturb=function(){return f(this,void 0,void 0,(function(){var t,e,r,i,s;return p(this,(function(a){switch(a.label){case 0:return t=C.of(this._iid),e=t.sdkState,r=t.requestQueue,i=new vp({userId:e.userId}),[4,r.send(i)];case 1:return s=a.sent(),[2,s.as(mp).preference]}}))}))},n.prototype.setDoNotDisturb=function(t,e,r,i,s,a){return e===void 0&&(e=0),r===void 0&&(r=0),i===void 0&&(i=0),s===void 0&&(s=0),a===void 0&&(a=""),f(this,void 0,void 0,(function(){var o,u,c,l,d;return p(this,(function(_){switch(_.label){case 0:return R(S("boolean",t)&&S("number",e)&&S("number",r)&&S("number",i)&&S("number",s)&&S("string",a)).throw(T.invalidParameters),o=C.of(this._iid),u=o.sdkState,c=o.requestQueue,l=new gp({userId:u.userId,doNotDisturbOn:t,startHour:e,startMin:r,endHour:i,endMin:s,timezone:a}),[4,c.send(l)];case 1:return d=_.sent(),[2,d.as(yp).preference]}}))}))},n.prototype.setWeeklyDoNotDisturb=function(t,e){return e===void 0&&(e=""),f(this,void 0,void 0,(function(){var r,i,s,a,o;return p(this,(function(u){switch(u.label){case 0:return R(t instanceof ii&&t.isValid()&&S("string",e)).throw(T.invalidParameters),r=C.of(this._iid),i=r.sdkState,s=r.requestQueue,a=new Vp({userId:i.userId,weeklyDndSchedules:t,timezone:e}),[4,s.send(a)];case 1:return o=u.sent(),[2,o.as(Gp).preference]}}))}))},n.prototype.getWeeklyDoNotDisturb=function(){return f(this,void 0,void 0,(function(){var t,e,r,i,s;return p(this,(function(a){switch(a.label){case 0:return t=C.of(this._iid),e=t.sdkState,r=t.requestQueue,i=new Qp({userId:e.userId}),[4,r.send(i)];case 1:return s=a.sent(),[2,s.as($p).preference]}}))}))},n.prototype.clearWeeklyDoNotDisturb=function(){return f(this,void 0,void 0,(function(){var t,e,r,i;return p(this,(function(s){switch(s.label){case 0:return t=C.of(this._iid),e=t.sdkState,r=t.requestQueue,i=new Wp({userId:e.userId}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},n.prototype.getSnoozePeriod=function(){return f(this,void 0,void 0,(function(){var t,e,r,i,s;return p(this,(function(a){switch(a.label){case 0:return t=C.of(this._iid),e=t.sdkState,r=t.requestQueue,i=new bp({userId:e.userId}),[4,r.send(i)];case 1:return s=a.sent(),[2,s.as(Ep).snoozePeriod]}}))}))},n.prototype.setSnoozePeriod=function(t,e,r){return e===void 0&&(e=0),r===void 0&&(r=0),f(this,void 0,void 0,(function(){var i,s,a,o,u;return p(this,(function(c){switch(c.label){case 0:return R(S("boolean",t)&&S("number",e)&&S("number",r)).throw(T.invalidParameters),i=C.of(this._iid),s=i.sdkState,a=i.requestQueue,o=new wp({userId:s.userId,snoozeOn:t,startTs:e,endTs:r}),[4,a.send(o)];case 1:return u=c.sent(),[2,u.as(Ip).snoozePeriod]}}))}))},n.prototype.getMyPushTokensByToken=function(t,e){return f(this,void 0,void 0,(function(){var r,i,s,a,o,u,c,l,d,_,h,v;return p(this,(function(m){switch(m.label){case 0:return R(S("string",t)&&ie(Ce,e)).throw(T.invalidParameters),r=C.of(this._iid),i=r.sdkState,s=r.requestQueue,a=r.sessionManager,o=new lp({userId:i.userId,type:e,token:t}),[4,s.send(o)];case 1:u=m.sent(),c=u.as(dp).pushTokens;try{for(l=z(c.deviceTokens),d=l.next();!d.done;d=l.next())_=d.value,a.setDeviceToken(c.type,_)}catch(y){h={error:y}}finally{try{d&&!d.done&&(v=l.return)&&v.call(l)}finally{if(h)throw h.error}}return[4,a.saveDeviceToken()];case 2:return m.sent(),[2,c]}}))}))},n.prototype.getPushTriggerOption=function(){return f(this,void 0,void 0,(function(){var t,e,r,i;return p(this,(function(s){switch(s.label){case 0:return t=C.of(this._iid),e=t.sdkState,r=t.requestQueue,i=new Cp({userId:e.userId}),[4,r.send(i)];case 1:return[2,s.sent().as(Ap).pushTriggerOption]}}))}))},n.prototype.setPushTriggerOption=function(t){return f(this,void 0,void 0,(function(){var e,r,i,s;return p(this,(function(a){switch(a.label){case 0:return R(ie(qi,t)).throw(T.invalidParameters),e=C.of(this._iid),r=e.sdkState,i=e.requestQueue,s=new Np({userId:r.userId,pushTriggerOption:t}),[4,i.send(s)];case 1:return[2,a.sent().as(kp).pushTriggerOption]}}))}))},n.prototype.getPushTemplate=function(){return f(this,void 0,void 0,(function(){var t,e,r,i;return p(this,(function(s){switch(s.label){case 0:return t=C.of(this._iid),e=t.sdkState,r=t.requestQueue,i=new Op({userId:e.userId}),[4,r.send(i)];case 1:return[2,s.sent().as(Dp).name]}}))}))},n.prototype.setPushTemplate=function(t){return f(this,void 0,void 0,(function(){var e,r,i,s;return p(this,(function(a){switch(a.label){case 0:return R(ie(zi,t)).throw(T.invalidParameters),e=C.of(this._iid),r=e.sdkState,i=e.requestQueue,s=new Rp({userId:r.userId,templateName:t}),[4,i.send(s)];case 1:return[2,a.sent().as(Lp).name]}}))}))},n.prototype.blockUser=function(t){return f(this,void 0,void 0,(function(){var e,r,i,s;return p(this,(function(a){switch(a.label){case 0:return R(t instanceof G||S("string",t)).throw(T.invalidParameters),e=C.of(this._iid),r=e.sdkState,i=e.requestQueue,s=new Tp({userId:r.userId,blockedUserId:t instanceof G?t.userId:t}),[4,i.send(s)];case 1:return a.sent(),[2]}}))}))},n.prototype.blockUserWithUserId=function(t){return f(this,void 0,void 0,(function(){return p(this,(function(e){return[2,this.blockUser(t)]}))}))},n.prototype.unblockUser=function(t){return f(this,void 0,void 0,(function(){var e,r,i,s;return p(this,(function(a){switch(a.label){case 0:return R(t instanceof G||S("string",t)).throw(T.invalidParameters),e=C.of(this._iid),r=e.sdkState,i=e.requestQueue,s=new Sp({userId:r.userId,unblockedUserId:t instanceof G?t.userId:t}),[4,i.send(s)];case 1:return a.sent(),[2]}}))}))},n.prototype.unblockUserWithUserId=function(t){return f(this,void 0,void 0,(function(){return p(this,(function(e){return[2,this.unblockUser(t)]}))}))},n.prototype.getFriendChangeLogsByToken=function(t){return f(this,void 0,void 0,(function(){var e,r,i,s,a;return p(this,(function(o){switch(o.label){case 0:return R(S("string",t)).throw(T.invalidParameters),e=C.of(this._iid),r=e.sdkState,i=e.requestQueue,s=new Up({userId:r.userId,token:t}),[4,i.send(s)];case 1:return a=o.sent(),[2,a.as(Mp).changelogs]}}))}))},n.prototype.getAllowFriendDiscovery=function(){return f(this,void 0,void 0,(function(){var t,e,r,i,s;return p(this,(function(a){switch(a.label){case 0:return t=C.of(this._iid),e=t.sdkState,r=t.requestQueue,i=new jp({userId:e.userId}),[4,r.send(i)];case 1:return s=a.sent(),[2,s.as(Kp).allowFriendDiscovery]}}))}))},n.prototype.setAllowFriendDiscovery=function(t){return f(this,void 0,void 0,(function(){var e,r,i,s;return p(this,(function(a){switch(a.label){case 0:return R(S("boolean",t)).throw(T.invalidParameters),e=C.of(this._iid),r=e.sdkState,i=e.requestQueue,s=new Hp({userId:r.userId,allowFriendDiscovery:t}),[4,i.send(s)];case 1:return a.sent(),[2,t]}}))}))},n.prototype.uploadFriendDiscoveries=function(t){return f(this,void 0,void 0,(function(){var e,r,i,s,a;return p(this,(function(o){switch(o.label){case 0:return e=C.of(this._iid),r=e.sdkState,i=e.requestQueue,s=new Pp({userId:r.userId,discoveries:t}),[4,i.send(s)];case 1:return a=o.sent(),[2,a.as(xp).friendDiscoveryRequestId]}}))}))},n.prototype.deleteFriendDiscovery=function(t){return f(this,void 0,void 0,(function(){return p(this,(function(e){return[2,this.deleteFriendDiscoveries([t])]}))}))},n.prototype.deleteFriendDiscoveries=function(t){return f(this,void 0,void 0,(function(){var e,r,i,s;return p(this,(function(a){switch(a.label){case 0:return R(J("string",t)).throw(T.invalidParameters),e=C.of(this._iid),r=e.sdkState,i=e.requestQueue,s=new Fp({userId:r.userId,discoveryKeys:t}),[4,i.send(s)];case 1:return a.sent(),[2]}}))}))},n.prototype.addFriends=function(t){return f(this,void 0,void 0,(function(){var e,r,i,s,a;return p(this,(function(o){switch(o.label){case 0:return R(J("string",t)).throw(T.invalidParameters),e=C.of(this._iid),r=e.sdkState,i=e.requestQueue,s=new qp({userId:r.userId,userIds:t}),[4,i.send(s)];case 1:return a=o.sent(),[2,a.as(zp).users]}}))}))},n.prototype.deleteFriend=function(t){return f(this,void 0,void 0,(function(){return p(this,(function(e){return[2,this.deleteFriends([t])]}))}))},n.prototype.deleteFriends=function(t){return f(this,void 0,void 0,(function(){var e,r,i,s;return p(this,(function(a){switch(a.label){case 0:return R(J("string",t)).throw(T.invalidParameters),e=C.of(this._iid),r=e.sdkState,i=e.requestQueue,s=new Bp({userId:r.userId,userIds:t}),[4,i.send(s)];case 1:return a.sent(),[2]}}))}))},n.prototype.getAllEmoji=function(){return f(this,void 0,void 0,(function(){var t,e,r;return p(this,(function(i){switch(i.label){case 0:return t=C.of(this._iid).requestQueue,e=new Yp,[4,t.send(e)];case 1:return r=i.sent(),[2,r.as(Zp).emojiContainer]}}))}))},n.prototype.getEmojiCategory=function(t){return f(this,void 0,void 0,(function(){var e,r,i;return p(this,(function(s){switch(s.label){case 0:return e=C.of(this._iid).requestQueue,r=new Xp({categoryId:t}),[4,e.send(r)];case 1:return i=s.sent(),[2,i.as(Jp).emojiCategory]}}))}))},n.prototype.getEmoji=function(t){return f(this,void 0,void 0,(function(){var e,r,i;return p(this,(function(s){switch(s.label){case 0:return e=C.of(this._iid).requestQueue,r=new e_({key:t}),[4,e.send(r)];case 1:return i=s.sent(),[2,i.as(t_).emoji]}}))}))},n.prototype.getUIKitConfiguration=function(){return f(this,void 0,void 0,(function(){var t,e,r,i;return p(this,(function(s){switch(s.label){case 0:return t=C.of(this._iid),R(t.hasExtension("sb_uikit")).throw(T.notSupportedError),e=t.requestQueue,r=new n_,[4,e.send(r)];case 1:return i=s.sent(),[2,i.as(r_).uikitConfiguration]}}))}))},n.prototype.getReportCategoryInfoList=function(){return f(this,void 0,void 0,(function(){return p(this,(function(t){switch(t.label){case 0:return[4,C.of(this._iid).reportCategoryManager.categories()];case 1:return[2,t.sent()]}}))}))},n})();export{td as $,he as A,ys as B,xt as C,C as D,Rf as E,Pf as F,_f as G,Gn as H,id as I,ue as J,ts as K,Ya as L,tl as M,J as N,i_ as O,Uf as P,g_ as Q,M as R,G as S,S as T,$i as U,po as V,we as W,pt as X,Qi as Y,P_ as Z,Tr as _,uu as a,mt as a$,R as a0,rt as a1,T as a2,Lf as a3,Nr as a4,ge as a5,Mh as a6,xl as a7,v_ as a8,p_ as a9,Pi as aA,Z as aB,Lr as aC,ks as aD,h_ as aE,qt as aF,U as aG,O as aH,qe as aI,gd as aJ,pu as aK,s_ as aL,bu as aM,ve as aN,je as aO,Ne as aP,de as aQ,te as aR,L as aS,Vr as aT,fs as aU,k as aV,o_ as aW,co as aX,Re as aY,Y as aZ,Ur as a_,m_ as aa,Fo as ab,__ as ac,st as ad,D_ as ae,R_ as af,ch as ag,yd as ah,L_ as ai,U_ as aj,Ue as ak,_u as al,qi as am,es as an,Ji as ao,wa as ap,xe as aq,Sa as ar,O_ as as,ae as at,vd as au,md as av,N_ as aw,bn as ax,Th as ay,C_ as az,x_ as b,He as b0,zt as b1,W as b2,l_ as b3,c_ as b4,vn as b5,A_ as b6,Ff as b7,yn as b8,X as b9,d_ as bA,La as bB,Ma as bC,th as bD,od as bE,f_ as bF,pa as bG,Zi as bH,k_ as bI,u_ as bJ,Ot as bK,Xo as bL,Wa as bM,Za as bN,rl as bO,mn as bP,F_ as bQ,Fr as bR,xf as ba,_n as bb,ze as bc,fe as bd,Xi as be,Ve as bf,a_ as bg,On as bh,ht as bi,Ul as bj,Mf as bk,as as bl,Eu as bm,b_ as bn,y_ as bo,S_ as bp,T_ as bq,I_ as br,E_ as bs,w_ as bt,tu as bu,Ih as bv,Fl as bw,Pl as bx,Ml as by,Jo as bz,Hr as c,V as d,M_ as e,K as f,ne as g,hs as h,nr as i,la as j,vf as k,be as l,Yn as m,E as n,z as o,tt as p,sr as q,f as r,p as s,g as t,B as u,ot as v,ie as w,Df as x,ke as y,oe as z}; 3//# sourceMappingURL=sendbird-haQy8H9b.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.