UNPKG

@amityco/ts-sdk

Version:

Amity Social Cloud Typescript SDK

1 lines 1.11 MB
var Amity=function(e){"use strict";var t,n,r;e.MembershipAcceptanceTypeEnum=void 0,(t=e.MembershipAcceptanceTypeEnum||(e.MembershipAcceptanceTypeEnum={})).AUTOMATIC="automatic",t.INVITATION="invitation",e.UserTypeEnum=void 0,(n=e.UserTypeEnum||(e.UserTypeEnum={})).SIGNED_IN="signed-in",n.VISITOR="visitor",n.BOT="bot",e.SearchUsersByEnum=void 0,(r=e.SearchUsersByEnum||(e.SearchUsersByEnum={})).DISPLAY_NAME="displayName",r.PROFILE_HANDLE="profileHandle",r.USER_ID="userId";const s=Object.freeze({FILE:"file",IMAGE:"image",VIDEO:"video",CLIP:"clip",AUDIO:"audio"}),i=Object.freeze({"1080P":"1080p","720P":"720p","480P":"480p","360P":"360p",ORIGINAL:"original"}),a=Object.freeze({UPLOADED:"uploaded",TRANSCODING:"transcoding",TRANSCODED:"transcoded",TRANSCODE_FAILED:"transcodeFailed"}),o=Object.freeze({LOW:"low",MEDIUM:"medium",HIGH:"high",ORIGINAL:"original"});var l;e.FileAccessTypeEnum=void 0,(l=e.FileAccessTypeEnum||(e.FileAccessTypeEnum={})).PUBLIC="public",l.NETWORK="network";const c=Object.freeze({ONLY_ADMIN_CAN_POST:"ONLY_ADMIN_CAN_POST",ADMIN_REVIEW_POST_REQUIRED:"ADMIN_REVIEW_POST_REQUIRED",ANYONE_CAN_POST:"ANYONE_CAN_POST"}),d=Object.freeze({ONLY_ADMIN_CAN_POST:{needApprovalOnPostCreation:!1,onlyAdminCanPost:!0},ADMIN_REVIEW_POST_REQUIRED:{needApprovalOnPostCreation:!0,onlyAdminCanPost:!1},ANYONE_CAN_POST:{needApprovalOnPostCreation:!1,onlyAdminCanPost:!1}}),u="ONLY_ADMIN_CAN_POST";var h;e.AmityCommunityType=void 0,(h=e.AmityCommunityType||(e.AmityCommunityType={})).Default="default",h.Event="event";const f=Object.freeze({STORY:"story",CLIP:"clip",CHAT:"chat",POST:"post",MESSAGE:"message"});var p;e.ContentFlagReasonEnum=void 0,(p=e.ContentFlagReasonEnum||(e.ContentFlagReasonEnum={})).CommunityGuidelines="Against community guidelines",p.HarassmentOrBullying="Harassment or bullying",p.SelfHarmOrSuicide="Self-harm or suicide",p.ViolenceOrThreateningContent="Violence or threatening content",p.SellingRestrictedItems="Selling and promoting restricted items",p.SexualContentOrNudity="Sexual content or nudity",p.SpamOrScams="Spam or scams",p.FalseInformation="False information or misinformation",p.Others="Others";const g=Object.freeze({TEXT:"text",IMAGE:"image",FILE:"file",VIDEO:"video",AUDIO:"audio",CUSTOM:"custom"}),m=Object.freeze({TEXT:"text",IMAGE:"image",FILE:"file",VIDEO:"video",LIVESTREAM:"liveStream",POLL:"poll",CLIP:"clip",AUDIO:"audio",ROOM:"room"}),y=Object.freeze({TEXT:"text",IMAGE:"image",VIDEO:"video",FILE:"file",AUDIO:"audio",MIXED:"mixed"});var v,b,w,S,T,I,C,E,A,k,R,_,O,D,L,P,x;e.InvitationTypeEnum=void 0,(v=e.InvitationTypeEnum||(e.InvitationTypeEnum={})).CommunityMemberInvite="communityMemberInvite",v.LivestreamCohostInvite="livestreamCohostInvite",e.InvitationStatusEnum=void 0,(b=e.InvitationStatusEnum||(e.InvitationStatusEnum={})).Pending="pending",b.Approved="approved",b.Rejected="rejected",b.Cancelled="cancelled",e.InvitationSortByEnum=void 0,(w=e.InvitationSortByEnum||(e.InvitationSortByEnum={})).FirstCreated="firstCreated",w.LastCreated="lastCreated",e.InvitationTargetTypeEnum=void 0,(S=e.InvitationTargetTypeEnum||(e.InvitationTargetTypeEnum={})).Community="community",S.Room="room",e.JoinRequestStatusEnum=void 0,(T=e.JoinRequestStatusEnum||(e.JoinRequestStatusEnum={})).Pending="pending",T.Approved="approved",T.Rejected="rejected",T.Cancelled="cancelled",e.JoinResultStatusEnum=void 0,(I=e.JoinResultStatusEnum||(e.JoinResultStatusEnum={})).Success="success",I.Pending="pending",e.FeedDataTypeEnum=void 0,(C=e.FeedDataTypeEnum||(e.FeedDataTypeEnum={})).Text="text",C.Video="video",C.Image="image",C.File="file",C.Audio="audio",C.LiveStream="liveStream",C.Clip="clip",C.Poll="poll",C.Room="room",e.FeedSortByEnum=void 0,(E=e.FeedSortByEnum||(e.FeedSortByEnum={})).LastCreated="lastCreated",E.FirstCreated="firstCreated",E.LastUpdated="lastUpdated",E.FirstUpdated="firstUpdated",e.FeedSourceEnum=void 0,(A=e.FeedSourceEnum||(e.FeedSourceEnum={})).Community="community",A.User="user",e.FeedTypeEnum=void 0,(k=e.FeedTypeEnum||(e.FeedTypeEnum={})).Reviewing="reviewing",k.Published="published",k.Declined="declined",e.AmityEventType=void 0,(R=e.AmityEventType||(e.AmityEventType={})).Virtual="virtual",R.InPerson="in_person",e.AmityEventOriginType=void 0,(_=e.AmityEventOriginType||(e.AmityEventOriginType={})).Community="community",_.User="user",e.AmityEventStatus=void 0,(O=e.AmityEventStatus||(e.AmityEventStatus={})).Scheduled="scheduled",O.Live="live",O.Ended="ended",O.Cancelled="cancelled",e.AmityEventResponseStatus=void 0,(D=e.AmityEventResponseStatus||(e.AmityEventResponseStatus={})).Going="going",D.NotGoing="not_going",e.AmityEventSortOption=void 0,(L=e.AmityEventSortOption||(e.AmityEventSortOption={})).StartTime="startTime",L.CreatedAt="createdAt",e.AmityEventOrderOption=void 0,(P=e.AmityEventOrderOption||(e.AmityEventOrderOption={})).Ascending="asc",P.Descending="desc",e.AnalyticsSourceTypeEnum=void 0,(x=e.AnalyticsSourceTypeEnum||(e.AnalyticsSourceTypeEnum={})).POST="post",x.ROOM="room";const M=function(){try{return"v7.21.0-umd"}catch(e){return"__dev__"}}(),U=5,F="cache_then_server",N="For using Live Collection feature you need to enable Cache!",B="Observing unsynced object is not supported by Live Object.",j=-5,q=1e3,$=6e5,K="dead",G=6e4,H=e=>JSON.stringify(e,((e,t)=>{return"object"==typeof t?(n=t,Object.keys(n).sort().reduce(((e,t)=>Object.assign(Object.assign({},e),{[t]:n[t]})),{})):t;var n})),V=e=>JSON.parse(e),z=(e,t)=>e===t||!(!e||!t)&&("object"==typeof e&&Object.keys(e).every((n=>z(e[n],t[n])))),W=e=>[400400,400300].includes(e),Y="function"==typeof atob,Q="function"==typeof btoa,J="function"==typeof Buffer,X="function"==typeof TextDecoder?new TextDecoder:void 0,Z="function"==typeof TextEncoder?new TextEncoder:void 0,ee=Array.prototype.slice.call("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="),te=(e=>{let t={};return e.forEach(((e,n)=>t[e]=n)),t})(ee),ne=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,re=String.fromCharCode.bind(String),se="function"==typeof Uint8Array.from?Uint8Array.from.bind(Uint8Array):(e,t=(e=>e))=>new Uint8Array(Array.prototype.slice.call(e,0).map(t)),ie=e=>e.replace(/[^A-Za-z0-9\+\/]/g,""),ae=Q?e=>btoa(e):J?e=>Buffer.from(e,"binary").toString("base64"):e=>{let t,n,r,s,i="";const a=e.length%3;for(let a=0;a<e.length;){if((n=e.charCodeAt(a++))>255||(r=e.charCodeAt(a++))>255||(s=e.charCodeAt(a++))>255)throw new TypeError("invalid character found");t=n<<16|r<<8|s,i+=ee[t>>18&63]+ee[t>>12&63]+ee[t>>6&63]+ee[63&t]}return a?i.slice(0,a-3)+"===".substring(a):i},oe=J?e=>Buffer.from(e).toString("base64"):e=>{let t=[];for(let n=0,r=e.length;n<r;n+=4096)t.push(re.apply(null,e.subarray(n,n+4096)));return ae(t.join(""))},le=e=>{if(e.length<2)return(t=e.charCodeAt(0))<128?e:t<2048?re(192|t>>>6)+re(128|63&t):re(224|t>>>12&15)+re(128|t>>>6&63)+re(128|63&t);var t=65536+1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320);return re(240|t>>>18&7)+re(128|t>>>12&63)+re(128|t>>>6&63)+re(128|63&t)},ce=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,de=J?e=>Buffer.from(e,"utf8").toString("base64"):Z?e=>oe(Z.encode(e)):e=>ae(e.replace(ce,le)),ue=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,he=e=>{switch(e.length){case 4:var t=((7&e.charCodeAt(0))<<18|(63&e.charCodeAt(1))<<12|(63&e.charCodeAt(2))<<6|63&e.charCodeAt(3))-65536;return re(55296+(t>>>10))+re(56320+(1023&t));case 3:return re((15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2));default:return re((31&e.charCodeAt(0))<<6|63&e.charCodeAt(1))}},fe=Y?e=>atob(ie(e)):J?e=>Buffer.from(e,"base64").toString("binary"):e=>{if(e=e.replace(/\s+/g,""),!ne.test(e))throw new TypeError("malformed base64.");e+="==".slice(2-(3&e.length));let t,n,r,s="";for(let i=0;i<e.length;)t=te[e.charAt(i++)]<<18|te[e.charAt(i++)]<<12|(n=te[e.charAt(i++)])<<6|(r=te[e.charAt(i++)]),s+=64===n?re(t>>16&255):64===r?re(t>>16&255,t>>8&255):re(t>>16&255,t>>8&255,255&t);return s},pe=J?e=>se(Buffer.from(e,"base64")):e=>se(fe(e),(e=>e.charCodeAt(0))),ge=J?e=>Buffer.from(e,"base64").toString("utf8"):X?e=>X.decode(pe(e)):e=>fe(e).replace(ue,he),me=e=>ge(ie(e.replace(/[-_]/g,(e=>"-"==e?"+":"/")))),ye=e=>["skip"].some((t=>t in e)),ve=e=>["after","before","first","last","limit"].some((t=>t in e)),be=e=>"limit"in e,we=e=>(null==e?void 0:e.hasOwnProperty("data"))&&(null==e?void 0:e.hasOwnProperty("nextPage"))&&(null==e?void 0:e.hasOwnProperty("prevPage")),Se=(e,t)=>{var n;if(!e||!Object.keys(e).length)return;let r={};return"skiplimit"===t?r={skip:null!==(n=e.after)&&void 0!==n?n:0,limit:e.limit}:"afterbefore"===t&&ve(e)?((null==e?void 0:e.before)&&(r=Object.assign(Object.assign({},r),{before:e.before})),(null==e?void 0:e.after)&&(r=Object.assign(Object.assign({},r),{after:e.after})),Number.isNaN(Number(null==e?void 0:e.limit))||(r=Object.assign(Object.assign({},r),{limit:e.limit}))):"afterbeforeraw"===t&&(r=e),Object.keys(r).length?((e,t=!1)=>t?(e=>e.replace(/=/g,"").replace(/[+\/]/g,(e=>"+"==e?"-":"_")))(de(e)):de(e))(JSON.stringify(r)):void 0},Te=e=>{if(!e)return;const t=JSON.parse(me(e));if(ye(t))return{after:t.skip,limit:t.limit};if(ve(t)){if("before"in t)return{before:t.before,limit:t.last};if("after"in t)return{after:t.after,limit:t.first}}},Ie=e=>"locally"in e,Ce=e=>"optimistically"in e,Ee=e=>Ie(e)||Ce(e),Ae=e=>null==e?void 0:e.hasOwnProperty("cachedAt"),ke=(e,t=6e4)=>{var n;return Date.now()-(null!==(n=null==e?void 0:e.cachedAt)&&void 0!==n?n:0)<=t},Re=(e,...t)=>({func:e,args:t}),_e=(e,t=6e4)=>"cache_only"===e?{lifeSpan:1/0}:{lifeSpan:t<G?G:t},Oe=({func:e,args:t},n,r=_e("cache_then_server"))=>{let s;const{lifeSpan:i}=_e("cache_then_server",r.lifeSpan);if(Ee(e)){try{s=Ce(e)?e.optimistically(...t):e.locally(...t)}catch(e){null==n||n(De(void 0,{origin:"local",loading:!1,error:e}))}const r=Ae(s)&&ke(s,i);if(null==n||n(De(s,{origin:"local",loading:!(Ie(e)&&r)})),r)return}else null==n||n(De(void 0,{origin:"local",loading:!0}));e(...t).then((e=>{null==n||n(De(e,{origin:"server",loading:!1}))})).catch((e=>{null==n||n(De(void 0,{origin:"server",loading:!1,error:e}))}))};function De(e,t){return we(e)||Ae(e)?Object.assign(Object.assign({},t),e):Object.assign(Object.assign({},t),{data:e})}const Le={user:({userId:e})=>e,file:({fileId:e})=>e,role:({roleId:e})=>e,channel:({channelInternalId:e})=>e,subChannel:({subChannelId:e})=>e,channelUsers:({channelId:e,userId:t})=>`${e}#${t}`,message:({messageId:e,referenceId:t})=>null!=t?t:e,messagePreviewChannel:({channelId:e})=>`${e}`,messagePreviewSubChannel:({subChannelId:e})=>`${e}`,channelUnreadInfo:({channelId:e})=>e,subChannelUnreadInfo:({subChannelId:e})=>e,channelUnread:({channelId:e})=>e,channelMarker:({entityId:e,userId:t})=>`${e}#${t}`,subChannelMarker:({entityId:e,feedId:t,userId:n})=>`${e}#${t}#${n}`,messageMarker:({feedId:e,contentId:t,creatorId:n})=>`${e}#${t}#${n}`,feedMarker:({feedId:e,entityId:t})=>`${e}#${t}`,userMarker:({userId:e})=>e,community:({communityId:e})=>e,category:({categoryId:e})=>e,communityUsers:({communityId:e,userId:t})=>`${e}#${t}`,post:({postId:e})=>e,comment:({commentId:e})=>e,commentChildren:({commentId:e})=>e,poll:({pollId:e})=>e,reaction:({referenceType:e,referenceId:t})=>`${e}#${t}`,reactor:({reactionId:e})=>e,stream:({streamId:e})=>e,streamModeration:({streamId:e})=>e,follow:({from:e,to:t})=>`${e}#${t}`,followInfo:({userId:e})=>e,followCount:({userId:e})=>e,feed:({targetId:e,feedId:t})=>`${e}#${t}`,story:({referenceId:e})=>e,storyTarget:({targetId:e})=>e,ad:({adId:e})=>e,advertiser:({advertiserId:e})=>e,pin:({placement:e,referenceId:t})=>`${e}#${t}`,pinTarget:({targetId:e})=>e,notificationTrayItem:({_id:e})=>e,notificationTraySeen:({userId:e})=>e,invitation:({_id:e})=>e,joinRequest:({joinRequestId:e})=>e,room:({roomId:e})=>e,viewer:({userId:e})=>e,event:({eventId:e})=>e,eventResponse:({userId:e})=>e,product:({productId:e})=>e},Pe=e=>Le[e],xe={users:"user",files:"file",roles:"role",stories:"story",storyTargets:"storyTarget",channels:"channel",messageFeeds:"subChannel",channelUsers:"channelUsers",messages:"message",messagePreviewChannel:"messagePreviewChannel",messagePreviewSubChannel:"messagePreviewSubChannel",channelUnreadInfo:"channelUnreadInfo",subChannelUnreadInfo:"subChannelUnreadInfo",userEntityMarkers:"channelMarker",userFeedMarkers:"subChannelMarker",contentMarkers:"messageMarker",feedMarkers:"feedMarker",userMarkers:"userMarker",communities:"community",categories:"category",communityUsers:"communityUsers",posts:"post",postChildren:"post",comments:"comment",commentChildren:"comment",polls:"poll",reactors:"reactor",reactions:"reaction",videoStreamings:"stream",videoStreamingChildren:"stream",videoStreamModerations:"streamModeration",follows:"follow",followCounts:"followCount",feeds:"feed",ads:"ad",advertisers:"advertiser",pinTargets:"pinTarget",pins:"pin",notificationTrayItems:"notificationTrayItem",invitations:"invitation",joinRequests:"joinRequest",rooms:"room",events:"event",viewers:"viewer",eventResponses:"eventResponse",products:"product"};function Me(e=(new Date).toISOString()){return new Date(new Date(e).getTime()+1).toISOString()}class Ue extends Error{constructor(e,t,n){super(`Amity SDK (${t}): ${e}`),this.code=t,this.level=n,this.type="ASC",this.timestamp=Date.now(),Error.captureStackTrace&&Error.captureStackTrace(this,Ue)}}class Fe extends Ue{constructor(e,t,n){super(e,t,n)}}class Ne extends Ue{constructor(e=8e5,t="fatal"){super("Unexpected error",e,t)}}class Be extends Ue{constructor(e,t="SDK client is having connection issues"){super(`${t} (${e})`,"disconnected"===e?800211:800210,"error"),this.event=e}}let je=null;const qe=()=>{if(!je)throw new Ue("There is no active client",8e5,"fatal");return je},$e=e=>{je=e},Ke=e=>{const{log:t,cache:n}=qe();if(n)return t("cache/api/queryCache",{key:e}),Object.keys(n.data).filter((t=>{const n=V(t);return z(e,n)})).map((e=>n.data[e]))},Ge=e=>{const{log:t,cache:n}=qe();if(!n)return;t("cache/api/pullFromCache",e);const r=H(e);return n.data[r]?n.data[r]:void 0},He=(e,t,n={cachedAt:Date.now()})=>{const{log:r,cache:s}=qe();if(!s)return!1;r("cache/api/pushToCache",{key:e,data:t,options:n}),!(null==n?void 0:n.hasOwnProperty("offline"))&&s.persistIf&&(n.offline=s.persistIf(e,t));const i=H(e);return s.data[i]=Object.assign({key:e,data:t},n),!0},Ve=(e,t,n)=>{const{log:r,cache:s}=qe();if(!s)return!1;r("cache/api/mergeInCache",{key:e,mutation:t});const i=Ge(e);if(!i)return!1;const a="function"==typeof t?t(i.data):Object.assign(Object.assign({},i.data),t);return o=i.data,!("updatedAt"in(l=a)&&"updatedAt"in o&&new Date(l.updatedAt)<new Date(o.updatedAt))&&(He(e,a,n),!0);var o,l},ze=(e,t,n={cachedAt:Date.now()})=>{const{log:r,cache:s}=qe();if(!s)return!1;r("cache/api/upsertInCache",{key:e,data:t,options:n});return Ge(e)?Ve(e,t,n):He(e,t,n)},We=(e,t=!1)=>{const{log:n,cache:r}=qe();if(!r)return!1;if(n("cache/api/dropFromCache",{key:e,exact:t}),!t)return Object.keys(r.data).map((e=>V(e))).filter((t=>z(e,t))).map((e=>We(e,!0))).every((e=>e));const s=H(e);return s in r.data&&(delete r.data[s],!0)},Ye=(e,t,n)=>void 0!==n?e.filter((e=>JSON.stringify(e[t])===JSON.stringify(n))):e,Qe=(e,t,n)=>void 0!==n?e.filter((e=>"string"==typeof e[t]&&"string"==typeof n&&String(e[t]).toLowerCase().match(n.toLowerCase()))):e,Je=(e,t,n)=>(null==n?void 0:n.length)?e.filter((e=>Array.isArray(e[t])&&n.some((n=>e[t].includes(n))))):e,Xe=(e,t,n)=>"all"===t?e:e.filter((e=>{var r;if("community"===e.type)return!0;const s=Pe("channelUsers")({channelId:e.channelPublicId,userId:n}),i=null===(r=Ge(["channelUsers","get",s]))||void 0===r?void 0:r.data;return"member"===t?i&&"none"!==i.membership:!i||"none"===i.membership})),Ze=(e,t)=>e.filter((({targetId:e,feedId:n})=>{var r;const s=null===(r=Ge(["feed","get",Pe("feed")({targetId:e,feedId:n})]))||void 0===r?void 0:r.data;return s&&s.feedType===t})),et=(e,t,n)=>"all"===t?e:e.filter((e=>{var r;const s=Pe("communityUsers")({communityId:e.communityId,userId:n}),i=null===(r=Ge(["communityUsers","get",s]))||void 0===r?void 0:r.data;return"member"===t?i&&"member"===i.communityMembership:!i||"none"!==i.communityMembership})),tt=(e,t)=>e.reduce(((e,n)=>{var r;if(null==t?void 0:t.includes(n.dataType))return[...e,n];if(((null==n?void 0:n.children)||[]).length>0){const s=null===(r=Ge(["post","get",n.children[0]]))||void 0===r?void 0:r.data;return(null==t?void 0:t.includes(null==s?void 0:s.dataType))?e:[...e,n]}return e}),[]),nt=(e,t)=>{const n=new RegExp(t,"i");return e.filter((e=>{var t;return!!e.userId.match(n)||e.user&&(null===(t=e.user.displayName)||void 0===t?void 0:t.match(n))}))},rt=({displayName:e},{displayName:t})=>e&&t?e.localeCompare(t):e?-1:1,st=({name:e},{name:t})=>e&&t?e.localeCompare(t):e?-1:1,it=({createdAt:e},{createdAt:t})=>new Date(e).valueOf()-new Date(t).valueOf(),at=({localSortingDate:e},{localSortingDate:t})=>new Date(t).getTime()-new Date(e).getTime(),ot=({createdAt:e},{createdAt:t})=>new Date(t).valueOf()-new Date(e).valueOf(),lt=({updatedAt:e=0},{updatedAt:t=0})=>new Date(e).valueOf()-new Date(t).valueOf(),ct=({updatedAt:e=0},{updatedAt:t=0})=>new Date(t).valueOf()-new Date(e).valueOf(),dt=({lastActivity:e},{lastActivity:t})=>new Date(t).valueOf()-new Date(e).valueOf(),ut=e=>{if(void 0===e)return;const t=new Date(e).valueOf();if(!Number.isNaN(t))return e;console.warn("untilAt is an invalid Date — ignoring, pagination will not be bounded")},ht=(e,t,n)=>{const r=new Date(e).valueOf(),s=new Date(t).valueOf();return"firstCreated"===n?r>=s:r<=s};let ft=null;const pt=()=>{if(!ft)throw new Ue("Connect client first",8e5,"fatal");return ft},gt=e=>{ft={_id:e._id,userId:e.userId,path:e.path}};let mt,yt=[];const vt=e=>{clearTimeout(mt),yt.push(e),mt=setTimeout((()=>{yt.forEach((e=>e())),yt=[]}),0)},bt=["connect","message","disconnect","error","close","end","reconnect","video-streaming.didStart","video-streaming.didRecord","video-streaming.didStop","video-streaming.didFlag","video-streaming.didTerminate","video-streaming.viewerDidBan","video-streaming.viewerDidUnban","liveReaction.created"],wt=()=>function(e){return{all:e=e||new Map,on:function(t,n){var r=e.get(t);r?r.push(n):e.set(t,[n])},off:function(t,n){var r=e.get(t);r&&(n?r.splice(r.indexOf(n)>>>0,1):e.set(t,[]))},emit:function(t,n){var r=e.get(t);r&&r.slice().map((function(e){e(n)})),(r=e.get("*"))&&r.slice().map((function(e){e(t,n)}))}}}(),St=(e,t,n,r)=>{const{log:s,emitter:i}=e,a=Date.now();s(`${t}(tmpid: ${a}) > listen`);const o=(...e)=>{s(`${t}(tmpid: ${a}) > trigger`,e);try{r(...e)}catch(e){s(`${t}(tmpid: ${a}) > error`,e)}};return i.on(n,o),()=>{s(`${t}(tmpid: ${a}) > dispose`),i.off(n,o)}},Tt=(e,t)=>{const{emitter:n}=qe();vt((()=>{n.emit(e,t)}))};let It,Ct;async function Et(){var e;const{mqtt:t,emitter:n,token:r}=qe();if(!t)return;const s=null!==(e=null==r?void 0:r.accessToken)&&void 0!==e?e:"",i=pt();It===s&&Ct===i._id||(It=s,Ct=i._id,await t.connect({accessToken:It,userId:Ct}),((e,t)=>{bt.forEach((n=>{null==e||e.on(n,((...e)=>{t.emit(n,1===e.length?e[0]:e)}))})),e.on("message",((e,n)=>{const r=JSON.parse(n.toString());t.emit(r.eventType,r.data)}))})(t,n))}const At=e=>Object.assign(Object.assign({},e),{get avatar(){var t;if(!e.avatarFileId)return;return null===(t=Ge(["file","get",`${e.avatarFileId}`]))||void 0===t?void 0:t.data}}),kt=()=>{var e;const t=qe();if(!t)throw new Ue("Connect client first",8e5,"fatal");const n=null===(e=Ge(["user","get",t.userId]))||void 0===e?void 0:e.data;return n?At(n):null};var Rt;e.SubscriptionLevels=void 0,(Rt=e.SubscriptionLevels||(e.SubscriptionLevels={})).COMMUNITY="community",Rt.POST="post",Rt.COMMENT="comment",Rt.POST_AND_COMMENT="post_and_comment",Rt.USER="user";const _t=(e,t)=>{switch(t){case"post":return`${e}/post/+`;case"comment":return`${e}/post/+/comment/+`;case"post_and_comment":return`${e}/post/#`;default:return e}},Ot=e=>e.path.split("/user/")[0],Dt=({path:t},n=e.SubscriptionLevels.USER)=>_t(n===e.SubscriptionLevels.USER?t:t.replace(/^(\w*)/,"$1/social"),n),Lt=({channelId:e,subChannelId:t})=>{const n=pt();return`${Ot(n)}/marker/channel/${e}/message/${t}`},Pt=()=>{const e=pt();return`${Ot(e)}/marker/user/${e._id}`},xt=()=>Ot(pt()),Mt=()=>{const e=pt();return`${Ot(e)}/smartfeed/${e._id}/channels`},Ut=()=>{const e=pt();return`${Ot(e)}/smartfeed/${e._id}/messagefeeds`},Ft=()=>{const e=pt();return`${Ot(e)}/smartfeed/${e._id}/messages`},Nt=()=>{const e=pt();return`${Ot(e)}/videostreaming`};function Bt(e,t){const{mqtt:n}=qe();return n?(Et(),n.subscribe(e,t)):()=>null}var jt="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function qt(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var $t,Kt,Gt={exports:{}};function Ht(){if(Kt)return $t;Kt=1;var e=1e3,t=60*e,n=60*t,r=24*n,s=7*r,i=365.25*r;function a(e,t,n,r){var s=t>=1.5*n;return Math.round(e/n)+" "+r+(s?"s":"")}return $t=function(o,l){l=l||{};var c=typeof o;if("string"===c&&o.length>0)return function(a){if((a=String(a)).length>100)return;var o=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(a);if(!o)return;var l=parseFloat(o[1]);switch((o[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return l*i;case"weeks":case"week":case"w":return l*s;case"days":case"day":case"d":return l*r;case"hours":case"hour":case"hrs":case"hr":case"h":return l*n;case"minutes":case"minute":case"mins":case"min":case"m":return l*t;case"seconds":case"second":case"secs":case"sec":case"s":return l*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return l;default:return}}(o);if("number"===c&&isFinite(o))return l.long?function(s){var i=Math.abs(s);if(i>=r)return a(s,i,r,"day");if(i>=n)return a(s,i,n,"hour");if(i>=t)return a(s,i,t,"minute");if(i>=e)return a(s,i,e,"second");return s+" ms"}(o):function(s){var i=Math.abs(s);if(i>=r)return Math.round(s/r)+"d";if(i>=n)return Math.round(s/n)+"h";if(i>=t)return Math.round(s/t)+"m";if(i>=e)return Math.round(s/e)+"s";return s+"ms"}(o);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(o))},$t}var Vt=function(e){function t(e){let r,s,i,a=null;function o(...e){if(!o.enabled)return;const n=o,s=Number(new Date),i=s-(r||s);n.diff=i,n.prev=r,n.curr=s,r=s,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let a=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((r,s)=>{if("%%"===r)return"%";a++;const i=t.formatters[s];if("function"==typeof i){const t=e[a];r=i.call(n,t),e.splice(a,1),a--}return r})),t.formatArgs.call(n,e);(n.log||t.log).apply(n,e)}return o.namespace=e,o.useColors=t.useColors(),o.color=t.selectColor(e),o.extend=n,o.destroy=t.destroy,Object.defineProperty(o,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==a?a:(s!==t.namespaces&&(s=t.namespaces,i=t.enabled(e)),i),set:e=>{a=e}}),"function"==typeof t.init&&t.init(o),o}function n(e,n){const r=t(this.namespace+(void 0===n?":":n)+e);return r.log=this.log,r}function r(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names.map(r),...t.skips.map(r).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let n;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const r=("string"==typeof e?e:"").split(/[\s,]+/),s=r.length;for(n=0;n<s;n++)r[n]&&("-"===(e=r[n].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.slice(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let n,r;for(n=0,r=t.skips.length;n<r;n++)if(t.skips[n].test(e))return!1;for(n=0,r=t.names.length;n<r;n++)if(t.names[n].test(e))return!0;return!1},t.humanize=Ht(),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((n=>{t[n]=e[n]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t<e.length;t++)n=(n<<5)-n+e.charCodeAt(t),n|=0;return t.colors[Math.abs(n)%t.colors.length]},t.enable(t.load()),t};!function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;t.splice(1,0,n,"color: inherit");let r=0,s=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(r++,"%c"===e&&(s=r))})),t.splice(s,0,n)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=Vt(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(Gt,Gt.exports);var zt,Wt=Gt.exports;const Yt="object"==typeof globalThis?globalThis:"object"==typeof global?global:window,{process:Qt={}}=Yt,Jt="production"===(null===(zt=Qt.env)||void 0===zt?void 0:zt.NODE_ENV),Xt={EU:"eu",SG:"sg",US:"us"},Zt={http:"https://apix.{region}.amity.co",upload:"https://upload.{region}.amity.co",mqtt:"wss://sse.{region}.amity.co:443/mqtt"};function en(e,t){return Zt[e].replace("{region}",t)}function tn(e,t){return function(){return e.apply(t,arguments)}}const{toString:nn}=Object.prototype,{getPrototypeOf:rn}=Object,{iterator:sn,toStringTag:an}=Symbol,on=(ln=Object.create(null),e=>{const t=nn.call(e);return ln[t]||(ln[t]=t.slice(8,-1).toLowerCase())});var ln;const cn=e=>(e=e.toLowerCase(),t=>on(t)===e),dn=e=>t=>typeof t===e,{isArray:un}=Array,hn=dn("undefined");function fn(e){return null!==e&&!hn(e)&&null!==e.constructor&&!hn(e.constructor)&&mn(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const pn=cn("ArrayBuffer");const gn=dn("string"),mn=dn("function"),yn=dn("number"),vn=e=>null!==e&&"object"==typeof e,bn=e=>{if("object"!==on(e))return!1;const t=rn(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||an in e||sn in e)},wn=cn("Date"),Sn=cn("File"),Tn=cn("Blob"),In=cn("FileList"),Cn=cn("URLSearchParams"),[En,An,kn,Rn]=["ReadableStream","Request","Response","Headers"].map(cn);function _n(e,t,{allOwnKeys:n=!1}={}){if(null==e)return;let r,s;if("object"!=typeof e&&(e=[e]),un(e))for(r=0,s=e.length;r<s;r++)t.call(null,e[r],r,e);else{if(fn(e))return;const s=n?Object.getOwnPropertyNames(e):Object.keys(e),i=s.length;let a;for(r=0;r<i;r++)a=s[r],t.call(null,e[a],a,e)}}function On(e,t){if(fn(e))return null;t=t.toLowerCase();const n=Object.keys(e);let r,s=n.length;for(;s-- >0;)if(r=n[s],t===r.toLowerCase())return r;return null}const Dn="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,Ln=e=>!hn(e)&&e!==Dn;const Pn=(xn="undefined"!=typeof Uint8Array&&rn(Uint8Array),e=>xn&&e instanceof xn);var xn;const Mn=cn("HTMLFormElement"),Un=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Fn=cn("RegExp"),Nn=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};_n(n,((n,s)=>{let i;!1!==(i=t(n,s,e))&&(r[s]=i||n)})),Object.defineProperties(e,r)};const Bn=cn("AsyncFunction"),jn=(qn="function"==typeof setImmediate,$n=mn(Dn.postMessage),qn?setImmediate:$n?((e,t)=>(Dn.addEventListener("message",(({source:n,data:r})=>{n===Dn&&r===e&&t.length&&t.shift()()}),!1),n=>{t.push(n),Dn.postMessage(e,"*")}))(`axios@${Math.random()}`,[]):e=>setTimeout(e));var qn,$n;const Kn="undefined"!=typeof queueMicrotask?queueMicrotask.bind(Dn):"undefined"!=typeof process&&process.nextTick||jn;var Gn={isArray:un,isArrayBuffer:pn,isBuffer:fn,isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||mn(e.append)&&("formdata"===(t=on(e))||"object"===t&&mn(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&pn(e.buffer),t},isString:gn,isNumber:yn,isBoolean:e=>!0===e||!1===e,isObject:vn,isPlainObject:bn,isEmptyObject:e=>{if(!vn(e)||fn(e))return!1;try{return 0===Object.keys(e).length&&Object.getPrototypeOf(e)===Object.prototype}catch(e){return!1}},isReadableStream:En,isRequest:An,isResponse:kn,isHeaders:Rn,isUndefined:hn,isDate:wn,isFile:Sn,isBlob:Tn,isRegExp:Fn,isFunction:mn,isStream:e=>vn(e)&&mn(e.pipe),isURLSearchParams:Cn,isTypedArray:Pn,isFileList:In,forEach:_n,merge:function e(){const{caseless:t,skipUndefined:n}=Ln(this)&&this||{},r={},s=(s,i)=>{const a=t&&On(r,i)||i;bn(r[a])&&bn(s)?r[a]=e(r[a],s):bn(s)?r[a]=e({},s):un(s)?r[a]=s.slice():n&&hn(s)||(r[a]=s)};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&_n(arguments[e],s);return r},extend:(e,t,n,{allOwnKeys:r}={})=>(_n(t,((t,r)=>{n&&mn(t)?e[r]=tn(t,n):e[r]=t}),{allOwnKeys:r}),e),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},toFlatObject:(e,t,n,r)=>{let s,i,a;const o={};if(t=t||{},null==e)return t;do{for(s=Object.getOwnPropertyNames(e),i=s.length;i-- >0;)a=s[i],r&&!r(a,e,t)||o[a]||(t[a]=e[a],o[a]=!0);e=!1!==n&&rn(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},kindOf:on,kindOfTest:cn,endsWith:(e,t,n)=>{e=String(e),(void 0===n||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return-1!==r&&r===n},toArray:e=>{if(!e)return null;if(un(e))return e;let t=e.length;if(!yn(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},forEachEntry:(e,t)=>{const n=(e&&e[sn]).call(e);let r;for(;(r=n.next())&&!r.done;){const n=r.value;t.call(e,n[0],n[1])}},matchAll:(e,t)=>{let n;const r=[];for(;null!==(n=e.exec(t));)r.push(n);return r},isHTMLForm:Mn,hasOwnProperty:Un,hasOwnProp:Un,reduceDescriptors:Nn,freezeMethods:e=>{Nn(e,((t,n)=>{if(mn(e)&&-1!==["arguments","caller","callee"].indexOf(n))return!1;const r=e[n];mn(r)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")}))}))},toObjectSet:(e,t)=>{const n={},r=e=>{e.forEach((e=>{n[e]=!0}))};return un(e)?r(e):r(String(e).split(t)),n},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,(function(e,t,n){return t.toUpperCase()+n})),noop:()=>{},toFiniteNumber:(e,t)=>null!=e&&Number.isFinite(e=+e)?e:t,findKey:On,global:Dn,isContextDefined:Ln,isSpecCompliantForm:function(e){return!!(e&&mn(e.append)&&"FormData"===e[an]&&e[sn])},toJSONObject:e=>{const t=new Array(10),n=(e,r)=>{if(vn(e)){if(t.indexOf(e)>=0)return;if(fn(e))return e;if(!("toJSON"in e)){t[r]=e;const s=un(e)?[]:{};return _n(e,((e,t)=>{const i=n(e,r+1);!hn(i)&&(s[t]=i)})),t[r]=void 0,s}}return e};return n(e,0)},isAsyncFn:Bn,isThenable:e=>e&&(vn(e)||mn(e))&&mn(e.then)&&mn(e.catch),setImmediate:jn,asap:Kn,isIterable:e=>null!=e&&mn(e[sn])};function Hn(e,t,n,r,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),s&&(this.response=s,this.status=s.status?s.status:null)}Gn.inherits(Hn,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:Gn.toJSONObject(this.config),code:this.code,status:this.status}}});const Vn=Hn.prototype,zn={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach((e=>{zn[e]={value:e}})),Object.defineProperties(Hn,zn),Object.defineProperty(Vn,"isAxiosError",{value:!0}),Hn.from=(e,t,n,r,s,i)=>{const a=Object.create(Vn);Gn.toFlatObject(e,a,(function(e){return e!==Error.prototype}),(e=>"isAxiosError"!==e));const o=e&&e.message?e.message:"Error",l=null==t&&e?e.code:t;return Hn.call(a,o,l,n,r,s),e&&null==a.cause&&Object.defineProperty(a,"cause",{value:e,configurable:!0}),a.name=e&&e.name||"Error",i&&Object.assign(a,i),a};function Wn(e){return Gn.isPlainObject(e)||Gn.isArray(e)}function Yn(e){return Gn.endsWith(e,"[]")?e.slice(0,-2):e}function Qn(e,t,n){return e?e.concat(t).map((function(e,t){return e=Yn(e),!n&&t?"["+e+"]":e})).join(n?".":""):t}const Jn=Gn.toFlatObject(Gn,{},null,(function(e){return/^is[A-Z]/.test(e)}));function Xn(e,t,n){if(!Gn.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;const r=(n=Gn.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,(function(e,t){return!Gn.isUndefined(t[e])}))).metaTokens,s=n.visitor||c,i=n.dots,a=n.indexes,o=(n.Blob||"undefined"!=typeof Blob&&Blob)&&Gn.isSpecCompliantForm(t);if(!Gn.isFunction(s))throw new TypeError("visitor must be a function");function l(e){if(null===e)return"";if(Gn.isDate(e))return e.toISOString();if(Gn.isBoolean(e))return e.toString();if(!o&&Gn.isBlob(e))throw new Hn("Blob is not supported. Use a Buffer instead.");return Gn.isArrayBuffer(e)||Gn.isTypedArray(e)?o&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function c(e,n,s){let o=e;if(e&&!s&&"object"==typeof e)if(Gn.endsWith(n,"{}"))n=r?n:n.slice(0,-2),e=JSON.stringify(e);else if(Gn.isArray(e)&&function(e){return Gn.isArray(e)&&!e.some(Wn)}(e)||(Gn.isFileList(e)||Gn.endsWith(n,"[]"))&&(o=Gn.toArray(e)))return n=Yn(n),o.forEach((function(e,r){!Gn.isUndefined(e)&&null!==e&&t.append(!0===a?Qn([n],r,i):null===a?n:n+"[]",l(e))})),!1;return!!Wn(e)||(t.append(Qn(s,n,i),l(e)),!1)}const d=[],u=Object.assign(Jn,{defaultVisitor:c,convertValue:l,isVisitable:Wn});if(!Gn.isObject(e))throw new TypeError("data must be an object");return function e(n,r){if(!Gn.isUndefined(n)){if(-1!==d.indexOf(n))throw Error("Circular reference detected in "+r.join("."));d.push(n),Gn.forEach(n,(function(n,i){!0===(!(Gn.isUndefined(n)||null===n)&&s.call(t,n,Gn.isString(i)?i.trim():i,r,u))&&e(n,r?r.concat(i):[i])})),d.pop()}}(e),t}function Zn(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,(function(e){return t[e]}))}function er(e,t){this._pairs=[],e&&Xn(e,this,t)}const tr=er.prototype;function nr(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function rr(e,t,n){if(!t)return e;const r=n&&n.encode||nr;Gn.isFunction(n)&&(n={serialize:n});const s=n&&n.serialize;let i;if(i=s?s(t,n):Gn.isURLSearchParams(t)?t.toString():new er(t,n).toString(r),i){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+i}return e}tr.append=function(e,t){this._pairs.push([e,t])},tr.toString=function(e){const t=e?function(t){return e.call(this,t,Zn)}:Zn;return this._pairs.map((function(e){return t(e[0])+"="+t(e[1])}),"").join("&")};class sr{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){Gn.forEach(this.handlers,(function(t){null!==t&&e(t)}))}}var ir={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},ar={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:er,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]};const or="undefined"!=typeof window&&"undefined"!=typeof document,lr="object"==typeof navigator&&navigator||void 0,cr=or&&(!lr||["ReactNative","NativeScript","NS"].indexOf(lr.product)<0),dr="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,ur=or&&window.location.href||"http://localhost";var hr={...Object.freeze({__proto__:null,hasBrowserEnv:or,hasStandardBrowserWebWorkerEnv:dr,hasStandardBrowserEnv:cr,navigator:lr,origin:ur}),...ar};function fr(e){function t(e,n,r,s){let i=e[s++];if("__proto__"===i)return!0;const a=Number.isFinite(+i),o=s>=e.length;if(i=!i&&Gn.isArray(r)?r.length:i,o)return Gn.hasOwnProp(r,i)?r[i]=[r[i],n]:r[i]=n,!a;r[i]&&Gn.isObject(r[i])||(r[i]=[]);return t(e,n,r[i],s)&&Gn.isArray(r[i])&&(r[i]=function(e){const t={},n=Object.keys(e);let r;const s=n.length;let i;for(r=0;r<s;r++)i=n[r],t[i]=e[i];return t}(r[i])),!a}if(Gn.isFormData(e)&&Gn.isFunction(e.entries)){const n={};return Gn.forEachEntry(e,((e,r)=>{t(function(e){return Gn.matchAll(/\w+|\[(\w*)]/g,e).map((e=>"[]"===e[0]?"":e[1]||e[0]))}(e),r,n,0)})),n}return null}const pr={transitional:ir,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const n=t.getContentType()||"",r=n.indexOf("application/json")>-1,s=Gn.isObject(e);s&&Gn.isHTMLForm(e)&&(e=new FormData(e));if(Gn.isFormData(e))return r?JSON.stringify(fr(e)):e;if(Gn.isArrayBuffer(e)||Gn.isBuffer(e)||Gn.isStream(e)||Gn.isFile(e)||Gn.isBlob(e)||Gn.isReadableStream(e))return e;if(Gn.isArrayBufferView(e))return e.buffer;if(Gn.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let i;if(s){if(n.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return Xn(e,new hr.classes.URLSearchParams,{visitor:function(e,t,n,r){return hr.isNode&&Gn.isBuffer(e)?(this.append(t,e.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)},...t})}(e,this.formSerializer).toString();if((i=Gn.isFileList(e))||n.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return Xn(i?{"files[]":e}:e,t&&new t,this.formSerializer)}}return s||r?(t.setContentType("application/json",!1),function(e,t,n){if(Gn.isString(e))try{return(t||JSON.parse)(e),Gn.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(n||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||pr.transitional,n=t&&t.forcedJSONParsing,r="json"===this.responseType;if(Gn.isResponse(e)||Gn.isReadableStream(e))return e;if(e&&Gn.isString(e)&&(n&&!this.responseType||r)){const n=!(t&&t.silentJSONParsing)&&r;try{return JSON.parse(e,this.parseReviver)}catch(e){if(n){if("SyntaxError"===e.name)throw Hn.from(e,Hn.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:hr.classes.FormData,Blob:hr.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Gn.forEach(["delete","get","head","post","put","patch"],(e=>{pr.headers[e]={}}));const gr=Gn.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]);const mr=Symbol("internals");function yr(e){return e&&String(e).trim().toLowerCase()}function vr(e){return!1===e||null==e?e:Gn.isArray(e)?e.map(vr):String(e)}function br(e,t,n,r,s){return Gn.isFunction(r)?r.call(this,t,n):(s&&(t=n),Gn.isString(t)?Gn.isString(r)?-1!==t.indexOf(r):Gn.isRegExp(r)?r.test(t):void 0:void 0)}class wr{constructor(e){e&&this.set(e)}set(e,t,n){const r=this;function s(e,t,n){const s=yr(t);if(!s)throw new Error("header name must be a non-empty string");const i=Gn.findKey(r,s);(!i||void 0===r[i]||!0===n||void 0===n&&!1!==r[i])&&(r[i||t]=vr(e))}const i=(e,t)=>Gn.forEach(e,((e,n)=>s(e,n,t)));if(Gn.isPlainObject(e)||e instanceof this.constructor)i(e,t);else if(Gn.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim()))i((e=>{const t={};let n,r,s;return e&&e.split("\n").forEach((function(e){s=e.indexOf(":"),n=e.substring(0,s).trim().toLowerCase(),r=e.substring(s+1).trim(),!n||t[n]&&gr[n]||("set-cookie"===n?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)})),t})(e),t);else if(Gn.isObject(e)&&Gn.isIterable(e)){let n,r,s={};for(const t of e){if(!Gn.isArray(t))throw TypeError("Object iterator must return a key-value pair");s[r=t[0]]=(n=s[r])?Gn.isArray(n)?[...n,t[1]]:[n,t[1]]:t[1]}i(s,t)}else null!=e&&s(t,e,n);return this}get(e,t){if(e=yr(e)){const n=Gn.findKey(this,e);if(n){const e=this[n];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}(e);if(Gn.isFunction(t))return t.call(this,e,n);if(Gn.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=yr(e)){const n=Gn.findKey(this,e);return!(!n||void 0===this[n]||t&&!br(0,this[n],n,t))}return!1}delete(e,t){const n=this;let r=!1;function s(e){if(e=yr(e)){const s=Gn.findKey(n,e);!s||t&&!br(0,n[s],s,t)||(delete n[s],r=!0)}}return Gn.isArray(e)?e.forEach(s):s(e),r}clear(e){const t=Object.keys(this);let n=t.length,r=!1;for(;n--;){const s=t[n];e&&!br(0,this[s],s,e,!0)||(delete this[s],r=!0)}return r}normalize(e){const t=this,n={};return Gn.forEach(this,((r,s)=>{const i=Gn.findKey(n,s);if(i)return t[i]=vr(r),void delete t[s];const a=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,((e,t,n)=>t.toUpperCase()+n))}(s):String(s).trim();a!==s&&delete t[s],t[a]=vr(r),n[a]=!0})),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return Gn.forEach(this,((n,r)=>{null!=n&&!1!==n&&(t[r]=e&&Gn.isArray(n)?n.join(", "):n)})),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map((([e,t])=>e+": "+t)).join("\n")}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const n=new this(e);return t.forEach((e=>n.set(e))),n}static accessor(e){const t=(this[mr]=this[mr]={accessors:{}}).accessors,n=this.prototype;function r(e){const r=yr(e);t[r]||(!function(e,t){const n=Gn.toCamelCase(" "+t);["get","set","has"].forEach((r=>{Object.defineProperty(e,r+n,{value:function(e,n,s){return this[r].call(this,t,e,n,s)},configurable:!0})}))}(n,e),t[r]=!0)}return Gn.isArray(e)?e.forEach(r):r(e),this}}function Sr(e,t){const n=this||pr,r=t||n,s=wr.from(r.headers);let i=r.data;return Gn.forEach(e,(function(e){i=e.call(n,i,s.normalize(),t?t.status:void 0)})),s.normalize(),i}function Tr(e){return!(!e||!e.__CANCEL__)}function Ir(e,t,n){Hn.call(this,null==e?"canceled":e,Hn.ERR_CANCELED,t,n),this.name="CanceledError"}function Cr(e,t,n){const r=n.config.validateStatus;n.status&&r&&!r(n.status)?t(new Hn("Request failed with status code "+n.status,[Hn.ERR_BAD_REQUEST,Hn.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n)):e(n)}wr.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),Gn.reduceDescriptors(wr.prototype,(({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[n]=e}}})),Gn.freezeMethods(wr),Gn.inherits(Ir,Hn,{__CANCEL__:!0});const Er=(e,t,n=3)=>{let r=0;const s=function(e,t){e=e||10;const n=new Array(e),r=new Array(e);let s,i=0,a=0;return t=void 0!==t?t:1e3,function(o){const l=Date.now(),c=r[a];s||(s=l),n[i]=o,r[i]=l;let d=a,u=0;for(;d!==i;)u+=n[d++],d%=e;if(i=(i+1)%e,i===a&&(a=(a+1)%e),l-s<t)return;const h=c&&l-c;return h?Math.round(1e3*u/h):void 0}}(50,250);return function(e,t){let n,r,s=0,i=1e3/t;const a=(t,i=Date.now())=>{s=i,n=null,r&&(clearTimeout(r),r=null),e(...t)};return[(...e)=>{const t=Date.now(),o=t-s;o>=i?a(e,t):(n=e,r||(r=setTimeout((()=>{r=null,a(n)}),i-o)))},()=>n&&a(n)]}((n=>{const i=n.loaded,a=n.lengthComputable?n.total:void 0,o=i-r,l=s(o);r=i;e({loaded:i,total:a,progress:a?i/a:void 0,bytes:o,rate:l||void 0,estimated:l&&a&&i<=a?(a-i)/l:void 0,event:n,lengthComputable:null!=a,[t?"download":"upload"]:!0})}),n)},Ar=(e,t)=>{const n=null!=e;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},kr=e=>(...t)=>Gn.asap((()=>e(...t)));var Rr=hr.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,hr.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(hr.origin),hr.navigator&&/(msie|trident)/i.test(hr.navigator.userAgent)):()=>!0,_r=hr.hasStandardBrowserEnv?{write(e,t,n,r,s,i){const a=[e+"="+encodeURIComponent(t)];Gn.isNumber(n)&&a.push("expires="+new Date(n).toGMTString()),Gn.isString(r)&&a.push("path="+r),Gn.isString(s)&&a.push("domain="+s),!0===i&&a.push("secure"),document.cookie=a.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read:()=>null,remove(){}};function Or(e,t,n){let r=!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t);return e&&(r||0==n)?function(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}const Dr=e=>e instanceof wr?{...e}:e;function Lr(e,t){t=t||{};const n={};function r(e,t,n,r){return Gn.isPlainObject(e)&&Gn.isPlainObject(t)?Gn.merge.call({caseless:r},e,t):Gn.isPlainObject(t)?Gn.merge({},t):Gn.isArray(t)?t.slice():t}function s(e,t,n,s){return Gn.isUndefined(t)?Gn.isUndefined(e)?void 0:r(void 0,e,0,s):r(e,t,0,s)}function i(e,t){if(!Gn.isUndefined(t))return r(void 0,t)}function a(e,t){return Gn.isUndefined(t)?Gn.isUndefined(e)?void 0:r(void 0,e):r(void 0,t)}function o(n,s,i){return i in t?r(n,s):i in e?r(void 0,n):void 0}const l={url:i,method:i,data:i,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,withXSRFToken:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,beforeRedirect:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:o,headers:(e,t,n)=>s(Dr(e),Dr(t),0,!0)};return Gn.forEach(Object.keys({...e,...t}),(function(r){const i=l[r]||s,a=i(e[r],t[r],r);Gn.isUndefined(a)&&i!==o||(n[r]=a)})),n}var Pr=e=>{const t=Lr({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:s,xsrfCookieName:i,headers:a,auth:o}=t;if(t.headers=a=wr.from(a),t.url=rr(Or(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),o&&a.set("Authorization","Basic "+btoa((o.username||"")+":"+(o.password?unescape(encodeURIComponent(o.password)):""))),Gn.isFormData(n))if(hr.hasStandardBrowserEnv||hr.hasStandardBrowserWebWorkerEnv)a.setContentType(void 0);else if(Gn.isFunction(n.getHeaders)){const e=n.getHeaders(),t=["content-type","content-length"];Object.entries(e).forEach((([e,n])=>{t.includes(e.toLowerCase())&&a.set(e,n)}))}if(hr.hasStandardBrowserEnv&&(r&&Gn.isFunction(r)&&(r=r(t)),r||!1!==r&&Rr(t.url))){const e=s&&i&&_r.read(i);e&&a.set(s,e)}return t};var xr="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise((function(t,n){const r=Pr(e);let s=r.data;const i=wr.from(r.headers).normalize();let a,o,l,c,d,{responseType:u,onUploadProgress:h,onDownloadProgress:f}=r;function p(){c&&c(),d&&d(),r.cancelToken&&r.cancelToken.unsubscribe(a),r.signal&&r.signal.removeEventListener("abort",a)}let g=new XMLHttpRequest;function m(){if(!g)return;const r=wr.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders());Cr((function(e){t(e),p()}),(function(e){n(e),p()}),{data:u&&"text"!==u&&"json"!==u?g.response:g.responseText,status:g.status,statusText:g.statusText,headers:r,config:e,request:g}),g=null}g.open(r.method.toUpperCase(),r.url,!0),g.timeout=r.timeout,"onloadend"in g?g.onloadend=m:g.onreadystatechange=function(){g&&4===g.readyState&&(0!==g.status||g.responseURL&&0===g.responseURL.indexOf("file:"))&&setTimeout(m)},g.onabort=function(){g&&(n(new Hn("Request aborted",Hn.ECONNABORTED,e,g)),g=null)},g.onerror=function(t){const r=new Hn(t&&t.message?t.message:"Network Error",Hn.ERR_NETWORK,e,g);r.event=t||null,n(r),g=null},g.ontimeout=function(){let t=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";const s=r.transitional||i