@sendbird/ai-agent-messenger-react 1.19.0 → 1.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/7UVs65zS.cjs +1 -0
- package/dist/cjs/BMS5Zb7W.cjs +1 -0
- package/dist/cjs/BRnfdIkb.cjs +1 -0
- package/dist/cjs/D2Opuq0j.cjs +1 -0
- package/dist/cjs/DFmkiYPE.cjs +1 -0
- package/dist/cjs/DTCJ6-eC.cjs +1 -0
- package/dist/cjs/DbxUqtQc.cjs +1 -0
- package/dist/cjs/DfRVurNO.cjs +1 -0
- package/dist/cjs/Dl0262MS.cjs +1 -0
- package/dist/cjs/JLk8Bvao.cjs +1 -0
- package/dist/es/{C4NDe7Wd.js → BB3d9QYh.js} +1 -1
- package/dist/es/{CWV-J3Ta.js → BELIKAJm.js} +1 -1
- package/dist/es/{fyKo7Xbp.js → BdQuAUPe.js} +1 -1
- package/dist/es/{Dqs_T84t.js → C5TioO5h.js} +1 -1
- package/dist/es/{C-dJq_hf.js → CNnV1uD8.js} +1 -1
- package/dist/es/{BEvfkh3_.js → CT9vVq3h.js} +1 -1
- package/dist/es/{kEl07Dux.js → D_jawtL2.js} +1 -1
- package/dist/es/{Cmz3dl3b.js → DlJqMPv3.js} +1 -1
- package/dist/es/{Pegg7Snc.js → DqTYCLQ3.js} +1 -1
- package/dist/es/{DSsAaVrV.js → ETHHqHi2.js} +1 -1
- package/dist/index.cjs +330 -1
- package/dist/index.d.ts +625 -4
- package/dist/index.js +7370 -37
- package/package.json +12 -6
- package/dist/cjs/B7RUkqyZ.cjs +0 -1
- package/dist/cjs/BHmi862p.cjs +0 -1
- package/dist/cjs/BRiNYhzZ.cjs +0 -1
- package/dist/cjs/BWtj68w5.cjs +0 -1
- package/dist/cjs/ByGRYJVz.cjs +0 -1
- package/dist/cjs/CDKvaFVD.cjs +0 -1
- package/dist/cjs/CkRtPYu2.cjs +0 -1
- package/dist/cjs/DmRtDiu3.cjs +0 -330
- package/dist/cjs/Dn0HIoDs.cjs +0 -1
- package/dist/cjs/DuYQj-T9.cjs +0 -1
- package/dist/cjs/KouyTorz.cjs +0 -1
- package/dist/es/cDVEvKPS.js +0 -6757
package/dist/index.cjs
CHANGED
|
@@ -1 +1,330 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("@sendbird/chat");const e=require("./cjs/DmRtDiu3.cjs");require("react");exports.AgentProviderContainer=e.AgentProviderContainer;exports.AgentUIProviderContainer=e.AgentUIProviderContainer;exports.AnonymousSessionInfo=e.AnonymousSessionInfo;exports.CSATType=e.CSATType;exports.Commands=e.DispatcherCommands;exports.Conversation=e.Conversation;exports.ConversationContext=e.ConversationContext;exports.ConversationContextProvider=e.ConversationContextProvider;exports.ConversationHeaderLayout=e.ConversationHeaderLayout;exports.ConversationLayout=e.ConversationLayout;exports.ConversationList=e.ConversationList;exports.ConversationListContext=e.ConversationListContext;exports.ConversationListContextProvider=e.ConversationListContextProvider;exports.ConversationListHeaderLayout=e.ConversationListHeaderLayout;exports.ConversationListItemLayout=e.ConversationListItemLayout;exports.ConversationListLayout=e.ConversationListLayout;exports.DefaultMessenger=e.DefaultMessenger;exports.FixedMessenger=e.FixedMessenger;exports.IncomingMessageLayout=e.IncomingMessageLayout;exports.LauncherBase=e.LauncherBase;exports.LogLevel=e.LogLevel;exports.ManualSessionInfo=e.ManualSessionInfo;exports.MessageListUILayout=e.MessageListUILayout;exports.MessageLogs=e.MessageLogs;exports.OutgoingMessageLayout=e.OutgoingMessageLayout;exports.PlaceholderLayout=e.PlaceholderLayout;exports.SystemMessageLayout=e.SystemMessageLayout;exports.messengerDispatcher=e.messengerDispatcher;exports.useConversationContext=e.useConversationContext;exports.useConversationListContext=e.useConversationListContext;exports.useLocalizationContext=e.useLocalizationContext;exports.useMessengerContext=e.useMessengerContext;exports.useMessengerSessionContext=e.useMessengerSessionContext;exports.useRefreshActiveChannel=e.useRefreshActiveChannel;
|
|
1
|
+
"use strict";var zs=Object.defineProperty;var Gs=(e,t,n)=>t in e?zs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var C=(e,t,n)=>Gs(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Y=require("@sendbird/chat"),d=require("react"),w=require("styled-components"),Fe=require("date-fns"),Ws=require("date-fns/locale/en-US"),J=require("@sendbird/chat/aiAgent"),Ie=require("@sendbird/chat/message"),Qe=require("@sendbird/chat/groupChannel"),Me=require("@sendbird/uikit-tools"),qs=require("react-dom"),js=require("date-fns/isSameDay"),Jt=require("@sendbird/react-uikit-message-template-view"),Ks=require("@sendbird/uikit-message-template"),Ys=require("dompurify"),Xs=require("@emotion/is-prop-valid"),kt=e=>e&&e.__esModule?e:{default:e};function Zs(e){if(e&&e.__esModule)return e;const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const Js=kt(Y),o=Zs(d),g=kt(w),Ir=kt(Ys),Qs=kt(Xs),We="sb-agent",wr="KEY_IMG_ASPECT_RATIO",Qt="*/*",B={BODY_MAX_WIDTH:244,WIDE_BODY_MAX_WIDTH:640,AVATAR_SIZE:26,BODY_TIME_GAP:4,HORIZONTAL_PADDING:12,GAP_GROUPED:2,GAP_UNGROUPED:16},ge=e=>!!e&&"sender"in e,eo=e=>ge(e)?e.sendingStatus==="succeeded"?String(e.messageId):e.reqId:String(e.messageId),to=(e,t,n,r=!0)=>{if(!r||!ge(e))return"single";const s=()=>{if(!t||!ge(t))return!1;const c=t.sender.userId===e.sender.userId,u=Fe.isSameMinute(t.createdAt,e.createdAt);return c&&u},a=()=>{if(!n||!ge(n))return!1;const c=n.sender.userId===e.sender.userId,u=Fe.isSameMinute(n.createdAt,e.createdAt);return c&&u},i=s(),l=a();return i&&l?"middle":i?"bottom":l?"top":"single"},tt=(e,t)=>(()=>{var r;return ge(e)?e.sender.userId:((r=e==null?void 0:e.sender)==null?void 0:r.userId)??void 0})()===t,Ge={isAdmin:e=>e.isAdminMessage(),isCSAT:e=>{var t;return e.isAdminMessage()&&!!((t=e.extendedMessagePayload)!=null&&t.csat)},isIncoming:(e,t)=>ge(e)&&e.sender.userId!==t,isOutgoing:(e,t)=>ge(e)&&(e.sender.userId===t||e.sendingStatus===Ie.SendingStatus.PENDING)},Te=e=>e.startsWith("image/"),kr=e=>e.startsWith("video/"),gn=(e,t)=>{if(e&&!e.startsWith(".")){const n=e.split(".").pop();if(n&&n!==e)return n.toUpperCase()}if(t){const[,n]=t.split("/");if(n)return n.toUpperCase()}return"FILE"},Mr=e=>{var t;return e.messageType==="file"?e.message.length>0&&e.file.name!==e.message:e.messageType==="multipleFiles"?e.message.length>0&&((t=e.files[0])==null?void 0:t.name)!==e.message:e.message.length>0},fn=e=>{switch(e){case"top":case"middle":return B.GAP_GROUPED;default:return B.GAP_UNGROUPED}},no=(e,t)=>{const n=/```(\w+)?\n([\s\S]*?)```/g,r=[];let s=0;return e.replace(n,(a,...i)=>{const[l,c,u]=i;return s<u&&r.push({type:"text",value:e.slice(s,u).trim()}),r.push({type:"code",value:c.trim(),language:l?l.trim():"plaintext"}),s=u+a.length,a}),s<e.length&&r.push({type:"text",value:e.slice(s).trim()}),t?r.map(a=>a.type!=="text"?a:{...a,value:t(a.value)}):r},ro=e=>e.replace(/\[([^\]]+)\](?!\()/g,"\\[$1\\]"),so=e=>e.replace(/([a-zA-Z0-9])_(?=[a-zA-Z0-9])/g,"$1\\_"),oo=e=>e.replace(/~~/g,"\\~\\~"),ao=e=>{let t=e;return t=ro(t),t=so(t),t=oo(t),t},io=typeof navigator<"u"&&navigator.product==="ReactNative",Un=(e,t)=>{const n=r=>!t||t.length===0?!0:ge(r)&&t.includes(r.sendingStatus);return io?e.find(n):e.findLast(n)};function ve(){}function lo(){const e=typeof navigator<"u"?navigator.userAgent:"",t=/iPad|iPhone|iPod/.test(e),n=/Android/.test(e);return t||n}function co(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return t.toString(16)}const en=e=>{try{return JSON.parse(e===""?"{}":e)}catch{return{}}},we={isStreaming(e){const t=en(e.data);return typeof t=="object"&&!!t.stream},isWelcomeMessage(e,t){var n;if(((n=e.extendedMessagePayload)==null?void 0:n.bot_message_type)==="welcome")return!0;if(tt(e,t)){const r=en(e.data);return!(r!=null&&r.respond_mesg_id)&&!(r!=null&&r.stream)}return!1},isGeneratedMessage(e){var t;return((t=e.extendedMessagePayload)==null?void 0:t.bot_message_type)==="generated"},hasFeedback(e){var t;return!!((t=e.extendedMessagePayload)!=null&&t.feedback)}},zt=`@${We}`,uo=({appId:e,aiAgentId:t,storage:n})=>{const r={templateBase:`${zt}-template`,template:s=>`${r.templateBase}/templates/${s}`,templateToken:()=>`${r.templateBase}/tokens`,messengerSession:s=>{const a=co(`${e}/${t}/${s}`);return`${zt}-udata/${a}`},anonUserSession:()=>`${zt}-session/${e}/${t}`};return{template:{set:(s,a)=>n.set(r.template(s),a),get:s=>n.get(r.template(s)),setCachedToken:s=>n.set(r.templateToken(),s),getCachedToken:()=>n.get(r.templateToken()),clear:()=>{n.getKeys(r.templateBase).forEach(n.delete)}},messenger:{getSettings:s=>{try{const a=n.get(r.messengerSession(s));return a?JSON.parse(a):null}catch{return null}},setSettings:(s,a)=>{try{delete a.auto_created_user;const i=JSON.stringify(a);n.set(r.messengerSession(s),i)}catch{return}},getAnonUser:()=>{try{const s=n.get(r.anonUserSession());return s?JSON.parse(s):null}catch{return null}},setAnonUser:s=>{try{const a=JSON.stringify(s);n.set(r.anonUserSession(),a)}catch{return}},clear:s=>{try{s&&n.delete(r.messengerSession(s)),n.delete(r.anonUserSession())}catch{return}}}}},$r=(e,t,n={})=>{let r=null,s=null,a=null;const{leading:i=!0,trailing:l=!0}=n,c=(...u)=>{const m=Date.now();if(a===null||m-a>=t)i?(e(...u),a=m):(s=u,a=m);else if(s=u,l&&!r){const p=t-(m-a);r=setTimeout(()=>{s&&l&&(e(...s),a=Date.now()),r=null,s=null},p)}};return c.cancel=()=>{r&&(clearTimeout(r),r=null),s=null,a=null},c};class Lr{constructor(t,{filter:n,limit:r=20}){C(this,"filter");C(this,"_sdk");C(this,"_pinnedChannels");C(this,"_channels");C(this,"_isDisposed",!1);C(this,"_handlerId",`handler-id-${Date.now()}`);C(this,"_order",Qe.GroupChannelListOrder.LATEST_LAST_MESSAGE);C(this,"_limit");C(this,"_query");C(this,"_token");C(this,"_timestamp");C(this,"_isSyncing");C(this,"_channelHandler");C(this,"_connectionHandler");C(this,"_collectionEventHandler");C(this,"_throttledOnChannelChanged");var s,a,i,l,c,u,m;this.filter=n,this._sdk=t,this._pinnedChannels=[],this._channels=[],this._limit=r,this._query=this._sdk.aiAgent.createMyGroupChannelListQuery({aiAgentChannelFilter:(s=this.filter)==null?void 0:s.aiAgentChannelFilter,aiAgentConversationStatusFilter:(a=this.filter)==null?void 0:a.aiAgentConversationStatusFilter,aiAgentIds:(i=this.filter)==null?void 0:i.aiAgentIds,deskChannelFilter:(l=this.filter)==null?void 0:l.deskChannelFilter,pinnedChannelUrls:(c=this.filter)==null?void 0:c.pinnedChannelUrls,copilotConversationOnly:(u=this.filter)==null?void 0:u.copilotConversationOnly,copilotSupportChannelUrl:(m=this.filter)==null?void 0:m.copilotSupportChannelUrl,limit:this._limit}),this._token="",this._timestamp=Number.MAX_SAFE_INTEGER,this._isSyncing=!1,this._throttledOnChannelChanged=$r(p=>{this._query.belongsTo(p)?this._addChannelsToView([p],!1):this._removeChannelsFromView([p.url])},250,{trailing:!1,leading:!0}),this._channelHandler=new Qe.GroupChannelHandler({onChannelChanged:p=>{p.isGroupChannel()&&this._throttledOnChannelChanged(p)},onChannelDeleted:p=>{this._removeChannelsFromView([p])}}),this._connectionHandler=new Y.ConnectionHandler({onReconnectSucceeded:()=>{this._isDefaultChangelogSyncTimestampUpdated&&this._syncChannelChangelogs()}}),this._sdk.addConnectionHandler(this._handlerId,this._connectionHandler),this._sdk.groupChannel.addGroupChannelHandler(this._handlerId,this._channelHandler)}get _isDefaultChangelogSyncTimestampUpdated(){return this._timestamp!==Number.MAX_SAFE_INTEGER}_setDefaultChangelogsSyncTimestamp(t){var a,i;const n=new Set(((a=this.filter)==null?void 0:a.pinnedChannelUrls)??[]),r=t.find(l=>!n.has(l.url));let s;r?s=((i=r.lastMessage)==null?void 0:i.createdAt)??r.createdAt:s=this._query.lastResponseAt,this._timestamp>s&&(this._timestamp=s)}async _syncChannelChangelogs(){if(this._isDisposed)return[];if(this._isSyncing)return[];try{this._isSyncing=!0;let t;for(this._token?t=await this._sdk.aiAgent.getMyGroupChannelChangeLogsByToken(this._token,this.filter):t=await this._sdk.aiAgent.getMyGroupChannelChangeLogsByTimestamp(this._timestamp,this.filter),this._token=t.token,this._addChannelsToView(t.updatedChannels),this._removeChannelsFromView(t.deletedChannelUrls);t.hasMore&&t.token;)t=await this._sdk.aiAgent.getMyGroupChannelChangeLogsByToken(this._token,this.filter),this._token=t.token,this._addChannelsToView(t.updatedChannels),this._removeChannelsFromView(t.deletedChannelUrls)}catch{}finally{this._isSyncing=!1}return[]}_upsertPinnedChannelsToArray(t){var l;const n=((l=this.filter)==null?void 0:l.pinnedChannelUrls)??[],r=new Map(n.map((c,u)=>[c,u])),s=[],a=[],i=[];for(const c of t){if(!this._query.belongsTo(c)){i.push(c.url);continue}const u=r.get(c.url);if(u===void 0)continue;const m=tn(this._pinnedChannels,c);m>=0?(this._pinnedChannels.splice(m,1),a.push(c)):s.push(c);const E=this._pinnedChannels.findIndex(x=>(r.get(x.url)??1/0)>u),y=E===-1?this._pinnedChannels.length:E;this._pinnedChannels.splice(y,0,c)}return{addedChannels:s,updatedChannels:a,unmatchedChannelUrls:i}}_upsertRegularChannelsToArray(t,n=!1){const r=[],s=[],a=[];for(const i of t){if(!this._query.belongsTo(i)){r.push(i.url);continue}const l=tn(this._channels,i),c=l<0;!c&&this._channels.splice(l,1);const m=mo(this._channels,i,this._order).place,p=m===this._channels.length;c?p?(n||!this.hasMore)&&(this._channels.push(i),s.push(i)):(this._channels.splice(m,0,i),s.push(i)):(this._channels.splice(m,0,i),a.push(i))}return{addedChannels:s,updatedChannels:a,unmatchedChannelUrls:r}}_addChannelsToView(t,n=!1){var p,E,y,x,b;const r=new Set(((p=this.filter)==null?void 0:p.pinnedChannelUrls)??[]),s=[],a=[];for(const f of t)r.has(f.url)?s.push(f):a.push(f);const i=this._upsertPinnedChannelsToArray(s),l=this._upsertRegularChannelsToArray(a,n),c=i.addedChannels.concat(l.addedChannels),u=i.updatedChannels.concat(l.updatedChannels),m=i.unmatchedChannelUrls.concat(l.unmatchedChannelUrls);c.length>0&&((y=(E=this._collectionEventHandler)==null?void 0:E.onChannelsAdded)==null||y.call(E,{},c)),u.length>0&&((b=(x=this._collectionEventHandler)==null?void 0:x.onChannelsUpdated)==null||b.call(x,{},u)),m.length>0&&this._removeChannelsFromView(m)}_removeChannelsFromView(t){var s,a,i;const n=new Set(((s=this.filter)==null?void 0:s.pinnedChannelUrls)??[]),r=[];for(const l of t)if(n.has(l)){const c=this._pinnedChannels.findIndex(u=>u.url===l);c>=0&&(r.push(l),this._pinnedChannels.splice(c,1))}else{const c=this._channels.findIndex(u=>u.url===l);c>=0&&(r.push(l),this._channels.splice(c,1))}r.length>0&&((i=(a=this._collectionEventHandler)==null?void 0:a.onChannelsDeleted)==null||i.call(a,{},r))}get channels(){return this._isDisposed?[]:[...this._pinnedChannels,...this._channels]}get hasMore(){return this._isDisposed?!1:this._query.hasNext}async loadMore(){if(this._isDisposed)return[];if(this.hasMore){const t=await this._query.next();return this._setDefaultChangelogsSyncTimestamp(t),this._addChannelsToView(t,!0),t}return[]}setConversationListCollectionHandler(t){this._collectionEventHandler=t}dispose(){this._isDisposed||(this._isDisposed=!0,this._throttledOnChannelChanged.cancel(),this._collectionEventHandler=void 0,this._sdk.removeConnectionHandler(this._handlerId),this._sdk.groupChannel.removeGroupChannelHandler(this._handlerId),this._pinnedChannels.length=0,this._channels.length=0)}}const tn=(e,t)=>e.findIndex(n=>n.isIdentical(t)),mo=(e,t,n)=>{if(e.length>0){const r=tn(e,t);let s=0,a=e.length-1,i=Math.floor((s+a)/2);for(;s<a;){const c=Hn(e[i],t,n);if(c>0)a=i,i=Math.floor((s+a)/2);else if(c<0)s=i+1,i=Math.floor((s+a)/2);else return{place:i,oldPosition:r}}return{place:Hn(e[i],t,n)>=0?i:i+1,oldPosition:r}}return{place:e.length,oldPosition:-1}},Hn=(e,t,n)=>{switch(n){case Qe.GroupChannelListOrder.LATEST_LAST_MESSAGE:if(e.lastMessage&&t.lastMessage){const r=t.lastMessage.createdAt-e.lastMessage.createdAt;return r===0?t.createdAt-e.createdAt:r}else return e.lastMessage?-1:t.lastMessage?1:t.createdAt-e.createdAt;default:return 0}};class Or{constructor(t){C(this,"subscribers",{});this.logger=t}async send(t){const n=ho(),r=this.subscribers[t.type];if(r){this.logger.debug(`messenger.dispatcher: dispatching command: ${t.type}`,t.payload);const s=r.map(a=>a(t.payload));await Promise.all(s).catch(a=>{this.logger.error(`messenger.dispatcher: error in callback for command: ${t.type}`,a)})}return n.resolve(),n.promise}subscribe(t,n){this.subscribers[t]||(this.subscribers[t]=[]),this.subscribers[t].push(n)}unsubscribe(t,n){const r=this.subscribers[t];r&&(this.subscribers[t]=r.filter(s=>s!==n))}}const ho=()=>{let e=ve,t=ve;return{promise:new Promise((r,s)=>{e=r,t=s}),resolve:e,reject:t}};var le=(e=>(e.ConversationClose="conv.close",e.MessengerSettingsUpdated="messenger.settings.updated",e.ActiveChannelUpdated="active.channel.updated",e.AnonymousSessionTokenExpired="anon.token.expired",e.AuthTokenRefreshed="auth.token.refreshed",e))(le||{});class nt{constructor(t={}){C(this,"payload");this.payload=t}toJSON(){return JSON.stringify({type:this.type,payload:this.payload})}}const Be={CloseConversation:e=>new go(e),MessengerSettingsUpdated:e=>new fo(e),ActiveChannelUpdated:e=>new po(e),AnonymousSessionTokenExpired:()=>new Eo,AuthTokenRefreshed:()=>new bo};class go extends nt{constructor(){super(...arguments);C(this,"type","conv.close")}}class fo extends nt{constructor(){super(...arguments);C(this,"type","messenger.settings.updated")}}class po extends nt{constructor(){super(...arguments);C(this,"type","active.channel.updated")}}class Eo extends nt{constructor(){super(...arguments);C(this,"type","anon.token.expired")}}class bo extends nt{constructor(){super(...arguments);C(this,"type","auth.token.refreshed")}}var pn=(e=>(e[e.VERBOSE=0]="VERBOSE",e[e.DEBUG=1]="DEBUG",e[e.INFO=2]="INFO",e[e.WARN=3]="WARN",e[e.ERROR=4]="ERROR",e[e.NONE=5]="NONE",e))(pn||{});class Rr{constructor(t){C(this,"level");this.level=t}verbose(...t){this.level<=0&&console.log(`[${We}/verbose]`,...t)}debug(...t){this.level<=1&&console.log(`[${We}/debug]`,...t)}info(...t){this.level<=2&&console.log(`[${We}/info]`,...t)}warn(...t){this.level<=3&&console.warn(`[${We}/warn]`,...t)}error(...t){this.level<=4&&console.error(`[${We}/error]`,...t)}}class Dr{constructor({userId:t,authToken:n,sessionHandler:r}){C(this,"userId");C(this,"authToken");C(this,"sessionHandler");this.userId=t,this.authToken=n,this.sessionHandler=r}}class nn{constructor(){C(this,"userId");C(this,"authToken");C(this,"sessionHandler")}}const _o=e=>({onSessionTokenRequired:t=>{t(null),e.send(Be.AnonymousSessionTokenExpired())}}),Co="ai_agent:stats",xo="conversation_initial_render",vo=800220;var K=(e=>(e.AUTH="auth_duration",e.GET_CHANNEL="get_channel_duration",e.GET_MESSAGES="get_messages_duration",e.TOTAL_DURATION="total_duration",e.TOTAL_DURATION_FROM_CACHE="total_duration_from_cache",e))(K||{});class yo{constructor(){C(this,"timers",new Map);C(this,"committed",!1);C(this,"commitCallback",null);C(this,"conversationId",null);C(this,"channelUrl",null);C(this,"errorCode",null);C(this,"errorDescription",null);C(this,"extraData",{})}setCommitCallback(t){return this.commitCallback=t,this}setConversationId(t){return this.conversationId=t,this}setChannelUrl(t){return this.setExtra("channel_url",t),this}setError(t,n){return this.errorCode=t??vo,this.errorDescription=n,this}setExtra(t,n){return n!=null&&(this.extraData[t]=n),this}startTimer(t){if(this.committed)return this;const n=this.timers.get(t);return(n==null?void 0:n.startTime)!==null&&(n==null?void 0:n.startTime)!==void 0?this:(this.timers.set(t,{startTime:Date.now(),endTime:null}),this)}stopTimer(t){if(this.committed)return this;const n=this.timers.get(t);return!n||n.startTime===null||n.endTime!==null?this:(this.timers.set(t,{...n,endTime:Date.now()}),this)}getDuration(t){const n=this.timers.get(t);return!n||n.startTime===null||n.endTime===null?null:n.endTime-n.startTime}isCommitted(){return this.committed}commit(){if(this.committed||!this.commitCallback)return!1;const t=this.buildPayload();return t?(this.committed=!0,this.commitCallback(Co,t)):!1}}class So extends yo{constructor(){super(...arguments);C(this,"presentMethod","direct_present")}setPresentMethod(n){return this.presentMethod=n,this}getMetricKey(){return xo}buildPayload(){const n=this.getDuration(K.AUTH),r=this.getDuration(K.GET_CHANNEL),s=this.getDuration(K.GET_MESSAGES),a=this.getDuration(K.TOTAL_DURATION_FROM_CACHE),i=this.getDuration(K.TOTAL_DURATION),l={...this.extraData,present_method:this.presentMethod,...n!==null&&{auth_duration:n},...r!==null&&{get_channel_duration:r},...s!==null&&{get_messages_duration:s},...a!==null&&{total_duration_from_cache:a}},c={key:this.getMetricKey(),value:i!==null?String(i):"0"};return this.conversationId!==null&&(c.conversation_id=this.conversationId),this.errorCode!==null&&(c.error_code=this.errorCode),this.errorDescription!==null&&(c.error_description=this.errorDescription),Object.keys(l).length>0&&(c.extra=l),c}}class Ao{constructor(t){C(this,"commitCallback");C(this,"presentMethod","direct_present");C(this,"stats",null);this.commitCallback=t}getOrCreateStats(){return(!this.stats||this.stats.isCommitted())&&(this.stats=new So().setCommitCallback(this.commitCallback).setPresentMethod(this.presentMethod)),this.stats}onAuthStart(){this.getOrCreateStats().startTimer(K.TOTAL_DURATION).startTimer(K.TOTAL_DURATION_FROM_CACHE).startTimer(K.AUTH)}onAuthComplete(){var t;(t=this.stats)==null||t.stopTimer(K.AUTH)}onAuthError(t){this.stats&&!this.stats.isCommitted()&&this.stats.stopTimer(K.AUTH).setError(t instanceof Y.SendbirdError?t.code:void 0,t.message).stopTimer(K.TOTAL_DURATION).commit()}onGetChannelStart(){var t;(t=this.stats)==null||t.startTimer(K.GET_CHANNEL)}onGetChannelComplete(t){this.stats&&(this.stats.stopTimer(K.GET_CHANNEL),t!==void 0&&this.stats.setConversationId(t),this.stats.startTimer(K.GET_MESSAGES))}onGetChannelError(t){this.stats&&!this.stats.isCommitted()&&this.stats.stopTimer(K.GET_CHANNEL).setError(t instanceof Y.SendbirdError?t.code:void 0,t.message).stopTimer(K.TOTAL_DURATION).commit()}onCacheResult(t){this.stats&&!this.stats.isCommitted()&&(t&&this.stats.setError(t instanceof Y.SendbirdError?t.code:void 0,t.message),this.stats.stopTimer(K.TOTAL_DURATION_FROM_CACHE))}onApiResult(t){this.stats&&!this.stats.isCommitted()&&(t&&this.stats.setError(t instanceof Y.SendbirdError?t.code:void 0,t.message),this.stats.stopTimer(K.TOTAL_DURATION).stopTimer(K.GET_MESSAGES).commit())}setChannelUrl(t){var n;(n=this.stats)==null||n.setChannelUrl(t)}cleanup(){var t;(t=this.stats)==null||t.commit()}setPresentMethod(t){var n;this.presentMethod=t,(n=this.stats)==null||n.setPresentMethod(t)}clear(){this.stats=null}}function To(){let e=null,t=0;const n=(r,s)=>{if((e==null?void 0:e.key)===r)return e.promise;const a=++t,l=(e?e.promise.catch(()=>{}).then(()=>s()):s()).finally(()=>{(e==null?void 0:e.id)===a&&(e=null)});return e={key:r,id:a,promise:l},l};return n.isPending=()=>e!==null,n}const Ae={conversation:{isTalkToAgentViewEnabled:!0,scrollMode:"auto",newMessageIndicatorEnabled:!0,senderAvatarEnabled:!0,messageAlertSoundEnabled:!1,header:{avatarEnabled:!0},input:{camera:{photoEnabled:!0},gallery:{photoEnabled:!0},fileEnabled:!0},fileViewer:{downloadEnabled:!0}}},Vn=e=>{var t,n,r,s,a,i,l,c,u,m,p,E,y,x;return e?{...Ae,...e,conversation:{...Ae.conversation,...e==null?void 0:e.conversation,header:{...(t=Ae.conversation)==null?void 0:t.header,...(n=e==null?void 0:e.conversation)==null?void 0:n.header},input:{...(r=Ae.conversation)==null?void 0:r.input,...(s=e==null?void 0:e.conversation)==null?void 0:s.input,camera:{...(i=(a=Ae.conversation)==null?void 0:a.input)==null?void 0:i.camera,...(c=(l=e==null?void 0:e.conversation)==null?void 0:l.input)==null?void 0:c.camera},gallery:{...(m=(u=Ae.conversation)==null?void 0:u.input)==null?void 0:m.gallery,...(E=(p=e==null?void 0:e.conversation)==null?void 0:p.input)==null?void 0:E.gallery}},fileViewer:{...(y=Ae.conversation)==null?void 0:y.fileViewer,...(x=e==null?void 0:e.conversation)==null?void 0:x.fileViewer}}}:Ae},ae=e=>{var t,n;return!!(e!=null&&e.isAIAgent&&((t=e==null?void 0:e.conversation)==null?void 0:t.status)===J.ConversationStatus.CLOSED||e!=null&&e.isDesk&&((n=e==null?void 0:e.helpdeskInfo)==null?void 0:n.ticketStatus)==="closed")},En=e=>{var t,n;return!!(e!=null&&e.isAIAgent&&((t=e==null?void 0:e.conversation)==null?void 0:t.status)===J.ConversationStatus.OPEN||e!=null&&e.isDesk&&((n=e==null?void 0:e.helpdeskInfo)==null?void 0:n.ticketStatus)==="open")};function qe(e){var n,r,s;return typeof(((n=e==null?void 0:e.conversation)==null?void 0:n.handedOverAt)??((s=(r=e==null?void 0:e.conversation)==null?void 0:r.handoff)==null?void 0:s.timestamp))=="number"}function Io(e){var t;if(((t=e==null?void 0:e.resolution)==null?void 0:t.determinedBy)==="user")return e.resolution.isResolved}function zn(e){return!!e&&e<Date.now()}function wo(e){return!e.title}function ko(e,t){var n;if(e)return wo(e)?{...e,title:t.title,csat_question:t.question,csat_scores:[{label:"",image_url:"https://static.dashboard.sendbird.com/assets/ai-agent/angry-active.png"},{label:"",image_url:"https://static.dashboard.sendbird.com/assets/ai-agent/suspicious-active.png"},{label:"",image_url:"https://static.dashboard.sendbird.com/assets/ai-agent/neutral-active.png"},{label:"",image_url:"https://static.dashboard.sendbird.com/assets/ai-agent/smile-active.png"},{label:"",image_url:"https://static.dashboard.sendbird.com/assets/ai-agent/happy-active.png"}],cre:{required:((n=e.cre)==null?void 0:n.required)??!0,question:t.cre.question,positive_label:t.cre.positive_label,negative_label:t.cre.negative_label},follow_up:[{response_type:"free_text",scores:[1,2,3,4,5],question:t.followUp.question,always_visible:!1}],csat_submit_label:t.submit_label,csat_submitted_label:t.submitted_label}:e}class Mo{constructor(){C(this,"_channelHandlerId",null);C(this,"_connectionHandlerId",null);C(this,"_handleActiveChannelChangedThrottled",null);C(this,"_setupChannelHandler",()=>{const t=Date.now();this._channelHandlerId=`aiagent_channel_${t}`,this._connectionHandlerId=`aiagent_connection_${t}`,this._handleActiveChannelChangedThrottled=$r(s=>{var a,i;(i=this._session)==null||i._updateActiveChannel({url:s.url,status:ae(s)?"closed":"open",conversationStatus:(a=s.conversation)==null?void 0:a.status}),this._logger.debug("AIAgentEventManager: activeChannel updated",s.url)},250,{leading:!0,trailing:!1});const n=new Qe.GroupChannelHandler({onChannelChanged:s=>{var a,i;s.isGroupChannel()&&s.url===((a=this._session)==null?void 0:a.activeChannel.url)&&((i=this._handleActiveChannelChangedThrottled)==null||i.call(this,s))}}),r=new Y.ConnectionHandler({onReconnectSucceeded:async()=>{await this._syncActiveChannelOnReconnect()}});this._chatClient.chatSDK.groupChannel.addGroupChannelHandler(this._channelHandlerId,n),this._chatClient.chatSDK.addConnectionHandler(this._connectionHandlerId,r),this._logger.debug("AIAgentEventManager: handlers registered",{channelHandlerId:this._channelHandlerId,connectionHandlerId:this._connectionHandlerId})});C(this,"_removeChannelHandler",()=>{this._channelHandlerId&&(this._chatClient.chatSDK.groupChannel.removeGroupChannelHandler(this._channelHandlerId),this._channelHandlerId=null),this._connectionHandlerId&&(this._chatClient.chatSDK.removeConnectionHandler(this._connectionHandlerId),this._connectionHandlerId=null),this._handleActiveChannelChangedThrottled&&(this._handleActiveChannelChangedThrottled.cancel(),this._handleActiveChannelChangedThrottled=null),this._logger.debug("AIAgentEventManager: handlers removed")});C(this,"_syncActiveChannelOnReconnect",async()=>{var n,r,s;const t=(n=this._session)==null?void 0:n.activeChannel.url;if(t)try{const i=await(await this._chatClient.chatSDK.groupChannel.getChannel(t)).refresh();i.url===t&&(this._initConversationIfNeeded(i),(s=this._session)==null||s._updateActiveChannel({url:i.url,status:ae(i)?"closed":"open",conversationStatus:(r=i.conversation)==null?void 0:r.status}),this._logger.debug("AIAgentEventManager: activeChannel synced on reconnect",i.url))}catch(a){this._logger.error("AIAgentEventManager: failed to sync activeChannel on reconnect",a)}});C(this,"_initConversationIfNeeded",t=>{t.isAIAgent&&!t.conversation&&t.initConversation({aiAgentId:this.aiAgentId}).catch(n=>this._logger.warn("AIAgentEventManager: initConversation failed",n))});C(this,"onMessengerSettingsUpdated",t=>(this._dispatcher.subscribe(le.MessengerSettingsUpdated,t),()=>{this._dispatcher.unsubscribe(le.MessengerSettingsUpdated,t)}));C(this,"onActiveChannelUpdated",t=>(this._dispatcher.subscribe(le.ActiveChannelUpdated,t),()=>{this._dispatcher.unsubscribe(le.ActiveChannelUpdated,t)}));C(this,"onAuthTokenRefreshed",t=>(this._dispatcher.subscribe(le.AuthTokenRefreshed,t),()=>{this._dispatcher.unsubscribe(le.AuthTokenRefreshed,t)}))}}class $o{constructor(t){C(this,"_sdkUser");C(this,"_userSession");C(this,"_dispatcher");C(this,"_activeChannel");C(this,"_updateActiveChannel",t=>{this._activeChannel=t,this._dispatcher.send(Be.ActiveChannelUpdated({channelUrl:t.url,status:t.status,conversationStatus:t.conversationStatus}))});C(this,"_updateAuthToken",t=>{this._userSession.authToken=t,this._dispatcher.send(Be.AuthTokenRefreshed())});this._sdkUser=t.sdkUser,this._userSession=t.userSession,this._dispatcher=t.dispatcher,this._activeChannel=t.activeChannel}get sdkUser(){return this._sdkUser}get userSession(){return this._userSession}get activeChannel(){return this._activeChannel}}const Nr=e=>{try{const t=JSON.parse(e);return typeof t=="string"?JSON.stringify(t).slice(1,-1):e.trim()}catch{return JSON.stringify(e).slice(1,-1)}},rt=e=>JSON.parse(e),Mt=e=>JSON.parse(e);function Lo(e,t){const[n,r]=t.split(",").map(s=>s.trim());return e==="dark"&&r||n}function Oo(e){const t={};function n(r,s=""){for(const[a,i]of Object.entries(r)){const l=s?`${s}.${a}`:a;i&&typeof i=="object"&&!Array.isArray(i)?n(i,l):t[l]=i}}return n(e),t}function bn({template:e,variables:t,variableKeyPattern:n,variableValueTransformer:r}){return Object.entries(t).reduce((s,[a,i])=>{if(!r&&!["number","boolean","string"].includes(typeof i))throw new Error(`If transformer is not provided, value(${a}:${i}) must be a {string, number, or boolean}`);const l=r?r(i):String(i),c=n(a);return s.replace(c,Nr(l))},e)}async function Ro({template:e,variables:t,variableKeyPattern:n,variableValueTransformer:r}){return(await Promise.all(Object.entries(t).map(async([a,i])=>{const l=await r(i);return{regex:n(a),transformedValue:l}}))).reduce((a,{regex:i,transformedValue:l})=>a.replace(i,Nr(l)),e)}var rn=(e=>(e[e.EXTERNAL_AUTH_TOKEN_EXPIRED=1]="EXTERNAL_AUTH_TOKEN_EXPIRED",e))(rn||{});const Pr=e=>typeof e=="object"&&e!==null,Gn=(e,t)=>t in e&&typeof e[t]=="string"&&e[t]!=="",Do=e=>!Pr(e)||!Gn(e,"channel_url")||!Gn(e,"ai_agent_id")?null:{channelUrl:e.channel_url,aiAgentId:e.ai_agent_id},No={1:Do};function Po(e){if(!Pr(e)||!("cat"in e)||typeof e.cat!="number"||!("data"in e))return null;const t=e.cat,n=No[t];if(!n)return null;const r=n(e.data);return r?{category:t,data:r}:null}function Fo(e,t,n,r){const s=Js.default.init({appId:e,modules:[new Qe.GroupChannelModule,new J.AIAgentModule],localCacheEnabled:!0,options:new Y.SendbirdChatOptions({typingIndicatorInvalidateTime:2e4}),...r});return s.addSendbirdExtensions([{version:n,product:Y.SendbirdProduct.AI_AGENT,platform:t.platform}],{platform:t.deviceOSPlatform,version:t.deviceOSVersion},t.customData)||console.warn("Invalid Sendbird Extensions",t),s}function Bo(e){const t=n=>{throw new Error(`Please initialize chat sdk with ${n}`)};typeof e.groupChannel!="object"&&t("GroupChannelModule"),typeof e.aiAgent!="object"&&t("AIAgentModule")}const Uo=[400300,400301,400302,400310];class _n{constructor(t,n,r){C(this,"chatSDK");C(this,"_logger");C(this,"_cache");C(this,"connect",async(t,n,r,s)=>{if(this._logger.debug("ChatClient.connect: start",t.userId),n){const a=new Y.SessionHandler({...n,onSessionTokenRequired:this._interceptTokenRefresh(n.onSessionTokenRequired,r,s)});this.chatSDK.setSessionHandler(a),this.chatSDK.aiAgent.addEventHandler(rn.EXTERNAL_AUTH_TOKEN_EXPIRED.toString(),i=>{var c;this._logger.debug("ChatClient.connect: EXTERNAL_AUTH_TOKEN_EXPIRED event received",i);const l=Po(i);(l==null?void 0:l.category)===rn.EXTERNAL_AUTH_TOKEN_EXPIRED&&(this._logger.debug("ChatClient.connect: calling onExternalAuthTokenExpired handler",l.data),(c=n==null?void 0:n.onExternalAuthTokenExpired)==null||c.call(n,l.data))})}try{return await this.chatSDK.connect(t.userId,t.authToken),await this._syncTemplatesIfNeeded(),this._logger.debug("ChatClient.connect: end",this.chatSDK.currentUser),this.chatSDK.currentUser}catch(a){const i=a;if(this.chatSDK.isCacheEnabled){if(this._isCacheRestrictedError(i))this._logger.warn("ChatClient.connect","offline connect restricted",i.message,i.code),this._logger.warn("ChatClient.connect","clear cached-data"),await this.chatSDK.clearCachedData().catch(l=>this._logger.warn("ChatClient.connect","clear cached-data failure",l));else if(this.chatSDK.currentUser)return this._logger.debug("ChatClient.connect: end (offline)",this.chatSDK.currentUser),this.chatSDK.currentUser}throw this._logger.warn("ChatClient.connect","connect failure",i.message,i.code),i}});C(this,"disconnect",async()=>{this._logger.debug("ChatClient.disconnect: start"),this.chatSDK.aiAgent.removeAllEventHandlers(),await this.chatSDK.disconnect(),this._cache.template.clear(),this._logger.debug("ChatClient.disconnect: end")});C(this,"getChannel",async t=>this.chatSDK.groupChannel.getChannel(t));C(this,"patchContext",async(t,n,r)=>this.chatSDK.aiAgent.patchContext(t,n,r));C(this,"updateContext",async(t,n,r)=>this.chatSDK.aiAgent.updateContext(t,n,r));C(this,"requestMessengerSettings",async t=>{var s;if(t.userId===""){const a=new Error("userId cannot be empty string for messenger settings request");throw this._logger.error("ChatClient.requestMessengerSettings: invalid userId",a),a}const n={...t,shouldSendFirstMessage:!1};this._logger.debug("ChatClient.requestMessengerSettings: requesting",n);const r=await this.chatSDK.aiAgent.requestMessengerSettings(n);return this._logger.debug("ChatClient.requestMessengerSettings: received",(s=r.active_channel)==null?void 0:s.channel_url),r});C(this,"_interceptTokenRefresh",(t,n,r)=>{if(t)return async(s,a)=>{new Promise((i,l)=>t==null?void 0:t(i,l)).then(i=>{i?n==null||n(i):r==null||r(),s(i)}).catch(i=>{r==null||r(),a(i)})}});C(this,"_isCacheRestrictedError",t=>Uo.some(n=>t.code===n));C(this,"_syncTemplatesIfNeeded",async()=>{var r,s;const t=(s=(r=this.chatSDK.appInfo)==null?void 0:r.aiAgentInfo)==null?void 0:s.templateListToken;if(!t)return;const n=this._cache.template.getCachedToken();if(!(n&&n===t)){this._logger.debug("ChatClient._syncTemplatesIfNeeded: syncing templates");try{const{templates:a,token:i}=await this.chatSDK.aiAgent.getMessageTemplates({limit:20});for(const{template:l}of a){const{key:c}=rt(l);this._cache.template.set(c,l)}this._cache.template.setCachedToken(i),this._logger.debug("ChatClient._syncTemplatesIfNeeded: sync completed")}catch(a){this._logger.error("ChatClient._syncTemplatesIfNeeded: error",a)}}});this.chatSDK=t,this._logger=n,this._cache=r}static init(t){let n;return t.chatSDK?(Bo(t.chatSDK),n=t.chatSDK):n=Fo(t.appId,t.extensions,t.messengerVersion,t.chatParams),new _n(n,t.logger,t.cache)}}const mt=new Map,Fr={set:(e,t)=>{mt.set(e,t)},get:e=>{if(mt.size===0)throw new Error("AIAgent platform not configured. Ensure you are using the correct package (@sendbird/ai-agent-messenger-react or @sendbird/ai-agent-messenger-react-native).");if(e){const n=mt.get(e);if(!n)throw new Error(`AIAgent platform "${e}" is not configured.`);return{platform:e,...n}}const t=mt.entries().next().value;return{platform:t[0],...t[1]}}},Ho=e=>Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0));class Wn extends Error{constructor(n,r){const s=(r==null?void 0:r.detail)??"";super(s||`Desk API error (${n})`);C(this,"status");C(this,"code");C(this,"detail");this.name="DeskApiError",this.status=n,this.code=(r==null?void 0:r.code)??"",this.detail=s}}var Cn=(e=>(e.INITIALIZED="INITIALIZED",e.PROACTIVE="PROACTIVE",e.PENDING="PENDING",e.ACTIVE="ACTIVE",e.CLOSED="CLOSED",e.WORK_IN_PROGRESS="WORK_IN_PROGRESS",e.IDLE="IDLE",e))(Cn||{}),xn=(e=>(e.URGENT="URGENT",e.HIGH="HIGH",e.MEDIUM="MEDIUM",e.LOW="LOW",e))(xn||{}),Br=(e=>(e.ERR_CREDENTIALS_NOT_PROVIDED="desk401100",e.ERR_NON_AUTHORIZED="desk401103",e.ERR_SESSION_KEY_EXPIRED="desk401106",e.ERR_SESSION_TOKEN_REVOKED="desk401107",e.ERR_USER_DEACTIVATED="desk401108",e.ERR_USER_NOT_EXIST="desk401109",e))(Br||{});const Vo=e=>e==="desk401103"||e==="desk401106"||e==="desk401107"||e==="desk401108"||e==="desk401109";class zo{constructor(t){C(this,"_appId");C(this,"_apiHost");C(this,"_logger");C(this,"_credential",null);C(this,"_authRefreshPromise",null);C(this,"_onDeskTokenRefreshRequired",async()=>!1);C(this,"request",async(t,n)=>{const r=n.authRequired??!0,s=`${this._apiHost}${t}`;r&&this._authRefreshPromise&&(this._logger.debug("DeskApiClient: waiting for in-flight recovery..."),await this._authRefreshPromise);const a=await this._fetch(s,n);return r&&a.status===401?this._handleUnauthorized(a,s,n):this._toResult(a)});C(this,"setCredential",(t,n=async()=>!1)=>{this._authRefreshPromise=null,this._onDeskTokenRefreshRequired=n,this._credential=t});C(this,"clearCredential",()=>{this._authRefreshPromise=null,this._credential=null,this._onDeskTokenRefreshRequired=async()=>!1});C(this,"_handleUnauthorized",async(t,n,r)=>{const s=await this._parseErrorCode(t);if(!Vo(s))return this._toResult(t);if(!await this._refresh(s)||this._credential===null)return this._toResult(t);const i=await this._fetch(n,r);return this._toResult(i)});C(this,"_refresh",async t=>{if(this._authRefreshPromise)return this._logger.debug("DeskApiClient: refresh already in progress, joining..."),this._authRefreshPromise;try{return this._authRefreshPromise=this._onDeskTokenRefreshRequired({reason:t}).catch(n=>(this._logger.error("DeskApiClient: delegated recovery failed",n),!1)),await this._authRefreshPromise}finally{this._authRefreshPromise=null}});C(this,"_fetch",(t,n)=>fetch(`${t}?${this._buildParams(n.params)}`,{method:n.method,headers:this._buildHeaders(n.authRequired??!0,n.headers),...n.body?{body:JSON.stringify(this._buildBody(n.body))}:{}}));C(this,"_buildParams",t=>new URLSearchParams({sendbirdAppId:this._appId,...t}));C(this,"_buildBody",t=>({sendbirdAppId:this._appId,...t}));C(this,"_buildHeaders",(t,n)=>({"content-type":"application/json",...t&&this._credential?{sendbirdDeskToken:this._credential.deskToken}:{},...n}));C(this,"_toResult",async t=>{if(!t.ok){const r=await t.json().catch(()=>({}));throw new Wn(t.status,r)}const n=await t.text();if(n)try{return JSON.parse(n)}catch{throw new Wn(t.status,{})}});C(this,"_parseErrorCode",async t=>{const n=await t.clone().json().catch(()=>({}));return n==null?void 0:n.code});this._appId=t.appId,this._apiHost=t.customApiHost??`https://desk-api-${t.appId}.sendbird.com/sapi`,this._logger=t.logger}get credential(){return this._credential}}class xt{constructor(t,n){C(this,"id");C(this,"title");C(this,"status");C(this,"agent");C(this,"priority");C(this,"group");C(this,"firstResponseTime");C(this,"issuedAt");C(this,"customFields");C(this,"_client");C(this,"refresh",async()=>this._client.getTicket(this.id));this.id=t.id,this.title=t.title,this.status=t.status,this.agent=t.agent,this.priority=t.priority,this.group=t.group,this.firstResponseTime=t.firstResponseTime,this.issuedAt=t.issuedAt,this.customFields=t.customFields,this._client=n}static _fromResponse(t,n){var r;return new xt({id:t.id,title:t.channelName??null,status:t.status2??Cn.INITIALIZED,agent:(()=>{var a;const s=(a=t.recentAssignment)==null?void 0:a.agent;return s?{userId:s.sendbirdId??"",name:s.displayName??"",profileUrl:s.photoThumbnailUrl??""}:null})(),priority:t.priority??xn.MEDIUM,group:t.group??0,firstResponseTime:t.firstResponseTime??-1,issuedAt:t.issuedAt??null,customFields:Object.fromEntries(((r=t.customFields)==null?void 0:r.map(s=>[s.key,s.value]))??[])},n)}}class vn{constructor(t){C(this,"_logger");C(this,"_apiClient");C(this,"_onDeskTokenRefreshRequired");C(this,"refreshDeskAuthToken",async t=>this._apiClient.credential?this.authenticate({userId:this._apiClient.credential.userId,accessToken:t,onDeskTokenRefreshRequired:this._onDeskTokenRefreshRequired}):!1);C(this,"authenticate",async t=>{this._logger.debug("DeskClient.authenticate: start",t.userId);try{const{token:n}=await this._apiClient.request("/customers/auth/",{method:"POST",headers:{sendbirdAccessToken:t.accessToken},body:{sendbirdId:t.userId},authRequired:!1});return t.onDeskTokenRefreshRequired!==void 0&&(this._onDeskTokenRefreshRequired=t.onDeskTokenRefreshRequired),this._apiClient.setCredential({userId:t.userId,deskToken:n,chatToken:t.accessToken},this._onDeskTokenRefreshRequired),this._logger.debug("DeskClient.authenticate: end"),!0}catch(n){return this._apiClient.clearCredential(),this._logger.debug("DeskClient.authenticate: failed",n),!1}});C(this,"deauthenticate",()=>{this._apiClient.clearCredential(),this._onDeskTokenRefreshRequired=void 0,this._logger.debug("DeskClient.deauthenticate: token cleared")});C(this,"setCustomerLanguage",async t=>{this._assertAuthenticated(this._apiClient),this._logger.debug("DeskClient.setCustomerLanguage: start",t),await this._apiClient.request("/customers/language/",{method:"PATCH",body:{language:t}}),this._logger.debug("DeskClient.setCustomerLanguage: end")});C(this,"getTicket",async t=>{this._assertAuthenticated(this._apiClient);const n=await this._apiClient.request(`/tickets/${encodeURIComponent(t)}/`,{method:"GET"});return xt._fromResponse(n,this)});C(this,"createTicket",async t=>{this._assertAuthenticated(this._apiClient);const n=await this._apiClient.request("/tickets/",{method:"POST",body:Ho({channelName:t.title,channelType:"SENDBIRD_JAVASCRIPT",customFields:t.customFields?JSON.stringify(t.customFields):void 0,info:JSON.stringify({ticket:{subject:t.title,requester:{name:t.name,email:this._apiClient.credential.userId}}}),priority:t.priority,groupKey:t.groupKey})});return xt._fromResponse(n,this)});this._logger=t.logger,this._apiClient=new zo(t)}static init(t){return new vn(t)}_assertAuthenticated(t){if(t.credential==null)throw new Error("DeskClient is not authenticated")}}function Go(e){return{get:t=>e.getString(t)??null,set:(t,n)=>{e.set(t,n)},delete:t=>{e.delete?e.delete(t):e.remove&&e.remove(t)},getKeys:t=>e.getAllKeys().filter(n=>n.startsWith(t))}}const Wo=1440*60*1e3;function Pe(e){if(!e)throw new Error("Not authenticated. Call authenticate() first.")}function qo(e,t){return Object.entries(t).every(([n,r])=>e[n]===r)}class vt extends Mo{constructor(n){super();C(this,"appId");C(this,"aiAgentId");C(this,"_chatClient");C(this,"_deskClient");C(this,"_cache");C(this,"_logger");C(this,"_dispatcher");C(this,"_session",null);C(this,"language");C(this,"countryCode");C(this,"context");C(this,"queryParams");C(this,"_config");C(this,"_networkStateAdapter");C(this,"_forceCreateChannel");C(this,"_statsTrackers");C(this,"_operationQueue",To());C(this,"dispose",()=>{this._operationQueue.isPending()||(this._logger.debug("AIAgent.dispose: start"),this._chatClient.chatSDK.connectionState==="OPEN"&&this._chatClient.chatSDK.disconnectWebSocket(),this._removeChannelHandler(),this._session=null,this._deskClient.deauthenticate(),this._statsTrackers.initialRender.clear(),this._logger.debug("AIAgent.dispose: end"))});C(this,"authenticate",n=>{const r=n&&"userId"in n?`auth:${n.userId}`:"auth:anon";return this._operationQueue(r,async()=>{var i,l,c,u,m;this._logger.debug("AIAgent.authenticate: start"),this._statsTrackers.initialRender.onAuthStart();const s=this._getSessionCandidate(n),a=(i=s.userSessionCandidate)!=null&&i.userId?this._cache.messenger.getSettings(s.userSessionCandidate.userId):null;a!=null&&a.bot&&this._dispatcher.send(Be.MessengerSettingsUpdated({settings:a,source:"cache"}));try{const p=await this._chatClient.requestMessengerSettings({aiAgentId:this.aiAgentId,userId:(l=s.userSessionCandidate)==null?void 0:l.userId,language:this.language,country:this.countryCode,context:this.context,knownActiveChannelUrl:(c=a==null?void 0:a.active_channel)==null?void 0:c.channel_url,forceCreateChannel:this._forceCreateChannel});let E;if(p.auto_created_user)if(s.type==="manual")this._logger.warn("Received auto created user info but current session is manual. Ignoring auto created user info."),E={userId:s.userSessionCandidate.userId,authToken:s.userSessionCandidate.authToken};else{const{user_id:b,session_token:f,expire_at:_}=p.auto_created_user;this._cache.messenger.setAnonUser({userId:b,authToken:f,expireAt:_}),E={userId:b,authToken:f},this._logger.debug("AIAgent.authenticate: anonymous user created",b)}else E={userId:((u=s.userSessionCandidate)==null?void 0:u.userId)??"",authToken:((m=s.userSessionCandidate)==null?void 0:m.authToken)??""};this._cache.messenger.setSettings(E.userId,p),this._dispatcher.send(Be.MessengerSettingsUpdated({settings:p,source:"server"}));const y=(()=>{var b;return s.type==="anonymous"?_o(this._dispatcher):(b=s.userSessionCandidate)==null?void 0:b.sessionHandler})(),x=await this._chatClient.connect(E,y,b=>{var f;this._logger.debug("AIAgent: session token refreshed"),(f=this._session)==null||f._updateAuthToken(b),this._deskClient.refreshDeskAuthToken(b)},()=>{this._logger.debug("AIAgent: session token unavailable, deauthenticating desk"),this._deskClient.deauthenticate()});return await this._deskClient.authenticate({userId:E.userId,accessToken:E.authToken,onDeskTokenRefreshRequired:async({reason:b})=>{var f;if(b===Br.ERR_SESSION_KEY_EXPIRED){await new Promise(v=>setTimeout(v,2e3));const _=(f=this._session)==null?void 0:f.userSession.authToken;return _?await this._deskClient.refreshDeskAuthToken(_):!1}return!1}}),(a==null?void 0:a.language)!==p.language&&this._deskClient.setCustomerLanguage(this.language).catch(()=>{}),this._statsTrackers.initialRender.onAuthComplete(),this._session=new $o({sdkUser:x,userSession:E,activeChannel:{url:p.active_channel.channel_url,status:"open"},dispatcher:this._dispatcher}),this._setupChannelHandler(),this._logger.debug("AIAgent.authenticate: end",{userId:E.userId}),p}catch(p){throw this._statsTrackers.initialRender.onAuthError(p),p}})});C(this,"deauthenticate",()=>this._operationQueue("deauth",async()=>{var n;this._logger.debug("AIAgent.deauthenticate: start"),await this._chatClient.disconnect(),this._deskClient.deauthenticate(),this._cache.messenger.clear((n=this._session)==null?void 0:n.userSession.userId),this._session=null,this._removeChannelHandler(),this._statsTrackers.initialRender.clear(),this._logger.debug("AIAgent.deauthenticate: end")}));C(this,"createConversation",async n=>{Pe(this._session),this._logger.debug("AIAgent.createConversation: start",n);const r=await this._chatClient.requestMessengerSettings({...n,userId:this._session.userSession.userId,knownActiveChannelUrl:void 0}),s=r.active_channel.channel_url;return this._cache.messenger.setSettings(this._session.userSession.userId,r),this._logger.debug("AIAgent.createConversation: end",s),s});C(this,"searchConversation",async n=>{if(Pe(this._session),this._logger.debug("AIAgent.searchConversation: start",n),Object.entries(n.context).length===0)return this._logger.debug("AIAgent.searchConversation: empty context, returning empty array"),[];const r=this.chatSDK.aiAgent.createConversationListQuery({aiAgentId:n.aiAgentId,status:J.ConversationStatus.OPEN,limit:100}),s=[];for(;r.hasNext;){const a=await r.next();for(const i of a)qo(i.context??{},n.context)&&s.push(i.channelInfo.url)}return this._logger.debug("AIAgent.searchConversation: end",{count:s.length}),s});C(this,"closeConversation",async n=>{var s;Pe(this._session),this._logger.debug("AIAgent.closeConversation: start",n);const r=await this._chatClient.getChannel(n);((s=r.conversation)==null?void 0:s.status)===J.ConversationStatus.OPEN?(await r.closeConversation(),this._session.activeChannel.url===n&&this._session._updateActiveChannel({url:n,status:"closed",conversationStatus:J.ConversationStatus.CLOSED}),this._logger.debug("AIAgent.closeConversation: end")):this._logger.debug("AIAgent.closeConversation: already closed or not an AI agent conversation")});C(this,"createConversationListCollection",n=>new Lr(this.chatSDK,n??{}));C(this,"patchContext",async(n,r)=>{Pe(this._session),this._logger.debug("AIAgent.patchContext: start",{channelUrl:n,context:r});const s=await this._chatClient.patchContext(this.aiAgentId,n,r);return this._logger.debug("AIAgent.patchContext: end",s),{...s,context:s.context??{}}});C(this,"updateContext",async(n,r)=>{Pe(this._session),this._logger.debug("AIAgent.updateContext: start",{channelUrl:n,context:r});const s=await this._chatClient.updateContext(this.aiAgentId,n,r);return this._logger.debug("AIAgent.updateContext: end",s),{...s,context:s.context??{}}});C(this,"getContextObject",async n=>{Pe(this._session),this._logger.debug("AIAgent.getContextObject: start",n);const s=await(await this._chatClient.getChannel(n)).getContextObject(this.aiAgentId);return this._logger.debug("AIAgent.getContextObject: end",s),{...s,context:s.context??{}}});C(this,"refreshActiveChannel",async n=>{var i,l;Pe(this._session);const r=(n==null?void 0:n.useKnownActiveChannelUrl)??!0;this._logger.debug("AIAgent.refreshActiveChannel: start",{useKnownActiveChannelUrl:r});const s=await this._chatClient.requestMessengerSettings({aiAgentId:this.aiAgentId,userId:this._session.userSession.userId,language:this.language,country:this.countryCode,context:this.context,knownActiveChannelUrl:r?(l=(i=this._cache.messenger.getSettings(this._session.userSession.userId))==null?void 0:i.active_channel)==null?void 0:l.channel_url:void 0,forceCreateChannel:this._forceCreateChannel}),a=s.active_channel.channel_url;return this._cache.messenger.setSettings(this._session.userSession.userId,s),this._session._updateActiveChannel({url:a,status:"open"}),this._logger.debug("AIAgent.refreshActiveChannel: end",a),a});C(this,"_getSessionCandidate",n=>n instanceof Dr?{type:"manual",userSessionCandidate:this._getManualSessionInfo(n)}:n instanceof nn?{type:"anonymous",userSessionCandidate:this._getAnonymousSessionInfo()}:n&&typeof n=="object"?(this._logger.warn("Please use ManualSessionInfo instead of the old userSessionInfo format."),{type:"manual",userSessionCandidate:this._getManualSessionInfo(n)}):n===void 0?(this._logger.warn("Please use AnonymousSessionInfo instead of undefined userSessionInfo."),{type:"anonymous",userSessionCandidate:this._getAnonymousSessionInfo()}):{type:"anonymous",userSessionCandidate:null});C(this,"_getAnonymousSessionInfo",()=>{const n=this._cache.messenger.getAnonUser();return n?n.expireAt-Wo<=Date.now()?(this._logger.debug("_getAnonymousSessionInfo: auto session expired, clear cache"),this._cache.messenger.clear(n.userId),null):(this._logger.debug("_getAnonymousSessionInfo: auto session info detected"),{userId:n.userId,authToken:n.authToken}):null});C(this,"_getManualSessionInfo",n=>{if(!n||n instanceof nn)throw new Error("userSessionInfo must be an instance of ManualSessionInfo");if(typeof n.userId!="string")throw new Error("userSessionInfo.userId must be a string");const r=["userId","authToken","sessionHandler"].filter(s=>!(s in n));return r.length>0&&this._logger.error(`_getManualSessionInfo: missing required keys in userSessionInfo: ${r.join(", ")}`),this._logger.debug("_getManualSessionInfo: manual session info detected"),{userId:n.userId,authToken:n.authToken,sessionHandler:n.sessionHandler}});this.appId=n.appId,this.aiAgentId=n.aiAgentId,this.language=n.language??"en",this.countryCode=n.countryCode,this.context=n.context,this._config=Vn(n.config),this.queryParams=n.queryParams,this._networkStateAdapter=n.networkStateAdapter,this._forceCreateChannel=n.forceCreateChannel,this._chatClient=n.chatClient,this._deskClient=n.deskClient,this._cache=n.cache,this._logger=n.logger,this._dispatcher=n.dispatcher,this._statsTrackers={initialRender:new Ao((r,s)=>this._chatClient.chatSDK.aiAgent.appendStat(r,s))}}static init(n){var m;const r=Fr.get(n.platform),s=n.logger??new Rr(n.logLevel??pn.WARN),a=n.dispatcher??new Or(s),i=n.useMMKVStorage?Go(n.useMMKVStorage):r.keyValueStorage,l=uo({appId:n.appId,aiAgentId:n.aiAgentId,storage:i}),c=_n.init({appId:n.appId,messengerVersion:r.messengerVersion,extensions:{platform:r.platform,deviceOSPlatform:r.deviceOSPlatform,deviceOSVersion:r.deviceOSVersion},chatParams:n.chatParams,chatSDK:n.chatSDK,logger:s,cache:l}),u=vn.init({appId:n.appId,logger:s,customApiHost:(m=n.deskParams)==null?void 0:m.customApiHost});return s.debug("AIAgent.init: created",{appId:n.appId,aiAgentId:n.aiAgentId}),new vt({appId:n.appId,aiAgentId:n.aiAgentId,language:n.language,countryCode:n.countryCode,context:n.context,config:n.config,queryParams:n.queryParams,networkStateAdapter:r.networkStateAdapter,forceCreateChannel:n._forceCreateChannel,chatClient:c,deskClient:u,cache:l,logger:s,dispatcher:a})}get chatSDK(){return this._chatClient.chatSDK}get deskClient(){return this._deskClient}get session(){return this._session}get config(){return this._config}set config(n){this._config=Vn(n)}get networkStateAdapter(){return this._networkStateAdapter}get logger(){return this._logger}get dispatcher(){return this._dispatcher}get cache(){return this._cache}get statsTrackers(){return this._statsTrackers}}const Q=(e,t)=>{const n=d.createContext(null),r=({children:i,value:l})=>o.createElement(n.Provider,{value:l},typeof i=="function"?i(l):i),s=({children:i})=>o.createElement(n.Consumer,null,l=>l?typeof i=="function"?i(l):i:null),a=()=>{const i=d.useContext(n);if(!i)throw new Error(`use${e}Context must be used within a ${e}Provider`);return i};return n.displayName=`${e}Context`,r.displayName=`${e}Provider`,s.displayName=`${e}Consumer`,a.displayName=`use${e}Context`,{Context:n,Provider:r,Consumer:s,useContext:a}};function fe(e){const t=d.createContext({Template:e.template,updateTemplate:()=>{},components:e.components,updateComponent:()=>{}});function n({children:a}){const[i,l]=d.useState(()=>e.template),[c,u]=d.useState(e.components),m={Template:i,updateTemplate:p=>l(()=>p),components:c,updateComponent:(p,E)=>u(y=>({...y,[p]:E}))};return o.createElement(t.Provider,{value:m},a)}function r({template:a,children:i}){const{updateTemplate:l}=d.useContext(t);return d.useLayoutEffect(()=>{a&&l(a)},[a]),o.createElement(o.Fragment,null,i)}function s({children:a}){return o.createElement(n,null,a)}return s.defaults=e,s.useContext=()=>d.useContext(t),s.Context=t,s.Template=r,Object.keys(e.components).forEach(a=>{s[a]=function({component:l}){const{updateComponent:c}=d.useContext(t);return d.useLayoutEffect(()=>{l&&c(a,l)},[l]),null}}),s}function jo(...e){return function({children:n}){return e.reduce((r,s)=>o.createElement(s,null,r),n)}}function Ko(e,t){var r;const n=e.lastMessage;if(n!=null&&n.isUserMessage()||n!=null&&n.isAdminMessage())return n.message||"";if(n!=null&&n.isFileMessage())return n.message||n.name||"FILE";if(n!=null&&n.isMultipleFilesMessage()){if(n.message)return n.message;const s=n.fileInfoList.length;return((r=t==null?void 0:t.formatMultipleFilesCount)==null?void 0:r.call(t,s))??`${s} photos`}return e.name}function Yo(e,t,n){var i;const r=new Date,s=new Date(((i=e.lastMessage)==null?void 0:i.createdAt)||e.createdAt),a=Fe.differenceInMinutes(r,s);return a<1?n.justNow:a<60?n.minutesAgo(a):Fe.isToday(s)?n.hoursAgo(Fe.differenceInHours(r,s)):t(s,n.dateShortFormat)}const{Provider:Xo,useContext:pe}=Q("AIAgent");function Zo(e){const t=Jo(e);return o.createElement(Xo,{value:{_aiAgentSDK:t,chatSDK:t.chatSDK,deskClient:t.deskClient,appId:t.appId,aiAgentId:t.aiAgentId,language:t.language,countryCode:t.countryCode,context:t.context,logger:t.logger,dispatcher:t.dispatcher,cache:t.cache,networkStateAdapter:t.networkStateAdapter,queryParams:t.queryParams,config:t.config}},e.children)}function Jo(e){const t=d.useRef(null),n=d.useRef(null);if(!t.current||!n.current)t.current=vt.init(e);else{const s=Qo(n.current,e);(s.appId||s.aiAgentId||s.chatSDK)&&(t.current.dispose(),t.current=vt.init({...e,chatParams:s.appId?{...e.chatParams,newInstance:!0}:e.chatParams}))}n.current=e,d.useEffect(()=>()=>{var s;(s=t.current)==null||s.dispose()},[]);const r=t.current;return r.language=e.language??"en",r.countryCode=e.countryCode,r.context=e.context,r.queryParams=e.queryParams,r.config=e.config,r}function Qo(e,t){const n=t.chatSDK!==void 0&&t.chatSDK!==null;return{appId:!n&&e.appId!==t.appId,aiAgentId:e.aiAgentId!==t.aiAgentId,chatSDK:!!e.chatSDK!==n||n&&t.chatSDK!==e.chatSDK}}const ea=(e,t,n)=>Me.useGroupChannelMessages(e,t,{...n,strictStreamingOrder:!0}),et={DEFAULT_PRIMARY:"#000000",DEFAULT_BOT_MSG_BG:"#ECECEC",WHITE:"#ffffff",BLACK:"#000000"};function Ur(e){return e.length===4?`#${[...e.slice(1)].map(t=>t+t).join("")}`:e}function ta(e){const t=Ur(e);return[parseInt(t.slice(1,3),16),parseInt(t.slice(3,5),16),parseInt(t.slice(5,7),16)]}function na(e){return`#${e.map(t=>t.toString(16).padStart(2,"0")).join("")}`}function ra(e,t,n){e/=255,t/=255,n/=255;const r=Math.max(e,t,n),s=Math.min(e,t,n),a=r-s;let i=0,l=0;const c=(r+s)/2;return r!==s&&(l=c>.5?a/(2-r-s):a/(r+s)),r===e?i=(t-n)/a+(t<n?6:0):r===t?i=(n-e)/a+2:r===n&&(i=(e-t)/a+4),i/=6,[i,l,c]}function sa(e,t,n){let r,s,a;if(t===0)r=s=a=n;else{const i=function(m,p,E){return E<0&&(E+=1),E>1&&(E-=1),E<.16666666666666666?m+(p-m)*6*E:E<.5?p:E<.6666666666666666?m+(p-m)*(.6666666666666666-E)*6:m},l=n<.5?n*(1+t):n+t-n*t,c=2*n-l;r=i(c,l,e+1/3),s=i(c,l,e),a=i(c,l,e-1/3)}return[Math.round(r*255),Math.round(s*255),Math.round(a*255)]}function ht(e,t,n){const[r,s,a]=ta(e),[i,l,c]=ra(r,s,a),u=Math.max(0,Math.min(1,c*t)),m=Math.max(0,Math.min(1,l*n)),[p,E,y]=sa(i,m,u);return na([Math.round(p),Math.round(E),Math.round(y)])}function oa(e,t="light"){return{extraDark:ht(e,.6,1.2),dark:ht(e,.85,1.1),main:e,light:ht(e,t==="dark"?1.1:1.5,t==="dark"?.95:.9),extraLight:ht(e,t==="dark"?1.2:1.75,t==="dark"?.9:.8)}}function sn(e){const t=Ur(e),n=149,r=+`0x${t[1]}${t[2]}`,s=+`0x${t[3]}${t[4]}`,a=+`0x${t[5]}${t[6]}`;return r*.299+s*.587+a*.114>n?et.BLACK:et.WHITE}function aa(e,t,n,r,s){return{base:{primary:t,primaryContrastContent:n,background:e.background50,headerBackground:e.background50,modalContentBackground:e.background50},messageInput:{text:e.onlight.textHighEmphasis,placeholderText:e.onlight.textLowEmphasis,background:e.background100},messageIncoming:{text:s,background:r},messageOutgoing:{text:n,background:t},csat:{background:e.background100}}}const ia=(e,t,n,r,s)=>({base:{primary:t,primaryContrastContent:n,background:e.background600,headerBackground:e.background500,modalContentBackground:e.background500},messageInput:{text:e.ondark.textHighEmphasis,placeholderText:e.ondark.textLowEmphasis,background:e.background400},messageIncoming:{text:s,background:r},messageOutgoing:{text:n,background:t},csat:{background:e.background400}}),gt={primary:{extraDark:"#491389",dark:"#6211c8",main:"#742ddd",light:"#c2a9fa",extraLight:"#dbd1ff"},secondary:{extraDark:"#066858",dark:"#027d69",main:"#259c72",light:"#69c085",extraLight:"#a8e2ab"},error:{extraDark:"#9d091e",dark:"#bf0711",main:"#de360b",light:"#f66161",extraLight:"#fdaaaa"},information:{extraDark:"#241389",dark:"#362ca9",main:"#4a48cd",light:"#a9bbfa",extraLight:"#d1dbff"},background700:"#000000",background600:"#161616",background500:"#2c2c2c",background400:"#393939",background300:"#bdbdbd",background200:"#e0e0e0",background100:"#eeeeee",background50:"#ffffff",onlight:{textHighEmphasis:"rgba(0, 0, 0, 0.88)",textMidEmphasis:"rgba(0, 0, 0, 0.5)",textLowEmphasis:"rgba(0, 0, 0, 0.38)",textDisabled:"rgba(0, 0, 0, 0.12)"},ondark:{textHighEmphasis:"rgba(255, 255, 255, 0.88)",textMidEmphasis:"rgba(255, 255, 255, 0.5)",textLowEmphasis:"rgba(255, 255, 255, 0.38)",textDisabled:"rgba(255, 255, 255, 0.12)"},overlay:{dark:"rgba(0, 0, 0, 0.55)",light:"rgba(22, 22, 22, 0.32)"}},Gt={h1:{fontSize:18,fontWeight:700},h2:{fontSize:16,fontWeight:700},subtitle1:{fontSize:16,fontWeight:500},subtitle2:{fontSize:16,fontWeight:400},body1:{fontSize:16,fontWeight:400},body2:{fontSize:14,fontWeight:500},body3:{fontSize:14,fontWeight:400},button:{fontSize:14,fontWeight:700},caption1:{fontSize:12,fontWeight:700},caption2:{fontSize:12,fontWeight:400},caption3:{fontSize:11,fontWeight:700},caption4:{fontSize:11,fontWeight:400}};function qn(e){const t=la(e),{colors:n,aiAgentColorVariables:r}=ca(e,t),s=ua(e);return{selectedTheme:e.selectedTheme,palette:t,colors:n,aiAgentColorVariables:r,typography:s}}function la({selectedTheme:e,palette:t,primary:n}){const r=t!=null&&t.primary?t.primary:n?n===gt.primary.main?gt.primary:oa(n,e):gt.primary;return{...gt,primary:r,...t}}function ca({selectedTheme:e,primaryContrast:t,botMessageBackground:n,botMessageBackgroundContrast:r},s){const a=s.primary.main,i=t??sn(a),l=n??et.DEFAULT_BOT_MSG_BG,c=r??sn(l);return{colors:(e==="light"?aa:ia)(s,a,i,l,c),aiAgentColorVariables:{primary_color:a,bot_message_bg_color:l,primary_contrast_color:i,bot_message_bg_contrast_color:c}}}function da(e,t,n){const r={...e};return n.forEach(s=>{const a=t[s];a!=null&&(r[s]=a)}),r}function ua({typography:e}){if(!e)return Gt;const t={...Gt};return Object.keys(e).forEach(n=>{const r=e[n];if(r&&typeof r=="object"){const s=Gt[n],a=["fontSize","fontWeight","fontFamily","lineHeight"];t[n]=da(s,r,a)}}),t}const{Provider:ma,useContext:yn}=Q("AIAgentTheme");function ha({logger:e,palette:t,typography:n,appearance:r,children:s}){const a=d.useRef(null),[i,l]=d.useState(()=>qn({selectedTheme:(r==null?void 0:r.theme)??"light",palette:t,typography:n,primary:r==null?void 0:r.primaryColor,botMessageBackground:r==null?void 0:r.botMessageBackgroundColor})),c=d.useCallback((u,m)=>{m&&(a.current=m);const p=(r==null?void 0:r.theme)??u,E=a.current?a.current.themes[p]:null,y={primary:r==null?void 0:r.primaryColor,primaryContrast:void 0,botMessageBackground:r==null?void 0:r.botMessageBackgroundColor,botMessageBackgroundContrast:void 0};!y.primary&&(E!=null&&E.primary_color)&&(y.primary=E.primary_color,y.primaryContrast=E.primary_contrast_color),!y.botMessageBackground&&(E!=null&&E.bot_message_bg_color)&&(y.botMessageBackground=E.bot_message_bg_color,y.botMessageBackgroundContrast=E.bot_message_bg_contrast_color);const x=qn({selectedTheme:p,palette:t,typography:n,...y});l(x),e==null||e.info("theme.update:",p)},[r==null?void 0:r.theme,r==null?void 0:r.primaryColor,r==null?void 0:r.botMessageBackgroundColor,t,n,e]);return d.useEffect(()=>{(r!=null&&r.theme||r!=null&&r.primaryColor||r!=null&&r.botMessageBackgroundColor)&&c(i.selectedTheme)},[r==null?void 0:r.theme,r==null?void 0:r.primaryColor,r==null?void 0:r.botMessageBackgroundColor]),o.createElement(ma,{value:{theme:i,updateTheme:c}},s)}const Wt=25*1024*1024,jn=1,Kn=new Set(["image/png","image/jpeg","image/jpg"]),Yn=new Set(["application/pdf"]),ga={off:"off",always:"always",handed_off_only:"handed_off_only"},fa=()=>{const[e,t]=d.useState(()=>({maxAttachmentCount:jn,attachmentMode:"handed_off_only",defaultUploadSizeLimit:Wt,uploadSizeLimitPerType:new Map,supportedImageMimeTypes:Kn,supportedFileMimeTypes:Yn})),n=d.useCallback(({active_channel:s,upload_restriction:a})=>{t({maxAttachmentCount:(a==null?void 0:a.max_attachment_count)??jn,attachmentMode:ga[s.attachment_mode]??"handed_off_only",defaultUploadSizeLimit:(a==null?void 0:a.default_upload_size_limit)??Wt,uploadSizeLimitPerType:new Map(Object.entries((a==null?void 0:a.upload_size_limit_per_type)??[])),supportedImageMimeTypes:new Set((a==null?void 0:a.supported_image_mime_types)??Kn),supportedFileMimeTypes:new Set((a==null?void 0:a.supported_file_mime_types)??Yn)})},[]),r=d.useCallback(s=>{const{channel:a,uploadSizeLimit:i=Wt}=s,l=(u=!0)=>a!=null&&a.isAIAgent?u?qe(a):!1:!0,c=u=>{if(l())return e.defaultUploadSizeLimit??i;const m=e.defaultUploadSizeLimit??i,p=e.uploadSizeLimitPerType.get(u)??m;return Math.min(m,p)};return{maxAttachmentCount:e.maxAttachmentCount,isEnabled:()=>{if(l(!1))return!0;switch(e.attachmentMode){case"off":return!1;case"always":return!0;case"handed_off_only":return qe(a);default:return!0}},get supportedMimeTypes(){return l()?[Qt]:[...e.supportedImageMimeTypes,...e.supportedFileMimeTypes]},isSupportedMimeType:u=>l()?!0:e.supportedImageMimeTypes.has(u)||e.supportedFileMimeTypes.has(u),getUploadSizeLimit:c,getUploadSizeLimitInMB:u=>c(u)/(1024*1024)}},[e]);return{updateBaseAttachmentRules:n,createAttachmentRules:r}},Xn=(...e)=>{const[t,n,r]=e;if(e.length===1&&typeof t=="object"&&t!==null)return{type:"active",context:t};if(e.length===3&&typeof t=="string"&&typeof n=="string"&&typeof r=="object"&&r!==null)return{type:"specific",aiAgentId:t,channelUrl:n,context:r};throw new Error("Invalid arguments: expected (context) or (aiAgentId, channelUrl, context)")},Ye=e=>({...e,context:e.context??{}}),{Provider:pa,useContext:st}=Q("AIAgentMessengerSession"),Ea=d.forwardRef(function({userSessionInfo:e,children:t},n){const{_aiAgentSDK:r,chatSDK:s,aiAgentId:a,logger:i}=pe(),{updateTheme:l}=yn(),[c,u]=d.useState(void 0),[m,p]=d.useState(void 0),[E,y]=d.useState(null),[x,b]=d.useState(null),[f,_]=d.useState(null),[v,A]=d.useState(null),{updateBaseAttachmentRules:T,createAttachmentRules:k}=fa();d.useEffect(()=>{const I=r.onMessengerSettingsUpdated(({settings:V})=>{const{appearance:X,bot:z,launcher:Re}=V;l(X.selected_theme,X),_({userId:z.bot_userid,profileUrl:z.bot_profile_url,nickname:z.bot_nickname,replyToFile:z.reply_to_file,specialNotice:z.special_notice,specialNoticeEnabled:z.is_special_notice_enabled,showHandoffButton:z.show_handoff_button??!0,isMultipleActiveConversationsEnabled:z.is_multiple_active_conversations_enabled??!0,isUserFeedbackEnabled:z.is_user_feedback_enabled??!1,isUserFeedbackCommentOptionEnabled:z.is_user_feedback_comment_option_enabled??!1}),A({type:Re.image_type||"default_icon",imageUrl:Re.image_url}),T(V)}),H=r.onActiveChannelUpdated(({channelUrl:V,status:X,conversationStatus:z})=>{p({url:V,status:X,conversationStatus:z})}),D=r.onAuthTokenRefreshed(()=>{var X;const V=(X=r.session)==null?void 0:X.userSession.authToken;V&&b(z=>z?{...z,authToken:V}:null)});return()=>{I(),H(),D()}},[r,l,T]);const L=d.useCallback(async()=>{u(void 0);try{const I=await r.authenticate(e),H=r.session;return y(H.sdkUser),b(H.userSession),p({url:I.active_channel.channel_url,status:"open"}),I}catch(I){throw u(I),I}},[r,e]),S=d.useCallback(async()=>{await r.deauthenticate(),y(null),p(void 0),b(null),_(null),A(null)},[r]),O=d.useCallback(async()=>{if(!r.session)throw i.error("agentMessengerSession.refreshActiveChannel: userSession is not ready"),new Error("userSession is not ready");return p(void 0),await r.refreshActiveChannel()},[r,i]),U=d.useCallback(async I=>{if(!r.session)throw new Error("Current user is not authenticated. Please authenticate first.");return r.createConversation(I)},[r]),R=d.useCallback(async I=>{if(!r.session)throw new Error("Current user is not authenticated. Please authenticate first.");return r.searchConversation(I)},[r]);return d.useImperativeHandle(n,()=>{const I=async()=>{if(!m)throw new Error("No active conversation. Please start a conversation first.");return await s.groupChannel.getChannel(m.url)};return{activeChannel:m,chatSDK:s,authenticate:L,deauthenticate:S,updateContext:async(...H)=>{const D=Xn(...H);if(D.type==="active"){const z=await(await I()).updateContext(a,D.context);return Ye(z)}const V=await s.aiAgent.updateContext(D.aiAgentId,D.channelUrl,D.context);return Ye(V)},patchContext:async(...H)=>{const D=Xn(...H);if(D.type==="active"){const z=await(await I()).patchContext(a,D.context);return Ye(z)}const V=await s.aiAgent.patchContext(D.aiAgentId,D.channelUrl,D.context);return Ye(V)},getContextObject:async()=>{const D=await(await I()).getContextObject(a);return Ye(D)}}},[L,S,m,s,a,i]),o.createElement(pa,{value:{sdkUser:E,userSessionInfo:e,userSession:x,activeChannel:m,setActiveChannel:p,refreshActiveChannel:O,createConversation:U,searchConversation:R,connectionError:c,aiAgentInfo:f,launcherInfo:v,authenticate:L,deauthenticate:S,createAttachmentRules:k,statsTrackers:r.statsTrackers}},t)}),Sn=(e,t)=>{const n=d.useId(),r=d.useRef(t);d.useLayoutEffect(()=>{r.current=t}),d.useEffect(()=>{const s=new Y.ConnectionHandler({onDisconnected:a=>{var i,l;return(l=(i=r.current).onDisconnected)==null?void 0:l.call(i,a)},onConnected:a=>{var i,l;return(l=(i=r.current).onConnected)==null?void 0:l.call(i,a)},onReconnectStarted:()=>{var a,i;return(i=(a=r.current).onReconnectStarted)==null?void 0:i.call(a)},onReconnectSucceeded:()=>{var a,i;return(i=(a=r.current).onReconnectSucceeded)==null?void 0:i.call(a)},onReconnectFailed:()=>{var a,i;return(i=(a=r.current).onReconnectFailed)==null?void 0:i.call(a)},onConnectionLost:()=>{var a,i;return(i=(a=r.current).onConnectionLost)==null?void 0:i.call(a)},onConnectionDelayed:a=>{var i,l;return(l=(i=r.current).onConnectionDelayed)==null?void 0:l.call(i,a)}});return e.addConnectionHandler(n,s),()=>{e.removeConnectionHandler(n)}},[e,n])};function ba(e){const{chatSDK:t,logger:n,aiAgentId:r}=pe(),{sdkUser:s,activeChannel:a,setActiveChannel:i,statsTrackers:l}=st(),c=Me.useForceUpdate(),[u,m]=d.useState(void 0),[p,E]=d.useState(void 0),[y,x]=d.useState(!1);function b(_){if(_.isAIAgent&&!_.conversation){x(!0);const v=_.initConversation({aiAgentId:r});v.catch(A=>n.warn("useChannel.initConversation: initialization failed",A)),v.finally(()=>x(!1))}}async function f(){var _,v;if(!s){n.debug("useChannel.getChannel: no sdk user, skip fetching channel");return}if(n.debug("useChannel.getChannel: start"),m(void 0),E(void 0),x(!1),e){l.initialRender.onGetChannelStart();try{n.debug("useChannel.getChannel: get channel",e);const A=await t.groupChannel.getChannel(e);b(A),m(A),l.initialRender.onGetChannelComplete((_=A.conversation)==null?void 0:_.id),A.url===(a==null?void 0:a.url)&&i({url:A.url,status:ae(A)?"closed":"open",conversationStatus:(v=A.conversation)==null?void 0:v.status}),n.debug("useChannel.getChannel: fetched channel",A)}catch(A){l.initialRender.onGetChannelError(A),A instanceof Y.SendbirdError&&E(A),n.error("useChannel.getChannel: error",A)}}}return d.useEffect(()=>{f()},[t,s,e,r]),Sn(t,{async onReconnectSucceeded(){var v;if(!u)return;const _=await u.refresh();b(_),m(_),_.url===(a==null?void 0:a.url)&&i({url:_.url,status:ae(_)?"closed":"open",conversationStatus:(v=_.conversation)==null?void 0:v.status})}}),Me.useGroupChannelHandler(t,{onChannelChanged:_=>{_.isGroupChannel()&&_.url===e&&(n.debug("useChannel.onChannelChanged: channel changed",_.url),m(_),c())}}),{channel:u,channelFetchError:p,getChannel:f,isInitializingConversation:y}}const _a=e=>{const t=e==null?void 0:e.lastMessage,n=t==null?void 0:t.extendedMessagePayload;return n==null?void 0:n.user_input_disabled_by},Ca=e=>{var i;const t=e==null?void 0:e.lastMessage;if(!t||!e)return!1;const n=t.extendedMessagePayload,r=n==null?void 0:n.form,s=!!r&&!r.submitted_at&&!r.canceled_at,a=e.isAIAgent&&!!((i=e.conversation)!=null&&i.handedOverAt);return s&&!a},xa=()=>{const{chatSDK:e,networkStateAdapter:t}=pe(),[n,r]=d.useState(()=>t?t.isOnline()?"connected":"reconnecting":"connected");return Sn(e,{onConnected:()=>r("connected"),onDisconnected:()=>r("disconnected"),onReconnectStarted:()=>r("reconnecting"),onReconnectSucceeded:()=>r("connected"),onReconnectFailed:()=>r("disconnected"),onConnectionLost:()=>r("reconnecting")}),d.useEffect(()=>{if(t)return t.subscribe(s=>{if(!s){r("reconnecting");return}r(a=>a==="reconnecting"&&e.connectionState===Y.ConnectionState.OPEN?"connected":a)})},[t,e]),n},va=3e4,ya=({shouldApply:e,lastMessage:t,isBlockedWhileAIResponding:n,currentUserId:r})=>{const[s,a]=d.useState(!1),i=d.useRef(null),l=t&&tt(t,r)?t.createdAt:0;return d.useEffect(()=>{const c=()=>{i.current&&(clearTimeout(i.current),i.current=null),a(!1)},u=E=>{i.current&&clearTimeout(i.current),a(!0),i.current=setTimeout(()=>{a(!1),i.current=null},E)},m=Date.now()-l,p=va-m;return n||p<=0?c():u(p),()=>{i.current&&clearTimeout(i.current)}},[n,l]),s&&e},Hr=e=>{const{chatSDK:t}=pe(),[n,r]=d.useState([]);return Me.useGroupChannelHandler(t,{onTypingStatusUpdated(s){if(s.url===(e==null?void 0:e.url)){const a=s.getTypingUsers();r(a)}}}),n},Sa=({channel:e,lastMessage:t,aiAgentUserId:n,isStreamAnimating:r})=>{const[s,a]=d.useState(!1),i=Hr(e);return d.useEffect(()=>{if(!t)return;const l=i.some(u=>u.userId===n),c=tt(t,n)&&(we.isStreaming(t)||r);a(c||l)},[i,t,n,r]),s},Aa=({channel:e,messages:t,isStreamAnimating:n,isInitializingConversation:r})=>{const{aiAgentInfo:s,userSession:a}=st(),i=xa(),l=Sa({channel:e,lastMessage:Un(t,[Ie.SendingStatus.SUCCEEDED]),aiAgentUserId:(s==null?void 0:s.userId)??"",isStreamAnimating:n}),c=ya({shouldApply:!!(e!=null&&e.isAIAgent)&&!qe(e),isBlockedWhileAIResponding:l,lastMessage:Un(t,[Ie.SendingStatus.PENDING,Ie.SendingStatus.SUCCEEDED]),currentUserId:(a==null?void 0:a.userId)??""});if(!e||i==="disconnected")return{disabled:!0,disabledBy:"unavailable"};if(i==="reconnecting")return{disabled:!0,disabledBy:"reconnecting"};if(ae(e))return{disabled:!0,disabledBy:"conversation_closed"};if(Ca(e))return{disabled:!0,disabledBy:"form_active"};const u=_a(e);return u?{disabled:!0,disabledBy:u}:l||c||r?{disabled:!0,disabledBy:"ai_responding"}:{disabled:!1,disabledBy:""}},Ta=()=>{const[e,t]=d.useState(new Set),n=d.useCallback(s=>{t(a=>{if(a.has(s))return a;const i=new Set(a);return i.add(s),i})},[]),r=d.useCallback(s=>{t(a=>{if(!a.has(s))return a;const i=new Set(a);return i.delete(s),i})},[]);return{isAnimating:e.size>0,start:n,stop:r}},{Provider:Ia}=Q("AIAgentConversation");function wa({children:e,channelUrl:t,onChannelDeleted:n,onMessagesReceived:r,onMessagesUpdated:s,onConversationClosedStatusChanged:a,onConversationClosedViaDispatcher:i,onBeforeSendMessage:l,onAfterSendMessage:c=ve,shouldMarkAsRead:u=!0,shouldCountNewMessages:m=()=>!1,sortComparator:p}){var R;const E=()=>u&&(f==null?void 0:f.markAsRead()),{chatSDK:y,logger:x,dispatcher:b}=pe(),{channel:f,channelFetchError:_,getChannel:v,isInitializingConversation:A}=ba(t),{statsTrackers:T}=st();d.useEffect(()=>{if(t)return T.initialRender.setChannelUrl(t),()=>{T.initialRender.cleanup()}},[t,T]);const k=ea(y,f,{replyType:Ie.ReplyType.ONLY_REPLY_TO_CHANNEL,shouldCountNewMessages:m,onChannelDeleted:n,onMessagesReceived:I=>r==null?void 0:r(I),onMessagesUpdated:I=>s==null?void 0:s(I),onCacheResult:I=>T.initialRender.onCacheResult(I),onApiResult:I=>T.initialRender.onApiResult(I),logger:x,markAsRead:E,sortComparator:p}),L=Ta(),S=Aa({channel:f,messages:k.messages,isStreamAnimating:L.isAnimating,isInitializingConversation:A});d.useEffect(()=>{E()},[u,f]);const O=ae(f);d.useEffect(()=>{a==null||a(O)},[O,a]),d.useEffect(()=>{const I=async H=>{const D=typeof(H==null?void 0:H.channelUrl)=="string";f&&D&&H.channelUrl!==f.url||(x.debug("conversation.dispatcher: try to close conversation",f),f!=null&&f.conversation&&f.conversation.status===J.ConversationStatus.OPEN&&(await f.closeConversation(),i==null||i()))};return b.subscribe(le.ConversationClose,I),()=>{b.unsubscribe(le.ConversationClose,I)}},[b,f,x,(R=f==null?void 0:f.conversation)==null?void 0:R.status,i]);const U={conversation:(f==null?void 0:f.conversation)??void 0,channelSource:{channel:f,error:_,refetch:()=>v(),closeConversation:async()=>{ae(f)||await(f==null?void 0:f.closeConversation())}},messageSource:{messages:k.messages,newMessages:k.newMessages,initialized:k.initialized,loadPrevious:()=>k.loadPrevious(),loadNext:()=>k.loadNext(),deleteMessage:I=>k.deleteMessage(I),resendMessage:I=>k.resendMessage(I),resetNewMessages:()=>k.resetNewMessages(),sendUserMessage:async I=>{var D;if(((D=f==null?void 0:f.conversation)==null?void 0:D.status)===J.ConversationStatus.CLOSED)throw new Error("Conversation is closed");l&&(I=await l(I));const H=await k.sendUserMessage(I,c);return c==null||c(H),H},sendFileMessage:async I=>{var D;if(((D=f==null?void 0:f.conversation)==null?void 0:D.status)===J.ConversationStatus.CLOSED)throw new Error("Conversation is closed");l&&(I=await l(I));const H=await k.sendFileMessage(I,c);return c==null||c(H),H},sendMultipleFilesMessage:async I=>{var D;if(((D=f==null?void 0:f.conversation)==null?void 0:D.status)===J.ConversationStatus.CLOSED)throw new Error("Conversation is closed");l&&(I=await l(I));const H=await k.sendMultipleFilesMessage(I,c);return c==null||c(H),H}},state:{streamAnimation:L,input:S}};return o.createElement(Ia,{value:U},e)}function ka(e,t){var y,x,b,f,_,v,A,T,k,L;const[n,r]=d.useState(!1),[s,a]=d.useState(null),[i,l]=d.useState([]),[c,u]=d.useState(null),m=d.useRef(!1),p=d.useCallback(async()=>{if(!m.current&&e.currentUser){m.current=!0,r(!1),a(null),l([]);try{c==null||c.dispose();const S=new Lr(e,t);S.setConversationListCollectionHandler({onChannelsAdded:()=>{l(S.channels)},onChannelsUpdated:()=>{l(S.channels)},onChannelsDeleted:()=>{l(S.channels)}}),await S.loadMore(),u(S),a(null)}catch(S){u(null),a(S)}finally{r(!0),m.current=!1}}},[e,e.currentUser,(y=t.filter)==null?void 0:y.aiAgentChannelFilter,(b=(x=t.filter)==null?void 0:x.aiAgentConversationStatusFilter)==null?void 0:b.join(),(_=(f=t.filter)==null?void 0:f.aiAgentIds)==null?void 0:_.join(),(v=t.filter)==null?void 0:v.deskChannelFilter,(T=(A=t.filter)==null?void 0:A.pinnedChannelUrls)==null?void 0:T.join(),(k=t.filter)==null?void 0:k.copilotConversationOnly,(L=t.filter)==null?void 0:L.copilotSupportChannelUrl,t.limit]),E=d.useCallback(async()=>{if(c)try{await c.loadMore()}catch(S){a(S)}},[c]);return Sn(e,{onConnected:()=>p()}),d.useEffect(()=>{p()},[p]),d.useEffect(()=>()=>{m.current=!1,c==null||c.dispose()},[c]),{initialized:n,error:s,channels:i,loadMore:E}}const{Provider:Ma}=Q("AIAgentConversationList");function $a({conversationListLimit:e,conversationListFilter:t,children:n}){var p,E;const{chatSDK:r,aiAgentId:s,queryParams:a}=pe(),i={aiAgentIds:[s],aiAgentConversationStatusFilter:[J.ConversationStatus.CLOSED,J.ConversationStatus.OPEN]},l=e??((p=a==null?void 0:a.conversationListParams)==null?void 0:p.limit),c={...i,...(E=a==null?void 0:a.conversationListParams)==null?void 0:E.filter,...t},u=ka(r,{limit:l,filter:c}),m={listSource:{initialized:u.initialized,error:u.error??void 0,channels:u.channels,loadMore:()=>u.loadMore()}};return o.createElement(Ma,{value:m},n)}function La(e){let t="pending",n=e.then(r=>{t="resolved",n=r}).catch(r=>{t="rejected",n=r});return{get value(){if(t==="resolved")return n;throw n}}}const{Provider:Oa,useContext:Vr}=Q("MessageTemplateFetching");function Ra({children:e,internalVariables:t}){const n=d.useRef({}),r=d.useRef({}),[s,a]=d.useState({}),i=d.useCallback((u,m)=>{a(p=>({...p,[u]:{fetching:!1,error:!1,...p[u],...m}}))},[]),l=d.useCallback(async({onRequestTemplate:u,onGetCachedTemplate:m,templateKey:p,suspense:E=!1})=>{const y=m(p);if(y)return y;const x=r.current[p];if(x)return x;E||i(p,{fetching:!0});const b=u(p).catch(f=>{throw E||i(p,{error:!0}),f}).finally(()=>{E||i(p,{fetching:!1}),delete r.current[p]});return r.current[p]=b,b},[i]),c={internalVariables:t,fetchTemplate:l,suspend:(u,m)=>{if(n.current[u])return n.current[u];const p=La(m());return n.current[u]=p,p},getIsFetching:u=>{var m;return((m=s[u])==null?void 0:m.fetching)??!1},getHasError:u=>{var m;return((m=s[u])==null?void 0:m.error)??!1}};return o.createElement(Oa,{value:c},e)}const $t={VARIABLE:e=>new RegExp(`\\{${e}\\}`,"g"),VIEW_VARIABLE:e=>new RegExp(`"{@${e}}"`,"g")};function $e({uiTemplateString:e,variables:t={}}){const n=Oo(t);return bn({template:e,variables:n,variableKeyPattern:r=>$t.VARIABLE(r)})}function Le({theme:e,uiTemplateString:t,colorVariables:n={}}){return bn({template:t,variables:n,variableKeyPattern:r=>$t.VARIABLE(r),variableValueTransformer:r=>Lo(e,r)})}function Da({theme:e,uiTemplateString:t,viewVariables:n={},aiAgentColorVariables:r,internalVariables:s,onRequestTemplate:a}){const l=Object.values(n).flat().map(u=>u.key);return[...new Set(l)].some(u=>!a(u))?null:bn({template:t,variables:n,variableKeyPattern:u=>$t.VIEW_VARIABLE(u),variableValueTransformer:u=>{const m=u.map(({key:p,variables:E})=>{const y=a(p),{ui_template:x,color_variables:b}=rt(y);let f=JSON.stringify(x);return f=$e({uiTemplateString:f,variables:s}),f=Le({theme:e,uiTemplateString:f,colorVariables:b}),f=Le({theme:e,uiTemplateString:f,colorVariables:r}),f=$e({uiTemplateString:f,variables:E}),Mt(f)});return JSON.stringify(m)}})}async function Na({theme:e,uiTemplateString:t,viewVariables:n={},aiAgentColorVariables:r,internalVariables:s,onRequestTemplate:a}){return Ro({template:t,variables:n,variableKeyPattern:i=>$t.VIEW_VARIABLE(i),variableValueTransformer:async i=>{const l=i.map(async({key:u,variables:m})=>{const p=await a(u),{ui_template:E,color_variables:y}=rt(p);let x=JSON.stringify(E);return x=$e({uiTemplateString:x,variables:s}),x=Le({theme:e,uiTemplateString:x,colorVariables:y}),x=Le({theme:e,uiTemplateString:x,colorVariables:r}),x=$e({uiTemplateString:x,variables:m}),Mt(x)}),c=await Promise.all(l);return JSON.stringify(c)}})}const Pa=({rawTemplate:e,aiAgentColorVariables:t,internalVariables:n,...r})=>{const{ui_template:s,color_variables:a}=rt(e);let i=JSON.stringify(s);if(Object.keys(r.viewVariables??{}).length>0){const c=Da({...r,uiTemplateString:i,aiAgentColorVariables:t,internalVariables:n});if(c===null)return null;i=c}return i=$e({...r,uiTemplateString:i,variables:n}),i=Le({...r,uiTemplateString:i,colorVariables:a}),i=Le({...r,uiTemplateString:i,colorVariables:t}),i=$e({...r,uiTemplateString:i}),Mt(i)},Fa=async({rawTemplate:e,aiAgentColorVariables:t,internalVariables:n,...r})=>{const{ui_template:s,color_variables:a}=rt(e);let i=JSON.stringify(s);return Object.keys(r.viewVariables??{}).length>0&&(i=await Na({...r,uiTemplateString:i,aiAgentColorVariables:t,internalVariables:n})),i=$e({...r,uiTemplateString:i,variables:n}),i=Le({...r,uiTemplateString:i,colorVariables:a}),i=Le({...r,uiTemplateString:i,colorVariables:t}),i=$e({...r,uiTemplateString:i}),Mt(i)},Ba=e=>{const{aiAgentColorVariables:t={}}=e,{internalVariables:n}=Vr();return d.useState(()=>{const r=e.onGetCachedTemplate(e.templateKey);return r?Pa({...e,rawTemplate:r,aiAgentColorVariables:t,internalVariables:n,onRequestTemplate:e.onGetCachedTemplate}):null})},Ua=e=>{const[t]=Ba(e);if(t)return t;const{aiAgentColorVariables:n={}}=e,{internalVariables:r,fetchTemplate:s,suspend:a}=Vr();return a(e.templateKey,async()=>{const l=await s({...e,suspense:!0});return await Fa({...e,rawTemplate:l,aiAgentColorVariables:n,internalVariables:r})}).value},Ha="remove_powered_by",An=(e,t)=>{var s,a;const{chatSDK:n}=pe(),{aiAgentInfo:r}=st();if(e==="handoff-button"){const i=!!((s=t==null?void 0:t.conversation)!=null&&s.handoff);return!!(t!=null&&t.isAIAgent)&&!!(r!=null&&r.showHandoffButton)&&i&&En(t)}if(e==="special-notice")return!!(t!=null&&t.isAIAgent)&&!!(r!=null&&r.specialNoticeEnabled)&&!!(r!=null&&r.specialNotice);if(e==="powered-by"){const i=(a=n==null?void 0:n.appInfo)==null?void 0:a.applicationAttributes;return d.useMemo(()=>!(Array.isArray(i)&&i.includes(Ha)),[i])}throw new Error("Unsupported feature")},Va={required:"This question is required",minLength:e=>`Minimum ${e} characters required`,maxLength:e=>`Maximum ${e} characters allowed`,min:e=>`Minimum value is ${e}`,max:e=>`Maximum value is ${e}`,minSelect:e=>`Select at least ${e} options`,maxSelect:e=>`Select at most ${e} options`,regex:"Invalid format",invalidSelection:"Invalid selection"},za={getValueOrDefault:e=>e.value??e.default_value??null,validate:(e,t,n)=>{const r=t;if(e.required&&(!r||r.trim()===""))return{isValid:!1,error:n.required};if(!r)return{isValid:!0};const{rules:s}=e;if(s){if(s.min_length!==void 0&&r.length<s.min_length)return{isValid:!1,error:typeof n.minLength=="function"?n.minLength(s.min_length):n.minLength};if(s.max_length!==void 0&&r.length>s.max_length)return{isValid:!1,error:typeof n.maxLength=="function"?n.maxLength(s.max_length):n.maxLength};if(s.regex&&!new RegExp(s.regex).test(r))return{isValid:!1,error:n.regex}}return{isValid:!0}}},Ga={getValueOrDefault:e=>e.value??e.default_value??null,validate:(e,t,n)=>{const r=t;if(e.required&&r===null)return{isValid:!1,error:n.required};if(r===null)return{isValid:!0};const{rules:s}=e;if(s){if(s.min!==void 0&&r<s.min)return{isValid:!1,error:typeof n.min=="function"?n.min(s.min):n.min};if(s.max!==void 0&&r>s.max)return{isValid:!1,error:typeof n.max=="function"?n.max(s.max):n.max}}return{isValid:!0}}},Wa={getValueOrDefault:e=>e.value??e.default_value??null,validate:(e,t,n)=>{const r=t;return e.required&&!r?{isValid:!1,error:n.required}:r&&!e.options.includes(r)?{isValid:!1,error:n.invalidSelection}:{isValid:!0}}},qa={getValueOrDefault:e=>e.values??e.default_values??null,validate:(e,t,n)=>{const r=t;if(e.required&&(!r||r.length===0))return{isValid:!1,error:n.required};if(!r||r.length===0)return{isValid:!0};if(r.filter(i=>!e.options.includes(i)).length>0)return{isValid:!1,error:n.invalidSelection};const{rules:a}=e;if(a){if(a.min_select!==void 0&&r.length<a.min_select)return{isValid:!1,error:typeof n.minSelect=="function"?n.minSelect(a.min_select):n.minSelect};if(a.max_select!==void 0&&r.length>a.max_select)return{isValid:!1,error:typeof n.maxSelect=="function"?n.maxSelect(a.max_select):n.maxSelect}}return{isValid:!0}}},ja={text:za,number:Ga,"single-select":Wa,"multi-select":qa},Ka={getValueOrDefault:()=>null,validate:()=>({isValid:!1})};function zr(e){return ja[e.type]||Ka}function Zn(e){return zr(e).getValueOrDefault(e)}function Ya(e,t,n={}){const r={...Va,...n};return zr(e).validate(e,t,r)}const Xa=(e,t={})=>{const{labels:n={},onSubmit:r,onCancel:s}=t,[a,i]=d.useState({}),[l,c]=d.useState(()=>{const b={};return e.fields.forEach(f=>{b[f.key]=Zn(f)}),b}),u=d.useMemo(()=>e.submitted_at?"submitted":e.canceled_at?"canceled":"draft",[e.submitted_at,e.canceled_at]);d.useEffect(()=>{if(u==="submitted"||u==="canceled"){const b={};let f=!1;e.fields.forEach(_=>{const v=Zn(_);JSON.stringify(l[_.key])!==JSON.stringify(v)&&(f=!0),b[_.key]=v}),f&&c(b)}},[u]);const m=(b,f)=>{c(_=>({..._,[b]:f})),i(_=>({..._,[b]:void 0}))},p=e.fields.map(b=>{var v,A,T;const f=l[b.key]??null,_={key:b.key,label:b.label,error:a[b.key],required:b.required};return b.type==="text"?{..._,type:"text",layout:b.layout,value:f,...b.placeholder&&{placeholder:b.placeholder},...((v=b.rules)==null?void 0:v.max_length)&&{maxLength:b.rules.max_length}}:b.type==="number"?{..._,type:"number",layout:b.layout,value:f,...b.placeholder&&{placeholder:b.placeholder},...((A=b.rules)==null?void 0:A.max)&&{max:b.rules.max}}:b.type==="single-select"?{..._,type:"single-select",layout:b.layout,value:f,options:b.options}:b.type==="multi-select"?{..._,type:"multi-select",layout:b.layout,value:f,options:b.options,...((T=b.rules)==null?void 0:T.max_select)&&{maxSelect:b.rules.max_select}}:{..._,type:"unknown",layout:"default",value:null}});return{state:u,fields:p,getField:b=>p.find(f=>f.key===b),updateFieldValue:m,submit:async()=>{const b={};let f=!1;for(const _ of e.fields){const v=l[_.key]??null,A=Ya(_,v,n);A.isValid||(b[_.key]=A.error,f=!0)}if(i(b),!f&&r){const _={};e.fields.forEach(v=>{_[v.key]=l[v.key]??null}),await r(_)}},cancel:async()=>{await(s==null?void 0:s())}}},Za=e=>{const{aiAgentInfo:t}=st(),r=Hr(e)[0];if(!r)return null;const s=r.userId===(t==null?void 0:t.userId);return{user:s?t:r,isBot:s}},Gr=({channel:e,userSession:t,aiAgentInfo:n})=>{if(!t||!n||!e)return{fallbackIcon:"delight",url:void 0,title:""};const r=(()=>{const[a]=e.members.filter(i=>i.userId!==t.userId);return a})(),s={ai(a){return{fallbackIcon:a,url:n.profileUrl,title:n.nickname}},human(a){return{fallbackIcon:a,url:r==null?void 0:r.profileUrl,title:(r==null?void 0:r.nickname)||n.nickname}},channel(a){return{fallbackIcon:a,url:e==null?void 0:e.coverUrl,title:(e==null?void 0:e.name)??""}}};return e.isAIAgent?qe(e)?s.human("agent"):s.ai("delight"):e.isDesk?s.human("agent"):s.channel("user")},Jn=e=>d.useReducer((t,n)=>({...t,...n}),e);var me=(e=>(e.AI_AGENT_CSAT_5="AI_AGENT_CSAT_5",e.AI_AGENT_CSAT_5_WITH_CRE="AI_AGENT_CSAT_5_WITH_CRE",e.HELPDESK_CSAT_5="HELPDESK_CSAT_5",e))(me||{});const Ja=new Set(["free_text","single_choice"]),Qa=({csatPayload:e,type:t,initialCsat:n,initialCsatReason:r,initialIsResolved:s})=>{const[a,i]=Jn({csatType:t,csat:n,csatReason:r,isResolved:s}),[l,c]=Jn({followUpItem:!1}),u=d.useMemo(()=>{var f;const y=a.csat,x=typeof y=="number",b=(f=e.follow_up)==null?void 0:f.find(_=>x?_.scores.includes(y):_.always_visible??!1);if(Ja.has(b==null?void 0:b.response_type))return b},[a.csat,e.follow_up]),m=(()=>{var y;if(typeof n=="number")return"submitted";if((t===me.AI_AGENT_CSAT_5||t===me.HELPDESK_CSAT_5)&&typeof a.csat=="number")return"submittable";if(t===me.AI_AGENT_CSAT_5_WITH_CRE){const x=typeof a.csat=="number",b=!((y=e.cre)!=null&&y.required)||typeof a.isResolved=="boolean";if(x&&b)return"submittable"}return"unsubmittable"})(),p=d.useCallback(()=>typeof a.csat>"u"?!1:u!=null&&u.required&&!a.csatReason?(c({followUpItem:!0}),!1):!0,[a,u,c]);return d.useEffect(()=>{r||(i({csatReason:""}),c({followUpItem:!1}))},[r,u,i,c]),{params:a,setParams:i,error:l,setError:c,followUpItem:u,state:m,validateParams:p,itemProps:{csatPayload:e,state:m,submitted:m==="submitted"}}},qt=5,ei=250,ti=50,Qn=e=>Math.max(0,e-ti),ni=e=>e<1e3?{speed:qt*.5,chunkSize:2}:e<2e3?{speed:qt*.8,chunkSize:2}:{speed:qt*.6,chunkSize:3},ri=e=>{const{text:t,enabled:n=!1,onAnimationStart:r,onAnimationProgress:s,onAnimationComplete:a}=e,[i,l]=d.useState(()=>Qn(t.length)),c=d.useRef(null),u=d.useRef({startTime:0,lastUpdate:0,lastProgressCall:0}).current,m=d.useRef({onStart:r,onProgress:s,onComplete:a}).current,p=d.useRef({startCalled:!1,completeCalled:!1}).current,E=d.useRef({initialEnabled:n,textLength:t.length,enabled:n}).current,y=n,x=i<t.length,b=E.initialEnabled&&(y||x);return d.useLayoutEffect(()=>{m.onStart=r,m.onProgress=s,m.onComplete=a,E.textLength=t.length,E.enabled=n}),d.useLayoutEffect(()=>{var f;E.initialEnabled&&(p.startCalled||(p.startCalled=!0,(f=m.onStart)==null||f.call(m)),l(_=>t.length<_?t.length:_))},[t]),d.useEffect(()=>{if(!E.initialEnabled)return;let f=Qn(t.length);u.lastUpdate=0,u.startTime=0,u.lastProgressCall=0;const _=v=>{var R;u.lastUpdate===0&&(u.lastUpdate=v,u.startTime=v,u.lastProgressCall=v);const A=E.textLength,T=v-u.lastUpdate,k=v-u.startTime,{speed:L,chunkSize:S}=ni(k),O=L*S;T>=O&&f<A&&(f=Math.min(f+S,A),l(f),u.lastUpdate=v),v-u.lastProgressCall>=ei&&(u.lastProgressCall=v,(R=m.onProgress)==null||R.call(m)),(f<A||E.enabled)&&(c.current=requestAnimationFrame(_))};return c.current=requestAnimationFrame(_),()=>{var v;c.current&&cancelAnimationFrame(c.current),p.startCalled&&!p.completeCalled&&(p.completeCalled=!0,(v=m.onComplete)==null||v.call(m))}},[]),d.useEffect(()=>{var A;const f=E.initialEnabled&&p.startCalled,_=!n,v=i>=t.length&&t.length>0;f&&_&&v&&!p.completeCalled&&(p.completeCalled=!0,(A=m.onComplete)==null||A.call(m))},[n,i,t.length]),{streamText:E.initialEnabled?t.slice(0,i):t,isAnimating:b}},si="1.20.0",oe="sb-agent",ce={ENTRY:`${oe}-entry`,MODAL_ROOT:`${oe}-modal-root`,WINDOW:`${oe}-window`,LAUNCHER:`${oe}-launcher`},ft=2147483647,He={MODAL:ft-1,TOOLTIP:ft-2,WINDOW:ft-3,LAUNCHER:ft-4},Wr=36,oi=100,ai=si,Tn="noopener noreferrer nofollow";function ii(){return{isOnline:()=>navigator.onLine,subscribe:e=>{const t=()=>e(!0),n=()=>e(!1);return window.addEventListener("online",t),window.addEventListener("offline",n),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",n)}}}}const pt={};function li(){return{get:e=>{try{return localStorage.getItem(e)}catch{return pt[e]??null}},set:(e,t)=>{try{localStorage.setItem(e,t)}catch{pt[e]=t}},delete:e=>{try{localStorage.removeItem(e)}catch{delete pt[e]}},getKeys:e=>{try{const t=[];for(let n=0;n<localStorage.length;n++){const r=localStorage.key(n);r&&r.startsWith(e)&&t.push(r)}return t}catch{return Object.keys(pt).filter(t=>t.startsWith(e))}}}}const ci='@import"https://fonts.googleapis.com/css?family=Roboto:400,500,600,700&display=swap";.sb-message-template__border{position:relative}.sb-message-template__border:after{content:"";position:absolute;top:0;right:0;bottom:0;left:0;z-index:1;box-shadow:inset 0 0 0 var(--border-width) var(--border-color);border-radius:var(--border-radius);pointer-events:none}.sb-message-template__action{cursor:pointer}.sb-message-template__parent{font-family:Roboto,serif}.sb-message-template__text{font-family:inherit;font-size:14px;font-weight:400;font-stretch:normal;font-style:normal;letter-spacing:normal;text-align:left}.sb-message-template__text-button{font-family:inherit;background-color:#e0e0e0;text-align:center;padding:10px;border-radius:6px;font-size:14px;font-weight:600;font-stretch:normal;font-style:normal;letter-spacing:normal}.sendbird-theme--light .sb-message-template__text-button{color:#742ddd}.sendbird-theme--dark .sb-message-template__text-button{color:#c2a9fa}.sb-message-template__text-button:hover{opacity:1;box-shadow:#0000001a 0 1px 3px,#0000000f 0 1px 2px}.sb-message-template__text-button,.sb-message-template__image-button{cursor:pointer;border-style:none}.sb-message-template__parent{border-radius:unset;background-color:transparent;overflow:hidden}.sb-message-template__parent *{box-sizing:border-box;line-height:1.3}.sb-message-template__carousel{display:flex;width:100%;box-sizing:border-box;touch-action:pan-y}',di={conversation:{input_placeholder:"Ask a question",input_placeholder_disabled:"Chat is unavailable in this channel",input_placeholder_wait_ai_agent_response:"Waiting for the agent's reply...",input_placeholder_active_form:"Please fill out the form to move forward.",input_placeholder_reconnecting:"Trying to reconnect. Refresh if persists.",unknown_message_type:"(Unknown message type)",powered_by:"Powered by",citation_title:"Source",start_new_conversation_label:"Start a conversation",scroll_to_new_messages_label:()=>"New message",failed_message_resend:"Retry",failed_message_remove:"Remove",file_upload_no_supported_files:"No supported file types available.",a11y_message_list:"Chat messages",a11y_scroll_to_bottom:"Scroll to bottom",a11y_scroll_to_new_messages:"Scroll to new messages",a11y_open_conversation_list:"Open conversation list"},conversation_list:{header_title:"Conversations",ended:"Ended",footer_title:"Start a conversation",multiple_files_count:e=>`${e} ${e===1?"file":"files"}`},date_format:{just_now:"Just now",minutes_ago:e=>`${e} minutes ago`,hours_ago:e=>`${e} hours ago`,date_short:"MM/dd/yyyy",date_separator:"MMMM dd, yyyy",message_timestamp:"p"},csat:{title:"Your feedback matters to us",submitted_label:"Successfully submitted!",cre_question:"Was your issue resolved?",cre_positive_label:"Yes, thank you! 👍",cre_negative_label:"No, that didn't help.",reason_placeholder:"Share your feedback",question:"How would you rate your experience?",submit_label:"Submit",submission_expired:"We're sorry, the survey period has ended."},form:{optional_label:"optional",validation_required:"This question is required"},common:{placeholder_something_went_wrong:"Something went wrong",placeholder_no_messages:"No messages",placeholder_no_conversations:"No conversations yet",placeholder_something_went_wrong_retry_label:"Retry"},feedback:{title:"Submit feedback",good:"Good",bad:"Bad",comment_label:"Comment (optional)",comment_placeholder:"Leave a comment",cancel:"Cancel",submit:"Submit",save:"Save",edit:"Edit feedback",remove:"Remove feedback"}},on={language:"en",strings:di,dateLocale:Ws.enUS},qr=e=>({MESSAGE_INPUT__PLACE_HOLDER:e.conversation.input_placeholder,MESSAGE_INPUT__PLACE_HOLDER__DISABLED:e.conversation.input_placeholder_disabled,MESSAGE_INPUT__PLACE_HOLDER__WAIT_AI_AGENT_RESPONSE:e.conversation.input_placeholder_wait_ai_agent_response,MESSAGE_INPUT__PLACE_HOLDER__RECONNECTING:e.conversation.input_placeholder_reconnecting,UNKNOWN__UNKNOWN_MESSAGE_TYPE:e.conversation.unknown_message_type,POWERED_BY:e.conversation.powered_by,CSAT_TITLE_UNSUBMITTED:e.csat.title,CSAT_TITLE_SUBMITTED:e.csat.submitted_label,CSAT_CRE_TITLE:e.csat.cre_question,CSAT_CRE_SOLVED:e.csat.cre_positive_label,CSAT_CRE_NOT_SOLVED:e.csat.cre_negative_label,CSAT_REASON_PLACEHOLDER:e.csat.reason_placeholder,CSAT_RATING_TITLE:e.csat.question,CSAT_SUBMIT_LABEL:e.csat.submit_label,CSAT_SUBMISSION_EXPIRED:e.csat.submission_expired,DATE_FORMAT__JUST_NOW:e.date_format.just_now,DATE_FORMAT__MINUTES_AGO:e.date_format.minutes_ago,DATE_FORMAT__HOURS_AGO:e.date_format.hours_ago,DATE_FORMAT__DATE_SHORT:e.date_format.date_short,DATE_FORMAT__MESSAGE_LIST__DATE_SEPARATOR:e.date_format.date_separator,DATE_FORMAT__MESSAGE_TIMESTAMP:e.date_format.message_timestamp,CONVERSATION_LIST__HEADER_TITLE:e.conversation_list.header_title,CONVERSATION_LIST__ENDED:e.conversation_list.ended,CONVERSATION_LIST__NO_CONVERSATIONS:e.common.placeholder_no_conversations,CONVERSATION_LIST__MULTIPLE_FILES_COUNT:e.conversation_list.multiple_files_count,TALK_TO_AGENT:e.conversation.start_new_conversation_label,CITATION_SOURCE_TITLE:e.conversation.citation_title,FORM_PLACEHOLDER:e.conversation.input_placeholder_active_form,FORM_VALIDATION_REQUIRED:e.form.validation_required,OPTIONAL:e.form.optional_label,PLACE_HOLDER__WRONG:e.common.placeholder_something_went_wrong,PLACE_HOLDER__NO_MESSAGES:e.common.placeholder_no_messages,RETRY:e.common.placeholder_something_went_wrong_retry_label,FAILED_MESSAGE_RESEND:e.conversation.failed_message_resend,FAILED_MESSAGE_REMOVE:e.conversation.failed_message_remove,FILE_UPLOAD_NO_SUPPORTED_FILES:e.conversation.file_upload_no_supported_files,FEEDBACK_TITLE:e.feedback.title,FEEDBACK_GOOD:e.feedback.good,FEEDBACK_BAD:e.feedback.bad,FEEDBACK_COMMENT_LABEL:e.feedback.comment_label,FEEDBACK_COMMENT_PLACEHOLDER:e.feedback.comment_placeholder,FEEDBACK_CANCEL:e.feedback.cancel,FEEDBACK_SUBMIT:e.feedback.submit,FEEDBACK_SAVE:e.feedback.save,FEEDBACK_EDIT:e.feedback.edit,FEEDBACK_REMOVE:e.feedback.remove,A11Y_MESSAGE_LIST:e.conversation.a11y_message_list,A11Y_SCROLL_TO_BOTTOM:e.conversation.a11y_scroll_to_bottom,A11Y_SCROLL_TO_NEW_MESSAGES:e.conversation.a11y_scroll_to_new_messages,A11Y_OPEN_CONVERSATION_LIST:e.conversation.a11y_open_conversation_list,SCROLL_TO_NEW_MESSAGES_LABEL:e.conversation.scroll_to_new_messages_label}),ui=e=>{var t;return((t=e.split("-"))==null?void 0:t[0])??Lt},Lt="en",mi=new Set([Lt,"ko","es","pt","fr","hi","it","de","tr","ja"]),hi=(e,t,n)=>{const r=e[t];return r?typeof r=="function"?r():Promise.resolve(r):new Promise((s,a)=>{(typeof queueMicrotask=="function"?queueMicrotask:setTimeout)(a.bind(null,new Error("Unknown variable dynamic import: "+t+(t.split("/").length!==n?". Note that variables only represent file names one level deep.":""))))})},er=qr(on.strings),gi={...er,HEADER_BUTTON__AGENT_HANDOFF:"Connect with an agent",MESSAGE_INPUT__PLACE_HOLDER__SUGGESTED_REPLIES:"Select an option to continue",BUTTON__CANCEL:"Cancel",BUTTON__SUBMIT:"Submit",SUBMITTED:"Submitted",TRY_AGAIN:"Please try again.",FILE_UPLOAD_NOTIFICATION__COUNT_LIMIT:"Up to %d files can be attached.",FILE_UPLOAD_NOTIFICATION__SIZE_LIMIT:"The maximum size per file is %d MB.",FILE_UPLOAD_NOTIFICATION__FILES_EXCLUDED_BY_VALIDATION:"%d files were excluded due to limits. Please select files individually.",FILE_UPLOAD_PHOTOS:"Photos",FILE_UPLOAD_FILES:"Files",FILE_VIEWER__UNSUPPORT:"Unsupported message",IMAGE_VIEWER__DEFAULT_TITLE:"Image",A11Y_IMAGE_VIEWER_CLOSE:"Close image viewer",A11Y_IMAGE_VIEWER_PREVIOUS:"Previous image",A11Y_IMAGE_VIEWER_NEXT:"Next image",A11Y_IMAGE_VIEWER_DOWNLOAD:"Download image",A11Y_ATTACH_FILE:"Attach file",FORM_UNAVAILABLE:"Form is no longer available.",FORM_NOT_SUPPORTED:"This form is not supported in the current version.",FORM_VALIDATION_MIN_LENGTH:e=>`Minimum ${e} characters required`,FORM_VALIDATION_MAX_LENGTH:e=>`Maximum ${e} characters allowed`,FORM_VALIDATION_MIN:e=>`Minimum value is ${e}`,FORM_VALIDATION_MAX:e=>`Maximum value is ${e}`,FORM_VALIDATION_MIN_SELECT:e=>`Select at least ${e} options`,FORM_VALIDATION_MAX_SELECT:e=>`Select at most ${e} options`,FORM_VALIDATION_REGEX_FAILED:"Invalid format",DATE_FORMAT__CONVERSATION_LIST__LIST_ITEM_TITLE:er.DATE_FORMAT__DATE_SHORT,DATE_FORMAT__CONVERSATION_LIST__LIST_ITEM_TITLE_CAPTION:"h:mma",CONVERSATION_LIST__TOPICS_FALLBACK:"No category",CONVERSATION_CLOSED_FOOTER_LABEL:"Your conversation has ended",START_NEW_CONVERSATION:"💬 Start a new conversation",RETURN_TO_CONVERSATION:"💬 Return to conversation",BUTTON__SAVE:"Save",BUTTON__OK:"OK",NO_NAME:"(No name)",CHANNEL_FROZEN:"Channel frozen"},yt={language:on.language,dateLocale:on.dateLocale,stringSet:gi},fi=Object.freeze(Object.defineProperty({__proto__:null,default:yt},Symbol.toStringTag,{value:"Module"})),an=new Map([[Lt,yt]]);async function pi(e){const t=an.get(e);if(t)return t;try{if(mi.has(e)){const{default:n}=await hi(Object.assign({"./languages/de.ts":()=>Promise.resolve().then(()=>require("./cjs/DbxUqtQc.cjs")),"./languages/en.ts":()=>Promise.resolve().then(()=>fi),"./languages/es.ts":()=>Promise.resolve().then(()=>require("./cjs/DTCJ6-eC.cjs")),"./languages/fr.ts":()=>Promise.resolve().then(()=>require("./cjs/7UVs65zS.cjs")),"./languages/hi.ts":()=>Promise.resolve().then(()=>require("./cjs/DfRVurNO.cjs")),"./languages/it.ts":()=>Promise.resolve().then(()=>require("./cjs/JLk8Bvao.cjs")),"./languages/ja.ts":()=>Promise.resolve().then(()=>require("./cjs/BRnfdIkb.cjs")),"./languages/ko.ts":()=>Promise.resolve().then(()=>require("./cjs/BMS5Zb7W.cjs")),"./languages/pt.ts":()=>Promise.resolve().then(()=>require("./cjs/Dl0262MS.cjs")),"./languages/tr.ts":()=>Promise.resolve().then(()=>require("./cjs/DFmkiYPE.cjs"))}),`./languages/${e}.ts`,3);return an.set(e,n),n}return yt}catch{return yt}}const{Provider:Ei,useContext:W}=Q("Localization"),bi=({language:e=navigator.language,logger:t,stringSet:n,children:r})=>{const[s,a]=d.useState(an.get(Lt));return d.useEffect(()=>{const i=ui(e);s.language!==i&&(t==null||t.debug("localization.useEffect: update language",{from:s.language,to:i}),pi(i).then(a))},[e,t]),o.createElement(Ei,{value:{language:s.language,stringSet:{...s.stringSet,...n},dateLocale:s.dateLocale,format:(i,l,c)=>Fe.format(i,l,{locale:s.dateLocale,...c})}},r)},St="data-sb-agent-theme",tr=e=>(t,...n)=>{let r="";return t.forEach((s,a)=>{r+=s+(n[a]??"")}),`[${St}='${e}'] & { ${r} }`},N={light:tr("light"),dark:tr("dark")},_i=w.css(({theme:e})=>{const{palette:t}=e;return`
|
|
2
|
+
:root,
|
|
3
|
+
:host {
|
|
4
|
+
--sendbird-primary-extra-dark: ${t.primary.extraDark};
|
|
5
|
+
--sendbird-primary-dark: ${t.primary.dark};
|
|
6
|
+
--sendbird-primary-main: ${t.primary.main};
|
|
7
|
+
--sendbird-primary-light: ${t.primary.light};
|
|
8
|
+
--sendbird-primary-extra-light: ${t.primary.extraLight};
|
|
9
|
+
|
|
10
|
+
--sendbird-secondary-extra-dark: ${t.secondary.extraDark};
|
|
11
|
+
--sendbird-secondary-dark: ${t.secondary.dark};
|
|
12
|
+
--sendbird-secondary-main: ${t.secondary.main};
|
|
13
|
+
--sendbird-secondary-light: ${t.secondary.light};
|
|
14
|
+
--sendbird-secondary-extra-light: ${t.secondary.extraLight};
|
|
15
|
+
|
|
16
|
+
--sendbird-information-extra-dark: ${t.information.extraDark};
|
|
17
|
+
--sendbird-information-dark: ${t.information.dark};
|
|
18
|
+
--sendbird-information-main: ${t.information.main};
|
|
19
|
+
--sendbird-information-light: ${t.information.light};
|
|
20
|
+
--sendbird-information-extra-light: ${t.information.extraLight};
|
|
21
|
+
|
|
22
|
+
--sendbird-error-extra-dark: ${t.error.extraDark};
|
|
23
|
+
--sendbird-error-dark: ${t.error.dark};
|
|
24
|
+
--sendbird-error-main: ${t.error.main};
|
|
25
|
+
--sendbird-error-light: ${t.error.light};
|
|
26
|
+
--sendbird-error-extra-light: ${t.error.extraLight};
|
|
27
|
+
|
|
28
|
+
--sendbird-background-700: ${t.background700};
|
|
29
|
+
--sendbird-background-600: ${t.background600};
|
|
30
|
+
--sendbird-background-500: ${t.background500};
|
|
31
|
+
--sendbird-background-400: ${t.background400};
|
|
32
|
+
--sendbird-background-300: ${t.background300};
|
|
33
|
+
--sendbird-background-200: ${t.background200};
|
|
34
|
+
--sendbird-background-100: ${t.background100};
|
|
35
|
+
--sendbird-background-50: ${t.background50};
|
|
36
|
+
|
|
37
|
+
--sendbird-onlight-text-high-emphasis: ${t.onlight.textHighEmphasis};
|
|
38
|
+
--sendbird-onlight-text-mid-emphasis: ${t.onlight.textMidEmphasis};
|
|
39
|
+
--sendbird-onlight-text-low-emphasis: ${t.onlight.textLowEmphasis};
|
|
40
|
+
--sendbird-onlight-text-disabled: ${t.onlight.textDisabled};
|
|
41
|
+
|
|
42
|
+
--sendbird-ondark-text-high-emphasis: ${t.ondark.textHighEmphasis};
|
|
43
|
+
--sendbird-ondark-text-mid-emphasis: ${t.ondark.textMidEmphasis};
|
|
44
|
+
--sendbird-ondark-text-low-emphasis: ${t.ondark.textLowEmphasis};
|
|
45
|
+
--sendbird-ondark-text-disabled: ${t.ondark.textDisabled};
|
|
46
|
+
|
|
47
|
+
--sendbird-overlay-dark: ${t.overlay.dark};
|
|
48
|
+
--sendbird-overlay-light: ${t.overlay.light};
|
|
49
|
+
}
|
|
50
|
+
`}),Ci=w.css`[${St}='light'] &{--sb-text-high-emphasis:var(--sendbird-onlight-text-high-emphasis);--sb-text-mid-emphasis:var(--sendbird-onlight-text-mid-emphasis);--sb-text-low-emphasis:var(--sendbird-onlight-text-low-emphasis);--sb-text-disabled:var(--sendbird-onlight-text-disabled);--sb-text-high-emphasis-inverse:var(--sendbird-ondark-text-high-emphasis);--sb-text-mid-emphasis-inverse:var(--sendbird-ondark-text-mid-emphasis);--sb-text-low-emphasis-inverse:var(--sendbird-ondark-text-low-emphasis);--sb-text-disabled-inverse:var(--sendbird-ondark-text-disabled);--sb-bg-50-600:var(--sendbird-background-50);--sb-bg-100-500:var(--sendbird-background-100);--sb-bg-200-400:var(--sendbird-background-200);--sb-primary:var(--sendbird-primary-main);--sb-secondary:var(--sendbird-secondary-main);--sb-error:var(--sendbird-error-main);--sb-information:var(--sendbird-information-light);}[${St}='dark'] &{--sb-text-high-emphasis:var(--sendbird-ondark-text-high-emphasis);--sb-text-mid-emphasis:var(--sendbird-ondark-text-mid-emphasis);--sb-text-low-emphasis:var(--sendbird-ondark-text-low-emphasis);--sb-text-disabled:var(--sendbird-ondark-text-disabled);--sb-text-high-emphasis-inverse:var(--sendbird-onlight-text-high-emphasis);--sb-text-mid-emphasis-inverse:var(--sendbird-onlight-text-mid-emphasis);--sb-text-low-emphasis-inverse:var(--sendbird-onlight-text-low-emphasis);--sb-text-disabled-inverse:var(--sendbird-onlight-text-disabled);--sb-bg-50-600:var(--sendbird-background-600);--sb-bg-100-500:var(--sendbird-background-500);--sb-bg-200-400:var(--sendbird-background-400);--sb-primary:var(--sendbird-primary-light);--sb-secondary:var(--sendbird-secondary-light);--sb-error:var(--sendbird-error-light);--sb-information:var(--sendbird-information-light);}`,h={color:{primary:{dark:"var(--sendbird-primary-dark)",main:"var(--sendbird-primary-main)"},information:{main:"var(--sendbird-information-main)",light:"var(--sendbird-information-light)"},background700:"var(--sendbird-background-700)",background600:"var(--sendbird-background-600)",background500:"var(--sendbird-background-500)",background400:"var(--sendbird-background-400)",background200:"var(--sendbird-background-200)",background100:"var(--sendbird-background-100)",background50:"var(--sendbird-background-50)",onlight:{textLowEmphasis:"var(--sendbird-onlight-text-low-emphasis)"},ondark:{textMidEmphasis:"var(--sendbird-ondark-text-mid-emphasis)",textLowEmphasis:"var(--sendbird-ondark-text-low-emphasis)",textDisabled:"var(--sendbird-ondark-text-disabled)"},overlay:{dark:"var(--sendbird-overlay-dark)"}},themedColor:{textHighEmphasis:"var(--sb-text-high-emphasis)",textMidEmphasis:"var(--sb-text-mid-emphasis)",textLowEmphasis:"var(--sb-text-low-emphasis)",textDisabled:"var(--sb-text-disabled)",textHighEmphasisInverse:"var(--sb-text-high-emphasis-inverse)",textLowEmphasisInverse:"var(--sb-text-low-emphasis-inverse)",bg_50_600:"var(--sb-bg-50-600)",bg_100_500:"var(--sb-bg-100-500)",bg_200_400:"var(--sb-bg-200-400)",primary:"var(--sb-primary)",error:"var(--sb-error)",secondary:"var(--sb-secondary)"}},{Provider:xi,useContext:jr}=Q("MessengerTheme");function vi(e){const{theme:t,appearance:n,logger:r}=e;return o.createElement(ha,{appearance:n,palette:t==null?void 0:t.palette,typography:t==null?void 0:t.typography,logger:r},o.createElement(yi,{...e}))}function yi({rootElement:e=document.body,children:t}){const{theme:n,updateTheme:r}=yn();return d.useLayoutEffect(()=>{e.setAttribute(St,n.selectedTheme)},[e,n.selectedTheme]),o.createElement(w.ThemeProvider,{theme:n},o.createElement(xi,{value:{theme:n,updateTheme:r,rootElement:e}},t))}function Ue(e,t){const n=e.getRootNode({composed:t});return n instanceof ShadowRoot||n instanceof Document?n:document}const Si=(e,t)=>{d.useEffect(()=>{const n=Ue(t)instanceof ShadowRoot,r=Ue(t,!0);if(!(n?t:r).querySelector(`link[href*='${e}']`)){const a=r.createElement("link");a.rel="stylesheet",a.href=e,(n?t:r.head).appendChild(a)}},[e,t])},Ai=(e,t=document.body)=>{d.useEffect(()=>{const n=Ue(t),s=n instanceof ShadowRoot?t:n.head;if(!s)return;const a=`sba-${btoa(e).slice(0,10)}`;let i=s.querySelector(`style#${a}`);i?i.textContent!==e&&(i.textContent=e):(i=s.ownerDocument.createElement("style"),i.id=a,i.textContent=e,s.appendChild(i))},[e,t])},{Provider:Ti,Consumer:Kr,useContext:j}=Q("Messenger");function Ii({children:e,state:t,enableCloseConversationButton:n=!1,enableExpandButton:r=!0,enableAutoDisconnectInLauncher:s=!0,...a}){const[i,l]=d.useState(!1),[c,u]=d.useState(!1),m={opened:(t==null?void 0:t.opened)??i,setOpened:(t==null?void 0:t.setOpened)??l,expanded:(t==null?void 0:t.expanded)??c,setExpanded:(t==null?void 0:t.setExpanded)??u};return o.createElement(Zo,{...a},p=>o.createElement(Ti,{value:{...a,...p,state:m,enableCloseConversationButton:n,enableExpandButton:r,enableAutoDisconnectInLauncher:s}},e))}const Yr=/iPad|iPhone|iPod/.test(navigator.userAgent),wi=/Android/.test(navigator.userAgent),ot=e=>Yr||wi;let Xe=null,jt=null;const ki=(e,t=5e3)=>{Xe&&(clearInterval(Xe),clearTimeout(jt));const n=document.title;Xe=setInterval(()=>{document.title=document.title===e?n:e},750),jt=setTimeout(()=>{clearInterval(Xe),Xe=null,jt=null,document.title=n},t)},Xr=()=>{Promise.resolve().then(()=>require("./cjs/B93o4u0P.cjs")).then(e=>{new Audio(e.default).play().catch(()=>{})})},he=e=>{const t=e;return typeof t=="number"?`${t}px`:t},$=({as:e,variant:t="body1",color:n,maxTextLines:r,className:s,...a})=>o.createElement(Li,{as:e,$variant:t,className:s,$color:n,$maxTextLines:r,...a}),nr=new WeakMap,Mi=(e,t)=>{let n=nr.get(t);n||(n=new Map,nr.set(t,n));const r=n.get(e);if(r)return r;const s=t[e]??t.body1,a=w.css`font-size:${he(s.fontSize)};font-weight:${s.fontWeight};${s.fontFamily?`font-family: ${s.fontFamily};`:""}
|
|
51
|
+
${s.lineHeight?`line-height: ${s.lineHeight};`:"line-height: 100%;"}
|
|
52
|
+
`;return n.set(e,a),a},$i=e=>e?w.css`display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:${e};overflow:hidden;`:"",Li=g.default.span`font-stretch:normal;letter-spacing:normal;${({$variant:e,theme:t})=>Mi(e,t.typography)}color:${({$color:e})=>e};${({$maxTextLines:e})=>$i(e)}`,Ot=({style:e,rootElementId:t,visible:n,onClose:r,children:s})=>{if(!n)return null;const{rootElement:a}=jr(),i=Ue(a),l=Ue(a,!0);return qs.createPortal(o.createElement(Oi,{onClick:r,style:e},o.createElement(Ri,{onClick:c=>c.stopPropagation()},s)),i.getElementById(t)??i.getElementById(ce.MODAL_ROOT)??l.body)},Oi=g.default.div`position:fixed;top:0;left:0;width:100%;height:100%;background:${h.color.overlay.dark};display:flex;justify-content:center;align-items:center;z-index:${He.MODAL};`,Ri=g.default.div`border-radius:4px;overflow:hidden;box-shadow:0 16px 24px 2px rgba(13,13,13,0.12),0 6px 30px 5px rgba(13,13,13,0.08),0 6px 10px -5px rgba(13,13,13,0.04);z-index:${He.MODAL};`,In=({visible:e,title:t,description:n,confirmText:r="OK",onConfirm:s,onClose:a})=>{const i=()=>{s==null||s(),a()};return o.createElement(Ot,{rootElementId:ce.WINDOW,visible:e,onClose:a},o.createElement(Di,null,o.createElement(Ni,null,t&&o.createElement($,{variant:"h1",color:h.themedColor.textHighEmphasis},t),n&&o.createElement(Pi,null,o.createElement($,{variant:"subtitle2",color:h.themedColor.textHighEmphasis},n))),o.createElement(Fi,null,o.createElement(Bi,{onClick:i},o.createElement($,{variant:"button",color:h.themedColor.primary},r)))))},Di=g.default.div`width:360px;height:auto;padding-block:24px 12px;padding-inline:24px;margin:0 auto;border-radius:4px;box-sizing:border-box;background-color:${({theme:e})=>e.colors.base.modalContentBackground};`,Ni=g.default.div`margin-bottom:16px;`,Pi=g.default.div`margin-top:8px;`,Fi=g.default.div`display:flex;flex-direction:row;justify-content:flex-end;`,Bi=g.default.button`all:unset;display:flex;justify-content:center;align-items:center;border-radius:4px;cursor:pointer;background-color:transparent;padding:10px 16px;`,{Provider:Ui,useContext:re}=Q("MessengerSession"),Hi=d.forwardRef(function({children:e,...t},n){return o.createElement(Ea,{ref:n,...t},r=>o.createElement(Vi,{...r},e))}),Vi=({children:e,...t})=>{const{chatSDK:n,logger:r,appId:s,aiAgentId:a,agentPreviewConfigs:i,state:l,handlers:c,dispatcher:u}=j(),{userSessionInfo:m,authenticate:p,setActiveChannel:E,userSession:y,aiAgentInfo:x,launcherInfo:b}=t,[f,_]=d.useState(!1),v=d.useRef(null);Me.useGroupChannelHandler(n,{async onUserJoined(T,k){var S,O,U;T.conversation&&T.conversation.type===J.ConversationType.PROACTIVE&&k.userId===((S=n.currentUser)==null?void 0:S.userId)&&(r.info("messengerSession.onUserJoined: proactive channel joined",T.url),E({url:T.url,status:"open",conversationStatus:(O=T.conversation)==null?void 0:O.status}),l.setOpened(!0),zi({sound:document.hidden||!l.opened}),(U=v.current)==null||U.call(v,{channel:T}))}}),d.useEffect(()=>{p().then(({launcher:T})=>{T.auto_open&&!ot()&&setTimeout(()=>l.setOpened(!0),500)}).catch(T=>{var k;r.error("messengerSession: failed to initialize",T),(k=c==null?void 0:c.onInitializeFailed)==null||k.call(c,T)})},[n,s,a,m==null?void 0:m.userId]),d.useEffect(()=>{const T=()=>_(!0);return u.subscribe(le.AnonymousSessionTokenExpired,T),()=>u.unsubscribe(le.AnonymousSessionTokenExpired,T)},[u]);const A=d.useCallback(()=>{t.deauthenticate().finally(()=>window.location.reload())},[t.deauthenticate]);return!y||!x||!b?null:o.createElement(Ui,{value:{...t,userSession:y,aiAgentInfo:{...x,...i==null?void 0:i.bot},launcherInfo:{...b,...i==null?void 0:i.launcher},registerOnJoinedProactiveConversation:T=>v.current=T}},e,o.createElement(In,{visible:f,title:"Session timed out",description:"Start a new conversation.",onConfirm:A,onClose:ve}))};function zi({sound:e}){ki("🔔You have received a new message"),e&&Xr()}const Gi=e=>{const{chatSDK:t,handlers:n,logger:r}=j(),{aiAgentInfo:s}=re(),a=d.useRef(new Set),i=m=>{if(!(n!=null&&n.onCustomEvent))return;ge(m)&&m.sender.userId===s.userId&&!we.isStreaming(m)&&!a.current.has(m.messageId)&&(r.debug("useCustomEventForMessageReceive: bot-message-received",m),n.onCustomEvent({type:"bot-message-received",data:{message:m}}),a.current.add(m.messageId))},l=m=>{if(n!=null&&n.onCustomEvent&&m.isAdminMessage()&&m.customType==="user_action_required"&&!a.current.has(m.messageId)){const p=en(m.data);Array.isArray(p.history)&&p.history.length===0&&(r.debug("useCustomEventForMessageReceive: user_action_required",p),n.onCustomEvent({type:"user-action-requested",data:p}),a.current.add(m.messageId))}},c=(m,p)=>{m.url===e&&(i(p),l(p))},u=m=>{l(m)};return Me.useGroupChannelHandler(t,{onMessageUpdated:c,onMessageReceived:c}),{checkForUserActionRequired:u}},At=`@${oe}-focused-channel`,Zr=`${Date.now()}-${Math.random().toString(36).slice(2)}`,Wi=()=>{try{const e=localStorage.getItem(At);return e?JSON.parse(e).channelUrl??null:null}catch{return null}},rr=e=>{try{localStorage.setItem(At,JSON.stringify({channelUrl:e,tabId:Zr}))}catch{}},sr=()=>{try{const e=localStorage.getItem(At);if(!e)return;JSON.parse(e).tabId===Zr&&localStorage.removeItem(At)}catch{}},qi=(e,t)=>(d.useEffect(()=>{if(!t||!e)return;const n=()=>rr(e),r=()=>sr();return document.hasFocus()&&rr(e),window.addEventListener("focus",n),window.addEventListener("blur",r),()=>{window.removeEventListener("focus",n),window.removeEventListener("blur",r),sr()}},[t,e]),{isChannelViewedInAnyTab:()=>document.hasFocus()||Wi()===e}),ji=e=>{var i;const{config:t,chatSDK:n}=j(),{sdkUser:r}=re(),s=!!((i=t==null?void 0:t.conversation)!=null&&i.messageAlertSoundEnabled),{isChannelViewedInAnyTab:a}=qi(e,s);Me.useGroupChannelHandler(n,{onMessageReceived(l,c){if(!s||l.url!==e||a())return;(ge(c)&&c.sender.userId!==(r==null?void 0:r.userId)||c.isAdminMessage()&&!c.silent)&&Xr()}})};function Ki(e){return new Promise(t=>{const n=new Image;n.onload=function(){const r=String(n.width),s=String(n.height);URL.revokeObjectURL(n.src),t({width:r,height:s})},n.src=URL.createObjectURL(e)})}async function Yi(e){if("file"in e&&e.file instanceof File&&e.file.type.startsWith("image/")){const{width:t,height:n}=await Ki(e.file);return new Ie.MessageMetaArray({key:wr,value:[t,n]})}}const Xi=({onScrollAfterSendMessage:e})=>{const{agentPreviewConfigs:t,handlers:n}=j(),r=d.useRef(t==null?void 0:t.agentAttributes);return r.current=t==null?void 0:t.agentAttributes,{onBeforeSendMessage:async s=>{const a=await Yi(s),i={...s,metaArrays:a?[a]:void 0},l=Zi(r.current);return l?{...i,data:JSON.stringify(l)}:i},onAfterSendMessage:s=>{var a,i,l;e(),(a=n==null?void 0:n.onMessageSend)==null||a.call(n,s.message),s.sendingStatus===Ie.SendingStatus.SUCCEEDED?(i=n==null?void 0:n.onCustomEvent)==null||i.call(n,{type:"message-sent-succeeded",data:{message:s}}):s.sendingStatus===Ie.SendingStatus.PENDING&&((l=n==null?void 0:n.onCustomEvent)==null||l.call(n,{type:"message-sent-pending",data:{message:s}}))}}},Zi=e=>{if(!e)return null;const t={};return e.ai&&Object.keys(e.ai).length>0&&(t.ai_attrs=e.ai),e.safeguard&&Object.keys(e.safeguard).length>0&&(t.safeguard_attrs=e.safeguard),typeof e.use_prompt_cache=="boolean"&&(t.use_prompt_cache=e.use_prompt_cache),Object.keys(t).length>0?t:null};async function wn(e){let t=e;t&&(!t.startsWith("http://")&&!t.startsWith("https://")&&(t="https://"+t),window.open(t,"_blank","noopener,noreferrer"))}function Jr(e){requestAnimationFrame(()=>{requestAnimationFrame(()=>{e()})})}const _t=50,Kt=_t-40,{Provider:Ji,useContext:Qi}=Q("ConversationScroll"),or={viewport:0,contentHeight:0,contentSnapshotHeight:0,shouldRecalc:!1,shouldUpdate:!1};function el({scrollMode:e,messageStackDirection:t,children:n}){const r=d.useRef(null),s=d.useRef(null),a=d.useRef(or),i=d.useRef(!1),l=d.useRef(null),c=d.useRef(0),u=d.useRef(0),m=d.useRef(!1),[p,E]=d.useState(0),[y,x]=d.useState(0),[b,f]=d.useState(!1),[_,v]=d.useState(!1),A=d.useMemo(()=>b||t==="bottom"?"auto":e,[b,t,e]),T=()=>{a.current.contentSnapshotHeight=a.current.contentHeight,a.current.shouldUpdate=!0,a.current.shouldRecalc=!0},k=()=>{const P=r.current;!P||!a.current.shouldUpdate||E(q=>{a.current.shouldUpdate=!1;const{contentHeight:ee,contentSnapshotHeight:Ee,shouldRecalc:ie}=a.current,te=P.clientHeight;if(Ee>ee)return q;const be=L(P,{messageType:"outgoing"});let de=0;if(be){const ue=be.message.offsetTop-Kt+te;de=Math.max(0,ue-ee)}else{const ue=ee-Ee,ze=te-Kt;de=Math.max(0,ue-ze)}return q===0||de!==q||ie?(a.current.shouldRecalc=!1,de):q})},L=d.useCallback((P,q)=>{const{messageType:ee="all"}=q??{},Ee=Array.from(P.querySelectorAll(`#${oe}-message-item`));let ie=Ee;ee==="outgoing"&&(ie=Ee.filter(Vt=>Vt.getAttribute("data-layout-id")==="outgoingmessage"));const te=ie[ie.length-1];if(!te)return null;const be=P.getBoundingClientRect(),de=te.getBoundingClientRect(),ue=P.scrollTop+(de.top-be.top),ze=ue+te.offsetHeight;return{message:te,scrollTop:ue,lastMessageBottom:ze}},[]),S=d.useCallback(()=>{const P=r.current;if(!P||A!=="fixed")return;const q=L(P);a.current.contentHeight=(q==null?void 0:q.lastMessageBottom)??P.scrollHeight,!i.current&&a.current.contentSnapshotHeight>0&&T();const ee=Math.max(0,P.scrollHeight-P.scrollTop-P.clientHeight);x(ee),k()},[A,L]),O=d.useCallback(()=>{s.current&&(s.current.disconnect(),s.current=null),a.current=or,E(0),x(0)},[]),U=d.useCallback((P=!0)=>{m.current=!1,Jr(()=>{const q=r.current;q&&q.scrollTo({top:q.scrollHeight,behavior:P?"smooth":"auto"})})},[]),R=d.useCallback(P=>{P&&(r.current=P,A==="fixed"&&(O(),a.current.viewport=P.clientHeight,s.current=new MutationObserver(()=>{S()}),s.current.observe(P,{childList:!0,subtree:!0})))},[A,S,O]),I=d.useCallback(()=>{const P=r.current;if(!P)return;const q=L(P,{messageType:"outgoing"});q&&(P.scrollTo({top:q.message.offsetTop-Kt,behavior:"smooth"}),l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{v(!1)},500))},[L]),H=P=>{const{scrollHeight:q,scrollTop:ee,clientHeight:Ee}=P.currentTarget,ie=Math.max(0,q-ee-Ee),te=u.current,be=ie<=_t,de=ee<te,ue=ee>te;de&&!be&&(m.current=!0),ue&&be&&(m.current=!1),u.current=ee,c.current=ie,x(ie)},D=d.useCallback(()=>{A==="fixed"&&(v(!0),T())},[A]),V=d.useCallback(()=>{A==="fixed"?setTimeout(()=>I(),300):U()},[A,I]),X=d.useCallback(P=>{i.current=P,A==="fixed"?T():m.current||U()},[A,U]),z=d.useCallback(P=>{f(P),P&&(E(0),s.current&&(s.current.disconnect(),s.current=null))},[]),Re=d.useCallback(P=>{A==="auto"&&P&&!m.current&&U()},[A,U]),M=!(y<=_t)&&!_,De=d.useCallback(()=>c.current>_t,[]);return o.createElement(Ji,{value:{ref:R,state:{bottomSpace:p,isAwayFromBottom:M,shouldCountNewMessages:De},props:{onScroll:H},actions:{scrollToBottom:U,onBeforeMessageSend:D,onAfterMessageSend:V,onStreamingUpdate:X,onConversationClosed:z,onTypingIndicatorUpdate:Re}}},n)}const{Provider:tl,Context:nl,useContext:se}=Q("Conversation"),rl=({children:e})=>{var s;const{channelSource:t}=se(),n=(s=t.channel)==null?void 0:s.url,{checkForUserActionRequired:r}=Gi(n);return d.useEffect(()=>{var i;const a=(i=t.channel)==null?void 0:i.lastMessage;a&&r(a)},[t.channel,r]),o.createElement(o.Fragment,null,e)},sl=({channelUrl:e,onClearChannelUrl:t,onNavigateToConversationList:n,shouldMarkAsRead:r,children:s})=>{const{activeChannel:a,refreshActiveChannel:i}=re(),l=Qi(),c=e||(a==null?void 0:a.url);ji(c);const{onBeforeSendMessage:u,onAfterSendMessage:m}=Xi({onScrollAfterSendMessage:()=>{l.actions.onAfterMessageSend()}}),p=d.useCallback(x=>(l.actions.onBeforeMessageSend(),u(x)),[l.actions,u]),E=d.useCallback(x=>{const b=x.some(f=>we.isStreaming(f));l.actions.onStreamingUpdate(b)},[l.actions.onStreamingUpdate]),y=d.useCallback(async()=>{await i(),e&&(t==null||t())},[i,e,t]);return o.createElement(wa,{key:c,channelUrl:c,onBeforeSendMessage:p,onAfterSendMessage:m,onMessagesUpdated:E,onMessagesReceived:E,onChannelDeleted:y,onConversationClosedStatusChanged:l.actions.onConversationClosed,shouldMarkAsRead:r,shouldCountNewMessages:l.state.shouldCountNewMessages},x=>o.createElement(tl,{value:{...x,scrollSource:l,goToActiveConversation:y,onNavigateToConversationList:n}},o.createElement(rl,null,s)))},Qr=({children:e,...t})=>{var i;const{config:n}=pe(),{agentPreviewConfigs:r}=j(),s=((i=n==null?void 0:n.conversation)==null?void 0:i.scrollMode)??"auto",a=r==null?void 0:r.messageStackDirection;return o.createElement(el,{scrollMode:s,messageStackDirection:a},o.createElement(sl,{...t},e))},kn=d.createContext({onDrop:ve,subscribe:()=>ve}),ln=({children:e})=>{const t=d.useRef(new Set);return o.createElement(kn.Provider,{value:{onDrop:n=>{var r;if(n.preventDefault(),(r=n.dataTransfer)!=null&&r.files){const s=Array.from(n.dataTransfer.files);s.length>0&&t.current.forEach(a=>a(s))}},subscribe:n=>(t.current.add(n),()=>t.current.delete(n))}},e)},ol=({onDropFiles:e})=>{const{subscribe:t}=d.useContext(kn);d.useEffect(()=>t(e),[e])};ln.Consumer=({children:e})=>{const{onDrop:t}=d.useContext(kn);return e({onDrop:t,onDragOver:s=>s.preventDefault()})};class Tt extends d.PureComponent{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){const{fallback:t=null,errorFallback:n=t,loadingFallback:r=t,children:s}=this.props;return this.state.hasError?n:o.createElement(d.Suspense,{fallback:r},s)}}const al=e=>o.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 64 64",...e},o.createElement("path",{className:"fill",d:"M52.552 11.448a2.666 2.666 0 0 1 .222 3.52l-.222.251-16.781 16.78 16.781 16.782a2.665 2.665 0 0 1 0 3.771 2.666 2.666 0 0 1-3.52.222l-.251-.222L32 35.771 15.219 52.552a2.665 2.665 0 0 1-3.771 0 2.666 2.666 0 0 1-.222-3.52l.222-.251L28.228 32l-16.78-16.781a2.665 2.665 0 0 1 0-3.771 2.666 2.666 0 0 1 3.52-.222l.251.222 16.78 16.78 16.782-16.78a2.665 2.665 0 0 1 3.771 0z",fill:"#000",fillRule:"evenodd"})),il=e=>o.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",...e},o.createElement("path",{className:"fill",d:"M7.33348 7.3335L2.00015 7.3335L2.00015 6.00016H5.05735L1.3335 2.27631L2.27631 1.3335L6.00015 5.05734V2.00016L7.33348 2.00016L7.33348 7.3335ZM8.66683 8.66683H14.0002V10.0002L10.943 10.0002L14.6668 13.724L13.724 14.6668L10.0002 10.943V14.0002H8.66683L8.66683 8.66683Z",fill:"#000",fillRule:"evenodd"})),ll=e=>o.createElement("svg",{viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",...e},o.createElement("path",{className:"fill",fillRule:"evenodd",clipRule:"evenodd",d:"M2 2H7.33333V3.33333L4.27613 3.33333L7.99999 7.05719L7.05718 8L3.33333 4.27616L3.33333 7.33333H2V2ZM14 14H8.66667V12.6667H11.7239L8.00001 8.94281L8.94282 8L12.6667 11.7238V8.66667H14V14Z",fill:"#000"})),cl=e=>o.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 64 64",fill:"evenodd",...e},o.createElement("path",{className:"fill",fill:"#0D0D0D",d:"M50.667 18.667H13.333v-5.334h37.334zM50.667 34.667H13.333v-5.334h37.334zM13.333 50.667h37.334v-5.334H13.333z"})),dl=e=>o.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 64 64",...e},o.createElement("path",{fill:"#000",fillRule:"evenodd",d:"M59.795 29.43 7.329 2.979C4.691 1.802 1.76 4.153 2.932 6.798l6.925 18.609a2 2 0 0 0 1.544 1.275l32.273 5.394L11.4 37.47a1.998 1.998 0 0 0-1.544 1.275L2.932 57.353c-.879 2.645 1.76 4.997 4.397 3.527l52.466-26.453c2.051-.882 2.051-3.82 0-4.996z",className:"fill"})),ul=new Set(["send","chat","message","chevron-right","good","good-filled","bad","bad-filled"]),ml={close:al,send:dl,menu:cl,expand:ll,collapse:il,spinner:d.lazy(()=>Promise.resolve().then(()=>require("./cjs/Cf3-irI8.cjs"))),chat:d.lazy(()=>Promise.resolve().then(()=>require("./cjs/BmdfYY9c.cjs"))),message:d.lazy(()=>Promise.resolve().then(()=>require("./cjs/CmWLVNPR.cjs"))),error:d.lazy(()=>Promise.resolve().then(()=>require("./cjs/DNmdC4-j.cjs"))),info:d.lazy(()=>Promise.resolve().then(()=>require("./cjs/ohTjxqcW.cjs"))),refresh:d.lazy(()=>Promise.resolve().then(()=>require("./cjs/D00MOxhE.cjs"))),"chevron-down":d.lazy(()=>Promise.resolve().then(()=>require("./cjs/wf-LdaaN.cjs"))),"chevron-right":d.lazy(()=>Promise.resolve().then(()=>require("./cjs/B0k-GApQ.cjs"))),done:d.lazy(()=>Promise.resolve().then(()=>require("./cjs/kp5wcW4s.cjs"))),user:d.lazy(()=>Promise.resolve().then(()=>require("./cjs/CtHfgPDp.cjs"))),"file-document":d.lazy(()=>Promise.resolve().then(()=>require("./cjs/_YfLwFkX.cjs"))),download:d.lazy(()=>Promise.resolve().then(()=>require("./cjs/BN09c8-A.cjs"))),attach:d.lazy(()=>Promise.resolve().then(()=>require("./cjs/DcDTXo8_.cjs"))),delete:d.lazy(()=>Promise.resolve().then(()=>require("./cjs/CKPzhVy2.cjs"))),"close-filled":d.lazy(()=>Promise.resolve().then(()=>require("./cjs/D1kINslt.cjs"))),agent:d.lazy(()=>Promise.resolve().then(()=>require("./cjs/Ce1MzjFq.cjs"))),question:d.lazy(()=>Promise.resolve().then(()=>require("./cjs/JA0x62Fd.cjs"))),actionbook:d.lazy(()=>Promise.resolve().then(()=>require("./cjs/CXa-CGHE.cjs"))),function:d.lazy(()=>Promise.resolve().then(()=>require("./cjs/zbLY6xl_.cjs"))),"radio-on":d.lazy(()=>Promise.resolve().then(()=>require("./cjs/B9NJk4MI.cjs"))),"radio-off":d.lazy(()=>Promise.resolve().then(()=>require("./cjs/Bb0r6Nhu.cjs"))),confluence:d.lazy(()=>Promise.resolve().then(()=>require("./cjs/c6TZaE94.cjs"))),zendesk:d.lazy(()=>Promise.resolve().then(()=>require("./cjs/DqpDy_26.cjs"))),salesforce:d.lazy(()=>Promise.resolve().then(()=>require("./cjs/BsgzT_SF.cjs"))),sprinklr:d.lazy(()=>Promise.resolve().then(()=>require("./cjs/D97ZpKUC.cjs"))),website:d.lazy(()=>Promise.resolve().then(()=>require("./cjs/ygZY2D-5.cjs"))),snippet:d.lazy(()=>Promise.resolve().then(()=>require("./cjs/BCFOnu0u.cjs"))),template:d.lazy(()=>Promise.resolve().then(()=>require("./cjs/eJXfXI1_.cjs"))),source:d.lazy(()=>Promise.resolve().then(()=>require("./cjs/yVmX6iux.cjs"))),bot:d.lazy(()=>Promise.resolve().then(()=>require("./cjs/PhHbzZB_.cjs"))),"bot-filled":d.lazy(()=>Promise.resolve().then(()=>require("./cjs/DlvMdI1f.cjs"))),copy:d.lazy(()=>Promise.resolve().then(()=>require("./cjs/COgkkyBM.cjs"))),show:d.lazy(()=>Promise.resolve().then(()=>require("./cjs/DM-WWpci.cjs"))),mute:d.lazy(()=>Promise.resolve().then(()=>require("./cjs/P_ra76fq.cjs"))),good:d.lazy(()=>Promise.resolve().then(()=>require("./cjs/DEgUVAck.cjs"))),bad:d.lazy(()=>Promise.resolve().then(()=>require("./cjs/C0s7eAf7.cjs"))),"good-filled":d.lazy(()=>Promise.resolve().then(()=>require("./cjs/Chg8xHXT.cjs"))),"bad-filled":d.lazy(()=>Promise.resolve().then(()=>require("./cjs/CGkmTaBn.cjs"))),delight:d.lazy(()=>Promise.resolve().then(()=>require("./cjs/DCB0iTxd.cjs"))),photo:d.lazy(()=>Promise.resolve().then(()=>require("./cjs/GQlGFYP2.cjs"))),"arrow-left":d.lazy(()=>Promise.resolve().then(()=>require("./cjs/CZIjo9nb.cjs"))),add:d.lazy(()=>Promise.resolve().then(()=>require("./cjs/DEGDJBmd.cjs"))),document:d.lazy(()=>Promise.resolve().then(()=>require("./cjs/DBHlAmeA.cjs")))},F=({type:e,size:t=24,className:n,color:r})=>{const s=ml[e];return o.createElement(gl,{className:n,$rtlFlip:ul.has(e),$size:t,$color:r??h.color.primary.main},o.createElement(Tt,{errorFallback:o.createElement(fl,null)},o.createElement(s,null)))},hl=w.css`[dir='rtl'] &{transform:scaleX(-1);}`,gl=g.default.div`width:${({$size:e})=>he(e)};height:${({$size:e})=>he(e)};display:inline-block;&:focus{outline:none;}svg{display:block;}[class*='fill']{fill:${({$color:e})=>e};}[class*='stroke']{stroke:${({$color:e})=>e};stroke-width:2px;stroke-linejoin:round;}${({$rtlFlip:e})=>e&&hl};`,fl=()=>o.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 64 64"},o.createElement("rect",{x:"8",y:"8",width:"48",height:"48",fill:"none",className:"stroke",rx:"4"}),o.createElement("line",{x1:"20",y1:"20",x2:"44",y2:"44",className:"stroke"}),o.createElement("line",{x1:"44",y1:"20",x2:"20",y2:"44",className:"stroke"})),pl=.75,es=6,El=es*2;let cn=null;typeof Intl<"u"&&"Segmenter"in Intl&&(cn=new Intl.Segmenter(void 0,{granularity:"grapheme"}));const bl=e=>cn?Array.from(cn.segment(e),t=>t.segment):[...e],_l=e=>{const t=Math.floor(e.length*pl),n=Math.max(0,e.length-es);return Math.max(t,n)},ar=(e,t="")=>{if(e.length<El)return{start:e+t,end:""};const n=bl(e),r=_l(n);return{start:n.slice(0,r).join(""),end:n.slice(r).join("")+t}},Cl=e=>{const t=e.normalize("NFC").trim(),n=t.lastIndexOf(".");if(!(n>0&&n<t.length-1))return ar(t);const s=t.slice(0,n),a=t.slice(n);return ar(s,a)},ts=({children:e,...t})=>{const{start:n,end:r}=d.useMemo(()=>Cl(e),[e]);return r?o.createElement(xl,null,o.createElement(vl,{...t},n),o.createElement(yl,{...t},r)):o.createElement($,{...t},n)},xl=g.default.span`display:flex;width:100%;min-width:0;overflow:hidden;direction:inherit;`,vl=g.default($)`overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex-shrink:1;min-width:0;`,yl=g.default($)`flex-shrink:0;white-space:nowrap;`,Mn=({name:e,type:t="FILE",iconColor:n,iconBackgroundColor:r,onClick:s})=>{const{colors:a}=w.useTheme();return o.createElement(Sl,{onClick:s,$clickable:!!s},o.createElement(Tl,{$bgColor:r??a.base.primary},o.createElement(F,{type:"file-document",size:24,color:n??a.base.primaryContrastContent})),o.createElement(Il,null,o.createElement(ts,{variant:"button",color:h.themedColor.textHighEmphasis},e),o.createElement($,{color:h.themedColor.textMidEmphasis,variant:"caption3"},t)))},Sl=g.default.div`border-radius:12px;gap:8px;width:${B.BODY_MAX_WIDTH}px;height:64px;display:flex;align-items:center;padding:12px;box-sizing:border-box;border:1px solid ${h.themedColor.textDisabled};background-color:${h.themedColor.bg_50_600};${({$clickable:e})=>e&&Al}`,Al=w.css`cursor:pointer;&:hover{background-color:${h.themedColor.bg_100_500};}`,Tl=g.default.div`border-radius:8px;width:40px;height:40px;display:flex;align-items:center;justify-content:center;background-color:${({$bgColor:e})=>e};`,Il=g.default.div`display:flex;flex:1;flex-direction:column;gap:4px;min-width:0;`;function wl({file:e,children:t,onClickFile:n}){return o.createElement(kl,null,o.createElement(Mn,{name:e.name,type:gn(e.name,e.type),onClick:n&&(()=>n==null?void 0:n(e))}),t)}const kl=g.default.div`display:flex;flex-direction:column;align-items:flex-start;gap:${B.GAP_GROUPED}px;`,ye=`${oe}-incoming-msg`,Ml=`${oe}-marked-text`;function $l({file:e,onClickMedia:t,onClickMediaFiles:n,children:r}){const s=()=>{n?n({files:[{url:e.url,type:e.type,name:e.name}],index:0}):t&&t(e)},a=()=>e.type.startsWith("image")?o.createElement(Rl,{src:e.url,alt:"image-message"}):e.type.startsWith("video")?o.createElement(Dl,{controls:!0},o.createElement("source",{src:e.url}),o.createElement("track",{kind:"captions"})):null;if(a){const i={id:`${ye}-media-body`,onClick:s};return o.createElement(Ll,null,o.createElement(Ol,{...i},a()),r)}return null}const Ll=g.default.div`display:flex;flex-direction:column;align-items:flex-start;gap:${B.GAP_GROUPED}px;`,Ol=g.default.div`width:${B.BODY_MAX_WIDTH}px;height:160px;border-radius:12px;overflow:hidden;cursor:pointer;${N.light`
|
|
53
|
+
background-color: ${h.color.background100};
|
|
54
|
+
`}
|
|
55
|
+
${N.dark`
|
|
56
|
+
background-color: ${h.color.background400};
|
|
57
|
+
`}
|
|
58
|
+
`,Rl=g.default.img`width:100%;height:100%;object-fit:cover;`,Dl=g.default.video`width:100%;height:100%;object-fit:cover;`,at=({className:e,children:t,size:n=26})=>o.createElement(Nl,{className:e,$size:n},t??o.createElement(F,{type:"spinner",size:n})),Nl=g.default.div`display:flex;align-items:center;justify-content:center;width:${({$size:e})=>he(e)};height:${({$size:e})=>he(e)};animation:1s infinite linear;animation-name:rotate;@keyframes rotate{from{transform:rotate(0);}to{transform:rotate(360deg);}}`,It=3,Rt=6,Pl=Rt/It,Fl=It,Bl=Rt,Ul=e=>{const t=e%It;return{gridColumns:t>0?Rt:It,wideBottomCount:t}},ns=({images:e,isPending:t=!1,onClickImage:n})=>{const r=e.length;if(r===0)return null;const{gridColumns:s,wideBottomCount:a=0}=Ul(r);return o.createElement(Vl,{$width:B.BODY_MAX_WIDTH,$columns:s},e.map((i,l)=>{const c=a>0&&l>=r-a;let u=1;return s===Rt&&(c?u=a===1?Bl:Fl:u=Pl),o.createElement(zl,{key:i.url,$clickable:!!n&&!t,$itemSpan:u,$isPending:t,onClick:()=>!t&&(n==null?void 0:n(l))},o.createElement(Hl,{src:i.url,alt:i.name||""}),t&&o.createElement(Gl,null))}))},Hl=({src:e,alt:t})=>{const[n,r]=d.useState(!1),[s,a]=d.useState(!1);return o.createElement(o.Fragment,null,!n&&!s&&o.createElement(Wl,null,o.createElement(at,{size:20},o.createElement(F,{type:"spinner",color:"textLowEmphasis",size:20}))),s?o.createElement(ql,null,o.createElement(F,{type:"photo",color:"textLowEmphasis",size:24})):o.createElement(jl,{src:e,alt:t,$loaded:n,onLoad:()=>r(!0),onError:()=>a(!0)}))},Vl=g.default.div`display:grid;grid-template-columns:repeat(${({$columns:e})=>e},1fr);width:${({$width:e})=>e}px;gap:2px;border-radius:16px;overflow:hidden;`,zl=g.default.div`position:relative;width:100%;aspect-ratio:1;overflow:hidden;cursor:${e=>e.$clickable?"pointer":"default"};${N.light`
|
|
59
|
+
background-color: ${h.color.background100};
|
|
60
|
+
`}
|
|
61
|
+
${N.dark`
|
|
62
|
+
background-color: ${h.color.background400};
|
|
63
|
+
`}
|
|
64
|
+
${e=>e.$itemSpan&&e.$itemSpan>1&&`
|
|
65
|
+
grid-column: span ${e.$itemSpan};
|
|
66
|
+
aspect-ratio: ${e.$itemSpan/2};
|
|
67
|
+
`}
|
|
68
|
+
|
|
69
|
+
&:hover {
|
|
70
|
+
${e=>e.$clickable&&!e.$isPending&&`
|
|
71
|
+
& > img {
|
|
72
|
+
opacity: 0.8;
|
|
73
|
+
}
|
|
74
|
+
`}
|
|
75
|
+
}
|
|
76
|
+
`,Gl=g.default.div`position:absolute;top:0;left:0;width:100%;height:100%;background-color:${h.color.overlay.dark};pointer-events:none;`,rs=g.default.div`display:flex;align-items:center;justify-content:center;`,Wl=g.default(rs)`position:absolute;inset:0;`,ql=g.default(rs)`position:absolute;inset:0;${N.light`
|
|
77
|
+
background-color: ${h.color.background200};
|
|
78
|
+
`}
|
|
79
|
+
${N.dark`
|
|
80
|
+
background-color: ${h.color.background500};
|
|
81
|
+
`}
|
|
82
|
+
`,jl=g.default.img`position:absolute;inset:0;width:100%;height:100%;object-fit:cover;opacity:${({$loaded:e})=>e?1:0};transition:opacity 0.3s ease;`,Kl=({files:e,children:t,onClickMedia:n,onClickMediaFiles:r})=>{const s=a=>{const i=e[a];i&&(r?r({files:e,index:a}):n&&n({url:i.url,type:i.type||"image/*"}))};return o.createElement(Yl,null,o.createElement(ns,{images:e,onClickImage:s}),t)},Yl=g.default.div`display:flex;flex-direction:column;align-items:flex-start;gap:${B.GAP_GROUPED}px;`,Xl="✱",ss=e=>{const t=new RegExp(`(\`+)([^\`]+?)\\1|(${Xl}+)`,"g");return e.replace(t,(n,r,s,a)=>r?n:a?`<span id=${Ml} aria-label="masked-text">${a}</span>`:n)},Zl=e=>e.replace(/\*\*(.*?)\*\*/g,"<b>$1</b>"),ir=e=>{var t;return{files:e.fileInfoList.map(n=>({url:n.url,type:n.mimeType??"",name:n.fileName??""})),metadata:{localFiles:(t=e.messageParams)==null?void 0:t.fileInfoList.map(n=>n.file)}}},Jl=d.lazy(async()=>({default:(await Promise.resolve().then(()=>require("./cjs/D2Opuq0j.cjs"))).MarkdownText})),Ql=d.lazy(async()=>({default:(await Promise.resolve().then(()=>require("./cjs/DlvEEpWX.cjs"))).CodeBlock}));function ec(e){var s,a;const t=e.maxBodyWidth??B.BODY_MAX_WIDTH,n=d.useMemo(()=>no(e.message,ss),[e.message]),r={id:`${ye}-text-body`,$maxWidth:t,$color:(s=e.customStyle)==null?void 0:s.bubbleContentColor,$bgColor:(a=e.customStyle)==null?void 0:a.bubbleBackgroundColor};return n.length===0?e.children?o.createElement(lr,{...r},e.children):null:o.createElement(lr,{...r},n.map((i,l)=>i.type==="text"?o.createElement(cr,{key:l,variant:"body3"},o.createElement(Tt,{fallback:i.value},o.createElement(Jl,{onClickImage:c=>{var u;return(u=e.onClickMedia)==null?void 0:u.call(e,{url:c,type:"image/*"})}},i.value))):i.type==="code"?o.createElement(Tt,{key:l,fallback:o.createElement(cr,{variant:"body3"},i.value)},o.createElement(Ql,{code:i.value,language:i.language})):null),e.children)}const lr=g.default.div`display:flex;flex-direction:column;border-radius:12px;overflow:hidden;min-width:0;max-width:min(${({$maxWidth:e})=>e}px,100%);${({theme:e,$color:t,$bgColor:n})=>w.css`
|
|
83
|
+
color: ${t||e.colors.messageIncoming.text};
|
|
84
|
+
background-color: ${n||e.colors.messageIncoming.background};
|
|
85
|
+
`}
|
|
86
|
+
padding: 12px 0;
|
|
87
|
+
transition: max-width 0.3s;
|
|
88
|
+
overflow-wrap: break-word;
|
|
89
|
+
`,cr=g.default($)`align-items:flex-start;line-height:140%;white-space:pre-wrap;padding:0 12px;`;function os({id:e,src:t,size:n=56,onClick:r,style:s}){return o.createElement(tc,{id:e,tabIndex:0,onClick:r,$size:he(n),style:s},t?o.createElement(nc,{src:t}):o.createElement(F,{type:"user",size:n}))}const tc=g.default.div`border-radius:50%;display:inline-block;overflow:hidden;position:relative;flex-shrink:0;height:${e=>e.$size};width:${e=>e.$size};background-color:${h.themedColor.bg_100_500};&:focus{outline:none;}`,nc=g.default.img`object-fit:cover;width:100%;height:100%;position:absolute;`,rc=({sender:e,isBotMessage:t})=>{const n=`${ye}-sender-avatar`;return t&&!e.profileUrl?o.createElement(sc,{id:n},o.createElement(F,{type:"delight",size:"100%"})):o.createElement(os,{id:n,size:B.AVATAR_SIZE,src:e.profileUrl})},sc=g.default.div`flex-shrink:0;width:${B.AVATAR_SIZE}px;height:${B.AVATAR_SIZE}px;box-sizing:border-box;padding:4px;border-radius:50%;display:flex;justify-content:center;align-items:center;background-color:${({theme:e})=>e.colors.base.primary}!important;ellipse,path{fill:${({theme:e})=>e.colors.base.primaryContrastContent}!important;}}`,oc=({sender:e})=>o.createElement(ac,{id:`${ye}-sender-name`,variant:"caption1",color:h.themedColor.textMidEmphasis},e.nickname),ac=g.default($)`text-align:start;width:100%;box-sizing:border-box;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding-block:5px;padding-inline:0 7px;`,ic=({createdAt:e})=>{const{stringSet:t,format:n}=W();return e?o.createElement($,{id:`${ye}-sent-time`,variant:"caption4",color:h.themedColor.textLowEmphasis},n(e,t.DATE_FORMAT__MESSAGE_TIMESTAMP)):null},lc=({customStyle:e})=>o.createElement(cc,{$bgColor:e==null?void 0:e.bubbleBackgroundColor},[0,1,2].map(t=>o.createElement(dc,{key:t,$color:e==null?void 0:e.bubbleContentColor}))),cc=g.default.div`align-items:center;border-radius:12px;display:flex;gap:6px;justify-content:center;padding:16px 12px;background-color:${({theme:e,$bgColor:t})=>t||e.colors.messageIncoming.background};`,dc=g.default.span`animation:blink 1.4s infinite;animation-fill-mode:both;border-radius:50%;height:8px;width:8px;background:${({theme:e,$color:t})=>t||e.colors.messageIncoming.text};@keyframes blink{0%{opacity:0.12;transform:scale(1);}21.43%{opacity:0.38;transform:scale(1.2);}42.86%{opacity:0.12;transform:scale(1);}100%{opacity:0.12;transform:scale(1);}}&:nth-child(1){animation-delay:0.4s;}&:nth-child(2){animation-delay:0.6s;}&:nth-child(3){animation-delay:0.8s;}`,uc=({extendedMessagePayload:e,onClickCTA:t=({url:n})=>wn(n)})=>{const n=e==null?void 0:e.cta_button;return n?o.createElement(mc,{id:`${ye}-ext-cta-button`,role:"button",onClick:()=>t(n)},o.createElement(hc,{variant:"button"},n.label)):null},mc=g.default.div`display:flex;align-items:center;justify-content:center;cursor:pointer;border-radius:6px;padding:8px;color:${h.themedColor.textHighEmphasis};background-color:${h.color.background50};${N.dark`
|
|
90
|
+
background-color: ${h.color.ondark.textDisabled};
|
|
91
|
+
`}
|
|
92
|
+
`,hc=g.default($)`overflow:hidden;text-overflow:ellipsis;white-space:nowrap;`,gc=({extendedMessagePayload:e,onClickCitation:t=n=>wn(n.link)})=>{const{stringSet:n}=W(),{theme:r}=yn(),s=e==null?void 0:e.citations;return!s||s.length===0?null:o.createElement(fc,{id:`${ye}-ext-citation`},o.createElement(pc,{variant:"caption1",color:r.colors.messageIncoming.text},n.CITATION_SOURCE_TITLE),o.createElement(Ec,null,s.map((a,i)=>o.createElement(_c,{key:`${a.embedding_id}-${i}`,role:"button",onClick:()=>t(a)},o.createElement(F,{type:"source",size:16,color:r.colors.messageIncoming.text}),o.createElement(bc,{variant:"body3",color:r.colors.messageIncoming.text},a.title)))))},fc=g.default.div`display:flex;flex-direction:column;gap:8px;border-radius:8px;padding:8px 12px 6px;`,pc=g.default($)`opacity:0.5;`,Ec=g.default.div`display:flex;flex-direction:column;gap:8px;`,bc=g.default($)`text-decoration:underline;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;`,_c=g.default.div`display:flex;align-items:center;gap:4px;cursor:pointer;&:hover{opacity:0.5;}`,Cc=e=>o.createElement(o.Fragment,null),xc=({visible:e,onClose:t,children:n})=>o.createElement(Ot,{rootElementId:ce.WINDOW,visible:e,onClose:t},o.createElement(Ac,null,n)),vc=({onClick:e,destructive:t,icon:n,children:r})=>o.createElement(yc,{onClick:e,$destructive:t},n&&o.createElement(Sc,null,o.createElement(F,{type:n,size:24,color:h.themedColor.primary})),r),ke=Object.assign(xc,{ActionItem:vc}),yc=g.default.button`all:unset;display:flex;align-items:center;gap:24px;width:100%;padding:12px 24px;cursor:pointer;color:${({$destructive:e})=>e?h.themedColor.error:h.themedColor.textHighEmphasis};`,Sc=g.default.div`display:flex;align-items:center;justify-content:center;flex-shrink:0;`,Ac=g.default.div`position:absolute;left:0;right:0;bottom:0;border-radius:12px 12px 0 0;flex-direction:column;align-items:flex-end;margin:0 auto;box-sizing:border-box;background-color:${({theme:e})=>e.colors.base.modalContentBackground};`,dn=e=>`${e}-filled`,Tc=e=>e==="good"?J.AIAgentMessageFeedbackRating.GOOD:J.AIAgentMessageFeedbackRating.BAD,as=w.css`&:hover{opacity:0.8;}&:active{opacity:0.6;}`,dr={good:h.themedColor.secondary,bad:h.themedColor.error},Ic=({visible:e,onClose:t,isEdit:n,initialRating:r,initialComment:s="",onSubmit:a,isCommentEnabled:i=!1})=>{const{stringSet:l}=W(),[c,u]=d.useState(r),[m,p]=d.useState(s);d.useLayoutEffect(()=>{e?(u(r),p(s)):(u(void 0),p(""))},[e,r,s]);const E=()=>{c&&(a({rating:c,comment:m.trim()||void 0}),t())},y=()=>{t()};return e?o.createElement(Ot,{rootElementId:ce.WINDOW,visible:e,onClose:y},o.createElement(wc,null,o.createElement(kc,null,o.createElement($,{variant:"h2",color:h.themedColor.textHighEmphasis},l.FEEDBACK_TITLE)),o.createElement(Mc,null,o.createElement($c,null,["good","bad"].map(x=>{const b=c===x,f=x==="good"?l.FEEDBACK_GOOD:l.FEEDBACK_BAD;return o.createElement(Lc,{key:x,$selected:b,$rating:x,onClick:()=>u(x)},o.createElement(F,{type:b?dn(x):x,size:24,color:b?dr[x]:h.themedColor.textLowEmphasis}),o.createElement($,{variant:"caption1",color:b?dr[x]:h.themedColor.textLowEmphasis},f))})),i&&o.createElement(Oc,null,o.createElement($,{variant:"caption3",color:h.themedColor.textHighEmphasis},l.FEEDBACK_COMMENT_LABEL),o.createElement(Rc,{placeholder:l.FEEDBACK_COMMENT_PLACEHOLDER,value:m,onChange:x=>p(x.target.value),maxLength:100}))),o.createElement(Dc,null,o.createElement(Nc,{onClick:y},o.createElement($,{variant:"button",color:h.themedColor.textHighEmphasis},l.FEEDBACK_CANCEL)),o.createElement(Pc,{onClick:E,disabled:!c},o.createElement($,{variant:"button"},n?l.FEEDBACK_SAVE:l.FEEDBACK_SUBMIT))))):null},wc=g.default.div`width:280px;background-color:${({theme:e})=>e.colors.base.modalContentBackground};border-radius:12px;overflow:hidden;`,kc=g.default.div`padding:24px;`,Mc=g.default.div`padding-inline:24px;display:flex;flex-direction:column;gap:24px;`,$c=g.default.div`display:flex;gap:4px;`,Lc=g.default.button`width:114px;height:64px;border-radius:12px;border:1px solid ${h.themedColor.textDisabled};box-sizing:border-box;cursor:pointer;display:flex;flex-direction:column;align-items:center;justify-content:center;padding:0;gap:0;transition:background-color 0.2s;background-color:${({$selected:e})=>e?h.color.background100:"transparent"};${({$selected:e})=>N.dark`
|
|
93
|
+
background-color: ${e?h.color.background600:"transparent"};
|
|
94
|
+
`}
|
|
95
|
+
|
|
96
|
+
&:hover {
|
|
97
|
+
opacity: 0.8;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
&:active {
|
|
101
|
+
opacity: 0.6;
|
|
102
|
+
}
|
|
103
|
+
`,Oc=g.default.div`display:flex;flex-direction:column;gap:6px;`,Rc=g.default.textarea`font-family:inherit;font-size:12px;line-height:16px;border:1px solid ${h.themedColor.textDisabled};border-radius:4px;padding:6px 12px;color:${h.themedColor.textHighEmphasis};background-color:${h.themedColor.textLowEmphasisInverse};resize:none;field-sizing:content;min-height:28px;max-height:118px;overflow-y:auto;&::placeholder{color:${h.themedColor.textLowEmphasis};}&:focus{outline:none;}`,Dc=g.default.div`padding-inline:24px;padding-block:16px;display:flex;justify-content:flex-end;gap:4px;`,is=g.default.button`width:86px;height:40px;border-radius:20px;border:none;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:opacity 0.2s;`,Nc=g.default(is)`${as}`,Pc=g.default(is)`cursor:${({disabled:e})=>e?"not-allowed":"pointer"};opacity:${({disabled:e})=>e?.4:1};&:hover:not(:disabled){opacity:0.8;}&:active:not(:disabled){opacity:0.6;}background-color:${({theme:e})=>e.colors.base.primary};span{color:${({theme:e})=>e.colors.base.primaryContrastContent};}`,ur={good:h.themedColor.secondary,bad:h.themedColor.error},Fc=({isBotMessage:e,isConversationClosed:t,isStreaming:n,isFeedbackEnabled:r,isFeedbackCommentEnabled:s,extendedMessagePayload:a,onFeedbackUpdate:i})=>{const{stringSet:l}=W(),[c,u]=d.useState(!1),[m,p]=d.useState(!1),[E,y]=d.useState(void 0),[x,b]=d.useState(""),f=a==null?void 0:a.feedback,_=(f==null?void 0:f.rating)??"none";if(_!=="none"?!1:!!(n||!e||!r||(a==null?void 0:a.bot_message_type)!=="generated"||t))return null;const A=S=>{_==="none"?(y(S),b(""),u(!0)):p(!0)},T=()=>{i==null||i(null),p(!1)},k=()=>{p(!1),y(f==null?void 0:f.rating),b((f==null?void 0:f.comment)??""),u(!0)},L=S=>{i==null||i(S)};return t&&_!=="none"?o.createElement(mr,{$horizontal:!0},o.createElement(Bc,null,o.createElement(F,{type:dn(_),size:12,color:ur[_]})),(f==null?void 0:f.comment)&&o.createElement(hr,{variant:"caption2",style:{lineHeight:"16px"}},f.comment)):o.createElement(o.Fragment,null,o.createElement(mr,null,o.createElement(Uc,null,["good","bad"].map(S=>{const O=_===S;return o.createElement(Hc,{key:S,$selected:O,$rating:S,onClick:()=>A(S)},o.createElement(F,{type:O?dn(S):S,size:14,color:O?ur[S]:h.themedColor.textMidEmphasis}))})),_!=="none"&&(f==null?void 0:f.comment)&&o.createElement(hr,{variant:"caption2"},f.comment)),o.createElement(ke,{visible:m,onClose:()=>p(!1)},o.createElement(ke.ActionItem,{onClick:k},l.FEEDBACK_EDIT),o.createElement(ke.ActionItem,{onClick:T,destructive:!0},l.FEEDBACK_REMOVE)),o.createElement(Ic,{visible:c,onClose:()=>u(!1),isEdit:_!=="none",initialRating:E,initialComment:x,onSubmit:L,isCommentEnabled:s}))},mr=g.default.div`display:flex;flex-direction:${({$horizontal:e})=>e?"row":"column"};align-items:${({$horizontal:e})=>e?"flex-start":"stretch"};gap:4px;margin-top:8px;word-break:break-word;max-width:${B.BODY_MAX_WIDTH}px;`,Bc=g.default.div`padding:2px;flex-shrink:0;display:flex;align-items:center;`,Uc=g.default.div`display:flex;gap:2px;`,Hc=g.default.button`width:38px;height:20px;border-radius:18px;cursor:pointer;display:flex;align-items:center;justify-content:center;padding:0;transition:opacity 0.2s;border:1px solid ${h.color.background200};background-color:${({$selected:e})=>e?h.color.background100:"transparent"};${({$selected:e})=>N.dark`
|
|
104
|
+
border: 1px solid ${h.color.background400};
|
|
105
|
+
background-color: ${e?h.color.background500:"transparent"};
|
|
106
|
+
`}
|
|
107
|
+
|
|
108
|
+
${as}
|
|
109
|
+
`,hr=g.default($)`color:${h.themedColor.textMidEmphasis};${N.dark`
|
|
110
|
+
color: ${h.themedColor.textHighEmphasis};
|
|
111
|
+
`}
|
|
112
|
+
`,$n=w.css`width:100%;height:36px;border-radius:6px;cursor:pointer;transition:all 0.2s ease;padding:0 12px;border:none;outline:none;display:flex;align-items:center;justify-content:center;&:disabled{cursor:not-allowed;}`,gr=g.default.button`${$n};background-color:${h.themedColor.primary};color:${h.themedColor.textHighEmphasis};&:hover:not(:disabled){opacity:0.9;}`,Vc=g.default.button`${$n};color:${h.themedColor.primary};${N.light`
|
|
113
|
+
background-color: ${h.color.background50};
|
|
114
|
+
`};
|
|
115
|
+
${N.dark`
|
|
116
|
+
background-color: ${h.color.background700};
|
|
117
|
+
`};
|
|
118
|
+
|
|
119
|
+
&:hover:not(:disabled) {
|
|
120
|
+
opacity: 0.9;
|
|
121
|
+
}
|
|
122
|
+
`,zc=g.default.button`${$n};background-color:transparent;color:${h.themedColor.textHighEmphasis};&:hover:not(:disabled){opacity:0.7;}`,Gc=e=>{switch(e){case"primary":return gr;case"secondary":return Vc;case"clear":return zc;default:return gr}},Wc=g.default.div`animation:1s infinite linear;animation-name:rotate;display:flex;align-items:center;justify-content:center;@keyframes rotate{from{transform:rotate(0);}to{transform:rotate(360deg);}}`,qc=({children:e,onClick:t,variant:n="primary",disabled:r=!1,loading:s=!1,className:a})=>{const i=()=>{switch(n){case"primary":return h.themedColor.textHighEmphasisInverse;case"secondary":return h.themedColor.primary;case"clear":return h.themedColor.textHighEmphasis;default:return h.themedColor.textHighEmphasisInverse}},l=Gc(n);return o.createElement(l,{onClick:t,disabled:r||s,className:a},s?o.createElement(Wc,null,o.createElement(F,{type:"spinner",size:22,color:i()})):o.createElement($,{variant:"button",color:i()},e))},jc=({children:e,className:t,style:n})=>o.createElement($,{variant:"caption4",color:h.themedColor.error,className:t,style:n},e),Kc=({children:e,className:t,style:n,required:r})=>{const{stringSet:s}=W();return o.createElement($,{variant:"caption3",color:h.themedColor.textMidEmphasis,className:t,style:n},e,!r&&o.createElement("span",{style:{color:h.themedColor.textLowEmphasis}},` (${s.OPTIONAL})`))},Yc=({value:e,onChange:t,placeholder:n,error:r=!1,submitted:s=!1,className:a,disabled:i=!1,max:l})=>{const c=m=>{const E=m.target.value.replace(/[^0-9.-]/g,""),y=E.split("."),b=y.length>1?y[0]+"."+y.slice(1).join("").replace(/\./g,""):E;if(m.target.value=b,b===""||b==="-")t==null||t(null);else{const f=Number(b);if(!isNaN(f)){if(l!==void 0&&f>l)return;t==null||t(f)}}},u=e==null?"":String(e);return o.createElement(ed,{type:"text",value:u,onChange:c,placeholder:n,className:a,disabled:i||s,inputMode:"decimal",$error:r,$submitted:s})},Xc=w.css`width:100%;height:36px;padding:8px 12px;border-radius:6px;font-size:14px;font-weight:400;line-height:1.43;outline:none;transition:all 0.2s ease;&::placeholder{color:${h.themedColor.textLowEmphasis};}&::-webkit-inner-spin-button,&::-webkit-outer-spin-button{-webkit-appearance:none;margin:0;}`,Zc=w.css`color:${h.themedColor.textHighEmphasis};border:1px solid transparent;cursor:not-allowed;${N.light`
|
|
123
|
+
background-color: ${h.color.ondark.textMidEmphasis};
|
|
124
|
+
`}
|
|
125
|
+
${N.dark`
|
|
126
|
+
background-color: ${h.color.onlight.textLowEmphasis};
|
|
127
|
+
`}
|
|
128
|
+
|
|
129
|
+
&::placeholder {
|
|
130
|
+
color: ${h.themedColor.textLowEmphasis};
|
|
131
|
+
}
|
|
132
|
+
`,Jc=w.css`border:1px solid ${h.themedColor.error};color:${h.themedColor.textHighEmphasis};${N.light`
|
|
133
|
+
background-color: ${h.color.background50};
|
|
134
|
+
`}
|
|
135
|
+
${N.dark`
|
|
136
|
+
background-color: ${h.color.onlight.textLowEmphasis};
|
|
137
|
+
`}
|
|
138
|
+
`,Qc=w.css`border:1px solid ${h.themedColor.textDisabled};color:${h.themedColor.textHighEmphasis};${N.light`
|
|
139
|
+
background-color: ${h.color.background50};
|
|
140
|
+
`}
|
|
141
|
+
${N.dark`
|
|
142
|
+
background-color: ${h.color.onlight.textLowEmphasis};
|
|
143
|
+
`}
|
|
144
|
+
|
|
145
|
+
&:focus {
|
|
146
|
+
border-color: ${h.themedColor.primary};
|
|
147
|
+
}
|
|
148
|
+
`,ed=g.default.input`${Xc}${({$error:e,$submitted:t})=>t?Zc:e?Jc:Qc}`,td=e=>{if(e.multiple){const{value:t=[],onChange:n,maxSelect:r,submitted:s=!1}=e;return{selectedValues:t,handleOptionClick:i=>{if(s)return;if(t.includes(i)){const c=t.filter(u=>u!==i);n==null||n(c)}else{if(r&&t.length>=r)return;const c=[...t,i];n==null||n(c)}}}}else{const{value:t,onChange:n,submitted:r=!1}=e;return{selectedValues:t?[t]:[],handleOptionClick:a=>{if(r)return;const i=t===a?"":a;n==null||n(i)}}}},ls=e=>{const{options:t,submitted:n=!1,error:r=!1,className:s}=e,{selectedValues:a,handleOptionClick:i}=td(e);return o.createElement(rd,{className:s},t.map(l=>{const c=a.includes(l.value);return o.createElement(dd,{key:l.value,$active:c,$submitted:n,$error:r,onClick:()=>i(l.value)},o.createElement($,{variant:"caption1",color:nd(c,n)},l.label))}))},nd=(e,t)=>t?e?h.themedColor.textHighEmphasis:h.themedColor.textDisabled:e?h.themedColor.primary:h.themedColor.textMidEmphasis,rd=g.default.div`display:flex;flex-wrap:wrap;gap:4px 2px;`,sd=w.css`display:inline-flex;align-items:center;padding:8px 12px;border-radius:15px;transition:all 0.2s ease;`,od=w.css`cursor:default;background-color:${h.color.ondark.textMidEmphasis};color:${h.themedColor.textHighEmphasis};${N.dark`
|
|
149
|
+
background-color: transparent;
|
|
150
|
+
border: 1px solid white;
|
|
151
|
+
color: white;
|
|
152
|
+
`}
|
|
153
|
+
`,ad=w.css`cursor:default;${N.light`
|
|
154
|
+
background-color: ${h.color.ondark.textMidEmphasis};
|
|
155
|
+
color: ${h.themedColor.textDisabled};
|
|
156
|
+
`}
|
|
157
|
+
${N.dark`
|
|
158
|
+
background-color: ${h.color.onlight.textLowEmphasis};
|
|
159
|
+
border: 1px solid ${h.color.onlight.textLowEmphasis};
|
|
160
|
+
color: ${h.themedColor.textDisabled};
|
|
161
|
+
`}
|
|
162
|
+
`,id=w.css`cursor:pointer;border:1px solid ${h.themedColor.primary};${N.light`
|
|
163
|
+
background-color: ${h.color.background50};
|
|
164
|
+
color: ${h.themedColor.primary};
|
|
165
|
+
`}
|
|
166
|
+
${N.dark`
|
|
167
|
+
background-color: ${h.color.onlight.textLowEmphasis};
|
|
168
|
+
color: ${h.themedColor.primary};
|
|
169
|
+
`}
|
|
170
|
+
`,ld=w.css`cursor:pointer;border:1px solid ${h.themedColor.textDisabled};${N.light`
|
|
171
|
+
background-color: ${h.color.background50};
|
|
172
|
+
color: ${h.themedColor.textMidEmphasis};
|
|
173
|
+
`}
|
|
174
|
+
${N.dark`
|
|
175
|
+
background-color: ${h.color.onlight.textLowEmphasis};
|
|
176
|
+
color: ${h.themedColor.textMidEmphasis};
|
|
177
|
+
`}
|
|
178
|
+
`,cd=w.css`border-color:${h.themedColor.error}!important;`,dd=g.default.div`${sd}${({$active:e,$submitted:t,$error:n})=>{if(t)return e?od:ad;const r=e?id:ld;return n?w.css`
|
|
179
|
+
${r} ${cd}
|
|
180
|
+
`:r}}
|
|
181
|
+
`,ud=e=>o.createElement(ls,{...e,multiple:!1}),md=e=>o.createElement(ls,{...e,multiple:!0}),hd=g.default.div`width:100%;height:1px;background-color:${h.themedColor.textDisabled};`,gd=({className:e})=>o.createElement(hd,{className:e}),fd=({value:e="",onChange:t,placeholder:n,variant:r="single-line",error:s=!1,submitted:a=!1,className:i,disabled:l=!1,maxLength:c})=>{const m={value:e,onChange:p=>{const E=p.target.value;c&&E.length>c||t==null||t(E)},placeholder:n,className:i,disabled:l||a,maxLength:c,$error:s,$submitted:a};return r==="multi-line"?o.createElement(Ed,{...m}):o.createElement(pd,{...m})},cs=w.css`width:100%;padding:8px 12px;border-radius:6px;font-size:14px;font-weight:400;line-height:1.43;outline:none;transition:all 0.2s ease;&::placeholder{color:${h.themedColor.textLowEmphasis};}`,ds=w.css`color:${h.themedColor.textHighEmphasis};border:1px solid transparent;cursor:not-allowed;${N.light`
|
|
182
|
+
background-color: ${h.color.ondark.textMidEmphasis};
|
|
183
|
+
`}
|
|
184
|
+
${N.dark`
|
|
185
|
+
background-color: ${h.color.onlight.textLowEmphasis};
|
|
186
|
+
`}
|
|
187
|
+
|
|
188
|
+
&::placeholder {
|
|
189
|
+
color: ${h.themedColor.textLowEmphasis};
|
|
190
|
+
}
|
|
191
|
+
`,us=w.css`border:1px solid ${h.themedColor.error};color:${h.themedColor.textHighEmphasis};${N.light`
|
|
192
|
+
background-color: ${h.color.background50};
|
|
193
|
+
`}
|
|
194
|
+
${N.dark`
|
|
195
|
+
background-color: ${h.color.onlight.textLowEmphasis};
|
|
196
|
+
`}
|
|
197
|
+
`,ms=w.css`border:1px solid ${h.themedColor.textDisabled};color:${h.themedColor.textHighEmphasis};${N.light`
|
|
198
|
+
background-color: ${h.color.background50};
|
|
199
|
+
`}
|
|
200
|
+
${N.dark`
|
|
201
|
+
background-color: ${h.color.onlight.textLowEmphasis};
|
|
202
|
+
`}
|
|
203
|
+
|
|
204
|
+
&:focus {
|
|
205
|
+
border-color: ${h.themedColor.primary};
|
|
206
|
+
}
|
|
207
|
+
`,pd=g.default.input`${cs};height:36px;${({$error:e,$submitted:t})=>t?ds:e?us:ms}`,Ed=g.default.textarea`${cs};height:96px;resize:none;font-family:inherit;${({$error:e,$submitted:t})=>t?ds:e?us:ms}`,bd=({children:e,className:t,style:n})=>o.createElement($,{variant:"button",color:h.themedColor.textHighEmphasis,className:t,style:n},e),Z={Title:bd,Label:Kc,ErrorLabel:jc,Separator:gd,Button:qc,TextInput:fd,NumberInput:Yc,SingleSelect:ud,MultiSelect:md},_d=1,Cd=new Set(["text","number","single-select","multi-select"]),xd=e=>{var f;const t=(f=e.extendedMessagePayload)==null?void 0:f.form;if(!t)throw new Error("Form is not provided");const{stringSet:n}=W(),[r,s]=d.useState({submitting:!1,canceling:!1}),[a,i]=d.useState({visible:!1}),{state:l,fields:c,submit:u,cancel:m,updateFieldValue:p}=Xa(t,{labels:{required:n.FORM_VALIDATION_REQUIRED,regex:n.FORM_VALIDATION_REGEX_FAILED,minLength:n.FORM_VALIDATION_MIN_LENGTH,maxLength:n.FORM_VALIDATION_MAX_LENGTH,min:n.FORM_VALIDATION_MIN,max:n.FORM_VALIDATION_MAX,minSelect:n.FORM_VALIDATION_MIN_SELECT,maxSelect:n.FORM_VALIDATION_MAX_SELECT},onSubmit:_=>{var v;return(v=e.onSubmitForm)==null?void 0:v.call(e,{key:t.key,data:_})},onCancel:()=>{var _;return(_=e.onCancelForm)==null?void 0:_.call(e,{key:t.key})}}),E=l==="submitted",y=async()=>{s(_=>({..._,submitting:!0}));try{await u()}catch(_){i({visible:!0,description:_ instanceof Error?_.message:n.TRY_AGAIN})}finally{s(_=>({..._,submitting:!1}))}},x=async()=>{s(_=>({..._,canceling:!0}));try{await m()}catch(_){i({visible:!0,description:_ instanceof Error?_.message:n.TRY_AGAIN})}finally{s(_=>({..._,canceling:!1}))}},b=d.useMemo(()=>{const _=()=>t.version>_d,v=()=>t.fields.some(A=>!Cd.has(A.type));return _()||v()?{visible:!1,cancelable:!0,reason:n.FORM_NOT_SUPPORTED}:l==="draft"&&(e.isHandedOff||e.isConversationClosed)?{visible:!1,cancelable:!1,reason:n.FORM_UNAVAILABLE}:{visible:!0,cancelable:!0,reason:""}},[t.version,t.fields,l,e.isHandedOff,e.isConversationClosed]);return l==="canceled"?null:b.visible?o.createElement(d.Fragment,null,o.createElement(fr,{$maxWidth:e.maxBodyWidth??B.BODY_MAX_WIDTH},o.createElement(Z.Title,null,t.title),o.createElement(vd,null,c.map(_=>o.createElement(yd,{key:_.key},o.createElement(Z.Label,{style:{marginBottom:"6px"},required:_.required},_.label),_.type==="text"&&o.createElement(Z.TextInput,{value:_.value||"",placeholder:_.placeholder,onChange:v=>p(_.key,v),disabled:E,error:!!_.error,submitted:E,variant:_.layout==="multiline"?"multi-line":"single-line",maxLength:_.maxLength}),_.type==="number"&&o.createElement(Z.NumberInput,{value:_.value||null,placeholder:_.placeholder,onChange:v=>p(_.key,v),disabled:E,error:!!_.error,submitted:E,max:_.max}),_.type==="single-select"&&o.createElement(Z.SingleSelect,{options:_.options.map(v=>({label:v,value:v})),value:_.value||"",onChange:v=>p(_.key,v),submitted:E}),_.type==="multi-select"&&o.createElement(Z.MultiSelect,{options:_.options.map(v=>({label:v,value:v})),value:_.value||[],onChange:v=>p(_.key,v),submitted:E,maxSelect:_.maxSelect}),_.error&&o.createElement(Z.ErrorLabel,{style:{marginTop:"4px"}},_.error)))),o.createElement(Z.Separator,null),o.createElement(Sd,null,o.createElement(Z.Button,{variant:E?"clear":"primary",onClick:y,disabled:E||r.canceling,loading:r.submitting},E?n.SUBMITTED:n.BUTTON__SUBMIT),l!=="submitted"&&o.createElement(Z.Button,{variant:"secondary",onClick:x,disabled:r.submitting,loading:r.canceling},n.BUTTON__CANCEL))),o.createElement(In,{...a,onClose:()=>i({visible:!1,title:""})})):o.createElement(fr,{$maxWidth:e.maxBodyWidth??B.BODY_MAX_WIDTH},o.createElement($,{variant:"body3"},b.reason),b.cancelable&&o.createElement(Z.Button,{variant:"primary",onClick:x,loading:r.canceling},n.BUTTON__CANCEL))},fr=g.default.div`display:flex;flex-direction:column;gap:12px;border-radius:12px;overflow:hidden;max-width:${({$maxWidth:e})=>e}px;${({theme:e})=>w.css`
|
|
208
|
+
color: ${e.colors.messageIncoming.text};
|
|
209
|
+
background-color: ${e.colors.messageIncoming.background};
|
|
210
|
+
`}
|
|
211
|
+
padding: 16px 12px;
|
|
212
|
+
transition: max-width 0.3s;
|
|
213
|
+
overflow-wrap: break-word;
|
|
214
|
+
`,vd=g.default.div`display:flex;flex-direction:column;gap:12px;`,yd=g.default.div`display:flex;flex-direction:column;`,Sd=g.default.div`display:flex;flex-direction:column;gap:8px;`,Ad=e=>o.createElement(o.Fragment,null),Td=new Set(["default"]),{MessageTemplate:Id}=Ks.createMessageTemplate({parser:Jt.parser,renderer:Jt.renderer,Container:e=>o.createElement("div",{...e})}),wd=e=>o.createElement(Tt,{errorFallback:e.messageTemplateErrorFallback,loadingFallback:e.messageTemplateLoadingFallback},o.createElement(kd,{...e})),kd=({extendedMessagePayload:e,onGetCachedMessageTemplate:t=()=>null,onRequestMessageTemplate:n,onHandleTemplateInternalAction:r=ve})=>{const s=e==null?void 0:e.message_template;if(!Td.has((s==null?void 0:s.type)??"default"))throw new Error("Unsupported template type");if(!n)throw new Error("onRequestMessageTemplate is required");const i=s==null?void 0:s.key;if(!i)throw new Error("Template key is missing");const{theme:l}=jr(),c=Ua({onRequestTemplate:n,onGetCachedTemplate:t,theme:l.selectedTheme,templateKey:i,variables:s==null?void 0:s.variables,viewVariables:s==null?void 0:s.view_variables,aiAgentColorVariables:l.aiAgentColorVariables});return o.createElement(Md,{id:`${ye}-ext-message-template`},o.createElement(Jt.MessageProvider,{handleInternalAction:(u,m)=>{u.stopPropagation(),r==null||r(m)}},o.createElement(Id,{templateItems:c.body.items,templateVersion:c.version})))},Md=g.default.div`box-sizing:border-box;overflow:hidden;width:100%;`,$d=({extendedMessagePayload:e,onClickSuggestedReply:t,suggestedRepliesDirection:n="vertical"})=>{const[r,s]=d.useState(!1),a=(e==null?void 0:e.suggested_replies)??[];return a.length===0||r?null:o.createElement(Ld,{id:`${ye}-ext-suggested-replies`,$type:n},a.map((i,l)=>o.createElement(Od,{key:l,$type:n,variant:"body3",onClick:()=>{t&&(t==null||t({reply:i}),s(!0))}},i)))},Ld=g.default.div`margin:16px 0;padding:0 ${B.HORIZONTAL_PADDING}px;position:relative;display:flex;align-self:stretch;gap:8px;${({$type:e})=>e==="vertical"?Rd:Dd};`,Od=g.default($)`box-sizing:border-box;padding:8px 12px;display:flex;align-items:center;border-radius:20px / clamp(20px,5%,100px);cursor:pointer;word-break:break-word;color:${h.color.primary.main};border:1px solid ${h.color.primary.main};background-color:${h.themedColor.bg_50_600};&:hover{background-color:${h.themedColor.bg_100_500};}${({$type:e,theme:t})=>w.css`
|
|
215
|
+
${e==="vertical"?Nd:Pd};
|
|
216
|
+
&:active {
|
|
217
|
+
background-color: ${t.colors.base.primary};
|
|
218
|
+
color: ${t.colors.base.primaryContrastContent};
|
|
219
|
+
}
|
|
220
|
+
`}
|
|
221
|
+
`,Rd=w.css`flex-direction:column;align-items:flex-end;`,Dd=w.css`flex-direction:row;overflow-x:scroll;-ms-overflow-style:none;scrollbar-width:none;&::-webkit-scrollbar{display:none;}`,Nd=w.css`max-width:calc(100% - 70px);white-space:pre-wrap;`,Pd=w.css`white-space:nowrap;`,Fd=e=>{const{components:t}=Oe.useContext(),{stringSet:n}=W(),r=Mr(e)?o.createElement(t.TextMessageBody,{...e}):null;if(e.messageType==="user")return r;if(e.messageType==="file"){const s=e.file;return s.type.startsWith("image")||s.type.startsWith("video")?o.createElement(t.MediaMessageBody,{...e},r):o.createElement(t.FileMessageBody,{...e},r)}return e.messageType==="multipleFiles"?o.createElement(t.MultipleFilesMessageBody,{...e},r):o.createElement(t.TextMessageBody,{...e,message:n.UNKNOWN__UNKNOWN_MESSAGE_TYPE})},Bd=e=>o.createElement(hs,{...e,testerMode:!1}),Oe=fe({template:Bd,components:{SenderName:oc,SenderAvatar:rc,SentTime:ic,MessageBody:Fd,TextMessageBody:ec,MediaMessageBody:$l,FileMessageBody:wl,MultipleFilesMessageBody:Kl,TypingIndicator:lc,SuggestedReplies:$d,MessageTemplate:wd,CustomMessageTemplate:Cc,CTAButton:uc,Citation:gc,Form:xd,Feedback:Fc,MessageLogs:Ad}}),hs=e=>{var f,_,v,A,T,k,L;const{components:t}=Oe.useContext(),{streamText:n,isAnimating:r}=ri({text:e.message,enabled:e.isStreaming,onAnimationStart:e.onStreamAnimationStart,onAnimationProgress:e.onStreamAnimationProgress,onAnimationComplete:e.onStreamAnimationComplete}),s={...e,message:n,extendedMessagePayload:r?{}:e.extendedMessagePayload},a=!!s.isTyping,i=s.testerMode,l=!!s.isSenderAvatarVisible,c=!!((f=s.extendedMessagePayload)!=null&&f.form)&&!((_=s.extendedMessagePayload)!=null&&_.form.canceled_at),u=!!((v=s.extendedMessagePayload)!=null&&v.message_template),m=!!((A=s.extendedMessagePayload)!=null&&A.cta_button),p=!!((T=s.extendedMessagePayload)!=null&&T.citations)&&s.extendedMessagePayload.citations.length>0,E=!!s.createdAt,y=s.groupType==="top"||s.groupType==="single",x=s.groupType==="bottom"||s.groupType==="single",b=i||!l?0:B.AVATAR_SIZE;return o.createElement(Ud,{$marginBottom:a?0:fn(s.groupType)},y&&o.createElement(Hd,null,!i&&l&&o.createElement(t.SenderAvatar,{...s}),o.createElement(t.SenderName,{...s})),o.createElement(zd,null,o.createElement(Yt,{$extraStartPadding:b},a?o.createElement(t.TypingIndicator,{...s}):o.createElement(t.MessageBody,{...s},m&&o.createElement("div",{style:{marginTop:12,marginInline:12}},o.createElement(t.CTAButton,{...s})),p&&o.createElement(t.Citation,{...s}))),u&&o.createElement(pr,{$startPadding:0,$endPadding:0},o.createElement(t.MessageTemplate,{...s,messageTemplateErrorFallback:s.messageTemplateErrorFallback??o.createElement(Yt,{$extraStartPadding:b},o.createElement(t.MessageBody,{...s,messageType:"user",message:((L=(k=s.extendedMessagePayload)==null?void 0:k.message_template)==null?void 0:L.fallback_message)??"Cannot read this template."})),messageTemplateLoadingFallback:s.messageTemplateLoadingFallback??o.createElement(Yt,{$extraStartPadding:b},o.createElement(t.TypingIndicator,{...s}))})),o.createElement(t.CustomMessageTemplate,{...s}),c&&o.createElement(pr,{$extraStartPadding:b},o.createElement(t.Form,{...s}))),x&&E&&o.createElement(Vd,{$extraStartPadding:b+8},o.createElement(t.SentTime,{...s})),o.createElement(d.Fragment,null,!a&&o.createElement(it,{$extraStartPadding:b+8},o.createElement(t.Feedback,{...s})),s.suggestedRepliesVisible&&o.createElement(t.SuggestedReplies,{...s}),o.createElement(t.MessageLogs,{...s})))},Ud=g.default.div`display:flex;flex-direction:column;align-items:flex-start;margin-bottom:${({$marginBottom:e})=>`${e}px`};
|
|
222
|
+
`,it=g.default.div`display:flex;align-self:stretch;justify-content:flex-start;${({$startPadding:e=B.HORIZONTAL_PADDING,$endPadding:t=B.HORIZONTAL_PADDING,$extraStartPadding:n=0})=>`
|
|
223
|
+
padding-inline: ${e+n}px ${t}px;
|
|
224
|
+
`}
|
|
225
|
+
`,Hd=g.default(it)`display:flex;flex-direction:row;align-items:center;gap:8px;`,Yt=g.default(it)`display:flex;`,Vd=g.default(it)`margin-top:${B.BODY_TIME_GAP}px;display:flex;align-items:flex-start;justify-content:flex-start;`,pr=g.default(it)`display:flex;${({$startPadding:e=B.HORIZONTAL_PADDING,$endPadding:t=B.HORIZONTAL_PADDING,$extraStartPadding:n=0})=>`
|
|
226
|
+
padding-inline: ${e+n}px ${t}px;
|
|
227
|
+
`}
|
|
228
|
+
`,zd=g.default.div`display:flex;flex-direction:column;min-width:0;max-width:100%;gap:${B.GAP_GROUPED}px;`;function Gd({file:e,children:t,onClickFile:n,sendingStatus:r}){const s=(()=>{if(!(!n||r==="failed"))return()=>n==null?void 0:n(e)})();return o.createElement(Wd,null,o.createElement(Mn,{name:e.name,type:gn(e.name,e.type),onClick:s}),t)}const Wd=g.default.div`display:flex;flex-direction:column;align-items:flex-end;gap:${B.GAP_GROUPED}px;`;function qd({sendingStatus:e,file:t,metadata:n,onClickMedia:r,onClickMediaFiles:s,children:a}){const{aspectRatio:i,localFile:l}=n,[c]=d.useState(()=>l instanceof Blob?URL.createObjectURL(l):t.url),[u,m]=d.useState(!1),p=(()=>{if(e!=="failed"){if(s)return()=>s({files:[{url:c,type:t.type,name:t.name}],index:0});if(r)return()=>r({...t,url:c})}})(),E={onClick:p,$ratio:i,$clickable:!!p};return o.createElement(jd,null,o.createElement(Kd,{...E},!u&&o.createElement(at,{size:26},o.createElement(F,{type:"spinner",color:"textLowEmphasis",size:26})),o.createElement(Yd,{$loaded:u,src:c,alt:"image-message",onLoad:()=>m(!0)})),a)}const jd=g.default.div`display:flex;flex-direction:column;align-items:flex-end;gap:${B.GAP_GROUPED}px;`,Kd=g.default.div`width:${B.BODY_MAX_WIDTH}px;border-radius:12px;overflow:hidden;cursor:${e=>e.$clickable?"pointer":"default"};height:auto;aspect-ratio:${e=>e.$ratio};position:relative;display:flex;align-items:center;justify-content:center;${N.light`
|
|
229
|
+
background-color: ${h.color.background100};
|
|
230
|
+
`}
|
|
231
|
+
${N.dark`
|
|
232
|
+
background-color: ${h.color.background400};
|
|
233
|
+
`}
|
|
234
|
+
`,Yd=g.default.img`position:absolute;width:100%;height:100%;inset-block-start:0;inset-inline-start:0;object-fit:cover;opacity:${e=>e.$loaded?1:0};transition:opacity 0.5s ease;`,Xd=({sendingStatus:e,files:t,metadata:n,onClickMedia:r,onClickMediaFiles:s,children:a})=>{const[i]=d.useState(()=>n.localFiles?n.localFiles.filter(m=>m instanceof Blob).map(m=>({...m,url:URL.createObjectURL(m)})):t),l=e==="pending",c=e==="failed",u=m=>{if(c||l)return;const p=i[m];p&&(s?s({files:i,index:m}):r&&r({url:p.url,type:p.type||"image/*"}))};return o.createElement(Zd,null,o.createElement(ns,{images:i,isPending:l,onClickImage:u}),a)},Zd=g.default.div`display:flex;flex-direction:column;align-items:flex-end;gap:${B.GAP_GROUPED}px;`;function Jd(e){var n,r;const t=d.useMemo(()=>{const s=Zl(ss(e.message));return Ir.default.sanitize(s)},[e.message]);return o.createElement(Qd,{$maxWidth:e.maxBodyWidth??B.BODY_MAX_WIDTH,$color:(n=e.customStyle)==null?void 0:n.bubbleContentColor,$bgColor:(r=e.customStyle)==null?void 0:r.bubbleBackgroundColor},o.createElement(eu,{variant:"body3",dangerouslySetInnerHTML:{__html:t}}))}const Qd=g.default.div`display:flex;flex-direction:column;border-radius:12px;overflow:hidden;max-width:${({$maxWidth:e})=>e}px;${({theme:e,$color:t,$bgColor:n})=>w.css`
|
|
235
|
+
color: ${t||e.colors.messageOutgoing.text};
|
|
236
|
+
background-color: ${n||e.colors.messageOutgoing.background};
|
|
237
|
+
`}
|
|
238
|
+
padding: 12px 0;
|
|
239
|
+
transition: max-width 0.3s;
|
|
240
|
+
overflow-wrap: break-word;
|
|
241
|
+
`,eu=g.default($)`align-items:flex-start;line-height:140%;white-space:pre-wrap;padding:0 12px;`,tu=({sendingStatus:e})=>{const t=w.useTheme();switch(e){case"pending":return o.createElement(nu,{size:16},o.createElement(F,{type:"spinner",color:t.colors.messageOutgoing.background,size:16}));case"failed":return o.createElement("div",{style:{marginBottom:2}},o.createElement(F,{type:"error",color:h.themedColor.error,size:16}));case"scheduled":case"canceled":return null;default:return o.createElement("div",{style:{marginBottom:2}},o.createElement(F,{type:"done",color:h.themedColor.secondary,size:16}))}},nu=g.default(at)`margin-bottom:2px;width:16px;height:16px;`,ru=({createdAt:e})=>{const{stringSet:t,format:n}=W();return e?o.createElement($,{variant:"caption4",color:h.themedColor.textLowEmphasis},n(e,t.DATE_FORMAT__MESSAGE_TIMESTAMP)):null},su=e=>{const{components:t}=lt.useContext(),{stringSet:n}=W(),r=()=>{const i=Mr(e)?o.createElement(t.TextMessageBody,{...e}):null;return e.messageType==="user"?i:e.messageType==="file"?e.file.type.startsWith("image")?o.createElement(t.MediaMessageBody,{...e},i):o.createElement(t.FileMessageBody,{...e},i):e.messageType==="multipleFiles"?o.createElement(t.MultipleFilesMessageBody,{...e},i):o.createElement(t.TextMessageBody,{...e,message:n.UNKNOWN__UNKNOWN_MESSAGE_TYPE})},s=e.sendingStatus==="failed"&&e.onClickFailedMessage,a=i=>{var l;(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),(l=e.onClickFailedMessage)==null||l.call(e))};return o.createElement("div",{...s&&{onClick:e.onClickFailedMessage,onKeyDown:a,role:"button",tabIndex:0},style:{display:"contents",cursor:s?"pointer":"default"}},r())},ou=e=>{const{components:t}=lt.useContext(),n=e.sendingStatus==="succeeded",r=e.groupType==="bottom"||e.groupType==="single";return o.createElement(au,{$marginBottom:fn(e.groupType)},o.createElement(iu,null,o.createElement(t.MessageBody,{...e})),r&&o.createElement(lu,{$extraEndPadding:8},n?o.createElement(t.SentTime,{...e}):o.createElement(t.SendingStatus,{...e})))},lt=fe({template:ou,components:{SendingStatus:tu,SentTime:ru,MessageBody:su,TextMessageBody:Jd,MediaMessageBody:qd,FileMessageBody:Gd,MultipleFilesMessageBody:Xd}}),au=g.default.div`display:flex;flex:1;flex-direction:column;align-items:flex-end;margin-bottom:${({$marginBottom:e})=>`${e}px`};
|
|
242
|
+
`,gs=g.default.div`display:flex;align-self:stretch;justify-content:flex-end;${({$startPadding:e=B.HORIZONTAL_PADDING,$endPadding:t=B.HORIZONTAL_PADDING,$extraEndPadding:n=0})=>`padding-inline: ${e}px ${t+n}px;`};
|
|
243
|
+
`,iu=g.default(gs)``,lu=g.default(gs)`margin-top:${B.BODY_TIME_GAP}px;`,cu=e=>e.messageType!=="admin"?null:o.createElement(du,null,o.createElement($,{variant:"caption2",color:h.themedColor.textMidEmphasis},uu(Ir.default.sanitize(e.message)))),du=g.default.div`text-align:center;text-wrap:pretty;word-break:break-word;padding-inline:${B.HORIZONTAL_PADDING}px;a{text-decoration:underline;color:inherit;}`,uu=e=>{try{const t=[];let n=e,r=0;for(;n;){const s=n.match(/\[([^\]]+)\]\((https?:\/\/[^\s]+)\)/),a=n.match(/\*\*([^*]+)\*\*/),i=[s&&{match:s,type:"link"},a&&{match:a,type:"bold"}].filter(p=>!!p);if(!i.length){t.push(n);break}const l=i.reduce((p,E)=>E.match.index<p.match.index?E:p),{match:c,type:u}=l,m=c.index;m>0&&t.push(n.slice(0,m)),u==="link"?t.push(o.createElement("a",{key:r++,href:c[2],target:"_blank",rel:Tn},c[1])):u==="bold"&&t.push(o.createElement("strong",{key:r++},c[1])),n=n.slice(m+c[0].length)}return t.filter(s=>s!=="")}catch{return[e]}},fs=({onClick:e,checked:t,label:n,disabled:r,labelVariant:s="caption2"})=>{const a=t?h.themedColor.primary:r?h.themedColor.textDisabled:h.themedColor.textLowEmphasis,i=t?h.themedColor.textHighEmphasis:r?h.themedColor.textLowEmphasis:h.themedColor.textHighEmphasis;return o.createElement(gu,{onClick:e,disabled:r},o.createElement(mu,null,o.createElement(F,{size:20,type:t?"radio-on":"radio-off",color:a})),o.createElement(hu,{variant:s,color:i},n))},mu=g.default.div`width:20px;height:20px;`,hu=g.default($)`line-height:20px;word-break:break-word;`,gu=g.default.button`all:unset;display:flex;align-items:flex-start;justify-content:flex-start;gap:2px;&:enabled{cursor:pointer;}`,fu=({csatPayload:e,submitted:t,defaultValue:n,value:r,onChange:s})=>(d.useEffect(()=>{typeof r>"u"&&typeof n=="boolean"&&(s==null||s(n))},[r,n]),e.cre?o.createElement(pu,null,o.createElement(Z.Label,{required:e.cre.required},e.cre.question),o.createElement(Eu,null,[{label:e.cre.positive_label,value:!0},{label:e.cre.negative_label,value:!1}].map(a=>o.createElement(fs,{key:a.label,checked:r===a.value,label:a.label,disabled:t,onClick:()=>s==null?void 0:s(a.value)})))):null),pu=g.default.div`display:flex;flex-direction:column;gap:8px;`,Eu=g.default.div`display:flex;flex-direction:column;gap:8px;`,bu=({followUpItem:e,submitted:t,value:n="",onChange:r,hasError:s})=>{const{stringSet:a}=W();return o.createElement(_u,null,o.createElement(Z.Label,{required:e.required},e.question),e.response_type==="free_text"&&o.createElement(Z.TextInput,{variant:"multi-line",disabled:t,submitted:t,maxLength:100,value:n,onChange:i=>r(i),error:s}),e.response_type==="single_choice"&&o.createElement(Cu,null,e.options.map(i=>o.createElement(fs,{key:i,checked:n===i,label:i,disabled:t,onClick:()=>r==null?void 0:r(i),labelVariant:"body3"}))),s&&o.createElement(Z.ErrorLabel,null,a.FORM_VALIDATION_REQUIRED))},_u=g.default.div`display:flex;flex-direction:column;gap:8px;`,Cu=g.default.div`display:flex;flex-direction:column;gap:8px;`,xu=({value:e,selected:t,label:n})=>o.createElement(vu,{$selected:t,"aria-label":n},yu[e-1]),vu=g.default.div`user-select:none;-webkit-user-drag:none;width:40px;height:40px;aspect-ratio:1;opacity:${({$selected:e})=>e?1:.38};`,yu=[o.createElement("svg",{width:"40",height:"40",viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg"},o.createElement("path",{d:"M2.08337 19.9999C2.08337 10.1048 10.1049 2.08325 20 2.08325C29.8952 2.08325 37.9167 10.1048 37.9167 19.9999C37.9167 29.8951 29.8952 37.9166 20 37.9166C10.1049 37.9166 2.08337 29.8951 2.08337 19.9999Z",fill:"url(#paint0_linear_159_173206)"}),o.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.5828 29.3328C13.1348 29.7473 13.9184 29.636 14.3329 29.084C15.6272 27.3607 17.6839 26.25 20 26.25C22.3164 26.25 24.373 27.3607 25.6672 29.084C26.0819 29.636 26.8654 29.7473 27.4175 29.3328C27.9695 28.9182 28.0809 28.1347 27.6662 27.5825C25.9202 25.2577 23.136 23.75 20 23.75C16.8642 23.75 14.0801 25.2577 12.334 27.5825C11.9194 28.1347 12.0308 28.9182 12.5828 29.3328Z",fill:"#141B34"}),o.createElement("path",{d:"M28.4454 13.7707C29.1329 13.8328 29.6405 14.4406 29.5785 15.1281C29.5165 15.8153 28.9095 16.3221 28.2224 16.2608C28.2224 16.2608 28.0287 16.2502 27.9272 16.2487C27.7229 16.2457 27.4387 16.2509 27.1229 16.2833C26.7869 16.3177 26.4649 16.3782 26.1804 16.4662L26.3045 16.86C26.7797 18.3675 25.5099 19.5813 24.2062 19.5813C23.5045 19.5813 22.8324 19.2617 22.43 18.6857C22.003 18.0745 21.9422 17.241 22.408 16.5344C22.751 16.0143 23.2449 15.3831 23.8964 14.8657C24.836 14.1195 26.044 13.8809 26.8675 13.7963C27.3029 13.7517 28.0154 13.7319 28.4454 13.7707Z",fill:"#141B34"}),o.createElement("path",{d:"M11.5549 13.7707C10.8674 13.8328 10.3597 14.4406 10.4218 15.1281C10.4838 15.8153 11.0908 16.3221 11.7779 16.2608C11.7779 16.2608 11.9716 16.2502 12.073 16.2487C12.2774 16.2457 12.5616 16.2509 12.8774 16.2833C13.2134 16.3177 13.5353 16.3782 13.8199 16.4662L13.6958 16.86C13.2205 18.3675 14.4904 19.5813 15.794 19.5813C16.4958 19.5813 17.168 19.2617 17.5703 18.6857C17.9971 18.0745 18.0581 17.241 17.5921 16.5344C17.2493 16.0143 16.7553 15.3831 16.1039 14.8657C15.1643 14.1195 13.9562 13.8809 13.1327 13.7963C12.6974 13.7517 11.9849 13.7319 11.5549 13.7707Z",fill:"#141B34"}),o.createElement("defs",null,o.createElement("linearGradient",{id:"paint0_linear_159_173206",x1:"20",y1:"2.08325",x2:"20",y2:"37.9166",gradientUnits:"userSpaceOnUse"},o.createElement("stop",{stopColor:"#FF2D1D"}),o.createElement("stop",{offset:"1",stopColor:"#FFA540"})))),o.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"40",height:"40",viewBox:"0 0 40 40",fill:"none"},o.createElement("path",{d:"M2.083 20C2.083 10.105 10.105 2.083 20 2.083c9.895 0 17.917 8.021 17.917 17.917 0 9.895-8.022 17.917-17.917 17.917C10.105 37.917 2.083 29.895 2.083 20Z",fill:"#FFD46E"}),o.createElement("path",{d:"M14.249 27.334C15.851 26.13 17.844 25.417 20 25.417c2.156 0 4.149.714 5.751 1.917.553.415.664 1.199.25 1.751-.415.552-1.199.664-1.751.25-1.183-.889-2.652-1.416-4.25-1.416s-3.067.527-4.25 1.416c-.553.414-1.336.302-1.751-.25-.415-.552-.303-1.336.249-1.751Z",fill:"#141B34"}),o.createElement("path",{d:"M23.445 14.596c-.687.062-1.294-.445-1.356-1.132-.062-.687.445-1.295 1.132-1.357.082-.005.342-.02.482-.022.277-.004.662.002 1.097.047.823.085 2.031.323 2.97 1.07.652.518 1.146 1.15 1.489 1.67.466.706.405 1.54-.022 2.15-.402.576-1.074.896-1.775.896-1.304 0-2.573-1.214-2.098-2.722l.125-.394c-.285-.088-.607-.148-.942-.182-.316-.033-.6-.038-.804-.035-.101.002-.242.01-.294.013Z",fill:"#141B34"}),o.createElement("path",{d:"M11.779 14.596c-.687.062-1.294-.445-1.356-1.132-.062-.687.445-1.295 1.132-1.357.082-.005.342-.02.482-.022.277-.004.662.002 1.097.047.823.085 2.031.323 2.97 1.07.652.518 1.146 1.15 1.489 1.67.466.706.405 1.54-.022 2.15-.402.576-1.074.896-1.775.896-1.304 0-2.573-1.214-2.098-2.722l.124-.394c-.284-.088-.606-.148-.941-.182-.316-.033-.6-.038-.804-.035-.101.002-.243.01-.294.013Z",fill:"#141B34"})),o.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"40",height:"40",viewBox:"0 0 40 40",fill:"none"},o.createElement("path",{d:"M2.083 20C2.083 10.105 10.105 2.083 20 2.083c9.895 0 17.917 8.021 17.917 17.917 0 9.895-8.022 17.917-17.917 17.917C10.105 37.917 2.083 29.895 2.083 20Z",fill:"#FFD46E"}),o.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M11.25 15c0-1.151.933-2.083 2.083-2.083h.015c1.151 0 2.084.933 2.084 2.083 0 1.151-.933 2.083-2.084 2.083h-.015c-1.15 0-2.083-.933-2.083-2.083ZM24.568 15c0-1.151.933-2.083 2.084-2.083h.015c1.151 0 2.083.933 2.083 2.083 0 1.151-.932 2.083-2.083 2.083h-.015c-1.151 0-2.084-.933-2.084-2.083Z",fill:"#141B34"}),o.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M13.75 26.667c0-.691.56-1.25 1.25-1.25h10c.69 0 1.25.559 1.25 1.25 0 .691-.56 1.25-1.25 1.25h-10c-.69 0-1.25-.559-1.25-1.25Z",fill:"#141B34"})),o.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"40",height:"40",viewBox:"0 0 40 40",fill:"none"},o.createElement("path",{d:"M2.083 20C2.083 10.105 10.105 2.083 20 2.083c9.895 0 17.917 8.021 17.917 17.917 0 9.895-8.022 17.917-17.917 17.917C10.105 37.917 2.083 29.895 2.083 20Z",fill:"#FFD46E"}),o.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.583 24.001c.552-.414 1.335-.302 1.75.25 1.294 1.723 3.35 2.834 5.667 2.834s4.373-1.11 5.667-2.834c.415-.552 1.199-.664 1.751-.25.552.415.664 1.199.25 1.751C25.92 28.076 23.136 29.584 20 29.584s-5.92-1.508-7.666-3.832c-.415-.552-.303-1.336.249-1.751Z",fill:"#141B34"}),o.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M11.25 15c0-1.151.933-2.083 2.083-2.083h.015c1.151 0 2.084.933 2.084 2.083 0 1.151-.933 2.083-2.084 2.083h-.015c-1.15 0-2.083-.933-2.083-2.083ZM24.568 15c0-1.151.933-2.083 2.084-2.083h.015c1.151 0 2.083.933 2.083 2.083 0 1.151-.932 2.083-2.083 2.083h-.015c-1.151 0-2.084-.933-2.084-2.083Z",fill:"#141B34"})),o.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"40",height:"40",viewBox:"0 0 40 40",fill:"none"},o.createElement("path",{d:"M2.083 20C2.083 10.105 10.105 2.083 20 2.083c9.895 0 17.917 8.021 17.917 17.917 0 9.895-8.022 17.917-17.917 17.917C10.105 37.917 2.083 29.895 2.083 20Z",fill:"#FFD46E"}),o.createElement("g",{clipPath:"url(#clip0_159_173224)"},o.createElement("g",{clipPath:"url(#clip1_159_173224)"},o.createElement("path",{d:"M20 30.624c3.752 0 6.904-2.532 7.789-5.956.412-1.593-.185-1.959-1.76-1.959H13.973c-1.575 0-2.173.366-1.761 1.959.885 3.424 4.037 5.956 7.788 5.956Z",fill:"#141B34"})),o.createElement("mask",{id:"mask0_159_173224",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:"12",y:"22",width:"16",height:"9"},o.createElement("path",{d:"M20 30.624c3.752 0 6.904-2.532 7.789-5.956.412-1.593-.185-1.959-1.76-1.959H13.973c-1.575 0-2.173.366-1.761 1.959.885 3.424 4.037 5.956 7.788 5.956Z",fill:"#141B34"})),o.createElement("g",{mask:"url(#mask0_159_173224)"},o.createElement("path",{d:"M20 32.998c3.278 0 5.936-1.594 5.936-3.561 0-1.968-2.658-3.562-5.936-3.562-3.278 0-5.936 1.594-5.936 3.562 0 1.967 2.658 3.561 5.936 3.561Z",fill:"#FF493B"}))),o.createElement("path",{d:"M11.667 15.833c0-1.381 1.12-2.5 2.5-2.5s2.5 1.12 2.5 2.5M23.333 15.833c0-1.381 1.12-2.5 2.5-2.5s2.5 1.12 2.5 2.5",stroke:"#141B34",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),o.createElement("defs",null,o.createElement("clipPath",{id:"clip0_159_173224"},o.createElement("rect",{width:"15.83",height:"7.915",fill:"white",transform:"translate(12.085 22.709)"})),o.createElement("clipPath",{id:"clip1_159_173224"},o.createElement("rect",{width:"15.83",height:"7.915",fill:"white",transform:"translate(12.085 22.709)"}))))],Su=({csatPayload:e,submitted:t,value:n,onChange:r})=>{const s=typeof n>"u";return o.createElement(Tu,null,o.createElement($,{variant:"caption3",color:h.themedColor.textMidEmphasis},e.csat_question),o.createElement(Iu,null,e.csat_scores.map(({label:a,image_url:i},l)=>{const c=l+1,u=n===c;return o.createElement(wu,{key:l,disabled:t,onClick:()=>r(c)},o.createElement(Au,{value:c,selected:s||u,label:a,src:i}),!!a&&o.createElement($,{color:u?h.themedColor.textHighEmphasis:h.themedColor.textLowEmphasis,variant:"caption3"},a))})))},Au=({value:e,src:t,label:n,selected:r})=>{const[s,a]=d.useState(!1),i=s?o.createElement(xu,{value:e,selected:r,label:n}):o.createElement(Mu,{$selected:r,"aria-label":n,src:t,onError:()=>a(!0)});return o.createElement(ku,null,i)},Tu=g.default.div`display:flex;flex-direction:column;gap:8px;`,Iu=g.default.div`display:flex;justify-content:space-between;align-self:center;width:100%;max-width:400px;gap:16px;`,wu=g.default.button`background-color:transparent;border:none;gap:4px;display:flex;flex-direction:column;align-items:center;justify-content:start;box-sizing:border-box;min-width:48px;max-width:68px;&:hover:not(:disabled) span{color:${h.themedColor.textHighEmphasis};}`,ku=g.default.div`button:hover:not(:disabled) &{border-radius:4px;cursor:pointer;background-color:${h.color.background200};${N.dark`
|
|
244
|
+
background-color: ${h.color.background500};
|
|
245
|
+
`}
|
|
246
|
+
}
|
|
247
|
+
`,Mu=g.default.img`user-select:none;-webkit-user-drag:none;width:40px;height:40px;aspect-ratio:1;opacity:${({$selected:e})=>e?1:.38};`,$u=({csatPayload:e})=>o.createElement($,{variant:"button",color:h.themedColor.textHighEmphasis},e.title),Xt=({csatPayload:e,type:t,renderSubmitButton:n,initialCsat:r,initialCsatReason:s,initialIsResolved:a})=>{const{params:i,setParams:l,error:c,setError:u,followUpItem:m,state:p,validateParams:E,itemProps:y}=Qa({csatPayload:e,type:t,initialCsat:r,initialCsatReason:s,initialIsResolved:a});return o.createElement(o.Fragment,null,o.createElement(Lu,null,o.createElement($u,{...y}),t===me.AI_AGENT_CSAT_5_WITH_CRE&&o.createElement(fu,{...y,defaultValue:a,value:i.isResolved,onChange:x=>l({isResolved:x})}),o.createElement(Su,{...y,value:i.csat,onChange:x=>l({csat:x})}),m&&o.createElement(bu,{...y,followUpItem:m,value:i.csatReason,onChange:x=>{l({csatReason:x}),u({followUpItem:!1})},hasError:c.followUpItem})),p!=="unsubmittable"&&o.createElement(o.Fragment,null,o.createElement(Z.Separator,null),n({state:p,params:i,validateParams:E})))},Lu=g.default.div`display:flex;flex-direction:column;gap:12px;`,Ou=e=>{const{stringSet:t}=W();return ko(e,{title:t.CSAT_TITLE_UNSUBMITTED,question:t.CSAT_RATING_TITLE,cre:{question:t.CSAT_CRE_TITLE,positive_label:t.CSAT_CRE_SOLVED,negative_label:t.CSAT_CRE_NOT_SOLVED},followUp:{question:t.CSAT_REASON_PLACEHOLDER},submit_label:t.CSAT_SUBMIT_LABEL,submitted_label:t.CSAT_TITLE_SUBMITTED})},Ru=()=>{const{stringSet:e}=W();return o.createElement($,{variant:"body2",color:h.themedColor.textMidEmphasis,style:{textAlign:"center"}},e.CSAT_SUBMISSION_EXPIRED)},Du=({onMount:e,children:t})=>(d.useEffect(()=>{e&&Jr(e)},[]),o.createElement(o.Fragment,null,t)),Nu=e=>{if(e.messageType!=="admin.csat")throw new Error("Invalid message type");const{extendedMessagePayload:t,onSubmitCSAT:n,onScrollToBottom:r}=e,{csat:s,csatReason:a,csatExpireAt:i,isResolvedWhenDeterminedByUser:l}=e,c=Me.useForceUpdate(),u=Ou(t==null?void 0:t.csat),m=d.useRef(!1);if(!u||!u.visibility||!me[u.type])return null;const p=u.type===me.AI_AGENT_CSAT_5||u.type===me.AI_AGENT_CSAT_5_WITH_CRE||u.type===me.HELPDESK_CSAT_5?Xt:()=>null;return o.createElement(Pu,null,!s&&zn(i)?o.createElement(Ru,null):o.createElement(p,{csatPayload:u,type:u.type,initialCsat:s,initialCsatReason:a,initialIsResolved:l,renderSubmitButton:({state:E,params:y,validateParams:x})=>o.createElement(Du,{onMount:r},o.createElement(Fu,{$state:E,disabled:E==="submitted",onClick:async()=>{m.current||(!zn(i)&&x()?(m.current=!0,await n(y).finally(()=>{m.current=!1})):c())}},o.createElement($,{variant:"button"},E==="submitted"?u.csat_submitted_label:u.csat_submit_label)))}))},Pu=g.default.div`display:flex;flex-direction:column;background-color:${({theme:e})=>e.colors.csat.background};border-radius:16px;gap:16px;padding:16px;`,Fu=g.default.button`all:unset;background-color:${({theme:e})=>e.colors.base.primary};color:${({theme:e})=>e.colors.base.primaryContrastContent};border-radius:6px;padding:10px 20px;display:flex;align-items:center;justify-content:center;cursor:pointer;text-align:center;word-break:break-word;&:hover{background-color:${h.color.primary.dark};}&:disabled{color:${({$state:e})=>e==="submitted"?h.themedColor.textHighEmphasis:h.color.ondark.textLowEmphasis};background-color:${h.themedColor.textDisabled};cursor:not-allowed;}`,Bu=e=>{const{components:t}=Dt.useContext(),n=e.messageType==="admin"?o.createElement(t.AdminMessage,{...e}):e.messageType==="admin.csat"?o.createElement(t.CSATMessage,{...e}):null;return o.createElement(Uu,{$marginBottom:fn(e.groupType)},n)},Dt=fe({template:Bu,components:{AdminMessage:cu,CSATMessage:Nu}}),Uu=g.default.div`padding-inline:${B.HORIZONTAL_PADDING}px;margin-bottom:${({$marginBottom:e})=>e}px;`,Er={file:"attach",snippet:"snippet",site:"website",sb_sprinklr:"sprinklr",sb_salesforce:"salesforce",sb_confluence:"confluence",sb_zendesk:"zendesk",sb_desk:"snippet"},ps=({actionbook:e,functionCalls:t,groundedness:n,agentMessageTemplates:r,onClickActionbook:s,onClickFunctionCall:a,onClickFunctionCallDetail:i,onClickGroundedness:l,onClickAgentMessageTemplate:c,bottomContent:u,renderCustomGroundednessIcon:m=E=>E.default,style:p={}})=>{const{iconColor:E="#000000",textColor:y="#000000",highlightColor:x=et.DEFAULT_PRIMARY}=p;return o.createElement(br,null,e&&o.createElement(br,null,o.createElement(wt,null,o.createElement(bt,null,o.createElement(F,{size:16,type:"actionbook",color:E})),o.createElement(Et,{$clickable:!!s,$highlightColor:x,variant:"body2",color:y,onClick:()=>s==null?void 0:s(e),maxTextLines:1},e.name))),t==null?void 0:t.map(b=>o.createElement(Zt,{key:b.key},o.createElement(bt,null,o.createElement(F,{size:16,type:"function",color:E})),o.createElement(wt,null,o.createElement(Et,{$clickable:!!a,$highlightColor:x,variant:"body2",color:y,onClick:()=>a==null?void 0:a(b),maxTextLines:1},b.name),i&&o.createElement(Vu,{role:"button",onClick:()=>i==null?void 0:i(b)},o.createElement($,{variant:"body2",color:x},"View details"),o.createElement(F,{type:"chevron-right",size:16,color:x}))))),n==null?void 0:n.map(b=>o.createElement(Zt,{key:b.id},o.createElement(bt,null,m({default:o.createElement(F,{size:16,type:Er[b.source_type]??Er.snippet,color:E}),sourceType:b.source_type})),o.createElement(Et,{$clickable:!!l,$highlightColor:x,variant:"body2",color:y,onClick:()=>l==null?void 0:l(b),maxTextLines:1},b.preview_title))),r==null?void 0:r.map(b=>o.createElement(Zt,{key:b.key},o.createElement(bt,null,o.createElement(F,{size:16,type:"template",color:E})),o.createElement(Et,{$clickable:!!c,$highlightColor:x,variant:"body2",color:y,onClick:()=>c==null?void 0:c(b),maxTextLines:1},b.name))),u)},Hu=g.default($)`font-weight:400;`,Et=g.default(Hu)`${({$clickable:e,$highlightColor:t})=>e&&w.css`
|
|
248
|
+
cursor: pointer;
|
|
249
|
+
text-decoration: underline;
|
|
250
|
+
&:hover {
|
|
251
|
+
color: ${t};
|
|
252
|
+
}
|
|
253
|
+
`}
|
|
254
|
+
`,bt=g.default.div`display:flex;align-items:center;justify-content:center;flex-shrink:0;`,wt=g.default.div`display:flex;gap:8px;align-items:center;word-break:break-word;`,Vu=g.default(wt)`cursor:pointer;gap:4px;`,Zt=g.default(wt)`flex-direction:row;align-items:center;`,br=g.default.div`display:flex;gap:4px;flex-direction:column;align-items:flex-start;`,Es=d.createContext(null);function zu({testerType:e,origin:t,children:n}){return o.createElement(Es.Provider,{value:{testerType:e,isActionbookTester:e==="actionbook",origin:t}},e&&o.createElement(Gu,null),n)}const je=()=>{const e=d.useContext(Es);if(!e)throw new Error("_UNSAFE_INTERNAL_DashboardTesterProvider not found");return e},Gu=()=>{const{isActionbookTester:e}=je();return o.createElement(Oe.Template,{template:e?Wu:void 0},o.createElement(Oe.MessageLogs,{component:qu}))},Wu=e=>o.createElement(hs,{...e,testerMode:!0,maxBodyWidth:B.WIDE_BODY_MAX_WIDTH}),qu=({extendedMessagePayload:e={}})=>{const{handlers:t}=j(),{manual:n,groundedness:r,function_calls:s,agent_message_templates:a,is_thinking:i}=e;return i||!n&&!(r!=null&&r.length)&&!(s!=null&&s.length)&&!(a!=null&&a.length)?o.createElement(o.Fragment,null):o.createElement(ju,null,o.createElement(Ku,{width:4}),o.createElement(ps,{actionbook:n,functionCalls:s,groundedness:r,agentMessageTemplates:a,onClickFunctionCallDetail:t==null?void 0:t.onFunctionCallDetailClick,style:{iconColor:h.themedColor.textHighEmphasis,textColor:h.themedColor.textHighEmphasis,barColor:h.themedColor.textDisabled},bottomContent:o.createElement(Yu,{variant:"caption2",color:h.themedColor.textLowEmphasis},"Only visible in the tester")}))},ju=g.default.div`display:flex;gap:16px;margin:16px ${B.HORIZONTAL_PADDING}px 0;align-self:stretch;`,Ku=g.default.div`width:${({width:e})=>e}px;background-color:${h.themedColor.textDisabled};border-radius:100px;flex-shrink:0;`,Yu=g.default($)`margin-top:5px;`,Xu=d.forwardRef(function(t,n){const{messages:r,renderMessage:s,loading:a,LoadingComponent:i,error:l,ErrorComponent:c,empty:u,EmptyComponent:m,messageTopArea:p,messageBottomArea:E,overlayArea:y,onLoadPrev:x,onLoadNext:b,loadThreshold:f=.05,onScroll:_=ve,depsForResetScrollPositionToBottom:v,stackDirection:A="top",bottomSpacerHeight:T=0,ariaLabel:k}=t,L=d.useRef(null),S=d.useCallback(D=>{L.current=D,n&&(typeof n=="function"?n(D):n.current=D)},[n]),O=d.useRef(!1),U=d.useRef(void 0),R=d.useRef(0),I=d.useRef(0);d.useLayoutEffect(()=>{L.current&&(L.current.scrollTop=L.current.scrollHeight)},v),d.useLayoutEffect(()=>{L.current&&(U.current==="top"&&(L.current.scrollTop=L.current.scrollHeight-I.current),U.current==="bottom"&&(L.current.scrollTop=R.current),U.current=void 0)},[L.current,r.length]);const H=async D=>{if(_==null||_(D),!L.current)return;const V=L.current;if(I.current=V.scrollHeight-V.scrollTop,R.current=V.scrollTop,O.current)return;const X=V.clientHeight*Math.min(Math.max(0,f),1);V.scrollTop<=X?(O.current=!0,U.current="top",await x(),O.current=!1):V.scrollHeight-V.scrollTop-V.clientHeight<=X?(O.current=!0,U.current="bottom",await b(),O.current=!1):U.current=void 0};return l?o.createElement(o.Fragment,null,c):a?o.createElement(o.Fragment,null,i):o.createElement(Zu,{id:"infinite-list-container"},o.createElement(Ju,{id:"infinite-list-inner",ref:S,onScroll:H,role:"list","aria-label":k},A==="bottom"&&o.createElement("div",{style:{flexGrow:1}}),p,u?m:r.map((D,V)=>s({message:D,index:V})),E,T>0&&o.createElement("div",{style:{minHeight:T}})),o.createElement(Qu,{id:"infinite-list-overlay-container"},o.createElement(em,{id:"infinite-list-overlay"},y)))}),Zu=g.default.div`display:flex;position:relative;flex:1;overflow:hidden;`,Ju=g.default.div`display:flex;flex:1;flex-direction:column;overflow-y:auto;overscroll-behavior:contain;scrollbar-color:${h.themedColor.textLowEmphasis}transparent;&::-webkit-scrollbar-thumb:hover{background-color:transparent;}`,Qu=g.default.div`position:absolute;top:0;bottom:0;left:0;right:0;pointer-events:none;`,em=g.default.div`pointer-events:auto;`,tm=e=>Te(e)||kr(e);function nm(e){return e.isAdminMessage()?e.message==="The channel's custom_type was updated.":!1}function rm(e,t){return e.filter(n=>we.isWelcomeMessage(n,t))}const Se=({as:e,type:t,size:n=16,color:r,disabled:s,...a})=>{const i=s?h.themedColor.textDisabled:h.themedColor.textHighEmphasis;return o.createElement(sm,{as:e,disabled:s,...a},o.createElement(F,{type:t,size:n,color:r??i}))},sm=g.default.button`all:unset;padding:4px;cursor:pointer;display:flex;align-items:center;justify-content:center;&:disabled{cursor:not-allowed;}`,om=({files:e,initialIndex:t=0,onClose:n,visible:r})=>{var k,L;const[s,a]=d.useState(t),[i,l]=d.useState(!1),{stringSet:c,format:u}=W(),{config:m}=j(),p=e.length,E=e[s],y=((L=(k=m==null?void 0:m.conversation)==null?void 0:k.fileViewer)==null?void 0:L.downloadEnabled)!==!1,x=p>1,b=(E==null?void 0:E.type)||"",f=Te(b),_=kr(b),v=!tm(b);d.useEffect(()=>{r&&(a(t),l(!1))},[r,t]);const A=d.useCallback(()=>{s>0&&(a(S=>S-1),l(!1))},[s]),T=d.useCallback(()=>{s<p-1&&(a(S=>S+1),l(!1))},[s,p]);return d.useEffect(()=>{if(!r)return;const S=O=>{O.key==="ArrowLeft"?A():O.key==="ArrowRight"?T():O.key==="Escape"&&n()};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[r,A,T,n]),!r||!E?null:o.createElement(Ot,{onClose:n,visible:r,rootElementId:ce.MODAL_ROOT},o.createElement(am,null,o.createElement(im,null,o.createElement(lm,null,o.createElement(cm,null,o.createElement($,{variant:"button",maxTextLines:1,color:h.themedColor.textHighEmphasis},E.name||c.IMAGE_VIEWER__DEFAULT_TITLE),E.timestamp&&o.createElement($,{variant:"caption2",color:h.themedColor.textMidEmphasis},u(new Date(E.timestamp),"h:mm a")))),o.createElement(dm,{type:"close",size:24,"aria-label":c.A11Y_IMAGE_VIEWER_CLOSE,onClick:n})),o.createElement(um,{onClick:S=>S.currentTarget===S.target&&n()},x&&o.createElement(_r,{$position:"left",type:"chevron-right",size:32,onClick:A,"aria-label":c.A11Y_IMAGE_VIEWER_PREVIOUS,disabled:s===0,$flipped:!0}),o.createElement(mm,null,f&&o.createElement(o.Fragment,null,!i&&o.createElement(hm,null,o.createElement(at,{size:32},o.createElement(F,{type:"spinner",color:"textLowEmphasis",size:32}))),o.createElement(gm,{src:E.url,alt:E.name||"Image",$loaded:i,onLoad:()=>l(!0)})),_&&o.createElement(fm,{controls:!0},o.createElement("source",{src:E.url,type:b})),v&&o.createElement(pm,null,o.createElement($,{variant:"h1",color:h.themedColor.textHighEmphasis},c.FILE_VIEWER__UNSUPPORT))),x&&o.createElement(_r,{$position:"right",type:"chevron-right",size:32,onClick:T,"aria-label":c.A11Y_IMAGE_VIEWER_NEXT,disabled:s===p-1})),o.createElement(Em,null,o.createElement(bm,null),x&&o.createElement($,{variant:"body3",color:h.themedColor.textHighEmphasis},s+1,"/",p),o.createElement(_m,null,y&&!v&&o.createElement(Se,{as:"a",href:E.url,download:E.name||"file",type:"download",size:24,"aria-label":c.A11Y_IMAGE_VIEWER_DOWNLOAD})))))},am=g.default.div`position:fixed;inset:0;outline:none;display:flex;flex-direction:column;background-color:${h.themedColor.bg_50_600};`,im=g.default.header`display:flex;align-items:center;justify-content:space-between;padding:12px 16px;min-height:56px;border-bottom:1px solid ${h.themedColor.textDisabled};`,lm=g.default.div`flex:1;min-width:0;padding-right:16px;`,cm=g.default.div`display:flex;flex-direction:column;gap:2px;`,dm=g.default(Se)`flex-shrink:0;width:32px;height:32px;border-radius:50%;&:hover{background-color:${h.themedColor.bg_100_500};}`,Nt=g.default.div`display:flex;align-items:center;justify-content:center;`,um=g.default(Nt)`flex:1;min-height:0;position:relative;padding:0 16px;`,mm=g.default(Nt)`position:relative;max-width:100%;max-height:100%;`,hm=g.default(Nt)`position:absolute;inset:0;`,gm=g.default.img`max-width:100%;max-height:100%;object-fit:contain;user-select:none;-webkit-user-drag:none;opacity:${e=>e.$loaded?1:0};transition:opacity 0.3s ease;`,fm=g.default.video`max-width:100%;max-height:100%;object-fit:contain;`,pm=g.default(Nt)`flex-direction:column;gap:16px;`,_r=g.default(Se)`position:absolute;${e=>e.$position==="left"?"left: 16px;":"right: 16px;"}top:50%;transform:translateY(-50%) ${e=>e.$flipped?"scaleX(-1)":""};border-radius:50%;&:hover:not(:disabled){background-color:${h.themedColor.bg_200_400};}&:disabled{opacity:0.3;}@media (max-width:480px){width:38px;height:38px;${e=>e.$position==="left"?"left: 8px;":"right: 8px;"}}`,Em=g.default.footer`display:flex;align-items:center;justify-content:space-between;padding:16px;min-height:56px;border-top:1px solid ${h.themedColor.textDisabled};`,bm=g.default.div`width:40px;`,_m=g.default.div`display:flex;align-items:center;justify-content:flex-end;width:40px;`,Cm=({className:e,label:t,ariaLabel:n,onClick:r})=>{const{colors:s}=w.useTheme();return o.createElement(xm,{className:e,onClick:r,"aria-label":n},o.createElement($,{variant:"button",color:s.base.primaryContrastContent},t),o.createElement(F,{size:16,type:"chevron-down",color:s.base.primaryContrastContent}))},xm=g.default.button`all:unset;cursor:pointer;display:flex;align-items:center;gap:4px;padding:10px 12px 10px 16px;border-radius:24px;background-color:${({theme:e})=>e.colors.base.primary};box-shadow:0 8px 10px 1px rgba(13,13,13,0.12),0 3px 14px 2px rgba(13,13,13,0.08),0 3px 5px -3px rgba(13,13,13,0.04);&:focus{outline:none;}`,Ln=({iconSize:e=64,icon:t,className:n,label:r,children:s})=>o.createElement(ym,{className:n},t&&o.createElement(F,{type:t,size:e,color:h.themedColor.textLowEmphasis}),r&&o.createElement($,{variant:"body1",color:h.themedColor.textMidEmphasis},r),s),vm=g.default.div`position:relative;display:flex;justify-content:center;align-items:center;width:100%;height:100%;`,ym=g.default.div`display:flex;flex-direction:column;min-height:104px;align-items:center;gap:20px;text-align:center;`,Sm=({label:e="Something went wrong",icon:t="error",action:n,...r})=>o.createElement(Ln,{icon:t,label:e,...r},n&&o.createElement(Am,{onClick:n.onClick,label:n.label??"Retry"})),Am=({label:e,onClick:t})=>o.createElement(Tm,{tabIndex:0,onClick:t},o.createElement(F,{type:"refresh",size:20}),o.createElement($,{variant:"button",color:h.color.primary.main},e)),Tm=g.default.button`all:unset;display:flex;cursor:pointer;gap:4px;align-items:center;justify-content:center;`,Im=({iconSize:e=48,className:t})=>o.createElement(at,{size:e,className:t}),wm=({label:e="No channels",icon:t="chat",...n})=>o.createElement(Ln,{icon:t,label:e,...n}),km=({label:e="No messages",icon:t="message",...n})=>o.createElement(Ln,{icon:t,label:e,...n}),Mm=e=>{const{components:t}=Pt.useContext(),n=e.type==="loading"?o.createElement(t.Loading,{...e}):e.type==="error"?o.createElement(t.Error,{...e}):e.type==="noChannels"?o.createElement(t.NoChannels,{...e}):e.type==="noMessages"?o.createElement(t.NoMessages,{...e}):null;return n&&o.createElement(vm,null,n)},Pt=fe({template:Mm,components:{Loading:Im,Error:Sm,NoChannels:wm,NoMessages:km}}),Je=e=>{const{Template:t}=Pt.useContext();return o.createElement(t,{...e})},$m=({className:e,date:t=Date.now(),style:n})=>{const{format:r,stringSet:s}=W();return o.createElement(Lm,{id:`${oe}-date-separator`,style:n,className:e},o.createElement($,{variant:"caption4",color:h.themedColor.textMidEmphasis},r(t,s.DATE_FORMAT__MESSAGE_LIST__DATE_SEPARATOR)))},Lm=g.default.div`display:flex;justify-content:center;align-items:center;text-align:center;word-break:break-word;`,Om=({className:e,style:t,onClick:n,ariaLabel:r})=>o.createElement(Rm,{className:e,style:t,onClick:n,tabIndex:0,"aria-label":r},o.createElement(F,{size:24,type:"chevron-down",color:h.color.primary.main})),Rm=g.default.button`all:unset;cursor:pointer;display:flex;align-items:center;justify-content:center;width:40px;height:40px;border-radius:24px;box-shadow:0 2px 8px 0 rgba(0,0,0,0.08),0 4px 6px 0 rgba(0,0,0,0.12);${N.light`
|
|
255
|
+
background-color: ${h.color.background50};
|
|
256
|
+
&:hover {
|
|
257
|
+
background-color: ${h.color.background100};
|
|
258
|
+
}
|
|
259
|
+
&:active {
|
|
260
|
+
background-color: ${h.color.background200};
|
|
261
|
+
}
|
|
262
|
+
`}
|
|
263
|
+
${N.dark`
|
|
264
|
+
background-color: ${h.color.background400};
|
|
265
|
+
&:hover {
|
|
266
|
+
background-color: ${h.color.background500};
|
|
267
|
+
}
|
|
268
|
+
&:active {
|
|
269
|
+
background-color: ${h.color.background700};
|
|
270
|
+
}
|
|
271
|
+
`}
|
|
272
|
+
|
|
273
|
+
&:focus {
|
|
274
|
+
outline: none;
|
|
275
|
+
}
|
|
276
|
+
`,Dm=()=>null,Ft=fe({template:Dm,components:{DateSeparator:$m,ScrollToBottomButton:Om}}),Nm=()=>{const{agentPreviewConfigs:e={},aiAgentId:t}=j(),{aiAgentInfo:n}=re(),{messageSource:r}=se(),{Template:s}=Oe.useContext(),{components:a}=Ft.useContext(),i=e.welcomeMessages??[],l=r.messages,c=rm(l,t),u=l[c.length+1],m=c[0]??u;return{filteredMessages:l.filter(p=>nm(p)?!1:i.length>0?!we.isWelcomeMessage(p,t):!0),shouldShowOriginalDate:p=>p>0||i.length===0?!0:u&&!Fe.isSameDay(u.createdAt,(m==null?void 0:m.createdAt)??0),renderAgentPreviewWelcomeMessages:()=>i.length===0?null:o.createElement(o.Fragment,null,o.createElement(a.DateSeparator,{style:{margin:"16px 0"},date:m==null?void 0:m.createdAt}),i.map((p,E)=>{const y=E===i.length-1,x=c.length!==l.length,b=i.length===1?"single":E===0?"top":y||x?"bottom":"middle";return o.createElement(s,{messageType:"user",message:p.message,sender:n,groupType:b,createdAt:(m==null?void 0:m.createdAt)??Date.now(),extendedMessagePayload:{suggested_replies:p.suggestedReplies},suggestedRepliesDirection:e.suggestedRepliesDirection,suggestedRepliesVisible:y&&!x,isBotMessage:!0,onClickSuggestedReply:async({reply:f})=>{r.sendUserMessage({message:f})}})}))}},Pm=e=>g.default(e).withConfig({shouldForwardProp:Qs.default}),Fm=({style:e})=>{const{stringSet:t}=W(),{isActionbookTester:n}=je();return!An("powered-by")||n?null:o.createElement(Bm,{variant:"caption2",style:e},t.POWERED_BY+" ",o.createElement(Um,{variant:"caption2",as:"a",href:"https://delight.ai?utm_medium=product&utm_source=aiagent&utm_campaign=fy26-glbl-ai-agent-poweredby","aria-label":"Learn more about Delight AI Agent",rel:Tn,target:"_blank"},"Sendbird"))},Bm=g.default($)`color:${h.themedColor.textLowEmphasis};text-align:center;`,Um=Pm($)`
|
|
277
|
+
color: ${h.themedColor.textLowEmphasis};
|
|
278
|
+
cursor: pointer;
|
|
279
|
+
text-decoration: none;
|
|
280
|
+
`,Hm=()=>{var i;const{stringSet:e}=W(),{channelSource:t,goToActiveConversation:n,scrollSource:r}=se(),s=ae(t.channel),a=d.useRef(s);return d.useEffect(()=>{if(!a.current&&s){const u=setTimeout(()=>{r.actions.scrollToBottom()},100);return()=>clearTimeout(u)}a.current=s},[s,r.actions.scrollToBottom]),!((i=t.channel)!=null&&i.isAIAgent)||!s?null:o.createElement(Vm,null,o.createElement(zm,{variant:"button",role:"button",color:h.themedColor.textHighEmphasis,onClick:()=>n()},e.TALK_TO_AGENT))},Vm=g.default.div`display:flex;justify-content:center;margin-bottom:16px;`,zm=g.default($)`border-radius:6px;box-sizing:border-box;padding:10px 20px;border:1px solid ${h.themedColor.textDisabled};cursor:pointer;user-select:none;`,Gm=()=>{var X,z,Re,Ht;const{Template:e}=lt.useContext(),{Template:t}=Oe.useContext(),{Template:n}=Dt.useContext(),{components:r}=Ft.useContext(),{stringSet:s}=W(),{config:a,cache:i,agentPreviewConfigs:l,chatSDK:c,state:u}=j(),{userSession:m,aiAgentInfo:p,connectionError:E}=re(),{conversation:y,channelSource:x,messageSource:b,scrollSource:f,state:{input:_,streamAnimation:v}}=se(),{isActionbookTester:A}=je(),{filteredMessages:T,shouldShowOriginalDate:k,renderAgentPreviewWelcomeMessages:L}=Nm(),S=Za(x.channel),[O,U]=d.useState(null),[R,I]=d.useState(null);d.useEffect(()=>{f.actions.onTypingIndicatorUpdate(!!S)},[!!S,f.actions.onTypingIndicatorUpdate]),d.useEffect(()=>{f.state.isAwayFromBottom||b.resetNewMessages()},[f.state.isAwayFromBottom]);const H=(M,De=!1)=>{var P;return De?p:((P=x.channel)==null?void 0:P.members.find(q=>q.userId===M.sender.userId))??M.sender},D=M=>{if(M.sendingStatus==="failed"&&!_.disabled)return()=>I(M)},V=({message:M,index:De})=>{const P=eo(M),q=T[De-1],ee=T[De+1],Ee=T[T.length-1],ie=M===Ee,te=tt(M,p.userId),be=!(p.isUserFeedbackEnabled&&te&&!we.isWelcomeMessage(M)),de=to(M,q,ee,be),ue=!js.isSameDay((q==null?void 0:q.createdAt)??0,M.createdAt)&&k(De)&&!A,ze=Ne=>{U({files:Ne.files.map(ut=>({...ut,timestamp:M.createdAt})),index:Ne.index})},Vt=Ne=>{ze({files:[Ne],index:0})},Bs=()=>{M.isFileMessage()&&wn(M.url)},Us=ue?o.createElement(r.DateSeparator,{style:{margin:"16px 0"},date:M.createdAt}):null,dt={data:M.data,maxBodyWidth:u.expanded?B.WIDE_BODY_MAX_WIDTH:void 0,extendedMessagePayload:M.extendedMessagePayload,createdAt:M.createdAt,groupType:de,onClickMedia:Vt,onClickMediaFiles:ze,onClickFile:Bs},Hs=()=>{if(Ge.isOutgoing(M,m.userId))return"outgoingmessage";if(Ge.isIncoming(M,m.userId))return"incomingmessage"},Vs=(()=>{var Ne,ut,Bn;if(Ge.isAdmin(M))return Ge.isCSAT(M)?y?o.createElement(n,{...dt,...y,isResolvedWhenDeterminedByUser:Io(y),messageType:"admin.csat",onSubmitCSAT:async _e=>{var G;await((G=x.channel)==null?void 0:G.submitCSAT(_e))},onScrollToBottom:()=>f.actions.scrollToBottom()}):null:o.createElement(n,{...dt,messageType:"admin",message:M.message});if(Ge.isOutgoing(M,m.userId)){const _e={...dt,message:M.message,sender:H(M),sendingStatus:M.sendingStatus,onClickFailedMessage:D(M)};if(M.isUserMessage())return o.createElement(e,{messageType:"user",..._e});if(M.isFileMessage()){const[G,ne]=((Ne=M.metaArrays.find(Ce=>Ce.key===wr))==null?void 0:Ne.value)??[];return o.createElement(e,{messageType:"file",file:M,metadata:{aspectRatio:G&&ne?`${G}/${ne}`:"1/1",localFile:(ut=M.messageParams)==null?void 0:ut.file},..._e})}if(M.isMultipleFilesMessage()){const{files:G,metadata:ne}=ir(M);return o.createElement(e,{messageType:"multipleFiles",files:G,metadata:ne,..._e})}}if(Ge.isIncoming(M,m.userId)){const _e={...dt,sender:H(M,te),message:M.message,suggestedRepliesVisible:ie,suggestedRepliesDirection:l==null?void 0:l.suggestedRepliesDirection,isBotMessage:te,isStreaming:we.isStreaming(M),isHandedOff:qe(x.channel),isConversationClosed:ae(x.channel),isFeedbackEnabled:p.isUserFeedbackEnabled,isFeedbackCommentEnabled:p.isUserFeedbackCommentOptionEnabled,isSenderAvatarVisible:(Bn=a==null?void 0:a.conversation)==null?void 0:Bn.senderAvatarEnabled,onClickSuggestedReply:async({reply:G})=>{b.sendUserMessage({message:G})},onRequestMessageTemplate:async G=>{const{template:ne}=await c.aiAgent.getMessageTemplate(G);return i.template.set(G,ne),ne},onGetCachedMessageTemplate:G=>i.template.get(G),onHandleTemplateInternalAction:G=>{if(G.type==="internal"&&G.internalData){const{method:ne,payload:Ce}=G.internalData;ne==="message.send"&&(Ce!=null&&Ce.message)&&b.sendUserMessage({message:Ce.message})}},onFeedbackUpdate:G=>{const ne={messageId:M.messageId,channelUrl:M.channelUrl};if(!G)return c.aiAgent.deleteMessageFeedback(ne);const Ce={...ne,rating:Tc(G.rating),comment:G.comment};return we.hasFeedback(M)?c.aiAgent.updateMessageFeedback(Ce):c.aiAgent.createMessageFeedback(Ce)},onSubmitForm:({key:G,data:ne})=>c.aiAgent.submitForm({messageId:M.messageId,channelUrl:M.channelUrl,formKey:G,formData:ne}),onCancelForm:({key:G})=>c.aiAgent.cancelForm({messageId:M.messageId,channelUrl:M.channelUrl,formKey:G}),onStreamAnimationStart:()=>{v.start(M.messageId)},onStreamAnimationProgress:()=>{f.actions.onStreamingUpdate(!0)},onStreamAnimationComplete:()=>{v.stop(M.messageId),f.actions.onStreamingUpdate(!1)}};if(M.isUserMessage())return o.createElement(t,{messageType:"user",..._e});if(M.isFileMessage())return o.createElement(t,{messageType:"file",file:M,..._e});if(M.isMultipleFilesMessage()){const{files:G}=ir(M);return o.createElement(t,{messageType:"multipleFiles",files:G,..._e})}}})();return o.createElement("div",{key:P,id:`${oe}-message-item`,role:"listitem","data-layout-id":Hs()},Us,Vs)};return o.createElement(Wm,{id:`${oe}-message-list`},o.createElement(Xu,{ref:f.ref,onScroll:f.props.onScroll,stackDirection:l==null?void 0:l.messageStackDirection,messages:T,renderMessage:V,onLoadPrev:b.loadPrevious,onLoadNext:b.loadNext,depsForResetScrollPositionToBottom:[b.initialized,b.messages.length!==0],bottomSpacerHeight:f.state.bottomSpace,ariaLabel:s.A11Y_MESSAGE_LIST,loading:!b.initialized||!x.channel,empty:T.length===0&&!S,error:!!(E||x.error),LoadingComponent:o.createElement(Je,{type:"loading"}),EmptyComponent:(()=>{const M=L();return M?o.createElement("div",{style:{width:"100%"}},M):o.createElement(Je,{type:"noMessages",label:s.PLACE_HOLDER__NO_MESSAGES})})(),ErrorComponent:o.createElement(Je,{type:"error",label:(E==null?void 0:E.message)??((X=x.error)==null?void 0:X.message),action:x.error?{label:s.RETRY,onClick:()=>x.refetch()}:void 0}),messageTopArea:o.createElement(o.Fragment,null,o.createElement(Fm,{style:{marginTop:16}}),L()),messageBottomArea:o.createElement(o.Fragment,null,S&&o.createElement("div",{id:`${oe}-message-item`,role:"listitem",style:{marginTop:T.length===0?8:0}},o.createElement(t,{isTyping:!0,isBotMessage:S.isBot,sender:S.user,messageType:"user",groupType:"single",message:"",isSenderAvatarVisible:(z=a==null?void 0:a.conversation)==null?void 0:z.senderAvatarEnabled})),((Re=a==null?void 0:a.conversation)==null?void 0:Re.isTalkToAgentViewEnabled)&&o.createElement(Hm,null)),overlayArea:o.createElement(o.Fragment,null,((Ht=a==null?void 0:a.conversation)==null?void 0:Ht.newMessageIndicatorEnabled)&&f.state.isAwayFromBottom&&b.newMessages.length>0&&o.createElement(qm,{label:s.SCROLL_TO_NEW_MESSAGES_LABEL(b.newMessages),ariaLabel:s.A11Y_SCROLL_TO_NEW_MESSAGES,onClick:()=>f.actions.scrollToBottom()}),f.state.isAwayFromBottom&&b.newMessages.length===0&&!S&&o.createElement(r.ScrollToBottomButton,{ariaLabel:s.A11Y_SCROLL_TO_BOTTOM,onClick:()=>f.actions.scrollToBottom(),style:{position:"absolute",bottom:12,insetInlineEnd:16}}))}),O&&o.createElement(om,{files:O.files,initialIndex:O.index,onClose:()=>U(null),visible:!0}),R&&o.createElement(ke,{visible:!0,onClose:()=>I(null)},o.createElement(ke.ActionItem,{onClick:()=>{b.resendMessage(R),I(null)}},s.FAILED_MESSAGE_RESEND),o.createElement(ke.ActionItem,{destructive:!0,onClick:()=>{b.deleteMessage(R),I(null)}},s.FAILED_MESSAGE_REMOVE)))},Wm=g.default.div`overflow-y:hidden;display:flex;flex:1;position:relative;`,qm=g.default(Cm)`position:absolute;bottom:12px;left:50%;transform:translateX(-50%);`,jm=()=>o.createElement(Gm,null),Km=()=>{var s;const{origin:e}=je(),{appId:t,aiAgentId:n}=pe(),{channelSource:r}=se();return(s=r.channel)!=null&&s.conversation?o.createElement(Ym,null,o.createElement(un,{style:{gap:4}},o.createElement(F,{color:h.themedColor.textLowEmphasis,size:12,type:"show"}),o.createElement($,{as:"i",color:h.themedColor.textLowEmphasis,variant:"caption2"},"Only visible in the tester")),o.createElement(un,{role:"button",style:{gap:4},onClick:()=>{var c,u;const a=e??window.location.origin,i=(u=(c=r.channel)==null?void 0:c.conversation)==null?void 0:u.id,l=`${a}/ai-agent/${t}/${n}/evaluate/conversations/${i}`;navigator.clipboard.writeText(l)}},o.createElement($,{variant:"body3",color:h.themedColor.textHighEmphasis},"Copy ",o.createElement("span",{style:{color:h.themedColor.primary}},"conversation link")),o.createElement(F,{color:h.themedColor.primary,size:14,type:"copy"}))):null},un=g.default.div`display:flex;justify-content:center;align-items:center;`,Ym=g.default(un)`flex-direction:column;padding-block:16px;background-color:${h.themedColor.bg_100_500};gap:8px;`,Xm=e=>{const t=e[0];if(!t)return e;const n=e.some(s=>Te(s.type)),r=e.some(s=>!Te(s.type));return n&&r?Te(t.type)?e.filter(s=>Te(s.type)):[t]:r?[t]:e},Zm=(e,t)=>{const n=[],r=[],s=[];for(const a of e){const i=t.isSupportedMimeType(a.type),l=a.size<=t.getUploadSizeLimit(a.type);i&&l?n.push(a):i?r.push(a):s.push(a)}return{passed:n,failedBySize:r,failedByType:s}},bs=d.createContext(void 0),Jm=({children:e})=>{var L;const{chatSDK:t}=j(),{createAttachmentRules:n}=re(),{stringSet:r}=W(),{channelSource:s}=se(),[a,i]=d.useState([]),[l,c]=d.useState({visible:!1,title:""}),u=n({channel:s.channel,uploadSizeLimit:(L=t.appInfo)==null?void 0:L.uploadSizeLimit}),m=u.isEnabled(),p=u.maxAttachmentCount,E=S=>{c({visible:!0,title:S})},y=()=>{E(r.FILE_UPLOAD_NOTIFICATION__COUNT_LIMIT.replace("%d",p.toString()))},x=S=>{E(r.FILE_UPLOAD_NOTIFICATION__SIZE_LIMIT.replace("%d",S.toString()))},b=S=>{E(r.FILE_UPLOAD_NOTIFICATION__FILES_EXCLUDED_BY_VALIDATION.replace("%d",S.toString()))},f=S=>S.map(O=>({file:O,preview:{url:URL.createObjectURL(O),type:O.type,name:O.name}})),_=S=>{i(O=>[...O,...f(S)])},v=S=>{i(O=>(O.forEach(U=>URL.revokeObjectURL(U.preview.url)),f(S)))},A=S=>{if(!m||S.length===0)return;if(p-a.length===0){y();return}if(a.length+S.length>p){y();return}const U=Xm(S),{passed:R,failedBySize:I,failedByType:H}=Zm(U,u),D=I.length+H.length,V=U.length===1?I[0]:void 0;if(V?x(u.getUploadSizeLimitInMB(V.type)):D>0&&b(D),R.length===0)return;a.length>0&&a.every(z=>Te(z.file.type))&&R.every(z=>Te(z.type))?_(R):v(R)},T=S=>{i(O=>{var R;const U=(R=O[S])==null?void 0:R.preview;return U&&URL.revokeObjectURL(U.url),O.filter((I,H)=>H!==S)})},k=()=>{i(S=>(S.forEach(O=>URL.revokeObjectURL(O.preview.url)),[]))};return o.createElement(bs.Provider,{value:{files:a,addFiles:A,removeFile:T,clearFiles:k,isFileUploadEnabled:m,acceptableMimeTypes:u.supportedMimeTypes,maxAttachmentCount:u.maxAttachmentCount,showFileUploadAlert:E}},e,o.createElement(In,{...l,onClose:()=>c({visible:!1,title:""})}))},On=()=>{const e=d.useContext(bs);if(!e)throw new Error("useFileUpload must be used within FileUploadProvider");return e};function Qm({blurred:e,elementRef:t,document:n=window.document}){const r=d.useRef(!1);e&&t.current&&n.activeElement===t.current&&(r.current=!0),d.useLayoutEffect(()=>{var s;!e&&r.current&&((s=t.current)==null||s.focus(),r.current=!1)},[e])}const eh=(e,t)=>{d.useEffect(()=>{t?e==null||e.startTyping():e==null||e.endTyping()},[e,t])},th=g.default.div`&::-webkit-scrollbar{display:none;}overflow-x:auto;display:flex;flex-direction:row;gap:10px;padding:8px 16px;background-color:transparent;`,nh=g.default.div`display:flex;flex-shrink:0;position:relative;margin-block-start:8px;border-radius:12px;height:64px;img{border-radius:12px;object-fit:cover;width:64px;-webkit-user-drag:none;}`,rh=g.default.div`display:flex;align-items:center;justify-content:center;position:absolute;inset-inline-end:-8px;inset-block-start:-8px;cursor:pointer;border-radius:50%;${N.light`
|
|
281
|
+
background-color: ${h.color.background50};
|
|
282
|
+
`}
|
|
283
|
+
${N.dark`
|
|
284
|
+
background-color: ${h.color.background500};
|
|
285
|
+
`}
|
|
286
|
+
path {
|
|
287
|
+
fill: ${h.themedColor.textMidEmphasis};
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
&:hover {
|
|
291
|
+
path {
|
|
292
|
+
fill: ${h.themedColor.textHighEmphasis};
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
circle {
|
|
297
|
+
stroke: ${h.themedColor.bg_50_600};
|
|
298
|
+
}
|
|
299
|
+
`,sh=()=>{const e=ot(),[t,n]=d.useState(),{files:r,removeFile:s,isFileUploadEnabled:a}=On();return!a||r.length===0?null:o.createElement(th,null,r.map(({preview:{type:i,name:l,url:c}},u)=>o.createElement(nh,{key:c,onMouseOver:()=>n(u),onMouseLeave:()=>n(void 0)},(e||t===u)&&o.createElement(rh,{title:"Remove file",onClick:()=>s(u)},o.createElement(F,{type:"close-filled",color:h.themedColor.textMidEmphasis})),i.startsWith("image/")?o.createElement("img",{alt:"file-image",src:c}):o.createElement(Mn,{name:l,type:gn(l,i)}))))},oh={textArea:w.css`min-height:40px;height:40px;font-size:16px;line-height:24px;`},_s=g.default.button`all:unset;cursor:pointer;display:flex;align-items:center;justify-content:center;width:32px;height:32px;`,Cr=g.default.div`width:100%;position:relative;background-color:${h.themedColor.bg_100_500};border-radius:20px;`,xr=g.default.div`display:flex;flex-direction:row;align-items:flex-end;position:relative;`,vr=g.default.textarea`all:unset;display:block;flex:1;min-width:0;padding-top:8px;padding-bottom:8px;padding-inline-start:16px;padding-inline-end:12px;box-sizing:border-box;font-size:14px;line-height:20px;color:${h.themedColor.textHighEmphasis};resize:none;width:100%;height:${Wr}px;overflow-wrap:break-word;white-space:pre-wrap;overflow-x:hidden;${Yr&&oh.textArea};&::placeholder{color:${h.themedColor.textLowEmphasis};}&:disabled{cursor:not-allowed;&::placeholder{color:${h.themedColor.textDisabled};}}`,ah=g.default.input`display:none;`;g.default.div`display:flex;align-items:center;gap:24px;`;const ih=g.default(_s)`flex-shrink:0;border-radius:8px;&:disabled{cursor:not-allowed;}&:not(:disabled){&:hover{background-color:${h.themedColor.bg_100_500};path{fill:${h.themedColor.textHighEmphasis};}}&:active{background-color:${h.themedColor.bg_200_400};}}`,yr=g.default.div`padding:10px 16px 10px 12px;position:relative;display:flex;align-items:center;gap:8px;`,Sr=e=>e.startsWith("image/"),Ar=({disabled:e})=>{var k,L,S,O,U;const{stringSet:t}=W(),{config:n}=j(),r=d.useRef(null),s=d.useRef(null),[a,i]=d.useState(!1),{addFiles:l,isFileUploadEnabled:c,acceptableMimeTypes:u,showFileUploadAlert:m}=On(),p=u.includes(Qt),E=p?["image/*"]:u.filter(Sr),y=p?[Qt]:u.filter(R=>!Sr(R)),x=!!((S=(L=(k=n==null?void 0:n.conversation)==null?void 0:k.input)==null?void 0:L.gallery)!=null&&S.photoEnabled),b=!!((U=(O=n==null?void 0:n.conversation)==null?void 0:O.input)!=null&&U.fileEnabled),f=()=>p||E.length>0,_=()=>p||y.length>0,v=R=>{const I=R.currentTarget.files;I&&l(Array.from(I)),R.target.value=""},A=()=>{i(!0)},T=d.useMemo(()=>{const R=[];return x&&R.push({type:"image",icon:"photo",label:t.FILE_UPLOAD_PHOTOS,accept:E.join(","),inputRef:r,onSelect:()=>{if(!f()){m(t.FILE_UPLOAD_NO_SUPPORTED_FILES);return}i(!1),setTimeout(()=>{var I;return(I=r.current)==null?void 0:I.click()},100)}}),b&&R.push({type:"file",icon:"document",label:t.FILE_UPLOAD_FILES,accept:u.join(","),inputRef:s,onSelect:()=>{if(!_()){m(t.FILE_UPLOAD_NO_SUPPORTED_FILES);return}i(!1),setTimeout(()=>{var I;return(I=s.current)==null?void 0:I.click()},100)}}),R},[E,u,t,x,b]);return c?o.createElement(o.Fragment,null,o.createElement(ih,{disabled:e,onClick:A,"aria-label":t.A11Y_ATTACH_FILE},o.createElement(F,{type:"add",color:e?h.themedColor.textDisabled:h.color.primary.main,size:20})),T.map(R=>o.createElement(ah,{key:R.type,type:"file",ref:R.inputRef,multiple:R.type==="image",onChange:v,accept:R.accept})),o.createElement(ke,{visible:a,onClose:()=>i(!1)},T.map(R=>o.createElement(ke.ActionItem,{key:R.type,onClick:R.onSelect,icon:R.icon},R.label)))):null},lh=()=>{const e=d.useRef(null),[t,n]=d.useState(""),{stringSet:r}=W(),{rootElement:s}=j(),{channelSource:a,messageSource:i,state:l}=se(),{files:c,addFiles:u,clearFiles:m}=On(),p=l.input.disabled,E=(()=>{if(!p)return r.MESSAGE_INPUT__PLACE_HOLDER;switch(l.input.disabledBy){case"form_active":return r.FORM_PLACEHOLDER;case"ai_responding":return r.MESSAGE_INPUT__PLACE_HOLDER__WAIT_AI_AGENT_RESPONSE;case"suggested_replies":return r.MESSAGE_INPUT__PLACE_HOLDER__SUGGESTED_REPLIES;case"reconnecting":return r.MESSAGE_INPUT__PLACE_HOLDER__RECONNECTING;case"unavailable":case"conversation_closed":default:return r.MESSAGE_INPUT__PLACE_HOLDER__DISABLED}})();ol({onDropFiles:u}),Qm({blurred:p,elementRef:e,document:Ue(s)}),eh(a.channel,t);const y=t.trim().length>0,x=c.length>0,b=!p&&(y||x),f=()=>{e.current&&(e.current.value="",e.current.style.height=""),m(),n("")},_=async()=>{const k=t.trim();if(!k&&!c.length)return;const L=[...c];if(f(),L.length===0){i.sendUserMessage({message:k});return}if(L.length===1)await i.sendFileMessage({message:k,file:L[0].file});else{const S=L.map(({file:O})=>({file:O}));await i.sendMultipleFilesMessage({message:k,fileInfoList:S})}},v=k=>{const L=Array.from(k.clipboardData.files);L.length>0&&(k.preventDefault(),u(L))},A=k=>{k.key!=="Enter"||k.nativeEvent.isComposing||k.shiftKey||(k.preventDefault(),_())},T=k=>{if(e.current){e.current.style.height="";const L=Math.min(oi,e.current.scrollHeight);Wr<L&&(e.current.style.height=`${L}px`)}n(k.target.value)};return p?o.createElement(yr,null,o.createElement(Ar,{disabled:!0}),o.createElement(Cr,null,o.createElement(xr,null,o.createElement(vr,{disabled:!0,placeholder:E})))):o.createElement(yr,null,o.createElement(Ar,null),o.createElement(Cr,null,o.createElement(sh,null),o.createElement(xr,null,o.createElement(vr,{ref:e,role:"textbox","aria-label":"Text Input",placeholder:E,maxLength:5e3,onKeyDown:A,onChange:T,onPaste:v}))),b&&o.createElement(_s,{onClick:()=>_()},o.createElement(F,{type:"send",color:h.color.primary.main,size:20})))},ch=g.default.div`padding:8px 16px;text-align:center;word-break:break-word;white-space:pre-wrap;line-height:1.43;letter-spacing:-0.2px;font-size:14px;font-weight:400;color:${h.themedColor.textLowEmphasis};&& a{font-weight:700;text-decoration:none;${N.light`
|
|
300
|
+
color: ${h.color.information.light};
|
|
301
|
+
`};
|
|
302
|
+
${N.dark`
|
|
303
|
+
color: ${h.color.information.main};
|
|
304
|
+
`};
|
|
305
|
+
}
|
|
306
|
+
`,dh=d.lazy(()=>Promise.resolve().then(()=>require("./cjs/D2Opuq0j.cjs")).then(e=>({default:e.MarkdownText}))),uh=()=>{const{aiAgentInfo:e,userSession:t}=re(),{messageSource:n,channelSource:r}=se(),[s,a]=d.useState(null),i=An("special-notice",r.channel),l=d.useCallback(()=>r.channel?i?n.messages.some(c=>tt(c,(t==null?void 0:t.userId)??"")):!0:null,[r.channel,i,n.messages,t==null?void 0:t.userId]);return d.useEffect(()=>{s||a(l())},[l,s]),s||!e.specialNotice?null:o.createElement(ch,null,o.createElement(dh,null,e.specialNotice))},mh=()=>o.createElement(hh,null,o.createElement(uh,null),o.createElement(Jm,null,o.createElement(lh,null))),hh=g.default.div`z-index:0;border:none;width:100%;`,gh=()=>{var s;const{testerType:e}=je(),{channelSource:t}=se(),n=ae(t.channel),r=!!e&&((s=t.channel)==null?void 0:s.isAIAgent);return n&&r?o.createElement(Km,null):o.createElement(mh,null)},Cs=({start:e,title:t,titleAlign:n="start",end:r})=>{const s=d.useRef(null),a=d.useRef(null),[i,l]=d.useState(0),[c,u]=d.useState(0);return d.useLayoutEffect(()=>{s.current&&l(s.current.offsetWidth),a.current&&u(a.current.offsetWidth)},[e,r]),o.createElement(fh,null,o.createElement(ph,null,n==="center"&&t&&o.createElement(Eh,{$sideWidth:Math.max(i,c)},o.createElement(bh,null,t)),o.createElement(_h,null,o.createElement(Ch,{ref:s},e),(n==="start"||n==="end")&&t&&o.createElement(vh,{$align:n,$hasStart:!!e,$hasEnd:!!r},t),o.createElement(xh,{ref:a},r))))},fh=g.default.div`position:relative;width:100%;background-color:${({theme:e})=>e.colors.base.headerBackground};border-bottom:1px solid ${h.themedColor.textDisabled};`,ph=g.default.div`position:relative;height:56px;padding:11px 12px;`,Eh=g.default.div`position:absolute;left:${({$sideWidth:e})=>e}px;right:${({$sideWidth:e})=>e}px;top:0;bottom:0;display:flex;align-items:center;justify-content:center;`,bh=g.default.div`max-width:100%;overflow:hidden;`,_h=g.default.div`display:flex;flex-direction:row;align-items:center;justify-content:space-between;height:100%;z-index:1;`,Ch=g.default.div`flex-shrink:0;display:flex;align-items:center;`,xh=g.default.div`flex-shrink:0;display:flex;align-items:center;`,vh=g.default.div`flex:1;overflow:hidden;display:flex;align-items:${({$align:e})=>e==="start"?"flex-start":"flex-end"};margin-left:${({$hasStart:e})=>e?8:0}px;margin-right:${({$hasEnd:e})=>e?8:0}px;`,ct=()=>ot()?24:16,yh=()=>{const{state:e}=j(),t=ct(),n=()=>{e.setOpened(!1)};return o.createElement(Se,{"aria-label":"close messenger",type:"close",size:t,onClick:n})},Sh=()=>{const{enableCloseConversationButton:e,dispatcher:t}=j(),{channelSource:n}=se(),r=n.channel,s=ct(),a=(r==null?void 0:r.isAIAgent)&&e,i=!En(r);if(!a)return null;const l=async()=>{r&&await t.send(Be.CloseConversation({channelUrl:r.url}))};return o.createElement(Se,{"aria-label":"close conversation",type:"mute",size:s,disabled:i,onClick:l})},Ah=()=>{const{state:e,enableExpandButton:t}=j(),n=ct();return t?o.createElement(Se,{"aria-label":"expand",type:e.expanded?"collapse":"expand",size:n,onClick:()=>e.setExpanded(!e.expanded)}):null},Th=({label:e,children:t,position:n="top",disabled:r})=>r?t:o.createElement(mn,null,t,o.createElement(kh,{$position:n},o.createElement(Mh,{variant:"caption1"},e),o.createElement(Ih,{$position:n}))),Ih=({$position:e})=>o.createElement("svg",{style:{transform:e==="top"?"rotate(0)":"rotate(180deg)"},xmlns:"http://www.w3.org/2000/svg",width:"12",height:"6",viewBox:"0 0 12 6",fill:"none"},o.createElement("path",{d:"M6 6L0 0h12L6 6Z",fill:h.themedColor.textHighEmphasis})),wh={top:w.css`flex-direction:column;top:0;transform:translate(-50%,-100%);`,bottom:w.css`flex-direction:column-reverse;bottom:0;transform:translate(-50%,100%);`},mn=g.default.div`position:relative;`,kh=g.default.div`display:flex;align-items:center;position:absolute;left:50%;z-index:${He.TOOLTIP};${({$position:e})=>wh[e]}opacity:0;transition:opacity 0.2s ease-in-out;pointer-events:none;${mn}:hover &,${mn}:focus-within &{opacity:1;}`,Mh=g.default($)`padding:6px 8px;background:${h.themedColor.textHighEmphasis};color:${h.themedColor.textHighEmphasisInverse};border-radius:4px;font-size:12px;white-space:nowrap;`,$h=()=>{const{logger:e}=j(),{stringSet:t}=W(),{channelSource:n}=se(),r=n.channel,s=ct(),a=An("handoff-button",r),i=!En(r)||qe(r),l=async()=>{try{const c=await(r==null?void 0:r.markConversationAsHandoff());e.info("conversation.handleAgentHandoff: success",c)}catch(c){e.error("conversation.handleAgentHandoff: error",c)}};return a?o.createElement(Th,{label:t.HEADER_BUTTON__AGENT_HANDOFF,position:"bottom",disabled:i},o.createElement(Se,{"aria-label":"request handoff",type:"agent",size:s,disabled:i,onClick:l})):null},Lh=()=>{const{stringSet:e}=W(),{onNavigateToConversationList:t}=se();return t?o.createElement(Se,{type:"menu",size:24,onClick:()=>t(),"aria-label":e.A11Y_OPEN_CONVERSATION_LIST}):null},xs=({channel:e,size:t=40})=>{const{userSession:n,aiAgentInfo:r}=re(),{fallbackIcon:s,url:a}=Gr({channel:e,aiAgentInfo:r,userSession:n}),i=w.useTheme();return a?o.createElement(os,{src:a,size:t}):o.createElement(Oh,{$size:t,$bgColor:i.colors.base.primary},o.createElement(F,{type:s,size:t*.55,color:i.colors.base.primaryContrastContent}))},Oh=g.default.div`width:${({$size:e})=>e}px;height:${({$size:e})=>e}px;border-radius:50%;background-color:${({$bgColor:e})=>e};display:flex;align-items:center;justify-content:center;flex-shrink:0;`,Rh=()=>{var l,c;const{channelSource:e}=se(),{aiAgentInfo:t,userSession:n}=re(),{config:r}=pe(),s=e.channel,a=Gr({channel:s,userSession:n,aiAgentInfo:t}),i=(c=(l=r==null?void 0:r.conversation)==null?void 0:l.header)==null?void 0:c.avatarEnabled;return o.createElement(Dh,null,i&&o.createElement(xs,{channel:s,size:34}),o.createElement(Nh,{variant:"h2",color:h.themedColor.textHighEmphasis},a.title))},Dh=g.default.div`display:flex;flex-direction:row;align-items:center;gap:6px;overflow:hidden;`,Nh=g.default($)`text-overflow:ellipsis;overflow:hidden;white-space:nowrap;padding:2px 0;`,Ph=e=>{const{components:t}=Ve.useContext();return o.createElement(Cs,{start:o.createElement(t.StartArea,null),title:o.createElement(t.TitleArea,null),titleAlign:e.titleAlign,end:o.createElement(t.EndArea,null)})},Fh=()=>{const{components:e}=Ve.useContext();return o.createElement(e.MenuButton,null)},Bh=()=>{const{components:e}=Ve.useContext();return o.createElement(e.Title,null)},Uh=()=>{const{components:e}=Ve.useContext();return o.createElement(Vh,null,o.createElement(e.HandoffButton,null),o.createElement(e.ConversationCloseButton,null),o.createElement(e.ExpandButton,null),o.createElement(e.CloseButton,null))},Ve=fe({template:Ph,components:{StartArea:Fh,TitleArea:Bh,EndArea:Uh,MenuButton:Lh,Title:Rh,HandoffButton:$h,ConversationCloseButton:Sh,ExpandButton:Ah,CloseButton:yh}}),Hh=()=>{const{isActionbookTester:e}=je(),{Template:t}=Ve.useContext();return e?null:o.createElement(t,{titleAlign:"start"})},Vh=g.default.div`display:flex;gap:10px;align-items:center;justify-content:center;`,vs=({children:e,onNavigateToConversationList:t,channelUrl:n,onClearChannelUrl:r,shouldMarkAsRead:s,style:a,closedChannelUrl:i,onClearClosedChannelUrl:l})=>{const{Template:c}=Bt.useContext();return o.createElement(Qr,{onNavigateToConversationList:t,channelUrl:n??i,onClearChannelUrl:r??l,shouldMarkAsRead:s},o.createElement(ln,null,o.createElement(ln.Consumer,null,u=>o.createElement(o.Fragment,null,o.createElement(Gh,{style:a,...u},o.createElement(c,null)),e))))},zh=()=>{const{components:e}=Bt.useContext();return o.createElement(o.Fragment,null,o.createElement(e.Header,null),o.createElement(e.Body,null),o.createElement(e.Footer,null))},Bt=fe({template:zh,components:{Header:Hh,Body:jm,Footer:gh}}),Gh=g.default.div`height:100%;width:100%;display:flex;flex-direction:column;flex:1;background-color:${({theme:e})=>e.colors.base.background};`,{Provider:Wh,Context:qh,useContext:Rn}=Q("ConversationList");function ys({conversationListLimit:e,conversationListFilter:t,onOpenConversationView:n=ve,children:r}){return o.createElement($a,{conversationListLimit:e,conversationListFilter:t},s=>o.createElement(Wh,{value:{...s,onOpenConversationView:n}},r))}const jh=({channel:e})=>o.createElement(xs,{channel:e}),hn=99,Kh=e=>{var c;const{channel:t,onClick:n}=e,{stringSet:r,format:s}=W(),a=Ko(t,{formatMultipleFilesCount:r.CONVERSATION_LIST__MULTIPLE_FILES_COUNT}),i=Yo(t,s,{justNow:r.DATE_FORMAT__JUST_NOW,minutesAgo:r.DATE_FORMAT__MINUTES_AGO,hoursAgo:r.DATE_FORMAT__HOURS_AGO,dateShortFormat:r.DATE_FORMAT__DATE_SHORT}),l=t.unreadMessageCount;return o.createElement(Yh,{role:"button",onClick:()=>n==null?void 0:n()},o.createElement(Xh,null,o.createElement(jh,{...e})),o.createElement(Zh,null,o.createElement(Jh,null,(c=t.lastMessage)!=null&&c.isFileMessage()&&(!t.lastMessage.message||t.lastMessage.name===t.lastMessage.message)?o.createElement(ts,{variant:"subtitle1",color:h.themedColor.textHighEmphasis},a):o.createElement($,{variant:"subtitle1",color:h.themedColor.textHighEmphasis,maxTextLines:1},a),o.createElement(Qh,null,ae(t)&&o.createElement(o.Fragment,null,o.createElement($,{variant:"caption1",color:h.themedColor.textMidEmphasis,maxTextLines:1},r.CONVERSATION_LIST__ENDED),o.createElement(eg,null)),o.createElement($,{variant:"caption2",color:h.themedColor.textLowEmphasis,maxTextLines:1},i))),l>0&&o.createElement(tg,{$count:l},o.createElement($,{variant:"caption3",color:h.themedColor.textHighEmphasisInverse},l<=hn?l:`${hn}+`))))},Dn=fe({template:Kh,components:{}}),Yh=g.default.div`display:flex;flex-shrink:0;flex-direction:row;align-items:center;position:relative;width:100%;height:72px;box-sizing:border-box;gap:16px;cursor:pointer;`,Xh=g.default.div`display:flex;align-items:center;justify-content:center;padding-inline-start:16px;`,Zh=g.default.div`display:flex;flex-direction:row;align-items:center;flex:1;min-width:0;padding-inline-end:16px;height:100%;gap:8px;border-bottom:1px solid ${h.themedColor.textDisabled};`,Jh=g.default.div`display:flex;flex-direction:column;justify-content:center;flex:1;min-width:0;gap:4px;word-break:break-word;overflow-wrap:break-word;`,Qh=g.default.div`display:flex;align-items:center;gap:6px;`,eg=g.default.div`width:2px;height:2px;border-radius:1px;background-color:${h.themedColor.textLowEmphasis};`,tg=g.default.div`display:flex;align-items:center;justify-content:center;height:20px;padding:4px;border-radius:10px;background-color:${h.themedColor.error};${({$count:e})=>e<=hn&&w.css`
|
|
307
|
+
width: 20px;
|
|
308
|
+
`}
|
|
309
|
+
`,ng=({items:e,renderItem:t,onEndReached:n})=>{const r=s=>{const a=s.target;a.scrollHeight-a.scrollTop===a.clientHeight&&(n==null||n())};return o.createElement(rg,{onScroll:s=>r(s)},e.map((s,a)=>t(s,a)))},rg=g.default.div`width:100%;height:100%;display:flex;flex-direction:column;flex:1;overflow:auto;overscroll-behavior:contain;`,sg=()=>{const{stringSet:e}=W(),{listSource:t,onOpenConversationView:n}=Rn(),{Template:r}=Dn.useContext();return t.initialized?t.channels.length===0?o.createElement(Je,{type:"noChannels",label:e.CONVERSATION_LIST__NO_CONVERSATIONS}):o.createElement(ng,{items:t.channels,renderItem:s=>{var a,i,l;return o.createElement(r,{key:s.url,channel:s,onClick:()=>n(s.url,ae(s)?"closed":"open"),channelUrl:s.url,title:(i=(a=s.conversation)==null?void 0:a.topics)==null?void 0:i.join(", "),lastMessageTimestamp:(l=s.lastMessage)==null?void 0:l.createdAt})},onEndReached:()=>{t.loadMore()}}):o.createElement(Je,{type:"loading"})},og=()=>{const{stringSet:e}=W(),{language:t,countryCode:n,context:r}=j(),{aiAgentInfo:s,refreshActiveChannel:a,createConversation:i,setActiveChannel:l}=re(),{onOpenConversationView:c}=Rn();return o.createElement(ag,{role:"button",onClick:async()=>{if(s.isMultipleActiveConversationsEnabled){const u=await i({aiAgentId:s.userId,language:t,country:n,context:r});l({url:u,status:"open"}),c(u,"open")}else{const u=await a();c(u,"open")}}},o.createElement(ig,{variant:"h1"},e.TALK_TO_AGENT))},ag=g.default.div`background-color:${({theme:e})=>e.colors.base.primary};display:flex;align-items:center;justify-content:center;padding:16px;cursor:pointer;`,ig=g.default($)`color:${({theme:e})=>e.colors.base.primaryContrastContent};overflow:hidden;text-overflow:ellipsis;white-space:nowrap;`,lg=()=>{const{state:e}=j(),t=ct(),n=()=>{e.setOpened(!1)};return o.createElement(Se,{"aria-label":"close messenger",type:"close",size:t,onClick:n})},cg=()=>{const{stringSet:e}=W();return o.createElement(dg,{variant:"h2",color:h.themedColor.textHighEmphasis},e.CONVERSATION_LIST__HEADER_TITLE)},dg=g.default($)`padding:0 4px;width:100%;box-sizing:border-box;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;`,ug=e=>{const{components:t}=Ke.useContext();return o.createElement(Cs,{start:o.createElement(t.StartArea,null),title:o.createElement(t.TitleArea,null),titleAlign:e.titleAlign,end:o.createElement(t.EndArea,null)})},mg=()=>null,hg=()=>{const{components:e}=Ke.useContext();return o.createElement(e.Title,null)},gg=()=>{const{components:e}=Ke.useContext();return o.createElement(e.CloseButton,null)},Ke=fe({template:ug,components:{StartArea:mg,TitleArea:hg,EndArea:gg,Title:cg,CloseButton:lg}}),fg=()=>{const{Template:e}=Ke.useContext();return o.createElement(e,{titleAlign:"start"})},Ss=({conversationListLimit:e,conversationListFilter:t,children:n,onOpenConversationView:r,style:s})=>{const{Template:a}=Ut.useContext();return o.createElement(ys,{conversationListLimit:e,conversationListFilter:t,onOpenConversationView:r},o.createElement(Eg,{style:s},o.createElement(a,null)),n)},pg=()=>{const{components:e}=Ut.useContext();return o.createElement(o.Fragment,null,o.createElement(e.Header,null),o.createElement(e.Body,null),o.createElement(e.Footer,null))},Ut=fe({template:pg,components:{Header:fg,Body:sg,Footer:og}}),Eg=g.default.div`height:100%;width:100%;display:flex;flex-direction:column;flex:1;background-color:${({theme:e})=>e.colors.base.background};`,bg=w.css`:where(#${ce.ENTRY}) :not(code *){font-family:'Roboto',sans-serif;box-sizing:border-box;}`,_g=[bg,_i,Ci],Cg=(e,...t)=>w.createGlobalStyle(e,..._g,...t),xg=Cg``,vg=jo(Bt,Oe,lt,Dt,Ft,Ut,Ve,Dn,Ke,Pt);function As({appearance:e,rootElement:t,logger:n,language:r,stringSet:s,children:a,messageTemplate:i,theme:l}){return Ai(ci,t),o.createElement(w.StyleSheetManager,{target:t},o.createElement(vi,{rootElement:t,logger:n,appearance:e,theme:l},o.createElement(Ra,{internalVariables:i==null?void 0:i.__internalVariables},o.createElement(bi,{stringSet:s,logger:n,language:r},o.createElement(vg,null,a,o.createElement(xg,null))))))}const Nn=d.forwardRef(function({rootElement:t=document.body,logLevel:n=Y.LogLevel.WARN,language:r=navigator.language,userSessionInfo:s,children:a,chatParams:i,...l},c){var u,m;return Ze.level!==n&&(Ze.level=n),Si("https://fonts.googleapis.com/css2?family=Roboto&display=swap",t),o.createElement("div",{id:ce.ENTRY,style:{width:"fit-content",height:"fit-content",...l.entryStyle}},o.createElement(As,{logger:Ze,rootElement:t,appearance:(u=l.agentPreviewConfigs)==null?void 0:u.appearance,stringSet:l.stringSet,language:r,messageTemplate:l.messageTemplate,theme:l.theme},o.createElement(Ii,{rootElement:t,language:r,logger:Ze,dispatcher:Ts,chatParams:{...i,...l.customApiHost&&{customApiHost:l.customApiHost},...l.customWebSocketHost&&{customWebSocketHost:l.customWebSocketHost}},chatSDK:l.customChatSDK,_forceCreateChannel:(m=l.agentPreviewConfigs)==null?void 0:m.forceCreateChannel,...l},o.createElement(Hi,{ref:c,userSessionInfo:s},o.createElement(zu,{...l._UNSAFE_INTERNAL_dashboardTester},a,o.createElement("div",{id:ce.MODAL_ROOT,dir:l.dir}))))))}),Ze=new Rr(Y.LogLevel.WARN),Ts=new Or(Ze),{Provider:yg,useContext:Pn}=Q("PageChildren"),Is=({children:e})=>{const[t,n]=d.useState(null),[r,s]=d.useState(null);return o.createElement(yg,{value:{conversationChildren:t,setConversationChildren:n,conversationListChildren:r,setConversationListChildren:s}},e)},ws=({children:e,isOpened:t})=>{const{dir:n,rootElement:r}=j(),s=Ue(r,!0);return d.useEffect(()=>{const a="sb-agent-block-scroll";return t?s.body.classList.add(a):s.body.classList.remove(a),()=>{s.body.classList.remove(a)}},[s,t]),o.createElement(Sg,{dir:n,$visible:t},e)},Sg=g.default.div`width:100%;height:100%;position:fixed;top:0;left:0;z-index:${He.WINDOW};visibility:${({$visible:e})=>e?"visible":"hidden"};`,Ag=48,Tg=2/3;function ks({className:e,isOpened:t,onClick:n,type:r,imageUrl:s,dir:a,animated:i=!0,backgroundColor:l,size:c=Ag}){const u=sn(l),m=Math.round(c*Tg);return o.createElement(kg,{dir:a,id:ce.LAUNCHER,className:e,"aria-label":"Sendbird AIAgent Launcher",onClick:n,$animated:i,$backgroundColor:l,$size:c},o.createElement(Mg,{$isOpened:t,$animated:i,$fillColor:u,$iconSize:m},o.createElement(Tr.Open,{url:s,isDefaultIcon:r==="default_icon",size:m})),o.createElement($g,{$isOpened:t,$animated:i,$fillColor:u,$iconSize:m},o.createElement(Tr.Close,{size:m})))}const Ig=w.css`&:hover{transition:transform 250ms cubic-bezier(0.33,0,0,1);transform:scale(1.1);}&:active{transform:scale(0.8);}`,wg=w.css`img{width:100%;height:100%;object-fit:cover;user-select:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;-webkit-user-drag:none;&[data-default-icon='true']{width:${({$iconSize:e})=>e}px;height:${({$iconSize:e})=>e}px;filter:${({$fillColor:e})=>e===et.WHITE?"grayscale(100%) brightness(2000%)":"grayscale(100%) invert(100%) saturate(0%) brightness(0%) contrast(1000%)"};}}`,Ms=w.css`svg{width:${({$iconSize:e})=>e}px;height:${({$iconSize:e})=>e}px;${({$fillColor:e})=>w.css`
|
|
310
|
+
ellipse,
|
|
311
|
+
path {
|
|
312
|
+
fill: ${e};
|
|
313
|
+
}
|
|
314
|
+
[class*='fill'] {
|
|
315
|
+
fill: ${e};
|
|
316
|
+
}
|
|
317
|
+
`}
|
|
318
|
+
}
|
|
319
|
+
`,kg=g.default.button`position:relative;padding:0;width:${({$size:e})=>e}px;height:${({$size:e})=>e}px;background:${({$backgroundColor:e})=>e};border-radius:50%;transition:all 0.3s cubic-bezier(0.31,-0.105,0.43,1.4);border:none;display:flex;justify-content:center;align-items:center;box-shadow:0 16px 24px 2px rgba(33,33,33,0.12),0 6px 30px 5px rgba(33,33,33,0.08),0 6px 10px -5px rgba(33,33,33,0.04);${({$animated:e})=>e&&Ig}`,$s=g.default.span`position:absolute;width:100%;height:100%;border-radius:50%;overflow:hidden;transition:transform 0.16s linear,opacity 0.08s linear,scale 0.16s linear;user-select:none;display:flex;justify-content:center;align-items:center;`,Mg=g.default($s)`opacity:${({$isOpened:e})=>e?0:1};transform:${({$animated:e,$isOpened:t})=>e&&(t?"rotate(-90deg) scale(0)":"rotate(0deg)")};${wg}${Ms}`,$g=g.default($s)`scale:${({$isOpened:e})=>e?1:0};transform:${({$animated:e,$isOpened:t})=>e&&(t?"rotate(0deg)":"rotate(-90deg)")};${Ms}`,Tr={Open:e=>e.url?o.createElement("img",{src:e.url,alt:"launcher-img","data-default-icon":e.isDefaultIcon}):o.createElement(F,{size:e.size,type:"delight"}),Close:({size:e})=>o.createElement(F,{size:e,type:"chevron-down"})};function Ls({className:e,size:t}){const{colors:n}=w.useTheme(),{dir:r,state:s}=j(),{launcherInfo:a,statsTrackers:i}=re();return d.useLayoutEffect(()=>{i.initialRender.setPresentMethod("launcher_toggle")},[i]),Og(),o.createElement(ks,{dir:r,className:e,isOpened:s.opened,onClick:()=>s.setOpened(!s.opened),type:a.type,imageUrl:a.imageUrl,backgroundColor:n.base.primary,size:t})}const Lg=1e3*60;function Og(){const{chatSDK:e,state:t,logger:n,enableAutoDisconnectInLauncher:r}=j(),s=d.useRef(null);d.useEffect(()=>{if(!r)return;function a(){s.current&&(clearTimeout(s.current),s.current=null)}function i(){e.connectionState===Y.ConnectionState.CLOSED&&(e.reconnect(),n.debug("useSDKInactivityTimeout: reconnected")),a(),n.debug("useSDKInactivityTimeout: clear disconnect schedule")}function l(){a(),s.current=setTimeout(async()=>{await e.disconnectWebSocket(),n.debug("useSDKInactivityTimeout: disconnected")},Lg)}t.opened?i():(l(),n.debug("useSDKInactivityTimeout: schedule disconnect"))},[r,e,t.opened])}const Os=d.createContext(null);function Rs(){const e=d.useContext(Os);if(!e)throw new Error("useNavigator() must be used within <Navigator />");return e}function Ds({children:e}){const t=Rs();return typeof e=="function"?e(t):o.createElement(o.Fragment,null,e)}const Rg=w.keyframes`0%{transform:translateY(40px);opacity:0;}100%{transform:translateY(0px);opacity:1;}`,Dg=w.keyframes`0%{transform:translateY(0px);opacity:1;}100%{transform:translateY(40px);opacity:0;}`,Ng=w.css`animation-name:${Rg};animation-duration:0.3s;animation-fill-mode:forwards;`,Pg=w.css``,Fg=w.css`animation-name:${Dg};animation-duration:0.3s;animation-fill-mode:forwards;`,Bg=w.css`visibility:hidden;`,Ug=g.default.div`position:absolute;top:0;left:0;width:100%;height:100%;${({$transitionState:e})=>{switch(e){case"entering":return Ng;case"entered":return Pg;case"exiting":return Fg;case"exited":return Bg;default:return""}}}${({$active:e})=>e?w.css`
|
|
320
|
+
z-index: 999;
|
|
321
|
+
`:w.css`z-index:1;pointer-events:none;`}
|
|
322
|
+
`;function Ct({initialId:e,children:t}){const[n,r]=d.useState([e]),s=n[n.length-1],a=d.useCallback((f,_)=>{r(v=>[...v,f]),p(v=>({...v,[f]:!0})),_!=null&&_.reset&&b(v=>({...v,[f]:(v[f]||0)+1})),y(v=>({...v,[f]:"entering"})),setTimeout(()=>{y(v=>({...v,[f]:"entered"}))},300)},[]),i=d.useCallback(()=>{r(f=>{if(f.length<=1)return f;const _=f[f.length-1];return y(v=>({...v,[_]:"exiting"})),setTimeout(()=>{y(v=>({...v,[_]:"exited"})),r(v=>v.slice(0,-1))},300),f})},[]),l=d.useMemo(()=>({navigation:{navigate:a,pop:i},activeScreenId:s}),[a,i,s]),c=d.useMemo(()=>d.Children.toArray(t).filter(f=>f.type===Ds),[t]),u=d.useMemo(()=>{const f={};return c.forEach(_=>{const{id:v,lazy:A,children:T}=_.props;f[v]={lazy:A,element:typeof T=="function"?T(l):T}}),f},[c,l]),[m,p]=d.useState(()=>{const f={};return Object.entries(u).forEach(([_,{lazy:v}])=>{v===!1&&(f[_]=!0)}),f[e]=!0,f}),[E,y]=d.useState(()=>{const f={};return Object.keys(u).forEach(_=>{_===e?f[_]="entered":f[_]="exited"}),f}),[x,b]=d.useState({});return o.createElement(Os.Provider,{value:l},o.createElement(Hg,null,Object.keys(u).map(f=>{var T;if(!m[f])return null;const _=E[f]||"exited",v=f===s,A=`${f}-${x[f]||0}`;return o.createElement(Ug,{key:A,$transitionState:_,$active:v},(T=u[f])==null?void 0:T.element)})))}const Hg=g.default.div`position:relative;width:100%;height:100%;`;Ct.Screen=Ds;const xe={conv:"conv",convList:"conv-list"},Ns=({isOpened:e,entryPoint:t,selectedChannelUrl:n,setSelectedChannelUrl:r})=>{const{conversationChildren:s,conversationListChildren:a}=Pn(),i=(()=>{switch(t){case"Conversation":return xe.conv;case"ConversationList":return xe.convList;default:return xe.conv}})(),l=o.createElement(o.Fragment,null,o.createElement(Vg,{onOpenConversationView:r}));return o.createElement(Ct,{initialId:i},o.createElement(Ct.Screen,{id:xe.conv},({navigation:c,activeScreenId:u})=>o.createElement(vs,{key:n,channelUrl:n,onClearChannelUrl:()=>r(void 0),onNavigateToConversationList:()=>c.navigate(xe.convList),shouldMarkAsRead:e&&u===xe.conv},l,s)),o.createElement(Ct.Screen,{id:xe.convList,lazy:!0},({navigation:c})=>o.createElement(Ss,{onOpenConversationView:u=>{r(u),c.navigate(xe.conv)}},l,a)))},Vg=({onOpenConversationView:e})=>{const{registerOnJoinedProactiveConversation:t}=re(),{navigation:n}=Rs();return t(({channel:r})=>{e(r.url),n.navigate(xe.conv)}),null};function zg({isExpanded:e,isOpened:t,children:n,launcher:r}){const{dir:s}=j();return o.createElement(Gg,null,o.createElement(Wg,{dir:s,id:ce.WINDOW,$isExpanded:e,$isOpened:t},n),r)}const Gg=g.default.div`display:flex;flex-direction:column;gap:8px;align-items:flex-end;`,Wg=g.default.div`background:${({theme:e})=>e.colors.base.background};display:flex;overscroll-behavior:none;-webkit-overflow-scrolling:auto;height:640px;min-height:80px;width:400px;max-width:80vw;max-height:80vh;box-shadow:0px 16px 24px 2px rgba(33,33,33,0.12),0px 6px 30px 5px rgba(33,33,33,0.08),0px 6px 10px -5px rgba(33,33,33,0.04);border-radius:16px;overflow:hidden;transition:width 200ms ease 0s,height 200ms ease 0s,max-height 200ms ease 0s,transform 150ms cubic-bezier(0,1.2,1,1) 0s,opacity 83ms ease-out 0s;transform:scale(0.15);opacity:0;transform-origin:right bottom;[dir='rtl'] &:not([dir='ltr']),&[dir='rtl']{transform-origin:left bottom;}${({$isOpened:e})=>e&&jg};${({$isExpanded:e})=>e&&qg};`,qg=w.css`width:743px;height:723px;`,jg=w.css`z-index:${He.WINDOW};pointer-events:all;transform:scale(1);opacity:1;transition:width 200ms ease 0s,height 200ms ease 0s,max-height 200ms ease 0s,transform 300ms cubic-bezier(0,1.2,1,1) 0s,opacity 83ms ease-out 0s;`,Kg=d.forwardRef(function({children:e,initialChannelUrl:t,...n},r){const s=ot(),[a,i]=d.useState(t),l=s?ws:zg;return o.createElement(Nn,{enableExpandButton:!s,ref:r,...n},o.createElement(Kr,null,({state:c})=>o.createElement(Is,null,o.createElement(l,{isExpanded:c.expanded,isOpened:c.opened,launcher:o.createElement(Ls,null)},o.createElement(Ns,{isOpened:c.opened,entryPoint:n.entryPoint,selectedChannelUrl:a,setSelectedChannelUrl:i})),e)))}),{Provider:Yg,useContext:Fn}=Q("FixedMessengerStyle");function Ps(e,t,n,r=0){const{top:s,bottom:a,start:i,end:l}=n;let c="",u="";switch(e){case"start":u=`inset-inline-start: ${he(i)}`;break;case"end":u=`inset-inline-end: ${he(l)}`;break}switch(t){case"top":c=`top: calc(${he(s)} + ${r}px)`;break;case"bottom":c=`bottom: calc(${he(a)} + ${r}px)`;break}return w.css`${c};${u};`}function Xg(e){const{horizontal:t,vertical:n,margin:r,launcherSize:s}=Fn();return o.createElement(Zg,{...e,size:s,$horizontal:t,$vertical:n,$margin:r})}const Zg=g.default(Ls)`position:fixed;z-index:${He.LAUNCHER};${({$horizontal:e,$vertical:t,$margin:n})=>Ps(e,t,n)};`;function Jg({isExpanded:e,isOpened:t,children:n}){const{dir:r}=j(),{horizontal:s,vertical:a,margin:i,launcherSize:l}=Fn();return o.createElement(Qg,{dir:r,id:ce.WINDOW,$isExpanded:e,$isOpened:t,$horizontal:s,$vertical:a,$margin:i,$launcherSize:l},n)}const Qg=g.default.div`background:${({theme:e})=>e.colors.base.background};display:flex;overscroll-behavior:none;-webkit-overflow-scrolling:auto;position:fixed;${({$horizontal:e,$vertical:t,$margin:n,$launcherSize:r})=>Ps(e,t,n,r+12)};height:640px;min-height:80px;width:400px;max-width:80vw;max-height:80vh;box-shadow:0px 16px 24px 2px rgba(33,33,33,0.12),0px 6px 30px 5px rgba(33,33,33,0.08),0px 6px 10px -5px rgba(33,33,33,0.04);border-radius:16px;overflow:hidden;transition:width 200ms ease 0s,height 200ms ease 0s,max-height 200ms ease 0s,transform 150ms cubic-bezier(0,1.2,1,1) 0s,opacity 83ms ease-out 0s;transform:scale(0.15);opacity:0;transform-origin:${({$horizontal:e,$vertical:t})=>`${e==="start"?"left":"right"} ${t}`};
|
|
323
|
+
[dir='rtl'] &:not([dir='ltr']),
|
|
324
|
+
&[dir='rtl'] {
|
|
325
|
+
transform-origin: ${({$horizontal:e,$vertical:t})=>`${e==="start"?"right":"left"} ${t}`};
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
${({$isOpened:e})=>e&&tf};
|
|
329
|
+
${({$isExpanded:e})=>e&&ef};
|
|
330
|
+
`,ef=w.css`width:743px;height:723px;`,tf=w.css`z-index:${He.WINDOW};pointer-events:all;transform:scale(1);opacity:1;transition:width 200ms ease 0s,height 200ms ease 0s,max-height 200ms ease 0s,transform 300ms cubic-bezier(0,1.2,1,1) 0s,opacity 83ms ease-out 0s;`,Fs={top:24,bottom:24,start:24,end:24},nf=d.forwardRef(function({children:e,initialChannelUrl:t,...n},r){const[s,a]=d.useState(t),[i,l]=d.useState("end-bottom"),[c,u]=d.useState(Fs),[m,p]=d.useState(48),E=ot(),y=E?ws:Jg,{horizontal:x,vertical:b}=d.useMemo(()=>{const[f,_]=i.split("-");return{horizontal:f==="start"?"start":"end",vertical:_==="top"?"top":"bottom"}},[i]);return o.createElement(Nn,{enableExpandButton:!E,ref:r,...n},o.createElement(Kr,null,({state:f})=>o.createElement(Yg,{value:{horizontal:x,vertical:b,margin:c,launcherSize:m,setPosition:l,setMargin:u,setLauncherSize:p}},o.createElement(Is,null,o.createElement(y,{isExpanded:f.expanded,isOpened:f.opened},o.createElement(Ns,{isOpened:f.opened,entryPoint:n.entryPoint,selectedChannelUrl:s,setSelectedChannelUrl:a})),o.createElement(Xg,null),e))))}),rf=e=>{var s,a,i,l;const{setPosition:t,setMargin:n,setLauncherSize:r}=Fn();return d.useLayoutEffect(()=>{e.position&&t(e.position),e.margin&&n({...Fs,...e.margin}),e.launcherSize&&r(e.launcherSize)},[e.position,(s=e.margin)==null?void 0:s.top,(a=e.margin)==null?void 0:a.bottom,(i=e.margin)==null?void 0:i.start,(l=e.margin)==null?void 0:l.end,e.launcherSize]),null},sf=({children:e})=>{const{setConversationChildren:t}=Pn();return d.useLayoutEffect(()=>(t(e),()=>t(null)),[e]),null},of=({children:e})=>{const{setConversationListChildren:t}=Pn();return d.useLayoutEffect(()=>(t(e),()=>t(null)),[e]),null},af=Object.assign(nf,{Style:rf,ConversationChildren:sf,ConversationListChildren:of}),lf=e=>{const{refreshActiveChannel:t}=re(),[n,r]=d.useState(!1),s=d.useRef(null),a=d.useRef(null);return d.useEffect(()=>{n&&t().then(()=>{var i;(i=s.current)==null||i.call(s),r(!1)}).catch(i=>{var l;(l=a.current)==null||l.call(a,i),r(!1)})},[n]),d.useCallback(()=>new Promise((i,l)=>{s.current=i,a.current=l,e().then(()=>r(!0)).catch(l)}),[e])};Fr.set(Y.SendbirdPlatform.JS,{deviceOSPlatform:lo()?Y.DeviceOsPlatform.MOBILE_WEB:Y.DeviceOsPlatform.WEB,messengerVersion:ai,keyValueStorage:li(),networkStateAdapter:ii()});exports.ANCHOR_REL=Tn;exports.AgentProviderContainer=Nn;exports.AgentUIProviderContainer=As;exports.AnonymousSessionInfo=nn;exports.CSATType=me;exports.Commands=Be;exports.Conversation=vs;exports.ConversationContext=nl;exports.ConversationContextProvider=Qr;exports.ConversationHeaderLayout=Ve;exports.ConversationLayout=Bt;exports.ConversationList=Ss;exports.ConversationListContext=qh;exports.ConversationListContextProvider=ys;exports.ConversationListHeaderLayout=Ke;exports.ConversationListItemLayout=Dn;exports.ConversationListLayout=Ut;exports.DefaultMessenger=Kg;exports.DeskTicketPriority=xn;exports.DeskTicketStatus=Cn;exports.FixedMessenger=af;exports.IncomingMessageLayout=Oe;exports.LauncherBase=ks;exports.LogLevel=pn;exports.ManualSessionInfo=Dr;exports.MessageListUILayout=Ft;exports.MessageLogs=ps;exports.OutgoingMessageLayout=lt;exports.PlaceholderLayout=Pt;exports.SystemMessageLayout=Dt;exports.cssVars=h;exports.escapeMarkdownSyntax=ao;exports.mapCommonStringsToReactFormat=qr;exports.messengerDispatcher=Ts;exports.useConversationContext=se;exports.useConversationListContext=Rn;exports.useLocalizationContext=W;exports.useMessengerContext=j;exports.useMessengerSessionContext=re;exports.useRefreshActiveChannel=lf;
|