@sendbird/ai-agent-messenger-react 1.1.0 → 1.1.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.
@@ -1,4 +1,4 @@
1
- "use strict";const d=require("react"),N=require("@sendbird/chat"),c=require("styled-components"),Ce=require("date-fns"),nr=require("date-fns/locale/en-US"),P=require("@sendbird/chat/aiAgent"),ze=require("@sendbird/uikit-tools"),rr=require("@sendbird/chat/groupChannel"),rn=require("@sendbird/chat/message"),or=require("date-fns/isSameDay"),nt=require("@sendbird/react-uikit-message-template-view"),sr=require("@sendbird/uikit-message-template"),on=require("dompurify"),ir=require("react-dom"),ar=require("@emotion/is-prop-valid");function lr(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const r=lr(d),F=(e,t)=>{const n=d.createContext(null),o=({children:a,value:l})=>r.createElement(n.Provider,{value:l},typeof a=="function"?a(l):a),s=({children:a})=>r.createElement(n.Consumer,null,l=>l?typeof a=="function"?a(l):a:null),i=()=>{const a=d.useContext(n);if(!a)throw new Error(`use${e}Context must be used within a ${e}Provider`);return a};return n.displayName=`${e}Context`,o.displayName=`${e}Provider`,s.displayName=`${e}Consumer`,i.displayName=`use${e}Context`,{Context:n,Provider:o,Consumer:s,useContext:i}};function pe(e){const t=d.createContext({Template:e.template,updateTemplate:()=>{},components:e.components,updateComponent:()=>{}});function n({children:i}){const[a,l]=d.useState(()=>e.template),[u,h]=d.useState(e.components),g={Template:a,updateTemplate:p=>l(()=>p),components:u,updateComponent:(p,f)=>h(x=>({...x,[p]:f}))};return r.createElement(t.Provider,{value:g},i)}function o({template:i,children:a}){const{updateTemplate:l}=d.useContext(t);return d.useEffect(()=>{i&&l(i)},[i]),r.createElement(r.Fragment,null,a)}function s({children:i}){return r.createElement(n,null,i)}return s.defaults=e,s.useContext=()=>d.useContext(t),s.Context=t,s.Template=o,Object.keys(e.components).forEach(i=>{s[i]=function({component:l}){const{updateComponent:u}=d.useContext(t);return d.useEffect(()=>{l&&u(i,l)},[l]),null}}),s}function cr(...e){return function({children:n}){return e.reduce((o,s)=>r.createElement(s,null,o),n)}}function rt(){}function dr(){const e=/iPad|iPhone|iPod/.test(navigator.userAgent),t=/Android/.test(navigator.userAgent);return e||t}class sn{constructor(t){this.logger=t,this.subscribers={}}async send(t){const n=ur(),o=this.subscribers[t.type];if(o){this.logger.debug(`messenger.dispatcher: dispatching command: ${t.type}`,t.payload);const s=o.map(i=>i(t.payload));await Promise.all(s).catch(i=>{this.logger.error(`messenger.dispatcher: error in callback for command: ${t.type}`,i)})}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(o=>o!==n))}}const ur=()=>{let e=rt,t=rt;return{promise:new Promise((o,s)=>{e=o,t=s}),resolve:e,reject:t}},mr="1.1.0",ve="sb-agent",gr=mr;var dt=(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))(dt||{});class an{constructor(t){this.level=t}verbose(...t){this.level<=0&&console.log(`[${ve}/verbose]`,...t)}debug(...t){this.level<=1&&console.log(`[${ve}/debug]`,...t)}info(...t){this.level<=2&&console.log(`[${ve}/info]`,...t)}warn(...t){this.level<=3&&console.warn(`[${ve}/warn]`,...t)}error(...t){this.level<=4&&console.error(`[${ve}/error]`,...t)}}function $t(e,t,n){const o=N.init({appId:e,modules:[new rr.GroupChannelModule,new P.AIAgentModule],localCacheEnabled:!0,...n});return o.addSendbirdExtensions([{version:gr,product:N.SendbirdProduct.AI_AGENT,platform:t.platform}],{platform:t.deviceOSPlatform,version:t.deviceOSVersion},t.customData)||console.warn("Invalid Sendbird Extensions",t),o}const{Provider:hr,useContext:He}=F("AIAgent");function pr({appId:e,aiAgentId:t,language:n,countryCode:o,context:s,chatSDK:i,chatParams:a,dispatcher:l,logger:u,children:h,extensions:g={platform:N.SendbirdPlatform.JS,deviceOSPlatform:dr()?N.DeviceOsPlatform.MOBILE_WEB:N.DeviceOsPlatform.WEB}}){const[p,f]=d.useState(()=>{const x=u??new an(dt.WARN),E=l??new sn(x);return{appId:e,aiAgentId:t,language:n,countryCode:o,context:s,chatSDK:i??$t(e,g,a),logger:x,dispatcher:E}});return(n!==p.language||o!==p.countryCode)&&f(x=>({...x,language:n,countryCode:o,context:s})),i&&i!==p.chatSDK?f(x=>({...x,aiAgentId:t,chatSDK:i})):!i&&p.chatSDK.appId!==e&&f(x=>({...x,aiAgentId:t,chatSDK:$t(e,g,{newInstance:!0,...a})})),d.useEffect(()=>()=>{p.chatSDK.disconnectWebSocket()},[p.chatSDK]),r.createElement(hr,{value:p},h)}const fr=(e,t,n)=>ze.useGroupChannelMessages(e,t,{...n,strictStreamingOrder:!0});var ot=(e=>(e.ConversationClose="conv.close",e))(ot||{});class br{constructor(t={}){this.payload=t}toJSON(){return JSON.stringify({type:this.type,payload:this.payload})}}class xr extends br{constructor(){super(...arguments),this.type="conv.close"}}const ln={CloseConversation:()=>new xr},{Provider:Er}=F("AIAgentConversation");function vr({children:e,channelUrl:t,onChannelDeleted:n,onMessagesUpdated:o,onConversationClosedViaDispatcher:s,onBeforeSendMessage:i,onAfterSendMessage:a=rt}){var y;const{chatSDK:l,logger:u,dispatcher:h}=He(),{channel:g,channelFetchError:p,fetchChannel:f}=yr(t),x=fr(l,g,{shouldCountNewMessages:()=>!1,onChannelDeleted:n,onMessagesReceived:o,onMessagesUpdated:o,logger:u});d.useEffect(()=>{const b=async()=>{u.debug("conversation.dispatcher: try to close conversation",g),g!=null&&g.conversation&&g.conversation.status===P.ConversationStatus.OPEN&&(await g.closeConversation(),s==null||s())};return h.subscribe(ot.ConversationClose,b),()=>{h.unsubscribe(ot.ConversationClose,b)}},[h,(y=g==null?void 0:g.conversation)==null?void 0:y.status,s]);const E={conversation:(g==null?void 0:g.conversation)??void 0,channelSource:{channel:g,error:p,refetch:()=>f()},messageSource:{messages:x.messages,initialized:x.initialized,loadPrevious:()=>x.loadPrevious(),loadNext:()=>x.loadNext(),sendUserMessage:async b=>{i&&(b=await i(b));const C=await x.sendUserMessage(b,a);return a==null||a(C),C},sendFileMessage:async b=>{i&&(b=await i(b));const C=await x.sendFileMessage(b,a);return a==null||a(C),C}}};return r.createElement(Er,{value:E},e)}function yr(e){const{chatSDK:t,logger:n}=He(),[o,s]=d.useState(void 0),[i,a]=d.useState(void 0);async function l(){if(n.debug("conversation.fetchChannel: start"),s(void 0),a(void 0),e)try{n.debug("conversation.fetchChannel: get channel",e);const u=await t.groupChannel.getChannel(e);s(u);const h=new N.ConnectionHandler({onReconnectSucceeded:()=>u.refresh()});t.addConnectionHandler("sba-refresh",h),n.debug("conversation.fetchChannel: fetched channel",u)}catch(u){u instanceof N.SendbirdError&&a(u),n.error("conversation.fetchChannel: error",u)}}return d.useEffect(()=>{l()},[e,t]),{channel:o,channelFetchError:i,fetchChannel:l}}const Cr=(e,t)=>{const n=d.useId(),[o,s]=d.useState(!1),[i,a]=d.useState(null),[l,u]=d.useState([]),[h,g]=d.useState(null),p=d.useRef(!1),f=d.useCallback(async()=>{if(!p.current&&e.currentUser){p.current=!0,s(!1),a(null),u([]);try{const E=e.aiAgent.createConversationListQuery(t),y=await E.next();u(y),g(E),a(null)}catch(E){g(null),a(E)}finally{s(!0),p.current=!1}}},[e,t.aiAgentId,t.status,t.limit,t.order,t.reverse]),x=d.useCallback(async()=>{h&&h.next().then(E=>{u(y=>[...y,...E])}).catch(()=>{})},[h]);return d.useEffect(()=>(e.addConnectionHandler(n,new N.ConnectionHandler({onConnected:()=>f()})),()=>e.removeConnectionHandler(n)),[e,n,f]),d.useEffect(()=>{f()},[f]),{initialized:o,error:i,conversations:l,loadMore:x}},{Provider:Sr}=F("AIAgentConversationList");function Tr({children:e}){const{chatSDK:t,aiAgentId:n}=He(),o=Cr(t,{aiAgentId:n,status:P.ConversationStatus.CLOSED,order:P.ConversationListOrder.UPDATED_AT,reverse:!0}),s={listSource:{initialized:o.initialized,error:o.error??void 0,conversations:o.conversations,loadMore:()=>o.loadMore()}};return r.createElement(Sr,{value:s},e)}const st={DEFAULT_BOT_MSG_BG:"#eeeeee",WHITE:"#ffffff",BLACK:"#000000"};function cn(e){return e.length===4?`#${[...e.slice(1)].map(t=>t+t).join("")}`:e}function _r(e){const t=cn(e);return[parseInt(t.slice(1,3),16),parseInt(t.slice(3,5),16),parseInt(t.slice(5,7),16)]}function wr(e){return`#${e.map(t=>t.toString(16).padStart(2,"0")).join("")}`}function kr(e,t,n){e/=255,t/=255,n/=255;const o=Math.max(e,t,n),s=Math.min(e,t,n),i=o-s;let a=0,l=0;const u=(o+s)/2;return o!==s&&(l=u>.5?i/(2-o-s):i/(o+s)),o===e?a=(t-n)/i+(t<n?6:0):o===t?a=(n-e)/i+2:o===n&&(a=(e-t)/i+4),a/=6,[a,l,u]}function Ar(e,t,n){let o,s,i;if(t===0)o=s=i=n;else{const a=function(g,p,f){return f<0&&(f+=1),f>1&&(f-=1),f<.16666666666666666?g+(p-g)*6*f:f<.5?p:f<.6666666666666666?g+(p-g)*(.6666666666666666-f)*6:g},l=n<.5?n*(1+t):n+t-n*t,u=2*n-l;o=a(u,l,e+1/3),s=a(u,l,e),i=a(u,l,e-1/3)}return[Math.round(o*255),Math.round(s*255),Math.round(i*255)]}function Ae(e,t,n){const[o,s,i]=_r(e),[a,l,u]=kr(o,s,i),h=Math.max(0,Math.min(1,u*t)),g=Math.max(0,Math.min(1,l*n)),[p,f,x]=Ar(a,g,h);return wr([Math.round(p),Math.round(f),Math.round(x)])}function Ir(e,t="light"){return{extraDark:Ae(e,.6,1.2),dark:Ae(e,.85,1.1),main:e,light:Ae(e,t==="dark"?1.1:1.5,t==="dark"?.95:.9),extraLight:Ae(e,t==="dark"?1.2:1.75,t==="dark"?.9:.8)}}function it(e){const t=cn(e),n=149,o=+`0x${t[1]}${t[2]}`,s=+`0x${t[3]}${t[4]}`,i=+`0x${t[5]}${t[6]}`;return o*.299+s*.587+i*.114>n?st.BLACK:st.WHITE}function $r(e,t,n,o,s){return{base:{primary:t,primaryContrastContent:n,background:e.background50,headerBackground:e.background50,modalContentBackground:e.background50},metadata:{errorContent:e.ondark.textHighEmphasis,placeholderText:e.onlight.textLowEmphasis},messageInput:{background:e.background100},messageIncoming:{text:s,background:o},messageOutgoing:{text:n,background:t},csat:{background:e.background100}}}const Mr=(e,t,n,o,s)=>({base:{primary:t,primaryContrastContent:n,background:e.background600,headerBackground:e.background500,modalContentBackground:e.background500},metadata:{errorContent:e.ondark.textHighEmphasis,placeholderText:e.ondark.textLowEmphasis},messageInput:{background:e.background400},messageIncoming:{text:s,background:o},messageOutgoing:{text:n,background:t},csat:{background:e.background400}}),Ie={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)"}},Je={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 Mt(e){const t=Or(e),{colors:n,aiAgentColorVariables:o}=Lr(e,t),s=Rr(e);return{selectedTheme:e.selectedTheme,palette:t,colors:n,aiAgentColorVariables:o,typography:s}}function Or({selectedTheme:e,palette:t,primary:n}){const o=t!=null&&t.primary?t.primary:n?n===Ie.primary.main?Ie.primary:Ir(n,e):Ie.primary;return{...Ie,primary:o,...t}}function Lr({selectedTheme:e,primaryContrast:t,botMessageBackground:n,botMessageBackgroundContrast:o},s){const i=s.primary.main,a=t??it(i),l=n??st.DEFAULT_BOT_MSG_BG,u=o??it(l);return{colors:(e==="light"?$r:Mr)(s,i,a,l,u),aiAgentColorVariables:{primary_color:i,bot_message_bg_color:l,primary_contrast_color:a,bot_message_bg_contrast_color:u}}}function Rr({typography:e}){if(!e)return Je;const t={...Je};return Object.keys(e).forEach(n=>{const o=e[n];if(o&&typeof o=="object"){const i={...Je[n]};o.fontSize!==void 0&&o.fontSize!==null&&(i.fontSize=o.fontSize),o.fontWeight!==void 0&&o.fontWeight!==null&&(i.fontWeight=o.fontWeight),o.fontFamily!==void 0&&o.fontFamily!==null&&(i.fontFamily=o.fontFamily),t[n]=i}}),t}const{Provider:Pr,useContext:dn}=F("AIAgentTheme");function Nr({logger:e,palette:t,typography:n,appearance:o,children:s}){const[i,a]=d.useState(()=>Mt({selectedTheme:(o==null?void 0:o.theme)??"light",palette:t,typography:n,primary:o==null?void 0:o.primaryColor,botMessageBackground:o==null?void 0:o.botMessageBackgroundColor})),l=d.useCallback((u,h)=>{const g=(o==null?void 0:o.theme)??u,p=h==null?void 0:h(g),f={primary:o==null?void 0:o.primaryColor,primaryContrast:void 0,botMessageBackground:o==null?void 0:o.botMessageBackgroundColor,botMessageBackgroundContrast:void 0};!f.primary&&(p!=null&&p.primaryColor)&&(f.primary=p.primaryColor,f.primaryContrast=p.primaryContrastColor),!f.botMessageBackground&&(p!=null&&p.botMessageBackgroundColor)&&(f.botMessageBackground=p.botMessageBackgroundColor,f.botMessageBackgroundContrast=p.botMessageBackgroundContrastColor);const x=Mt({selectedTheme:g,palette:t,typography:n,...f});a(x),e==null||e.info("theme.update:",g)},[o==null?void 0:o.theme,o==null?void 0:o.primaryColor,o==null?void 0:o.botMessageBackgroundColor,t,n,e]);return d.useEffect(()=>{(o!=null&&o.theme||o!=null&&o.primaryColor||o!=null&&o.botMessageBackgroundColor)&&l(i.selectedTheme)},[o==null?void 0:o.theme,o==null?void 0:o.primaryColor,o==null?void 0:o.botMessageBackgroundColor]),r.createElement(Pr,{value:{theme:i,updateTheme:l}},s)}const un=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)}},Se=e=>JSON.parse(e),Ue=e=>JSON.parse(e);function Dr(e,t){const[n,o]=t.split(",").map(s=>s.trim());return e==="dark"&&o||n}function Br(e){const t={};function n(o,s=""){for(const[i,a]of Object.entries(o)){const l=s?`${s}.${i}`:i;a&&typeof a=="object"&&!Array.isArray(a)?n(a,l):t[l]=a}}return n(e),t}function ut({template:e,variables:t,variableKeyPattern:n,variableValueTransformer:o}){return Object.entries(t).reduce((s,[i,a])=>{if(!o&&!["number","boolean","string"].includes(typeof a))throw new Error("If transformer is not provided, value must be a {string, number, or boolean}");const l=o?o(a):String(a),u=n(i);return s.replace(u,un(l))},e)}async function Fr({template:e,variables:t,variableKeyPattern:n,variableValueTransformer:o}){return(await Promise.all(Object.entries(t).map(async([i,a])=>{const l=await o(a);return{regex:n(i),transformedValue:l}}))).reduce((i,{regex:a,transformedValue:l})=>i.replace(a,un(l)),e)}const zr=e=>({setTemplate:(t,n)=>e.onSetTemplate(t,n),getTemplate:t=>e.onGetTemplate(t),setCachedToken:t=>e.onSetCachedToken(t),getCachedToken:()=>e.onGetCachedToken(),clear:()=>e.onClear()}),{Provider:Hr,useContext:mn}=F("MessageCacheTemplate");function Ur({logger:e,storage:t,children:n}){const o=d.useCallback(a=>{var h,g;const l=(g=(h=a.appInfo)==null?void 0:h.aiAgentInfo)==null?void 0:g.templateListToken;if(!l)return!1;const u=t.getCachedToken();return u?l!==u:!0},[t]),s=d.useCallback(async a=>{try{const{templates:l,token:u}=await a.aiAgent.getMessageTemplates({limit:20});for(const{template:h}of l){const{key:g}=Se(h);t.setTemplate(g,h)}t.setCachedToken(u)}catch(l){e==null||e.error("messageTemplateContext.syncCachedTemplates: error:",l)}},[t,e]),i=d.useCallback(()=>{t.clear()},[t]);return r.createElement(Hr,{value:{shouldSyncCachedTemplate:o,syncCachedTemplates:s,clearCachedTemplates:i,storage:t}},n)}function Wr(e){let t="pending",n=e.then(o=>{t="resolved",n=o}).catch(o=>{t="rejected",n=o});return{get value(){if(t==="resolved")return n;throw n}}}const{Provider:Vr,useContext:gn}=F("MessageTemplateFetching");function jr({children:e,internalVariables:t}){const n=d.useRef({}),o=d.useRef({}),[s,i]=d.useState({}),a=d.useCallback((h,g)=>{i(p=>({...p,[h]:{fetching:!1,error:!1,...p[h],...g}}))},[]),l=d.useCallback(async({onRequestTemplate:h,onGetCachedTemplate:g,templateKey:p,suspense:f=!1})=>{const x=g(p);if(x)return x;const E=o.current[p];if(E)return E;f||a(p,{fetching:!0});const y=h(p).catch(b=>{throw f||a(p,{error:!0}),b}).finally(()=>{f||a(p,{fetching:!1}),delete o.current[p]});return o.current[p]=y,y},[a]),u={internalVariables:t,fetchTemplate:l,suspend:(h,g)=>{if(n.current[h])return n.current[h];const p=Wr(g());return n.current[h]=p,p},getIsFetching:h=>{var g;return((g=s[h])==null?void 0:g.fetching)??!1},getHasError:h=>{var g;return((g=s[h])==null?void 0:g.error)??!1}};return r.createElement(Vr,{value:u},e)}const We={VARIABLE:e=>new RegExp(`\\{${e}\\}`,"g"),VIEW_VARIABLE:e=>new RegExp(`"{@${e}}"`,"g")};function ee({uiTemplateString:e,variables:t={}}){const n=Br(t);return ut({template:e,variables:n,variableKeyPattern:o=>We.VARIABLE(o)})}function te({theme:e,uiTemplateString:t,colorVariables:n={}}){return ut({template:t,variables:n,variableKeyPattern:o=>We.VARIABLE(o),variableValueTransformer:o=>Dr(e,o)})}function Gr({theme:e,uiTemplateString:t,viewVariables:n={},aiAgentColorVariables:o,internalVariables:s,onRequestTemplate:i}){const l=Object.values(n).flat().map(h=>h.key);return[...new Set(l)].some(h=>!i(h))?null:ut({template:t,variables:n,variableKeyPattern:h=>We.VIEW_VARIABLE(h),variableValueTransformer:h=>{const g=h.map(({key:p,variables:f})=>{const x=i(p),{ui_template:E,color_variables:y}=Se(x);let b=JSON.stringify(E);return b=ee({uiTemplateString:b,variables:s}),b=te({theme:e,uiTemplateString:b,colorVariables:y}),b=te({theme:e,uiTemplateString:b,colorVariables:o}),b=ee({uiTemplateString:b,variables:f}),Ue(b)});return JSON.stringify(g)}})}async function qr({theme:e,uiTemplateString:t,viewVariables:n={},aiAgentColorVariables:o,internalVariables:s,onRequestTemplate:i}){return Fr({template:t,variables:n,variableKeyPattern:a=>We.VIEW_VARIABLE(a),variableValueTransformer:async a=>{const l=a.map(async({key:h,variables:g})=>{const p=await i(h),{ui_template:f,color_variables:x}=Se(p);let E=JSON.stringify(f);return E=ee({uiTemplateString:E,variables:s}),E=te({theme:e,uiTemplateString:E,colorVariables:x}),E=te({theme:e,uiTemplateString:E,colorVariables:o}),E=ee({uiTemplateString:E,variables:g}),Ue(E)}),u=await Promise.all(l);return JSON.stringify(u)}})}const Kr=({rawTemplate:e,aiAgentColorVariables:t,internalVariables:n,...o})=>{const{ui_template:s,color_variables:i}=Se(e);let a=JSON.stringify(s);if(Object.keys(o.viewVariables??{}).length>0){const u=Gr({...o,uiTemplateString:a,aiAgentColorVariables:t,internalVariables:n});if(u===null)return null;a=u}return a=ee({...o,uiTemplateString:a,variables:n}),a=te({...o,uiTemplateString:a,colorVariables:i}),a=te({...o,uiTemplateString:a,colorVariables:t}),a=ee({...o,uiTemplateString:a}),Ue(a)},Zr=async({rawTemplate:e,aiAgentColorVariables:t,internalVariables:n,...o})=>{const{ui_template:s,color_variables:i}=Se(e);let a=JSON.stringify(s);return Object.keys(o.viewVariables??{}).length>0&&(a=await qr({...o,uiTemplateString:a,aiAgentColorVariables:t,internalVariables:n})),a=ee({...o,uiTemplateString:a,variables:n}),a=te({...o,uiTemplateString:a,colorVariables:i}),a=te({...o,uiTemplateString:a,colorVariables:t}),a=ee({...o,uiTemplateString:a}),Ue(a)},Yr=e=>{const{aiAgentColorVariables:t={}}=e,{internalVariables:n}=gn();return d.useState(()=>{const o=e.onGetCachedTemplate(e.templateKey);return o?Kr({...e,rawTemplate:o,aiAgentColorVariables:t,internalVariables:n,onRequestTemplate:e.onGetCachedTemplate}):null})},Jr=e=>{const[t]=Yr(e);if(t)return t;const{aiAgentColorVariables:n={}}=e,{internalVariables:o,fetchTemplate:s,suspend:i}=gn();return i(e.templateKey,async()=>{const l=await s({...e,suspense:!0});return await Zr({...e,rawTemplate:l,aiAgentColorVariables:n,internalVariables:o})}).value},Xr='@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;bottom:0;left:0;right: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}',Te="en",Qr=new Set([Te,"ko","es","pt","fr","hi","it","de","tr","ja"]),eo=(e,t,n)=>{const o=e[t];return o?typeof o=="function"?o():Promise.resolve(o):new Promise((s,i)=>{(typeof queueMicrotask=="function"?queueMicrotask:setTimeout)(i.bind(null,new Error("Unknown variable dynamic import: "+t+(t.split("/").length!==n?". Note that variables only represent file names one level deep.":""))))})},to=nr.enUS,no={CHANNEL_FROZEN:"Channel frozen",PLACE_HOLDER__WRONG:"Something went wrong",PLACE_HOLDER__NO_MESSAGES:"No messages",UNKNOWN__UNKNOWN_MESSAGE_TYPE:"(Unknown message type)",HEADER_BUTTON__AGENT_HANDOFF:"Connect with an agent",MESSAGE_INPUT__PLACE_HOLDER:"Ask a question",MESSAGE_INPUT__PLACE_HOLDER__WAIT_AI_AGENT_RESPONSE:"Waiting for the agent’s reply…",MESSAGE_INPUT__PLACE_HOLDER__DISABLED:"Chat is unavailable in this channel",BUTTON__CANCEL:"Cancel",BUTTON__SAVE:"Save",BUTTON__OK:"OK",NO_NAME:"(No name)",RETRY:"Retry",DATE_FORMAT__MESSAGE_LIST__DATE_SEPARATOR:"MMMM dd, yyyy",DATE_FORMAT__MESSAGE_TIMESTAMP:"p",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",CSAT_TITLE_UNSUBMITTED:"Your feedback matters to us",CSAT_TITLE_SUBMITTED:"Successfully submitted!",CSAT_CRE_TITLE:"Was your issue resolved?",CSAT_CRE_SOLVED:"Yes, thank you! 👍",CSAT_CRE_NOT_SOLVED:"No, that didn’t help.",CSAT_REASON_PLACEHOLDER:"Share your feedback",CSAT_RATING_TITLE:"How would you rate your experience?",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",CSAT_SUBMIT_LABEL:"Submit",CSAT_SUBMISSION_EXPIRED:"We’re sorry, the survey period has ended.",POWERED_BY:"Powered by",CONVERSATION_CLOSED_FOOTER_LABEL:"Your conversation has ended",START_NEW_CONVERSATION:"💬 Start a new conversation",RETURN_TO_CONVERSATION:"💬 Return to conversation",CONVERSATION_LIST__HEADER_TITLE:"Conversation history",CONVERSATION_LIST__TOPICS_FALLBACK:"No category",CONVERSATION_LIST__NO_CONVERSATIONS:"No conversations yet",DATE_FORMAT__CONVERSATION_LIST__LIST_ITEM_TITLE:"MM/dd/yyyy",DATE_FORMAT__CONVERSATION_LIST__LIST_ITEM_TITLE_CAPTION:"h:mma"},mt={language:"en",dateLocale:to,stringSet:no},ro=Object.freeze(Object.defineProperty({__proto__:null,default:mt},Symbol.toStringTag,{value:"Module"})),Pe=new Map([[Te,mt]]);async function oo(e){if(Pe.has(e))return Pe.get(e);const t=Qr.has(e)?e:Te;try{const{default:n}=await eo(Object.assign({"./languages/de.ts":()=>Promise.resolve().then(()=>require("./DowWpnG0.cjs")),"./languages/en.ts":()=>Promise.resolve().then(()=>ro),"./languages/es.ts":()=>Promise.resolve().then(()=>require("./C1Vn3mTH.cjs")),"./languages/fr.ts":()=>Promise.resolve().then(()=>require("./DMo1MF5p.cjs")),"./languages/hi.ts":()=>Promise.resolve().then(()=>require("./B-7iTaEa.cjs")),"./languages/it.ts":()=>Promise.resolve().then(()=>require("./CKKH64uB.cjs")),"./languages/ja.ts":()=>Promise.resolve().then(()=>require("./CMUqnGWo.cjs")),"./languages/ko.ts":()=>Promise.resolve().then(()=>require("./BvIqSXsB.cjs")),"./languages/pt.ts":()=>Promise.resolve().then(()=>require("./CrKG9A2m.cjs")),"./languages/tr.ts":()=>Promise.resolve().then(()=>require("./FdyX1U8o.cjs"))}),`./languages/${t}.ts`,3);return Pe.set(e,n),n}catch{return mt}}const{Provider:so,useContext:I}=F("Localization");function io(e){var t;return((t=e.split("-"))==null?void 0:t[0])??Te}function ao({language:e=navigator.language,logger:t,stringSet:n,children:o}){const[s,i]=d.useState(Pe.get(Te));return d.useEffect(()=>{const a=io(e);s.language!==a&&(t==null||t.debug("localization.useEffect: update language",`${s.language} -> ${a}`),oo(a).then(i))},[e]),r.createElement(so,{value:{language:s.language,stringSet:{...s.stringSet,...n},dateLocale:s.dateLocale,format:(a,l,u)=>Ce.format(a,l,{locale:s.dateLocale,...u})}},o)}const Ne="data-sb-agent-theme",Ot=e=>(t,...n)=>{let o="";return t.forEach((s,i)=>{o+=s+(n[i]??"")}),`[${Ne}='${e}'] & { ${o} }`},L={light:Ot("light"),dark:Ot("dark")},lo=c.css(({theme:e})=>{const{palette:t}=e;return`
1
+ "use strict";const d=require("react"),N=require("@sendbird/chat"),c=require("styled-components"),Ce=require("date-fns"),rr=require("date-fns/locale/en-US"),P=require("@sendbird/chat/aiAgent"),ze=require("@sendbird/uikit-tools"),or=require("@sendbird/chat/groupChannel"),on=require("@sendbird/chat/message"),sr=require("date-fns/isSameDay"),nt=require("@sendbird/react-uikit-message-template-view"),ir=require("@sendbird/uikit-message-template"),sn=require("dompurify"),ar=require("react-dom"),lr=require("@emotion/is-prop-valid");function cr(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const r=cr(d),F=(e,t)=>{const n=d.createContext(null),o=({children:i,value:l})=>r.createElement(n.Provider,{value:l},typeof i=="function"?i(l):i),s=({children:i})=>r.createElement(n.Consumer,null,l=>l?typeof i=="function"?i(l):i:null),a=()=>{const i=d.useContext(n);if(!i)throw new Error(`use${e}Context must be used within a ${e}Provider`);return i};return n.displayName=`${e}Context`,o.displayName=`${e}Provider`,s.displayName=`${e}Consumer`,a.displayName=`use${e}Context`,{Context:n,Provider:o,Consumer:s,useContext:a}};function pe(e){const t=d.createContext({Template:e.template,updateTemplate:()=>{},components:e.components,updateComponent:()=>{}});function n({children:a}){const[i,l]=d.useState(()=>e.template),[u,h]=d.useState(e.components),g={Template:i,updateTemplate:p=>l(()=>p),components:u,updateComponent:(p,f)=>h(x=>({...x,[p]:f}))};return r.createElement(t.Provider,{value:g},a)}function o({template:a,children:i}){const{updateTemplate:l}=d.useContext(t);return d.useEffect(()=>{a&&l(a)},[a]),r.createElement(r.Fragment,null,i)}function s({children:a}){return r.createElement(n,null,a)}return s.defaults=e,s.useContext=()=>d.useContext(t),s.Context=t,s.Template=o,Object.keys(e.components).forEach(a=>{s[a]=function({component:l}){const{updateComponent:u}=d.useContext(t);return d.useEffect(()=>{l&&u(a,l)},[l]),null}}),s}function dr(...e){return function({children:n}){return e.reduce((o,s)=>r.createElement(s,null,o),n)}}function rt(){}function ur(){const e=/iPad|iPhone|iPod/.test(navigator.userAgent),t=/Android/.test(navigator.userAgent);return e||t}class an{constructor(t){this.logger=t,this.subscribers={}}async send(t){const n=mr(),o=this.subscribers[t.type];if(o){this.logger.debug(`messenger.dispatcher: dispatching command: ${t.type}`,t.payload);const s=o.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(o=>o!==n))}}const mr=()=>{let e=rt,t=rt;return{promise:new Promise((o,s)=>{e=o,t=s}),resolve:e,reject:t}},gr="1.1.0",ve="sb-agent",hr=gr;var ut=(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))(ut||{});class ln{constructor(t){this.level=t}verbose(...t){this.level<=0&&console.log(`[${ve}/verbose]`,...t)}debug(...t){this.level<=1&&console.log(`[${ve}/debug]`,...t)}info(...t){this.level<=2&&console.log(`[${ve}/info]`,...t)}warn(...t){this.level<=3&&console.warn(`[${ve}/warn]`,...t)}error(...t){this.level<=4&&console.error(`[${ve}/error]`,...t)}}function Mt(e,t,n){const o=N.init({appId:e,modules:[new or.GroupChannelModule,new P.AIAgentModule],localCacheEnabled:!0,...n});return o.addSendbirdExtensions([{version:hr,product:N.SendbirdProduct.AI_AGENT,platform:t.platform}],{platform:t.deviceOSPlatform,version:t.deviceOSVersion},t.customData)||console.warn("Invalid Sendbird Extensions",t),o}const{Provider:pr,useContext:He}=F("AIAgent");function fr({appId:e,aiAgentId:t,language:n,countryCode:o,context:s,chatSDK:a,chatParams:i,dispatcher:l,logger:u,children:h,extensions:g={platform:N.SendbirdPlatform.JS,deviceOSPlatform:ur()?N.DeviceOsPlatform.MOBILE_WEB:N.DeviceOsPlatform.WEB}}){const[p,f]=d.useState(()=>{const x=u??new ln(ut.WARN),E=l??new an(x);return{appId:e,aiAgentId:t,language:n,countryCode:o,context:s,chatSDK:a??Mt(e,g,i),logger:x,dispatcher:E}});return(n!==p.language||o!==p.countryCode)&&f(x=>({...x,language:n,countryCode:o,context:s})),a&&a!==p.chatSDK?f(x=>({...x,aiAgentId:t,chatSDK:a})):!a&&p.chatSDK.appId!==e&&f(x=>({...x,aiAgentId:t,chatSDK:Mt(e,g,{newInstance:!0,...i})})),d.useEffect(()=>()=>{p.chatSDK.disconnectWebSocket()},[p.chatSDK]),r.createElement(pr,{value:p},h)}const br=(e,t,n)=>ze.useGroupChannelMessages(e,t,{...n,strictStreamingOrder:!0});var ot=(e=>(e.ConversationClose="conv.close",e))(ot||{});class xr{constructor(t={}){this.payload=t}toJSON(){return JSON.stringify({type:this.type,payload:this.payload})}}class Er extends xr{constructor(){super(...arguments),this.type="conv.close"}}const cn={CloseConversation:()=>new Er},{Provider:vr}=F("AIAgentConversation");function yr({children:e,channelUrl:t,onChannelDeleted:n,onMessagesUpdated:o,onConversationClosedViaDispatcher:s,onBeforeSendMessage:a,onAfterSendMessage:i=rt}){var y;const{chatSDK:l,logger:u,dispatcher:h}=He(),{channel:g,channelFetchError:p,fetchChannel:f}=Cr(t),x=br(l,g,{shouldCountNewMessages:()=>!1,onChannelDeleted:n,onMessagesReceived:o,onMessagesUpdated:o,logger:u});d.useEffect(()=>{const b=async()=>{u.debug("conversation.dispatcher: try to close conversation",g),g!=null&&g.conversation&&g.conversation.status===P.ConversationStatus.OPEN&&(await g.closeConversation(),s==null||s())};return h.subscribe(ot.ConversationClose,b),()=>{h.unsubscribe(ot.ConversationClose,b)}},[h,(y=g==null?void 0:g.conversation)==null?void 0:y.status,s]);const E={conversation:(g==null?void 0:g.conversation)??void 0,channelSource:{channel:g,error:p,refetch:()=>f()},messageSource:{messages:x.messages,initialized:x.initialized,loadPrevious:()=>x.loadPrevious(),loadNext:()=>x.loadNext(),sendUserMessage:async b=>{a&&(b=await a(b));const C=await x.sendUserMessage(b,i);return i==null||i(C),C},sendFileMessage:async b=>{a&&(b=await a(b));const C=await x.sendFileMessage(b,i);return i==null||i(C),C}}};return r.createElement(vr,{value:E},e)}function Cr(e){const{chatSDK:t,logger:n}=He(),[o,s]=d.useState(void 0),[a,i]=d.useState(void 0);async function l(){if(n.debug("conversation.fetchChannel: start"),s(void 0),i(void 0),e)try{n.debug("conversation.fetchChannel: get channel",e);const u=await t.groupChannel.getChannel(e);s(u);const h=new N.ConnectionHandler({onReconnectSucceeded:()=>u.refresh()});t.addConnectionHandler("sba-refresh",h),n.debug("conversation.fetchChannel: fetched channel",u)}catch(u){u instanceof N.SendbirdError&&i(u),n.error("conversation.fetchChannel: error",u)}}return d.useEffect(()=>{l()},[e,t]),{channel:o,channelFetchError:a,fetchChannel:l}}const Sr=(e,t)=>{const n=d.useId(),[o,s]=d.useState(!1),[a,i]=d.useState(null),[l,u]=d.useState([]),[h,g]=d.useState(null),p=d.useRef(!1),f=d.useCallback(async()=>{if(!p.current&&e.currentUser){p.current=!0,s(!1),i(null),u([]);try{const E=e.aiAgent.createConversationListQuery(t),y=await E.next();u(y),g(E),i(null)}catch(E){g(null),i(E)}finally{s(!0),p.current=!1}}},[e,t.aiAgentId,t.status,t.limit,t.order,t.reverse]),x=d.useCallback(async()=>{h&&h.next().then(E=>{u(y=>[...y,...E])}).catch(()=>{})},[h]);return d.useEffect(()=>(e.addConnectionHandler(n,new N.ConnectionHandler({onConnected:()=>f()})),()=>e.removeConnectionHandler(n)),[e,n,f]),d.useEffect(()=>{f()},[f]),{initialized:o,error:a,conversations:l,loadMore:x}},{Provider:Tr}=F("AIAgentConversationList");function _r({children:e}){const{chatSDK:t,aiAgentId:n}=He(),o=Sr(t,{aiAgentId:n,status:P.ConversationStatus.CLOSED,order:P.ConversationListOrder.UPDATED_AT,reverse:!0}),s={listSource:{initialized:o.initialized,error:o.error??void 0,conversations:o.conversations,loadMore:()=>o.loadMore()}};return r.createElement(Tr,{value:s},e)}const st={DEFAULT_BOT_MSG_BG:"#eeeeee",WHITE:"#ffffff",BLACK:"#000000"};function dn(e){return e.length===4?`#${[...e.slice(1)].map(t=>t+t).join("")}`:e}function wr(e){const t=dn(e);return[parseInt(t.slice(1,3),16),parseInt(t.slice(3,5),16),parseInt(t.slice(5,7),16)]}function kr(e){return`#${e.map(t=>t.toString(16).padStart(2,"0")).join("")}`}function Ar(e,t,n){e/=255,t/=255,n/=255;const o=Math.max(e,t,n),s=Math.min(e,t,n),a=o-s;let i=0,l=0;const u=(o+s)/2;return o!==s&&(l=u>.5?a/(2-o-s):a/(o+s)),o===e?i=(t-n)/a+(t<n?6:0):o===t?i=(n-e)/a+2:o===n&&(i=(e-t)/a+4),i/=6,[i,l,u]}function Ir(e,t,n){let o,s,a;if(t===0)o=s=a=n;else{const i=function(g,p,f){return f<0&&(f+=1),f>1&&(f-=1),f<.16666666666666666?g+(p-g)*6*f:f<.5?p:f<.6666666666666666?g+(p-g)*(.6666666666666666-f)*6:g},l=n<.5?n*(1+t):n+t-n*t,u=2*n-l;o=i(u,l,e+1/3),s=i(u,l,e),a=i(u,l,e-1/3)}return[Math.round(o*255),Math.round(s*255),Math.round(a*255)]}function Ae(e,t,n){const[o,s,a]=wr(e),[i,l,u]=Ar(o,s,a),h=Math.max(0,Math.min(1,u*t)),g=Math.max(0,Math.min(1,l*n)),[p,f,x]=Ir(i,g,h);return kr([Math.round(p),Math.round(f),Math.round(x)])}function $r(e,t="light"){return{extraDark:Ae(e,.6,1.2),dark:Ae(e,.85,1.1),main:e,light:Ae(e,t==="dark"?1.1:1.5,t==="dark"?.95:.9),extraLight:Ae(e,t==="dark"?1.2:1.75,t==="dark"?.9:.8)}}function it(e){const t=dn(e),n=149,o=+`0x${t[1]}${t[2]}`,s=+`0x${t[3]}${t[4]}`,a=+`0x${t[5]}${t[6]}`;return o*.299+s*.587+a*.114>n?st.BLACK:st.WHITE}function Mr(e,t,n,o,s){return{base:{primary:t,primaryContrastContent:n,background:e.background50,headerBackground:e.background50,modalContentBackground:e.background50},metadata:{errorContent:e.ondark.textHighEmphasis,placeholderText:e.onlight.textLowEmphasis},messageInput:{background:e.background100},messageIncoming:{text:s,background:o},messageOutgoing:{text:n,background:t},csat:{background:e.background100}}}const Or=(e,t,n,o,s)=>({base:{primary:t,primaryContrastContent:n,background:e.background600,headerBackground:e.background500,modalContentBackground:e.background500},metadata:{errorContent:e.ondark.textHighEmphasis,placeholderText:e.ondark.textLowEmphasis},messageInput:{background:e.background400},messageIncoming:{text:s,background:o},messageOutgoing:{text:n,background:t},csat:{background:e.background400}}),Ie={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)"}},Je={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 Ot(e){const t=Lr(e),{colors:n,aiAgentColorVariables:o}=Rr(e,t),s=Nr(e);return{selectedTheme:e.selectedTheme,palette:t,colors:n,aiAgentColorVariables:o,typography:s}}function Lr({selectedTheme:e,palette:t,primary:n}){const o=t!=null&&t.primary?t.primary:n?n===Ie.primary.main?Ie.primary:$r(n,e):Ie.primary;return{...Ie,primary:o,...t}}function Rr({selectedTheme:e,primaryContrast:t,botMessageBackground:n,botMessageBackgroundContrast:o},s){const a=s.primary.main,i=t??it(a),l=n??st.DEFAULT_BOT_MSG_BG,u=o??it(l);return{colors:(e==="light"?Mr:Or)(s,a,i,l,u),aiAgentColorVariables:{primary_color:a,bot_message_bg_color:l,primary_contrast_color:i,bot_message_bg_contrast_color:u}}}function Pr(e,t,n){const o={...e};return n.forEach(s=>{const a=t[s];a!=null&&(o[s]=a)}),o}function Nr({typography:e}){if(!e)return Je;const t={...Je};return Object.keys(e).forEach(n=>{const o=e[n];if(o&&typeof o=="object"){const s=Je[n],a=["fontSize","fontWeight","fontFamily","lineHeight"];t[n]=Pr(s,o,a)}}),t}const{Provider:Dr,useContext:un}=F("AIAgentTheme");function Br({logger:e,palette:t,typography:n,appearance:o,children:s}){const[a,i]=d.useState(()=>Ot({selectedTheme:(o==null?void 0:o.theme)??"light",palette:t,typography:n,primary:o==null?void 0:o.primaryColor,botMessageBackground:o==null?void 0:o.botMessageBackgroundColor})),l=d.useCallback((u,h)=>{const g=(o==null?void 0:o.theme)??u,p=h==null?void 0:h(g),f={primary:o==null?void 0:o.primaryColor,primaryContrast:void 0,botMessageBackground:o==null?void 0:o.botMessageBackgroundColor,botMessageBackgroundContrast:void 0};!f.primary&&(p!=null&&p.primaryColor)&&(f.primary=p.primaryColor,f.primaryContrast=p.primaryContrastColor),!f.botMessageBackground&&(p!=null&&p.botMessageBackgroundColor)&&(f.botMessageBackground=p.botMessageBackgroundColor,f.botMessageBackgroundContrast=p.botMessageBackgroundContrastColor);const x=Ot({selectedTheme:g,palette:t,typography:n,...f});i(x),e==null||e.info("theme.update:",g)},[o==null?void 0:o.theme,o==null?void 0:o.primaryColor,o==null?void 0:o.botMessageBackgroundColor,t,n,e]);return d.useEffect(()=>{(o!=null&&o.theme||o!=null&&o.primaryColor||o!=null&&o.botMessageBackgroundColor)&&l(a.selectedTheme)},[o==null?void 0:o.theme,o==null?void 0:o.primaryColor,o==null?void 0:o.botMessageBackgroundColor]),r.createElement(Dr,{value:{theme:a,updateTheme:l}},s)}const mn=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)}},Se=e=>JSON.parse(e),Ue=e=>JSON.parse(e);function Fr(e,t){const[n,o]=t.split(",").map(s=>s.trim());return e==="dark"&&o||n}function zr(e){const t={};function n(o,s=""){for(const[a,i]of Object.entries(o)){const l=s?`${s}.${a}`:a;i&&typeof i=="object"&&!Array.isArray(i)?n(i,l):t[l]=i}}return n(e),t}function mt({template:e,variables:t,variableKeyPattern:n,variableValueTransformer:o}){return Object.entries(t).reduce((s,[a,i])=>{if(!o&&!["number","boolean","string"].includes(typeof i))throw new Error("If transformer is not provided, value must be a {string, number, or boolean}");const l=o?o(i):String(i),u=n(a);return s.replace(u,mn(l))},e)}async function Hr({template:e,variables:t,variableKeyPattern:n,variableValueTransformer:o}){return(await Promise.all(Object.entries(t).map(async([a,i])=>{const l=await o(i);return{regex:n(a),transformedValue:l}}))).reduce((a,{regex:i,transformedValue:l})=>a.replace(i,mn(l)),e)}const Ur=e=>({setTemplate:(t,n)=>e.onSetTemplate(t,n),getTemplate:t=>e.onGetTemplate(t),setCachedToken:t=>e.onSetCachedToken(t),getCachedToken:()=>e.onGetCachedToken(),clear:()=>e.onClear()}),{Provider:Wr,useContext:gn}=F("MessageCacheTemplate");function Vr({logger:e,storage:t,children:n}){const o=d.useCallback(i=>{var h,g;const l=(g=(h=i.appInfo)==null?void 0:h.aiAgentInfo)==null?void 0:g.templateListToken;if(!l)return!1;const u=t.getCachedToken();return u?l!==u:!0},[t]),s=d.useCallback(async i=>{try{const{templates:l,token:u}=await i.aiAgent.getMessageTemplates({limit:20});for(const{template:h}of l){const{key:g}=Se(h);t.setTemplate(g,h)}t.setCachedToken(u)}catch(l){e==null||e.error("messageTemplateContext.syncCachedTemplates: error:",l)}},[t,e]),a=d.useCallback(()=>{t.clear()},[t]);return r.createElement(Wr,{value:{shouldSyncCachedTemplate:o,syncCachedTemplates:s,clearCachedTemplates:a,storage:t}},n)}function jr(e){let t="pending",n=e.then(o=>{t="resolved",n=o}).catch(o=>{t="rejected",n=o});return{get value(){if(t==="resolved")return n;throw n}}}const{Provider:Gr,useContext:hn}=F("MessageTemplateFetching");function qr({children:e,internalVariables:t}){const n=d.useRef({}),o=d.useRef({}),[s,a]=d.useState({}),i=d.useCallback((h,g)=>{a(p=>({...p,[h]:{fetching:!1,error:!1,...p[h],...g}}))},[]),l=d.useCallback(async({onRequestTemplate:h,onGetCachedTemplate:g,templateKey:p,suspense:f=!1})=>{const x=g(p);if(x)return x;const E=o.current[p];if(E)return E;f||i(p,{fetching:!0});const y=h(p).catch(b=>{throw f||i(p,{error:!0}),b}).finally(()=>{f||i(p,{fetching:!1}),delete o.current[p]});return o.current[p]=y,y},[i]),u={internalVariables:t,fetchTemplate:l,suspend:(h,g)=>{if(n.current[h])return n.current[h];const p=jr(g());return n.current[h]=p,p},getIsFetching:h=>{var g;return((g=s[h])==null?void 0:g.fetching)??!1},getHasError:h=>{var g;return((g=s[h])==null?void 0:g.error)??!1}};return r.createElement(Gr,{value:u},e)}const We={VARIABLE:e=>new RegExp(`\\{${e}\\}`,"g"),VIEW_VARIABLE:e=>new RegExp(`"{@${e}}"`,"g")};function ee({uiTemplateString:e,variables:t={}}){const n=zr(t);return mt({template:e,variables:n,variableKeyPattern:o=>We.VARIABLE(o)})}function te({theme:e,uiTemplateString:t,colorVariables:n={}}){return mt({template:t,variables:n,variableKeyPattern:o=>We.VARIABLE(o),variableValueTransformer:o=>Fr(e,o)})}function Kr({theme:e,uiTemplateString:t,viewVariables:n={},aiAgentColorVariables:o,internalVariables:s,onRequestTemplate:a}){const l=Object.values(n).flat().map(h=>h.key);return[...new Set(l)].some(h=>!a(h))?null:mt({template:t,variables:n,variableKeyPattern:h=>We.VIEW_VARIABLE(h),variableValueTransformer:h=>{const g=h.map(({key:p,variables:f})=>{const x=a(p),{ui_template:E,color_variables:y}=Se(x);let b=JSON.stringify(E);return b=ee({uiTemplateString:b,variables:s}),b=te({theme:e,uiTemplateString:b,colorVariables:y}),b=te({theme:e,uiTemplateString:b,colorVariables:o}),b=ee({uiTemplateString:b,variables:f}),Ue(b)});return JSON.stringify(g)}})}async function Zr({theme:e,uiTemplateString:t,viewVariables:n={},aiAgentColorVariables:o,internalVariables:s,onRequestTemplate:a}){return Hr({template:t,variables:n,variableKeyPattern:i=>We.VIEW_VARIABLE(i),variableValueTransformer:async i=>{const l=i.map(async({key:h,variables:g})=>{const p=await a(h),{ui_template:f,color_variables:x}=Se(p);let E=JSON.stringify(f);return E=ee({uiTemplateString:E,variables:s}),E=te({theme:e,uiTemplateString:E,colorVariables:x}),E=te({theme:e,uiTemplateString:E,colorVariables:o}),E=ee({uiTemplateString:E,variables:g}),Ue(E)}),u=await Promise.all(l);return JSON.stringify(u)}})}const Yr=({rawTemplate:e,aiAgentColorVariables:t,internalVariables:n,...o})=>{const{ui_template:s,color_variables:a}=Se(e);let i=JSON.stringify(s);if(Object.keys(o.viewVariables??{}).length>0){const u=Kr({...o,uiTemplateString:i,aiAgentColorVariables:t,internalVariables:n});if(u===null)return null;i=u}return i=ee({...o,uiTemplateString:i,variables:n}),i=te({...o,uiTemplateString:i,colorVariables:a}),i=te({...o,uiTemplateString:i,colorVariables:t}),i=ee({...o,uiTemplateString:i}),Ue(i)},Jr=async({rawTemplate:e,aiAgentColorVariables:t,internalVariables:n,...o})=>{const{ui_template:s,color_variables:a}=Se(e);let i=JSON.stringify(s);return Object.keys(o.viewVariables??{}).length>0&&(i=await Zr({...o,uiTemplateString:i,aiAgentColorVariables:t,internalVariables:n})),i=ee({...o,uiTemplateString:i,variables:n}),i=te({...o,uiTemplateString:i,colorVariables:a}),i=te({...o,uiTemplateString:i,colorVariables:t}),i=ee({...o,uiTemplateString:i}),Ue(i)},Xr=e=>{const{aiAgentColorVariables:t={}}=e,{internalVariables:n}=hn();return d.useState(()=>{const o=e.onGetCachedTemplate(e.templateKey);return o?Yr({...e,rawTemplate:o,aiAgentColorVariables:t,internalVariables:n,onRequestTemplate:e.onGetCachedTemplate}):null})},Qr=e=>{const[t]=Xr(e);if(t)return t;const{aiAgentColorVariables:n={}}=e,{internalVariables:o,fetchTemplate:s,suspend:a}=hn();return a(e.templateKey,async()=>{const l=await s({...e,suspense:!0});return await Jr({...e,rawTemplate:l,aiAgentColorVariables:n,internalVariables:o})}).value},eo='@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;bottom:0;left:0;right: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}',Te="en",to=new Set([Te,"ko","es","pt","fr","hi","it","de","tr","ja"]),no=(e,t,n)=>{const o=e[t];return o?typeof o=="function"?o():Promise.resolve(o):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.":""))))})},ro=rr.enUS,oo={CHANNEL_FROZEN:"Channel frozen",PLACE_HOLDER__WRONG:"Something went wrong",PLACE_HOLDER__NO_MESSAGES:"No messages",UNKNOWN__UNKNOWN_MESSAGE_TYPE:"(Unknown message type)",HEADER_BUTTON__AGENT_HANDOFF:"Connect with an agent",MESSAGE_INPUT__PLACE_HOLDER:"Ask a question",MESSAGE_INPUT__PLACE_HOLDER__WAIT_AI_AGENT_RESPONSE:"Waiting for the agent’s reply…",MESSAGE_INPUT__PLACE_HOLDER__DISABLED:"Chat is unavailable in this channel",BUTTON__CANCEL:"Cancel",BUTTON__SAVE:"Save",BUTTON__OK:"OK",NO_NAME:"(No name)",RETRY:"Retry",DATE_FORMAT__MESSAGE_LIST__DATE_SEPARATOR:"MMMM dd, yyyy",DATE_FORMAT__MESSAGE_TIMESTAMP:"p",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",CSAT_TITLE_UNSUBMITTED:"Your feedback matters to us",CSAT_TITLE_SUBMITTED:"Successfully submitted!",CSAT_CRE_TITLE:"Was your issue resolved?",CSAT_CRE_SOLVED:"Yes, thank you! 👍",CSAT_CRE_NOT_SOLVED:"No, that didn’t help.",CSAT_REASON_PLACEHOLDER:"Share your feedback",CSAT_RATING_TITLE:"How would you rate your experience?",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",CSAT_SUBMIT_LABEL:"Submit",CSAT_SUBMISSION_EXPIRED:"We’re sorry, the survey period has ended.",POWERED_BY:"Powered by",CONVERSATION_CLOSED_FOOTER_LABEL:"Your conversation has ended",START_NEW_CONVERSATION:"💬 Start a new conversation",RETURN_TO_CONVERSATION:"💬 Return to conversation",CONVERSATION_LIST__HEADER_TITLE:"Conversation history",CONVERSATION_LIST__TOPICS_FALLBACK:"No category",CONVERSATION_LIST__NO_CONVERSATIONS:"No conversations yet",DATE_FORMAT__CONVERSATION_LIST__LIST_ITEM_TITLE:"MM/dd/yyyy",DATE_FORMAT__CONVERSATION_LIST__LIST_ITEM_TITLE_CAPTION:"h:mma"},gt={language:"en",dateLocale:ro,stringSet:oo},so=Object.freeze(Object.defineProperty({__proto__:null,default:gt},Symbol.toStringTag,{value:"Module"})),Pe=new Map([[Te,gt]]);async function io(e){if(Pe.has(e))return Pe.get(e);const t=to.has(e)?e:Te;try{const{default:n}=await no(Object.assign({"./languages/de.ts":()=>Promise.resolve().then(()=>require("./DowWpnG0.cjs")),"./languages/en.ts":()=>Promise.resolve().then(()=>so),"./languages/es.ts":()=>Promise.resolve().then(()=>require("./C1Vn3mTH.cjs")),"./languages/fr.ts":()=>Promise.resolve().then(()=>require("./DMo1MF5p.cjs")),"./languages/hi.ts":()=>Promise.resolve().then(()=>require("./B-7iTaEa.cjs")),"./languages/it.ts":()=>Promise.resolve().then(()=>require("./CKKH64uB.cjs")),"./languages/ja.ts":()=>Promise.resolve().then(()=>require("./CMUqnGWo.cjs")),"./languages/ko.ts":()=>Promise.resolve().then(()=>require("./BvIqSXsB.cjs")),"./languages/pt.ts":()=>Promise.resolve().then(()=>require("./CrKG9A2m.cjs")),"./languages/tr.ts":()=>Promise.resolve().then(()=>require("./FdyX1U8o.cjs"))}),`./languages/${t}.ts`,3);return Pe.set(e,n),n}catch{return gt}}const{Provider:ao,useContext:I}=F("Localization");function lo(e){var t;return((t=e.split("-"))==null?void 0:t[0])??Te}function co({language:e=navigator.language,logger:t,stringSet:n,children:o}){const[s,a]=d.useState(Pe.get(Te));return d.useEffect(()=>{const i=lo(e);s.language!==i&&(t==null||t.debug("localization.useEffect: update language",`${s.language} -> ${i}`),io(i).then(a))},[e]),r.createElement(ao,{value:{language:s.language,stringSet:{...s.stringSet,...n},dateLocale:s.dateLocale,format:(i,l,u)=>Ce.format(i,l,{locale:s.dateLocale,...u})}},o)}const Ne="data-sb-agent-theme",Lt=e=>(t,...n)=>{let o="";return t.forEach((s,a)=>{o+=s+(n[a]??"")}),`[${Ne}='${e}'] & { ${o} }`},L={light:Lt("light"),dark:Lt("dark")},uo=c.css(({theme:e})=>{const{palette:t}=e;return`
2
2
  :root,
3
3
  :host {
4
4
  --sendbird-primary-extra-dark: ${t.primary.extraDark};
@@ -47,56 +47,57 @@
47
47
  --sendbird-overlay-dark: ${t.overlay.dark};
48
48
  --sendbird-overlay-light: ${t.overlay.light};
49
49
  }
50
- `}),co=c.css`[${Ne}='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);}[${Ne}='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);}`,m={color:{primary:{dark:"var(--sendbird-primary-dark)",main:"var(--sendbird-primary-main)"},error:{extraDark:"var(--sendbird-error-extra-dark)",dark:"var(--sendbird-error-dark)"},information:{main:"var(--sendbird-information-main)",light:"var(--sendbird-information-light)"},background700:"var(--sendbird-background-700)",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)",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)",bg_50_600:"var(--sb-bg-50-600)",bg_100_500:"var(--sb-bg-100-500)",bg_200_400:"var(--sb-bg-200-400)",error:"var(--sb-error)"}},{Provider:uo,useContext:mo}=F("AIAgentTheme");function go(e){const{theme:t,appearance:n,logger:o}=e;return r.createElement(Nr,{appearance:n,palette:t==null?void 0:t.palette,typography:t==null?void 0:t.typography,logger:o},r.createElement(ho,{...e}))}function ho({rootElement:e=document.body,children:t}){const{theme:n,updateTheme:o}=dn();return d.useLayoutEffect(()=>{e.setAttribute(Ne,n.selectedTheme)},[e,n.selectedTheme]),r.createElement(c.ThemeProvider,{theme:n},r.createElement(uo,{value:{theme:n,updateTheme:o}},t))}function le(e,t){const n=e.getRootNode({composed:t});return n instanceof ShadowRoot||n instanceof Document?n:document}const po=(e,t)=>{d.useEffect(()=>{const n=le(t)instanceof ShadowRoot,o=le(t,!0);if(!(n?t:o).querySelector(`link[href*='${e}']`)){const i=o.createElement("link");i.rel="stylesheet",i.href=e,(n?t:o.head).appendChild(i)}},[e,t])},fo=(e,t=document.body)=>{d.useEffect(()=>{const n=le(t),s=n instanceof ShadowRoot?t:n.head;if(!s)return;const i=`sba-${btoa(e).slice(0,10)}`;let a=s.querySelector(`style#${i}`);a?a.textContent!==e&&(a.textContent=e):(a=s.ownerDocument.createElement("style"),a.id=i,a.textContent=e,s.appendChild(a))},[e,t])},gt=/iPad|iPhone|iPod/.test(navigator.userAgent),bo=/Android/.test(navigator.userAgent),_e=e=>gt||bo,V="sb-agent",q={ENTRY:`${V}-entry`,MODAL_ROOT:`${V}-modal-root`,WINDOW:`${V}-window`,LAUNCHER:`${V}-launcher`},$e=2147483647,de={MODAL:$e-1,TOOLTIP:$e-2,WINDOW:$e-3,LAUNCHER:$e-4},hn={SESSION:`@${V}-session`,USER_DATA:`@${V}-udata`},pn={DEFAULT_PRIMARY:"#742ddd",WHITE:"#ffffff"},fn=36,xo=100,Eo=25*1024*1024,bn=["application/pdf","image/jpeg","image/jpg","image/png"],Ve="noopener noreferrer nofollow",Me={},G={getItem:e=>{try{return localStorage.getItem(e)}catch{return Me[e]??null}},setItem:(e,t)=>{try{localStorage.setItem(e,t)}catch{Me[e]=t}},deleteItem:e=>{try{localStorage.removeItem(e)}catch{delete Me[e]}},getKeys:e=>{try{const t=[];for(let n=0;n<localStorage.length;n++){const o=localStorage.key(n);o&&o.startsWith(e)&&t.push(o)}return t}catch{return Object.keys(Me).filter(t=>t.startsWith(e))}}};function xn(e){const{keyGenerator:t,keyParamsValidator:n}=e;function o(a){try{n&&n(a);const l=t(a),u=G.getItem(l);return u?JSON.parse(u):null}catch{return null}}function s(a,l){try{n&&n(a);const u=t(a),h=JSON.stringify(l);G.setItem(u,h)}catch{}}function i(a){try{n&&n(a);const l=t(a);G.deleteItem(l)}catch{}}return{get:o,set:s,clear:i}}const Xe=xn({keyGenerator:({appId:e,aiAgentId:t,userId:n})=>{const o=vo(`${e}/${t}/${n}`);return`${hn.USER_DATA}/${o}`},keyParamsValidator:({appId:e,aiAgentId:t,userId:n})=>{if(!e||!t||!n)throw new Error("Invalid parameters for user data cache")}});function vo(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 Qe=xn({keyGenerator:({appId:e,aiAgentId:t})=>`${hn.SESSION}/${e}/${t}`}),{Provider:yo,Consumer:En,useContext:O}=F("Agent");function Co({children:e,state:t,enableCloseConversationButton:n=!1,enableExpandButton:o=!0,enableAutoDisconnectInLauncher:s=!0,...i}){const a=He(),[l,u]=d.useState(!1),[h,g]=d.useState(!1),p={opened:(t==null?void 0:t.opened)??l,setOpened:(t==null?void 0:t.setOpened)??u,expanded:(t==null?void 0:t.expanded)??h,setExpanded:(t==null?void 0:t.setExpanded)??g};return r.createElement(yo,{value:{...i,...a,state:p,enableCloseConversationButton:n,enableExpandButton:o,enableAutoDisconnectInLauncher:s}},e)}function So(){const{chatSDK:e,logger:t}=O(),{shouldSyncCachedTemplate:n,syncCachedTemplates:o,clearCachedTemplates:s}=mn(),i=d.useCallback(async(l,u)=>{t.debug("authManager.authenticate: session:",l.userId),u&&e.setSessionHandler(new N.SessionHandler(u)),await e.connect(l.userId,l.authToken),t.debug("authManager.authenticate: user:",e.currentUser),n(e)&&await o(e)},[e,t,n,o]),a=d.useCallback(async()=>{t.debug("authManager.deauthenticate: disconnect"),await e.disconnect(),s()},[e,t,s]);return{authenticate:i,deauthenticate:a}}const To=24*60*60*1e3,{Provider:_o,useContext:R}=F("MessengerSession");function wo({userSessionInfo:e,children:t}){const{appId:n,aiAgentId:o,chatSDK:s,agentPreviewConfigs:i,state:a,logger:l,language:u,countryCode:h,context:g,handlers:p}=O(),{updateTheme:f}=dn(),{authenticate:x,deauthenticate:E}=So(),[y,b]=d.useState(void 0),[C,T]=d.useState(void 0),[_,$]=d.useState(null),[Z,D]=d.useState(null),[oe,be]=d.useState(null),v=i==null?void 0:i.forceCreateChannel;function B(){if(e){l.debug("messengerSession.initialize: manual session info detected");const w=["userId","authToken","sessionHandler"].filter(M=>!(M in e));return w.length>0&&l.error(`messengerSession.initialize: missing required keys in userSessionInfo: ${w.join(", ")}`),e}const k=Qe.get({appId:n,aiAgentId:o});return k?k.expireAt-To<=Date.now()?(l.debug("messengerSession.initialize: auto session expired, clear cache"),Qe.clear({appId:n,aiAgentId:o}),Xe.clear({appId:n,aiAgentId:o,userId:k.userId}),null):(l.debug("messengerSession.initialize: auto session info detected"),k):null}const Y=d.useCallback((k,w)=>{Xe.set({appId:n,aiAgentId:o,userId:k},{knownActiveChannelUrl:w})},[n,o]),H=d.useCallback(k=>{const w=Xe.get({appId:n,aiAgentId:o,userId:k});return w==null?void 0:w.knownActiveChannelUrl},[n,o]),Ye=d.useCallback(async()=>{if(_){l.debug("messengerSession.refreshActiveChannel: try to refresh active channel"),b(void 0);const k=await s.aiAgent.requestMessengerSettings({aiAgentId:o,userId:_.userId,language:u,country:h,context:g,forceCreateChannel:v,knownActiveChannelUrl:H(_.userId)});return Y(_.userId,k.active_channel.channel_url),b({url:k.active_channel.channel_url,status:P.ConversationStatus.OPEN}),l.info("messengerSession.refreshActiveChannel: refreshed active channel",k.active_channel.channel_url),k.active_channel.channel_url}else throw l.error("messengerSession.refreshActiveChannel: userSession is not ready"),new Error("userSession is not ready")},[s,n,o,_==null?void 0:_.userId,u,h,g,v,H,Y]);return ze.useGroupChannelHandler(s,{onChannelChanged:k=>{var w;k.isGroupChannel()&&k.url===(y==null?void 0:y.url)&&(l.info("messengerSession.channelChanged: channel.conversation",k.conversation),b({url:k.url,status:((w=k.conversation)==null?void 0:w.status)??P.ConversationStatus.OPEN}))},async onUserJoined(k,w){var U,ue;if(k.conversation&&k.conversation.type===P.ConversationType.PROACTIVE&&w.userId===((U=s.currentUser)==null?void 0:U.userId)){l.info("messengerSession.onUserJoined: proactive channel joined",k.url);const xe=((ue=k.conversation)==null?void 0:ue.status)??P.ConversationStatus.OPEN;b({url:k.url,status:xe}),a.setOpened(!0),ko({sound:document.hidden||!a.opened})}}}),d.useEffect(()=>{async function k(){l.debug("messengerSession.initialize: start");const w=B(),M=await s.aiAgent.requestMessengerSettings({aiAgentId:o,userId:w==null?void 0:w.userId,language:u,country:h,context:g,forceCreateChannel:v,knownActiveChannelUrl:H(w==null?void 0:w.userId)});l.debug("messengerSession.initialize: messenger settings response",M);let U=null;if(M.auto_created_user){const{user_id:W,session_token:J,expire_at:Ee}=M.auto_created_user;Qe.set({appId:n,aiAgentId:o},{userId:W,authToken:J,expireAt:Ee}),U={userId:W,authToken:J}}else U={userId:(w==null?void 0:w.userId)??"",authToken:(w==null?void 0:w.authToken)??""};Y(U.userId,M.active_channel.channel_url);function ue(){const W=M.appearance.selected_theme;f(W,Ee=>{const se=M.appearance.themes[Ee];return{primaryColor:se.primary_color,botMessageBackgroundColor:se.bot_message_bg_color,primaryContrastColor:se.primary_contrast_color,botMessageBackgroundContrastColor:se.bot_message_bg_contrast_color}}),T(void 0),$(U),D({userId:M.bot.bot_userid,profileUrl:M.bot.bot_profile_url,nickname:M.bot.bot_nickname,replyToFile:M.bot.reply_to_file,specialNotice:M.bot.special_notice,specialNoticeEnabled:M.bot.is_special_notice_enabled,showHandoffButton:M.bot.show_handoff_button??!0}),be({type:M.launcher.image_type||"default_icon",imageUrl:M.launcher.image_url}),M.launcher.auto_open&&!_e()&&setTimeout(()=>a.setOpened(!0),500)}function xe(){b({url:M.active_channel.channel_url,status:P.ConversationStatus.OPEN})}try{ue(),await x(U,e==null?void 0:e.sessionHandler),xe()}catch(W){W instanceof Error&&(l.error("messengerSession.initialize: failed to connect",W),T(W))}}k().catch(w=>{l.error("messengerSession: failed to initialize",w)})},[s,n,o,e==null?void 0:e.userId,e==null?void 0:e.authToken]),d.useEffect(()=>{p!=null&&p.onRegisterDeauthenticateHandler&&(l.debug("messengerSession: registering deauthenticate handler"),p.onRegisterDeauthenticateHandler(E))},[p==null?void 0:p.onRegisterDeauthenticateHandler,E]),!_||!Z||!oe?null:r.createElement(_o,{value:{userSession:_,activeChannel:y,refreshActiveChannel:Ye,connectionError:C,aiAgentInfo:{...Z,...i==null?void 0:i.bot},launcherInfo:{...oe,...i==null?void 0:i.launcher}}},t)}function ko({sound:e}){const t="🔔You have received a new message",n=document.title,o=setInterval(()=>{document.title=document.title===t?n:t},750);setTimeout(()=>clearInterval(o),5e3),e&&Promise.resolve().then(()=>require("./B93o4u0P.cjs")).then(s=>{new Audio(s.default).play()})}const Ao=({publishSynchronous:e=!1})=>{const t=new Set;return{publish:n=>{t.forEach(o=>{e?o(n):setTimeout(()=>o(n),0)})},subscribe:n=>(t.add(n),()=>t.delete(n))}};function Io(e,t=[]){const n=d.useRef(null),o=d.useRef(0),s=d.useRef(0),[i]=d.useState(()=>Ao({publishSynchronous:!0})),[a,l]=d.useState(!0);return d.useLayoutEffect(()=>{o.current=0,s.current=0,l(!0),n.current&&(n.current.scrollTop=n.current.scrollHeight)},t),d.useLayoutEffect(()=>i.subscribe(({type:u,data:h})=>{const{resolve:g,animated:p}=h??{};if(!n.current)return g==null?void 0:g();if(u==="scrollToBottom"&&(n.current.scroll?n.current.scroll({top:n.current.scrollHeight,behavior:Lt(e,p)}):n.current.scrollTop=n.current.scrollHeight,s.current=0,l(!0),g==null||g()),u==="scroll"){const f=h==null?void 0:h.top,{scrollTop:x,scrollHeight:E,clientHeight:y}=n.current;n.current.scroll?n.current.scroll({top:f,behavior:Lt(e,p)}):typeof f=="number"&&(n.current.scrollTop=f),s.current=Math.max(0,E-x-y),l(s.current===0),g==null||g()}}),[e]),{scrollRef:n,scrollPubSub:i,isScrollBottomReached:a,setIsScrollBottomReached:l,scrollDistanceFromBottomRef:s,scrollPositionRef:o}}function Lt(e,t){return typeof t=="boolean"?t?"smooth":"auto":e}function $o(e){return new Promise(t=>{const n=new Image;n.onload=function(){const o=String(n.width),s=String(n.height);URL.revokeObjectURL(n.src),t({width:o,height:s})},n.src=URL.createObjectURL(e)})}async function Mo(e){if("file"in e&&e.file instanceof File&&e.file.type.startsWith("image/")){const{width:t,height:n}=await $o(e.file);return new rn.MessageMetaArray({key:vn,value:[t,n]})}}const vn="KEY_IMG_ASPECT_RATIO",Oo=({onScroll:e})=>{const{agentPreviewConfigs:t,handlers:n}=O(),o=d.useRef(t==null?void 0:t.agentAttributes);return o.current=t==null?void 0:t.agentAttributes,{onBeforeSendMessage:async s=>{const i=await Mo(s),a={...s,metaArrays:i?[i]:void 0},l=Lo(o.current);return l?{...a,data:JSON.stringify(l)}:a},onAfterSendMessage:s=>{var i;e(),(i=n==null?void 0:n.onMessageSend)==null||i.call(n,s.message)}}},Lo=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},{Provider:Ro,useContext:j}=F("Conversation"),Po=({closedChannelUrl:e,onClearClosedChannelUrl:t,onNavigateToConversationList:n,children:o})=>{const{activeChannel:s,refreshActiveChannel:i}=R(),a=Io("smooth"),l=()=>{setTimeout(()=>a.scrollPubSub.publish({type:"scrollToBottom"}),25)},{onBeforeSendMessage:u,onAfterSendMessage:h}=Oo({onScroll:l}),g=d.useCallback(async()=>{await i(),e&&(t==null||t())},[i,e,t]);return r.createElement(vr,{channelUrl:e||(s==null?void 0:s.url),onBeforeSendMessage:u,onAfterSendMessage:h,onMessagesUpdated:l,onChannelDeleted:g,onConversationClosedViaDispatcher:g},p=>r.createElement(Ro,{value:{...p,scrollSource:a,goToActiveConversation:g,onNavigateToConversationList:n}},o))};function De(){}async function yn(e){let t=e;t&&(!t.startsWith("http://")&&!t.startsWith("https://")&&(t="https://"+t),window.open(t,"_blank","noopener,noreferrer"))}function Rt(e){try{return JSON.parse(e===""?"{}":e)}catch{return{}}}function Cn(e){return!e||!e.conversation?!1:e.conversation.status===P.ConversationStatus.CLOSED}function Sn(e){return!e||!e.conversation?!1:e.conversation.status===P.ConversationStatus.OPEN}function No(e){var o;const t=(o=e==null?void 0:e.conversation)==null?void 0:o.handoff,n=!!(t!=null&&t.timestamp);return Sn(e)&&!n}const ht=d.createContext({onDrop:De,subscribe:()=>De}),at=({children:e})=>{const t=d.useRef(new Set);return r.createElement(ht.Provider,{value:{onDrop:n=>{var o;if(n.preventDefault(),(o=n.dataTransfer)!=null&&o.files){const s=Array.from(n.dataTransfer.files);s.length>0&&t.current.forEach(i=>i(s))}},subscribe:n=>(t.current.add(n),()=>t.current.delete(n))}},e)},Do=({onDropFiles:e})=>{const{subscribe:t}=d.useContext(ht);d.useEffect(()=>t(e),[e])};at.Consumer=({children:e})=>{const{onDrop:t}=d.useContext(ht);return e({onDrop:t,onDragOver:s=>s.preventDefault()})};const ne=e=>{const t=e;return typeof t=="number"?`${t}px`:t},Bo=new Set(["send","chat","message","chevron-right"]),Fo={spinner:d.lazy(()=>Promise.resolve().then(()=>require("./VJQajGKm.cjs"))),chat:d.lazy(()=>Promise.resolve().then(()=>require("./Bgi113yh.cjs"))),message:d.lazy(()=>Promise.resolve().then(()=>require("./CCMVMvEA.cjs"))),error:d.lazy(()=>Promise.resolve().then(()=>require("./D4zXKBh-.cjs"))),info:d.lazy(()=>Promise.resolve().then(()=>require("./7sOpksia.cjs"))),refresh:d.lazy(()=>Promise.resolve().then(()=>require("./BqEtwmXd.cjs"))),"chevron-down":d.lazy(()=>Promise.resolve().then(()=>require("./WCwJJYUZ.cjs"))),"chevron-right":d.lazy(()=>Promise.resolve().then(()=>require("./CCeC8Z_c.cjs"))),done:d.lazy(()=>Promise.resolve().then(()=>require("./Ck7-iOpx.cjs"))),user:d.lazy(()=>Promise.resolve().then(()=>require("./DRna04x8.cjs"))),"file-document":d.lazy(()=>Promise.resolve().then(()=>require("./CYWHwsSv.cjs"))),download:d.lazy(()=>Promise.resolve().then(()=>require("./na-hjKnS.cjs"))),attach:d.lazy(()=>Promise.resolve().then(()=>require("./CsHNpYuX.cjs"))),delete:d.lazy(()=>Promise.resolve().then(()=>require("./dtQmhQL-.cjs"))),close:d.lazy(()=>Promise.resolve().then(()=>require("./BCgKHuFY.cjs"))),"close-filled":d.lazy(()=>Promise.resolve().then(()=>require("./DkhICmYA.cjs"))),send:d.lazy(()=>Promise.resolve().then(()=>require("./B3UTkiZj.cjs"))),menu:d.lazy(()=>Promise.resolve().then(()=>require("./BIQTp46D.cjs"))),expand:d.lazy(()=>Promise.resolve().then(()=>require("./D2OIGiV4.cjs"))),collapse:d.lazy(()=>Promise.resolve().then(()=>require("./BA7eP_0y.cjs"))),agent:d.lazy(()=>Promise.resolve().then(()=>require("./BdOKSPN6.cjs"))),question:d.lazy(()=>Promise.resolve().then(()=>require("./Bt7i9B_X.cjs"))),actionbook:d.lazy(()=>Promise.resolve().then(()=>require("./DxL6Qc1e.cjs"))),function:d.lazy(()=>Promise.resolve().then(()=>require("./BlL9mJ1G.cjs"))),"radio-on":d.lazy(()=>Promise.resolve().then(()=>require("./BE_UkM2D.cjs"))),"radio-off":d.lazy(()=>Promise.resolve().then(()=>require("./CI0UG_vg.cjs"))),confluence:d.lazy(()=>Promise.resolve().then(()=>require("./VvpIczL4.cjs"))),zendesk:d.lazy(()=>Promise.resolve().then(()=>require("./D-9eFzYR.cjs"))),salesforce:d.lazy(()=>Promise.resolve().then(()=>require("./Bj4NR2YK.cjs"))),sprinklr:d.lazy(()=>Promise.resolve().then(()=>require("./8n-lNFQi.cjs"))),website:d.lazy(()=>Promise.resolve().then(()=>require("./CYokBh9g.cjs"))),snippet:d.lazy(()=>Promise.resolve().then(()=>require("./CbUzmxPM.cjs"))),template:d.lazy(()=>Promise.resolve().then(()=>require("./CtPGsbRN.cjs")))},A=({type:e,size:t=24,className:n,color:o})=>{const s=Fo[e];return r.createElement(Ho,{className:n,$rtlFlip:Bo.has(e),$size:t,$color:o??m.color.primary.main},r.createElement(d.Suspense,{fallback:null},r.createElement(s,null)))},zo=c.css`[dir='rtl'] &{transform:scaleX(-1);}`,Ho=c.div`width:${({$size:e})=>ne(e)};height:${({$size:e})=>ne(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&&zo};`,S=({as:e,variant:t="body1",color:n,className:o,...s})=>r.createElement(Wo,{as:e,$variant:t,className:o,$color:n,...s}),Pt=new WeakMap,Uo=(e,t)=>{let n=Pt.get(t);n||(n=new Map,Pt.set(t,n));const o=n.get(e);if(o)return o;const s=t[e]??t.body1,i=c.css`font-size:${ne(s.fontSize)};font-weight:${s.fontWeight};${s.fontFamily?`font-family: ${s.fontFamily};`:""}
51
- `;return n.set(e,i),i},Wo=c.span`font-stretch:normal;font-style:normal;letter-spacing:normal;line-height:100%;${({$variant:e,theme:t})=>Uo(e,t.typography)}color:${({$color:e})=>e};`,Vo=({iconSize:e=64,icon:t,className:n,label:o,children:s})=>r.createElement(Go,{className:n},r.createElement(A,{type:t,size:e,color:m.themedColor.textLowEmphasis}),r.createElement(S,{variant:"body1",color:m.themedColor.textMidEmphasis},o),s),jo=c.div`position:relative;display:flex;justify-content:center;align-items:center;width:100%;height:100%;`,Go=c.div`display:flex;flex-direction:column;min-height:104px;align-items:center;gap:20px;text-align:center;`,qo={loading:d.lazy(()=>Promise.resolve().then(()=>require("./C5P45HBc.cjs"))),error:d.lazy(()=>Promise.resolve().then(()=>require("./DQtZKX7E.cjs"))),noChannels:d.lazy(()=>Promise.resolve().then(()=>require("./5eIFdny1.cjs"))),noMessages:d.lazy(()=>Promise.resolve().then(()=>require("./DQ9PZuXI.cjs")))},he=({className:e,type:t="loading",...n})=>{const o=qo[t];return r.createElement(jo,{className:e},r.createElement(d.Suspense,{fallback:null},r.createElement(o,{...n})))},we=244,Tn=640,Be=26,_n=4,K=12,fe=2,Ko=16,re=`${V}-incoming-msg`,Zo=`${V}-marked-text`;function pt(e){switch(e){case"top":case"middle":return fe;default:return Ko}}function ft(e,t){if(t){const[,n]=t.split("/");if(n)return n.toUpperCase()}if(e&&!e.startsWith(".")){const n=e.split(".").pop();if(n&&n!==e)return n.toUpperCase()}return"FILE"}function wn(e){return e.messageType==="file"?e.message.length>0&&e.file.name!==e.message:e.message.length>0}function bt({name:e,type:t="FILE",iconColor:n,iconBackgroundColor:o,onClick:s}){const{colors:i}=c.useTheme();return r.createElement(Yo,{onClick:s,$clickable:!!s},r.createElement(Xo,{$bgColor:o??i.base.primary},r.createElement(A,{type:"file-document",size:24,color:n??i.base.primaryContrastContent})),r.createElement(Qo,null,r.createElement(es,{variant:"button",color:m.themedColor.textHighEmphasis},e),r.createElement(S,{color:m.themedColor.textMidEmphasis,variant:"caption3"},t)))}const Yo=c.div`border-radius:12px;gap:8px;width:${we}px;height:64px;display:flex;align-items:center;padding:12px;box-sizing:border-box;border:1px solid ${m.themedColor.textDisabled};background-color:${m.themedColor.bg_50_600};${({$clickable:e})=>e&&Jo}`,Jo=c.css`cursor:pointer;&:hover{background-color:${m.themedColor.bg_100_500};}`,Xo=c.div`border-radius:8px;width:40px;height:40px;display:flex;align-items:center;justify-content:center;background-color:${({$bgColor:e})=>e};`,Qo=c.div`display:flex;flex:1;flex-direction:column;gap:4px;min-width:0;`,es=c(S)`text-overflow:ellipsis;white-space:nowrap;overflow:hidden;`;function ts({file:e,children:t,onClickFile:n}){return r.createElement(ns,null,r.createElement(bt,{name:e.name,type:ft(e.name,e.type),onClick:n&&(()=>n==null?void 0:n(e))}),t)}const ns=c.div`display:flex;flex-direction:column;align-items:flex-start;gap:${fe}px;`;function rs({file:e,onClickMedia:t,children:n}){const o=()=>e.type.startsWith("image")?r.createElement(is,{src:e.url,alt:"image-message"}):e.type.startsWith("video")?r.createElement(as,{controls:!0},r.createElement("source",{src:e.url}),r.createElement("track",{kind:"captions"})):null;if(o){const s={id:`${re}-media-body`,onClick:()=>t==null?void 0:t(e)};return r.createElement(os,null,r.createElement(ss,{...s},o()),n)}return null}const os=c.div`display:flex;flex-direction:column;align-items:flex-start;gap:${fe}px;`,ss=c.div`width:${we}px;height:160px;border-radius:12px;overflow:hidden;cursor:pointer;${L.light`
50
+ `}),mo=c.css`[${Ne}='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);}[${Ne}='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);}`,m={color:{primary:{dark:"var(--sendbird-primary-dark)",main:"var(--sendbird-primary-main)"},error:{extraDark:"var(--sendbird-error-extra-dark)",dark:"var(--sendbird-error-dark)"},information:{main:"var(--sendbird-information-main)",light:"var(--sendbird-information-light)"},background700:"var(--sendbird-background-700)",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)",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)",bg_50_600:"var(--sb-bg-50-600)",bg_100_500:"var(--sb-bg-100-500)",bg_200_400:"var(--sb-bg-200-400)",error:"var(--sb-error)"}},{Provider:go,useContext:ho}=F("AIAgentTheme");function po(e){const{theme:t,appearance:n,logger:o}=e;return r.createElement(Br,{appearance:n,palette:t==null?void 0:t.palette,typography:t==null?void 0:t.typography,logger:o},r.createElement(fo,{...e}))}function fo({rootElement:e=document.body,children:t}){const{theme:n,updateTheme:o}=un();return d.useLayoutEffect(()=>{e.setAttribute(Ne,n.selectedTheme)},[e,n.selectedTheme]),r.createElement(c.ThemeProvider,{theme:n},r.createElement(go,{value:{theme:n,updateTheme:o}},t))}function le(e,t){const n=e.getRootNode({composed:t});return n instanceof ShadowRoot||n instanceof Document?n:document}const bo=(e,t)=>{d.useEffect(()=>{const n=le(t)instanceof ShadowRoot,o=le(t,!0);if(!(n?t:o).querySelector(`link[href*='${e}']`)){const a=o.createElement("link");a.rel="stylesheet",a.href=e,(n?t:o.head).appendChild(a)}},[e,t])},xo=(e,t=document.body)=>{d.useEffect(()=>{const n=le(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])},ht=/iPad|iPhone|iPod/.test(navigator.userAgent),Eo=/Android/.test(navigator.userAgent),_e=e=>ht||Eo,V="sb-agent",q={ENTRY:`${V}-entry`,MODAL_ROOT:`${V}-modal-root`,WINDOW:`${V}-window`,LAUNCHER:`${V}-launcher`},$e=2147483647,de={MODAL:$e-1,TOOLTIP:$e-2,WINDOW:$e-3,LAUNCHER:$e-4},pn={SESSION:`@${V}-session`,USER_DATA:`@${V}-udata`},fn={DEFAULT_PRIMARY:"#742ddd",WHITE:"#ffffff"},bn=36,vo=100,yo=25*1024*1024,xn=["application/pdf","image/jpeg","image/jpg","image/png"],Ve="noopener noreferrer nofollow",Me={},G={getItem:e=>{try{return localStorage.getItem(e)}catch{return Me[e]??null}},setItem:(e,t)=>{try{localStorage.setItem(e,t)}catch{Me[e]=t}},deleteItem:e=>{try{localStorage.removeItem(e)}catch{delete Me[e]}},getKeys:e=>{try{const t=[];for(let n=0;n<localStorage.length;n++){const o=localStorage.key(n);o&&o.startsWith(e)&&t.push(o)}return t}catch{return Object.keys(Me).filter(t=>t.startsWith(e))}}};function En(e){const{keyGenerator:t,keyParamsValidator:n}=e;function o(i){try{n&&n(i);const l=t(i),u=G.getItem(l);return u?JSON.parse(u):null}catch{return null}}function s(i,l){try{n&&n(i);const u=t(i),h=JSON.stringify(l);G.setItem(u,h)}catch{}}function a(i){try{n&&n(i);const l=t(i);G.deleteItem(l)}catch{}}return{get:o,set:s,clear:a}}const Xe=En({keyGenerator:({appId:e,aiAgentId:t,userId:n})=>{const o=Co(`${e}/${t}/${n}`);return`${pn.USER_DATA}/${o}`},keyParamsValidator:({appId:e,aiAgentId:t,userId:n})=>{if(!e||!t||!n)throw new Error("Invalid parameters for user data cache")}});function Co(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return t.toString(16)}const Qe=En({keyGenerator:({appId:e,aiAgentId:t})=>`${pn.SESSION}/${e}/${t}`}),{Provider:So,Consumer:vn,useContext:O}=F("Agent");function To({children:e,state:t,enableCloseConversationButton:n=!1,enableExpandButton:o=!0,enableAutoDisconnectInLauncher:s=!0,...a}){const i=He(),[l,u]=d.useState(!1),[h,g]=d.useState(!1),p={opened:(t==null?void 0:t.opened)??l,setOpened:(t==null?void 0:t.setOpened)??u,expanded:(t==null?void 0:t.expanded)??h,setExpanded:(t==null?void 0:t.setExpanded)??g};return r.createElement(So,{value:{...a,...i,state:p,enableCloseConversationButton:n,enableExpandButton:o,enableAutoDisconnectInLauncher:s}},e)}function _o(){const{chatSDK:e,logger:t}=O(),{shouldSyncCachedTemplate:n,syncCachedTemplates:o,clearCachedTemplates:s}=gn(),a=d.useCallback(async(l,u)=>{t.debug("authManager.authenticate: session:",l.userId),u&&e.setSessionHandler(new N.SessionHandler(u)),await e.connect(l.userId,l.authToken),t.debug("authManager.authenticate: user:",e.currentUser),n(e)&&await o(e)},[e,t,n,o]),i=d.useCallback(async()=>{t.debug("authManager.deauthenticate: disconnect"),await e.disconnect(),s()},[e,t,s]);return{authenticate:a,deauthenticate:i}}const wo=24*60*60*1e3,{Provider:ko,useContext:R}=F("MessengerSession");function Ao({userSessionInfo:e,children:t}){const{appId:n,aiAgentId:o,chatSDK:s,agentPreviewConfigs:a,state:i,logger:l,language:u,countryCode:h,context:g,handlers:p}=O(),{updateTheme:f}=un(),{authenticate:x,deauthenticate:E}=_o(),[y,b]=d.useState(void 0),[C,T]=d.useState(void 0),[_,$]=d.useState(null),[Z,D]=d.useState(null),[oe,be]=d.useState(null),v=a==null?void 0:a.forceCreateChannel;function B(){if(e){l.debug("messengerSession.initialize: manual session info detected");const w=["userId","authToken","sessionHandler"].filter(M=>!(M in e));return w.length>0&&l.error(`messengerSession.initialize: missing required keys in userSessionInfo: ${w.join(", ")}`),e}const k=Qe.get({appId:n,aiAgentId:o});return k?k.expireAt-wo<=Date.now()?(l.debug("messengerSession.initialize: auto session expired, clear cache"),Qe.clear({appId:n,aiAgentId:o}),Xe.clear({appId:n,aiAgentId:o,userId:k.userId}),null):(l.debug("messengerSession.initialize: auto session info detected"),k):null}const Y=d.useCallback((k,w)=>{Xe.set({appId:n,aiAgentId:o,userId:k},{knownActiveChannelUrl:w})},[n,o]),H=d.useCallback(k=>{const w=Xe.get({appId:n,aiAgentId:o,userId:k});return w==null?void 0:w.knownActiveChannelUrl},[n,o]),Ye=d.useCallback(async()=>{if(_){l.debug("messengerSession.refreshActiveChannel: try to refresh active channel"),b(void 0);const k=await s.aiAgent.requestMessengerSettings({aiAgentId:o,userId:_.userId,language:u,country:h,context:g,forceCreateChannel:v,knownActiveChannelUrl:H(_.userId)});return Y(_.userId,k.active_channel.channel_url),b({url:k.active_channel.channel_url,status:P.ConversationStatus.OPEN}),l.info("messengerSession.refreshActiveChannel: refreshed active channel",k.active_channel.channel_url),k.active_channel.channel_url}else throw l.error("messengerSession.refreshActiveChannel: userSession is not ready"),new Error("userSession is not ready")},[s,n,o,_==null?void 0:_.userId,u,h,g,v,H,Y]);return ze.useGroupChannelHandler(s,{onChannelChanged:k=>{var w;k.isGroupChannel()&&k.url===(y==null?void 0:y.url)&&(l.info("messengerSession.channelChanged: channel.conversation",k.conversation),b({url:k.url,status:((w=k.conversation)==null?void 0:w.status)??P.ConversationStatus.OPEN}))},async onUserJoined(k,w){var U,ue;if(k.conversation&&k.conversation.type===P.ConversationType.PROACTIVE&&w.userId===((U=s.currentUser)==null?void 0:U.userId)){l.info("messengerSession.onUserJoined: proactive channel joined",k.url);const xe=((ue=k.conversation)==null?void 0:ue.status)??P.ConversationStatus.OPEN;b({url:k.url,status:xe}),i.setOpened(!0),Io({sound:document.hidden||!i.opened})}}}),d.useEffect(()=>{async function k(){l.debug("messengerSession.initialize: start");const w=B(),M=await s.aiAgent.requestMessengerSettings({aiAgentId:o,userId:w==null?void 0:w.userId,language:u,country:h,context:g,forceCreateChannel:v,knownActiveChannelUrl:H(w==null?void 0:w.userId)});l.debug("messengerSession.initialize: messenger settings response",M);let U=null;if(M.auto_created_user){const{user_id:W,session_token:J,expire_at:Ee}=M.auto_created_user;Qe.set({appId:n,aiAgentId:o},{userId:W,authToken:J,expireAt:Ee}),U={userId:W,authToken:J}}else U={userId:(w==null?void 0:w.userId)??"",authToken:(w==null?void 0:w.authToken)??""};Y(U.userId,M.active_channel.channel_url);function ue(){const W=M.appearance.selected_theme;f(W,Ee=>{const se=M.appearance.themes[Ee];return{primaryColor:se.primary_color,botMessageBackgroundColor:se.bot_message_bg_color,primaryContrastColor:se.primary_contrast_color,botMessageBackgroundContrastColor:se.bot_message_bg_contrast_color}}),T(void 0),$(U),D({userId:M.bot.bot_userid,profileUrl:M.bot.bot_profile_url,nickname:M.bot.bot_nickname,replyToFile:M.bot.reply_to_file,specialNotice:M.bot.special_notice,specialNoticeEnabled:M.bot.is_special_notice_enabled,showHandoffButton:M.bot.show_handoff_button??!0}),be({type:M.launcher.image_type||"default_icon",imageUrl:M.launcher.image_url}),M.launcher.auto_open&&!_e()&&setTimeout(()=>i.setOpened(!0),500)}function xe(){b({url:M.active_channel.channel_url,status:P.ConversationStatus.OPEN})}try{ue(),await x(U,e==null?void 0:e.sessionHandler),xe()}catch(W){W instanceof Error&&(l.error("messengerSession.initialize: failed to connect",W),T(W))}}k().catch(w=>{l.error("messengerSession: failed to initialize",w)})},[s,n,o,e==null?void 0:e.userId,e==null?void 0:e.authToken]),d.useEffect(()=>{p!=null&&p.onRegisterDeauthenticateHandler&&(l.debug("messengerSession: registering deauthenticate handler"),p.onRegisterDeauthenticateHandler(E))},[p==null?void 0:p.onRegisterDeauthenticateHandler,E]),!_||!Z||!oe?null:r.createElement(ko,{value:{userSession:_,activeChannel:y,refreshActiveChannel:Ye,connectionError:C,aiAgentInfo:{...Z,...a==null?void 0:a.bot},launcherInfo:{...oe,...a==null?void 0:a.launcher}}},t)}function Io({sound:e}){const t="🔔You have received a new message",n=document.title,o=setInterval(()=>{document.title=document.title===t?n:t},750);setTimeout(()=>clearInterval(o),5e3),e&&Promise.resolve().then(()=>require("./B93o4u0P.cjs")).then(s=>{new Audio(s.default).play()})}const $o=({publishSynchronous:e=!1})=>{const t=new Set;return{publish:n=>{t.forEach(o=>{e?o(n):setTimeout(()=>o(n),0)})},subscribe:n=>(t.add(n),()=>t.delete(n))}};function Mo(e,t=[]){const n=d.useRef(null),o=d.useRef(0),s=d.useRef(0),[a]=d.useState(()=>$o({publishSynchronous:!0})),[i,l]=d.useState(!0);return d.useLayoutEffect(()=>{o.current=0,s.current=0,l(!0),n.current&&(n.current.scrollTop=n.current.scrollHeight)},t),d.useLayoutEffect(()=>a.subscribe(({type:u,data:h})=>{const{resolve:g,animated:p}=h??{};if(!n.current)return g==null?void 0:g();if(u==="scrollToBottom"&&(n.current.scroll?n.current.scroll({top:n.current.scrollHeight,behavior:Rt(e,p)}):n.current.scrollTop=n.current.scrollHeight,s.current=0,l(!0),g==null||g()),u==="scroll"){const f=h==null?void 0:h.top,{scrollTop:x,scrollHeight:E,clientHeight:y}=n.current;n.current.scroll?n.current.scroll({top:f,behavior:Rt(e,p)}):typeof f=="number"&&(n.current.scrollTop=f),s.current=Math.max(0,E-x-y),l(s.current===0),g==null||g()}}),[e]),{scrollRef:n,scrollPubSub:a,isScrollBottomReached:i,setIsScrollBottomReached:l,scrollDistanceFromBottomRef:s,scrollPositionRef:o}}function Rt(e,t){return typeof t=="boolean"?t?"smooth":"auto":e}function Oo(e){return new Promise(t=>{const n=new Image;n.onload=function(){const o=String(n.width),s=String(n.height);URL.revokeObjectURL(n.src),t({width:o,height:s})},n.src=URL.createObjectURL(e)})}async function Lo(e){if("file"in e&&e.file instanceof File&&e.file.type.startsWith("image/")){const{width:t,height:n}=await Oo(e.file);return new on.MessageMetaArray({key:yn,value:[t,n]})}}const yn="KEY_IMG_ASPECT_RATIO",Ro=({onScroll:e})=>{const{agentPreviewConfigs:t,handlers:n}=O(),o=d.useRef(t==null?void 0:t.agentAttributes);return o.current=t==null?void 0:t.agentAttributes,{onBeforeSendMessage:async s=>{const a=await Lo(s),i={...s,metaArrays:a?[a]:void 0},l=Po(o.current);return l?{...i,data:JSON.stringify(l)}:i},onAfterSendMessage:s=>{var a;e(),(a=n==null?void 0:n.onMessageSend)==null||a.call(n,s.message)}}},Po=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},{Provider:No,useContext:j}=F("Conversation"),Do=({closedChannelUrl:e,onClearClosedChannelUrl:t,onNavigateToConversationList:n,children:o})=>{const{activeChannel:s,refreshActiveChannel:a}=R(),i=Mo("smooth"),l=()=>{setTimeout(()=>i.scrollPubSub.publish({type:"scrollToBottom"}),25)},{onBeforeSendMessage:u,onAfterSendMessage:h}=Ro({onScroll:l}),g=d.useCallback(async()=>{await a(),e&&(t==null||t())},[a,e,t]);return r.createElement(yr,{channelUrl:e||(s==null?void 0:s.url),onBeforeSendMessage:u,onAfterSendMessage:h,onMessagesUpdated:l,onChannelDeleted:g,onConversationClosedViaDispatcher:g},p=>r.createElement(No,{value:{...p,scrollSource:i,goToActiveConversation:g,onNavigateToConversationList:n}},o))};function De(){}async function Cn(e){let t=e;t&&(!t.startsWith("http://")&&!t.startsWith("https://")&&(t="https://"+t),window.open(t,"_blank","noopener,noreferrer"))}function Pt(e){try{return JSON.parse(e===""?"{}":e)}catch{return{}}}function Sn(e){return!e||!e.conversation?!1:e.conversation.status===P.ConversationStatus.CLOSED}function Tn(e){return!e||!e.conversation?!1:e.conversation.status===P.ConversationStatus.OPEN}function Bo(e){var o;const t=(o=e==null?void 0:e.conversation)==null?void 0:o.handoff,n=!!(t!=null&&t.timestamp);return Tn(e)&&!n}const pt=d.createContext({onDrop:De,subscribe:()=>De}),at=({children:e})=>{const t=d.useRef(new Set);return r.createElement(pt.Provider,{value:{onDrop:n=>{var o;if(n.preventDefault(),(o=n.dataTransfer)!=null&&o.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)},Fo=({onDropFiles:e})=>{const{subscribe:t}=d.useContext(pt);d.useEffect(()=>t(e),[e])};at.Consumer=({children:e})=>{const{onDrop:t}=d.useContext(pt);return e({onDrop:t,onDragOver:s=>s.preventDefault()})};const ne=e=>{const t=e;return typeof t=="number"?`${t}px`:t},zo=new Set(["send","chat","message","chevron-right"]),Ho={spinner:d.lazy(()=>Promise.resolve().then(()=>require("./VJQajGKm.cjs"))),chat:d.lazy(()=>Promise.resolve().then(()=>require("./Bgi113yh.cjs"))),message:d.lazy(()=>Promise.resolve().then(()=>require("./CCMVMvEA.cjs"))),error:d.lazy(()=>Promise.resolve().then(()=>require("./D4zXKBh-.cjs"))),info:d.lazy(()=>Promise.resolve().then(()=>require("./7sOpksia.cjs"))),refresh:d.lazy(()=>Promise.resolve().then(()=>require("./BqEtwmXd.cjs"))),"chevron-down":d.lazy(()=>Promise.resolve().then(()=>require("./WCwJJYUZ.cjs"))),"chevron-right":d.lazy(()=>Promise.resolve().then(()=>require("./CCeC8Z_c.cjs"))),done:d.lazy(()=>Promise.resolve().then(()=>require("./Ck7-iOpx.cjs"))),user:d.lazy(()=>Promise.resolve().then(()=>require("./DRna04x8.cjs"))),"file-document":d.lazy(()=>Promise.resolve().then(()=>require("./CYWHwsSv.cjs"))),download:d.lazy(()=>Promise.resolve().then(()=>require("./na-hjKnS.cjs"))),attach:d.lazy(()=>Promise.resolve().then(()=>require("./CsHNpYuX.cjs"))),delete:d.lazy(()=>Promise.resolve().then(()=>require("./dtQmhQL-.cjs"))),close:d.lazy(()=>Promise.resolve().then(()=>require("./BCgKHuFY.cjs"))),"close-filled":d.lazy(()=>Promise.resolve().then(()=>require("./DkhICmYA.cjs"))),send:d.lazy(()=>Promise.resolve().then(()=>require("./B3UTkiZj.cjs"))),menu:d.lazy(()=>Promise.resolve().then(()=>require("./BIQTp46D.cjs"))),expand:d.lazy(()=>Promise.resolve().then(()=>require("./D2OIGiV4.cjs"))),collapse:d.lazy(()=>Promise.resolve().then(()=>require("./BA7eP_0y.cjs"))),agent:d.lazy(()=>Promise.resolve().then(()=>require("./BdOKSPN6.cjs"))),question:d.lazy(()=>Promise.resolve().then(()=>require("./Bt7i9B_X.cjs"))),actionbook:d.lazy(()=>Promise.resolve().then(()=>require("./DxL6Qc1e.cjs"))),function:d.lazy(()=>Promise.resolve().then(()=>require("./BlL9mJ1G.cjs"))),"radio-on":d.lazy(()=>Promise.resolve().then(()=>require("./BE_UkM2D.cjs"))),"radio-off":d.lazy(()=>Promise.resolve().then(()=>require("./CI0UG_vg.cjs"))),confluence:d.lazy(()=>Promise.resolve().then(()=>require("./VvpIczL4.cjs"))),zendesk:d.lazy(()=>Promise.resolve().then(()=>require("./D-9eFzYR.cjs"))),salesforce:d.lazy(()=>Promise.resolve().then(()=>require("./Bj4NR2YK.cjs"))),sprinklr:d.lazy(()=>Promise.resolve().then(()=>require("./8n-lNFQi.cjs"))),website:d.lazy(()=>Promise.resolve().then(()=>require("./CYokBh9g.cjs"))),snippet:d.lazy(()=>Promise.resolve().then(()=>require("./CbUzmxPM.cjs"))),template:d.lazy(()=>Promise.resolve().then(()=>require("./CtPGsbRN.cjs")))},A=({type:e,size:t=24,className:n,color:o})=>{const s=Ho[e];return r.createElement(Wo,{className:n,$rtlFlip:zo.has(e),$size:t,$color:o??m.color.primary.main},r.createElement(d.Suspense,{fallback:null},r.createElement(s,null)))},Uo=c.css`[dir='rtl'] &{transform:scaleX(-1);}`,Wo=c.div`width:${({$size:e})=>ne(e)};height:${({$size:e})=>ne(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&&Uo};`,S=({as:e,variant:t="body1",color:n,className:o,...s})=>r.createElement(jo,{as:e,$variant:t,className:o,$color:n,...s}),Nt=new WeakMap,Vo=(e,t)=>{let n=Nt.get(t);n||(n=new Map,Nt.set(t,n));const o=n.get(e);if(o)return o;const s=t[e]??t.body1,a=c.css`font-size:${ne(s.fontSize)};font-weight:${s.fontWeight};${s.fontFamily?`font-family: ${s.fontFamily};`:""}
51
+ ${s.lineHeight?`line-height: ${s.lineHeight};`:"line-height: 100%;"}
52
+ `;return n.set(e,a),a},jo=c.span`font-stretch:normal;font-style:normal;letter-spacing:normal;${({$variant:e,theme:t})=>Vo(e,t.typography)}color:${({$color:e})=>e};`,Go=({iconSize:e=64,icon:t,className:n,label:o,children:s})=>r.createElement(Ko,{className:n},r.createElement(A,{type:t,size:e,color:m.themedColor.textLowEmphasis}),r.createElement(S,{variant:"body1",color:m.themedColor.textMidEmphasis},o),s),qo=c.div`position:relative;display:flex;justify-content:center;align-items:center;width:100%;height:100%;`,Ko=c.div`display:flex;flex-direction:column;min-height:104px;align-items:center;gap:20px;text-align:center;`,Zo={loading:d.lazy(()=>Promise.resolve().then(()=>require("./CVXXGvT2.cjs"))),error:d.lazy(()=>Promise.resolve().then(()=>require("./56s3GVJ_.cjs"))),noChannels:d.lazy(()=>Promise.resolve().then(()=>require("./DZu-bitL.cjs"))),noMessages:d.lazy(()=>Promise.resolve().then(()=>require("./C2iVxqfU.cjs")))},he=({className:e,type:t="loading",...n})=>{const o=Zo[t];return r.createElement(qo,{className:e},r.createElement(d.Suspense,{fallback:null},r.createElement(o,{...n})))},we=244,_n=640,Be=26,wn=4,K=12,fe=2,Yo=16,re=`${V}-incoming-msg`,Jo=`${V}-marked-text`;function ft(e){switch(e){case"top":case"middle":return fe;default:return Yo}}function bt(e,t){if(t){const[,n]=t.split("/");if(n)return n.toUpperCase()}if(e&&!e.startsWith(".")){const n=e.split(".").pop();if(n&&n!==e)return n.toUpperCase()}return"FILE"}function kn(e){return e.messageType==="file"?e.message.length>0&&e.file.name!==e.message:e.message.length>0}function xt({name:e,type:t="FILE",iconColor:n,iconBackgroundColor:o,onClick:s}){const{colors:a}=c.useTheme();return r.createElement(Xo,{onClick:s,$clickable:!!s},r.createElement(es,{$bgColor:o??a.base.primary},r.createElement(A,{type:"file-document",size:24,color:n??a.base.primaryContrastContent})),r.createElement(ts,null,r.createElement(ns,{variant:"button",color:m.themedColor.textHighEmphasis},e),r.createElement(S,{color:m.themedColor.textMidEmphasis,variant:"caption3"},t)))}const Xo=c.div`border-radius:12px;gap:8px;width:${we}px;height:64px;display:flex;align-items:center;padding:12px;box-sizing:border-box;border:1px solid ${m.themedColor.textDisabled};background-color:${m.themedColor.bg_50_600};${({$clickable:e})=>e&&Qo}`,Qo=c.css`cursor:pointer;&:hover{background-color:${m.themedColor.bg_100_500};}`,es=c.div`border-radius:8px;width:40px;height:40px;display:flex;align-items:center;justify-content:center;background-color:${({$bgColor:e})=>e};`,ts=c.div`display:flex;flex:1;flex-direction:column;gap:4px;min-width:0;`,ns=c(S)`text-overflow:ellipsis;white-space:nowrap;overflow:hidden;`;function rs({file:e,children:t,onClickFile:n}){return r.createElement(os,null,r.createElement(xt,{name:e.name,type:bt(e.name,e.type),onClick:n&&(()=>n==null?void 0:n(e))}),t)}const os=c.div`display:flex;flex-direction:column;align-items:flex-start;gap:${fe}px;`;function ss({file:e,onClickMedia:t,children:n}){const o=()=>e.type.startsWith("image")?r.createElement(ls,{src:e.url,alt:"image-message"}):e.type.startsWith("video")?r.createElement(cs,{controls:!0},r.createElement("source",{src:e.url}),r.createElement("track",{kind:"captions"})):null;if(o){const s={id:`${re}-media-body`,onClick:()=>t==null?void 0:t(e)};return r.createElement(is,null,r.createElement(as,{...s},o()),n)}return null}const is=c.div`display:flex;flex-direction:column;align-items:flex-start;gap:${fe}px;`,as=c.div`width:${we}px;height:160px;border-radius:12px;overflow:hidden;cursor:pointer;${L.light`
52
53
  background-color: ${m.color.background100};
53
54
  `}
54
55
  ${L.dark`
55
56
  background-color: ${m.color.background400};
56
57
  `}
57
- `,is=c.img`width:100%;height:100%;object-fit:cover;`,as=c.video`width:100%;height:100%;object-fit:cover;`,ls="✱";function kn(e){const t=new RegExp(`${ls}+`,"g");return e.replace(t,n=>`<span id=${Zo} aria-label="masked-text">${n}</span>`)}function cs(e){const t=/```(\w+)?\n([\s\S]*?)```/g,n=[];let o=0;return e.replace(t,(s,...i)=>{const[a,l,u]=i;return o<u&&n.push({type:"text",value:e.slice(o,u).trim()}),n.push({type:"code",value:l.trim(),language:a?a.trim():"plaintext"}),o=u+s.length,s}),o<e.length&&n.push({type:"text",value:e.slice(o).trim()}),n.map(s=>s.type!=="text"?s:{...s,value:kn(s.value)})}const ds=d.lazy(async()=>({default:(await Promise.resolve().then(()=>require("./muE0PabX.cjs"))).MarkdownText})),us=d.lazy(async()=>({default:(await Promise.resolve().then(()=>require("./u4HvlMWl.cjs"))).CodeBlock}));function Nt(e){var s,i;const t=e.maxBodyWidth??we,n=d.useMemo(()=>cs(e.message),[e.message]),o={id:`${re}-text-body`,$maxWidth:t,$color:(s=e.customStyle)==null?void 0:s.bubbleContentColor,$bgColor:(i=e.customStyle)==null?void 0:i.bubbleBackgroundColor};return n.length===0?e.children?r.createElement(Dt,{...o},e.children):null:r.createElement(Dt,{...o},n.map((a,l)=>a.type==="text"?r.createElement(Bt,{key:l,variant:"body3"},r.createElement(d.Suspense,{fallback:a.value},r.createElement(ds,null,a.value))):a.type==="code"?r.createElement(d.Suspense,{key:l,fallback:r.createElement(Bt,{variant:"body3"},a.value)},r.createElement(us,{code:a.value,language:a.language})):null),e.children)}const Dt=c.div`display:flex;flex-direction:column;border-radius:12px;overflow:hidden;max-width:${({$maxWidth:e})=>e}px;${({theme:e,$color:t,$bgColor:n})=>c.css`
58
+ `,ls=c.img`width:100%;height:100%;object-fit:cover;`,cs=c.video`width:100%;height:100%;object-fit:cover;`,ds="✱";function An(e){const t=new RegExp(`${ds}+`,"g");return e.replace(t,n=>`<span id=${Jo} aria-label="masked-text">${n}</span>`)}function us(e){const t=/```(\w+)?\n([\s\S]*?)```/g,n=[];let o=0;return e.replace(t,(s,...a)=>{const[i,l,u]=a;return o<u&&n.push({type:"text",value:e.slice(o,u).trim()}),n.push({type:"code",value:l.trim(),language:i?i.trim():"plaintext"}),o=u+s.length,s}),o<e.length&&n.push({type:"text",value:e.slice(o).trim()}),n.map(s=>s.type!=="text"?s:{...s,value:An(s.value)})}const ms=d.lazy(async()=>({default:(await Promise.resolve().then(()=>require("./Hose4Xqt.cjs"))).MarkdownText})),gs=d.lazy(async()=>({default:(await Promise.resolve().then(()=>require("./u4HvlMWl.cjs"))).CodeBlock}));function Dt(e){var s,a;const t=e.maxBodyWidth??we,n=d.useMemo(()=>us(e.message),[e.message]),o={id:`${re}-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?r.createElement(Bt,{...o},e.children):null:r.createElement(Bt,{...o},n.map((i,l)=>i.type==="text"?r.createElement(Ft,{key:l,variant:"body3"},r.createElement(d.Suspense,{fallback:i.value},r.createElement(ms,null,i.value))):i.type==="code"?r.createElement(d.Suspense,{key:l,fallback:r.createElement(Ft,{variant:"body3"},i.value)},r.createElement(gs,{code:i.value,language:i.language})):null),e.children)}const Bt=c.div`display:flex;flex-direction:column;border-radius:12px;overflow:hidden;max-width:${({$maxWidth:e})=>e}px;${({theme:e,$color:t,$bgColor:n})=>c.css`
58
59
  color: ${t||e.colors.messageIncoming.text};
59
60
  background-color: ${n||e.colors.messageIncoming.background};
60
61
  `}
61
62
  padding: 12px 0;
62
63
  transition: max-width 0.3s;
63
64
  overflow-wrap: break-word;
64
- `,Bt=c(S)`align-items:flex-start;line-height:18px;white-space:pre-wrap;padding:0 12px;`;function ms(e){const{stringSet:t}=I(),n=wn(e)?r.createElement(Nt,{...e}):null;if(e.messageType==="user")return n;if(e.messageType==="file"){const o=e.file;return o.type.startsWith("image")||o.type.startsWith("video")?r.createElement(rs,{...e},n):r.createElement(ts,{...e},n)}return r.createElement(Nt,{...e,message:t.UNKNOWN__UNKNOWN_MESSAGE_TYPE})}const xt=e=>r.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},r.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.0008 0.973633C10.6172 0.973633 9.49558 2.09527 9.49558 3.47888C9.49558 4.50705 10.115 5.39055 11.0009 5.77664V7.47887H13.0009V5.77653C13.8868 5.3904 14.5061 4.50696 14.5061 3.47888C14.5061 2.09527 13.3844 0.973633 12.0008 0.973633ZM0.250977 16.5788L0.250977 10.5789H2.25098L2.25098 16.5788H0.250977ZM21.7511 10.5789V16.5788H23.7511V10.5789H21.7511ZM18.251 7.47888H3.25097V18.9789C3.25097 20.3596 4.37026 21.4789 5.75097 21.4789H18.251C19.6317 21.4789 20.751 20.3596 20.751 18.9789V9.97887C20.751 8.59816 19.6317 7.47888 18.251 7.47888ZM9.78434 11.9539V15.2038C9.78434 15.7561 9.33663 16.2038 8.78434 16.2038C8.23206 16.2038 7.78434 15.7561 7.78434 15.2038V11.9539C7.78434 11.4016 8.23206 10.9539 8.78434 10.9539C9.33663 10.9539 9.78434 11.4016 9.78434 11.9539ZM16.2677 11.9539V15.2038C16.2677 15.7561 15.82 16.2038 15.2677 16.2038C14.7154 16.2038 14.2677 15.7561 14.2677 15.2038V11.9539C14.2677 11.4016 14.7154 10.9539 15.2677 10.9539C15.82 10.9539 16.2677 11.4016 16.2677 11.9539Z",fill:"#0D0D0D"}));function Et({id:e,src:t,size:n=56,onClick:o,style:s}){return r.createElement(gs,{id:e,tabIndex:0,onClick:o,$size:ne(n),style:s},t?r.createElement(hs,{src:t}):r.createElement(A,{type:"user",size:n}))}const gs=c.div`border-radius:50%;display:inline-block;overflow:hidden;position:relative;flex-shrink:0;height:${e=>e.$size};width:${e=>e.$size};background-color:${m.themedColor.bg_100_500};&:focus{outline:none;}`,hs=c.img`object-fit:cover;width:100%;height:100%;position:absolute;`;function ps({sender:e,isBotMessage:t}){const n=`${re}-sender-avatar`;return!e.profileUrl&&t?r.createElement(fs,{id:n},r.createElement(xt,null)):r.createElement(Et,{id:n,size:Be,src:e.profileUrl})}const fs=c.div`flex-shrink:0;width:${Be}px;height:${Be}px;box-sizing:border-box;padding:6px;border-radius:50%;display:flex;justify-content:center;align-items:center;background-color:${({theme:e})=>e.colors.base.primary};path{fill:${({theme:e})=>e.colors.base.primaryContrastContent};}}`;function bs({sender:e}){return r.createElement(xs,{id:`${re}-sender-name`,variant:"caption1",color:m.themedColor.textMidEmphasis},e.nickname)}const xs=c(S)`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 Es({createdAt:e}){const{stringSet:t,format:n}=I();return e?r.createElement(S,{id:`${re}-sent-time`,variant:"caption4",color:m.themedColor.textLowEmphasis},n(e,t.DATE_FORMAT__MESSAGE_TIMESTAMP)):null}function vs({customStyle:e}){return r.createElement(ys,{$bgColor:e==null?void 0:e.bubbleBackgroundColor},[0,1,2].map(t=>r.createElement(Cs,{key:t,$color:e==null?void 0:e.bubbleContentColor})))}const ys=c.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};`,Cs=c.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;}`;function Ss({extendedMessagePayload:e,onClickCTA:t=({url:n})=>yn(n)}){const n=e==null?void 0:e.cta_button;return n?r.createElement(Ts,{id:`${re}-ext-cta-button`,role:"button",onClick:()=>t(n)},r.createElement(_s,{variant:"button"},n.label)):null}const Ts=c.div`display:flex;align-items:center;justify-content:center;cursor:pointer;border-radius:6px;padding:8px;background-color:${m.color.primary.main};color:${({theme:e})=>e.colors.base.primaryContrastContent};&:hover{background-color:${m.color.primary.dark};}`,_s=c(S)`overflow:hidden;text-overflow:ellipsis;white-space:nowrap;`;function ws(e){return r.createElement(r.Fragment,null)}class ks extends d.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?this.props.errorFallback:r.createElement(d.Suspense,{fallback:this.props.loadingFallback},this.props.children)}}const As=new Set(["default"]),{MessageTemplate:Is}=sr.createMessageTemplate({parser:nt.parser,renderer:nt.renderer,Container:e=>r.createElement("div",{...e})});function $s(e){return r.createElement(ks,{errorFallback:e.messageTemplateErrorFallback,loadingFallback:e.messageTemplateLoadingFallback},r.createElement(Ms,{...e}))}const Ms=({extendedMessagePayload:e,onGetCachedMessageTemplate:t=()=>null,onRequestMessageTemplate:n})=>{const o=e==null?void 0:e.message_template;if(!As.has((o==null?void 0:o.type)??"default"))throw new Error("Unsupported template type");if(!n)throw new Error("onRequestMessageTemplate is required");const{theme:i}=mo(),a=Jr({onRequestTemplate:n,onGetCachedTemplate:t,theme:i.selectedTheme,templateKey:(o==null?void 0:o.key)??"invalid",variables:o==null?void 0:o.variables,viewVariables:o==null?void 0:o.view_variables,aiAgentColorVariables:i.aiAgentColorVariables});return r.createElement(Os,{id:`${re}-ext-message-template`},r.createElement(nt.MessageProvider,{message:{}},r.createElement(Is,{templateItems:a.body.items,templateVersion:a.version})))},Os=c.div`box-sizing:border-box;overflow:hidden;width:100%;`;function Ls({extendedMessagePayload:e,onClickSuggestedReply:t,suggestedRepliesDirection:n="vertical"}){const[o,s]=d.useState(!1),i=(e==null?void 0:e.suggested_replies)??[];return i.length===0||o?null:r.createElement(Rs,{id:`${re}-ext-suggested-replies`,$type:n},i.map((a,l)=>r.createElement(Ps,{key:l,$type:n,variant:"body3",onClick:()=>{t&&(t==null||t({reply:a}),s(!0))}},a)))}const Rs=c.div`margin:16px 0;padding:0 ${K}px;position:relative;display:flex;gap:8px;${({$type:e})=>e==="vertical"?Ns:Ds};`,Ps=c(S)`box-sizing:border-box;padding:8px 12px;display:flex;align-items:center;border-radius:100px;cursor:pointer;word-break:break-word;color:${m.color.primary.main};border:1px solid ${m.color.primary.main};background-color:${m.themedColor.bg_50_600};&:hover{background-color:${m.themedColor.bg_100_500};}${({$type:e,theme:t})=>c.css`
65
- ${e==="vertical"?Bs:Fs};
65
+ `,Ft=c(S)`align-items:flex-start;line-height:140%;white-space:pre-wrap;padding:0 12px;`;function hs(e){const{stringSet:t}=I(),n=kn(e)?r.createElement(Dt,{...e}):null;if(e.messageType==="user")return n;if(e.messageType==="file"){const o=e.file;return o.type.startsWith("image")||o.type.startsWith("video")?r.createElement(ss,{...e},n):r.createElement(rs,{...e},n)}return r.createElement(Dt,{...e,message:t.UNKNOWN__UNKNOWN_MESSAGE_TYPE})}const Et=e=>r.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},r.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.0008 0.973633C10.6172 0.973633 9.49558 2.09527 9.49558 3.47888C9.49558 4.50705 10.115 5.39055 11.0009 5.77664V7.47887H13.0009V5.77653C13.8868 5.3904 14.5061 4.50696 14.5061 3.47888C14.5061 2.09527 13.3844 0.973633 12.0008 0.973633ZM0.250977 16.5788L0.250977 10.5789H2.25098L2.25098 16.5788H0.250977ZM21.7511 10.5789V16.5788H23.7511V10.5789H21.7511ZM18.251 7.47888H3.25097V18.9789C3.25097 20.3596 4.37026 21.4789 5.75097 21.4789H18.251C19.6317 21.4789 20.751 20.3596 20.751 18.9789V9.97887C20.751 8.59816 19.6317 7.47888 18.251 7.47888ZM9.78434 11.9539V15.2038C9.78434 15.7561 9.33663 16.2038 8.78434 16.2038C8.23206 16.2038 7.78434 15.7561 7.78434 15.2038V11.9539C7.78434 11.4016 8.23206 10.9539 8.78434 10.9539C9.33663 10.9539 9.78434 11.4016 9.78434 11.9539ZM16.2677 11.9539V15.2038C16.2677 15.7561 15.82 16.2038 15.2677 16.2038C14.7154 16.2038 14.2677 15.7561 14.2677 15.2038V11.9539C14.2677 11.4016 14.7154 10.9539 15.2677 10.9539C15.82 10.9539 16.2677 11.4016 16.2677 11.9539Z",fill:"#0D0D0D"}));function vt({id:e,src:t,size:n=56,onClick:o,style:s}){return r.createElement(ps,{id:e,tabIndex:0,onClick:o,$size:ne(n),style:s},t?r.createElement(fs,{src:t}):r.createElement(A,{type:"user",size:n}))}const ps=c.div`border-radius:50%;display:inline-block;overflow:hidden;position:relative;flex-shrink:0;height:${e=>e.$size};width:${e=>e.$size};background-color:${m.themedColor.bg_100_500};&:focus{outline:none;}`,fs=c.img`object-fit:cover;width:100%;height:100%;position:absolute;`;function bs({sender:e,isBotMessage:t}){const n=`${re}-sender-avatar`;return!e.profileUrl&&t?r.createElement(xs,{id:n},r.createElement(Et,null)):r.createElement(vt,{id:n,size:Be,src:e.profileUrl})}const xs=c.div`flex-shrink:0;width:${Be}px;height:${Be}px;box-sizing:border-box;padding:6px;border-radius:50%;display:flex;justify-content:center;align-items:center;background-color:${({theme:e})=>e.colors.base.primary};path{fill:${({theme:e})=>e.colors.base.primaryContrastContent};}}`;function Es({sender:e}){return r.createElement(vs,{id:`${re}-sender-name`,variant:"caption1",color:m.themedColor.textMidEmphasis},e.nickname)}const vs=c(S)`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 ys({createdAt:e}){const{stringSet:t,format:n}=I();return e?r.createElement(S,{id:`${re}-sent-time`,variant:"caption4",color:m.themedColor.textLowEmphasis},n(e,t.DATE_FORMAT__MESSAGE_TIMESTAMP)):null}function Cs({customStyle:e}){return r.createElement(Ss,{$bgColor:e==null?void 0:e.bubbleBackgroundColor},[0,1,2].map(t=>r.createElement(Ts,{key:t,$color:e==null?void 0:e.bubbleContentColor})))}const Ss=c.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};`,Ts=c.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;}`;function _s({extendedMessagePayload:e,onClickCTA:t=({url:n})=>Cn(n)}){const n=e==null?void 0:e.cta_button;return n?r.createElement(ws,{id:`${re}-ext-cta-button`,role:"button",onClick:()=>t(n)},r.createElement(ks,{variant:"button"},n.label)):null}const ws=c.div`display:flex;align-items:center;justify-content:center;cursor:pointer;border-radius:6px;padding:8px;background-color:${m.color.primary.main};color:${({theme:e})=>e.colors.base.primaryContrastContent};&:hover{background-color:${m.color.primary.dark};}`,ks=c(S)`overflow:hidden;text-overflow:ellipsis;white-space:nowrap;`;function As(e){return r.createElement(r.Fragment,null)}class Is extends d.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?this.props.errorFallback:r.createElement(d.Suspense,{fallback:this.props.loadingFallback},this.props.children)}}const $s=new Set(["default"]),{MessageTemplate:Ms}=ir.createMessageTemplate({parser:nt.parser,renderer:nt.renderer,Container:e=>r.createElement("div",{...e})});function Os(e){return r.createElement(Is,{errorFallback:e.messageTemplateErrorFallback,loadingFallback:e.messageTemplateLoadingFallback},r.createElement(Ls,{...e}))}const Ls=({extendedMessagePayload:e,onGetCachedMessageTemplate:t=()=>null,onRequestMessageTemplate:n})=>{const o=e==null?void 0:e.message_template;if(!$s.has((o==null?void 0:o.type)??"default"))throw new Error("Unsupported template type");if(!n)throw new Error("onRequestMessageTemplate is required");const{theme:a}=ho(),i=Qr({onRequestTemplate:n,onGetCachedTemplate:t,theme:a.selectedTheme,templateKey:(o==null?void 0:o.key)??"invalid",variables:o==null?void 0:o.variables,viewVariables:o==null?void 0:o.view_variables,aiAgentColorVariables:a.aiAgentColorVariables});return r.createElement(Rs,{id:`${re}-ext-message-template`},r.createElement(nt.MessageProvider,{message:{}},r.createElement(Ms,{templateItems:i.body.items,templateVersion:i.version})))},Rs=c.div`box-sizing:border-box;overflow:hidden;width:100%;`;function Ps({extendedMessagePayload:e,onClickSuggestedReply:t,suggestedRepliesDirection:n="vertical"}){const[o,s]=d.useState(!1),a=(e==null?void 0:e.suggested_replies)??[];return a.length===0||o?null:r.createElement(Ns,{id:`${re}-ext-suggested-replies`,$type:n},a.map((i,l)=>r.createElement(Ds,{key:l,$type:n,variant:"body3",onClick:()=>{t&&(t==null||t({reply:i}),s(!0))}},i)))}const Ns=c.div`margin:16px 0;padding:0 ${K}px;position:relative;display:flex;gap:8px;${({$type:e})=>e==="vertical"?Bs:Fs};`,Ds=c(S)`box-sizing:border-box;padding:8px 12px;display:flex;align-items:center;border-radius:20px / clamp(20px,5%,100px);cursor:pointer;word-break:break-word;color:${m.color.primary.main};border:1px solid ${m.color.primary.main};background-color:${m.themedColor.bg_50_600};&:hover{background-color:${m.themedColor.bg_100_500};}${({$type:e,theme:t})=>c.css`
66
+ ${e==="vertical"?zs:Hs};
66
67
  &:active {
67
68
  background-color: ${t.colors.base.primary};
68
69
  color: ${t.colors.base.primaryContrastContent};
69
70
  }
70
71
  `}
71
- `,Ns=c.css`flex-direction:column;align-items:flex-end;`,Ds=c.css`flex-direction:row;overflow-x:scroll;-ms-overflow-style:none;scrollbar-width:none;&::-webkit-scrollbar{display:none;}`,Bs=c.css`max-width:calc(100% - 70px);white-space:pre-wrap;`,Fs=c.css`white-space:nowrap;`;function vt(e){return e()}const ce=pe({template:zs,components:{SenderName:bs,SenderAvatar:ps,SentTime:Es,MessageBody:ms,TypingIndicator:vs,SuggestedReplies:Ls,MessageTemplate:$s,CTAButton:Ss,MessageLogs:ws}});function zs(e){return r.createElement(An,{...e,testerMode:!1})}function An(e){var p,f,x,E;const{components:t}=ce.useContext(),n=!!e.isTyping,o=e.testerMode,s=!!((p=e.extendedMessagePayload)!=null&&p.message_template),i=!!((f=e.extendedMessagePayload)!=null&&f.cta_button),a=!!e.createdAt,l=vt(()=>e.messageType==="user"?e.message.length>0:!0),u=e.groupType==="top"||e.groupType==="single",h=e.groupType==="bottom"||e.groupType==="single",g=o?0:Be;return r.createElement(Hs,{$marginBottom:n?0:pt(e.groupType)},u&&r.createElement(Us,null,!o&&r.createElement(t.SenderAvatar,{...e}),r.createElement(t.SenderName,{...e})),r.createElement(d.Fragment,null,r.createElement(et,{$extraStartPadding:g},n&&r.createElement(t.TypingIndicator,{...e}),r.createElement(t.MessageBody,{...e},i&&r.createElement("div",{style:{marginTop:12,marginInline:12}},r.createElement(t.CTAButton,{...e})))),s&&r.createElement(Ft,{$startPadding:0,$endPadding:0,style:{marginTop:l?fe:0}},r.createElement(t.MessageTemplate,{...e,messageTemplateErrorFallback:e.messageTemplateErrorFallback??r.createElement(et,{$extraStartPadding:g},r.createElement(t.MessageBody,{...e,messageType:"user",message:((E=(x=e.extendedMessagePayload)==null?void 0:x.message_template)==null?void 0:E.fallback_message)??"Cannot read this template."})),messageTemplateLoadingFallback:e.messageTemplateLoadingFallback??r.createElement(et,{$extraStartPadding:g},r.createElement(t.TypingIndicator,{...e}))}))),h&&a&&r.createElement(Ws,{$extraStartPadding:g+8},r.createElement(t.SentTime,{...e})),r.createElement(d.Fragment,null,e.suggestedRepliesVisible&&r.createElement(Ft,null,r.createElement(t.SuggestedReplies,{...e})),r.createElement(t.MessageLogs,{...e})))}const Hs=c.div`display:flex;flex-direction:column;align-items:flex-start;margin-bottom:${({$marginBottom:e})=>`${e}px`};
72
+ `,Bs=c.css`flex-direction:column;align-items:flex-end;`,Fs=c.css`flex-direction:row;overflow-x:scroll;-ms-overflow-style:none;scrollbar-width:none;&::-webkit-scrollbar{display:none;}`,zs=c.css`max-width:calc(100% - 70px);white-space:pre-wrap;`,Hs=c.css`white-space:nowrap;`;function yt(e){return e()}const ce=pe({template:Us,components:{SenderName:Es,SenderAvatar:bs,SentTime:ys,MessageBody:hs,TypingIndicator:Cs,SuggestedReplies:Ps,MessageTemplate:Os,CTAButton:_s,MessageLogs:As}});function Us(e){return r.createElement(In,{...e,testerMode:!1})}function In(e){var p,f,x,E;const{components:t}=ce.useContext(),n=!!e.isTyping,o=e.testerMode,s=!!((p=e.extendedMessagePayload)!=null&&p.message_template),a=!!((f=e.extendedMessagePayload)!=null&&f.cta_button),i=!!e.createdAt,l=yt(()=>e.messageType==="user"?e.message.length>0:!0),u=e.groupType==="top"||e.groupType==="single",h=e.groupType==="bottom"||e.groupType==="single",g=o?0:Be;return r.createElement(Ws,{$marginBottom:n?0:ft(e.groupType)},u&&r.createElement(Vs,null,!o&&r.createElement(t.SenderAvatar,{...e}),r.createElement(t.SenderName,{...e})),r.createElement(d.Fragment,null,r.createElement(et,{$extraStartPadding:g},n&&r.createElement(t.TypingIndicator,{...e}),r.createElement(t.MessageBody,{...e},a&&r.createElement("div",{style:{marginTop:12,marginInline:12}},r.createElement(t.CTAButton,{...e})))),s&&r.createElement(zt,{$startPadding:0,$endPadding:0,style:{marginTop:l?fe:0}},r.createElement(t.MessageTemplate,{...e,messageTemplateErrorFallback:e.messageTemplateErrorFallback??r.createElement(et,{$extraStartPadding:g},r.createElement(t.MessageBody,{...e,messageType:"user",message:((E=(x=e.extendedMessagePayload)==null?void 0:x.message_template)==null?void 0:E.fallback_message)??"Cannot read this template."})),messageTemplateLoadingFallback:e.messageTemplateLoadingFallback??r.createElement(et,{$extraStartPadding:g},r.createElement(t.TypingIndicator,{...e}))}))),h&&i&&r.createElement(js,{$extraStartPadding:g+8},r.createElement(t.SentTime,{...e})),r.createElement(d.Fragment,null,e.suggestedRepliesVisible&&r.createElement(zt,null,r.createElement(t.SuggestedReplies,{...e})),r.createElement(t.MessageLogs,{...e})))}const Ws=c.div`display:flex;flex-direction:column;align-items:flex-start;margin-bottom:${({$marginBottom:e})=>`${e}px`};
72
73
  `,je=c.div`display:flex;align-self:stretch;justify-content:flex-start;${({$startPadding:e=K,$endPadding:t=K,$extraStartPadding:n=0})=>`
73
74
  padding-inline: ${e+n}px ${t}px;
74
75
  `}
75
- `,Us=c(je)`display:flex;flex-direction:row;align-items:center;gap:8px;`,et=c(je)`display:flex;`,Ws=c(je)`margin-top:${_n}px;display:flex;align-items:flex-start;justify-content:flex-start;`,Ft=c(je)`display:flex;flex-direction:column;${({$startPadding:e=K,$endPadding:t=K,$extraStartPadding:n=0})=>`
76
+ `,Vs=c(je)`display:flex;flex-direction:row;align-items:center;gap:8px;`,et=c(je)`display:flex;`,js=c(je)`margin-top:${wn}px;display:flex;align-items:flex-start;justify-content:flex-start;`,zt=c(je)`display:flex;flex-direction:column;${({$startPadding:e=K,$endPadding:t=K,$extraStartPadding:n=0})=>`
76
77
  padding-inline: ${e+n}px ${t}px;
77
78
  `}
78
- `;function Vs({file:e,children:t,onClickFile:n}){return r.createElement(js,null,r.createElement(bt,{name:e.name,type:ft(e.name,e.type),onClick:n&&(()=>n==null?void 0:n(e))}),t)}const js=c.div`display:flex;flex-direction:column;align-items:flex-end;gap:${fe}px;`,yt=({className:e,children:t,size:n=26})=>r.createElement(Gs,{className:e,$size:n},t??r.createElement(A,{type:"spinner",size:n})),Gs=c.div`display:flex;align-items:center;justify-content:center;width:${({$size:e})=>ne(e)};height:${({$size:e})=>ne(e)};animation:1s infinite linear;animation-name:rotate;@keyframes rotate{from{transform:rotate(0);}to{transform:rotate(360deg);}}`;function qs({file:e,metadata:t,onClickMedia:n,children:o}){const{aspectRatio:s,localFile:i}=t,[a]=d.useState(()=>i instanceof File?URL.createObjectURL(i):e.url),[l,u]=d.useState(!1),h={onClick:()=>n==null?void 0:n(e),$ratio:s};return r.createElement(Ks,null,r.createElement(Zs,{...h},!l&&r.createElement(yt,{size:26},r.createElement(A,{type:"spinner",color:"textLowEmphasis",size:26})),r.createElement(Ys,{$loaded:l,src:a,alt:"image-message",onLoad:()=>u(!0)})),o)}const Ks=c.div`display:flex;flex-direction:column;align-items:flex-end;gap:${fe}px;`,Zs=c.div`width:${we}px;border-radius:12px;overflow:hidden;cursor:pointer;height:auto;aspect-ratio:${e=>e.$ratio};position:relative;display:flex;align-items:center;justify-content:center;${L.light`
79
+ `;function Gs({file:e,children:t,onClickFile:n}){return r.createElement(qs,null,r.createElement(xt,{name:e.name,type:bt(e.name,e.type),onClick:n&&(()=>n==null?void 0:n(e))}),t)}const qs=c.div`display:flex;flex-direction:column;align-items:flex-end;gap:${fe}px;`,Ct=({className:e,children:t,size:n=26})=>r.createElement(Ks,{className:e,$size:n},t??r.createElement(A,{type:"spinner",size:n})),Ks=c.div`display:flex;align-items:center;justify-content:center;width:${({$size:e})=>ne(e)};height:${({$size:e})=>ne(e)};animation:1s infinite linear;animation-name:rotate;@keyframes rotate{from{transform:rotate(0);}to{transform:rotate(360deg);}}`;function Zs({file:e,metadata:t,onClickMedia:n,children:o}){const{aspectRatio:s,localFile:a}=t,[i]=d.useState(()=>a instanceof File?URL.createObjectURL(a):e.url),[l,u]=d.useState(!1),h={onClick:()=>n==null?void 0:n(e),$ratio:s};return r.createElement(Ys,null,r.createElement(Js,{...h},!l&&r.createElement(Ct,{size:26},r.createElement(A,{type:"spinner",color:"textLowEmphasis",size:26})),r.createElement(Xs,{$loaded:l,src:i,alt:"image-message",onLoad:()=>u(!0)})),o)}const Ys=c.div`display:flex;flex-direction:column;align-items:flex-end;gap:${fe}px;`,Js=c.div`width:${we}px;border-radius:12px;overflow:hidden;cursor:pointer;height:auto;aspect-ratio:${e=>e.$ratio};position:relative;display:flex;align-items:center;justify-content:center;${L.light`
79
80
  background-color: ${m.color.background100};
80
81
  `}
81
82
  ${L.dark`
82
83
  background-color: ${m.color.background400};
83
84
  `}
84
- `,Ys=c.img`position:absolute;width:100%;height:100%;inset-block-start:0;inset-inline-start:0;object-fit:cover;opacity:${e=>e.$loaded?1:0};transition:opacity 0.5s ease;`;function zt(e){var n,o;const t=d.useMemo(()=>on.sanitize(kn(e.message)),[e.message]);return r.createElement(Js,{$maxWidth:e.maxBodyWidth??we,$color:(n=e.customStyle)==null?void 0:n.bubbleContentColor,$bgColor:(o=e.customStyle)==null?void 0:o.bubbleBackgroundColor},r.createElement(Xs,{variant:"body3",dangerouslySetInnerHTML:{__html:t}}))}const Js=c.div`display:flex;flex-direction:column;border-radius:12px;overflow:hidden;max-width:${({$maxWidth:e})=>e}px;${({theme:e,$color:t,$bgColor:n})=>c.css`
85
+ `,Xs=c.img`position:absolute;width:100%;height:100%;inset-block-start:0;inset-inline-start:0;object-fit:cover;opacity:${e=>e.$loaded?1:0};transition:opacity 0.5s ease;`;function Ht(e){var n,o;const t=d.useMemo(()=>sn.sanitize(An(e.message)),[e.message]);return r.createElement(Qs,{$maxWidth:e.maxBodyWidth??we,$color:(n=e.customStyle)==null?void 0:n.bubbleContentColor,$bgColor:(o=e.customStyle)==null?void 0:o.bubbleBackgroundColor},r.createElement(ei,{variant:"body3",dangerouslySetInnerHTML:{__html:t}}))}const Qs=c.div`display:flex;flex-direction:column;border-radius:12px;overflow:hidden;max-width:${({$maxWidth:e})=>e}px;${({theme:e,$color:t,$bgColor:n})=>c.css`
85
86
  color: ${t||e.colors.messageOutgoing.text};
86
87
  background-color: ${n||e.colors.messageOutgoing.background};
87
88
  `}
88
89
  padding: 12px 0;
89
90
  transition: max-width 0.3s;
90
91
  overflow-wrap: break-word;
91
- `,Xs=c(S)`align-items:flex-start;line-height:18px;white-space:pre-wrap;padding:0 12px;`;function Qs(e){const{stringSet:t}=I(),n=wn(e)?r.createElement(zt,{...e}):null;return e.messageType==="user"?n:e.messageType==="file"?e.file.type.startsWith("image")?r.createElement(qs,{...e},n):r.createElement(Vs,{...e},n):r.createElement(zt,{...e,message:t.UNKNOWN__UNKNOWN_MESSAGE_TYPE})}function ei({sendingStatus:e}){const t=c.useTheme();switch(e){case"pending":return r.createElement(ti,{size:16},r.createElement(A,{type:"spinner",color:t.colors.messageOutgoing.background,size:16}));case"failed":return r.createElement("div",{style:{marginBottom:2}},r.createElement(A,{type:"error",color:m.themedColor.error,size:16}));case"scheduled":case"canceled":return null;default:return r.createElement("div",null,r.createElement(A,{type:"chevron-down"}))}}const ti=c(yt)`margin-bottom:2px;width:16px;height:16px;`;function ni({createdAt:e}){const{stringSet:t,format:n}=I();return e?r.createElement(S,{variant:"caption4",color:m.themedColor.textLowEmphasis},n(e,t.DATE_FORMAT__MESSAGE_TIMESTAMP)):null}const Ge=pe({template:ri,components:{SendingStatus:ei,SentTime:ni,MessageBody:Qs}});function ri(e){const{components:t}=Ge.useContext(),n=e.sendingStatus==="succeeded",o=e.groupType==="bottom"||e.groupType==="single";return r.createElement(oi,{$marginBottom:pt(e.groupType)},r.createElement(si,null,r.createElement(t.MessageBody,{...e})),o&&r.createElement(ii,{$extraEndPadding:8},n?r.createElement(t.SentTime,{...e}):r.createElement(t.SendingStatus,{...e})))}const oi=c.div`display:flex;flex:1;flex-direction:column;align-items:flex-end;margin-bottom:${({$marginBottom:e})=>`${e}px`};
92
- `,In=c.div`display:flex;align-self:stretch;justify-content:flex-end;${({$startPadding:e=K,$endPadding:t=K,$extraEndPadding:n=0})=>`padding-inline: ${e}px ${t+n}px;`};
93
- `,si=c(In)``,ii=c(In)`margin-top:${_n}px;`;function ai(e){return e.messageType!=="admin"?null:r.createElement(li,null,r.createElement(S,{variant:"caption2",color:m.themedColor.textMidEmphasis},ci(on.sanitize(e.message))))}const li=c.div`text-align:center;text-wrap:pretty;a{text-decoration:none;color:inherit;}`,ci=e=>{const t=/\[([^\]]+)\]\((https?:\/\/[^\s]+)\)/g,n=[];let o=0;return e.replace(t,(s,i,a,l)=>(n.push(e.slice(o,l)),n.push(r.createElement("a",{key:a,href:a,target:"_blank",rel:Ve},i)),o=l+s.length,s)),n.push(e.slice(o)),n},di=({submitted:e,defaultValue:t,value:n,onChange:o})=>{const{stringSet:s}=I();return d.useEffect(()=>{typeof n>"u"&&typeof t=="boolean"&&(o==null||o(t))},[n,t]),r.createElement(ui,null,r.createElement(S,{variant:"caption2",color:m.themedColor.textMidEmphasis},s.CSAT_CRE_TITLE),r.createElement("div",null,r.createElement(Ht,{checked:n===!0,label:s.CSAT_CRE_SOLVED,disabled:e,onClick:()=>o==null?void 0:o(!0)}),r.createElement(Ht,{checked:n===!1,label:s.CSAT_CRE_NOT_SOLVED,disabled:e,onClick:()=>o==null?void 0:o(!1)})))},Ht=({onClick:e,checked:t,label:n,disabled:o})=>{const s=t?m.color.primary.main:o?m.themedColor.textDisabled:m.themedColor.textLowEmphasis,i=t?m.themedColor.textHighEmphasis:o?m.themedColor.textLowEmphasis:m.themedColor.textHighEmphasis;return r.createElement(mi,{onClick:e,disabled:o},r.createElement(A,{size:24,type:t?"radio-on":"radio-off",color:s}),r.createElement(S,{variant:"caption2",color:i},n))},ui=c.div`display:flex;flex-direction:column;gap:8px;`,mi=c.button`all:unset;display:flex;align-items:center;justify-content:flex-start;gap:2px;span{line-height:initial;}&:enabled{cursor:pointer;}`,gi=e=>r.createElement("svg",{width:40,height:40,viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",id:"csat1",...e},r.createElement("path",{d:"M2.08301 20C2.08301 10.1049 10.1046 2.08334 19.9997 2.08334C29.8948 2.08334 37.9163 10.1049 37.9163 20C37.9163 29.8952 29.8948 37.9167 19.9997 37.9167C10.1046 37.9167 2.08301 29.8952 2.08301 20Z",fill:"#E0E0E0"}),r.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.5824 29.3328C13.1344 29.7473 13.918 29.636 14.3326 29.084C15.6269 27.3607 17.6835 26.25 19.9997 26.25C22.316 26.25 24.3727 27.3607 25.6668 29.084C26.0815 29.636 26.865 29.7473 27.4172 29.3328C27.9692 28.9182 28.0805 28.1347 27.6658 27.5825C25.9198 25.2577 23.1357 23.75 19.9997 23.75C16.8638 23.75 14.0797 25.2577 12.3336 27.5825C11.919 28.1347 12.0304 28.9182 12.5824 29.3328Z",fill:"black",fillOpacity:.12}),r.createElement("path",{d:"M28.4449 13.7707C29.1324 13.8328 29.64 14.4406 29.578 15.1281C29.516 15.8153 28.909 16.3221 28.2219 16.2608C28.2219 16.2608 28.0282 16.2502 27.9267 16.2487C27.7224 16.2457 27.4382 16.2509 27.1224 16.2833C26.7864 16.3177 26.4644 16.3782 26.1799 16.4662L26.304 16.86C26.7792 18.3675 25.5094 19.5813 24.2057 19.5813C23.504 19.5813 22.8319 19.2617 22.4295 18.6857C22.0025 18.0745 21.9417 17.241 22.4075 16.5344C22.7505 16.0143 23.2444 15.3831 23.8959 14.8657C24.8355 14.1195 26.0435 13.8809 26.867 13.7963C27.3024 13.7517 28.0149 13.7319 28.4449 13.7707Z",fill:"black",fillOpacity:.12}),r.createElement("path",{d:"M11.5553 13.7707C10.8677 13.8328 10.3601 14.4406 10.4221 15.1281C10.4842 15.8153 11.0912 16.3221 11.7782 16.2608C11.7782 16.2608 11.972 16.2502 12.0734 16.2487C12.2778 16.2457 12.562 16.2509 12.8778 16.2833C13.2137 16.3177 13.5357 16.3782 13.8203 16.4662L13.6962 16.86C13.2209 18.3675 14.4907 19.5813 15.7944 19.5813C16.4962 19.5813 17.1683 19.2617 17.5707 18.6857C17.9975 18.0745 18.0585 17.241 17.5925 16.5344C17.2497 16.0143 16.7557 15.3831 16.1043 14.8657C15.1646 14.1195 13.9566 13.8809 13.1331 13.7963C12.6978 13.7517 11.9853 13.7319 11.5553 13.7707Z",fill:"black",fillOpacity:.12})),hi=e=>r.createElement("svg",{width:40,height:40,viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},r.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)"}),r.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"}),r.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"}),r.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"}),r.createElement("defs",null,r.createElement("linearGradient",{id:"paint0_linear_159_173206",x1:20,y1:2.08325,x2:20,y2:37.9166,gradientUnits:"userSpaceOnUse"},r.createElement("stop",{stopColor:"#FF2D1D"}),r.createElement("stop",{offset:1,stopColor:"#FFA540"})))),pi=e=>r.createElement("svg",{width:40,height:40,viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},r.createElement("path",{d:"M19.9997 36.6667C29.2044 36.6667 36.6663 29.2048 36.6663 20C36.6663 10.7953 29.2044 3.33334 19.9997 3.33334C10.7949 3.33334 3.33301 10.7953 3.33301 20C3.33301 29.2048 10.7949 36.6667 19.9997 36.6667Z",fill:"#E0E0E0"}),r.createElement("path",{d:"M15 28.333C16.3927 27.2867 18.124 26.6667 20 26.6667C21.876 26.6667 23.6073 27.2867 25 28.333",stroke:"black",strokeOpacity:.12,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),r.createElement("path",{d:"M11.667 13.3511C11.667 13.3511 14.0161 13.139 15.3268 14.18M15.3268 14.18L14.8882 15.5711C14.7153 16.1199 15.1675 16.6667 15.7943 16.6667C16.4531 16.6667 16.8882 16.0723 16.549 15.5579C16.2483 15.102 15.8388 14.5866 15.3268 14.18ZM23.3337 13.3511C23.3337 13.3511 25.6827 13.139 26.9935 14.18M26.9935 14.18L26.555 15.5711C26.382 16.1199 26.8342 16.6667 27.461 16.6667C28.1198 16.6667 28.5548 16.0723 28.2157 15.5579C27.915 15.102 27.5055 14.5866 26.9935 14.18Z",stroke:"black",strokeOpacity:.12,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})),fi=e=>r.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:40,height:40,viewBox:"0 0 40 40",fill:"none",...e},r.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"}),r.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"}),r.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"}),r.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"})),bi=e=>r.createElement("svg",{width:40,height:40,viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},r.createElement("path",{d:"M19.9997 36.6667C29.2044 36.6667 36.6663 29.2048 36.6663 20C36.6663 10.7953 29.2044 3.33334 19.9997 3.33334C10.7949 3.33334 3.33301 10.7953 3.33301 20C3.33301 29.2048 10.7949 36.6667 19.9997 36.6667Z",fill:"#E0E0E0"}),r.createElement("path",{d:"M13.348 15H13.333M26.6663 15H26.6513",stroke:"black",strokeOpacity:.12,strokeWidth:3.33333,strokeLinecap:"round",strokeLinejoin:"round"}),r.createElement("path",{d:"M15 26.6667H25",stroke:"black",strokeOpacity:.12,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})),xi=e=>r.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:40,height:40,viewBox:"0 0 40 40",fill:"none",...e},r.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"}),r.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"}),r.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"})),Ei=e=>r.createElement("svg",{width:40,height:40,viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},r.createElement("path",{d:"M19.9997 36.6667C29.2044 36.6667 36.6663 29.2048 36.6663 20C36.6663 10.7953 29.2044 3.33334 19.9997 3.33334C10.7949 3.33334 3.33301 10.7953 3.33301 20C3.33301 29.2048 10.7949 36.6667 19.9997 36.6667Z",fill:"#E0E0E0"}),r.createElement("path",{d:"M13.333 25C14.8532 27.024 17.2735 28.3333 19.9997 28.3333C22.7258 28.3333 25.1462 27.024 26.6663 25",stroke:"black",strokeOpacity:.12,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),r.createElement("path",{d:"M13.348 15H13.333M26.6663 15H26.6513",stroke:"black",strokeOpacity:.12,strokeWidth:3.33333,strokeLinecap:"round",strokeLinejoin:"round"})),vi=e=>r.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:40,height:40,viewBox:"0 0 40 40",fill:"none",...e},r.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"}),r.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"}),r.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"})),yi=e=>r.createElement("svg",{width:40,height:40,viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},r.createElement("path",{d:"M19.9997 36.6663C29.2044 36.6663 36.6663 29.2044 36.6663 19.9997C36.6663 10.7949 29.2044 3.33301 19.9997 3.33301C10.7949 3.33301 3.33301 10.7949 3.33301 19.9997C3.33301 29.2044 10.7949 36.6663 19.9997 36.6663Z",fill:"#E0E0E0"}),r.createElement("path",{d:"M19.9997 30C23.16 30 25.8145 27.867 26.56 24.9832C26.9068 23.6413 26.4033 23.3333 25.0765 23.3333H14.9228C13.5959 23.3333 13.0925 23.6413 13.4393 24.9832C14.1848 27.867 16.8393 30 19.9997 30Z",stroke:"black",strokeOpacity:.12,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),r.createElement("path",{d:"M11.667 15.8333C11.667 14.4526 12.7863 13.3333 14.167 13.3333C15.5477 13.3333 16.667 14.4526 16.667 15.8333M23.3337 15.8333C23.3337 14.4526 24.453 13.3333 25.8337 13.3333C27.2143 13.3333 28.3337 14.4526 28.3337 15.8333",stroke:"black",strokeOpacity:.12,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})),Ci=e=>r.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:40,height:40,viewBox:"0 0 40 40",fill:"none",...e},r.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"}),r.createElement("g",{clipPath:"url(#clip0_159_173224)"},r.createElement("g",{clipPath:"url(#clip1_159_173224)"},r.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"})),r.createElement("mask",{id:"mask0_159_173224",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:12,y:22,width:16,height:9},r.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"})),r.createElement("g",{mask:"url(#mask0_159_173224)"},r.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"}))),r.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"}),r.createElement("defs",null,r.createElement("clipPath",{id:"clip0_159_173224"},r.createElement("rect",{width:15.83,height:7.915,fill:"white",transform:"translate(12.085 22.709)"})),r.createElement("clipPath",{id:"clip1_159_173224"},r.createElement("rect",{width:15.83,height:7.915,fill:"white",transform:"translate(12.085 22.709)"})))),Si=[{value:1,Icon:{Active:hi,Inactive:gi},isActive:e=>e<=1,getTooltip:e=>e.CSAT5_RATING_SCORE_1},{value:2,Icon:{Active:fi,Inactive:pi},isActive:e=>e===2,getTooltip:e=>e.CSAT5_RATING_SCORE_2},{value:3,Icon:{Active:xi,Inactive:bi},isActive:e=>e===3,getTooltip:e=>e.CSAT5_RATING_SCORE_3},{value:4,Icon:{Active:vi,Inactive:Ei},isActive:e=>e===4,getTooltip:e=>e.CSAT5_RATING_SCORE_4},{value:5,Icon:{Active:Ci,Inactive:yi},isActive:e=>5<=e,getTooltip:e=>e.CSAT5_RATING_SCORE_5}],Ti=()=>Si,$n=({label:e,children:t,position:n="top",disabled:o})=>{const[s,i]=d.useState(!1);return o?t:r.createElement("div",{style:{position:"relative"},onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1)},t,r.createElement(ki,{$visible:s,$position:n},r.createElement(Ai,{variant:"caption1"},e),r.createElement(_i,{$position:n})))},_i=({$position:e})=>r.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"},r.createElement("path",{d:"M6 6L0 0h12L6 6Z",fill:m.themedColor.textHighEmphasis})),wi={top:c.css`flex-direction:column;top:0;transform:translate(-50%,-100%);`,bottom:c.css`flex-direction:column-reverse;bottom:0;transform:translate(-50%,100%);`},ki=c.div`display:${({$visible:e})=>e?"flex":"none"};align-items:center;position:absolute;left:50%;z-index:${de.TOOLTIP};${({$position:e})=>wi[e]}`,Ai=c(S)`padding:6px 8px;background:${m.themedColor.textHighEmphasis};color:${m.themedColor.textHighEmphasisInverse};border-radius:4px;font-size:12px;white-space:nowrap;`,Ii=({submitted:e,value:t,onChange:n})=>{const{stringSet:o}=I(),s=Ti(),i=typeof t=="number";return r.createElement($i,null,r.createElement(S,{variant:"caption2",color:m.themedColor.textMidEmphasis},o.CSAT_RATING_TITLE),r.createElement(Mi,null,s.map(a=>r.createElement($n,{disabled:e,key:a.value,label:a.getTooltip(o)},r.createElement(Oi,{disabled:e,onClick:()=>n(a.value),$inactive:i&&!a.isActive(t)},i?a.isActive(t)?r.createElement(a.Icon.Active,null):r.createElement(a.Icon.Inactive,null):r.createElement(a.Icon.Active,null))))))},$i=c.div`display:flex;flex-direction:column;gap:8px;`,Mi=c.div`display:flex;justify-content:space-between;width:100%;max-width:320px;`,Oi=c.button`background-color:transparent;border:none;border-radius:4px;padding:0;display:flex;align-items:center;justify-content:center;box-sizing:border-box;&:enabled:hover{cursor:pointer;background-color:${m.color.background200};${L.dark`
92
+ `,ei=c(S)`align-items:flex-start;line-height:140%;white-space:pre-wrap;padding:0 12px;`;function ti(e){const{stringSet:t}=I(),n=kn(e)?r.createElement(Ht,{...e}):null;return e.messageType==="user"?n:e.messageType==="file"?e.file.type.startsWith("image")?r.createElement(Zs,{...e},n):r.createElement(Gs,{...e},n):r.createElement(Ht,{...e,message:t.UNKNOWN__UNKNOWN_MESSAGE_TYPE})}function ni({sendingStatus:e}){const t=c.useTheme();switch(e){case"pending":return r.createElement(ri,{size:16},r.createElement(A,{type:"spinner",color:t.colors.messageOutgoing.background,size:16}));case"failed":return r.createElement("div",{style:{marginBottom:2}},r.createElement(A,{type:"error",color:m.themedColor.error,size:16}));case"scheduled":case"canceled":return null;default:return r.createElement("div",null,r.createElement(A,{type:"chevron-down"}))}}const ri=c(Ct)`margin-bottom:2px;width:16px;height:16px;`;function oi({createdAt:e}){const{stringSet:t,format:n}=I();return e?r.createElement(S,{variant:"caption4",color:m.themedColor.textLowEmphasis},n(e,t.DATE_FORMAT__MESSAGE_TIMESTAMP)):null}const Ge=pe({template:si,components:{SendingStatus:ni,SentTime:oi,MessageBody:ti}});function si(e){const{components:t}=Ge.useContext(),n=e.sendingStatus==="succeeded",o=e.groupType==="bottom"||e.groupType==="single";return r.createElement(ii,{$marginBottom:ft(e.groupType)},r.createElement(ai,null,r.createElement(t.MessageBody,{...e})),o&&r.createElement(li,{$extraEndPadding:8},n?r.createElement(t.SentTime,{...e}):r.createElement(t.SendingStatus,{...e})))}const ii=c.div`display:flex;flex:1;flex-direction:column;align-items:flex-end;margin-bottom:${({$marginBottom:e})=>`${e}px`};
93
+ `,$n=c.div`display:flex;align-self:stretch;justify-content:flex-end;${({$startPadding:e=K,$endPadding:t=K,$extraEndPadding:n=0})=>`padding-inline: ${e}px ${t+n}px;`};
94
+ `,ai=c($n)``,li=c($n)`margin-top:${wn}px;`;function ci(e){return e.messageType!=="admin"?null:r.createElement(di,null,r.createElement(S,{variant:"caption2",color:m.themedColor.textMidEmphasis},ui(sn.sanitize(e.message))))}const di=c.div`text-align:center;text-wrap:pretty;a{text-decoration:none;color:inherit;}`,ui=e=>{const t=/\[([^\]]+)\]\((https?:\/\/[^\s]+)\)/g,n=[];let o=0;return e.replace(t,(s,a,i,l)=>(n.push(e.slice(o,l)),n.push(r.createElement("a",{key:i,href:i,target:"_blank",rel:Ve},a)),o=l+s.length,s)),n.push(e.slice(o)),n},mi=({submitted:e,defaultValue:t,value:n,onChange:o})=>{const{stringSet:s}=I();return d.useEffect(()=>{typeof n>"u"&&typeof t=="boolean"&&(o==null||o(t))},[n,t]),r.createElement(gi,null,r.createElement(S,{variant:"caption2",color:m.themedColor.textMidEmphasis},s.CSAT_CRE_TITLE),r.createElement("div",null,r.createElement(Ut,{checked:n===!0,label:s.CSAT_CRE_SOLVED,disabled:e,onClick:()=>o==null?void 0:o(!0)}),r.createElement(Ut,{checked:n===!1,label:s.CSAT_CRE_NOT_SOLVED,disabled:e,onClick:()=>o==null?void 0:o(!1)})))},Ut=({onClick:e,checked:t,label:n,disabled:o})=>{const s=t?m.color.primary.main:o?m.themedColor.textDisabled:m.themedColor.textLowEmphasis,a=t?m.themedColor.textHighEmphasis:o?m.themedColor.textLowEmphasis:m.themedColor.textHighEmphasis;return r.createElement(hi,{onClick:e,disabled:o},r.createElement(A,{size:24,type:t?"radio-on":"radio-off",color:s}),r.createElement(S,{variant:"caption2",color:a},n))},gi=c.div`display:flex;flex-direction:column;gap:8px;`,hi=c.button`all:unset;display:flex;align-items:center;justify-content:flex-start;gap:2px;span{line-height:initial;}&:enabled{cursor:pointer;}`,pi=e=>r.createElement("svg",{width:40,height:40,viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",id:"csat1",...e},r.createElement("path",{d:"M2.08301 20C2.08301 10.1049 10.1046 2.08334 19.9997 2.08334C29.8948 2.08334 37.9163 10.1049 37.9163 20C37.9163 29.8952 29.8948 37.9167 19.9997 37.9167C10.1046 37.9167 2.08301 29.8952 2.08301 20Z",fill:"#E0E0E0"}),r.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.5824 29.3328C13.1344 29.7473 13.918 29.636 14.3326 29.084C15.6269 27.3607 17.6835 26.25 19.9997 26.25C22.316 26.25 24.3727 27.3607 25.6668 29.084C26.0815 29.636 26.865 29.7473 27.4172 29.3328C27.9692 28.9182 28.0805 28.1347 27.6658 27.5825C25.9198 25.2577 23.1357 23.75 19.9997 23.75C16.8638 23.75 14.0797 25.2577 12.3336 27.5825C11.919 28.1347 12.0304 28.9182 12.5824 29.3328Z",fill:"black",fillOpacity:.12}),r.createElement("path",{d:"M28.4449 13.7707C29.1324 13.8328 29.64 14.4406 29.578 15.1281C29.516 15.8153 28.909 16.3221 28.2219 16.2608C28.2219 16.2608 28.0282 16.2502 27.9267 16.2487C27.7224 16.2457 27.4382 16.2509 27.1224 16.2833C26.7864 16.3177 26.4644 16.3782 26.1799 16.4662L26.304 16.86C26.7792 18.3675 25.5094 19.5813 24.2057 19.5813C23.504 19.5813 22.8319 19.2617 22.4295 18.6857C22.0025 18.0745 21.9417 17.241 22.4075 16.5344C22.7505 16.0143 23.2444 15.3831 23.8959 14.8657C24.8355 14.1195 26.0435 13.8809 26.867 13.7963C27.3024 13.7517 28.0149 13.7319 28.4449 13.7707Z",fill:"black",fillOpacity:.12}),r.createElement("path",{d:"M11.5553 13.7707C10.8677 13.8328 10.3601 14.4406 10.4221 15.1281C10.4842 15.8153 11.0912 16.3221 11.7782 16.2608C11.7782 16.2608 11.972 16.2502 12.0734 16.2487C12.2778 16.2457 12.562 16.2509 12.8778 16.2833C13.2137 16.3177 13.5357 16.3782 13.8203 16.4662L13.6962 16.86C13.2209 18.3675 14.4907 19.5813 15.7944 19.5813C16.4962 19.5813 17.1683 19.2617 17.5707 18.6857C17.9975 18.0745 18.0585 17.241 17.5925 16.5344C17.2497 16.0143 16.7557 15.3831 16.1043 14.8657C15.1646 14.1195 13.9566 13.8809 13.1331 13.7963C12.6978 13.7517 11.9853 13.7319 11.5553 13.7707Z",fill:"black",fillOpacity:.12})),fi=e=>r.createElement("svg",{width:40,height:40,viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},r.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)"}),r.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"}),r.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"}),r.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"}),r.createElement("defs",null,r.createElement("linearGradient",{id:"paint0_linear_159_173206",x1:20,y1:2.08325,x2:20,y2:37.9166,gradientUnits:"userSpaceOnUse"},r.createElement("stop",{stopColor:"#FF2D1D"}),r.createElement("stop",{offset:1,stopColor:"#FFA540"})))),bi=e=>r.createElement("svg",{width:40,height:40,viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},r.createElement("path",{d:"M19.9997 36.6667C29.2044 36.6667 36.6663 29.2048 36.6663 20C36.6663 10.7953 29.2044 3.33334 19.9997 3.33334C10.7949 3.33334 3.33301 10.7953 3.33301 20C3.33301 29.2048 10.7949 36.6667 19.9997 36.6667Z",fill:"#E0E0E0"}),r.createElement("path",{d:"M15 28.333C16.3927 27.2867 18.124 26.6667 20 26.6667C21.876 26.6667 23.6073 27.2867 25 28.333",stroke:"black",strokeOpacity:.12,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),r.createElement("path",{d:"M11.667 13.3511C11.667 13.3511 14.0161 13.139 15.3268 14.18M15.3268 14.18L14.8882 15.5711C14.7153 16.1199 15.1675 16.6667 15.7943 16.6667C16.4531 16.6667 16.8882 16.0723 16.549 15.5579C16.2483 15.102 15.8388 14.5866 15.3268 14.18ZM23.3337 13.3511C23.3337 13.3511 25.6827 13.139 26.9935 14.18M26.9935 14.18L26.555 15.5711C26.382 16.1199 26.8342 16.6667 27.461 16.6667C28.1198 16.6667 28.5548 16.0723 28.2157 15.5579C27.915 15.102 27.5055 14.5866 26.9935 14.18Z",stroke:"black",strokeOpacity:.12,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})),xi=e=>r.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:40,height:40,viewBox:"0 0 40 40",fill:"none",...e},r.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"}),r.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"}),r.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"}),r.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"})),Ei=e=>r.createElement("svg",{width:40,height:40,viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},r.createElement("path",{d:"M19.9997 36.6667C29.2044 36.6667 36.6663 29.2048 36.6663 20C36.6663 10.7953 29.2044 3.33334 19.9997 3.33334C10.7949 3.33334 3.33301 10.7953 3.33301 20C3.33301 29.2048 10.7949 36.6667 19.9997 36.6667Z",fill:"#E0E0E0"}),r.createElement("path",{d:"M13.348 15H13.333M26.6663 15H26.6513",stroke:"black",strokeOpacity:.12,strokeWidth:3.33333,strokeLinecap:"round",strokeLinejoin:"round"}),r.createElement("path",{d:"M15 26.6667H25",stroke:"black",strokeOpacity:.12,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})),vi=e=>r.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:40,height:40,viewBox:"0 0 40 40",fill:"none",...e},r.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"}),r.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"}),r.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"})),yi=e=>r.createElement("svg",{width:40,height:40,viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},r.createElement("path",{d:"M19.9997 36.6667C29.2044 36.6667 36.6663 29.2048 36.6663 20C36.6663 10.7953 29.2044 3.33334 19.9997 3.33334C10.7949 3.33334 3.33301 10.7953 3.33301 20C3.33301 29.2048 10.7949 36.6667 19.9997 36.6667Z",fill:"#E0E0E0"}),r.createElement("path",{d:"M13.333 25C14.8532 27.024 17.2735 28.3333 19.9997 28.3333C22.7258 28.3333 25.1462 27.024 26.6663 25",stroke:"black",strokeOpacity:.12,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),r.createElement("path",{d:"M13.348 15H13.333M26.6663 15H26.6513",stroke:"black",strokeOpacity:.12,strokeWidth:3.33333,strokeLinecap:"round",strokeLinejoin:"round"})),Ci=e=>r.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:40,height:40,viewBox:"0 0 40 40",fill:"none",...e},r.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"}),r.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"}),r.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"})),Si=e=>r.createElement("svg",{width:40,height:40,viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},r.createElement("path",{d:"M19.9997 36.6663C29.2044 36.6663 36.6663 29.2044 36.6663 19.9997C36.6663 10.7949 29.2044 3.33301 19.9997 3.33301C10.7949 3.33301 3.33301 10.7949 3.33301 19.9997C3.33301 29.2044 10.7949 36.6663 19.9997 36.6663Z",fill:"#E0E0E0"}),r.createElement("path",{d:"M19.9997 30C23.16 30 25.8145 27.867 26.56 24.9832C26.9068 23.6413 26.4033 23.3333 25.0765 23.3333H14.9228C13.5959 23.3333 13.0925 23.6413 13.4393 24.9832C14.1848 27.867 16.8393 30 19.9997 30Z",stroke:"black",strokeOpacity:.12,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),r.createElement("path",{d:"M11.667 15.8333C11.667 14.4526 12.7863 13.3333 14.167 13.3333C15.5477 13.3333 16.667 14.4526 16.667 15.8333M23.3337 15.8333C23.3337 14.4526 24.453 13.3333 25.8337 13.3333C27.2143 13.3333 28.3337 14.4526 28.3337 15.8333",stroke:"black",strokeOpacity:.12,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})),Ti=e=>r.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:40,height:40,viewBox:"0 0 40 40",fill:"none",...e},r.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"}),r.createElement("g",{clipPath:"url(#clip0_159_173224)"},r.createElement("g",{clipPath:"url(#clip1_159_173224)"},r.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"})),r.createElement("mask",{id:"mask0_159_173224",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:12,y:22,width:16,height:9},r.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"})),r.createElement("g",{mask:"url(#mask0_159_173224)"},r.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"}))),r.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"}),r.createElement("defs",null,r.createElement("clipPath",{id:"clip0_159_173224"},r.createElement("rect",{width:15.83,height:7.915,fill:"white",transform:"translate(12.085 22.709)"})),r.createElement("clipPath",{id:"clip1_159_173224"},r.createElement("rect",{width:15.83,height:7.915,fill:"white",transform:"translate(12.085 22.709)"})))),_i=[{value:1,Icon:{Active:fi,Inactive:pi},isActive:e=>e<=1,getTooltip:e=>e.CSAT5_RATING_SCORE_1},{value:2,Icon:{Active:xi,Inactive:bi},isActive:e=>e===2,getTooltip:e=>e.CSAT5_RATING_SCORE_2},{value:3,Icon:{Active:vi,Inactive:Ei},isActive:e=>e===3,getTooltip:e=>e.CSAT5_RATING_SCORE_3},{value:4,Icon:{Active:Ci,Inactive:yi},isActive:e=>e===4,getTooltip:e=>e.CSAT5_RATING_SCORE_4},{value:5,Icon:{Active:Ti,Inactive:Si},isActive:e=>5<=e,getTooltip:e=>e.CSAT5_RATING_SCORE_5}],wi=()=>_i,Mn=({label:e,children:t,position:n="top",disabled:o})=>o?t:r.createElement(lt,null,t,r.createElement(Ii,{$position:n},r.createElement($i,{variant:"caption1"},e),r.createElement(ki,{$position:n}))),ki=({$position:e})=>r.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"},r.createElement("path",{d:"M6 6L0 0h12L6 6Z",fill:m.themedColor.textHighEmphasis})),Ai={top:c.css`flex-direction:column;top:0;transform:translate(-50%,-100%);`,bottom:c.css`flex-direction:column-reverse;bottom:0;transform:translate(-50%,100%);`},lt=c.div`position:relative;`,Ii=c.div`display:flex;align-items:center;position:absolute;left:50%;z-index:${de.TOOLTIP};${({$position:e})=>Ai[e]}opacity:0;transition:opacity 0.2s ease-in-out;pointer-events:none;${lt}:hover &,${lt}:focus-within &{opacity:1;}`,$i=c(S)`padding:6px 8px;background:${m.themedColor.textHighEmphasis};color:${m.themedColor.textHighEmphasisInverse};border-radius:4px;font-size:12px;white-space:nowrap;`,Mi=({submitted:e,value:t,onChange:n})=>{const{stringSet:o}=I(),s=wi(),a=typeof t=="number";return r.createElement(Oi,null,r.createElement(S,{variant:"caption2",color:m.themedColor.textMidEmphasis},o.CSAT_RATING_TITLE),r.createElement(Li,null,s.map(i=>r.createElement(Mn,{disabled:e,key:i.value,label:i.getTooltip(o)},r.createElement(Ri,{disabled:e,onClick:()=>n(i.value),$inactive:a&&!i.isActive(t)},a?i.isActive(t)?r.createElement(i.Icon.Active,null):r.createElement(i.Icon.Inactive,null):r.createElement(i.Icon.Active,null))))))},Oi=c.div`display:flex;flex-direction:column;gap:8px;`,Li=c.div`display:flex;justify-content:space-between;width:100%;max-width:320px;`,Ri=c.button`background-color:transparent;border:none;border-radius:4px;padding:0;display:flex;align-items:center;justify-content:center;box-sizing:border-box;&:enabled:hover{cursor:pointer;background-color:${m.color.background200};${L.dark`
94
95
  background-color: ${m.color.background500};
95
96
  `}
96
97
  }
97
98
 
98
- ${({$inactive:e,theme:t})=>e&&t.selected==="dark"&&Li};
99
- `,Li=c.css`[fill]{fill:white;fill-opacity:0.12;}[stroke]{stroke:white;stroke-opacity:0.12;}`,Ri=({submitted:e,value:t="",onChange:n})=>{const{stringSet:o}=I();return e&&!t?null:r.createElement(Pi,{disabled:e,maxLength:255,value:t,onChange:s=>n(s.target.value),placeholder:o.CSAT_REASON_PLACEHOLDER})},Pi=c.input`box-sizing:border-box;width:100%;border-radius:4px;padding:10px 16px;font-size:14px;font-weight:400;font-style:normal;border:unset;&:focus{outline:none;}color:${m.themedColor.textHighEmphasis};&::placeholder{color:${m.themedColor.textLowEmphasis};}background-color:${m.color.background50};${L.dark`
99
+ ${({$inactive:e,theme:t})=>e&&t.selectedTheme==="dark"&&Pi};
100
+ `,Pi=c.css`[fill]{fill:white;fill-opacity:0.12;}[stroke]{stroke:white;stroke-opacity:0.12;}`,Ni=({submitted:e,value:t="",onChange:n})=>{const{stringSet:o}=I();return e&&!t?null:r.createElement(Di,{disabled:e,maxLength:255,value:t,onChange:s=>n(s.target.value),placeholder:o.CSAT_REASON_PLACEHOLDER})},Di=c.input`box-sizing:border-box;width:100%;border-radius:4px;padding:10px 16px;font-size:14px;font-weight:400;font-style:normal;border:unset;&:focus{outline:none;}color:${m.themedColor.textHighEmphasis};&::placeholder{color:${m.themedColor.textLowEmphasis};}background-color:${m.color.background50};${L.dark`
100
101
  background-color: ${m.themedColor.textDisabled};
101
102
  `}
102
103
 
@@ -109,14 +110,14 @@
109
110
  background-color: ${m.themedColor.textDisabled};
110
111
  `}
111
112
  }
112
- `,Ni=({submitted:e})=>{const{stringSet:t}=I();return e?r.createElement(S,{variant:"h2",color:m.themedColor.textHighEmphasis},t.CSAT_TITLE_SUBMITTED):r.createElement(S,{variant:"h2",color:m.themedColor.textHighEmphasis},t.CSAT_TITLE_UNSUBMITTED)};var Q=(e=>(e.AI_AGENT_CSAT_5="AI_AGENT_CSAT_5",e.AI_AGENT_CSAT_5_WITH_CRE="AI_AGENT_CSAT_5_WITH_CRE",e))(Q||{});const Di=e=>d.useReducer((t,n)=>({...t,...n}),e),Ut=({type:e,renderSubmitButton:t,initialCsat:n,initialCsatReason:o,initialIsResolved:s})=>{const[i,a]=Di({csatType:e,csat:n,csatReason:o,isResolved:s}),l=typeof n=="number"?"submitted":e===Q.AI_AGENT_CSAT_5&&typeof i.csat=="number"||e===Q.AI_AGENT_CSAT_5_WITH_CRE&&typeof i.csat=="number"&&typeof i.isResolved=="boolean"?"submittable":"unsubmittable",u={state:l,submitted:l==="submitted"};return r.createElement(r.Fragment,null,r.createElement(Bi,null,r.createElement(Ni,{...u}),e===Q.AI_AGENT_CSAT_5_WITH_CRE&&r.createElement(di,{...u,defaultValue:s,value:i.isResolved,onChange:h=>a({isResolved:h})}),r.createElement(Ii,{...u,value:i.csat,onChange:h=>a({csat:h})}),i.csat&&r.createElement(Ri,{...u,value:i.csatReason,onChange:h=>a({csatReason:h})})),l!=="submitted"&&t({state:l,params:i}))},Bi=c.div`display:flex;flex-direction:column;gap:12px;`,Fi=()=>{const{stringSet:e}=I();return r.createElement(S,{variant:"body2",color:m.themedColor.textMidEmphasis,style:{textAlign:"center"}},e.CSAT_SUBMISSION_EXPIRED)},zi=e=>{if(e.messageType!=="admin.csat")throw new Error("Invalid message type");const t=ze.useForceUpdate(),{stringSet:n}=I(),{extendedMessagePayload:o,csat:s,csatReason:i,csatExpireAt:a,isResolvedWhenDeterminedByUser:l,onSubmitCSAT:u}=e,{visibility:h,type:g}=(o==null?void 0:o.csat)??{};if(!h||!g||!Q[g])return null;const p=g===Q.AI_AGENT_CSAT_5||g===Q.AI_AGENT_CSAT_5_WITH_CRE?Ut:()=>null,f=x=>{x.csat&&!Wt(a)?u({csatType:x.csatType,csat:x.csat,csatReason:x.csatReason,isResolved:x.isResolved}):t()};return r.createElement(Hi,null,!s&&Wt(a)?r.createElement(Fi,null):r.createElement(p,{type:g,initialCsat:s,initialCsatReason:i,initialIsResolved:l,renderSubmitButton:({state:x,params:E})=>r.createElement(Ui,{disabled:x!=="submittable",onClick:()=>f(E)},r.createElement(S,{variant:"button"},n.CSAT_SUBMIT_LABEL))}))},Hi=c.div`display:flex;flex-direction:column;background-color:${({theme:e})=>e.colors.csat.background};border-radius:16px;gap:16px;padding:24px;`,Ui=c.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;&:hover{background-color:${m.color.primary.dark};}&:disabled{color:${m.color.ondark.textLowEmphasis};background-color:${m.themedColor.textDisabled};cursor:not-allowed;}`;function Wt(e){return!!e&&e<Date.now()}const qe=pe({template:Wi,components:{AdminMessage:ai,CSATMessage:zi}});function Wi(e){const{components:t}=qe.useContext(),n=vt(()=>e.messageType==="admin"?r.createElement(t.AdminMessage,{...e}):e.messageType==="admin.csat"?r.createElement(t.CSATMessage,{...e}):null);return r.createElement(Vi,{$marginBottom:pt(e.groupType)},n)}const Vi=c.div`padding-inline:${K}px;margin-bottom:${({$marginBottom:e})=>e}px;`,Vt={file:"attach",snippet:"snippet",site:"website",sb_sprinklr:"sprinklr",sb_salesforce:"salesforce",sb_confluence:"confluence",sb_zendesk:"zendesk",sb_desk:"snippet"},Mn=({actionbook:e,functionCalls:t,groundedness:n,agentMessageTemplates:o,onClickActionbook:s,onClickFunctionCall:i,onClickFunctionCallDetail:a,onClickGroundedness:l,onClickAgentMessageTemplate:u,bottomContent:h,renderCustomGroundednessIcon:g=f=>f.default,style:p={}})=>{const{iconColor:f="#000000",textColor:x="#000000",highlightColor:E=pn.DEFAULT_PRIMARY}=p;return r.createElement(jt,null,e&&r.createElement(jt,null,r.createElement(Fe,null,r.createElement(Le,null,r.createElement(A,{size:16,type:"actionbook",color:f})),r.createElement(Oe,{$clickable:!!s,$highlightColor:E,variant:"body2",color:x,onClick:()=>s==null?void 0:s(e)},e.name))),t==null?void 0:t.map(y=>r.createElement(tt,{key:y.key},r.createElement(Le,null,r.createElement(A,{size:16,type:"function",color:f})),r.createElement(Fe,null,r.createElement(Oe,{$clickable:!!s,$highlightColor:E,variant:"body2",color:x,onClick:()=>i==null?void 0:i(y)},y.name),r.createElement(Gi,{role:"button",onClick:()=>a==null?void 0:a(y)},r.createElement(S,{variant:"body2",color:E},"View details"),r.createElement(A,{type:"chevron-right",size:16,color:E}))))),n==null?void 0:n.map(y=>r.createElement(tt,{key:y.id},r.createElement(Le,null,g({default:r.createElement(A,{size:16,type:Vt[y.source_type]??Vt.snippet,color:f}),sourceType:y.source_type})),r.createElement(Oe,{$clickable:!!l,$highlightColor:E,variant:"body2",color:x,onClick:()=>l==null?void 0:l(y)},y.preview_title))),o==null?void 0:o.map(y=>r.createElement(tt,{key:y.key},r.createElement(Le,null,r.createElement(A,{size:16,type:"template",color:f})),r.createElement(Oe,{$clickable:!!u,$highlightColor:E,variant:"body2",color:x,onClick:()=>u==null?void 0:u(y)},y.name))),h)},ji=c(S)`font-weight:400;`,Oe=c(ji)`${({$clickable:e,$highlightColor:t})=>e&&c.css`
113
+ `,Bi=({submitted:e})=>{const{stringSet:t}=I();return e?r.createElement(S,{variant:"h2",color:m.themedColor.textHighEmphasis},t.CSAT_TITLE_SUBMITTED):r.createElement(S,{variant:"h2",color:m.themedColor.textHighEmphasis},t.CSAT_TITLE_UNSUBMITTED)};var Q=(e=>(e.AI_AGENT_CSAT_5="AI_AGENT_CSAT_5",e.AI_AGENT_CSAT_5_WITH_CRE="AI_AGENT_CSAT_5_WITH_CRE",e))(Q||{});const Fi=e=>d.useReducer((t,n)=>({...t,...n}),e),Wt=({type:e,renderSubmitButton:t,initialCsat:n,initialCsatReason:o,initialIsResolved:s})=>{const[a,i]=Fi({csatType:e,csat:n,csatReason:o,isResolved:s}),l=typeof n=="number"?"submitted":e===Q.AI_AGENT_CSAT_5&&typeof a.csat=="number"||e===Q.AI_AGENT_CSAT_5_WITH_CRE&&typeof a.csat=="number"&&typeof a.isResolved=="boolean"?"submittable":"unsubmittable",u={state:l,submitted:l==="submitted"};return r.createElement(r.Fragment,null,r.createElement(zi,null,r.createElement(Bi,{...u}),e===Q.AI_AGENT_CSAT_5_WITH_CRE&&r.createElement(mi,{...u,defaultValue:s,value:a.isResolved,onChange:h=>i({isResolved:h})}),r.createElement(Mi,{...u,value:a.csat,onChange:h=>i({csat:h})}),a.csat&&r.createElement(Ni,{...u,value:a.csatReason,onChange:h=>i({csatReason:h})})),l!=="submitted"&&t({state:l,params:a}))},zi=c.div`display:flex;flex-direction:column;gap:12px;`,Hi=()=>{const{stringSet:e}=I();return r.createElement(S,{variant:"body2",color:m.themedColor.textMidEmphasis,style:{textAlign:"center"}},e.CSAT_SUBMISSION_EXPIRED)},Ui=e=>{if(e.messageType!=="admin.csat")throw new Error("Invalid message type");const t=ze.useForceUpdate(),{stringSet:n}=I(),{extendedMessagePayload:o,csat:s,csatReason:a,csatExpireAt:i,isResolvedWhenDeterminedByUser:l,onSubmitCSAT:u}=e,{visibility:h,type:g}=(o==null?void 0:o.csat)??{};if(!h||!g||!Q[g])return null;const p=g===Q.AI_AGENT_CSAT_5||g===Q.AI_AGENT_CSAT_5_WITH_CRE?Wt:()=>null,f=x=>{x.csat&&!Vt(i)?u({csatType:x.csatType,csat:x.csat,csatReason:x.csatReason,isResolved:x.isResolved}):t()};return r.createElement(Wi,null,!s&&Vt(i)?r.createElement(Hi,null):r.createElement(p,{type:g,initialCsat:s,initialCsatReason:a,initialIsResolved:l,renderSubmitButton:({state:x,params:E})=>r.createElement(Vi,{disabled:x!=="submittable",onClick:()=>f(E)},r.createElement(S,{variant:"button"},n.CSAT_SUBMIT_LABEL))}))},Wi=c.div`display:flex;flex-direction:column;background-color:${({theme:e})=>e.colors.csat.background};border-radius:16px;gap:16px;padding:24px;`,Vi=c.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;&:hover{background-color:${m.color.primary.dark};}&:disabled{color:${m.color.ondark.textLowEmphasis};background-color:${m.themedColor.textDisabled};cursor:not-allowed;}`;function Vt(e){return!!e&&e<Date.now()}const qe=pe({template:ji,components:{AdminMessage:ci,CSATMessage:Ui}});function ji(e){const{components:t}=qe.useContext(),n=yt(()=>e.messageType==="admin"?r.createElement(t.AdminMessage,{...e}):e.messageType==="admin.csat"?r.createElement(t.CSATMessage,{...e}):null);return r.createElement(Gi,{$marginBottom:ft(e.groupType)},n)}const Gi=c.div`padding-inline:${K}px;margin-bottom:${({$marginBottom:e})=>e}px;`,jt={file:"attach",snippet:"snippet",site:"website",sb_sprinklr:"sprinklr",sb_salesforce:"salesforce",sb_confluence:"confluence",sb_zendesk:"zendesk",sb_desk:"snippet"},On=({actionbook:e,functionCalls:t,groundedness:n,agentMessageTemplates:o,onClickActionbook:s,onClickFunctionCall:a,onClickFunctionCallDetail:i,onClickGroundedness:l,onClickAgentMessageTemplate:u,bottomContent:h,renderCustomGroundednessIcon:g=f=>f.default,style:p={}})=>{const{iconColor:f="#000000",textColor:x="#000000",highlightColor:E=fn.DEFAULT_PRIMARY}=p;return r.createElement(Gt,null,e&&r.createElement(Gt,null,r.createElement(Fe,null,r.createElement(Le,null,r.createElement(A,{size:16,type:"actionbook",color:f})),r.createElement(Oe,{$clickable:!!s,$highlightColor:E,variant:"body2",color:x,onClick:()=>s==null?void 0:s(e)},e.name))),t==null?void 0:t.map(y=>r.createElement(tt,{key:y.key},r.createElement(Le,null,r.createElement(A,{size:16,type:"function",color:f})),r.createElement(Fe,null,r.createElement(Oe,{$clickable:!!s,$highlightColor:E,variant:"body2",color:x,onClick:()=>a==null?void 0:a(y)},y.name),r.createElement(Ki,{role:"button",onClick:()=>i==null?void 0:i(y)},r.createElement(S,{variant:"body2",color:E},"View details"),r.createElement(A,{type:"chevron-right",size:16,color:E}))))),n==null?void 0:n.map(y=>r.createElement(tt,{key:y.id},r.createElement(Le,null,g({default:r.createElement(A,{size:16,type:jt[y.source_type]??jt.snippet,color:f}),sourceType:y.source_type})),r.createElement(Oe,{$clickable:!!l,$highlightColor:E,variant:"body2",color:x,onClick:()=>l==null?void 0:l(y)},y.preview_title))),o==null?void 0:o.map(y=>r.createElement(tt,{key:y.key},r.createElement(Le,null,r.createElement(A,{size:16,type:"template",color:f})),r.createElement(Oe,{$clickable:!!u,$highlightColor:E,variant:"body2",color:x,onClick:()=>u==null?void 0:u(y)},y.name))),h)},qi=c(S)`font-weight:400;`,Oe=c(qi)`${({$clickable:e,$highlightColor:t})=>e&&c.css`
113
114
  cursor: pointer;
114
115
  text-decoration: underline;
115
116
  &:hover {
116
117
  color: ${t};
117
118
  }
118
119
  `}
119
- `,Le=c.div`display:flex;align-items:center;justify-content:center;flex-shrink:0;`,Fe=c.div`display:flex;gap:8px;align-items:center;`,Gi=c(Fe)`cursor:pointer;gap:4px;`,tt=c(Fe)`flex-direction:row;align-items:center;`,jt=c.div`display:flex;gap:4px;flex-direction:column;align-items:flex-start;`,On=d.createContext(null);function qi({isDashboardActionbookTester:e=!1,children:t}){return r.createElement(On.Provider,{value:{isDashboardActionbookTester:e}},e&&r.createElement(Ki,null),t)}const Ct=()=>{const e=d.useContext(On);if(!e)throw new Error("_UNSAFE_INTERNAL_DashboardActionbookTesterProvider not found");return e},Ki=()=>r.createElement(ce.Template,{template:Zi},r.createElement(ce.MessageLogs,{component:Yi})),Zi=e=>r.createElement(An,{...e,testerMode:!0,maxBodyWidth:Tn}),Yi=({extendedMessagePayload:e={}})=>{const{handlers:t}=O(),{manual:n,groundedness:o,function_calls:s,agent_message_templates:i,is_thinking:a}=e;return a||!n&&!(o!=null&&o.length)&&!(s!=null&&s.length)&&!(i!=null&&i.length)?r.createElement(r.Fragment,null):r.createElement(Ji,null,r.createElement(Xi,{width:4}),r.createElement(Mn,{actionbook:n,functionCalls:s,groundedness:o,agentMessageTemplates:i,onClickFunctionCallDetail:t==null?void 0:t.onFunctionCallDetailClick,style:{iconColor:m.themedColor.textHighEmphasis,textColor:m.themedColor.textHighEmphasis,barColor:m.themedColor.textDisabled},bottomContent:r.createElement(Qi,{variant:"caption2",color:m.themedColor.textLowEmphasis},"Only visible in the tester")}))},Ji=c.div`display:flex;gap:16px;margin:16px ${K}px 0;align-self:stretch;`,Xi=c.div`width:${({width:e})=>e}px;background-color:${m.themedColor.textDisabled};border-radius:100px;flex-shrink:0;`,Qi=c(S)`margin-top:5px;`,St={isStreaming(e){const t=Rt(e.data);return typeof t=="object"?!!t.stream:!1},isWelcomeMessage(e,t){var n;if(((n=e.extendedMessagePayload)==null?void 0:n.bot_message_type)==="welcome")return!0;if((e.isUserMessage()||e.isFileMessage())&&e.sender.userId===t){const o=Rt(e.data);return!(o!=null&&o.respond_mesg_id)&&!(o!=null&&o.stream)}return!1}};function ea(e){return"sendingStatus"in e?e.sendingStatus==="succeeded"?String(e.messageId):e.reqId:String(e.messageId)}const ta=(e,t,n,o=!0)=>{if(!o||!e.isUserMessage()&&!e.isFileMessage())return"single";const s=()=>{if(!t||!t.isUserMessage()&&!t.isFileMessage())return!1;const u=t.sender.userId===e.sender.userId,h=Ce.isSameMinute(t.createdAt,e.createdAt);return u&&h},i=()=>{if(!n||!n.isUserMessage()&&!n.isFileMessage())return!1;const u=n.sender.userId===e.sender.userId,h=Ce.isSameMinute(n.createdAt,e.createdAt);return u&&h},a=s(),l=i();return a&&l?"middle":a?"bottom":l?"top":"single"};function na(e,t){return e.filter(n=>St.isWelcomeMessage(n,t))}function Ln(e,t){return ra(e)===t}function ra(e){var t;if(e)return e.isUserMessage()||e.isFileMessage()||e.isMultipleFilesMessage()?e.sender.userId:((t=e==null?void 0:e.sender)==null?void 0:t.userId)??void 0}function oa(e){return e.isAdminMessage()?e.message==="The channel's custom_type was updated.":!1}const Gt=e=>!!e&&"sender"in e,Rn=e=>e.startsWith("image/"),Pn=e=>e.startsWith("video/"),qt=e=>Rn(e)||Pn(e),Re={isAdmin:e=>e.isAdminMessage(),isCSAT:e=>{var t;return e.isAdminMessage()&&!!((t=e.extendedMessagePayload)!=null&&t.csat)},isIncoming:(e,t)=>Gt(e)&&e.sender.userId!==t,isOutgoing:(e,t)=>Gt(e)&&(e.sender.userId===t||e.sendingStatus===rn.SendingStatus.PENDING)},Nn=({rootElementId:e,visible:t,onClose:n,children:o})=>{if(!t)return null;const{rootElement:s}=O(),i=le(s),a=le(s,!0);return ir.createPortal(r.createElement(sa,{onClick:n},r.createElement(ia,{onClick:l=>l.stopPropagation()},o)),i.getElementById(e)??i.getElementById(q.MODAL_ROOT)??a.body)},sa=c.div`position:fixed;top:0;left:0;width:100%;height:100%;background:${m.color.overlay.dark};display:flex;justify-content:center;align-items:center;z-index:${de.MODAL};`,ia=c.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:${de.MODAL};`,aa=c.div`flex-shrink:0;width:${({$size:e})=>ne(e)};height:${({$size:e})=>ne(e)};background-color:${({theme:e})=>e.colors.base.primary};box-sizing:border-box;padding:6px;border-radius:50%;display:flex;justify-content:center;align-items:center;}`,la=c(xt)`path{fill:${({theme:e})=>e.colors.base.primaryContrastContent};}`;function Dn({size:e}){const{aiAgentInfo:t}=R();return t.profileUrl?r.createElement(Et,{size:e,src:t.profileUrl}):r.createElement(aa,{$size:e},r.createElement(la,null))}const ca=c.div`width:100%;height:100%;position:fixed;top:0;left:0;outline:none;`,da=c.div`height:64px;min-height:64px;box-sizing:border-box;display:flex;justify-content:space-between;border-bottom:1px solid ${m.themedColor.textDisabled};background-color:${m.themedColor.bg_50_600};@media screen and (max-width:768px){position:relative;}`,ua=c.div`box-sizing:border-box;display:flex;flex-direction:row;align-items:center;height:64px;padding:16px 20px;width:calc(100% - 128px);`,ma=c.div`margin-inline-end:8px;`,ga=c.div`max-width:500px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;display:inline-block;@media screen and (max-width:768px){position:absolute;inset-inline-start:64px;top:10px;display:block;max-width:calc(100vw - 240px);}`,ha=c.div`display:inline-block;margin-inline-start:8px;padding-top:5px;@media screen and (max-width:768px){position:absolute;inset-inline-start:56px;top:24px;}`,pa=c.div`display:flex;width:160px;justify-content:flex-end;`,fa=c.div`inset-inline-end:0;display:flex;flex-direction:row;`,lt=c.div`width:64px;padding:21px;box-sizing:border-box;cursor:${e=>e.disabled?"not-allowed":"pointer"};`,ba=c(lt)`border-inline-start:1px solid ${m.themedColor.textDisabled};`,xa=c.div`width:100%;height:100%;display:flex;align-items:center;justify-content:center;`,Ea=c.video`max-width:100%;max-height:100%;user-select:none;-webkit-user-drag:none;`,va=c.img`max-width:90%;max-height:90%;user-select:none;-webkit-user-drag:none;`,ya=c.div`max-width:100%;max-height:100%;display:flex;justify-content:center;align-items:center;`,Ca=({message:e,onClose:t,onDownloadClick:n})=>{const{sender:o,type:s,url:i,name:a="",threadInfo:l}=e,{profileUrl:u,nickname:h,userId:g}=o,{userSession:p,aiAgentInfo:f}=R();return r.createElement(Ta,{profileUrl:u,nickname:h,type:s,url:i,name:a,onClose:t,isBotMessage:g===f.userId,isByMe:p.userId===g,disableDelete:l!=null&&l.replyCount?l.replyCount>0:!1,onDownloadClick:n})},Sa=({profileUrl:e,isBotMessage:t})=>!e&&t?r.createElement(Dn,{size:32}):r.createElement(Et,{size:32,src:e}),Ta=({profileUrl:e,isBotMessage:t,nickname:n,name:o,type:s,url:i,isByMe:a,onClose:l,onDelete:u,disableDelete:h,onDownloadClick:g})=>{const{stringSet:p}=I();return r.createElement(Nn,{onClose:l,visible:!0,rootElementId:q.MODAL_ROOT},r.createElement(ca,null,r.createElement(da,null,r.createElement(ua,null,r.createElement(ma,null,r.createElement(Sa,{profileUrl:e,isBotMessage:t})),r.createElement(ga,null,r.createElement(S,{variant:"h2",color:m.themedColor.textHighEmphasis},o)),r.createElement(ha,null,r.createElement(S,{variant:"body1",color:m.color.ondark.textMidEmphasis},n))),r.createElement(pa,null,qt(s)&&r.createElement(fa,null,r.createElement(lt,{as:"a",href:i,target:"_blank",rel:Ve,onClick:g},r.createElement(A,{type:"download",color:m.themedColor.textHighEmphasis,size:24})),u&&a&&r.createElement(lt,{disabled:h,onClick:()=>{h||u()}},r.createElement(A,{type:"delete",color:h?"gray":m.themedColor.textHighEmphasis,size:24}))),r.createElement(ba,{onClick:l},r.createElement(A,{type:"close",color:m.themedColor.textHighEmphasis,size:24})))),r.createElement(xa,{onClick:f=>f.currentTarget===f.target&&l()},Pn(s)&&r.createElement(Ea,{controls:!0},r.createElement("source",{src:i,type:s})),Rn(s)&&r.createElement(va,{src:i,alt:o}),!qt(s)&&r.createElement(ya,null,r.createElement(S,{variant:"h1",color:m.themedColor.textHighEmphasis},p.FILE_VIEWER__UNSUPPORT)))))},Bn=({className:e,locale:t,date:n=Date.now(),formatString:o="MMMM dd, yyyy",style:s})=>r.createElement(_a,{style:s,className:e},r.createElement(S,{variant:"caption4",color:m.themedColor.textMidEmphasis},Ce.format(n,o,{locale:t}))),_a=c.div`display:flex;justify-content:center;align-items:center;`,wa=d.forwardRef(function(t,n){const{messages:o,renderMessage:s,messageTopArea:i,messageBottomArea:a,overlayArea:l,onLoadPrev:u,onLoadNext:h,loadThreshold:g=.05,onScrollPosition:p=De,depsForResetScrollPositionToBottom:f,scrollPositionRef:x,scrollDistanceFromBottomRef:E,stackDirection:y="top"}=t,b=n&&"current"in n?n:{current:null},C=d.useRef(!1),T=d.useRef(void 0),_=d.useRef(0),$=d.useRef(0),Z=d.useRef(0),D=x??$,oe=E??Z;d.useLayoutEffect(()=>{b.current&&(b.current.scrollTop=b.current.scrollHeight)},f),d.useLayoutEffect(()=>{b.current&&(T.current==="top"&&(b.current.scrollTop=b.current.scrollHeight-D.current),T.current==="bottom"&&(b.current.scrollTop=_.current),T.current=void 0)},[b.current,o.length]);const be=async()=>{if(!b.current)return;const v=b.current;if(p(ka(v)),D.current=v.scrollHeight-v.scrollTop,oe.current=D.current-v.clientHeight,_.current=v.scrollTop,C.current)return;const B=v.clientHeight*Math.min(Math.max(0,g),1);v.scrollTop<=B?(C.current=!0,T.current="top",await u(),C.current=!1):v.scrollHeight-v.scrollTop-v.clientHeight<=B?(C.current=!0,T.current="bottom",await h(),C.current=!1):T.current=void 0};return r.createElement(Aa,{id:"infinite-list-container"},r.createElement(Ia,{id:"infinite-list-inner",ref:b,onScroll:be},y==="bottom"&&r.createElement("div",{style:{flexGrow:1}}),i,o.map((v,B)=>s({message:v,index:B})),a),r.createElement($a,{id:"infinite-list-overlay-container"},r.createElement(Ma,{id:"infinite-list-overlay"},l)))});function ka(e){return e.scrollTop<=10?"top":e.scrollHeight-(e.scrollTop+e.clientHeight)<=10?"bottom":"middle"}const Aa=c.div`display:flex;position:relative;flex:1;overflow:hidden;`,Ia=c.div`display:flex;flex:1;flex-direction:column;overflow-y:auto;scrollbar-color:${m.themedColor.textLowEmphasis}transparent;&::-webkit-scrollbar-thumb:hover{background-color:transparent;}`,$a=c.div`position:absolute;top:0;bottom:0;left:0;right:0;pointer-events:none;`,Ma=c.div`pointer-events:auto;`,Oa=({className:e,onClick:t})=>r.createElement(La,{className:e,onClick:t,tabIndex:0},r.createElement(A,{size:24,type:"chevron-down",color:m.color.primary.main})),La=c.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);${L.light`
120
+ `,Le=c.div`display:flex;align-items:center;justify-content:center;flex-shrink:0;`,Fe=c.div`display:flex;gap:8px;align-items:center;`,Ki=c(Fe)`cursor:pointer;gap:4px;`,tt=c(Fe)`flex-direction:row;align-items:center;`,Gt=c.div`display:flex;gap:4px;flex-direction:column;align-items:flex-start;`,Ln=d.createContext(null);function Zi({isDashboardActionbookTester:e=!1,children:t}){return r.createElement(Ln.Provider,{value:{isDashboardActionbookTester:e}},e&&r.createElement(Yi,null),t)}const St=()=>{const e=d.useContext(Ln);if(!e)throw new Error("_UNSAFE_INTERNAL_DashboardActionbookTesterProvider not found");return e},Yi=()=>r.createElement(ce.Template,{template:Ji},r.createElement(ce.MessageLogs,{component:Xi})),Ji=e=>r.createElement(In,{...e,testerMode:!0,maxBodyWidth:_n}),Xi=({extendedMessagePayload:e={}})=>{const{handlers:t}=O(),{manual:n,groundedness:o,function_calls:s,agent_message_templates:a,is_thinking:i}=e;return i||!n&&!(o!=null&&o.length)&&!(s!=null&&s.length)&&!(a!=null&&a.length)?r.createElement(r.Fragment,null):r.createElement(Qi,null,r.createElement(ea,{width:4}),r.createElement(On,{actionbook:n,functionCalls:s,groundedness:o,agentMessageTemplates:a,onClickFunctionCallDetail:t==null?void 0:t.onFunctionCallDetailClick,style:{iconColor:m.themedColor.textHighEmphasis,textColor:m.themedColor.textHighEmphasis,barColor:m.themedColor.textDisabled},bottomContent:r.createElement(ta,{variant:"caption2",color:m.themedColor.textLowEmphasis},"Only visible in the tester")}))},Qi=c.div`display:flex;gap:16px;margin:16px ${K}px 0;align-self:stretch;`,ea=c.div`width:${({width:e})=>e}px;background-color:${m.themedColor.textDisabled};border-radius:100px;flex-shrink:0;`,ta=c(S)`margin-top:5px;`,Tt={isStreaming(e){const t=Pt(e.data);return typeof t=="object"?!!t.stream:!1},isWelcomeMessage(e,t){var n;if(((n=e.extendedMessagePayload)==null?void 0:n.bot_message_type)==="welcome")return!0;if((e.isUserMessage()||e.isFileMessage())&&e.sender.userId===t){const o=Pt(e.data);return!(o!=null&&o.respond_mesg_id)&&!(o!=null&&o.stream)}return!1}};function na(e){return"sendingStatus"in e?e.sendingStatus==="succeeded"?String(e.messageId):e.reqId:String(e.messageId)}const ra=(e,t,n,o=!0)=>{if(!o||!e.isUserMessage()&&!e.isFileMessage())return"single";const s=()=>{if(!t||!t.isUserMessage()&&!t.isFileMessage())return!1;const u=t.sender.userId===e.sender.userId,h=Ce.isSameMinute(t.createdAt,e.createdAt);return u&&h},a=()=>{if(!n||!n.isUserMessage()&&!n.isFileMessage())return!1;const u=n.sender.userId===e.sender.userId,h=Ce.isSameMinute(n.createdAt,e.createdAt);return u&&h},i=s(),l=a();return i&&l?"middle":i?"bottom":l?"top":"single"};function oa(e,t){return e.filter(n=>Tt.isWelcomeMessage(n,t))}function Rn(e,t){return sa(e)===t}function sa(e){var t;if(e)return e.isUserMessage()||e.isFileMessage()||e.isMultipleFilesMessage()?e.sender.userId:((t=e==null?void 0:e.sender)==null?void 0:t.userId)??void 0}function ia(e){return e.isAdminMessage()?e.message==="The channel's custom_type was updated.":!1}const qt=e=>!!e&&"sender"in e,Pn=e=>e.startsWith("image/"),Nn=e=>e.startsWith("video/"),Kt=e=>Pn(e)||Nn(e),Re={isAdmin:e=>e.isAdminMessage(),isCSAT:e=>{var t;return e.isAdminMessage()&&!!((t=e.extendedMessagePayload)!=null&&t.csat)},isIncoming:(e,t)=>qt(e)&&e.sender.userId!==t,isOutgoing:(e,t)=>qt(e)&&(e.sender.userId===t||e.sendingStatus===on.SendingStatus.PENDING)},Dn=({rootElementId:e,visible:t,onClose:n,children:o})=>{if(!t)return null;const{rootElement:s}=O(),a=le(s),i=le(s,!0);return ar.createPortal(r.createElement(aa,{onClick:n},r.createElement(la,{onClick:l=>l.stopPropagation()},o)),a.getElementById(e)??a.getElementById(q.MODAL_ROOT)??i.body)},aa=c.div`position:fixed;top:0;left:0;width:100%;height:100%;background:${m.color.overlay.dark};display:flex;justify-content:center;align-items:center;z-index:${de.MODAL};`,la=c.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:${de.MODAL};`,ca=c.div`flex-shrink:0;width:${({$size:e})=>ne(e)};height:${({$size:e})=>ne(e)};background-color:${({theme:e})=>e.colors.base.primary};box-sizing:border-box;padding:6px;border-radius:50%;display:flex;justify-content:center;align-items:center;}`,da=c(Et)`path{fill:${({theme:e})=>e.colors.base.primaryContrastContent};}`;function Bn({size:e}){const{aiAgentInfo:t}=R();return t.profileUrl?r.createElement(vt,{size:e,src:t.profileUrl}):r.createElement(ca,{$size:e},r.createElement(da,null))}const ua=c.div`width:100%;height:100%;position:fixed;top:0;left:0;outline:none;`,ma=c.div`height:64px;min-height:64px;box-sizing:border-box;display:flex;justify-content:space-between;border-bottom:1px solid ${m.themedColor.textDisabled};background-color:${m.themedColor.bg_50_600};@media screen and (max-width:768px){position:relative;}`,ga=c.div`box-sizing:border-box;display:flex;flex-direction:row;align-items:center;height:64px;padding:16px 20px;width:calc(100% - 128px);`,ha=c.div`margin-inline-end:8px;`,pa=c.div`max-width:500px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;display:inline-block;@media screen and (max-width:768px){position:absolute;inset-inline-start:64px;top:10px;display:block;max-width:calc(100vw - 240px);}`,fa=c.div`display:inline-block;margin-inline-start:8px;padding-top:5px;@media screen and (max-width:768px){position:absolute;inset-inline-start:56px;top:24px;}`,ba=c.div`display:flex;width:160px;justify-content:flex-end;`,xa=c.div`inset-inline-end:0;display:flex;flex-direction:row;`,ct=c.div`width:64px;padding:21px;box-sizing:border-box;cursor:${e=>e.disabled?"not-allowed":"pointer"};`,Ea=c(ct)`border-inline-start:1px solid ${m.themedColor.textDisabled};`,va=c.div`width:100%;height:100%;display:flex;align-items:center;justify-content:center;`,ya=c.video`max-width:100%;max-height:100%;user-select:none;-webkit-user-drag:none;`,Ca=c.img`max-width:90%;max-height:90%;user-select:none;-webkit-user-drag:none;`,Sa=c.div`max-width:100%;max-height:100%;display:flex;justify-content:center;align-items:center;`,Ta=({message:e,onClose:t,onDownloadClick:n})=>{const{sender:o,type:s,url:a,name:i="",threadInfo:l}=e,{profileUrl:u,nickname:h,userId:g}=o,{userSession:p,aiAgentInfo:f}=R();return r.createElement(wa,{profileUrl:u,nickname:h,type:s,url:a,name:i,onClose:t,isBotMessage:g===f.userId,isByMe:p.userId===g,disableDelete:l!=null&&l.replyCount?l.replyCount>0:!1,onDownloadClick:n})},_a=({profileUrl:e,isBotMessage:t})=>!e&&t?r.createElement(Bn,{size:32}):r.createElement(vt,{size:32,src:e}),wa=({profileUrl:e,isBotMessage:t,nickname:n,name:o,type:s,url:a,isByMe:i,onClose:l,onDelete:u,disableDelete:h,onDownloadClick:g})=>{const{stringSet:p}=I();return r.createElement(Dn,{onClose:l,visible:!0,rootElementId:q.MODAL_ROOT},r.createElement(ua,null,r.createElement(ma,null,r.createElement(ga,null,r.createElement(ha,null,r.createElement(_a,{profileUrl:e,isBotMessage:t})),r.createElement(pa,null,r.createElement(S,{variant:"h2",color:m.themedColor.textHighEmphasis},o)),r.createElement(fa,null,r.createElement(S,{variant:"body1",color:m.color.ondark.textMidEmphasis},n))),r.createElement(ba,null,Kt(s)&&r.createElement(xa,null,r.createElement(ct,{as:"a",href:a,target:"_blank",rel:Ve,onClick:g},r.createElement(A,{type:"download",color:m.themedColor.textHighEmphasis,size:24})),u&&i&&r.createElement(ct,{disabled:h,onClick:()=>{h||u()}},r.createElement(A,{type:"delete",color:h?"gray":m.themedColor.textHighEmphasis,size:24}))),r.createElement(Ea,{onClick:l},r.createElement(A,{type:"close",color:m.themedColor.textHighEmphasis,size:24})))),r.createElement(va,{onClick:f=>f.currentTarget===f.target&&l()},Nn(s)&&r.createElement(ya,{controls:!0},r.createElement("source",{src:a,type:s})),Pn(s)&&r.createElement(Ca,{src:a,alt:o}),!Kt(s)&&r.createElement(Sa,null,r.createElement(S,{variant:"h1",color:m.themedColor.textHighEmphasis},p.FILE_VIEWER__UNSUPPORT)))))},Fn=({className:e,locale:t,date:n=Date.now(),formatString:o="MMMM dd, yyyy",style:s})=>r.createElement(ka,{style:s,className:e},r.createElement(S,{variant:"caption4",color:m.themedColor.textMidEmphasis},Ce.format(n,o,{locale:t}))),ka=c.div`display:flex;justify-content:center;align-items:center;`,Aa=d.forwardRef(function(t,n){const{messages:o,renderMessage:s,messageTopArea:a,messageBottomArea:i,overlayArea:l,onLoadPrev:u,onLoadNext:h,loadThreshold:g=.05,onScrollPosition:p=De,depsForResetScrollPositionToBottom:f,scrollPositionRef:x,scrollDistanceFromBottomRef:E,stackDirection:y="top"}=t,b=n&&"current"in n?n:{current:null},C=d.useRef(!1),T=d.useRef(void 0),_=d.useRef(0),$=d.useRef(0),Z=d.useRef(0),D=x??$,oe=E??Z;d.useLayoutEffect(()=>{b.current&&(b.current.scrollTop=b.current.scrollHeight)},f),d.useLayoutEffect(()=>{b.current&&(T.current==="top"&&(b.current.scrollTop=b.current.scrollHeight-D.current),T.current==="bottom"&&(b.current.scrollTop=_.current),T.current=void 0)},[b.current,o.length]);const be=async()=>{if(!b.current)return;const v=b.current;if(p(Ia(v)),D.current=v.scrollHeight-v.scrollTop,oe.current=D.current-v.clientHeight,_.current=v.scrollTop,C.current)return;const B=v.clientHeight*Math.min(Math.max(0,g),1);v.scrollTop<=B?(C.current=!0,T.current="top",await u(),C.current=!1):v.scrollHeight-v.scrollTop-v.clientHeight<=B?(C.current=!0,T.current="bottom",await h(),C.current=!1):T.current=void 0};return r.createElement($a,{id:"infinite-list-container"},r.createElement(Ma,{id:"infinite-list-inner",ref:b,onScroll:be},y==="bottom"&&r.createElement("div",{style:{flexGrow:1}}),a,o.map((v,B)=>s({message:v,index:B})),i),r.createElement(Oa,{id:"infinite-list-overlay-container"},r.createElement(La,{id:"infinite-list-overlay"},l)))});function Ia(e){return e.scrollTop<=10?"top":e.scrollHeight-(e.scrollTop+e.clientHeight)<=10?"bottom":"middle"}const $a=c.div`display:flex;position:relative;flex:1;overflow:hidden;`,Ma=c.div`display:flex;flex:1;flex-direction:column;overflow-y:auto;scrollbar-color:${m.themedColor.textLowEmphasis}transparent;&::-webkit-scrollbar-thumb:hover{background-color:transparent;}`,Oa=c.div`position:absolute;top:0;bottom:0;left:0;right:0;pointer-events:none;`,La=c.div`pointer-events:auto;`,Ra=({className:e,onClick:t})=>r.createElement(Pa,{className:e,onClick:t,tabIndex:0},r.createElement(A,{size:24,type:"chevron-down",color:m.color.primary.main})),Pa=c.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);${L.light`
120
121
  background-color: ${m.color.background50};
121
122
  &:hover {
122
123
  background-color: ${m.color.background100};
@@ -138,23 +139,23 @@
138
139
  &:focus {
139
140
  outline: none;
140
141
  }
141
- `,Fn=()=>{const{chatSDK:e}=O(),{channelSource:t}=j(),[n,o]=d.useState([]);return ze.useGroupChannelHandler(e,{onTypingStatusUpdated(s){var i;if(s.url===((i=t.channel)==null?void 0:i.url)){const a=s.getTypingUsers();o(a)}}}),n},Ra=()=>{const{agentPreviewConfigs:e={},aiAgentId:t}=O(),{aiAgentInfo:n}=R(),{stringSet:o,dateLocale:s}=I(),{messageSource:i}=j(),{Template:a}=ce.useContext(),l=e.welcomeMessages??[],u=i.messages,h=na(u,t),g=u[h.length+1],p=h[0]??g;return{filteredMessages:u.filter(f=>oa(f)?!1:l.length>0?!St.isWelcomeMessage(f,t):!0),shouldShowOriginalDate:f=>f>0||l.length===0?!0:g&&!Ce.isSameDay(g.createdAt,(p==null?void 0:p.createdAt)??0),renderAgentPreviewWelcomeMessages:()=>l.length===0?null:r.createElement(r.Fragment,null,r.createElement(Bn,{style:{margin:"16px 0"},date:p==null?void 0:p.createdAt,locale:s,formatString:o.DATE_FORMAT__MESSAGE_LIST__DATE_SEPARATOR}),l.map((f,x)=>{const E=x===l.length-1,y=h.length!==u.length,b=l.length===1?"single":x===0?"top":E||y?"bottom":"middle";return r.createElement(a,{messageType:"user",message:f.message,sender:n,groupType:b,createdAt:(p==null?void 0:p.createdAt)??Date.now(),extendedMessagePayload:{suggested_replies:f.suggestedReplies},suggestedRepliesDirection:e.suggestedRepliesDirection,suggestedRepliesVisible:E&&!y,isBotMessage:!0,onClickSuggestedReply:async({reply:C})=>{i.sendUserMessage({message:C})}})}))}},Pa=e=>c(e).withConfig({shouldForwardProp:ar});function Na(e){var o;const t="remove_powered_by",n=(o=e==null?void 0:e.appInfo)==null?void 0:o.applicationAttributes;return Array.isArray(n)&&n.includes(t)}const Da=({style:e})=>{const{stringSet:t}=I(),{chatSDK:n}=O(),{isDashboardActionbookTester:o}=Ct();return Na(n)||o?null:r.createElement(Ba,{variant:"caption2",style:e},t.POWERED_BY+" ",r.createElement(Fa,{variant:"caption2",as:"a",href:"https://sendbird.com?utm_medium=product&utm_source=aiagent&utm_campaign=fy26-glbl-ai-agent-poweredby","aria-label":"Learn more about Sendbird",rel:Ve,target:"_blank"},"Sendbird"))},Ba=c(S)`color:${m.themedColor.textLowEmphasis};text-align:center;`,Fa=Pa(S)`
142
+ `,zn=()=>{const{chatSDK:e}=O(),{channelSource:t}=j(),[n,o]=d.useState([]);return ze.useGroupChannelHandler(e,{onTypingStatusUpdated(s){var a;if(s.url===((a=t.channel)==null?void 0:a.url)){const i=s.getTypingUsers();o(i)}}}),n},Na=()=>{const{agentPreviewConfigs:e={},aiAgentId:t}=O(),{aiAgentInfo:n}=R(),{stringSet:o,dateLocale:s}=I(),{messageSource:a}=j(),{Template:i}=ce.useContext(),l=e.welcomeMessages??[],u=a.messages,h=oa(u,t),g=u[h.length+1],p=h[0]??g;return{filteredMessages:u.filter(f=>ia(f)?!1:l.length>0?!Tt.isWelcomeMessage(f,t):!0),shouldShowOriginalDate:f=>f>0||l.length===0?!0:g&&!Ce.isSameDay(g.createdAt,(p==null?void 0:p.createdAt)??0),renderAgentPreviewWelcomeMessages:()=>l.length===0?null:r.createElement(r.Fragment,null,r.createElement(Fn,{style:{margin:"16px 0"},date:p==null?void 0:p.createdAt,locale:s,formatString:o.DATE_FORMAT__MESSAGE_LIST__DATE_SEPARATOR}),l.map((f,x)=>{const E=x===l.length-1,y=h.length!==u.length,b=l.length===1?"single":x===0?"top":E||y?"bottom":"middle";return r.createElement(i,{messageType:"user",message:f.message,sender:n,groupType:b,createdAt:(p==null?void 0:p.createdAt)??Date.now(),extendedMessagePayload:{suggested_replies:f.suggestedReplies},suggestedRepliesDirection:e.suggestedRepliesDirection,suggestedRepliesVisible:E&&!y,isBotMessage:!0,onClickSuggestedReply:async({reply:C})=>{a.sendUserMessage({message:C})}})}))}},Da=e=>c(e).withConfig({shouldForwardProp:lr});function Ba(e){var o;const t="remove_powered_by",n=(o=e==null?void 0:e.appInfo)==null?void 0:o.applicationAttributes;return Array.isArray(n)&&n.includes(t)}const Fa=({style:e})=>{const{stringSet:t}=I(),{chatSDK:n}=O(),{isDashboardActionbookTester:o}=St();return Ba(n)||o?null:r.createElement(za,{variant:"caption2",style:e},t.POWERED_BY+" ",r.createElement(Ha,{variant:"caption2",as:"a",href:"https://sendbird.com?utm_medium=product&utm_source=aiagent&utm_campaign=fy26-glbl-ai-agent-poweredby","aria-label":"Learn more about Sendbird",rel:Ve,target:"_blank"},"Sendbird"))},za=c(S)`color:${m.themedColor.textLowEmphasis};text-align:center;`,Ha=Da(S)`
142
143
  color: ${m.themedColor.textLowEmphasis};
143
144
  cursor: pointer;
144
145
  text-decoration: none;
145
- `,za=()=>{var u;const{stringSet:e}=I(),{activeChannel:t}=R(),{channelSource:n,goToActiveConversation:o,scrollSource:s}=j(),i=Cn(n.channel),l=t&&((u=n.channel)==null?void 0:u.url)===(t==null?void 0:t.url)&&i;return d.useLayoutEffect(()=>{l&&s.scrollPubSub.publish({type:"scrollToBottom",data:{animated:!0}})},[l]),l?r.createElement(Ha,null,r.createElement(Ua,{variant:"button",role:"button",color:m.themedColor.textHighEmphasis,onClick:()=>o()},e.START_NEW_CONVERSATION)):null},Ha=c.div`display:flex;justify-content:center;margin:16px 0;`,Ua=c(S)`border-radius:6px;box-sizing:border-box;padding:10px 20px;border:1px solid ${m.themedColor.textDisabled};cursor:pointer;user-select:none;`,Wa=!0,Va=()=>{const{Template:e}=Ge.useContext(),{Template:t}=ce.useContext(),{Template:n}=qe.useContext(),[o,s]=d.useState(null),{userSession:i,aiAgentInfo:a}=R(),{agentPreviewConfigs:l,chatSDK:u,state:h}=O(),{stringSet:g,dateLocale:p}=I(),{conversation:f,channelSource:x,messageSource:E,scrollSource:y}=j(),{isDashboardActionbookTester:b}=Ct(),{filteredMessages:C,shouldShowOriginalDate:T,renderAgentPreviewWelcomeMessages:_}=Ra(),{storage:$}=mn(),Z=Fn(),D=vt(()=>{const v=Z[0];return v?v.userId===a.userId?a:v:null});d.useEffect(()=>{D&&setTimeout(()=>y.scrollPubSub.publish({type:"scrollToBottom",data:{animated:!0}}),25)},[!!D,y]);const oe=(v,B=!1)=>{var Y;return B?a:((Y=x.channel)==null?void 0:Y.members.find(H=>H.userId===v.sender.userId))??v.sender},be=()=>{if(!E.initialized)return r.createElement(he,{type:"loading"});if(E.messages.length===0){const v=_();return v?r.createElement("div",{style:{width:"100%"}},v):r.createElement(he,{type:"noMessages",label:g.PLACE_HOLDER__NO_MESSAGES})}return r.createElement(wa,{ref:y.scrollRef,scrollPositionRef:y.scrollPositionRef,scrollDistanceFromBottomRef:y.scrollDistanceFromBottomRef,onScrollPosition:v=>y.setIsScrollBottomReached(v==="bottom"),stackDirection:l==null?void 0:l.messageStackDirection,messages:C,onLoadPrev:E.loadPrevious,onLoadNext:E.loadNext,depsForResetScrollPositionToBottom:[E.initialized,E.messages.length!==0],messageTopArea:r.createElement(r.Fragment,null,r.createElement(Da,{style:{marginTop:16}}),_()),messageBottomArea:r.createElement(r.Fragment,null,D&&r.createElement(t,{isTyping:!0,sender:D,messageType:"user",groupType:"single",message:""}),r.createElement(za,null)),overlayArea:r.createElement(r.Fragment,null,!y.isScrollBottomReached&&r.createElement(Ga,{onClick:()=>y.scrollPubSub.publish({type:"scrollToBottom"})})),renderMessage:({message:v,index:B})=>{const Y=ea(v),H=C[B-1],Ye=C[B+1],k=C[C.length-1],w=v===k,M=ta(v,H,Ye,Wa),U=!or.isSameDay((H==null?void 0:H.createdAt)??0,v.createdAt)&&T(B)&&!b,ue=()=>{v.isFileMessage()&&s(v)},xe=()=>{v.isFileMessage()&&yn(v.url)},W=U?r.createElement(Bn,{style:{margin:"16px 0"},date:v.createdAt,locale:p,formatString:g.DATE_FORMAT__MESSAGE_LIST__DATE_SEPARATOR}):null,J={maxBodyWidth:h.expanded?Tn:void 0,extendedMessagePayload:v.extendedMessagePayload,createdAt:v.createdAt,groupType:M,onClickMedia:ue,onClickFile:xe},Ee=(()=>{var se,At;if(Re.isAdmin(v))return Re.isCSAT(v)?f?r.createElement(n,{...J,...f,isResolvedWhenDeterminedByUser:qa(f),messageType:"admin.csat",onSubmitCSAT:({csat:X,csatType:ie,csatReason:z,isResolved:me})=>{var It;X&&((It=x.channel)==null||It.submitCSAT({csat:X,csatType:ie,csatReason:z,isResolved:me}))}}):null:r.createElement(n,{...J,messageType:"admin",message:v.message});if(Re.isOutgoing(v,i.userId)){const X={...J,message:v.message,sender:oe(v),sendingStatus:v.sendingStatus};if(v.isUserMessage())return r.createElement(e,{messageType:"user",...X});if(v.isFileMessage()){const[ie,z]=((se=v.metaArrays.find(me=>me.key===vn))==null?void 0:se.value)??[];return r.createElement(e,{messageType:"file",file:v,metadata:{aspectRatio:ie&&z?`${ie}/${z}`:"1/1",localFile:(At=v.messageParams)==null?void 0:At.file},...X})}}if(Re.isIncoming(v,i.userId)){const X=v.sender.userId===a.userId,ie={...J,sender:oe(v,X),message:v.message,suggestedRepliesVisible:w,suggestedRepliesDirection:l==null?void 0:l.suggestedRepliesDirection,isBotMessage:X,onClickSuggestedReply:async({reply:z})=>{E.sendUserMessage({message:z})},onRequestMessageTemplate:async z=>{const{template:me}=await u.aiAgent.getMessageTemplate(z);return $.setTemplate(z,me),me},onGetCachedMessageTemplate:z=>$.getTemplate(z)};if(v.isUserMessage())return r.createElement(t,{messageType:"user",...ie});if(v.isFileMessage())return r.createElement(t,{messageType:"file",file:v,...ie})}})();return r.createElement("div",{key:Y,id:`${V}-message-item`},W,Ee)}})};return r.createElement(ja,{id:`${V}-message-list`},be(),o&&r.createElement(Ca,{onClose:()=>s(null),message:o}))},ja=c.div`overflow-y:hidden;display:flex;flex:1;position:relative;`,Ga=c(Oa)`position:absolute;bottom:20px;inset-inline-end:20px;`;function qa(e){var t;if(((t=e==null?void 0:e.resolution)==null?void 0:t.determinedBy)==="user")return e.resolution.isResolved}const Ka=()=>{const{stringSet:e}=I(),{connectionError:t}=R(),{channelSource:n}=j(),o=t||n.error;if(o){const s=t?void 0:{label:e.RETRY,onClick:()=>n.refetch()};return r.createElement(he,{type:"error",label:o.message,action:s})}return n.channel?r.createElement(Va,null):r.createElement(he,{type:"loading"})},zn=()=>{const{stringSet:e}=I(),{activeChannel:t}=R(),[n]=d.useState(()=>(t==null?void 0:t.status)===P.ConversationStatus.OPEN);return n?e.RETURN_TO_CONVERSATION:e.START_NEW_CONVERSATION},Za=()=>{const{stringSet:e}=I(),{goToActiveConversation:t}=j(),n=zn();return r.createElement(Ya,null,r.createElement(S,{variant:"body1",color:m.themedColor.textMidEmphasis},e.CONVERSATION_CLOSED_FOOTER_LABEL),r.createElement(Ja,{onClick:t},r.createElement(S,{variant:"button",color:m.themedColor.textHighEmphasis},n)))},Ya=c.div`display:flex;flex-direction:column;align-items:center;justify-content:center;padding:32px 0;gap:14px;${L.light`
146
+ `,Ua=()=>{var u;const{stringSet:e}=I(),{activeChannel:t}=R(),{channelSource:n,goToActiveConversation:o,scrollSource:s}=j(),a=Sn(n.channel),l=t&&((u=n.channel)==null?void 0:u.url)===(t==null?void 0:t.url)&&a;return d.useLayoutEffect(()=>{l&&s.scrollPubSub.publish({type:"scrollToBottom",data:{animated:!0}})},[l]),l?r.createElement(Wa,null,r.createElement(Va,{variant:"button",role:"button",color:m.themedColor.textHighEmphasis,onClick:()=>o()},e.START_NEW_CONVERSATION)):null},Wa=c.div`display:flex;justify-content:center;margin:16px 0;`,Va=c(S)`border-radius:6px;box-sizing:border-box;padding:10px 20px;border:1px solid ${m.themedColor.textDisabled};cursor:pointer;user-select:none;`,ja=!0,Ga=()=>{const{Template:e}=Ge.useContext(),{Template:t}=ce.useContext(),{Template:n}=qe.useContext(),[o,s]=d.useState(null),{userSession:a,aiAgentInfo:i}=R(),{agentPreviewConfigs:l,chatSDK:u,state:h}=O(),{stringSet:g,dateLocale:p}=I(),{conversation:f,channelSource:x,messageSource:E,scrollSource:y}=j(),{isDashboardActionbookTester:b}=St(),{filteredMessages:C,shouldShowOriginalDate:T,renderAgentPreviewWelcomeMessages:_}=Na(),{storage:$}=gn(),Z=zn(),D=yt(()=>{const v=Z[0];return v?v.userId===i.userId?i:v:null});d.useEffect(()=>{D&&setTimeout(()=>y.scrollPubSub.publish({type:"scrollToBottom",data:{animated:!0}}),25)},[!!D,y]);const oe=(v,B=!1)=>{var Y;return B?i:((Y=x.channel)==null?void 0:Y.members.find(H=>H.userId===v.sender.userId))??v.sender},be=()=>{if(!E.initialized)return r.createElement(he,{type:"loading"});if(E.messages.length===0){const v=_();return v?r.createElement("div",{style:{width:"100%"}},v):r.createElement(he,{type:"noMessages",label:g.PLACE_HOLDER__NO_MESSAGES})}return r.createElement(Aa,{ref:y.scrollRef,scrollPositionRef:y.scrollPositionRef,scrollDistanceFromBottomRef:y.scrollDistanceFromBottomRef,onScrollPosition:v=>y.setIsScrollBottomReached(v==="bottom"),stackDirection:l==null?void 0:l.messageStackDirection,messages:C,onLoadPrev:E.loadPrevious,onLoadNext:E.loadNext,depsForResetScrollPositionToBottom:[E.initialized,E.messages.length!==0],messageTopArea:r.createElement(r.Fragment,null,r.createElement(Fa,{style:{marginTop:16}}),_()),messageBottomArea:r.createElement(r.Fragment,null,D&&r.createElement(t,{isTyping:!0,sender:D,messageType:"user",groupType:"single",message:""}),r.createElement(Ua,null)),overlayArea:r.createElement(r.Fragment,null,!y.isScrollBottomReached&&r.createElement(Ka,{onClick:()=>y.scrollPubSub.publish({type:"scrollToBottom"})})),renderMessage:({message:v,index:B})=>{const Y=na(v),H=C[B-1],Ye=C[B+1],k=C[C.length-1],w=v===k,M=ra(v,H,Ye,ja),U=!sr.isSameDay((H==null?void 0:H.createdAt)??0,v.createdAt)&&T(B)&&!b,ue=()=>{v.isFileMessage()&&s(v)},xe=()=>{v.isFileMessage()&&Cn(v.url)},W=U?r.createElement(Fn,{style:{margin:"16px 0"},date:v.createdAt,locale:p,formatString:g.DATE_FORMAT__MESSAGE_LIST__DATE_SEPARATOR}):null,J={maxBodyWidth:h.expanded?_n:void 0,extendedMessagePayload:v.extendedMessagePayload,createdAt:v.createdAt,groupType:M,onClickMedia:ue,onClickFile:xe},Ee=(()=>{var se,It;if(Re.isAdmin(v))return Re.isCSAT(v)?f?r.createElement(n,{...J,...f,isResolvedWhenDeterminedByUser:Za(f),messageType:"admin.csat",onSubmitCSAT:({csat:X,csatType:ie,csatReason:z,isResolved:me})=>{var $t;X&&(($t=x.channel)==null||$t.submitCSAT({csat:X,csatType:ie,csatReason:z,isResolved:me}))}}):null:r.createElement(n,{...J,messageType:"admin",message:v.message});if(Re.isOutgoing(v,a.userId)){const X={...J,message:v.message,sender:oe(v),sendingStatus:v.sendingStatus};if(v.isUserMessage())return r.createElement(e,{messageType:"user",...X});if(v.isFileMessage()){const[ie,z]=((se=v.metaArrays.find(me=>me.key===yn))==null?void 0:se.value)??[];return r.createElement(e,{messageType:"file",file:v,metadata:{aspectRatio:ie&&z?`${ie}/${z}`:"1/1",localFile:(It=v.messageParams)==null?void 0:It.file},...X})}}if(Re.isIncoming(v,a.userId)){const X=v.sender.userId===i.userId,ie={...J,sender:oe(v,X),message:v.message,suggestedRepliesVisible:w,suggestedRepliesDirection:l==null?void 0:l.suggestedRepliesDirection,isBotMessage:X,onClickSuggestedReply:async({reply:z})=>{E.sendUserMessage({message:z})},onRequestMessageTemplate:async z=>{const{template:me}=await u.aiAgent.getMessageTemplate(z);return $.setTemplate(z,me),me},onGetCachedMessageTemplate:z=>$.getTemplate(z)};if(v.isUserMessage())return r.createElement(t,{messageType:"user",...ie});if(v.isFileMessage())return r.createElement(t,{messageType:"file",file:v,...ie})}})();return r.createElement("div",{key:Y,id:`${V}-message-item`},W,Ee)}})};return r.createElement(qa,{id:`${V}-message-list`},be(),o&&r.createElement(Ta,{onClose:()=>s(null),message:o}))},qa=c.div`overflow-y:hidden;display:flex;flex:1;position:relative;`,Ka=c(Ra)`position:absolute;bottom:20px;inset-inline-end:20px;`;function Za(e){var t;if(((t=e==null?void 0:e.resolution)==null?void 0:t.determinedBy)==="user")return e.resolution.isResolved}const Ya=()=>{const{stringSet:e}=I(),{connectionError:t}=R(),{channelSource:n}=j(),o=t||n.error;if(o){const s=t?void 0:{label:e.RETRY,onClick:()=>n.refetch()};return r.createElement(he,{type:"error",label:o.message,action:s})}return n.channel?r.createElement(Ga,null):r.createElement(he,{type:"loading"})},Hn=()=>{const{stringSet:e}=I(),{activeChannel:t}=R(),[n]=d.useState(()=>(t==null?void 0:t.status)===P.ConversationStatus.OPEN);return n?e.RETURN_TO_CONVERSATION:e.START_NEW_CONVERSATION},Ja=()=>{const{stringSet:e}=I(),{goToActiveConversation:t}=j(),n=Hn();return r.createElement(Xa,null,r.createElement(S,{variant:"body1",color:m.themedColor.textMidEmphasis},e.CONVERSATION_CLOSED_FOOTER_LABEL),r.createElement(Qa,{onClick:t},r.createElement(S,{variant:"button",color:m.themedColor.textHighEmphasis},n)))},Xa=c.div`display:flex;flex-direction:column;align-items:center;justify-content:center;padding:32px 0;gap:14px;${L.light`
146
147
  background-color: ${m.color.background100};
147
148
  `}
148
149
  ${L.dark`
149
150
  background-color: ${m.color.background500};
150
151
  `}
151
- `,Ja=c.button`all:unset;padding:10px 20px;border-radius:6px;border:1px solid ${m.themedColor.textDisabled};cursor:pointer;${L.light`
152
+ `,Qa=c.button`all:unset;padding:10px 20px;border-radius:6px;border:1px solid ${m.themedColor.textDisabled};cursor:pointer;${L.light`
152
153
  background-color: ${m.color.background50};
153
154
  `}
154
155
  ${L.dark`
155
156
  background-color: ${m.color.background700};
156
157
  `}
157
- `,Hn=d.createContext(void 0),Xa=({children:e})=>{const{stringSet:t}=I(),{aiAgentInfo:n}=R(),[o,s]=d.useState([]),[i,a]=d.useState({visible:!1,title:"",buttonText:t.BUTTON__OK}),l=n==null?void 0:n.replyToFile,u=p=>{if(!l)return;const f=p.filter(x=>bn.includes(x.type));if(f.length!==0){if(f.some(x=>x.size>Eo)){a(x=>({...x,visible:!0,title:t.FILE_UPLOAD_NOTIFICATION__SIZE_LIMIT.replace("%d","25")}));return}if(f.length>1||f.length>0&&o.length>0){a(x=>({...x,visible:!0,title:t.FILE_UPLOAD_NOTIFICATION__COUNT_LIMIT}));return}s(x=>[...x,...f.map(E=>({file:E,preview:{url:URL.createObjectURL(E),type:E.type,name:E.name}}))])}},h=p=>{s(f=>{var E;const x=(E=f[p])==null?void 0:E.preview;return x&&URL.revokeObjectURL(x.url),f.filter((y,b)=>b!==p)})},g=()=>{s(p=>(p.forEach(f=>URL.revokeObjectURL(f.preview.url)),[]))};return r.createElement(Hn.Provider,{value:{files:o,addFiles:u,removeFile:h,clearFiles:g,isFileUploadEnabled:l}},e,r.createElement(Qa,{...i,onClose:()=>a(p=>({...p,visible:!1,title:""}))}))},Tt=()=>{const e=d.useContext(Hn);if(!e)throw new Error("useFileUpload must be used within FileUploadProvider");return e},Qa=({title:e,buttonText:t,visible:n,onClose:o})=>r.createElement(Nn,{rootElementId:q.WINDOW,visible:n,onClose:o},r.createElement(el,null,r.createElement(nl,null,r.createElement(S,{variant:"h1",color:m.themedColor.textHighEmphasis},e)),r.createElement(tl,null,r.createElement(rl,{onClick:o},r.createElement(S,{variant:"button",color:m.themedColor.textHighEmphasisInverse},t))))),el=c.div`width:100%;height:auto;padding-block:18px 24px;padding-inline:24px;margin:0 auto;border-radius:4px;box-sizing:border-box;background-color:${({theme:e})=>e.colors.base.modalContentBackground};`,tl=c.div`display:flex;flex-direction:row;justify-content:flex-end;`,nl=c.div`margin-bottom:16px;`,rl=c.button`display:flex;justify-content:center;align-items:center;border-radius:4px;cursor:pointer;background-color:${m.themedColor.error};border:1px solid ${m.themedColor.error};padding:10px 16px;&:hover{background-color:${m.color.error.dark};border-color:${m.color.error.dark};}&:active{background-color:${m.color.error.extraDark};}`;function ol({blurred:e,elementRef:t,document:n=window.document}){const o=d.useRef(!1);e&&t.current&&n.activeElement===t.current&&(o.current=!0),d.useLayoutEffect(()=>{var s;!e&&o.current&&((s=t.current)==null||s.focus(),o.current=!1)},[e])}const sl=c.div`&::-webkit-scrollbar{display:none;}overflow-x:auto;display:flex;flex-direction:row;gap:10px;padding:8px 16px;background-color:transparent;`,il=c.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;}`,al=c.div`display:flex;align-items:center;justify-content:center;position:absolute;inset-inline-end:-8px;inset-block-start:-8px;cursor:pointer;border-radius:50%;${L.light`
158
+ `,Un=d.createContext(void 0),el=({children:e})=>{const{stringSet:t}=I(),{aiAgentInfo:n}=R(),[o,s]=d.useState([]),[a,i]=d.useState({visible:!1,title:"",buttonText:t.BUTTON__OK}),l=n==null?void 0:n.replyToFile,u=p=>{if(!l)return;const f=p.filter(x=>xn.includes(x.type));if(f.length!==0){if(f.some(x=>x.size>yo)){i(x=>({...x,visible:!0,title:t.FILE_UPLOAD_NOTIFICATION__SIZE_LIMIT.replace("%d","25")}));return}if(f.length>1||f.length>0&&o.length>0){i(x=>({...x,visible:!0,title:t.FILE_UPLOAD_NOTIFICATION__COUNT_LIMIT}));return}s(x=>[...x,...f.map(E=>({file:E,preview:{url:URL.createObjectURL(E),type:E.type,name:E.name}}))])}},h=p=>{s(f=>{var E;const x=(E=f[p])==null?void 0:E.preview;return x&&URL.revokeObjectURL(x.url),f.filter((y,b)=>b!==p)})},g=()=>{s(p=>(p.forEach(f=>URL.revokeObjectURL(f.preview.url)),[]))};return r.createElement(Un.Provider,{value:{files:o,addFiles:u,removeFile:h,clearFiles:g,isFileUploadEnabled:l}},e,r.createElement(tl,{...a,onClose:()=>i(p=>({...p,visible:!1,title:""}))}))},_t=()=>{const e=d.useContext(Un);if(!e)throw new Error("useFileUpload must be used within FileUploadProvider");return e},tl=({title:e,buttonText:t,visible:n,onClose:o})=>r.createElement(Dn,{rootElementId:q.WINDOW,visible:n,onClose:o},r.createElement(nl,null,r.createElement(ol,null,r.createElement(S,{variant:"h1",color:m.themedColor.textHighEmphasis},e)),r.createElement(rl,null,r.createElement(sl,{onClick:o},r.createElement(S,{variant:"button",color:m.themedColor.textHighEmphasisInverse},t))))),nl=c.div`width:100%;height:auto;padding-block:18px 24px;padding-inline:24px;margin:0 auto;border-radius:4px;box-sizing:border-box;background-color:${({theme:e})=>e.colors.base.modalContentBackground};`,rl=c.div`display:flex;flex-direction:row;justify-content:flex-end;`,ol=c.div`margin-bottom:16px;`,sl=c.button`display:flex;justify-content:center;align-items:center;border-radius:4px;cursor:pointer;background-color:${m.themedColor.error};border:1px solid ${m.themedColor.error};padding:10px 16px;&:hover{background-color:${m.color.error.dark};border-color:${m.color.error.dark};}&:active{background-color:${m.color.error.extraDark};}`;function il({blurred:e,elementRef:t,document:n=window.document}){const o=d.useRef(!1);e&&t.current&&n.activeElement===t.current&&(o.current=!0),d.useLayoutEffect(()=>{var s;!e&&o.current&&((s=t.current)==null||s.focus(),o.current=!1)},[e])}const al=c.div`&::-webkit-scrollbar{display:none;}overflow-x:auto;display:flex;flex-direction:row;gap:10px;padding:8px 16px;background-color:transparent;`,ll=c.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;}`,cl=c.div`display:flex;align-items:center;justify-content:center;position:absolute;inset-inline-end:-8px;inset-block-start:-8px;cursor:pointer;border-radius:50%;${L.light`
158
159
  background-color: ${m.color.background50};
159
160
  `}
160
161
  ${L.dark`
@@ -173,14 +174,14 @@
173
174
  circle {
174
175
  stroke: ${m.themedColor.bg_50_600};
175
176
  }
176
- `,ll=()=>{const e=_e(),[t,n]=d.useState(),{files:o,removeFile:s,isFileUploadEnabled:i}=Tt();return!i||o.length===0?null:r.createElement(sl,null,o.map(({preview:{type:a,name:l,url:u}},h)=>r.createElement(il,{key:u,onMouseOver:()=>n(h),onMouseLeave:()=>n(void 0)},(e||t===h)&&r.createElement(al,{title:"Remove file",onClick:()=>s(h)},r.createElement(A,{type:"close-filled",color:m.themedColor.textMidEmphasis})),a.startsWith("image/")?r.createElement("img",{alt:"file-image",src:u}):r.createElement(bt,{name:l,type:ft(l,a)}))))},cl=({channel:e,messages:t})=>{const{stringSet:n}=I(),{aiAgentInfo:o}=R(),s=dl(),i=ul({lastMessage:t[t.length-1],aiAgentUserId:o.userId});return!e||!s||Cn(e)?[!0,n.MESSAGE_INPUT__PLACE_HOLDER__DISABLED]:i?[!0,n.MESSAGE_INPUT__PLACE_HOLDER__WAIT_AI_AGENT_RESPONSE]:[!1,n.MESSAGE_INPUT__PLACE_HOLDER]},dl=()=>{const e=d.useId(),{chatSDK:t}=O(),[n,o]=d.useState(!0);return d.useEffect(()=>{const s=new N.ConnectionHandler({onDisconnected:()=>o(!1),onConnected:()=>o(!0),onReconnectSucceeded:()=>o(!0)});return t.addConnectionHandler(e,s),()=>{t.removeConnectionHandler(e)}},[t]),n},ul=({lastMessage:e,aiAgentUserId:t})=>{const[n,o]=d.useState(!1),s=Fn();return d.useEffect(()=>{if(!e)return;const i=s.some(l=>l.userId===t),a=Ln(e,t)&&St.isStreaming(e);o(!!(a||i))},[s,e,t]),n},Un={textArea:c.css`min-height:40px;height:40px;font-size:16px;line-height:24px;`,attachIcon:c.css`margin-bottom:4px;`},Wn=c.button`all:unset;cursor:pointer;display:flex;align-items:center;justify-content:center;width:32px;height:32px;`,ml=c(Wn)`flex-shrink:0;margin-inline-end:12px;margin-bottom:2px;&:disabled{cursor:not-allowed;}&:not(:disabled){&:hover{path{fill:${m.themedColor.textHighEmphasis};}}&:active{border-radius:4px;background-color:${m.themedColor.bg_200_400};}}${gt&&Un.attachIcon};`,gl=c.input`display:none;`,Kt=c.div`width:100%;position:relative;background-color:${m.themedColor.bg_100_500};border-radius:20px;`,Zt=c.div`display:flex;flex-direction:row;align-items:flex-end;position:relative;`,Yt=c.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:${m.themedColor.textHighEmphasis};resize:none;width:100%;height:${fn}px;overflow-wrap:break-word;white-space:pre-wrap;overflow-x:hidden;${gt&&Un.textArea};&::placeholder{color:${m.themedColor.textLowEmphasis};}&:disabled{cursor:not-allowed;&::placeholder{color:${m.themedColor.textDisabled};}}`,Jt=c.div`padding:12px 16px;position:relative;display:flex;align-items:center;`,Xt=({disabled:e})=>{const t=d.useRef(null),{addFiles:n,clearFiles:o,files:s,isFileUploadEnabled:i}=Tt();return!i||s.length>0?null:r.createElement(ml,{disabled:e,onClick:()=>{var a;o(),(a=t.current)==null||a.click()}},r.createElement(A,{type:"attach",color:e?m.themedColor.textDisabled:m.themedColor.textMidEmphasis,size:16}),r.createElement(gl,{type:"file",ref:t,onChange:a=>{const l=a.currentTarget.files;l&&n(Array.from(l)),a.target.value=""},accept:bn.join(",")}))},hl=()=>{const e=d.useRef(null),[t,n]=d.useState(""),{rootElement:o}=O(),{channelSource:s,messageSource:i}=j(),[a,l]=cl({channel:s.channel,messages:i.messages}),{files:u,addFiles:h,clearFiles:g}=Tt();Do({onDropFiles:h}),ol({blurred:a,elementRef:e,document:le(o)});const p=t.trim().length>0,f=u.length>0,x=!a&&(p||f),E=()=>{e.current&&(e.current.value="",e.current.style.height=""),g(),n("")},y=async()=>{const _=t.trim(),$={message:_};if(!(!_&&!u.length)){if(u.length>0){const Z=u[0].file,D={...$,file:Z};i.sendFileMessage(D),E();return}i.sendUserMessage($),E()}},b=_=>{const $=Array.from(_.clipboardData.files);$.length>0&&(_.preventDefault(),h($))},C=_=>{_.key!=="Enter"||_.nativeEvent.isComposing||_.shiftKey||(_.preventDefault(),y())},T=_=>{if(e.current){e.current.style.height="";const $=Math.min(xo,e.current.scrollHeight);fn<$&&(e.current.style.height=`${$}px`)}n(_.target.value)};return a?r.createElement(Jt,null,r.createElement(Kt,null,r.createElement(Zt,null,r.createElement(Yt,{disabled:!0,placeholder:l}),r.createElement(Xt,{disabled:!0})))):r.createElement(Jt,null,r.createElement(Kt,null,r.createElement(ll,null),r.createElement(Zt,null,r.createElement(Yt,{ref:e,role:"textbox","aria-label":"Text Input",placeholder:l,maxLength:5e3,onKeyDown:C,onChange:T,onPaste:b}),r.createElement(Xt,null))),x&&r.createElement(Wn,{onClick:()=>y()},r.createElement(A,{type:"send",color:m.color.primary.main,size:20})))},pl=c.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:${m.themedColor.textLowEmphasis};&& a{font-weight:700;text-decoration:none;${L.light`
177
+ `,dl=()=>{const e=_e(),[t,n]=d.useState(),{files:o,removeFile:s,isFileUploadEnabled:a}=_t();return!a||o.length===0?null:r.createElement(al,null,o.map(({preview:{type:i,name:l,url:u}},h)=>r.createElement(ll,{key:u,onMouseOver:()=>n(h),onMouseLeave:()=>n(void 0)},(e||t===h)&&r.createElement(cl,{title:"Remove file",onClick:()=>s(h)},r.createElement(A,{type:"close-filled",color:m.themedColor.textMidEmphasis})),i.startsWith("image/")?r.createElement("img",{alt:"file-image",src:u}):r.createElement(xt,{name:l,type:bt(l,i)}))))},ul=({channel:e,messages:t})=>{const{stringSet:n}=I(),{aiAgentInfo:o}=R(),s=ml(),a=gl({lastMessage:t[t.length-1],aiAgentUserId:o.userId});return!e||!s||Sn(e)?[!0,n.MESSAGE_INPUT__PLACE_HOLDER__DISABLED]:a?[!0,n.MESSAGE_INPUT__PLACE_HOLDER__WAIT_AI_AGENT_RESPONSE]:[!1,n.MESSAGE_INPUT__PLACE_HOLDER]},ml=()=>{const e=d.useId(),{chatSDK:t}=O(),[n,o]=d.useState(!0);return d.useEffect(()=>{const s=new N.ConnectionHandler({onDisconnected:()=>o(!1),onConnected:()=>o(!0),onReconnectSucceeded:()=>o(!0)});return t.addConnectionHandler(e,s),()=>{t.removeConnectionHandler(e)}},[t]),n},gl=({lastMessage:e,aiAgentUserId:t})=>{const[n,o]=d.useState(!1),s=zn();return d.useEffect(()=>{if(!e)return;const a=s.some(l=>l.userId===t),i=Rn(e,t)&&Tt.isStreaming(e);o(!!(i||a))},[s,e,t]),n},Wn={textArea:c.css`min-height:40px;height:40px;font-size:16px;line-height:24px;`,attachIcon:c.css`margin-bottom:4px;`},Vn=c.button`all:unset;cursor:pointer;display:flex;align-items:center;justify-content:center;width:32px;height:32px;`,hl=c(Vn)`flex-shrink:0;margin-inline-end:12px;margin-bottom:2px;&:disabled{cursor:not-allowed;}&:not(:disabled){&:hover{path{fill:${m.themedColor.textHighEmphasis};}}&:active{border-radius:4px;background-color:${m.themedColor.bg_200_400};}}${ht&&Wn.attachIcon};`,pl=c.input`display:none;`,Zt=c.div`width:100%;position:relative;background-color:${m.themedColor.bg_100_500};border-radius:20px;`,Yt=c.div`display:flex;flex-direction:row;align-items:flex-end;position:relative;`,Jt=c.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:${m.themedColor.textHighEmphasis};resize:none;width:100%;height:${bn}px;overflow-wrap:break-word;white-space:pre-wrap;overflow-x:hidden;${ht&&Wn.textArea};&::placeholder{color:${m.themedColor.textLowEmphasis};}&:disabled{cursor:not-allowed;&::placeholder{color:${m.themedColor.textDisabled};}}`,Xt=c.div`padding:12px 16px;position:relative;display:flex;align-items:center;`,Qt=({disabled:e})=>{const t=d.useRef(null),{addFiles:n,clearFiles:o,files:s,isFileUploadEnabled:a}=_t();return!a||s.length>0?null:r.createElement(hl,{disabled:e,onClick:()=>{var i;o(),(i=t.current)==null||i.click()}},r.createElement(A,{type:"attach",color:e?m.themedColor.textDisabled:m.themedColor.textMidEmphasis,size:16}),r.createElement(pl,{type:"file",ref:t,onChange:i=>{const l=i.currentTarget.files;l&&n(Array.from(l)),i.target.value=""},accept:xn.join(",")}))},fl=()=>{const e=d.useRef(null),[t,n]=d.useState(""),{rootElement:o}=O(),{channelSource:s,messageSource:a}=j(),[i,l]=ul({channel:s.channel,messages:a.messages}),{files:u,addFiles:h,clearFiles:g}=_t();Fo({onDropFiles:h}),il({blurred:i,elementRef:e,document:le(o)});const p=t.trim().length>0,f=u.length>0,x=!i&&(p||f),E=()=>{e.current&&(e.current.value="",e.current.style.height=""),g(),n("")},y=async()=>{const _=t.trim(),$={message:_};if(!(!_&&!u.length)){if(u.length>0){const Z=u[0].file,D={...$,file:Z};a.sendFileMessage(D),E();return}a.sendUserMessage($),E()}},b=_=>{const $=Array.from(_.clipboardData.files);$.length>0&&(_.preventDefault(),h($))},C=_=>{_.key!=="Enter"||_.nativeEvent.isComposing||_.shiftKey||(_.preventDefault(),y())},T=_=>{if(e.current){e.current.style.height="";const $=Math.min(vo,e.current.scrollHeight);bn<$&&(e.current.style.height=`${$}px`)}n(_.target.value)};return i?r.createElement(Xt,null,r.createElement(Zt,null,r.createElement(Yt,null,r.createElement(Jt,{disabled:!0,placeholder:l}),r.createElement(Qt,{disabled:!0})))):r.createElement(Xt,null,r.createElement(Zt,null,r.createElement(dl,null),r.createElement(Yt,null,r.createElement(Jt,{ref:e,role:"textbox","aria-label":"Text Input",placeholder:l,maxLength:5e3,onKeyDown:C,onChange:T,onPaste:b}),r.createElement(Qt,null))),x&&r.createElement(Vn,{onClick:()=>y()},r.createElement(A,{type:"send",color:m.color.primary.main,size:20})))},bl=c.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:${m.themedColor.textLowEmphasis};&& a{font-weight:700;text-decoration:none;${L.light`
177
178
  color: ${m.color.information.light};
178
179
  `};
179
180
  ${L.dark`
180
181
  color: ${m.color.information.main};
181
182
  `};
182
183
  }
183
- `,fl=d.lazy(()=>Promise.resolve().then(()=>require("./muE0PabX.cjs")).then(e=>({default:e.MarkdownText}))),bl=()=>{const{aiAgentInfo:e}=R(),{messageSource:t}=j(),{userSession:n}=R();return!e.specialNoticeEnabled||!e.specialNotice||!(t.initialized&&!t.messages.some(s=>Ln(s,n.userId)))?null:r.createElement(pl,null,r.createElement(fl,null,e.specialNotice))},xl=()=>r.createElement(El,null,r.createElement(bl,null),r.createElement(Xa,null,r.createElement(hl,null))),El=c.div`z-index:0;border:none;width:100%;`,vl=()=>{var i,a,l;const{activeChannel:e}=R(),{channelSource:t}=j(),n=((a=(i=t.channel)==null?void 0:i.conversation)==null?void 0:a.status)===P.ConversationStatus.CLOSED;return!(((l=t.channel)==null?void 0:l.url)===(e==null?void 0:e.url))&&n?r.createElement(Za,null):r.createElement(xl,null)},yl=()=>{var T;const{state:e,logger:t,enableCloseConversationButton:n,enableExpandButton:o,dispatcher:s}=O(),{stringSet:i}=I(),{aiAgentInfo:a,activeChannel:l}=R(),{channelSource:u,onNavigateToConversationList:h}=j(),g=u.channel,f=_e()?24:16,x=()=>{e.setOpened(!1)},E=async()=>{try{const _=await(g==null?void 0:g.markConversationAsHandoff());t.info("conversation.handleAgentHandoff: success",_)}catch(_){t.error("conversation.handleAgentHandoff: error",_)}},y=async()=>{g&&await s.send(ln.CloseConversation())},b=l&&(g==null?void 0:g.url)===l.url,C=a.showHandoffButton&&!!((T=g==null?void 0:g.conversation)!=null&&T.handoff)&&b;return r.createElement(wl,null,r.createElement(kl,null,h&&r.createElement(ke,{onClick:()=>h()},r.createElement(A,{type:"menu",size:24,color:m.themedColor.textHighEmphasis})),b&&r.createElement(Dn,{size:34}),r.createElement(Il,{variant:"h2",color:m.themedColor.textHighEmphasis},a.nickname||(g==null?void 0:g.name))),r.createElement(Al,null,C&&r.createElement(_l,{tooltipLabel:i.HEADER_BUTTON__AGENT_HANDOFF,disabled:!No(g),size:f,onClick:E}),n&&r.createElement(Tl,{disabled:!Sn(g),size:f,onClick:y}),o&&r.createElement(Cl,{size:f}),r.createElement(Sl,{size:f,onClick:x})))},Cl=({size:e,disabled:t})=>{const{state:n}=O();return r.createElement(ke,{"aria-label":"expand",onClick:()=>n.setExpanded(!n.expanded),disabled:t},r.createElement(A,{type:n.expanded?"collapse":"expand",size:e,color:m.themedColor.textHighEmphasis}))},Sl=({size:e,disabled:t,onClick:n})=>r.createElement(ke,{"aria-label":"close messenger",onClick:n,disabled:t},r.createElement(A,{type:"close",size:e,color:m.themedColor.textHighEmphasis})),Tl=({size:e,disabled:t,onClick:n})=>r.createElement(ke,{"aria-label":"close conversation",onClick:n,disabled:t},r.createElement(A,{type:"refresh",size:e,color:t?m.themedColor.textDisabled:m.themedColor.textHighEmphasis})),_l=({size:e,onClick:t,disabled:n,tooltipLabel:o})=>r.createElement($n,{label:o,position:"bottom",disabled:n},r.createElement(ke,{"aria-label":"agent",onClick:t,disabled:n},r.createElement(A,{type:"agent",size:e,color:n?m.themedColor.textDisabled:m.themedColor.textHighEmphasis}))),wl=c.div`height:56px;box-sizing:border-box;display:flex;align-items:center;padding:11px 12px;border-bottom:1px solid ${m.themedColor.textDisabled};background-color:${({theme:e})=>e.colors.base.headerBackground};`,kl=c.div`display:flex;flex:1;flex-direction:row;align-items:center;gap:6px;overflow:hidden;`,Al=c.div`display:flex;gap:10px;align-items:center;justify-content:center;`,Il=c(S)`text-overflow:ellipsis;overflow:hidden;white-space:nowrap;padding:2px 0;`,ke=c.button`all:unset;padding:4px;cursor:pointer;display:flex;align-items:center;justify-content:center;&:disabled{cursor:not-allowed;}`,$l=()=>{const{isDashboardActionbookTester:e}=Ct();return e?null:r.createElement(yl,null)},ct=({children:e,onNavigateToConversationList:t,closedChannelUrl:n,onClearClosedChannelUrl:o})=>{const{Template:s}=Ke.useContext();return r.createElement(Po,{onNavigateToConversationList:t,closedChannelUrl:n,onClearClosedChannelUrl:o},r.createElement(at,null,r.createElement(at.Consumer,null,i=>r.createElement(r.Fragment,null,r.createElement(Ol,{...i},r.createElement(s,null)),e))))},Ke=pe({template:Ml,components:{Header:$l,Body:Ka,Footer:vl}});function Ml(){const{components:e}=Ke.useContext();return r.createElement(r.Fragment,null,r.createElement(e.Header,null),r.createElement(e.Body,null),r.createElement(e.Footer,null))}const Ol=c.div`height:100%;width:100%;display:flex;flex-direction:column;flex:1;background-color:${({theme:e})=>e.colors.base.background};`,{Provider:Ll,useContext:Vn}=F("ConversationList");function Rl({onOpenConversationView:e=De,children:t}){return r.createElement(Tr,null,n=>r.createElement(Ll,{value:{...n,onOpenConversationView:e}},t))}const _t=pe({template:Pl,components:{}});function Pl({title:e="",lastMessageTimestamp:t=Date.now(),onClick:n}){const{stringSet:o,format:s}=I();return r.createElement(Nl,{role:"button",onClick:()=>n==null?void 0:n()},r.createElement(Bl,null,r.createElement(Fl,null,r.createElement(S,{variant:"subtitle1",color:m.themedColor.textHighEmphasis},s(t,o.DATE_FORMAT__CONVERSATION_LIST__LIST_ITEM_TITLE)),r.createElement(S,{variant:"caption2",color:m.themedColor.textLowEmphasis},s(t,o.DATE_FORMAT__CONVERSATION_LIST__LIST_ITEM_TITLE_CAPTION))),r.createElement(S,{variant:"body3",color:m.themedColor.textMidEmphasis},e||o.CONVERSATION_LIST__TOPICS_FALLBACK)),r.createElement(A,{type:"chevron-right",size:16,color:m.themedColor.textHighEmphasis}),r.createElement(Dl,null))}const Nl=c.div`display:flex;flex-direction:row;align-items:center;position:relative;width:100%;padding:14px 16px;box-sizing:border-box;gap:4px;cursor:pointer;`,Dl=c.div`position:absolute;bottom:0;height:1px;width:calc(100% - 32px);background-color:${m.themedColor.textDisabled};`,Bl=c.div`gap:4px;display:flex;flex-direction:column;flex:1;`,Fl=c.div`display:flex;justify-content:flex-start;align-items:center;gap:6px;`,zl=({items:e,renderItem:t,onEndReached:n})=>{const o=s=>{const i=s.target;i.scrollHeight-i.scrollTop===i.clientHeight&&(n==null||n())};return r.createElement(Hl,{onScroll:s=>o(s)},e.map((s,i)=>t(s,i)))},Hl=c.div`width:100%;height:100%;display:flex;flex-direction:column;flex:1;overflow:auto;`,Ul=()=>{const{stringSet:e}=I(),{listSource:t,onOpenConversationView:n}=Vn(),{Template:o}=_t.useContext();return t.initialized?t.conversations.length===0?r.createElement(he,{type:"noChannels",label:e.CONVERSATION_LIST__NO_CONVERSATIONS}):r.createElement(zl,{items:t.conversations,renderItem:(s,i)=>{var a;return r.createElement(o,{key:i,channelUrl:s.channelInfo.url,title:(a=s.topics)==null?void 0:a.join(", "),lastMessageTimestamp:s.channelInfo.lastMessageTs,onClick:()=>n(s.channelInfo.url,P.ConversationStatus.CLOSED)})},onEndReached:()=>{t.loadMore()}}):r.createElement(he,{type:"loading"})},Wl=()=>{const{refreshActiveChannel:e}=R(),{onOpenConversationView:t}=Vn(),n=zn();return r.createElement(Vl,{role:"button",onClick:async()=>{const o=await e();t(o,P.ConversationStatus.OPEN)}},r.createElement(jl,{variant:"h1"},n))},Vl=c.div`background-color:${({theme:e})=>e.colors.base.primary};display:flex;align-items:center;justify-content:center;padding:16px;cursor:pointer;`,jl=c(S)`color:${({theme:e})=>e.colors.base.primaryContrastContent};overflow:hidden;text-overflow:ellipsis;white-space:nowrap;`,Gl=()=>{const{stringSet:e}=I();return r.createElement(ql,null,r.createElement(Kl,{variant:"h2",color:m.themedColor.textHighEmphasis},e.CONVERSATION_LIST__HEADER_TITLE),r.createElement(Zl,null))},ql=c.div`display:flex;flex-direction:column;align-items:flex-start;justify-content:center;width:100%;flex-shrink:0;height:56px;position:relative;background-color:${({theme:e})=>e.colors.base.headerBackground};`,Kl=c(S)`padding:0 12px;width:100%;box-sizing:border-box;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;`,Zl=c.div`position:absolute;bottom:0;width:100%;height:1px;background-color:${m.themedColor.textDisabled};`,jn=({children:e,onOpenConversationView:t})=>{const{Template:n}=Ze.useContext();return r.createElement(Rl,{onOpenConversationView:t},r.createElement(Jl,null,r.createElement(n,null)),e)},Ze=pe({template:Yl,components:{Header:Gl,Body:Ul,Footer:Wl}});function Yl(){const{components:e}=Ze.useContext();return r.createElement(r.Fragment,null,r.createElement(e.Header,null),r.createElement(e.Body,null),r.createElement(e.Footer,null))}const Jl=c.div`height:100%;width:100%;display:flex;flex-direction:column;flex:1;background-color:${({theme:e})=>e.colors.base.background};`,Xl=c.css`:where(#${q.ENTRY}) :not(code *){font-family:'Roboto',sans-serif;box-sizing:border-box;}`,Ql=[Xl,lo,co],ec=(e,...t)=>c.createGlobalStyle(e,...Ql,...t),tc=ec``,nc=cr(Ke,ce,Ge,qe,Ze,_t);function Gn({appearance:e,rootElement:t,logger:n,language:o,stringSet:s,children:i,messageTemplate:a,theme:l}){return fo(Xr,t),r.createElement(c.StyleSheetManager,{target:t},r.createElement(go,{rootElement:t,logger:n,appearance:e,theme:l},r.createElement(jr,{internalVariables:a==null?void 0:a.__internalVariables},r.createElement(ao,{stringSet:s,logger:n,language:o},r.createElement(nc,null,i,r.createElement(tc,null))))))}const Qt={key_payment_plan_container:{color_variables:{},created_at:1232,updated_at:4563,key:"key_payment_plan_container",ui_template:{body:{items:[{carouselStyle:{maxChildWidth:265,spacing:10},items:"{@templates}",type:"carouselView",viewStyle:{padding:{top:0,bottom:0,left:50,right:16}}}]},version:2}},key_payment_plan:{color_variables:{},created_at:123,updated_at:456,key:"key_payment_plan",ui_template:{version:1,body:{items:[{viewStyle:{radius:16,backgroundColor:"#FFFFFF",borderWidth:"1",borderColor:"#E0E0E0"},width:{type:"fixed",value:"264"},height:{type:"fixed",value:"275"},type:"box",layout:"column",items:[{viewStyle:{padding:{left:16,right:16,top:16,bottom:16},backgroundImageUrl:"https://storage-66w.pages.dev/carousel-bg.png"},action:{type:"web",data:"{action_url}"},type:"box",layout:"column",items:[{type:"text",text:"{header_plan}",textStyle:{size:14,weight:"bold",color:"#FFFFFF"}},{type:"text",text:"{header_desc}",textStyle:{size:12,color:"#FFFFFF"}}]},{viewStyle:{padding:{left:16,right:16,top:16,bottom:16}},action:{type:"web",data:"{action_url}"},type:"box",layout:"column",items:[{type:"text",text:"{price}",textStyle:{size:20,weight:"bold"}},{viewStyle:{padding:{left:0,right:0,top:16,bottom:16}},type:"box",layout:"column",items:[{viewStyle:{backgroundColor:"#E0E0E0"},width:{type:"flex",value:0},height:{type:"fixed",value:"1"},type:"box",layout:"column"}]},{viewStyle:{margin:{bottom:8,top:0,left:0,right:0}},type:"text",text:"{description}",textStyle:{size:14,weight:"normal",color:"#7F7F7F"}}]}]}]}}},key_content_preview:{color_variables:{},created_at:1232,updated_at:4563,key:"key_content_preview",ui_template:{version:1,body:{items:[{viewStyle:{radius:16,borderWidth:1,borderColor:"#1F000000",backgroundColor:"#FFFFFF"},width:{type:"fixed",value:264},action:{type:"web",data:"{action_url}"},type:"box",layout:"column",items:[{action:{type:"web",data:"{action_url}"},width:{type:"flex",value:0},height:{type:"fixed",value:200},type:"image",imageUrl:"{image}",imageStyle:{contentMode:"aspectFill"}},{action:{type:"web",data:"{action_url}"},viewStyle:{padding:{left:16,right:16,top:16,bottom:16}},type:"box",layout:"column",items:[{viewStyle:{margin:{bottom:4,top:0,left:0,right:0}},height:{type:"fixed",value:16},type:"text",text:"{title}",maxTextLines:1,textStyle:{size:14,weight:"bold",color:"#000000"}},{height:{type:"fixed",value:16},type:"text",text:"{release_date}",maxTextLines:1,textStyle:{size:14,weight:"normal",color:"#80000000"}}]}]}]}}}};function wt({rootElement:e=document.body,logLevel:t=N.LogLevel.WARN,language:n=navigator.language,userSessionInfo:o,children:s,...i}){var a;return ge.level!==t&&(ge.level=t),po("https://fonts.googleapis.com/css2?family=Roboto&display=swap",e),r.createElement("div",{id:q.ENTRY,style:{width:"fit-content",height:"fit-content"}},r.createElement(Ur,{logger:ge,storage:rc},r.createElement(Gn,{logger:ge,rootElement:e,appearance:(a=i.agentPreviewConfigs)==null?void 0:a.appearance,stringSet:i.stringSet,language:n,messageTemplate:i.messageTemplate,theme:i.theme},r.createElement(pr,{appId:i.appId,aiAgentId:i.aiAgentId,language:n,countryCode:i.countryCode,context:i.context,logger:ge,dispatcher:qn,chatParams:{customApiHost:i.customApiHost,customWebSocketHost:i.customWebSocketHost}},r.createElement(Co,{rootElement:e,...i},r.createElement(wo,{userSessionInfo:o},r.createElement(qi,{isDashboardActionbookTester:i._UNSAFE_INTERNAL_isActionbookTester},s,r.createElement("div",{id:q.MODAL_ROOT}))))))))}const ge=new an(N.LogLevel.WARN),qn=new sn(ge),kt="@sba/message-template",en=e=>`${kt}/templates/${e}`,tn=()=>`${kt}/token`,rc=zr({onSetTemplate:(e,t)=>{Qt[e]||G.setItem(en(e),t)},onGetTemplate:e=>{const t=Qt[e];return t?JSON.stringify(t):G.getItem(en(e))},onSetCachedToken(e){G.setItem(tn(),e)},onGetCachedToken(){return G.getItem(tn())},onClear:()=>{G.getKeys(kt).forEach(G.deleteItem)}}),Kn=({children:e,isOpened:t})=>{const{dir:n,rootElement:o}=O(),s=le(o,!0);return d.useEffect(()=>{const i="sb-agent-block-scroll";return t?s.body.classList.add(i):s.body.classList.remove(i),()=>{s.body.classList.remove(i)}},[s,t]),r.createElement(oc,{dir:n,$visible:t},e)},oc=c.div`width:100%;height:100%;position:fixed;top:0;left:0;z-index:${de.WINDOW};visibility:${({$visible:e})=>e?"visible":"hidden"};`;function Zn({className:e,isOpened:t,onClick:n,type:o,imageUrl:s,dir:i,animated:a=!0,backgroundColor:l}){const u=it(l);return r.createElement(ac,{dir:i,id:q.LAUNCHER,className:e,"aria-label":"Sendbird AIAgent Launcher",onClick:n,$animated:a,$backgroundColor:l},r.createElement(lc,{$isOpened:t,$animated:a,$fillColor:u},r.createElement(nn.Open,{url:s,isDefaultIcon:o==="default_icon"})),r.createElement(cc,{$isOpened:t,$animated:a,$fillColor:u},r.createElement(nn.Close,null)))}const sc=c.css`&:hover{transition:transform 250ms cubic-bezier(0.33,0,0,1);transform:scale(1.1);}&:active{transform:scale(0.8);}`,ic=c.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:32px;height:32px;filter:${({$fillColor:e})=>e===pn.WHITE?"grayscale(100%) brightness(2000%)":"grayscale(100%) invert(100%) saturate(0%) brightness(0%) contrast(1000%)"};}}`,Yn=c.css`svg{width:32px;height:32px;${({$fillColor:e})=>c.css`
184
+ `,xl=d.lazy(()=>Promise.resolve().then(()=>require("./Hose4Xqt.cjs")).then(e=>({default:e.MarkdownText}))),El=()=>{const{aiAgentInfo:e}=R(),{messageSource:t}=j(),{userSession:n}=R();return!e.specialNoticeEnabled||!e.specialNotice||!(t.initialized&&!t.messages.some(s=>Rn(s,n.userId)))?null:r.createElement(bl,null,r.createElement(xl,null,e.specialNotice))},vl=()=>r.createElement(yl,null,r.createElement(El,null),r.createElement(el,null,r.createElement(fl,null))),yl=c.div`z-index:0;border:none;width:100%;`,Cl=()=>{var a,i,l;const{activeChannel:e}=R(),{channelSource:t}=j(),n=((i=(a=t.channel)==null?void 0:a.conversation)==null?void 0:i.status)===P.ConversationStatus.CLOSED;return!(((l=t.channel)==null?void 0:l.url)===(e==null?void 0:e.url))&&n?r.createElement(Ja,null):r.createElement(vl,null)},Sl=()=>{var T;const{state:e,logger:t,enableCloseConversationButton:n,enableExpandButton:o,dispatcher:s}=O(),{stringSet:a}=I(),{aiAgentInfo:i,activeChannel:l}=R(),{channelSource:u,onNavigateToConversationList:h}=j(),g=u.channel,f=_e()?24:16,x=()=>{e.setOpened(!1)},E=async()=>{try{const _=await(g==null?void 0:g.markConversationAsHandoff());t.info("conversation.handleAgentHandoff: success",_)}catch(_){t.error("conversation.handleAgentHandoff: error",_)}},y=async()=>{g&&await s.send(cn.CloseConversation())},b=l&&(g==null?void 0:g.url)===l.url,C=i.showHandoffButton&&!!((T=g==null?void 0:g.conversation)!=null&&T.handoff)&&b;return r.createElement(Al,null,r.createElement(Il,null,h&&r.createElement(ke,{onClick:()=>h()},r.createElement(A,{type:"menu",size:24,color:m.themedColor.textHighEmphasis})),b&&r.createElement(Bn,{size:34}),r.createElement(Ml,{variant:"h2",color:m.themedColor.textHighEmphasis},i.nickname||(g==null?void 0:g.name))),r.createElement($l,null,C&&r.createElement(kl,{tooltipLabel:a.HEADER_BUTTON__AGENT_HANDOFF,disabled:!Bo(g),size:f,onClick:E}),n&&r.createElement(wl,{disabled:!Tn(g),size:f,onClick:y}),o&&r.createElement(Tl,{size:f}),r.createElement(_l,{size:f,onClick:x})))},Tl=({size:e,disabled:t})=>{const{state:n}=O();return r.createElement(ke,{"aria-label":"expand",onClick:()=>n.setExpanded(!n.expanded),disabled:t},r.createElement(A,{type:n.expanded?"collapse":"expand",size:e,color:m.themedColor.textHighEmphasis}))},_l=({size:e,disabled:t,onClick:n})=>r.createElement(ke,{"aria-label":"close messenger",onClick:n,disabled:t},r.createElement(A,{type:"close",size:e,color:m.themedColor.textHighEmphasis})),wl=({size:e,disabled:t,onClick:n})=>r.createElement(ke,{"aria-label":"close conversation",onClick:n,disabled:t},r.createElement(A,{type:"refresh",size:e,color:t?m.themedColor.textDisabled:m.themedColor.textHighEmphasis})),kl=({size:e,onClick:t,disabled:n,tooltipLabel:o})=>r.createElement(Mn,{label:o,position:"bottom",disabled:n},r.createElement(ke,{"aria-label":"agent",onClick:t,disabled:n},r.createElement(A,{type:"agent",size:e,color:n?m.themedColor.textDisabled:m.themedColor.textHighEmphasis}))),Al=c.div`height:56px;box-sizing:border-box;display:flex;align-items:center;padding:11px 12px;border-bottom:1px solid ${m.themedColor.textDisabled};background-color:${({theme:e})=>e.colors.base.headerBackground};`,Il=c.div`display:flex;flex:1;flex-direction:row;align-items:center;gap:6px;overflow:hidden;`,$l=c.div`display:flex;gap:10px;align-items:center;justify-content:center;`,Ml=c(S)`text-overflow:ellipsis;overflow:hidden;white-space:nowrap;padding:2px 0;`,ke=c.button`all:unset;padding:4px;cursor:pointer;display:flex;align-items:center;justify-content:center;&:disabled{cursor:not-allowed;}`,Ol=()=>{const{isDashboardActionbookTester:e}=St();return e?null:r.createElement(Sl,null)},dt=({children:e,onNavigateToConversationList:t,closedChannelUrl:n,onClearClosedChannelUrl:o})=>{const{Template:s}=Ke.useContext();return r.createElement(Do,{onNavigateToConversationList:t,closedChannelUrl:n,onClearClosedChannelUrl:o},r.createElement(at,null,r.createElement(at.Consumer,null,a=>r.createElement(r.Fragment,null,r.createElement(Rl,{...a},r.createElement(s,null)),e))))},Ke=pe({template:Ll,components:{Header:Ol,Body:Ya,Footer:Cl}});function Ll(){const{components:e}=Ke.useContext();return r.createElement(r.Fragment,null,r.createElement(e.Header,null),r.createElement(e.Body,null),r.createElement(e.Footer,null))}const Rl=c.div`height:100%;width:100%;display:flex;flex-direction:column;flex:1;background-color:${({theme:e})=>e.colors.base.background};`,{Provider:Pl,useContext:jn}=F("ConversationList");function Nl({onOpenConversationView:e=De,children:t}){return r.createElement(_r,null,n=>r.createElement(Pl,{value:{...n,onOpenConversationView:e}},t))}const wt=pe({template:Dl,components:{}});function Dl({title:e="",lastMessageTimestamp:t=Date.now(),onClick:n}){const{stringSet:o,format:s}=I();return r.createElement(Bl,{role:"button",onClick:()=>n==null?void 0:n()},r.createElement(zl,null,r.createElement(Hl,null,r.createElement(S,{variant:"subtitle1",color:m.themedColor.textHighEmphasis},s(t,o.DATE_FORMAT__CONVERSATION_LIST__LIST_ITEM_TITLE)),r.createElement(S,{variant:"caption2",color:m.themedColor.textLowEmphasis},s(t,o.DATE_FORMAT__CONVERSATION_LIST__LIST_ITEM_TITLE_CAPTION))),r.createElement(S,{variant:"body3",color:m.themedColor.textMidEmphasis},e||o.CONVERSATION_LIST__TOPICS_FALLBACK)),r.createElement(A,{type:"chevron-right",size:16,color:m.themedColor.textHighEmphasis}),r.createElement(Fl,null))}const Bl=c.div`display:flex;flex-direction:row;align-items:center;position:relative;width:100%;padding:14px 16px;box-sizing:border-box;gap:4px;cursor:pointer;`,Fl=c.div`position:absolute;bottom:0;height:1px;width:calc(100% - 32px);background-color:${m.themedColor.textDisabled};`,zl=c.div`gap:4px;display:flex;flex-direction:column;flex:1;`,Hl=c.div`display:flex;justify-content:flex-start;align-items:center;gap:6px;`,Ul=({items:e,renderItem:t,onEndReached:n})=>{const o=s=>{const a=s.target;a.scrollHeight-a.scrollTop===a.clientHeight&&(n==null||n())};return r.createElement(Wl,{onScroll:s=>o(s)},e.map((s,a)=>t(s,a)))},Wl=c.div`width:100%;height:100%;display:flex;flex-direction:column;flex:1;overflow:auto;`,Vl=()=>{const{stringSet:e}=I(),{listSource:t,onOpenConversationView:n}=jn(),{Template:o}=wt.useContext();return t.initialized?t.conversations.length===0?r.createElement(he,{type:"noChannels",label:e.CONVERSATION_LIST__NO_CONVERSATIONS}):r.createElement(Ul,{items:t.conversations,renderItem:(s,a)=>{var i;return r.createElement(o,{key:a,channelUrl:s.channelInfo.url,title:(i=s.topics)==null?void 0:i.join(", "),lastMessageTimestamp:s.channelInfo.lastMessageTs,onClick:()=>n(s.channelInfo.url,P.ConversationStatus.CLOSED)})},onEndReached:()=>{t.loadMore()}}):r.createElement(he,{type:"loading"})},jl=()=>{const{refreshActiveChannel:e}=R(),{onOpenConversationView:t}=jn(),n=Hn();return r.createElement(Gl,{role:"button",onClick:async()=>{const o=await e();t(o,P.ConversationStatus.OPEN)}},r.createElement(ql,{variant:"h1"},n))},Gl=c.div`background-color:${({theme:e})=>e.colors.base.primary};display:flex;align-items:center;justify-content:center;padding:16px;cursor:pointer;`,ql=c(S)`color:${({theme:e})=>e.colors.base.primaryContrastContent};overflow:hidden;text-overflow:ellipsis;white-space:nowrap;`,Kl=()=>{const{stringSet:e}=I();return r.createElement(Zl,null,r.createElement(Yl,{variant:"h2",color:m.themedColor.textHighEmphasis},e.CONVERSATION_LIST__HEADER_TITLE),r.createElement(Jl,null))},Zl=c.div`display:flex;flex-direction:column;align-items:flex-start;justify-content:center;width:100%;flex-shrink:0;height:56px;position:relative;background-color:${({theme:e})=>e.colors.base.headerBackground};`,Yl=c(S)`padding:0 12px;width:100%;box-sizing:border-box;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;`,Jl=c.div`position:absolute;bottom:0;width:100%;height:1px;background-color:${m.themedColor.textDisabled};`,Gn=({children:e,onOpenConversationView:t})=>{const{Template:n}=Ze.useContext();return r.createElement(Nl,{onOpenConversationView:t},r.createElement(Ql,null,r.createElement(n,null)),e)},Ze=pe({template:Xl,components:{Header:Kl,Body:Vl,Footer:jl}});function Xl(){const{components:e}=Ze.useContext();return r.createElement(r.Fragment,null,r.createElement(e.Header,null),r.createElement(e.Body,null),r.createElement(e.Footer,null))}const Ql=c.div`height:100%;width:100%;display:flex;flex-direction:column;flex:1;background-color:${({theme:e})=>e.colors.base.background};`,ec=c.css`:where(#${q.ENTRY}) :not(code *){font-family:'Roboto',sans-serif;box-sizing:border-box;}`,tc=[ec,uo,mo],nc=(e,...t)=>c.createGlobalStyle(e,...tc,...t),rc=nc``,oc=dr(Ke,ce,Ge,qe,Ze,wt);function qn({appearance:e,rootElement:t,logger:n,language:o,stringSet:s,children:a,messageTemplate:i,theme:l}){return xo(eo,t),r.createElement(c.StyleSheetManager,{target:t},r.createElement(po,{rootElement:t,logger:n,appearance:e,theme:l},r.createElement(qr,{internalVariables:i==null?void 0:i.__internalVariables},r.createElement(co,{stringSet:s,logger:n,language:o},r.createElement(oc,null,a,r.createElement(rc,null))))))}const en={key_payment_plan_container:{color_variables:{},created_at:1232,updated_at:4563,key:"key_payment_plan_container",ui_template:{body:{items:[{carouselStyle:{maxChildWidth:265,spacing:10},items:"{@templates}",type:"carouselView",viewStyle:{padding:{top:0,bottom:0,left:50,right:16}}}]},version:2}},key_payment_plan:{color_variables:{},created_at:123,updated_at:456,key:"key_payment_plan",ui_template:{version:1,body:{items:[{viewStyle:{radius:16,backgroundColor:"#FFFFFF",borderWidth:"1",borderColor:"#E0E0E0"},width:{type:"fixed",value:"264"},height:{type:"fixed",value:"275"},type:"box",layout:"column",items:[{viewStyle:{padding:{left:16,right:16,top:16,bottom:16},backgroundImageUrl:"https://storage-66w.pages.dev/carousel-bg.png"},action:{type:"web",data:"{action_url}"},type:"box",layout:"column",items:[{type:"text",text:"{header_plan}",textStyle:{size:14,weight:"bold",color:"#FFFFFF"}},{type:"text",text:"{header_desc}",textStyle:{size:12,color:"#FFFFFF"}}]},{viewStyle:{padding:{left:16,right:16,top:16,bottom:16}},action:{type:"web",data:"{action_url}"},type:"box",layout:"column",items:[{type:"text",text:"{price}",textStyle:{size:20,weight:"bold"}},{viewStyle:{padding:{left:0,right:0,top:16,bottom:16}},type:"box",layout:"column",items:[{viewStyle:{backgroundColor:"#E0E0E0"},width:{type:"flex",value:0},height:{type:"fixed",value:"1"},type:"box",layout:"column"}]},{viewStyle:{margin:{bottom:8,top:0,left:0,right:0}},type:"text",text:"{description}",textStyle:{size:14,weight:"normal",color:"#7F7F7F"}}]}]}]}}},key_content_preview:{color_variables:{},created_at:1232,updated_at:4563,key:"key_content_preview",ui_template:{version:1,body:{items:[{viewStyle:{radius:16,borderWidth:1,borderColor:"#1F000000",backgroundColor:"#FFFFFF"},width:{type:"fixed",value:264},action:{type:"web",data:"{action_url}"},type:"box",layout:"column",items:[{action:{type:"web",data:"{action_url}"},width:{type:"flex",value:0},height:{type:"fixed",value:200},type:"image",imageUrl:"{image}",imageStyle:{contentMode:"aspectFill"}},{action:{type:"web",data:"{action_url}"},viewStyle:{padding:{left:16,right:16,top:16,bottom:16}},type:"box",layout:"column",items:[{viewStyle:{margin:{bottom:4,top:0,left:0,right:0}},height:{type:"fixed",value:16},type:"text",text:"{title}",maxTextLines:1,textStyle:{size:14,weight:"bold",color:"#000000"}},{height:{type:"fixed",value:16},type:"text",text:"{release_date}",maxTextLines:1,textStyle:{size:14,weight:"normal",color:"#80000000"}}]}]}]}}}};function kt({rootElement:e=document.body,logLevel:t=N.LogLevel.WARN,language:n=navigator.language,userSessionInfo:o,children:s,...a}){var i;return ge.level!==t&&(ge.level=t),bo("https://fonts.googleapis.com/css2?family=Roboto&display=swap",e),r.createElement("div",{id:q.ENTRY,style:{width:"fit-content",height:"fit-content"}},r.createElement(Vr,{logger:ge,storage:sc},r.createElement(qn,{logger:ge,rootElement:e,appearance:(i=a.agentPreviewConfigs)==null?void 0:i.appearance,stringSet:a.stringSet,language:n,messageTemplate:a.messageTemplate,theme:a.theme},r.createElement(fr,{appId:a.appId,aiAgentId:a.aiAgentId,language:n,countryCode:a.countryCode,context:a.context,logger:ge,dispatcher:Kn,chatParams:{customApiHost:a.customApiHost,customWebSocketHost:a.customWebSocketHost}},r.createElement(To,{rootElement:e,...a},r.createElement(Ao,{userSessionInfo:o},r.createElement(Zi,{isDashboardActionbookTester:a._UNSAFE_INTERNAL_isActionbookTester},s,r.createElement("div",{id:q.MODAL_ROOT}))))))))}const ge=new ln(N.LogLevel.WARN),Kn=new an(ge),At="@sba/message-template",tn=e=>`${At}/templates/${e}`,nn=()=>`${At}/token`,sc=Ur({onSetTemplate:(e,t)=>{en[e]||G.setItem(tn(e),t)},onGetTemplate:e=>{const t=en[e];return t?JSON.stringify(t):G.getItem(tn(e))},onSetCachedToken(e){G.setItem(nn(),e)},onGetCachedToken(){return G.getItem(nn())},onClear:()=>{G.getKeys(At).forEach(G.deleteItem)}}),Zn=({children:e,isOpened:t})=>{const{dir:n,rootElement:o}=O(),s=le(o,!0);return d.useEffect(()=>{const a="sb-agent-block-scroll";return t?s.body.classList.add(a):s.body.classList.remove(a),()=>{s.body.classList.remove(a)}},[s,t]),r.createElement(ic,{dir:n,$visible:t},e)},ic=c.div`width:100%;height:100%;position:fixed;top:0;left:0;z-index:${de.WINDOW};visibility:${({$visible:e})=>e?"visible":"hidden"};`;function Yn({className:e,isOpened:t,onClick:n,type:o,imageUrl:s,dir:a,animated:i=!0,backgroundColor:l}){const u=it(l);return r.createElement(cc,{dir:a,id:q.LAUNCHER,className:e,"aria-label":"Sendbird AIAgent Launcher",onClick:n,$animated:i,$backgroundColor:l},r.createElement(dc,{$isOpened:t,$animated:i,$fillColor:u},r.createElement(rn.Open,{url:s,isDefaultIcon:o==="default_icon"})),r.createElement(uc,{$isOpened:t,$animated:i,$fillColor:u},r.createElement(rn.Close,null)))}const ac=c.css`&:hover{transition:transform 250ms cubic-bezier(0.33,0,0,1);transform:scale(1.1);}&:active{transform:scale(0.8);}`,lc=c.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:32px;height:32px;filter:${({$fillColor:e})=>e===fn.WHITE?"grayscale(100%) brightness(2000%)":"grayscale(100%) invert(100%) saturate(0%) brightness(0%) contrast(1000%)"};}}`,Jn=c.css`svg{width:32px;height:32px;${({$fillColor:e})=>c.css`
184
185
  path {
185
186
  fill: ${e};
186
187
  }
@@ -189,7 +190,7 @@
189
190
  }
190
191
  `}
191
192
  }
192
- `,ac=c.button`position:relative;padding:0;width:48px;height:48px;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&&sc}`,Jn=c.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;`,lc=c(Jn)`opacity:${({$isOpened:e})=>e?0:1};transform:${({$animated:e,$isOpened:t})=>e&&(t?"rotate(-90deg) scale(0)":"rotate(0deg)")};${ic}${Yn}`,cc=c(Jn)`scale:${({$isOpened:e})=>e?1:0};transform:${({$animated:e,$isOpened:t})=>e&&(t?"rotate(0deg)":"rotate(-90deg)")};${Yn}`,nn={Open:e=>e.url?r.createElement("img",{src:e.url,alt:"launcher-img","data-default-icon":e.isDefaultIcon}):r.createElement(xt,null),Close:()=>r.createElement(A,{size:32,type:"chevron-down"})};function Xn({className:e}){const{colors:t}=c.useTheme(),{dir:n,state:o}=O(),{launcherInfo:s}=R();return uc(),r.createElement(Zn,{dir:n,className:e,isOpened:o.opened,onClick:()=>o.setOpened(!o.opened),type:s.type,imageUrl:s.imageUrl,backgroundColor:t.base.primary})}const dc=1e3*60;function uc(){const{chatSDK:e,state:t,logger:n,enableAutoDisconnectInLauncher:o}=O(),s=d.useRef(null);d.useEffect(()=>{if(!o)return;function i(){s.current&&(clearTimeout(s.current),s.current=null)}function a(){e.connectionState===N.ConnectionState.CLOSED&&(e.reconnect(),n.debug("useSDKInactivityTimeout: reconnected")),i(),n.debug("useSDKInactivityTimeout: clear disconnect schedule")}function l(){i(),s.current=setTimeout(async()=>{await e.disconnectWebSocket(),n.debug("useSDKInactivityTimeout: disconnected")},dc)}t.opened?a():(l(),n.debug("useSDKInactivityTimeout: schedule disconnect"))},[o,e,t.opened])}const Qn=d.createContext(null);function mc(){const e=d.useContext(Qn);if(!e)throw new Error("useNavigator() must be used within <Navigator />");return e}function er({children:e}){const t=mc();return typeof e=="function"?e(t):r.createElement(r.Fragment,null,e)}const gc=c.keyframes`0%{transform:translateY(40px);opacity:0;}100%{transform:translateY(0px);opacity:1;}`,hc=c.keyframes`0%{transform:translateY(0px);opacity:1;}100%{transform:translateY(40px);opacity:0;}`,pc=c.css`animation-name:${gc};animation-duration:0.3s;animation-fill-mode:forwards;`,fc=c.css``,bc=c.css`animation-name:${hc};animation-duration:0.3s;animation-fill-mode:forwards;`,xc=c.css`visibility:hidden;`,Ec=c.div`position:absolute;top:0;left:0;width:100%;height:100%;${({$transitionState:e})=>{switch(e){case"entering":return pc;case"entered":return fc;case"exiting":return bc;case"exited":return xc;default:return""}}}${({$active:e})=>e?c.css`
193
+ `,cc=c.button`position:relative;padding:0;width:48px;height:48px;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&&ac}`,Xn=c.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;`,dc=c(Xn)`opacity:${({$isOpened:e})=>e?0:1};transform:${({$animated:e,$isOpened:t})=>e&&(t?"rotate(-90deg) scale(0)":"rotate(0deg)")};${lc}${Jn}`,uc=c(Xn)`scale:${({$isOpened:e})=>e?1:0};transform:${({$animated:e,$isOpened:t})=>e&&(t?"rotate(0deg)":"rotate(-90deg)")};${Jn}`,rn={Open:e=>e.url?r.createElement("img",{src:e.url,alt:"launcher-img","data-default-icon":e.isDefaultIcon}):r.createElement(Et,null),Close:()=>r.createElement(A,{size:32,type:"chevron-down"})};function Qn({className:e}){const{colors:t}=c.useTheme(),{dir:n,state:o}=O(),{launcherInfo:s}=R();return gc(),r.createElement(Yn,{dir:n,className:e,isOpened:o.opened,onClick:()=>o.setOpened(!o.opened),type:s.type,imageUrl:s.imageUrl,backgroundColor:t.base.primary})}const mc=1e3*60;function gc(){const{chatSDK:e,state:t,logger:n,enableAutoDisconnectInLauncher:o}=O(),s=d.useRef(null);d.useEffect(()=>{if(!o)return;function a(){s.current&&(clearTimeout(s.current),s.current=null)}function i(){e.connectionState===N.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")},mc)}t.opened?i():(l(),n.debug("useSDKInactivityTimeout: schedule disconnect"))},[o,e,t.opened])}const er=d.createContext(null);function hc(){const e=d.useContext(er);if(!e)throw new Error("useNavigator() must be used within <Navigator />");return e}function tr({children:e}){const t=hc();return typeof e=="function"?e(t):r.createElement(r.Fragment,null,e)}const pc=c.keyframes`0%{transform:translateY(40px);opacity:0;}100%{transform:translateY(0px);opacity:1;}`,fc=c.keyframes`0%{transform:translateY(0px);opacity:1;}100%{transform:translateY(40px);opacity:0;}`,bc=c.css`animation-name:${pc};animation-duration:0.3s;animation-fill-mode:forwards;`,xc=c.css``,Ec=c.css`animation-name:${fc};animation-duration:0.3s;animation-fill-mode:forwards;`,vc=c.css`visibility:hidden;`,yc=c.div`position:absolute;top:0;left:0;width:100%;height:100%;${({$transitionState:e})=>{switch(e){case"entering":return bc;case"entered":return xc;case"exiting":return Ec;case"exited":return vc;default:return""}}}${({$active:e})=>e?c.css`
193
194
  z-index: 999;
194
195
  `:c.css`z-index:1;pointer-events:none;`}
195
- `;function ye({initialId:e,children:t}){const n=d.useCallback((b,C)=>{u(T=>[...T,b]),g(T=>({...T,[b]:!0})),C!=null&&C.reset&&E(T=>({...T,[b]:(T[b]||0)+1})),f(T=>({...T,[b]:"entering"})),setTimeout(()=>{f(T=>({...T,[b]:"entered"}))},300)},[]),o=d.useCallback(()=>{u(b=>{if(b.length<=1)return b;const C=b[b.length-1];return f(T=>({...T,[C]:"exiting"})),setTimeout(()=>{f(T=>({...T,[C]:"exited"})),u(T=>T.slice(0,-1))},300),b})},[]),s=d.useMemo(()=>({navigation:{navigate:n,pop:o}}),[n,o]),i=d.useMemo(()=>d.Children.toArray(t).filter(b=>b.type===er),[t]),a=d.useMemo(()=>{const b={};return i.forEach(C=>{const{id:T,lazy:_,children:$}=C.props;b[T]={lazy:_,element:typeof $=="function"?$(s):$}}),b},[i]),[l,u]=d.useState([e]),[h,g]=d.useState(()=>{const b={};return Object.entries(a).forEach(([C,{lazy:T}])=>{T===!1&&(b[C]=!0)}),b[e]=!0,b}),[p,f]=d.useState(()=>{const b={};return Object.keys(a).forEach(C=>{C===e?b[C]="entered":b[C]="exited"}),b}),[x,E]=d.useState({}),y=l[l.length-1];return r.createElement(Qn.Provider,{value:s},r.createElement(vc,null,Object.keys(a).map(b=>{var $;if(!h[b])return null;const C=p[b]||"exited",T=b===y,_=`${b}-${x[b]||0}`;return r.createElement(Ec,{key:_,$transitionState:C,$active:T},($=a[b])==null?void 0:$.element)})))}const vc=c.div`position:relative;width:100%;height:100%;`;ye.Screen=er;const ae={activeConv:"active-conv",closedConv:"closed-conv",convList:"conv-list"},tr=({setClosedChannelUrl:e,closedChannelUrl:t})=>r.createElement(ye,{initialId:ae.activeConv},r.createElement(ye.Screen,{id:ae.activeConv},({navigation:n})=>r.createElement(ct,{onNavigateToConversationList:()=>n.navigate(ae.convList,{reset:!0})})),r.createElement(ye.Screen,{id:ae.closedConv},({navigation:n})=>r.createElement(ct,{onNavigateToConversationList:()=>n.pop(),closedChannelUrl:t,onClearClosedChannelUrl:()=>e(void 0)})),r.createElement(ye.Screen,{id:ae.convList,lazy:!0},({navigation:n})=>r.createElement(jn,{onOpenConversationView:(o,s)=>{s==="closed"?(e(o),n.navigate(ae.closedConv,{reset:!0})):n.navigate(ae.activeConv)}})));function yc({isExpanded:e,isOpened:t,children:n,launcher:o}){const{dir:s}=O();return r.createElement(Cc,null,r.createElement(Sc,{dir:s,id:q.WINDOW,$isExpanded:e,$isOpened:t},n),o)}const Cc=c.div`display:flex;flex-direction:column;gap:8px;align-items:flex-end;`,Sc=c.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&&_c};${({$isExpanded:e})=>e&&Tc};`,Tc=c.css`width:743px;height:723px;`,_c=c.css`z-index:${de.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;`,wc=({children:e,...t})=>{const n=_e(),[o,s]=d.useState(),i=n?Kn:yc;return r.createElement(wt,{enableExpandButton:!n,...t},r.createElement(En,null,({state:a})=>r.createElement(r.Fragment,null,r.createElement(i,{isExpanded:a.expanded,isOpened:a.opened,launcher:r.createElement(Xn,null)},r.createElement(tr,{closedChannelUrl:o,setClosedChannelUrl:s})),e)))};function kc(e){return r.createElement(Ac,{...e})}const Ac=c(Xn)`position:fixed;z-index:${de.LAUNCHER};bottom:24px;inset-inline-end:24px;`;function Ic({isExpanded:e,isOpened:t,children:n}){const{dir:o}=O();return r.createElement($c,{dir:o,id:q.WINDOW,$isExpanded:e,$isOpened:t},n)}const $c=c.div`background:${({theme:e})=>e.colors.base.background};display:flex;overscroll-behavior:none;-webkit-overflow-scrolling:auto;position:fixed;bottom:84px;inset-inline-end:20px;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&&Oc};${({$isExpanded:e})=>e&&Mc};`,Mc=c.css`width:743px;height:723px;`,Oc=c.css`z-index:${de.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;`,Lc=({children:e,...t})=>{const n=_e(),[o,s]=d.useState(),i=n?Kn:Ic;return r.createElement(wt,{enableExpandButton:!n,...t},r.createElement(En,null,({state:a})=>r.createElement(r.Fragment,null,r.createElement(i,{isExpanded:a.expanded,isOpened:a.opened},r.createElement(tr,{closedChannelUrl:o,setClosedChannelUrl:s})),r.createElement(kc,null),e)))};exports.ANCHOR_REL=Ve;exports.AgentProviderContainer=wt;exports.AgentUIProviderContainer=Gn;exports.CSATType=Q;exports.Commands=ln;exports.Conversation=ct;exports.ConversationLayout=Ke;exports.ConversationList=jn;exports.ConversationListItemLayout=_t;exports.ConversationListLayout=Ze;exports.DefaultMessenger=wc;exports.FixedMessenger=Lc;exports.Icon=A;exports.IncomingMessageLayout=ce;exports.Label=S;exports.LauncherBase=Zn;exports.Loader=yt;exports.LogLevel=dt;exports.MessageLogs=Mn;exports.OutgoingMessageLayout=Ge;exports.PlaceholderBase=Vo;exports.SystemMessageLayout=qe;exports.cssVars=m;exports.messengerDispatcher=qn;exports.useLocalizationContext=I;exports.useMessengerContext=O;exports.useMessengerSessionContext=R;
196
+ `;function ye({initialId:e,children:t}){const n=d.useCallback((b,C)=>{u(T=>[...T,b]),g(T=>({...T,[b]:!0})),C!=null&&C.reset&&E(T=>({...T,[b]:(T[b]||0)+1})),f(T=>({...T,[b]:"entering"})),setTimeout(()=>{f(T=>({...T,[b]:"entered"}))},300)},[]),o=d.useCallback(()=>{u(b=>{if(b.length<=1)return b;const C=b[b.length-1];return f(T=>({...T,[C]:"exiting"})),setTimeout(()=>{f(T=>({...T,[C]:"exited"})),u(T=>T.slice(0,-1))},300),b})},[]),s=d.useMemo(()=>({navigation:{navigate:n,pop:o}}),[n,o]),a=d.useMemo(()=>d.Children.toArray(t).filter(b=>b.type===tr),[t]),i=d.useMemo(()=>{const b={};return a.forEach(C=>{const{id:T,lazy:_,children:$}=C.props;b[T]={lazy:_,element:typeof $=="function"?$(s):$}}),b},[a]),[l,u]=d.useState([e]),[h,g]=d.useState(()=>{const b={};return Object.entries(i).forEach(([C,{lazy:T}])=>{T===!1&&(b[C]=!0)}),b[e]=!0,b}),[p,f]=d.useState(()=>{const b={};return Object.keys(i).forEach(C=>{C===e?b[C]="entered":b[C]="exited"}),b}),[x,E]=d.useState({}),y=l[l.length-1];return r.createElement(er.Provider,{value:s},r.createElement(Cc,null,Object.keys(i).map(b=>{var $;if(!h[b])return null;const C=p[b]||"exited",T=b===y,_=`${b}-${x[b]||0}`;return r.createElement(yc,{key:_,$transitionState:C,$active:T},($=i[b])==null?void 0:$.element)})))}const Cc=c.div`position:relative;width:100%;height:100%;`;ye.Screen=tr;const ae={activeConv:"active-conv",closedConv:"closed-conv",convList:"conv-list"},nr=({setClosedChannelUrl:e,closedChannelUrl:t})=>r.createElement(ye,{initialId:ae.activeConv},r.createElement(ye.Screen,{id:ae.activeConv},({navigation:n})=>r.createElement(dt,{onNavigateToConversationList:()=>n.navigate(ae.convList,{reset:!0})})),r.createElement(ye.Screen,{id:ae.closedConv},({navigation:n})=>r.createElement(dt,{onNavigateToConversationList:()=>n.pop(),closedChannelUrl:t,onClearClosedChannelUrl:()=>e(void 0)})),r.createElement(ye.Screen,{id:ae.convList,lazy:!0},({navigation:n})=>r.createElement(Gn,{onOpenConversationView:(o,s)=>{s==="closed"?(e(o),n.navigate(ae.closedConv,{reset:!0})):n.navigate(ae.activeConv)}})));function Sc({isExpanded:e,isOpened:t,children:n,launcher:o}){const{dir:s}=O();return r.createElement(Tc,null,r.createElement(_c,{dir:s,id:q.WINDOW,$isExpanded:e,$isOpened:t},n),o)}const Tc=c.div`display:flex;flex-direction:column;gap:8px;align-items:flex-end;`,_c=c.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&&kc};${({$isExpanded:e})=>e&&wc};`,wc=c.css`width:743px;height:723px;`,kc=c.css`z-index:${de.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;`,Ac=({children:e,...t})=>{const n=_e(),[o,s]=d.useState(),a=n?Zn:Sc;return r.createElement(kt,{enableExpandButton:!n,...t},r.createElement(vn,null,({state:i})=>r.createElement(r.Fragment,null,r.createElement(a,{isExpanded:i.expanded,isOpened:i.opened,launcher:r.createElement(Qn,null)},r.createElement(nr,{closedChannelUrl:o,setClosedChannelUrl:s})),e)))};function Ic(e){return r.createElement($c,{...e})}const $c=c(Qn)`position:fixed;z-index:${de.LAUNCHER};bottom:24px;inset-inline-end:24px;`;function Mc({isExpanded:e,isOpened:t,children:n}){const{dir:o}=O();return r.createElement(Oc,{dir:o,id:q.WINDOW,$isExpanded:e,$isOpened:t},n)}const Oc=c.div`background:${({theme:e})=>e.colors.base.background};display:flex;overscroll-behavior:none;-webkit-overflow-scrolling:auto;position:fixed;bottom:84px;inset-inline-end:20px;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&&Rc};${({$isExpanded:e})=>e&&Lc};`,Lc=c.css`width:743px;height:723px;`,Rc=c.css`z-index:${de.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;`,Pc=({children:e,...t})=>{const n=_e(),[o,s]=d.useState(),a=n?Zn:Mc;return r.createElement(kt,{enableExpandButton:!n,...t},r.createElement(vn,null,({state:i})=>r.createElement(r.Fragment,null,r.createElement(a,{isExpanded:i.expanded,isOpened:i.opened},r.createElement(nr,{closedChannelUrl:o,setClosedChannelUrl:s})),r.createElement(Ic,null),e)))};exports.ANCHOR_REL=Ve;exports.AgentProviderContainer=kt;exports.AgentUIProviderContainer=qn;exports.CSATType=Q;exports.Commands=cn;exports.Conversation=dt;exports.ConversationLayout=Ke;exports.ConversationList=Gn;exports.ConversationListItemLayout=wt;exports.ConversationListLayout=Ze;exports.DefaultMessenger=Ac;exports.FixedMessenger=Pc;exports.Icon=A;exports.IncomingMessageLayout=ce;exports.Label=S;exports.LauncherBase=Yn;exports.Loader=Ct;exports.LogLevel=ut;exports.MessageLogs=On;exports.OutgoingMessageLayout=Ge;exports.PlaceholderBase=Go;exports.SystemMessageLayout=qe;exports.cssVars=m;exports.messengerDispatcher=Kn;exports.useLocalizationContext=I;exports.useMessengerContext=O;exports.useMessengerSessionContext=R;