@sendbird/ai-agent-messenger-react 1.13.0 → 1.13.1
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/{Ci7Su9OO.cjs → BKGMHnw9.cjs} +1 -1
- package/dist/cjs/{DUJ7QCV9.cjs → BPwCUUtB.cjs} +1 -1
- package/dist/cjs/{DkIeZWe9.cjs → BdwWrAAp.cjs} +1 -1
- package/dist/cjs/{B75_RK1b.cjs → C0ghQ00S.cjs} +1 -1
- package/dist/cjs/{FPcgniHk.cjs → C6epASKA.cjs} +1 -1
- package/dist/cjs/{BR_bOr-Y.cjs → Cfl_OFPL.cjs} +1 -1
- package/dist/cjs/{DUDXGnqg.cjs → CgKaFsNM.cjs} +1 -1
- package/dist/cjs/{D3sz6O-l.cjs → DEtHXyvH.cjs} +1 -1
- package/dist/cjs/{B1EyhD-2.cjs → DHKyBmS2.cjs} +1 -1
- package/dist/cjs/{DteMrIDa.cjs → DwrHbIrU.cjs} +22 -22
- package/dist/cjs/{D0ZzpfdW.cjs → PZ2du4si.cjs} +1 -1
- package/dist/es/{D7zRQ3VS.js → -WWqhsdP.js} +1 -1
- package/dist/es/{kx5oY12W.js → 7nVEVfxl.js} +1 -1
- package/dist/es/{DsASYf2Y.js → BDvtEnu9.js} +1 -1
- package/dist/es/{D5KHmygq.js → Bsb8urZu.js} +1 -1
- package/dist/es/{DQFii4-w.js → By2XFBR_.js} +564 -569
- package/dist/es/{Dur4PKN0.js → C3PP_RTM.js} +1 -1
- package/dist/es/{BxWKGsN8.js → CFFZNjOj.js} +1 -1
- package/dist/es/{BGcty2ek.js → DIrWtn8H.js} +1 -1
- package/dist/es/{mtnNHynw.js → YUOGDsml.js} +1 -1
- package/dist/es/{4_6hq4x3.js → nGzMJZzZ.js} +1 -1
- package/dist/es/{C9VMhstH.js → yBEMlNSs.js} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +4 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var oo=Object.defineProperty;var so=(e,t,n)=>t in e?oo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var U=(e,t,n)=>so(e,typeof t!="symbol"?t+"":t,n);const u=require("react"),X=require("@sendbird/chat"),S=require("styled-components"),_e=require("date-fns"),ao=require("date-fns/locale/en-US"),Se=require("@sendbird/chat/message"),q=require("@sendbird/chat/aiAgent"),lt=require("@sendbird/chat/groupChannel"),io=require("react-dom"),Lt=require("@sendbird/react-uikit-message-template-view"),lo=require("@sendbird/uikit-message-template"),Ue=require("@sendbird/uikit-tools"),co=require("dompurify"),uo=require("date-fns/isSameDay"),mo=require("@emotion/is-prop-valid"),gt=e=>e&&e.__esModule?e:{default:e};function go(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 o=go(u),ho=gt(X),f=gt(S),Jn=gt(co),fo=gt(mo),J=(e,t)=>{const n=u.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=u.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 pe(e){const t=u.createContext({Template:e.template,updateTemplate:()=>{},components:e.components,updateComponent:()=>{}});function n({children:a}){const[i,l]=u.useState(()=>e.template),[c,d]=u.useState(e.components),h={Template:i,updateTemplate:p=>l(()=>p),components:c,updateComponent:(p,E)=>d(y=>({...y,[p]:E}))};return o.createElement(t.Provider,{value:h},a)}function r({template:a,children:i}){const{updateTemplate:l}=u.useContext(t);return u.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=()=>u.useContext(t),s.Context=t,s.Template=r,Object.keys(e.components).forEach(a=>{s[a]=function({component:l}){const{updateComponent:c}=u.useContext(t);return u.useLayoutEffect(()=>{l&&c(a,l)},[l]),null}}),s}function po(...e){return function({children:n}){return e.reduce((r,s)=>o.createElement(s,null,r),n)}}const Ae=e=>{var t,n;return!!(e!=null&&e.isAIAgent&&((t=e==null?void 0:e.conversation)==null?void 0:t.status)===q.ConversationStatus.CLOSED||e!=null&&e.isDesk&&((n=e==null?void 0:e.helpdeskInfo)==null?void 0:n.ticketStatus)==="closed")},Wt=e=>{var t,n;return!!(e!=null&&e.isAIAgent&&((t=e==null?void 0:e.conversation)==null?void 0:t.status)===q.ConversationStatus.OPEN||e!=null&&e.isDesk&&((n=e==null?void 0:e.helpdeskInfo)==null?void 0:n.ticketStatus)==="open")};function Be(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 bo(e){var t;if(((t=e==null?void 0:e.resolution)==null?void 0:t.determinedBy)==="user")return e.resolution.isResolved}function En(e){return!!e&&e<Date.now()}function Eo(e){return!e.title}function xo(e,t){var n;if(e)return Eo(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}],csat_submit_label:t.submit_label,csat_submitted_label:t.submitted_label}:e}function vo(e){const t=e.lastMessage;return t!=null&&t.isUserMessage()||t!=null&&t.isAdminMessage()?t.message||"":t!=null&&t.isFileMessage()?t.message||t.name||"FILE":e.name}function Co(e,t,n){var i;const r=new Date,s=new Date(((i=e.lastMessage)==null?void 0:i.createdAt)||e.createdAt),a=_e.differenceInMinutes(r,s);return a<1?n.justNow:a<60?n.minutesAgo(a):_e.isToday(s)?n.hoursAgo(_e.differenceInHours(r,s)):t(s,n.dateShortFormat)}const Ne="sb-agent",Qn="KEY_IMG_ASPECT_RATIO",yo="*/*",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},he=e=>!!e&&"sender"in e,_o=e=>he(e)?e.sendingStatus==="succeeded"?String(e.messageId):e.reqId:String(e.messageId),So=(e,t,n,r=!0)=>{if(!r||!he(e))return"single";const s=()=>{if(!t||!he(t))return!1;const c=t.sender.userId===e.sender.userId,d=_e.isSameMinute(t.createdAt,e.createdAt);return c&&d},a=()=>{if(!n||!he(n))return!1;const c=n.sender.userId===e.sender.userId,d=_e.isSameMinute(n.createdAt,e.createdAt);return c&&d},i=s(),l=a();return i&&l?"middle":i?"bottom":l?"top":"single"},je=(e,t)=>(()=>{var r;return he(e)?e.sender.userId:((r=e==null?void 0:e.sender)==null?void 0:r.userId)??void 0})()===t,De={isAdmin:e=>e.isAdminMessage(),isCSAT:e=>{var t;return e.isAdminMessage()&&!!((t=e.extendedMessagePayload)!=null&&t.csat)},isIncoming:(e,t)=>he(e)&&e.sender.userId!==t,isOutgoing:(e,t)=>he(e)&&(e.sender.userId===t||e.sendingStatus===Se.SendingStatus.PENDING)},er=e=>e.startsWith("image/"),tr=e=>e.startsWith("video/"),qt=(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"},nr=e=>e.messageType==="file"?e.message.length>0&&e.file.name!==e.message:e.message.length>0,jt=e=>{switch(e){case"top":case"middle":return B.GAP_GROUPED;default:return B.GAP_UNGROUPED}},To=(e,t)=>{const n=/```(\w+)?\n([\s\S]*?)```/g,r=[];let s=0;return e.replace(n,(a,...i)=>{const[l,c,d]=i;return s<d&&r.push({type:"text",value:e.slice(s,d).trim()}),r.push({type:"code",value:c.trim(),language:l?l.trim():"plaintext"}),s=d+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},Ao=e=>e.replace(/\[([^\]]+)\](?!\()/g,"\\[$1\\]"),wo=e=>e.replace(/([a-zA-Z0-9])_(?=[a-zA-Z0-9])/g,"$1\\_"),ko=e=>e.replace(/~~/g,"\\~\\~"),Io=e=>{let t=e;return t=Ao(t),t=wo(t),t=ko(t),t},$o=typeof navigator<"u"&&navigator.product==="ReactNative",xn=(e,t)=>{const n=r=>!t||t.length===0?!0:he(r)&&t.includes(r.sendingStatus);return $o?e.find(n):e.findLast(n)};function fe(){}function Mo(){const e=typeof navigator<"u"?navigator.userAgent:"",t=/iPad|iPhone|iPod/.test(e),n=/Android/.test(e);return t||n}function Lo(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 Ot=e=>{try{return JSON.parse(e===""?"{}":e)}catch{return{}}},Te={isStreaming(e){const t=Ot(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(je(e,t)){const r=Ot(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)}},Tt=`@${Ne}`,vn=({appId:e,aiAgentId:t,storage:n})=>{const r={templateBase:`${Tt}-template`,template:s=>`${r.templateBase}/templates/${s}`,templateToken:()=>`${r.templateBase}-template/message-template/tokens`,messengerSession:s=>{const a=Lo(`${e}/${t}/${s}`);return`${Tt}-udata/${a}`},anonUserSession:()=>`${Tt}-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}}}}};class rr{constructor(t){U(this,"subscribers",{});this.logger=t}async send(t){const n=Oo(),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){this.subscribers[t]&&(this.subscribers[t]=this.subscribers[t].filter(r=>r!==n))}}const Oo=()=>{let e=fe,t=fe;return{promise:new Promise((r,s)=>{e=r,t=s}),resolve:e,reject:t}};var Kt=(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))(Kt||{});class or{constructor(t){U(this,"level");this.level=t}verbose(...t){this.level<=0&&console.log(`[${Ne}/verbose]`,...t)}debug(...t){this.level<=1&&console.log(`[${Ne}/debug]`,...t)}info(...t){this.level<=2&&console.log(`[${Ne}/info]`,...t)}warn(...t){this.level<=3&&console.warn(`[${Ne}/warn]`,...t)}error(...t){this.level<=4&&console.error(`[${Ne}/error]`,...t)}}function Cn(e,t,n,r){const s=ho.default.init({appId:e,modules:[new lt.GroupChannelModule,new q.AIAgentModule],localCacheEnabled:!0,options:new X.SendbirdChatOptions({typingIndicatorInvalidateTime:2e4}),...r});return s.addSendbirdExtensions([{version:n,product:X.SendbirdProduct.AI_AGENT,platform:t.platform}],{platform:t.deviceOSPlatform,version:t.deviceOSVersion},t.customData)||console.warn("Invalid Sendbird Extensions",t),s}function Ro(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 ye={conversation:{isTalkToAgentViewEnabled:!0,scrollMode:"auto",newMessageIndicatorEnabled:!0,senderAvatarEnabled:!0,header:{avatarEnabled:!0},input:{camera:{photoEnabled:!0},gallery:{photoEnabled:!0},fileEnabled:!0},fileViewer:{downloadEnabled:!0}}},Do=e=>{var t,n,r,s,a,i,l,c,d,h,p,E,y,C;return e?{...ye,...e,conversation:{...ye.conversation,...e==null?void 0:e.conversation,header:{...(t=ye.conversation)==null?void 0:t.header,...(n=e==null?void 0:e.conversation)==null?void 0:n.header},input:{...(r=ye.conversation)==null?void 0:r.input,...(s=e==null?void 0:e.conversation)==null?void 0:s.input,camera:{...(i=(a=ye.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:{...(h=(d=ye.conversation)==null?void 0:d.input)==null?void 0:h.gallery,...(E=(p=e==null?void 0:e.conversation)==null?void 0:p.input)==null?void 0:E.gallery}},fileViewer:{...(y=ye.conversation)==null?void 0:y.fileViewer,...(C=e==null?void 0:e.conversation)==null?void 0:C.fileViewer}}}:ye},{Provider:No,useContext:K}=J("AIAgent");function Po({appId:e,aiAgentId:t,keyValueStorage:n,networkStateAdapter:r,language:s,countryCode:a,context:i,queryParams:l,config:c,chatSDK:d,chatParams:h,children:p,logger:E,dispatcher:y,messengerVersion:C,extensions:x={platform:X.SendbirdPlatform.JS,deviceOSPlatform:Mo()?X.DeviceOsPlatform.MOBILE_WEB:X.DeviceOsPlatform.WEB}}){const[m,b]=u.useState(()=>{const v=E??new or(Kt.WARN),_=y??new rr(v);return{logger:v,dispatcher:_,chatSDK:d??Cn(e,x,C,h),cache:vn({appId:e,aiAgentId:t,storage:n})}});return u.useEffect(()=>{b(v=>{let _=v.logger,I=v.dispatcher,T=v.chatSDK;return E&&E!==v.logger&&(_=E),y&&y!==v.dispatcher&&(I=y),d&&d!==v.chatSDK?T=d:!d&&v.chatSDK.appId!==e&&(T=Cn(e,x,C,{newInstance:!0,...h})),{...v,logger:_,dispatcher:I,chatSDK:T,cache:vn({appId:e,aiAgentId:t,storage:n})}})},[e,t,E,y,d,n]),u.useEffect(()=>()=>{m.chatSDK.disconnectWebSocket()},[m.chatSDK]),Ro(m.chatSDK),o.createElement(No,{value:{...m,appId:e,aiAgentId:t,context:i,language:s,countryCode:a,queryParams:l,config:Do(c),networkStateAdapter:r}},p)}const Bo=(e,t,n)=>Ue.useGroupChannelMessages(e,t,{...n,strictStreamingOrder:!0});var Rt=(e=>(e.ConversationClose="conv.close",e))(Rt||{});class Fo{constructor(t={}){U(this,"payload");this.payload=t}toJSON(){return JSON.stringify({type:this.type,payload:this.payload})}}const sr={CloseConversation:e=>new Uo(e)};class Uo extends Fo{constructor(){super(...arguments);U(this,"type","conv.close")}}const ar=(e,t,n={})=>{let r=null,s=null,a=null;const{leading:i=!0,trailing:l=!0}=n,c=(...d)=>{const h=Date.now();if(a===null||h-a>=t)i?(e(...d),a=h):(s=d,a=h);else if(s=d,l&&!r){const p=t-(h-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},qe={DEFAULT_PRIMARY:"#000000",DEFAULT_BOT_MSG_BG:"#ECECEC",WHITE:"#ffffff",BLACK:"#000000"};function ir(e){return e.length===4?`#${[...e.slice(1)].map(t=>t+t).join("")}`:e}function Ho(e){const t=ir(e);return[parseInt(t.slice(1,3),16),parseInt(t.slice(3,5),16),parseInt(t.slice(5,7),16)]}function zo(e){return`#${e.map(t=>t.toString(16).padStart(2,"0")).join("")}`}function Vo(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 Go(e,t,n){let r,s,a;if(t===0)r=s=a=n;else{const i=function(h,p,E){return E<0&&(E+=1),E>1&&(E-=1),E<.16666666666666666?h+(p-h)*6*E:E<.5?p:E<.6666666666666666?h+(p-h)*(.6666666666666666-E)*6:h},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 Qe(e,t,n){const[r,s,a]=Ho(e),[i,l,c]=Vo(r,s,a),d=Math.max(0,Math.min(1,c*t)),h=Math.max(0,Math.min(1,l*n)),[p,E,y]=Go(i,h,d);return zo([Math.round(p),Math.round(E),Math.round(y)])}function Wo(e,t="light"){return{extraDark:Qe(e,.6,1.2),dark:Qe(e,.85,1.1),main:e,light:Qe(e,t==="dark"?1.1:1.5,t==="dark"?.95:.9),extraLight:Qe(e,t==="dark"?1.2:1.75,t==="dark"?.9:.8)}}function Dt(e){const t=ir(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?qe.BLACK:qe.WHITE}function qo(e,t,n,r,s){return{base:{primary:t,primaryContrastContent:n,background:e.background50,headerBackground:e.background50,modalContentBackground:e.background50},metadata:{errorContent:e.ondark.textHighEmphasis},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 jo=(e,t,n,r,s)=>({base:{primary:t,primaryContrastContent:n,background:e.background600,headerBackground:e.background500,modalContentBackground:e.background500},metadata:{errorContent:e.ondark.textHighEmphasis},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}}),et={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)"}},At={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 yn(e){const t=Ko(e),{colors:n,aiAgentColorVariables:r}=Yo(e,t),s=Xo(e);return{selectedTheme:e.selectedTheme,palette:t,colors:n,aiAgentColorVariables:r,typography:s}}function Ko({selectedTheme:e,palette:t,primary:n}){const r=t!=null&&t.primary?t.primary:n?n===et.primary.main?et.primary:Wo(n,e):et.primary;return{...et,primary:r,...t}}function Yo({selectedTheme:e,primaryContrast:t,botMessageBackground:n,botMessageBackgroundContrast:r},s){const a=s.primary.main,i=t??Dt(a),l=n??qe.DEFAULT_BOT_MSG_BG,c=r??Dt(l);return{colors:(e==="light"?qo:jo)(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 Zo(e,t,n){const r={...e};return n.forEach(s=>{const a=t[s];a!=null&&(r[s]=a)}),r}function Xo({typography:e}){if(!e)return At;const t={...At};return Object.keys(e).forEach(n=>{const r=e[n];if(r&&typeof r=="object"){const s=At[n],a=["fontSize","fontWeight","fontFamily","lineHeight"];t[n]=Zo(s,r,a)}}),t}const{Provider:Jo,useContext:Yt}=J("AIAgentTheme");function Qo({logger:e,palette:t,typography:n,appearance:r,children:s}){const a=u.useRef(null),[i,l]=u.useState(()=>yn({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=u.useCallback((d,h)=>{h&&(a.current=h);const p=(r==null?void 0:r.theme)??d,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 C=yn({selectedTheme:p,palette:t,typography:n,...y});l(C),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 u.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(Jo,{value:{theme:i,updateTheme:c}},s)}const _n=25*1024*1024,es={off:"off",always:"always",handed_off_only:"handed_off_only"},ts=()=>{const[e,t]=u.useState(()=>({maxAttachmentCount:1,attachmentMode:"handed_off_only",defaultUploadSizeLimit:_n,uploadSizeLimitPerType:new Map,supportedImageMimeTypes:new Set(["image/png","image/jpeg","image/jpg"]),supportedFileMimeTypes:new Set(["application/pdf"])})),n=u.useCallback(({active_channel:s,upload_restriction:a})=>{const{maxAttachmentCount:i,attachmentMode:l,defaultUploadSizeLimit:c,supportedImageMimeTypes:d,supportedFileMimeTypes:h}=e;t({maxAttachmentCount:i,attachmentMode:es[s.attachment_mode]??l,defaultUploadSizeLimit:(a==null?void 0:a.default_upload_size_limit)??c,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)??d),supportedFileMimeTypes:new Set((a==null?void 0:a.supported_file_mime_types)??h)})},[]),r=u.useCallback(s=>{const{channel:a,uploadSizeLimit:i=_n}=s,l=(d=!0)=>a!=null&&a.isAIAgent?d?Be(a):!1:!0,c=d=>{if(l())return e.defaultUploadSizeLimit??i;const h=e.defaultUploadSizeLimit??i,p=e.uploadSizeLimitPerType.get(d)??h;return Math.min(h,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 Be(a);default:return!0}},get supportedMimeTypes(){return l()?[yo]:[...e.supportedImageMimeTypes,...e.supportedFileMimeTypes]},isSupportedMimeType:d=>l()?!0:e.supportedImageMimeTypes.has(d)||e.supportedFileMimeTypes.has(d),getUploadSizeLimit:c,getUploadSizeLimitInMB:d=>c(d)/(1024*1024)}},[e]);return{updateBaseAttachmentRules:n,createAttachmentRules:r}};function lr(){const{chatSDK:e,logger:t}=K();return u.useCallback(async n=>{if(n.userId===""){const r=new Error("userId cannot be empty string for messenger settings request");throw t.error("requestMessengerSettings: invalid userId",r),r}return await e.aiAgent.requestMessengerSettings(n)},[e,t])}function ns(){const{chatSDK:e,logger:t}=K(),n=u.useCallback(async(s,a,i)=>{if(t.debug("useChatConnection.connect: start, session",s.userId),a){const l=new X.SessionHandler({...a,onSessionTokenRequired:rs(a.onSessionTokenRequired,i)});e.setSessionHandler(l)}try{return await e.connect(s.userId,s.authToken),t.debug("useChatConnection.connect: end, currentUser",e.currentUser),e.currentUser}catch(l){const c=l;if(e.isCacheEnabled){if(ss(c))t.warn("useChatConnection.connect","offline connect restricted",c.message,c.code),t.warn("useChatConnection.connect","clear cached-data"),await e.clearCachedData().catch(d=>t.warn("useChatConnection.connect","clear cached-data failure",d));else if(e.currentUser)return t.debug("useChatConnection.connect: end (offline), currentUser",e.currentUser),e.currentUser}throw t.warn("useChatConnection.connect","connect failure",c.message,c.code),c}},[e,t]),r=u.useCallback(async()=>{t.debug("useChatConnection.disconnect: start"),await e.disconnect(),t.debug("useChatConnection.disconnect: end")},[e,t]);return{connect:n,disconnect:r}}function rs(e,t){if(e)return async(n,r)=>{new Promise((s,a)=>e==null?void 0:e(s,a)).then(s=>{s&&(t==null||t(s)),n(s)}).catch(s=>{r(s)})}}const os=[400300,400301,400302,400310];function ss(e){return os.some(t=>e.code===t)}class cr{constructor({userId:t,authToken:n,sessionHandler:r}){U(this,"userId");U(this,"authToken");U(this,"sessionHandler");this.userId=t,this.authToken=n,this.sessionHandler=r}}class Nt{constructor(){U(this,"userId");U(this,"authToken");U(this,"sessionHandler")}}const as=1440*60*1e3,is=e=>{const{logger:t,cache:n}=K(),r=()=>{const a=n.messenger.getAnonUser();return a?a.expireAt-as<=Date.now()?(t.debug("useUserSessionCandidate.getAnonymousSessionInfo: auto session expired, clear cache"),n.messenger.clear(a.userId),null):(t.debug("useUserSessionCandidate.getAnonymousSessionInfo: auto session info detected"),a):null},s=()=>{if(!e||e instanceof Nt)throw new Error("userSessionInfo must be an instance of ManualSessionInfo");if(typeof e.userId!="string")throw new Error("userSessionInfo.userId must be a string");const a=["userId","authToken","sessionHandler"].filter(i=>!(i in e));return a.length>0&&t.error(`useUserSessionCandidate.getManualSessionInfo: missing required keys in userSessionInfo: ${a.join(", ")}`),t.debug("useUserSessionCandidate.getManualSessionInfo: manual session info detected"),e};return u.useMemo(()=>e instanceof cr?{type:"manual",userSessionCandidate:s()}:e instanceof Nt?{type:"anonymous",userSessionCandidate:r()}:e&&typeof e=="object"?(t.warn("Please use ManualSessionInfo instead of the old userSessionInfo format."),{type:"manual",userSessionCandidate:s()}):e===void 0?(t.warn("Please use AnonymousSessionInfo instead of undefined userSessionInfo."),{type:"anonymous",userSessionCandidate:r()}):{type:"anonymous",userSessionCandidate:null},[t,e==null?void 0:e.userId,e==null?void 0:e.authToken,e==null?void 0:e.sessionHandler,n.messenger.getAnonUser,n.messenger.clear])};function ls({userSessionInfo:e,onUpdateMessengerSettings:t,onPreAuth:n,onPostAuth:r,onErrorAuth:s,onAuthTokenRefreshed:a,onPostDeauth:i,forceCreateChannel:l}){const{aiAgentId:c,language:d,context:h,countryCode:p,logger:E,cache:y}=K(),{connect:C,disconnect:x}=ns(),{type:m,userSessionCandidate:b}=is(e),v=lr(),_=u.useCallback(async()=>{var M;E.debug("useAuthentication.authenticate: start");const T=b!=null&&b.userId?y.messenger.getSettings(b.userId):null;T!=null&&T.bot&&(t(T),E.debug("useAuthentication.authenticate: cached messenger settings",T));const L=await v({aiAgentId:c,userId:b==null?void 0:b.userId,language:d,country:p,context:h,forceCreateChannel:l,knownActiveChannelUrl:(M=T==null?void 0:T.active_channel)==null?void 0:M.channel_url});E.debug("useAuthentication.authenticate: messenger settings response",L);let $=null;if(L.auto_created_user)if(m==="manual")E.warn("Received auto created user info but current session is manual. Ignoring auto created user info."),$={userId:b.userId,authToken:b.authToken};else{const{user_id:R,session_token:H,expire_at:G}=L.auto_created_user;y.messenger.setAnonUser({userId:R,authToken:H,expireAt:G}),$={userId:R,authToken:H}}else $={userId:(b==null?void 0:b.userId)??"",authToken:(b==null?void 0:b.authToken)??""};y.messenger.setSettings($.userId,L),t(L);try{await n(L,$),await C($,b==null?void 0:b.sessionHandler,a),await r(L,$)}catch(R){throw R instanceof Error&&(s(R),E.error("useAuthentication.authenticate: failed to connect",R)),R}return L},[v,C,m,b==null?void 0:b.userId,b==null?void 0:b.sessionHandler,b==null?void 0:b.authToken,c,d,h,p,l,y.messenger.setAnonUser,y.messenger.getSettings,y.messenger.setSettings,t,n,r,s,a]),I=u.useCallback(async()=>{E.debug("useAuthentication.deauthenticate: start"),await x(),i(),E.debug("useAuthentication.deauthenticate: completed")},[x,E,i]);return{authenticate:_,deauthenticate:I,userSessionCandidate:b}}const ur=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)}},Ke=e=>JSON.parse(e),ht=e=>JSON.parse(e);function cs(e,t){const[n,r]=t.split(",").map(s=>s.trim());return e==="dark"&&r||n}function us(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 Zt({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,ur(l))},e)}async function ds({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,ur(l)),e)}const ms=()=>{const{chatSDK:e,logger:t,cache:n}=K(),r=u.useCallback(()=>{var l,c;const a=(c=(l=e.appInfo)==null?void 0:l.aiAgentInfo)==null?void 0:c.templateListToken;if(!a)return!1;const i=n.template.getCachedToken();return i?a!==i:!0},[e,n.template.getCachedToken]),s=u.useCallback(async()=>{try{const{templates:a,token:i}=await e.aiAgent.getMessageTemplates({limit:20});for(const{template:l}of a){const{key:c}=Ke(l);n.template.set(c,l)}n.template.setCachedToken(i)}catch(a){t==null||t.error("messageTemplateContext.syncCachedTemplates: error:",a)}},[e,t,n.template.set,n.template.setCachedToken]);return{shouldSyncCachedTemplate:r,syncCachedTemplates:s}},{Provider:gs,useContext:ft}=J("AIAgentMessengerSession"),hs=u.forwardRef(function({userSessionInfo:e,forceCreateChannel:t,children:n},r){const{appId:s,aiAgentId:a,chatSDK:i,language:l,countryCode:c,context:d,cache:h,logger:p}=K(),{updateTheme:E}=Yt(),[y,C]=u.useState(void 0),[x,m]=u.useState(void 0),[b,v]=u.useState(null),[_,I]=u.useState(null),[T,L]=u.useState(null),[$,M]=u.useState(null),{updateBaseAttachmentRules:R,createAttachmentRules:H}=ts(),{shouldSyncCachedTemplate:G,syncCachedTemplates:Ee}=ms(),xe=lr(),{authenticate:$e,deauthenticate:j}=ls({userSessionInfo:e,forceCreateChannel:t,onUpdateMessengerSettings:u.useCallback(N=>{const{appearance:A,bot:O,launcher:z}=N;E(A.selected_theme,A),L({userId:O.bot_userid,profileUrl:O.bot_profile_url,nickname:O.bot_nickname,replyToFile:O.reply_to_file,specialNotice:O.special_notice,specialNoticeEnabled:O.is_special_notice_enabled,showHandoffButton:O.show_handoff_button??!0,isMultipleActiveConversationsEnabled:O.is_multiple_active_conversations_enabled??!0,isUserFeedbackEnabled:N.bot.is_user_feedback_enabled??!1,isUserFeedbackCommentOptionEnabled:N.bot.is_user_feedback_comment_option_enabled??!1}),M({type:z.image_type||"default_icon",imageUrl:z.image_url}),R(N)},[E]),onPreAuth:u.useCallback((N,A)=>{C(void 0),I(A)},[]),onPostAuth:u.useCallback(async N=>{v(i.currentUser),G()&&await Ee(),m({url:N.active_channel.channel_url,status:q.ConversationStatus.OPEN})},[i,G,Ee]),onErrorAuth:u.useCallback(N=>{C(N)},[]),onAuthTokenRefreshed:u.useCallback(N=>{I(A=>A?{...A,authToken:N}:null)},[]),onPostDeauth:u.useCallback(()=>{h.template.clear(),h.messenger.clear(_==null?void 0:_.userId),v(null),m(void 0),I(null),L(null),M(null)},[h.template.clear,h.messenger.clear,_])}),ne=u.useCallback(async()=>{var N;if(_){p.debug("agentMessengerSession.refreshActiveChannel: try to refresh active channel"),m(void 0);const A=await xe({aiAgentId:a,userId:_.userId,language:l,country:c,context:d,forceCreateChannel:t,knownActiveChannelUrl:(N=h.messenger.getSettings(_.userId))==null?void 0:N.active_channel.channel_url});return h.messenger.setSettings(_.userId,A),m({url:A.active_channel.channel_url,status:q.ConversationStatus.OPEN}),p.info("agentMessengerSession.refreshActiveChannel: refreshed active channel",A.active_channel.channel_url),A.active_channel.channel_url}else throw p.error("agentMessengerSession.refreshActiveChannel: userSession is not ready"),new Error("userSession is not ready")},[xe,s,a,_==null?void 0:_.userId,l,c,d,t,h.messenger.getSettings,h.messenger.setSettings]),ve=u.useCallback(async N=>{if(!(_!=null&&_.userId))throw new Error("Current user is not authenticated. Please authenticate first.");const A=await xe({...N,userId:_.userId,knownActiveChannelUrl:void 0}),O=A.active_channel.channel_url;return h.messenger.setSettings(_.userId,A),O},[_==null?void 0:_.userId,xe]),[w]=u.useState(()=>ar(N=>{var A;p.info("agentMessengerSession.channelChanged: channel.conversation",N.conversation),m({url:N.url,status:((A=N.conversation)==null?void 0:A.status)??q.ConversationStatus.OPEN})},250,{trailing:!1,leading:!0}));return Ue.useGroupChannelHandler(i,{onChannelChanged:N=>{N.isGroupChannel()&&N.url===(x==null?void 0:x.url)&&w(N)}}),u.useEffect(()=>()=>{w.cancel()},[w]),u.useImperativeHandle(r,()=>{const N=async()=>{if(!x)throw new Error("No active conversation. Please start a conversation first.");return await i.groupChannel.getChannel(x.url)};return{activeChannel:x,chatSDK:i,authenticate:$e,deauthenticate:j,updateContext:async A=>{const z=await(await N()).updateContext(a,A);return{...z,context:z.context??{}}},patchContext:async A=>{const z=await(await N()).patchContext(a,A);return{...z,context:z.context??{}}},getContextObject:async()=>{const O=await(await N()).getContextObject(a);return{...O,context:O.context??{}}}}},[$e,j,x,i,a,p]),o.createElement(gs,{value:{sdkUser:b,userSessionInfo:e,userSession:_,activeChannel:x,setActiveChannel:m,refreshActiveChannel:ne,createConversation:ve,connectionError:y,aiAgentInfo:T,launcherInfo:$,authenticate:$e,deauthenticate:j,createAttachmentRules:H}},n)}),fs=()=>{const e=u.useId(),{chatSDK:t,networkStateAdapter:n}=K(),[r,s]=u.useState(()=>n?n.isOnline()?"connected":"reconnecting":"connected");return u.useEffect(()=>{const a=new X.ConnectionHandler({onDisconnected:()=>s("disconnected"),onConnected:()=>s("connected"),onReconnectStarted:()=>s("reconnecting"),onReconnectSucceeded:()=>s("connected"),onReconnectFailed:()=>s("disconnected"),onConnectionLost:()=>s("reconnecting")});return t.addConnectionHandler(e,a),()=>{t.removeConnectionHandler(e)}},[t,e]),u.useEffect(()=>{if(n)return n.subscribe(()=>{s("reconnecting")})},[n]),r},dr=e=>{const{chatSDK:t}=K(),[n,r]=u.useState([]);return Ue.useGroupChannelHandler(t,{onTypingStatusUpdated(s){if(s.url===(e==null?void 0:e.url)){const a=s.getTypingUsers();r(a)}}}),n},ps=({channel:e,messages:t,isStreamAnimating:n})=>{const{aiAgentInfo:r,userSession:s}=ft(),a=fs(),i=bs({channel:e,lastMessage:xn(t,[Se.SendingStatus.SUCCEEDED]),aiAgentUserId:(r==null?void 0:r.userId)??"",isStreamAnimating:n}),l=Cs({shouldApply:!!(e!=null&&e.isAIAgent)&&!Be(e),isDisabledWhileAIResponding:i,lastMessage:xn(t,[Se.SendingStatus.PENDING,Se.SendingStatus.SUCCEEDED]),currentUserId:(s==null?void 0:s.userId)??""});if(!e||a==="disconnected")return{disabled:!0,disabledBy:"unavailable"};if(a==="reconnecting")return{disabled:!0,disabledBy:"reconnecting"};if(Ae(e))return{disabled:!0,disabledBy:"conversation_closed"};if(Es(e))return{disabled:!0,disabledBy:"form_active"};const c=xs(e);return c?{disabled:!0,disabledBy:c}:i||l?{disabled:!0,disabledBy:"ai_responding"}:{disabled:!1,disabledBy:""}},bs=({channel:e,lastMessage:t,aiAgentUserId:n,isStreamAnimating:r})=>{const[s,a]=u.useState(!1),i=dr(e);return u.useEffect(()=>{if(!t)return;const l=i.some(d=>d.userId===n),c=je(t,n)&&(Te.isStreaming(t)||r);a(!!(c||l))},[i,t,n,r]),s},Es=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},xs=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},vs=3e4,Cs=({shouldApply:e,lastMessage:t,isDisabledWhileAIResponding:n,currentUserId:r})=>{const[s,a]=u.useState(!1),i=u.useRef(null),l=t&&je(t,r)?t.createdAt:0;return u.useEffect(()=>{const c=()=>{i.current&&(clearTimeout(i.current),i.current=null),a(!1)},d=E=>{i.current&&clearTimeout(i.current),a(!0),i.current=setTimeout(()=>{a(!1),i.current=null},E)},h=Date.now()-l,p=vs-h;return n||p<=0?c():d(p),()=>{i.current&&clearTimeout(i.current)}},[n,l]),s&&e},ys=()=>{const[e,t]=u.useState(new Set),n=u.useCallback(s=>{t(a=>{if(a.has(s))return a;const i=new Set(a);return i.add(s),i})},[]),r=u.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:_s}=J("AIAgentConversation");function Ss({children:e,channelUrl:t,onChannelDeleted:n,onMessagesReceived:r,onMessagesUpdated:s,onConversationClosedStatusChanged:a,onConversationClosedViaDispatcher:i,onBeforeSendMessage:l,onAfterSendMessage:c=fe,shouldMarkAsRead:d=!0,shouldCountNewMessages:h=()=>!1,sortComparator:p}){var M;const E=()=>d&&(m==null?void 0:m.markAsRead()),{chatSDK:y,logger:C,dispatcher:x}=K(),{channel:m,channelFetchError:b,fetchChannel:v}=Ts(t),_=Bo(y,m,{replyType:Se.ReplyType.ONLY_REPLY_TO_CHANNEL,shouldCountNewMessages:h,onChannelDeleted:n,onMessagesReceived:R=>r==null?void 0:r(R),onMessagesUpdated:R=>s==null?void 0:s(R),logger:C,markAsRead:E,sortComparator:p}),I=ys(),T=ps({channel:m,messages:_.messages,isStreamAnimating:I.isAnimating});u.useEffect(()=>{E()},[d]);const L=Ae(m);u.useEffect(()=>{a==null||a(L)},[L,a]),u.useEffect(()=>{const R=async H=>{const G=typeof(H==null?void 0:H.channelUrl)=="string";m&&G&&H.channelUrl!==m.url||(C.debug("conversation.dispatcher: try to close conversation",m),m!=null&&m.conversation&&m.conversation.status===q.ConversationStatus.OPEN&&(await m.closeConversation(),i==null||i()))};return x.subscribe(Rt.ConversationClose,R),()=>{x.unsubscribe(Rt.ConversationClose,R)}},[x,(M=m==null?void 0:m.conversation)==null?void 0:M.status,i]);const $={conversation:(m==null?void 0:m.conversation)??void 0,channelSource:{channel:m,error:b,refetch:()=>v(),closeConversation:async()=>{Ae(m)||await(m==null?void 0:m.closeConversation())}},messageSource:{messages:_.messages,newMessages:_.newMessages,initialized:_.initialized,loadPrevious:()=>_.loadPrevious(),loadNext:()=>_.loadNext(),deleteMessage:R=>_.deleteMessage(R),resendMessage:R=>_.resendMessage(R),resetNewMessages:()=>_.resetNewMessages(),sendUserMessage:async R=>{var G;if(((G=m==null?void 0:m.conversation)==null?void 0:G.status)===q.ConversationStatus.CLOSED)throw new Error("Conversation is closed");l&&(R=await l(R));const H=await _.sendUserMessage(R,c);return c==null||c(H),H},sendFileMessage:async R=>{var G;if(((G=m==null?void 0:m.conversation)==null?void 0:G.status)===q.ConversationStatus.CLOSED)throw new Error("Conversation is closed");l&&(R=await l(R));const H=await _.sendFileMessage(R,c);return c==null||c(H),H}},state:{streamAnimation:I,input:T}};return o.createElement(_s,{value:$},e)}function Ts(e){const{chatSDK:t,logger:n}=K(),{sdkUser:r}=ft(),[s,a]=u.useState(void 0),[i,l]=u.useState(void 0);async function c(){if(!r){n.debug("conversation.fetchChannel: no sdk user, skip fetching channel");return}if(n.debug("conversation.fetchChannel: start"),a(void 0),l(void 0),e)try{n.debug("conversation.fetchChannel: get channel",e);const d=await t.groupChannel.getChannel(e);a(d),n.debug("conversation.fetchChannel: fetched channel",d)}catch(d){d instanceof X.SendbirdError&&l(d),n.error("conversation.fetchChannel: error",d)}}return As(s),u.useEffect(()=>{c()},[t,r,e]),{channel:s,channelFetchError:i,fetchChannel:c}}function As(e){const{chatSDK:t}=K(),{activeChannel:n,setActiveChannel:r}=ft(),s=u.useId();u.useEffect(()=>{if(!e||!n)return;const a=new X.ConnectionHandler({onReconnectSucceeded:async()=>{var l;const i=await e.refresh();i.url===n.url&&r({url:i.url,status:((l=i.conversation)==null?void 0:l.status)??q.ConversationStatus.OPEN})}});return t.addConnectionHandler(s,a),()=>{t.removeConnectionHandler(s)}},[t,e,n])}class ws{constructor(t,{filter:n,limit:r=20}){U(this,"filter");U(this,"_sdk");U(this,"_pinnedChannels");U(this,"_channels");U(this,"_isDisposed",!1);U(this,"_handlerId",`handler-id-${Date.now()}`);U(this,"_order",lt.GroupChannelListOrder.LATEST_LAST_MESSAGE);U(this,"_limit");U(this,"_query");U(this,"_token");U(this,"_timestamp");U(this,"_isSyncing");U(this,"_channelHandler");U(this,"_connectionHandler");U(this,"_collectionEventHandler");U(this,"_throttledOnChannelChanged");var s,a,i,l,c,d,h;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:(d=this.filter)==null?void 0:d.copilotConversationOnly,copilotSupportChannelUrl:(h=this.filter)==null?void 0:h.copilotSupportChannelUrl,limit:this._limit}),this._token="",this._timestamp=Number.MAX_SAFE_INTEGER,this._isSyncing=!1,this._throttledOnChannelChanged=ar(p=>{p.isGroupChannel()&&(this._query.belongsTo(p)?this._addChannelsToView([p],!1):this._removeChannelsFromView([p.url]))},250,{trailing:!1,leading:!0}),this._channelHandler=new lt.GroupChannelHandler({onChannelChanged:this._throttledOnChannelChanged,onChannelDeleted:p=>{this._removeChannelsFromView([p])}}),this._connectionHandler=new X.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,d)=>[c,d])),s=[],a=[],i=[];for(const c of t){if(!this._query.belongsTo(c)){i.push(c.url);continue}const d=r.get(c.url);if(d===void 0)continue;const h=Pt(this._pinnedChannels,c);h>=0?(this._pinnedChannels.splice(h,1),a.push(c)):s.push(c);const E=this._pinnedChannels.findIndex(C=>(r.get(C.url)??1/0)>d),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=Pt(this._channels,i),c=l<0;!c&&this._channels.splice(l,1);const h=ks(this._channels,i,this._order).place,p=h===this._channels.length;c?p?(n||!this.hasMore)&&(this._channels.push(i),s.push(i)):(this._channels.splice(h,0,i),s.push(i)):(this._channels.splice(h,0,i),a.push(i))}return{addedChannels:s,updatedChannels:a,unmatchedChannelUrls:r}}_addChannelsToView(t,n=!1){var p,E,y,C,x;const r=new Set(((p=this.filter)==null?void 0:p.pinnedChannelUrls)??[]),s=[],a=[];for(const m of t)r.has(m.url)?s.push(m):a.push(m);const i=this._upsertPinnedChannelsToArray(s),l=this._upsertRegularChannelsToArray(a,n),c=i.addedChannels.concat(l.addedChannels),d=i.updatedChannels.concat(l.updatedChannels),h=i.unmatchedChannelUrls.concat(l.unmatchedChannelUrls);c.length>0&&((y=(E=this._collectionEventHandler)==null?void 0:E.onChannelsAdded)==null||y.call(E,{},c)),d.length>0&&((x=(C=this._collectionEventHandler)==null?void 0:C.onChannelsUpdated)==null||x.call(C,{},d)),h.length>0&&this._removeChannelsFromView(h)}_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(d=>d.url===l);c>=0&&(r.push(l),this._pinnedChannels.splice(c,1))}else{const c=this._channels.findIndex(d=>d.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 Pt=(e,t)=>e.findIndex(n=>n.isIdentical(t)),ks=(e,t,n)=>{if(e.length>0){const r=Pt(e,t);let s=0,a=e.length-1,i=Math.floor((s+a)/2);for(;s<a;){const c=Sn(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:Sn(e[i],t,n)>=0?i:i+1,oldPosition:r}}return{place:e.length,oldPosition:-1}},Sn=(e,t,n)=>{switch(n){case lt.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}};function Is(e,t){var C,x,m,b,v,_,I,T,L,$;const n=u.useId(),[r,s]=u.useState(!1),[a,i]=u.useState(null),[l,c]=u.useState([]),[d,h]=u.useState(null),p=u.useRef(!1),E=u.useCallback(async()=>{if(!p.current&&e.currentUser){p.current=!0,s(!1),i(null),c([]);try{d==null||d.dispose();const M=new ws(e,t);M.setConversationListCollectionHandler({onChannelsAdded:()=>{c(M.channels)},onChannelsUpdated:()=>{c(M.channels)},onChannelsDeleted:()=>{c(M.channels)}}),await M.loadMore(),h(M),i(null)}catch(M){h(null),i(M)}finally{s(!0),p.current=!1}}},[e,e.currentUser,(C=t.filter)==null?void 0:C.aiAgentChannelFilter,(m=(x=t.filter)==null?void 0:x.aiAgentConversationStatusFilter)==null?void 0:m.join(),(v=(b=t.filter)==null?void 0:b.aiAgentIds)==null?void 0:v.join(),(_=t.filter)==null?void 0:_.deskChannelFilter,(T=(I=t.filter)==null?void 0:I.pinnedChannelUrls)==null?void 0:T.join(),(L=t.filter)==null?void 0:L.copilotConversationOnly,($=t.filter)==null?void 0:$.copilotSupportChannelUrl,t.limit]),y=u.useCallback(async()=>{if(d)try{await d.loadMore()}catch(M){i(M)}},[d]);return u.useEffect(()=>(e.addConnectionHandler(n,new X.ConnectionHandler({onConnected:()=>E()})),()=>e.removeConnectionHandler(n)),[e,n,E]),u.useEffect(()=>{E()},[E]),u.useEffect(()=>()=>{p.current=!1,d==null||d.dispose()},[d]),{initialized:r,error:a,channels:l,loadMore:y}}const{Provider:$s}=J("AIAgentConversationList");function Ms({conversationListLimit:e,conversationListFilter:t,children:n}){var p,E;const{chatSDK:r,aiAgentId:s,queryParams:a}=K(),i={aiAgentIds:[s],aiAgentConversationStatusFilter:[q.ConversationStatus.CLOSED,q.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},d=Is(r,{limit:l,filter:c}),h={listSource:{initialized:d.initialized,error:d.error??void 0,channels:d.channels,loadMore:()=>d.loadMore()}};return o.createElement($s,{value:h},n)}function Ls(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:Os,useContext:mr}=J("MessageTemplateFetching");function Rs({children:e,internalVariables:t}){const n=u.useRef({}),r=u.useRef({}),[s,a]=u.useState({}),i=u.useCallback((d,h)=>{a(p=>({...p,[d]:{fetching:!1,error:!1,...p[d],...h}}))},[]),l=u.useCallback(async({onRequestTemplate:d,onGetCachedTemplate:h,templateKey:p,suspense:E=!1})=>{const y=h(p);if(y)return y;const C=r.current[p];if(C)return C;E||i(p,{fetching:!0});const x=d(p).catch(m=>{throw E||i(p,{error:!0}),m}).finally(()=>{E||i(p,{fetching:!1}),delete r.current[p]});return r.current[p]=x,x},[i]),c={internalVariables:t,fetchTemplate:l,suspend:(d,h)=>{if(n.current[d])return n.current[d];const p=Ls(h());return n.current[d]=p,p},getIsFetching:d=>{var h;return((h=s[d])==null?void 0:h.fetching)??!1},getHasError:d=>{var h;return((h=s[d])==null?void 0:h.error)??!1}};return o.createElement(Os,{value:c},e)}const pt={VARIABLE:e=>new RegExp(`\\{${e}\\}`,"g"),VIEW_VARIABLE:e=>new RegExp(`"{@${e}}"`,"g")};function we({uiTemplateString:e,variables:t={}}){const n=us(t);return Zt({template:e,variables:n,variableKeyPattern:r=>pt.VARIABLE(r)})}function ke({theme:e,uiTemplateString:t,colorVariables:n={}}){return Zt({template:t,variables:n,variableKeyPattern:r=>pt.VARIABLE(r),variableValueTransformer:r=>cs(e,r)})}function Ds({theme:e,uiTemplateString:t,viewVariables:n={},aiAgentColorVariables:r,internalVariables:s,onRequestTemplate:a}){const l=Object.values(n).flat().map(d=>d.key);return[...new Set(l)].some(d=>!a(d))?null:Zt({template:t,variables:n,variableKeyPattern:d=>pt.VIEW_VARIABLE(d),variableValueTransformer:d=>{const h=d.map(({key:p,variables:E})=>{const y=a(p),{ui_template:C,color_variables:x}=Ke(y);let m=JSON.stringify(C);return m=we({uiTemplateString:m,variables:s}),m=ke({theme:e,uiTemplateString:m,colorVariables:x}),m=ke({theme:e,uiTemplateString:m,colorVariables:r}),m=we({uiTemplateString:m,variables:E}),ht(m)});return JSON.stringify(h)}})}async function Ns({theme:e,uiTemplateString:t,viewVariables:n={},aiAgentColorVariables:r,internalVariables:s,onRequestTemplate:a}){return ds({template:t,variables:n,variableKeyPattern:i=>pt.VIEW_VARIABLE(i),variableValueTransformer:async i=>{const l=i.map(async({key:d,variables:h})=>{const p=await a(d),{ui_template:E,color_variables:y}=Ke(p);let C=JSON.stringify(E);return C=we({uiTemplateString:C,variables:s}),C=ke({theme:e,uiTemplateString:C,colorVariables:y}),C=ke({theme:e,uiTemplateString:C,colorVariables:r}),C=we({uiTemplateString:C,variables:h}),ht(C)}),c=await Promise.all(l);return JSON.stringify(c)}})}const Ps=({rawTemplate:e,aiAgentColorVariables:t,internalVariables:n,...r})=>{const{ui_template:s,color_variables:a}=Ke(e);let i=JSON.stringify(s);if(Object.keys(r.viewVariables??{}).length>0){const c=Ds({...r,uiTemplateString:i,aiAgentColorVariables:t,internalVariables:n});if(c===null)return null;i=c}return i=we({...r,uiTemplateString:i,variables:n}),i=ke({...r,uiTemplateString:i,colorVariables:a}),i=ke({...r,uiTemplateString:i,colorVariables:t}),i=we({...r,uiTemplateString:i}),ht(i)},Bs=async({rawTemplate:e,aiAgentColorVariables:t,internalVariables:n,...r})=>{const{ui_template:s,color_variables:a}=Ke(e);let i=JSON.stringify(s);return Object.keys(r.viewVariables??{}).length>0&&(i=await Ns({...r,uiTemplateString:i,aiAgentColorVariables:t,internalVariables:n})),i=we({...r,uiTemplateString:i,variables:n}),i=ke({...r,uiTemplateString:i,colorVariables:a}),i=ke({...r,uiTemplateString:i,colorVariables:t}),i=we({...r,uiTemplateString:i}),ht(i)},Fs=e=>{const{aiAgentColorVariables:t={}}=e,{internalVariables:n}=mr();return u.useState(()=>{const r=e.onGetCachedTemplate(e.templateKey);return r?Ps({...e,rawTemplate:r,aiAgentColorVariables:t,internalVariables:n,onRequestTemplate:e.onGetCachedTemplate}):null})},Us=e=>{const[t]=Fs(e);if(t)return t;const{aiAgentColorVariables:n={}}=e,{internalVariables:r,fetchTemplate:s,suspend:a}=mr();return a(e.templateKey,async()=>{const l=await s({...e,suspense:!0});return await Bs({...e,rawTemplate:l,aiAgentColorVariables:n,internalVariables:r})}).value},Hs="remove_powered_by",Xt=(e,t)=>{var s,a;const{chatSDK:n}=K(),{aiAgentInfo:r}=ft();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&&Wt(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 u.useMemo(()=>!(Array.isArray(i)&&i.includes(Hs)),[i])}throw new Error("Unsupported feature")},zs={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"},Vs={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}}},Gs={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}}},Ws={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}}},qs={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}}},js={text:Vs,number:Gs,"single-select":Ws,"multi-select":qs},Ks={getValueOrDefault:()=>null,validate:()=>({isValid:!1})};function gr(e){return js[e.type]||Ks}function Tn(e){return gr(e).getValueOrDefault(e)}function Ys(e,t,n={}){const r={...zs,...n};return gr(e).validate(e,t,r)}const Zs=(e,t={})=>{const{labels:n={},onSubmit:r,onCancel:s}=t,[a,i]=u.useState({}),[l,c]=u.useState(()=>{const x={};return e.fields.forEach(m=>{x[m.key]=Tn(m)}),x}),d=u.useMemo(()=>e.submitted_at?"submitted":e.canceled_at?"canceled":"draft",[e.submitted_at,e.canceled_at]);u.useEffect(()=>{if(d==="submitted"||d==="canceled"){const x={};let m=!1;e.fields.forEach(b=>{const v=Tn(b);JSON.stringify(l[b.key])!==JSON.stringify(v)&&(m=!0),x[b.key]=v}),m&&c(x)}},[d]);const h=(x,m)=>{c(b=>({...b,[x]:m})),i(b=>({...b,[x]:void 0}))},p=e.fields.map(x=>{var v,_,I;const m=l[x.key]??null,b={key:x.key,label:x.label,error:a[x.key],required:x.required};return x.type==="text"?{...b,type:"text",layout:x.layout,value:m,...x.placeholder&&{placeholder:x.placeholder},...((v=x.rules)==null?void 0:v.max_length)&&{maxLength:x.rules.max_length}}:x.type==="number"?{...b,type:"number",layout:x.layout,value:m,...x.placeholder&&{placeholder:x.placeholder},...((_=x.rules)==null?void 0:_.max)&&{max:x.rules.max}}:x.type==="single-select"?{...b,type:"single-select",layout:x.layout,value:m,options:x.options}:x.type==="multi-select"?{...b,type:"multi-select",layout:x.layout,value:m,options:x.options,...((I=x.rules)==null?void 0:I.max_select)&&{maxSelect:x.rules.max_select}}:{...b,type:"unknown",layout:"default",value:null}});return{state:d,fields:p,getField:x=>p.find(m=>m.key===x),updateFieldValue:h,submit:async()=>{const x={};let m=!1;for(const b of e.fields){const v=l[b.key]??null,_=Ys(b,v,n);_.isValid||(x[b.key]=_.error,m=!0)}if(i(x),!m&&r){const b={};e.fields.forEach(v=>{b[v.key]=l[v.key]??null}),await r(b)}},cancel:async()=>{await(s==null?void 0:s())}}},hr=({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?Be(e)?s.human("agent"):s.ai("delight"):e.isDesk?s.human("agent"):s.channel("user")},An=e=>u.useReducer((t,n)=>({...t,...n}),e);var le=(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))(le||{});const Xs=new Set(["free_text","single_choice"]),Js=({csatPayload:e,type:t,initialCsat:n,initialCsatReason:r,initialIsResolved:s})=>{const[a,i]=An({csatType:t,csat:n,csatReason:r,isResolved:s}),[l,c]=An({followUpItem:!1}),d=u.useMemo(()=>{var x;const y=a.csat;if(typeof y!="number")return;const C=(x=e.follow_up)==null?void 0:x.find(m=>m.scores.includes(y));if(Xs.has(C==null?void 0:C.response_type))return C},[a.csat,e.follow_up]),h=(()=>{var y;if(typeof n=="number")return"submitted";if((t===le.AI_AGENT_CSAT_5||t===le.HELPDESK_CSAT_5)&&typeof a.csat=="number")return"submittable";if(t===le.AI_AGENT_CSAT_5_WITH_CRE){const C=typeof a.csat=="number",x=!((y=e.cre)!=null&&y.required)||typeof a.isResolved=="boolean";if(C&&x)return"submittable"}return"unsubmittable"})(),p=u.useCallback(()=>typeof a.csat>"u"?!1:d!=null&&d.required&&!a.csatReason?(c({followUpItem:!0}),!1):!0,[a,d,c]);return u.useEffect(()=>{r||(i({csatReason:""}),c({followUpItem:!1}))},[r,d,i,c]),{params:a,setParams:i,error:l,setError:c,followUpItem:d,state:h,validateParams:p,itemProps:{csatPayload:e,state:h,submitted:h==="submitted"}}},wt=5,Qs=250,ea=50,wn=e=>Math.max(0,e-ea),ta=e=>e<1e3?{speed:wt*.5,chunkSize:2}:e<2e3?{speed:wt*.8,chunkSize:2}:{speed:wt*.6,chunkSize:3},na=e=>{const{text:t,enabled:n=!1,onAnimationStart:r,onAnimationProgress:s,onAnimationComplete:a}=e,[i,l]=u.useState(()=>wn(t.length)),c=u.useRef(null),d=u.useRef({startTime:0,lastUpdate:0,lastProgressCall:0}).current,h=u.useRef({onStart:r,onProgress:s,onComplete:a}).current,p=u.useRef({startCalled:!1,completeCalled:!1}).current,E=u.useRef({initialEnabled:n,textLength:t.length,enabled:n}).current,y=n,C=i<t.length,x=E.initialEnabled&&(y||C);return u.useLayoutEffect(()=>{h.onStart=r,h.onProgress=s,h.onComplete=a,E.textLength=t.length,E.enabled=n}),u.useLayoutEffect(()=>{var m;E.initialEnabled&&(p.startCalled||(p.startCalled=!0,(m=h.onStart)==null||m.call(h)),l(b=>t.length<b?t.length:b))},[t]),u.useEffect(()=>{if(!E.initialEnabled)return;let m=wn(t.length);d.lastUpdate=0,d.startTime=0,d.lastProgressCall=0;const b=v=>{var H;d.lastUpdate===0&&(d.lastUpdate=v,d.startTime=v,d.lastProgressCall=v);const _=E.textLength,I=v-d.lastUpdate,T=v-d.startTime,{speed:L,chunkSize:$}=ta(T),M=L*$;I>=M&&m<_&&(m=Math.min(m+$,_),l(m),d.lastUpdate=v),v-d.lastProgressCall>=Qs&&(d.lastProgressCall=v,(H=h.onProgress)==null||H.call(h)),(m<_||E.enabled)&&(c.current=requestAnimationFrame(b))};return c.current=requestAnimationFrame(b),()=>{c.current&&cancelAnimationFrame(c.current)}},[]),u.useEffect(()=>{var _;const m=E.initialEnabled&&p.startCalled,b=!n,v=i>=t.length&&t.length>0;m&&b&&v&&!p.completeCalled&&(p.completeCalled=!0,(_=h.onComplete)==null||_.call(h))},[n,i,t.length]),{streamText:E.initialEnabled?t.slice(0,i):t,isAnimating:x}},ra='@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}',oa={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"},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"}},Bt={language:"en",strings:oa,dateLocale:ao.enUS},fr=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,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}),sa=e=>{var t;return((t=e.split("-"))==null?void 0:t[0])??bt},bt="en",aa=new Set([bt,"ko","es","pt","fr","hi","it","de","tr","ja"]),ia=(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.":""))))})},kn=fr(Bt.strings),la={...kn,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:"You can't upload more than one image",FILE_UPLOAD_NOTIFICATION__SIZE_LIMIT:"The maximum size per file is %d MB.",FILE_VIEWER__UNSUPPORT:"Unsupported message",CSAT5_RATING_SCORE_1:"Terrible",CSAT5_RATING_SCORE_2:"Bad",CSAT5_RATING_SCORE_3:"Okay",CSAT5_RATING_SCORE_4:"Good",CSAT5_RATING_SCORE_5:"Great",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:kn.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"},ct={language:Bt.language,dateLocale:Bt.dateLocale,stringSet:la},ca=Object.freeze(Object.defineProperty({__proto__:null,default:ct},Symbol.toStringTag,{value:"Module"})),Ft=new Map([[bt,ct]]);async function ua(e){const t=Ft.get(e);if(t)return t;try{if(aa.has(e)){const{default:n}=await ia(Object.assign({"./languages/de.ts":()=>Promise.resolve().then(()=>require("./DkIeZWe9.cjs")),"./languages/en.ts":()=>Promise.resolve().then(()=>ca),"./languages/es.ts":()=>Promise.resolve().then(()=>require("./B75_RK1b.cjs")),"./languages/fr.ts":()=>Promise.resolve().then(()=>require("./BR_bOr-Y.cjs")),"./languages/hi.ts":()=>Promise.resolve().then(()=>require("./Ci7Su9OO.cjs")),"./languages/it.ts":()=>Promise.resolve().then(()=>require("./B1EyhD-2.cjs")),"./languages/ja.ts":()=>Promise.resolve().then(()=>require("./D0ZzpfdW.cjs")),"./languages/ko.ts":()=>Promise.resolve().then(()=>require("./DUJ7QCV9.cjs")),"./languages/pt.ts":()=>Promise.resolve().then(()=>require("./FPcgniHk.cjs")),"./languages/tr.ts":()=>Promise.resolve().then(()=>require("./D3sz6O-l.cjs"))}),`./languages/${e}.ts`,3);return Ft.set(e,n),n}return ct}catch{return ct}}const{Provider:da,useContext:F}=J("Localization"),ma=({language:e=navigator.language,logger:t,stringSet:n,children:r})=>{const[s,a]=u.useState(Ft.get(bt));return u.useEffect(()=>{const i=sa(e);s.language!==i&&(t==null||t.debug("localization.useEffect: update language",{from:s.language,to:i}),ua(i).then(a))},[e,t]),o.createElement(da,{value:{language:s.language,stringSet:{...s.stringSet,...n},dateLocale:s.dateLocale,format:(i,l,c)=>_e.format(i,l,{locale:s.dateLocale,...c})}},r)},ut="data-sb-agent-theme",In=e=>(t,...n)=>{let r="";return t.forEach((s,a)=>{r+=s+(n[a]??"")}),`[${ut}='${e}'] & { ${r} }`},D={light:In("light"),dark:In("dark")},ga=S.css(({theme:e})=>{const{palette:t}=e;return`
|
|
1
|
+
"use strict";var oo=Object.defineProperty;var so=(e,t,n)=>t in e?oo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var U=(e,t,n)=>so(e,typeof t!="symbol"?t+"":t,n);const u=require("react"),Z=require("@sendbird/chat"),S=require("styled-components"),ye=require("date-fns"),ao=require("date-fns/locale/en-US"),_e=require("@sendbird/chat/message"),q=require("@sendbird/chat/aiAgent"),lt=require("@sendbird/chat/groupChannel"),io=require("react-dom"),Lt=require("@sendbird/react-uikit-message-template-view"),lo=require("@sendbird/uikit-message-template"),Ue=require("@sendbird/uikit-tools"),co=require("dompurify"),uo=require("date-fns/isSameDay"),mo=require("@emotion/is-prop-valid"),gt=e=>e&&e.__esModule?e:{default:e};function go(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 o=go(u),ho=gt(Z),f=gt(S),Jn=gt(co),fo=gt(mo),X=(e,t)=>{const n=u.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=u.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 pe(e){const t=u.createContext({Template:e.template,updateTemplate:()=>{},components:e.components,updateComponent:()=>{}});function n({children:a}){const[i,l]=u.useState(()=>e.template),[c,d]=u.useState(e.components),h={Template:i,updateTemplate:b=>l(()=>b),components:c,updateComponent:(b,E)=>d(C=>({...C,[b]:E}))};return o.createElement(t.Provider,{value:h},a)}function r({template:a,children:i}){const{updateTemplate:l}=u.useContext(t);return u.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=()=>u.useContext(t),s.Context=t,s.Template=r,Object.keys(e.components).forEach(a=>{s[a]=function({component:l}){const{updateComponent:c}=u.useContext(t);return u.useLayoutEffect(()=>{l&&c(a,l)},[l]),null}}),s}function po(...e){return function({children:n}){return e.reduce((r,s)=>o.createElement(s,null,r),n)}}const Te=e=>{var t,n;return!!(e!=null&&e.isAIAgent&&((t=e==null?void 0:e.conversation)==null?void 0:t.status)===q.ConversationStatus.CLOSED||e!=null&&e.isDesk&&((n=e==null?void 0:e.helpdeskInfo)==null?void 0:n.ticketStatus)==="closed")},Wt=e=>{var t,n;return!!(e!=null&&e.isAIAgent&&((t=e==null?void 0:e.conversation)==null?void 0:t.status)===q.ConversationStatus.OPEN||e!=null&&e.isDesk&&((n=e==null?void 0:e.helpdeskInfo)==null?void 0:n.ticketStatus)==="open")};function Be(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 bo(e){var t;if(((t=e==null?void 0:e.resolution)==null?void 0:t.determinedBy)==="user")return e.resolution.isResolved}function En(e){return!!e&&e<Date.now()}function Eo(e){return!e.title}function xo(e,t){var n;if(e)return Eo(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}],csat_submit_label:t.submit_label,csat_submitted_label:t.submitted_label}:e}function vo(e){const t=e.lastMessage;return t!=null&&t.isUserMessage()||t!=null&&t.isAdminMessage()?t.message||"":t!=null&&t.isFileMessage()?t.message||t.name||"FILE":e.name}function Co(e,t,n){var i;const r=new Date,s=new Date(((i=e.lastMessage)==null?void 0:i.createdAt)||e.createdAt),a=ye.differenceInMinutes(r,s);return a<1?n.justNow:a<60?n.minutesAgo(a):ye.isToday(s)?n.hoursAgo(ye.differenceInHours(r,s)):t(s,n.dateShortFormat)}const Ne="sb-agent",Qn="KEY_IMG_ASPECT_RATIO",yo="*/*",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},he=e=>!!e&&"sender"in e,_o=e=>he(e)?e.sendingStatus==="succeeded"?String(e.messageId):e.reqId:String(e.messageId),So=(e,t,n,r=!0)=>{if(!r||!he(e))return"single";const s=()=>{if(!t||!he(t))return!1;const c=t.sender.userId===e.sender.userId,d=ye.isSameMinute(t.createdAt,e.createdAt);return c&&d},a=()=>{if(!n||!he(n))return!1;const c=n.sender.userId===e.sender.userId,d=ye.isSameMinute(n.createdAt,e.createdAt);return c&&d},i=s(),l=a();return i&&l?"middle":i?"bottom":l?"top":"single"},je=(e,t)=>(()=>{var r;return he(e)?e.sender.userId:((r=e==null?void 0:e.sender)==null?void 0:r.userId)??void 0})()===t,De={isAdmin:e=>e.isAdminMessage(),isCSAT:e=>{var t;return e.isAdminMessage()&&!!((t=e.extendedMessagePayload)!=null&&t.csat)},isIncoming:(e,t)=>he(e)&&e.sender.userId!==t,isOutgoing:(e,t)=>he(e)&&(e.sender.userId===t||e.sendingStatus===_e.SendingStatus.PENDING)},er=e=>e.startsWith("image/"),tr=e=>e.startsWith("video/"),qt=(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"},nr=e=>e.messageType==="file"?e.message.length>0&&e.file.name!==e.message:e.message.length>0,jt=e=>{switch(e){case"top":case"middle":return B.GAP_GROUPED;default:return B.GAP_UNGROUPED}},To=(e,t)=>{const n=/```(\w+)?\n([\s\S]*?)```/g,r=[];let s=0;return e.replace(n,(a,...i)=>{const[l,c,d]=i;return s<d&&r.push({type:"text",value:e.slice(s,d).trim()}),r.push({type:"code",value:c.trim(),language:l?l.trim():"plaintext"}),s=d+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},Ao=e=>e.replace(/\[([^\]]+)\](?!\()/g,"\\[$1\\]"),wo=e=>e.replace(/([a-zA-Z0-9])_(?=[a-zA-Z0-9])/g,"$1\\_"),ko=e=>e.replace(/~~/g,"\\~\\~"),Io=e=>{let t=e;return t=Ao(t),t=wo(t),t=ko(t),t},$o=typeof navigator<"u"&&navigator.product==="ReactNative",xn=(e,t)=>{const n=r=>!t||t.length===0?!0:he(r)&&t.includes(r.sendingStatus);return $o?e.find(n):e.findLast(n)};function fe(){}function Mo(){const e=typeof navigator<"u"?navigator.userAgent:"",t=/iPad|iPhone|iPod/.test(e),n=/Android/.test(e);return t||n}function Lo(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 Ot=e=>{try{return JSON.parse(e===""?"{}":e)}catch{return{}}},Se={isStreaming(e){const t=Ot(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(je(e,t)){const r=Ot(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)}},Tt=`@${Ne}`,vn=({appId:e,aiAgentId:t,storage:n})=>{const r={templateBase:`${Tt}-template`,template:s=>`${r.templateBase}/templates/${s}`,templateToken:()=>`${r.templateBase}-template/message-template/tokens`,messengerSession:s=>{const a=Lo(`${e}/${t}/${s}`);return`${Tt}-udata/${a}`},anonUserSession:()=>`${Tt}-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}}}}};class rr{constructor(t){U(this,"subscribers",{});this.logger=t}async send(t){const n=Oo(),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){this.subscribers[t]&&(this.subscribers[t]=this.subscribers[t].filter(r=>r!==n))}}const Oo=()=>{let e=fe,t=fe;return{promise:new Promise((r,s)=>{e=r,t=s}),resolve:e,reject:t}};var Kt=(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))(Kt||{});class or{constructor(t){U(this,"level");this.level=t}verbose(...t){this.level<=0&&console.log(`[${Ne}/verbose]`,...t)}debug(...t){this.level<=1&&console.log(`[${Ne}/debug]`,...t)}info(...t){this.level<=2&&console.log(`[${Ne}/info]`,...t)}warn(...t){this.level<=3&&console.warn(`[${Ne}/warn]`,...t)}error(...t){this.level<=4&&console.error(`[${Ne}/error]`,...t)}}function Cn(e,t,n,r){const s=ho.default.init({appId:e,modules:[new lt.GroupChannelModule,new q.AIAgentModule],localCacheEnabled:!0,options:new Z.SendbirdChatOptions({typingIndicatorInvalidateTime:2e4}),...r});return s.addSendbirdExtensions([{version:n,product:Z.SendbirdProduct.AI_AGENT,platform:t.platform}],{platform:t.deviceOSPlatform,version:t.deviceOSVersion},t.customData)||console.warn("Invalid Sendbird Extensions",t),s}function Ro(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 Ce={conversation:{isTalkToAgentViewEnabled:!0,scrollMode:"auto",newMessageIndicatorEnabled:!0,senderAvatarEnabled:!0,header:{avatarEnabled:!0},input:{camera:{photoEnabled:!0},gallery:{photoEnabled:!0},fileEnabled:!0},fileViewer:{downloadEnabled:!0}}},Do=e=>{var t,n,r,s,a,i,l,c,d,h,b,E,C,y;return e?{...Ce,...e,conversation:{...Ce.conversation,...e==null?void 0:e.conversation,header:{...(t=Ce.conversation)==null?void 0:t.header,...(n=e==null?void 0:e.conversation)==null?void 0:n.header},input:{...(r=Ce.conversation)==null?void 0:r.input,...(s=e==null?void 0:e.conversation)==null?void 0:s.input,camera:{...(i=(a=Ce.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:{...(h=(d=Ce.conversation)==null?void 0:d.input)==null?void 0:h.gallery,...(E=(b=e==null?void 0:e.conversation)==null?void 0:b.input)==null?void 0:E.gallery}},fileViewer:{...(C=Ce.conversation)==null?void 0:C.fileViewer,...(y=e==null?void 0:e.conversation)==null?void 0:y.fileViewer}}}:Ce},{Provider:No,useContext:K}=X("AIAgent");function Po({appId:e,aiAgentId:t,keyValueStorage:n,networkStateAdapter:r,language:s,countryCode:a,context:i,queryParams:l,config:c,chatSDK:d,chatParams:h,children:b,logger:E,dispatcher:C,messengerVersion:y,extensions:x={platform:Z.SendbirdPlatform.JS,deviceOSPlatform:Mo()?Z.DeviceOsPlatform.MOBILE_WEB:Z.DeviceOsPlatform.WEB}}){const[m,p]=u.useState(()=>{const v=E??new or(Kt.WARN),_=C??new rr(v);return{logger:v,dispatcher:_,chatSDK:d??Cn(e,x,y,h),cache:vn({appId:e,aiAgentId:t,storage:n})}});return u.useEffect(()=>{p(v=>{let _=v.logger,I=v.dispatcher,T=v.chatSDK;return E&&E!==v.logger&&(_=E),C&&C!==v.dispatcher&&(I=C),d&&d!==v.chatSDK?T=d:!d&&v.chatSDK.appId!==e&&(T=Cn(e,x,y,{newInstance:!0,...h})),{...v,logger:_,dispatcher:I,chatSDK:T,cache:vn({appId:e,aiAgentId:t,storage:n})}})},[e,t,E,C,d,n]),u.useEffect(()=>()=>{m.chatSDK.disconnectWebSocket()},[m.chatSDK]),Ro(m.chatSDK),o.createElement(No,{value:{...m,appId:e,aiAgentId:t,context:i,language:s,countryCode:a,queryParams:l,config:Do(c),networkStateAdapter:r}},b)}const Bo=(e,t,n)=>Ue.useGroupChannelMessages(e,t,{...n,strictStreamingOrder:!0});var Rt=(e=>(e.ConversationClose="conv.close",e))(Rt||{});class Fo{constructor(t={}){U(this,"payload");this.payload=t}toJSON(){return JSON.stringify({type:this.type,payload:this.payload})}}const sr={CloseConversation:e=>new Uo(e)};class Uo extends Fo{constructor(){super(...arguments);U(this,"type","conv.close")}}const ar=(e,t,n={})=>{let r=null,s=null,a=null;const{leading:i=!0,trailing:l=!0}=n,c=(...d)=>{const h=Date.now();if(a===null||h-a>=t)i?(e(...d),a=h):(s=d,a=h);else if(s=d,l&&!r){const b=t-(h-a);r=setTimeout(()=>{s&&l&&(e(...s),a=Date.now()),r=null,s=null},b)}};return c.cancel=()=>{r&&(clearTimeout(r),r=null),s=null,a=null},c},qe={DEFAULT_PRIMARY:"#000000",DEFAULT_BOT_MSG_BG:"#ECECEC",WHITE:"#ffffff",BLACK:"#000000"};function ir(e){return e.length===4?`#${[...e.slice(1)].map(t=>t+t).join("")}`:e}function Ho(e){const t=ir(e);return[parseInt(t.slice(1,3),16),parseInt(t.slice(3,5),16),parseInt(t.slice(5,7),16)]}function zo(e){return`#${e.map(t=>t.toString(16).padStart(2,"0")).join("")}`}function Vo(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 Go(e,t,n){let r,s,a;if(t===0)r=s=a=n;else{const i=function(h,b,E){return E<0&&(E+=1),E>1&&(E-=1),E<.16666666666666666?h+(b-h)*6*E:E<.5?b:E<.6666666666666666?h+(b-h)*(.6666666666666666-E)*6:h},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 Qe(e,t,n){const[r,s,a]=Ho(e),[i,l,c]=Vo(r,s,a),d=Math.max(0,Math.min(1,c*t)),h=Math.max(0,Math.min(1,l*n)),[b,E,C]=Go(i,h,d);return zo([Math.round(b),Math.round(E),Math.round(C)])}function Wo(e,t="light"){return{extraDark:Qe(e,.6,1.2),dark:Qe(e,.85,1.1),main:e,light:Qe(e,t==="dark"?1.1:1.5,t==="dark"?.95:.9),extraLight:Qe(e,t==="dark"?1.2:1.75,t==="dark"?.9:.8)}}function Dt(e){const t=ir(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?qe.BLACK:qe.WHITE}function qo(e,t,n,r,s){return{base:{primary:t,primaryContrastContent:n,background:e.background50,headerBackground:e.background50,modalContentBackground:e.background50},metadata:{errorContent:e.ondark.textHighEmphasis},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 jo=(e,t,n,r,s)=>({base:{primary:t,primaryContrastContent:n,background:e.background600,headerBackground:e.background500,modalContentBackground:e.background500},metadata:{errorContent:e.ondark.textHighEmphasis},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}}),et={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)"}},At={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 yn(e){const t=Ko(e),{colors:n,aiAgentColorVariables:r}=Yo(e,t),s=Xo(e);return{selectedTheme:e.selectedTheme,palette:t,colors:n,aiAgentColorVariables:r,typography:s}}function Ko({selectedTheme:e,palette:t,primary:n}){const r=t!=null&&t.primary?t.primary:n?n===et.primary.main?et.primary:Wo(n,e):et.primary;return{...et,primary:r,...t}}function Yo({selectedTheme:e,primaryContrast:t,botMessageBackground:n,botMessageBackgroundContrast:r},s){const a=s.primary.main,i=t??Dt(a),l=n??qe.DEFAULT_BOT_MSG_BG,c=r??Dt(l);return{colors:(e==="light"?qo:jo)(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 Zo(e,t,n){const r={...e};return n.forEach(s=>{const a=t[s];a!=null&&(r[s]=a)}),r}function Xo({typography:e}){if(!e)return At;const t={...At};return Object.keys(e).forEach(n=>{const r=e[n];if(r&&typeof r=="object"){const s=At[n],a=["fontSize","fontWeight","fontFamily","lineHeight"];t[n]=Zo(s,r,a)}}),t}const{Provider:Jo,useContext:Yt}=X("AIAgentTheme");function Qo({logger:e,palette:t,typography:n,appearance:r,children:s}){const a=u.useRef(null),[i,l]=u.useState(()=>yn({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=u.useCallback((d,h)=>{h&&(a.current=h);const b=(r==null?void 0:r.theme)??d,E=a.current?a.current.themes[b]:null,C={primary:r==null?void 0:r.primaryColor,primaryContrast:void 0,botMessageBackground:r==null?void 0:r.botMessageBackgroundColor,botMessageBackgroundContrast:void 0};!C.primary&&(E!=null&&E.primary_color)&&(C.primary=E.primary_color,C.primaryContrast=E.primary_contrast_color),!C.botMessageBackground&&(E!=null&&E.bot_message_bg_color)&&(C.botMessageBackground=E.bot_message_bg_color,C.botMessageBackgroundContrast=E.bot_message_bg_contrast_color);const y=yn({selectedTheme:b,palette:t,typography:n,...C});l(y),e==null||e.info("theme.update:",b)},[r==null?void 0:r.theme,r==null?void 0:r.primaryColor,r==null?void 0:r.botMessageBackgroundColor,t,n,e]);return u.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(Jo,{value:{theme:i,updateTheme:c}},s)}const _n=25*1024*1024,es={off:"off",always:"always",handed_off_only:"handed_off_only"},ts=()=>{const[e,t]=u.useState(()=>({maxAttachmentCount:1,attachmentMode:"handed_off_only",defaultUploadSizeLimit:_n,uploadSizeLimitPerType:new Map,supportedImageMimeTypes:new Set(["image/png","image/jpeg","image/jpg"]),supportedFileMimeTypes:new Set(["application/pdf"])})),n=u.useCallback(({active_channel:s,upload_restriction:a})=>{const{maxAttachmentCount:i,attachmentMode:l,defaultUploadSizeLimit:c,supportedImageMimeTypes:d,supportedFileMimeTypes:h}=e;t({maxAttachmentCount:i,attachmentMode:es[s.attachment_mode]??l,defaultUploadSizeLimit:(a==null?void 0:a.default_upload_size_limit)??c,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)??d),supportedFileMimeTypes:new Set((a==null?void 0:a.supported_file_mime_types)??h)})},[]),r=u.useCallback(s=>{const{channel:a,uploadSizeLimit:i=_n}=s,l=(d=!0)=>a!=null&&a.isAIAgent?d?Be(a):!1:!0,c=d=>{if(l())return e.defaultUploadSizeLimit??i;const h=e.defaultUploadSizeLimit??i,b=e.uploadSizeLimitPerType.get(d)??h;return Math.min(h,b)};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 Be(a);default:return!0}},get supportedMimeTypes(){return l()?[yo]:[...e.supportedImageMimeTypes,...e.supportedFileMimeTypes]},isSupportedMimeType:d=>l()?!0:e.supportedImageMimeTypes.has(d)||e.supportedFileMimeTypes.has(d),getUploadSizeLimit:c,getUploadSizeLimitInMB:d=>c(d)/(1024*1024)}},[e]);return{updateBaseAttachmentRules:n,createAttachmentRules:r}};function lr(){const{chatSDK:e,logger:t}=K();return u.useCallback(async n=>{if(n.userId===""){const r=new Error("userId cannot be empty string for messenger settings request");throw t.error("requestMessengerSettings: invalid userId",r),r}return await e.aiAgent.requestMessengerSettings(n)},[e,t])}function ns(){const{chatSDK:e,logger:t}=K(),n=u.useCallback(async(s,a,i)=>{if(t.debug("useChatConnection.connect: start, session",s.userId),a){const l=new Z.SessionHandler({...a,onSessionTokenRequired:rs(a.onSessionTokenRequired,i)});e.setSessionHandler(l)}try{return await e.connect(s.userId,s.authToken),t.debug("useChatConnection.connect: end, currentUser",e.currentUser),e.currentUser}catch(l){const c=l;if(e.isCacheEnabled){if(ss(c))t.warn("useChatConnection.connect","offline connect restricted",c.message,c.code),t.warn("useChatConnection.connect","clear cached-data"),await e.clearCachedData().catch(d=>t.warn("useChatConnection.connect","clear cached-data failure",d));else if(e.currentUser)return t.debug("useChatConnection.connect: end (offline), currentUser",e.currentUser),e.currentUser}throw t.warn("useChatConnection.connect","connect failure",c.message,c.code),c}},[e,t]),r=u.useCallback(async()=>{t.debug("useChatConnection.disconnect: start"),await e.disconnect(),t.debug("useChatConnection.disconnect: end")},[e,t]);return{connect:n,disconnect:r}}function rs(e,t){if(e)return async(n,r)=>{new Promise((s,a)=>e==null?void 0:e(s,a)).then(s=>{s&&(t==null||t(s)),n(s)}).catch(s=>{r(s)})}}const os=[400300,400301,400302,400310];function ss(e){return os.some(t=>e.code===t)}class cr{constructor({userId:t,authToken:n,sessionHandler:r}){U(this,"userId");U(this,"authToken");U(this,"sessionHandler");this.userId=t,this.authToken=n,this.sessionHandler=r}}class Nt{constructor(){U(this,"userId");U(this,"authToken");U(this,"sessionHandler")}}const as=1440*60*1e3,is=e=>{const{logger:t,cache:n}=K(),r=()=>{const a=n.messenger.getAnonUser();return a?a.expireAt-as<=Date.now()?(t.debug("useUserSessionCandidate.getAnonymousSessionInfo: auto session expired, clear cache"),n.messenger.clear(a.userId),null):(t.debug("useUserSessionCandidate.getAnonymousSessionInfo: auto session info detected"),a):null},s=()=>{if(!e||e instanceof Nt)throw new Error("userSessionInfo must be an instance of ManualSessionInfo");if(typeof e.userId!="string")throw new Error("userSessionInfo.userId must be a string");const a=["userId","authToken","sessionHandler"].filter(i=>!(i in e));return a.length>0&&t.error(`useUserSessionCandidate.getManualSessionInfo: missing required keys in userSessionInfo: ${a.join(", ")}`),t.debug("useUserSessionCandidate.getManualSessionInfo: manual session info detected"),e};return u.useMemo(()=>e instanceof cr?{type:"manual",userSessionCandidate:s()}:e instanceof Nt?{type:"anonymous",userSessionCandidate:r()}:e&&typeof e=="object"?(t.warn("Please use ManualSessionInfo instead of the old userSessionInfo format."),{type:"manual",userSessionCandidate:s()}):e===void 0?(t.warn("Please use AnonymousSessionInfo instead of undefined userSessionInfo."),{type:"anonymous",userSessionCandidate:r()}):{type:"anonymous",userSessionCandidate:null},[t,e==null?void 0:e.userId,e==null?void 0:e.authToken,e==null?void 0:e.sessionHandler,n.messenger.getAnonUser,n.messenger.clear])};function ls({userSessionInfo:e,onUpdateMessengerSettings:t,onPreAuth:n,onPostAuth:r,onErrorAuth:s,onAuthTokenRefreshed:a,onPostDeauth:i,forceCreateChannel:l}){const{aiAgentId:c,language:d,context:h,countryCode:b,logger:E,cache:C}=K(),{connect:y,disconnect:x}=ns(),{type:m,userSessionCandidate:p}=is(e),v=lr(),_=u.useCallback(async()=>{var M;E.debug("useAuthentication.authenticate: start");const T=p!=null&&p.userId?C.messenger.getSettings(p.userId):null;T!=null&&T.bot&&(t(T),E.debug("useAuthentication.authenticate: cached messenger settings",T));const L=await v({aiAgentId:c,userId:p==null?void 0:p.userId,language:d,country:b,context:h,forceCreateChannel:l,knownActiveChannelUrl:(M=T==null?void 0:T.active_channel)==null?void 0:M.channel_url});E.debug("useAuthentication.authenticate: messenger settings response",L);let $=null;if(L.auto_created_user)if(m==="manual")E.warn("Received auto created user info but current session is manual. Ignoring auto created user info."),$={userId:p.userId,authToken:p.authToken};else{const{user_id:R,session_token:z,expire_at:G}=L.auto_created_user;C.messenger.setAnonUser({userId:R,authToken:z,expireAt:G}),$={userId:R,authToken:z}}else $={userId:(p==null?void 0:p.userId)??"",authToken:(p==null?void 0:p.authToken)??""};C.messenger.setSettings($.userId,L),t(L);try{await n(L,$),await y($,p==null?void 0:p.sessionHandler,a),await r(L,$)}catch(R){throw R instanceof Error&&(s(R),E.error("useAuthentication.authenticate: failed to connect",R)),R}return L},[v,y,m,p==null?void 0:p.userId,p==null?void 0:p.sessionHandler,p==null?void 0:p.authToken,c,d,h,b,l,C.messenger.setAnonUser,C.messenger.getSettings,C.messenger.setSettings,t,n,r,s,a]),I=u.useCallback(async()=>{E.debug("useAuthentication.deauthenticate: start"),await x(),i(),E.debug("useAuthentication.deauthenticate: completed")},[x,E,i]);return{authenticate:_,deauthenticate:I,userSessionCandidate:p}}const ur=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)}},Ke=e=>JSON.parse(e),ht=e=>JSON.parse(e);function cs(e,t){const[n,r]=t.split(",").map(s=>s.trim());return e==="dark"&&r||n}function us(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 Zt({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,ur(l))},e)}async function ds({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,ur(l)),e)}const ms=()=>{const{chatSDK:e,logger:t,cache:n}=K(),r=u.useCallback(()=>{var l,c;const a=(c=(l=e.appInfo)==null?void 0:l.aiAgentInfo)==null?void 0:c.templateListToken;if(!a)return!1;const i=n.template.getCachedToken();return i?a!==i:!0},[e,n.template.getCachedToken]),s=u.useCallback(async()=>{try{const{templates:a,token:i}=await e.aiAgent.getMessageTemplates({limit:20});for(const{template:l}of a){const{key:c}=Ke(l);n.template.set(c,l)}n.template.setCachedToken(i)}catch(a){t==null||t.error("messageTemplateContext.syncCachedTemplates: error:",a)}},[e,t,n.template.set,n.template.setCachedToken]);return{shouldSyncCachedTemplate:r,syncCachedTemplates:s}},{Provider:gs,useContext:ft}=X("AIAgentMessengerSession"),hs=u.forwardRef(function({userSessionInfo:e,forceCreateChannel:t,children:n},r){const{appId:s,aiAgentId:a,chatSDK:i,language:l,countryCode:c,context:d,cache:h,logger:b}=K(),{updateTheme:E}=Yt(),[C,y]=u.useState(void 0),[x,m]=u.useState(void 0),[p,v]=u.useState(null),[_,I]=u.useState(null),[T,L]=u.useState(null),[$,M]=u.useState(null),{updateBaseAttachmentRules:R,createAttachmentRules:z}=ts(),{shouldSyncCachedTemplate:G,syncCachedTemplates:Ee}=ms(),xe=lr(),{authenticate:Ie,deauthenticate:j}=ls({userSessionInfo:e,forceCreateChannel:t,onUpdateMessengerSettings:u.useCallback(N=>{const{appearance:A,bot:O,launcher:V}=N;E(A.selected_theme,A),L({userId:O.bot_userid,profileUrl:O.bot_profile_url,nickname:O.bot_nickname,replyToFile:O.reply_to_file,specialNotice:O.special_notice,specialNoticeEnabled:O.is_special_notice_enabled,showHandoffButton:O.show_handoff_button??!0,isMultipleActiveConversationsEnabled:O.is_multiple_active_conversations_enabled??!0,isUserFeedbackEnabled:N.bot.is_user_feedback_enabled??!1,isUserFeedbackCommentOptionEnabled:N.bot.is_user_feedback_comment_option_enabled??!1}),M({type:V.image_type||"default_icon",imageUrl:V.image_url}),R(N)},[E]),onPreAuth:u.useCallback((N,A)=>{y(void 0),I(A)},[]),onPostAuth:u.useCallback(async N=>{v(i.currentUser),G()&&await Ee(),m({url:N.active_channel.channel_url,status:q.ConversationStatus.OPEN})},[i,G,Ee]),onErrorAuth:u.useCallback(N=>{y(N)},[]),onAuthTokenRefreshed:u.useCallback(N=>{I(A=>A?{...A,authToken:N}:null)},[]),onPostDeauth:u.useCallback(()=>{h.template.clear(),h.messenger.clear(_==null?void 0:_.userId),v(null),m(void 0),I(null),L(null),M(null)},[h.template.clear,h.messenger.clear,_])}),ne=u.useCallback(async()=>{var N;if(_){b.debug("agentMessengerSession.refreshActiveChannel: try to refresh active channel"),m(void 0);const A=await xe({aiAgentId:a,userId:_.userId,language:l,country:c,context:d,forceCreateChannel:t,knownActiveChannelUrl:(N=h.messenger.getSettings(_.userId))==null?void 0:N.active_channel.channel_url});return h.messenger.setSettings(_.userId,A),m({url:A.active_channel.channel_url,status:q.ConversationStatus.OPEN}),b.info("agentMessengerSession.refreshActiveChannel: refreshed active channel",A.active_channel.channel_url),A.active_channel.channel_url}else throw b.error("agentMessengerSession.refreshActiveChannel: userSession is not ready"),new Error("userSession is not ready")},[xe,s,a,_==null?void 0:_.userId,l,c,d,t,h.messenger.getSettings,h.messenger.setSettings]),ve=u.useCallback(async N=>{if(!(_!=null&&_.userId))throw new Error("Current user is not authenticated. Please authenticate first.");const A=await xe({...N,userId:_.userId,knownActiveChannelUrl:void 0}),O=A.active_channel.channel_url;return h.messenger.setSettings(_.userId,A),O},[_==null?void 0:_.userId,xe]),[w]=u.useState(()=>ar(N=>{var A;b.info("agentMessengerSession.channelChanged: channel.conversation",N.conversation),m({url:N.url,status:((A=N.conversation)==null?void 0:A.status)??q.ConversationStatus.OPEN})},250,{trailing:!1,leading:!0}));return Ue.useGroupChannelHandler(i,{onChannelChanged:N=>{N.isGroupChannel()&&N.url===(x==null?void 0:x.url)&&w(N)}}),u.useEffect(()=>()=>{w.cancel()},[w]),u.useImperativeHandle(r,()=>{const N=async()=>{if(!x)throw new Error("No active conversation. Please start a conversation first.");return await i.groupChannel.getChannel(x.url)};return{activeChannel:x,chatSDK:i,authenticate:Ie,deauthenticate:j,updateContext:async A=>{const V=await(await N()).updateContext(a,A);return{...V,context:V.context??{}}},patchContext:async A=>{const V=await(await N()).patchContext(a,A);return{...V,context:V.context??{}}},getContextObject:async()=>{const O=await(await N()).getContextObject(a);return{...O,context:O.context??{}}}}},[Ie,j,x,i,a,b]),o.createElement(gs,{value:{sdkUser:p,userSessionInfo:e,userSession:_,activeChannel:x,setActiveChannel:m,refreshActiveChannel:ne,createConversation:ve,connectionError:C,aiAgentInfo:T,launcherInfo:$,authenticate:Ie,deauthenticate:j,createAttachmentRules:z}},n)}),fs=()=>{const e=u.useId(),{chatSDK:t,networkStateAdapter:n}=K(),[r,s]=u.useState(()=>n?n.isOnline()?"connected":"reconnecting":"connected");return u.useEffect(()=>{const a=new Z.ConnectionHandler({onDisconnected:()=>s("disconnected"),onConnected:()=>s("connected"),onReconnectStarted:()=>s("reconnecting"),onReconnectSucceeded:()=>s("connected"),onReconnectFailed:()=>s("disconnected"),onConnectionLost:()=>s("reconnecting")});return t.addConnectionHandler(e,a),()=>{t.removeConnectionHandler(e)}},[t,e]),u.useEffect(()=>{if(n)return n.subscribe(()=>{s("reconnecting")})},[n]),r},dr=e=>{const{chatSDK:t}=K(),[n,r]=u.useState([]);return Ue.useGroupChannelHandler(t,{onTypingStatusUpdated(s){if(s.url===(e==null?void 0:e.url)){const a=s.getTypingUsers();r(a)}}}),n},ps=({channel:e,messages:t,isStreamAnimating:n})=>{const{aiAgentInfo:r,userSession:s}=ft(),a=fs(),i=bs({channel:e,lastMessage:xn(t,[_e.SendingStatus.SUCCEEDED]),aiAgentUserId:(r==null?void 0:r.userId)??"",isStreamAnimating:n}),l=Cs({shouldApply:!!(e!=null&&e.isAIAgent)&&!Be(e),isDisabledWhileAIResponding:i,lastMessage:xn(t,[_e.SendingStatus.PENDING,_e.SendingStatus.SUCCEEDED]),currentUserId:(s==null?void 0:s.userId)??""});if(!e||a==="disconnected")return{disabled:!0,disabledBy:"unavailable"};if(a==="reconnecting")return{disabled:!0,disabledBy:"reconnecting"};if(Te(e))return{disabled:!0,disabledBy:"conversation_closed"};if(Es(e))return{disabled:!0,disabledBy:"form_active"};const c=xs(e);return c?{disabled:!0,disabledBy:c}:i||l?{disabled:!0,disabledBy:"ai_responding"}:{disabled:!1,disabledBy:""}},bs=({channel:e,lastMessage:t,aiAgentUserId:n,isStreamAnimating:r})=>{const[s,a]=u.useState(!1),i=dr(e);return u.useEffect(()=>{if(!t)return;const l=i.some(d=>d.userId===n),c=je(t,n)&&(Se.isStreaming(t)||r);a(!!(c||l))},[i,t,n,r]),s},Es=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},xs=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},vs=3e4,Cs=({shouldApply:e,lastMessage:t,isDisabledWhileAIResponding:n,currentUserId:r})=>{const[s,a]=u.useState(!1),i=u.useRef(null),l=t&&je(t,r)?t.createdAt:0;return u.useEffect(()=>{const c=()=>{i.current&&(clearTimeout(i.current),i.current=null),a(!1)},d=E=>{i.current&&clearTimeout(i.current),a(!0),i.current=setTimeout(()=>{a(!1),i.current=null},E)},h=Date.now()-l,b=vs-h;return n||b<=0?c():d(b),()=>{i.current&&clearTimeout(i.current)}},[n,l]),s&&e},ys=()=>{const[e,t]=u.useState(new Set),n=u.useCallback(s=>{t(a=>{if(a.has(s))return a;const i=new Set(a);return i.add(s),i})},[]),r=u.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:_s}=X("AIAgentConversation");function Ss({children:e,channelUrl:t,onChannelDeleted:n,onMessagesReceived:r,onMessagesUpdated:s,onConversationClosedStatusChanged:a,onConversationClosedViaDispatcher:i,onBeforeSendMessage:l,onAfterSendMessage:c=fe,shouldMarkAsRead:d=!0,shouldCountNewMessages:h=()=>!1,sortComparator:b}){var M;const E=()=>d&&(m==null?void 0:m.markAsRead()),{chatSDK:C,logger:y,dispatcher:x}=K(),{channel:m,channelFetchError:p,fetchChannel:v}=Ts(t),_=Bo(C,m,{replyType:_e.ReplyType.ONLY_REPLY_TO_CHANNEL,shouldCountNewMessages:h,onChannelDeleted:n,onMessagesReceived:R=>r==null?void 0:r(R),onMessagesUpdated:R=>s==null?void 0:s(R),logger:y,markAsRead:E,sortComparator:b}),I=ys(),T=ps({channel:m,messages:_.messages,isStreamAnimating:I.isAnimating});u.useEffect(()=>{E()},[d]);const L=Te(m);u.useEffect(()=>{a==null||a(L)},[L,a]),u.useEffect(()=>{const R=async z=>{const G=typeof(z==null?void 0:z.channelUrl)=="string";m&&G&&z.channelUrl!==m.url||(y.debug("conversation.dispatcher: try to close conversation",m),m!=null&&m.conversation&&m.conversation.status===q.ConversationStatus.OPEN&&(await m.closeConversation(),i==null||i()))};return x.subscribe(Rt.ConversationClose,R),()=>{x.unsubscribe(Rt.ConversationClose,R)}},[x,(M=m==null?void 0:m.conversation)==null?void 0:M.status,i]);const $={conversation:(m==null?void 0:m.conversation)??void 0,channelSource:{channel:m,error:p,refetch:()=>v(),closeConversation:async()=>{Te(m)||await(m==null?void 0:m.closeConversation())}},messageSource:{messages:_.messages,newMessages:_.newMessages,initialized:_.initialized,loadPrevious:()=>_.loadPrevious(),loadNext:()=>_.loadNext(),deleteMessage:R=>_.deleteMessage(R),resendMessage:R=>_.resendMessage(R),resetNewMessages:()=>_.resetNewMessages(),sendUserMessage:async R=>{var G;if(((G=m==null?void 0:m.conversation)==null?void 0:G.status)===q.ConversationStatus.CLOSED)throw new Error("Conversation is closed");l&&(R=await l(R));const z=await _.sendUserMessage(R,c);return c==null||c(z),z},sendFileMessage:async R=>{var G;if(((G=m==null?void 0:m.conversation)==null?void 0:G.status)===q.ConversationStatus.CLOSED)throw new Error("Conversation is closed");l&&(R=await l(R));const z=await _.sendFileMessage(R,c);return c==null||c(z),z}},state:{streamAnimation:I,input:T}};return o.createElement(_s,{value:$},e)}function Ts(e){const{chatSDK:t,logger:n}=K(),{sdkUser:r}=ft(),[s,a]=u.useState(void 0),[i,l]=u.useState(void 0);async function c(){if(!r){n.debug("conversation.fetchChannel: no sdk user, skip fetching channel");return}if(n.debug("conversation.fetchChannel: start"),a(void 0),l(void 0),e)try{n.debug("conversation.fetchChannel: get channel",e);const d=await t.groupChannel.getChannel(e);a(d),n.debug("conversation.fetchChannel: fetched channel",d)}catch(d){d instanceof Z.SendbirdError&&l(d),n.error("conversation.fetchChannel: error",d)}}return As(s),u.useEffect(()=>{c()},[t,r,e]),{channel:s,channelFetchError:i,fetchChannel:c}}function As(e){const{chatSDK:t}=K(),{activeChannel:n,setActiveChannel:r}=ft(),s=u.useId();u.useEffect(()=>{if(!e||!n)return;const a=new Z.ConnectionHandler({onReconnectSucceeded:async()=>{var l;const i=await e.refresh();i.url===n.url&&r({url:i.url,status:((l=i.conversation)==null?void 0:l.status)??q.ConversationStatus.OPEN})}});return t.addConnectionHandler(s,a),()=>{t.removeConnectionHandler(s)}},[t,e,n])}class ws{constructor(t,{filter:n,limit:r=20}){U(this,"filter");U(this,"_sdk");U(this,"_pinnedChannels");U(this,"_channels");U(this,"_isDisposed",!1);U(this,"_handlerId",`handler-id-${Date.now()}`);U(this,"_order",lt.GroupChannelListOrder.LATEST_LAST_MESSAGE);U(this,"_limit");U(this,"_query");U(this,"_token");U(this,"_timestamp");U(this,"_isSyncing");U(this,"_channelHandler");U(this,"_connectionHandler");U(this,"_collectionEventHandler");U(this,"_throttledOnChannelChanged");var s,a,i,l,c,d,h;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:(d=this.filter)==null?void 0:d.copilotConversationOnly,copilotSupportChannelUrl:(h=this.filter)==null?void 0:h.copilotSupportChannelUrl,limit:this._limit}),this._token="",this._timestamp=Number.MAX_SAFE_INTEGER,this._isSyncing=!1,this._throttledOnChannelChanged=ar(b=>{b.isGroupChannel()&&(this._query.belongsTo(b)?this._addChannelsToView([b],!1):this._removeChannelsFromView([b.url]))},250,{trailing:!1,leading:!0}),this._channelHandler=new lt.GroupChannelHandler({onChannelChanged:this._throttledOnChannelChanged,onChannelDeleted:b=>{this._removeChannelsFromView([b])}}),this._connectionHandler=new Z.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,d)=>[c,d])),s=[],a=[],i=[];for(const c of t){if(!this._query.belongsTo(c)){i.push(c.url);continue}const d=r.get(c.url);if(d===void 0)continue;const h=Pt(this._pinnedChannels,c);h>=0?(this._pinnedChannels.splice(h,1),a.push(c)):s.push(c);const E=this._pinnedChannels.findIndex(y=>(r.get(y.url)??1/0)>d),C=E===-1?this._pinnedChannels.length:E;this._pinnedChannels.splice(C,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=Pt(this._channels,i),c=l<0;!c&&this._channels.splice(l,1);const h=ks(this._channels,i,this._order).place,b=h===this._channels.length;c?b?(n||!this.hasMore)&&(this._channels.push(i),s.push(i)):(this._channels.splice(h,0,i),s.push(i)):(this._channels.splice(h,0,i),a.push(i))}return{addedChannels:s,updatedChannels:a,unmatchedChannelUrls:r}}_addChannelsToView(t,n=!1){var b,E,C,y,x;const r=new Set(((b=this.filter)==null?void 0:b.pinnedChannelUrls)??[]),s=[],a=[];for(const m of t)r.has(m.url)?s.push(m):a.push(m);const i=this._upsertPinnedChannelsToArray(s),l=this._upsertRegularChannelsToArray(a,n),c=i.addedChannels.concat(l.addedChannels),d=i.updatedChannels.concat(l.updatedChannels),h=i.unmatchedChannelUrls.concat(l.unmatchedChannelUrls);c.length>0&&((C=(E=this._collectionEventHandler)==null?void 0:E.onChannelsAdded)==null||C.call(E,{},c)),d.length>0&&((x=(y=this._collectionEventHandler)==null?void 0:y.onChannelsUpdated)==null||x.call(y,{},d)),h.length>0&&this._removeChannelsFromView(h)}_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(d=>d.url===l);c>=0&&(r.push(l),this._pinnedChannels.splice(c,1))}else{const c=this._channels.findIndex(d=>d.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 Pt=(e,t)=>e.findIndex(n=>n.isIdentical(t)),ks=(e,t,n)=>{if(e.length>0){const r=Pt(e,t);let s=0,a=e.length-1,i=Math.floor((s+a)/2);for(;s<a;){const c=Sn(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:Sn(e[i],t,n)>=0?i:i+1,oldPosition:r}}return{place:e.length,oldPosition:-1}},Sn=(e,t,n)=>{switch(n){case lt.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}};function Is(e,t){var y,x,m,p,v,_,I,T,L,$;const n=u.useId(),[r,s]=u.useState(!1),[a,i]=u.useState(null),[l,c]=u.useState([]),[d,h]=u.useState(null),b=u.useRef(!1),E=u.useCallback(async()=>{if(!b.current&&e.currentUser){b.current=!0,s(!1),i(null),c([]);try{d==null||d.dispose();const M=new ws(e,t);M.setConversationListCollectionHandler({onChannelsAdded:()=>{c(M.channels)},onChannelsUpdated:()=>{c(M.channels)},onChannelsDeleted:()=>{c(M.channels)}}),await M.loadMore(),h(M),i(null)}catch(M){h(null),i(M)}finally{s(!0),b.current=!1}}},[e,e.currentUser,(y=t.filter)==null?void 0:y.aiAgentChannelFilter,(m=(x=t.filter)==null?void 0:x.aiAgentConversationStatusFilter)==null?void 0:m.join(),(v=(p=t.filter)==null?void 0:p.aiAgentIds)==null?void 0:v.join(),(_=t.filter)==null?void 0:_.deskChannelFilter,(T=(I=t.filter)==null?void 0:I.pinnedChannelUrls)==null?void 0:T.join(),(L=t.filter)==null?void 0:L.copilotConversationOnly,($=t.filter)==null?void 0:$.copilotSupportChannelUrl,t.limit]),C=u.useCallback(async()=>{if(d)try{await d.loadMore()}catch(M){i(M)}},[d]);return u.useEffect(()=>(e.addConnectionHandler(n,new Z.ConnectionHandler({onConnected:()=>E()})),()=>e.removeConnectionHandler(n)),[e,n,E]),u.useEffect(()=>{E()},[E]),u.useEffect(()=>()=>{b.current=!1,d==null||d.dispose()},[d]),{initialized:r,error:a,channels:l,loadMore:C}}const{Provider:$s}=X("AIAgentConversationList");function Ms({conversationListLimit:e,conversationListFilter:t,children:n}){var b,E;const{chatSDK:r,aiAgentId:s,queryParams:a}=K(),i={aiAgentIds:[s],aiAgentConversationStatusFilter:[q.ConversationStatus.CLOSED,q.ConversationStatus.OPEN]},l=e??((b=a==null?void 0:a.conversationListParams)==null?void 0:b.limit),c={...i,...(E=a==null?void 0:a.conversationListParams)==null?void 0:E.filter,...t},d=Is(r,{limit:l,filter:c}),h={listSource:{initialized:d.initialized,error:d.error??void 0,channels:d.channels,loadMore:()=>d.loadMore()}};return o.createElement($s,{value:h},n)}function Ls(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:Os,useContext:mr}=X("MessageTemplateFetching");function Rs({children:e,internalVariables:t}){const n=u.useRef({}),r=u.useRef({}),[s,a]=u.useState({}),i=u.useCallback((d,h)=>{a(b=>({...b,[d]:{fetching:!1,error:!1,...b[d],...h}}))},[]),l=u.useCallback(async({onRequestTemplate:d,onGetCachedTemplate:h,templateKey:b,suspense:E=!1})=>{const C=h(b);if(C)return C;const y=r.current[b];if(y)return y;E||i(b,{fetching:!0});const x=d(b).catch(m=>{throw E||i(b,{error:!0}),m}).finally(()=>{E||i(b,{fetching:!1}),delete r.current[b]});return r.current[b]=x,x},[i]),c={internalVariables:t,fetchTemplate:l,suspend:(d,h)=>{if(n.current[d])return n.current[d];const b=Ls(h());return n.current[d]=b,b},getIsFetching:d=>{var h;return((h=s[d])==null?void 0:h.fetching)??!1},getHasError:d=>{var h;return((h=s[d])==null?void 0:h.error)??!1}};return o.createElement(Os,{value:c},e)}const pt={VARIABLE:e=>new RegExp(`\\{${e}\\}`,"g"),VIEW_VARIABLE:e=>new RegExp(`"{@${e}}"`,"g")};function Ae({uiTemplateString:e,variables:t={}}){const n=us(t);return Zt({template:e,variables:n,variableKeyPattern:r=>pt.VARIABLE(r)})}function we({theme:e,uiTemplateString:t,colorVariables:n={}}){return Zt({template:t,variables:n,variableKeyPattern:r=>pt.VARIABLE(r),variableValueTransformer:r=>cs(e,r)})}function Ds({theme:e,uiTemplateString:t,viewVariables:n={},aiAgentColorVariables:r,internalVariables:s,onRequestTemplate:a}){const l=Object.values(n).flat().map(d=>d.key);return[...new Set(l)].some(d=>!a(d))?null:Zt({template:t,variables:n,variableKeyPattern:d=>pt.VIEW_VARIABLE(d),variableValueTransformer:d=>{const h=d.map(({key:b,variables:E})=>{const C=a(b),{ui_template:y,color_variables:x}=Ke(C);let m=JSON.stringify(y);return m=Ae({uiTemplateString:m,variables:s}),m=we({theme:e,uiTemplateString:m,colorVariables:x}),m=we({theme:e,uiTemplateString:m,colorVariables:r}),m=Ae({uiTemplateString:m,variables:E}),ht(m)});return JSON.stringify(h)}})}async function Ns({theme:e,uiTemplateString:t,viewVariables:n={},aiAgentColorVariables:r,internalVariables:s,onRequestTemplate:a}){return ds({template:t,variables:n,variableKeyPattern:i=>pt.VIEW_VARIABLE(i),variableValueTransformer:async i=>{const l=i.map(async({key:d,variables:h})=>{const b=await a(d),{ui_template:E,color_variables:C}=Ke(b);let y=JSON.stringify(E);return y=Ae({uiTemplateString:y,variables:s}),y=we({theme:e,uiTemplateString:y,colorVariables:C}),y=we({theme:e,uiTemplateString:y,colorVariables:r}),y=Ae({uiTemplateString:y,variables:h}),ht(y)}),c=await Promise.all(l);return JSON.stringify(c)}})}const Ps=({rawTemplate:e,aiAgentColorVariables:t,internalVariables:n,...r})=>{const{ui_template:s,color_variables:a}=Ke(e);let i=JSON.stringify(s);if(Object.keys(r.viewVariables??{}).length>0){const c=Ds({...r,uiTemplateString:i,aiAgentColorVariables:t,internalVariables:n});if(c===null)return null;i=c}return i=Ae({...r,uiTemplateString:i,variables:n}),i=we({...r,uiTemplateString:i,colorVariables:a}),i=we({...r,uiTemplateString:i,colorVariables:t}),i=Ae({...r,uiTemplateString:i}),ht(i)},Bs=async({rawTemplate:e,aiAgentColorVariables:t,internalVariables:n,...r})=>{const{ui_template:s,color_variables:a}=Ke(e);let i=JSON.stringify(s);return Object.keys(r.viewVariables??{}).length>0&&(i=await Ns({...r,uiTemplateString:i,aiAgentColorVariables:t,internalVariables:n})),i=Ae({...r,uiTemplateString:i,variables:n}),i=we({...r,uiTemplateString:i,colorVariables:a}),i=we({...r,uiTemplateString:i,colorVariables:t}),i=Ae({...r,uiTemplateString:i}),ht(i)},Fs=e=>{const{aiAgentColorVariables:t={}}=e,{internalVariables:n}=mr();return u.useState(()=>{const r=e.onGetCachedTemplate(e.templateKey);return r?Ps({...e,rawTemplate:r,aiAgentColorVariables:t,internalVariables:n,onRequestTemplate:e.onGetCachedTemplate}):null})},Us=e=>{const[t]=Fs(e);if(t)return t;const{aiAgentColorVariables:n={}}=e,{internalVariables:r,fetchTemplate:s,suspend:a}=mr();return a(e.templateKey,async()=>{const l=await s({...e,suspense:!0});return await Bs({...e,rawTemplate:l,aiAgentColorVariables:n,internalVariables:r})}).value},Hs="remove_powered_by",Xt=(e,t)=>{var s,a;const{chatSDK:n}=K(),{aiAgentInfo:r}=ft();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&&Wt(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 u.useMemo(()=>!(Array.isArray(i)&&i.includes(Hs)),[i])}throw new Error("Unsupported feature")},zs={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"},Vs={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}}},Gs={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}}},Ws={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}}},qs={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}}},js={text:Vs,number:Gs,"single-select":Ws,"multi-select":qs},Ks={getValueOrDefault:()=>null,validate:()=>({isValid:!1})};function gr(e){return js[e.type]||Ks}function Tn(e){return gr(e).getValueOrDefault(e)}function Ys(e,t,n={}){const r={...zs,...n};return gr(e).validate(e,t,r)}const Zs=(e,t={})=>{const{labels:n={},onSubmit:r,onCancel:s}=t,[a,i]=u.useState({}),[l,c]=u.useState(()=>{const x={};return e.fields.forEach(m=>{x[m.key]=Tn(m)}),x}),d=u.useMemo(()=>e.submitted_at?"submitted":e.canceled_at?"canceled":"draft",[e.submitted_at,e.canceled_at]);u.useEffect(()=>{if(d==="submitted"||d==="canceled"){const x={};let m=!1;e.fields.forEach(p=>{const v=Tn(p);JSON.stringify(l[p.key])!==JSON.stringify(v)&&(m=!0),x[p.key]=v}),m&&c(x)}},[d]);const h=(x,m)=>{c(p=>({...p,[x]:m})),i(p=>({...p,[x]:void 0}))},b=e.fields.map(x=>{var v,_,I;const m=l[x.key]??null,p={key:x.key,label:x.label,error:a[x.key],required:x.required};return x.type==="text"?{...p,type:"text",layout:x.layout,value:m,...x.placeholder&&{placeholder:x.placeholder},...((v=x.rules)==null?void 0:v.max_length)&&{maxLength:x.rules.max_length}}:x.type==="number"?{...p,type:"number",layout:x.layout,value:m,...x.placeholder&&{placeholder:x.placeholder},...((_=x.rules)==null?void 0:_.max)&&{max:x.rules.max}}:x.type==="single-select"?{...p,type:"single-select",layout:x.layout,value:m,options:x.options}:x.type==="multi-select"?{...p,type:"multi-select",layout:x.layout,value:m,options:x.options,...((I=x.rules)==null?void 0:I.max_select)&&{maxSelect:x.rules.max_select}}:{...p,type:"unknown",layout:"default",value:null}});return{state:d,fields:b,getField:x=>b.find(m=>m.key===x),updateFieldValue:h,submit:async()=>{const x={};let m=!1;for(const p of e.fields){const v=l[p.key]??null,_=Ys(p,v,n);_.isValid||(x[p.key]=_.error,m=!0)}if(i(x),!m&&r){const p={};e.fields.forEach(v=>{p[v.key]=l[v.key]??null}),await r(p)}},cancel:async()=>{await(s==null?void 0:s())}}},hr=({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?Be(e)?s.human("agent"):s.ai("delight"):e.isDesk?s.human("agent"):s.channel("user")},An=e=>u.useReducer((t,n)=>({...t,...n}),e);var le=(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))(le||{});const Xs=new Set(["free_text","single_choice"]),Js=({csatPayload:e,type:t,initialCsat:n,initialCsatReason:r,initialIsResolved:s})=>{const[a,i]=An({csatType:t,csat:n,csatReason:r,isResolved:s}),[l,c]=An({followUpItem:!1}),d=u.useMemo(()=>{var x;const C=a.csat;if(typeof C!="number")return;const y=(x=e.follow_up)==null?void 0:x.find(m=>m.scores.includes(C));if(Xs.has(y==null?void 0:y.response_type))return y},[a.csat,e.follow_up]),h=(()=>{var C;if(typeof n=="number")return"submitted";if((t===le.AI_AGENT_CSAT_5||t===le.HELPDESK_CSAT_5)&&typeof a.csat=="number")return"submittable";if(t===le.AI_AGENT_CSAT_5_WITH_CRE){const y=typeof a.csat=="number",x=!((C=e.cre)!=null&&C.required)||typeof a.isResolved=="boolean";if(y&&x)return"submittable"}return"unsubmittable"})(),b=u.useCallback(()=>typeof a.csat>"u"?!1:d!=null&&d.required&&!a.csatReason?(c({followUpItem:!0}),!1):!0,[a,d,c]);return u.useEffect(()=>{r||(i({csatReason:""}),c({followUpItem:!1}))},[r,d,i,c]),{params:a,setParams:i,error:l,setError:c,followUpItem:d,state:h,validateParams:b,itemProps:{csatPayload:e,state:h,submitted:h==="submitted"}}},wt=5,Qs=250,ea=50,wn=e=>Math.max(0,e-ea),ta=e=>e<1e3?{speed:wt*.5,chunkSize:2}:e<2e3?{speed:wt*.8,chunkSize:2}:{speed:wt*.6,chunkSize:3},na=e=>{const{text:t,enabled:n=!1,onAnimationStart:r,onAnimationProgress:s,onAnimationComplete:a}=e,[i,l]=u.useState(()=>wn(t.length)),c=u.useRef(null),d=u.useRef({startTime:0,lastUpdate:0,lastProgressCall:0}).current,h=u.useRef({onStart:r,onProgress:s,onComplete:a}).current,b=u.useRef({startCalled:!1,completeCalled:!1}).current,E=u.useRef({initialEnabled:n,textLength:t.length,enabled:n}).current,C=n,y=i<t.length,x=E.initialEnabled&&(C||y);return u.useLayoutEffect(()=>{h.onStart=r,h.onProgress=s,h.onComplete=a,E.textLength=t.length,E.enabled=n}),u.useLayoutEffect(()=>{var m;E.initialEnabled&&(b.startCalled||(b.startCalled=!0,(m=h.onStart)==null||m.call(h)),l(p=>t.length<p?t.length:p))},[t]),u.useEffect(()=>{if(!E.initialEnabled)return;let m=wn(t.length);d.lastUpdate=0,d.startTime=0,d.lastProgressCall=0;const p=v=>{var z;d.lastUpdate===0&&(d.lastUpdate=v,d.startTime=v,d.lastProgressCall=v);const _=E.textLength,I=v-d.lastUpdate,T=v-d.startTime,{speed:L,chunkSize:$}=ta(T),M=L*$;I>=M&&m<_&&(m=Math.min(m+$,_),l(m),d.lastUpdate=v),v-d.lastProgressCall>=Qs&&(d.lastProgressCall=v,(z=h.onProgress)==null||z.call(h)),(m<_||E.enabled)&&(c.current=requestAnimationFrame(p))};return c.current=requestAnimationFrame(p),()=>{c.current&&cancelAnimationFrame(c.current)}},[]),u.useEffect(()=>{var _;const m=E.initialEnabled&&b.startCalled,p=!n,v=i>=t.length&&t.length>0;m&&p&&v&&!b.completeCalled&&(b.completeCalled=!0,(_=h.onComplete)==null||_.call(h))},[n,i,t.length]),{streamText:E.initialEnabled?t.slice(0,i):t,isAnimating:x}},ra='@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}',oa={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"},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"}},Bt={language:"en",strings:oa,dateLocale:ao.enUS},fr=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,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}),sa=e=>{var t;return((t=e.split("-"))==null?void 0:t[0])??bt},bt="en",aa=new Set([bt,"ko","es","pt","fr","hi","it","de","tr","ja"]),ia=(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.":""))))})},kn=fr(Bt.strings),la={...kn,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:"You can't upload more than one image",FILE_UPLOAD_NOTIFICATION__SIZE_LIMIT:"The maximum size per file is %d MB.",FILE_VIEWER__UNSUPPORT:"Unsupported message",CSAT5_RATING_SCORE_1:"Terrible",CSAT5_RATING_SCORE_2:"Bad",CSAT5_RATING_SCORE_3:"Okay",CSAT5_RATING_SCORE_4:"Good",CSAT5_RATING_SCORE_5:"Great",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:kn.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"},ct={language:Bt.language,dateLocale:Bt.dateLocale,stringSet:la},ca=Object.freeze(Object.defineProperty({__proto__:null,default:ct},Symbol.toStringTag,{value:"Module"})),Ft=new Map([[bt,ct]]);async function ua(e){const t=Ft.get(e);if(t)return t;try{if(aa.has(e)){const{default:n}=await ia(Object.assign({"./languages/de.ts":()=>Promise.resolve().then(()=>require("./BdwWrAAp.cjs")),"./languages/en.ts":()=>Promise.resolve().then(()=>ca),"./languages/es.ts":()=>Promise.resolve().then(()=>require("./C0ghQ00S.cjs")),"./languages/fr.ts":()=>Promise.resolve().then(()=>require("./Cfl_OFPL.cjs")),"./languages/hi.ts":()=>Promise.resolve().then(()=>require("./BKGMHnw9.cjs")),"./languages/it.ts":()=>Promise.resolve().then(()=>require("./DHKyBmS2.cjs")),"./languages/ja.ts":()=>Promise.resolve().then(()=>require("./PZ2du4si.cjs")),"./languages/ko.ts":()=>Promise.resolve().then(()=>require("./BPwCUUtB.cjs")),"./languages/pt.ts":()=>Promise.resolve().then(()=>require("./C6epASKA.cjs")),"./languages/tr.ts":()=>Promise.resolve().then(()=>require("./DEtHXyvH.cjs"))}),`./languages/${e}.ts`,3);return Ft.set(e,n),n}return ct}catch{return ct}}const{Provider:da,useContext:F}=X("Localization"),ma=({language:e=navigator.language,logger:t,stringSet:n,children:r})=>{const[s,a]=u.useState(Ft.get(bt));return u.useEffect(()=>{const i=sa(e);s.language!==i&&(t==null||t.debug("localization.useEffect: update language",{from:s.language,to:i}),ua(i).then(a))},[e,t]),o.createElement(da,{value:{language:s.language,stringSet:{...s.stringSet,...n},dateLocale:s.dateLocale,format:(i,l,c)=>ye.format(i,l,{locale:s.dateLocale,...c})}},r)},ut="data-sb-agent-theme",In=e=>(t,...n)=>{let r="";return t.forEach((s,a)=>{r+=s+(n[a]??"")}),`[${ut}='${e}'] & { ${r} }`},D={light:In("light"),dark:In("dark")},ga=S.css(({theme:e})=>{const{palette:t}=e;return`
|
|
2
2
|
:root,
|
|
3
3
|
:host {
|
|
4
4
|
--sendbird-primary-extra-dark: ${t.primary.extraDark};
|
|
@@ -47,15 +47,15 @@
|
|
|
47
47
|
--sendbird-overlay-dark: ${t.overlay.dark};
|
|
48
48
|
--sendbird-overlay-light: ${t.overlay.light};
|
|
49
49
|
}
|
|
50
|
-
`}),ha=S.css`[${ut}='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);}[${ut}='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);}`,g={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:fa,useContext:pr}=
|
|
50
|
+
`}),ha=S.css`[${ut}='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);}[${ut}='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);}`,g={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:fa,useContext:pr}=X("MessengerTheme");function pa(e){const{theme:t,appearance:n,logger:r}=e;return o.createElement(Qo,{appearance:n,palette:t==null?void 0:t.palette,typography:t==null?void 0:t.typography,logger:r},o.createElement(ba,{...e}))}function ba({rootElement:e=document.body,children:t}){const{theme:n,updateTheme:r}=Yt();return u.useLayoutEffect(()=>{e.setAttribute(ut,n.selectedTheme)},[e,n.selectedTheme]),o.createElement(S.ThemeProvider,{theme:n},o.createElement(fa,{value:{theme:n,updateTheme:r,rootElement:e}},t))}function Me(e,t){const n=e.getRootNode({composed:t});return n instanceof ShadowRoot||n instanceof Document?n:document}const Ea=(e,t)=>{u.useEffect(()=>{const n=Me(t)instanceof ShadowRoot,r=Me(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])},xa=(e,t=document.body)=>{u.useEffect(()=>{const n=Me(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:va,Consumer:br,useContext:W}=X("Messenger");function Ca({children:e,state:t,enableCloseConversationButton:n=!1,enableExpandButton:r=!0,enableAutoDisconnectInLauncher:s=!0,...a}){const[i,l]=u.useState(!1),[c,d]=u.useState(!1),h={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)??d};return o.createElement(Po,{...a},b=>o.createElement(va,{value:{...a,...b,state:h,enableCloseConversationButton:n,enableExpandButton:r,enableAutoDisconnectInLauncher:s}},e))}const ce=e=>{const t=e;return typeof t=="number"?`${t}px`:t},k=({as:e,variant:t="body1",color:n,maxTextLines:r,className:s,...a})=>o.createElement(Sa,{as:e,$variant:t,className:s,$color:n,$maxTextLines:r,...a}),$n=new WeakMap,ya=(e,t)=>{let n=$n.get(t);n||(n=new Map,$n.set(t,n));const r=n.get(e);if(r)return r;const s=t[e]??t.body1,a=S.css`font-size:${ce(s.fontSize)};font-weight:${s.fontWeight};${s.fontFamily?`font-family: ${s.fontFamily};`:""}
|
|
51
51
|
${s.lineHeight?`line-height: ${s.lineHeight};`:"line-height: 100%;"}
|
|
52
|
-
`;return n.set(e,a),a},_a=e=>e?S.css`display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:${e};overflow:hidden;`:"",Sa=f.default.span`font-stretch:normal;letter-spacing:normal;${({$variant:e,theme:t})=>ya(e,t.typography)}color:${({$color:e})=>e};${({$maxTextLines:e})=>_a(e)}`;class dt extends u.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(u.Suspense,{fallback:r},s)}}const Ta=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"})),Aa=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"})),wa=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"})),ka=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"})),Ia=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"})),$a=new Set(["send","chat","message","chevron-right","good","good-filled","bad","bad-filled"]),Ma={close:Ta,send:Ia,menu:ka,expand:wa,collapse:Aa,spinner:u.lazy(()=>Promise.resolve().then(()=>require("./Cf3-irI8.cjs"))),chat:u.lazy(()=>Promise.resolve().then(()=>require("./BmdfYY9c.cjs"))),message:u.lazy(()=>Promise.resolve().then(()=>require("./CmWLVNPR.cjs"))),error:u.lazy(()=>Promise.resolve().then(()=>require("./DNmdC4-j.cjs"))),info:u.lazy(()=>Promise.resolve().then(()=>require("./ohTjxqcW.cjs"))),refresh:u.lazy(()=>Promise.resolve().then(()=>require("./D00MOxhE.cjs"))),"chevron-down":u.lazy(()=>Promise.resolve().then(()=>require("./wf-LdaaN.cjs"))),"chevron-right":u.lazy(()=>Promise.resolve().then(()=>require("./B0k-GApQ.cjs"))),done:u.lazy(()=>Promise.resolve().then(()=>require("./kp5wcW4s.cjs"))),user:u.lazy(()=>Promise.resolve().then(()=>require("./CtHfgPDp.cjs"))),"file-document":u.lazy(()=>Promise.resolve().then(()=>require("./_YfLwFkX.cjs"))),download:u.lazy(()=>Promise.resolve().then(()=>require("./BN09c8-A.cjs"))),attach:u.lazy(()=>Promise.resolve().then(()=>require("./DcDTXo8_.cjs"))),delete:u.lazy(()=>Promise.resolve().then(()=>require("./CKPzhVy2.cjs"))),"close-filled":u.lazy(()=>Promise.resolve().then(()=>require("./D1kINslt.cjs"))),agent:u.lazy(()=>Promise.resolve().then(()=>require("./Ce1MzjFq.cjs"))),question:u.lazy(()=>Promise.resolve().then(()=>require("./JA0x62Fd.cjs"))),actionbook:u.lazy(()=>Promise.resolve().then(()=>require("./CXa-CGHE.cjs"))),function:u.lazy(()=>Promise.resolve().then(()=>require("./zbLY6xl_.cjs"))),"radio-on":u.lazy(()=>Promise.resolve().then(()=>require("./B9NJk4MI.cjs"))),"radio-off":u.lazy(()=>Promise.resolve().then(()=>require("./Bb0r6Nhu.cjs"))),confluence:u.lazy(()=>Promise.resolve().then(()=>require("./c6TZaE94.cjs"))),zendesk:u.lazy(()=>Promise.resolve().then(()=>require("./DqpDy_26.cjs"))),salesforce:u.lazy(()=>Promise.resolve().then(()=>require("./BsgzT_SF.cjs"))),sprinklr:u.lazy(()=>Promise.resolve().then(()=>require("./D97ZpKUC.cjs"))),website:u.lazy(()=>Promise.resolve().then(()=>require("./ygZY2D-5.cjs"))),snippet:u.lazy(()=>Promise.resolve().then(()=>require("./BCFOnu0u.cjs"))),template:u.lazy(()=>Promise.resolve().then(()=>require("./eJXfXI1_.cjs"))),source:u.lazy(()=>Promise.resolve().then(()=>require("./yVmX6iux.cjs"))),bot:u.lazy(()=>Promise.resolve().then(()=>require("./PhHbzZB_.cjs"))),"bot-filled":u.lazy(()=>Promise.resolve().then(()=>require("./DlvMdI1f.cjs"))),copy:u.lazy(()=>Promise.resolve().then(()=>require("./COgkkyBM.cjs"))),show:u.lazy(()=>Promise.resolve().then(()=>require("./DM-WWpci.cjs"))),mute:u.lazy(()=>Promise.resolve().then(()=>require("./P_ra76fq.cjs"))),good:u.lazy(()=>Promise.resolve().then(()=>require("./DEgUVAck.cjs"))),bad:u.lazy(()=>Promise.resolve().then(()=>require("./C0s7eAf7.cjs"))),"good-filled":u.lazy(()=>Promise.resolve().then(()=>require("./Chg8xHXT.cjs"))),"bad-filled":u.lazy(()=>Promise.resolve().then(()=>require("./CGkmTaBn.cjs"))),delight:u.lazy(()=>Promise.resolve().then(()=>require("./DCB0iTxd.cjs")))},P=({type:e,size:t=24,className:n,color:r})=>{const s=Ma[e];return o.createElement(Oa,{className:n,$rtlFlip:$a.has(e),$size:t,$color:r??g.color.primary.main},o.createElement(dt,{errorFallback:o.createElement(Ra,null)},o.createElement(s,null)))},La=S.css`[dir='rtl'] &{transform:scaleX(-1);}`,Oa=f.default.div`width:${({$size:e})=>ce(e)};height:${({$size:e})=>ce(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&&La};`,Ra=()=>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"}));function Jt({name:e,type:t="FILE",iconColor:n,iconBackgroundColor:r,onClick:s}){const{colors:a}=S.useTheme();return o.createElement(Da,{onClick:s,$clickable:!!s},o.createElement(Pa,{$bgColor:r??a.base.primary},o.createElement(P,{type:"file-document",size:24,color:n??a.base.primaryContrastContent})),o.createElement(Ba,null,o.createElement(Fa,{variant:"button",color:g.themedColor.textHighEmphasis},e),o.createElement(k,{color:g.themedColor.textMidEmphasis,variant:"caption3"},t)))}const Da=f.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 ${g.themedColor.textDisabled};background-color:${g.themedColor.bg_50_600};${({$clickable:e})=>e&&Na}`,Na=S.css`cursor:pointer;&:hover{background-color:${g.themedColor.bg_100_500};}`,Pa=f.default.div`border-radius:8px;width:40px;height:40px;display:flex;align-items:center;justify-content:center;background-color:${({$bgColor:e})=>e};`,Ba=f.default.div`display:flex;flex:1;flex-direction:column;gap:4px;min-width:0;`,Fa=f.default(k)`text-overflow:ellipsis;white-space:nowrap;overflow:hidden;`;function Ua({file:e,children:t,onClickFile:n}){return o.createElement(Ha,null,o.createElement(Jt,{name:e.name,type:qt(e.name,e.type),onClick:n&&(()=>n==null?void 0:n(e))}),t)}const Ha=f.default.div`display:flex;flex-direction:column;align-items:flex-start;gap:${B.GAP_GROUPED}px;`,za="1.13.
|
|
52
|
+
`;return n.set(e,a),a},_a=e=>e?S.css`display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:${e};overflow:hidden;`:"",Sa=f.default.span`font-stretch:normal;letter-spacing:normal;${({$variant:e,theme:t})=>ya(e,t.typography)}color:${({$color:e})=>e};${({$maxTextLines:e})=>_a(e)}`;class dt extends u.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(u.Suspense,{fallback:r},s)}}const Ta=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"})),Aa=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"})),wa=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"})),ka=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"})),Ia=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"})),$a=new Set(["send","chat","message","chevron-right","good","good-filled","bad","bad-filled"]),Ma={close:Ta,send:Ia,menu:ka,expand:wa,collapse:Aa,spinner:u.lazy(()=>Promise.resolve().then(()=>require("./Cf3-irI8.cjs"))),chat:u.lazy(()=>Promise.resolve().then(()=>require("./BmdfYY9c.cjs"))),message:u.lazy(()=>Promise.resolve().then(()=>require("./CmWLVNPR.cjs"))),error:u.lazy(()=>Promise.resolve().then(()=>require("./DNmdC4-j.cjs"))),info:u.lazy(()=>Promise.resolve().then(()=>require("./ohTjxqcW.cjs"))),refresh:u.lazy(()=>Promise.resolve().then(()=>require("./D00MOxhE.cjs"))),"chevron-down":u.lazy(()=>Promise.resolve().then(()=>require("./wf-LdaaN.cjs"))),"chevron-right":u.lazy(()=>Promise.resolve().then(()=>require("./B0k-GApQ.cjs"))),done:u.lazy(()=>Promise.resolve().then(()=>require("./kp5wcW4s.cjs"))),user:u.lazy(()=>Promise.resolve().then(()=>require("./CtHfgPDp.cjs"))),"file-document":u.lazy(()=>Promise.resolve().then(()=>require("./_YfLwFkX.cjs"))),download:u.lazy(()=>Promise.resolve().then(()=>require("./BN09c8-A.cjs"))),attach:u.lazy(()=>Promise.resolve().then(()=>require("./DcDTXo8_.cjs"))),delete:u.lazy(()=>Promise.resolve().then(()=>require("./CKPzhVy2.cjs"))),"close-filled":u.lazy(()=>Promise.resolve().then(()=>require("./D1kINslt.cjs"))),agent:u.lazy(()=>Promise.resolve().then(()=>require("./Ce1MzjFq.cjs"))),question:u.lazy(()=>Promise.resolve().then(()=>require("./JA0x62Fd.cjs"))),actionbook:u.lazy(()=>Promise.resolve().then(()=>require("./CXa-CGHE.cjs"))),function:u.lazy(()=>Promise.resolve().then(()=>require("./zbLY6xl_.cjs"))),"radio-on":u.lazy(()=>Promise.resolve().then(()=>require("./B9NJk4MI.cjs"))),"radio-off":u.lazy(()=>Promise.resolve().then(()=>require("./Bb0r6Nhu.cjs"))),confluence:u.lazy(()=>Promise.resolve().then(()=>require("./c6TZaE94.cjs"))),zendesk:u.lazy(()=>Promise.resolve().then(()=>require("./DqpDy_26.cjs"))),salesforce:u.lazy(()=>Promise.resolve().then(()=>require("./BsgzT_SF.cjs"))),sprinklr:u.lazy(()=>Promise.resolve().then(()=>require("./D97ZpKUC.cjs"))),website:u.lazy(()=>Promise.resolve().then(()=>require("./ygZY2D-5.cjs"))),snippet:u.lazy(()=>Promise.resolve().then(()=>require("./BCFOnu0u.cjs"))),template:u.lazy(()=>Promise.resolve().then(()=>require("./eJXfXI1_.cjs"))),source:u.lazy(()=>Promise.resolve().then(()=>require("./yVmX6iux.cjs"))),bot:u.lazy(()=>Promise.resolve().then(()=>require("./PhHbzZB_.cjs"))),"bot-filled":u.lazy(()=>Promise.resolve().then(()=>require("./DlvMdI1f.cjs"))),copy:u.lazy(()=>Promise.resolve().then(()=>require("./COgkkyBM.cjs"))),show:u.lazy(()=>Promise.resolve().then(()=>require("./DM-WWpci.cjs"))),mute:u.lazy(()=>Promise.resolve().then(()=>require("./P_ra76fq.cjs"))),good:u.lazy(()=>Promise.resolve().then(()=>require("./DEgUVAck.cjs"))),bad:u.lazy(()=>Promise.resolve().then(()=>require("./C0s7eAf7.cjs"))),"good-filled":u.lazy(()=>Promise.resolve().then(()=>require("./Chg8xHXT.cjs"))),"bad-filled":u.lazy(()=>Promise.resolve().then(()=>require("./CGkmTaBn.cjs"))),delight:u.lazy(()=>Promise.resolve().then(()=>require("./DCB0iTxd.cjs")))},P=({type:e,size:t=24,className:n,color:r})=>{const s=Ma[e];return o.createElement(Oa,{className:n,$rtlFlip:$a.has(e),$size:t,$color:r??g.color.primary.main},o.createElement(dt,{errorFallback:o.createElement(Ra,null)},o.createElement(s,null)))},La=S.css`[dir='rtl'] &{transform:scaleX(-1);}`,Oa=f.default.div`width:${({$size:e})=>ce(e)};height:${({$size:e})=>ce(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&&La};`,Ra=()=>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"}));function Jt({name:e,type:t="FILE",iconColor:n,iconBackgroundColor:r,onClick:s}){const{colors:a}=S.useTheme();return o.createElement(Da,{onClick:s,$clickable:!!s},o.createElement(Pa,{$bgColor:r??a.base.primary},o.createElement(P,{type:"file-document",size:24,color:n??a.base.primaryContrastContent})),o.createElement(Ba,null,o.createElement(Fa,{variant:"button",color:g.themedColor.textHighEmphasis},e),o.createElement(k,{color:g.themedColor.textMidEmphasis,variant:"caption3"},t)))}const Da=f.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 ${g.themedColor.textDisabled};background-color:${g.themedColor.bg_50_600};${({$clickable:e})=>e&&Na}`,Na=S.css`cursor:pointer;&:hover{background-color:${g.themedColor.bg_100_500};}`,Pa=f.default.div`border-radius:8px;width:40px;height:40px;display:flex;align-items:center;justify-content:center;background-color:${({$bgColor:e})=>e};`,Ba=f.default.div`display:flex;flex:1;flex-direction:column;gap:4px;min-width:0;`,Fa=f.default(k)`text-overflow:ellipsis;white-space:nowrap;overflow:hidden;`;function Ua({file:e,children:t,onClickFile:n}){return o.createElement(Ha,null,o.createElement(Jt,{name:e.name,type:qt(e.name,e.type),onClick:n&&(()=>n==null?void 0:n(e))}),t)}const Ha=f.default.div`display:flex;flex-direction:column;align-items:flex-start;gap:${B.GAP_GROUPED}px;`,za="1.13.1",oe="sb-agent",se={ENTRY:`${oe}-entry`,MODAL_ROOT:`${oe}-modal-root`,WINDOW:`${oe}-window`,LAUNCHER:`${oe}-launcher`},tt=2147483647,Oe={MODAL:tt-1,TOOLTIP:tt-2,WINDOW:tt-3,LAUNCHER:tt-4},Er=36,Va=100,Ga=za,Qt="noopener noreferrer nofollow",be=`${oe}-incoming-msg`,Wa=`${oe}-marked-text`;function qa({file:e,onClickMedia:t,children:n}){const r=()=>e.type.startsWith("image")?o.createElement(Ya,{src:e.url,alt:"image-message"}):e.type.startsWith("video")?o.createElement(Za,{controls:!0},o.createElement("source",{src:e.url}),o.createElement("track",{kind:"captions"})):null;if(r){const s={id:`${be}-media-body`,onClick:()=>t==null?void 0:t(e)};return o.createElement(ja,null,o.createElement(Ka,{...s},r()),n)}return null}const ja=f.default.div`display:flex;flex-direction:column;align-items:flex-start;gap:${B.GAP_GROUPED}px;`,Ka=f.default.div`width:${B.BODY_MAX_WIDTH}px;height:160px;border-radius:12px;overflow:hidden;cursor:pointer;${D.light`
|
|
53
53
|
background-color: ${g.color.background100};
|
|
54
54
|
`}
|
|
55
55
|
${D.dark`
|
|
56
56
|
background-color: ${g.color.background400};
|
|
57
57
|
`}
|
|
58
|
-
`,Ya=f.default.img`width:100%;height:100%;object-fit:cover;`,Za=f.default.video`width:100%;height:100%;object-fit:cover;`,Xa="✱",xr=e=>{const t=new RegExp(`(\`+)([^\`]+?)\\1|(${Xa}+)`,"g");return e.replace(t,(n,r,s,a)=>r?n:a?`<span id=${Wa} aria-label="masked-text">${a}</span>`:n)},Ja=e=>e.replace(/\*\*(.*?)\*\*/g,"<b>$1</b>"),Qa=u.lazy(async()=>({default:(await Promise.resolve().then(()=>require("./
|
|
58
|
+
`,Ya=f.default.img`width:100%;height:100%;object-fit:cover;`,Za=f.default.video`width:100%;height:100%;object-fit:cover;`,Xa="✱",xr=e=>{const t=new RegExp(`(\`+)([^\`]+?)\\1|(${Xa}+)`,"g");return e.replace(t,(n,r,s,a)=>r?n:a?`<span id=${Wa} aria-label="masked-text">${a}</span>`:n)},Ja=e=>e.replace(/\*\*(.*?)\*\*/g,"<b>$1</b>"),Qa=u.lazy(async()=>({default:(await Promise.resolve().then(()=>require("./CgKaFsNM.cjs"))).MarkdownText})),ei=u.lazy(async()=>({default:(await Promise.resolve().then(()=>require("./DlvEEpWX.cjs"))).CodeBlock}));function Mn(e){var s,a;const t=e.maxBodyWidth??B.BODY_MAX_WIDTH,n=u.useMemo(()=>To(e.message,xr),[e.message]),r={id:`${be}-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(Ln,{...r},e.children):null:o.createElement(Ln,{...r},n.map((i,l)=>i.type==="text"?o.createElement(On,{key:l,variant:"body3"},o.createElement(dt,{fallback:i.value},o.createElement(Qa,{onClickImage:c=>{var d;return(d=e.onClickMedia)==null?void 0:d.call(e,{url:c,type:"image/*"})}},i.value))):i.type==="code"?o.createElement(dt,{key:l,fallback:o.createElement(On,{variant:"body3"},i.value)},o.createElement(ei,{code:i.value,language:i.language})):null),e.children)}const Ln=f.default.div`display:flex;flex-direction:column;border-radius:12px;overflow:hidden;max-width:${({$maxWidth:e})=>e}px;${({theme:e,$color:t,$bgColor:n})=>S.css`
|
|
59
59
|
color: ${t||e.colors.messageIncoming.text};
|
|
60
60
|
background-color: ${n||e.colors.messageIncoming.background};
|
|
61
61
|
`}
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
`,On=f.default(k)`align-items:flex-start;line-height:140%;white-space:pre-wrap;padding:0 12px;`;function ti(e){const{stringSet:t}=F(),n=nr(e)?o.createElement(Mn,{...e}):null;if(e.messageType==="user")return n;if(e.messageType==="file"){const r=e.file;return r.type.startsWith("image")||r.type.startsWith("video")?o.createElement(qa,{...e},n):o.createElement(Ua,{...e},n)}return o.createElement(Mn,{...e,message:t.UNKNOWN__UNKNOWN_MESSAGE_TYPE})}function en({id:e,src:t,size:n=56,onClick:r,style:s}){return o.createElement(ni,{id:e,tabIndex:0,onClick:r,$size:ce(n),style:s},t?o.createElement(ri,{src:t}):o.createElement(P,{type:"user",size:n}))}const ni=f.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:${g.themedColor.bg_100_500};&:focus{outline:none;}`,ri=f.default.img`object-fit:cover;width:100%;height:100%;position:absolute;`;function oi({sender:e,isBotMessage:t}){const n=`${be}-sender-avatar`;return t&&!e.profileUrl?o.createElement(si,{id:n},o.createElement(P,{type:"delight",size:"100%"})):o.createElement(en,{id:n,size:B.AVATAR_SIZE,src:e.profileUrl})}const si=f.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;}}`;function ai({sender:e}){return o.createElement(ii,{id:`${be}-sender-name`,variant:"caption1",color:g.themedColor.textMidEmphasis},e.nickname)}const ii=f.default(k)`text-align:start;width:100%;box-sizing:border-box;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding-block:5px;padding-inline:0 7px;`;function li({createdAt:e}){const{stringSet:t,format:n}=F();return e?o.createElement(k,{id:`${be}-sent-time`,variant:"caption4",color:g.themedColor.textLowEmphasis},n(e,t.DATE_FORMAT__MESSAGE_TIMESTAMP)):null}function ci({customStyle:e}){return o.createElement(ui,{$bgColor:e==null?void 0:e.bubbleBackgroundColor},[0,1,2].map(t=>o.createElement(di,{key:t,$color:e==null?void 0:e.bubbleContentColor})))}const ui=f.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};`,di=f.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;}`;async function tn(e){let t=e;t&&(!t.startsWith("http://")&&!t.startsWith("https://")&&(t="https://"+t),window.open(t,"_blank","noopener,noreferrer"))}function mi(e){requestAnimationFrame(()=>{requestAnimationFrame(()=>{e()})})}function gi({extendedMessagePayload:e,onClickCTA:t=({url:n})=>tn(n)}){const n=e==null?void 0:e.cta_button;return n?o.createElement(hi,{id:`${be}-ext-cta-button`,role:"button",onClick:()=>t(n)},o.createElement(fi,{variant:"button"},n.label)):null}const hi=f.default.div`display:flex;align-items:center;justify-content:center;cursor:pointer;border-radius:6px;padding:8px;color:${g.themedColor.textHighEmphasis};background-color:${g.color.background50};${D.dark`
|
|
66
66
|
background-color: ${g.color.ondark.textDisabled};
|
|
67
67
|
`}
|
|
68
|
-
`,fi=f.default(k)`overflow:hidden;text-overflow:ellipsis;white-space:nowrap;`;function pi({extendedMessagePayload:e,onClickCitation:t=n=>tn(n.link)}){const{stringSet:n}=F(),{theme:r}=Yt(),s=e==null?void 0:e.citations;return!s||s.length===0?null:o.createElement(bi,{id:`${be}-ext-citation`},o.createElement(Ei,{variant:"caption1",color:r.colors.messageIncoming.text},n.CITATION_SOURCE_TITLE),o.createElement(xi,null,s.map((a,i)=>o.createElement(Ci,{key:`${a.embedding_id}-${i}`,role:"button",onClick:()=>t(a)},o.createElement(P,{type:"source",size:16,color:r.colors.messageIncoming.text}),o.createElement(vi,{variant:"body3",color:r.colors.messageIncoming.text},a.title)))))}const bi=f.default.div`display:flex;flex-direction:column;gap:8px;border-radius:8px;padding:8px 12px 6px;`,Ei=f.default(k)`opacity:0.5;`,xi=f.default.div`display:flex;flex-direction:column;gap:8px;`,vi=f.default(k)`text-decoration:underline;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;`,Ci=f.default.div`display:flex;align-items:center;gap:4px;cursor:pointer;&:hover{opacity:0.5;}`;function yi(e){return o.createElement(o.Fragment,null)}const Et=({style:e,rootElementId:t,visible:n,onClose:r,children:s})=>{if(!n)return null;const{rootElement:a}=pr(),i=Me(a),l=Me(a,!0);return io.createPortal(o.createElement(_i,{onClick:r,style:e},o.createElement(Si,{onClick:c=>c.stopPropagation()},s)),i.getElementById(t)??i.getElementById(se.MODAL_ROOT)??l.body)},_i=f.default.div`position:fixed;top:0;left:0;width:100%;height:100%;background:${g.color.overlay.dark};display:flex;justify-content:center;align-items:center;z-index:${Oe.MODAL};`,Si=f.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:${Oe.MODAL};`,Ti=({visible:e,onClose:t,children:n})=>o.createElement(Et,{rootElementId:se.WINDOW,visible:e,onClose:t},o.createElement(ki,null,n)),Ai=({onClick:e,destructive:t,children:n})=>o.createElement(wi,{onClick:e,$destructive:t},n),Pe=Object.assign(Ti,{ActionItem:Ai}),wi=f.default.button`all:unset;width:100%;padding:14px 24px;text-align:start;cursor:pointer;color:${({$destructive:e})=>e?g.themedColor.error:g.themedColor.textHighEmphasis};`,ki=f.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};`,Ut=e=>`${e}-filled`,Ii=e=>e==="good"?q.AIAgentMessageFeedbackRating.GOOD:q.AIAgentMessageFeedbackRating.BAD,vr=S.css`&:hover{opacity:0.8;}&:active{opacity:0.6;}`,Rn={good:g.themedColor.secondary,bad:g.themedColor.error},$i=({visible:e,onClose:t,isEdit:n,initialRating:r,initialComment:s="",onSubmit:a,isCommentEnabled:i=!1})=>{const{stringSet:l}=F(),[c,d]=u.useState(r),[h,
|
|
68
|
+
`,fi=f.default(k)`overflow:hidden;text-overflow:ellipsis;white-space:nowrap;`;function pi({extendedMessagePayload:e,onClickCitation:t=n=>tn(n.link)}){const{stringSet:n}=F(),{theme:r}=Yt(),s=e==null?void 0:e.citations;return!s||s.length===0?null:o.createElement(bi,{id:`${be}-ext-citation`},o.createElement(Ei,{variant:"caption1",color:r.colors.messageIncoming.text},n.CITATION_SOURCE_TITLE),o.createElement(xi,null,s.map((a,i)=>o.createElement(Ci,{key:`${a.embedding_id}-${i}`,role:"button",onClick:()=>t(a)},o.createElement(P,{type:"source",size:16,color:r.colors.messageIncoming.text}),o.createElement(vi,{variant:"body3",color:r.colors.messageIncoming.text},a.title)))))}const bi=f.default.div`display:flex;flex-direction:column;gap:8px;border-radius:8px;padding:8px 12px 6px;`,Ei=f.default(k)`opacity:0.5;`,xi=f.default.div`display:flex;flex-direction:column;gap:8px;`,vi=f.default(k)`text-decoration:underline;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;`,Ci=f.default.div`display:flex;align-items:center;gap:4px;cursor:pointer;&:hover{opacity:0.5;}`;function yi(e){return o.createElement(o.Fragment,null)}const Et=({style:e,rootElementId:t,visible:n,onClose:r,children:s})=>{if(!n)return null;const{rootElement:a}=pr(),i=Me(a),l=Me(a,!0);return io.createPortal(o.createElement(_i,{onClick:r,style:e},o.createElement(Si,{onClick:c=>c.stopPropagation()},s)),i.getElementById(t)??i.getElementById(se.MODAL_ROOT)??l.body)},_i=f.default.div`position:fixed;top:0;left:0;width:100%;height:100%;background:${g.color.overlay.dark};display:flex;justify-content:center;align-items:center;z-index:${Oe.MODAL};`,Si=f.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:${Oe.MODAL};`,Ti=({visible:e,onClose:t,children:n})=>o.createElement(Et,{rootElementId:se.WINDOW,visible:e,onClose:t},o.createElement(ki,null,n)),Ai=({onClick:e,destructive:t,children:n})=>o.createElement(wi,{onClick:e,$destructive:t},n),Pe=Object.assign(Ti,{ActionItem:Ai}),wi=f.default.button`all:unset;width:100%;padding:14px 24px;text-align:start;cursor:pointer;color:${({$destructive:e})=>e?g.themedColor.error:g.themedColor.textHighEmphasis};`,ki=f.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};`,Ut=e=>`${e}-filled`,Ii=e=>e==="good"?q.AIAgentMessageFeedbackRating.GOOD:q.AIAgentMessageFeedbackRating.BAD,vr=S.css`&:hover{opacity:0.8;}&:active{opacity:0.6;}`,Rn={good:g.themedColor.secondary,bad:g.themedColor.error},$i=({visible:e,onClose:t,isEdit:n,initialRating:r,initialComment:s="",onSubmit:a,isCommentEnabled:i=!1})=>{const{stringSet:l}=F(),[c,d]=u.useState(r),[h,b]=u.useState(s);u.useLayoutEffect(()=>{e?(d(r),b(s)):(d(void 0),b(""))},[e,r,s]);const E=()=>{c&&(a({rating:c,comment:h.trim()||void 0}),t())},C=()=>{t()};return e?o.createElement(Et,{rootElementId:se.WINDOW,visible:e,onClose:C},o.createElement(Mi,null,o.createElement(Li,null,o.createElement(k,{variant:"h2",color:g.themedColor.textHighEmphasis},l.FEEDBACK_TITLE)),o.createElement(Oi,null,o.createElement(Ri,null,["good","bad"].map(y=>{const x=c===y,m=y==="good"?l.FEEDBACK_GOOD:l.FEEDBACK_BAD;return o.createElement(Di,{key:y,$selected:x,$rating:y,onClick:()=>d(y)},o.createElement(P,{type:x?Ut(y):y,size:24,color:x?Rn[y]:g.themedColor.textLowEmphasis}),o.createElement(k,{variant:"caption1",color:x?Rn[y]:g.themedColor.textLowEmphasis},m))})),i&&o.createElement(Ni,null,o.createElement(k,{variant:"caption3",color:g.themedColor.textHighEmphasis},l.FEEDBACK_COMMENT_LABEL),o.createElement(Pi,{placeholder:l.FEEDBACK_COMMENT_PLACEHOLDER,value:h,onChange:y=>b(y.target.value),maxLength:100}))),o.createElement(Bi,null,o.createElement(Fi,{onClick:C},o.createElement(k,{variant:"button",color:g.themedColor.textHighEmphasis},l.FEEDBACK_CANCEL)),o.createElement(Ui,{onClick:E,disabled:!c},o.createElement(k,{variant:"button"},n?l.FEEDBACK_SAVE:l.FEEDBACK_SUBMIT))))):null},Mi=f.default.div`width:280px;background-color:${({theme:e})=>e.colors.base.modalContentBackground};border-radius:12px;overflow:hidden;`,Li=f.default.div`padding:24px;`,Oi=f.default.div`padding-inline:24px;display:flex;flex-direction:column;gap:24px;`,Ri=f.default.div`display:flex;gap:4px;`,Di=f.default.button`width:114px;height:64px;border-radius:12px;border:1px solid ${g.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?g.color.background100:"transparent"};${({$selected:e})=>D.dark`
|
|
69
69
|
background-color: ${e?g.color.background600:"transparent"};
|
|
70
70
|
`}
|
|
71
71
|
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
&:active {
|
|
77
77
|
opacity: 0.6;
|
|
78
78
|
}
|
|
79
|
-
`,Ni=f.default.div`display:flex;flex-direction:column;gap:6px;`,Pi=f.default.textarea`font-family:inherit;font-size:12px;line-height:16px;border:1px solid ${g.themedColor.textDisabled};border-radius:4px;padding:6px 12px;color:${g.themedColor.textHighEmphasis};background-color:${g.themedColor.textLowEmphasisInverse};resize:none;field-sizing:content;min-height:28px;max-height:118px;overflow-y:auto;&::placeholder{color:${g.themedColor.textLowEmphasis};}&:focus{outline:none;}`,Bi=f.default.div`padding-inline:24px;padding-block:16px;display:flex;justify-content:flex-end;gap:4px;`,Cr=f.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;`,Fi=f.default(Cr)`${vr}`,Ui=f.default(Cr)`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};}`,Dn={good:g.themedColor.secondary,bad:g.themedColor.error};function Hi({isBotMessage:e,isConversationClosed:t,isStreaming:n,isFeedbackEnabled:r,isFeedbackCommentEnabled:s,extendedMessagePayload:a,onFeedbackUpdate:i}){const{stringSet:l}=F(),[c,d]=u.useState(!1),[h,
|
|
79
|
+
`,Ni=f.default.div`display:flex;flex-direction:column;gap:6px;`,Pi=f.default.textarea`font-family:inherit;font-size:12px;line-height:16px;border:1px solid ${g.themedColor.textDisabled};border-radius:4px;padding:6px 12px;color:${g.themedColor.textHighEmphasis};background-color:${g.themedColor.textLowEmphasisInverse};resize:none;field-sizing:content;min-height:28px;max-height:118px;overflow-y:auto;&::placeholder{color:${g.themedColor.textLowEmphasis};}&:focus{outline:none;}`,Bi=f.default.div`padding-inline:24px;padding-block:16px;display:flex;justify-content:flex-end;gap:4px;`,Cr=f.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;`,Fi=f.default(Cr)`${vr}`,Ui=f.default(Cr)`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};}`,Dn={good:g.themedColor.secondary,bad:g.themedColor.error};function Hi({isBotMessage:e,isConversationClosed:t,isStreaming:n,isFeedbackEnabled:r,isFeedbackCommentEnabled:s,extendedMessagePayload:a,onFeedbackUpdate:i}){const{stringSet:l}=F(),[c,d]=u.useState(!1),[h,b]=u.useState(!1),[E,C]=u.useState(void 0),[y,x]=u.useState(""),m=a==null?void 0:a.feedback,p=(m==null?void 0:m.rating)??"none";if(p!=="none"?!1:!!(n||!e||!r||(a==null?void 0:a.bot_message_type)!=="generated"||t))return null;const _=$=>{p==="none"?(C($),x(""),d(!0)):b(!0)},I=()=>{i==null||i(null),b(!1)},T=()=>{b(!1),C(m==null?void 0:m.rating),x((m==null?void 0:m.comment)??""),d(!0)},L=$=>{i==null||i($)};return t&&p!=="none"?o.createElement(Nn,{$horizontal:!0},o.createElement(zi,null,o.createElement(P,{type:Ut(p),size:12,color:Dn[p]})),(m==null?void 0:m.comment)&&o.createElement(Pn,{variant:"caption2",style:{lineHeight:"16px"}},m.comment)):o.createElement(o.Fragment,null,o.createElement(Nn,null,o.createElement(Vi,null,["good","bad"].map($=>{const M=p===$;return o.createElement(Gi,{key:$,$selected:M,$rating:$,onClick:()=>_($)},o.createElement(P,{type:M?Ut($):$,size:14,color:M?Dn[$]:g.themedColor.textMidEmphasis}))})),p!=="none"&&(m==null?void 0:m.comment)&&o.createElement(Pn,{variant:"caption2"},m.comment)),o.createElement(Pe,{visible:h,onClose:()=>b(!1)},o.createElement(Pe.ActionItem,{onClick:T},l.FEEDBACK_EDIT),o.createElement(Pe.ActionItem,{onClick:I,destructive:!0},l.FEEDBACK_REMOVE)),o.createElement($i,{visible:c,onClose:()=>d(!1),isEdit:p!=="none",initialRating:E,initialComment:y,onSubmit:L,isCommentEnabled:s}))}const Nn=f.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;`,zi=f.default.div`padding:2px;flex-shrink:0;display:flex;align-items:center;`,Vi=f.default.div`display:flex;gap:2px;`,Gi=f.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 ${g.color.background200};background-color:${({$selected:e})=>e?g.color.background100:"transparent"};${({$selected:e})=>D.dark`
|
|
80
80
|
border: 1px solid ${g.color.background400};
|
|
81
81
|
background-color: ${e?g.color.background500:"transparent"};
|
|
82
82
|
`}
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
&:hover:not(:disabled) {
|
|
96
96
|
opacity: 0.9;
|
|
97
97
|
}
|
|
98
|
-
`,Xi=f.default.button`${rn};background-color:transparent;color:${g.themedColor.textHighEmphasis};&:hover:not(:disabled){opacity:0.7;}`,Ji=e=>{switch(e){case"primary":return Bn;case"secondary":return Zi;case"clear":return Xi;default:return Bn}},Qi=f.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);}}`,el=({children:e,onClick:t,variant:n="primary",disabled:r=!1,loading:s=!1,className:a})=>{const i=()=>{switch(n){case"primary":return g.themedColor.textHighEmphasisInverse;case"secondary":return g.themedColor.primary;case"clear":return g.themedColor.textHighEmphasis;default:return g.themedColor.textHighEmphasisInverse}},l=Ji(n);return o.createElement(l,{onClick:t,disabled:r||s,className:a},s?o.createElement(Qi,null,o.createElement(P,{type:"spinner",size:22,color:i()})):o.createElement(k,{variant:"button",color:i()},e))},tl=({children:e,className:t,style:n})=>o.createElement(k,{variant:"caption4",color:g.themedColor.error,className:t,style:n},e),nl=({children:e,className:t,style:n,required:r})=>{const{stringSet:s}=F();return o.createElement(k,{variant:"caption3",color:g.themedColor.textMidEmphasis,className:t,style:n},e,!r&&o.createElement("span",{style:{color:g.themedColor.textLowEmphasis}},` (${s.OPTIONAL})`))},rl=({value:e,onChange:t,placeholder:n,error:r=!1,submitted:s=!1,className:a,disabled:i=!1,max:l})=>{const c=h=>{const E=h.target.value.replace(/[^0-9.-]/g,""),
|
|
98
|
+
`,Xi=f.default.button`${rn};background-color:transparent;color:${g.themedColor.textHighEmphasis};&:hover:not(:disabled){opacity:0.7;}`,Ji=e=>{switch(e){case"primary":return Bn;case"secondary":return Zi;case"clear":return Xi;default:return Bn}},Qi=f.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);}}`,el=({children:e,onClick:t,variant:n="primary",disabled:r=!1,loading:s=!1,className:a})=>{const i=()=>{switch(n){case"primary":return g.themedColor.textHighEmphasisInverse;case"secondary":return g.themedColor.primary;case"clear":return g.themedColor.textHighEmphasis;default:return g.themedColor.textHighEmphasisInverse}},l=Ji(n);return o.createElement(l,{onClick:t,disabled:r||s,className:a},s?o.createElement(Qi,null,o.createElement(P,{type:"spinner",size:22,color:i()})):o.createElement(k,{variant:"button",color:i()},e))},tl=({children:e,className:t,style:n})=>o.createElement(k,{variant:"caption4",color:g.themedColor.error,className:t,style:n},e),nl=({children:e,className:t,style:n,required:r})=>{const{stringSet:s}=F();return o.createElement(k,{variant:"caption3",color:g.themedColor.textMidEmphasis,className:t,style:n},e,!r&&o.createElement("span",{style:{color:g.themedColor.textLowEmphasis}},` (${s.OPTIONAL})`))},rl=({value:e,onChange:t,placeholder:n,error:r=!1,submitted:s=!1,className:a,disabled:i=!1,max:l})=>{const c=h=>{const E=h.target.value.replace(/[^0-9.-]/g,""),C=E.split("."),x=C.length>1?C[0]+"."+C.slice(1).join("").replace(/\./g,""):E;if(h.target.value=x,x===""||x==="-")t==null||t(null);else{const m=Number(x);if(!isNaN(m)){if(l!==void 0&&m>l)return;t==null||t(m)}}},d=e==null?"":String(e);return o.createElement(ll,{type:"text",value:d,onChange:c,placeholder:n,className:a,disabled:i||s,inputMode:"decimal",$error:r,$submitted:s})},ol=S.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:${g.themedColor.textLowEmphasis};}&::-webkit-inner-spin-button,&::-webkit-outer-spin-button{-webkit-appearance:none;margin:0;}`,sl=S.css`color:${g.themedColor.textHighEmphasis};border:1px solid transparent;cursor:not-allowed;${D.light`
|
|
99
99
|
background-color: ${g.color.ondark.textMidEmphasis};
|
|
100
100
|
`}
|
|
101
101
|
${D.dark`
|
|
@@ -154,7 +154,7 @@
|
|
|
154
154
|
`,bl=S.css`border-color:${g.themedColor.error}!important;`,El=f.default.div`${ml}${({$active:e,$submitted:t,$error:n})=>{if(t)return e?gl:hl;const r=e?fl:pl;return n?S.css`
|
|
155
155
|
${r} ${bl}
|
|
156
156
|
`:r}}
|
|
157
|
-
`,xl=e=>o.createElement(yr,{...e,multiple:!1}),vl=e=>o.createElement(yr,{...e,multiple:!0}),Cl=f.default.div`width:100%;height:1px;background-color:${g.themedColor.textDisabled};`,yl=({className:e})=>o.createElement(Cl,{className:e}),_l=({value:e="",onChange:t,placeholder:n,variant:r="single-line",error:s=!1,submitted:a=!1,className:i,disabled:l=!1,maxLength:c})=>{const h={value:e,onChange:
|
|
157
|
+
`,xl=e=>o.createElement(yr,{...e,multiple:!1}),vl=e=>o.createElement(yr,{...e,multiple:!0}),Cl=f.default.div`width:100%;height:1px;background-color:${g.themedColor.textDisabled};`,yl=({className:e})=>o.createElement(Cl,{className:e}),_l=({value:e="",onChange:t,placeholder:n,variant:r="single-line",error:s=!1,submitted:a=!1,className:i,disabled:l=!1,maxLength:c})=>{const h={value:e,onChange:b=>{const E=b.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(Tl,{...h}):o.createElement(Sl,{...h})},_r=S.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:${g.themedColor.textLowEmphasis};}`,Sr=S.css`color:${g.themedColor.textHighEmphasis};border:1px solid transparent;cursor:not-allowed;${D.light`
|
|
158
158
|
background-color: ${g.color.ondark.textMidEmphasis};
|
|
159
159
|
`}
|
|
160
160
|
${D.dark`
|
|
@@ -180,7 +180,7 @@
|
|
|
180
180
|
&:focus {
|
|
181
181
|
border-color: ${g.themedColor.primary};
|
|
182
182
|
}
|
|
183
|
-
`,Sl=f.default.input`${_r};height:36px;${({$error:e,$submitted:t})=>t?Sr:e?Tr:Ar}`,Tl=f.default.textarea`${_r};height:96px;resize:none;font-family:inherit;${({$error:e,$submitted:t})=>t?Sr:e?Tr:Ar}`,Al=({children:e,className:t,style:n})=>o.createElement(k,{variant:"button",color:g.themedColor.textHighEmphasis,className:t,style:n},e),Y={Title:Al,Label:nl,ErrorLabel:tl,Separator:yl,Button:el,TextInput:_l,NumberInput:rl,SingleSelect:xl,MultiSelect:vl},wl=1,kl=new Set(["text","number","single-select","multi-select"]),Il=e=>{var m;const t=(m=e.extendedMessagePayload)==null?void 0:m.form;if(!t)throw new Error("Form is not provided");const{stringSet:n}=F(),[r,s]=u.useState({submitting:!1,canceling:!1}),[a,i]=u.useState({visible:!1}),{state:l,fields:c,submit:d,cancel:h,updateFieldValue:
|
|
183
|
+
`,Sl=f.default.input`${_r};height:36px;${({$error:e,$submitted:t})=>t?Sr:e?Tr:Ar}`,Tl=f.default.textarea`${_r};height:96px;resize:none;font-family:inherit;${({$error:e,$submitted:t})=>t?Sr:e?Tr:Ar}`,Al=({children:e,className:t,style:n})=>o.createElement(k,{variant:"button",color:g.themedColor.textHighEmphasis,className:t,style:n},e),Y={Title:Al,Label:nl,ErrorLabel:tl,Separator:yl,Button:el,TextInput:_l,NumberInput:rl,SingleSelect:xl,MultiSelect:vl},wl=1,kl=new Set(["text","number","single-select","multi-select"]),Il=e=>{var m;const t=(m=e.extendedMessagePayload)==null?void 0:m.form;if(!t)throw new Error("Form is not provided");const{stringSet:n}=F(),[r,s]=u.useState({submitting:!1,canceling:!1}),[a,i]=u.useState({visible:!1}),{state:l,fields:c,submit:d,cancel:h,updateFieldValue:b}=Zs(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:p=>{var v;return(v=e.onSubmitForm)==null?void 0:v.call(e,{key:t.key,data:p})},onCancel:()=>{var p;return(p=e.onCancelForm)==null?void 0:p.call(e,{key:t.key})}}),E=l==="submitted",C=async()=>{s(p=>({...p,submitting:!0}));try{await d()}catch(p){i({visible:!0,description:p instanceof Error?p.message:n.TRY_AGAIN})}finally{s(p=>({...p,submitting:!1}))}},y=async()=>{s(p=>({...p,canceling:!0}));try{await h()}catch(p){i({visible:!0,description:p instanceof Error?p.message:n.TRY_AGAIN})}finally{s(p=>({...p,canceling:!1}))}},x=u.useMemo(()=>{const p=()=>t.version>wl,v=()=>t.fields.some(_=>!kl.has(_.type));return p()||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:x.visible?o.createElement(u.Fragment,null,o.createElement(Fn,{$maxWidth:e.maxBodyWidth??B.BODY_MAX_WIDTH},o.createElement(Y.Title,null,t.title),o.createElement($l,null,c.map(p=>o.createElement(Ml,{key:p.key},o.createElement(Y.Label,{style:{marginBottom:"6px"},required:p.required},p.label),p.type==="text"&&o.createElement(Y.TextInput,{value:p.value||"",placeholder:p.placeholder,onChange:v=>b(p.key,v),disabled:E,error:!!p.error,submitted:E,variant:p.layout==="multiline"?"multi-line":"single-line",maxLength:p.maxLength}),p.type==="number"&&o.createElement(Y.NumberInput,{value:p.value||null,placeholder:p.placeholder,onChange:v=>b(p.key,v),disabled:E,error:!!p.error,submitted:E,max:p.max}),p.type==="single-select"&&o.createElement(Y.SingleSelect,{options:p.options.map(v=>({label:v,value:v})),value:p.value||"",onChange:v=>b(p.key,v),submitted:E}),p.type==="multi-select"&&o.createElement(Y.MultiSelect,{options:p.options.map(v=>({label:v,value:v})),value:p.value||[],onChange:v=>b(p.key,v),submitted:E,maxSelect:p.maxSelect}),p.error&&o.createElement(Y.ErrorLabel,{style:{marginTop:"4px"}},p.error)))),o.createElement(Y.Separator,null),o.createElement(Ll,null,o.createElement(Y.Button,{variant:E?"clear":"primary",onClick:C,disabled:E||r.canceling,loading:r.submitting},E?n.SUBMITTED:n.BUTTON__SUBMIT),l!=="submitted"&&o.createElement(Y.Button,{variant:"secondary",onClick:y,disabled:r.submitting,loading:r.canceling},n.BUTTON__CANCEL))),o.createElement(nn,{...a,onClose:()=>i({visible:!1,title:""})})):o.createElement(Fn,{$maxWidth:e.maxBodyWidth??B.BODY_MAX_WIDTH},o.createElement(k,{variant:"body3"},x.reason),x.cancelable&&o.createElement(Y.Button,{variant:"primary",onClick:y,loading:r.canceling},n.BUTTON__CANCEL))},Fn=f.default.div`display:flex;flex-direction:column;gap:12px;border-radius:12px;overflow:hidden;max-width:${({$maxWidth:e})=>e}px;${({theme:e})=>S.css`
|
|
184
184
|
color: ${e.colors.messageIncoming.text};
|
|
185
185
|
background-color: ${e.colors.messageIncoming.background};
|
|
186
186
|
`}
|
|
@@ -194,14 +194,14 @@
|
|
|
194
194
|
color: ${t.colors.base.primaryContrastContent};
|
|
195
195
|
}
|
|
196
196
|
`}
|
|
197
|
-
`,zl=S.css`flex-direction:column;align-items:flex-end;`,Vl=S.css`flex-direction:row;overflow-x:scroll;-ms-overflow-style:none;scrollbar-width:none;&::-webkit-scrollbar{display:none;}`,Gl=S.css`max-width:calc(100% - 70px);white-space:pre-wrap;`,Wl=S.css`white-space:nowrap;`,Le=pe({template:ql,components:{SenderName:ai,SenderAvatar:oi,SentTime:li,MessageBody:ti,TypingIndicator:ci,SuggestedReplies:Fl,MessageTemplate:Nl,CustomMessageTemplate:yi,CTAButton:gi,Citation:pi,Form:Il,Feedback:Hi,MessageLogs:Ol}});function ql(e){return o.createElement(wr,{...e,testerMode:!1})}function wr(e){var m,
|
|
197
|
+
`,zl=S.css`flex-direction:column;align-items:flex-end;`,Vl=S.css`flex-direction:row;overflow-x:scroll;-ms-overflow-style:none;scrollbar-width:none;&::-webkit-scrollbar{display:none;}`,Gl=S.css`max-width:calc(100% - 70px);white-space:pre-wrap;`,Wl=S.css`white-space:nowrap;`,Le=pe({template:ql,components:{SenderName:ai,SenderAvatar:oi,SentTime:li,MessageBody:ti,TypingIndicator:ci,SuggestedReplies:Fl,MessageTemplate:Nl,CustomMessageTemplate:yi,CTAButton:gi,Citation:pi,Form:Il,Feedback:Hi,MessageLogs:Ol}});function ql(e){return o.createElement(wr,{...e,testerMode:!1})}function wr(e){var m,p,v,_,I,T,L;const{components:t}=Le.useContext(),{streamText:n,isAnimating:r}=na({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=!!((m=s.extendedMessagePayload)!=null&&m.form)&&!((p=s.extendedMessagePayload)!=null&&p.form.canceled_at),d=!!((v=s.extendedMessagePayload)!=null&&v.message_template),h=!!((_=s.extendedMessagePayload)!=null&&_.cta_button),b=!!((I=s.extendedMessagePayload)!=null&&I.citations)&&s.extendedMessagePayload.citations.length>0,E=!!s.createdAt,C=s.groupType==="top"||s.groupType==="single",y=s.groupType==="bottom"||s.groupType==="single",x=i||!l?0:B.AVATAR_SIZE;return o.createElement(jl,{$marginBottom:a?0:jt(s.groupType)},C&&o.createElement(Kl,null,!i&&l&&o.createElement(t.SenderAvatar,{...s}),o.createElement(t.SenderName,{...s})),o.createElement(Zl,null,o.createElement(kt,{$extraStartPadding:x},a?o.createElement(t.TypingIndicator,{...s}):o.createElement(t.MessageBody,{...s},h&&o.createElement("div",{style:{marginTop:12,marginInline:12}},o.createElement(t.CTAButton,{...s})),b&&o.createElement(t.Citation,{...s}))),d&&o.createElement(Un,{$startPadding:0,$endPadding:0},o.createElement(t.MessageTemplate,{...s,messageTemplateErrorFallback:s.messageTemplateErrorFallback??o.createElement(kt,{$extraStartPadding:x},o.createElement(t.MessageBody,{...s,messageType:"user",message:((L=(T=s.extendedMessagePayload)==null?void 0:T.message_template)==null?void 0:L.fallback_message)??"Cannot read this template."})),messageTemplateLoadingFallback:s.messageTemplateLoadingFallback??o.createElement(kt,{$extraStartPadding:x},o.createElement(t.TypingIndicator,{...s}))})),o.createElement(t.CustomMessageTemplate,{...s}),c&&o.createElement(Un,{$extraStartPadding:x},o.createElement(t.Form,{...s}))),y&&E&&o.createElement(Yl,{$extraStartPadding:x+8},o.createElement(t.SentTime,{...s})),o.createElement(u.Fragment,null,!a&&o.createElement(Ye,{$extraStartPadding:x+8},o.createElement(t.Feedback,{...s})),s.suggestedRepliesVisible&&o.createElement(t.SuggestedReplies,{...s}),o.createElement(t.MessageLogs,{...s})))}const jl=f.default.div`display:flex;flex-direction:column;align-items:flex-start;margin-bottom:${({$marginBottom:e})=>`${e}px`};
|
|
198
198
|
`,Ye=f.default.div`display:flex;align-self:stretch;justify-content:flex-start;${({$startPadding:e=B.HORIZONTAL_PADDING,$endPadding:t=B.HORIZONTAL_PADDING,$extraStartPadding:n=0})=>`
|
|
199
199
|
padding-inline: ${e+n}px ${t}px;
|
|
200
200
|
`}
|
|
201
201
|
`,Kl=f.default(Ye)`display:flex;flex-direction:row;align-items:center;gap:8px;`,kt=f.default(Ye)`display:flex;`,Yl=f.default(Ye)`margin-top:${B.BODY_TIME_GAP}px;display:flex;align-items:flex-start;justify-content:flex-start;`,Un=f.default(Ye)`display:flex;${({$startPadding:e=B.HORIZONTAL_PADDING,$endPadding:t=B.HORIZONTAL_PADDING,$extraStartPadding:n=0})=>`
|
|
202
202
|
padding-inline: ${e+n}px ${t}px;
|
|
203
203
|
`}
|
|
204
|
-
`,Zl=f.default.div`display:flex;flex-direction:column;gap:${B.GAP_GROUPED}px;`;function Xl({file:e,children:t,onClickFile:n,sendingStatus:r}){const s=(()=>{if(!(!n||r==="failed"))return()=>n==null?void 0:n(e)})();return o.createElement(Jl,null,o.createElement(Jt,{name:e.name,type:qt(e.name,e.type),onClick:s}),t)}const Jl=f.default.div`display:flex;flex-direction:column;align-items:flex-end;gap:${B.GAP_GROUPED}px;`,on=({className:e,children:t,size:n=26})=>o.createElement(Ql,{className:e,$size:n},t??o.createElement(P,{type:"spinner",size:n})),Ql=f.default.div`display:flex;align-items:center;justify-content:center;width:${({$size:e})=>ce(e)};height:${({$size:e})=>ce(e)};animation:1s infinite linear;animation-name:rotate;@keyframes rotate{from{transform:rotate(0);}to{transform:rotate(360deg);}}`;function ec({sendingStatus:e,file:t,metadata:n,onClickMedia:r,children:s}){const{aspectRatio:a,localFile:i}=n,[l]=u.useState(()=>i instanceof Blob?URL.createObjectURL(i):t.url),[c,d]=u.useState(!1),h=(()=>{if(!(!r||e==="failed"))return()=>r==null?void 0:r({...t,url:l})})(),
|
|
204
|
+
`,Zl=f.default.div`display:flex;flex-direction:column;gap:${B.GAP_GROUPED}px;`;function Xl({file:e,children:t,onClickFile:n,sendingStatus:r}){const s=(()=>{if(!(!n||r==="failed"))return()=>n==null?void 0:n(e)})();return o.createElement(Jl,null,o.createElement(Jt,{name:e.name,type:qt(e.name,e.type),onClick:s}),t)}const Jl=f.default.div`display:flex;flex-direction:column;align-items:flex-end;gap:${B.GAP_GROUPED}px;`,on=({className:e,children:t,size:n=26})=>o.createElement(Ql,{className:e,$size:n},t??o.createElement(P,{type:"spinner",size:n})),Ql=f.default.div`display:flex;align-items:center;justify-content:center;width:${({$size:e})=>ce(e)};height:${({$size:e})=>ce(e)};animation:1s infinite linear;animation-name:rotate;@keyframes rotate{from{transform:rotate(0);}to{transform:rotate(360deg);}}`;function ec({sendingStatus:e,file:t,metadata:n,onClickMedia:r,children:s}){const{aspectRatio:a,localFile:i}=n,[l]=u.useState(()=>i instanceof Blob?URL.createObjectURL(i):t.url),[c,d]=u.useState(!1),h=(()=>{if(!(!r||e==="failed"))return()=>r==null?void 0:r({...t,url:l})})(),b={onClick:h,$ratio:a,$clickable:!!h};return o.createElement(tc,null,o.createElement(nc,{...b},!c&&o.createElement(on,{size:26},o.createElement(P,{type:"spinner",color:"textLowEmphasis",size:26})),o.createElement(rc,{$loaded:c,src:l,alt:"image-message",onLoad:()=>d(!0)})),s)}const tc=f.default.div`display:flex;flex-direction:column;align-items:flex-end;gap:${B.GAP_GROUPED}px;`,nc=f.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;${D.light`
|
|
205
205
|
background-color: ${g.color.background100};
|
|
206
206
|
`}
|
|
207
207
|
${D.dark`
|
|
@@ -216,18 +216,18 @@
|
|
|
216
216
|
overflow-wrap: break-word;
|
|
217
217
|
`,sc=f.default(k)`align-items:flex-start;line-height:140%;white-space:pre-wrap;padding:0 12px;`;function ac(e){const{stringSet:t}=F(),n=()=>{const a=nr(e)?o.createElement(Hn,{...e}):null;return e.messageType==="user"?a:e.messageType==="file"?e.file.type.startsWith("image")?o.createElement(ec,{...e},a):o.createElement(Xl,{...e},a):o.createElement(Hn,{...e,message:t.UNKNOWN__UNKNOWN_MESSAGE_TYPE})},r=e.sendingStatus==="failed"&&e.onClickFailedMessage,s=a=>{var i;(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),(i=e.onClickFailedMessage)==null||i.call(e))};return o.createElement("div",{...r&&{onClick:e.onClickFailedMessage,onKeyDown:s,role:"button",tabIndex:0},style:{display:"contents",cursor:r?"pointer":"default"}},n())}function ic({sendingStatus:e}){const t=S.useTheme();switch(e){case"pending":return o.createElement(lc,{size:16},o.createElement(P,{type:"spinner",color:t.colors.messageOutgoing.background,size:16}));case"failed":return o.createElement("div",{style:{marginBottom:2}},o.createElement(P,{type:"error",color:g.themedColor.error,size:16}));case"scheduled":case"canceled":return null;default:return o.createElement("div",{style:{marginBottom:2}},o.createElement(P,{type:"done",color:g.themedColor.secondary,size:16}))}}const lc=f.default(on)`margin-bottom:2px;width:16px;height:16px;`;function cc({createdAt:e}){const{stringSet:t,format:n}=F();return e?o.createElement(k,{variant:"caption4",color:g.themedColor.textLowEmphasis},n(e,t.DATE_FORMAT__MESSAGE_TIMESTAMP)):null}const xt=pe({template:uc,components:{SendingStatus:ic,SentTime:cc,MessageBody:ac}});function uc(e){const{components:t}=xt.useContext(),n=e.sendingStatus==="succeeded",r=e.groupType==="bottom"||e.groupType==="single";return o.createElement(dc,{$marginBottom:jt(e.groupType)},o.createElement(mc,null,o.createElement(t.MessageBody,{...e})),r&&o.createElement(gc,{$extraEndPadding:8},n?o.createElement(t.SentTime,{...e}):o.createElement(t.SendingStatus,{...e})))}const dc=f.default.div`display:flex;flex:1;flex-direction:column;align-items:flex-end;margin-bottom:${({$marginBottom:e})=>`${e}px`};
|
|
218
218
|
`,kr=f.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;`};
|
|
219
|
-
`,mc=f.default(kr)``,gc=f.default(kr)`margin-top:${B.BODY_TIME_GAP}px;`;function hc(e){return e.messageType!=="admin"?null:o.createElement(fc,null,o.createElement(k,{variant:"caption2",color:g.themedColor.textMidEmphasis},pc(Jn.default.sanitize(e.message))))}const fc=f.default.div`text-align:center;text-wrap:pretty;word-break:break-word;padding-inline:${B.HORIZONTAL_PADDING}px;a{text-decoration:underline;color:inherit;}`,pc=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:d}=l,h=c.index;h>0&&t.push(n.slice(0,h)),d==="link"?t.push(o.createElement("a",{key:r++,href:c[2],target:"_blank",rel:Qt},c[1])):d==="bold"&&t.push(o.createElement("strong",{key:r++},c[1])),n=n.slice(h+c[0].length)}return t.filter(s=>s!=="")}catch{return[e]}},Ir=({onClick:e,checked:t,label:n,disabled:r,labelVariant:s="caption2"})=>{const a=t?g.themedColor.primary:r?g.themedColor.textDisabled:g.themedColor.textLowEmphasis,i=t?g.themedColor.textHighEmphasis:r?g.themedColor.textLowEmphasis:g.themedColor.textHighEmphasis;return o.createElement(xc,{onClick:e,disabled:r},o.createElement(bc,null,o.createElement(P,{size:20,type:t?"radio-on":"radio-off",color:a})),o.createElement(Ec,{variant:s,color:i},n))},bc=f.default.div`width:20px;height:20px;`,Ec=f.default(k)`line-height:20px;word-break:break-word;`,xc=f.default.button`all:unset;display:flex;align-items:flex-start;justify-content:flex-start;gap:2px;&:enabled{cursor:pointer;}`,vc=({csatPayload:e,submitted:t,defaultValue:n,value:r,onChange:s})=>(u.useEffect(()=>{typeof r>"u"&&typeof n=="boolean"&&(s==null||s(n))},[r,n]),e.cre?o.createElement(Cc,null,o.createElement(Y.Label,{required:e.cre.required},e.cre.question),o.createElement(yc,null,[{label:e.cre.positive_label,value:!0},{label:e.cre.negative_label,value:!1}].map(a=>o.createElement(Ir,{key:a.label,checked:r===a.value,label:a.label,disabled:t,onClick:()=>s==null?void 0:s(a.value)})))):null),Cc=f.default.div`display:flex;flex-direction:column;gap:8px;`,yc=f.default.div`display:flex;flex-direction:column;gap:8px;`,_c=({followUpItem:e,submitted:t,value:n="",onChange:r,hasError:s})=>{const{stringSet:a}=F();return o.createElement(Sc,null,o.createElement(Y.Label,{required:e.required},e.question),e.response_type==="free_text"&&o.createElement(Y.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(Tc,null,e.options.map(i=>o.createElement(Ir,{key:i,checked:n===i,label:i,disabled:t,onClick:()=>r==null?void 0:r(i),labelVariant:"body3"}))),s&&o.createElement(Y.ErrorLabel,null,a.FORM_VALIDATION_REQUIRED))},Sc=f.default.div`display:flex;flex-direction:column;gap:8px;`,Tc=f.default.div`display:flex;flex-direction:column;gap:8px;`,Ac=({value:e,selected:t,label:n})=>o.createElement(wc,{$selected:t,"aria-label":n},kc[e-1]),wc=f.default.div`user-select:none;-webkit-user-drag:none;width:40px;height:40px;aspect-ratio:1;opacity:${({$selected:e})=>e?1:.38};`,kc=[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)"}))))],Ic=({csatPayload:e,submitted:t,value:n,onChange:r})=>{const s=typeof n>"u";return o.createElement(Mc,null,o.createElement(k,{variant:"caption3",color:g.themedColor.textMidEmphasis},e.csat_question),o.createElement(Lc,null,e.csat_scores.map(({label:a,image_url:i},l)=>{const c=l+1,d=n===c;return o.createElement(Oc,{key:l,disabled:t,onClick:()=>r(c)},o.createElement($c,{value:c,selected:s||d,label:a,src:i}),!!a&&o.createElement(k,{color:d?g.themedColor.textHighEmphasis:g.themedColor.textLowEmphasis,variant:"caption3"},a))})))},$c=({value:e,src:t,label:n,selected:r})=>{const[s,a]=u.useState(!1),i=s?o.createElement(Ac,{value:e,selected:r,label:n}):o.createElement(Dc,{$selected:r,"aria-label":n,src:t,onError:()=>a(!0)});return o.createElement(Rc,null,i)},Mc=f.default.div`display:flex;flex-direction:column;gap:8px;`,Lc=f.default.div`display:flex;justify-content:space-between;align-self:center;width:100%;max-width:400px;gap:16px;`,Oc=f.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:${g.themedColor.textHighEmphasis};}`,Rc=f.default.div`button:hover:not(:disabled) &{border-radius:4px;cursor:pointer;background-color:${g.color.background200};${D.dark`
|
|
219
|
+
`,mc=f.default(kr)``,gc=f.default(kr)`margin-top:${B.BODY_TIME_GAP}px;`;function hc(e){return e.messageType!=="admin"?null:o.createElement(fc,null,o.createElement(k,{variant:"caption2",color:g.themedColor.textMidEmphasis},pc(Jn.default.sanitize(e.message))))}const fc=f.default.div`text-align:center;text-wrap:pretty;word-break:break-word;padding-inline:${B.HORIZONTAL_PADDING}px;a{text-decoration:underline;color:inherit;}`,pc=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(b=>!!b);if(!i.length){t.push(n);break}const l=i.reduce((b,E)=>E.match.index<b.match.index?E:b),{match:c,type:d}=l,h=c.index;h>0&&t.push(n.slice(0,h)),d==="link"?t.push(o.createElement("a",{key:r++,href:c[2],target:"_blank",rel:Qt},c[1])):d==="bold"&&t.push(o.createElement("strong",{key:r++},c[1])),n=n.slice(h+c[0].length)}return t.filter(s=>s!=="")}catch{return[e]}},Ir=({onClick:e,checked:t,label:n,disabled:r,labelVariant:s="caption2"})=>{const a=t?g.themedColor.primary:r?g.themedColor.textDisabled:g.themedColor.textLowEmphasis,i=t?g.themedColor.textHighEmphasis:r?g.themedColor.textLowEmphasis:g.themedColor.textHighEmphasis;return o.createElement(xc,{onClick:e,disabled:r},o.createElement(bc,null,o.createElement(P,{size:20,type:t?"radio-on":"radio-off",color:a})),o.createElement(Ec,{variant:s,color:i},n))},bc=f.default.div`width:20px;height:20px;`,Ec=f.default(k)`line-height:20px;word-break:break-word;`,xc=f.default.button`all:unset;display:flex;align-items:flex-start;justify-content:flex-start;gap:2px;&:enabled{cursor:pointer;}`,vc=({csatPayload:e,submitted:t,defaultValue:n,value:r,onChange:s})=>(u.useEffect(()=>{typeof r>"u"&&typeof n=="boolean"&&(s==null||s(n))},[r,n]),e.cre?o.createElement(Cc,null,o.createElement(Y.Label,{required:e.cre.required},e.cre.question),o.createElement(yc,null,[{label:e.cre.positive_label,value:!0},{label:e.cre.negative_label,value:!1}].map(a=>o.createElement(Ir,{key:a.label,checked:r===a.value,label:a.label,disabled:t,onClick:()=>s==null?void 0:s(a.value)})))):null),Cc=f.default.div`display:flex;flex-direction:column;gap:8px;`,yc=f.default.div`display:flex;flex-direction:column;gap:8px;`,_c=({followUpItem:e,submitted:t,value:n="",onChange:r,hasError:s})=>{const{stringSet:a}=F();return o.createElement(Sc,null,o.createElement(Y.Label,{required:e.required},e.question),e.response_type==="free_text"&&o.createElement(Y.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(Tc,null,e.options.map(i=>o.createElement(Ir,{key:i,checked:n===i,label:i,disabled:t,onClick:()=>r==null?void 0:r(i),labelVariant:"body3"}))),s&&o.createElement(Y.ErrorLabel,null,a.FORM_VALIDATION_REQUIRED))},Sc=f.default.div`display:flex;flex-direction:column;gap:8px;`,Tc=f.default.div`display:flex;flex-direction:column;gap:8px;`,Ac=({value:e,selected:t,label:n})=>o.createElement(wc,{$selected:t,"aria-label":n},kc[e-1]),wc=f.default.div`user-select:none;-webkit-user-drag:none;width:40px;height:40px;aspect-ratio:1;opacity:${({$selected:e})=>e?1:.38};`,kc=[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)"}))))],Ic=({csatPayload:e,submitted:t,value:n,onChange:r})=>{const s=typeof n>"u";return o.createElement(Mc,null,o.createElement(k,{variant:"caption3",color:g.themedColor.textMidEmphasis},e.csat_question),o.createElement(Lc,null,e.csat_scores.map(({label:a,image_url:i},l)=>{const c=l+1,d=n===c;return o.createElement(Oc,{key:l,disabled:t,onClick:()=>r(c)},o.createElement($c,{value:c,selected:s||d,label:a,src:i}),!!a&&o.createElement(k,{color:d?g.themedColor.textHighEmphasis:g.themedColor.textLowEmphasis,variant:"caption3"},a))})))},$c=({value:e,src:t,label:n,selected:r})=>{const[s,a]=u.useState(!1),i=s?o.createElement(Ac,{value:e,selected:r,label:n}):o.createElement(Dc,{$selected:r,"aria-label":n,src:t,onError:()=>a(!0)});return o.createElement(Rc,null,i)},Mc=f.default.div`display:flex;flex-direction:column;gap:8px;`,Lc=f.default.div`display:flex;justify-content:space-between;align-self:center;width:100%;max-width:400px;gap:16px;`,Oc=f.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:${g.themedColor.textHighEmphasis};}`,Rc=f.default.div`button:hover:not(:disabled) &{border-radius:4px;cursor:pointer;background-color:${g.color.background200};${D.dark`
|
|
220
220
|
background-color: ${g.color.background500};
|
|
221
221
|
`}
|
|
222
222
|
}
|
|
223
|
-
`,Dc=f.default.img`user-select:none;-webkit-user-drag:none;width:40px;height:40px;aspect-ratio:1;opacity:${({$selected:e})=>e?1:.38};`,Nc=({csatPayload:e})=>o.createElement(k,{variant:"button",color:g.themedColor.textHighEmphasis},e.title),It=({csatPayload:e,type:t,renderSubmitButton:n,initialCsat:r,initialCsatReason:s,initialIsResolved:a})=>{const{params:i,setParams:l,error:c,setError:d,followUpItem:h,state:
|
|
223
|
+
`,Dc=f.default.img`user-select:none;-webkit-user-drag:none;width:40px;height:40px;aspect-ratio:1;opacity:${({$selected:e})=>e?1:.38};`,Nc=({csatPayload:e})=>o.createElement(k,{variant:"button",color:g.themedColor.textHighEmphasis},e.title),It=({csatPayload:e,type:t,renderSubmitButton:n,initialCsat:r,initialCsatReason:s,initialIsResolved:a})=>{const{params:i,setParams:l,error:c,setError:d,followUpItem:h,state:b,validateParams:E,itemProps:C}=Js({csatPayload:e,type:t,initialCsat:r,initialCsatReason:s,initialIsResolved:a});return o.createElement(o.Fragment,null,o.createElement(Pc,null,o.createElement(Nc,{...C}),t===le.AI_AGENT_CSAT_5_WITH_CRE&&o.createElement(vc,{...C,defaultValue:a,value:i.isResolved,onChange:y=>l({isResolved:y})}),o.createElement(Ic,{...C,value:i.csat,onChange:y=>l({csat:y})}),h&&o.createElement(_c,{...C,followUpItem:h,value:i.csatReason,onChange:y=>{l({csatReason:y}),d({followUpItem:!1})},hasError:c.followUpItem})),b!=="unsubmittable"&&o.createElement(o.Fragment,null,o.createElement(Y.Separator,null),n({state:b,params:i,validateParams:E})))},Pc=f.default.div`display:flex;flex-direction:column;gap:12px;`,Bc=e=>{const{stringSet:t}=F();return xo(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})},Fc=()=>{const{stringSet:e}=F();return o.createElement(k,{variant:"body2",color:g.themedColor.textMidEmphasis,style:{textAlign:"center"}},e.CSAT_SUBMISSION_EXPIRED)},Uc=e=>{if(e.messageType!=="admin.csat")throw new Error("Invalid message type");const{extendedMessagePayload:t,onSubmitCSAT:n}=e,{csat:r,csatReason:s,csatExpireAt:a,isResolvedWhenDeterminedByUser:i}=e,l=Ue.useForceUpdate(),c=Bc(t==null?void 0:t.csat),d=u.useRef(!1);if(!c||!c.visibility||!le[c.type])return null;const h=c.type===le.AI_AGENT_CSAT_5||c.type===le.AI_AGENT_CSAT_5_WITH_CRE||c.type===le.HELPDESK_CSAT_5?It:()=>null;return o.createElement(Hc,null,!r&&En(a)?o.createElement(Fc,null):o.createElement(h,{csatPayload:c,type:c.type,initialCsat:r,initialCsatReason:s,initialIsResolved:i,renderSubmitButton:({state:b,params:E,validateParams:C})=>o.createElement(zc,{$state:b,disabled:b==="submitted",onClick:async()=>{d.current||(!En(a)&&C()?(d.current=!0,await n(E).finally(()=>{d.current=!1})):l())}},o.createElement(k,{variant:"button"},b==="submitted"?c.csat_submitted_label:c.csat_submit_label))}))},Hc=f.default.div`display:flex;flex-direction:column;background-color:${({theme:e})=>e.colors.csat.background};border-radius:16px;gap:16px;padding:16px;`,zc=f.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:${g.color.primary.dark};}&:disabled{color:${({$state:e})=>e==="submitted"?g.themedColor.textHighEmphasis:g.color.ondark.textLowEmphasis};background-color:${g.themedColor.textDisabled};cursor:not-allowed;}`,vt=pe({template:Vc,components:{AdminMessage:hc,CSATMessage:Uc}});function Vc(e){const{components:t}=vt.useContext(),n=e.messageType==="admin"?o.createElement(t.AdminMessage,{...e}):e.messageType==="admin.csat"?o.createElement(t.CSATMessage,{...e}):null;return o.createElement(Gc,{$marginBottom:jt(e.groupType)},n)}const Gc=f.default.div`padding-inline:${B.HORIZONTAL_PADDING}px;margin-bottom:${({$marginBottom:e})=>e}px;`,zn={file:"attach",snippet:"snippet",site:"website",sb_sprinklr:"sprinklr",sb_salesforce:"salesforce",sb_confluence:"confluence",sb_zendesk:"zendesk",sb_desk:"snippet"},$r=({actionbook:e,functionCalls:t,groundedness:n,agentMessageTemplates:r,onClickActionbook:s,onClickFunctionCall:a,onClickFunctionCallDetail:i,onClickGroundedness:l,onClickAgentMessageTemplate:c,bottomContent:d,renderCustomGroundednessIcon:h=E=>E.default,style:b={}})=>{const{iconColor:E="#000000",textColor:C="#000000",highlightColor:y=qe.DEFAULT_PRIMARY}=b;return o.createElement(Vn,null,e&&o.createElement(Vn,null,o.createElement(mt,null,o.createElement(rt,null,o.createElement(P,{size:16,type:"actionbook",color:E})),o.createElement(nt,{$clickable:!!s,$highlightColor:y,variant:"body2",color:C,onClick:()=>s==null?void 0:s(e),maxTextLines:1},e.name))),t==null?void 0:t.map(x=>o.createElement($t,{key:x.key},o.createElement(rt,null,o.createElement(P,{size:16,type:"function",color:E})),o.createElement(mt,null,o.createElement(nt,{$clickable:!!a,$highlightColor:y,variant:"body2",color:C,onClick:()=>a==null?void 0:a(x),maxTextLines:1},x.name),i&&o.createElement(qc,{role:"button",onClick:()=>i==null?void 0:i(x)},o.createElement(k,{variant:"body2",color:y},"View details"),o.createElement(P,{type:"chevron-right",size:16,color:y}))))),n==null?void 0:n.map(x=>o.createElement($t,{key:x.id},o.createElement(rt,null,h({default:o.createElement(P,{size:16,type:zn[x.source_type]??zn.snippet,color:E}),sourceType:x.source_type})),o.createElement(nt,{$clickable:!!l,$highlightColor:y,variant:"body2",color:C,onClick:()=>l==null?void 0:l(x),maxTextLines:1},x.preview_title))),r==null?void 0:r.map(x=>o.createElement($t,{key:x.key},o.createElement(rt,null,o.createElement(P,{size:16,type:"template",color:E})),o.createElement(nt,{$clickable:!!c,$highlightColor:y,variant:"body2",color:C,onClick:()=>c==null?void 0:c(x),maxTextLines:1},x.name))),d)},Wc=f.default(k)`font-weight:400;`,nt=f.default(Wc)`${({$clickable:e,$highlightColor:t})=>e&&S.css`
|
|
224
224
|
cursor: pointer;
|
|
225
225
|
text-decoration: underline;
|
|
226
226
|
&:hover {
|
|
227
227
|
color: ${t};
|
|
228
228
|
}
|
|
229
229
|
`}
|
|
230
|
-
`,rt=f.default.div`display:flex;align-items:center;justify-content:center;flex-shrink:0;`,mt=f.default.div`display:flex;gap:8px;align-items:center;word-break:break-word;`,qc=f.default(mt)`cursor:pointer;gap:4px;`,$t=f.default(mt)`flex-direction:row;align-items:center;`,Vn=f.default.div`display:flex;gap:4px;flex-direction:column;align-items:flex-start;`,Mr=u.createContext(null);function jc({testerType:e,origin:t,children:n}){return o.createElement(Mr.Provider,{value:{testerType:e,isActionbookTester:e==="actionbook",origin:t}},e&&o.createElement(Kc,null),n)}const He=()=>{const e=u.useContext(Mr);if(!e)throw new Error("_UNSAFE_INTERNAL_DashboardTesterProvider not found");return e},Kc=()=>{const{isActionbookTester:e}=He();return o.createElement(Le.Template,{template:e?Yc:void 0},o.createElement(Le.MessageLogs,{component:Zc}))},Yc=e=>o.createElement(wr,{...e,testerMode:!0,maxBodyWidth:B.WIDE_BODY_MAX_WIDTH}),Zc=({extendedMessagePayload:e={}})=>{const{handlers:t}=W(),{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(Xc,null,o.createElement(Jc,{width:4}),o.createElement($r,{actionbook:n,functionCalls:s,groundedness:r,agentMessageTemplates:a,onClickFunctionCallDetail:t==null?void 0:t.onFunctionCallDetailClick,style:{iconColor:g.themedColor.textHighEmphasis,textColor:g.themedColor.textHighEmphasis,barColor:g.themedColor.textDisabled},bottomContent:o.createElement(Qc,{variant:"caption2",color:g.themedColor.textLowEmphasis},"Only visible in the tester")}))},Xc=f.default.div`display:flex;gap:16px;margin:16px ${B.HORIZONTAL_PADDING}px 0;align-self:stretch;`,Jc=f.default.div`width:${({width:e})=>e}px;background-color:${g.themedColor.textDisabled};border-radius:100px;flex-shrink:0;`,Qc=f.default(k)`margin-top:5px;`,sn=({start:e,title:t,titleAlign:n="start",end:r})=>{const s=u.useRef(null),a=u.useRef(null),[i,l]=u.useState(0),[c,d]=u.useState(0);return u.useLayoutEffect(()=>{s.current&&l(s.current.offsetWidth),a.current&&d(a.current.offsetWidth)},[e,r]),o.createElement(eu,null,o.createElement(tu,null,n==="center"&&t&&o.createElement(nu,{$sideWidth:Math.max(i,c)},o.createElement(ru,null,t)),o.createElement(ou,null,o.createElement(su,{ref:s},e),(n==="start"||n==="end")&&t&&o.createElement(iu,{$align:n,$hasStart:!!e,$hasEnd:!!r},t),o.createElement(au,{ref:a},r))))},eu=f.default.div`position:relative;width:100%;background-color:${({theme:e})=>e.colors.base.headerBackground};border-bottom:1px solid ${g.themedColor.textDisabled};`,tu=f.default.div`position:relative;height:56px;padding:11px 12px;`,nu=f.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;`,ru=f.default.div`max-width:100%;overflow:hidden;`,ou=f.default.div`display:flex;flex-direction:row;align-items:center;justify-content:space-between;height:100%;z-index:1;`,su=f.default.div`flex-shrink:0;display:flex;align-items:center;`,au=f.default.div`flex-shrink:0;display:flex;align-items:center;`,iu=f.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;`,Ie=({as:e,type:t,size:n=16,color:r,disabled:s,...a})=>{const i=s?g.themedColor.textDisabled:g.themedColor.textHighEmphasis;return o.createElement(lu,{as:e,disabled:s,...a},o.createElement(P,{type:t,size:n,color:r??i}))},lu=f.default.button`all:unset;padding:4px;cursor:pointer;display:flex;align-items:center;justify-content:center;&:disabled{cursor:not-allowed;}`,an=/iPad|iPhone|iPod/.test(navigator.userAgent),cu=/Android/.test(navigator.userAgent),Ze=e=>an||cu,ze=()=>Ze()?24:16,uu=()=>{const{state:e}=W(),t=ze(),n=()=>{e.setOpened(!1)};return o.createElement(Ie,{"aria-label":"close messenger",type:"close",size:t,onClick:n})},{Provider:du,useContext:Q}=J("MessengerSession"),mu=u.forwardRef(function({children:e,...t},n){return o.createElement(hs,{ref:n,...t},r=>o.createElement(gu,{...r},e))}),gu=({children:e,...t})=>{const{chatSDK:n,logger:r,appId:s,aiAgentId:a,agentPreviewConfigs:i,state:l,handlers:c}=W(),{userSessionInfo:d,authenticate:h,setActiveChannel:p,userSession:E,aiAgentInfo:y,launcherInfo:C}=t,x=u.useRef(null);return Ue.useGroupChannelHandler(n,{async onUserJoined(m,b){var _,I,T;if(m.conversation&&m.conversation.type===q.ConversationType.PROACTIVE&&b.userId===((_=n.currentUser)==null?void 0:_.userId)){r.info("messengerSession.onUserJoined: proactive channel joined",m.url);const L=((I=m.conversation)==null?void 0:I.status)??q.ConversationStatus.OPEN;p({url:m.url,status:L}),l.setOpened(!0),hu({sound:document.hidden||!l.opened}),(T=x.current)==null||T.call(x,{channel:m})}}}),u.useEffect(()=>{h().then(({launcher:m})=>{m.auto_open&&!Ze()&&setTimeout(()=>l.setOpened(!0),500)}).catch(m=>{var b;r.error("messengerSession: failed to initialize",m),(b=c==null?void 0:c.onInitializeFailed)==null||b.call(c,m)})},[n,s,a,d==null?void 0:d.userId]),!E||!y||!C?null:o.createElement(du,{value:{...t,userSession:E,aiAgentInfo:{...y,...i==null?void 0:i.bot},launcherInfo:{...C,...i==null?void 0:i.launcher},registerOnJoinedProactiveConversation:m=>x.current=m}},e)};function hu({sound:e}){const t="🔔You have received a new message",n=document.title,r=setInterval(()=>{document.title=document.title===t?n:t},750);setTimeout(()=>clearInterval(r),5e3),e&&Promise.resolve().then(()=>require("./B93o4u0P.cjs")).then(s=>{new Audio(s.default).play()})}const fu=e=>{const{chatSDK:t,handlers:n,logger:r}=W(),{aiAgentInfo:s}=Q(),a=u.useRef(new Set),i=h=>{if(!(n!=null&&n.onCustomEvent))return;he(h)&&h.sender.userId===s.userId&&!Te.isStreaming(h)&&!a.current.has(h.messageId)&&(r.debug("useCustomEventForMessageReceive: bot-message-received",h),n.onCustomEvent({type:"bot-message-received",data:{message:h}}),a.current.add(h.messageId))},l=h=>{if(n!=null&&n.onCustomEvent&&h.isAdminMessage()&&h.customType==="user_action_required"&&!a.current.has(h.messageId)){const p=Ot(h.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(h.messageId))}},c=(h,p)=>{h.url===e&&(i(p),l(p))},d=h=>{l(h)};return Ue.useGroupChannelHandler(t,{onMessageUpdated:c,onMessageReceived:c}),{checkForUserActionRequired:d}};function pu(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 bu(e){if("file"in e&&e.file instanceof File&&e.file.type.startsWith("image/")){const{width:t,height:n}=await pu(e.file);return new Se.MessageMetaArray({key:Qn,value:[t,n]})}}const Eu=({onScrollAfterSendMessage:e})=>{const{agentPreviewConfigs:t,handlers:n}=W(),r=u.useRef(t==null?void 0:t.agentAttributes);return r.current=t==null?void 0:t.agentAttributes,{onBeforeSendMessage:async s=>{const a=await bu(s),i={...s,metaArrays:a?[a]:void 0},l=xu(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===Se.SendingStatus.SUCCEEDED?(i=n==null?void 0:n.onCustomEvent)==null||i.call(n,{type:"message-sent-succeeded",data:{message:s}}):s.sendingStatus===Se.SendingStatus.PENDING&&((l=n==null?void 0:n.onCustomEvent)==null||l.call(n,{type:"message-sent-pending",data:{message:s}}))}}},xu=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},at=50,Mt=at-40,{Provider:vu,useContext:Cu}=J("ConversationScroll"),Gn={viewport:0,contentHeight:0,contentSnapshotHeight:0,shouldRecalc:!1,shouldUpdate:!1};function yu({scrollMode:e,children:t}){const n=u.useRef(null),r=u.useRef(null),s=u.useRef(Gn),a=u.useRef(!1),i=u.useRef(null),l=u.useRef(0),c=u.useRef(0),d=u.useRef(!1),[h,p]=u.useState(0),[E,y]=u.useState(0),[C,x]=u.useState(!1),[m,b]=u.useState(!1),v=u.useMemo(()=>C?"auto":e,[C,e]),_=()=>{s.current.contentSnapshotHeight=s.current.contentHeight,s.current.shouldUpdate=!0,s.current.shouldRecalc=!0},I=()=>{const A=n.current;!A||!s.current.shouldUpdate||p(O=>{s.current.shouldUpdate=!1;const{contentHeight:z,contentSnapshotHeight:ue,shouldRecalc:re}=s.current,te=A.clientHeight;if(ue>z)return O;const de=T(A,{messageType:"outgoing"});let ae=0;if(de){const ie=de.message.offsetTop-Mt+te;ae=Math.max(0,ie-z)}else{const ie=z-ue,Ge=te-Mt;ae=Math.max(0,ie-Ge)}return O===0||ae!==O||re?(s.current.shouldRecalc=!1,ae):O})},T=u.useCallback((A,O)=>{const{messageType:z="all"}=O??{},ue=Array.from(A.querySelectorAll(`#${oe}-message-item`));let re=ue;z==="outgoing"&&(re=ue.filter(St=>St.getAttribute("data-layout-id")==="outgoingmessage"));const te=re[re.length-1];if(!te)return null;const de=A.getBoundingClientRect(),ae=te.getBoundingClientRect(),ie=A.scrollTop+(ae.top-de.top),Ge=ie+te.offsetHeight;return{message:te,scrollTop:ie,lastMessageBottom:Ge}},[]),L=u.useCallback(()=>{const A=n.current;if(!A||v!=="fixed")return;const O=T(A);s.current.contentHeight=(O==null?void 0:O.lastMessageBottom)??A.scrollHeight,!a.current&&s.current.contentSnapshotHeight>0&&_();const z=Math.max(0,A.scrollHeight-A.scrollTop-A.clientHeight);y(z),I()},[v,T]),$=u.useCallback(()=>{r.current&&(r.current.disconnect(),r.current=null),s.current=Gn,p(0),y(0)},[]),M=u.useCallback((A=!0)=>{d.current=!1,mi(()=>{const O=n.current;O&&O.scrollTo({top:O.scrollHeight,behavior:A?"smooth":"auto"})})},[]),R=u.useCallback(A=>{A&&(n.current=A,v==="fixed"&&($(),s.current.viewport=A.clientHeight,r.current=new MutationObserver(()=>{L()}),r.current.observe(A,{childList:!0,subtree:!0})))},[v,L,$]),H=u.useCallback(()=>{const A=n.current;if(!A)return;const O=T(A,{messageType:"outgoing"});O&&(A.scrollTo({top:O.message.offsetTop-Mt,behavior:"smooth"}),i.current&&clearTimeout(i.current),i.current=setTimeout(()=>{b(!1)},500))},[T]),G=A=>{const{scrollHeight:O,scrollTop:z,clientHeight:ue}=A.currentTarget,re=Math.max(0,O-z-ue),te=c.current,de=re<=at,ae=z<te,ie=z>te;ae&&!de&&(d.current=!0),ie&&de&&(d.current=!1),c.current=z,l.current=re,y(re)},Ee=u.useCallback(()=>{v==="fixed"&&(b(!0),_())},[v]),xe=u.useCallback(()=>{v==="fixed"?setTimeout(()=>H(),300):M()},[v,H]),$e=u.useCallback(A=>{a.current=A,v==="fixed"?_():d.current||M()},[v,M]),j=u.useCallback(A=>{x(A),A&&(p(0),r.current&&(r.current.disconnect(),r.current=null))},[]),ne=u.useCallback(A=>{v==="auto"&&A&&!d.current&&M()},[v,M]),w=!(E<=at)&&!m,N=u.useCallback(()=>l.current>at,[]);return o.createElement(vu,{value:{ref:R,state:{bottomSpace:h,isAwayFromBottom:w,shouldCountNewMessages:N},props:{onScroll:G},actions:{scrollToBottom:M,onBeforeMessageSend:Ee,onAfterMessageSend:xe,onStreamingUpdate:$e,onConversationClosed:j,onTypingIndicatorUpdate:ne}}},t)}const{Provider:_u,Context:Su,useContext:ee}=J("Conversation"),Tu=({children:e})=>{var s;const{channelSource:t}=ee(),n=(s=t.channel)==null?void 0:s.url,{checkForUserActionRequired:r}=fu(n);return u.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)},Au=({channelUrl:e,onClearChannelUrl:t,onNavigateToConversationList:n,shouldMarkAsRead:r,children:s})=>{const{activeChannel:a,refreshActiveChannel:i}=Q(),l=Cu(),{onBeforeSendMessage:c,onAfterSendMessage:d}=Eu({onScrollAfterSendMessage:()=>{l.actions.onAfterMessageSend()}}),h=e||(a==null?void 0:a.url),p=u.useCallback(C=>(l.actions.onBeforeMessageSend(),c(C)),[l.actions,c]),E=u.useCallback(C=>{const x=C.some(m=>Te.isStreaming(m));l.actions.onStreamingUpdate(x)},[l.actions.onStreamingUpdate]),y=u.useCallback(async()=>{await i(),e&&(t==null||t())},[i,e,t]);return o.createElement(Ss,{key:h,channelUrl:h,onBeforeSendMessage:p,onAfterSendMessage:d,onMessagesUpdated:E,onMessagesReceived:E,onChannelDeleted:y,onConversationClosedStatusChanged:l.actions.onConversationClosed,shouldMarkAsRead:r,shouldCountNewMessages:l.state.shouldCountNewMessages},C=>o.createElement(_u,{value:{...C,scrollSource:l,goToActiveConversation:y,onNavigateToConversationList:n}},o.createElement(Tu,null,s)))},Lr=({children:e,...t})=>{var s;const{config:n}=K(),r=((s=n==null?void 0:n.conversation)==null?void 0:s.scrollMode)??"auto";return o.createElement(yu,{scrollMode:r},o.createElement(Au,{...t},e))},wu=()=>{const{enableCloseConversationButton:e,dispatcher:t}=W(),{channelSource:n}=ee(),r=n.channel,s=ze(),a=(r==null?void 0:r.isAIAgent)&&e,i=!Wt(r);if(!a)return null;const l=async()=>{r&&await t.send(sr.CloseConversation({channelUrl:r.url}))};return o.createElement(Ie,{"aria-label":"close conversation",type:"mute",size:s,disabled:i,onClick:l})},ku=()=>{const{state:e,enableExpandButton:t}=W(),n=ze();return t?o.createElement(Ie,{"aria-label":"expand",type:e.expanded?"collapse":"expand",size:n,onClick:()=>e.setExpanded(!e.expanded)}):null},Iu=({label:e,children:t,position:n="top",disabled:r})=>r?t:o.createElement(Ht,null,t,o.createElement(Lu,{$position:n},o.createElement(Ou,{variant:"caption1"},e),o.createElement($u,{$position:n}))),$u=({$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:g.themedColor.textHighEmphasis})),Mu={top:S.css`flex-direction:column;top:0;transform:translate(-50%,-100%);`,bottom:S.css`flex-direction:column-reverse;bottom:0;transform:translate(-50%,100%);`},Ht=f.default.div`position:relative;`,Lu=f.default.div`display:flex;align-items:center;position:absolute;left:50%;z-index:${Oe.TOOLTIP};${({$position:e})=>Mu[e]}opacity:0;transition:opacity 0.2s ease-in-out;pointer-events:none;${Ht}:hover &,${Ht}:focus-within &{opacity:1;}`,Ou=f.default(k)`padding:6px 8px;background:${g.themedColor.textHighEmphasis};color:${g.themedColor.textHighEmphasisInverse};border-radius:4px;font-size:12px;white-space:nowrap;`,Ru=()=>{const{logger:e}=W(),{stringSet:t}=F(),{channelSource:n}=ee(),r=n.channel,s=ze(),a=Xt("handoff-button",r),i=!Wt(r)||Be(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(Iu,{label:t.HEADER_BUTTON__AGENT_HANDOFF,position:"bottom",disabled:i},o.createElement(Ie,{"aria-label":"request handoff",type:"agent",size:s,disabled:i,onClick:l})):null},Du=()=>{const{stringSet:e}=F(),{onNavigateToConversationList:t}=ee();return t?o.createElement(Ie,{type:"menu",size:24,onClick:()=>t(),"aria-label":e.A11Y_OPEN_CONVERSATION_LIST}):null},Or=({channel:e,size:t=40})=>{const{userSession:n,aiAgentInfo:r}=Q(),{fallbackIcon:s,url:a}=hr({channel:e,aiAgentInfo:r,userSession:n}),i=S.useTheme();return a?o.createElement(en,{src:a,size:t}):o.createElement(Nu,{$size:t,$bgColor:i.colors.base.primary},o.createElement(P,{type:s,size:t*.55,color:i.colors.base.primaryContrastContent}))},Nu=f.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;`,Pu=()=>{var l,c;const{channelSource:e}=ee(),{aiAgentInfo:t,userSession:n}=Q(),{config:r}=K(),s=e.channel,a=hr({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(Bu,null,i&&o.createElement(Or,{channel:s,size:34}),o.createElement(Fu,{variant:"h2",color:g.themedColor.textHighEmphasis},a.title))},Bu=f.default.div`display:flex;flex-direction:row;align-items:center;gap:6px;overflow:hidden;`,Fu=f.default(k)`text-overflow:ellipsis;overflow:hidden;white-space:nowrap;padding:2px 0;`,Uu=e=>{const{components:t}=Re.useContext();return o.createElement(sn,{start:o.createElement(t.StartArea,null),title:o.createElement(t.TitleArea,null),titleAlign:e.titleAlign,end:o.createElement(t.EndArea,null)})},Hu=()=>{const{components:e}=Re.useContext();return o.createElement(e.MenuButton,null)},zu=()=>{const{components:e}=Re.useContext();return o.createElement(e.Title,null)},Vu=()=>{const{components:e}=Re.useContext();return o.createElement(Wu,null,o.createElement(e.HandoffButton,null),o.createElement(e.ConversationCloseButton,null),o.createElement(e.ExpandButton,null),o.createElement(e.CloseButton,null))},Re=pe({template:Uu,components:{StartArea:Hu,TitleArea:zu,EndArea:Vu,MenuButton:Du,Title:Pu,HandoffButton:Ru,ConversationCloseButton:wu,ExpandButton:ku,CloseButton:uu}}),Gu=()=>{const{isActionbookTester:e}=He(),{Template:t}=Re.useContext();return e?null:o.createElement(t,{titleAlign:"start"})},Wu=f.default.div`display:flex;gap:10px;align-items:center;justify-content:center;`,ln=u.createContext({onDrop:fe,subscribe:()=>fe}),zt=({children:e})=>{const t=u.useRef(new Set);return o.createElement(ln.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)},qu=({onDropFiles:e})=>{const{subscribe:t}=u.useContext(ln);u.useEffect(()=>t(e),[e])};zt.Consumer=({children:e})=>{const{onDrop:t}=u.useContext(ln);return e({onDrop:t,onDragOver:s=>s.preventDefault()})};const cn=({iconSize:e=64,icon:t,className:n,label:r,children:s})=>o.createElement(Ku,{className:n},t&&o.createElement(P,{type:t,size:e,color:g.themedColor.textLowEmphasis}),r&&o.createElement(k,{variant:"body1",color:g.themedColor.textMidEmphasis},r),s),ju=f.default.div`position:relative;display:flex;justify-content:center;align-items:center;width:100%;height:100%;`,Ku=f.default.div`display:flex;flex-direction:column;min-height:104px;align-items:center;gap:20px;text-align:center;`,Yu=({label:e="Something went wrong",icon:t="error",action:n,...r})=>o.createElement(cn,{icon:t,label:e,...r},n&&o.createElement(Zu,{onClick:n.onClick,label:n.label??"Retry"})),Zu=({label:e,onClick:t})=>o.createElement(Xu,{tabIndex:0,onClick:t},o.createElement(P,{type:"refresh",size:20}),o.createElement(k,{variant:"button",color:g.color.primary.main},e)),Xu=f.default.button`all:unset;display:flex;cursor:pointer;gap:4px;align-items:center;justify-content:center;`,Ju=({iconSize:e=48,className:t})=>o.createElement(on,{size:e,className:t}),Qu=({label:e="No channels",icon:t="chat",...n})=>o.createElement(cn,{icon:t,label:e,...n}),ed=({label:e="No messages",icon:t="message",...n})=>o.createElement(cn,{icon:t,label:e,...n}),td=e=>{const{components:t}=Ct.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(ju,null,n)},Ct=pe({template:td,components:{Loading:Ju,Error:Yu,NoChannels:Qu,NoMessages:ed}}),Fe=e=>{const{Template:t}=Ct.useContext();return o.createElement(t,{...e})},Wn=e=>er(e)||tr(e);function nd(e){return e.isAdminMessage()?e.message==="The channel's custom_type was updated.":!1}function rd(e,t){return e.filter(n=>Te.isWelcomeMessage(n,t))}const od=f.default.div`width:${({$size:e})=>e}px;height:${({$size:e})=>e}px;border-radius:50%;display:flex;align-items:center;justify-content:center;background-color:${({theme:e})=>e.colors.base.primary}!important;ellipse,path{fill:${({theme:e})=>e.colors.base.primaryContrastContent}!important;}`,sd=f.default.div`position:fixed;inset:0;outline:none;display:flex;flex-direction:column;`,ad=f.default.div`display:flex;gap:10px;align-items:center;`,id=f.default.div`flex:1;min-height:0;display:flex;align-items:center;justify-content:center;`,ld=f.default.video`max-width:100%;max-height:100%;user-select:none;-webkit-user-drag:none;`,cd=f.default.img`max-width:100%;max-height:100%;padding:40px;box-sizing:border-box;object-fit:contain;user-select:none;-webkit-user-drag:none;`,ud=f.default.div`max-width:100%;max-height:100%;display:flex;justify-content:center;align-items:center;`,dd=({file:e,sender:t={},onClose:n})=>{const{type:r,url:s,name:a=""}=e,{profileUrl:i,userId:l}=t,{aiAgentInfo:c}=Q();return o.createElement(md,{profileUrl:i??"",type:r,url:s,name:a,onClose:n,isBotMessage:l===c.userId})},md=({profileUrl:e,isBotMessage:t,name:n,type:r,url:s,onClose:a})=>{var d,h;const{stringSet:i}=F(),l=ze(),{config:c}=W();return o.createElement(Et,{onClose:a,visible:!0,rootElementId:se.MODAL_ROOT},o.createElement(sd,null,o.createElement(sn,{start:o.createElement(gd,{profileUrl:e,isBotMessage:t}),title:o.createElement(k,{variant:"h2",color:g.themedColor.textHighEmphasis,maxTextLines:1},n),end:o.createElement(ad,null,Wn(r)&&((h=(d=c==null?void 0:c.conversation)==null?void 0:d.fileViewer)==null?void 0:h.downloadEnabled)&&o.createElement(Ie,{as:"a",href:s,download:n,"aria-label":"download file",type:"download",size:l}),o.createElement(Ie,{"aria-label":"close file viewer",type:"close",size:l,onClick:a}))}),o.createElement(id,{onClick:p=>p.currentTarget===p.target&&a()},tr(r)&&o.createElement(ld,{controls:!0},o.createElement("source",{src:s,type:r})),er(r)&&o.createElement(cd,{src:s,alt:n}),!Wn(r)&&o.createElement(ud,null,o.createElement(k,{variant:"h1",color:g.themedColor.textHighEmphasis},i.FILE_VIEWER__UNSUPPORT)))))},gd=({profileUrl:e,isBotMessage:t})=>t&&!e?o.createElement(od,{$size:32},o.createElement(P,{type:"delight",size:20})):o.createElement(en,{size:32,src:e}),Rr=({className:e,locale:t,date:n=Date.now(),formatString:r="MMMM dd, yyyy",style:s})=>o.createElement(hd,{id:`${oe}-date-separator`,style:s,className:e},o.createElement(k,{variant:"caption4",color:g.themedColor.textMidEmphasis},_e.format(n,r,{locale:t}))),hd=f.default.div`display:flex;justify-content:center;align-items:center;text-align:center;word-break:break-word;`,fd=u.forwardRef(function(t,n){const{messages:r,renderMessage:s,messageTopArea:a,messageBottomArea:i,overlayArea:l,onLoadPrev:c,onLoadNext:d,loadThreshold:h=.05,onScroll:p=fe,depsForResetScrollPositionToBottom:E,stackDirection:y="top",bottomSpacerHeight:C=0,ariaLabel:x}=t,m=u.useRef(null),b=u.useCallback($=>{m.current=$,n&&(typeof n=="function"?n($):n.current=$)},[n]),v=u.useRef(!1),_=u.useRef(void 0),I=u.useRef(0),T=u.useRef(0);u.useLayoutEffect(()=>{m.current&&(m.current.scrollTop=m.current.scrollHeight)},E),u.useLayoutEffect(()=>{m.current&&(_.current==="top"&&(m.current.scrollTop=m.current.scrollHeight-T.current),_.current==="bottom"&&(m.current.scrollTop=I.current),_.current=void 0)},[m.current,r.length]);const L=async $=>{if(p==null||p($),!m.current)return;const M=m.current;if(T.current=M.scrollHeight-M.scrollTop,I.current=M.scrollTop,v.current)return;const R=M.clientHeight*Math.min(Math.max(0,h),1);M.scrollTop<=R?(v.current=!0,_.current="top",await c(),v.current=!1):M.scrollHeight-M.scrollTop-M.clientHeight<=R?(v.current=!0,_.current="bottom",await d(),v.current=!1):_.current=void 0};return o.createElement(pd,{id:"infinite-list-container"},o.createElement(bd,{id:"infinite-list-inner",ref:b,onScroll:L,role:"list","aria-label":x},y==="bottom"&&o.createElement("div",{style:{flexGrow:1}}),a,r.map(($,M)=>s({message:$,index:M})),i,C>0&&o.createElement("div",{style:{minHeight:C}})),o.createElement(Ed,{id:"infinite-list-overlay-container"},o.createElement(xd,{id:"infinite-list-overlay"},l)))}),pd=f.default.div`display:flex;position:relative;flex:1;overflow:hidden;`,bd=f.default.div`display:flex;flex:1;flex-direction:column;overflow-y:auto;overscroll-behavior:contain;scrollbar-color:${g.themedColor.textLowEmphasis}transparent;&::-webkit-scrollbar-thumb:hover{background-color:transparent;}`,Ed=f.default.div`position:absolute;top:0;bottom:0;left:0;right:0;pointer-events:none;`,xd=f.default.div`pointer-events:auto;`,vd=({className:e,label:t,ariaLabel:n,onClick:r})=>{const{colors:s}=S.useTheme();return o.createElement(Cd,{className:e,onClick:r,"aria-label":n},o.createElement(k,{variant:"button",color:s.base.primaryContrastContent},t),o.createElement(P,{size:16,type:"chevron-down",color:s.base.primaryContrastContent}))},Cd=f.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;}`,yd=({className:e,onClick:t,ariaLabel:n})=>o.createElement(_d,{className:e,onClick:t,tabIndex:0,"aria-label":n},o.createElement(P,{size:24,type:"chevron-down",color:g.color.primary.main})),_d=f.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);${D.light`
|
|
230
|
+
`,rt=f.default.div`display:flex;align-items:center;justify-content:center;flex-shrink:0;`,mt=f.default.div`display:flex;gap:8px;align-items:center;word-break:break-word;`,qc=f.default(mt)`cursor:pointer;gap:4px;`,$t=f.default(mt)`flex-direction:row;align-items:center;`,Vn=f.default.div`display:flex;gap:4px;flex-direction:column;align-items:flex-start;`,Mr=u.createContext(null);function jc({testerType:e,origin:t,children:n}){return o.createElement(Mr.Provider,{value:{testerType:e,isActionbookTester:e==="actionbook",origin:t}},e&&o.createElement(Kc,null),n)}const He=()=>{const e=u.useContext(Mr);if(!e)throw new Error("_UNSAFE_INTERNAL_DashboardTesterProvider not found");return e},Kc=()=>{const{isActionbookTester:e}=He();return o.createElement(Le.Template,{template:e?Yc:void 0},o.createElement(Le.MessageLogs,{component:Zc}))},Yc=e=>o.createElement(wr,{...e,testerMode:!0,maxBodyWidth:B.WIDE_BODY_MAX_WIDTH}),Zc=({extendedMessagePayload:e={}})=>{const{handlers:t}=W(),{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(Xc,null,o.createElement(Jc,{width:4}),o.createElement($r,{actionbook:n,functionCalls:s,groundedness:r,agentMessageTemplates:a,onClickFunctionCallDetail:t==null?void 0:t.onFunctionCallDetailClick,style:{iconColor:g.themedColor.textHighEmphasis,textColor:g.themedColor.textHighEmphasis,barColor:g.themedColor.textDisabled},bottomContent:o.createElement(Qc,{variant:"caption2",color:g.themedColor.textLowEmphasis},"Only visible in the tester")}))},Xc=f.default.div`display:flex;gap:16px;margin:16px ${B.HORIZONTAL_PADDING}px 0;align-self:stretch;`,Jc=f.default.div`width:${({width:e})=>e}px;background-color:${g.themedColor.textDisabled};border-radius:100px;flex-shrink:0;`,Qc=f.default(k)`margin-top:5px;`,sn=({start:e,title:t,titleAlign:n="start",end:r})=>{const s=u.useRef(null),a=u.useRef(null),[i,l]=u.useState(0),[c,d]=u.useState(0);return u.useLayoutEffect(()=>{s.current&&l(s.current.offsetWidth),a.current&&d(a.current.offsetWidth)},[e,r]),o.createElement(eu,null,o.createElement(tu,null,n==="center"&&t&&o.createElement(nu,{$sideWidth:Math.max(i,c)},o.createElement(ru,null,t)),o.createElement(ou,null,o.createElement(su,{ref:s},e),(n==="start"||n==="end")&&t&&o.createElement(iu,{$align:n,$hasStart:!!e,$hasEnd:!!r},t),o.createElement(au,{ref:a},r))))},eu=f.default.div`position:relative;width:100%;background-color:${({theme:e})=>e.colors.base.headerBackground};border-bottom:1px solid ${g.themedColor.textDisabled};`,tu=f.default.div`position:relative;height:56px;padding:11px 12px;`,nu=f.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;`,ru=f.default.div`max-width:100%;overflow:hidden;`,ou=f.default.div`display:flex;flex-direction:row;align-items:center;justify-content:space-between;height:100%;z-index:1;`,su=f.default.div`flex-shrink:0;display:flex;align-items:center;`,au=f.default.div`flex-shrink:0;display:flex;align-items:center;`,iu=f.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;`,ke=({as:e,type:t,size:n=16,color:r,disabled:s,...a})=>{const i=s?g.themedColor.textDisabled:g.themedColor.textHighEmphasis;return o.createElement(lu,{as:e,disabled:s,...a},o.createElement(P,{type:t,size:n,color:r??i}))},lu=f.default.button`all:unset;padding:4px;cursor:pointer;display:flex;align-items:center;justify-content:center;&:disabled{cursor:not-allowed;}`,an=/iPad|iPhone|iPod/.test(navigator.userAgent),cu=/Android/.test(navigator.userAgent),Ze=e=>an||cu,ze=()=>Ze()?24:16,uu=()=>{const{state:e}=W(),t=ze(),n=()=>{e.setOpened(!1)};return o.createElement(ke,{"aria-label":"close messenger",type:"close",size:t,onClick:n})},{Provider:du,useContext:J}=X("MessengerSession"),mu=u.forwardRef(function({children:e,...t},n){return o.createElement(hs,{ref:n,...t},r=>o.createElement(gu,{...r},e))}),gu=({children:e,...t})=>{const{chatSDK:n,logger:r,appId:s,aiAgentId:a,agentPreviewConfigs:i,state:l,handlers:c}=W(),{userSessionInfo:d,authenticate:h,setActiveChannel:b,userSession:E,aiAgentInfo:C,launcherInfo:y}=t,x=u.useRef(null);return Ue.useGroupChannelHandler(n,{async onUserJoined(m,p){var _,I,T;if(m.conversation&&m.conversation.type===q.ConversationType.PROACTIVE&&p.userId===((_=n.currentUser)==null?void 0:_.userId)){r.info("messengerSession.onUserJoined: proactive channel joined",m.url);const L=((I=m.conversation)==null?void 0:I.status)??q.ConversationStatus.OPEN;b({url:m.url,status:L}),l.setOpened(!0),hu({sound:document.hidden||!l.opened}),(T=x.current)==null||T.call(x,{channel:m})}}}),u.useEffect(()=>{h().then(({launcher:m})=>{m.auto_open&&!Ze()&&setTimeout(()=>l.setOpened(!0),500)}).catch(m=>{var p;r.error("messengerSession: failed to initialize",m),(p=c==null?void 0:c.onInitializeFailed)==null||p.call(c,m)})},[n,s,a,d==null?void 0:d.userId]),!E||!C||!y?null:o.createElement(du,{value:{...t,userSession:E,aiAgentInfo:{...C,...i==null?void 0:i.bot},launcherInfo:{...y,...i==null?void 0:i.launcher},registerOnJoinedProactiveConversation:m=>x.current=m}},e)};function hu({sound:e}){const t="🔔You have received a new message",n=document.title,r=setInterval(()=>{document.title=document.title===t?n:t},750);setTimeout(()=>clearInterval(r),5e3),e&&Promise.resolve().then(()=>require("./B93o4u0P.cjs")).then(s=>{new Audio(s.default).play()})}const fu=e=>{const{chatSDK:t,handlers:n,logger:r}=W(),{aiAgentInfo:s}=J(),a=u.useRef(new Set),i=h=>{if(!(n!=null&&n.onCustomEvent))return;he(h)&&h.sender.userId===s.userId&&!Se.isStreaming(h)&&!a.current.has(h.messageId)&&(r.debug("useCustomEventForMessageReceive: bot-message-received",h),n.onCustomEvent({type:"bot-message-received",data:{message:h}}),a.current.add(h.messageId))},l=h=>{if(n!=null&&n.onCustomEvent&&h.isAdminMessage()&&h.customType==="user_action_required"&&!a.current.has(h.messageId)){const b=Ot(h.data);Array.isArray(b.history)&&b.history.length===0&&(r.debug("useCustomEventForMessageReceive: user_action_required",b),n.onCustomEvent({type:"user-action-requested",data:b}),a.current.add(h.messageId))}},c=(h,b)=>{h.url===e&&(i(b),l(b))},d=h=>{l(h)};return Ue.useGroupChannelHandler(t,{onMessageUpdated:c,onMessageReceived:c}),{checkForUserActionRequired:d}};function pu(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 bu(e){if("file"in e&&e.file instanceof File&&e.file.type.startsWith("image/")){const{width:t,height:n}=await pu(e.file);return new _e.MessageMetaArray({key:Qn,value:[t,n]})}}const Eu=({onScrollAfterSendMessage:e})=>{const{agentPreviewConfigs:t,handlers:n}=W(),r=u.useRef(t==null?void 0:t.agentAttributes);return r.current=t==null?void 0:t.agentAttributes,{onBeforeSendMessage:async s=>{const a=await bu(s),i={...s,metaArrays:a?[a]:void 0},l=xu(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===_e.SendingStatus.SUCCEEDED?(i=n==null?void 0:n.onCustomEvent)==null||i.call(n,{type:"message-sent-succeeded",data:{message:s}}):s.sendingStatus===_e.SendingStatus.PENDING&&((l=n==null?void 0:n.onCustomEvent)==null||l.call(n,{type:"message-sent-pending",data:{message:s}}))}}},xu=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},at=50,Mt=at-40,{Provider:vu,useContext:Cu}=X("ConversationScroll"),Gn={viewport:0,contentHeight:0,contentSnapshotHeight:0,shouldRecalc:!1,shouldUpdate:!1};function yu({scrollMode:e,children:t}){const n=u.useRef(null),r=u.useRef(null),s=u.useRef(Gn),a=u.useRef(!1),i=u.useRef(null),l=u.useRef(0),c=u.useRef(0),d=u.useRef(!1),[h,b]=u.useState(0),[E,C]=u.useState(0),[y,x]=u.useState(!1),[m,p]=u.useState(!1),v=u.useMemo(()=>y?"auto":e,[y,e]),_=()=>{s.current.contentSnapshotHeight=s.current.contentHeight,s.current.shouldUpdate=!0,s.current.shouldRecalc=!0},I=()=>{const A=n.current;!A||!s.current.shouldUpdate||b(O=>{s.current.shouldUpdate=!1;const{contentHeight:V,contentSnapshotHeight:ue,shouldRecalc:re}=s.current,ee=A.clientHeight;if(ue>V)return O;const de=T(A,{messageType:"outgoing"});let ae=0;if(de){const ie=de.message.offsetTop-Mt+ee;ae=Math.max(0,ie-V)}else{const ie=V-ue,Ge=ee-Mt;ae=Math.max(0,ie-Ge)}return O===0||ae!==O||re?(s.current.shouldRecalc=!1,ae):O})},T=u.useCallback((A,O)=>{const{messageType:V="all"}=O??{},ue=Array.from(A.querySelectorAll(`#${oe}-message-item`));let re=ue;V==="outgoing"&&(re=ue.filter(St=>St.getAttribute("data-layout-id")==="outgoingmessage"));const ee=re[re.length-1];if(!ee)return null;const de=A.getBoundingClientRect(),ae=ee.getBoundingClientRect(),ie=A.scrollTop+(ae.top-de.top),Ge=ie+ee.offsetHeight;return{message:ee,scrollTop:ie,lastMessageBottom:Ge}},[]),L=u.useCallback(()=>{const A=n.current;if(!A||v!=="fixed")return;const O=T(A);s.current.contentHeight=(O==null?void 0:O.lastMessageBottom)??A.scrollHeight,!a.current&&s.current.contentSnapshotHeight>0&&_();const V=Math.max(0,A.scrollHeight-A.scrollTop-A.clientHeight);C(V),I()},[v,T]),$=u.useCallback(()=>{r.current&&(r.current.disconnect(),r.current=null),s.current=Gn,b(0),C(0)},[]),M=u.useCallback((A=!0)=>{d.current=!1,mi(()=>{const O=n.current;O&&O.scrollTo({top:O.scrollHeight,behavior:A?"smooth":"auto"})})},[]),R=u.useCallback(A=>{A&&(n.current=A,v==="fixed"&&($(),s.current.viewport=A.clientHeight,r.current=new MutationObserver(()=>{L()}),r.current.observe(A,{childList:!0,subtree:!0})))},[v,L,$]),z=u.useCallback(()=>{const A=n.current;if(!A)return;const O=T(A,{messageType:"outgoing"});O&&(A.scrollTo({top:O.message.offsetTop-Mt,behavior:"smooth"}),i.current&&clearTimeout(i.current),i.current=setTimeout(()=>{p(!1)},500))},[T]),G=A=>{const{scrollHeight:O,scrollTop:V,clientHeight:ue}=A.currentTarget,re=Math.max(0,O-V-ue),ee=c.current,de=re<=at,ae=V<ee,ie=V>ee;ae&&!de&&(d.current=!0),ie&&de&&(d.current=!1),c.current=V,l.current=re,C(re)},Ee=u.useCallback(()=>{v==="fixed"&&(p(!0),_())},[v]),xe=u.useCallback(()=>{v==="fixed"?setTimeout(()=>z(),300):M()},[v,z]),Ie=u.useCallback(A=>{a.current=A,v==="fixed"?_():d.current||M()},[v,M]),j=u.useCallback(A=>{x(A),A&&(b(0),r.current&&(r.current.disconnect(),r.current=null))},[]),ne=u.useCallback(A=>{v==="auto"&&A&&!d.current&&M()},[v,M]),w=!(E<=at)&&!m,N=u.useCallback(()=>l.current>at,[]);return o.createElement(vu,{value:{ref:R,state:{bottomSpace:h,isAwayFromBottom:w,shouldCountNewMessages:N},props:{onScroll:G},actions:{scrollToBottom:M,onBeforeMessageSend:Ee,onAfterMessageSend:xe,onStreamingUpdate:Ie,onConversationClosed:j,onTypingIndicatorUpdate:ne}}},t)}const{Provider:_u,Context:Su,useContext:Q}=X("Conversation"),Tu=({children:e})=>{var s;const{channelSource:t}=Q(),n=(s=t.channel)==null?void 0:s.url,{checkForUserActionRequired:r}=fu(n);return u.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)},Au=({channelUrl:e,onClearChannelUrl:t,onNavigateToConversationList:n,shouldMarkAsRead:r,children:s})=>{const{activeChannel:a,refreshActiveChannel:i}=J(),l=Cu(),{onBeforeSendMessage:c,onAfterSendMessage:d}=Eu({onScrollAfterSendMessage:()=>{l.actions.onAfterMessageSend()}}),h=e||(a==null?void 0:a.url),b=u.useCallback(y=>(l.actions.onBeforeMessageSend(),c(y)),[l.actions,c]),E=u.useCallback(y=>{const x=y.some(m=>Se.isStreaming(m));l.actions.onStreamingUpdate(x)},[l.actions.onStreamingUpdate]),C=u.useCallback(async()=>{await i(),e&&(t==null||t())},[i,e,t]);return o.createElement(Ss,{key:h,channelUrl:h,onBeforeSendMessage:b,onAfterSendMessage:d,onMessagesUpdated:E,onMessagesReceived:E,onChannelDeleted:C,onConversationClosedStatusChanged:l.actions.onConversationClosed,shouldMarkAsRead:r,shouldCountNewMessages:l.state.shouldCountNewMessages},y=>o.createElement(_u,{value:{...y,scrollSource:l,goToActiveConversation:C,onNavigateToConversationList:n}},o.createElement(Tu,null,s)))},Lr=({children:e,...t})=>{var s;const{config:n}=K(),r=((s=n==null?void 0:n.conversation)==null?void 0:s.scrollMode)??"auto";return o.createElement(yu,{scrollMode:r},o.createElement(Au,{...t},e))},wu=()=>{const{enableCloseConversationButton:e,dispatcher:t}=W(),{channelSource:n}=Q(),r=n.channel,s=ze(),a=(r==null?void 0:r.isAIAgent)&&e,i=!Wt(r);if(!a)return null;const l=async()=>{r&&await t.send(sr.CloseConversation({channelUrl:r.url}))};return o.createElement(ke,{"aria-label":"close conversation",type:"mute",size:s,disabled:i,onClick:l})},ku=()=>{const{state:e,enableExpandButton:t}=W(),n=ze();return t?o.createElement(ke,{"aria-label":"expand",type:e.expanded?"collapse":"expand",size:n,onClick:()=>e.setExpanded(!e.expanded)}):null},Iu=({label:e,children:t,position:n="top",disabled:r})=>r?t:o.createElement(Ht,null,t,o.createElement(Lu,{$position:n},o.createElement(Ou,{variant:"caption1"},e),o.createElement($u,{$position:n}))),$u=({$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:g.themedColor.textHighEmphasis})),Mu={top:S.css`flex-direction:column;top:0;transform:translate(-50%,-100%);`,bottom:S.css`flex-direction:column-reverse;bottom:0;transform:translate(-50%,100%);`},Ht=f.default.div`position:relative;`,Lu=f.default.div`display:flex;align-items:center;position:absolute;left:50%;z-index:${Oe.TOOLTIP};${({$position:e})=>Mu[e]}opacity:0;transition:opacity 0.2s ease-in-out;pointer-events:none;${Ht}:hover &,${Ht}:focus-within &{opacity:1;}`,Ou=f.default(k)`padding:6px 8px;background:${g.themedColor.textHighEmphasis};color:${g.themedColor.textHighEmphasisInverse};border-radius:4px;font-size:12px;white-space:nowrap;`,Ru=()=>{const{logger:e}=W(),{stringSet:t}=F(),{channelSource:n}=Q(),r=n.channel,s=ze(),a=Xt("handoff-button",r),i=!Wt(r)||Be(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(Iu,{label:t.HEADER_BUTTON__AGENT_HANDOFF,position:"bottom",disabled:i},o.createElement(ke,{"aria-label":"request handoff",type:"agent",size:s,disabled:i,onClick:l})):null},Du=()=>{const{stringSet:e}=F(),{onNavigateToConversationList:t}=Q();return t?o.createElement(ke,{type:"menu",size:24,onClick:()=>t(),"aria-label":e.A11Y_OPEN_CONVERSATION_LIST}):null},Or=({channel:e,size:t=40})=>{const{userSession:n,aiAgentInfo:r}=J(),{fallbackIcon:s,url:a}=hr({channel:e,aiAgentInfo:r,userSession:n}),i=S.useTheme();return a?o.createElement(en,{src:a,size:t}):o.createElement(Nu,{$size:t,$bgColor:i.colors.base.primary},o.createElement(P,{type:s,size:t*.55,color:i.colors.base.primaryContrastContent}))},Nu=f.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;`,Pu=()=>{var l,c;const{channelSource:e}=Q(),{aiAgentInfo:t,userSession:n}=J(),{config:r}=K(),s=e.channel,a=hr({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(Bu,null,i&&o.createElement(Or,{channel:s,size:34}),o.createElement(Fu,{variant:"h2",color:g.themedColor.textHighEmphasis},a.title))},Bu=f.default.div`display:flex;flex-direction:row;align-items:center;gap:6px;overflow:hidden;`,Fu=f.default(k)`text-overflow:ellipsis;overflow:hidden;white-space:nowrap;padding:2px 0;`,Uu=e=>{const{components:t}=Re.useContext();return o.createElement(sn,{start:o.createElement(t.StartArea,null),title:o.createElement(t.TitleArea,null),titleAlign:e.titleAlign,end:o.createElement(t.EndArea,null)})},Hu=()=>{const{components:e}=Re.useContext();return o.createElement(e.MenuButton,null)},zu=()=>{const{components:e}=Re.useContext();return o.createElement(e.Title,null)},Vu=()=>{const{components:e}=Re.useContext();return o.createElement(Wu,null,o.createElement(e.HandoffButton,null),o.createElement(e.ConversationCloseButton,null),o.createElement(e.ExpandButton,null),o.createElement(e.CloseButton,null))},Re=pe({template:Uu,components:{StartArea:Hu,TitleArea:zu,EndArea:Vu,MenuButton:Du,Title:Pu,HandoffButton:Ru,ConversationCloseButton:wu,ExpandButton:ku,CloseButton:uu}}),Gu=()=>{const{isActionbookTester:e}=He(),{Template:t}=Re.useContext();return e?null:o.createElement(t,{titleAlign:"start"})},Wu=f.default.div`display:flex;gap:10px;align-items:center;justify-content:center;`,ln=u.createContext({onDrop:fe,subscribe:()=>fe}),zt=({children:e})=>{const t=u.useRef(new Set);return o.createElement(ln.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)},qu=({onDropFiles:e})=>{const{subscribe:t}=u.useContext(ln);u.useEffect(()=>t(e),[e])};zt.Consumer=({children:e})=>{const{onDrop:t}=u.useContext(ln);return e({onDrop:t,onDragOver:s=>s.preventDefault()})};const cn=({iconSize:e=64,icon:t,className:n,label:r,children:s})=>o.createElement(Ku,{className:n},t&&o.createElement(P,{type:t,size:e,color:g.themedColor.textLowEmphasis}),r&&o.createElement(k,{variant:"body1",color:g.themedColor.textMidEmphasis},r),s),ju=f.default.div`position:relative;display:flex;justify-content:center;align-items:center;width:100%;height:100%;`,Ku=f.default.div`display:flex;flex-direction:column;min-height:104px;align-items:center;gap:20px;text-align:center;`,Yu=({label:e="Something went wrong",icon:t="error",action:n,...r})=>o.createElement(cn,{icon:t,label:e,...r},n&&o.createElement(Zu,{onClick:n.onClick,label:n.label??"Retry"})),Zu=({label:e,onClick:t})=>o.createElement(Xu,{tabIndex:0,onClick:t},o.createElement(P,{type:"refresh",size:20}),o.createElement(k,{variant:"button",color:g.color.primary.main},e)),Xu=f.default.button`all:unset;display:flex;cursor:pointer;gap:4px;align-items:center;justify-content:center;`,Ju=({iconSize:e=48,className:t})=>o.createElement(on,{size:e,className:t}),Qu=({label:e="No channels",icon:t="chat",...n})=>o.createElement(cn,{icon:t,label:e,...n}),ed=({label:e="No messages",icon:t="message",...n})=>o.createElement(cn,{icon:t,label:e,...n}),td=e=>{const{components:t}=Ct.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(ju,null,n)},Ct=pe({template:td,components:{Loading:Ju,Error:Yu,NoChannels:Qu,NoMessages:ed}}),Fe=e=>{const{Template:t}=Ct.useContext();return o.createElement(t,{...e})},Wn=e=>er(e)||tr(e);function nd(e){return e.isAdminMessage()?e.message==="The channel's custom_type was updated.":!1}function rd(e,t){return e.filter(n=>Se.isWelcomeMessage(n,t))}const od=f.default.div`width:${({$size:e})=>e}px;height:${({$size:e})=>e}px;border-radius:50%;display:flex;align-items:center;justify-content:center;background-color:${({theme:e})=>e.colors.base.primary}!important;ellipse,path{fill:${({theme:e})=>e.colors.base.primaryContrastContent}!important;}`,sd=f.default.div`position:fixed;inset:0;outline:none;display:flex;flex-direction:column;`,ad=f.default.div`display:flex;gap:10px;align-items:center;`,id=f.default.div`flex:1;min-height:0;display:flex;align-items:center;justify-content:center;`,ld=f.default.video`max-width:100%;max-height:100%;user-select:none;-webkit-user-drag:none;`,cd=f.default.img`max-width:100%;max-height:100%;padding:40px;box-sizing:border-box;object-fit:contain;user-select:none;-webkit-user-drag:none;`,ud=f.default.div`max-width:100%;max-height:100%;display:flex;justify-content:center;align-items:center;`,dd=({file:e,sender:t={},onClose:n})=>{const{type:r,url:s,name:a=""}=e,{profileUrl:i,userId:l}=t,{aiAgentInfo:c}=J();return o.createElement(md,{profileUrl:i??"",type:r,url:s,name:a,onClose:n,isBotMessage:l===c.userId})},md=({profileUrl:e,isBotMessage:t,name:n,type:r,url:s,onClose:a})=>{var d,h;const{stringSet:i}=F(),l=ze(),{config:c}=W();return o.createElement(Et,{onClose:a,visible:!0,rootElementId:se.MODAL_ROOT},o.createElement(sd,null,o.createElement(sn,{start:o.createElement(gd,{profileUrl:e,isBotMessage:t}),title:o.createElement(k,{variant:"h2",color:g.themedColor.textHighEmphasis,maxTextLines:1},n),end:o.createElement(ad,null,Wn(r)&&((h=(d=c==null?void 0:c.conversation)==null?void 0:d.fileViewer)==null?void 0:h.downloadEnabled)&&o.createElement(ke,{as:"a",href:s,download:n,"aria-label":"download file",type:"download",size:l}),o.createElement(ke,{"aria-label":"close file viewer",type:"close",size:l,onClick:a}))}),o.createElement(id,{onClick:b=>b.currentTarget===b.target&&a()},tr(r)&&o.createElement(ld,{controls:!0},o.createElement("source",{src:s,type:r})),er(r)&&o.createElement(cd,{src:s,alt:n}),!Wn(r)&&o.createElement(ud,null,o.createElement(k,{variant:"h1",color:g.themedColor.textHighEmphasis},i.FILE_VIEWER__UNSUPPORT)))))},gd=({profileUrl:e,isBotMessage:t})=>t&&!e?o.createElement(od,{$size:32},o.createElement(P,{type:"delight",size:20})):o.createElement(en,{size:32,src:e}),Rr=({className:e,locale:t,date:n=Date.now(),formatString:r="MMMM dd, yyyy",style:s})=>o.createElement(hd,{id:`${oe}-date-separator`,style:s,className:e},o.createElement(k,{variant:"caption4",color:g.themedColor.textMidEmphasis},ye.format(n,r,{locale:t}))),hd=f.default.div`display:flex;justify-content:center;align-items:center;text-align:center;word-break:break-word;`,fd=u.forwardRef(function(t,n){const{messages:r,renderMessage:s,messageTopArea:a,messageBottomArea:i,overlayArea:l,onLoadPrev:c,onLoadNext:d,loadThreshold:h=.05,onScroll:b=fe,depsForResetScrollPositionToBottom:E,stackDirection:C="top",bottomSpacerHeight:y=0,ariaLabel:x}=t,m=u.useRef(null),p=u.useCallback($=>{m.current=$,n&&(typeof n=="function"?n($):n.current=$)},[n]),v=u.useRef(!1),_=u.useRef(void 0),I=u.useRef(0),T=u.useRef(0);u.useLayoutEffect(()=>{m.current&&(m.current.scrollTop=m.current.scrollHeight)},E),u.useLayoutEffect(()=>{m.current&&(_.current==="top"&&(m.current.scrollTop=m.current.scrollHeight-T.current),_.current==="bottom"&&(m.current.scrollTop=I.current),_.current=void 0)},[m.current,r.length]);const L=async $=>{if(b==null||b($),!m.current)return;const M=m.current;if(T.current=M.scrollHeight-M.scrollTop,I.current=M.scrollTop,v.current)return;const R=M.clientHeight*Math.min(Math.max(0,h),1);M.scrollTop<=R?(v.current=!0,_.current="top",await c(),v.current=!1):M.scrollHeight-M.scrollTop-M.clientHeight<=R?(v.current=!0,_.current="bottom",await d(),v.current=!1):_.current=void 0};return o.createElement(pd,{id:"infinite-list-container"},o.createElement(bd,{id:"infinite-list-inner",ref:p,onScroll:L,role:"list","aria-label":x},C==="bottom"&&o.createElement("div",{style:{flexGrow:1}}),a,r.map(($,M)=>s({message:$,index:M})),i,y>0&&o.createElement("div",{style:{minHeight:y}})),o.createElement(Ed,{id:"infinite-list-overlay-container"},o.createElement(xd,{id:"infinite-list-overlay"},l)))}),pd=f.default.div`display:flex;position:relative;flex:1;overflow:hidden;`,bd=f.default.div`display:flex;flex:1;flex-direction:column;overflow-y:auto;overscroll-behavior:contain;scrollbar-color:${g.themedColor.textLowEmphasis}transparent;&::-webkit-scrollbar-thumb:hover{background-color:transparent;}`,Ed=f.default.div`position:absolute;top:0;bottom:0;left:0;right:0;pointer-events:none;`,xd=f.default.div`pointer-events:auto;`,vd=({className:e,label:t,ariaLabel:n,onClick:r})=>{const{colors:s}=S.useTheme();return o.createElement(Cd,{className:e,onClick:r,"aria-label":n},o.createElement(k,{variant:"button",color:s.base.primaryContrastContent},t),o.createElement(P,{size:16,type:"chevron-down",color:s.base.primaryContrastContent}))},Cd=f.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;}`,yd=({className:e,onClick:t,ariaLabel:n})=>o.createElement(_d,{className:e,onClick:t,tabIndex:0,"aria-label":n},o.createElement(P,{size:24,type:"chevron-down",color:g.color.primary.main})),_d=f.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);${D.light`
|
|
231
231
|
background-color: ${g.color.background50};
|
|
232
232
|
&:hover {
|
|
233
233
|
background-color: ${g.color.background100};
|
|
@@ -249,11 +249,11 @@
|
|
|
249
249
|
&:focus {
|
|
250
250
|
outline: none;
|
|
251
251
|
}
|
|
252
|
-
`,Sd=()=>{const{agentPreviewConfigs:e={},aiAgentId:t}=W(),{aiAgentInfo:n}=
|
|
252
|
+
`,Sd=()=>{const{agentPreviewConfigs:e={},aiAgentId:t}=W(),{aiAgentInfo:n}=J(),{stringSet:r,dateLocale:s}=F(),{messageSource:a}=Q(),{Template:i}=Le.useContext(),l=e.welcomeMessages??[],c=a.messages,d=rd(c,t),h=c[d.length+1],b=d[0]??h;return{filteredMessages:c.filter(E=>nd(E)?!1:l.length>0?!Se.isWelcomeMessage(E,t):!0),shouldShowOriginalDate:E=>E>0||l.length===0?!0:h&&!ye.isSameDay(h.createdAt,(b==null?void 0:b.createdAt)??0),renderAgentPreviewWelcomeMessages:()=>l.length===0?null:o.createElement(o.Fragment,null,o.createElement(Rr,{style:{margin:"16px 0"},date:b==null?void 0:b.createdAt,locale:s,formatString:r.DATE_FORMAT__MESSAGE_LIST__DATE_SEPARATOR}),l.map((E,C)=>{const y=C===l.length-1,x=d.length!==c.length,m=l.length===1?"single":C===0?"top":y||x?"bottom":"middle";return o.createElement(i,{messageType:"user",message:E.message,sender:n,groupType:m,createdAt:(b==null?void 0:b.createdAt)??Date.now(),extendedMessagePayload:{suggested_replies:E.suggestedReplies},suggestedRepliesDirection:e.suggestedRepliesDirection,suggestedRepliesVisible:y&&!x,isBotMessage:!0,onClickSuggestedReply:async({reply:p})=>{a.sendUserMessage({message:p})}})}))}},Td=e=>f.default(e).withConfig({shouldForwardProp:fo.default}),Ad=({style:e})=>{const{stringSet:t}=F(),{isActionbookTester:n}=He();return!Xt("powered-by")||n?null:o.createElement(wd,{variant:"caption2",style:e},t.POWERED_BY+" ",o.createElement(kd,{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:Qt,target:"_blank"},"Sendbird"))},wd=f.default(k)`color:${g.themedColor.textLowEmphasis};text-align:center;`,kd=Td(k)`
|
|
253
253
|
color: ${g.themedColor.textLowEmphasis};
|
|
254
254
|
cursor: pointer;
|
|
255
255
|
text-decoration: none;
|
|
256
|
-
`,Id=()=>{var i;const{stringSet:e}=F(),{channelSource:t,goToActiveConversation:n,scrollSource:r}=ee(),s=Ae(t.channel),a=u.useRef(s);return u.useEffect(()=>{if(!a.current&&s){const d=setTimeout(()=>{r.actions.scrollToBottom()},100);return()=>clearTimeout(d)}a.current=s},[s,r.actions.scrollToBottom]),!((i=t.channel)!=null&&i.isAIAgent)||!s?null:o.createElement($d,null,o.createElement(Md,{variant:"button",role:"button",color:g.themedColor.textHighEmphasis,onClick:()=>n()},e.TALK_TO_AGENT))},$d=f.default.div`display:flex;justify-content:center;margin-bottom:16px;`,Md=f.default(k)`border-radius:6px;box-sizing:border-box;padding:10px 20px;border:1px solid ${g.themedColor.textDisabled};cursor:pointer;user-select:none;`,Ld=()=>{const{Template:e}=xt.useContext(),{Template:t}=Le.useContext(),{Template:n}=vt.useContext(),[r,s]=u.useState(null),[a,i]=u.useState(null),{userSession:l,aiAgentInfo:c}=Q(),{cache:d,agentPreviewConfigs:h,chatSDK:p,state:E}=W(),{config:y}=K(),{stringSet:C,dateLocale:x}=F(),{conversation:m,channelSource:b,messageSource:v,scrollSource:_,state:{input:I,streamAnimation:T}}=ee(),{isActionbookTester:L}=He(),{filteredMessages:$,shouldShowOriginalDate:M,renderAgentPreviewWelcomeMessages:R}=Sd(),H=dr(b.channel),G=(()=>{const j=H[0];if(!j)return null;const ne=j.userId===c.userId;return{user:ne?c:j,isBot:ne}})();u.useEffect(()=>{_.actions.onTypingIndicatorUpdate(!!G)},[!!G,_.actions.onTypingIndicatorUpdate]),u.useEffect(()=>{_.state.isAwayFromBottom||v.resetNewMessages()},[_.state.isAwayFromBottom]);const Ee=(j,ne=!1)=>{var ve;return ne?c:((ve=b.channel)==null?void 0:ve.members.find(w=>w.userId===j.sender.userId))??j.sender},xe=j=>{if(j.sendingStatus==="failed"&&!I.disabled)return()=>i(j)},$e=()=>{var j,ne,ve;if(!v.initialized)return o.createElement(Fe,{type:"loading"});if(v.messages.length===0){const w=R();return w?o.createElement("div",{style:{width:"100%"}},w):o.createElement(Fe,{type:"noMessages",label:C.PLACE_HOLDER__NO_MESSAGES})}return o.createElement(fd,{ref:_.ref,onScroll:_.props.onScroll,stackDirection:h==null?void 0:h.messageStackDirection,messages:$,onLoadPrev:v.loadPrevious,onLoadNext:v.loadNext,depsForResetScrollPositionToBottom:[v.initialized,v.messages.length!==0],bottomSpacerHeight:_.state.bottomSpace,ariaLabel:C.A11Y_MESSAGE_LIST,messageTopArea:o.createElement(o.Fragment,null,o.createElement(Ad,{style:{marginTop:16}}),R()),messageBottomArea:o.createElement(o.Fragment,null,G&&o.createElement("div",{id:`${oe}-message-item`,role:"listitem"},o.createElement(t,{isTyping:!0,isBotMessage:G.isBot,sender:G.user,messageType:"user",groupType:"single",message:"",isSenderAvatarVisible:(j=y==null?void 0:y.conversation)==null?void 0:j.senderAvatarEnabled})),((ne=y==null?void 0:y.conversation)==null?void 0:ne.isTalkToAgentViewEnabled)&&o.createElement(Id,null)),overlayArea:o.createElement(o.Fragment,null,((ve=y==null?void 0:y.conversation)==null?void 0:ve.newMessageIndicatorEnabled)&&_.state.isAwayFromBottom&&v.newMessages.length>0&&o.createElement(Dd,{label:C.SCROLL_TO_NEW_MESSAGES_LABEL(v.newMessages),ariaLabel:C.A11Y_SCROLL_TO_NEW_MESSAGES,onClick:()=>_.actions.scrollToBottom()}),_.state.isAwayFromBottom&&v.newMessages.length===0&&!G&&o.createElement(Rd,{ariaLabel:C.A11Y_SCROLL_TO_BOTTOM,onClick:()=>_.actions.scrollToBottom()})),renderMessage:({message:w,index:N})=>{const A=_o(w),O=$[N-1],z=$[N+1],ue=$[$.length-1],re=w===ue,te=je(w,c.userId),de=!(c.isUserFeedbackEnabled&&te&&!Te.isWelcomeMessage(w)),ae=So(w,O,z,de),ie=!uo.isSameDay((O==null?void 0:O.createdAt)??0,w.createdAt)&&M(N)&&!L,Ge=Je=>{(w.isFileMessage()||w.isUserMessage())&&s({file:Je,sender:Ee(w,w.sender.userId===c.userId)})},St=()=>{w.isFileMessage()&&tn(w.url)},to=ie?o.createElement(Rr,{style:{margin:"16px 0"},date:w.createdAt,locale:x,formatString:C.DATE_FORMAT__MESSAGE_LIST__DATE_SEPARATOR}):null,Xe={data:w.data,maxBodyWidth:E.expanded?B.WIDE_BODY_MAX_WIDTH:void 0,extendedMessagePayload:w.extendedMessagePayload,createdAt:w.createdAt,groupType:ae,onClickMedia:Ge,onClickFile:St},no=()=>{if(De.isOutgoing(w,l.userId))return"outgoingmessage";if(De.isIncoming(w,l.userId))return"incomingmessage"},ro=(()=>{var Je,pn,bn;if(De.isAdmin(w))return De.isCSAT(w)?m?o.createElement(n,{...Xe,...m,isResolvedWhenDeterminedByUser:bo(m),messageType:"admin.csat",onSubmitCSAT:async({csat:Ce,...V})=>{var Z;Ce&&await((Z=b.channel)==null?void 0:Z.submitCSAT({csat:Ce,...V}))}}):null:o.createElement(n,{...Xe,messageType:"admin",message:w.message});if(De.isOutgoing(w,l.userId)){const Ce={...Xe,message:w.message,sender:Ee(w),sendingStatus:w.sendingStatus,onClickFailedMessage:xe(w)};if(w.isUserMessage())return o.createElement(e,{messageType:"user",...Ce});if(w.isFileMessage()){const[V,Z]=((Je=w.metaArrays.find(me=>me.key===Qn))==null?void 0:Je.value)??[];return o.createElement(e,{messageType:"file",file:w,metadata:{aspectRatio:V&&Z?`${V}/${Z}`:"1/1",localFile:(pn=w.messageParams)==null?void 0:pn.file},...Ce})}}if(De.isIncoming(w,l.userId)){const Ce={...Xe,sender:Ee(w,te),message:w.message,suggestedRepliesVisible:re,suggestedRepliesDirection:h==null?void 0:h.suggestedRepliesDirection,isBotMessage:te,isStreaming:Te.isStreaming(w),isHandedOff:Be(b.channel),isConversationClosed:Ae(b.channel),isFeedbackEnabled:c.isUserFeedbackEnabled,isFeedbackCommentEnabled:c.isUserFeedbackCommentOptionEnabled,isSenderAvatarVisible:(bn=y==null?void 0:y.conversation)==null?void 0:bn.senderAvatarEnabled,onClickSuggestedReply:async({reply:V})=>{v.sendUserMessage({message:V})},onRequestMessageTemplate:async V=>{const{template:Z}=await p.aiAgent.getMessageTemplate(V);return d.template.set(V,Z),Z},onGetCachedMessageTemplate:V=>d.template.get(V),onHandleTemplateInternalAction:V=>{if(V.type==="internal"&&V.internalData){const{method:Z,payload:me}=V.internalData;Z==="message.send"&&(me!=null&&me.message)&&v.sendUserMessage({message:me.message})}},onFeedbackUpdate:V=>{const Z={messageId:w.messageId,channelUrl:w.channelUrl};if(!V)return p.aiAgent.deleteMessageFeedback(Z);const me={...Z,rating:Ii(V.rating),comment:V.comment};return Te.hasFeedback(w)?p.aiAgent.updateMessageFeedback(me):p.aiAgent.createMessageFeedback(me)},onSubmitForm:({key:V,data:Z})=>p.aiAgent.submitForm({messageId:w.messageId,channelUrl:w.channelUrl,formKey:V,formData:Z}),onCancelForm:({key:V})=>p.aiAgent.cancelForm({messageId:w.messageId,channelUrl:w.channelUrl,formKey:V}),onStreamAnimationStart:()=>{T.start(w.messageId)},onStreamAnimationProgress:()=>{_.actions.onStreamingUpdate(!0)},onStreamAnimationComplete:()=>{T.stop(w.messageId),_.actions.onStreamingUpdate(!1)}};if(w.isUserMessage())return o.createElement(t,{messageType:"user",...Ce});if(w.isFileMessage())return o.createElement(t,{messageType:"file",file:w,...Ce})}})();return o.createElement("div",{key:A,id:`${oe}-message-item`,role:"listitem","data-layout-id":no()},to,ro)}})};return o.createElement(Od,{id:`${oe}-message-list`},$e(),r&&o.createElement(dd,{onClose:()=>s(null),sender:r.sender,file:r.file}),a&&o.createElement(Pe,{visible:!0,onClose:()=>i(null)},o.createElement(Pe.ActionItem,{onClick:()=>{v.resendMessage(a),i(null)}},C.FAILED_MESSAGE_RESEND),o.createElement(Pe.ActionItem,{destructive:!0,onClick:()=>{v.deleteMessage(a),i(null)}},C.FAILED_MESSAGE_REMOVE)))},Od=f.default.div`overflow-y:hidden;display:flex;flex:1;position:relative;`,Rd=f.default(yd)`position:absolute;bottom:12px;inset-inline-end:16px;`,Dd=f.default(vd)`position:absolute;bottom:12px;left:50%;transform:translateX(-50%);`,Nd=()=>{const{stringSet:e}=F(),{connectionError:t}=Q(),{channelSource:n}=ee(),r=t||n.error;if(r){const s=t?void 0:{label:e.RETRY,onClick:()=>n.refetch()};return o.createElement(Fe,{type:"error",label:r.message,action:s})}return n.channel?o.createElement(Ld,null):o.createElement(Fe,{type:"loading"})},Pd=()=>{var s;const{origin:e}=He(),{appId:t,aiAgentId:n}=K(),{channelSource:r}=ee();return(s=r.channel)!=null&&s.conversation?o.createElement(Bd,null,o.createElement(Vt,{style:{gap:4}},o.createElement(P,{color:g.themedColor.textLowEmphasis,size:12,type:"show"}),o.createElement(k,{as:"i",color:g.themedColor.textLowEmphasis,variant:"caption2"},"Only visible in the tester")),o.createElement(Vt,{role:"button",style:{gap:4},onClick:()=>{var c,d;const a=e??window.location.origin,i=(d=(c=r.channel)==null?void 0:c.conversation)==null?void 0:d.id,l=`${a}/ai-agent/${t}/${n}/evaluate/conversations/${i}`;navigator.clipboard.writeText(l)}},o.createElement(k,{variant:"body3",color:g.themedColor.textHighEmphasis},"Copy ",o.createElement("span",{style:{color:g.themedColor.primary}},"conversation link")),o.createElement(P,{color:g.themedColor.primary,size:14,type:"copy"}))):null},Vt=f.default.div`display:flex;justify-content:center;align-items:center;`,Bd=f.default(Vt)`flex-direction:column;padding-block:16px;background-color:${g.themedColor.bg_100_500};gap:8px;`,Dr=u.createContext(void 0),Fd=({children:e})=>{var x;const{chatSDK:t}=W(),{createAttachmentRules:n}=Q(),{stringSet:r}=F(),{channelSource:s}=ee(),[a,i]=u.useState([]),[l,c]=u.useState({visible:!1,title:""}),d=n({channel:s.channel,uploadSizeLimit:(x=t.appInfo)==null?void 0:x.uploadSizeLimit}),h=d.isEnabled(),p=m=>{const b=d.getUploadSizeLimit(m.type);return m.size>b},E=m=>{if(!h)return;const b=m.filter(I=>d.isSupportedMimeType(I.type));if(b.length===0)return;const v=b.find(I=>p(I));if(v){const I=d.getUploadSizeLimitInMB(v.type);c({visible:!0,title:r.FILE_UPLOAD_NOTIFICATION__SIZE_LIMIT.replace("%d",I.toString())});return}if(a.length+b.length>d.maxAttachmentCount){c({visible:!0,title:r.FILE_UPLOAD_NOTIFICATION__COUNT_LIMIT});return}i(I=>[...I,...b.map(T=>({file:T,preview:{url:URL.createObjectURL(T),type:T.type,name:T.name}}))])},y=m=>{i(b=>{var _;const v=(_=b[m])==null?void 0:_.preview;return v&&URL.revokeObjectURL(v.url),b.filter((I,T)=>T!==m)})},C=()=>{i(m=>(m.forEach(b=>URL.revokeObjectURL(b.preview.url)),[]))};return o.createElement(Dr.Provider,{value:{files:a,addFiles:E,removeFile:y,clearFiles:C,isFileUploadEnabled:h,acceptableMimeTypes:d.supportedMimeTypes}},e,o.createElement(nn,{...l,onClose:()=>c({visible:!1,title:""})}))},un=()=>{const e=u.useContext(Dr);if(!e)throw new Error("useFileUpload must be used within FileUploadProvider");return e};function Ud({blurred:e,elementRef:t,document:n=window.document}){const r=u.useRef(!1);e&&t.current&&n.activeElement===t.current&&(r.current=!0),u.useLayoutEffect(()=>{var s;!e&&r.current&&((s=t.current)==null||s.focus(),r.current=!1)},[e])}const Hd=(e,t)=>{u.useEffect(()=>{t?e==null||e.startTyping():e==null||e.endTyping()},[e,t])},zd=f.default.div`&::-webkit-scrollbar{display:none;}overflow-x:auto;display:flex;flex-direction:row;gap:10px;padding:8px 16px;background-color:transparent;`,Vd=f.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;}`,Gd=f.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%;${D.light`
|
|
256
|
+
`,Id=()=>{var i;const{stringSet:e}=F(),{channelSource:t,goToActiveConversation:n,scrollSource:r}=Q(),s=Te(t.channel),a=u.useRef(s);return u.useEffect(()=>{if(!a.current&&s){const d=setTimeout(()=>{r.actions.scrollToBottom()},100);return()=>clearTimeout(d)}a.current=s},[s,r.actions.scrollToBottom]),!((i=t.channel)!=null&&i.isAIAgent)||!s?null:o.createElement($d,null,o.createElement(Md,{variant:"button",role:"button",color:g.themedColor.textHighEmphasis,onClick:()=>n()},e.TALK_TO_AGENT))},$d=f.default.div`display:flex;justify-content:center;margin-bottom:16px;`,Md=f.default(k)`border-radius:6px;box-sizing:border-box;padding:10px 20px;border:1px solid ${g.themedColor.textDisabled};cursor:pointer;user-select:none;`,Ld=()=>{const{Template:e}=xt.useContext(),{Template:t}=Le.useContext(),{Template:n}=vt.useContext(),[r,s]=u.useState(null),[a,i]=u.useState(null),{userSession:l,aiAgentInfo:c}=J(),{cache:d,agentPreviewConfigs:h,chatSDK:b,state:E}=W(),{config:C}=K(),{stringSet:y,dateLocale:x}=F(),{conversation:m,channelSource:p,messageSource:v,scrollSource:_,state:{input:I,streamAnimation:T}}=Q(),{isActionbookTester:L}=He(),{filteredMessages:$,shouldShowOriginalDate:M,renderAgentPreviewWelcomeMessages:R}=Sd(),z=dr(p.channel),G=(()=>{const j=z[0];if(!j)return null;const ne=j.userId===c.userId;return{user:ne?c:j,isBot:ne}})();u.useEffect(()=>{_.actions.onTypingIndicatorUpdate(!!G)},[!!G,_.actions.onTypingIndicatorUpdate]),u.useEffect(()=>{_.state.isAwayFromBottom||v.resetNewMessages()},[_.state.isAwayFromBottom]);const Ee=(j,ne=!1)=>{var ve;return ne?c:((ve=p.channel)==null?void 0:ve.members.find(w=>w.userId===j.sender.userId))??j.sender},xe=j=>{if(j.sendingStatus==="failed"&&!I.disabled)return()=>i(j)},Ie=()=>{var j,ne,ve;if(!v.initialized)return o.createElement(Fe,{type:"loading"});if(v.messages.length===0){const w=R();return w?o.createElement("div",{style:{width:"100%"}},w):o.createElement(Fe,{type:"noMessages",label:y.PLACE_HOLDER__NO_MESSAGES})}return o.createElement(fd,{ref:_.ref,onScroll:_.props.onScroll,stackDirection:h==null?void 0:h.messageStackDirection,messages:$,onLoadPrev:v.loadPrevious,onLoadNext:v.loadNext,depsForResetScrollPositionToBottom:[v.initialized,v.messages.length!==0],bottomSpacerHeight:_.state.bottomSpace,ariaLabel:y.A11Y_MESSAGE_LIST,messageTopArea:o.createElement(o.Fragment,null,o.createElement(Ad,{style:{marginTop:16}}),R()),messageBottomArea:o.createElement(o.Fragment,null,G&&o.createElement("div",{id:`${oe}-message-item`,role:"listitem"},o.createElement(t,{isTyping:!0,isBotMessage:G.isBot,sender:G.user,messageType:"user",groupType:"single",message:"",isSenderAvatarVisible:(j=C==null?void 0:C.conversation)==null?void 0:j.senderAvatarEnabled})),((ne=C==null?void 0:C.conversation)==null?void 0:ne.isTalkToAgentViewEnabled)&&o.createElement(Id,null)),overlayArea:o.createElement(o.Fragment,null,((ve=C==null?void 0:C.conversation)==null?void 0:ve.newMessageIndicatorEnabled)&&_.state.isAwayFromBottom&&v.newMessages.length>0&&o.createElement(Dd,{label:y.SCROLL_TO_NEW_MESSAGES_LABEL(v.newMessages),ariaLabel:y.A11Y_SCROLL_TO_NEW_MESSAGES,onClick:()=>_.actions.scrollToBottom()}),_.state.isAwayFromBottom&&v.newMessages.length===0&&!G&&o.createElement(Rd,{ariaLabel:y.A11Y_SCROLL_TO_BOTTOM,onClick:()=>_.actions.scrollToBottom()})),renderMessage:({message:w,index:N})=>{const A=_o(w),O=$[N-1],V=$[N+1],ue=$[$.length-1],re=w===ue,ee=je(w,c.userId),de=!(c.isUserFeedbackEnabled&&ee&&!Se.isWelcomeMessage(w)),ae=So(w,O,V,de),ie=!uo.isSameDay((O==null?void 0:O.createdAt)??0,w.createdAt)&&M(N)&&!L,Ge=Je=>{(w.isFileMessage()||w.isUserMessage())&&s({file:Je,sender:Ee(w,w.sender.userId===c.userId)})},St=()=>{w.isFileMessage()&&tn(w.url)},to=ie?o.createElement(Rr,{style:{margin:"16px 0"},date:w.createdAt,locale:x,formatString:y.DATE_FORMAT__MESSAGE_LIST__DATE_SEPARATOR}):null,Xe={data:w.data,maxBodyWidth:E.expanded?B.WIDE_BODY_MAX_WIDTH:void 0,extendedMessagePayload:w.extendedMessagePayload,createdAt:w.createdAt,groupType:ae,onClickMedia:Ge,onClickFile:St},no=()=>{if(De.isOutgoing(w,l.userId))return"outgoingmessage";if(De.isIncoming(w,l.userId))return"incomingmessage"},ro=(()=>{var Je,pn,bn;if(De.isAdmin(w))return De.isCSAT(w)?m?o.createElement(n,{...Xe,...m,isResolvedWhenDeterminedByUser:bo(m),messageType:"admin.csat",onSubmitCSAT:async $e=>{var H;await((H=p.channel)==null?void 0:H.submitCSAT($e))}}):null:o.createElement(n,{...Xe,messageType:"admin",message:w.message});if(De.isOutgoing(w,l.userId)){const $e={...Xe,message:w.message,sender:Ee(w),sendingStatus:w.sendingStatus,onClickFailedMessage:xe(w)};if(w.isUserMessage())return o.createElement(e,{messageType:"user",...$e});if(w.isFileMessage()){const[H,te]=((Je=w.metaArrays.find(me=>me.key===Qn))==null?void 0:Je.value)??[];return o.createElement(e,{messageType:"file",file:w,metadata:{aspectRatio:H&&te?`${H}/${te}`:"1/1",localFile:(pn=w.messageParams)==null?void 0:pn.file},...$e})}}if(De.isIncoming(w,l.userId)){const $e={...Xe,sender:Ee(w,ee),message:w.message,suggestedRepliesVisible:re,suggestedRepliesDirection:h==null?void 0:h.suggestedRepliesDirection,isBotMessage:ee,isStreaming:Se.isStreaming(w),isHandedOff:Be(p.channel),isConversationClosed:Te(p.channel),isFeedbackEnabled:c.isUserFeedbackEnabled,isFeedbackCommentEnabled:c.isUserFeedbackCommentOptionEnabled,isSenderAvatarVisible:(bn=C==null?void 0:C.conversation)==null?void 0:bn.senderAvatarEnabled,onClickSuggestedReply:async({reply:H})=>{v.sendUserMessage({message:H})},onRequestMessageTemplate:async H=>{const{template:te}=await b.aiAgent.getMessageTemplate(H);return d.template.set(H,te),te},onGetCachedMessageTemplate:H=>d.template.get(H),onHandleTemplateInternalAction:H=>{if(H.type==="internal"&&H.internalData){const{method:te,payload:me}=H.internalData;te==="message.send"&&(me!=null&&me.message)&&v.sendUserMessage({message:me.message})}},onFeedbackUpdate:H=>{const te={messageId:w.messageId,channelUrl:w.channelUrl};if(!H)return b.aiAgent.deleteMessageFeedback(te);const me={...te,rating:Ii(H.rating),comment:H.comment};return Se.hasFeedback(w)?b.aiAgent.updateMessageFeedback(me):b.aiAgent.createMessageFeedback(me)},onSubmitForm:({key:H,data:te})=>b.aiAgent.submitForm({messageId:w.messageId,channelUrl:w.channelUrl,formKey:H,formData:te}),onCancelForm:({key:H})=>b.aiAgent.cancelForm({messageId:w.messageId,channelUrl:w.channelUrl,formKey:H}),onStreamAnimationStart:()=>{T.start(w.messageId)},onStreamAnimationProgress:()=>{_.actions.onStreamingUpdate(!0)},onStreamAnimationComplete:()=>{T.stop(w.messageId),_.actions.onStreamingUpdate(!1)}};if(w.isUserMessage())return o.createElement(t,{messageType:"user",...$e});if(w.isFileMessage())return o.createElement(t,{messageType:"file",file:w,...$e})}})();return o.createElement("div",{key:A,id:`${oe}-message-item`,role:"listitem","data-layout-id":no()},to,ro)}})};return o.createElement(Od,{id:`${oe}-message-list`},Ie(),r&&o.createElement(dd,{onClose:()=>s(null),sender:r.sender,file:r.file}),a&&o.createElement(Pe,{visible:!0,onClose:()=>i(null)},o.createElement(Pe.ActionItem,{onClick:()=>{v.resendMessage(a),i(null)}},y.FAILED_MESSAGE_RESEND),o.createElement(Pe.ActionItem,{destructive:!0,onClick:()=>{v.deleteMessage(a),i(null)}},y.FAILED_MESSAGE_REMOVE)))},Od=f.default.div`overflow-y:hidden;display:flex;flex:1;position:relative;`,Rd=f.default(yd)`position:absolute;bottom:12px;inset-inline-end:16px;`,Dd=f.default(vd)`position:absolute;bottom:12px;left:50%;transform:translateX(-50%);`,Nd=()=>{const{stringSet:e}=F(),{connectionError:t}=J(),{channelSource:n}=Q(),r=t||n.error;if(r){const s=t?void 0:{label:e.RETRY,onClick:()=>n.refetch()};return o.createElement(Fe,{type:"error",label:r.message,action:s})}return n.channel?o.createElement(Ld,null):o.createElement(Fe,{type:"loading"})},Pd=()=>{var s;const{origin:e}=He(),{appId:t,aiAgentId:n}=K(),{channelSource:r}=Q();return(s=r.channel)!=null&&s.conversation?o.createElement(Bd,null,o.createElement(Vt,{style:{gap:4}},o.createElement(P,{color:g.themedColor.textLowEmphasis,size:12,type:"show"}),o.createElement(k,{as:"i",color:g.themedColor.textLowEmphasis,variant:"caption2"},"Only visible in the tester")),o.createElement(Vt,{role:"button",style:{gap:4},onClick:()=>{var c,d;const a=e??window.location.origin,i=(d=(c=r.channel)==null?void 0:c.conversation)==null?void 0:d.id,l=`${a}/ai-agent/${t}/${n}/evaluate/conversations/${i}`;navigator.clipboard.writeText(l)}},o.createElement(k,{variant:"body3",color:g.themedColor.textHighEmphasis},"Copy ",o.createElement("span",{style:{color:g.themedColor.primary}},"conversation link")),o.createElement(P,{color:g.themedColor.primary,size:14,type:"copy"}))):null},Vt=f.default.div`display:flex;justify-content:center;align-items:center;`,Bd=f.default(Vt)`flex-direction:column;padding-block:16px;background-color:${g.themedColor.bg_100_500};gap:8px;`,Dr=u.createContext(void 0),Fd=({children:e})=>{var x;const{chatSDK:t}=W(),{createAttachmentRules:n}=J(),{stringSet:r}=F(),{channelSource:s}=Q(),[a,i]=u.useState([]),[l,c]=u.useState({visible:!1,title:""}),d=n({channel:s.channel,uploadSizeLimit:(x=t.appInfo)==null?void 0:x.uploadSizeLimit}),h=d.isEnabled(),b=m=>{const p=d.getUploadSizeLimit(m.type);return m.size>p},E=m=>{if(!h)return;const p=m.filter(I=>d.isSupportedMimeType(I.type));if(p.length===0)return;const v=p.find(I=>b(I));if(v){const I=d.getUploadSizeLimitInMB(v.type);c({visible:!0,title:r.FILE_UPLOAD_NOTIFICATION__SIZE_LIMIT.replace("%d",I.toString())});return}if(a.length+p.length>d.maxAttachmentCount){c({visible:!0,title:r.FILE_UPLOAD_NOTIFICATION__COUNT_LIMIT});return}i(I=>[...I,...p.map(T=>({file:T,preview:{url:URL.createObjectURL(T),type:T.type,name:T.name}}))])},C=m=>{i(p=>{var _;const v=(_=p[m])==null?void 0:_.preview;return v&&URL.revokeObjectURL(v.url),p.filter((I,T)=>T!==m)})},y=()=>{i(m=>(m.forEach(p=>URL.revokeObjectURL(p.preview.url)),[]))};return o.createElement(Dr.Provider,{value:{files:a,addFiles:E,removeFile:C,clearFiles:y,isFileUploadEnabled:h,acceptableMimeTypes:d.supportedMimeTypes}},e,o.createElement(nn,{...l,onClose:()=>c({visible:!1,title:""})}))},un=()=>{const e=u.useContext(Dr);if(!e)throw new Error("useFileUpload must be used within FileUploadProvider");return e};function Ud({blurred:e,elementRef:t,document:n=window.document}){const r=u.useRef(!1);e&&t.current&&n.activeElement===t.current&&(r.current=!0),u.useLayoutEffect(()=>{var s;!e&&r.current&&((s=t.current)==null||s.focus(),r.current=!1)},[e])}const Hd=(e,t)=>{u.useEffect(()=>{t?e==null||e.startTyping():e==null||e.endTyping()},[e,t])},zd=f.default.div`&::-webkit-scrollbar{display:none;}overflow-x:auto;display:flex;flex-direction:row;gap:10px;padding:8px 16px;background-color:transparent;`,Vd=f.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;}`,Gd=f.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%;${D.light`
|
|
257
257
|
background-color: ${g.color.background50};
|
|
258
258
|
`}
|
|
259
259
|
${D.dark`
|
|
@@ -272,17 +272,17 @@
|
|
|
272
272
|
circle {
|
|
273
273
|
stroke: ${g.themedColor.bg_50_600};
|
|
274
274
|
}
|
|
275
|
-
`,Wd=()=>{const e=Ze(),[t,n]=u.useState(),{files:r,removeFile:s,isFileUploadEnabled:a}=un();return!a||r.length===0?null:o.createElement(zd,null,r.map(({preview:{type:i,name:l,url:c}},d)=>o.createElement(Vd,{key:c,onMouseOver:()=>n(d),onMouseLeave:()=>n(void 0)},(e||t===d)&&o.createElement(Gd,{title:"Remove file",onClick:()=>s(d)},o.createElement(P,{type:"close-filled",color:g.themedColor.textMidEmphasis})),i.startsWith("image/")?o.createElement("img",{alt:"file-image",src:c}):o.createElement(Jt,{name:l,type:qt(l,i)}))))},Nr={textArea:S.css`min-height:40px;height:40px;font-size:16px;line-height:24px;`,attachIcon:S.css`margin-bottom:4px;`},Pr=f.default.button`all:unset;cursor:pointer;display:flex;align-items:center;justify-content:center;width:32px;height:32px;`,qd=f.default(Pr)`flex-shrink:0;margin-inline-end:12px;margin-bottom:2px;&:disabled{cursor:not-allowed;}&:not(:disabled){&:hover{path{fill:${g.themedColor.textHighEmphasis};}}&:active{border-radius:4px;background-color:${g.themedColor.bg_200_400};}}${an&&Nr.attachIcon};`,jd=f.default.input`display:none;`,qn=f.default.div`width:100%;position:relative;background-color:${g.themedColor.bg_100_500};border-radius:20px;`,jn=f.default.div`display:flex;flex-direction:row;align-items:flex-end;position:relative;`,Kn=f.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:${g.themedColor.textHighEmphasis};resize:none;width:100%;height:${Er}px;overflow-wrap:break-word;white-space:pre-wrap;overflow-x:hidden;${an&&Nr.textArea};&::placeholder{color:${g.themedColor.textLowEmphasis};}&:disabled{cursor:not-allowed;&::placeholder{color:${g.themedColor.textDisabled};}}`,Yn=f.default.div`padding:12px 16px;position:relative;display:flex;align-items:center;`,Zn=({disabled:e})=>{const{stringSet:t}=F(),n=u.useRef(null),[r,s]=u.useState(!1),{addFiles:a,clearFiles:i,files:l,isFileUploadEnabled:c,acceptableMimeTypes:d}=un();return!c||l.length>0?null:o.createElement(qd,{disabled:e,onClick:()=>{var h;if(d.length===0)return s(!0);i(),(h=n.current)==null||h.click()}},o.createElement(P,{type:"attach",color:e?g.themedColor.textDisabled:g.themedColor.textMidEmphasis,size:16}),o.createElement(jd,{type:"file",ref:n,onChange:h=>{const
|
|
275
|
+
`,Wd=()=>{const e=Ze(),[t,n]=u.useState(),{files:r,removeFile:s,isFileUploadEnabled:a}=un();return!a||r.length===0?null:o.createElement(zd,null,r.map(({preview:{type:i,name:l,url:c}},d)=>o.createElement(Vd,{key:c,onMouseOver:()=>n(d),onMouseLeave:()=>n(void 0)},(e||t===d)&&o.createElement(Gd,{title:"Remove file",onClick:()=>s(d)},o.createElement(P,{type:"close-filled",color:g.themedColor.textMidEmphasis})),i.startsWith("image/")?o.createElement("img",{alt:"file-image",src:c}):o.createElement(Jt,{name:l,type:qt(l,i)}))))},Nr={textArea:S.css`min-height:40px;height:40px;font-size:16px;line-height:24px;`,attachIcon:S.css`margin-bottom:4px;`},Pr=f.default.button`all:unset;cursor:pointer;display:flex;align-items:center;justify-content:center;width:32px;height:32px;`,qd=f.default(Pr)`flex-shrink:0;margin-inline-end:12px;margin-bottom:2px;&:disabled{cursor:not-allowed;}&:not(:disabled){&:hover{path{fill:${g.themedColor.textHighEmphasis};}}&:active{border-radius:4px;background-color:${g.themedColor.bg_200_400};}}${an&&Nr.attachIcon};`,jd=f.default.input`display:none;`,qn=f.default.div`width:100%;position:relative;background-color:${g.themedColor.bg_100_500};border-radius:20px;`,jn=f.default.div`display:flex;flex-direction:row;align-items:flex-end;position:relative;`,Kn=f.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:${g.themedColor.textHighEmphasis};resize:none;width:100%;height:${Er}px;overflow-wrap:break-word;white-space:pre-wrap;overflow-x:hidden;${an&&Nr.textArea};&::placeholder{color:${g.themedColor.textLowEmphasis};}&:disabled{cursor:not-allowed;&::placeholder{color:${g.themedColor.textDisabled};}}`,Yn=f.default.div`padding:12px 16px;position:relative;display:flex;align-items:center;`,Zn=({disabled:e})=>{const{stringSet:t}=F(),n=u.useRef(null),[r,s]=u.useState(!1),{addFiles:a,clearFiles:i,files:l,isFileUploadEnabled:c,acceptableMimeTypes:d}=un();return!c||l.length>0?null:o.createElement(qd,{disabled:e,onClick:()=>{var h;if(d.length===0)return s(!0);i(),(h=n.current)==null||h.click()}},o.createElement(P,{type:"attach",color:e?g.themedColor.textDisabled:g.themedColor.textMidEmphasis,size:16}),o.createElement(jd,{type:"file",ref:n,onChange:h=>{const b=h.currentTarget.files;b&&a(Array.from(b)),h.target.value=""},accept:d.join(",")}),o.createElement(nn,{visible:r,title:t.FILE_UPLOAD_NO_SUPPORTED_FILES,onClose:()=>s(!1)}))},Kd=()=>{const e=u.useRef(null),[t,n]=u.useState(""),{stringSet:r}=F(),{rootElement:s}=W(),{channelSource:a,messageSource:i,state:l}=Q(),{files:c,addFiles:d,clearFiles:h}=un(),b=l.input.disabled,E=(()=>{if(!b)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}})();qu({onDropFiles:d}),Ud({blurred:b,elementRef:e,document:Me(s)}),Hd(a.channel,t);const C=t.trim().length>0,y=c.length>0,x=!b&&(C||y),m=()=>{e.current&&(e.current.value="",e.current.style.height=""),h(),n("")},p=async()=>{const T=t.trim(),L={message:T};if(!(!T&&!c.length)){if(c.length>0){const $=c[0].file,M={...L,file:$};i.sendFileMessage(M),m();return}i.sendUserMessage(L),m()}},v=T=>{const L=Array.from(T.clipboardData.files);L.length>0&&(T.preventDefault(),d(L))},_=T=>{T.key!=="Enter"||T.nativeEvent.isComposing||T.shiftKey||(T.preventDefault(),p())},I=T=>{if(e.current){e.current.style.height="";const L=Math.min(Va,e.current.scrollHeight);Er<L&&(e.current.style.height=`${L}px`)}n(T.target.value)};return b?o.createElement(Yn,null,o.createElement(qn,null,o.createElement(jn,null,o.createElement(Kn,{disabled:!0,placeholder:E}),o.createElement(Zn,{disabled:!0})))):o.createElement(Yn,null,o.createElement(qn,null,o.createElement(Wd,null),o.createElement(jn,null,o.createElement(Kn,{ref:e,role:"textbox","aria-label":"Text Input",placeholder:E,maxLength:5e3,onKeyDown:_,onChange:I,onPaste:v}),o.createElement(Zn,null))),x&&o.createElement(Pr,{onClick:()=>p()},o.createElement(P,{type:"send",color:g.color.primary.main,size:20})))},Yd=f.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:${g.themedColor.textLowEmphasis};&& a{font-weight:700;text-decoration:none;${D.light`
|
|
276
276
|
color: ${g.color.information.light};
|
|
277
277
|
`};
|
|
278
278
|
${D.dark`
|
|
279
279
|
color: ${g.color.information.main};
|
|
280
280
|
`};
|
|
281
281
|
}
|
|
282
|
-
`,Zd=u.lazy(()=>Promise.resolve().then(()=>require("./
|
|
282
|
+
`,Zd=u.lazy(()=>Promise.resolve().then(()=>require("./CgKaFsNM.cjs")).then(e=>({default:e.MarkdownText}))),Xd=()=>{const{aiAgentInfo:e,userSession:t}=J(),{messageSource:n,channelSource:r}=Q(),[s,a]=u.useState(null),i=Xt("special-notice",r.channel),l=u.useCallback(()=>r.channel?i?n.messages.some(c=>je(c,(t==null?void 0:t.userId)??"")):!0:null,[r.channel,i,n.messages,t==null?void 0:t.userId]);return u.useEffect(()=>{s||a(l())},[l,s]),s||!e.specialNotice?null:o.createElement(Yd,null,o.createElement(Zd,null,e.specialNotice))},Jd=()=>o.createElement(Qd,null,o.createElement(Xd,null),o.createElement(Fd,null,o.createElement(Kd,null))),Qd=f.default.div`z-index:0;border:none;width:100%;`,em=()=>{var s;const{testerType:e}=He(),{channelSource:t}=Q(),n=Te(t.channel),r=!!e&&((s=t.channel)==null?void 0:s.isAIAgent);return n&&r?o.createElement(Pd,null):o.createElement(Jd,null)},Br=({children:e,onNavigateToConversationList:t,channelUrl:n,onClearChannelUrl:r,shouldMarkAsRead:s,closedChannelUrl:a,onClearClosedChannelUrl:i})=>{const{Template:l}=yt.useContext();return o.createElement(Lr,{onNavigateToConversationList:t,channelUrl:n??a,onClearChannelUrl:r??i,shouldMarkAsRead:s},o.createElement(zt,null,o.createElement(zt.Consumer,null,c=>o.createElement(o.Fragment,null,o.createElement(nm,{...c},o.createElement(l,null)),e))))},yt=pe({template:tm,components:{Header:Gu,Body:Nd,Footer:em}});function tm(){const{components:e}=yt.useContext();return o.createElement(o.Fragment,null,o.createElement(e.Header,null),o.createElement(e.Body,null),o.createElement(e.Footer,null))}const nm=f.default.div`height:100%;width:100%;display:flex;flex-direction:column;flex:1;background-color:${({theme:e})=>e.colors.base.background};`,{Provider:rm,Context:om,useContext:dn}=X("ConversationList");function Fr({conversationListLimit:e,conversationListFilter:t,onOpenConversationView:n=fe,children:r}){return o.createElement(Ms,{conversationListLimit:e,conversationListFilter:t},s=>o.createElement(rm,{value:{...s,onOpenConversationView:n}},r))}const sm=({channel:e})=>o.createElement(Or,{channel:e}),mn=pe({template:am,components:{}}),Gt=99;function am(e){const{channel:t,onClick:n}=e,{stringSet:r,format:s}=F(),a=vo(t),i=Co(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(im,{role:"button",onClick:()=>n==null?void 0:n()},o.createElement(lm,null,o.createElement(sm,{...e})),o.createElement(cm,null,o.createElement(um,null,o.createElement(k,{variant:"subtitle1",color:g.themedColor.textHighEmphasis,maxTextLines:1},a),o.createElement(dm,null,Te(t)&&o.createElement(o.Fragment,null,o.createElement(k,{variant:"caption1",color:g.themedColor.textMidEmphasis,maxTextLines:1},r.CONVERSATION_LIST__ENDED),o.createElement(mm,null)),o.createElement(k,{variant:"caption2",color:g.themedColor.textLowEmphasis,maxTextLines:1},i))),l>0&&o.createElement(gm,{$count:l},o.createElement(k,{variant:"caption3",color:g.themedColor.textHighEmphasisInverse},l<=Gt?l:`${Gt}+`))))}const im=f.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;`,lm=f.default.div`display:flex;align-items:center;justify-content:center;padding-inline-start:16px;`,cm=f.default.div`display:flex;flex-direction:row;align-items:center;flex:1;padding-inline-end:16px;height:100%;gap:8px;border-bottom:1px solid ${g.themedColor.textDisabled};`,um=f.default.div`display:flex;flex-direction:column;justify-content:center;flex:1;gap:4px;word-break:break-word;overflow-wrap:break-word;`,dm=f.default.div`display:flex;align-items:center;gap:6px;`,mm=f.default.div`width:2px;height:2px;border-radius:1px;background-color:${g.themedColor.textLowEmphasis};`,gm=f.default.div`display:flex;align-items:center;justify-content:center;height:20px;padding:4px;border-radius:10px;background-color:${g.themedColor.error};${({$count:e})=>e<=Gt&&S.css`
|
|
283
283
|
width: 20px;
|
|
284
284
|
`}
|
|
285
|
-
`,hm=({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(fm,{onScroll:s=>r(s)},e.map((s,a)=>t(s,a)))},fm=f.default.div`width:100%;height:100%;display:flex;flex-direction:column;flex:1;overflow:auto;overscroll-behavior:contain;`,pm=()=>{const{stringSet:e}=F(),{listSource:t,onOpenConversationView:n}=dn(),{Template:r}=mn.useContext();return t.initialized?t.channels.length===0?o.createElement(Fe,{type:"noChannels",label:e.CONVERSATION_LIST__NO_CONVERSATIONS}):o.createElement(hm,{items:t.channels,renderItem:s=>{var a,i,l;return o.createElement(r,{key:s.url,channel:s,onClick:()=>n(s.url,
|
|
285
|
+
`,hm=({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(fm,{onScroll:s=>r(s)},e.map((s,a)=>t(s,a)))},fm=f.default.div`width:100%;height:100%;display:flex;flex-direction:column;flex:1;overflow:auto;overscroll-behavior:contain;`,pm=()=>{const{stringSet:e}=F(),{listSource:t,onOpenConversationView:n}=dn(),{Template:r}=mn.useContext();return t.initialized?t.channels.length===0?o.createElement(Fe,{type:"noChannels",label:e.CONVERSATION_LIST__NO_CONVERSATIONS}):o.createElement(hm,{items:t.channels,renderItem:s=>{var a,i,l;return o.createElement(r,{key:s.url,channel:s,onClick:()=>n(s.url,Te(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(Fe,{type:"loading"})},bm=()=>{const{stringSet:e}=F(),{language:t,countryCode:n,context:r}=W(),{aiAgentInfo:s,refreshActiveChannel:a,createConversation:i,setActiveChannel:l}=J(),{onOpenConversationView:c}=dn();return o.createElement(Em,{role:"button",onClick:async()=>{if(s.isMultipleActiveConversationsEnabled){const d=await i({aiAgentId:s.userId,language:t,country:n,context:r});l({url:d,status:q.ConversationStatus.OPEN}),c(d,q.ConversationStatus.OPEN)}else{const d=await a();c(d,q.ConversationStatus.OPEN)}}},o.createElement(xm,{variant:"h1"},e.TALK_TO_AGENT))},Em=f.default.div`background-color:${({theme:e})=>e.colors.base.primary};display:flex;align-items:center;justify-content:center;padding:16px;cursor:pointer;`,xm=f.default(k)`color:${({theme:e})=>e.colors.base.primaryContrastContent};overflow:hidden;text-overflow:ellipsis;white-space:nowrap;`,vm=()=>{const{state:e}=W(),t=ze(),n=()=>{e.setOpened(!1)};return o.createElement(ke,{"aria-label":"close messenger",type:"close",size:t,onClick:n})},Cm=()=>{const{stringSet:e}=F();return o.createElement(ym,{variant:"h2",color:g.themedColor.textHighEmphasis},e.CONVERSATION_LIST__HEADER_TITLE)},ym=f.default(k)`padding:0 4px;width:100%;box-sizing:border-box;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;`,_m=e=>{const{components:t}=Ve.useContext();return o.createElement(sn,{start:o.createElement(t.StartArea,null),title:o.createElement(t.TitleArea,null),titleAlign:e.titleAlign,end:o.createElement(t.EndArea,null)})},Sm=()=>null,Tm=()=>{const{components:e}=Ve.useContext();return o.createElement(e.Title,null)},Am=()=>{const{components:e}=Ve.useContext();return o.createElement(e.CloseButton,null)},Ve=pe({template:_m,components:{StartArea:Sm,TitleArea:Tm,EndArea:Am,Title:Cm,CloseButton:vm}}),wm=()=>{const{Template:e}=Ve.useContext();return o.createElement(e,{titleAlign:"start"})},Ur=({conversationListLimit:e,conversationListFilter:t,children:n,onOpenConversationView:r})=>{const{Template:s}=_t.useContext();return o.createElement(Fr,{conversationListLimit:e,conversationListFilter:t,onOpenConversationView:r},o.createElement(Im,null,o.createElement(s,null)),n)},_t=pe({template:km,components:{Header:wm,Body:pm,Footer:bm}});function km(){const{components:e}=_t.useContext();return o.createElement(o.Fragment,null,o.createElement(e.Header,null),o.createElement(e.Body,null),o.createElement(e.Footer,null))}const Im=f.default.div`height:100%;width:100%;display:flex;flex-direction:column;flex:1;background-color:${({theme:e})=>e.colors.base.background};`,$m=S.css`:where(#${se.ENTRY}) :not(code *){font-family:'Roboto',sans-serif;box-sizing:border-box;}`,Mm=[$m,ga,ha],Lm=(e,...t)=>S.createGlobalStyle(e,...Mm,...t),Om=Lm``,Rm=po(yt,Le,xt,vt,_t,Re,mn,Ve,Ct);function Hr({appearance:e,rootElement:t,logger:n,language:r,stringSet:s,children:a,messageTemplate:i,theme:l}){return xa(ra,t),o.createElement(S.StyleSheetManager,{target:t},o.createElement(pa,{rootElement:t,logger:n,appearance:e,theme:l},o.createElement(Rs,{internalVariables:i==null?void 0:i.__internalVariables},o.createElement(ma,{stringSet:s,logger:n,language:r},o.createElement(Rm,null,a,o.createElement(Om,null))))))}const Dm={isOnline:()=>typeof window>"u"?!0:navigator.onLine,subscribe:e=>{if(typeof window>"u")return fe;const t=()=>e(!0),n=()=>e(!1);return window.addEventListener("online",t),window.addEventListener("offline",n),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",n)}}},ot={},st={getItem:e=>{try{return localStorage.getItem(e)}catch{return ot[e]??null}},setItem:(e,t)=>{try{localStorage.setItem(e,t)}catch{ot[e]=t}},deleteItem:e=>{try{localStorage.removeItem(e)}catch{delete ot[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(ot).filter(t=>t.startsWith(e))}}},gn=u.forwardRef(function({rootElement:t=document.body,logLevel:n=Z.LogLevel.WARN,language:r=navigator.language,userSessionInfo:s,children:a,chatParams:i,...l},c){var d,h;return We.level!==n&&(We.level=n),Ea("https://fonts.googleapis.com/css2?family=Roboto&display=swap",t),o.createElement("div",{id:se.ENTRY,style:{width:"fit-content",height:"fit-content",...l.entryStyle}},o.createElement(Hr,{logger:We,rootElement:t,appearance:(d=l.agentPreviewConfigs)==null?void 0:d.appearance,stringSet:l.stringSet,language:r,messageTemplate:l.messageTemplate,theme:l.theme},o.createElement(Ca,{rootElement:t,keyValueStorage:{get:st.getItem,set:st.setItem,delete:st.deleteItem,getKeys:st.getKeys},networkStateAdapter:Dm,language:r,logger:We,dispatcher:zr,chatParams:{...i,customApiHost:l.customApiHost,customWebSocketHost:l.customWebSocketHost},chatSDK:l.customChatSDK,messengerVersion:Ga,...l},o.createElement(mu,{ref:c,userSessionInfo:s,forceCreateChannel:(h=l.agentPreviewConfigs)==null?void 0:h.forceCreateChannel},o.createElement(jc,{...l._UNSAFE_INTERNAL_dashboardTester},a,o.createElement("div",{id:se.MODAL_ROOT,dir:l.dir}))))))}),We=new or(Z.LogLevel.WARN),zr=new rr(We),{Provider:Nm,useContext:hn}=X("PageChildren"),Vr=({children:e})=>{const[t,n]=u.useState(null),[r,s]=u.useState(null);return o.createElement(Nm,{value:{conversationChildren:t,setConversationChildren:n,conversationListChildren:r,setConversationListChildren:s}},e)},Gr=({children:e,isOpened:t})=>{const{dir:n,rootElement:r}=W(),s=Me(r,!0);return u.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(Pm,{dir:n,$visible:t},e)},Pm=f.default.div`width:100%;height:100%;position:fixed;top:0;left:0;z-index:${Oe.WINDOW};visibility:${({$visible:e})=>e?"visible":"hidden"};`,Bm=48,Fm=2/3;function Wr({className:e,isOpened:t,onClick:n,type:r,imageUrl:s,dir:a,animated:i=!0,backgroundColor:l,size:c=Bm}){const d=Dt(l),h=Math.round(c*Fm);return o.createElement(zm,{dir:a,id:se.LAUNCHER,className:e,"aria-label":"Sendbird AIAgent Launcher",onClick:n,$animated:i,$backgroundColor:l,$size:c},o.createElement(Vm,{$isOpened:t,$animated:i,$fillColor:d,$iconSize:h},o.createElement(Xn.Open,{url:s,isDefaultIcon:r==="default_icon",size:h})),o.createElement(Gm,{$isOpened:t,$animated:i,$fillColor:d,$iconSize:h},o.createElement(Xn.Close,{size:h})))}const Um=S.css`&:hover{transition:transform 250ms cubic-bezier(0.33,0,0,1);transform:scale(1.1);}&:active{transform:scale(0.8);}`,Hm=S.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===qe.WHITE?"grayscale(100%) brightness(2000%)":"grayscale(100%) invert(100%) saturate(0%) brightness(0%) contrast(1000%)"};}}`,qr=S.css`svg{width:${({$iconSize:e})=>e}px;height:${({$iconSize:e})=>e}px;${({$fillColor:e})=>S.css`
|
|
286
286
|
ellipse,
|
|
287
287
|
path {
|
|
288
288
|
fill: ${e};
|
|
@@ -292,10 +292,10 @@
|
|
|
292
292
|
}
|
|
293
293
|
`}
|
|
294
294
|
}
|
|
295
|
-
`,zm=f.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&&Um}`,jr=f.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;`,Vm=f.default(jr)`opacity:${({$isOpened:e})=>e?0:1};transform:${({$animated:e,$isOpened:t})=>e&&(t?"rotate(-90deg) scale(0)":"rotate(0deg)")};${Hm}${qr}`,Gm=f.default(jr)`scale:${({$isOpened:e})=>e?1:0};transform:${({$animated:e,$isOpened:t})=>e&&(t?"rotate(0deg)":"rotate(-90deg)")};${qr}`,Xn={Open:e=>e.url?o.createElement("img",{src:e.url,alt:"launcher-img","data-default-icon":e.isDefaultIcon}):o.createElement(P,{size:e.size,type:"delight"}),Close:({size:e})=>o.createElement(P,{size:e,type:"chevron-down"})};function Kr({className:e,size:t}){const{colors:n}=S.useTheme(),{dir:r,state:s}=W(),{launcherInfo:a}=
|
|
295
|
+
`,zm=f.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&&Um}`,jr=f.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;`,Vm=f.default(jr)`opacity:${({$isOpened:e})=>e?0:1};transform:${({$animated:e,$isOpened:t})=>e&&(t?"rotate(-90deg) scale(0)":"rotate(0deg)")};${Hm}${qr}`,Gm=f.default(jr)`scale:${({$isOpened:e})=>e?1:0};transform:${({$animated:e,$isOpened:t})=>e&&(t?"rotate(0deg)":"rotate(-90deg)")};${qr}`,Xn={Open:e=>e.url?o.createElement("img",{src:e.url,alt:"launcher-img","data-default-icon":e.isDefaultIcon}):o.createElement(P,{size:e.size,type:"delight"}),Close:({size:e})=>o.createElement(P,{size:e,type:"chevron-down"})};function Kr({className:e,size:t}){const{colors:n}=S.useTheme(),{dir:r,state:s}=W(),{launcherInfo:a}=J();return qm(),o.createElement(Wr,{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 Wm=1e3*60;function qm(){const{chatSDK:e,state:t,logger:n,enableAutoDisconnectInLauncher:r}=W(),s=u.useRef(null);u.useEffect(()=>{if(!r)return;function a(){s.current&&(clearTimeout(s.current),s.current=null)}function i(){e.connectionState===Z.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")},Wm)}t.opened?i():(l(),n.debug("useSDKInactivityTimeout: schedule disconnect"))},[r,e,t.opened])}const Yr=u.createContext(null);function Zr(){const e=u.useContext(Yr);if(!e)throw new Error("useNavigator() must be used within <Navigator />");return e}function Xr({children:e}){const t=Zr();return typeof e=="function"?e(t):o.createElement(o.Fragment,null,e)}const jm=S.keyframes`0%{transform:translateY(40px);opacity:0;}100%{transform:translateY(0px);opacity:1;}`,Km=S.keyframes`0%{transform:translateY(0px);opacity:1;}100%{transform:translateY(40px);opacity:0;}`,Ym=S.css`animation-name:${jm};animation-duration:0.3s;animation-fill-mode:forwards;`,Zm=S.css``,Xm=S.css`animation-name:${Km};animation-duration:0.3s;animation-fill-mode:forwards;`,Jm=S.css`visibility:hidden;`,Qm=f.default.div`position:absolute;top:0;left:0;width:100%;height:100%;${({$transitionState:e})=>{switch(e){case"entering":return Ym;case"entered":return Zm;case"exiting":return Xm;case"exited":return Jm;default:return""}}}${({$active:e})=>e?S.css`
|
|
296
296
|
z-index: 999;
|
|
297
297
|
`:S.css`z-index:1;pointer-events:none;`}
|
|
298
|
-
`;function it({initialId:e,children:t}){const[n,r]=u.useState([e]),s=n[n.length-1],a=u.useCallback((m,
|
|
298
|
+
`;function it({initialId:e,children:t}){const[n,r]=u.useState([e]),s=n[n.length-1],a=u.useCallback((m,p)=>{r(v=>[...v,m]),b(v=>({...v,[m]:!0})),p!=null&&p.reset&&x(v=>({...v,[m]:(v[m]||0)+1})),C(v=>({...v,[m]:"entering"})),setTimeout(()=>{C(v=>({...v,[m]:"entered"}))},300)},[]),i=u.useCallback(()=>{r(m=>{if(m.length<=1)return m;const p=m[m.length-1];return C(v=>({...v,[p]:"exiting"})),setTimeout(()=>{C(v=>({...v,[p]:"exited"})),r(v=>v.slice(0,-1))},300),m})},[]),l=u.useMemo(()=>({navigation:{navigate:a,pop:i},activeScreenId:s}),[a,i,s]),c=u.useMemo(()=>u.Children.toArray(t).filter(m=>m.type===Xr),[t]),d=u.useMemo(()=>{const m={};return c.forEach(p=>{const{id:v,lazy:_,children:I}=p.props;m[v]={lazy:_,element:typeof I=="function"?I(l):I}}),m},[c,l]),[h,b]=u.useState(()=>{const m={};return Object.entries(d).forEach(([p,{lazy:v}])=>{v===!1&&(m[p]=!0)}),m[e]=!0,m}),[E,C]=u.useState(()=>{const m={};return Object.keys(d).forEach(p=>{p===e?m[p]="entered":m[p]="exited"}),m}),[y,x]=u.useState({});return o.createElement(Yr.Provider,{value:l},o.createElement(eg,null,Object.keys(d).map(m=>{var I;if(!h[m])return null;const p=E[m]||"exited",v=m===s,_=`${m}-${y[m]||0}`;return o.createElement(Qm,{key:_,$transitionState:p,$active:v},(I=d[m])==null?void 0:I.element)})))}const eg=f.default.div`position:relative;width:100%;height:100%;`;it.Screen=Xr;const ge={conv:"conv",convList:"conv-list"},Jr=({isOpened:e,entryPoint:t,selectedChannelUrl:n,setSelectedChannelUrl:r})=>{const{conversationChildren:s,conversationListChildren:a}=hn(),i=(()=>{switch(t){case"Conversation":return ge.conv;case"ConversationList":return ge.convList;default:return ge.conv}})(),l=o.createElement(o.Fragment,null,o.createElement(tg,{onOpenConversationView:r}));return o.createElement(it,{initialId:i},o.createElement(it.Screen,{id:ge.conv},({navigation:c,activeScreenId:d})=>o.createElement(Br,{key:n,channelUrl:n,onClearChannelUrl:()=>r(void 0),onNavigateToConversationList:()=>c.navigate(ge.convList),shouldMarkAsRead:e&&d===ge.conv},l,s)),o.createElement(it.Screen,{id:ge.convList,lazy:!0},({navigation:c})=>o.createElement(Ur,{onOpenConversationView:d=>{r(d),c.navigate(ge.conv)}},l,a)))},tg=({onOpenConversationView:e})=>{const{registerOnJoinedProactiveConversation:t}=J(),{navigation:n}=Zr();return t(({channel:r})=>{e(r.url),n.navigate(ge.conv)}),null};function ng({isExpanded:e,isOpened:t,children:n,launcher:r}){const{dir:s}=W();return o.createElement(rg,null,o.createElement(og,{dir:s,id:se.WINDOW,$isExpanded:e,$isOpened:t},n),r)}const rg=f.default.div`display:flex;flex-direction:column;gap:8px;align-items:flex-end;`,og=f.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&&ag};${({$isExpanded:e})=>e&&sg};`,sg=S.css`width:743px;height:723px;`,ag=S.css`z-index:${Oe.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;`,ig=u.forwardRef(function({children:e,initialChannelUrl:t,...n},r){const s=Ze(),[a,i]=u.useState(t),l=s?Gr:ng;return o.createElement(gn,{enableExpandButton:!s,ref:r,...n},o.createElement(br,null,({state:c})=>o.createElement(Vr,null,o.createElement(l,{isExpanded:c.expanded,isOpened:c.opened,launcher:o.createElement(Kr,null)},o.createElement(Jr,{isOpened:c.opened,entryPoint:n.entryPoint,selectedChannelUrl:a,setSelectedChannelUrl:i})),e)))}),{Provider:lg,useContext:fn}=X("FixedMessengerStyle");function Qr(e,t,n,r=0){const{top:s,bottom:a,start:i,end:l}=n;let c="",d="";switch(e){case"start":d=`inset-inline-start: ${ce(i)}`;break;case"end":d=`inset-inline-end: ${ce(l)}`;break}switch(t){case"top":c=`top: calc(${ce(s)} + ${r}px)`;break;case"bottom":c=`bottom: calc(${ce(a)} + ${r}px)`;break}return S.css`${c};${d};`}function cg(e){const{horizontal:t,vertical:n,margin:r,launcherSize:s}=fn();return o.createElement(ug,{...e,size:s,$horizontal:t,$vertical:n,$margin:r})}const ug=f.default(Kr)`position:fixed;z-index:${Oe.LAUNCHER};${({$horizontal:e,$vertical:t,$margin:n})=>Qr(e,t,n)};`;function dg({isExpanded:e,isOpened:t,children:n}){const{dir:r}=W(),{horizontal:s,vertical:a,margin:i,launcherSize:l}=fn();return o.createElement(mg,{dir:r,id:se.WINDOW,$isExpanded:e,$isOpened:t,$horizontal:s,$vertical:a,$margin:i,$launcherSize:l},n)}const mg=f.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})=>Qr(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}`};
|
|
299
299
|
[dir='rtl'] &:not([dir='ltr']),
|
|
300
300
|
&[dir='rtl'] {
|
|
301
301
|
transform-origin: ${({$horizontal:e,$vertical:t})=>`${e==="start"?"right":"left"} ${t}`};
|
|
@@ -303,4 +303,4 @@
|
|
|
303
303
|
|
|
304
304
|
${({$isOpened:e})=>e&&hg};
|
|
305
305
|
${({$isExpanded:e})=>e&&gg};
|
|
306
|
-
`,gg=S.css`width:743px;height:723px;`,hg=S.css`z-index:${Oe.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;`,eo={top:24,bottom:24,start:24,end:24},fg=u.forwardRef(function({children:e,initialChannelUrl:t,...n},r){const[s,a]=u.useState(t),[i,l]=u.useState("end-bottom"),[c,d]=u.useState(eo),[h,
|
|
306
|
+
`,gg=S.css`width:743px;height:723px;`,hg=S.css`z-index:${Oe.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;`,eo={top:24,bottom:24,start:24,end:24},fg=u.forwardRef(function({children:e,initialChannelUrl:t,...n},r){const[s,a]=u.useState(t),[i,l]=u.useState("end-bottom"),[c,d]=u.useState(eo),[h,b]=u.useState(48),E=Ze(),C=E?Gr:dg,{horizontal:y,vertical:x}=u.useMemo(()=>{const[m,p]=i.split("-");return{horizontal:m==="start"?"start":"end",vertical:p==="top"?"top":"bottom"}},[i]);return o.createElement(gn,{enableExpandButton:!E,ref:r,...n},o.createElement(br,null,({state:m})=>o.createElement(lg,{value:{horizontal:y,vertical:x,margin:c,launcherSize:h,setPosition:l,setMargin:d,setLauncherSize:b}},o.createElement(Vr,null,o.createElement(C,{isExpanded:m.expanded,isOpened:m.opened},o.createElement(Jr,{isOpened:m.opened,entryPoint:n.entryPoint,selectedChannelUrl:s,setSelectedChannelUrl:a})),o.createElement(cg,null),e))))}),pg=e=>{var s,a,i,l;const{setPosition:t,setMargin:n,setLauncherSize:r}=fn();return u.useLayoutEffect(()=>{e.position&&t(e.position),e.margin&&n({...eo,...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},bg=({children:e})=>{const{setConversationChildren:t}=hn();return u.useLayoutEffect(()=>(t(e),()=>t(null)),[e]),null},Eg=({children:e})=>{const{setConversationListChildren:t}=hn();return u.useLayoutEffect(()=>(t(e),()=>t(null)),[e]),null},xg=Object.assign(fg,{Style:pg,ConversationChildren:bg,ConversationListChildren:Eg}),vg=e=>{const{refreshActiveChannel:t}=J(),[n,r]=u.useState(!1),s=u.useRef(null),a=u.useRef(null);return u.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]),u.useCallback(()=>new Promise((i,l)=>{s.current=i,a.current=l,e().then(()=>r(!0)).catch(l)}),[e])};exports.ANCHOR_REL=Qt;exports.AgentProviderContainer=gn;exports.AgentUIProviderContainer=Hr;exports.AnonymousSessionInfo=Nt;exports.CSATType=le;exports.Conversation=Br;exports.ConversationContext=Su;exports.ConversationContextProvider=Lr;exports.ConversationHeaderLayout=Re;exports.ConversationLayout=yt;exports.ConversationList=Ur;exports.ConversationListContext=om;exports.ConversationListContextProvider=Fr;exports.ConversationListHeaderLayout=Ve;exports.ConversationListItemLayout=mn;exports.ConversationListLayout=_t;exports.DefaultMessenger=ig;exports.DispatcherCommands=sr;exports.FixedMessenger=xg;exports.IncomingMessageLayout=Le;exports.LauncherBase=Wr;exports.LogLevel=Kt;exports.ManualSessionInfo=cr;exports.MessageLogs=$r;exports.OutgoingMessageLayout=xt;exports.PlaceholderLayout=Ct;exports.SystemMessageLayout=vt;exports.cssVars=g;exports.escapeMarkdownSyntax=Io;exports.mapCommonStringsToReactFormat=fr;exports.messengerDispatcher=zr;exports.useConversationContext=Q;exports.useConversationListContext=dn;exports.useLocalizationContext=F;exports.useMessengerContext=W;exports.useMessengerSessionContext=J;exports.useRefreshActiveChannel=vg;
|