UNPKG

@sendbird/chat

Version:
1 lines 278 kB
import{e,u as t,V as n,c as r,A as i,am as s,f as a,g as o,j as u,U as c,an as l,a1 as d,a as h,a4 as f,q as p,r as m,w as v,ag as y,ao as _,ap as g,aq as b,C as I,ar as E,as as T,at as w,W as M,au as S,av as U,_ as A,b as N,aw as C,aa as O,t as k,D as P,ax as R,ay as x,az as D,F as L,aA as F,aB as q,aC as z,aD as B,K as j,M as K,aE as Q,i as G,aF as V,aG as H,aH as W,aI as Y,aJ as J,aK as X,aL as Z,af as $,aM as ee,aN as te,aO as ne,aP as re,aQ as ie,aR as se,o as ae,N as oe,a0 as ue,aS as ce,G as le,H as de,aT as he,aU as fe,aV as pe,h as me,aW as ve,aX as ye,aY as _e,aZ as ge,a_ as be,a$ as Ie,J as Ee,b0 as Te,b1 as we,b2 as Me,b3 as Se,b4 as Ue,b5 as Ae,I as Ne,b6 as Ce,b7 as Oe}from"./__bundle-d4c97ab8.js";var ke,Pe=function(){function r(e,t,n){var r,i;this.width=0,this.height=0,this.realWidth=0,this.realHeight=0,this._requireAuth=!1,this._iid=e,this.plainUrl=t.url,this.width=t.width,this.height=t.height,this.realWidth=null!==(r=t.real_width)&&void 0!==r?r:t.width,this.realHeight=null!==(i=t.real_height)&&void 0!==i?i:t.height,this._requireAuth=n}return r.payloadify=function(n){return e(t(n instanceof r?{url:n.plainUrl,width:n.width,height:n.height,real_width:n.realWidth,real_height:n.realHeight}:{url:"",width:n.maxWidth,height:n.maxHeight,real_width:0,real_height:0}))},Object.defineProperty(r.prototype,"url",{get:function(){var e=n.of(this._iid).sessionManager;return this._requireAuth&&e.ekey?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl},enumerable:!1,configurable:!0}),r}(),Re=function(t){function n(n){var r=t.call(this)||this;if(r.method=i.POST,r.path="".concat(s),r.params=e({file:n.file,channel_url:n.channelUrl}),n.thumbnailSizes)for(var a=0;a<n.thumbnailSizes.length;a++){var o=n.thumbnailSizes[a],u=o.maxWidth,c=o.maxHeight;r.params["thumbnail".concat(a+1)]="".concat(u,",").concat(c)}return r.requestId=n.requestId,r}return r(n,t),n}(a),xe=function(e){function t(t,n){var r,i,s,a,o=this;return(o=e.call(this,t,n)||this).url=n.url,o.fileSize=null!==(r=n.file_size)&&void 0!==r?r:0,o.thumbnails=null!==(s=null===(i=n.thumbnails)||void 0===i?void 0:i.map((function(e){return new Pe(t,e,!1)})))&&void 0!==s?s:[],o.requireAuth=null!==(a=n.require_auth)&&void 0!==a&&a,o}return r(t,e),t}(o),De=function(n){function i(e,t){var r,i,s,a,o,u=this;return(u=n.call(this,e)||this).replyCount=0,u.memberCount=0,u.lastRepliedAt=0,u.updatedAt=0,u.replyCount=null!==(r=t.reply_count)&&void 0!==r?r:0,u.memberCount=null!==(i=t.member_count)&&void 0!==i?i:0,u.mostRepliedUsers=t.most_replies&&d("object",t.most_replies)?t.most_replies.map((function(e){return new c(u._iid,e)})):[],u.unreadReplyCount=null!==(s=t.unread_message_count)&&void 0!==s?s:0,u.isPushNotificationEnabled="number"==typeof t.push_enabled?t.push_enabled>0:void 0,u.lastRepliedAt=null!==(a=t.last_replied_at)&&void 0!==a?a:0,u.updatedAt=null!==(o=t.updated_at)&&void 0!==o?o:0,u}return r(i,n),i.payloadify=function(r){return e(t(u(u({},n.payloadify.call(this,r)),{reply_count:r.replyCount,unread_message_count:r.unreadReplyCount,member_count:r.memberCount,most_replies:Array.isArray(r.mostRepliedUsers)?r.mostRepliedUsers.map((function(e){return c.payloadify(e)})):[],push_enabled:"boolean"==typeof r.isPushNotificationEnabled?r.isPushNotificationEnabled?1:0:void 0,last_replied_at:r.lastRepliedAt,updated_at:r.updatedAt})))},Object.defineProperty(i.prototype,"_isUpdateRequired",{get:function(){return void 0===this.unreadReplyCount||void 0===this.isPushNotificationEnabled},enumerable:!1,configurable:!0}),i.prototype._updateFrom=function(e){var t,n;this.unreadReplyCount=null!==(t=e.unreadReplyCount)&&void 0!==t?t:this.unreadReplyCount,this.isPushNotificationEnabled=null!==(n=e.isPushNotificationEnabled)&&void 0!==n?n:this.isPushNotificationEnabled},i}(l);!function(e){e.ADD="add",e.DELETE="delete"}(ke||(ke={}));var Le,Fe=function(e){var t;this.messageId=0,this.operation=null,this.updatedAt=0;var n=h("string",e.msg_id)?parseInt(e.msg_id):e.msg_id,r=e.user_id,i=e.operation?e.operation.toLowerCase():null,s=e.reaction,a=e.updated_at,o=e.count,u=e.sampled_user_ids,c=null!==(t=e.sampled_user_info)&&void 0!==t?t:{};n&&h("string",r)&&h("string",i)&&f(ke,i)&&h("string",s)&&s&&h("number",a)&&(this.messageId=n,this.userId=r,this.key=s,this.operation=i,this.updatedAt=a,this._count=o,this._sampledUserIds=u,this._sampledUserInfoList=c)},qe=function(e){function t(t,n,r){var i,s=this;return(s=e.call(this,t)||this).userId=n,s.nickname=r.nickname,s.plainProfileUrl=r.profile_url,s.requireAuth=null!==(i=r.require_auth_for_profile_image)&&void 0!==i&&i,s}return r(t,e),Object.defineProperty(t.prototype,"profileUrl",{get:function(){var e=n.of(this._iid).sessionManager;return this.requireAuth&&e.ekey?"".concat(this.plainProfileUrl,"?auth=").concat(e.ekey):this.plainProfileUrl},enumerable:!1,configurable:!0}),t.payloadify=function(e){return{nickname:e.nickname,profile_url:e.plainProfileUrl,require_auth_for_profile_image:e.requireAuth}},t}(l),ze=function(i){function s(e,t){var r,s,a,o,u,c,l,f,y,_=this;(_=i.call(this,e)||this)._sampledUserInfoList=[],_._count=0,_._hasCurrentUserReacted=!1;var g=t.key,b=p([],m(null!==(o=null!==(a=t.sampled_user_ids)&&void 0!==a?a:t.user_ids)&&void 0!==o?o:[]),!1),I=null!==(c=null!==(u=t.last_ts)&&void 0!==u?u:t.updated_at)&&void 0!==c?c:0,E=null!==(l=t.is_self_included)&&void 0!==l?l:b.includes(n.of(e).sdkState.userId),T=null!==(f=t.sampled_user_info)&&void 0!==f?f:{};h("string",g)&&g&&d("string",b)&&b.length>0&&h("number",I)&&(_.key=g,_._sampledUserIds=b,_._updatedAt=I,_._count=null!==(y=t.count)&&void 0!==y?y:b.length,_._hasCurrentUserReacted=E,Object.keys(T).forEach((function(t){_._sampledUserInfoList.push(new qe(e,t,T[t]))})));var w={};try{for(var M=v(_.sampledUserIds),S=M.next();!S.done;S=M.next()){w[S.value]=_.updatedAt}}catch(e){r={error:e}}finally{try{S&&!S.done&&(s=M.return)&&s.call(M)}finally{if(r)throw r.error}}return _._version=w,_}return r(s,i),Object.defineProperty(s.prototype,"isEmpty",{get:function(){return 0===this._count},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"userIds",{get:function(){return this._sampledUserIds},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"sampledUserIds",{get:function(){return this._sampledUserIds},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"sampledUserInfoList",{get:function(){return this._sampledUserInfoList},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"count",{get:function(){return this._count},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"updatedAt",{get:function(){return this._updatedAt},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"hasCurrentUserReacted",{get:function(){return this._hasCurrentUserReacted},enumerable:!1,configurable:!0}),s.payloadify=function(n){var r={};return n._sampledUserInfoList.forEach((function(e){r[e.userId]=qe.payloadify(e)})),e(t({key:n.key,sampled_user_ids:n._sampledUserIds,sampled_user_info:r,count:n._count,is_self_included:n._hasCurrentUserReacted,last_ts:n._updatedAt}))},s.prototype.applyEvent=function(e){var t=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(n){t._sampledUserInfoList.push(new qe(t._iid,n,e._sampledUserInfoList[n]))})),this._count=e._count,void 0!==e._hasCurrentUserReacted&&(this._hasCurrentUserReacted=e._hasCurrentUserReacted),this._updatedAt=e.updatedAt;else{if(!this._version[e.userId]||this._version[e.userId]<=e.updatedAt){var n=this._sampledUserIds.indexOf(e.userId);switch(e.operation){case ke.ADD:n<0&&this._sampledUserIds.push(e.userId);break;case ke.DELETE:n>=0&&this._sampledUserIds.splice(n,1)}this._count=this._sampledUserIds.length,this._version[e.userId]=e.updatedAt}this._updatedAt=Math.max(this.updatedAt,e.updatedAt)}},s}(l),Be=function(){function n(e){this.secureUrl=null,this.type=null,this.width=0,this.height=0,this.alt=null,this.url=e.url,e.secure_url&&(this.secureUrl=e.secure_url),e.type&&(this.type=e.type),e.width&&(this.width=e.width),e.height&&(this.height=e.height),e.alt&&(this.alt=e.alt)}return n.payloadify=function(n){var r,i;return e(t({url:n.url,secure_url:n.secureUrl,type:n.type,width:null!==(r=n.width)&&void 0!==r?r:0,height:null!==(i=n.height)&&void 0!==i?i:0,alt:n.alt}))},n}(),je=function(){function n(e){this.title=null,this.url=null,this.description=null,this.defaultImage=null,e["og:title"]&&(this.title=e["og:title"]),e["og:url"]&&(this.url=e["og:url"]),e["og:description"]&&(this.description=e["og:description"]),e["og:image"]&&(this.defaultImage=new Be(e["og:image"]))}return n.payloadify=function(n){return e(t({"og:title":n.title,"og:url":n.url,"og:description":n.description,"og:image":n.defaultImage?Be.payloadify(n.defaultImage):null}))},n}(),Ke=function(){function n(e){var t,n;this.volume=0,this.name=null!==(t=e.name)&&void 0!==t?t:"default",this.volume=null!==(n=e.volume)&&void 0!==n?n:1}return n.prototype.serialize=function(){return{name:this.name,volume:this.volume}},n.payloadify=function(n){return e(t({name:n.name,volume:n.volume}))},n}();!function(e){e.GOOD="good",e.BAD="bad"}(Le||(Le={}));var Qe=function(){function n(e){this.id=e.id,this.rating=e.rating,this.comment=e.comment}return n._getStatus=function(e){return e?"id"in e?"SUBMITTED":"NO_FEEDBACK":"NOT_APPLICABLE"},n._isSubmitted=function(e){return"SUBMITTED"===n._getStatus(e)},n._getPayloadByStatus=function(e){return"NO_FEEDBACK"===e?{}:null},n.payloadify=function(n){return e(t({id:n.id,rating:n.rating,comment:n.comment}))},n}(),Ge=function(n){function i(e,t){var r,i=this;return(i=n.call(this,e,t)||this).isBlockedByMe=!1,i.role=f(y,t.role)?t.role:y.NONE,i.isBlockedByMe=null!==(r=t.is_blocked_by_me)&&void 0!==r&&r,i}return r(i,n),i.payloadify=function(r){return e(t(u(u({},n.payloadify.call(this,r)),{role:r.role,is_blocked_by_me:r.isBlockedByMe})))},i}(c),Ve=function(){function n(e){this.key=e.key,this.value=d("string",e.value)?p([],m(e.value),!1):[]}return n.payloadify=function(n){var r;return e(t({key:n.key,value:null!==(r=n.value)&&void 0!==r?r:[]}))},n}(),He=function(e){switch(e){case g.BASE:return"";case g.USER:return"MESG";case g.FILE:return"FILE";case g.ADMIN:return"ADMM"}},We=function(n){function i(e,t){var r,i,s,a,o,u,l,d,h,p=this;(p=n.call(this,e)||this).channelType=I.BASE,p.messageType=g.BASE,p.mentionType=null,p.mentionedUsers=null,p.mentionedUserIds=null,p.metaArrays=[],p.extendedMessage={},p.createdAt=0,p.updatedAt=0,p.channelUrl=t.channel_url,p.channelType=f(I,t.channel_type)?t.channel_type:I.GROUP,t.channel&&(t.channel.channel_url&&(p.channelUrl=t.channel.channel_url),t.channel.channel_type&&(p.channelType=t.channel.channel_type)),p.data=null!==(r=t.data)&&void 0!==r?r:"",p.customType=null!==(i=t.custom_type)&&void 0!==i?i:"",p.mentionType=f(E,t.mention_type)?t.mention_type:null,p.mentionedUsers=t.mentioned_users?t.mentioned_users.map((function(e){return new c(p._iid,e)})):null,p.mentionedUserIds=null!==(s=t.mentioned_user_ids)&&void 0!==s?s:null,p.mentionedUsers&&!p.mentionedUserIds&&(p.mentionedUserIds=p.mentionedUsers.map((function(e){return e.userId})));var m=null!==(a=t.metaarray)&&void 0!==a?a:{},v=null!==(o=t.metaarray_key_order)&&void 0!==o?o:Object.keys(m).sort((function(e,t){return e.localeCompare(t)}));p.metaArrays=[];for(var y=0;y<v.length;y++){var _=v[y];p.metaArrays.push(new Ve({key:_,value:m[_]||[]}))}return t.sorted_metaarray&&(p.metaArrays=t.sorted_metaarray.map((function(e){return new Ve(e)}))),p.extendedMessage=null!==(u=t.extended_message)&&void 0!==u?u:{},p.extendedMessagePayload=t.extended_message_payload,p.createdAt=null!==(d=null!==(l=t.created_at)&&void 0!==l?l:t.ts)&&void 0!==d?d:0,p.updatedAt=null!==(h=t.updated_at)&&void 0!==h?h:0,p}return r(i,n),i.payloadify=function(r){var i,s;return e(t(u(u({},n.payloadify.call(this,r)),{channel_url:r.channelUrl,channel_type:r.channelType,type:He(r.messageType),data:r.data,custom_type:r.customType,mention_type:r.mentionType,mentioned_user_ids:r.mentionedUserIds,mentioned_users:null===(i=r.mentionedUsers)||void 0===i?void 0:i.map((function(e){return c.payloadify(e)})),sorted_metaarray:null===(s=r.metaArrays)||void 0===s?void 0:s.map((function(e){return Ve.payloadify(e)})),extended_message:r.extendedMessage,extended_message_payload:r.extendedMessagePayload,created_at:r.createdAt,updated_at:r.updatedAt})))},i.prototype.isIdentical=function(e){return!0},i.prototype.isEqual=function(e){return _(this,e)},i.prototype.isUserMessage=function(){return this.messageType===g.USER},i.prototype.isFileMessage=function(){return this.messageType===g.FILE&&!Object.prototype.hasOwnProperty.call(this,"fileInfoList")},i.prototype.isMultipleFilesMessage=function(){return this.messageType===g.FILE&&Object.prototype.hasOwnProperty.call(this,"fileInfoList")},i.prototype.isAdminMessage=function(){return this.messageType===g.ADMIN},i.prototype.serialize=function(){return b(this)},i.prototype.getMetaArraysByKeys=function(e){return this.metaArrays.filter((function(t){return e.includes(t.key)}))},i}(l),Ye=function(e){function t(t,n){var r,i,s=this;return(s=e.call(this,t)||this).channelUrl=null!==(r=n.channel_url)&&void 0!==r?r:"",s.channelType=null!==(i=n.channel_type)&&void 0!==i?i:I.GROUP,s.reader=new c(s._iid,n.user),s.readAt=n.ts,s}return r(t,e),t}(l),Je=function(e){function t(t){var n=t.channelUrl;return e.call(this,{code:"READ",ackRequired:!0,payload:{channel_url:n}})||this}return r(t,e),t}(T),Xe=function(n){function s(r){var s=n.call(this)||this,a=r.channelUrl,o=r.channelType,u=r.userId,c=r.notificationIds;return s.method=i.PUT,s.path="".concat(w(o),"/").concat(encodeURIComponent(a),"/messages/mark_as_read"),s.params=e(t({user_id:u,message_ids:c})),s}return r(s,n),s}(a),Ze=function(e){function t(t,n,r){var i=e.call(this,t,"READ",r)||this;return i.readStatus=new Ye(t,r),i}return r(t,e),t}(M),$e=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.readAt=n.ts,r.unreadMessageCount=n.unread_message_count,r}return r(t,e),t}(o),et=function(e){function t(t){var n=t.channelUrl,r=t.messageId;return e.call(this,{code:"READ",ackRequired:!0,payload:{channel_url:n,parent_message_id:r}})||this}return r(t,e),t}(T),tt=function(e){function t(t){var n=t.channelType,r=t.channelUrl,s=t.messageId,a=t.pushEnabled,o=e.call(this)||this;return o.method=i.PUT,o.path="".concat(w(n),"/").concat(encodeURIComponent(r),"/messages/").concat(s,"/thread_push"),o.params={push_enabled:a},o}return r(t,e),t}(a);!function(e){function t(t,n){return e.call(this,t,n)||this}r(t,e)}(o);var nt=function(e){function t(t){var n=t.channelType,r=t.channelUrl,s=t.messageId,a=t.rating,o=t.comment,u=e.call(this)||this;return u.method=i.POST,u.path="".concat(w(n),"/").concat(encodeURIComponent(r),"/messages/").concat(s,"/feedbacks"),u.params={rating:a,comment:o},u}return r(t,e),t}(a),rt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.feedback=new Qe(n),r}return r(t,e),t}(o),it=function(e){function t(t){var n=t.channelType,r=t.channelUrl,s=t.messageId,a=t.feedbackId,o=t.rating,u=t.comment,c=e.call(this)||this;return c.method=i.PUT,c.path="".concat(w(n),"/").concat(encodeURIComponent(r),"/messages/").concat(s,"/feedbacks/").concat(a),c.params={rating:o,comment:u},c}return r(t,e),t}(a),st=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.feedback=new Qe(n),r}return r(t,e),t}(o),at=function(e){function t(t){var n=t.channelType,r=t.channelUrl,s=t.messageId,a=t.feedbackId,o=e.call(this)||this;return o.method=i.DELETE,o.path="".concat(w(n),"/").concat(encodeURIComponent(r),"/messages/").concat(s,"/feedbacks/").concat(a),o}return r(t,e),t}(a);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.feedback=new Qe(n),r}r(t,e)}(o);var ot,ut,ct=function(i){function s(e,t){var n,r,s,a,o,c=this;return(c=i.call(this,e)||this).plainUrl="",c.fileName=null,c.mimeType=null,c.fileSize=0,c.thumbnails=[],c._requireAuth=!1,c.plainUrl=null!==(n=t.url)&&void 0!==n?n:"",c.fileName=null!==(r=t.file_name)&&void 0!==r?r:null,c.mimeType=null!==(s=t.file_type)&&void 0!==s?s:null,c.fileSize=null!==(a=t.file_size)&&void 0!==a?a:0,c._requireAuth=null!==(o=t.require_auth)&&void 0!==o&&o,c.thumbnails=t.thumbnails?t.thumbnails.map((function(e){var t;return new Pe(c._iid,"string"==typeof e?{url:e,width:0,height:0}:u(u({},e),{url:(null!==(t=e.url)&&void 0!==t?t:"").split("auth=")[0]}),c._requireAuth)})):[],c}return r(s,i),s.payloadify=function(n){var r;return e(t({url:n.plainUrl,file_name:n.fileName,file_type:n.mimeType,file_size:n.fileSize,thumbnails:null===(r=n.thumbnails)||void 0===r?void 0:r.map((function(e){var t;return{url:(null!==(t=e.plainUrl)&&void 0!==t?t:"").split("auth=")[0],width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}})),require_auth:n._requireAuth}))},Object.defineProperty(s.prototype,"url",{get:function(){var e=n.of(this._iid).sessionManager;return this._requireAuth&&e.ekey?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl},enumerable:!1,configurable:!0}),s}(l),lt=function(e){var t=e.channelUrl,n=e.channelType,r=e.parentMessage;this.channelUrl=t,this.channelType=n,this.parentMessage=r};!function(e){e.NUMBER="number",e.ENUM="enum",e.TEXT="text",e.REGEX="regex",e.DECIMAL_PLACE="decimal_place"}(ot||(ot={})),function(e){e.TEXT="text",e.TEXTAREA="textarea",e.NUMBER="number",e.PHONE="phone",e.EMAIL="email",e.CHIP="chip"}(ut||(ut={}));var dt,ht,ft=function(){function n(e,t){var n=t.id,r=t.name,i=t.items,s=t.version,a=t.is_submitted;this.messageId=e,this.id=n,this.name=r,this.items=i.map((function(e){return new pt(e)})).sort((function(e,t){return e.sortOrder-t.sortOrder})),this.version=null!=s?s:1,this._isSubmitted=a}return Object.defineProperty(n.prototype,"isSubmitted",{get:function(){var e;return null!==(e=this._isSubmitted)&&void 0!==e?e:this.items.some((function(e){return Array.isArray(e.submittedValues)}))},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isSubmittable",{get:function(){return this.items.every((function(e){return e.required?!!(Array.isArray(e.draftValues)&&e.draftValues.length>0)&&e.isValid(e.draftValues):!(Array.isArray(e.draftValues)&&e.draftValues.length>0)||e.isValid(e.draftValues)}))},enumerable:!1,configurable:!0}),n.payloadify=function(n){return e(t({id:n.id,name:n.name,items:n.items.map((function(e){return pt.payloadify(e)})),version:n.version,is_submitted:n._isSubmitted}))},n.isMessageFormPayload=function(e){return Boolean(null==e?void 0:e.message_form)},n}(),pt=function(){function n(t){var n=t.id,r=t.name,i=t.required,s=t.sort_order,a=t.placeholder,o=t.style,u=t.item_type,c=t.validators,l=t.value,d=t.values;this.id=n,this.name=r,this.required=i,this.sortOrder=s,this.placeholder=a,0===Object.keys(o).length?this.style={layout:u}:this.style=e({layout:o.layout,options:o.options,defaultOptions:o.default_options,resultCount:o.result_count}),d?this.submittedValues=d:l&&(this.submittedValues=[l]),this._validators=c}return n.prototype.isValid=function(e){var t=this;return e.every((function(e){var n=function(e,t){return t.every((function(t){switch(t.key){case ot.NUMBER:var n=Number(e);return!(isNaN(n)||t.min&&"number"!=typeof t.min||t.max&&"number"!=typeof t.max||"number"==typeof t.min&&n<t.min||"number"==typeof t.max&&n>t.max);case ot.ENUM:return"string"==typeof e&&(!(t.enums&&Array.isArray(t.enums)&&t.enums.length>0&&!t.enums.includes(e))||t.allow_other);case ot.TEXT:return!("string"!=typeof e||"number"==typeof t.min_length&&e.length<t.min_length||"number"==typeof t.max_length&&e.length>t.max_length);case ot.REGEX:if("string"!=typeof e)return!1;if(t.regex){if("string"!=typeof t.regex)return!1;if(!new RegExp(t.regex).test(e))return!1}return!0;case ot.DECIMAL_PLACE:return 0!==e.length&&(n=Number(e),!(isNaN(n)||(!t.max_decimal_place||"number"==typeof t.max_decimal_place)&&t.max_decimal_place&&!function(e,t){var n=e.toString(),r=n.indexOf(".");return-1===r||n.slice(r+1).length<=t}(n,t.max_decimal_place)));default:return!0}}))}(e,t._validators);return n}))},n.payloadify=function(n){return e(t({id:n.id,name:n.name,required:n.required,sort_order:n.sortOrder,placeholder:n.placeholder,style:e({layout:n.style.layout,options:n.style.options,default_options:n.style.defaultOptions,result_count:n.style.resultCount}),item_type:n.style.layout,validators:n._validators,values:n.submittedValues}))},n}(),mt=function(t){function n(n){var r=t.call(this)||this;return r.method=i.POST,r.path="".concat(S,"/").concat(n.formId,"/submit"),r.params=e({message_id:n.messageId,items:n.items}),r}return r(n,t),n}(a);!function(e){e.PENDING="pending",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled"}(dt||(dt={})),function(e){e.PENDING="pending",e.IN_QUEUE="in_queue",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled",e.REMOVED="removed"}(ht||(ht={}));var vt,yt=function(i){function s(e,t){var n,r,s,a,o,u,c,l,d,h=this;return(h=i.call(this,e,t)||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=null!==(r=null!==(n=t.msg_id)&&void 0!==n?n:t.message_id)&&void 0!==r?r:0,h.parentMessageId=null!==(s="string"==typeof t.parent_message_id?parseInt(t.parent_message_id):t.parent_message_id)&&void 0!==s?s:0,h.threadInfo=t.thread_info?new De(h._iid,t.thread_info):null,t.reactions_summary?h.reactions=t.reactions_summary.map((function(t){return new ze(e,t)})):t.reactions?h.reactions=t.reactions.map((function(t){return new ze(e,t)})):h.reactions=[],h.ogMetaData=t.og_tag?new je(t.og_tag):null,h.silent=null!==(a=t.silent)&&void 0!==a&&a,h.isOperatorMessage=null!==(o=t.is_op_msg)&&void 0!==o&&o,h.appleCriticalAlertOptions=t.apple_critical_alert_options?new Ke(t.apple_critical_alert_options):null,"number"==typeof t.scheduled_message_id&&"number"==typeof t.scheduled_at&&t.scheduled_status&&(h.scheduledInfo={scheduledMessageId:t.scheduled_message_id,scheduledAt:t.scheduled_at},h._scheduledStatus=t.scheduled_status),h._isContinuousMessages=null!==(u=t.is_continuous_messages)&&void 0!==u&&u,h.myFeedback=Qe._isSubmitted(t.feedback)?new Qe(t.feedback):null,h.myFeedbackStatus=Qe._getStatus(t.feedback),h.suggestedReplies=null!==(l=null===(c=t.extended_message_payload)||void 0===c?void 0:c.suggested_replies)&&void 0!==l?l:null,h.messageForm=ft.isMessageFormPayload(t.extended_message_payload)?new ft(h.messageId,t.extended_message_payload.message_form):null,h.message=null!==(d=t.message)&&void 0!==d?d:"",h._poll=t.poll?new U(h._iid,t.poll):null,h}return r(s,i),s.payloadify=function(n){var r,s;return e(t(u(u({},i.payloadify.call(this,n)),{message_id:n.messageId,parent_message_id:n.parentMessageId,thread_info:n.threadInfo?De.payloadify(n.threadInfo):null,reactions_summary:n.reactions.map((function(e){return ze.payloadify(e)})),og_tag:n.ogMetaData?je.payloadify(n.ogMetaData):null,silent:n.silent,is_op_msg:n.isOperatorMessage,apple_critical_alert_options:n.appleCriticalAlertOptions?Ke.payloadify(n.appleCriticalAlertOptions):null,scheduled_message_id:null===(r=n.scheduledInfo)||void 0===r?void 0:r.scheduledMessageId,scheduled_at:null===(s=n.scheduledInfo)||void 0===s?void 0:s.scheduledAt,scheduled_status:n._scheduledStatus,feedback:n.myFeedback?Qe.payloadify(n.myFeedback):Qe._getPayloadByStatus(n.myFeedbackStatus),message:n.message,poll:n._poll?U.payloadify(n._poll):null})))},s._getParentMessageInfoPayload=function(n){return e(t({type:He(n.messageType),ts:n.createdAt,user:n.sender?Ge.payloadify(n.sender):null,message:n.message,file:{url:n.plainUrl,name:n.name,type:n.type,require_auth:n.requireAuth},files:Array.isArray(n.fileInfoList)?n.fileInfoList.map((function(e){return ct.payloadify(e)})):null}))},s.prototype.isIdentical=function(e){return this.messageId===e.messageId},s.prototype.applyThreadInfoUpdateEvent=function(e){return this.messageId===e.targetMessageId&&(e.threadInfo._isUpdateRequired&&this.threadInfo&&e.threadInfo._updateFrom(this.threadInfo),this.threadInfo=e.threadInfo,!0)},s.prototype._findReactionIndex=function(e){for(var t=0;t<this.reactions.length;t++)if(this.reactions[t].key===e)return t;return-1},s.prototype.applyReactionEvent=function(e){var t=n.of(this._iid).sdkState;if(this.messageId===e.messageId)switch(e.operation){case ke.ADD:e.userId===t.userId&&(e._hasCurrentUserReacted=!0),-1!==(r=this._findReactionIndex(e.key))?this.reactions[r].applyEvent(e):e._sampledUserIds?this.reactions.push(new ze(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 ze(this._iid,{key:e.key,user_ids:[e.userId],updated_at:e.updatedAt}));break;case ke.DELETE:var r;-1!==(r=this._findReactionIndex(e.key))&&(e._sampledUserIds?0===e._count?this.reactions.splice(r,1):(e.userId===t.userId&&(e._hasCurrentUserReacted=!1),this.reactions[r].applyEvent(e)):(this.reactions[r].applyEvent(e),this.reactions[r].isEmpty&&this.reactions.splice(r,1)))}},s.prototype.applyParentMessage=function(e){if(!this.parentMessage)return this.parentMessage=e,!0;if(this.parentMessageId===e.messageId){var t=this.parentMessage.updatedAt;if(e.updatedAt>=t)return this.parentMessage=e,!0}return!1},s.prototype.applyPoll=function(e){return!(this._poll&&this._poll.id===e.id&&this._poll.updatedAt>e.updatedAt)&&(this._poll=e,!0)},Object.defineProperty(s.prototype,"poll",{get:function(){return this._poll},enumerable:!1,configurable:!0}),s.prototype._triggerThreadInfoUpdatedEvent=function(){return A(this,void 0,void 0,(function(){var e;return N(this,(function(t){return(e=n.of(this._iid).dispatcher).dispatch(new lt({channelType:I.GROUP,channelUrl:this.channelUrl,parentMessage:this})),e.dispatch(new C({messages:[this],source:O.EVENT_MESSAGE_THREADINFO_UPDATED})),[2]}))}))},s.prototype.markThreadAsRead=function(){return A(this,void 0,void 0,(function(){var e,t;return N(this,(function(r){switch(r.label){case 0:return e=n.of(this._iid).requestQueue,t=new et({channelUrl:this.channelUrl,messageId:this.messageId}),[4,e.send(t)];case 1:return r.sent(),this.threadInfo&&0!==this.threadInfo.unreadReplyCount?(this.threadInfo.unreadReplyCount=0,[4,this._triggerThreadInfoUpdatedEvent()]):[3,3];case 2:r.sent(),r.label=3;case 3:return[2]}}))}))},s.prototype.setPushNotificationEnabled=function(e){return A(this,void 0,void 0,(function(){var t,r;return N(this,(function(i){switch(i.label){case 0:return t=n.of(this._iid).requestQueue,r=new tt({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,pushEnabled:e}),[4,t.send(r)];case 1:return i.sent(),this.threadInfo&&this.threadInfo.isPushNotificationEnabled!==e&&(this.threadInfo.isPushNotificationEnabled=e),[2]}}))}))},s.prototype.submitMessageForm=function(e){return A(this,void 0,void 0,(function(){var t,r,i,s,a;return N(this,(function(o){switch(o.label){case 0:if(t=n.of(this._iid).requestQueue,r=null,i=null,s=this.messageForm,!e&&s){if(!s.isSubmittable)throw new k({code:P.INVALID_PARAMETER,message:"The form is not submittable. Please check all form items are valid before submitting."});if(s.isSubmitted)throw new k({code:P.INVALID_PARAMETER,message:"The form has already been submitted."});r=s.id,i=s.items.reduce((function(e,t){return e.push({form_item_id:t.id,values:Array.isArray(t.draftValues)?t.draftValues:[]}),e}),[])}else e&&(r=e.formId,i=Object.entries(e.answers).reduce((function(e,t){var n=m(t,2),r=n[0],i=n[1],s=Number(r);if(Number.isNaN(s))throw new k({code:P.INVALID_PARAMETER,message:"Keys in answers must be numeric string."});return e.push({form_item_id:s,value:i}),e}),[]));if(!r||!i)throw new k({code:P.INVALID_PARAMETER,message:"Missing one or more required inputs: formId, answers."});return a=new mt({messageId:this.messageId,formId:r,items:i}),[4,t.send(a)];case 1:return o.sent(),[2]}}))}))},s.prototype.submitFeedback=function(e){return A(this,void 0,void 0,(function(){var t,r,i,s,a,o;return N(this,(function(u){switch(u.label){case 0:return t=n.of(this._iid),r=t.requestQueue,i=t.dispatcher,s=new nt({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,rating:e.rating,comment:e.comment}),[4,r.send(s)];case 1:return a=u.sent(),o=a.as(rt),this.myFeedback=o.feedback,this.myFeedbackStatus="SUBMITTED",i.dispatch(new C({messages:[this],source:O.EVENT_MESSAGE_FEEDBACK_ADDED})),[2]}}))}))},s.prototype.updateFeedback=function(e){return A(this,void 0,void 0,(function(){var t,r,i,s,a,o;return N(this,(function(u){switch(u.label){case 0:return t=n.of(this._iid),r=t.requestQueue,i=t.dispatcher,s=new it({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,feedbackId:e.id,rating:e.rating,comment:e.comment}),[4,r.send(s)];case 1:return a=u.sent(),o=a.as(st),this.myFeedback=o.feedback,this.myFeedbackStatus="SUBMITTED",i.dispatch(new C({messages:[this],source:O.EVENT_MESSAGE_FEEDBACK_UPDATED})),[2]}}))}))},s.prototype.deleteFeedback=function(e){return A(this,void 0,void 0,(function(){var t,r,i,s;return N(this,(function(a){switch(a.label){case 0:return t=n.of(this._iid),r=t.requestQueue,i=t.dispatcher,s=new at({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,feedbackId:e}),[4,r.send(s)];case 1:return a.sent(),this.myFeedback=null,this.myFeedbackStatus="NO_FEEDBACK",i.dispatch(new C({messages:[this],source:O.EVENT_MESSAGE_FEEDBACK_DELETED})),[2]}}))}))},s}(We),_t=function(n){function i(e,t){var r,i,s,a,o=this;if((o=n.call(this,e,t)||this).reqId="",o.replyToChannel=!1,o.errorCode=0,o.sender=t.user?new Ge(o._iid,t.user):t.sender_id,o.reqId=null!==(i=null!==(r=t.req_id)&&void 0!==r?r:t.request_id)&&void 0!==i?i:"",o.replyToChannel=null!==(s=t.is_reply_to_channel)&&void 0!==s&&s,t.request_state&&f(R,t.request_state)&&(o.sendingStatus=t.request_state),!o.sendingStatus)if(o.messageId>0)o.sendingStatus=R.SUCCEEDED;else if(o.scheduledInfo)switch(t.scheduled_status&&(o._scheduledStatus=t.scheduled_status),t.scheduled_status){case ht.SENT:case ht.IN_QUEUE:o.sendingStatus=R.SUCCEEDED;break;case ht.PENDING:o.sendingStatus=R.SCHEDULED;break;case ht.FAILED:case ht.REMOVED:o.sendingStatus=R.FAILED;break;case ht.CANCELED:o.sendingStatus=R.CANCELED}else o.sendingStatus=R.PENDING;return o.errorCode=null!==(a=t.error_code)&&void 0!==a?a:0,o._messageToken=t.mesg_token,o}return r(i,n),i.payloadify=function(r){return e(t(u(u({},n.payloadify.call(this,r)),{user:Ge.payloadify(r.sender),req_id:r.reqId,is_reply_to_channel:r.replyToChannel,request_state:r.sendingStatus,error_code:r.errorCode,mesg_token:r._messageToken})))},Object.defineProperty(i.prototype,"isResendable",{get:function(){return(this.sendingStatus===R.FAILED||this.sendingStatus===R.CANCELED)&&x(this.errorCode)},enumerable:!1,configurable:!0}),i.prototype.isIdentical=function(e){return this.messageId>0&&e.messageId>0?this.messageId===e.messageId:this.reqId===e.reqId},i}(yt),gt={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:D.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1},bt=function(e){return h("number",e.prevResultSize)&&h("number",e.nextResultSize)&&h("boolean",e.isInclusive)&&h("boolean",e.reverse)&&h("string",e.messageTypeFilter)&&f(D,e.messageTypeFilter)&&d("string",e.customTypesFilter,!0)&&d("string",e.senderUserIdsFilter,!0)&&h("boolean",e.includeMetaArray)&&h("boolean",e.includeReactions)&&h("boolean",e.includeParentMessageInfo)},It=function(n){function i(r,i){var s,a,o,c=this;if((c=n.call(this,r,i)||this).translations={},c.messageType=g.ADMIN,c.translations=null!==(s=i.translations)&&void 0!==s?s:{},i.parent_message_info){var l=i.parent_message_info;c.parentMessage=At(r,e(t(u(u({},l),{message_id:c.parentMessageId,channel_url:c.channelUrl,channel_type:c.channelType,file:l.file,url:null===(a=l.file)||void 0===a?void 0:a.url,require_auth:null===(o=l.file)||void 0===o?void 0:o.require_auth}))))}return c}return r(i,n),i.payloadify=function(r){return e(t(u(u({},n.payloadify.call(this,r)),{translations:r.translations,parent_message_info:r.parentMessage?n._getParentMessageInfoPayload.call(this,r.parentMessage):null})))},i.prototype.getThreadedMessagesByTimestamp=function(e,t){return A(this,void 0,void 0,(function(){var n;return N(this,(function(r){switch(r.label){case 0:return n=u(u({},gt),t),L(this.messageId>0&&h("number",e)&&bt(n)).throw(k.invalidParameters),[4,la.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,r.sent()]}}))}))},i}(yt),Et=function(){function n(e){var t,n;this.detail={},this.type=null!==(t=e.type)&&void 0!==t?t:"",this.vendor=null!==(n=e.vendor)&&void 0!==n?n:"",e.detail&&h("object",e.detail)&&!Array.isArray(e.detail)&&(this.detail=e.detail)}return n.payloadify=function(n){return e(t({type:n.type,vendor:n.vendor,detail:n.detail}))},n}(),Tt=function(){function t(e){this.status=e.status,e.original_message_info&&(this.originalMessageInfo={createdAt:e.original_message_info.ts,messageId:e.original_message_info.id})}return t.payloadify=function(t){return e({status:t.status,original_message_info:t.originalMessageInfo?{id:t.originalMessageInfo.messageId,ts:t.originalMessageInfo.createdAt}:void 0})},t}(),wt=function(n){function i(r,i){var s,a,o,c,l,d,h,f=this;if((f=n.call(this,r,i)||this).messageParams=null,f.mentionedMessageTemplate=void 0,f.translations={},f.translationTargetLanguages=[],f.messageSurvivalSeconds=-1,f.plugins=[],f.messageType=g.USER,f.translations=null!==(o=i.translations)&&void 0!==o?o:{},f.translationTargetLanguages=null!==(c=i.target_langs)&&void 0!==c?c:[],0===Object.keys(f.translations).length&&f.translationTargetLanguages.length>0)try{for(var p=v(f.translationTargetLanguages),m=p.next();!m.done;m=p.next()){var y=m.value;f.translations[y]=""}}catch(e){s={error:e}}finally{try{m&&!m.done&&(a=p.return)&&a.call(p)}finally{if(s)throw s.error}}if(f.mentionedMessageTemplate=i.mentioned_message_template,f.messageSurvivalSeconds=null!==(l=i.message_survival_seconds)&&void 0!==l?l:-1,f.plugins=i.plugins?i.plugins.map((function(e){return new Et(e)})):[],i.parent_message_info){var _=i.parent_message_info;f.parentMessage=At(r,e(t(u(u({},_),{created_at:_.ts,message_id:f.parentMessageId,channel_url:f.channelUrl,channel_type:f.channelType,file:_.file,url:null===(d=_.file)||void 0===d?void 0:d.url,require_auth:null===(h=_.file)||void 0===h?void 0:h.require_auth}))))}return i.review_info&&(f.messageReviewInfo=new Tt(i.review_info)),f}return r(i,n),i.payloadify=function(r){return e(t(u(u({},n.payloadify.call(this,r)),{translations:r.translations,message_survival_seconds:r.messageSurvivalSeconds,mentioned_message_template:r.mentionedMessageTemplate,plugins:r.plugins.map((function(e){return Et.payloadify(e)})),parent_message_info:r.parentMessage?n._getParentMessageInfoPayload.call(this,r.parentMessage):null,review_info:r.messageReviewInfo?Tt.payloadify(r.messageReviewInfo):void 0})))},i.prototype.getThreadedMessagesByTimestamp=function(e,t){return A(this,void 0,void 0,(function(){var n;return N(this,(function(r){switch(r.label){case 0:return n=u(u({},gt),t),L(this.messageId>0&&h("number",e)&&bt(n)).throw(k.invalidParameters),[4,la.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,r.sent()]}}))}))},i}(_t),Mt=function(n){function i(r,i){var s,a,o,c,l,d,h,f,p=this;if((p=n.call(this,r,i)||this).messageParams=null,p.fileInfoList=[],p.messageSurvivalSeconds=-1,p.messageType=g.FILE,p.data=null!==(o=null!==(a=null===(s=i.file)||void 0===s?void 0:s.data)&&void 0!==a?a:i.custom)&&void 0!==o?o:"",p.fileInfoList=null!==(l=null===(c=i.files)||void 0===c?void 0:c.map((function(e){return new ct(r,e)})))&&void 0!==l?l:[],p.messageSurvivalSeconds=null!==(d=i.message_survival_seconds)&&void 0!==d?d:-1,i.parent_message_info){var m=i.parent_message_info;p.parentMessage=At(r,e(t(u(u({},m),{created_at:m.ts,message_id:p.parentMessageId,channel_url:p.channelUrl,channel_type:p.channelType,file:m.file,url:null===(h=m.file)||void 0===h?void 0:h.url,require_auth:null===(f=m.file)||void 0===f?void 0:f.require_auth}))))}return p}return r(i,n),i.prototype.getThreadedMessagesByTimestamp=function(e,t){return A(this,void 0,void 0,(function(){var n;return N(this,(function(r){switch(r.label){case 0:return n=u(u({},gt),t),L(this.messageId>0&&h("number",e)&&bt(n)).throw(k.invalidParameters),[4,la.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,r.sent()]}}))}))},i.payloadify=function(r){var i,s,a,o,c,l;return e(t(u(u({},n.payloadify.call(this,r)),{file:{name:null!==(s=null===(i=r.fileInfoList[0])||void 0===i?void 0:i.fileName)&&void 0!==s?s:"",size:null!==(o=null===(a=r.fileInfoList[0])||void 0===a?void 0:a.fileSize)&&void 0!==o?o:0,type:null!==(l=null===(c=r.fileInfoList[0])||void 0===c?void 0:c.mimeType)&&void 0!==l?l:"",data:r.data},files:Array.isArray(r.fileInfoList)?r.fileInfoList.map((function(e){return ct.payloadify(e)})):null,message_survival_seconds:r.messageSurvivalSeconds,parent_message_info:r.parentMessage?n._getParentMessageInfoPayload.call(this,r.parentMessage):null})))},i._isMultipleFilesMessagePayload=function(e){var t=e.files;return Array.isArray(t)&&t.length>=2},i._isMultipleFilesMessageSerializedData=function(e){var t=e.fileInfoList;return Array.isArray(t)},i}(_t);!function(e){e.SENT="SENT",e.READ="READ"}(vt||(vt={}));var St=function(n){function i(e,t){var r,i,s=this;if((s=n.call(this,e,t)||this).notificationData=null,s.notificationId=t.notification_message_id,s.messageType=g.ADMIN,s.messageStatus=null!==(r=t.message_status)&&void 0!==r?r:vt.SENT,s.priority=null!==(i=t.priority)&&void 0!==i?i:F.NORMAL,s.notificationEventDeadline=t.notification_event_deadline,0===s.extendedMessage.sub_type)try{var a=JSON.parse(s.extendedMessage.sub_data),o=a.label,u=a.tags,c=void 0===u?[]:u,l=a.template_key,d=a.template_variables;s.notificationData={label:o,tags:c,templateKey:l,templateVariables:d}}catch(e){}return s}return r(i,n),i.payloadify=function(r){return e(t(u(u({},n.payloadify.call(this,r)),{notification_message_id:r.notificationId,message_status:r.messageStatus,priority:r.priority,notification_event_deadline:r.notificationEventDeadline})))},i.prototype.isIdentical=function(e){return this.notificationId===e.notificationId},i}(We),Ut=function(e){if(e.notificationId)return St.payloadify(e);switch(e.messageType){case g.USER:return wt.payloadify(e);case g.FILE:return e.fileInfoList?Mt.payloadify(e):Nt.payloadify(e);case g.ADMIN:return It.payloadify(e);default:throw k.unknown}},At=function(e,t){if(t.notification_message_id)return new St(e,t);switch(t.type){case"MESG":return new wt(e,t);case"FILE":return Mt._isMultipleFilesMessagePayload(t)?new Mt(e,t):new Nt(e,t);case"ADMM":case"BRDM":return new It(e,t);default:return null}},Nt=function(i){function s(n,r){var s,a,o,c,l,d,h,f,p,m,v,y,_,b,I=this;(I=i.call(this,n,r)||this).messageParams=null,I.plainUrl="",I.requireAuth=!1,I.thumbnails=[],I.messageSurvivalSeconds=-1,I.messageType=g.FILE;var E=r.file;if(I.plainUrl=(null!==(a=null!==(s=null==E?void 0:E.url)&&void 0!==s?s:r.url)&&void 0!==a?a:"").split("?auth=")[0],I.name=null!==(c=null!==(o=null==E?void 0:E.name)&&void 0!==o?o:r.name)&&void 0!==c?c:"File",I.size=null!==(d=null!==(l=null==E?void 0:E.size)&&void 0!==l?l:r.size)&&void 0!==d?d:0,I.data=null!==(f=null!==(h=null==E?void 0:E.data)&&void 0!==h?h:r.custom)&&void 0!==f?f:"",I.type=E?null!==(p=E.type)&&void 0!==p?p:"":null!==(m=r.type)&&void 0!==m?m:"",I.requireAuth=null!==(v=r.require_auth)&&void 0!==v&&v,I.thumbnails=r.thumbnails?r.thumbnails.map((function(e){var t;return new Pe(I._iid,"string"==typeof e?{url:e,width:0,height:0}:u(u({},e),{url:(null!==(t=e.url)&&void 0!==t?t:"").split("auth=")[0]}),I.requireAuth)})):[],I.messageSurvivalSeconds=null!==(y=r.message_survival_seconds)&&void 0!==y?y:-1,r.parent_message_info){var T=r.parent_message_info;I.parentMessage=At(n,e(t(u(u({},T),{created_at:T.ts,message_id:I.parentMessageId,channel_url:I.channelUrl,channel_type:I.channelType,file:T.file,url:null===(_=T.file)||void 0===_?void 0:_.url,require_auth:null===(b=T.file)||void 0===b?void 0:b.require_auth}))))}return I}return r(s,i),s.payloadify=function(n){var r;return e(t(u(u({},i.payloadify.call(this,n)),{url:n.plainUrl,require_auth:n.requireAuth,file:{name:n.name,size:n.size,type:n.type,data:n.data},thumbnails:null===(r=n.thumbnails)||void 0===r?void 0:r.map((function(e){return{url:e.plainUrl,width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}})),message_survival_seconds:n.messageSurvivalSeconds,parent_message_info:n.parentMessage?i._getParentMessageInfoPayload.call(this,n.parentMessage):null})))},Object.defineProperty(s.prototype,"url",{get:function(){var e=n.of(this._iid).sessionManager;return this.requireAuth&&e.ekey?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl},enumerable:!1,configurable:!0}),s.prototype.getThreadedMessagesByTimestamp=function(e,t){return A(this,void 0,void 0,(function(){var n;return N(this,(function(r){switch(r.label){case 0:return n=u(u({},gt),t),L(this.messageId>0&&h("number",e)&&bt(n)).throw(k.invalidParameters),[4,la.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,r.sent()]}}))}))},s}(_t),Ct=function(e){function t(t,n){var r=n.file,i=n.fileUrl,s=n.fileName,a=n.fileSize,o=n.mimeType,u=n.thumbnailSizes,c=n._uploadedMetaData,l=n._thumbnails,d=e.call(this,t)||this;return d._plainUrl=i,d.file=r,d.fileName=s,d.fileSize=a,d.mimeType=o,d.thumbnailSizes=u,d._uploadedMetaData=c,d._thumbnails=l,d}return r(t,e),t.getPlainUrl=function(e){return e instanceof t?e._plainUrl:e.fileUrl},Object.defineProperty(t.prototype,"fileUrl",{get:function(){var e,t=n.of(this._iid).sessionManager;return this._plainUrl&&(null===(e=this._uploadedMetaData)||void 0===e?void 0:e.requireAuth)&&t.ekey?"".concat(this._plainUrl,"?auth=").concat(t.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}(l),Ot=function(n){function i(r){var i,s,a,o,u=[];return r.mentionType===E.USERS&&(r.mentionedUserIds?u=r.mentionedUserIds:r.mentionedUsers&&(u=r.mentionedUsers.map((function(e){return e.userId})))),n.call(this,{code:"FILE",ackRequired:!0,payload:e(t({channel_url:r.channelUrl,files:r.files?xt(r.files):null,url:r.url,name:null!==(i=r.fileName)&&void 0!==i?i:"",type:null!==(s=r.mimeType)&&void 0!==s?s:"",size:null!==(a=r.fileSize)&&void 0!==a?a:0,custom:r.data,custom_type:r.customType,thumbnails:null===(o=r._thumbnails)||void 0===o?void 0:o.map((function(e){return Pe.payloadify(e)})),require_auth:r.requireAuth,metaarray:r.metaArrays,mention_type:r.mentionType,mentioned_user_ids:u,push_option:r.pushNotificationDeliveryOption&&r.pushNotificationDeliveryOption!==q.DEFAULT?r.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:r.appleCriticalAlertOptions?Ke.payloadify(r.appleCriticalAlertOptions):null,silent:r.silent,reply_to_channel:r.isReplyToChannel,parent_message_id:r.parentMessageId?r.parentMessageId:null,req_id:r.reqId,poll_id:r.pollId,pin_message:r.isPinnedMessage,message:r.message}))})||this}return r(i,n),i}(T),kt=function(n){function s(r){var s,a,o=this;o=n.call(this)||this;var u=[];return r.mentionType===E.USERS&&(r.mentionedUserIds?u=r.mentionedUserIds:r.mentionedUsers&&(u=r.mentionedUsers.map((function(e){return e.userId})))),o.method=i.POST,o.path="".concat(w(r.channelType),"/").concat(encodeURIComponent(r.channelUrl),"/messages"),o.params=e(t({message_type:g.FILE,user_id:r.userId,files:r.files?xt(r.files):null,url:r.fileUrl,mention_type:r.mentionType,mentioned_user_ids:u,file_name:r.fileName,file_size:r.fileSize,file_type:r.mimeType,data:r.data,custom_type:r.customType,thumbnails:null===(s=r._thumbnails)||void 0===s?void 0:s.map((function(e){return Pe.payloadify(e)})),require_auth:r.requireAuth,sorted_metaarray:null===(a=r.metaArrays)||void 0===a?void 0:a.map((function(e){return Ve.payloadify(e)})),push_option:r.pushNotificationDeliveryOption,parent_message_id:r.parentMessageId?r.parentMessageId:null,apple_critical_alert_options:r.appleCriticalAlertOptions?Ke.payloadify(r.appleCriticalAlertOptions):null,reply_to_channel:r.isReplyToChannel,req_id:r.reqId,poll_id:r.pollId,pin_message:r.isPinnedMessage})),o}return r(s,n),s}(a),Pt=function(e){function t(t,r,i){var s,a,o,u,c=this;(c=e.call(this,t,"FILE",i)||this).message=i.files&&i.files.length>=2?new Mt(t,i):new Nt(t,i);var l=n.of(t).sdkState;return c.isMentioned=z(c.message.mentionType,null!==(o=null!==(s=c.message.mentionedUserIds)&&void 0!==s?s:null===(a=c.message.mentionedUsers)||void 0===a?void 0:a.map((function(e){return e.userId})))&&void 0!==o?o:[],l.userId),c.forceUpdateLastMessage=null!==(u=i.force_update_last_message)&&void 0!==u&&u,c}return r(t,e),t}(M),Rt=function(e){function t(t,r){var i,s,a,o,u=this;(u=e.call(this,t,r)||this).message=r.files&&r.files.length>=2?new Mt(t,r):new Nt(t,r);var c=n.of(t).sdkState;return u.isMentioned=z(u.message.mentionType,null!==(a=null!==(i=u.message.mentionedUserIds)&&void 0!==i?i:null===(s=u.message.mentionedUsers)||void 0===s?void 0:s.map((function(e){return e.userId})))&&void 0!==a?a:[],c.userId),u.forceUpdateLastMessage=null!==(o=r.force_update_last_message)&&void 0!==o&&o,u}return r(t,e),t}(o);function xt(n){return n.map((function(n){var r,i;return e(t({url:Ct.getPlainUrl(n),file_name:n.fileName,file_type:n.mimeType,file_size:n.fileSize,thumbnails:null===(r=n._thumbnails)||void 0===r?void 0:r.map((function(e){return Pe.payloadify(e)})),require_auth:null===(i=n._uploadedMetaData)||void 0===i?void 0:i.requireAuth}))}))}var Dt;!function(e){e[e.PENDING=0]="PENDING",e[e.UPLOADING=1]="UPLOADING",e[e.UPLOADED=2]="UPLOADED",e[e.SENDING=3]="SENDING",e[e.FAILED=4]="FAILED"}(Dt||(Dt={}));var Lt=function(){function e(e,t){var n=t.sdkState,r=t.dispatcher,i=t.requestQueue,s=t.onlineDetector,a=t.cacheContext,o=this;this._queueMap=new Map,this._iid=e,this._sdkState=n,this._requestQueue=i,this._cacheContext=a,this._dispatcher=r,this._dispatcher.on((function(e){e instanceof j&&(o._connectionState=e.stateType)})),this._onlineDetector=s}return Object.defineProperty(e.prototype,"_shouldSendThroughWebSocket",{get:function(){return this._connectionState===K.CONNECTED||this._connectionState===K.CONNECTING||this._connectionState===K.RECONNECTING},enumerable:!1,configurable:!0}),e.prototype._sendFileMessage=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i;return N(this,(function(s){switch(s.label){case 0:return n=this._createSendFileMessageRequestParams(e,t),this._shouldSendThroughWebSocket?(r=new Ot(n),[4,this._requestQueue.send(r)]):[3,2];case 1:return i=s.sent(),[2,i.as(Pt).message];case 2:return r=new kt(u(u({},n),{userId:this._sdkState.userId})),[4,this._requestQueue.send(r)];case 3:return i=s.sent(),[2,i.as(Rt).message]}}))}))},e.prototype._createSendFileMessageRequestParams=function(e,t){var n=u(u({},t.params),{channelUrl:e.url,channelType:e.channelType,reqId:t.requestId,url:""});if(t.multipleFileUploadInfo){var r=t.params;n.files=r.fileInfoList}else{r=t.params;n.url=r.fileUrl,n.requireAuth=r.requireAuth}return n},e.prototype._resolveMessageQueue=function(e){var t;return A(this,void 0,void 0,(function(){var n,r,i,s,a,o,u,c,l,d,h,f,p;return N(this,(function(m){switch(m.label){case 0:if(!(n=this._queueMap.get(e.url)))return[3,21];if(n.isResolving)return[3,20];n.isResolving=!0,r=[],i=!0,m.label=1;case 1:m.trys.push([1,15,16,17]),s=v(n.messageQueue),a=s.next(),m.label=2;case 2:if(a.done)return[3,14];switch(o=a.value,o.state){case Dt.PENDING:case Dt.UPLOADING:return[3,3];case Dt.UPLOADED:return[3,4];case Dt.FAILED:return[3,12]}return[3,13];case 3:return i=!1,r.push(o),[3,13];case 4:if(!i)return[3,10];m.label=5;case 5:return m.trys.push([5,8,,9]),o.state=Dt.SENDING,[4,this._sendFileMessage(e,o)];case 6:return u=m.sent(),o.deferred.resolve(u),[4,Q(100)];case 7:return m.sent(),[3,9];case 8:return c=m.sent(),o.deferred.reject(c),[3,9];case 9:return[3,11];case 10:r.push(o),m.label=11;case 11:return[3,13];case 12:return l=null!==(t=o.error)&&void 0!==t?t:k.unknown,o.deferred.reject(l.code===P.REQUEST_CANCELED?k.fileUploadCanceled:l),[3,13];case 13:return a=s.next(),[3,2];case 14:return[3,17];case 15:return d=m.sent(),f={error:d},[3,17];case 16:try{a&&!a.done&&(p=s.return)&&p.call(s)}finally{if(f)throw f.error}return[7];case 17:return h=n.isResolveRequestPending,n.messageQueue=r,n.isResolving=!1,n.isResolveRequestPending=!1,h?[4,this._resolveMessageQueue(e)]:[3,19];case 18:m.sent(),m.label=19;case 19:return[3,21];case 20:n.isResolveRequestPending=!0,m.label=21;case 21:return[2]}}))}))},e.prototype._uploadNextPendingItem=function(e){var t;return A(this,void 0,void 0,(function(){var n,r,i,s,a,o,u,c,l,d;return N(this,(function(h){switch(h.label){case 0:return(n=this._queueMap.get(e.url))&&(r=n.messageQueue.find((function(e){return e.state===Dt.PENDING})))?r.multipleFileUploadInfo?(i=r.multipleFileUploadInfo,s=i.uploadIndex,a=i.uploadCount,o=i.requestHandler,d=r.params,u=d.fileInfoList[s],!G(u.file)||(null===(t=u._uploadedMetaData)||void 0===t?void 0:t.isUploaded)?[3,2]:[4,this._tryUploadNextItemAndUpdateItemState(e,n,r)]):[3,4]:[3,9];case 1:return h.sent(),[3,3];case 2:r.state=s<a-1?Dt.PENDING:Dt.UPLOADED,h.label=3;case 3:return c=d.fileInfoList[s],l=r.multipleFileUploadInfo.uploadIndex++,r.multipleFileUploadInfo.isCopy||null==o||o._triggerOnFileUploaded(r.requestId,l,c,r.error),[3,7];case 4:return d=r.params,G(d.file)?[4,this._tryUploadNextItemAndUpdateItemState(e,n,r)]:[3,6];case 5:return h.sent(),[3,7];case 6:d.thumbnailSizes=[],r.state=Dt.UPLOADED,h.label=7;case 7:return this._uploadNextPendingItem