UNPKG

@sendbird/chat

Version:
2 lines 174 kB
function e(e,t,s,i){return new(s||(s=Promise))((function(n,o){function r(e){try{d(i.next(e))}catch(e){o(e)}}function a(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(r,a)}d((i=i.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;var t,s="4.17.4";class i{static get OS_VERSION(){return"undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.replace(/,/g,"."):"noAgent"}static get SDK_VERSION(){return s}static get SDK_MAJOR_VERSION(){return i.SDK_VERSION.split(".")[0]}static get DEFAULT_MAX_UNREAD_COUNT_OF_SUPER_GROUP_CHANNEL(){return 100}static get INTERNAL_CALL(){return"ic"}}exports.SendbirdErrorCode=void 0,(t=exports.SendbirdErrorCode||(exports.SendbirdErrorCode={}))[t.NON_AUTHORIZED=400108]="NON_AUTHORIZED",t[t.INVALID_TOKEN=400111]="INVALID_TOKEN",t[t.NOT_FOUND_IN_DATABASE=400201]="NOT_FOUND_IN_DATABASE",t[t.USER_AUTH_DEACTIVATED=400300]="USER_AUTH_DEACTIVATED",t[t.USER_AUTH_DELETED_OR_NOT_FOUND=400301]="USER_AUTH_DELETED_OR_NOT_FOUND",t[t.SESSION_TOKEN_EXPIRED=400302]="SESSION_TOKEN_EXPIRED",t[t.APPLICATION_NOT_FOUND=400304]="APPLICATION_NOT_FOUND",t[t.SESSION_KEY_EXPIRED=400309]="SESSION_KEY_EXPIRED",t[t.SESSION_REVOKED=400310]="SESSION_REVOKED",t[t.INVALID_SESSION_TYPE=400312]="INVALID_SESSION_TYPE",t[t.INVALID_AUTH_FOR_SERVICE=400313]="INVALID_AUTH_FOR_SERVICE",t[t.STAT_UPLOAD_NOT_ALLOWED=403200]="STAT_UPLOAD_NOT_ALLOWED",t[t.NOT_SUPPORTED_PINNED_MESSAGE_IN_REVIEW_MESSAGE=400940]="NOT_SUPPORTED_PINNED_MESSAGE_IN_REVIEW_MESSAGE",t[t.INTERNAL_SERVER_ERROR=500901]="INTERNAL_SERVER_ERROR",t[t.RATE_LIMIT_EXCEEDED=500910]="RATE_LIMIT_EXCEEDED",t[t.INVALID_REQUIRED_FORM_VALUE=400105]="INVALID_REQUIRED_FORM_VALUE",t[t.UNKNOWN_SERVER_ERROR=900200]="UNKNOWN_SERVER_ERROR",t[t.NOT_SUPPORTED_FEATURE_IN_IN_REVIEW_MESSAGE=901500]="NOT_SUPPORTED_FEATURE_IN_IN_REVIEW_MESSAGE",t[t.ERR_DUPLICATED_DATA=400202]="ERR_DUPLICATED_DATA",t[t.DEBUG_MODE_REQUIRED=7e5]="DEBUG_MODE_REQUIRED",t[t.LOST_INSTANCE=700100]="LOST_INSTANCE",t[t.CONNECTION_RENEW=700102]="CONNECTION_RENEW",t[t.INVALID_CONNECTION_STATE_TRANSITION=700200]="INVALID_CONNECTION_STATE_TRANSITION",t[t.INVALID_COMMAND=700700]="INVALID_COMMAND",t[t.XMLHTTPREQUEST_NOT_SUPPORTED=700800]="XMLHTTPREQUEST_NOT_SUPPORTED",t[t.UNKNOWN_ERROR=77e4]="UNKNOWN_ERROR",t[t.INVALID_INITIALIZATION=800100]="INVALID_INITIALIZATION",t[t.CONNECTION_REQUIRED=800101]="CONNECTION_REQUIRED",t[t.CONNECTION_CANCELED=800102]="CONNECTION_CANCELED",t[t.INVALID_PARAMETER=800110]="INVALID_PARAMETER",t[t.NOT_SUPPORTED_ERROR=800111]="NOT_SUPPORTED_ERROR",t[t.NETWORK_ERROR=800120]="NETWORK_ERROR",t[t.NETWORK_ROUTING_ERROR=800121]="NETWORK_ROUTING_ERROR",t[t.MALFORMED_DATA=800130]="MALFORMED_DATA",t[t.MALFORMED_ERROR_DATA=800140]="MALFORMED_ERROR_DATA",t[t.WRONG_CHANNEL_TYPE=800150]="WRONG_CHANNEL_TYPE",t[t.MARK_AS_READ_RATE_LIMIT_EXCEEDED=800160]="MARK_AS_READ_RATE_LIMIT_EXCEEDED",t[t.QUERY_IN_PROGRESS=800170]="QUERY_IN_PROGRESS",t[t.ACK_TIMEOUT=800180]="ACK_TIMEOUT",t[t.LOGIN_TIMEOUT=800190]="LOGIN_TIMEOUT",t[t.WEBSOCKET_CONNECTION_CLOSED=800200]="WEBSOCKET_CONNECTION_CLOSED",t[t.WEBSOCKET_CONNECTION_FAILED=800210]="WEBSOCKET_CONNECTION_FAILED",t[t.REQUEST_FAILED=800220]="REQUEST_FAILED",t[t.FILE_UPLOAD_CANCEL_FAILED=800230]="FILE_UPLOAD_CANCEL_FAILED",t[t.REQUEST_CANCELED=800240]="REQUEST_CANCELED",t[t.REQUEST_DUPLICATED=800250]="REQUEST_DUPLICATED",t[t.FILE_SIZE_LIMIT_EXCEEDED=800260]="FILE_SIZE_LIMIT_EXCEEDED",t[t.ERR_UPLOAD_STAT_RETRY_COUNT_EXCEEDED=800270]="ERR_UPLOAD_STAT_RETRY_COUNT_EXCEEDED",t[t.SESSION_TOKEN_REQUEST_FAILED=800500]="SESSION_TOKEN_REQUEST_FAILED",t[t.SESSION_TOKEN_REFRESHED=800501]="SESSION_TOKEN_REFRESHED",t[t.SESSION_TOKEN_REFRESH_FAILED=800502]="SESSION_TOKEN_REFRESH_FAILED",t[t.COLLECTION_DISPOSED=800600]="COLLECTION_DISPOSED",t[t.DATABASE_ERROR=800700]="DATABASE_ERROR",t[t.USER_DEACTIVATED=900021]="USER_DEACTIVATED",t[t.CHANNEL_IS_FROZEN=900050]="CHANNEL_IS_FROZEN",t[t.RECEIVER_USER_DEACTIVATED=900081]="RECEIVER_USER_DEACTIVATED";const n=e=>!(e instanceof o&&!e.shouldThrowOutside);class o extends Error{constructor({code:e=0,message:t=""}){super(t),this.shouldThrowOutside=!1,this._detail="",this.name="SendbirdError",this.code=e,Object.setPrototypeOf(this,o.prototype)}get detail(){return this._detail}setDetail(e){this._detail=e}get isInvalidTokenError(){return this.code===exports.SendbirdErrorCode.INVALID_TOKEN}get isSessionExpiredError(){return this.isSessionTokenExpiredError||this.isSessionKeyExpiredError}get isSessionTokenExpiredError(){return this.code===exports.SendbirdErrorCode.SESSION_TOKEN_EXPIRED}get isSessionKeyExpiredError(){return this.code===exports.SendbirdErrorCode.SESSION_KEY_EXPIRED}get isSessionInvalidatedError(){return this.isSessionRevokedError||this.isUserAuthDeactivedError||this.isUserAuthDeletedOrNotFoundError}get isSessionRevokedError(){return this.code===exports.SendbirdErrorCode.SESSION_REVOKED}get isUserAuthDeactivedError(){return this.code===exports.SendbirdErrorCode.USER_AUTH_DEACTIVATED}get isUserAuthDeletedOrNotFoundError(){return this.code===exports.SendbirdErrorCode.USER_AUTH_DELETED_OR_NOT_FOUND}get isNetworkError(){return this.code===exports.SendbirdErrorCode.NETWORK_ERROR||this.code===exports.SendbirdErrorCode.NETWORK_ROUTING_ERROR}static get debugModeRequired(){return new o({code:exports.SendbirdErrorCode.DEBUG_MODE_REQUIRED,message:"Cannot run this operation in production mode."})}static get lostInstance(){return new o({code:exports.SendbirdErrorCode.LOST_INSTANCE,message:"Instance ID is missing. It should belong to an instance."})}static get invalidCommand(){return new o({code:exports.SendbirdErrorCode.INVALID_COMMAND,message:"Cannot send invalid command."})}static get unknown(){return new o({code:exports.SendbirdErrorCode.UNKNOWN_ERROR,message:"Unknown error occurred."})}static get connectionRenew(){return new o({code:exports.SendbirdErrorCode.CONNECTION_RENEW,message:"Connection restarts."})}static get invalidConnectionStateTransition(){return new o({code:exports.SendbirdErrorCode.INVALID_CONNECTION_STATE_TRANSITION,message:"Invalid connection state transition."})}static get xmlHttpRequestNotSupported(){return new o({code:exports.SendbirdErrorCode.XMLHTTPREQUEST_NOT_SUPPORTED,message:"Cannot upload file. XMLHttpRequest is not defined in this environment."})}static get connectionRequired(){return new o({code:exports.SendbirdErrorCode.CONNECTION_REQUIRED,message:"Connection is required."})}static get connectionCanceled(){return new o({code:exports.SendbirdErrorCode.CONNECTION_CANCELED,message:"Connection is canceled."})}static get invalidParameters(){return new o({code:exports.SendbirdErrorCode.INVALID_PARAMETER,message:"Invalid parameters."})}static get notSupportedError(){return new o({code:exports.SendbirdErrorCode.NOT_SUPPORTED_ERROR,message:"Given parameters are not supported."})}static get channelTypeNotSupportedError(){return new o({code:exports.SendbirdErrorCode.NOT_SUPPORTED_ERROR,message:"Called method is not supported in the current channel's channel type."})}static get networkError(){return new o({code:exports.SendbirdErrorCode.NETWORK_ERROR,message:"There was a network error."})}static get markAsReadAllRateLimitExceeded(){return new o({code:exports.SendbirdErrorCode.MARK_AS_READ_RATE_LIMIT_EXCEEDED,message:"markAsRead rate limit exceeded."})}static get queryInProgress(){return new o({code:exports.SendbirdErrorCode.QUERY_IN_PROGRESS,message:"Query in progress."})}static get noAckTimeout(){return new o({code:exports.SendbirdErrorCode.ACK_TIMEOUT,message:"Command received no ack."})}static get loginTimeout(){return new o({code:exports.SendbirdErrorCode.LOGIN_TIMEOUT,message:"Connection timeout."})}static get connectionClosed(){return new o({code:exports.SendbirdErrorCode.WEBSOCKET_CONNECTION_CLOSED,message:"Connection is closed. Please reconnect."})}static get requestFailed(){return new o({code:exports.SendbirdErrorCode.REQUEST_FAILED,message:"Request failed."})}static get tooManyRequests(){return new o({code:exports.SendbirdErrorCode.REQUEST_DUPLICATED,message:"Too many requests."})}static get alreadyConnectedAsAnotherUser(){return new o({code:exports.SendbirdErrorCode.REQUEST_FAILED,message:"Already logged in as a different user. Call disconnect() first."})}static get fileUploadCanceled(){return new o({code:exports.SendbirdErrorCode.FILE_UPLOAD_CANCEL_FAILED,message:"File upload has been canceled."})}static get requestCanceled(){return new o({code:exports.SendbirdErrorCode.REQUEST_CANCELED,message:"Request has been canceled."})}static get sessionTokenRefreshFailed(){return new o({code:exports.SendbirdErrorCode.SESSION_TOKEN_REFRESH_FAILED,message:"Failed to refresh the session key."})}static get sessionTokenRequestFailed(){return new o({code:exports.SendbirdErrorCode.SESSION_TOKEN_REQUEST_FAILED,message:"Failed to get the session token."})}static get databaseError(){return new o({code:exports.SendbirdErrorCode.DATABASE_ERROR,message:"Database error."})}static get fileSizeLimitExceededError(){return new o({code:exports.SendbirdErrorCode.FILE_SIZE_LIMIT_EXCEEDED,message:"File size exceeds the file size limit."})}static get statLogUploadLimitExceededError(){return new o({code:exports.SendbirdErrorCode.ERR_UPLOAD_STAT_RETRY_COUNT_EXCEEDED,message:"The upload request failed due to the retry count being exceeded."})}static get malformedDataError(){return new o({code:exports.SendbirdErrorCode.MALFORMED_DATA,message:"Malformed data."})}throwOutside(){throw this.shouldThrowOutside=!0,this}}const r=[exports.SendbirdErrorCode.CONNECTION_REQUIRED,exports.SendbirdErrorCode.NETWORK_ERROR,exports.SendbirdErrorCode.ACK_TIMEOUT,exports.SendbirdErrorCode.WEBSOCKET_CONNECTION_CLOSED,exports.SendbirdErrorCode.WEBSOCKET_CONNECTION_FAILED,exports.SendbirdErrorCode.FILE_UPLOAD_CANCEL_FAILED,exports.SendbirdErrorCode.REQUEST_CANCELED,exports.SendbirdErrorCode.INTERNAL_SERVER_ERROR,exports.SendbirdErrorCode.RATE_LIMIT_EXCEEDED,exports.SendbirdErrorCode.UNKNOWN_SERVER_ERROR,exports.SendbirdErrorCode.USER_DEACTIVATED,exports.SendbirdErrorCode.CHANNEL_IS_FROZEN,exports.SendbirdErrorCode.RECEIVER_USER_DEACTIVATED],a=[exports.SendbirdErrorCode.WEBSOCKET_CONNECTION_CLOSED,exports.SendbirdErrorCode.WEBSOCKET_CONNECTION_FAILED,exports.SendbirdErrorCode.CONNECTION_REQUIRED,exports.SendbirdErrorCode.CHANNEL_IS_FROZEN],d=(e,t,s=!1)=>!(!s||!_(t))||("string"!=typeof e?"object"==typeof e?l(e,t):c(e,t):typeof t===e),l=(e,t,s=!1)=>!(!s||!_(t))||Object.values(e).includes(t),c=(e,t)=>t instanceof e,h=(e,t,s=!1)=>!(!s||!_(t))||Array.isArray(t)&&t.every((t=>d(e,t))),u=(e,t=!1)=>{if(t&&_(e))return!0;const s="object"==typeof e&&null!==e&&e.hasOwnProperty("name")&&"string"==typeof e.name&&e.hasOwnProperty("uri")&&"string"==typeof e.uri&&e.hasOwnProperty("type")&&"string"==typeof e.type;if(!s){if("undefined"!=typeof Blob)return e instanceof Blob;if("undefined"!=typeof File)return e instanceof File}return s},_=e=>null==e;class p{constructor({useMemberInfoInMessage:e=!0,typingIndicatorInvalidateTime:t=1e4,typingIndicatorThrottle:s=1e3,websocketResponseTimeout:i=1e4,websocketPayloadDecompression:n=!0,sessionTokenRefreshTimeout:o=60}={}){this._useMemberInfoInMessage=!0,this._typingIndicatorInvalidateTime=1e4,this._typingIndicatorThrottle=1e3,this._websocketResponseTimeout=1e4,this._sessionTokenRefreshTimeout=60,this._useMemberInfoInMessage=e,this._typingIndicatorInvalidateTime=t,this._typingIndicatorThrottle=s,this._websocketResponseTimeout=i,this._sessionTokenRefreshTimeout=o,this.websocketPayloadDecompression=n}get useMemberInfoInMessage(){return this._useMemberInfoInMessage}set useMemberInfoInMessage(e){d("boolean",e)&&(this._useMemberInfoInMessage=e)}get typingIndicatorInvalidateTime(){return this._typingIndicatorInvalidateTime}set typingIndicatorInvalidateTime(e){d("number",e)&&(this._typingIndicatorInvalidateTime=e)}get typingIndicatorThrottle(){return this._typingIndicatorThrottle}set typingIndicatorThrottle(e){d("number",e)&&e>=1e3&&e<=9e3&&(this._typingIndicatorThrottle=e)}get websocketResponseTimeout(){return this._websocketResponseTimeout}set websocketResponseTimeout(e){d("number",e)&&e>=5e3&&e<=3e4&&(this._websocketResponseTimeout=e)}get sessionTokenRefreshTimeout(){return this._sessionTokenRefreshTimeout}set sessionTokenRefreshTimeout(e){d("number",e)&&(e<60?e=60:e>1800&&(e=1800),this._sessionTokenRefreshTimeout=e)}}const E={encrypt:e=>e,decrypt:e=>e};class f{constructor({store:e}){this._preference=new Map,this._store=e}_savePreferenceKeys(){return e(this,void 0,void 0,(function*(){yield this._store.set({key:this._keysAddress,value:[...this._preference.keys()]})}))}init(t,s=1){var i;return e(this,void 0,void 0,(function*(){this._version=s,this._keysAddress=t;const e=`${t}.metadata.version`,n=yield this._store.get(e),o=null!==(i=yield this._store.get(t))&&void 0!==i?i:[];if(!n||n.version<this._version){switch(this._version){case 9:{const e=o.find((e=>e.includes("groupchannel/sync.meta")));e&&(yield this._store.remove(e));break}default:yield this._resetPreferenceData(o)}yield this._updatePreferenceVersionInfo(e)}else for(const e of o){const t=yield this._store.get(e);t&&this._preference.set(e,t)}}))}_updatePreferenceVersionInfo(t){return e(this,void 0,void 0,(function*(){yield this._store.set({key:t,value:{version:this._version}})}))}_resetPreferenceData(t){return e(this,void 0,void 0,(function*(){this._preference=new Map,yield this._store.removeMany(t)}))}get(t){return e(this,void 0,void 0,(function*(){return this._preference.get(t)}))}set(t,s){return e(this,void 0,void 0,(function*(){const e=!this._preference.has(t);yield this._store.set({key:t,value:s}),this._preference.set(t,s),e&&(yield this._savePreferenceKeys())}))}remove(t){return e(this,void 0,void 0,(function*(){yield this._store.remove(t),this._preference.delete(t),yield this._savePreferenceKeys()}))}clear(){return e(this,void 0,void 0,(function*(){yield this._store.removeMany([...this._preference.keys()]),this._preference.clear(),yield this._savePreferenceKeys()}))}}class g{constructor({encryption:e,store:t,localCacheEnabled:s,localCacheConfig:i}){this.store=t,this.preference=new f({store:t}),this.encryption=null!=e?e:E,this.localCacheEnabled=s,this.localCacheConfig=i}replaceStore(e){this.store=e,this.preference=new f({store:e})}}var S,v,m,C,T,y;exports.PushTokenRegistrationState=void 0,(S=exports.PushTokenRegistrationState||(exports.PushTokenRegistrationState={})).SUCCESS="success",S.PENDING="pending",S.ERROR="error",exports.PushTriggerOption=void 0,(v=exports.PushTriggerOption||(exports.PushTriggerOption={})).DEFAULT="default",v.ALL="all",v.MENTION_ONLY="mention_only",v.OFF="off",exports.PushTokenType=void 0,(m=exports.PushTokenType||(exports.PushTokenType={})).FCM="gcm",m.APNS="apns",m.UNKNOWN="unknown",exports.AuthTokenType=void 0,(C=exports.AuthTokenType||(exports.AuthTokenType={})).SESSION_TOKEN="session_token",C.ACCESS_TOKEN="access_token",exports.PushTemplate=void 0,(T=exports.PushTemplate||(exports.PushTemplate={})).ALTERNATIVE="alternative",T.DEFAULT="default",exports.CachedDataClearOrder=void 0,(y=exports.CachedDataClearOrder||(exports.CachedDataClearOrder={})).CUSTOM="custom",y.MESSAGE_COLLECTION_ACCESSED_AT="messagecollection_accessed_at";class A{constructor({maxSize:e=256,clearOrder:t=exports.CachedDataClearOrder.MESSAGE_COLLECTION_ACCESSED_AT,customClearOrderComparator:s,enableAutoResend:i=!0}={}){this._clearOrderComparatorUseMessageCollectionAccessedAt=(e,t)=>e.channel.messageCollectionLastAccessedAt===t.channel.messageCollectionLastAccessedAt?e.channel.lastMessage&&!t.channel.lastMessage?1:!e.channel.lastMessage&&t.channel.lastMessage?-1:e.channel.lastMessage||t.channel.lastMessage?e.channel.lastMessage.createdAt-t.channel.lastMessage.createdAt:0:e.channel.messageCollectionLastAccessedAt>t.channel.messageCollectionLastAccessedAt?1:-1,this._maxSize=Math.max(e,64),s?(this._clearOrder=t,this._customClearOrderComparator=s):this._clearOrder=exports.CachedDataClearOrder.MESSAGE_COLLECTION_ACCESSED_AT,this._enableAutoResend=i}get maxSize(){return this._maxSize}get clearOrder(){return this._clearOrder}get clearOrderComparator(){var e;return this._clearOrder===exports.CachedDataClearOrder.MESSAGE_COLLECTION_ACCESSED_AT?this._clearOrderComparatorUseMessageCollectionAccessedAt:null!==(e=this._customClearOrderComparator)&&void 0!==e?e:this._clearOrderComparatorUseMessageCollectionAccessedAt}get enableAutoResend(){return this._enableAutoResend}}var N;exports.SessionService=void 0,(N=exports.SessionService||(exports.SessionService={})).FEED="feed",N.CHAT="chat",N.CHAT_API="chat_api";class w{constructor(){this.isRefreshing=!1}get hasSession(){return!!this.sessionKey}get hasChatServicePermission(){var e;return!!(null===(e=this.services)||void 0===e?void 0:e.includes(exports.SessionService.CHAT))}clear(){this.authToken=void 0,this.sessionKey=void 0,this.services=[]}}const b=()=>{let e=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(t=>{const s=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"===t?s:3&s|8).toString(16)}))};class I{constructor({container:e}){this._container={},this._container=e,this.key=b()}_register(e,t,s){var i;return e in this._container||(this._container[e]=new Map),null===(i=this._container[e])||void 0===i||i.set(this.key,{occurence:t,handler:s}),this}on(e,t){return this._register(e,-1,t)}once(e,t){return this._register(e,1,t)}close(){Object.keys(this._container).forEach((e=>{var t;null===(t=this._container[e])||void 0===t||t.delete(this.key)}))}}class x{constructor(){this._container={}}on(e,t){return new I({container:this._container}).on(e,t)}once(e,t){return new I({container:this._container}).once(e,t)}dispatch(e,t){const s=this._container[e];if(s){const e=[];for(const i of s.keys()){const n=s.get(i);n.handler(t),n.occurence>0&&(n.occurence--,0===n.occurence&&e.push(i))}e.forEach((e=>s.delete(e)))}}}class R{constructor(){this._dispatcher=new x}on(e){return this._dispatcher.on("event",e)}once(e){return this._dispatcher.once("event",e)}dispatch(e){this._dispatcher.dispatch("event",e)}}class D{}const O=e=>{const t={};return e&&Object.keys(e).forEach((s=>{void 0===e[s]||Number.isNaN(e[s])||null===e[s]||(t[s]=e[s])})),t},k=e=>{if(null!=e){if("object"==typeof e){if(Array.isArray(e)){const t=[...e];for(let e=0;e<t.length;e++)t[e]=k(t[e]);return t}return Object.keys(e).forEach((t=>{null===e[t]&&delete e[t]})),e}return e}};var L,P,U,M,q,F,H,V,z,G,K,B,Q;exports.ChannelType=void 0,(L=exports.ChannelType||(exports.ChannelType={})).BASE="base",L.GROUP="group",L.OPEN="open",L.FEED="feed",exports.Role=void 0,(P=exports.Role||(exports.Role={})).OPERATOR="operator",P.NONE="none",exports.MutedState=void 0,(U=exports.MutedState||(exports.MutedState={})).MUTED="muted",U.UNMUTED="unmuted",exports.MessageType=void 0,(M=exports.MessageType||(exports.MessageType={})).BASE="base",M.USER="user",M.FILE="file",M.ADMIN="admin",exports.MessageTypeFilter=void 0,(q=exports.MessageTypeFilter||(exports.MessageTypeFilter={})).ALL="",q.USER="MESG",q.FILE="FILE",q.ADMIN="ADMM",exports.ServerSideMessageType=void 0,(F=exports.ServerSideMessageType||(exports.ServerSideMessageType={})).USER="MESG",F.FILE="FILE",F.ADMIN="ADMM",exports.MentionType=void 0,(H=exports.MentionType||(exports.MentionType={})).USERS="users",H.CHANNEL="channel",exports.ReplyType=void 0,(V=exports.ReplyType||(exports.ReplyType={})).ALL="all",V.NONE="none",V.ONLY_REPLY_TO_CHANNEL="only_reply_to_channel",exports.PushNotificationDeliveryOption=void 0,(z=exports.PushNotificationDeliveryOption||(exports.PushNotificationDeliveryOption={})).DEFAULT="default",z.SUPPRESS="suppress",exports.SendingStatus=void 0,(G=exports.SendingStatus||(exports.SendingStatus={})).PENDING="pending",G.SCHEDULED="scheduled",G.SUCCEEDED="succeeded",G.FAILED="failed",G.CANCELED="canceled",exports.MessageReviewStatus=void 0,(K=exports.MessageReviewStatus||(exports.MessageReviewStatus={})).INREVIEW="InReview",K.APPROVED="Approved",exports.NotificationPriority=void 0,(B=exports.NotificationPriority||(exports.NotificationPriority={})).HIGH="high",B.NORMAL="normal",B.LOW="low",exports.MessageTemplateListOrder=void 0,(Q=exports.MessageTemplateListOrder||(exports.MessageTemplateListOrder={})).CREATED_AT="created_at",Q.UPDATED_AT="updated_at";const W="v3",j=`/${W}/users`,$=`/${W}/sdk/users`,Z=`/${W}/storage/file`,Y=`/${W}/group_channels`,X=`/${W}/sdk/group_channels`,J=`/${W}/open_channels`,ee=`/${W}/sdk/open_channels`,te=`/${W}/search`,se=`/${W}/report`,ie=`/${W}/emojis`,ne=`/${W}/emoji_categories`,oe=`/${W}/polls`,re=`/${W}/scheduled_messages`,ae=`/${W}/sdk/ui_kit/configuration`,de=`/${W}/sdk/statistics`,le=`/${W}/sdk/notification_statistics`,ce=`/${W}/notifications`,he=`/${W}/notifications/users`,ue=`/${W}/message_templates`,_e=`/${W}/sdk/push_delivery`,pe=`/${W}/forms`,Ee=`/${W}/report_category`,fe=`/${W}/sdk/applications/settings`,ge=e=>{switch(e){case exports.ChannelType.FEED:case exports.ChannelType.GROUP:return Y;case exports.ChannelType.OPEN:return J;default:return null}},Se=(e,t,s)=>{switch(e){case exports.MentionType.CHANNEL:return!0;case exports.MentionType.USERS:if(t)for(const e of t)if(e===s)return!0}return!1},ve=(e,t,s)=>{var i;let n=t||new FormData;for(const t in e){if(!e.hasOwnProperty(t))continue;const o=e[t],r=s?`${s}[${t}]`:t;u(o)?n.append(r,o,null!==(i=o.name)&&void 0!==i?i:"filename"):"object"!=typeof o||null===o||Array.isArray(o)||o instanceof Blob?n.append(r,String(o)):n=ve(o,n,r)}return n};var me;exports.APIRequestMethod=void 0,(me=exports.APIRequestMethod||(exports.APIRequestMethod={})).GET="GET",me.POST="POST",me.PUT="PUT",me.DELETE="DELETE";class Ce extends D{constructor(){super(...arguments),this.params={},this.requireAuth=!0,this.headers={},this.requestId=b()}encodeParams(e){return null==e||""===e?encodeURIComponent(""):Array.isArray(e)?e.map((e=>this.encodeParams(e))).join(","):"object"==typeof e?encodeURIComponent(JSON.stringify(e)):encodeURIComponent(String(e))}get query(){const e=O(this.params);return`?${Object.keys(e).map((t=>`${encodeURIComponent(t)}=${this.encodeParams(e[t])}`)).join("&")}`}get payload(){const e=O(this.params);return Object.keys(e).some((t=>u(e[t])))?ve(e):JSON.stringify(e)}get hasSessionKey(){return void 0!==this.headers["Session-Key"]}}class Te extends D{constructor(e,t){super(),this._iid=e,this._payload=t}get payload(){return Object.assign({},this._payload)}as(e){return new e(this._iid,this.payload)}}class ye extends D{constructor(e){super(),this.requestId=e}}class Ae extends D{constructor({expires_in:e,reason:t=exports.SendbirdErrorCode.SESSION_KEY_EXPIRED,message:s=""}){switch(super(),this.expiresIn=null!=e?e:0,t){case exports.SendbirdErrorCode.SESSION_KEY_EXPIRED:case exports.SendbirdErrorCode.SESSION_TOKEN_EXPIRED:case exports.SendbirdErrorCode.SESSION_REVOKED:case exports.SendbirdErrorCode.USER_AUTH_DEACTIVATED:case exports.SendbirdErrorCode.USER_AUTH_DELETED_OR_NOT_FOUND:this.error=new o({code:t,message:s})}}get invalidateSessionToken(){var e;return!!(null===(e=this.error)||void 0===e?void 0:e.isSessionTokenExpiredError)}}class Ne extends D{constructor(e,t,s,i=""){var n;super(),this._iid=e,this.code=t,this.payload=s,this.requestId=null!==(n=s.req_id)&&void 0!==n?n:i}static createFromRawMessage(e,t){let s=t.substring(0,4),i={};try{i=JSON.parse(t.substring(4))}catch(e){s="NOOP"}finally{return new Ne(e,s,i)}}convertToMessage(){return`${this.code}${JSON.stringify(this.payload)}\n`}as(e){return new e(this._iid,this.code,this.payload)}}class we extends D{constructor({code:e,ackRequired:t,payload:s={}}){var i;super(),this.code=e,this.payload=s,this.requestId=null!==(i=this.payload.req_id)&&void 0!==i?i:b(),this.ackRequired=t,this.payload.req_id=this.requestId}convertToMessage(){return`${this.code}${JSON.stringify(this.payload)}\n`}}class be extends Ce{constructor({userId:e,authToken:t,services:s,expiringSession:i=!0}){super(),this.path=`${j}/${e}/session_key`,this.method=exports.APIRequestMethod.POST,this.params=O({token:t,services:s,expiring_session:!!i}),this.requireAuth=!1}}class Ie extends we{constructor({authToken:e,expiringSession:t=!0,requestId:s}){super({code:"LOGI",payload:O({token:e,expiring_session:t?1:0,req_id:s}),ackRequired:!0})}}class xe extends Te{constructor(e,t){super(e,t);const{key:s,expires_at:i,services:n}=t;this.key=s,this.expiresAt=i,this.services=n}}class Re extends Ne{constructor(e,t,s){var i;super(e,"LOGI",s),this.error=null,this.newKey=null,this.newKey=null!==(i=s.new_key)&&void 0!==i?i:null,this.error=s.error?new o(s):null}}class De extends D{constructor(e){super(),this.statLog=e}}class Oe extends D{constructor({request:e,deferred:t,error:s=o.requestFailed}){super(),this.request=e,this.deferred=t,this.error=s}}var ke;exports.StatType=void 0,(ke=exports.StatType||(exports.StatType={})).FEATURE_LOCALCACHE="feature:local_cache",ke.FEATURE_LOCALCACHE_EVENT="feature:local_cache_event",ke.NOTIFICATION="noti:stats",ke.WEBSOCKET_CONNECT="ws:connect",ke.WEBSOCKET_DISCONNECT="ws:disconnect",ke.API_RESULT="api:result";class Le{constructor({type:e,data:t,ts:s=Date.now()}){this.type=e,this.createdAt=s,this.data=t}static payloadify(e){return O({stat_type:e.type,ts:e.createdAt,data:O(e.data)})}}const Pe=()=>"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"==navigator.product,Ue=()=>!("undefined"==typeof navigator||!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Windows Phone/i.test(navigator.userAgent));var Me,qe,Fe,He;exports.SendbirdProduct=void 0,(qe=exports.SendbirdProduct||(exports.SendbirdProduct={})).CHAT="chat",qe.CALLS="calls",qe.DESK="desk",qe.LIVE="live",qe.UIKIT_CHAT="uikit-chat",qe.UIKIT_LIVE="uikit-live",exports.SendbirdPlatform=void 0,(Fe=exports.SendbirdPlatform||(exports.SendbirdPlatform={})).ANDROID="android",Fe.IOS="ios",Fe.JS="js",Fe.UNREAL="unreal",Fe.UNITY="unity",Fe.REACT_NATIVE="react-native",Fe.FLUTTER="flutter",exports.DeviceOsPlatform=void 0,(He=exports.DeviceOsPlatform||(exports.DeviceOsPlatform={})).ANDROID="android",He.IOS="ios",He.WEB="web",He.MOBILE_WEB="mobile_web",He.WINDOWS="windows";class Ve{}Me=Ve,Ve._getFrameWork=()=>{if("undefined"!=typeof window){if(window.__REACT__)return"react";if(window.__VUE__)return"vue";const 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""},Ve.sendbirdSdkUserAgentWithExtension=e=>{let t={main_sdk_info:`chat/${Pe()?exports.SendbirdPlatform.REACT_NATIVE:exports.SendbirdPlatform.JS}/${i.SDK_VERSION}`,device_os_platform:Ue()?"mobile-web":"web",os_version:i.OS_VERSION};if(e){const{sendbirdExtensions:s,deviceOS:i,customData:n={}}=e;i.version&&(t.os_version=i.version),i.platform&&(t.device_os_platform=i.platform),s.length>0&&(t.extension_sdk_info=s.map((({product:e,platform:t,version:s})=>`${e}/${t}/${s}`)).join(",")),Object.keys(t).forEach((e=>delete n[e])),Object.keys(n).length>0&&(t=Object.assign(Object.assign({},t),n))}const s=Me._getFrameWork();return s&&(t.javascript_framework=s),Object.entries(t).map((([e,t])=>`${e}=${t}`)).join("&")},Ve.userAgentWithExtension=e=>{const t=Pe()?"reactnative":"JS",s=e.sb_syncmanager?`s${e.sb_syncmanager}`:"",n=e.sb_uikit?`u${e.sb_uikit}`:"",o=e["device-os-platform"]?`o${e["device-os-platform"]}`:Ue()?"omobile-web":"oweb";return`${t}/c${i.SDK_VERSION}/${s}/${n}/${o}`};class ze{constructor(){this.promise=new Promise(((e,t)=>{this.resolve=e,this.reject=e=>{t(e)}}))}}class Ge extends D{constructor(e){super(),this.requestId=e.requestId}}class Ke extends Ce{constructor(e){super(),this.method=exports.APIRequestMethod.DELETE,this.path=`${ge(e.channelType)}/${e.channelUrl}/messages/${e.messageId}`,e.messageToken&&(this.params=O({mesg_token:e.messageToken}))}}class Be{constructor(e,{session:t,sdkState:s,dispatcher:i,logger:n,useFetchCompat:o=!1}){this._abortControl=new Map,this._shouldImportFetchCompat=!1,this._iid=e,this._session=t,this._sdkState=s,this._dispatcher=i,this._dispatcher.on((e=>{e instanceof ye&&this.cancel(e.requestId)})),this._logger=n,this._shouldImportFetchCompat=o}_createHeader(e,t){const{appId:s,appVersion:n,sendbirdRuntimeEnvironment:o}=this._sdkState,r=Object.assign(Object.assign({},e.headers),{SendBird:`JS,${i.OS_VERSION},${i.SDK_VERSION},${s}${n?`,${n}`:""}`,"SB-User-Agent":Ve.userAgentWithExtension(this._sdkState.extensions),"Request-Sent-Timestamp":Date.now().toString(),"SB-SDK-User-Agent":Ve.sendbirdSdkUserAgentWithExtension(o)});return t||(r["Content-Type"]="application/json; charset=utf-8"),e.requireAuth&&!e.hasSessionKey&&this._session.hasSession&&(r["Session-Key"]=this._session.sessionKey),r["App-Id"]=s,this._session&&this._session.authToken&&(r["Access-Token"]=this._session.authToken),r}_statLogApiResult(e,t,s){e.path.includes("/sdk/statistics")||this._dispatcher.dispatch(new De(new Le({type:exports.StatType.API_RESULT,data:{endpoint:e.path,method:e.method,success:!s,latency:Date.now()-t,error_code:null==s?void 0:s.code,error_description:null==s?void 0:s.message}})))}_isBodyRequired(e){const{method:t}=e;return t!==exports.APIRequestMethod.GET&&(t!==exports.APIRequestMethod.DELETE||e instanceof Ke)}send(t){return e(this,void 0,void 0,(function*(){const{path:e,method:s,uploadProgressHandler:i}=t,n=this._isBodyRequired(t),{api:r}=this._sdkState,a=`${r.host}${e}${n?"":t.query}`,d=n?t.payload:null,l=this._createHeader(t,d instanceof FormData?d:void 0),c=new AbortController,{signal:h}=c;this._abortControl.set(t.requestId,c);const u=Date.now();try{if(i){const{xmlHttpRequest:e}=yield Promise.resolve().then((function(){return require("./__bundle-b1a4325a.cjs")}));try{const s=yield e(this._iid,{requestId:t.requestId,method:t.method,url:a,headers:l,data:null!=d?d:void 0,uploadProgressHandler:i});return this._logger.debug("receive api response",t.requestId),this._statLogApiResult(t,u),s}catch(e){if(!(e instanceof o&&e.code===exports.SendbirdErrorCode.XMLHTTPREQUEST_NOT_SUPPORTED))throw e;this._logger.debug("XMLHttpRequest is not available in this environment. progressHandler is ignored.")}}if(this._shouldImportFetchCompat){this._shouldImportFetchCompat=!1;("undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||"undefined"!=typeof global&&global||{fetch:null}).fetch=null}"undefined"==typeof AbortController&&(yield Promise.resolve().then((function(){return require("./__bundle-093a1164.cjs")}))),"function"!=typeof fetch&&(yield Promise.resolve().then((function(){return require("./__bundle-38c66c0d.cjs")})));const e=yield fetch(a,{method:s,body:d,headers:l,signal:h}),n=yield e.json();if(e.ok||e.redirected)return this._logger.debug("receive api response",t.requestId),this._statLogApiResult(t,u),new Te(this._iid,n);if(n){const e=new o(n);if(e.isSessionExpiredError){if(this._dispatcher.dispatch(new Ae({reason:e.code,message:e.message})),!(t instanceof be)){const s=new ze;return this._dispatcher.dispatch(new Oe({request:t,deferred:s,error:e})),s.promise}throw e}throw e.isSessionInvalidatedError?(this._dispatcher.dispatch(new Ae({reason:e.code,message:e.message})),e):e}throw o.requestFailed}catch(e){throw this._statLogApiResult(t,u,e),e instanceof o?(this._logger.debug("fail api request",e),e):"AbortError"===(null==e?void 0:e.name)?o.requestCanceled:(this._logger.debug("fail api request",e),o.networkError)}}))}cancel(e){if(this._abortControl.has(e)){this._abortControl.get(e).abort(),this._abortControl.delete(e)}this._dispatcher.dispatch(new Ge({requestId:e}))}cancelAll(){for(const e of this._abortControl.values())e.abort();this._abortControl.clear(),this._dispatcher.dispatch(new Ge({}))}}const Qe=()=>{}; /*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */function We(e){let t=e.length;for(;--t>=0;)e[t]=0}const je=256,$e=286,Ze=30,Ye=15,Xe=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]),Je=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]),et=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),tt=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),st=new Array(576);We(st);const it=new Array(60);We(it);const nt=new Array(512);We(nt);const ot=new Array(256);We(ot);const rt=new Array(29);We(rt);const at=new Array(Ze);function dt(e,t,s,i,n){this.static_tree=e,this.extra_bits=t,this.extra_base=s,this.elems=i,this.max_length=n,this.has_stree=e&&e.length}let lt,ct,ht;function ut(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}We(at);const _t=e=>e<256?nt[e]:nt[256+(e>>>7)],pt=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},Et=(e,t,s)=>{e.bi_valid>16-s?(e.bi_buf|=t<<e.bi_valid&65535,pt(e,e.bi_buf),e.bi_buf=t>>16-e.bi_valid,e.bi_valid+=s-16):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=s)},ft=(e,t,s)=>{Et(e,s[2*t],s[2*t+1])},gt=(e,t)=>{let s=0;do{s|=1&e,e>>>=1,s<<=1}while(--t>0);return s>>>1},St=(e,t,s)=>{const i=new Array(16);let n,o,r=0;for(n=1;n<=Ye;n++)r=r+s[n-1]<<1,i[n]=r;for(o=0;o<=t;o++){let t=e[2*o+1];0!==t&&(e[2*o]=gt(i[t]++,t))}},vt=e=>{let t;for(t=0;t<$e;t++)e.dyn_ltree[2*t]=0;for(t=0;t<Ze;t++)e.dyn_dtree[2*t]=0;for(t=0;t<19;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.sym_next=e.matches=0},mt=e=>{e.bi_valid>8?pt(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},Ct=(e,t,s,i)=>{const n=2*t,o=2*s;return e[n]<e[o]||e[n]===e[o]&&i[t]<=i[s]},Tt=(e,t,s)=>{const i=e.heap[s];let n=s<<1;for(;n<=e.heap_len&&(n<e.heap_len&&Ct(t,e.heap[n+1],e.heap[n],e.depth)&&n++,!Ct(t,i,e.heap[n],e.depth));)e.heap[s]=e.heap[n],s=n,n<<=1;e.heap[s]=i},yt=(e,t,s)=>{let i,n,o,r,a=0;if(0!==e.sym_next)do{i=255&e.pending_buf[e.sym_buf+a++],i+=(255&e.pending_buf[e.sym_buf+a++])<<8,n=e.pending_buf[e.sym_buf+a++],0===i?ft(e,n,t):(o=ot[n],ft(e,o+je+1,t),r=Xe[o],0!==r&&(n-=rt[o],Et(e,n,r)),i--,o=_t(i),ft(e,o,s),r=Je[o],0!==r&&(i-=at[o],Et(e,i,r)))}while(a<e.sym_next);ft(e,256,t)},At=(e,t)=>{const s=t.dyn_tree,i=t.stat_desc.static_tree,n=t.stat_desc.has_stree,o=t.stat_desc.elems;let r,a,d,l=-1;for(e.heap_len=0,e.heap_max=573,r=0;r<o;r++)0!==s[2*r]?(e.heap[++e.heap_len]=l=r,e.depth[r]=0):s[2*r+1]=0;for(;e.heap_len<2;)d=e.heap[++e.heap_len]=l<2?++l:0,s[2*d]=1,e.depth[d]=0,e.opt_len--,n&&(e.static_len-=i[2*d+1]);for(t.max_code=l,r=e.heap_len>>1;r>=1;r--)Tt(e,s,r);d=o;do{r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Tt(e,s,1),a=e.heap[1],e.heap[--e.heap_max]=r,e.heap[--e.heap_max]=a,s[2*d]=s[2*r]+s[2*a],e.depth[d]=(e.depth[r]>=e.depth[a]?e.depth[r]:e.depth[a])+1,s[2*r+1]=s[2*a+1]=d,e.heap[1]=d++,Tt(e,s,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],((e,t)=>{const s=t.dyn_tree,i=t.max_code,n=t.stat_desc.static_tree,o=t.stat_desc.has_stree,r=t.stat_desc.extra_bits,a=t.stat_desc.extra_base,d=t.stat_desc.max_length;let l,c,h,u,_,p,E=0;for(u=0;u<=Ye;u++)e.bl_count[u]=0;for(s[2*e.heap[e.heap_max]+1]=0,l=e.heap_max+1;l<573;l++)c=e.heap[l],u=s[2*s[2*c+1]+1]+1,u>d&&(u=d,E++),s[2*c+1]=u,c>i||(e.bl_count[u]++,_=0,c>=a&&(_=r[c-a]),p=s[2*c],e.opt_len+=p*(u+_),o&&(e.static_len+=p*(n[2*c+1]+_)));if(0!==E){do{for(u=d-1;0===e.bl_count[u];)u--;e.bl_count[u]--,e.bl_count[u+1]+=2,e.bl_count[d]--,E-=2}while(E>0);for(u=d;0!==u;u--)for(c=e.bl_count[u];0!==c;)h=e.heap[--l],h>i||(s[2*h+1]!==u&&(e.opt_len+=(u-s[2*h+1])*s[2*h],s[2*h+1]=u),c--)}})(e,t),St(s,l,e.bl_count)},Nt=(e,t,s)=>{let i,n,o=-1,r=t[1],a=0,d=7,l=4;for(0===r&&(d=138,l=3),t[2*(s+1)+1]=65535,i=0;i<=s;i++)n=r,r=t[2*(i+1)+1],++a<d&&n===r||(a<l?e.bl_tree[2*n]+=a:0!==n?(n!==o&&e.bl_tree[2*n]++,e.bl_tree[32]++):a<=10?e.bl_tree[34]++:e.bl_tree[36]++,a=0,o=n,0===r?(d=138,l=3):n===r?(d=6,l=3):(d=7,l=4))},wt=(e,t,s)=>{let i,n,o=-1,r=t[1],a=0,d=7,l=4;for(0===r&&(d=138,l=3),i=0;i<=s;i++)if(n=r,r=t[2*(i+1)+1],!(++a<d&&n===r)){if(a<l)do{ft(e,n,e.bl_tree)}while(0!=--a);else 0!==n?(n!==o&&(ft(e,n,e.bl_tree),a--),ft(e,16,e.bl_tree),Et(e,a-3,2)):a<=10?(ft(e,17,e.bl_tree),Et(e,a-3,3)):(ft(e,18,e.bl_tree),Et(e,a-11,7));a=0,o=n,0===r?(d=138,l=3):n===r?(d=6,l=3):(d=7,l=4)}};let bt=!1;const It=(e,t,s,i)=>{Et(e,0+(i?1:0),3),mt(e),pt(e,s),pt(e,~s),s&&e.pending_buf.set(e.window.subarray(t,t+s),e.pending),e.pending+=s};var xt=(e,t,s,i)=>{let n,o,r=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=(e=>{let t,s=4093624447;for(t=0;t<=31;t++,s>>>=1)if(1&s&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t<je;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0})(e)),At(e,e.l_desc),At(e,e.d_desc),r=(e=>{let t;for(Nt(e,e.dyn_ltree,e.l_desc.max_code),Nt(e,e.dyn_dtree,e.d_desc.max_code),At(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*tt[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),n=e.opt_len+3+7>>>3,o=e.static_len+3+7>>>3,o<=n&&(n=o)):n=o=s+5,s+4<=n&&-1!==t?It(e,t,s,i):4===e.strategy||o===n?(Et(e,2+(i?1:0),3),yt(e,st,it)):(Et(e,4+(i?1:0),3),((e,t,s,i)=>{let n;for(Et(e,t-257,5),Et(e,s-1,5),Et(e,i-4,4),n=0;n<i;n++)Et(e,e.bl_tree[2*tt[n]+1],3);wt(e,e.dyn_ltree,t-1),wt(e,e.dyn_dtree,s-1)})(e,e.l_desc.max_code+1,e.d_desc.max_code+1,r+1),yt(e,e.dyn_ltree,e.dyn_dtree)),vt(e),i&&mt(e)},Rt={_tr_init:e=>{bt||((()=>{let e,t,s,i,n;const o=new Array(16);for(s=0,i=0;i<28;i++)for(rt[i]=s,e=0;e<1<<Xe[i];e++)ot[s++]=i;for(ot[s-1]=i,n=0,i=0;i<16;i++)for(at[i]=n,e=0;e<1<<Je[i];e++)nt[n++]=i;for(n>>=7;i<Ze;i++)for(at[i]=n<<7,e=0;e<1<<Je[i]-7;e++)nt[256+n++]=i;for(t=0;t<=Ye;t++)o[t]=0;for(e=0;e<=143;)st[2*e+1]=8,e++,o[8]++;for(;e<=255;)st[2*e+1]=9,e++,o[9]++;for(;e<=279;)st[2*e+1]=7,e++,o[7]++;for(;e<=287;)st[2*e+1]=8,e++,o[8]++;for(St(st,287,o),e=0;e<Ze;e++)it[2*e+1]=5,it[2*e]=gt(e,5);lt=new dt(st,Xe,257,$e,Ye),ct=new dt(it,Je,0,Ze,Ye),ht=new dt(new Array(0),et,0,19,7)})(),bt=!0),e.l_desc=new ut(e.dyn_ltree,lt),e.d_desc=new ut(e.dyn_dtree,ct),e.bl_desc=new ut(e.bl_tree,ht),e.bi_buf=0,e.bi_valid=0,vt(e)},_tr_stored_block:It,_tr_flush_block:xt,_tr_tally:(e,t,s)=>(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=s,0===t?e.dyn_ltree[2*s]++:(e.matches++,t--,e.dyn_ltree[2*(ot[s]+je+1)]++,e.dyn_dtree[2*_t(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{Et(e,2,3),ft(e,256,st),(e=>{16===e.bi_valid?(pt(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)})(e)}};var Dt=(e,t,s,i)=>{let n=65535&e,o=e>>>16&65535,r=0;for(;0!==s;){r=s>2e3?2e3:s,s-=r;do{n=n+t[i++]|0,o=o+n|0}while(--r);n%=65521,o%=65521}return n|o<<16};const Ot=new Uint32Array((()=>{let e,t=[];for(var s=0;s<256;s++){e=s;for(var i=0;i<8;i++)e=1&e?3988292384^e>>>1:e>>>1;t[s]=e}return t})());var kt=(e,t,s,i)=>{const n=Ot,o=i+s;e^=-1;for(let s=i;s<o;s++)e=e>>>8^n[255&(e^t[s])];return~e},Lt={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"},Pt={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:Ut,_tr_stored_block:Mt,_tr_flush_block:qt,_tr_tally:Ft,_tr_align:Ht}=Rt,{Z_NO_FLUSH:Vt,Z_PARTIAL_FLUSH:zt,Z_FULL_FLUSH:Gt,Z_FINISH:Kt,Z_BLOCK:Bt,Z_OK:Qt,Z_STREAM_END:Wt,Z_STREAM_ERROR:jt,Z_DATA_ERROR:$t,Z_BUF_ERROR:Zt,Z_DEFAULT_COMPRESSION:Yt,Z_FILTERED:Xt,Z_HUFFMAN_ONLY:Jt,Z_RLE:es,Z_FIXED:ts,Z_DEFAULT_STRATEGY:ss,Z_UNKNOWN:is,Z_DEFLATED:ns}=Pt,os=258,rs=262,as=42,ds=113,ls=666,cs=(e,t)=>(e.msg=Lt[t],t),hs=e=>2*e-(e>4?9:0),us=e=>{let t=e.length;for(;--t>=0;)e[t]=0},_s=e=>{let t,s,i,n=e.w_size;t=e.hash_size,i=t;do{s=e.head[--i],e.head[i]=s>=n?s-n:0}while(--t);t=n,i=t;do{s=e.prev[--i],e.prev[i]=s>=n?s-n:0}while(--t)};let ps=(e,t,s)=>(t<<e.hash_shift^s)&e.hash_mask;const Es=e=>{const t=e.state;let s=t.pending;s>e.avail_out&&(s=e.avail_out),0!==s&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+s),e.next_out),e.next_out+=s,t.pending_out+=s,e.total_out+=s,e.avail_out-=s,t.pending-=s,0===t.pending&&(t.pending_out=0))},fs=(e,t)=>{qt(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,Es(e.strm)},gs=(e,t)=>{e.pending_buf[e.pending++]=t},Ss=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},vs=(e,t,s,i)=>{let n=e.avail_in;return n>i&&(n=i),0===n?0:(e.avail_in-=n,t.set(e.input.subarray(e.next_in,e.next_in+n),s),1===e.state.wrap?e.adler=Dt(e.adler,t,n,s):2===e.state.wrap&&(e.adler=kt(e.adler,t,n,s)),e.next_in+=n,e.total_in+=n,n)},ms=(e,t)=>{let s,i,n=e.max_chain_length,o=e.strstart,r=e.prev_length,a=e.nice_match;const d=e.strstart>e.w_size-rs?e.strstart-(e.w_size-rs):0,l=e.window,c=e.w_mask,h=e.prev,u=e.strstart+os;let _=l[o+r-1],p=l[o+r];e.prev_length>=e.good_match&&(n>>=2),a>e.lookahead&&(a=e.lookahead);do{if(s=t,l[s+r]===p&&l[s+r-1]===_&&l[s]===l[o]&&l[++s]===l[o+1]){o+=2,s++;do{}while(l[++o]===l[++s]&&l[++o]===l[++s]&&l[++o]===l[++s]&&l[++o]===l[++s]&&l[++o]===l[++s]&&l[++o]===l[++s]&&l[++o]===l[++s]&&l[++o]===l[++s]&&o<u);if(i=os-(u-o),o=u-os,i>r){if(e.match_start=t,r=i,i>=a)break;_=l[o+r-1],p=l[o+r]}}}while((t=h[t&c])>d&&0!=--n);return r<=e.lookahead?r:e.lookahead},Cs=e=>{const t=e.w_size;let s,i,n;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-rs)&&(e.window.set(e.window.subarray(t,t+t-i),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),_s(e),i+=t),0===e.strm.avail_in)break;if(s=vs(e.strm,e.window,e.strstart+e.lookahead,i),e.lookahead+=s,e.lookahead+e.insert>=3)for(n=e.strstart-e.insert,e.ins_h=e.window[n],e.ins_h=ps(e,e.ins_h,e.window[n+1]);e.insert&&(e.ins_h=ps(e,e.ins_h,e.window[n+3-1]),e.prev[n&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=n,n++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead<rs&&0!==e.strm.avail_in)},Ts=(e,t)=>{let s,i,n,o=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,r=0,a=e.strm.avail_in;do{if(s=65535,n=e.bi_valid+42>>3,e.strm.avail_out<n)break;if(n=e.strm.avail_out-n,i=e.strstart-e.block_start,s>i+e.strm.avail_in&&(s=i+e.strm.avail_in),s>n&&(s=n),s<o&&(0===s&&t!==Kt||t===Vt||s!==i+e.strm.avail_in))break;r=t===Kt&&s===i+e.strm.avail_in?1:0,Mt(e,0,0,r),e.pending_buf[e.pending-4]=s,e.pending_buf[e.pending-3]=s>>8,e.pending_buf[e.pending-2]=~s,e.pending_buf[e.pending-1]=~s>>8,Es(e.strm),i&&(i>s&&(i=s),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+i),e.strm.next_out),e.strm.next_out+=i,e.strm.avail_out-=i,e.strm.total_out+=i,e.block_start+=i,s-=i),s&&(vs(e.strm,e.strm.output,e.strm.next_out,s),e.strm.next_out+=s,e.strm.avail_out-=s,e.strm.total_out+=s)}while(0===r);return a-=e.strm.avail_in,a&&(a>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=a&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-a,e.strm.next_in),e.strstart),e.strstart+=a,e.insert+=a>e.w_size-e.insert?e.w_size-e.insert:a),e.block_start=e.strstart),e.high_water<e.strstart&&(e.high_water=e.strstart),r?4:t!==Vt&&t!==Kt&&0===e.strm.avail_in&&e.strstart===e.block_start?2:(n=e.window_size-e.strstart,e.strm.avail_in>n&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,n+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),n>e.strm.avail_in&&(n=e.strm.avail_in),n&&(vs(e.strm,e.window,e.strstart,n),e.strstart+=n,e.insert+=n>e.w_size-e.insert?e.w_size-e.insert:n),e.high_water<e.strstart&&(e.high_water=e.strstart),n=e.bi_valid+42>>3,n=e.pending_buf_size-n>65535?65535:e.pending_buf_size-n,o=n>e.w_size?e.w_size:n,i=e.strstart-e.block_start,(i>=o||(i||t===Kt)&&t!==Vt&&0===e.strm.avail_in&&i<=n)&&(s=i>n?n:i,r=t===Kt&&0===e.strm.avail_in&&s===i?1:0,Mt(e,e.block_start,s,r),e.block_start+=s,Es(e.strm)),r?3:1)},ys=(e,t)=>{let s,i;for(;;){if(e.lookahead<rs){if(Cs(e),e.lookahead<rs&&t===Vt)return 1;if(0===e.lookahead)break}if(s=0,e.lookahead>=3&&(e.ins_h=ps(e,e.ins_h,e.window[e.strstart+3-1]),s=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==s&&e.strstart-s<=e.w_size-rs&&(e.match_length=ms(e,s)),e.match_length>=3)if(i=Ft(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=ps(e,e.ins_h,e.window[e.strstart+3-1]),s=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=ps(e,e.ins_h,e.window[e.strstart+1]);else i=Ft(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(i&&(fs(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===Kt?(fs(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(fs(e,!1),0===e.strm.avail_out)?1:2},As=(e,t)=>{let s,i,n;for(;;){if(e.lookahead<rs){if(Cs(e),e.lookahead<rs&&t===Vt)return 1;if(0===e.lookahead)break}if(s=0,e.lookahead>=3&&(e.ins_h=ps(e,e.ins_h,e.window[e.strstart+3-1]),s=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==s&&e.prev_length<e.max_lazy_match&&e.strstart-s<=e.w_size-rs&&(e.match_length=ms(e,s),e.match_length<=5&&(e.strategy===Xt||3===e.match_length&&e.strstart-e.match_start>4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){n=e.strstart+e.lookahead-3,i=Ft(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=n&&(e.ins_h=ps(e,e.ins_h,e.window[e.strstart+3-1]),s=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,i&&(fs(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(i=Ft(e,0,e.window[e.strstart-1]),i&&fs(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(i=Ft(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===Kt?(fs(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(fs(e,!1),0===e.strm.avail_out)?1:2};function Ns(e,t,s,i,n){this.good_length=e,this.max_lazy=t,this.nice_length=s,this.max_chain=i,this.func=n}const ws=[new Ns(0,0,0,0,Ts),new Ns(4,4,8,4,ys),new Ns(4,5,16,8,ys),new Ns(4,6,32,32,ys),new Ns(4,4,16,16,As),new Ns(8,16,32,32,As),new Ns(8,16,128,128,As),new Ns(8,32,128,256,As),new Ns(32,128,258,1024,As),new Ns(32,258,258,4096,As)];function bs(){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=ns,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),us(this.dyn_ltree),us(this.dyn_dtree),us(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),us(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),us(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 Is=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==as&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==ds&&t.status!==ls?1:0},xs=e=>{if(Is(e))return cs(e,jt);e.total_in=e.total_out=0,e.data_type=is;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=2===t.wrap?57:t.wrap?as:ds,e.adler=2===t.wrap?0:1,t.last_flush=-2,Ut(t),Qt},Rs=e=>{const t=xs(e);var s;return t===Qt&&((s=e.state).window_size=2*s.w_size,us(s.head),s.max_lazy_match=ws[s.level].max_lazy,s.good_match=ws[s.level].good_length,s.nice_match=ws[s.level].nice_length,s.max_chain_length=ws[s.level].max_chain,s.strstart=0,s.block_start=0,s.lookahead=0,s.insert=0,s.match_length=s.prev_length=2,s.match_available=0,s.ins_h=0),t},Ds=(e,t,s,i,n,o)=>{if(!e)return jt;let r=1;if(t===Yt&&(t=6),i<0?(r=0,i=-i):i>15&&(r=2,i-=16),n<1||n>9||s!==ns||i<8||i>15||t<0||t>9||o<0||o>ts||8===i&&1!==r)return cs(e,jt);8===i&&(i=9);const a=new bs;return e.state=a,a.strm=e,a.status=as,a.wrap=r,a.gzhead=null,a.w_bits=i,a.w_size=1<<a.w_bits,a.w_mask=a.w_size-1,a.hash_bits=n+7,a.hash_size=1<<a.hash_bits,a.hash_mask=a.hash_size-1,a.hash_shift=~~((a.hash_bits+3-1)/3),a.window=new Uint8Array(2*a.w_size),a.head=new Uint16Array(a.hash_size),a.prev=new Uint16Array(a.w_size),a.lit_bufsize=1<<n+6,a.pending_buf_size=4*a.lit_bufsize,a.pending_buf=new Uint8Array(a.pending_buf_size),a.sym_buf=a.lit_bufsize,a.sym_end=3*(a.lit_bufsize-1),a.level=t,a.strategy=o,a.method=s,Rs(e)};var Os={deflateInit:(e,t)=>Ds(e,t,ns,15,8,ss),deflateInit2:Ds,deflateReset:Rs,deflateResetKeep:xs,deflateSetHeader:(e,t)=>Is(e)||2!==e.state.wrap?jt:(e.state.gzhead=t,Qt),deflate:(e,t)=>{if(Is(e)||t>Bt||t<0)return e?cs(e,jt):jt;const s=e.state;if(!e.output||0!==e.avail_in&&!e.input||s.status===ls&&t!==Kt)return cs(e,0===e.avail_out?Zt:jt);const i=s.last_flush;if