-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathaiAgent.js
More file actions
1 lines (1 loc) · 30.8 KB
/
aiAgent.js
File metadata and controls
1 lines (1 loc) · 30.8 KB
1
import{c as t,A as e,by as n,f as r,h as i,j as a,a as s,a2 as o,d as c,bE as u,a5 as l,bx as h,g as d,_ as p,q as g,r as m,ab as f,W as v,a1 as C,b as y,N as U,V as b,aM as k,ap as A,t as w,F as S,B as F,aq as E,u as P}from"./lib/__bundle-e9d3f9f9.js";export{bF as AIAgentInfo}from"./lib/__bundle-e9d3f9f9.js";import{I as T,J as O,b as M,K as q,L as x,N as R,R as L,V as D,W as Q,X as N}from"./lib/__bundle-cd0f09d3.js";export{I as Conversation,$ as ConversationChannelInfo,Z as ConversationHandoff,_ as ConversationResolution,J as ConversationStatus,Y as ConversationType,a0 as HelpdeskInfo}from"./lib/__bundle-cd0f09d3.js";import"./lib/__bundle-b83d0535.js";import"./lib/__bundle-3845896a.js";import"./lib/__bundle-6c219ecb.js";import"./lib/__bundle-d136e60a.js";import"./lib/__bundle-acd77193.js";var j,H,G=function(i){function a(t){var a=t.aiAgentId,s=t.userId,o=t.language,c=t.country,u=t.context,l=t.forceCreateChannel,h=t.knownActiveChannelUrl,d=t.shouldSendFirstMessage,p=t.agentVersion,g=i.call(this)||this;return g.method=e.POST,g.path="".concat(n,"/ai_agents/").concat(encodeURIComponent(a),"/messenger_settings"),g.requireAuth=!1,g.params=r({user_id:s,country:c,language:o,context:u,force_create:l,known_active_channel_url:h,should_send_first_message:d,agent_version:p}),g}return t(a,i),a}(i),K=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.settings=n,r}return t(n,e),n}(a),V=function(i){function a(t){var a=this,s=t.token,o=t.limit,c=t.aiAgentId,u=t.status,l=t.reverse,h=t.order;return(a=i.call(this)||this).method=e.GET,a.path="".concat(n,"/my_conversations"),a.params=r({token:s,limit:o,reverse:l,order:h,status:u,bot_userid:c}),a}return t(a,i),a}(i),X=function(e){function n(t,n){var r=e.call(this,t,n)||this;r.conversations=[];var i=n.next_token,a=n.conversations;return r.token=i,a&&a.length>0&&(r.conversations=a.map((function(t){return new T(t)}))),r}return t(n,e),n}(a),B={limit:10},z=function(i){function a(t){var a=this,s=t.limit,o=void 0===s?B.limit:s,c=t.keys,u=t.token;return(a=i.call(this)||this).method=e.GET,a.path="".concat(n,"/sdk_message_templates"),a.params=r({limit:o,keys:c,token:u}),a}return t(a,i),a}(i),W=function(e){function n(t,n){var r=e.call(this,t,n)||this,i=n.templates,a=n.template_list_token;return r.token=a,r.templates=i.map((function(t){return{template:JSON.stringify(t)}})),r}return t(n,e),n}(a),tt=function(r){function i(t){var i=this,a=t.key;return(i=r.call(this)||this).method=e.GET,i.path="".concat(n,"/sdk_message_templates/").concat(a),i}return t(i,r),i}(i),et=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.template=JSON.stringify(n),r}return t(n,e),n}(a);!function(t){t.INCLUDE="include",t.EXCLUDE="exclude"}(j||(j={})),function(t){t.INCLUDE="include",t.EXCLUDE="exclude"}(H||(H={}));var nt,rt={aiAgentChannelFilter:j.INCLUDE,aiAgentConversationStatusFilter:[O.OPEN,O.CLOSED],aiAgentIds:[],deskChannelFilter:H.INCLUDE,pinnedChannelUrls:[],copilotConversationOnly:!1,copilotSupportChannelUrl:void 0},it=function(n){function i(t){var i=n.call(this)||this,a=c(c({},rt),t),s=a.aiAgentChannelFilter,o=a.aiAgentIds,l=a.deskChannelFilter,h=a.aiAgentConversationStatusFilter,d=a.pinnedChannelUrls,p=a.copilotConversationOnly,g=a.copilotSupportChannelUrl,m=a.userId,f=a.token,v=a.limit;return i.method=e.GET,i.path="".concat(u,"/").concat(encodeURIComponent(m),"/my_group_channels"),i.params=r({token:f,limit:v,ai_agent_channel_filter:s,desk_channel_filter:l,copilot_conversation_only:p,copilot_support_channel_url:g}),h&&h.length>0&&(i.params.ai_agent_conversation_status_filter=h),o&&o.length>0&&(i.params.ai_agent_ids=o),d&&d.length>0&&(i.params.pinned_channel_urls=d),i}return t(i,n),i}(i),at=function(e){function n(t,n){var r=e.call(this,t,n)||this;r.channels=[];var i=n.next,a=n.channels,s=n.ts;return r.token=i,a&&a.length>0&&(r.channels=a.map((function(e){return e.ts=s,new M(t,e)}))),r.ts=null!=s?s:0,r}return t(n,e),n}(a),st={aiAgentChannelFilter:j.INCLUDE,aiAgentIds:[],deskChannelFilter:H.INCLUDE,pinnedChannelUrls:[],copilotConversationOnly:!1,copilotSupportChannelUrl:void 0},ot=function(t){return l(j,t.aiAgentChannelFilter,!0)&&o("string",t.aiAgentIds,!0)&&l(H,t.deskChannelFilter,!0)&&o("string",t.pinnedChannelUrls,!0)&&s("boolean",t.copilotConversationOnly,!0)&&s("string",t.copilotSupportChannelUrl,!0)},ct=function(n){function i(t){var i=t.userId,a=t.ts,s=t.token,o=t.params,l=n.call(this)||this,h=c(c({},st),o),d=h.aiAgentChannelFilter,p=h.aiAgentIds,g=h.deskChannelFilter,m=h.pinnedChannelUrls,f=h.copilotConversationOnly,v=h.copilotSupportChannelUrl;return l.method=e.GET,l.path="".concat(u,"/").concat(encodeURIComponent(i),"/my_group_channels/changelogs"),l.params=r({token:s,change_ts:a,ai_agent_channel_filter:d,desk_channel_filter:g,copilot_conversation_only:f,copilot_support_channel_url:v}),p&&p.length>0&&(l.params.ai_agent_ids=p),m&&m.length>0&&(l.params.pinned_channel_urls=m),l}return t(i,n),i}(i),ut=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.updatedChannels=n.updated.map((function(e){var r=Object.assign(e,{ts:n.ts});return new M(t,r)})),r.deletedChannelUrls=n.deleted,r.hasMore=n.has_more,r.token=n.next,r.ts=n.ts,r}return t(n,e),n}(a),lt={aiAgentChannelFilter:j.INCLUDE,aiAgentConversationStatusFilter:[O.OPEN,O.CLOSED],aiAgentIds:[],deskChannelFilter:H.INCLUDE,pinnedChannelUrls:[],copilotConversationOnly:!1,copilotSupportChannelUrl:void 0},ht=function(n){function i(t){var i=t.userId,a=t.params,s=n.call(this)||this,o=c(c({},lt),a),l=o.aiAgentChannelFilter,h=o.aiAgentConversationStatusFilter,d=o.aiAgentIds,p=o.deskChannelFilter,g=o.pinnedChannelUrls,m=o.copilotConversationOnly,f=o.copilotSupportChannelUrl;return s.method=e.GET,s.path="".concat(u,"/").concat(encodeURIComponent(i),"/my_group_channels/unread_message_count"),s.params=r({ai_agent_channel_filter:l,desk_channel_filter:p,copilot_conversation_only:m,copilot_support_channel_url:f}),h&&h.length>0&&(s.params.ai_agent_conversation_status_filter=h),d&&d.length>0&&(s.params.ai_agent_ids=d),g&&g.length>0&&(s.params.pinned_channel_urls=g),s}return t(i,n),i}(i),dt=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.total=n.total,r.aiAgentChannelCount=n.ai_agent_channel,r.deskChannelCount=n.desk_channel,r.pinnedChannel=n.pinned_channel.map((function(t){return{channelUrl:t.channel_url,count:t.count}})),r}return t(n,e),n}(a),pt=function(n){function i(t){var i=t.channelUrl,a=t.key,s=t.requestId,o=t.action,c=t.data,u=n.call(this)||this;return u.method=e.POST,u.path="".concat(h,"/").concat(encodeURIComponent(i),"/challenge"),u.params=r(d({key:a,request_id:s,action:o,data:c})),u}return t(i,n),i}(i),gt=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.result=null!=n?n:{},r}return t(n,e),n}(a),mt=function(n){function i(t){var i=t.channelUrl,a=t.messageId,s=t.key,o=t.data,c=n.call(this)||this;return c.method=e.POST,c.path="".concat(h,"/").concat(encodeURIComponent(i),"/messages/").concat(encodeURIComponent(a),"/forms/").concat(encodeURIComponent(s),"/submit"),c.params=r(d({data:o})),c}return t(i,n),i}(i),ft=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.result=null!=n?n:{},r}return t(n,e),n}(a),vt=function(n){function r(t){var r=t.channelUrl,i=t.messageId,a=t.key,s=n.call(this)||this;return s.method=e.POST,s.path="".concat(h,"/").concat(encodeURIComponent(r),"/messages/").concat(encodeURIComponent(i),"/forms/").concat(encodeURIComponent(a),"/cancel"),s.params={},s}return t(r,n),r}(i),_t=function(n){function i(t){var i=t.channelUrl,a=t.messageId,s=t.key,o=t.channel,c=t.data,u=n.call(this)||this;return u.method=e.POST,u.path="".concat(h,"/").concat(encodeURIComponent(i),"/messages/").concat(encodeURIComponent(a),"/otps/").concat(encodeURIComponent(s),"/request"),u.params=r(d({channel:o,data:c})),u}return t(i,n),i}(i),Ct=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.result=null!=n?n:{},r}return t(n,e),n}(a),yt=function(n){function i(t){var i=t.channelUrl,a=t.messageId,s=t.key,o=t.code,c=n.call(this)||this;return c.method=e.POST,c.path="".concat(h,"/").concat(encodeURIComponent(i),"/messages/").concat(encodeURIComponent(a),"/otps/").concat(encodeURIComponent(s),"/verify"),c.params=r(d({code:o})),c}return t(i,n),i}(i),Ut=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.result=null!=n?n:{},r}return t(n,e),n}(a),It=function(n){function r(t){var r=t.channelUrl,i=t.messageId,a=t.key,s=n.call(this)||this;return s.method=e.POST,s.path="".concat(h,"/").concat(encodeURIComponent(r),"/messages/").concat(encodeURIComponent(i),"/otps/").concat(encodeURIComponent(a),"/cancel"),s.params={},s}return t(r,n),r}(i),bt=function(n){function i(t){var i=t.channelUrl,a=t.messageId,s=t.rating,o=t.comment,c=n.call(this)||this;return c.method=e.POST,c.path="".concat(h,"/").concat(encodeURIComponent(i),"/messages/").concat(encodeURIComponent(a),"/feedback"),c.params=r(d({rating:s,comment:o})),c}return t(i,n),i}(i),kt=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.id=n.id,r.rating=n.rating,r.comment=n.comment,r}return t(n,e),n}(a),At=function(n){function i(t){var i=t.channelUrl,a=t.messageId,s=t.rating,o=t.comment,c=n.call(this)||this;return c.method=e.PUT,c.path="".concat(h,"/").concat(encodeURIComponent(i),"/messages/").concat(encodeURIComponent(a),"/feedback"),c.params=r(d({rating:s,comment:o})),c}return t(i,n),i}(i),wt=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.id=n.id,r.rating=n.rating,r.comment=n.comment,r}return t(n,e),n}(a),St=function(n){function r(t){var r=t.channelUrl,i=t.messageId,a=n.call(this)||this;return a.method=e.DELETE,a.path="".concat(h,"/").concat(encodeURIComponent(r),"/messages/").concat(encodeURIComponent(i),"/feedback"),a.params={},a}return t(r,n),r}(i),Ft=function(n){function r(t){var r=t.channelUrl,i=t.messageId,a=t.status,s=t.detail,o=n.call(this)||this;return o.method=e.POST,o.path="".concat(h,"/").concat(encodeURIComponent(r),"/messages/").concat(encodeURIComponent(i),"/user_action_messages"),o.params={status:a,detail:null!=s?s:""},o}return t(r,n),r}(i),Et=function(n){function r(t){var r=t.channelUrl,i=t.messageId,a=n.call(this)||this;return a.method=e.POST,a.path="".concat(h,"/").concat(encodeURIComponent(r),"/messages/").concat(encodeURIComponent(i),"/steward_tasks/cancel"),a.params={},a}return t(r,n),r}(i),Pt=function(n){function i(t){var i=t.userId,a=t.params,s=n.call(this)||this;return s.method=e.PUT,s.path="".concat(u,"/").concat(encodeURIComponent(i),"/memory_state"),s.params=r({enabled:a.enabled,context_ai_agent_id:a.contextAiAgentId}),s}return t(i,n),i}(i),Tt=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.memory=n.memory,r}return t(n,e),n}(a),Ot=function(n){function i(t){var i=t.userId,a=t.params,s=void 0===a?{}:a,o=n.call(this)||this;return o.method=e.DELETE,o.path="".concat(u,"/").concat(encodeURIComponent(i),"/memories"),o.params=r({context_ai_agent_id:s.contextAiAgentId}),o}return t(i,n),i}(i),Mt={},qt=function(){function t(t,e){var n=e.sdkState,r=e.requestQueue,i=e.logger,a=e.dispatcher,s=this;this._iid=t,this._sdkState=n,this._requestQueue=r,this._logger=i,this._dispatcher=a,this._aiAgentHandlers=new Map,this._groupChannelCache=q.of(this._iid),this._dispatcher.on((function(t){t instanceof v&&s._handleEvent(t).catch((function(t){if(C(t)&&"foreground"===s._sdkState.appState)throw t}))})),Mt[t]=this}return t.prototype._handleEvent=function(t){return p(this,void 0,void 0,(function(){var e=this;return y(this,(function(n){return"AIEV"===t.code&&U((function(){return p(e,void 0,void 0,(function(){return y(this,(function(e){return this._aiAgentHandlers.forEach((function(e){e(t.payload)})),[2]}))}))})),[2]}))}))},t.of=function(t){return Mt[t]},Object.defineProperty(t.prototype,"handlers",{get:function(){return g([],m(this._aiAgentHandlers.values()),!1)},enumerable:!1,configurable:!0}),t.prototype.addEventHandler=function(t,e){this._aiAgentHandlers.set(t,e)},t.prototype.removeEventHandler=function(t){this._aiAgentHandlers.delete(t)},t.prototype.clearEventHandler=function(){this._aiAgentHandlers.clear()},t.prototype.requestMessengerSettings=function(t){return p(this,void 0,void 0,(function(){var e,n,r;return y(this,(function(i){switch(i.label){case 0:return e=b.of(this._iid).requestQueue,n=new G(t),[4,e.forceSend(n)];case 1:return r=i.sent(),[2,r.as(K).settings]}}))}))},t.prototype.setUserMemoryState=function(t){return p(this,void 0,void 0,(function(){var e,n,r;return y(this,(function(i){switch(i.label){case 0:return e=b.of(this._iid).requestQueue,n=new Pt({userId:this._sdkState.userId,params:t}),[4,e.send(n)];case 1:return r=i.sent(),[2,r.as(Tt).memory]}}))}))},t.prototype.clearUserMemories=function(t){return void 0===t&&(t={}),p(this,void 0,void 0,(function(){var e,n;return y(this,(function(r){switch(r.label){case 0:return e=b.of(this._iid).requestQueue,n=new Ot({userId:this._sdkState.userId,params:t}),[4,e.send(n)];case 1:return r.sent(),[2]}}))}))},t.prototype.getConversations=function(t,e,n){return p(this,void 0,void 0,(function(){var r,i,a,s,o,u;return y(this,(function(l){switch(l.label){case 0:return r=b.of(this._iid).requestQueue,i=new V(c(c({},e),{token:t,limit:n})),[4,r.send(i)];case 1:return a=l.sent(),s=a.as(X),o=s.conversations,u=s.token,[2,{conversations:o,token:u}]}}))}))},t.prototype.getMessageTemplates=function(t){return void 0===t&&(t={}),p(this,void 0,void 0,(function(){var e,n,r,i,a,s,o;return y(this,(function(c){switch(c.label){case 0:return e=t.keys,n=t.limit,r=new z({keys:e,limit:n}),[4,this._requestQueue.send(r)];case 1:return i=c.sent(),a=i.as(W),s=a.templates,o=a.token,[2,{templates:s,token:o}]}}))}))},t.prototype.getMessageTemplate=function(t){return p(this,void 0,void 0,(function(){var e,n;return y(this,(function(r){switch(r.label){case 0:return e=new tt({key:t}),[4,this._requestQueue.send(e)];case 1:return n=r.sent(),[2,{template:n.as(et).template}]}}))}))},t.prototype.getMyGroupChannels=function(t,e,n,r){return void 0===r&&(r=f.REQUEST_CHANNEL),p(this,void 0,void 0,(function(){var i,a,s,o,u,l;return y(this,(function(h){switch(h.label){case 0:return i=new it(c(c({},e),{userId:this._sdkState.userId,token:t,limit:n})),[4,this._requestQueue.send(i)];case 1:return a=h.sent(),s=a.as(at),o=s.channels,u=s.token,l=s.ts,this._dispatcher.dispatch(new x({channels:o,context:{source:r}})),[2,{channels:o,token:u,ts:l}]}}))}))},t.prototype.getMyGroupChannelChangeLogs=function(t,e,n){return void 0===n&&(n=f.REQUEST_CHANNEL_CHANGELOGS),p(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,l,h;return y(this,(function(p){switch(p.label){case 0:return r="string"==typeof t?t:null,i="number"==typeof t?t:null,a=new ct(d({userId:this._sdkState.userId,ts:i,token:r,params:e})),[4,this._requestQueue.send(a)];case 1:return s=p.sent(),o=s.as(ut),c=o.updatedChannels,u=o.deletedChannelUrls,l=o.hasMore,h=o.ts,c.length>0&&this._dispatcher.dispatch(new x({channels:c,context:{source:n},ts:h})),u.length>0&&this._dispatcher.dispatch(new R({channelUrls:u,context:{source:n}})),[2,{updatedChannels:c,deletedChannelUrls:u,hasMore:l,token:o.token}]}}))}))},t.prototype.getChannelsFromCache=function(t,e,n,r,i){return p(this,void 0,void 0,(function(){return y(this,(function(a){switch(a.label){case 0:return[4,this._groupChannelCache.fetch({token:t,filter:e,order:n,limit:r,excludeChannelUrls:i})];case 1:return[2,a.sent()]}}))}))},t.prototype.getUnreadMessageCount=function(t){return p(this,void 0,void 0,(function(){var e,n,r,i,a,s,o;return y(this,(function(c){switch(c.label){case 0:return e=new ht({userId:this._sdkState.userId,params:t}),[4,this._requestQueue.send(e)];case 1:return n=c.sent(),r=n.as(dt),i=r.total,a=r.aiAgentChannelCount,s=r.deskChannelCount,o=r.pinnedChannel,[2,{total:i,aiAgentChannelCount:a,deskChannelCount:s,pinnedChannel:o}]}}))}))},t.prototype.submitForm=function(t){return p(this,void 0,void 0,(function(){var e,n,r;return y(this,(function(i){switch(i.label){case 0:return e=b.of(this._iid).requestQueue,n=new mt({channelUrl:t.channelUrl,messageId:t.messageId,key:t.formKey,data:t.formData}),[4,e.send(n)];case 1:return r=i.sent(),[2,r.as(ft).result]}}))}))},t.prototype.sendChallengeAction=function(t){return p(this,void 0,void 0,(function(){var e,n,r;return y(this,(function(i){switch(i.label){case 0:return e=b.of(this._iid).requestQueue,n=new pt(t),[4,e.send(n)];case 1:return r=i.sent(),[2,r.as(gt).result]}}))}))},t.prototype.cancelForm=function(t){return p(this,void 0,void 0,(function(){var e,n;return y(this,(function(r){switch(r.label){case 0:return e=b.of(this._iid).requestQueue,n=new vt({channelUrl:t.channelUrl,messageId:t.messageId,key:t.formKey}),[4,e.send(n)];case 1:return r.sent(),[2]}}))}))},t.prototype.requestOTP=function(t){return p(this,void 0,void 0,(function(){var e,n,r;return y(this,(function(i){switch(i.label){case 0:return e=b.of(this._iid).requestQueue,n=new _t({channelUrl:t.channelUrl,messageId:t.messageId,key:t.otpKey,channel:t.otpChannel,data:t.otpData}),[4,e.send(n)];case 1:return r=i.sent(),[2,r.as(Ct).result]}}))}))},t.prototype.verifyOTP=function(t){return p(this,void 0,void 0,(function(){var e,n,r;return y(this,(function(i){switch(i.label){case 0:return e=b.of(this._iid).requestQueue,n=new yt({channelUrl:t.channelUrl,messageId:t.messageId,key:t.otpKey,code:t.code}),[4,e.send(n)];case 1:return r=i.sent(),[2,r.as(Ut).result]}}))}))},t.prototype.cancelOTP=function(t){return p(this,void 0,void 0,(function(){var e,n;return y(this,(function(r){switch(r.label){case 0:return e=b.of(this._iid).requestQueue,n=new It({channelUrl:t.channelUrl,messageId:t.messageId,key:t.otpKey}),[4,e.send(n)];case 1:return r.sent(),[2]}}))}))},t.prototype.createMessageFeedback=function(t){return p(this,void 0,void 0,(function(){var e,n,r,i;return y(this,(function(a){switch(a.label){case 0:return e=b.of(this._iid).requestQueue,n=new bt({channelUrl:t.channelUrl,messageId:t.messageId,rating:t.rating,comment:t.comment}),[4,e.send(n)];case 1:return r=a.sent(),[2,{id:(i=r.as(kt)).id,rating:i.rating,comment:i.comment}]}}))}))},t.prototype.updateMessageFeedback=function(t){return p(this,void 0,void 0,(function(){var e,n,r,i;return y(this,(function(a){switch(a.label){case 0:return e=b.of(this._iid).requestQueue,n=new At({channelUrl:t.channelUrl,messageId:t.messageId,rating:t.rating,comment:t.comment}),[4,e.send(n)];case 1:return r=a.sent(),[2,{id:(i=r.as(wt)).id,rating:i.rating,comment:i.comment}]}}))}))},t.prototype.deleteMessageFeedback=function(t){return p(this,void 0,void 0,(function(){var e,n;return y(this,(function(r){switch(r.label){case 0:return e=b.of(this._iid).requestQueue,n=new St({channelUrl:t.channelUrl,messageId:t.messageId}),[4,e.send(n)];case 1:return r.sent(),[2]}}))}))},t.prototype.submitUserActionMessage=function(t){return p(this,void 0,void 0,(function(){var e,n;return y(this,(function(r){switch(r.label){case 0:return e=b.of(this._iid).requestQueue,n=new Ft({channelUrl:t.channelUrl,messageId:t.messageId,status:t.status,detail:t.detail}),[4,e.send(n)];case 1:return r.sent(),[2]}}))}))},t.prototype.updateContext=function(t,e,n){return p(this,void 0,void 0,(function(){var r,i,a;return y(this,(function(s){switch(s.label){case 0:return r=b.of(this._iid).requestQueue,i=new D({aiAgentId:t,channelUrl:e,context:n}),[4,r.send(i)];case 1:return a=s.sent(),[2,a.as(L).contextObject]}}))}))},t.prototype.cancelStewardTask=function(t){return p(this,void 0,void 0,(function(){var e,n;return y(this,(function(r){switch(r.label){case 0:return e=b.of(this._iid).requestQueue,n=new Et({channelUrl:t.channelUrl,messageId:t.messageId}),[4,e.send(n)];case 1:return r.sent(),[2]}}))}))},t.prototype.patchContext=function(t,e,n){return p(this,void 0,void 0,(function(){var r,i,a;return y(this,(function(s){switch(s.label){case 0:return r=b.of(this._iid).requestQueue,i=new N({aiAgentId:t,channelUrl:e,context:n}),[4,r.send(i)];case 1:return a=s.sent(),[2,a.as(Q).contextObject]}}))}))},t}();!function(t){t.CREATED_AT="created_at",t.UPDATED_AT="updated_at"}(nt||(nt={}));var xt,Rt={status:void 0,aiAgentId:void 0,reverse:!1,order:nt.UPDATED_AT},Lt=function(e){function n(t,n){var r,i,a,s,o=this;return(o=e.call(this,t,n)||this).status=null!==(r=n.status)&&void 0!==r?r:void 0,o.aiAgentId=null!==(i=n.aiAgentId)&&void 0!==i?i:void 0,o.reverse=null!==(a=n.reverse)&&void 0!==a?a:Rt.reverse,o.order=null!==(s=n.order)&&void 0!==s?s:Rt.order,o}return t(n,e),n.prototype._validate=function(){return e.prototype._validate.call(this)&&l(O,this.status,!0)&&s("string",this.aiAgentId,!0)&&s("boolean",this.reverse)&&l(nt,this.order)},n.prototype.serialize=function(){return k(this)},n.prototype.next=function(){return p(this,void 0,void 0,(function(){var t,e,n,r;return y(this,(function(i){switch(i.label){case 0:return t=qt.of(this._iid),this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,[4,t.getConversations(this._token,d(c({},this)),this.limit)]):[3,2]:[3,5];case 1:return e=i.sent(),n=e.conversations,r=e.token,this._token=r,this._hasNext=!!r,this._isLoading=!1,[2,n];case 2:return[2,[]];case 3:throw w.queryInProgress;case 4:return[3,6];case 5:throw w.invalidParameters;case 6:return[2]}}))}))},n}(A),Dt=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r._ts=0,r.aiAgentChannelFilter=rt.aiAgentChannelFilter,r.aiAgentIds=rt.aiAgentIds,r.deskChannelFilter=rt.deskChannelFilter,r.pinnedChannelUrls=rt.pinnedChannelUrls,r.copilotConversationOnly=rt.copilotConversationOnly,r.copilotSupportChannelUrl=rt.copilotSupportChannelUrl,n.aiAgentChannelFilter&&(r.aiAgentChannelFilter=n.aiAgentChannelFilter),n.aiAgentConversationStatusFilter&&(r.aiAgentConversationStatusFilter=n.aiAgentConversationStatusFilter),n.aiAgentIds&&(r.aiAgentIds=n.aiAgentIds),n.deskChannelFilter&&(r.deskChannelFilter=n.deskChannelFilter),n.pinnedChannelUrls&&(r.pinnedChannelUrls=n.pinnedChannelUrls),n.copilotConversationOnly&&(r.copilotConversationOnly=n.copilotConversationOnly),n.copilotSupportChannelUrl&&(r.copilotSupportChannelUrl=n.copilotSupportChannelUrl),r}return t(n,e),n.prototype._validate=function(){return e.prototype._validate.call(this)&&l(j,this.aiAgentChannelFilter)&&o(O,this.aiAgentConversationStatusFilter,!0)&&o("string",this.aiAgentIds)&&l(H,this.deskChannelFilter)&&o("string",this.pinnedChannelUrls)&&s("boolean",this.copilotConversationOnly,!0)&&s("string",this.copilotSupportChannelUrl,!0)},n.prototype.serialize=function(){return k(this)},Object.defineProperty(n.prototype,"lastResponseAt",{get:function(){return this._ts},enumerable:!1,configurable:!0}),n.prototype.belongsTo=function(t){if(this.pinnedChannelUrls.includes(t.url))return!0;if(t.isAIAgent){if(!t.conversation)return!1;if(this.aiAgentChannelFilter===j.EXCLUDE)return!1;if(this.aiAgentIds&&this.aiAgentIds.length>0&&!this.aiAgentIds.includes(t.conversation.aiAgentId))return!1;if(this.aiAgentConversationStatusFilter&&this.aiAgentConversationStatusFilter.length>0)if(!this.aiAgentConversationStatusFilter.some((function(e){var n;return(null===(n=t.conversation)||void 0===n?void 0:n.status)===e})))return!1;return!0}return!!t.isDesk&&this.deskChannelFilter!==H.EXCLUDE},n.prototype.next=function(){return p(this,void 0,void 0,(function(){var t,e,n,r,i,a;return y(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,t=qt.of(this._iid),e=d({aiAgentChannelFilter:this.aiAgentChannelFilter,aiAgentConversationStatusFilter:this.aiAgentConversationStatusFilter,aiAgentIds:this.aiAgentIds,deskChannelFilter:this.deskChannelFilter,pinnedChannelUrls:this.pinnedChannelUrls,copilotConversationOnly:this.copilotConversationOnly,copilotSupportChannelUrl:this.copilotSupportChannelUrl}),[4,t.getMyGroupChannels(this._token,e,this.limit)]):[3,2]:[3,5];case 1:return n=s.sent(),r=n.channels,i=n.token,a=n.ts,this._token=i,this._hasNext=!!i,this._isLoading=!1,this._ts=a,[2,r];case 2:return[2,[]];case 3:throw w.queryInProgress;case 4:return[3,6];case 5:throw w.invalidParameters;case 6:return[2]}}))}))},n}(A);!function(t){t.GOOD="good",t.BAD="bad"}(xt||(xt={}));var Qt=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="aiAgent",t._runtimeId=P(),t}return t(n,e),n.prototype.init=function(t,n){var r=n.sdkState,i=n.dispatcher,a=n.sessionManager,s=n.requestQueue,o=n.logger,c=n.onlineDetector,u=n.cacheContext;e.prototype.init.call(this,t,{sdkState:r,dispatcher:i,sessionManager:a,requestQueue:s,logger:o,onlineDetector:c,cacheContext:u}),this._manager=new qt(t,{sdkState:r,requestQueue:s,logger:o,dispatcher:i})},n.prototype.addEventHandler=function(t,e){S(s("string",t)).throw(w.invalidParameters),this._manager.addEventHandler(t,e)},n.prototype.removeEventHandler=function(t){S(s("string",t)).throw(w.invalidParameters),this._manager.removeEventHandler(t)},n.prototype.removeAllEventHandlers=function(){this._manager.clearEventHandler()},n.prototype.updateContext=function(t,e,n){return p(this,void 0,void 0,(function(){return y(this,(function(r){return S(s("string",t)&&s("string",e)&&s("object",n)).throw(w.invalidParameters),[2,this._manager.updateContext(t,e,n)]}))}))},n.prototype.patchContext=function(t,e,n){return p(this,void 0,void 0,(function(){return y(this,(function(r){return S(s("string",t)&&s("string",e)&&s("object",n)).throw(w.invalidParameters),[2,this._manager.patchContext(t,e,n)]}))}))},n.prototype.requestMessengerSettings=function(t){return p(this,void 0,void 0,(function(){var e,n,r,i,a,o,c,u,l;return y(this,(function(h){return e=t.aiAgentId,n=t.userId,r=t.language,i=t.country,a=t.context,o=t.forceCreateChannel,c=t.knownActiveChannelUrl,u=t.shouldSendFirstMessage,l=t.agentVersion,S(s("string",e)&&s("string",n,!0)&&s("string",r,!0)&&s("string",i,!0)&&s("object",a,!0)&&s("boolean",o,!0)&&s("string",c,!0)&&s("boolean",u,!0)&&s("number",l,!0)).throw(w.invalidParameters),[2,this._manager.requestMessengerSettings(t)]}))}))},n.prototype.setUserMemoryState=function(t){return p(this,void 0,void 0,(function(){return y(this,(function(e){return S(s("boolean",t.enabled)&&s("string",t.contextAiAgentId,!0)).throw(w.invalidParameters),[2,this._manager.setUserMemoryState(t)]}))}))},n.prototype.clearUserMemories=function(t){return void 0===t&&(t={}),p(this,void 0,void 0,(function(){return y(this,(function(e){return S(s("string",t.contextAiAgentId,!0)).throw(w.invalidParameters),[2,this._manager.clearUserMemories(t)]}))}))},n.prototype.createConversationListQuery=function(t){return void 0===t&&(t={}),new Lt(this._iid,t)},n.prototype.createMyGroupChannelListQuery=function(t){return void 0===t&&(t={}),new Dt(this._iid,t)},n.prototype.getMyGroupChannelChangeLogsByToken=function(t,e){return void 0===e&&(e={}),p(this,void 0,void 0,(function(){var n;return y(this,(function(r){switch(r.label){case 0:return n=c(c({},st),e),S(s("string",t)&&ot(n)).throw(w.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(t,n)];case 1:return[2,r.sent()]}}))}))},n.prototype.getMyGroupChannelChangeLogsByTimestamp=function(t,e){return void 0===e&&(e={}),p(this,void 0,void 0,(function(){var n;return y(this,(function(r){switch(r.label){case 0:return n=c(c({},st),e),S(s("number",t)&&ot(n)).throw(w.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(t,n)];case 1:return[2,r.sent()]}}))}))},n.prototype.getUnreadMessageCount=function(t){return void 0===t&&(t={}),p(this,void 0,void 0,(function(){var e;return y(this,(function(n){return e=c(c({},lt),t),S(l(j,e.aiAgentChannelFilter,!0)&&o(O,e.aiAgentConversationStatusFilter,!0)&&o("string",e.aiAgentIds,!0)&&l(H,e.deskChannelFilter,!0)&&o("string",e.pinnedChannelUrls,!0)&&s("boolean",e.copilotConversationOnly,!0)&&s("string",e.copilotSupportChannelUrl,!0)).throw(w.invalidParameters),[2,this._manager.getUnreadMessageCount(e)]}))}))},n.prototype.getMessageTemplates=function(t){return void 0===t&&(t={}),p(this,void 0,void 0,(function(){var e;return y(this,(function(n){return e=c(c({},B),t),S(function(t){return s("number",t.limit,!0)&&o("string",t.keys,!0)}(e)).throw(w.invalidParameters),[2,this._manager.getMessageTemplates(t)]}))}))},n.prototype.getMessageTemplate=function(t){return p(this,void 0,void 0,(function(){return y(this,(function(e){return S(s("string",t)).throw(w.invalidParameters),[2,this._manager.getMessageTemplate(t)]}))}))},n.prototype.submitForm=function(t){return p(this,void 0,void 0,(function(){return y(this,(function(e){return S(s("string",t.channelUrl)&&s("number",t.messageId)&&s("string",t.formKey)&&s("object",t.formData)).throw(w.invalidParameters),[2,this._manager.submitForm(t)]}))}))},n.prototype.cancelForm=function(t){return p(this,void 0,void 0,(function(){return y(this,(function(e){return S(s("string",t.channelUrl)&&s("number",t.messageId)&&s("string",t.formKey)).throw(w.invalidParameters),[2,this._manager.cancelForm(t)]}))}))},n.prototype.sendChallengeAction=function(t){return p(this,void 0,void 0,(function(){return y(this,(function(e){return S(s("string",t.channelUrl)&&s("string",t.key)&&s("string",t.requestId)&&s("string",t.action)&&s("object",t.data,!0)).throw(w.invalidParameters),[2,this._manager.sendChallengeAction(t)]}))}))},n.prototype.createMessageFeedback=function(t){return p(this,void 0,void 0,(function(){return y(this,(function(e){return S(s("string",t.channelUrl)&&s("number",t.messageId)&&l(xt,t.rating)&&s("string",t.comment,!0)).throw(w.invalidParameters),[2,this._manager.createMessageFeedback(t)]}))}))},n.prototype.updateMessageFeedback=function(t){return p(this,void 0,void 0,(function(){return y(this,(function(e){return S(s("string",t.channelUrl)&&s("number",t.messageId)&&l(xt,t.rating)&&s("string",t.comment,!0)).throw(w.invalidParameters),[2,this._manager.updateMessageFeedback(t)]}))}))},n.prototype.requestOTP=function(t){return p(this,void 0,void 0,(function(){return y(this,(function(e){return S(s("string",t.channelUrl)&&s("number",t.messageId)&&s("string",t.otpKey)&&s("string",t.otpChannel)&&s("object",t.otpData)).throw(w.invalidParameters),[2,this._manager.requestOTP(t)]}))}))},n.prototype.verifyOTP=function(t){return p(this,void 0,void 0,(function(){return y(this,(function(e){return S(s("string",t.channelUrl)&&s("number",t.messageId)&&s("string",t.otpKey)&&s("string",t.code)).throw(w.invalidParameters),[2,this._manager.verifyOTP(t)]}))}))},n.prototype.cancelOTP=function(t){return p(this,void 0,void 0,(function(){return y(this,(function(e){return S(s("string",t.channelUrl)&&s("number",t.messageId)&&s("string",t.otpKey)).throw(w.invalidParameters),[2,this._manager.cancelOTP(t)]}))}))},n.prototype.deleteMessageFeedback=function(t){return p(this,void 0,void 0,(function(){return y(this,(function(e){return S(s("string",t.channelUrl)&&s("number",t.messageId)).throw(w.invalidParameters),[2,this._manager.deleteMessageFeedback(t)]}))}))},n.prototype.submitUserActionMessage=function(t){return p(this,void 0,void 0,(function(){return y(this,(function(e){return S(s("string",t.channelUrl)&&s("number",t.messageId)&&s("string",t.status)&&s("string",t.detail,!0)).throw(w.invalidParameters),[2,this._manager.submitUserActionMessage(t)]}))}))},n.prototype.cancelStewardTask=function(t){return p(this,void 0,void 0,(function(){return y(this,(function(e){return S(s("string",t.channelUrl)&&s("number",t.messageId)).throw(w.invalidParameters),[2,this._manager.cancelStewardTask(t)]}))}))},n.prototype.appendStat=function(t,e){return t===F.AI_AGENT_SDK_STATS&&b.of(this._iid).statManager.appendStat(t,e,this._runtimeId)},n}(E);export{j as AIAgentChannelFilter,Dt as AIAgentGroupChannelListQuery,xt as AIAgentMessageFeedbackRating,Qt as AIAgentModule,nt as ConversationListOrder,Lt as ConversationListQuery,H as DeskChannelFilter};