PageSourceSearch

https://app.slaydigital.ai/static/react/1815.59845f0e5fddd0b072c6.js

js slaydigital.ai collected 2026-10-05 14:39:00 UTC 396,880 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkStammer_ai=self.webpackChunkStammer_ai||[]).push([[1815],{18097:function(e,n,t){t.d(n,{AS:function(){return h},WT:function(){return p},pU:function(){return x},FW:function(){return S},Xo:function(){return u}});var r=t(19124),i=t(6765),o=t(21762),a=t(86591),l="summary-settings",s="analytics-overview",c=function(e,n,t,r){return new(t||(t=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function l(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){var n;e.done?i(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(a,l)}s((r=r.apply(e,n||[])).next())}))},d=function(e,n){var t,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=l(0),a.throw=l(1),a.return=l(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function l(l){return function(s){return function(l){if(t)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(o=0)),o;)try{if(t=1,r&&(i=2&l[0]?r.return:l[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,l[1])).done)return i;switch(r=0,i&&(l=[2&l[0],i.value]),l[0]){case 0:case 1:i=l;break;case 4:return o.label++,{value:l[1],done:!1};case 5:o.label++,r=l[1],l=[0];continue;case 7:l=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==l[0]&&2!==l[0])){o=0;continue}if(3===l[0]&&(!i||l[1]>i[0]&&l[1]<i[3])){o.label=l[1];break}if(6===l[0]&&o.label<i[1]){o.label=i[1],i=l;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(l);break}i[2]&&o.ops.pop(),o.trys.pop();continue}l=n.call(e,o)}catch(e){l=[6,e],r=0}finally{t=i=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,s])}}},u=function(e){return(0,a.I)({queryKey:[l],queryFn:function(){return function(e){return c(void 0,void 0,Promise,(function(){var n;return d(this,(function(t){switch(t.label){case 0:return[4,i.nv.get(o.n.CHATBOT.SUMMARY_SETTINGS(e))];case 1:return n=t.sent(),[2,(0,r.Cb)(n.data)]}}))}))}(e)},refetchOnWindowFocus:!0,refetchOnMount:!0,staleTime:0})},h=function(e,n,t,a){return c(void 0,void 0,Promise,(function(){var l;return d(this,(function(s){switch(s.label){case 0:return[4,i.nv.get(o.n.CHATBOT.ANALYTICS_OVERVIEW(e),{params:(0,r.uc)({statFilter:n,overviewFilter:t,download:!!a})})];case 1:return l=s.sent(),[2,(0,r.Cb)(l.data)]}}))}))},S=function(e,n,t){return(0,a.I)({queryKey:[s,e,n,t],queryFn:function(){return h(e,n,t)},refetchOnWindowFocus:!0,refetchOnMount:!0,staleTime:0})},p=function(e,n){return c(void 0,void 0,Promise,(function(){var t;return d(this,(function(a){switch(a.label){case 0:return[4,i.nv.put(o.n.CHATBOT.UPDATE_SUMMARY_PROMPT(e),(0,r.uc)({baseSystemMessage:n}))];case 1:return t=a.sent(),[2,(0,r.Cb)(t.data)]}}))}))},x=function(e,n){return c(void 0,void 0,Promise,(function(){var t;return d(this,(function(a){switch(a.label){case 0:return[4,i.nv.patch(o.n.CHATBOT.SUMMARY_SETTINGS(e),(0,r.uc)(n))];case 1:return t=a.sent(),[2,(0,r.Cb)(t.data)]}}))}))}},38044:function(e,n,t){t.d(n,{Ar:function(){return _},HY:function(){return A},NR:function(){return S},_l:function(){return m},cB:function(){return f},dR:function(){return h},hg:function(){return I},mi:function(){return x},vk:function(){return p}});var r=t(19124),i=t(6765),o=t(21762),a=t(86591),l=t(79847),s=t(30227),c=function(e,n,t,r){return new(t||(t=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function l(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){var n;e.done?i(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(a,l)}s((r=r.apply(e,n||[])).next())}))},d=function(e,n){var t,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=l(0),a.throw=l(1),a.return=l(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function l(l){return function(s){return function(l){if(t)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(o=0)),o;)try{if(t=1,r&&(i=2&l[0]?r.return:l[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,l[1])).done)return i;switch(r=0,i&&(l=[2&l[0],i.value]),l[0]){case 0:case 1:i=l;break;case 4:return o.label++,{value:l[1],done:!1};case 5:o.label++,r=l[1],l=[0];continue;case 7:l=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==l[0]&&2!==l[0])){o=0;continue}if(3===l[0]&&(!i||l[1]>i[0]&&l[1]<i[3])){o.label=l[1];break}if(6===l[0]&&o.label<i[1]){o.label=i[1],i=l;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(l);break}i[2]&&o.ops.pop(),o.trys.pop();continue}l=n.call(e,o)}catch(e){l=[6,e],r=0}finally{t=i=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,s])}}},u=function(e,n,t){return"chatwidget_details:".concat(e,":").concat(n,":").concat(t)},h=function(e){return c(void 0,void 0,Promise,(function(){return d(this,(function(n){switch(n.label){case 0:return[4,i.Ay.post(o.n.
1CHATBOT.CONVERSATION_DELETE,void 0,{params:{user_key:e}})];case 1:return n.sent(),[2]}}))}))},S=function(e){if("undefined"==typeof navigator||!navigator.sendBeacon)return!1;var n="".concat(o.n.CHATBOT.CONVERSATION_DELETE,"?user_key=").concat(encodeURIComponent(e));return navigator.sendBeacon(n)},p=function(e,n,t){return void 0===n&&(n=!0),(0,a.I)({queryKey:["WIDGET_CONFIGURATIONS",e,t],queryFn:function(){return function(e,n){return c(void 0,void 0,Promise,(function(){var t;return d(this,(function(a){switch(a.label){case 0:return[4,i.Ay.get(o.n.CHATBOT.WIDGET_CONFIGURATIONS(e),n?{params:{parent_url:n}}:void 0)];case 1:return t=a.sent(),[2,(0,r.Cb)(t.data)]}}))}))}(e,t)},refetchOnWindowFocus:!0,refetchOnMount:!0,staleTime:0,retry:!1,enabled:n})},x=function(e,n){return void 0===n&&(n=!0),(0,a.I)({queryKey:["WIDGET_APPEARANCE_CONFIG",e],queryFn:function(){return function(e){return c(void 0,void 0,Promise,(function(){var n;return d(this,(function(t){switch(t.label){case 0:return[4,i.Ay.get(o.n.CHATBOT.CHATWIDGET_APPEARANCE_UPDATE(e))];case 1:return n=t.sent(),[2,(0,r.Cb)(n.data)]}}))}))}(e)},refetchOnWindowFocus:!0,refetchOnMount:!0,staleTime:0,retry:!1,enabled:n})},f=function(e,n){return c(void 0,void 0,Promise,(function(){return d(this,(function(t){switch(t.label){case 0:return[4,i.Ay.patch(o.n.CHATBOT.CHATWIDGET_APPEARANCE_UPDATE(e),(0,r.uc)(n))];case 1:return[2,t.sent().data]}}))}))},_=function(e,n,t){return(0,a.I)({queryKey:["CHATWIDGET_DETAILS",e,n,t],queryFn:function(){return function(e,n,t){return c(void 0,void 0,Promise,(function(){var a,l,c,h,S;return d(this,(function(d){switch(d.label){case 0:a=u(e,n,t),l=(0,s.BP)(a),d.label=1;case 1:return d.trys.push([1,3,,4]),[4,i.Ay.get(o.n.CHATBOT.CHATWIDGET_DETAILS(e,n),{params:{parent_domain:t}})];case 2:return c=d.sent(),h=(0,r.Cb)(c.data),(0,s.qX)(a,h,12e4),[2,h];case 3:if(S=d.sent(),l)return[2,l];throw S;case 4:return[2]}}
1))}))}(e,n,t)},refetchOnWindowFocus:!0,refetchOnMount:!0,staleTime:0,retry:!1,enabled:!!e&&!!n&&!n.endsWith("_undefined")})},A=function(e,n,t,r){return c(void 0,void 0,Promise,(function(){var a;return d(this,(function(l){switch(l.label){case 0:return[4,i.Ay.post(o.n.CHATBOT.CHATWIDGET_LEADS_SAVE(e,n),t,{params:{parent_domain:r}})];case 1:return a=l.sent(),(0,s.ph)(u(e,n,r)),[2,a.data]}}))}))},I=function(e,n){return(0,l.q)({queryKey:["CHATWIDGET_CHATS",e,n,"infinite"],queryFn:function(t){return c(void 0,[t],void 0,(function(t){var a,l,s=t.pageParam;return d(this,(function(t){switch(t.label){case 0:return a={page_size:25,chatbot_uuid:e,user_key:n},s&&(a.cursor=s),[4,i.Ay.get(o.n.CHATBOT.CHATWIDGET_CHATS,{params:a})];case 1:return l=t.sent(),[2,(0,r.Cb)(l.data)]}}))}))},initialPageParam:null,getNextPageParam:function(e){if(e.next)return new URL(e.next).searchParams.get("cursor")},getPreviousPageParam:function(e){if(e.previous)return new URL(e.previous).searchParams.get("cursor")},enabled:!!e&&!!n,staleTime:0,refetchOnWindowFocus:!1,retry:!1})},m=function(e,n){return c(void 0,void 0,void 0,(function(){return d(this,(function(t){switch(t.label){case 0:return[4,i.Ay.post(o.n.CHATBOT.CHAT_REACTION,{chat:e,reaction:n})];case 1:return[2,t.sent().data]}}))}))}},11815:function(e,n,t){t.d(n,{H:function(){return _}});var r=t(78685),i=(t(2057),t(86591)),o=t(17e3),a=t(78166),l=t(73433),s=t(16657),c=t(99658),d=t(65108),u=t
1(9752),h=t(42317),S=t(81e3),p=t(14160);function x(e){var n,t=e.mode,i=e.chatbotId,l=e.currentViewName,c=e.showLegacySchedulingTab,d=void 0!==c&&c,x=e.disableLegacySchedulingTab,f=void 0!==x&&x,_=(0,s.Bd)().t,A=(0,S.J)().userDetails,I=(0,h.PJ)(),m="create"===t,T=null!==(n=null==A?void 0:A.permissions)&&void 0!==n?n:[],v=(null==A?void 0:A.isSubaccountUser)||!1,b=function(e){return T.includes(e)},g=function(e){return v&&!b(e)},E=b(p.Qp.CAN_EMBED_CHATBOT.value)||b(p.Qp.CAN_UPDATE_INTEGRATIONS.value),y=b(p.Qp.CAN_UPDATE_LEADS.value)||b(p.Qp.CAN_UPDATE_SCHEDULING.value)||b(p.Qp.CAN_UPDATE_FUNCTIONS.value),L=[{key:"chatbot-detail",label:_("DISPLAY_LABELS.CHAT_AGENT"),active:"chatbot-detail"===l,disabled:m},{key:"update-chatbot",label:_("DISPLAY_LABELS.SETTINGS"),active:"update-chatbot"===l,disabled:m,hidden:g(p.Qp.CAN_UPDATE_CHATBOT.value)},{key:"train-chatbot",label:_("DISPLAY_LABELS.KNOWLEDGE_BASE_TAB"),active:"train-chatbot"===l,disabled:m,hidden:g(p.Qp.CAN_UPDATE_KNOWLEDGE_BASE.value)},{key:"chatbot-custom-tools",label:_("DISPLAY_LABELS.TOOLS_TAB"),active:"chatbot-custom-tools"===l,disabled:m,hidden:v&&!y},{key:"chat-inbox",label:_("DISPLAY_STRINGS.CONVERSATIONS",{defaultValue:"Conversations"}),active:"chat-inbox"===l,disabled:m},{key:"chatwidget-configuration",label:_("DISPLAY_LABELS.APPEARANCE_TAB"),active:"chatwidget-configuration"===l,disabled:m,hidden:g(p.Qp.CAN_CUSTOMIZE_APPEARANCE.value)},{key:"chatbot-integration-human-handoff",label:_("DISPLAY_LABELS.INTEGRATIONS_TAB"),active:"chatbot-integration-human-handoff"===l,disabled:m,hidden:v&&!E},{key:"chatbot-observability",label:_("DISPLAY_LABELS.SHELL_OBSERVABILITY"),active:"chatbot-observability"===l,disabled:m,hidden:!b(p.Qp.CAN_VIEW_OBSERVABILITY.value)}];!m&&i&&d&&L.splice(4,0,{key:"chatbot-appointment-scheduling",label:_("DISPLAY_STRINGS.SCHEDULING",{defaultValue:"Scheduling"}),active:"chatbot-appointment-scheduling"===l,disabled:f,href:"".concat(I,"chatbot/scheduling/").concat(i),badgeText:"legacy",tooltip:f?_("DISPLAY_STRINGS.NOT_AVAILABLE_YET"):void 0,useSpaNavigation:!1});var N=L.filter((function(e){return!e.hidden}));return N.length?(0,r.jsx)(a.azJ,{sx:{mt:0,mb:3},children:(0,r.jsx)(a.azJ,{sx:{display:"flex",flexWrap:"wrap",gap:0,borderBottom:1,borderColor:"divider",overflowX:"auto"},children:N.map((function(e){var n,t,l,s=e.badgeText?(0,r.jsx)(a.vu3,{label:e.badgeText,size:"x-small",color:"warning",sx:{ml:1,color:"common.white",textTransform:"uppercase"}}):null,c={borderRadius:0,px:2,py:1.25,borderBottom:e.active?2:0,borderColor:e.active?"primary.main":"transparent",color:e.active?"primary.main":"text.secondary",fontWeight:e.active?600:500,whiteSpace:"nowrap"};return e.disabled?(0,r.jsxs)(a.$nd,{disabled:!0,title:null!==(n=e.tooltip)&&void 0!==n?n:void 0,sx:c,children:[e.label,s]},e.key):!1===e.useSpaNavigation&&e.href?(0,r.jsxs)(a.$nd,{component:"a",href:e.href,title:null!==(t=e.tooltip)&&void 0!==t?t:void 0,sx:c,children:[e.label,s]},e.key):i?(0,r.jsxs)(a.$nd,{component:o.N_,to:(0,u.DL)(e.key,i),title:null!==(l=e.tooltip)&&void 0!==l?l:void 0,sx:c,children:[e.label,s]},e.key):null}))})}):null}var f=t(16003);function _(e){var n,t,u,h=e.heading,S=e.children,p=e.chatbotId,_=e.currentViewName,A=e.tabsMode,I=void 0===A?"update":A,m=e.showTabs,T=void 0===m||m,v=e.showHeader,b=void 0===v||v,g=e.showBackToList,E=void 0===g||g,y=e.detailData,L=e.fullWidth,N=void 0!==L&&L,j=e.disableLegacyContentPadding,C=void 0!==j&&j,P=(0,s.Bd)().t,D=(0,i.I)({queryKey:["chatbot-layout-header",null!=p?p:null],queryFn:function(){return(0,c.PF)(p)},enabled:Boolean(p)&&!y,retry:!1,staleTime:3e4}).data,R=null!=y?y:D,O={"chatbot-detail":{label:P("DISPLAY_LABELS.CHAT_AGENT"),icon:(0,r.jsx)(l.$3,{})},"chatbot-observability":{label:P("DISPLAY_LABELS.SHELL_OBSERVABILITY"),icon:(0,r.jsx)(l.iL,{})},"update-chatbot":{label:"Settings",icon:(0,r.jsx)(l.wB,{})},"train-chatbot":{label:"Knowledge Base",icon:(0,r.jsx)(l.bc,{})},"chatbot-custom-tools":{label:P("DISPLAY_LABELS.TOOLS_TAB"),icon:(0,r.jsx)(l.L2,{})},"chat-inbox":{label:P("DISPLAY_STRINGS.CONVERSATIONS"),icon:(0,r.jsx)(l.Pl,{})},"chatwidget-configuration":{label:"Appearance",icon:(0,r.jsx)(l.es,{})},"chatbot-integration-human-handoff":{label:"Integrations",icon:(0,r.jsx)(l.Bt,{})}},w=_?O[_]:void 0,G=null===(n=null==R?void 0:R.chatbot)||void 0===n?void 0:n.name,Y=G&&w?"update-chatbot"===_?"Update ".concat(G):"".concat(G,"'s ").concat(w.label):h,B=E?(0,r.jsx)(a.m_M,{title:"Back to Chat Agents",arrow:!0,children:(0,r.jsx)(a.K0,{component:o.N_,to:f.b.CHATBOT_LIST,"aria-label":"Back to Chat Agents",sx:function(e){return{width:32,height:32,color:e.palette.common.white,flexShrink:0,"&:hover":{bgcolor:"transparent",color:e.palette.common.white,transform:"translateX(-2px)"},"& .MuiSvgIcon-root":{fontSize:20}}},children:(0,r.jsx)(l.v$,{})})}):null,M=(0,r.jsxs)(a.azJ,{className:N||C?void 0:"px-4",sx:N?{pt:0,px:2}:{pt:0},children:[T?(0,r.jsx)(x,{mode:I,chatbotId:p,currentViewName:_,showLegacySchedulingTab:Boolean(null===(t=null==R?void 0:R.flags)||void 0===t?void 0:t.showLegacySchedulingTab),disableLegacySchedulingTab:Boolean(null===(u=null==R?void 0:R.chatbot)||void 0===u?void 0:u.isDefaultForAgencies)}):null,S]});return(0,r.jsxs)(d.L,{children:[b?(0,r.jsx)(a.aTG,{heading:Y,icon:null==w?void 0:w.icon,leftContent:B}):null,N?(0,r.jsx)(a.azJ,{sx:{width:"100%"},children:M}):(0,r.jsx)(a.KGj,{children:M})]})}},974:function(e,n,t){t.d(n,{Gn:function(){return q},ME:function(){return F}});var r=t(78685),i=t(2057),o=t(78166),a=t(73433),l=t(45602),s=t(97749),c=t(16657),d=t(19124),u=t
1(79335),h=t(86591),S=t(6765),p=t(21762),x="evaluations",f="evaluation-detail",_="evaluation-config",A={queued:{color:"default",labelKey:"DISPLAY_LABELS.EVALUATION_STATUS_QUEUED"},running:{color:"info",labelKey:"DISPLAY_LABELS.EVALUATION_STATUS_RUNNING"},completed:{color:"success",labelKey:"DISPLAY_LABELS.EVALUATION_STATUS_COMPLETED"},failed:{color:"error",labelKey:"DISPLAY_LABELS.EVALUATION_STATUS_FAILED"},payment_failed:{color:"warning",labelKey:"DISPLAY_LABELS.EVALUATION_STATUS_PAYMENT_FAILED"},expired:{color:"default",labelKey:"DISPLAY_LABELS.EVALUATION_STATUS_EXPIRED"}},I={pass:{color:"success",labelKey:"DISPLAY_LABELS.EVALUATION_VERDICT_PASS"},needs_review:{color:"warning",labelKey:"DISPLAY_LABELS.EVALUATION_VERDICT_NEEDS_REVIEW"},fail:{color:"error",labelKey:"DISPLAY_LABELS.EVALUATION_VERDICT_FAIL"}},m=["queued","running"],T=[{key:"accuracy",labelKey:"DISPLAY_LABELS.EVALUATION_DIM_ACCURACY",helpKey:"DISPLAY_LABELS.EVALUATION_DIM_ACCURACY_HELP"},{key:"toolExecution",labelKey:"DISPLAY_LABELS.EVALUATION_DIM_TOOL_EXECUTION",helpKey:"DISPLAY_LABELS.EVALUATION_DIM_TOOL_EXECUTION_HELP"},{key:"groundedness",labelKey:"DISPLAY_LABELS.EVALUATION_DIM_GROUNDEDNESS",helpKey:"DISPLAY_LABELS.EVALUATION_DIM_GROUNDEDNESS_HELP"},{key:"completeness",labelKey:"DISPLAY_LABELS.EVALUATION_DIM_COMPLETENESS",helpKey:"DISPLAY_LABELS.EVALUATION_DIM_COMPLETENESS_HELP"},{key:"latency",labelKey:"DISPLAY_LABELS.EVALUATION_DIM_LATENCY",helpKey:"DISPLAY_LABELS.EVALUATION_DIM_LATENCY_HELP"}],v=function(e,n,t,r){return new(t||(t=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function l(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){var n;e.done?i(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(a,l)}s((r=r.apply(e,n||[])).next())}))},b=function(e,n){var t,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=l(0),a.throw=l(1),a.return=l(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function l(l){return function(s){return function(l){if(t)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(o=0)),o;)try{if(t=1,r&&(i=2&l[0]?r.return:l[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,l[1])).done)return i;switch(r=0,i&&(l=[2&l[0],i.value]),l[0]){case 0:case 1:i=l;break;case 4:return o.label++,{value:l[1],done:!1};case 5:o.label++,r=l[1],l=[0];continue;case 7:l=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==l[0]&&2!==l[0])){o=0;continue}if(3===l[0]&&(!i||l[1]>i[0]&&l[1]<i[3])){o.label=l[1];break}if(6===l[0]&&o.label<i[1]){o.label=i[1],i=l;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(l);break}i[2]&&o.ops.pop(),o.trys.pop();continue}l=n.call(e,o)}catch(e){l=[6,e],r=0}finally{t=i=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,s])}}},g=function(e){return v(void 0,void 0,Promise,(function(){var n;return b(this,(function(t){switch(t.label){case 0:return[4,S.nv.post(p.n.OBSERVABILITY.EVALUATIONS,(0,d.uc)({conversation:e}),{headers:{"Idempotency-Key":(0,u.A)()}})];case 1:return n=t.sent(),[2,(0,d.Cb)(n.data)]}}))}))},E=function(e,n,t){return(0,h.I)({queryKey:[x,e,n,t],queryFn:function(){return function(e,n,t){return v(void 0,void 0,Promise,(function(){var r;return b(this,(function(i){switch(i.label){case 0:return[4,S.nv.get(p.n.OBSERVABILITY.EVALUATIONS,{params:(0,d.uc)({chatbot:e,conversation:n.conversation||void 0,conversationSearch:n.conversationSearch||void 0,status:n.status||void 0,group:n.group||void 0,page:t,pageSize:25})})];case 1:return r=i.sent(),[2,(0,d.Cb)(r.data)]}}))}))}(e,n,t)},refetchOnWindowFocus:!0,refetchOnMount:!0,staleTime:0,refetchInterval:function(e){var n,t=e.state.data;return!!(null===(n=null==t?void 0:t.results)||void 0===n?void 0:n.some((function(e){return m.includes(e.status)})))&&4e3}})},y=function(e){return(0,h.I)({queryKey:[f,e],queryFn:function(){return function(e){return v(void 0,void 0,Promise,(function(){var n;return b(this,(function(t){switch(t.label){case 0:return[4,S.nv.get(p.n.OBSERVABILITY.EVALUATION_DETAIL(e))];case 1:return n=t.sent(),[2,(0,d.Cb)(n.data)]}}))}))}(e)},enabled:Boolean(e),refetchOnWindowFocus:!1,staleTime:15e3})},L=function(){return v(void 0,void 0,Promise,(function(){var e;return b(this,(function(n){switch(n.label){case 0:return[4,S.nv.get(p.n.OBSERVABILITY.EVALUATION_CONFIG)];case 1:return e=n.sent(),[2,(0,d.Cb)(e.data)]}}))}))},N=t(1331);function j(e){if(null==e||""===e)return"—";var n=Number(e);return Number.isNaN(n)?"—":"".concat(Math.round(100*n),"%")}function C(e){if(null==e||""===e)return 0;var n=Number(e);return Number.isNaN(n)?0:Math.max(0,Math.min(1,n))}function P(e){var n=C(e);return n>=.8?"success":n>=.5?"warning":"error"}function D(e){if(!e)return"—";var n=new Date(e);return Number.isNaN(n.getTime())?"—":(0,N.r6)(e)}function R(e,n){var t=n||"";if(null==e||""===e)return"".concat(t,"0");var r=Number(e);return Number.isNaN(r)?"".concat(t).concat(e):"".concat(t).concat(parseFloat(r.toFixed(6)))}var O=function(e){var n=e.status,t=e.size,i=void 0===t?"small":t,a=(0,c.Bd)().t,l=A[n];return l?(0,r.jsx)(o.vu3,{size:i,color:l.color,variant:"outlined",label:a(l.labelKey),sx:{fontWeight:600}}):null};var w=function(e){var n=e.verdict,t=e.size,i=void 0===t?"small":t,a=(0,c.Bd)().t;if(!n)return null;var l=I[n];return l?(0,r.jsx)(o.vu3,{size:i,color:l.color,label:a(l.labelKey),sx:{fontWeight:700}}):null},G=t(7098);function Y(e){var n=e.labelKey,t=e.helpKey,i=e.value,l=(0,c.Bd)().t;return(0,r.jsxs)(o.azJ,{sx:{display:"grid",gridTemplateColumns:{xs:"130px 1fr 44px",sm:"190px 1fr 48px"},alignItems:"center",columnGap:1.5,mb:1},children:[(0,r.jsxs)(o.azJ,{display:"flex",alignItems:"center",gap:.5,minWidth:0,children:[(0,r.jsx)(o.o5u,{variant:"body2",color:"text.primary",noWrap:!0,children:l(n)}),t&&(0,r.jsx)(o.m_M,{title:l(t),children:(0,r.jsx)(a.JL,{sx:{fontSize:15,color:"text.disabled",cursor:"help",flexShrink:0}})})]}),(0,r.jsx)(o.hZv,{variant:"determinate",value:100*C(i),color:P(i),sx:{height:8,borderRadius:4,bgcolor:"action.hover"}}),(0,r.jsx)(o.o5u,{variant:"body2",fontWeight:700,textAlign:"right",children:j(i)})]})}function B(e){var n=e.children;return(0,r.jsx)(o.o5u,{variant:"caption",color:"text.primary",sx:{dis
1play:"block",fontWeight:700,textTransform:"uppercase",letterSpacing:.4,mb:1},children:n})}function M(e){var n=e.detail,t=(0,c.Bd)().t;return(0,r.jsxs)(o.azJ,{sx:{maxWidth:760},children:[(0,r.jsxs)(o.azJ,{display:"flex",alignItems:"center",gap:1.5,mb:2.5,flexWrap:"wrap",children:[(0,r.jsx)(o.o5u,{variant:"h4",fontWeight:800,lineHeight:1,children:j(n.score)}),(0,r.jsx)(w,{verdict:n.verdict,size:"medium"}),n.insufficientTimingData&&(0,r.jsx)(o.vu3,{size:"small",variant:"outlined",color:"warning",label:t("DISPLAY_LABELS.EVALUATION_INSUFFICIENT_TIMING")})]}),(0,r.jsx)(o.azJ,{mb:2.5,children:T.map((function(e){return(0,r.jsx)(Y,{labelKey:e.labelKey,helpKey:e.helpKey,value:n[e.key]},e.key)}))}),n.reason&&(0,r.jsxs)(o.azJ,{mb:2.5,children:[(0,r.jsx)(B,{children:t("DISPLAY_LABELS.EVALUATION_REASON")}),(0,r.jsx)(o.azJ,{sx:{p:1.5,borderRadius:1,border:function(e){return"1px solid ".concat(e.palette.divider)},bgcolor:"action.hover"},children:(0,r.jsx)(o.o5u,{variant:"body2",color:"text.primary",sx:{whiteSpace:"pre-wrap"},children:n.reason})})]}),n.issues&&n.issues.length>0&&(0,r.jsxs)(o.azJ,{mb:2.5,children:[(0,r.jsxs)(B,{children:[t("DISPLAY_LABELS.EVALUATION_ISSUES")," (",n.issues.length,")"]}),(0,r.jsx)(o.azJ,{display:"flex",flexDirection:"column",gap:1,children:n.issues.map((function(e,n){return(0,r.jsxs)(o.azJ,{display:"flex",gap:1,alignItems:"flex-start",sx:{p:1.25,borderRadius:1,border:function(e){return"1px solid ".concat((0,G.X4)(e.palette.warning.main,.3))},bgcolor:function(e){return(0,G.X4)(e.palette.warning.main,.08)}},children:[(0,r.jsx)(a.po,{fontSize:"small",color:"warning",sx:{mt:"2px",flexShrink:0}}),(0,r.jsx)(o.o5u,{variant:"body2",color:"text.primary",children:e})]},n)}))})]}),n.suggestedImprovement&&(0,r.jsxs)(o.azJ,{mb:2.5,children:[(0,r.jsx)(B,{children:t("DISPLAY_LABELS.EVALUATION_SUGGESTED_IMPROVEMENT")}),(0,r.jsxs)(o.azJ,{display:"flex",gap:1,alignItems:"flex-start",sx:{p:1.5,borderRadius:1,border:function(e){return"1px solid ".concat((0,G.X4)(e.palette.info.main,.3))},bgcolor:function(e){return(0,G.X4)(e.palette.info.main,.08)}},children:[(0,r.jsx)(a.JL,{fontSize:"small",color:"info",sx:{mt:"2px",flexShrink:0}}),(0,r.jsx)(o.o5u,{variant:"body2",color:"text.primary",children:n.suggestedImprovement})]})]}),(0,r.jsxs)(o.o5u,{variant:"caption",color:"text.secondary",display:"block",children:[t("DISPLAY_LABELS.EVALUATION_MODEL"),": ",n.modelVersion||"—"," ·"," ",t("DISPLAY_LABELS.EVALUATION_RUBRIC"),": ",n.rubricVersion]})]})}function k(e){var n=e.evaluationId,t=(0,c.Bd)().t,i=y(n),a=i.data,l=i.isLoading,s=i.isError;return l?(0,r.jsxs)(o.azJ,{py:1,children:[(0,r.jsx)(o.EAD,{variant:"text",width:120,height:40}),(0,r.jsx)(o.EAD,{variant:"rectangular",height:80,sx:{mt:1,borderRadius:1}})]}):s||!a?(0,r.jsx)(o.FcD,{severity:"error",sx:{my:1},children:t("DISPLAY_STRINGS.EVALUATION_LOAD_ERROR")}):(0,r.jsx)(M,{detail:a})}var U=function(e){var n=e.row,t=(0,c.Bd)().t;return"queued"===n.status||"running"===n.status?(0,r.jsxs)(o.azJ,{display:"flex",alignItems:"center",gap:1.5,py:2,children:[(0,r.jsx)(o.PaH,{size:18}),(0,r.jsx)(o.o5u,{variant:"body2",color:"text.secondary",children:t("DISPLAY_STRINGS.EVALUATION_IN_PROGRESS")})]}):"failed"===n.status||"expired"===n.status?(0,r.jsx)(o.FcD,{severity:"error",sx:{my:1},children:t("DISPLAY_STRINGS.EVALUATION_FAILED_HELP")}):"payment_failed"===n.status?(0,r.jsx)(o.FcD,{severity:"warning",sx:{my:1},children:t("DISPLAY_STRINGS.EVALUATION_PAYMENT_FAILED_HELP")}):(0,r.jsx)(k,{evaluationId:n.id})};var z=function(e){var n,t=e.chatbotId,l=e.conversationId,s=e.latestRunId,d=(0,c.Bd)().t,u=E(t,{conversation:l},1),h=u.data,S=u.isLoading,p=(0,i.useState)(null),x=p[0],f=p[1];if(S)return(0,r.jsx)(o.EAD,{variant:"rounded",height:48,sx:{mt:2}});var _=(null!==(n=null==h?void 0:h.results)&&void 0!==n?n:[]).filter((function(e){return e.id!==s}));return 0===_.length?null:(0,r.jsxs)(o.azJ,{mt:3,children:[(0,r.jsxs)(o.o5u,{variant:"caption",color:"text.primary",sx:{display:"block",fontWeight:700,textTransform:"uppercase",letterSpacing:.4,mb:1},children:[d("DISPLAY_LABELS.EVALUATION_HISTORY")," (",_.length,")"]}),(0,r.jsx)(o.azJ,{sx:{border:function(e){return"1px solid ".concat(e.palette.divider)},borderRadius:1,overflow:"hidden"},children:_.map((function(e,n){var t=x===e.id;return(0,r.jsxs)(o.azJ,{sx:{borderTop:function(e){return 0===n?"none":"1px solid ".concat(e.palette.divider)}},children:[(0,r.jsxs)(o.azJ,{onClick:function(){return f((function(n){return n===e.id?null:e.id}))},sx:{display:"flex",alignItems:"center",gap:1.5,px:1.5,py:1,cursor:"pointer","&:hover":{bgcolor:"action.hover"}},children:[(0,r.jsx)(o.K0,{size:"small",sx:{p:.25},children:(0,r.jsx)(a.CO,{fontSize:"small",sx:{transition:"transform 0.2s",transform:t?"rotate(180deg)":"none"}})}),(0,r.jsx)(o.o5u,{variant:"body2",color:"text.secondary",sx:{minWidth:150},children:D(e.createdAt)}),(0,r.jsx)(o.o5u,{variant:"body2",fontWeight:700,color:e.score?"".concat(P(e.score),".main"):"text.primary",sx:{minWidth:48},children:j(e.score)}),(0,r.jsx)(w,{verdict:e.verdict}),(0,r.jsx)(o.azJ,{flex:1}),(0,r.jsx)(O,{status:e.status})]}),(0,r.jsx)(o.SDm,{in:t,timeout:"auto",unmountOnExit:!0,children:(0,r.jsx)(o.azJ,{px:2,pb:2,pt:.5,children:(0,r.jsx)(U,{row:e})})})]},e.id)}))})]})},W=(0,o.I4L)(o.nA6)((function(e){var n=e.theme;return{color:n.palette.text.secondary,fontWeight:600,fontSize:12,textTransform:"uppercase",letterSpacing:.4,backgroundColor:n.palette.action.hover,borderBottom:"1px solid ".concat(n.palette.divider),whiteSpace:"nowrap"}})),H=(0,o.I4L)(o.nA6)((function(e){var n=e.theme;return{color:n.palette.text.primary,borderBottom:"1px solid ".concat(n.palette.divider),whiteSpace:"nowrap"}}));var F=function(e){var n,t=e.chatbotId,u=e.highlightConversationId,h=(0,c.Bd)().t,S=(0,l.jE)(),p=(0,i.useState)(1),f=p[0],_=p[1],A=(0,i.useState)(null),I=A[0],m=A[1],T=(0,i.useState)(null),v=T[0],b=T[1],y=(0,i.useState)(""),L=y[0],N=y[1],C=(0,i.useState)(""),G=C[0],Y=C[1],B=(0,i.useRef)(!1),M=E(t,{conversationSearch:G||void 0,group:"conversation"},f),k=M.data,F=M.isLoading,K=M.isError,J=(0,i.useMemo)((function(){var e;return null!==(e=null==k?void 0:k.results)&&void 0!==e?e:[]}),[k]),V=null!==(n=null==k?void 0:k.count)&&void 0!==n?n:0,q=Math.max(1,Math.ceil(V/25)),Q=function(){Y(L.trim()),_(1)};(0,i.useEffect)((function(){if(!B.current&&u&&0!==J.length){var e=J.find((function(e){return e.conversationId===u}));e&&(m(e.id),B.current=!0)}}),[J,u]);var $,X=(0,s.n)({mutationFn:function(e){return g(e)},onSuccess:function(){S.invalidateQueries({queryKey:[x]}),(0,d.Sx)(h("DISPLAY_STRINGS.EVALUATION_STARTED_HEADING"),h("DISPLAY_STRINGS.EVALUATION_STARTED_MESSAGE"),"success")},onError:function(e){var n,t,r=(null===(t=null===(n=null==e?void 0:e.response)||void 0===n?void 0:n.data)||void 0===t?void 0:t.detail)||h("DISPLAY_STRINGS.EVALUATION_START_ERROR");(0,d.Sx)(h("DISPLAY_STRINGS.ERROR"),r,"error")},onSettled:function(){return b(null)}}),Z=(0,r.jsx)(o.A_L,{size:"small",value:L,placeholder:h("DISPLAY_STRINGS.EVALUATION_SEARCH_PLACEHOLDER"),onChange:function(e){return N(e.target.value)},onKeyDown:function(e){"Enter"===e.key&&Q()},onBlur:Q,sx:{minWidth:280},InputProps:{startAdornment:(0,r.jsx)(o.jC1,{position:"start",children:(0,r.jsx)(a.vj,{fontSize:"small",color:"action"})}),endAdornment:L?(0,r.jsx)(o.jC1,{position:"end",children:(0,r.jsx)(o.K0,{size:"small",onClick:function(){N(""),Y(""),_(1)},"aria-label":h("DISPLAY_LABELS.CLOSE_BUTTON"),children:(0,r.jsx)(a.bm,{fontSize:"small"})})}):null}});return $=K?(0,r.jsx)(o.o5u,{color:"error",variant:"body2",children:h("DISPLAY_STRINGS.EVALUATION_LIST_ERROR")}
1):F||0!==J.length?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(o.K3K,{sx:{border:function(e){return"1px solid ".concat(e.palette.divider)},borderRadius:1},children:(0,r.jsxs)(o.XIK,{stickyHeader:!0,size:"small",children:[(0,r.jsx)(o.ndF,{children:(0,r.jsxs)(o.Hjg,{children:[(0,r.jsx)(W,{sx:{width:48}}),(0,r.jsx)(W,{sx:{width:"38%"},children:h("DISPLAY_LABELS.EVALUATION_COL_CONVERSATION")}),(0,r.jsx)(W,{children:h("DISPLAY_LABELS.EVALUATION_COL_SCORE")}),(0,r.jsx)(W,{children:h("DISPLAY_LABELS.EVALUATION_COL_VERDICT")}),(0,r.jsx)(W,{children:h("DISPLAY_LABELS.EVALUATION_COL_STATUS")}),(0,r.jsx)(W,{children:h("DISPLAY_LABELS.EVALUATION_COL_DATE")}),(0,r.jsx)(W,{align:"right",children:h("DISPLAY_LABELS.EVALUATION_COL_ACTIONS")})]})}),(0,r.jsx)(o.BFY,{children:F?Array.from({length:6}).map((function(e,n){return(0,r.jsx)(o.Hjg,{children:Array.from({length:7}).map((function(e,n){return(0,r.jsx)(H,{children:(0,r.jsx)(o.EAD,{variant:"text"})},n)}))},"skeleton-".concat(n))})):J.map((function(e){var n,l,s,c,d,S=I===e.id,p=null!=u&&e.conversationId===u;return(0,r.jsxs)(i.Fragment,{children:[(0,r.jsxs)(o.Hjg,{hover:!0,sx:p?{backgroundColor:"action.selected"}:void 0,children:[(0,r.jsx)(H,{padding:"checkbox",children:(0,r.jsx)(o.K0,{size:"small",onClick:function(){return n=e.id,m((function(e){return e===n?null:n}));var n},children:(0,r.jsx)(a.CO,{sx:{transition:"transform 0.2s",transform:S?"rotate(180deg)":"none"}})})}),(0,r.jsxs)(H,{sx:{maxWidth:320},children:[(0,r.jsx)(o.o5u,{variant:"body2",fontWeight:600,noWrap:!0,children:(c=e.conversationTitle,d=e.conversationNumber,c||(null!=d?"#".concat(d):"—"))}),(null!==(n=e.evaluationCount)&&void 0!==n?n:0)>1&&(0,r.jsx)(o.vu3,{size:"small",variant:"outlined",label:h("DISPLAY_LABELS.EVALUATION_RUN_BADGE",{count:null!==(l=e.evaluationCount)&&void 0!==l?l:0}),sx:{mt:.5,height:20,fontSize:11}})]}),(0,r.jsx)(H,{children:(0,r.jsx)(o.o5u,{variant:"body2",fontWeight:700,color:e.score?"".concat(P(e.score),".main"):"text.primary",children:j(e.score)})}),(0,r.jsx)(H,{children:(0,r.jsx)(w,{verdict:e.verdict})}),(0,r.jsx)(H,{children:(0,r.jsx)(O,{status:e.status})}),(0,r.jsx)(H,{children:(0,r.jsx)(o.o5u,{variant:"body2",color:"text.secondary",noWrap:!0,children:D(e.createdAt)})}),(0,r.jsx)(H,{align:"right",children:(0,r.jsx)(o.m_M,{title:h("DISPLAY_STRINGS.EVALUATION_REEVALUATE_TOOLTIP"),children:(0,r.jsx)("span",{children:(0,r.jsx)(o.K0,{size:"small",color:"primary",disabled:!e.conversationUuid,onClick:function(){return b(e)},children:(0,r.jsx)(a.C4,{fontSize:"small"})})})})})]}),(0,r.jsx)(o.Hjg,{children:(0,r.jsx)(H,{colSpan:7,sx:{py:0,whiteSpace:"normal",borderBottom:S?void 0:"none"},children:(0,r.jsx)(o.SDm,{in:S,timeout:"auto",unmountOnExit:!0,children:(0,r.jsxs)(o.azJ,{px:1,py:2,children:[(0,r.jsx)(U,{row:e}),(null!==(s=e.evaluationCount)&&void 0!==s?s:0)>1&&null!=e.conversationId&&(0,r.jsx)(z,{chatbotId:t,conversationId:e.conversationId,latestRunId:e.id})]})})})})]},e.id)}))})]})}),!F&&V>25&&(0,r.jsxs)(o.azJ,{display:"flex",justifyContent:"space-between",alignItems:"center",mt:2,children:[(0,r.jsx)(o.o5u,{variant:"caption",color:"text.secondary",children:h("DISPLAY_LABELS.EVALUATION_TOTAL_COUNT",{count:V})}),(0,r.jsx)(o.dKS,{count:q,page:f,onChange:function(e,n){return _(n)},color:"primary",size:"small",shape:"rounded"})]})]}):(0,r.jsxs)(o.azJ,{textAlign:"center",py:6,children:[(0,r.jsx)(o.o5u,{variant:"subtitle1",fontWeight:600,gutterBottom:!0,children:h(G?"DISPLAY_STRINGS.EVALUATION_NO_SEARCH_RESULTS":"DISPLAY_STRINGS.EVALUATION_EMPTY_TITLE")}),(0,r.jsx)(o.o5u,{variant:"body2",color:"text.secondary",children:h(G?"DISPLAY_STRINGS.EVALUATION_NO_SEARCH_RESULTS_HELP":"DISPLAY_STRINGS.EVALUATION_EMPTY_HELP")})]}),(0,r.jsxs)(o.Zkm,{title:h("DISPLAY_LABELS.EVALUATED_CONVERSATIONS"),rightContent:Z,children:[$,(0,r.jsxs)(o.lGe,{open:Boolean(v),onClose:function(){return b(null)},children:[(0,r.jsx)(o.L33,{children:h("DISPLAY_STRINGS.EVALUATION_REEVALUATE_CONFIRM_TITLE")}),(0,r.jsx)(o.Cff,{children:(0,r.jsxs)(o.zTD,{component:"div",children:[h("DISPLAY_STRINGS.EVALUATION_REEVALUATE_CONFIRM_BODY"),(0,r.jsx)(o.azJ,{mt:1.5,children:(0,r.jsxs)(o.o5u,{variant:"subtitle1",fontWeight:700,children:[h("DISPLAY_LABELS.EVALUATION_PRICE"),":"," ",R(null==v?void 0:v.chargeAmount,null==v?void 0:v.currencySymbol)]})}),(0,r.jsx)(o.o5u,{variant:"caption",color:"text.secondary",children:h("DISPLAY_STRINGS.EVALUATION_AI_DISCLAIMER")})]})}),(0,r.jsxs)(o.iin,{children:[(0,r.jsx)(o.$nd,{onClick:function(){return b(null)},color:"inherit",children:h("DISPLAY_STRINGS.CANCEL")}),(0,r.jsx)(o.$nd,{variant:"contained",disabled:X.isPending||!(null==v?void 0:v.conversationUuid),onClick:function(){(null==v?void 0:v.conversationUuid)&&X.mutate(v.conversationUuid)},children:h("DISPLAY_STRINGS.EVALUATION_CONFIRM_EVALUATE")})]})]})]})},K=t(17e3),J=t(9752),V=t(81491);var q=function(e){var n,t=e.open,i=e.conversationUuid,l=e.chatbotId,u=e.conversationId,S=e.onClose,p=(0,c.Bd)().t,x=(0,K.Zp)(),f=(n=t,(0,h.I)({queryKey:[_],queryFn:L,enabled:n,refetchOnWindowFocus:!1,staleTime:3e5})).data,A=(0,s.n)({mutationFn:function(e){return g(e)},onSuccess:function(){(0,d.Sx)(p("DISPLAY_STRINGS.EVALUATION_STARTED_HEADING"),p("DISPLAY_STRINGS.EVALUATION_STARTED_MESSAGE"),"success"),S(),x("".concat((0,J.DL)("chatbot-observability",l))+"?tab=".concat(V.fg.EVALUATED_CONVERSATIONS)+"&highlight=".concat(u))},onError:function(e){var n,t,r=(null===(t=null===(n=null==e?void 0:e.response)||void 0===n?void 0:n.data)||void 0===t?void 0:t.detail)||p("DISPLAY_STRINGS.EVALUATION_START_ERROR");(0,d.Sx)(p("DISPLAY_STRINGS.ERROR"),r,"error")}});return(0,r.jsxs)(o.lGe,{open:t,onClose:S,maxWidth:"sm",fullWidth:!0,children:[(0,r.jsx)(o.L33,{children:(0,r.jsxs)(o.azJ,{display:"flex",alignItems:"center",gap:1,children:[(0,r.jsx)(a.iL,{color:"primary"}),p("DISPLAY_STRINGS.EVALUATE_CONVERSATION")]})}),(0,r.jsxs)(o.Cff,{dividers:!0,children:[(0,r.jsx)(o.o5u,{variant:"body2",color:"text.secondary",gutterBottom:!0,children:p("DISPLAY_STRINGS.EVALUATION_MODAL_INTRO")}),(0,r.jsxs)(o.azJ,{component:"ul",sx:{pl:3,mt:1,mb:1},children:[(0,r.jsx)("li",{children:(0,r.jsx)(o.o5u,{variant:"body2",color:"text.secondary",children:p("DISPLAY_STRINGS.EVALUATION_MODAL_POINT_SCOPE")})}),(0,r.jsx)("li",{children:(0,r.jsx)(o.o5u,{variant:"body2",color:"text.secondary",children:p("DISPLAY_STRINGS.EVALUATION_MODAL_POINT_RESULT")})}),(0,r.jsx)("li",{children:(0,r.jsx)(o.o5u,{variant:"body2",color:"text.secondary",children:p("DISPLAY_STRINGS.EVALUATION_MODAL_POINT_TRACE")})})]}),(0,r.jsx)(o.cGx,{sx:{my:1.5}}),(0,r.jsxs)(o.azJ,{display:"flex",alignItems:"baseline",gap:1,children:[(0,r.jsxs)(o.o5u,{variant:"subtitle2",children:[p("DISPLAY_LABELS.EVALUATION_PRICE"),":"]}),(0,r.jsx)(o.o5u,{variant:"h6",fontWeight:700,children:R(null==f?void 0:f.chargeAmount,null==f?void 0:f.currencySymbol)}),(0,r.jsx)(o.o5u,{variant:"caption",color:"text.secondary",children:p("DISPLAY_STRINGS.EVALUATION_PER_CONVERSATION")})]}),(0,r.jsx)(o.FcD,{severity:"info",sx:{mt:1.5},children:p("DISPLAY_STRINGS.EVALUATION_AI_DISCLAIMER")})]}),(0,r.jsxs)(o.iin,{children:[(0,r.jsx)(o.$nd,{onClick:S,color:"inherit",children:p("DISPLAY_STRINGS.CANCEL")}),(0,r.jsx)(o.$nd,{variant:"contained",disabled:A.isPending||!i,startIcon:(0,r.jsx)(a.iL,{}),onClick:function(){i&&A.mutate(i)},children:p("DISPLAY_STRINGS.EVALUATION_CONFIRM_EVALUATE")})]})]})}},16472:function(e,n,t){t.d(n,{Jf:function(){return L},Ko:function(){return E},Rx:function(){return I},SW:function(){return m},b6:function(){return A},hg:function(){return C},mm:function(){return v},mw:function(){return y},nk:function(){return j},pf:function(){return N},qx:function(){return T},wW:function(){return b},xC:function(){return g}});var r=t(86591),i=t(30829),o=t(79847),a=t(28520),l=t(6765),s=t(85667),c=t(2
11762),d=t(19124),u=t(38451),h=function(){return h=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var i in n=arguments[t])Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i]);return e},h.apply(this,arguments)},S=function(e,n,t,r){return new(t||(t=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function l(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){var n;e.done?i(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(a,l)}s((r=r.apply(e,n||[])).next())}))},p=function(e,n){var t,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=l(0),a.throw=l(1),a.return=l(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function l(l){return function(s){return function(l){if(t)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(o=0)),o;)try{if(t=1,r&&(i=2&l[0]?r.return:l[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,l[1])).done)return i;switch(r=0,i&&(l=[2&l[0],i.value]),l[0]){case 0:case 1:i=l;break;case 4:return o.label++,{value:l[1],done:!1};case 5:o.label++,r=l[1],l=[0];continue;case 7:l=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==l[0]&&2!==l[0])){o=0;continue}if(3===l[0]&&(!i||l[1]>i[0]&&l[1]<i[3])){o.label=l[1];break}if(6===l[0]&&o.label<i[1]){o.label=i[1],i=l;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(l);break}i[2]&&o.ops.pop(),o.trys.pop();continue}l=n.call(e,o)}catch(e){l=[6,e],r=0}finally{t=i=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,s])}}},x=function(e,n,t){if(t||2===arguments.length)for(var r,i=0,o=n.length;i<o;i++)!r&&i in n||(r||(r=Array.prototype.slice.call(n,0,i)),r[i]=n[i]);return e.concat(r||Array.prototype.slice.call(n))},f=function(e){if("string"==typeof e)return e;if(Array.isArray(e))for(var n=0,t=e;n<t.length;n++){var r=t[n];if(c=f(r))return c}if(e&&"object"==typeof e){for(var i=e,o=0,a=["message","detail","errors"];o<a.length;o++){if(c=f(i[a[o]]))return c}for(var l=0,s=Object.values(i);l<s.length;l++){var c;r=s[l];if(c=f(r))return c}}return null},_=function(e,n,t){return S(void 0,void 0,Promise,(function(){return p(this,(function(r){switch(r.label){case 0:return[4,l.Ay.get(c.n.CHATBOT.CONTACTS,{params:{offset:(n-1)*t,limit:t,chatbot_id:e>0?e:void 0,all_chatbots:0===e||void 0}})];case 1:return[2,r.sent().data]}}))}))},A=function(e){return S(void 0,void 0,Promise,(function(){var n,t,r,i,o,a;return p(this,(function(l){switch(l.label){case 0:return[4,_(e,1,n=250)];case 1:t=l.sent(),r=x([],t.results,!0),i=Math.ceil(t.count/n),o=2,l.label=2;case 2:return o<=i?[4,_(e,o,n)]:[3,5];case 3:a=l.sent(),r.push.apply(r,a.results),l.label=4;case 4:return o+=1,[3,2];case 5:return[2,r]}}))}))},I=function(e,n,t){return(0,r.I)({queryKey:[s.e.contacts,e,n,t],queryFn:function(){return _(e,n,t)},placeholderData:i.rX,refetchOnWindowFocus:!1,retry:!1})},m=function(e,n,t,o,a){return void 0===a&&(a=!1),(0,r.I)({queryKey:[s.e.conversations,e,n,o,a],queryFn:function(){return function(e,n,t,r){for(var i=[],o=4;o<arguments.length;o++)i[o-4]=arguments[o];return S(void 0,x([e,n,t,r],i,!0),Promise,(function(e,n,t,r,i){var o;return void 0===i&&(i=!1),p(this,(function(a){switch(a.label){case 0:return o=new URLSearchParams,r.conversation_number&&o.append("conversation_number",r.conversation_number.toString()),[4,l.Ay.get(c.n.CHATBOT.CONVERSATIONS,{params:h({offset:(n-1)*t,limit:t,chatbot_id:e>0?e:void 0,all_chatbots:0===e||void 0,ordering:i?"-updated_at":"updated_at"},Object.fromEntries(Object.entries(r).filter((function(e){e[0];var n=e[1];return n&&-1!==n}))))})];case 1:return[2,a.sent().data]}}))}))}(e,n,t,o,a)},refetchOnWindowFocus:!1,refetchOnMount:!0,staleTime:0,placeholderData:i.rX,retry:!1})},T=function(e,n){return void 0===n&&(n=!1),(0,r.I)({queryKey:[s.e.conversationDetail,e,n?"archived":"live"],queryFn:function(){return function(e){for(var n=[],t=1;t<arguments.length;t++)n[t-1]=arguments[t];return S(void 0,x([e],n,!0),Promise,(function(e,n){return void 0===n&&(n=!1),p(this,(function(t){switch(t.label){case 0:return[4,l.Ay.get(c.n.CHATBOT.CONVERSATION_DETAILS(e),{params:{includeArchivedConversations:n}})];case 1:return[2,t.sent().data]}}))}))}(e,n)},refetchOnWindowFocus:!1,refetchOnMount:!0,staleTime:0,retry:!1})},v=function(e){return S(void 0,void 0,void 0,(function(){return p(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,l.Ay.post(c.n.CHATBOT.CONVERSATION_DEACTIVATE(e),{})];case 1:return[2,n.sent().data];case 2:throw n.sent(),new Error(u.Ay.t("DISPLAY_STRINGS.FAILED_TO_DEACTIVATE_CONVERSATION"));case 3:return[2]}}
1))}))},b=function(e,n,t){return S(void 0,void 0,void 0,(function(){var r,i,o;return p(this,(function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,l.Ay.post(c.n.CHATBOT.TRAIN_CHATBOT_QA,{chatbot_id:e,question:n,answer:t})];case 1:return[2,s.sent().data];case 2:throw r=s.sent(),i=a.A.isAxiosError(r)?f(null===(o=r.response)||void 0===o?void 0:o.data):null,new Error(i||u.Ay.t("DISPLAY_STRINGS.FAILED_TO_TRAIN_CHATBOT_QA"));case 3:return[2]}}))}))},g=function(e,n){return S(void 0,void 0,void 0,(function(){return p(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,l.Ay.put(c.n.CHATBOT.CONVERSATION_HUMAN_HANDOFF(e),{is_human_handed_off:n})];case 1:return[2,t.sent().data];case 2:throw t.sent(),new Error(u.Ay.t("DISPLAY_STRINGS.FAILED_TO_UPDATE_HUMAN_HANDOFF"));case 3:return[2]}}))}))},E=function(e){return(0,r.I)({queryKey:[s.e.humanHandoffSettings,e],queryFn:function(){return function(e){return S(void 0,void 0,Promise,(function(){return p(this,(function(n){switch(n.label){case 0:return[4,l.Ay.get(c.n.CHATBOT.HUMAN_HANDOFF_SETTINGS(e))];case 1:return[2,n.sent().data]}}))}))}(e)},refetchOnWindowFocus:!0,refetchOnMount:!0,staleTime:0,retry:!1})},y=function(e,n){return S(void 0,void 0,Promise,(function(){return p(this,(function(t){switch(t.label){case 0:return[4,l.Ay.put(c.n.CHATBOT.HUMAN_HANDOFF_SETTINGS(e),n)];case 1:return[2,t.sent().data]}}))}))},L=function(e){return(0,r.I)({queryKey:[s.e.conversationSummary,e],queryFn:function(){return e?function(e){return S(void 0,void 0,Promise,(function(){var n;return p(this,(function(t){switch(t.label){case 0:return[4,l.Ay.get("".concat(c.n.CHATBOT.CONVERSATION_SUMMARY),{params:{uuid:e}})];case 1:return n=t.sent(),[2,(0,d.Cb)(n.data)]}}))}))}(e):Promise.reject(u.Ay.t("DISPLAY_STRINGS.NO_UUID_PROVIDED"))},refetchOnWindowFocus:!1,refetchOnMount:!0,staleTime:0})},N=function(e,n){return l.Ay.post("".concat(c.n.CHATBOT.CONVERSATION_SUMMARY),(0,d.uc)({uuid:e,basePrompt:n}))},j=function(e){return S(void 0,void 0,void 0,(function(){return p(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,l.Ay.post(c.n.CHATBOT.UPDATE_CONVERSATION_READING_STATUS(e),{})];case 1:return[2,n.sent().data];case 2:return n.sent(),[2,null];case 3:return[2]}}
1))}))},C=function(e,n){return void 0===n&&(n=!1),(0,o.q)({queryKey:[s.e.chats,e,n?"archived":"live","infinite"],queryFn:function(t){return S(void 0,[t],void 0,(function(t){var r,i=t.pageParam;return p(this,(function(t){switch(t.label){case 0:return r={page_size:25,includeArchivedConversations:n},i&&(r.cursor=i),[4,l.Ay.get(c.n.CHATBOT.CONVERSATION_CHATS(e),{params:r})];case 1:return[2,t.sent().data]}}))}))},initialPageParam:null,getNextPageParam:function(e){if(e.next)return new URL(e.next).searchParams.get("cursor")},getPreviousPageParam:function(e){if(e.previous)return new URL(e.previous).searchParams.get("cursor")},enabled:!!e,staleTime:0,refetchOnWindowFocus:!1})}},982:function(e,n,t){t.d(n,{HY:function(){return Oe},qx:function(){return ke},Ay:function(){return Ue}});var r=t(78685),i=t(2057),o=t(45602),a=t(16472),l=t(45666),s=t(38544);var c=t(19124),d=t(8081),u=t(21762),h=t(81e3),S=t(14160),p=t(97749),x=t(17e3),f=t(9752),_=t(81491),A=t(974),I=t(26165),m=t(16657),T=t(78166),v=function(e){var n=e.show,t=e.onCancel,i=e.onConfirm,o=(0,m.Bd)().t;return(0,r.jsxs)(T.lGe,{open:n,onClose:t,maxWidth:"xs",fullWidth:!0,children:[(0,r.jsx)(T.L33,{children:o("DISPLAY_STRINGS.CONFIRMATION_REQUIRED")}),(0,r.jsx)(T.Cff,{children:(0,r.jsx)(T.zTD,{children:o("DISPLAY_STRINGS.HUMAN_MODE_CONFIRMATION")})}),(0,r.jsxs)(T.iin,{children:[(0,r.jsx)(T.$nd,{color:"inherit",onClick:t,children:o("DISPLAY_LABELS.CLOSE_BUTTON")}),(0,r.jsx)(T.$nd,{color:"warning",variant:"contained",onClick:i,children:o("DISPLAY_STRINGS.CONFIRM")})]})]})},b=t(89543),g=function(e){var n=e.query,t=e.answer,o=e.chatbot_id,l=e.show,s=e.handleClose,c=(0,m.Bd)().t,d=(0,i.useState)(n),u=d[0],h=d[1],S=(0,i.useState)(t),x=S[0],f=S[1];(0,i.useEffect)((function(){l&&(h(n),f(t))}),[t,n,l]);var _=(0,p.n)({mutationFn:function(){return(0,a.wW)(o,u.trim(),x.trim())},onSuccess:s}),A=_.isPending,I=Boolean(u.trim()&&x.trim())&&!A;return(0,r.jsxs)(T.lGe,{open:l,onClose:A?void 0:s,fullWidth:!0,maxWidth:"sm","aria-labelledby":"train-better-response-title",children:[(0,r.jsxs)(T.L33,{id:"train-better-response-title",sx:{pr:7},children:[(0,r.jsx)(T.o5u,{component:"span",variant:"h6",fontWeight:600,children:c("DISPLAY_LABELS.TRAIN_BETTER_RESPONSE_TITLE")}),(0,r.jsx)(T.K0,{"aria-label":c("DISPLAY_LABELS.CLOSE_BUTTON"),onClick:s,disabled:A,sx:{position:"absolute",top:12,right:12},children:(0,r.jsx)(b.A,{})})]}),(0,r.jsx)(T.Cff,{dividers:!0,children:(0,r.jsxs)(T.BJc,{spacing:2.5,sx:{pt:.5},children:[(0,r.jsx)(T.A_L,{id:"train-response-user-query",label:c("DISPLAY_LABELS.USER_QUERY"),value:u,onChange:function(e){return h(e.target.value)},multiline:!0,minRows:3,fullWidth:!0,disabled:A}),(0,r.jsx)(T.A_L,{id:"train-response-agent-answer",label:c("DISPLAY_LABELS.AI_AGENT_RESPONSE"),value:x,onChange:function(e){return f(e.target.value)},multiline:!0,minRows:5,fullWidth:!0,disabled:A}),_.isError&&(0,r.jsx)(T.azJ,{role:"alert",children:(0,r.jsx)(T.o5u,{variant:"body2",color:"error.main",children:_.error.message||c("DISPLAY_STRINGS.FAILED_TO_TRAIN_CHATBOT_QA")})})]})}),(0,r.jsxs)(T.iin,{sx:{px:3,py:2},children:[(0,r.jsx)(T.$nd,{onClick:s,disabled:A,color:"inherit",children:c("DISPLAY_LABELS.CLOSE_BUTTON")}),(0,r.jsx)(T.$nd,{variant:"contained",disabled:!I,onClick:function(){return _.mutate()},children:c("DISPLAY_LABELS.TRAIN_RESPONSE")})]})]})},E=function(e){var n=e.show,t=e.onCancel,i=e.onConfirm,o=(0,m.Bd)().t;return(0,r.jsxs)(T.lGe,{open:n,onClose:t,maxWidth:"xs",fullWidth:!0,children:[(0,r.jsx)(T.L33,{children:o("DISPLAY_STRINGS.CONFIRMATION_REQUIRED")}),(0,r.jsx)(T.Cff,{children:(0,r.jsx)(T.zTD,{children:o("DISPLAY_STRINGS.DELETE_CONVERSATION_CONFIRMATION")})}),(0,r.jsxs)(T.iin,{children:[(0,r.jsx)(T.$nd,{color:"inherit",onClick:t,children:o("DISPLAY_LABELS.CLOSE_BUTTON")}),(0,r.jsx)(T.$nd,{color:"error",variant:"contained",onClick:i,children:o("DISPLAY_STRINGS.CONFIRM")})]})]})},y=t(73433),L=t(23770),N=t(91251),j=t(79108),C=t(10792),P=t(12081),D=t(88914);var R=function(e){var n=e.uuid,t=e.handleClose,o=(0,m.Bd)().t,l=(0,a.Jf)(n),s=l.data,c=l.isLoading,d=l.isFetching,u=l.refetch,h=(0,i.useState)(!1),S=h[0],p=h[1],x=c||d||S;return(0,r.jsxs)(T.lGe,{open:!!n,onClose:t,maxWidth:"md",fullWidth:!0,children:[(0,r.jsx)(T.L33,{children:o("DISPLAY_STRINGS.AI_SUMMARY_OF_CONVERSATION")}),(0,r.jsx)(T.Cff,{children:s&&!x?(0,r.jsxs)("div",{style:{width:"100%"},children:[(0,r.jsx)(T.o5u,{variant:"subtitle1",fontWeight:"bold",children:o("DISPLAY_LABELS.SUMMARY")}),(0,r.jsx)("div",{style:{width:"100%"},children:(0,r.jsx)("textarea",{readOnly:!0,style:{width:"100%",minHeight:"300px",fontFamily:"monospace",textAlign:"left",borderRadius:"5px",padding:"10px",resize:"none"},value:(null==s?void 0:s.summary)?null==s?void 0:s.summary.trim():o("DISPLAY_STRINGS.NO_SUMMARY_GENERATED")})}),(null==s?void 0:s.summaryGeneratedAt)&&(0,r.jsx)(T.o5u,{align:"right",variant:"subtitle2",className:"text-muted",children:null==s?void 0:s.summaryGeneratedAt})]}):(0,r.jsxs)("div",{children:[(0,r.jsx)(T.EAD,{variant:"text",width:"100%"}),(0,r.jsx)(T.EAD,{variant:"text",width:"100%"}),(0,r.jsx)(T.EAD,{variant:"text",width:"100%"}),(0,r.jsx)(T.EAD,{variant:"text",width:"100%"}),(0,r.jsx)(T.EAD,{variant:"text",width:"100%"})]})}),(0,r.jsxs)(T.iin,{children:[(0,r.jsxs)(T.$nd,{disabled:x,variant:"contained",onClick:function(){s.baseMessage&&n&&(p(!0),(0,a.pf)(n,s.baseMessage).then((function(){u(),p(!1)})).catch((function(){p(!1),console.error(o("DISPLAY_STRINGS.ERROR_GENERATING_SUMMARY"))})))},children:[S&&(0,r.jsx)(T.PaH,{size:"14px",sx:{marginRight:"10px"}}),o("DISPLAY_STRINGS.GENERATE")]}
1),(0,r.jsx)(T.$nd,{onClick:t,children:o("DISPLAY_LABELS.CLOSE_BUTTON")})]})]})},O=t(56581);var w=function(e){var n=e.leadData,t=e.onClose,i=e.isOpen,o=(0,m.Bd)().t;return(0,r.jsx)(T._s,{anchor:"right",open:i,onClose:t,hideBackdrop:!0,sx:{"& .MuiDrawer-paper":{p:2.5,width:{xs:"100%",sm:D.TZ}}},children:(0,r.jsxs)(T.azJ,{children:[(0,r.jsxs)(T.azJ,{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2,children:[(0,r.jsx)(T.azJ,{children:(0,r.jsx)(T.o5u,{variant:"h5",fontWeight:600,children:o("DISPLAY_STRINGS.LEAD_DATA")})}),(0,r.jsx)(T.azJ,{children:(0,r.jsx)(T.K0,{onClick:t,size:"small","aria-label":o("DISPLAY_LABELS.CLOSE_BUTTON"),children:(0,r.jsx)(b.A,{fontSize:"small"})})})]}),(0,r.jsx)(T.K3K,{sx:{maxHeight:"calc(100dvh - 100px)"},children:(0,r.jsxs)(T.XIK,{stickyHeader:!0,size:"small",children:[(0,r.jsx)(T.ndF,{children:(0,r.jsxs)(T.Hjg,{children:[(0,r.jsx)(T.nA6,{children:o("DISPLAY_STRINGS.KEY")}),(0,r.jsx)(T.nA6,{children:o("DISPLAY_STRINGS.VALUE")})]})}),(0,r.jsx)(T.BFY,{children:n&&Object.entries(n).map((function(e){var n=e[0],t=e[1];return(0,r.jsxs)(T.Hjg,{children:[(0,r.jsx)(T.nA6,{component:"th",scope:"row",children:(0,r.jsx)(T.o5u,{variant:"body2",fontWeight:600,children:n})}),(0,r.jsx)(T.nA6,{sx:{maxWidth:260,overflowWrap:"anywhere"},children:(0,r.jsx)(O.yk,{value:t,maxChars:28})})]},n)}))})]})})]})})},G=t(39675),Y=t(98777),B=t(56137),M=function(e){var n=e.dataSourceInfo,t=e.chatId,o=(0,m.Bd)().t,a=(0,i.useState)(null),l=a[0],s=a[1],c=n.split("\n").map((function(e){return e.trim()})).filter(Boolean);if(!c.length)return null;return(0,r.jsxs)(T.azJ,{children:[(0,r.jsx)(T.$nd,{size:"small",variant:"text",startIcon:l?(0,r.jsx)(Y.A,{}):(0,r.jsx)(B.A,{}),onClick:function(e){return s(e.currentTarget)},"aria-controls":l?"data-sources-".concat(t):void 0,children:o("DISPLAY_STRINGS.SHOW_ANSWER_SOURCES")}),(0,r.jsx)(T.AMh,{id:"data-sources-".concat(t),open:Boolean(l),anchorEl:l,onClose:function(){return s(null)},anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"bottom",horizontal:"left"},children:(0,r.jsx)(T.B8B,{dense:!0,sx:{width:{xs:280,sm:420},maxWidth:"90vw",p:1},children:c.map((function(e,n){return(0,r.jsxs)(T.ckQ,{sx:{alignItems:"flex-start",gap:1},children:[(0,r.jsx)(T.o5u,{component:"span",color:"text.secondary",children:"•"}),(0,r.jsx)(T.o5u,{variant:"body2",color:"text.secondary",sx:{overflowWrap:"anywhere"},children:(o=e,o.split(/(https?:\/\/[^\s]+)/g).map((function(e,n){return/^https?:\/\//.test(e)?(0,r.jsx)(T.N_E,{href:e,target:"_blank",rel:"noopener noreferrer",children:e},"".concat(e,"-").concat(n)):(0,r.jsx)(i.Fragment,{children:e},"".concat(e,"-").concat(n))})))})]},"".concat(t,"-").concat(n));var o}))})})]})},k=function(){return k=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var i in n=arguments[t])Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i]);return e},k.apply(this,arguments)},U=function(e,n,t,r){return new(t||(t=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function l(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){var n;e.done?i(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(a,l)}s((r=r.apply(e,n||[])).next())}))},z=function(e,n){var t,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=l(0),a.throw=l(1),a.return=l(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function l(l){return function(s){return function(l){if(t)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(o=0)),o;)try{if(t=1,r&&(i=2&l[0]?r.return:l[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,l[1])).done)return i;switch(r=0,i&&(l=[2&l[0],i.value]),l[0]){case 0:case 1:i=l;break;case 4:return o.label++,{value:l[1],done:!1};case 5:o.label++,r=l[1],l=[0];continue;case 7:l=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==l[0]&&2!==l[0])){o=0;continue}if(3===l[0]&&(!i||l[1]>i[0]&&l[1]<i[3])){o.label=l[1];break}if(6===l[0]&&o.label<i[1]){o.label=i[1],i=l;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(l);break}i[2]&&o.ops.pop(),o.trys.pop();continue}l=n.call(e,o)}catch(e){l=[6,e],r=0}finally{t=i=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,s])}}},W=function(e,n,t){if(t||2===arguments.length)for(var r,i=0,o=n.length;i<o;i++)!r&&i in n||(r||(r=Array.prototype.slice.call(n,0,i)),r[i]=n[i]);return e.concat(r||Array.prototype.slice.call(n))},H={query:"",answer:""},F=(0,T.I4L)(T.m_M)((function(e){return{tooltip:{backgroundColor:e.theme.palette.common.black,color:"white",fontSize:"0.875rem",borderRadius:"4px"}}})),K=(0,T.I4L)(T.fPr)((function(e){e.theme;return{transition:"width 0.5s ease"}})),J={xs:"90%",md:"68%",lg:"60%"},V={display:"inline-block",px:1.5,py:1,borderRadius:1.25,fontSize:"0.875rem",lineHeight:1.5,maxWidth:"100%",wordBreak:"break-word","& > *":{mt:0,mb:0},"& > * + *":{mt:.75},"& ol, & ul":{pl:2.5,mb:0},"& li + li":{mt:.25}},q=(0,T.I4L)(T.azJ)((function(e){var n=e.theme;return{display:"flex",flexDirection:"column",alignItems:"center",padding:"8px",borderRadius:"8px",background:n.palette.background.paper,border:"1px solid ".concat(n.palette.divider)}})),Q=function(e){var n,t,o,b,O,Y,B,Q,$=e.id,X=e.includeArchivedConversations,Z=(e.notificationSoundUrl,e.setNotificationSoundUrl),ee=e.setSelectedConversation,ne=e.onConversationMarkedAsRead,te=e.hasUnreadMessage,re=e.shouldMarkAsRead,ie=e.onBack,oe=e.chatbotName,ae=(0,m.Bd)().t,le=(0,x.Zp)(),se=(0,i.useState)(""),ce=se[0],de=se[1],ue=(0,i.useState)(null),he=ue[0],Se=ue[1],pe=(0,i.useState)(!0),xe=pe[0],fe=pe[1],_e=(0,i.useState)(null),Ae=_e[0],Ie=_e[1],me=(0,i.useState)(!1),Te=me[0],ve=me[1],be=(0,i.useState)(H),ge=be[0],Ee=be[1],ye=(0,i.useState)(null),Le=ye[0],Ne=ye[1],je=(0,i.useState)(null),Ce=je[0],Pe=je[1],De=(0,i.useState)([]),Re=De[0],we=De[1],Ge=(0,i.useState)(new Map),Ye=Ge[0],Be=Ge[1],Me=(0,i.useState)(null),ke=Me[0],Ue=Me[1],ze=(0,i.useState)(!1),We=ze[0],He=ze[1],Fe=(0,i.useState)(!1),Ke=Fe[0],Je=Fe[1],Ve=(0,i.useState)(!1),qe=Ve[0],Qe=Ve[1],$e=(0,i.useState)(!1),Xe=$e[0],Ze=$e[1],en=(0,i.useState)(!0),nn=en[0],tn=en[1],rn=(0,i.useState)(null),on=rn[0],an=rn[1],ln=(0,i.useState)(!1),sn=ln[0],cn=ln[1],dn=(0,i.useState)(!1),un=dn[0],hn=dn[1],Sn=(0,i.useState)(!1),pn=Sn[0],xn=Sn[1],fn=(0,i.useState)(!1),_n=fn[0],An=fn[1],In=(0,i.useState)(null),mn=In[0],Tn=In[1],vn=(0,i.useState)(null),bn=vn[0],gn=vn[1],En=(0,i.useState)(!1),yn=En[0],Ln=En[1],Nn=(0,i.useState)(null),jn=Nn[0],Cn=Nn[1],Pn=(0,i.useRef)(null),Dn=(0,i.useRef)(null),Rn=(0,i.useRef)(null),On=(0,i.useRef)(null),wn=(0,i.useRef)(null),Gn=(0,G.fL)(),Yn=Gn.theme,Bn=Gn.themeMode,Mn="dark"===Bn?"#444":"#ddd",kn="dark"===Bn?"#333":Yn.palette.primary.light,Un="dark"===Bn?"#fff":"#333",zn=(0,a.qx)($,X),Wn=zn.data,Hn=zn.isLoading,Fn=zn.isFetching,Kn=zn.isError,Jn=zn.error,Vn=zn.refetch,qn=(0,i.useState)(!1),Qn=qn[0],$n=qn[1],Xn=(0,i.useState)(!1),Zn=Xn[0],et=Xn[1],nt=(0,a.hg)($,X),tt=nt.data,rt=nt.fetchNextPage,it=nt.hasNextPage,ot=nt.isFetchingNextPage,at=nt.isLoading,lt=nt.refetch,st=(0,i.useMemo)((function(){return(null==tt?void 0:tt.pages)?tt.pages.reduce((function(e,n){return W(W([],e,!0),n.results,!0)}),[]):[]}),[tt]),ct=(0,i.useMemo)((function(){return st.reduce((function(e,n){return e+(n.query?1:0)}),0)}),[st]),dt=ct>=2,ut=(0,h.J)().userDetails,ht=null!==(t=null===(n=null==ut?void 0:ut.permissions)||void 0===n?void 0:n.includes(S.Qp.CAN_VIEW_OBSERVABILITY.value))&&void 0!==t&&t;(0,i.useEffect)((function(){$n(!1),Cn(null),Be(new Map),wn.current=null}),[$]),(0,i.useEffect)((function(){Z((null==Wn?void 0:Wn.notification_sound)||null)}),[null==Wn?void 0:Wn.notification_sound]);var St=Wn||{chatbot_uuid:"",is_human_handed_off:!1,user_key:"",source_platform:""},pt=St.chatbot_uuid,xt=St.user_key,ft=St.source_platform,_t=(0,i.useMemo)((function(){return null==Wn?void 0:Wn.id}),[null==Wn?void 0:Wn.id]),At=function(e){var n;if(e&&"object"==typeof e){console.log("Socket Response: ",e);var t=e.answer,r=e.from,i=e.chat_id,o=e.is_conversation_ended,a=e.conversation,l=e.is_human_handed_off,s=e.files,d=null!==(n=null==a?void 0:a.id)&&void 0!==n?n:_t;if(_t&&d===_t){if(void 0!==o&&!0===o)return Ce&&(Ce.disconnect(),Pe(null)),void Vn();if("boolean"==typeof l&&Ze(l),t||(null==s?void 0:s.length)){var u=r===P.i$.USER,h=(new Date).toISOString();if(u&&!i)return wn.current=t,void Be((function(e){var n=new Map(e);return n.set("pending_user",{query:t,timestamp:h}),n}));i&&Be((function(e){var n=new Map(e),o=n.get("pending_user"),a=n.get(i.toString())||{timestamp:h};if(u)a.query=t,a.files=(0,c.GD)(s),a.fromSource=P.i$.USER,n.delete("pending_user");else{var l=wn.current||(null==o?void 0:o.query);!a.query&&l&&(a.query=l,wn.current=null),n.delete("pending_user"),a.answer=t,a.fromSource=r||P.i$.CHATBOT}return n.set(i.toString(),a),n}))}}}};(0,i.useEffect)((function(){He(!1)}),[$]),(0,i.useEffect)((function(){if(pt&&xt&&ft){var e=new s.c(pt,xt,ft,At,!0,!0);return e.setIsStreamingEnabled(!0),e.connect(),tn(!0),Pe((function(n){return null==n||n.disconnect(),e})),function(){e.disconnect()}}}),[pt,xt,ft]);var It=function(e){if(!e)return{__html:""};var n=l.xI.parse(e,{async:!1}),t=document.createElement("div");t.innerHTML=n;var r=t.querySelectorAll("code");return r&&r.forEach((function(e){var n,t=document.createElement("div");
1if(t.className="code-container",e.parentNode){var r=document.createElement("pre");t.appendChild(r),null===(n=null==e?void 0:e.parentNode)||void 0===n||n.insertBefore(t,e),r.appendChild(e)}})),{__html:t.innerHTML}},mt=(0,i.useCallback)((function(){if(Pn.current){var e=Pn.current,n=e.scrollTop,t=e.scrollHeight-n-e.clientHeight,r=t<=100;Ln(t>80),r&&it&&!ot&&rt()}}),[it,ot,rt]);(0,i.useEffect)((function(){var e=window.requestAnimationFrame(mt);return function(){return window.cancelAnimationFrame(e)}}),[Re,mt]);var Tt=null!=jn?jn:null==Wn?void 0:Wn.last_read_chat_id,vt=(0,i.useMemo)((function(){var e="";return st.map((function(n){return e=n.query||e,{id:n.id.toString(),chatId:n.id,query:(0,d.Zd)(n.query,n.files.length>0),answer:(0,d.Zd)(n.answer,n.files.length>0),recentQuery:e,createdAt:n.created_at,files:(0,c.GD)(n.files),fileSender:n.from_source===P.i$.SUPPORT_PERSON?"agent":"user",dataSourceInfo:n.data_source_info,messageSourceDisplay:n.message_source_display,isLastReadChat:null!=Tt&&n.id===Tt,isRealtime:!1}}))}),[st,Tt]);(0,i.useEffect)((function(){var e=new Set(vt.map((function(e){return e.id}))),n=Array.from(Ye.entries()).filter((function(n){var t=n[0];return!e.has(t)})).map((function(e){var n,t=e[0],r=e[1],i=Number(t);return{id:"realtime-".concat(t),chatId:Number.isNaN(i)?void 0:i,query:(0,d.Zd)(r.query,((null===(n=r.files)||void 0===n?void 0:n.length)||0)>0),answer:r.answer,recentQuery:r.query,createdAt:r.timestamp,files:r.files||[],fileSender:r.fromSource===P.i$.USER?"user":"agent",fromSource:r.fromSource,isLastReadChat:!Number.isNaN(i)&&i===Tt,isRealtime:!0}}));we(W(W([],vt,!0),n,!0))}),[vt,Ye,Tt]);var bt=function(){if(nn)return on&&clearTimeout(on),void an(null);var e=setTimeout(bt,100);an(e),Vn(),lt()},gt=(null==Wn?void 0:Wn.ai_agent_avatar_image)||null,Et="dark"===Bn?Yn.palette.grey[700]:Yn.palette.grey[400],yt=function(e){return!!e&&/replied by/i.test(e.split(":")[0])},Lt=function(e){return e.fromSource?e.fromSource===P.i$.CHATBOT:yt(e.messageSourceDisplay)},Nt=function(e){if(!e)return null;var n=e.indexOf(":"),t=-1===n?e.trim():e.slice(n+1).trim();return-1!==n&&/replied by/i.test(e.slice(0,n))?(null==oe?void 0:oe.trim())||t||null:t||null},jt=Re.map((function(e){return e.messageSourceDisplay})).filter((function(e){return e&&!yt(e)})).map((function(e){return Nt(e)})).find(Boolean)||ae("DISPLAY_STRINGS.SUPPORT_PERSON"),Ct=function(e){return e.fromSource===P.i$.SUPPORT_PERSON?jt:e.fromSource===P.i$.CHATBOT?(null==oe?void 0:oe.trim())||null:Nt(e.messageSourceDisplay)},Pt=function(e,n){return(0,r.jsx)(T.o5u,{component:"small",variant:"caption",sx:{display:"block",mt:.5,fontSize:"0.6875rem",lineHeight:1.4,color:"text.secondary",cursor:"pointer",textAlign:n},onClick:function(){return et((function(e){return!e}))},children:Zn?(0,c.y3)(e):(0,c.r6)(e)})},Dt=Wn?"".concat(Wn.username).concat(Wn.is_visitor?"#".concat(Wn.conversation_number):""):"",Rt=function(e,n,t){return void 0===n&&(n=!1),gt?(0,r.jsx)(T.euF,{src:e,"aria-hidden":!0,sx:{width:28,height:28,flexShrink:0,ml:n?0:.75,mr:n?.75:0,mt:.25,bgcolor:Et,color:Yn.palette.getContrastText(Et),border:"1px solid ".concat(Yn.palette.divider),fontSize:"0.75rem",textTransform:"uppercase"},children:t}):null},Ot=function(){if((ce.trim()||(null==he?void 0:he.length))&&Ce){var e=Ce.query(ce,he,Xe);if(tn(e),!e&&!on){var n=setTimeout(bt,100);an(n)}var t="temp-".concat(Date.now()),r=(new Date).toISOString();Be((function(e){var n=new Map(e);return n.set(t,{answer:ce,timestamp:r,files:he||[],fromSource:P.i$.SUPPORT_PERSON}),n})),de(""),Se(null)}};(0,i.useLayoutEffect)((function(){Pn.current&&0!==st.length&&(Qn?setTimeout((function(){Pn.current&&(Pn.current.scrollTop=Pn.current.scrollHeight)}),100):On.current?On.current.scrollIntoView({behavior:"smooth",block:"center"}):setTimeout((function(){Pn.current&&(Pn.current.scrollTop=Pn.current.scrollHeight)}),100))}),[st,Qn]),(0,i.useEffect)((function(){Ze((null==Wn?void 0:Wn.is_human_handed_off)||!1)}),[Wn]),(0,i.useEffect)((function(){if(0!==Ye.size){var e=setTimeout((function(){Pn.current&&(Pn.current.scrollTop=Pn.current.scrollHeight)}),100);return function(){return clearTimeout(e)}}}),[Ye]);(0,i.useEffect)((function(){de(""),Se(null),fe(!0),Ee(H),Ne(null),ve(!1),we([]),Be(new Map),Ue(null),He(!1),Je(!1),Qe(!1),tn(!0),an(null),cn(!1),hn(!1),xn(!1),An(!1),$n(!1)}),[$]);var wt=(0,p.n)({mutationFn:function(e){return(0,a.mm)(e)},onSuccess:function(e,n){He(!0);var t=function(e){var n,t=Oe.findIndex((function(n){return n.id===e})),r=Oe.length-1,i=-1;return r<=0?(Oe.splice(t,1),-1):(i=t===r?Oe[r-1].id:(null===(n=Oe[t+1
1])||void 0===n?void 0:n.id)||-1,Oe.splice(t,1),i)}(n);ee(t)},onSettled:function(){return Je(!1)},onMutate:function(){return Je(!0)}}),Gt=(0,p.n)({mutationFn:function(e){return(0,a.xC)(e.conversationId,e.checked)},onSuccess:function(e){Qe(!1),Ze(e.is_human_handed_off)},onSettled:function(){return Qe(!1)},onMutate:function(){return Qe(!0)}}),Yt=Hn,Bt=function(){return U(void 0,void 0,void 0,(function(){return z(this,(function(e){switch(e.label){case 0:return!Wn||Wn.is_read&&!te||Qn?[3,2]:(null!=Wn.last_read_chat_id&&Cn(Wn.last_read_chat_id),[4,(0,a.nk)(Wn.id)]);case 1:null!==e.sent()&&($n(!0),null==ne||ne(Wn.id)),e.label=2;case 2:return[2]}}))}))};(0,i.useEffect)((function(){re&&!Fn&&Bt()}),[re,Fn,null==Wn?void 0:Wn.id,null==Wn?void 0:Wn.is_read,null==Wn?void 0:Wn.last_read_chat_id]);if(Yt||!Wn||We)return(0,r.jsx)(I.x0,{});if(Kn)return console.error("Error fetching conversations: ",Jn.message),(0,r.jsx)(I.x0,{});var Mt,kt=(!Wn.is_read||te)&&!Qn,Ut=(0,r.jsxs)(T._s,{anchor:"right",open:!xe,onClose:function(){return fe(!0)},sx:{"& .MuiDrawer-paper":{width:{xs:"100%",sm:D.TZ},overflow:"hidden",bgcolor:"background.default"}},children:[(0,r.jsxs)(T.BJc,{direction:"row",alignItems:"center",justifyContent:"space-between",sx:{px:2.5,py:1.75,borderBottom:1,borderColor:"divider",bgcolor:"background.paper",flexShrink:0},children:[(0,r.jsx)(T.o5u,{variant:"h6",fontWeight:600,children:ae("DISPLAY_STRINGS.VIEW_DETAILS")}),(0,r.jsx)(T.K0,{size:"small","aria-label":ae("DISPLAY_LABELS.CLOSE_BUTTON"),onClick:function(){return fe(!0)},children:(0,r.jsx)(y.bm,{})})]}),(0,r.jsx)(T.azJ,{sx:{overflowY:"auto",minHeight:0,p:2.5},children:(0,r.jsxs)(T.BJc,{spacing:2,children:[(0,r.jsx)(T.tu9,{variant:"outlined",sx:{p:2.5,borderRadius:2,boxShadow:"none"},children:(0,r.jsxs)(T.BJc,{alignItems:"center",spacing:1,children:[(0,r.jsx)(T.euF,{src:Wn.profile_pic||void 0,sx:{width:64,height:64,mb:.5,bgcolor:"primary.light",color:"primary.main",fontWeight:600},children:Wn.short_username}),(0,r.jsx)(T.o5u,{variant:"h6",fontWeight:600,sx:{textTransform:"capitalize"},children:Wn.username}),(0,r.jsx)(T.o5u,{variant:"body2",color:"text.secondary",children:(null===(o=null==Wn?void 0:Wn.user_info)||void 0===o?void 0:o.user_location)&&"None, None"!=Wn.user_info.user_location?Wn.user_info.user_location:ae("DISPLAY_STRINGS.UNKNOWN_LOCATION")}),(0,r.jsx)(T.o5u,{variant:"caption",color:"text.secondary",sx:{cursor:"pointer",px:1,py:.25,borderRadius:1,"&:hover":{bgcolor:"action.hover"}},onClick:function(){et((function(e){return!e}))},children:Zn?(0,c.y3)(Wn.created_at):(0,c.r6)(Wn.created_at)}),(0,r.jsxs)(T.BJc,{direction:"row",spacing:.75,useFlexGap:!0,flexWrap:"wrap",justifyContent:"center",sx:{pt:.5},children:[Wn.is_summary_sent?(0,r.jsx)(T.vu3,{size:"small",label:ae("DISPLAY_STRINGS.SUMMARY_SENT"),title:ae("DISPLAY_STRINGS.SUMMARY_SENT_TOOLTIP")}):null,Wn.is_deleted&&(0,r.jsx)(T.vu3,{size:"small",color:"warning",label:ae("DISPLAY_STRINGS.ENDED"),title:ae("DISPLAY_STRINGS.CONVERSATION_ENDED_TOOLTIP")}),Wn.source_platform&&(0,r.jsx)(T.vu3,{size:"small",color:"success",label:(0,c.wy)(Wn.source_platform),title:ae("DISPLAY_STRINGS.CONVERSATION_PLATFORM_TOOLTIP",{platform:Wn.source_platform})})]})]})}),(0,r.jsxs)(T.fPr,{container:!0,spacing:1.25,sx:{width:"100%"},children:[(0,r.jsxs)(T.fPr,{size:{lg:6,xs:12},children:[(0,r.jsx)(R,{uuid:Le,handleClose:function(){return Ne(null)}}),(0,r.jsxs)(T.$nd,{variant:"contained",fullWidth:!0,sx:{minHeight:40},onClick:function(){return Ne(Wn.uuid)},children:[(0,r.jsx)(y.B7,{sx:{mr:.75}}),ae("DISPLAY_STRINGS.AI_SUMMARY")]})]}),(0,r.jsx)(T.fPr,{size:{lg:6,xs:12},children:(0,r.jsxs)(T.$nd,{variant:"contained",fullWidth:!0,sx:{minHeight:40},onClick:function(){return Ue(null==Wn?void 0:Wn.lead_data)},children:[(0,r.jsx)(y.pr,{sx:{mr:.75}})," ",ae("DISPLAY_STRINGS.LEAD_DATA")]})}),ht&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(T.fPr,{size:{lg:6,xs:12},children:(0,r.jsx)(F,{title:dt?"":ae("DISPLAY_STRINGS.EVALUATE_MIN_MESSAGES_HELP"),children:(0,r.jsx)(T.azJ,{component:"span",sx:{display:"block"},children:(0,r.jsxs)(T.$nd,{variant:"outlined",fullWidth:!0,sx:{minHeight:40},disabled:!dt,onClick:function(){return ve(!0)},children:[(0,r.jsx)(y.iL,{sx:{mr:.75}})," ",ae("DISPLAY_STRINGS.EVALUATE")]})})})}),(0,r.jsx)(T.fPr,{size:{lg:6,xs:12},children:(0,r.jsxs)(T.$nd,{variant:"outlined",fullWidth:!0,sx:{minHeight:40},onClick:function(){return le("".concat((0,f.DL)("chatbot-observability",Wn.chatbot_id),"?tab=").concat(_.fg.TRACES)+"&conversation=".concat(Wn.id))},children:[(0,r.jsx)(y.Mm,{sx:{mr:.75}})," ",ae("DISPLAY_STRINGS.VIEW_TRACES")]})})]})]}
1),(0,r.jsx)(A.Gn,{open:Te,conversationUuid:Wn.uuid,chatbotId:Wn.chatbot_id,conversationId:$,onClose:function(){return ve(!1)}}),Wn.title&&(0,r.jsx)(T.azJ,{sx:{width:"100%"},children:(0,r.jsx)(T.WsE,{title:ae("DISPLAY_STRINGS.TITLE"),value:Wn.title,enableResponsiveTruncation:!0})}),(0,r.jsx)(T.azJ,{sx:{width:"100%"},children:(0,r.jsx)(T.WsE,{title:ae("DISPLAY_STRINGS.USER_KEY"),value:Wn.user_key,enableResponsiveTruncation:!0})}),(Wn.total_input_tokens>0||Wn.total_output_tokens>0)&&(0,r.jsx)(T.azJ,{sx:{width:"100%"},children:(0,r.jsxs)(T.tu9,{variant:"outlined",sx:{p:2,borderRadius:2,boxShadow:"none"},children:[(0,r.jsx)(T.azJ,{mb:1,display:"flex",justifyContent:"flex-start",children:(0,r.jsx)(T.o5u,{variant:"body1",color:"text.primary",children:ae("DISPLAY_STRINGS.SESSION_TOKEN_USAGE")})}),(0,r.jsxs)(T.fPr,{container:!0,spacing:2,children:[(0,r.jsx)(T.fPr,{size:6,children:(0,r.jsxs)(q,{children:[(0,r.jsx)(T.o5u,{variant:"caption",sx:{color:"text.secondary",fontWeight:500,marginBottom:.5},children:ae("DISPLAY_STRINGS.INPUT_TOKENS")}),(0,r.jsx)(T.o5u,{variant:"body2",sx:{fontWeight:700,color:"success.main"},children:(null===(b=Wn.total_input_tokens)||void 0===b?void 0:b.toLocaleString())||0})]})}),(0,r.jsx)(T.fPr,{size:6,children:(0,r.jsxs)(q,{children:[(0,r.jsx)(T.o5u,{variant:"caption",sx:{color:"text.secondary",fontWeight:500,marginBottom:.5},children:ae("DISPLAY_STRINGS.OUTPUT_TOKENS")}),(0,r.jsx)(T.o5u,{variant:"body2",sx:{fontWeight:700,color:"warning.main"},children:(null===(O=Wn.total_output_tokens)||void 0===O?void 0:O.toLocaleString())||0})]})})]})]})})]})},Wn.id)]}),zt=function(e){void 0===e&&(e=!1),e||Xe?(Gt.mutate({conversationId:Wn.id,checked:!Xe}),cn(!1)):cn(!0)};return(0,r.jsxs)(T.fPr,{container:!0,sx:{height:"100%",minHeight:0,overflow:"hidden"},children:[(0,r.jsx)(g,{show:pn,handleClose:function(){Ee(H),xn(!1)},query:ge.query,answer:ge.answer,chatbot_id:Wn.chatbot_id}),(0,r.jsx)(E,{show:un,onCancel:function(){return hn(!1)},onConfirm:function(){hn(!1),wt.mutate(Wn.id)}}),(0,r.jsx)(v,{show:sn,onCancel:function(){return cn(!1)},onConfirm:function(){return zt(!0)}}),(0,r.jsx)(T.deU,{open:!!mn,onClose:function(){return Tn(null)},file:null!==(Y=null==mn?void 0:mn.file)&&void 0!==Y?Y:null,mimeType:null==mn?void 0:mn.mimeType}),(0,r.jsx)(T.BbZ,{open:!!bn,onClose:function(){return gn(null)},src:null!==(B=null==bn?void 0:bn.src)&&void 0!==B?B:null,alt:null==bn?void 0:bn.alt}),(0,r.jsx)(K,{size:12,sx:{flexGrow:1,flexBasis:0,maxWidth:"100%",minWidth:0,minHeight:0,overflow:"hidden"},children:(0,r.jsxs)(T.azJ,{sx:{height:"100%",minHeight:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:[(0,r.jsxs)(T.BJc,{direction:"row",alignItems:"center",spacing:1.25,sx:{minHeight:60,px:2,py:1,borderBottom:1,borderColor:"divider"},children:[ie&&(0,r.jsx)(T.K0,{"aria-label":ae("DISPLAY_LABELS.BACK"),onClick:ie,children:(0,r.jsx)(y.v$,{})}),(0,r.jsx)(T.Exy,{overlap:"circular",variant:"dot",invisible:!Xe||Wn.is_deleted,anchorOrigin:{vertical:"bottom",horizontal:"right"},sx:{"& .MuiBadge-badge":{width:12,height:12,minWidth:12,borderRadius:"50%",bgcolor:kt?"warning.main":"success.main",border:2,borderColor:"background.paper"}},children:(0,r.jsx)(T.euF,{src:Wn.profile_pic||void 0,sx:{width:36,height:36,bgcolor:"primary.light",color:"primary.main"},children:Wn.short_username})}),(0,r.jsxs)(T.azJ,{sx:{minWidth:0},children:[(0,r.jsxs)(T.BJc,{direction:"row",alignItems:"center",children:[(0,r.jsx)(T.o5u,{variant:"subtitle2",noWrap:!0,sx:{textTransform:"capitalize"},children:Wn.username}),(0,r.jsx)(T.K0,{size:"small","aria-label":ae("DISPLAY_LABELS.REFRESH"),onClick:function(){return U(void 0,void 0,void 0,(function(){return z(this,(function(e){switch(e.label){case 0:return An(!0),[4,Promise.all([Vn(),lt()])];case 1:return e.sent(),An(!1),[2]}}))}))},disabled:_n,sx:{p:.25,ml:.25},children:(0,r.jsx)(y.C4,{sx:k({fontSize:18},_n?{animation:"inbox-spin 0.8s linear infinite","@keyframes inbox-spin":{to:{transform:"rotate(360deg)"}}}:{})})})]}),(0,r.jsx)(T.o5u,{variant:"caption",color:"text.secondary",noWrap:!0,children:(null===(Q=null==Wn?void 0:Wn.user_info)||void 0===Q?void 0:Q.user_location)&&"None, None"!=Wn.user_info.user_location?Wn.user_info.user_location:ae("DISPLAY_STRINGS.UNKNOWN_LOCATION")})]}),(0,r.jsx)(T.azJ,{sx:{flexGrow:1}}),(Mt=!!(null==Wn?void 0:Wn.is_deleted),(0,r.jsxs)(T.BJc,{direction:"row",alignItems:"center",spacing:.5,children:[(0,r.jsx)(T.o5u,{variant:"caption",color:Xe?"text.disabled":"text.primary",children:ae("DISPLAY_STRINGS.AI_AGENT")}),(0,r.jsx)(T.dOG,{size:"small",color:"warning",checked:Xe,disabled:qe||Mt,onChange:function(){return zt()},inputProps:{"aria-label":ae("DISPLAY_STRINGS.HUMAN_HANDOFF_TOOLTIP")}}),(0,r.jsx)(T.o5u,{variant:"caption",color:Xe?"warning.main":"text.disabled",children:ae("DISPLAY_STRINGS.HUMAN")}),(0,r.jsx)(F,{arrow:!0,placement:"top",title:ae("DISPLAY_STRINGS.HUMAN_HANDOFF_TOOLTIP"),children:(0,r.jsx)(y.R2,{fontSize:"small",color:Mt?"disabled":"warning"})})]})),(0,r.jsx)(F,{title:ae("DISPLAY_STRINGS.VIEW_DETAILS"),children:(0,r.jsx)(T.K0,{onClick:function(){return fe(!1)},children:(0,r.jsx)(y.JL,{})})}),(0,r.jsx)(T.K0,{"aria-label":ae("DISPLAY_LABELS.MORE_ACTIONS"),onClick:function(e){return Ie(e.currentTarget)},children:(0,r.jsx)(j.A,{})}),(0,r.jsxs)(T.W1t,{anchorEl:Ae,open:Boolean(Ae),onClose:function(){return Ie(null)},children:[(0,r.jsxs)(T.Drp,{onClick:function(e){(0,c.lW)(e.currentTarget,"conversationUUID_".concat(Wn.uuid)),Ie(null)},children:[(0,r.jsx)(y.PM,{fontSize:"small",sx:{mr:1}}),ae("DISPLAY_STRINGS.COPY_UUID")]}),(0,r.jsxs)(T.Drp,{onClick:function(e){(0,c.lW)(e.currentTarget,"chatbotPublicConversationLink_".concat(Wn.id)),Ie(null)},children:[(0,r.jsx)(y.PM,{fontSize:"small",sx:{mr:1}}),ae("DISPLAY_STRINGS.COPY_SHARE_LINK")]}),(0,r.jsxs)(T.Drp,{onClick:function(e){(0,c.lW)(e.currentTarget,"conversationUUID_".concat(Wn.user_key)),Ie(null)},children:[(0,r.jsx)(y.PM,{fontSize:"small",sx:{mr:1}}),ae("DISPLAY_STRINGS.COPY_USER_KEY")]}),(0,r.jsx)(T.cGx,{}),(0,r.jsxs)(T.Drp,{disabled:Ke,onClick:function(){Ie(null),hn(!0)}
1,sx:{color:"error.main"},children:[(0,r.jsx)(y.Og,{fontSize:"small",sx:{mr:1}}),ae("DISPLAY_STRINGS.DELETE")]})]}),(0,r.jsx)(T.azJ,{component:"pre",id:"conversationUUID_".concat(Wn.uuid),sx:{display:"none"},children:Wn.uuid}),(0,r.jsx)(T.azJ,{component:"pre",id:"chatbotPublicConversationLink_".concat(Wn.id),sx:{display:"none"},children:"".concat(window.location.hostname).concat(u.n.CHATBOT.CONVERSATION_DETAILS_PUBLIC(Wn.chatbot_id,Wn.uuid))}),(0,r.jsx)(T.azJ,{component:"pre",id:"conversationUUID_".concat(Wn.user_key),sx:{display:"none"},children:Wn.user_key})]}),(0,r.jsxs)(T.azJ,{sx:{position:"relative",display:"flex",flexGrow:1,height:0,minHeight:0,overflow:"hidden"},children:[(0,r.jsxs)(T.azJ,{sx:{flex:1,height:"100%",minHeight:0,overflowY:"auto",overscrollBehavior:"contain",px:2,pt:2,pb:4,bgcolor:"background.default"},ref:Pn,onClick:function(){Bt()},onScroll:mt,children:[0!==Re.length||0!==Ye.size||at?Re.map((function(e){return(0,r.jsxs)(i.Fragment,{children:[e.isLastReadChat&&(!(null==Wn?void 0:Wn.is_read)||te||null!=jn)&&(0,r.jsxs)(T.azJ,{sx:{display:"flex",alignItems:"center",my:2,mx:1},children:[(0,r.jsx)(T.cGx,{sx:{flexGrow:1,borderColor:"primary.main",borderWidth:"1px"}}),(0,r.jsx)(T.o5u,{variant:"caption",sx:{mx:2,px:2,py:.5,backgroundColor:"primary.main",color:"primary.contrastText",borderRadius:"12px",fontWeight:"bold",textTransform:"uppercase"},children:ae("DISPLAY_STRINGS.NEW_MESSAGES")}),(0,r.jsx)(T.cGx,{sx:{flexGrow:1,borderColor:"primary.main",borderWidth:"1px"}})]}),(0,r.jsxs)(T.azJ,{ref:e.isLastReadChat?On:null,sx:{position:"relative",mb:2,animation:e.isLastReadChat?"fadeIn 0.3s ease-in-out":"none","@keyframes fadeIn":{from:{opacity:.7},to:{opacity:1}}},children:[(e.query||!!e.files.length&&"user"===e.fileSender)&&(0,r.jsxs)(T.azJ,{sx:{display:"flex",alignItems:"flex-start",justifyContent:"flex-start"},children:[Rt((null==Wn?void 0:Wn.profile_pic)||(null==Wn?void 0:Wn.user_avatar_image),!0,null==Wn?void 0:Wn.short_username),(0,r.jsxs)(T.azJ,{sx:{display:"flex",flexDirection:"column",alignItems:"flex-start",maxWidth:J},children:[Dt&&(0,r.jsx)(T.o5u,{variant:"caption",sx:{mb:.25,px:.5,color:"text.secondary",fontWeight:700,textTransform:"capitalize"},children:Dt}),!!e.files.length&&"user"===e.fileSender&&(0,r.jsx)(T.azJ,{sx:{mb:e.query?1:0},children:(0,r.jsx)(T.hcB,{files:e.files,themeContext:G.fL,readOnly:!0,align:"left",subtleImageBackground:!0,onImageClick:function(e,n){return gn({src:e,alt:null!=n?n:""})},onFilePreview:function(e,n){return Tn({file:e,mimeType:n})}})}),e.query&&(0,r.jsx)(T.azJ,{component:"span",sx:V,style:{backgroundColor:kn,color:Un},children:e.query}),Pt(e.createdAt,"left")]})]}),(e.answer||!!e.files.length&&"agent"===e.fileSender)&&(0,r.jsxs)(T.azJ,{sx:{display:"flex",alignItems:"flex-start",justifyContent:"flex-end"},children:[(0,r.jsx)(T.azJ,{sx:{maxWidth:J},children:(0,r.jsx)(T.azJ,{sx:{display:"flex",justifyContent:"flex-end"},children:(0,r.jsxs)(T.azJ,{sx:{display:"inline-flex",flexDirection:"column",alignItems:"flex-end",maxWidth:"100%"},children:[!!e.files.length&&"agent"===e.fileSender&&(0,r.jsx)(T.azJ,{sx:{mb:e.answer?1:0},children:(0,r.jsx)(T.hcB,{files:e.files,themeContext:G.fL,readOnly:!0,align:"right",subtleImageBackground:!0,onImageClick:function(e,n){return gn({src:e,alt:null!=n?n:""})},onFilePreview:function(e,n){return Tn({file:e,mimeType:n})}})}),Ct(e)&&(0,r.jsx)(T.o5u,{variant:"caption",sx:{mb:.25,px:.5,color:"text.secondary",fontWeight:700},children:Ct(e)}),(0,r.jsxs)(T.azJ,{sx:{display:"flex",alignItems:"flex-end",justifyContent:"flex-end",gap:.5,maxWidth:"100%"},children:[Lt(e)&&(0,r.jsx)(F,{title:ae("DISPLAY_STRINGS.TRAIN_BETTER_RESPONSE"),placement:"left",arrow:!0,children:(0,r.jsx)(T.K0,{size:"small","aria-label":ae("DISPLAY_STRINGS.TRAIN_BETTER_RESPONSE"),onClick:function(){return n=e.recentQuery||e.query||"",t=e.answer||"",Ee({query:n,answer:t}),void xn(!0);var n,t},sx:{p:.25,mb:.25,flexShrink:0,color:"text.secondary","&:hover":{color:"primary.main"}},children:(0,r.jsx)(L.A,{fontSize:"small"})})}),e.answer&&(0,r.jsx)(T.azJ,{component:"span",sx:k(k({},V),{"& p":{whiteSpace:"break-spaces"}}),style:{backgroundColor:Mn,color:Un},dangerouslySetInnerHTML:It(e.answer)})]}),Pt(e.createdAt,"right"),!e.isRealtime&&e.dataSourceInfo&&e.chatId&&(0,r.jsx)(T.azJ,{sx:{mt:.5,typography:"caption"},children:(0,r.jsx)(M,{dataSourceInfo:e.dataSourceInfo,chatId:e.chatId})})]})})}),Rt(null==Wn?void 0:Wn.ai_agent_avatar_image,!1)]})]})]},e.id)})):(0,r.jsx)(T.azJ,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"},children:(0,r.jsx)(T.o5u,{variant:"body2",color:"text.secondary",children:ae("DISPLAY_STRINGS.NO_CHATS_FOUND")})}),ot&&(0,r.jsx)(T.azJ,{sx:{display:"flex",justifyContent:"center",alignItems:"center",py:2,borderTop:"1px solid #eee",mt:2},children:(0,r.jsx)(T.o5u,{variant:"body2",color:"text.secondary",children:ae("DISPLAY_STRINGS.LOADING_OLDER_MESSAGES")||"Loading older messages..."})})]},Wn.id),yn&&(0,r.jsx)(F,{title:ae("DISPLAY_STRINGS.SCROLL_TO_BOTTOM"),arrow:!0,children:(0,r.jsx)(T.K0,{"aria-label":ae("DISPLAY_STRINGS.SCROLL_TO_BOTTOM"),onClick:function(){var e;null===(e=Pn.current)||void 0===e||e.scrollTo({top:Pn.current.scrollHeight,behavior:"smooth"}),Ln(!1)},size:"small",sx:{position:"absolute",bottom:16,left:"50%",transform:"translateX(-50%)",zIndex:function(e){return e.zIndex.fab},bgcolor:"primary.main",color:"primary.contrastText",boxShadow:3,"&:hover":{bgcolor:"primary.dark"}},children:(0,r.jsx)(y.OX,{})})})]}),Wn.is_deleted&&(0,r.jsx)(T.azJ,{sx:{display:"flex",justifyContent:"center",p:1.5,borderTop:1,borderColor:"divider",bgcolor:"background.paper"},children:(0,r.jsx)(T.vu3,{size:"small",variant:"outlined",color:"warning",label:ae("DISPLAY_STRINGS.CONVERSATION_ENDED")})}),Xe&&!Wn.is_deleted&&(0,r.jsxs)(T.azJ,{sx:{p:1.5,borderTop:1,borderColor:"divider",bgcolor:"background.paper"},children:[(0,r.jsx)("input",{ref:Rn,type:"file",multiple:!0,hidden:!0,accept:".pdf,.csv,.txt,.doc,.docx,image/jpg,image/png,image/jpeg,image/gif,image/webp",onChange:function(e){var n=Array.from(e.target.files||[]),t=he||[],r=5-t.length;n.length>
1r&&(0,c.Sx)("",ae("DISPLAY_STRINGS.MAX_FILES_EXCEEDED",{max:5,uploaded:t.length+n.length}),"warning"),Se(W(W([],t,!0),n.slice(0,Math.max(r,0)),!0)),e.target.value=""}}),!!(null==he?void 0:he.length)&&(0,r.jsx)(T.tu9,{variant:"outlined",sx:{width:"100%",maxWidth:780,mx:"auto",mb:1,p:1,bgcolor:"action.hover"},children:(0,r.jsx)(T.hcB,{files:he,setFiles:Se,themeContext:G.fL,align:"left",ignoreSpacing:!0,inline:!0,subtleImageBackground:!0})}),(0,r.jsxs)(T.BJc,{direction:"row",alignItems:"flex-end",spacing:1,sx:{width:"100%",maxWidth:780,mx:"auto"},children:[(0,r.jsx)(F,{title:ae("DISPLAY_LABELS.UPLOAD_FILES"),children:(0,r.jsx)(T.K0,{size:"small","aria-label":ae("DISPLAY_LABELS.UPLOAD_FILES"),onClick:function(){var e;return null===(e=Rn.current)||void 0===e?void 0:e.click()},disabled:((null==he?void 0:he.length)||0)>=5,sx:{width:40,height:40,flexShrink:0},children:(0,r.jsx)(N.A,{fontSize:"small"})})}),(0,r.jsx)(T.A_L,{fullWidth:!0,multiline:!0,rows:1,inputRef:Dn,placeholder:ae("DISPLAY_STRINGS.TYPE_HERE_PLACEHOLDER"),value:ce,onChange:function(e){Bt(),de(e.target.value)},onKeyDown:function(e){"Enter"!==e.key||e.shiftKey||(e.preventDefault(),Ot())},size:"small",sx:{"& .MuiOutlinedInput-root":{height:40,borderRadius:1.5,bgcolor:"background.default"},"& textarea":{overflowY:"auto !important"}}}),(0,r.jsx)(T.K0,{color:"primary","aria-label":ae("DISPLAY_STRINGS.SEND_MESSAGE"),onClick:Ot,disabled:!ce.trim()&&!(null==he?void 0:he.length),sx:{width:40,height:40,flexShrink:0,borderRadius:1.5,bgcolor:"primary.main",color:"primary.contrastText","&:hover":{bgcolor:"primary.dark"},"&.Mui-disabled":{bgcolor:"action.disabledBackground",color:"action.disabled"}},children:(0,r.jsx)(C.A,{fontSize:"small"})})]})]})]})}),Ut,(0,r.jsx)(w,{leadData:ke,onClose:function(){return Ue(null)},isOpen:!!ke})]},$)},$=t(41099),X=function(){return X=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var i in n=arguments[t])Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i]);return e},X.apply(this,arguments)},Z=function(e){return e?e.toISOString().split("T")[0]:""},ee=function(e){var n=e.filters,t=e.handleFilter,o=(0,m.Bd)().t,a=(0,i.useState)(null),l=a[0],s=a[1],c=(0,i.useState)(D.q9),d=c[0],u=c[1],h=(0,D.df)();return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(T.m_M,{title:o("DISPLAY_STRINGS.FILTER"),children:(0,r.jsx)(T.K0,{size:"small",color:"primary","aria-label":o("DISPLAY_STRINGS.FILTER"),sx:{width:32,height:32},onClick:function(e){u(n),s(e.currentTarget)},children:(0,r.jsx)($.A,{fontSize:"small"})})}),(0,r.jsx)(T.AMh,{open:Boolean(l),anchorEl:l,onClose:function(){return s(null)},anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},children:(0,r.jsxs)(T.BJc,{spacing:2,sx:{width:300,p:2,"& .MuiInputBase-input, & .MuiInputLabel-root":{fontSize:"0.875rem"}},children:[(0,r.jsx)(T.A_L,{size:"small",type:"date",label:o("DISPLAY_STRINGS.START_DATE"),value:Z(d.startDate),onChange:function(e){return u((function(n){return X(X({},n),{startDate:e.target.value?new Date(e.target.value):null})}))},slotProps:{inputLabel:{shrink:!0}}}),(0,r.jsx)(T.A_L,{size:"small",type:"date",label:o("DISPLAY_STRINGS.END_DATE"),value:Z(d.endDate),onChange:function(e){return u((function(n){return X(X({},n),{endDate:e.target.value?new Date(e.target.value):null})}))},slotProps:{inputLabel:{shrink:!0}}}),(0,r.jsxs)(T.MJN,{size:"small",fullWidth:!0,children:[(0,r.jsx)(T.l1Y,{children:o("DISPLAY_STRINGS.SOURCE_PLATFORM")}),(0,r.jsxs)(T.l6P,{label:o("DISPLAY_STRINGS.SOURCE_PLATFORM"),value:d.sourcePlatform||"",sx:{fontSize:"0.875rem"},onChange:function(e){return u((function(n){return X(X({},n),{sourcePlatform:e.target.value})}))},children:[(0,r.jsx)(T.Drp,{value:"",sx:{fontSize:"0.875rem"},children:o("DISPLAY_STRINGS.SELECT_PLATFORM")}),Object.entries(h).map((function(e){var n=e[0],t=e[1];return(0,r.jsx)(T.Drp,{value:n,sx:{fontSize:"0.875rem"},children:t},n)}))]})]}),(0,r.jsx)(T.ip9,{sx:{m:0,mt:"8px !important"},control:(0,r.jsx)(T.Sc0,{size:"small",sx:{p:0,mr:1},checked:d.onlyDeletedConversations,onChange:function(e){return u((function(n){return X(X({},n),{onlyDeletedConversations:e.target.checked})}))}}),label:(0,r.jsx)(T.azJ,{component:"span",sx:{fontSize:"0.875rem"},children:o("DISPLAY_STRINGS.SHOW_DELETED_CONVERSATIONS")})}),(0,r.jsx)(T.ip9,{sx:{m:0,mt:"8px !important"},control:(0,r.jsx)(T.Sc0,{size:"small",sx:{p:0,mr:1},checked:d.includeArchivedConversations,onChange:function(e){return u((function(n){return X(X({},n),{includeArchivedConversations:e.target.checked})}))}}),label:(0,r.jsx)(T.azJ,{component:"span",sx:{fontSize:"0.875rem"},children:o("DISPLAY_STRINGS.SHOW_ARCHIVED")})}),(0,r.jsxs)(T.azJ,{sx:{display:"flex",justifyContent:"flex-end",gap:1}
1,children:[(0,r.jsx)(T.$nd,{size:"small",color:"inherit",onClick:function(){u(D.q9),t(D.q9),s(null)},children:o("DISPLAY_STRINGS.RESET")}),(0,r.jsx)(T.$nd,{size:"small",variant:"contained",onClick:function(){t(d),s(null)},children:o("DISPLAY_STRINGS.APPLY")})]})]})})]})},ne=function(){function e(e,n){var t=e.chatbot_id;this.chatbot_id=t,this.handleResponse=n,this.chatbotWebSocket=null,this.initializeWebSocket()}return e.prototype.initializeWebSocket=function(){var e=this,n="https:"===window.location.protocol?"wss":"ws",t="".concat(n,"://").concat(window.location.host,"/ws/chatbot/info/").concat(this.chatbot_id);try{this.chatbotWebSocket=new WebSocket(t)}catch(e){return console.error("WebSocket blocked or unavailable",e),void(this.chatbotWebSocket=null)}this.chatbotWebSocket.onopen=function(n){console.log("WebSocket connection established for chatbot Info"),e.initializeChatbotWebSocketData()},this.chatbotWebSocket.onclose=function(e){console.error("Connection closed",e)},this.chatbotWebSocket.onmessage=function(n){var t=JSON.parse(n.data);e.handleResponse(t)},this.chatbotWebSocket.onerror=function(e){console.error("WebSocket error",e)}},e.prototype.initializeChatbotWebSocketData=function(){if(this.isWebSocketOpen()){var e={data_initialisation:!0,chatbot_id:this.chatbot_id};this.sendWebSocketData(e)}else console.error("Trying to reinitialize WebSocket, but connection is not open.")},e.prototype.isWebSocketOpen=function(){return null!==this.chatbotWebSocket&&this.chatbotWebSocket.readyState===WebSocket.OPEN},e.prototype.sendWebSocketData=function(e){this.isWebSocketOpen()?this.chatbotWebSocket.send(JSON.stringify(e)):console.error("WebSocket connection is not open. Cannot send data.")},e.prototype.close=function(){this.chatbotWebSocket&&(this.chatbotWebSocket.close(),this.chatbotWebSocket=null)},e}(),te=t(8919),re=t(71198),ie=t(57312),oe=t(26832),ae=t(33254),le=t(95614),se=t(68101),ce=t(50507),de=t(7098),ue=t(85667),he=t(58257),Se=t(21120),pe=t(67340),xe=t.n(pe),fe=t(16003),_e=t(33664),Ae=t(49432),Ie=t(39436),me=t(22380),Te=t(48160),ve=function(e){var n,t=e.channel,i=e.hideLabel,o=void 0!==i&&i,a=(0,T.DPo)(),l=(t||"").toLowerCase();if(!l||"none"===l)return(0,r.jsx)(r.Fragment,{children:"-"});var s={facebook:{label:"Facebook",icon:(0,r.jsx)(Ae.A,{}),color:"#4f46e5"},instagram:{label:"Instagram",icon:(0,r.jsx)(Ie.A,{}),color:"#db2777"},whatsapp:{label:"WhatsApp",icon:(0,r.jsx)(Te.A,{}),color:a.palette.success.main},api:{label:"API",icon:(0,r.jsx)(_e.A,{}),color:"#0f9f86"}},c=new Set(["embeded","personalized","shared"]),d=l.replace(/[_-]+/g," ").replace(/\b\w/g,(function(e){return e.toUpperCase()})),u=null!==(n=s[l])&&void 0!==n?n:{label:c.has(l)?"Website":d,icon:(0,r.jsx)(me.A,{}),color:a.palette.primary.main};return(0,r.jsx)(T.m_M,{title:u.label,placement:"right",children:(0,r.jsxs)(T.azJ,{component:"span","aria-label":u.label,sx:{display:"inline-flex",alignItems:"center",gap:.5,color:u.color,"& .MuiSvgIcon-root":{fontSize:16}},children:[u.icon,!o&&(0,r.jsx)(T.o5u,{component:"span",variant:"caption",color:"text.secondary",children:u.label})]})})},be=function(e,n,t,r){return new(t||(t=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function l(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){var n;e.done?i(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(a,l)}s((r=r.apply(e,n||[])).next())}))},ge=function(e,n){var t,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=l(0),a.throw=l(1),a.return=l(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function l(l){return function(s){return function(l){if(t)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(o=0)),o;)try{if(t=1,r&&(i=2&l[0]?r.return:l[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,l[1])).done)return i;switch(r=0,i&&(l=[2&l[0],i.value]),l[0]){case 0:case 1:i=l;break;case 4:return o.label++,{value:l[1],done:!1};case 5:o.label++,r=l[1],l=[0];continue;case 7:l=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==l[0]&&2!==l[0])){o=0;continue}if(3===l[0]&&(!i||l[1]>i[0]&&l[1]<i[3])){o.label=l[1];break}if(6===l[0]&&o.label<i[1]){o.label=i[1],i=l;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(l);break}i[2]&&o.ops.pop(),o.trys.pop();continue}l=n.call(e,o)}catch(e){l=[6,e],r=0}finally{t=i=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,s])}}},Ee=function(e,n,t){if(t||2===arguments.length)for(var r,i=0,o=n.length;i<o;i++)!r&&i in n||(r||(r=Array.prototype.slice.call(n,0,i)),r[i]=n[i]);return e.concat(r||Array.prototype.slice.call(n))},ye=function(e){return null==e||""===e?"-":"object"==typeof e?JSON.stringify(e):String(e)},Le=function(e){return e.trim().toLowerCase()},Ne=function(e){return e.replace(/[_-]+/g," ").replace(/\b\w/g,(function(e){return e.toUpperCase()}))},je=function(e,n){var t,r,i,o=Object.entries(e||{}).filter((function(e){var t=e[0];return Le(t)===n}));return null!==(r=null===(t=o.find((function(e){var n=e[1];return"-"!==ye(n)})))||void 0===t?void 0:t[1])&&void 0!==r?r:null===(i=o[0])||void 0===i?void 0:i[1]},Ce=function(e){var n,t,o=e.chatbot,l=e.onExportChange,s=(0,m.Bd)().t,c=(0,i.useState)(1),d=c[0],u=c[1],h=(0,i.useState)(!1),S=h[0],p=h[1],f=(0,a.Rx)(o,d,25),_=f.data,A=f.isLoading,I=f.isError,v=(0,i.useMemo)((function(){var e;return null!==(e=null==_?void 0:_.results)&&void 0!==e?e:[]}),[null==_?void 0:_.results]),g=(null!==(n=null==_?void 0:_.count)&&void 0!==n?n:0)>25,E=(0,i.useMemo)((function(){return Array.from(new Set(v.flatMap((function(e){return Object.keys(e.lead_data||{}).map(Le)}))))}),[v]),y=(0,i.useCallback)((function(){return be(void 0,void 0,void 0,(function(){var e,n,t,r,i,l,s,c,d;return ge(this,(function(u){switch(u.label){case 0:if(0===(null!==(d=null==_?void 0:_.count)&&void 0!==d?d:0)||S)return[2];p(!0),u.label=1;case 1:return u.trys.push([1,,3,4]),[4,(0,a.b6)(o)];case 2:return e=u.sent(),n=Array.from(new Set(e.flatMap((function(e){return Object.keys(e.lead_data||{}).map(Le)})))),t=Ee(Ee(["conversation_id"],n,!0),["chatbot_id","chatbot_name","source_platform","chats_count","last_message_at"],!1),r=function(e){return'"'.concat(ye(e).replaceAll('"','""'),'"')},i=e.map((function(e){return Ee(Ee([e.conversation_id],n.map((function(n){return je(e.lead_data,n)})),!0),[e.chatbot_id,e.chatbot_name,e.source_platform,e.chats_count,e.last_message_at],!1).map(r).join(",")})),l=new Blob([Ee([t.join(",")],i,!0).join("\n")],{type:"text/csv;charset=utf-8"}),s=URL.createObjectURL(l),(c=document.createElement("a")).href=s,c.download="contacts.csv",c.click(),URL.revokeObjectURL(s),[3,4];case 3:return p(!1),[7];case 4:return[2]}}
1))}))}),[o,null==_?void 0:_.count,S]);(0,i.useEffect)((function(){var e;null==l||l(y,0===(null!==(e=null==_?void 0:_.count)&&void 0!==e?e:0)||S)}),[null==_?void 0:_.count,y,S,l]);return(0,r.jsxs)(T.azJ,{sx:{height:"100%",minHeight:0,display:"flex",flexDirection:"column",overflow:"hidden",bgcolor:"background.default"},children:[(0,r.jsx)(T.K3K,{sx:{maxHeight:"100%",minHeight:0,flex:g?"1 1 auto":"0 1 auto",bgcolor:"background.paper",border:0,borderRadius:0},children:(0,r.jsxs)(T.XIK,{stickyHeader:!0,"aria-label":s("DISPLAY_LABELS.CONTACTS"),children:[(0,r.jsx)(T.ndF,{children:(0,r.jsxs)(T.Hjg,{children:[(0,r.jsx)(T.nA6,{children:s("DISPLAY_STRINGS.ID")}),E.map((function(e){return(0,r.jsx)(T.nA6,{children:Ne(e)},e)})),(0,r.jsx)(T.nA6,{children:s("DISPLAY_STRINGS.SOURCE")}),(0,r.jsx)(T.nA6,{children:s("DISPLAY_LABELS.SOURCE_PLATFORM")}),(0,r.jsx)(T.nA6,{children:s("DISPLAY_LABELS.CHATS")}),(0,r.jsx)(T.nA6,{children:s("DISPLAY_LABELS.LAST_MESSAGE")}),(0,r.jsx)(T.nA6,{align:"center"})]})}),(0,r.jsxs)(T.BFY,{children:[A&&Array.from({length:5}).map((function(e,n){return(0,r.jsx)(T.Hjg,{children:Array.from({length:6}).map((function(e,n){return(0,r.jsx)(T.nA6,{children:(0,r.jsx)(T.EAD,{width:"80%"})},n)}))},n)})),!A&&v.map((function(e){return(0,r.jsxs)(T.Hjg,{children:[(0,r.jsx)(T.nA6,{children:ye(e.conversation_id)}),E.map((function(n){return(0,r.jsx)(T.nA6,{children:(t=je(e.lead_data,n),i="string"==typeof t?t.trim().toLowerCase():t,!0===i||"true"===i?(0,r.jsx)(Se.A,{color:"success",fontSize:"small",titleAccess:s("DISPLAY_STRINGS.YES")}):!1===i||"false"===i?(0,r.jsx)(b.A,{color:"error",fontSize:"small",titleAccess:s("DISPLAY_STRINGS.NO")}):ye(t))},n);var t,i})),(0,r.jsx)(T.nA6,{children:(0,r.jsxs)(T.azJ,{component:x.N_,to:(0,x.tW)(fe.b.CHATBOT_DETAIL,{chatbotId:String(e.chatbot_id)}),target:"_blank",rel:"noopener noreferrer",sx:{color:"primary.main",textDecoration:"none","&:hover":{textDecoration:"none"}},children:[ye(e.chatbot_name)," (",e.chatbot_id,")"]})}),(0,r.jsx)(T.nA6,{children:(0,r.jsx)(ve,{channel:e.source_platform})}),(0,r.jsx)(T.nA6,{children:ye(e.chats_count)}),(0,r.jsx)(T.nA6,{children:(n=e.last_message_at,t=xe()(n),t.isValid()?t.fromNow():"-")}),(0,r.jsx)(T.nA6,{align:"center",children:(0,r.jsx)(T.m_M,{title:s("DISPLAY_STRINGS.VIEW_CONVERSATION"),placement:"left",arrow:!0,children:(0,r.jsx)(T.K0,{component:x.N_,to:"".concat((0,x.tW)(fe.b.CHATBOT_INBOX,{chatbotId:String(e.chatbot_id)}),"?conversation_id=").concat(e.conversation_id),target:"_blank",rel:"noopener noreferrer",size:"small",color:"primary","aria-label":s("DISPLAY_STRINGS.VIEW_CONVERSATION"),children:(0,r.jsx)(he.A,{fontSize:"small"})})})})]},e.conversation_id);var n,t})),!A&&(I||0===v.length)&&(0,r.jsx)(T.Hjg,{children:(0,r.jsx)(T.nA6,{colSpan:E.length+6,children:(0,r.jsx)(T.FcD,{severity:I?"error":"info",children:I?s("DISPLAY_STRINGS.SOMETHING_WENT_WRONG"):s("DISPLAY_STRINGS.NO_ITEMS_FOUND",{items:s("DISPLAY_LABELS.CONTACTS").toLowerCase()})})})})]})]})}),g&&(0,r.jsx)(T.azJ,{sx:{display:"flex",flexShrink:0,justifyContent:"center",padding:"19px 10px",borderTop:1,borderColor:"divider"},children:(0,r.jsx)(T.dKS,{size:"small",color:"primary",page:d,count:Math.ceil((null!==(t=null==_?void 0:_.count)&&void 0!==t?t:0)/25),onChange:function(e,n){return u(n)}})})]})},Pe=function(){return Pe=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var i in n=arguments[t])Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i]);return e},Pe.apply(this,arguments)},De=function(e,n){var t={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&n.indexOf(r)<0&&(t[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)n.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(t[r[i]]=e[r[i]])}return t},Re=function(e,n,t){if(t||2===arguments.length)for(var r,i=0,o=n.length;i<o;i++)!r&&i in n||(r||(r=Array.prototype.slice.call(n,0,i)),r[i]=n[i]);return e.concat(r||Array.prototype.slice.call(n))},Oe=[],we="conversations",Ge="contacts",Ye={yr:"y",yrs:"y",mo:"mo",mos:"mo",day:"d",days:"d",hr:"h",hrs:"h",min:"m",mins:"m",sec:"s",secs:"s"},Be=function(e){var n=e.trim().split(/\s+/),t=n[0],r=n[1];return"".concat(t).concat(Ye[r]||r)},Me={"&:hover":{bgcolor:"primary.main",color:"primary.contrastText",opacity:.85}},ke=function(e){var n=e.chatAgentFilter,t=e.showInboxTitle,i=void 0===t||t,o=(0,m.Bd)().t;return(0,r.jsxs)(T.azJ,{sx:{height:"calc(100dvh - 140px)",minHeight:560,bgcolor:"background.paper",border:1,borderColor:"divider",borderRadius:1,overflow:"hidden"},children:[(0,r.jsxs)(T.BJc,{direction:"row",alignItems:"center",spacing:1.5,sx:{minHeight:60,px:2,py:1,borderBottom:1,borderColor:"divider"},children:[i&&(0,r.jsx)(T.o5u,{variant:"h5",children:o("DISPLAY_LABELS.INBOX")}),(0,r.jsx)(T.azJ,{sx:{width:260},children:n}),(0,r.jsx)(T.azJ,{sx:{flexGrow:1}}),(0,r.jsx)(T.m_M,{title:o("DISPLAY_LABELS.EXPORT"),children:(0,r.jsx)("span",{children:(0,r.jsx)(T.$
1nd,{size:"small",variant:"contained",disabled:!0,sx:Me,startIcon:(0,r.jsx)(ie.A,{fontSize:"small"}),children:o("DISPLAY_LABELS.EXPORT")})})}),(0,r.jsx)(T.m_M,{title:o("DISPLAY_STRINGS.HUMAN_HANDOFF_SETTINGS"),children:(0,r.jsx)("span",{children:(0,r.jsx)(T.$nd,{size:"small",variant:"outlined",disabled:!0,startIcon:(0,r.jsx)(oe.A,{fontSize:"small"}),children:o("DISPLAY_STRINGS.HUMAN_HANDOFF_SETTINGS")})})})]}),(0,r.jsxs)(T.azJ,{sx:{display:"flex",height:"calc(100% - 60px)"},children:[(0,r.jsxs)(T.azJ,{sx:{width:{xs:"100%",sm:340},flexShrink:0,position:"relative","&::after":{content:'""',position:"absolute",top:0,right:0,bottom:0,width:"1px",bgcolor:"divider",display:{xs:"none",sm:"block"},zIndex:1},display:"flex",flexDirection:"column"},children:[(0,r.jsx)(T.azJ,{sx:{padding:"12px",borderBottom:1,borderColor:"divider"},children:(0,r.jsxs)(T.BJc,{direction:"row",alignItems:"center",spacing:.5,children:[(0,r.jsx)(T.azJ,{sx:{flexGrow:1,minWidth:0},children:(0,r.jsx)(T.DOo,{fullWidth:!0,disabled:!0,onSearch:function(){},placeholder:o("DISPLAY_STRINGS.SEARCH_PLACEHOLDER")})}),(0,r.jsx)(T.K0,{size:"small",disabled:!0,children:(0,r.jsx)($.A,{fontSize:"small"})}),(0,r.jsx)(T.K0,{size:"small",disabled:!0,children:(0,r.jsx)(ae.A,{fontSize:"small"})})]})}),(0,r.jsx)(T.azJ,{sx:{p:2},children:(0,r.jsx)(T.FcD,{severity:"info",children:o("DISPLAY_STRINGS.NO_CONVERSATIONS_FOUND")})})]}),(0,r.jsx)(T.azJ,{sx:{display:{xs:"none",sm:"block"},flexGrow:1,p:3},children:(0,r.jsx)(T.FcD,{severity:"info",children:o("DISPLAY_STRINGS.NO_CONVERSATIONS_FOUND")})})]})]})},Ue=function(e){var n,t=e.chatbot,l=e.chatbotName,s=e.chatAgentFilter,h=e.activeTab,p=e.onTabChange,x=e.showInboxTitle,f=void 0===x||x,_=(0,m.Bd)().t,A=(0,o.jE)(),v=(0,T.DPo)(),b=(0,T.Ubj)(v.breakpoints.down("sm")),g=0===t,E=(0,i.useRef)("/static/common/sounds/notification.mp3"),y=(0,i.useCallback)((function(e){e&&(E.current=e)}),[]),L=(0,i.useState)(1),N=L[0],j=L[1],C=(0,i.useState)(-1),P=C[0],R=C[1],O=(0,i.useState)(10)[0],w=(0,i.useState)(D.q9),G=w[0],Y=w[1],B=(0,i.useState)(!0),M=B[0],k=B[1],U=(0,i.useState)("Inbox"),z=U[0],W=(U[1],(0,i.useState)(we)),H=W[0],F=W[1],K=null!=h?h:H,J=(0,i.useCallback)((function(e){F(e),null==p||p(e)}),[p]),V=(0,i.useState)(new Set),q=V[0],$=V[1],X=(0,i.useState)([]),Z=X[0],he=X[1],Se=(0,i.useState)(null),pe=Se[0],xe=Se[1],fe=(0,i.useState)(null),_e=fe[0],Ae=fe[1],Ie=(0,i.useState)(!0),me=Ie[0],Te=Ie[1],be=(0,i.useCallback)((function(e,n){Ae((function(){return e})),Te(n)}),[]),ge=(0,i.useRef)(null),Ee=new URLSearchParams(window.location.search).get("conversation_id"),ye=parseInt(Ee||"");(0,i.useEffect)((function(){ge.current="Inbox"===z&&-1!==P?P:null}),[z,P]),(0,i.useEffect)((function(){var e=new ne({chatbot_id:g?"all":t},(function(e){var n=e.unread_conversation;if(n&&(ge.current===n?(0,a.nk)(n).then((function(e){null!==e&&($((function(e){return new Set(e).add(n)})),he((function(e){return e.filter((function(e){return e!==n}))}
1)),A.invalidateQueries({queryKey:[ue.e.conversations,t]}))})):(he((function(e){var t=new Set(e);return t.add(n),Array.from(t)})),$((function(e){var t=new Set(e);return t.delete(n),t})),A.invalidateQueries({queryKey:[ue.e.conversations,t]}),A.invalidateQueries({queryKey:[ue.e.conversationDetail,n]}),A.invalidateQueries({queryKey:[ue.e.chats,n]})),E.current))try{new Audio(E.current).play().catch((function(e){console.error("Error playing notification sound:",e)}))}catch(e){console.error("Error creating notification sound:",e)}}));return function(){e.close()}}),[t,g,A]);var Le=(0,a.SW)(t,N,O,G,M),Ne=Le.data,je=Le.isLoading,Ye=Le.isError,ke=Le.error,Ue=Le.refetch;Ye&&console.error("Error Loading Conversations: ",ke.message);var ze=(null==Ne?void 0:Ne.results)||[];Oe=ze;var We=(null==Ne?void 0:Ne.count)||0;(0,i.useEffect)((function(){ze.length>0&&$((function(e){var n=new Set;return e.forEach((function(e){var t=ze.find((function(n){return n.id===e}));t&&t.is_read&&n.add(e)})),n}))}),[ze]),(0,i.useEffect)((function(){null!=P&&-1!=P?(0,c.y4)("conversation_id",P.toString()):ye?R(ye):ze.length&&-1===P&&!b&&((0,c.y4)("conversation_id",ze[0].id.toString()),R(ze[0].id))}),[ye,ze,b,P]);var He=je,Fe=He?Re([],Array(10),!0).map((function(e,n){return(0,r.jsx)(I.eU,{},n)})):ze.length>0?ze.map((function(e){var n=e.id===P,t=(!e.is_read||Z.includes(e.id))&&!q.has(e.id);return(0,r.jsxs)(T.Wj3,{selected:n,onClick:function(){R(e.id),e.is_read&&!Z.includes(e.id)||xe(e.id)},sx:{alignItems:"flex-start",gap:1,px:1.25,py:1.5,borderBottom:1,borderColor:"divider",borderLeft:3,borderLeftColor:n?"primary.main":"transparent","&.Mui-selected":{bgcolor:function(e){return(0,de.X4)(e.palette.primary.main,.03)},"&:hover":{bgcolor:function(e){return(0,de.X4)(e.palette.primary.main,.05)}}}},children:[(0,r.jsx)(T.$cp,{sx:{minWidth:38,mt:.125},children:(0,r.jsx)(T.euF,{src:e.profile_pic||void 0,sx:{width:32,height:32,fontSize:"0.875rem",bgcolor:n?"primary.light":"action.hover",color:n?"primary.main":"text.secondary"},children:e.short_username})}),(0,r.jsx)(T.ZqK,{sx:{my:0,minWidth:0},primary:(0,r.jsxs)(T.BJc,{direction:"row",alignItems:"center",spacing:.75,children:[(0,r.jsxs)(T.BJc,{direction:"row",alignItems:"center",spacing:.75,sx:{flexGrow:1,minWidth:0},children:[(0,r.jsxs)(T.o5u,{variant:"subtitle2",color:t?"text.primary":"text.secondary",noWrap:!0,sx:{fontSize:"0.875rem",fontWeight:t?700:500,textTransform:"capitalize"},children:[e.username,e.is_visitor?"#".concat(e.conversation_number):""]}),e.is_deleted?(0,r.jsx)(T.vu3,{component:"span",size:"x-small",label:_("DISPLAY_LABELS.CLOSED"),sx:{flexShrink:0,color:"error.main",bgcolor:function(e){return(0,de.X4)(e.palette.error.main,.1)},border:0}}):e.is_human_handed_off&&(0,r.jsx)(T.vu3,{component:"span",size:"x-small",icon:(0,r.jsx)(re.A,{}),label:_(t?"DISPLAY_LABELS.WAITING":"DISPLAY_STRINGS.ACTIVE"),sx:{flexShrink:0,color:t?"warning.main":"success.main",bgcolor:function(e){return(0,de.X4)(t?e.palette.warning.main:e.palette.success.main,.1)},border:0,"& .MuiChip-icon":{color:t?"warning.main":"success.main",fontSize:8}}})]}),(0,r.jsx)(T.o5u,{variant:"caption",color:"text.secondary",sx:{flexShrink:0,fontSize:"0.6875rem"},children:Be(e.last_message_since)})]}),secondaryTypographyProps:{component:"div"},secondary:(0,r.jsxs)(T.azJ,{component:"span",sx:{display:"block",minWidth:0},children:[(0,r.jsxs)(T.BJc,{direction:"row",alignItems:"center",spacing:.75,component:"span",children:[t&&(0,r.jsx)(re.A,{sx:{fontSize:7,color:"primary.main",flexShrink:0}}),t?(0,r.jsx)(T.o5u,{component:"span",variant:"body2",color:"text.primary",fontWeight:600,noWrap:!0,sx:{fontSize:"0.75rem",paddingRight:"20px"},children:_("DISPLAY_LABELS.NEW_MESSAGE")}):(0,d.CH)(e.latest_message_preview)?(0,r.jsxs)(T.BJc,{component:"span",direction:"row",alignItems:"center",spacing:.5,color:"text.secondary",sx:{minWidth:0},children:[(0,r.jsx)(se.A,{sx:{fontSize:14}}),(0,r.jsx)(T.o5u,{component:"span",variant:"body2",noWrap:!0,sx:{fontSize:"0.75rem"},children:_("DISPLAY_LABELS.ATTACHMENTS")})]}):(0,r.jsx)(T.o5u,{component:"span",variant:"body2",color:"text.secondary",fontWeight:400,noWrap:!0,sx:{fontSize:"0.75rem",paddingRight:"20px"},children:e.latest_message_preview||_("DISPLAY_LABELS.NO_MESSAGES")})]}),(0,r.jsxs)(T.BJc,{direction:"row",alignItems:"center",spacing:.75,c
1omponent:"span",sx:{display:"flex",mt:.5,width:"100%"},children:[(e.chatbot_name||l)&&(0,r.jsx)(T.vu3,{component:"span",size:"x-small",variant:"outlined",label:e.chatbot_name||l,sx:{maxWidth:170,bgcolor:"transparent",color:"text.secondary",borderColor:"divider"}}),e.source_platform&&(0,r.jsx)(ve,{channel:e.source_platform,hideLabel:!0})]})]})})]},e.id)})):(0,r.jsx)(T.azJ,{sx:{p:2},children:(0,r.jsxs)(T.FcD,{severity:"info",children:[_("DISPLAY_STRINGS.NO_CONVERSATIONS_FOUND_ADJUST_CRITERIA","No conversations found. Please adjust your search criteria."),!(null==G?void 0:G.includeArchivedConversations)&&(0,r.jsx)(T.$nd,{size:"small",onClick:function(){return Ke(!0)},children:_("DISPLAY_STRINGS.OR_CHECK_OLD_CONVERSATIONS","or check old conversations.")})]})}),Ke=function(e){(0,c.y4)("conversation_id"),R(-1),Y((function(n){return Pe(Pe({},n),{conversation_number:void 0,conversation_id:void 0,includeArchivedConversations:e})})),j(1)},Je=function(e){var n=new URLSearchParams;return e.startDate&&n.append("from_date",e.startDate.toISOString().split("T")[0]),e.endDate&&n.append("to_date",e.endDate.toISOString().split("T")[0]),e.sourcePlatform&&n.append("source_platform",e.sourcePlatform),void 0!==e.onlyDeletedConversations&&n.append("is_deleted",String(e.onlyDeletedConversations)),e.includeArchivedConversations&&n.append("includeArchivedConversations","true"),void 0!==e.conversation_number&&(n.append("conversation_number",String(e.conversation_number)),n.append("conversation_id",String(e.conversation_id))),n.toString()}(G),Ve="".concat(u.n.CHATBOT.SETTINGS_PAGE(t),"?tab=human-handoff"),qe=!b||-1===P,Qe=!b||-1!==P;return(0,r.jsx)(te.A,{permission:S.Qp.CAN_VIEW_CONVERSATIONS.value,loadingSkeleton:(0,r.jsx)(I.u5,{}),children:(0,r.jsxs)(T.azJ,{sx:{height:"calc(100dvh - 140px)",minHeight:560,bgcolor:"background.paper",border:1,borderColor:"divider",borderRadius:1,overflow:"hidden"},children:[(0,r.jsxs)(T.BJc,{direction:"row",alignItems:"center",spacing:1.5,sx:{minHeight:60,px:2,py:1,borderBottom:1,borderColor:"divider"},children:[f&&(0,r.jsx)(T.o5u,{variant:"h5",children:_("DISPLAY_LABELS.INBOX")}),s&&(0,r.jsx)(T.qIE,{selectedTab:K,onTabChange:J,tabs:[{id:we,label:_("DISPLAY_LABELS.CONVERSATIONS"),icon:(0,r.jsx)(le.A,{fontSize:"small"}),isActive:K===we},{id:Ge,label:_("DISPLAY_LABELS.CONTACTS"),icon:(0,r.jsx)(ce.A,{fontSize:"small"}),isActive:K===Ge}],sx:{p:.5,gap:.5,backgroundColor:"action.selected","& .MuiButton-root":{px:1.5,py:.5,minHeight:32,whiteSpace:"nowrap"}}}),s&&(0,r.jsx)(T.azJ,{sx:{width:260},children:s}),(0,r.jsx)(T.azJ,{sx:{flexGrow:1}}),K===we&&!g&&(0,r.jsx)(T.m_M,{title:_("DISPLAY_LABELS.EXPORT"),children:(0,r.jsx)(T.$nd,{size:"small",variant:"contained",component:"a",href:u.n.CHATBOT.EXPORT_CONVERSATIONS(t,Je),disabled:-1===t,"aria-label":_("DISPLAY_LABELS.EXPORT"),sx:Me,startIcon:(0,r.jsx)(ie.A,{fontSize:"small"}),children:_("DISPLAY_LABELS.EXPORT")})}),K===Ge&&(0,r.jsx)(T.$nd,{size:"small",variant:"contained",disabled:me,onClick:function(){return null==_e?void 0:_e()},sx:Me,startIcon:(0,r.jsx)(ie.A,{fontSize:"small"}),children:_("DISPLAY_LABELS.EXPORT")}),K===we&&!g&&(0,r.jsx)(T.m_M,{title:_("DISPLAY_STRINGS.HUMAN_HANDOFF_SETTINGS"),children:(0,r.jsx)(T.$nd,{size:"small",variant:"outlined",component:"a",href:g?void 0:Ve,disabled:g,"aria-label":_("DISPLAY_STRINGS.HUMAN_HANDOFF_SETTINGS"),startIcon:(0,r.jsx)(oe.A,{fontSize:"small"}),children:_("DISPLAY_STRINGS.HUMAN_HANDOFF_SETTINGS")})})]}),K===Ge?(0,r.jsx)(T.azJ,{sx:{height:"calc(100% - 60px)"},children:(0,r.jsx)(Ce,{chatbot:t,onExportChange:be})}):(0,r.jsxs)(T.azJ,{sx:{display:"flex",height:"calc(100% - 60px)"},children:[qe&&(0,r.jsxs)(T.azJ,{sx:{width:{xs:"100%",sm:340},flexShrink:0,position:"relative","&::after":{content:'""',position:"absolute",top:0,right:0,bottom:0,width:"1px",bgcolor:"divider",display:{xs:"none",sm:"block"},zIndex:1},display:"flex",flexDirection:"column",minHeight:0},children:[(0,r.jsx)(T.azJ,{sx:{padding:"12px",borderBottom:1,borderColor:"divider"},children:(0,r.jsxs)(T.BJc,{direction:"row",alignItems:"center",spacing:.5,children:[(0,r.jsx)(T.azJ,{sx:{flexGrow:1,minWidth:0},children:(0,r.jsx)(T.DOo,{fullWidth:!0,onSearch:function(e){if(R(-1),(0,c.y4)("conversation_id"),!e)return Y((function(e){e.conversation_number,e.conversation_uuid,e.user_key,e.conversation_id,e.search_term;return De(e,["conversation_number","conversation_uuid","user_key","conversation_id","search_term"])})),j(1),void Ue();if(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)){var n=e;Y((function(t){return Pe(Pe({},t),{conversation_uuid:n,user_key:e,search_term:void 0})}))}else/^\d+$/.test(e)?Y((function(n){return Pe(Pe({},n),{conversation_number:parseInt(e,10),conversation_id:parseInt(e,10),user_key:void 0,search_term:void 0})})):e.length>0&&Y((function(n){return Pe(Pe({},n),{search_term:e,user_key:e,conversation_number:void 0,conversation_uuid:void 0,conversation_id:void 0})}));j(1)},placeholder:_("DISPLAY_STRINGS.SEARCH_PLACEHOLDER")})}),(0,r.jsx)(ee,{filters:G,handleFilter:function(e){e.includeArchivedConversations!==G.includeArchivedConversations&&((0,c.y4)("conversation_id"),R(-1)),Y(e),j(1),Ue()}}),(0,r.jsx)(T.m_M,{title:_("DISPLAY_STRINGS.SORT"),children:(0,r.jsx)(T.K0,{size:"small",color:"primary",onClick:function(){k((function(e){return!e})),j(1)},sx:{width:32,height:32},children:(0,r.jsx)(ae.A,{fontSize:"small",sx:{transform:M?"none":"rotate(180deg)",transition:"transform 150ms ease"}})})})]})}),(0,r.jsx)(T.B8B,{disablePadding:!0,sx:{overflowY:"auto",flexGrow:1,minHeight:0,scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"}},children:Fe}),We>O&&(0,r.jsx)(T.azJ,{sx:{display:"flex",justifyContent:"center",padding:"19px 10px",borderTop:1,borderColor:"divider"},children:(0,r.jsx)(T.dKS,{size:"small",color:"primary",page:N,count:Math.ceil(We/O),onChange:function(e,n){return j(n)}})})]}),Qe&&(0,r.jsx)(T.azJ,{sx:{flexGrow:1,minWidth:0,minHeight:0,height:"100%",overflow:"hidden"},children:-1!==P?(0,r.jsx)(Q,{id:P,chatbotName:(null===(n=ze.find((function(e){return e.id===P})))||void 0===n?void 0:n.chatbot_name)||l,includeArchivedConversations:G.includeArchivedConversations,notificationSoundUrl:E.current,setNotificationSoundUrl:y,setSelectedConversation:R,onConversationMarkedAsRead:function(e){xe((function(n){return n===e?null:n})),$((function(n){return new Set(n).add(e)})),he((function(n){return n.filter((function(n){return n!==e}))}
1)),A.invalidateQueries({queryKey:[ue.e.conversations,t]}),A.invalidateQueries({queryKey:[ue.e.conversationDetail,e]})},hasUnreadMessage:Z.includes(P)||ze.some((function(e){return e.id===P&&!e.is_read})),shouldMarkAsRead:pe===P,onBack:b?function(){(0,c.y4)("conversation_id"),R(-1)}:void 0}):(0,r.jsx)(r.Fragment,{children:He?(0,r.jsx)(I.x0,{}):(0,r.jsx)(T.azJ,{sx:{p:3},children:(0,r.jsx)(T.FcD,{severity:"info",children:_("DISPLAY_STRINGS.NO_CONVERSATIONS_FOUND")})})})})]})]})})}},85667:function(e,n,t){t.d(n,{e:function(){return r}});var r={humanHandoffSettings:"human-handoff-settings",conversations:"conversations",contacts:"contacts",conversationDetail:"conversation-detail",conversationSummary:"conversation-summary",chats:"chats"}},99658:function(e,n,t){t.d(n,{jl:function(){return be},MR:function(){return ko},hu:function(){return yt.Ay},cn:function(){return xn},p_:function(){return Et},j1:function(){return Wa},ib:function(){return Zi},Wh:function(){return eo.W},cj:function(){return Do},ay:function(){return Ro.A},qM:function(){return Ce.A},PF:function(){return An}});var r=t(78685),i=t(2057),o=t(78166),a=t(95336),l=t(48950),s=t(73433),c=t(16657);var d=function(e){var n=e.faqs,t=e.showFAQModal,i=e.setShowFAQModal,a=(0,c.Bd)().t;return(0,r.jsxs)(o.lGe,{open:t,onClose:function(){return i(!1)},title:a("DISPLAY_LABELS.FAQS_TITLE"),maxWidth:"md",children:[(0,r.jsx)(o.L33,{children:a("DISPLAY_LABELS.FAQS_TITLE")}),(0,r.jsx)(o.K0,{"aria-label":a("DISPLAY_LABELS.CLOSE_BUTTON"),onClick:function(){return i(!1)},sx:function(e){return{position:"absolute",right:8,top:8,color:e.palette.grey[500]}},children:(0,r.jsx)(s.bm,{})}),(0,r.jsx)(o.Cff,{children:null==n?void 0:n.map((function(e,n){return(0,r.jsxs)(o.nD3,{sx:{marginBottom:"10px"},children:[(0,r.jsx)(o.Xo_,{expandIcon:(0,r.jsx)(s.CO,{}),children:(0,r.jsx)(o.o5u,{component:"span",children:null==e?void 0:e.question})}),(0,r.jsx)(o.ZiS,{children:e.answer})]},n)}))})]})},u=t(31547),h=t(92624),S=t(45602),p=t(97749),x=t(19124),f=t(65466),_=t(93413),A=t(22249),I=function(){return I=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var i in n=arguments[t])Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i]);return e},I.apply(this,arguments)},m=function(e,n,t,r){return new(t||(t=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function l(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){var n;e.done?i(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(a,l)}s((r=r.apply(e,n||[])).next())}))},T=function(e,n){var t,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=l(0),a.throw=l(1),a.return=l(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function l(l){return function(s){return function(l){if(t)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(o=0)),o;)try{if(t=1,r&&(i=2&l[0]?r.return:l[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,l[1])).done)return i;switch(r=0,i&&(l=[2&l[0],i.value]),l[0]){case 0:case 1:i=l;break;case 4:return o.label++,{value:l[1],done:!1};case 5:o.label++,r=l[1],l=[0];continue;case 7:l=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==l[0]&&2!==l[0])){o=0;continue}if(3===l[0]&&(!i||l[1]>i[0]&&l[1]<i[3])){o.label=l[1];break}if(6===l[0]&&o.label<i[1]){o.label=i[1],i=l;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(l);break}i[2]&&o.ops.pop(),o.trys.pop();continue}l=n.call(e,o)}catch(e){l=[6,e],r=0}finally{t=i=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,s])}}};var v=function(e){var n=this,t=e.settings,s=e.chatbotId,d=e.isLoading,v=(0,i.useState)(!1),b=(v[0],v[1]),g=(0,S.jE)(),E=(0,c.Bd)().t,y=(0,A.nd)(),L=y.data,N=y.isFetching,j=!!(null==L?void 0:L.messageRateLimitLocked),C=(0,p.n)({mutationFn:function(e){var n=e.id,t=e.updates;return(0,l.sM)(n,t)},onSuccess:function(e){b(!1),g.setQueryData([_.e.AI_AGENT_SETTINGS,s],(function(n){return I(I({},n),{messageRateLimitSettings:e})})),(0,x.vd)(E("DISPLAY_STRINGS.SETTINGS_UPDATED_SUCCESS"))},onError:function(e){var n;b(!1),(0,x.oh)(null===(n=e.response)||void 0===n?void 0:n.data)},onSettled:function(){return b(!1)},onMutate:function(){return b(!0)}});return(0,r.jsx)(o.l1m,I({},{initialValues:t||(j?h.pZ:h.UV),validationSchema:f.$d,enableReinitialize:!0,onSubmit:function(e,t){return m(n,[e,t],void 0,(function(e,n){var t,r,i,o=n.setSubmitting,a=n.setErrors,l=n.resetForm;return T(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,3,4]),[4,C.mutateAsync({id:s,updates:e})];case 1:return n.sent(),l({values:e}),[3,4];case 2:return t=n.sent(),r=function(e){if(!e||"object"!=typeof e)return{};var n=(0,x.Cb)(e,1);return Object.keys(n).reduce((function(e,t){var r=n[t];if(Array.isArray(r)){var i=r.filter((function(e){return"string"==typeof e})).join(" ");i&&(e[t]=i)}else"string"==typeof r&&(e[t]=r);return e}),{})}(null===(i=null==t?void 0:t.response)||void 0===i?void 0:i.data),Object.keys(r).length>0&&a(r),[3,4];case 3:return o(!1),[7];case 4:return[2]}}
1))}))}},{children:function(e){var n,i,l,s,c,S=e.values,p=e.errors,x=e.touched,f=e.dirty,_=e.setFieldValue,A=e.setFieldTouched,I=e.resetForm,m=e.isSubmitting,T=e.handleSubmit,v=e.handleBlur,b=d||m||j||N;return(0,r.jsxs)("div",{style:{position:"relative"},children:[j&&(0,r.jsx)("div",{style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",backgroundColor:"rgba(0, 0, 0, 0.7)",zIndex:1e3,display:"flex",alignItems:"center",justifyContent:"center",cursor:"not-allowed",pointerEvents:"all",padding:"24px"},children:(0,r.jsx)(o.QIW,{})}),(0,r.jsx)("form",{className:"p-2",onSubmit:function(e){e.preventDefault(),T(e)},children:(0,r.jsxs)(o.fPr,{container:!0,spacing:2,children:[(0,r.jsxs)(o.fPr,{size:12,sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(0,r.jsx)(o.JU7,{name:E("DISPLAY_LABELS.ENABLE_RATE_LIMITING"),helptext:E("DISPLAY_STRINGS.ENABLED_HELP")}),(0,r.jsx)(o.dOG,{id:"enableRateLimiting",checked:S.rateLimitingEnabled,onChange:function(e){return _("rateLimitingEnabled",e.target.checked)},disabled:b})]}),(0,r.jsxs)(o.fPr,{size:6,children:[(0,r.jsx)(o.JU7,{name:E("DISPLAY_LABELS.TIME_PERIOD")}),(0,r.jsx)(o.l6P,{id:"timePeriod",name:"timePeriod",value:S.timePeriod,onChange:function(e){return _("timePeriod",e.target.value)},onBlur:v,variant:"outlined",disabled:b||!S.rateLimitingEnabled,fullWidth:!0,error:x.timePeriod&&!!p.timePeriod,sx:{"& #timePeriod":{padding:"10px"}},children:h.Uw.map((function(e){return(0,r.jsx)(o.Drp,{value:e.value,children:e.label},e.value)}))}),(0,a.P)(x.timePeriod,p.timePeriod)]}),(0,r.jsxs)(o.fPr,{size:6,children:[(0,r.jsx)(o.JU7,{name:E("DISPLAY_LABELS.MESSAGE_LIMIT")}),(0,r.jsx)(o.A_L,{fullWidth:!0,id:"messagesLimit",name:"messagesLimit",type:"number",value:S.messagesLimit,disabled:b||!S.rateLimitingEnabled,onChange:function(e){var n=e.target.value,t=parseInt(n,10);_("messagesLimit",Number.isFinite(t)?t:"")},onBlur:v,error:x.messagesLimit&&!!p.messagesLimit,sx:{"& #messagesLimit":{padding:"10px"}},inputProps:{min:1,step:1}}),(0,a.P)(x.messagesLimit,p.messagesLimit)]}),(0,r.jsxs)(o.fPr,{size:12,children:[(0,r.jsx)(o.JU7,{name:E("DISPLAY_LABELS.COOLDOWN_PERIOD")}),(0,r.jsx)(o.A_L,{fullWidth:!0,id:"cooldownPeriod",name:"cooldownPeriod",type:"number",value:S.cooldownPeriod,disabled:b||!S.rateLimitingEnabled,onChange:function(e){var n=e.target.value,t=parseInt(n,10);_("cooldownPeriod",Number.isFinite(t)?t:"")},onBlur:v,error:x.cooldownPeriod&&!!p.cooldownPeriod,sx:{"& #cooldownPeriod":{padding:"10px"}},inputProps:{min:1,step:1}}),(0,a.P)(x.cooldownPeriod,p.cooldownPeriod)]}),(0,r.jsxs)(o.fPr,{size:12,children:[(0,r.jsx)(o.JU7,{name:E("DISPLAY_LABELS.COOLDOWN_MESSAGE")}),(0,r.jsx)(o.A_L,{fullWidth:!0,id:"cooldownMessage",name:"cooldownMessage",multiline:!0,rows:3,value:S.cooldownMessage,disabled:b||!S.rateLimitingEnabled,onChange:function(e){_("cooldownMessage",e.target.value),x.cooldownMessage||A("cooldownMessage",!0,!1)},onBlur:v,error:x.cooldownMessage&&!!p.cooldownMessage,sx:{"& .MuiInputBase-root":{padding:"10px"}}}),(0,r.jsxs)(u.A,{sx:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:1,mt:.5},children:[(0,r.jsx)(u.A,{sx:{flex:1,minWidth:0},children:(0,a.P)(x.cooldownMessage,p.cooldownMessage)}),(0,r.jsx)(o.o5u,{variant:"caption",color:(null!==(i=null===(n=S.cooldownMessage)||void 0===n?void 0:n.length)&&void 0!==i?i:0)>255?"error":"text.secondary",sx:{flexShrink:0,whiteSpace:"nowrap"},children:E("DISPLAY_STRINGS.COOLDOWN_MESSAGE_CHAR_COUNT",{count:null!==(s=null===(l=S.cooldownMessage)||void 0===l?void 0:l.length)&&void 0!==s?s:0,max:255})})]})]}),(0,r.jsx)(o.fPr,{size:12,children:(0,r.jsxs)(o.tu9,{elevation:0,sx:{p:2,backgroundColor:"action.hover",borderRadius:1},children:[(0,r.jsx)(o.o5u,{variant:"body1",fontWeight:"bold",gutterBottom:!0,children:E("DISPLAY_LABELS.CURRENT_CONFIGURATION")}),(0,r.jsx)(o.o5u,{variant:"body2",color:"text.secondary",children:E("DISPLAY_STRINGS.CURRENT_CONFIGURATION_DESC",{messagesLimit:S.messagesLimit,timePeriod:(c=h.Uw.find((function(e){return e.value===S.timePeriod})),c?c.label.toLowerCase().replace("per ",""):"hour"),cooldownPeriod:S.cooldownPeriod})})]})}
1),!j&&(0,r.jsxs)(o.fPr,{size:12,sx:{display:"flex",justifyContent:"flex-end",mt:2},children:[(0,r.jsx)(o.$nd,{onClick:function(){return I({values:j&&t?t:j?h.pZ:h.UV})},variant:"outlined",type:"button",disabled:d||m,sx:{textTransform:"none",marginRight:2},children:E("DISPLAY_LABELS.RESET_TO_DEFAULTS")}),(0,r.jsx)(o.$nd,{type:"submit",variant:"contained",color:"primary",disabled:d||!f||m,sx:{textTransform:"none"},children:E(m?"DISPLAY_LABELS.SAVING":"DISPLAY_LABELS.SAVE_CONFIGURATION")})]}),(0,r.jsx)(o.$nd,{type:"submit",variant:"contained",color:"primary",disabled:d||!f||m,children:E(m?"DISPLAY_LABELS.SAVING":"DISPLAY_LABELS.SAVE_CONFIGURATION")})]})})]})}}))},b=t(28481),g=t(86591),E=t(6765),y=t(21762),L="chatbot-integration-settings",N="mcp-connections",j="mcp-connection-tools",C="mcp-official-connectors",P=function(){return P=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var i in n=arguments[t])Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i]);return e},P.apply(this,arguments)},D=function(e,n,t,r){return new(t||(t=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function l(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){var n;e.done?i(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(a,l)}s((r=r.apply(e,n||[])).next())}))},R=function(e,n){var t,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=l(0),a.throw=l(1),a.return=l(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function l(l){return function(s){return function(l){if(t)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(o=0)),o;)try{if(t=1,r&&(i=2&l[0]?r.return:l[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,l[1])).done)return i;switch(r=0,i&&(l=[2&l[0],i.value]),l[0]){case 0:case 1:i=l;break;case 4:return o.label++,{value:l[1],done:!1};case 5:o.label++,r=l[1],l=[0];continue;case 7:l=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==l[0]&&2!==l[0])){o=0;continue}if(3===l[0]&&(!i||l[1]>i[0]&&l[1]<i[3])){o.label=l[1];break}if(6===l[0]&&o.label<i[1]){o.label=i[1],i=l;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(l);break}i[2]&&o.ops.pop(),o.trys.pop();continue}l=n.call(e,o)}catch(e){l=[6,e],r=0}finally{t=i=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,s])}}},O=function(e){return(0,g.I)({queryKey:[L,e],queryFn:function(){return function(e){return D(void 0,void 0,Promise,(function(){return R(this,(function(n){switch(n.label){case 0:return[4,E.nv.get(y.n.INTEGRATIONS.SETTINGS(e))];case 1:return[2,n.sent().data]}}))}))}(e)},refetchOnWindowFocus:!0,refetchOnMount:!0,staleTime:0,retry:!1})},w=function(e,n){return D(void 0,void 0,Promise,(function(){return R(this,(function(t){switch(t.label){case 0:return[4,E.nv.patch(y.n.INTEGRATIONS.SETTINGS(e),n)];case 1:return[2,t.sent().data]}}))}))},G=function(e,n){var t;return(0,g.I)({queryKey:[N,e],queryFn:function(){return D(void 0,void 0,void 0,(function(){var n;return R(this,(function(t){switch(t.label){case 0:return[4,E.nv.get(y.n.MCP.CONNECTIONS,{params:{chatbot:e}})];case 1:return n=t.sent(),[2,(0,x.w9)(n.data)]}}))}))},retry:!1,enabled:null===(t=null==n?void 0:n.enabled)||void 0===t||t})},Y=function(){return(0,g.I)({queryKey:[C],queryFn:function(){return D(void 0,void 0,void 0,(function(){var e;return R(this,(function(n){switch(n.label){case 0:return[4,E.nv.get(y.n.MCP.OFFICIAL_CONNECTORS)];case 1:return e=n.sent(),[2,(0,x.w9)(e.data)]}}))}))},staleTime:18e5,gcTime:1/0,refetchOnReconnect:!1,retry:!1})},B=function(e,n){e.invalidateQueries({queryKey:[j,n]}),e.invalidateQueries({queryKey:[N]})},M=function(){return M=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var i in n=arguments[t])Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i]);return e},M.apply(this,arguments)},k=function(e,n,t,r){return new(t||(t=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function l(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){var n;e.done?i(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(a,l)}s((r=r.apply(e,n||[])).next())}))},U=function(e,n){var t,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=l(0),a.throw=l(1),a.return=l(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function l(l){return function(s){return function(l){if(t)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(o=0)),o;)try{if(t=1,r&&(i=2&l[0]?r.return:l[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,l[1])).done)return i;switch(r=0,i&&(l=[2&l[0],i.value]),l[0]){case 0:case 1:i=l;break;case 4:return o.label++,{value:l[1],done:!1};case 5:o.label++,r=l[1],l=[0];continue;case 7:l=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==l[0]&&2!==l[0])){o=0;continue}if(3===l[0]&&(!i||l[1]>i[0]&&l[1]<i[3])){o.label=l[1];break}if(6===l[0]&&o.label<i[1]){o.label=i[1],i=l;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(l);break}i[2]&&o.ops.pop(),o.trys.pop();continue}l=n.call(e,o)}catch(e){l=[6,e],r=0}finally{t=i=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,s])}}},z=function(e){var n=e.chatbotId,t=e.settings,i=e.isLoading,s=(0,c.Bd)().t,d=(0,S.jE)(),u=O(n).data,h={nudgeEnabled:!1,nudgeDelayMinutes:5,nudgeMaxCount:1,nudgeMessage:s("DISPLAY_STRINGS.DEFAULT_NUDGE_MESSAGE")},A=t?M(M({},t),{nudgeMessage:t.nudgeMessage||h.nudgeMessage}):h,I=(0,p.n)({mutationFn:function(e){return(0,l.iP)(n,e)},onSuccess:function(e){d.setQueryData([_.e.AI_AGENT_SETTINGS,n],(function(n){return M(M({},n),{nudgeSettings:e})})),(0,x.vd)(s("DISPLAY_STRINGS.SETTINGS_UPDATED_SUCCESS"))},onError:function(e){var n;return(0,x.oh)(null===(n=e.response)||void 0===n?void 0:n.data)}});return(0,r.jsx)(o.l1m,{initialValues:A,validationSchema:f.EU,enableReinitialize:!0,onSubmit:function(e,n){return k(void 0,[e,n],void 0,(function(e,n){var t,r=n.resetForm;return U(this,(function(n){switch(n.label){case 0:return[4,I.mutateAsync(e)];case 1:return t=n.sent(),r({values:t}),[2]}}))}))},children:function(e){var n=e.values,t=e.errors,l=e.touched,c=e.dirty,d=e.setFieldValue,S=e.resetForm,p=e.handleBlur,x=i||I.isPending||!n.nudgeEnabled;return(0,r.jsxs)(b.lV,{children:[(0,r.jsxs)(o.azJ,{sx:{display:"flex",justifyContent:"space-between",mb:2},children:[(0,r.jsxs)(o.azJ,{children:[(0,r.jsx)(o.o5u,{fontWeight:600,children:s("DISPLAY_LABELS.ENABLE_NUDGING")}),(0,r.jsx)(o.o5u,{variant:"body2",color:"text.secondary",children:s("DISPLAY_STRINGS.ENABLE_NUDGING_HELP")})]}),(0,r.jsx)(o.dOG,{checked:n.nudgeEnabled,onChange:function(e,n){return d("nudgeEnabled",n)},disabled:i||I.isPending})]}),n.nudgeEnabled&&(null==u?void 0:u.auto_refresh_enabled)&&(0,r.jsxs)(o.FcD,{severity:"warning",sx:{mb:2},children:[(0,r.jsxs)(o.azJ,{component:"span",sx:{color:"warning.main",fontWeight:700},children:[s("DISPLAY_STRINGS.WARNING_LABEL")," "]}),s("DISPLAY_STRINGS.NUDGE_AUTO_REFRESH_WARNING")]}),(0,r.jsxs)(o.fPr,{container:!0,spacing:2,children:[(0,r.jsxs)(o.fPr,{size:{xs:12,md:6},children:[(0,r.jsx)(o.JU7,{name:s("DISPLAY_LABELS.NUDGE_AFTER_MINUTES")}),(0,r.jsx)(o.A_L,{fullWidth:!0,type:"number",name:"nudgeDelayMinutes",value:n.nudgeDelayMinutes,onChange:function(e){return d("nudgeDelayMinutes",Number(e.target.value))},onBlur:p,error:l.nudgeDelayMinutes&&Boolean(t.nudgeDelayMinutes),disabled:x,inputProps:{min:1,max:60}}),(0,a.P)(l.nudgeDelayMinutes,t.nudgeDelayMinutes)]}),(0,r.jsxs)(o.fPr,{size:{xs:12,md:6},children:[(0,r.jsx)(o.JU7,{name:s("DISPLAY_LABELS.MAX_NUDGES")}),(0,r.jsx)(o.A_L,{fullWidth:!0,type:"number",name:"nudgeMaxCount",value:n.nudgeMaxCount,onChange:function(e){return d("nudgeMaxCount",Number(e.target.value))},onBlur:p,error:l.nudgeMaxCount&&Boolean(t.nudgeMaxCount),disabled:x,inputProps:{min:1,max:3}}),(0,a.P)(l.nudgeMaxCount,t.nudgeMaxCount)]}),(0,r.jsxs)(o.fPr,{size:12,children:[(0,r.jsx)(o.JU7,{name:s("DISPLAY_LABELS.NUDGE_MESSAGE")}),(0,r.jsx)(o.A_L,{fullWidth:!0,multiline:!0,minRows:4,name:"nudgeMessage",value:n.nudgeMessage,onChange:function(e){return d("nudgeMessage",e.target.value)},onBlur:p,error:l.nudgeMessage&&Boolean(t.nudgeMessage),disabled:x,inputProps:{maxLength:255}}),(0,r.jsxs)(o.azJ,{sx:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:1,mt:.5},children:[(0,r.jsx)(o.azJ,{sx:{flex:1,minWidth:0},children:(0,a.P)(l.nudgeMessage,t.nudgeMessage)}),(0,r.jsxs)(o.o5u,{variant:"caption",color:"text.secondary",sx:{flexShrink:0,whiteSpace:"nowrap"},children:[n.nudgeMessage.length," / 255"]}
1)]})]})]}),(0,r.jsxs)(o.azJ,{sx:{display:"flex",justifyContent:"flex-end",gap:1,mt:3},children:[(0,r.jsx)(o.$nd,{variant:"outlined",onClick:function(){return S({values:h})},disabled:I.isPending,children:s("DISPLAY_LABELS.RESET_TO_DEFAULTS")}),(0,r.jsx)(o.$nd,{type:"submit",variant:"contained",disabled:!c||I.isPending,children:s("DISPLAY_LABELS.SAVE_CHANGES")})]})]})}})},W=t(26088),H=t(12081),F=t(39675),K=function(){return K=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var i in n=arguments[t])Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i]);return e},K.apply(this,arguments)},J=function(e,n,t,r){return new(t||(t=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function l(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){var n;e.done?i(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(a,l)}s((r=r.apply(e,n||[])).next())}))},V=function(e,n){var t,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=l(0),a.throw=l(1),a.return=l(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function l(l){return function(s){return function(l){if(t)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(o=0)),o;)try{if(t=1,r&&(i=2&l[0]?r.return:l[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,l[1])).done)return i;switch(r=0,i&&(l=[2&l[0],i.value]),l[0]){case 0:case 1:i=l;break;case 4:return o.label++,{value:l[1],done:!1};case 5:o.label++,r=l[1],l=[0];continue;case 7:l=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==l[0]&&2!==l[0])){o=0;continue}if(3===l[0]&&(!i||l[1]>i[0]&&l[1]<i[3])){o.label=l[1];break}if(6===l[0]&&o.label<i[1]){o.label=i[1],i=l;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(l);break}i[2]&&o.ops.pop(),o.trys.pop();continue}l=n.call(e,o)}catch(e){l=[6,e],r=0}finally{t=i=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,s])}}},q=function(e,n,t){if(t||2===arguments.length)for(var r,i=0,o=n.length;i<o;i++)!r&&i in n||(r||(r=Array.prototype.slice.call(n,0,i)),r[i]=n[i]);return e.concat(r||Array.prototype.slice.call(n))},Q={unknownAnswerEmailEnabled:!0,unknownAnswerNotificationEmails:"",unknownAnswerWebhookEnabled:!1,unknownAnswerWebhookUrl:""},$=function(e){var n=e.chatbotId,t=e.settings,a=e.isLoading,d=(0,c.Bd)().t,u=(0,S.jE)(),h=(0,F.fL)().themeMode,f=(0,i.useState)(!1),A=f[0],I=f[1],m=(0,i.useState)(""),T=m[0],v=m[1],b=(0,i.useState)(Q),g=b[0],E=b[1];(0,i.useEffect)((function(){var e,n,r,i;t&&E({unknownAnswerEmailEnabled:null===(e=t.unknownAnswerEmailEnabled)||void 0===e||e,unknownAnswerNotificationEmails:null!==(n=t.unknownAnswerNotificationEmails)&&void 0!==n?n:"",unknownAnswerWebhookEnabled:null!==(r=t.unknownAnswerWebhookEnabled)&&void 0!==r&&r,unknownAnswerWebhookUrl:null!==(i=t.unknownAnswerWebhookUrl)&&void 0!==i?i:""})}),[t]);var y=(0,p.n)({mutationFn:function(e){return(0,l.kI)(n,e)},onSuccess:function(e){var t,r,i,o;u.setQueryData([_.e.AI_AGENT_SETTINGS,n],(function(n){return n?K(K({},n),{unknownAnswerNotificationSettings:e}):n})),E({unknownAnswerEmailEnabled:null===(t=e.unknownAnswerEmailEnabled)||void 0===t||t,unknownAnswerNotificationEmails:null!==(r=e.unknownAnswerNotificationEmails)&&void 0!==r?r:"",unknownAnswerWebhookEnabled:null!==(i=e.unknownAnswerWebhookEnabled)&&void 0!==i&&i,unknownAnswerWebhookUrl:null!==(o=e.unknownAnswerWebhookUrl)&&void 0!==o?o:""}),(0,x.vd)(d("DISPLAY_STRINGS.UNKNOWN_ANSWER_NOTIFICATION_SETTINGS_UPDATED"))},onError:function(e){var n;(0,x.oh)(null===(n=e.response)||void 0===n?void 0:n.data)}}),L=(0,i.useState)(!1),N=L[0],j=L[1],C=(0,x._6)(g.unknownAnswerNotificationEmails).filter((function(e){return""!==e.trim()}));return a?null:(0,r.jsxs)(o.fPr,{container:!0,spacing:0,children:[(0,r.jsx)(o.fPr,{size:12,children:(0,r.jsx)(o.ZpM,{sx:{borderRadius:2},variant:"outlined",children:(0,r.jsxs)(o.Wux,{children:[(0,r.jsx)(o.azJ,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:.5},children:(0,r.jsxs)(o.o5u,{variant:"h6",fontWeight:"bold",gutterBottom:!0,color:"primary",children:[(0,r.jsx)(s.$0,{sx:{mr:1,verticalAlign:"middle"}}),d("DISPLAY_STRINGS.UNKNOWN_ANSWER_GET_NOTIFIED_HEADING")]})}),(0,r.jsx)(o.o5u,{color:"text.secondary",sx:{mb:3},children:d("DISPLAY_STRINGS.UNKNOWN_ANSWER_GET_NOTIFIED_DESCRIPTION")}),(0,r.jsx)(o.o5u,{fontWeight:"bold",color:"primary",sx:{mt:2,mb:2},variant:"body2",children:d("DISPLAY_STRINGS.UNKNOWN_ANSWER_PROMPT_INSTRUCTIONS_LABEL")}),(0,r.jsxs)(o.azJ,{sx:{p:2,bgcolor:"dark"===h?"#222":"#f5f7fa",borderRadius:2,position:"relative",mb:0},children:[(0,r.jsx)(o.azJ,{component:"pre",sx:{fontFamily:"monospace",typography:"body1",background:"transparent",whiteSpace:"pre-wrap",wordBreak:"break-word",color:"dark"===h?"#e0e0e0":"#000000"},children:H.Py}),(0,r.jsx)(o.m_M,{title:d(A?"DISPLAY_STRINGS.COPIED_TOOLTIP":"DISPLAY_STRINGS.COPY_TOOLTIP"),placement:"top",children:(0,r.jsx)(o.K0,{size:"small",sx:{position:"absolute",top:8,right:8},onClick:function(){(0,x.eM)(H.Py),I(!0),setTimeout((function(){return I(!1)}),2e3)},children:(0,r.jsx)(W.A,{fontSize:"small"})})})]})]})})}),(0,r.jsx)(o.fPr,{size:12,children:(0,r.jsx)(o.ZpM,{sx:{mt:4,borderRadius:2},variant:"outlined",children:(0,r.jsxs)(o.Wux,{children:[(0,r.jsxs)(o.azJ,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:.5},children:[(0,r.jsxs)(o.o5u,{variant:"h6",fontWeight:"bold",gutterBottom:!0,color:"primary",children:[(0,r.jsx)(s.$0,{sx:{mr:1,verticalAlign:"middle"}}),d("DISPLAY_STRINGS.UNKNOWN_ANSWER_EMAIL_ENABLED_LABEL")]}),(0,r.jsx)(o.dOG,{checked:g.unknownAnswerEmailEnabled,onChange:function(e){return E((function(n){return K(K({},n),{unknownAnswerEmailEnabled:e.target.checked})}))},color:"primary"})]}),(0,r.jsx)(o.o5u,{color:"text.secondary",sx:{mb:3},children:d("DISPLAY_STRINGS.UNKNOWN_ANSWER_EMAIL_DESCRIPTION")}),g.unknownAnswerEmailEnabled&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(o.o5u,{fontWeight:"bold",color:"primary",sx:{mb:1},variant:"body2",children:d("DISPLAY_STRINGS.UNKNOWN_ANSWER_NOTIFICATION_EMAILS_LABEL")}),(0,r.jsx)(o.azJ,{sx:{mb:2},children:C.map((function(e,n){return(0,r.jsx)(o.vu3,{label:e,onDelete:function(){return function(e){var n=(0,x._6)(g.unknownAnswerNotificationEmails).filter((function(n){return n!==e})).join(", ");E((function(e){return K(K({},e),{unknownAnswerNotificationEmails:n})}))}(e)},color:"primary",variant:"outlined",size:"small",sx:{mr:1,mb:1,backgroundColor:"transparent","&:hover":{backgroundColor:"rgba(33, 150, 243, 0.08)"}}},"".concat(e,"-").concat(n))}))}),(0,r.jsx)(o.A_L,{label:d("DISPLAY_STRINGS.EMAIL"),placeholder:d("DISPLAY_STRINGS.UNKNOWN_ANSWER_ENTER_EMAIL_PLACEHOLDER"),variant:"outlined",fullWidth:!0,size:"small",value:T,onChange:function(e){return v(e.target.value)},onKeyDown:function(e){return function(e){if(!e||"Enter"===e.key){e&&e.preventDefault();var n=T.trim();if(n){var t=(0,x._6)(g.unknownAnswerNotificationEmails);if(t.includes(n))v("");else{var r=q(q([],t,!0),[n],!1).join(", ");E((function(e){return K(K({},e),{unknownAnswerNotificationEmails:r})})),v("")}}}}(e)},slotProps:{inputLabel:{shrink:!0}}})]})]})})}),(0,r.jsx)(o.fPr,{size:12,children:(0,r.jsx)(o.ZpM,{sx:{mt:4,borderRadius:2},variant:"outlined",children:(0,r.jsxs)(o.Wux,{children:[(0,r.jsxs)(o.azJ,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:.5},children:[(0,r.jsxs)(o.o5u,{variant:"h6",fontWeight:"bold",gutterBottom:!0,color:"primary",children:[(0,r.jsx)(s.TM,{sx:{mr:1,verticalAlign:"middle"}}),d("DISPLAY_STRINGS.UNKNOWN_ANSWER_WEBHOOK_ENABLED_LABEL")]}),(0,r.jsx)(o.dOG,{checked:g.unknownAnswerWebhookEnabled,onChange:function(e){return E((function(n){return K(K({},n),{unknownAnswerWebhookEnabled:e.target.checked})}))},color:"primary"})]}),(0,r.jsx)(o.o5u,{color:"text.secondary",sx:{mb:3},children:d("DISPLAY_STRINGS.UNKNOWN_ANSWER_WEBHOOK_DESCRIPTION")}),g.unknownAnswerWebhookEnabled&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(o.o5u,{fontWeight:"bold",color:"primary",sx:{mb:1},variant:"body2",children:d("DISPLAY_STRINGS.UNKNOWN_ANSWER_WEBHOOK_URL_LABEL")}),(0,r.jsx)(o.A_L,{label:d("DISPLAY_STRINGS.UNKNOWN_ANSWER_WEBHOOK_URL_LABEL"),placeholder:d("DISPLAY_STRINGS.UNKNOWN_ANSWER_WEBHOOK_PLACEHOLDER"),variant:"outlined",fullWidth:!0,size:"small",value:g.unknownAnswerWebhookUrl,onChange:function(e){return E((function(n){return K(K({},n),{unknownAnswerWebhookUrl:e.target.value})}))},slotProps:{inputLabel:{shrink:!0}},sx:{mb:3}})]})]})})}),(0,r.jsx)(o.fPr,{size:12,children:(0,r.jsxs)(o.azJ,{sx:{display:"flex",justifyContent:"flex-end",mt:3,gap:2},children:[(0,r.jsx)(o.$nd,{variant:"outlined",color:"primary",onClick:function(){return J(void 0,void 0,void 0,(function(){var e,t,r;return V(this,(function(i){switch(i.label){case 0:if(!(e=(g.unknownAnswerWebhookUrl||"").trim()))return[2];j(!0),i.label=1;case 1:return i.trys.push([1,3,4,5]),[4,(0,l.aU)(n,e)];case 2:return i.sent(),(0,x.vd)(d("DISPLAY_STRINGS.TEST_WEBHOOK_SENT_SUCCESS")),[3,5];case 3:return t=i.sent(),(0,x.oh)(null===(r=null==t?void 0:t.response)||void 0===r?void 0:r.data),[3,5];case 4:return j(!1),[7];case 5:return[2]}}
1))}))},disabled:N||!(g.unknownAnswerWebhookUrl||"").trim(),children:d(N?"DISPLAY_STRINGS.SENDING":"DISPLAY_LABELS.TEST_WEBHOOK")}),(0,r.jsx)(o.$nd,{variant:"contained",color:"primary",disabled:y.isPending,onClick:function(){y.mutate(g)},sx:{paddingX:2,paddingY:1},children:y.isPending?d("DISPLAY_STRINGS.SAVING"):d("DISPLAY_LABELS.SAVE_CHANGES")})]})})]})},X=t(92912),Z=t(16472),ee=t(12566),ne=t(41175),te=t(10838),re=t(26120),ie=t(51140),oe=t(77040),ae=t(34369),le=t(81560),se=t(64602),ce=function(){return ce=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var i in n=arguments[t])Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i]);return e},ce.apply(this,arguments)},de=function(e,n,t){if(t||2===arguments.length)for(var r,i=0,o=n.length;i<o;i++)!r&&i in n||(r||(r=Array.prototype.slice.call(n,0,i)),r[i]=n[i]);return e.concat(r||Array.prototype.slice.call(n))},ue=function(e){var n=e.schedule,t=e.onChange,i=(0,c.Bd)().t,a=(0,x.N$)().map((function(e){return{value:e[0],label:e[1]}})),l=function(e){t(ce(ce({},n),{handoff_days:n.handoff_days.map((function(n){return n.day_name===e.day_name?e:n}))}))},s=[se.A4.SUNDAY,se.A4.MONDAY,se.A4.TUESDAY,se.A4.WEDNESDAY,se.A4.THURSDAY,se.A4.FRIDAY,se.A4.SATURDAY],d=de([],n.handoff_days,!0).sort((function(e,n){return s.indexOf(e.day_name)-s.indexOf(n.day_name)}));return(0,r.jsxs)(ne.A,{elevation:0,sx:{p:3,border:"1px solid #e0e0e0"},children:[(0,r.jsxs)(te.A,{variant:"body1",color:"primary",className:"fw-bolder mb-3",children:[(0,r.jsx)(ae.A,{})," ",i("DISPLAY_STRINGS.HUMAN_HANDOFF_AVAILABLE_HOURS")]}),(0,r.jsxs)(u.A,{sx:{mb:2,bgcolor:"#f5f5f5",borderRadius:1},children:[(0,r.jsxs)(u.A,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:1,p:1},children:[(0,r.jsx)(te.A,{sx:{fontWeight:500},children:n.is_handoff_scheduled?i("DISPLAY_STRINGS.HUMAN_HANDOFF_FOLLOWS_SCHEDULE"):i("DISPLAY_STRINGS.HUMAN_HANDOFF_ENABLED_24_7")}),(0,r.jsxs)(u.A,{children:[(0,r.jsx)(re.A,{control:(0,r.jsx)(ie.A,{checked:n.is_handoff_scheduled,onChange:function(e){t(ce(ce({},n),{is_handoff_scheduled:e.target.checked}))},color:"primary"}),labelPlacement:"start",label:i("DISPLAY_STRINGS.ALL_TIME")}),(0,r.jsx)("span",{className:"ms-2",children:i("DISPLAY_STRINGS.SCHEDULED")})]})]}),n.is_handoff_scheduled&&(0,r.jsx)(oe.A,{fullWidth:!0,sx:{mb:2,p:1},children:(0,r.jsx)(o._8Q,{options:a,selectedValue:n.handoff_schedule_timezone,onChange:function(e){t(ce(ce({},n),{handoff_schedule_timezone:e}))},label:i("DISPLAY_LABELS.TIMEZONE"),isSearchable:!0,isClearable:!1})})]}),n.is_handoff_scheduled&&(0,r.jsx)(u.A,{children:d.map((function(e){return(0,r.jsx)(le.A,{day:e,onDayChange:l},e.day_name)}))})]})},he=function(){return he=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var i in n=arguments[t])Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i]);return e},he.apply(this,arguments)};function Se(e){var n=e.icon,t=e.title,i=e.description,a=void 0===i?"":i,l=e.heading,s=void 0===l?"":l,c=e.chipCount,d=void 0===c?4:c,u=e.label,h=void 0===u?"":u,S=e.showTextInput,p=void 0===S||S,x=e.sx,f=void 0===x?{}:x;return(0,r.jsx)(o.ZpM,{sx:he({marginTop:0},f),children:(0,r.jsxs)(o.Wux,{children:[(0,r.jsx)(o.azJ,{sx:{display:"flex",alignItems:"center"},children:(0,r.jsxs)(o.o5u,{variant:"body1",color:"primary",className:"fw-bolder",children:[n," ",t]})}),a&&(0,r.jsx)(o.o5u,{variant:"body2",color:"textDisabled",children:a}),s&&(0,r.jsx)(o.o5u,{sx:{marginTop:2},children:s}),d>0&&(0,r.jsx)(o.azJ,{sx:{marginTop:3,display:"flex",flexWrap:"wrap"},children:Array(d).fill(0).map((function(e,n){return(0,r.jsx)(o.EAD,{variant:"rounded",width:80+40*Math.random(),height:32,sx:{marginRight:1,marginBottom:1}},n)}))}),p&&(0,r.jsx)(o.A_L,{label:h,disabled:!0,placeholder:"...",variant:"outlined",size:"small",slotProps:{inputLabel:{shrink:!0}},sx:{marginTop:3,width:"100%"}})]})})}var pe=function(){var e=(0,c.Bd)().t;return(0,r.jsxs)(o.azJ,{sx:{padding:3,width:"100%"},children:[(0,r.jsx)(Se,{icon:(0,r.jsx)(s.iL,{}),title:e("DISPLAY_STRINGS.TRIGGER_SETTINGS"),description:e("DISPLAY_STRINGS.TRIGGER_SETTINGS_DESCRIPTION"),heading:e("DISPLAY_STRINGS.HANDOFF_KEYWORDS_AND_PHRASES"),chipCount:4,label:e("DISPLAY_STRINGS.KEYWORD_PHRASE")}),(0,r.jsx)(Se,{icon:(0,r.jsx)(s.Jd,{}),title:e("DISPLAY_STRINGS.HANDOFF_RESPONSE"),description:e("DISPLAY_STRINGS.HANDOFF_RESPONSE_DESCRIPTION"),heading:e("DISPLAY_STRINGS.AI_AGENTS_FINAL_MESSAGE"),chipCount:0,label:e("DISPLAY_STRINGS.HANDOFF_MESSAGE")}),(0,r.jsx)(Se,{icon:(0,r.jsx)(s.gO,{}),title:e("DISPLAY_STRINGS.HUMAN_HANDOFF_AVAILABLE_HOURS"),heading:e("DISPLAY_STRINGS.HUMAN_HANDOFF_ENABLED_24_7"),chipCount:0,showTextInput:!1})]})},xe=t(85667),fe=t(57736),_e=function(e){var n=e.title,t=e.description;return(0,r.jsxs)(o.azJ,{sx:{mb:2.5},children:[(0,r.jsx)(o.o5u,{variant:"subtitle1",color:"primary",fontWeight:700,children:n}),t&&(0,r.jsx)(o.o5u,{variant:"body2",color:"text.secondary",sx:{mt:.5},children:t})]})},Ae=function(e){var n=e.chatbotId,t=e.embedded,a=void 0!==t&&t,l=(0,c.Bd)().t,d=(0,S.jE)(),u=(0,A.nd)().data,h=!!u&&!u.canUseHumanHandoff,f=(0,i.useState)(""),_=f[0],I=f[1],m=(0,i.useState)(""),T=m[0],v=m[1],g=(0,i.useState)(!1),E=g[0],y=g[1],L=(0,i.useState)(null),N=L[0],j=L[1],C=l("DISPLAY_LABELS.HANDOFF_KEYWORD_CONFLICT_WITH_INTENT_PROMPT"),P=[{id:1,key:"is_widget_handoff_enabled",title:l("DISPLAY_STRINGS.CHAT_WIDGET"),icon:(0,r.jsx)(s.g4,{})},{id:2,key:"is_whatsapp_handoff_enabled",title:l("DISPLAY_STRINGS.WHATSAPP"),icon:(0,r.jsx)(s.LO,{})},{id:3,key:"is_instagram_handoff_enabled",title:l("DISPLAY_STRINGS.INSTAGRAM"),icon:(0,r.jsx)(s.pd,{})},{id:4,key:"is_facebook_handoff_enabled",title:l("DISPLAY_STRINGS.FACEBOOK"),icon:(0,r.jsx)(s.Nb,{})},{id:5,key:"is_api_handoff_enabled",title:l("DISPLAY_STRINGS.API"),icon:(0,r.jsx)(s.jI,{})}
1],D=(0,Z.Ko)(n),R=D.data,O=D.isLoading;D.isFetching;(0,i.useEffect)((function(){y(O)}),[O]),(0,i.useEffect)((function(){j(R||null)}),[R]);var w=(0,p.n)({mutationFn:function(e){return(0,Z.mw)(n,e)},onSuccess:function(e){j(e),(0,x.vd)(l("DISPLAY_STRINGS.HUMAN_HANDOFF_SETTINGS_UPDATED")),d.invalidateQueries({queryKey:[xe.e.humanHandoffSettings,n]})},onError:function(e){var n,t=null===(n=null==e?void 0:e.response)||void 0===n?void 0:n.data,r=(Array.isArray(null==t?void 0:t.handoff_trigger_mode)?t.handoff_trigger_mode[0]:null==t?void 0:t.handoff_trigger_mode)||(Array.isArray(null==t?void 0:t.handoffTriggerMode)?t.handoffTriggerMode[0]:null==t?void 0:t.handoffTriggerMode)||(null==t?void 0:t.error)||(null==e?void 0:e.message);(0,x.ag)(r||l("DISPLAY_STRINGS.SOMETHING_WENT_WRONG"))},onSettled:function(){return y(!1)},onMutate:function(){return y(!0)}});return E||!N?a?(0,r.jsxs)(o.Wux,{sx:{p:3,"&:last-child":{pb:3}},children:[(0,r.jsx)(_e,{title:l("DISPLAY_STRINGS.HUMAN_HANDOFF_SETTINGS"),description:l("DISPLAY_STRINGS.HUMAN_HANDOFF_SETTINGS_DESCRIPTION")}),(0,r.jsx)(pe,{})]}):(0,r.jsx)(o.Zkm,{title:l("DISPLAY_STRINGS.HUMAN_HANDOFF_SETTINGS"),description:l("DISPLAY_STRINGS.HUMAN_HANDOFF_SETTINGS_DESCRIPTION"),children:(0,r.jsx)(pe,{})}):(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(o.l1m,{initialValues:N,enableReinitialize:!0,onSubmit:function(e){w.mutate(e)},children:function(e){var t,i=e.values,c=(e.errors,e.touched,e.handleChange),d=e.setFieldValue,u="keyword"===i.handoff_trigger_mode?"keyword":"auto-detect",S="auto-detect"===u,p="keyword"===u,f=(0,r.jsxs)(o.azJ,{sx:{width:"100%"},children:[(0,r.jsx)(o.ZpM,{variant:"outlined",sx:{borderColor:"divider",borderRadius:2,mb:3,overflow:"visible"},children:(0,r.jsxs)(o.Wux,{sx:{pt:2,pb:2,"&:last-child":{pb:2}},children:[(0,r.jsxs)(o.azJ,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:2},children:[(0,r.jsxs)(o.azJ,{children:[(0,r.jsx)(o.o5u,{variant:"subtitle1",fontWeight:600,children:l("DISPLAY_STRINGS.ENABLE_HUMAN_HANDOFF")}),(0,r.jsx)(o.o5u,{variant:"body2",color:"text.secondary",children:l("DISPLAY_STRINGS.ENABLE_HUMAN_HANDOFF_DESCRIPTION")})]}),(0,r.jsx)(o.dOG,{checked:Boolean(i.is_widget_handoff_enabled),onChange:function(e){return d("is_widget_handoff_enabled",e.target.checked)},color:"primary"})]}),(0,r.jsxs)(o.azJ,{sx:{mb:3,display:"grid",gridTemplateColumns:{xs:"1fr",md:"1fr 1fr"},gap:2,alignItems:"stretch"},children:[(0,r.jsx)(o.ZpM,{variant:"outlined",sx:{borderRadius:2},children:(0,r.jsxs)(o.Wux,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:2,py:2,"&:last-child":{pb:2}},children:[(0,r.jsxs)(o.azJ,{children:[(0,r.jsx)(o.o5u,{variant:"subtitle1",fontWeight:600,children:l("DISPLAY_STRINGS.HANDOFF_TAB_AUTO_DETECT")}),(0,r.jsx)(o.o5u,{variant:"body2",color:"text.secondary",children:l("DISPLAY_STRINGS.AUTO_DETECT_HANDOFF_INTENT_DESCRIPTION")})]}),(0,r.jsx)(o.dOG,{checked:S,onChange:function(e){e.target.checked&&d("handoff_trigger_mode","intent")},color:"primary"})]})}),(0,r.jsx)(o.ZpM,{variant:"outlined",sx:{borderRadius:2},children:(0,r.jsxs)(o.Wux,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:2,py:2,"&:last-child":{pb:2}},children:[(0,r.jsxs)(o.azJ,{children:[(0,r.jsx)(o.o5u,{variant:"subtitle1",fontWeight:600,children:l("DISPLAY_STRINGS.HANDOFF_TAB_KEYWORD_BASED")}),(0,r.jsx)(o.o5u,{variant:"body2",color:"text.secondary",children:l("DISPLAY_STRINGS.HANDOFF_KEYWORD_TAB_DESCRIPTION")})]}),(0,r.jsx)(o.dOG,{checked:p,onChange:function(e){e.target.checked&&((null==R?void 0:R.base_prompt_contains_intent_handoff)?(0,x.ag)(C):d("handoff_trigger_mode","keyword"))},color:"primary"})]})})]}),"auto-detect"===u&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(o.azJ,{sx:{my:3},children:[(0,r.jsx)(o.JU7,{name:l("DISPLAY_STRINGS.HANDOFF_INTENT_PROMPT_LABEL"),helptext:l("DISPLAY_STRINGS.AUTO_DETECT_HANDOFF_INTENT_DESCRIPTION"),style:{marginTop:15}}),(0,r.jsxs)(o.azJ,{sx:{position:"relative"},children:[(0,r.jsx)(X.H,{fullWidth:!0,multiline:!0,minRows:4,maxRows:10,value:(H.to||"").trim(),size:"small",InputProps:{readOnly:!0},sx:{"& .MuiInputBase-input":{paddingBottom:1},"& .MuiInputBase-root":{alignItems:"flex-start"}}}),(0,r.jsx)(o.azJ,{sx:{position:"absolute",right:20,top:10},children:(0,r.jsx)(o.K0,{size:"small",onClick:function(){(0,x.eM)((H.to||"").trim(),l("DISPLAY_STRINGS.COPIED_TO_CLIPBOARD"))},"aria-label":l("DISPLAY_STRINGS.COPY_TO_CLIPBOARD"),children:(0,r.jsx)(W.A,{fontSize:"small"})})})]}
1),(0,r.jsxs)(o.o5u,{variant:"caption",sx:{display:"block",mt:1},children:[(0,r.jsx)("strong",{style:{color:"red"},children:l("DISPLAY_STRINGS.PROMPT_INSTRUCTIONS_IMPORTANT")})," ",l("DISPLAY_STRINGS.HANDOFF_INTENT_PROMPT_IMPORTANT_CAPTION")]})]}),(0,r.jsxs)(o.azJ,{sx:{mt:3},children:[(0,r.jsx)(o.o5u,{variant:"subtitle2",fontWeight:600,sx:{mb:1.5,display:"block"},children:l("DISPLAY_STRINGS.HANDOFF_MESSAGE")}),(0,r.jsx)(b.D0,{as:o.A_L,name:"handoff_response",placeholder:l("DISPLAY_LABELS.HANDOFF_MESSAGE_PLACEHOLDER"),size:"small",variant:"outlined",fullWidth:!0,multiline:!0,minRows:2,onChange:c,slotProps:{inputLabel:{shrink:!0}},sx:{"& .MuiOutlinedInput-root":{backgroundColor:"background.paper",borderRadius:1,alignItems:"flex-start"}}})]})]}),"keyword"===u&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(o.o5u,{variant:"body2",color:"text.secondary",sx:{mb:2},children:l("DISPLAY_STRINGS.HANDOFF_KEYWORD_TAB_DESCRIPTION")}),(0,r.jsx)(o.o5u,{variant:"subtitle2",fontWeight:600,sx:{mb:1},children:l("DISPLAY_STRINGS.HANDOFF_KEYWORDS_AND_PHRASES")}),(0,r.jsx)(o.azJ,{sx:{mb:2},children:(0,x.Hv)(i.user_trigger_handoff_keywords).map((function(e,n){return(0,r.jsx)(o.vu3,{label:e,onDelete:function(){return function(e,n,t){t("user_trigger_handoff_keywords",(0,x._6)(n).filter((function(n){return n!==e})).join(", "))}(e,i.user_trigger_handoff_keywords,d)},size:"small",color:"primary",variant:"outlined",sx:{marginRight:1,mb:1,backgroundColor:"transparent","&:hover":{backgroundColor:"rgba(33, 150, 243, 0.08)"}}},n)}))}),(0,r.jsx)(o.A_L,{label:l("DISPLAY_STRINGS.KEYWORD_PHRASE"),placeholder:l("DISPLAY_STRINGS.ENTER_KEYWORD_PRESS_ENTER"),variant:"outlined",size:"small",value:_,slotProps:{inputLabel:{shrink:!0}},onChange:function(e){return I(e.target.value)},onKeyDown:function(e){return function(e,n,t){"Enter"===e.key&&""!==_.trim()&&(e.preventDefault(),t("user_trigger_handoff_keywords","".concat(n,", ").concat(_)),I(""))}(e,i.user_trigger_handoff_keywords,d)},onBlur:function(){return function(e,n){""!==_.trim()&&(n("user_trigger_handoff_keywords","".concat(e,", ").concat(_)),I(""))}(i.user_trigger_handoff_keywords,d)},sx:{mb:3,width:"100%"}}),(0,r.jsxs)(o.azJ,{sx:{mt:2},children:[(0,r.jsx)(o.o5u,{variant:"subtitle2",fontWeight:600,sx:{mb:1.5,display:"block"},children:l("DISPLAY_STRINGS.HANDOFF_MESSAGE")}),(0,r.jsx)(b.D0,{as:o.A_L,name:"handoff_response",placeholder:l("DISPLAY_LABELS.HANDOFF_MESSAGE_PLACEHOLDER"),size:"small",variant:"outlined",fullWidth:!0,multiline:!0,minRows:2,onChange:c,slotProps:{inputLabel:{shrink:!0}},sx:{"& .MuiOutlinedInput-root":{backgroundColor:"background.paper",borderRadius:1,alignItems:"flex-start"}}})]})]})]})}),(0,r.jsx)(o.ZpM,{sx:{marginTop:0},children:(0,r.jsx)(ue,{schedule:{is_handoff_scheduled:i.is_handoff_scheduled,handoff_schedule_timezone:i.handoff_schedule_timezone,handoff_days:i.handoff_days},onChange:function(e){d("is_handoff_scheduled",e.is_handoff_scheduled),d("handoff_schedule_timezone",e.handoff_schedule_timezone),d("handoff_days",e.handoff_days)}})}),(0,r.jsx)(o.ZpM,{sx:{marginTop:3},children:(0,r.jsxs)(o.Wux,{children:[(0,r.jsx)(o.azJ,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:(0,r.jsxs)(o.o5u,{variant:"body1",color:"primary",fontWeight:"bold",className:"fw-bolder",children:[(0,r.jsx)(fe.A,{})," ",l("DISPLAY_STRINGS.NOTIFICATION_SETTINGS")]})}),(0,r.jsx)(o.o5u,{variant:"body2",color:"textDisabled",children:l("DISPLAY_STRINGS.NOTIFICATION_SETTINGS_DESCRIPTION")}),(0,r.jsx)(o.ZpM,{sx:{marginTop:3},children:(0,r.jsxs)(o.Wux,{children:[(0,r.jsxs)(o.azJ,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(0,r.jsxs)(o.o5u,{variant:"body1",className:"fw-bold p-2",children:[(0,r.jsx)(fe.A,{fontSize:"small"}),l("DISPLAY_STRINGS.EMAIL_NOTIFICATIONS")]}),(0,r.jsx)(o.vu3,{label:(t=i.handoff_notification_emails,Boolean(null==t?void 0:t.trim())?l("DISPLAY_STRINGS.ACTIVE"):l("DISPLAY_STRINGS.NOT_CONFIGURED")),variant:"outlined",color:i.handoff_notification_emails?"success":"warning",sx:{borderRadius:"16px",height:"24px",fontSize:"0.75rem"}})]}),(0,r.jsx)(o.azJ,{sx:{marginBottom:2},children:(0,x.Hv)(i.handoff_notification_emails).map((function(e,n){return(0,r.jsx)(o.vu3,{label:e,onDelete:function(){return function(e,n,t){t("handoff_notification_emails",(0,x._6)(n).filter((function(n){return n!==e})).join(", "))}(e,i.handoff_notification_emails,d)},color:"primary",variant:"outlined",size:"small",sx:{marginRight:1,marginBottom:1,backgroundColor:"transparent","&:hover":{backgroundColor:"rgba(33, 150, 243, 0.08)"}}},n)}))}),(0,r.jsxs)(o.azJ,{display:"flex",gap:2,alignItems:"center",children:[(0,r.jsx)(o.A_L,{name:"handoff_notification_emails",label:l("DISPLAY_STRINGS.EMAIL"),placeholder:l("DISPLAY_STRINGS.ENTER_EMAIL_PRESS_ENTER"),variant:"outlined",slotProps:{inputLabel:{shrink:!0}},fullWidth:!0,size:"small",value:T,sx:{pointerEvents:"auto"},onChange:function(e){return v(e.target.value)},onKeyDown:function(e){return function(e,n,t){if("Enter"===e.key&&""!==T.trim()){if(e.preventDefault(),!(0,x.B9)(T,!0))return;t("handoff_notification_emails","".concat(n?n+", ":"").concat(T)),v("")}}(e,i.handoff_notification_emails,d)},onBlur:function(){return function(e,n){if(""!==T.trim()){if(!(0,x.B9)(T,!0))return;n("handoff_notification_emails","".concat(e?e+", ":"").concat(T)),v("")}}(i.handoff_notification_emails,d)}}),(0,r.jsx)(o.A_L,{name:"reminder_time",label:l("DISPLAY_STRINGS.REMINDER_TIME"),placeholder:l("DISPLAY_STRINGS.REMINDER_TIME_PLACEHOLDER"),variant:"outlined",slotProps:{inputLabel:{shrink:!0}},fullWidth:!0,size:"small",value:null==i?void 0:i.reminder_time,sx:{pointerEvents:"auto"},onChange:function(e){return d("reminder_time",e.target.value)}})]})]})}),(0,r.jsx)(o.ZpM,{sx:{marginTop:3},children:(0,r.jsxs)(o.Wux,{children:[(0,r.jsxs)(o.azJ,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(0,r.jsxs)(o.o5u,{variant:"body1",className:"fw-bold",children:[(0,r.jsx)(s.TM,{fontSize:"small"}),l("DISPLAY_STRINGS.WEBHOOK")]}),(0,r.jsx)(o.A8K,{webhook_type:ee.c.HUMAN_HANDED_OFF,chatbotId:n})]}),(0,r.jsx)(b.D0,{as:o.A_L,name:"handoff_notification_webhook",label:l("DISPLAY_STRINGS.WEBHOOK_URL"),variant:"outlined",fullWidth:!0,size:"small",sx:{marginTop:3},slotProps:{inputLabel:{shrink:!0}},onChange:c})]})})]})}),(0,r.jsx)(o.ZpM,{sx:{marginTop:3},children:(0,r.jsxs)(o.Wux,{children:[(0,r.jsxs)(o.o5u,{variant:"body1",color:"primary",className:"fw-bolder",children:[(0,r.jsx)(s.Wv,{})," ",l("DISPLAY_STRINGS.PLATFORM_INTEGRATION")]}),(0,r.jsx)(o.o5u,{variant:"body2",color:"textDisabled",children:l("DISPLAY_STRINGS.PLATFORM_INTEGRATION_DESCRIPTION")}),P.map((function(e){return(0,r.jsxs)(o.azJ,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",border:"1px solid",borderColor:"divider",borderRadius:1,padding:"9px",marginTop:2},children:[(0,r.jsxs)(o.o5u,{children:[e.icon," ",e.title]}),(0,r.jsx)(o.dOG,{checked:Boolean(i[e.key]),onChange:function(n){return d(e.key,n.target.checked)}})]},e.key)}))]})}),(0,r.jsx)(o.azJ,{sx:{mt:3,display:"flex",justifyContent:"flex-end"},children:(0,r.jsx)(o.$nd,{variant:"contained",type:"submit",children:l("DISPLAY_LABELS.SAVE_BUTTON")})})]});return(0,r.jsx)(b.lV,{children:a?(0,r.jsxs)(o.Wux,{sx:{p:3,"&:last-child":{pb:3}},children:[(0,r.jsx)(_e,{title:l("DISPLAY_STRINGS.HUMAN_HANDOFF_SETTINGS"),description:l("DISPLAY_STRINGS.HUMAN_HANDOFF_SETTINGS_DESCRIPTION")}),(0,r.jsxs)("div",{style:{position:"relative"},children:[f,h&&(0,r.jsx)("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.7)",zIndex:1e3,display:"flex",alignItems:"center",justifyContent:"center",cursor:"not-allowed",pointerEvents:"all",padding:"24px"},children:(0,r.jsx)(o.QIW,{})})]})]}):(0,r.jsx)(o.Zkm,{title:l("DISPLAY_STRINGS.HUMAN_HANDOFF_SETTINGS"),description:l("DISPLAY_STRINGS.HUMAN_HANDOFF_SETTINGS_DESCRIPTION"),children:(0,r.jsxs)("div",{style:{position:"relative"},children:[f,h&&(0,r.jsx)("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.7)",zIndex:1e3,display:"flex",alignItems:"center",justifyContent:"center",cursor:"not-allowed",pointerEvents:"all",padding:"24px"},children:(0,r.jsx)(o.QIW,{})})]})})})}})})},Ie=t(8919),me=t(14160),Te="tab",ve=function(e){var n=e.label;return(0,r.jsx)(o.vu3,{label:n,size:"x-small",color:"warning",sx:{ml:1,color:"common.white",textTransform:"uppercase"}})},be=function(e){var n,t,s=e.chatbotId,u=(0,c.Bd)().t,h={GENERAL:{value:"general",name:u("DISPLAY_LABELS.GENERAL_TAB"),isNew:!1},HUMAN_HANDOFF:{value:"human-handoff",name:u("DISPLAY_STRINGS.HUMAN_HANDOFF_SETTINGS"),isNew:!1},NUDGING:{value:"nudging",name:u("DISPLAY_LABELS.NUDGING_SETTINGS_TAB"),isNew:!0,description:u("DISPLAY_STRINGS.NUDGING_SETTINGS_DESC")},UNKNOWN_ANSWER_NOTIFICATIONS:{value:"unknown-answer-notifications",name:u("DISPLAY_LABELS.UNKNOWN_ANSWER_NOTIFICATIONS_TAB"),isNew:!1},MESSAGE_RATING:{value:"message-rate",name:u("DISPLAY_LABELS.MESSAGE_RATE_LIMITS_TAB"),isNew:!1,description:u("DISPLAY_STRINGS.MESSAGE_RATE_LIMITS_DESC")}}
1,S=(0,l.cG)(s),p=S.data,x=S.isLoading,f=S.refetch,_=(0,i.useState)(!1),A=_[0],I=_[1],m=(0,i.useState)((function(){return new URLSearchParams(window.location.search).get(Te)||h.GENERAL.value})),T=m[0],b=m[1];(0,i.useEffect)((function(){var e=new URL(window.location.href);T!==h.GENERAL.value?e.searchParams.set(Te,T):e.searchParams.delete(Te),window.history.replaceState({},"",e.toString())}),[T]);var g=Object.values(h).find((function(e){return e.value===T})),E=(0,r.jsx)(o.IzF,{value:T,exclusive:!0,onChange:function(e,n){null!==n&&b(n)},"aria-label":u("DISPLAY_LABELS.SETTINGS_TABS"),size:"small",color:"primary",children:Object.entries(h).map((function(e){var n=e[0],t=e[1];return(0,r.jsxs)(o.ffE,{value:t.value,children:[t.name,t.isNew&&(0,r.jsx)(ve,{label:u("DISPLAY_LABELS.NEW_BADGE")})]},n)}))});return(0,r.jsx)(o.fPr,{container:!0,spacing:2,justifyContent:"center",children:(0,r.jsx)(o.fPr,{container:!0,spacing:2,size:12,children:(0,r.jsxs)(o.fPr,{size:12,children:[(0,r.jsx)(d,{faqs:(null===(n=null==p?void 0:p.faq)||void 0===n?void 0:n.questionsAnswers)||[],showFAQModal:A,setShowFAQModal:I}),(0,r.jsxs)(o.ZpM,{children:[s&&(0,r.jsx)(o.azJ,{sx:{px:2,py:1.5,borderBottom:"1px solid",borderColor:"divider"},children:E}),T===h.HUMAN_HANDOFF.value&&s?(0,r.jsx)(Ie.A,{permission:me.Qp.CAN_USE_HUMAN_HANDOFF.value,loadingSkeleton:(0,r.jsx)(pe,{}),children:(0,r.jsx)(Ae,{chatbotId:s,embedded:!0})}):(0,r.jsxs)(o.Wux,{sx:{p:3,"&:last-child":{pb:3}},children:[g&&(0,r.jsxs)(o.azJ,{sx:{mb:2.5},children:[(0,r.jsx)(o.o5u,{variant:"subtitle1",color:"primary",fontWeight:700,children:g.name}),g.description&&(0,r.jsx)(o.o5u,{variant:"body2",color:"text.secondary",sx:{mt:.5},children:g.description})]}),T===h.GENERAL.value&&(0,r.jsx)(a.A,{categories:(null==p?void 0:p.categories)||[],defaultChoice:(null==p?void 0:p.defaultChoice)||(null===(t=null==p?void 0:p.gptModels[0])||void 0===t?void 0:t.id),chatbotId:s,settings:p,isLoadingSettings:x,refetchSettings:f,setShowFAQModal:I}),T===h.MESSAGE_RATING.value&&s&&(0,r.jsx)(v,{chatbotId:s,settings:null==p?void 0:p.messageRateLimitSettings,isLoading:x}),T===h.NUDGING.value&&s&&(0,r.jsx)(z,{chatbotId:s,settings:null==p?void 0:p.nudgeSettings,isLoading:x}),T===h.UNKNOWN_ANSWER_NOTIFICATIONS.value&&s&&(0,r.jsx)($,{chatbotId:s,settings:null==p?void 0:p.unknownAnswerNotificationSettings,isLoading:x})]})]})]})})})},ge=t(81170),Ee=t(95516),ye=t(56450),Le=t(783),Ne=t(25361),je=t(7098),Ce=t(33361),Pe=t(49994),De=t(67325);var Re=function(e){var n,t=e.formikProps,a=e.oldSettings,l=e.isDisabled,s=window.chatbotUUID,c=t.values,d=c.widgetWidth,u=c.widgetHeight,h=c.widgetPosition,S=(0,i.useState)(!1),p=S[0],f=S[1],_=(0,o.DPo)(),A="dark"===_.palette.mode,I=A?_.palette.common.black:_.palette.common.white,m=A?_.palette.grey[900]:_.palette.grey[100],T=A?_.palette.grey[400]:_.palette.grey[800],v=_.palette.divider,b=A?(0,je.X4)(_.palette.common.white,.1):(0,je.X4)(_.palette.common.black,.1),g=(null===(n=De.kG.find((function(e){return e.value==="".concat(d,":").concat(u)})))||void 0===n?void 0:n.label)||"Custom - ".concat(d,"px x ").concat(u,"px");return(0,i.useEffect)((function(){var e=function(){window.parent&&window.parent.postMessage({type:"chatwidget-parent-size",width:window.innerWidth,height:window.innerHeight},"*")};return window.addEventListener("load",e),window.addEventListener("resize",e),function(){window.removeEventListener("load",e),window.removeEventListener("resize",e)}}),[]),window.addEventListener("resize",(function(e){window.parent&&window.parent.postMessage({type:"chatwidget-parent-size",width:window.innerWidth,height:window.innerHeight},"*")})),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(o.azJ,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:2,px:2,py:1.5,borderBottom:"1px solid",borderColor:"divider"},children:[(0,r.jsxs)(o.azJ,{children:[(0,r.jsx)(o.o5u,{variant:"subtitle1",color:"primary",fontWeight:700,children:"Live Preview"}),(0,r.jsxs)(o.o5u,{variant:"body2",color:"text.secondary",sx:{mt:.5},children:[g," • bottom-",h]})]}),(0,r.jsxs)(o.azJ,{sx:{display:"flex",gap:1},children:[(0,r.jsx)(o.$nd,{startIcon:(0,r.jsx)(ye.A,{fontSize:"small"}),variant:"contained",color:"primary",onClick:function(){return t.handleSubmit()},disabled:l,children:"Save"}),(0,r.jsx)(o.$nd,{startIcon:(0,r.jsx)(Ne.A,{fontSize:"small"}),variant:"outlined",color:"primary",onClick:function(){return f(!0)},disabled:l,children:"Reset"}),(0,r.jsx)(o.KKB,{isOpen:p,onClose:function(){return f(!1)},title:"Revert Changes Confirmation",onConfirm:function(){t.setValues(a||(0,Pe.u5)(a)),f(!1)},message:"All the changes will be lost. Are you sure you want to revert the changes?"})]})]}),(0,r.jsx)(o.Wux,{sx:{flex:1,p:3,"&:last-child":{pb:3},display:"flex",flexDirection:"column",minHeight:0},children:(0,r.jsxs)(o.ZpM,{variant:"outlined",sx:{flex:1,backgroundColor:I,display:"flex",flexDirection:"column",minHeight:0},children:[(0,r.jsxs)(o.azJ,{sx:{display:"flex",alignItems:"center",bgcolor:m,pl:1.25}
1,children:[(0,r.jsxs)(o.azJ,{sx:{display:"flex",gap:1},children:[(0,r.jsx)(o.azJ,{sx:{width:10,height:10,bgcolor:"#dc143c",borderRadius:"50%"}}),(0,r.jsx)(o.azJ,{sx:{width:10,height:10,bgcolor:"#ffa500",borderRadius:"50%"}}),(0,r.jsx)(o.azJ,{sx:{width:10,height:10,bgcolor:"#32cd32",borderRadius:"50%"}})]}),(0,r.jsx)(o.azJ,{sx:{display:"flex",alignItems:"center",mt:"5px",ml:1.25,width:180,height:26,bgcolor:I,borderRadius:"10px 10px 0 0"},children:(0,r.jsx)(o.o5u,{variant:"body2",sx:{color:T,pl:1.5},children:(0,x.wy)(location.host)})})]}),(0,r.jsxs)(o.azJ,{sx:{display:"flex",alignItems:"center",gap:1,p:1,boxShadow:"0 4px 2px -2px ".concat(b)},children:[(0,r.jsxs)(o.azJ,{sx:{display:"flex",alignItems:"center",justifyContent:"center",gap:1},children:[(0,r.jsx)(ge.A,{htmlColor:T,fontSize:"small"}),(0,r.jsx)(Ee.A,{htmlColor:T,fontSize:"small"}),(0,r.jsx)(Le.A,{htmlColor:T,fontSize:"small"})]}),(0,r.jsx)(o.azJ,{sx:{width:"-webkit-fill-available",border:"1px solid",borderColor:v,borderRadius:"5px"},children:(0,r.jsx)(o.o5u,{variant:"body2",sx:{color:T,p:"2px 8px"},children:location.origin})})]}),(0,r.jsx)(o.azJ,{sx:{flex:1,position:"relative",minHeight:0,overflow:"hidden",p:"8px",bgcolor:A?(0,je.X4)(_.palette.common.white,.04):_.palette.grey[100]},children:(0,r.jsx)(Ce.A,{chatbotUUID:s,sourcePlatform:De.NR.DASHBOARD,embedType:"bubble",settingConfigurations:t.values,previewOnly:!0})})]})})]})},Oe=t(93610),we=t(65179),Ge=t(14428),Ye=t(38588),Be=t(21942),Me=t(1222);function ke(e){var n=e.formikProps,t=e.expanded,a=e.handleChange,l=e.isDisabled,s=n.values,c=s.widgetHeight,d=s.widgetWidth,u=s.widgetPosition,h=n.setFieldValue,S=(0,i.useState)(!1),p=S[0],x=S[1];return(0,i.useEffect)((function(){var e="".concat(d,":").concat(c),n=De.kG.find((function(n){return n.value===e}));x(!n)}),[d,c]),(0,r.jsxs)(Me.L,{title:"Layout & Display",icon:(0,r.jsx)(Be.A,{color:"primary",fontSize:"small"}),expanded:t===De.nI.LAYOUT_DISPLAY,onChange:a(De.nI.LAYOUT_DISPLAY),children:[(0,r.jsx)(o.JU7,{name:"Widget Size",helptext:"The size of the widget",style:{fontWeight:500}}),(0,r.jsx)(Oe.A,{sx:{marginBottom:1},value:"".concat(d,":").concat(c),disabled:l,onChange:function(e){var n=e.target.value;if("custom"!==n){var t=n.split(":"),r=t[0],i=t[1];h("widgetHeight",Number(i)),h("widgetWidth",Number(r))}else x(!0)},fullWidth:!0,size:"small",renderValue:function(e){var n=De.kG.find((function(n){return n.value===e}));return(null==n?void 0:n.label)||"Custom"},children:De.kG.map((function(e){return(0,r.jsx)(we.A,{value:e.value,children:e.label},e.value)}))}),p&&(0,r.jsxs)(Ge.A,{container:!0,spacing:2,mb:1,children:[(0,r.jsxs)(Ge.A,{size:6,children:[(0,r.jsx)(o.JU7,{name:"Width (px)",helptext:"The custom width of the widget",style:{fontWeight:500}}),(0,r.jsx)(Ye.A,{value:d,type:"number",inputProps:{min:300,step:1},size:"small",fullWidth:!0,disabled:l,onChange:function(e){h("widgetWidth",Number(e.target.value))}})]}),(0,r.jsxs)(Ge.A,{size:6,children:[(0,r.jsx)(o.JU7,{name:"Height (px)",helptext:"The custom height of the widget",style:{fontWeight:500}}),(0,r.jsx)(Ye.A,{value:c,type:"number",inputProps:{min:400,step:1},size:"small",fullWidth:!0,disabled:l,onChange:function(e){h("widgetHeight",Number(e.target.value))}})]})]}),(0,r.jsx)(o.JU7,{name:"Widget Position",helptext:"The position of the widget on the page",style:{fontWeight:500}}),(0,r.jsxs)(Oe.A,{value:u,disabled:l,onChange:function(e){h("widgetPosition",e.target.value)},fullWidth:!0,size:"small",children:[(0,r.jsx)(we.A,{value:"left",children:"Bottom Left"}),(0,r.jsx)(we.A,{value:"right",children:"Bottom Right"})]})]})}var Ue=t(95614);function ze(e){var n=e.formikProps,t=e.expanded,i=e.handleChange,a=e.isDisabled,l=(0,A.nd)(),s=l.data,c=l.isFetching,d="nwl_free"===(null==s?void 0:s.subscribedPlanKey),h=!c&&!d,S=n.values,p=S.displayName,x=S.subheading,f=S.initialMessage,_=S.chatInputPlaceholder,I=S.leadsCollectionFormPromptText,m=S.tagline,T=S.showTagline,v=n.setFieldValue;return(0,r.jsxs)(Me.L,{title:"Content & Messages",icon:(0,r.jsx)(Ue.A,{color:"primary",fontSize:"small"}),expanded:t===De.nI.CONTENT_MESSAGES,onChange:i(De.nI.CONTENT_MESSAGES),children:[(0,r.jsx)(o.JU7,{name:"Bot Name",helptext:"The name of the chatbot to be displayed on the widget",style:{fontWeight:500}}),(0,r.jsx)(b.D0,{mb:1,name:"displayName",placeholder:"Name of the chatbot",component:Ye.A,fullWidth:!0,size:"small",value:p,onChange:function(e){v("displayName",e.target.value)},disabled:a}),(0,r.jsx)(o.JU7,{name:"Subheading/Status",helptext:"The subheading/status message of the chatbot to be displayed on the widget",style:{fontWeight:500,marginTop:"10px"}}),(0,r.jsx)(b.D0,{name:"subheading",placeholder:"Typing...",component:Ye.A,fullWidth:!0,size:"small",value:x,onChange:function(e){v("subheading",e.target.value)},disabled:a}),(0,r.jsx)(o.JU7,{name:"Welcome Message",helptext:"The welcome message displayed in the popup and start of the conversation. Each message is separated by a new line. HTML 
1supported (for hyperlinks and line breaks).",style:{fontWeight:500,marginTop:"10px"}}),(0,r.jsx)(b.D0,{name:"initialMessage",placeholder:"Welcome! How can I help you today?",component:Ye.A,fullWidth:!0,multiline:!0,rows:4,size:"small",value:f,onChange:function(e){v("initialMessage",e.target.value)},sx:{"& .MuiFormHelperText-root":{margin:0}},helperText:"HTML supported. Use <br> for line breaks.",disabled:a}),(0,r.jsx)(o.JU7,{name:"Input Placeholder",helptext:"The placeholder of the chat input box.",style:{fontWeight:500,marginTop:"10px"}}),(0,r.jsx)(b.D0,{name:"chatInputPlaceholder",placeholder:"Type your message...",component:Ye.A,fullWidth:!0,size:"small",value:_,onChange:function(e){v("chatInputPlaceholder",e.target.value)}}),(0,r.jsx)(o.JU7,{name:"Leads Collection Form Prompt Text",helptext:"The text of the leads collection form prompt to be displayed on the widget.",style:{fontWeight:500,marginTop:"10px"}}),(0,r.jsx)(b.D0,{name:"leadsCollectionFormPromptText",placeholder:"Please provide the information requested to continue:",component:Ye.A,fullWidth:!0,size:"small",value:I,onChange:function(e){v("leadsCollectionFormPromptText",e.target.value)},disabled:a}),h&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(u.A,{display:"flex",justifyContent:"space-between",alignItems:"center",mt:"10px",children:[(0,r.jsx)(o.JU7,{name:"Show Tagline",helptext:T?"The text of the tagline to be displayed on the widget. HTML supported (for hyperlinks).":"Whether to hide the tagline in the widget",style:{fontWeight:500}}),(0,r.jsx)(u.A,{children:(0,r.jsx)(ie.A,{sx:{"& .MuiSwitch-thumb":{marginTop:"-10px"}},checked:T,disabled:a,onChange:function(e){v("showTagline",e.target.checked)}})})]}),T&&(0,r.jsx)(u.A,{sx:{marginTop:"-10px"},children:(0,r.jsx)(b.D0,{name:"tagline",placeholder:"Powered by 'Your Brand' <a href='https://yourbrand.com'>Your Brand</a>",component:Ye.A,fullWidth:!0,size:"small",value:m,onChange:function(e){v("tagline",e.target.value)},disabled:a})})]})]})}var We=t(53630),He=t(48608);function Fe(e){var n=e.formikProps,t=e.expanded,i=e.handleChange,a=e.isDisabled,l=n.values,s=l.showTimestamp,c=l.enableActions,d=l.enableSoundEffects,h=l.conversationStarterMessage,S=l.persistentConversationStarterMessage,p=n.setFieldValue;return(0,r.jsxs)(Me.L,{title:"Features",icon:(0,r.jsx)(He.A,{color:"primary",fontSize:"small"}),expanded:t===De.nI.FEATURES,onChange:i(De.nI.FEATURES),children:[(0,r.jsx)(o.JU7,{name:"Quick Messages",helptext:"Predefined clickable messages for user prompts. Separate multiple messages with new lines",style:{fontWeight:500}}),(0,r.jsx)(b.D0,{name:"conversationStarterMessage",placeholder:"What would you like to know about us?",component:Ye.A,multiline:!0,rows:4,fullWidth:!0,size:"small",value:h,onChange:function(e){p("conversationStarterMessage",e.target.value)},disabled:a}),(0,r.jsx)(We.A,{sx:{my:1}}),(0,r.jsxs)(u.A,{display:"flex",justifyContent:"space-between",alignItems:"center",mt:1,children:[(0,r.jsx)(o.JU7,{name:"Persist Quick Messages",helptext:"Keep the quick messages remain visible throughout the conversation.",style:{fontWeight:500}}),(0,r.jsx)(u.A,{children:(0,r.jsx)(ie.A,{sx:{"& .MuiSwitch-thumb":{marginTop:"-10px"}},checked:S,onChange:function(e){p("persistentConversationStarterMessage",e.target.checked)},disabled:a})})]}),(0,r.jsxs)(u.A,{display:"flex",justifyContent:"space-between",alignItems:"center",children:[(0,r.jsx)(o.JU7,{name:"Show Action Buttons",helptext:"Whether to show action buttons for each message in the conversation (Copy, Reactions, etc.).",style:{fontWeight:500}}),(0,r.jsx)(u.A,{children:(0,r.jsx)(ie.A,{sx:{"& .MuiSwitch-thumb":{marginTop:"-10px"}},checked:c,onChange:function(e){p("enableActions",e.target.checked)},disabled:a})})]}),(0,r.jsxs)(u.A,{display:"flex",justifyContent:"space-between",alignItems:"center",children:[(0,r.jsx)(o.JU7,{name:"Show Timestamp",helptext:"Whether to show the timestamp in the messages",style:{fontWeight:500}}),(0,r.jsx)(u.A,{children:(0,r.jsx)(ie.A,{sx:{"& .MuiSwitch-thumb":{marginTop:"-10px"}},checked:s,disabled:a,onChange:function(e){p("showTimestamp",e.target.checked)}})})]}),(0,r.jsxs)(u.A,{display:"flex",justifyContent:"space-between",alignItems:"center",children:[(0,r.jsx)(o.JU7,{name:"Sound Effects",helptext:"Gives a sound feedback when a message is recieved.",style:{fontWeight:500}}),(0,r.jsx)(u.A,{children:(0,r.jsx)(ie.A,{sx:{"& .MuiSwitch-thumb":{marginTop:"-10px"}},checked:d,onChange:function(e){p("enableSoundEffects",e.target.checked)},disabled:a})})]})]})}var Ke=t(70559),Je=t(26400),Ve=t(20275);function qe(e){var n=e.formikProps,t=e.expanded,i=e.handleChange,a=e.isDisabled,l=n.values,s=l.isStreamingEnabled,c=l.enableResponseTypingSimulation,d=l.responseTypingSpeed,h=l.enableAiAgentStatusMessages,S=l.aiAgentStatusMessages,p=n.setFieldValue;return(0,r.jsxs)(Me.L,{title:"Automation & Timing",icon:(0,r.jsx)(Ve.A,{color:"primary",fontSize:"small"}),expanded:t===De.nI.AUTOMATION_TIMING,onChange:i(De.nI.AUTOMATION_TIMING),children:[(0,r.jsx)(Ke.A,{arrow:!0,placement:"top",title:s?"Streaming is enabled. Typing simulation is disabled.":"",children:(0,r.jsxs)(u.A,{sx:{opacity:s?.5:1},children:[(0,r.jsxs)(u.A,{display:"flex",justifyContent:"space-between",alignItems:"center",children:[(0,r.jsx)(o.JU7,{name:"Typing Simulation",helptext:"Simulate the typing of responses if not streaming.",style:{fontWeight:500}}),(0,r.jsx)(u.A,{children:(0,r.jsx)(ie.A,{sx:{"& .MuiSwitch-thumb":{marginTop:"-10px"}},disabled:s||a,checked:c,onChange:function(e){p("enableResponseTypingSimulation",e.target.checked)}})})]}),c&&!s&&(0,r.jsx)(u.A,{mx:"10px",children:(0,r.jsx)(o.KK8,{disabled:s||a,min:1,max:10,step:1,value:d,onChange:function(e,n){return p("responseTypingSpeed",n)}})})]})}),(0,r.jsx)(We.A,{sx:{my:1}}),(0,r.jsxs)(u.A,{display:"flex",justifyContent:"space-between",alignItems:"center",children:[(0,r.jsx)(o.JU7,{name:"Status Messages",helptext:"Display the status messages of the AI agent in the chat widget while thinking.",style:{fontWeight:500}}),(0,r.jsx)(u.A,{children:(0,r.jsx)(ie.A,{sx:{"& .MuiSwitch-thumb":{marginTop:"-10px"}},checked:h,onChange:function(e){p("enableAiAgentStatusMessages",e.target.checked)},disabled:a})})]}),h&&(0,r.jsx)(b.D0,{name:"aiAgentStatusMessages",placeholder:"Agent is reading and analyzing your messages\\nAgent is checking the knowledge base\\nAgent is generating a response",component:Ye.A,fullWidth:!0,multiline:!0,rows:4,size:"small",value:S,onChange:function(e){p("aiAgentStatusMessages",e.target.value)},disabled:a}),(0,r.jsx)(We.A,{sx:{my:1}}),(0,r.jsx)(Je.A,{variant:"outlined",color:"primary",fullWidth:!0,size:"small",onClick:function(){var e=y.n.CHATBOT.INTEGRATIONS_PAGE(window.chatbotId)+"?focus=chat-widget-settings";(0,x.dg)(e)},children:"Change Popup Behaviour"})]})}var Qe=t(23792);function $e(e){var n=e.formikProps,t=e.expanded,i=e.handleChange,a=e.isDisabled,l=n.values,s=l.fontFamily,c=l.fontSize,d=n.setFieldValue;return(0,r.jsxs)(Me.L,{title:"Typography",icon:(0,r.jsx)(Qe.A,{color:"primary",fontSize:"small"}
1),expanded:t===De.nI.TYPOGRAPHY,onChange:i(De.nI.TYPOGRAPHY),children:[(0,r.jsx)(o.JU7,{name:"Font Family",helptext:"Font family of the chat widget.",style:{fontWeight:500}}),(0,r.jsx)(Oe.A,{sx:{marginBottom:1},value:s,onChange:function(e){d("fontFamily",e.target.value)},fullWidth:!0,size:"small",disabled:a,children:Pe.I$.map((function(e){return(0,r.jsx)(we.A,{value:e.value,children:e.label},e.value)}))}),(0,r.jsxs)(u.A,{display:"flex",justifyContent:"space-between",alignItems:"center",children:[(0,r.jsx)(o.JU7,{name:"Font Size",helptext:"Font size of the chat widget.",style:{fontWeight:500}}),(0,r.jsx)(u.A,{children:(0,r.jsxs)(te.A,{variant:"subtitle2",color:"text.secondary",fontWeight:500,children:[c,"px"]})})]}),(0,r.jsx)(u.A,{mx:"10px",children:(0,r.jsx)(o.KK8,{disabled:a,min:10,max:24,step:1,value:c,onChange:function(e,n){d("fontSize",n)}})})]})}var Xe=t(88083),Ze=t(34266);function en(e){var n=e.formikProps,t=e.isDisabled,a=(0,i.useState)(De.nI.CONTENT_MESSAGES),l=a[0],s=a[1],c=function(e){return function(n,t){s(!!t&&e)}};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(o.DOo,{sx:{mt:1},onChange:function(e){return function(e){var n=Object.entries(De.iz).find((function(n){var t=n[0];return n[1],t.toLowerCase().includes(e.toLowerCase())}));s(!!n&&n[1])}(e)},fullWidth:!0}),(0,r.jsx)(We.A,{sx:{my:2}}),(0,r.jsx)(ze,{formikProps:n,expanded:l,handleChange:c,isDisabled:t}),(0,r.jsx)(ke,{formikProps:n,expanded:l,handleChange:c,isDisabled:t}),(0,r.jsx)(Fe,{formikProps:n,expanded:l,handleChange:c,isDisabled:t}),(0,r.jsx)(qe,{formikProps:n,expanded:l,handleChange:c,isDisabled:t}),(0,r.jsx)($e,{formikProps:n,expanded:l,handleChange:c,isDisabled:t}),(0,r.jsx)(Ze.Ay,{formikProps:n,expanded:l,handleChange:c,isDisabled:t}),(0,r.jsx)(Xe.A,{formikProps:n,expanded:l,handleChange:c,isDisabled:t})]})}var nn,tn,rn,on=t(51080);function an(e){var n=e.formikProps,t=e.isDisabled,i=(0,c.Bd)().t,a=n.values,l=n.setFieldValue;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(We.A,{sx:{my:2}}),(0,r.jsx)(o.JU7,{name:"Custom CSS"}),(0,r.jsx)(te.A,{variant:"body1",color:"text.secondary",children:"Write custom CSS to style your chat widget. Use the element references below."}),(0,r.jsx)(Ye.A,{multiline:!0,fullWidth:!0,disabled:t,rows:18,value:a.rawCss||"",onChange:function(e){return l("rawCss",e.target.value)},placeholder:De.xK,sx:{mt:2,mb:1,"& .MuiInputBase-root":{padding:"10px",fontSize:"12px !important",fontFamily:'"Courier New", monospace !important'}}}),(0,r.jsxs)(te.A,{variant:"caption",color:"warning",children:[(0,r.jsx)(on.A,{fontSize:"small",sx:{mr:.5}}),i("DISPLAY_LABELS.CUSTOM_CSS_WARNING")]}),(0,r.jsx)(We.A,{sx:{mt:1,mb:2}}),(0,r.jsx)(o.JU7,{name:"Widget Elements References"}),(0,r.jsx)(Me.z,{className:".chat-widget-container",description:"Widget header container."}),(0,r.jsx)(Me.z,{className:".chat-widget-header",description:"Widget header container."}),(0,r.jsx)(Me.z,{className:".chat-widget-body",description:"Widget body container."}),(0,r.jsx)(Me.z,{className:".message-container",description:"Message container."}),(0,r.jsx)(Me.z,{className:".message-user",description:"User message container."}),(0,r.jsx)(Me.z,{className:".message-agent",description:"Agent message container."}),(0,r.jsx)(Me.z,{className:".read-more-button",description:"Read more/less button."}),(0,r.jsx)(Me.z,{className:".message-action-buttons",description:"Message action buttons container."}),(0,r.jsx)(Me.z,{className:".action-button",description:"Message action button."}),(0,r.jsx)(Me.z,{className:".answer-sources-button",description:"Answer sources button."}),(0,r.jsx)(Me.z,{className:".answer-sources-popover",description:"Answer sources popover container."}),(0,r.jsx)(Me.z,{className:".chat-widget-footer",description:"Widget footer container."}),(0,r.jsx)(Me.z,{className:".chat-widget-input",description:"Chat widget input container."}),(0,r.jsx)(Me.z,{className:".chat-bubble",description:"Chat bubble button."}),(0,r.jsx)(Me.z,{className:".load-previous-chats-button",description:"Load previous chats button."}),(0,r.jsx)(Me.z,{className:".starter-messages",description:"Starter messages container."}),(0,r.jsx)(Me.z,{className:".initial-message",description:"Initial popup message."}),(0,r.jsx)(Me.z,{className:".starter-message-item",description:"Starter message item."}
1),(0,r.jsx)(Me.z,{className:".reset-chat-dialog",description:"Reset Chat Dialog Container."}),(0,r.jsx)(We.A,{sx:{my:2}}),(0,r.jsx)(o.JU7,{name:"Lead Collection Form References"}),(0,r.jsx)(Me.z,{className:".lead-collection-form-container",description:"Lead collection form container."}),(0,r.jsx)(Me.z,{className:".lead-collection-form-input-field",description:"Lead collection form input field."}),(0,r.jsx)(Me.z,{className:".lead-collection-form-close-btn",description:"Lead collection form close button."}),(0,r.jsx)(Me.z,{className:".lead-collection-form-input-label",description:"Lead collection form input label."}),(0,r.jsx)(Me.z,{className:".lead-collection-form-submit-btn",description:"Lead collection form submit button."})]})}!function(e){e.CLASSIC_BLUE="classic_blue",e.DARK="dark",e.LIGHT="light",e.MIDNIGHT_PURPLE="midnight_purple",e.CLASSIC_TEAL="classic_teal",e.PURPLE_GRADIENT="purple_gradient",e.MINIMAL_CLEAN="minimal_clean"}(rn||(rn={}));var ln=((nn={})[rn.CLASSIC_BLUE]="Classic Blue",nn[rn.DARK]="Dark",nn[rn.LIGHT]="Light",nn[rn.MIDNIGHT_PURPLE]="Midnight Purple",nn[rn.CLASSIC_TEAL]="Classic Teal",nn[rn.PURPLE_GRADIENT]="Purple Gradient",nn[rn.MINIMAL_CLEAN]="Minimal Clean",nn),sn=Object.values(rn).map((function(e){return{label:ln[e],value:e}})),cn=((tn={})[rn.CLASSIC_BLUE]={chatwidgetTitleTextColor:"#ffffff",userMsgTextColor:"#69707a",aiMsgTextColor:"#69707a",userMessageBgColor:"#dae7fb",aiMessageBgColor:"#e0e5ec",headerGradientColor_1:"#0061f2",headerGradientColor_2:"#5f1a9c",taglineColor:"#3d3d3d",chatInputTextColor:"#02070d",widgetBorderColor:"#ededed",widgetBorderWidth:1,widgetBgPreference:"color",widgetBgColor:"#fff",widgetInputBgColor:"#fafafa",hyperlinkColor:"#0964f1",chatBubbleColor:"#0000ff",showTimestamp:!0,showActions:!0},tn[rn.LIGHT]={chatwidgetTitleTextColor:"#000000",userMsgTextColor:"#000000",aiMsgTextColor:"#45494f",userMessageBgColor:"#e8e8e8",aiMessageBgColor:"#ffffff",headerGradientColor_1:"#ffffff",headerGradientColor_2:"#ffffff",taglineColor:"#3d3d3d",chatInputTextColor:"#000000",widgetBorderColor:"#ededed",widgetBorderWidth:1,widgetBgPreference:"color",widgetBgColor:"#f5f5f5",widgetInputBgColor:"#ffffff",hyperlinkColor:"#0000ff",chatBubbleColor:"#000000",showTimestamp:!0,showActions:!0},tn[rn.DARK]={chatwidgetTitleTextColor:"#ffffff",userMsgTextColor:"#c2c2c2",aiMsgTextColor:"#fafafa",userMessageBgColor:"#1c1c1c",aiMessageBgColor:"#2b2b2b",headerGradientColor_1:"#1c1c1c",headerGradientColor_2:"#3d3d3d",taglineColor:"#e8e8e8",chatInputTextColor:"#d1d1d1",widgetBorderColor:"#000000",widgetBorderWidth:0,widgetBgPreference:"color",widgetBgColor:"#454545",widgetInputBgColor:"#242424",hyperlinkColor:"#b0b0b0",chatBubbleColor:"#000000",showTimestamp:!0,showActions:!0},tn[rn.MIDNIGHT_PURPLE]={chatwidgetTitleTextColor:"#ffffff",userMsgTextColor:"#ffffff",aiMsgTextColor:"#1a1a1a",userMessageBgColor:"#523371",aiMessageBgColor:"#f5f5f5",headerGradientColor_1:"#1a1a1a",headerGradientColor_2:"#643172",taglineColor:"#4f265a",chatInputTextColor:"#1a1a1a",widgetBorderColor:"#e0e5ec",widgetBorderWidth:1,widgetBgPreference:"color",widgetBgColor:"#ffffff",widgetInputBgColor:"#fdfdfd",hyperlinkColor:"#0964f1",chatBubbleColor:"#523371",showTimestamp:!0,showActions:!0},tn[rn.CLASSIC_TEAL]={chatwidgetTitleTextColor:"#ffffff",userMsgTextColor:"#ffffff",aiMsgTextColor:"#134e4a",userMessageBgColor:"#14b8a6",aiMessageBgColor:"#f0fdfa",headerGradientColor_1:"#0d9488",headerGradientColor_2:"#0891b2",taglineColor:"#134e4a",chatInputTextColor:"#1a1a1a",widgetBorderColor:"#cff2ee",widgetBorderWidth:1,widgetBgPreference:"color",widgetBgColor:"#ffffff",widgetInputBgColor:"#fdfdfd",hyperlinkColor:"#0964f1",chatBubbleColor:"#14b8a6",showTimestamp:!0,showActions:!0},tn[rn.PURPLE_GRADIENT]={chatwidgetTitleTextColor:"#FFFFFF",userMsgTextColor:"#ffffff",aiMsgTextColor:"#581c87",userMessageBgColor:"#a855f7",aiMessageBgColor:"#fdf4ff",headerGradientColor_1:"#8b5cf6",headerGradientColor_2:"#ec4899",taglineColor:"#e100ff",chatInputTextColor:"#1a1a1a",widgetBorderColor:"#e9d5ff",widgetBorderWidth:1,widgetBgPreference:"color",widgetBgColor:"#ffffff",widgetInputBgColor:"#faf5ff",hyperlinkColor:"#0964f1",chatBubbleColor:"#ae57ff",showTimestamp:!0,showActions:!0},tn[rn.MINIMAL_CLEAN]={chatwidgetTitleTextColor:"#000000",userMsgTextColor:"#000000",aiMsgTextColor:"#45494f",userMe
1ssageBgColor:"#d6d6d6",aiMessageBgColor:"#f5f5f5",headerGradientColor_1:"#ffffff",headerGradientColor_2:"#f8f7f7",taglineColor:"#3d3d3d",chatInputTextColor:"#000000",widgetBorderColor:"#ededed",widgetBorderWidth:1,widgetBgPreference:"color",widgetBgColor:"#ffffff",widgetInputBgColor:"#fafafa",chatBubbleColor:"#5c5c5c",hyperlinkColor:"#0000ff",showAvatar:!1,showTimestamp:!1,showActions:!1,showTagline:!1},tn),dn=t(77469),un=function(e){return{"& .MuiInputBase-input, & .MuiSelect-select":{fontSize:e.typography.body2.fontSize}}},hn={PaperProps:{sx:{"& .MuiMenuItem-root":{fontSize:function(e){return e.typography.body2.fontSize}}}}};var Sn=function(e){var n=e.formikProps,t=e.isDisabled,a={fontWeight:500,color:(0,o.DPo)().palette.primary.main},l=(0,x.jr)().mode,s=(0,i.useState)(l||De.S9.UI_SETTINGS),c=s[0],d=s[1];return(0,r.jsxs)(o.azJ,{sx:un,children:[(0,r.jsx)(o.JU7,{name:"Templates",style:a}),(0,r.jsx)(o.l6P,{value:"",onChange:function(e){var t=e.target.value,r=cn[t];Object.entries(r).forEach((function(e){var t=e[0],r=e[1];void 0!==r&&n.setFieldValue(t,r)}))},fullWidth:!0,size:"small",displayEmpty:!0,disabled:t,MenuProps:hn,renderValue:function(){return"Design Template"},children:sn.map((function(e){var n=e.value,t=e.label;return(0,r.jsxs)(o.Drp,{value:n,children:[(0,r.jsx)(dn.A,{fontSize:"small",sx:{mr:1}})," ",t]},n)}))}),(0,r.jsx)(o.cGx,{sx:{mb:1,mt:2}}),(0,r.jsx)(o.JU7,{name:"Customization Mode",style:a}),(0,r.jsx)(o.l6P,{value:c,onChange:function(e){var n=e.target.value;d(n),(0,x.y4)("mode",n)},fullWidth:!0,size:"small",displayEmpty:!0,disabled:t,MenuProps:hn,children:(0,De.Y5)().map((function(e){var n=e.value,t=e.label;return(0,r.jsx)(o.Drp,{value:n,children:t},n)}))}),(0,r.jsx)(o.azJ,{children:c===De.S9.UI_SETTINGS?(0,r.jsx)(en,{formikProps:n,isDisabled:t}):(0,r.jsx)(an,{formikProps:n,isDisabled:t})})]})},pn=t(38044);var xn=function(){var e=window.chatbotUUID,n=(0,pn.mi)(e),t=n.data,a=n.isLoading,l=n.refetch,s=n.isRefetching,c=t||null,d=(0,i.useState)(!1),u=d[0],h=d[1],S=u||a||s;return(0,r.jsx)(o.L0s,{permission:me.Qp.CAN_CUSTOMIZE_APPEARANCE.value,loadingSkeleton:(0,r.jsx)(o.ZpM,{sx:{height:"85vh"}}),children:(0,r.jsx)(o.l1m,{initialValues:c||(0,Pe.u5)(c),enableReinitialize:!0,onSubmit:function(n){(0,pn.cB)(e,n).then((function(e){(0,x.vd)(e),l()})).catch((function(e){var n,t;(0,x.ag)((null===(t=null===(n=e.response)||void 0===n?void 0:n.data)||void 0===t?void 0:t.message)||"Failed to update chat widget appearance")})).finally((function(){h(!1)}))},children:function(e){return(0,r.jsx)(b.lV,{children:(0,r.jsx)(o.ZpM,{sx:{height:"85vh",overflow:"hidden"},children:(0,r.jsxs)(o.fPr,{container:!0,sx:{height:"100%",flexWrap:"nowrap"},children:[(0,r.jsx)(o.fPr,{size:{xs:12,md:4,xl:3},sx:{borderRight:"1px solid",borderColor:"divider",height:"100%",overflow:"auto","::-webkit-scrollbar":{display:"none"}},children:(0,r.jsx)(o.Wux,{sx:{p:3,"&:last-child":{pb:3}},children:(0,r.jsx)(Sn,{formikProps:e,isDisabled:S})})}),(0,r.jsx)(o.fPr,{size:{xs:12,md:8,xl:9},sx:{height:"100%",display:"flex",flexDirection:"column",minWidth:0},children:(0,r.jsx)(Re,{formikProps:e,oldSettings:t||null,isDisabled:S})})]})})})}})})},fn=function(e,n,t,r){return new(t||(t=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function l(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){var n;e.done?i(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(a,l)}s((r=r.apply(e,n||[])).next())}))},_n=function(e,n){var t,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=l(0),a.throw=l(1),a.return=l(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function l(l){return function(s){return function(l){if(t)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(o=0)),o;)try{if(t=1,r&&(i=2&l[0]?r.return:l[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,l[1])).done)return i;switch(r=0,i&&(l=[2&l[0],i.value]),l[0]){case 0:case 1:i=l;break;case 4:return o.label++,{value:l[1],done:!1};case 5:o.label++,r=l[1],l=[0];continue;case 7:l=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==l[0]&&2!==l[0])){o=0;continue}if(3===l[0]&&(!i||l[1]>i[0]&&l[1]<i[3])){o.label=l[1];break}if(6===l[0]&&o.label<i[1]){o.label=i[1],i=l;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(l);break}i[2]&&o.ops.pop(),o.trys.pop();continue}l=n.call(e,o)}catch(e){l=[6,e],r=0}finally{t=i=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,s])}}},An=function(e){return fn(void 0,void 0,void 0,(function(){var n;return _n(this,(function(t){switch(t.label){case 0:return[4,E.Ay.get(y.n.CHATBOT.DETAIL_DASHBOARD(e))];case 1:return n=t.sent(),[2,(0,x.Cb)(n.data)]}}))}))},In=t(4298),mn=t(18982),Tn=t(78153),vn=t(83474),bn=t(80813),gn=t(31184),En=t(16402),yn=t(59492),Ln=t(73349),Nn=t(34994),jn=t(93715),Cn=t(24926),Pn=t(8482),Dn=t(72433),Rn=t(30350),On=t(54935),wn=t(26832),Gn=t(47308),Yn=t(63402),Bn=t(97205),Mn=t(68081),kn=t(58257),Un=t(89543),zn=t(18097),Wn=t(33420),Hn=t(69179),Fn=t(17e3),Kn=t(9752),Jn=t(88914),Vn=t(67496),qn=function(e,n,t,r){return new(t||(t=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function l(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){var n;e.done?i(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(a,l)}s((r=r.apply(e,n||[])).next())}))},Qn=function(e,n){var t,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=l(0),a.throw=l(1),a.return=l(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function l(l){return function(s){return function(l){if(t)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(o=0)),o;)try{if(t=1,r&&(i=2&l[0]?r.return:l[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,l[1])).done)return i;switch(r=0,i&&(l=[2&l[0],i.value]),l[0]){case 0:case 1:i=l;break;case 4:return o.label++,{value:l[1],done:!1};case 5:o.label++,r=l[1],l=[0];continue;case 7:l=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==l[0]&&2!==l[0])){o=0;continue}if(3===l[0]&&(!i||l[1]>i[0]&&l[1]<i[3])){o.label=l[1];break}if(6===l[0]&&o.label<i[1]){o.label=i[1],i=l;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(l);break}i[2]&&o.ops.pop(),o.trys.pop();continue}l=n.call(e,o)}catch(e){l=[6,e],r=0}finally{t=i=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,s])}}},$n=(0,Tn.Ay)(te.A)((function(e){e.theme;return{fontWeight:500}}
1)),Xn=function(e){var n=e.icon,t=e.color,i=void 0===t?"primary.main":t,o=e.children;return(0,r.jsxs)(u.A,{sx:{display:"flex",alignItems:"center",gap:1.25,color:i},children:[n,(0,r.jsx)($n,{children:o})]})},Zn={border:"1px solid",borderColor:"divider",borderRadius:"8px","&.Mui-expanded":{borderRadius:"8px"},"&:before":{display:"none"}},et={minHeight:42,px:1.5,"& .MuiAccordionSummary-content":{color:"primary.main",my:.75},"&.Mui-expanded":{minHeight:42},"&.Mui-expanded .MuiAccordionSummary-content":{my:.75}},nt={px:1.5,pt:.75,pb:1.5},tt=function(e){var n,t,o,a,l,s=e.chatbotId,d=e.uuid,h=e.baseUrl,S=e.isApiAccessible,p=e.apiDocsUrl,f=e.visibility,_=(e.visibilityLabel,e.isRequesterAgencyAdmin),I=void 0!==_&&_,m=(0,c.Bd)().t,T=((0,vn.A)(),(0,F.Jd)().userDetails),v=(null!==(n=null==T?void 0:T.permissions)&&void 0!==n?n:[]).includes(me.Qp.CAN_EMBED_CHATBOT.value),b=i.useState("status"),g=b[0],L=b[1],N=i.useState(!1),j=N[0],C=N[1],P=i.useState(7),D=P[0],R=P[1],O=i.useState("days"),w=O[0],G=O[1],Y=i.useState(""),B=Y[0],M=Y[1],k=i.useState(null),U=k[0],z=k[1],W=i.useState(!1),H=W[0],K=W[1],J=i.useState(!1),V=J[0],q=J[1],Q=i.useState(!1),$=Q[0],X=Q[1],Z=i.useState(!1),ee=Z[0],ae=Z[1],le=i.useState(!1),se=le[0],ce=le[1],de=i.useState(!1),ue=de[0],he=de[1],Se=i.useState(!1),pe=Se[0],xe=Se[1],fe=i.useState(!1),_e=fe[0],Ae=fe[1],Ie=(0,x.BY)(),Te="".concat(h,"/").concat(Ie,"/chatbot/share/").concat(d),ve="".concat(Te,"?clone_chatbot=true"),be=null!=U?U:se?ve:Te,ge="".concat(h,"/").concat(Ie,"/chatbot/visibility/public/").concat(d),Ee="".concat("undefined"!=typeof window?window.location.origin:"").concat(y.n.CHATBOT.CLONE(s)),ye=(0,A._w)(Boolean(_e&&I)).data,Le=function(){(0,x.eM)(be,"Link copied!"),ae(!0),setTimeout((function(){return ae(!1)}),2e3)},Ne=(0,Kn.$m)(s,Jn.kd.ANALYTICS),je=(0,zn.FW)(s,"week","today"),Ce=je.data,Pe=je.isLoading,De=null==Ce?void 0:Ce.overview,Re=null!==(t=null==De?void 0:De.totalConversations)&&void 0!==t?t:"—",Ge=null!==(o=null==De?void 0:De.totalMessages)&&void 0!==o?o:"—",Be=null!==(a=null==De?void 0:De.avgMessagesPerConversation)&&void 0!==a?a:"—",Me=null!==(l=null==De?void 0:De.lastUpdated)&&void 0!==l?l:"—",ke=function(e){return function(n,t){L(!!t&&e)}};return(0,r.jsxs)(u.A,{children:[(0,r.jsxs)(u.A,{sx:{display:"flex",flexDirection:"column",gap:1},children:[(0,r.jsxs)(bn.A,{expanded:"status"===g,onChange:ke("status"),disableGutters:!0,elevation:0,sx:Zn,children:[(0,r.jsx)(gn.A,{expandIcon:(0,r.jsx)(On.A,{sx:{color:"primary.main"}}),sx:et,children:(0,r.jsx)(Xn,{icon:(0,r.jsx)(wn.A,{}),children:m("DISPLAY_STRINGS.AI_AGENT_TAB_STATUS")})}),(0,r.jsxs)(En.A,{sx:nt,children:[(0,r.jsx)(te.A,{variant:"body2",color:"text.secondary",sx:{mb:1.25},children:m("DISPLAY_STRINGS.AI_AGENT_TAB_CURRENT_METRICS")}),(0,r.jsxs)(yn.Ay,{container:!0,spacing:1.25,children:[(0,r.jsx)(yn.Ay,{item:!0,xs:6,children:(0,r.jsxs)(ne.A,{variant:"outlined",sx:{p:1,borderRadius:1.5},children:[(0,r.jsx)(te.A,{variant:"caption",color:"text.secondary",children:m("DISPLAY_STRINGS.AI_AGENT_TAB_TOTAL_CONVERSATIONS")}),(0,r.jsx)(te.A,{variant:"body2",sx:{fontWeight:700},children:Pe?"…":null!=Re?Re:"—"})]})}),(0,r.jsx)(yn.Ay,{item:!0,xs:6,children:(0,r.jsxs)(ne.A,{variant:"outlined",sx:{p:1,borderRadius:1.5},children:[(0,r.jsx)(te.A,{variant:"caption",color:"text.secondary",children:m("DISPLAY_STRINGS.AI_AGENT_TAB_TOTAL_MESSAGES")}),(0,r.jsx)(te.A,{variant:"body2",sx:{fontWeight:700},children:Pe?"…":null!=Ge?Ge:"—"})]})}),(0,r.jsx)(yn.Ay,{item:!0,xs:6,children:(0,r.jsxs)(ne.A,{variant:"outlined",sx:{p:1,borderRadius:1.5},children:[(0,r.jsx)(te.A,{variant:"caption",color:"text.secondary",children:m("DISPLAY_STRINGS.AI_AGENT_TAB_AVG_MESSAGES_PER_CONV")}),(0,r.jsx)(te.A,{variant:"body2",sx:{fontWeight:700},children:Pe?"…":null!=Be?Be:"—"})]})}),(0,r.jsx)(yn.Ay,{item:!0,xs:6,children:(0,r.jsxs)(ne.A,{variant:"outlined",sx:{p:1,borderRadius:1.5},children:[(0,r.jsx)(te.A,{variant:"caption",color:"text.secondary",children:m("DISPLAY_STRINGS.AI_AGENT_TAB_LAST_UPDATED")}),(0,r.jsx)(te.A,{variant:"body2",sx:{fontWeight:700},children:Pe?"…":function(e){if(!e)return"—";var n=new Date(e);return Number.isNaN(n.getTime())?"—":n.toLocaleDateString("en-US",{year:"numeric",month:"short",day:"2-digit"})}(Me)})]})})]}),(0,r.jsx)(Je.A,{component:Fn.N_,fullWidth:!0,startIcon:(0,r.jsx)(Vn.A,{fontSize:"small"}),color:"primary",sx:{mt:1.5,borderRadius:1.5,py:.75,"&:hover":{color:"#fff"}},to:Ne,variant:"contained",children:m("DISPLAY_STRINGS.AI_AGENT_TAB_VIEW_DETAILED_ANALYTICS")})]})]}),(0,r.jsxs)(bn.A,{expanded:"uuid"===g,onChange:ke("uuid"),disableGutters:!0,elevation:0,sx:Zn,children:[(0,r.jsx)(gn.A,{expandIcon:(0,r.jsx)(On.A,{sx:{color:"primary.main"}}),sx:et,children:(0,r.jsx)(Xn,{icon:(0,r.jsx)(Yn.A,{fontSize:"small"}),children:m("DISPLAY_STRINGS.AI_AGENT_TAB_UUID_TITLE")})}),(0,r.jsxs)(En.A,{sx:nt,children:[(0,r.jsxs)(te.A,{variant:"body2",color:"text.secondary",sx:{mb:2},title:S?void 0:m("DISPLAY_STRINGS.AI_AGENT_TAB_API_UPGRADE"),children:[m("DISPLAY_STRINGS.AI_AGENT_TAB_UUID_DESCRIPTION")," ",(0,r.jsx)(Ke.A,{title:S?"":m("DISPLAY_STRINGS.AI_AGENT_TAB_API_UPGRADE"),disableHoverListener:S,children:(0,r.jsx)(u.A,{component:"span",sx:{"& a":{color:S?"primary.main":"text.disabled"}},children:(0,r.jsx)("a",{href:S?p:"#",style:{pointerEvents:S?"auto":"none",textDecoration:"none"},children:m("DISPLAY_STRINGS.AI_AGENT_TAB_API_LABEL")})})})]}),(0,r.jsxs)(ne.A,{variant:"outlined",sx:{p:"5px 10px",borderRadius:2,display:"flex",alignItems:"center",justifyContent:"space-between",gap:2},children:[(0,r.jsx)(te.A,{variant:"body2",sx:{fontFamily:"monospace",overflowWrap:"anywhere"},children:d}),(0,r.jsx)(Je.A,{size:"small",color:"primary",startIcon:$?(0,r.jsx)(Gn.A,{fontSize:"small"}):null,onClick:function(){navigator.clipboard.writeText(d),X(!0),setTimeout((function(){return X(!1)}),1500)},children:m($?"DISPLAY_STRINGS.AI_AGENT_TAB_COPIED":"DISPLAY_STRINGS.AI_AGENT_TAB_COPY")})]})]})]}),(0,r.jsxs)(bn.A,{expanded:"share"===g,onChange:ke("share"),disableGutters:!0,elevation:0,sx:Zn,children:[(0,r.jsx)(gn.A,{expandIcon:(0,r.jsx)(On.A,{sx:{color:"primary.main"}}),sx:et,children:(0,r.jsx)(Xn,{icon:(0,r.jsx)(Bn.A,{fontSize:"small"}),children:m("DISPLAY_STRINGS.AI_AGENT_TAB_SHARE_TITLE")})}),(0,r.jsxs)(En.A,{sx:nt,children:[(0,r.jsx)(te.A,{variant:"body2",color:"text.secondary",sx:{mb:2},children:m("DISPLAY_STRINGS.AI_AGENT_TAB_SHARE_DESCRIPTION")}),(0,r.jsxs)(u.A,{sx:{borderRadius:1},children:[(0,r.jsxs)(u.A,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(0,r.jsx)(te.A,{variant:"body2",sx:{fontWeight:500},children:m("DISPLAY_STRINGS.AI_AGENT_TAB_LINK_EXPIRATION")}),(0,r.jsxs)(u.A,{sx:{display:"flex",alignItems:"center",gap:1},children:[(0,r.jsx)(te.A,{variant:"caption",color:"text.secondary",children:m("DISPLAY_STRINGS.AI_AGENT_TAB_ENABLED")}),(0,r.jsx)(ie.A,{checked:j,onChange:function(e){return C(e.target.checked)}})]})]}),j&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(u.A,{sx:{display:"flex",gap:1.5,mb:1,alignItems:"center"},children:[(0,r.jsx)(Ye.A,{size:"small",variant:"outlined",type:"number",value:D,onChange:function(e){return R(Math.max(1,parseInt(e.target.value)||1))},sx:{width:80},inputProps:{min:1}}),(0,r.jsx)(oe.A,{size:"small",fullWidth:!0,variant:"outlined",children:(0,r.jsxs)(Oe.A,{value:w,onChange:function(e){return G(e.target.value)},children:[(0,r.jsx)(we.A,{value:"hours",children:m("DISPLAY_STRINGS.AI_AGENT_TAB_HOURS")}),(0,r.jsx)(we.A,{value:"days",children:m("DISPLAY_STRINGS.AI_AGENT_TAB_DAYS")})]})})]}),(0,r.jsx)(te.A,{variant:"caption",color:"text.secondary",sx:{dis
1play:"block",mb:2},children:m("DISPLAY_STRINGS.AI_AGENT_TAB_EXPIRATION_OPENING_NOTE",{value:D,unit:m("hours"===w?"DISPLAY_STRINGS.AI_AGENT_TAB_HOURS":"DISPLAY_STRINGS.AI_AGENT_TAB_DAYS").toLowerCase()})}),(0,r.jsx)(te.A,{variant:"body2",sx:{mt:2,fontWeight:500},children:m("DISPLAY_STRINGS.AI_AGENT_TAB_CUSTOM_EXPIRATION_MESSAGE")}),(0,r.jsx)(Ye.A,{size:"small",fullWidth:!0,variant:"outlined",placeholder:m("DISPLAY_STRINGS.AI_AGENT_TAB_CUSTOM_EXPIRATION_PLACEHOLDER"),sx:{mt:1},value:B,onChange:function(e){return M(e.target.value)}})]})]}),"public"!==f&&(0,r.jsxs)(Ln.A,{severity:"warning",sx:{mt:2},children:[m("DISPLAY_STRINGS.AI_AGENT_TAB_NOT_PUBLIC_WARNING")," ",(0,r.jsx)("a",{href:"#",onClick:function(e){e.preventDefault(),he(!0)},children:m("DISPLAY_STRINGS.AI_AGENT_TAB_MAKE_PUBLIC_LINK")}),"."]}),(0,r.jsx)(Je.A,{fullWidth:!0,variant:"contained",color:"primary",sx:{mt:2},disabled:"public"!==f||H,onClick:function(){return qn(void 0,void 0,void 0,(function(){var e,n;return Qn(this,(function(t){switch(t.label){case 0:if(!j)return z(null),xe(!0),[2];K(!0),q(!1),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,E.Ay.post(y.n.CHATBOT.GENERATE_ACCESS_LINK(s),{expiration_enabled:!0,expiration_value:D,expiration_unit:w,custom_message:B})];case 2:return e=t.sent(),n=e.data.token,z("".concat(h,"/").concat(Ie,"/chatbot/access-link/").concat(n,"/")),xe(!0),[3,5];case 3:return t.sent(),q(!0),[3,5];case 4:return K(!1),[7];case 5:return[2]}}
1))}))},children:m(H?"DISPLAY_STRINGS.AI_AGENT_TAB_GENERATING":"DISPLAY_STRINGS.AI_AGENT_TAB_GENERATE_SHARE_LINK")}),V&&(0,r.jsx)(Ln.A,{severity:"error",sx:{mt:1},children:m("DISPLAY_STRINGS.SOMETHING_WENT_WRONG")})]})]}),v&&(0,r.jsxs)(bn.A,{expanded:"embed"===g,onChange:ke("embed"),disableGutters:!0,elevation:0,sx:Zn,children:[(0,r.jsx)(gn.A,{expandIcon:(0,r.jsx)(On.A,{sx:{color:"primary.main"}}),sx:et,children:(0,r.jsx)(Xn,{icon:(0,r.jsx)(Mn.A,{fontSize:"small"}),children:m("DISPLAY_STRINGS.AI_AGENT_TAB_EMBED_TITLE")})}),(0,r.jsxs)(En.A,{sx:nt,children:[(0,r.jsx)(te.A,{variant:"body2",color:"text.secondary",sx:{mb:2},children:m("DISPLAY_STRINGS.AI_AGENT_TAB_EMBED_DESCRIPTION")}),(0,r.jsx)(te.A,{variant:"body2",sx:{fontWeight:500,mb:.5},children:m("DISPLAY_STRINGS.AI_AGENT_TAB_IFRAME_CODE")}),(0,r.jsxs)(u.A,{sx:{position:"relative",mb:2},children:[(0,r.jsx)(ne.A,{variant:"outlined",sx:{p:1.5,pr:5,borderRadius:2,fontFamily:"monospace",typography:"body2",whiteSpace:"pre-wrap",overflowWrap:"anywhere"},children:'<iframe\n  width="100%"\n  height="60%"\n  style="border: none;"\n  title="Chat Agent"\n  allow="microphone; clipboard-read; clipboard-write"\n  src="'.concat("undefined"!=typeof window?window.location.origin:"","/").concat((0,x.BY)(),"/chatbot/embed/").concat(d,'"\n></iframe>')}),(0,r.jsx)(Nn.A,{size:"small",sx:{position:"absolute",top:8,right:8},onClick:function(){var e='<iframe\n  width="100%"\n  height="60%"\n  style="border: none;"\n  title="Chat Agent"\n  allow="microphone; clipboard-read; clipboard-write"\n  src="'.concat("undefined"!=typeof window?window.location.origin:"","/").concat((0,x.BY)(),"/chatbot/embed/").concat(d,'"\n></iframe>');(0,x.eM)(e,"Embed code copied. Please paste it in your website")},children:(0,r.jsx)(Yn.A,{sx:{fontSize:16}})})]}),(0,r.jsx)(te.A,{variant:"body2",sx:{fontWeight:500,mb:.5},children:m("DISPLAY_STRINGS.AI_AGENT_TAB_SCRIPT_CODE")}),(0,r.jsxs)(u.A,{sx:{position:"relative"},children:[(0,r.jsx)(ne.A,{variant:"outlined",sx:{p:1.5,pr:5,borderRadius:2,fontFamily:"monospace",typography:"body2",whiteSpace:"pre-wrap",overflowWrap:"anywhere"},children:'<script\n  data-position="right"\n  data-domain="'.concat("undefined"!=typeof window?window.location.origin:"",'"\n  data-language="').concat((0,x.BY)(),'"\n  data-id="').concat(d,'"\n  src="').concat("undefined"!=typeof window?window.location.origin:"",'/static/chatbot/js/chatbubble.js"\n><\/script>')}),(0,r.jsx)(Nn.A,{size:"small",sx:{position:"absolute",top:8,right:8},onClick:function(){var e='<script\n  data-position="right"\n  data-domain="'.concat("undefined"!=typeof window?window.location.origin:"",'"\n  data-language="').concat((0,x.BY)(),'"\n  data-id="').concat(d,'"\n  src="').concat("undefined"!=typeof window?window.location.origin:"",'/static/chatbot/js/chatbubble.js"\n><\/script>');(0,x.eM)(e,"Script code copied. Please paste it in your website")},children:(0,r.jsx)(Yn.A,{sx:{fontSize:16}})})]})]})]}),(0,r.jsxs)(bn.A,{expanded:"clone"===g,onChange:ke("clone"),disableGutters:!0,elevation:0,sx:Zn,children:[(0,r.jsx)(gn.A,{expandIcon:(0,r.jsx)(On.A,{sx:{color:"primary.main"}}),sx:et,children:(0,r.jsx)(Xn,{icon:(0,r.jsx)(Yn.A,{fontSize:"small"}),children:m("DISPLAY_STRINGS.AI_AGENT_TAB_CLONE_TITLE")})}),(0,r.jsxs)(En.A,{sx:nt,children:[(0,r.jsx)(te.A,{variant:"body2",color:"text.secondary",sx:{mb:2},children:m("DISPLAY_STRINGS.AI_AGENT_TAB_CLONE_DESCRIPTION")}),(0,r.jsx)(te.A,{variant:"body2",sx:{fontWeight:500},children:m("DISPLAY_STRINGS.AI_AGENT_TAB_CLONE_DESCRIPTION_2")}),(0,r.jsxs)(u.A,{sx:{display:"flex",gap:1.5,mt:1.5},children:[(0,r.jsx)(Ye.A,{size:"small",fullWidth:!0,placeholder:m("DISPLAY_STRINGS.AI_AGENT_TAB_NEW_AGENT_NAME_PLACEHOLDER"),variant:"outlined"}),(0,r.jsx)(Je.A,{variant:"contained",color:"primary",sx:{minWidth:90},onClick:function(){return Ae(!0)},children:m("DISPLAY_STRINGS.AI_AGENT_TAB_CLONE_BUTTON")})]})]})]})]}),(0,r.jsxs)(jn.A,{open:ue,onClose:function(){return he(!1)},maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:2,boxShadow:24}},children:[(0,r.jsxs)(Cn.A,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:"1px solid",borderColor:"divider",py:2,pr:1},children:[(0,r.jsx)(te.A,{component:"span",variant:"h6",children:m("DISPLAY_STRINGS.AI_AGENT_TAB_MAKE_PUBLIC_TITLE")}),(0,r.jsx)(Nn.A,{"aria-label":"Close",onClick:function(){return he(!1)},size:"small",children:(0,r.jsx)(Un.A,{})})]}),(0,r.jsx)(Pn.A,{sx:{pt:2.5},children:(0,r.jsxs)(te.A,{variant:"body2",children:[(0,r.jsx)("strong",{children:m("DISPLAY_STRINGS.AI_AGENT_TAB_MAKE_PUBLIC_CONFIRM")}),(0,r.jsx)("br",{}),m("DISPLAY_STRINGS.AI_AGENT_TAB_MAKE_PUBLIC_DESCRIPTION")]})}),(0,r.jsxs)(Dn.A,{sx:{px:3,py:2,borderTop:"1px solid",borderColor:"divider"},children:[(0,r.jsx)(Je.A,{onClick:function(){return he(!1)},color:"error",variant:"outlined",children:m("DISPLAY_STRINGS.CANCEL")}),(0,r.jsx)(Je.A,{variant:"contained",onClick:function(){window.location.href=ge},children:m("DISPLAY_STRINGS.AI_AGENT_TAB_YES_CHANGE_VISIBILITY")})]})]}),(0,r.jsx)(Hn.KKB,{isOpen:pe,onClose:function(){return xe(!1)},onConfirm:Le,title:m("DISPLAY_STRINGS.AI_AGENT_TAB_SHARE_MODAL_TITLE"),confirmButtonLabel:m("DISPLAY_STRINGS.AI_AGENT_TAB_COPY"),cancelButtonLabel:m("DISPLAY_STRINGS.AI_AGENT_TAB_CLOSE_BUTTON"),showLoader:!1,message:(0,r.jsxs)(u.A,{children:[(0,r.jsx)(te.A,{variant:"body2",color:"text.secondary",sx:{mb:1.5},children:m("DISPLAY_STRINGS.AI_AGENT_TAB_SHARE_MODAL_INTRO")}),(0,r.jsxs)(u.A,{sx:{display:"flex",justifyContent:"flex-end",gap:.5,mb:.5},children:[(0,r.jsx)(Ke.A,{title:m(ee?"DISPLAY_STRINGS.AI_AGENT_TAB_COPIED":"DISPLAY_STRINGS.COPY_TOOLTIP"),children:(0,r.jsx)(Nn.A,{size:"small",onClick:Le,"aria-label":m("DISPLAY_STRINGS.AI_AGENT_TAB_COPY_LINK_ARIA"),children:(0,r.jsx)(Yn.A,{fontSize:"small"})})}),(0,r.jsx)(Ke.A,{title:m("DISPLAY_STRINGS.AI_AGENT_TAB_VISIT_LINK"),children:(0,r.jsx)(Nn.A,{component:"a",size:"small",href:be,target:"_blank",rel:"noopener noreferrer","aria-label":m("DISPLAY_STRINGS.AI_AGENT_TAB_VISIT_LINK_ARIA"),children:(0,r.jsx)(kn.A,{fontSize:"small"})})})]}),(0,r.jsx)(ne.A,{component:"pre",variant:"outlined",sx:{m:0,p:1.5,borderRadius:2,fontFamily:"monospace",typography:"body2",wordBreak:"break-all",whiteSpace:"pre-wrap",backgroundColor:"action.hover",borderColor:"divider"},children:be}),I&&(0,r.jsx)(u.A,{sx:{mt:2.5},children:(0,r.jsx)(re.A,{sx:{mb:0,alignItems:"flex-start"},control:(0,r.jsx)(Rn.A,{checked:se,onChange:function(e){return ce(e.target.checked)},size:"small",sx:{pt:0}}),label:(0,r.jsxs)(u.A,{children:[(0,r.jsx)(te.A,{variant:"body2",children:m("DISPLAY_STRINGS.AI_AGENT_TAB_ALLOW_USERS_TO_CLONE")}),(0,r.jsx)(te.A,{variant:"caption",sx:{color:"text.secondary"},children:m("DISPLAY_STRINGS.AI_AGENT_TAB_ALLOW_CLONE_HELP")})]})})})]})}),(0,r.jsx)(Wn.A,{open:_e,onClose:function(){return Ae(!1)},isAgencyUser:I,subaccounts:null==ye?void 0:ye.data,isHijacked:!1,onClone:function(e,n){var t=Ee;
1if(e||n){var r=new URLSearchParams;e&&r.set("subaccountId",e),n&&r.set("subaccountToAgency","true"),t="".concat(Ee,"?").concat(r.toString())}window.location.href=t,Ae(!1)}})]})},rt=t(49780),it=t(54815),ot=t(97340),at=t(19688),lt=t(24205),st=function(e,n,t,r){return new(t||(t=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function l(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){var n;e.done?i(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(a,l)}s((r=r.apply(e,n||[])).next())}))},ct=function(e,n){var t,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=l(0),a.throw=l(1),a.return=l(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function l(l){return function(s){return function(l){if(t)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(o=0)),o;)try{if(t=1,r&&(i=2&l[0]?r.return:l[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,l[1])).done)return i;switch(r=0,i&&(l=[2&l[0],i.value]),l[0]){case 0:case 1:i=l;break;case 4:return o.label++,{value:l[1],done:!1};case 5:o.label++,r=l[1],l=[0];continue;case 7:l=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==l[0]&&2!==l[0])){o=0;continue}if(3===l[0]&&(!i||l[1]>i[0]&&l[1]<i[3])){o.label=l[1];break}if(6===l[0]&&o.label<i[1]){o.label=i[1],i=l;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(l);break}i[2]&&o.ops.pop(),o.trys.pop();continue}l=n.call(e,o)}catch(e){l=[6,e],r=0}finally{t=i=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,s])}}},dt=function(e){var n=e.icon,t=e.title;return(0,r.jsxs)(u.A,{sx:{display:"flex",alignItems:"center",gap:1.25,color:"primary.main"},children:[(0,r.jsx)(u.A,{sx:{display:"flex",alignItems:"center"},children:n}),(0,r.jsx)(te.A,{variant:"body1",sx:{fontWeight:500},children:t})]})},ut=function(e){var n=e.value,t=e.label,i=e.description,o=e.selected,a=e.onSelect,l=e.disabled;return(0,r.jsxs)(u.A,{onClick:function(){return!l&&a(n)},sx:{display:"flex",gap:1.25,p:1.25,borderRadius:2,cursor:l?"not-allowed":"pointer",opacity:l?.6:1,"&:hover":{bgcolor:l?"transparent":"action.hover"}},children:[(0,r.jsx)(rt.A,{checked:o,value:n,disabled:l,sx:{p:.25,mt:.25,color:"primary.main","&.Mui-checked":{color:"primary.main"}}}),(0,r.jsxs)(u.A,{children:[(0,r.jsx)(te.A,{variant:"body1",sx:{fontWeight:500},children:t}),(0,r.jsx)(te.A,{variant:"body2",color:"text.secondary",sx:{mt:.25},children:i})]})]})};var ht=function(e){var n=e.chatbotId,t=e.enabled,o=void 0!==t&&t,a=e.masterChatName,l=void 0===a?"MasterChat":a,s=e.defaultMethod,d=void 0===s?"free_usage":s,h=e.saasConfiguratorUrl,p=void 0===h?"/saas-configurator":h,x=e.disabledSwitch,f=void 0!==x&&x,_=e.disabledReason,A=void 0===_?"":_,I=e.onToggleEnabled,m=e.onChangeMethod,T=e.masterChatAvailabilityUrl,v=(0,c.Bd)().t,b=(0,S.jE)(),g=i.useState(!0),E=g[0],y=g[1],L=i.useState(o),N=L[0],j=L[1],C=i.useState(d),P=C[0],D=C[1],R=i.useState(!1),O=R[0],w=R[1],G=i.useState(null),Y=G[0],B=G[1],M=i.useCallback((function(e){return v(e,{masterChatName:l}).replace(/MasterChat/g,l)}),[l,v]),k=i.useMemo((function(){return(A||"").replace(/MasterChat/g,l)}),[A,l]);i.useEffect((function(){return j(o)}),[o]),i.useEffect((function(){return D(d)}),[d]);var U=function(e){return st(void 0,void 0,void 0,(function(){var t,r;return ct(this,(function(i){switch(i.label){case 0:return(t=new FormData).append("id",String(n)),t.append("available_in_master_chat",String(e)),[4,fetch(T,{method:"POST",headers:{"X-CSRFToken":(o="csrftoken",a=document.cookie.split("; ").find((function(e){return e.startsWith(o+"=")})),a?decodeURIComponent(a.split("=")[1]):"")},body:t,credentials:"include"})];case 1:if(!(r=i.sent()).ok)throw new Error("Failed to update MasterChat availability (".concat(r.status,")"));return[2]}var o,a}))}))},z=function(e){D(e),null==m||m(e)},W=(0,r.jsx)(ie.A,{checked:N,onChange:function(e){return t=e.target.checked,st(void 0,void 0,void 0,(function(){var e,r;return ct(this,(function(i){switch(i.label){case 0:if(O)return[2];e=N,j(t),w(!0),B(null),i.label=1;case 1:return i.trys.push([1,3,4,5]),[4,U(t)];case 2:return i.sent(),null==I||I(t),b.invalidateQueries({queryKey:["chatbot-detail-dashboard",n]}),[3,5];case 3:return r=i.sent(),j(e),B((null==r?void 0:r.message)||v("DISPLAY_STRINGS.MASTER_CHAT_TAB_FAILED_UPDATE")),[3,5];case 4:return w(!1),[7];case 5:return[2]}}
1))}));var t},disabled:f||O,inputProps:{"aria-label":v("DISPLAY_STRINGS.MASTER_CHAT_TAB_TOGGLE_ARIA")}});return(0,r.jsx)(u.A,{children:(0,r.jsxs)(bn.A,{expanded:E,onChange:function(e,n){return y(n)},disableGutters:!0,elevation:0,sx:{border:"1px solid",borderColor:"divider",borderRadius:2,"&:before":{display:"none"}},children:[(0,r.jsx)(gn.A,{expandIcon:(0,r.jsx)(On.A,{sx:{color:"primary.main"}}),sx:{"& .MuiAccordionSummary-content":{color:"primary.main",fontWeight:500}},children:(0,r.jsx)(dt,{icon:(0,r.jsx)(at.A,{fontSize:"small"}),title:M("DISPLAY_STRINGS.MASTER_CHAT_TAB_VIEW_IN_MASTER_CHAT")})}),(0,r.jsxs)(En.A,{children:[(0,r.jsx)(te.A,{variant:"body2",color:"text.secondary",sx:{mb:2},children:M("DISPLAY_STRINGS.MASTER_CHAT_TAB_VIEW_DESCRIPTION")}),Y&&(0,r.jsx)(Ln.A,{severity:"error",sx:{mb:2},children:Y}),(0,r.jsxs)(u.A,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(0,r.jsxs)(te.A,{variant:"body1",sx:{fontWeight:500},children:[M("DISPLAY_STRINGS.MASTER_CHAT_TAB_ENABLE_IN_MASTER_CHAT"),O&&(0,r.jsx)(te.A,{component:"span",variant:"body2",sx:{ml:1,color:"text.secondary"},children:v("DISPLAY_STRINGS.MASTER_CHAT_TAB_SAVING")})]}),f?(0,r.jsx)(Ke.A,{title:k,arrow:!0,placement:"top",children:(0,r.jsx)(u.A,{sx:{display:"inline-flex"},children:W})}):W]}),(0,r.jsx)(te.A,{variant:"body2",color:"text.secondary",sx:{mt:1,mb:2},children:M("DISPLAY_STRINGS.MASTER_CHAT_TAB_CONFIGURE_ACCESS")}),(0,r.jsxs)(u.A,{sx:{position:"relative"},children:[(0,r.jsxs)(ne.A,{variant:"outlined",sx:{borderRadius:2,p:2},children:[(0,r.jsx)(te.A,{variant:"body1",sx:{fontWeight:500,mb:1},children:v("DISPLAY_STRINGS.MASTER_CHAT_TAB_ACCOUNT_CREATION_METHOD")}),(0,r.jsxs)(it.A,{value:P,onChange:function(){},children:[(0,r.jsx)(ut,{value:"existing_users",label:v("DISPLAY_STRINGS.MASTER_CHAT_TAB_EXISTING_USERS"),description:M("DISPLAY_STRINGS.MASTER_CHAT_TAB_EXISTING_USERS_DESC"),selected:"existing_users"===P,onSelect:z,disabled:!N}),(0,r.jsx)(u.A,{sx:{borderTop:"1px solid",borderColor:"divider",my:1}}),(0,r.jsx)(te.A,{variant:"body1",sx:{fontWeight:500,mb:1},children:v("DISPLAY_STRINGS.MASTER_CHAT_TAB_TRY_BEFORE_YOU_BUY")}),(0,r.jsx)(ut,{value:"none",label:v("DISPLAY_STRINGS.MASTER_CHAT_TAB_NONE"),description:M("DISPLAY_STRINGS.MASTER_CHAT_TAB_NONE_DESC"),selected:"none"===P,onSelect:z,disabled:!N}),(0,r.jsx)(ut,{value:"free_usage",label:v("DISPLAY_STRINGS.MASTER_CHAT_TAB_FREE_USAGE"),description:M("DISPLAY_STRINGS.MASTER_CHAT_TAB_FREE_USAGE_DESC"),selected:"free_usage"===P,onSelect:z,disabled:!N}),(0,r.jsx)(ut,{value:"free_trial_account",label:v("DISPLAY_STRINGS.MASTER_CHAT_TAB_FREE_TRIAL_ACCOUNT"),description:v("DISPLAY_STRINGS.MASTER_CHAT_TAB_FREE_TRIAL_ACCOUNT_DESC"),selected:"free_trial_account"===P,onSelect:z,disabled:!N}),(0,r.jsx)(ut,{value:"paid_plans_only",label:v("DISPLAY_STRINGS.MASTER_CHAT_TAB_PAID_PLANS_ONLY"),description:v("DISPLAY_STRINGS.MASTER_CHAT_TAB_PAID_PLANS_ONLY_DESC"),selected:"paid_plans_only"===P,onSelect:z,disabled:!N}),(0,r.jsxs)(te.A,{variant:"body2",color:"text.secondary",sx:{mt:1.25},children:[v("DISPLAY_STRINGS.MASTER_CHAT_TAB_SAAS_CONFIGURATOR_INTRO")," ",(0,r.jsxs)(ot.A,{href:p,underline:"hover",sx:{display:"inline-flex",alignItems:"center",gap:.5},children:[v("DISPLAY_STRINGS.MASTER_CHAT_TAB_SAAS_CONFIGURATOR_LINK")," ",(0,r.jsx)(lt.A,{sx:{fontSize:16}})]})]})]})]}),(0,r.jsx)(u.A,{sx:{mt:2},children:(0,r.jsx)(Je.A,{variant:"contained",color:"primary",fullWidth:!0,sx:{borderRadius:2,py:1.2},children:M("DISPLAY_STRINGS.MASTER_CHAT_TAB_ACTIVATE_MASTER_CHAT")})}),(0,r.jsxs)(u.A,{sx:{position:"absolute",inset:0,borderRadius:2,bgcolor:"background.paper",opacity:.9,backdropFilter:"blur(1px)",display:"flex",flexDirection:"column",textAlign:"center",alignItems:"center",justifyContent:"center",pointerEvents:"auto"},children:[(0,r.jsx)(te.A,{variant:"h5",color:"primary",fontWeight:700,align:"center",children:v("DISPLAY_STRINGS.MASTER_CHAT_TAB_COMING_SOON")}),(0,r.jsx)(te.A,{variant:"h5",align:"center",color:"text.secondary",sx:{maxWidth:500},children:M("DISPLAY_STRINGS.MASTER_CHAT_TAB_COMING_SOON_DESC")})]})]})]})]})})},St=t(25978),pt=t(27520),xt=t(90801),ft=t(57275),_t=function(e,n,t,r){return new(t||(t=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function l(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){var n;e.done?i(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(a,l)}s((r=r.apply(e,n||[])).next())}))},At=function(e,n){var t,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=l(0),a.throw=l(1),a.return=l(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function l(l){return function(s){return function(l){if(t)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(o=0)),o;)try{if(t=1,r&&(i=2&l[0]?r.return:l[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,l[1])).done)return i;switch(r=0,i&&(l=[2&l[0],i.value]),l[0]){case 0:case 1:i=l;break;case 4:return o.label++,{value:l[1],done:!1};case 5:o.label++,r=l[1],l=[0];continue;case 7:l=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==l[0]&&2!==l[0])){o=0;continue}if(3===l[0]&&(!i||l[1]>i[0]&&l[1]<i[3])){o.label=l[1];break}if(6===l[0]&&o.label<i[1]){o.label=i[1],i=l;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(l);break}i[2]&&o.ops.pop(),o.trys.pop();continue}l=n.call(e,o)}catch(e){l=[6,e],r=0}finally{t=i=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,s])}}};var It,mt=function(e){var n=e.icon,t=e.title;return(0,r.jsxs)(u.A,{sx:{display:"flex",alignItems:"center",gap:1.25,color:"primary.main"},children:[n,(0,r.jsx)(te.A,{variant:"body1",sx:{fontWeight:500},children:t})]})},Tt=function(e){e.chatbotId;var n=e.uuid,t=void 0===n?"":n,o=e.isInternalSupportForAgency,a=void 0!==o&&o,l=e.marketplaceChatbotId,s=void 0===l?-1:l,d=e.canDelete,h=void 0===d||d,S=e.isRequesterAgencyAdm
1in,p=void 0!==S&&S,x=e.showInternalSupportSection,f=void 0!==x&&x,_=e.showMarketplaceSection,A=void 0!==_&&_,I=e.toggleInternalSupportUrl,m=(e.marketplaceUrl,(0,c.Bd)().t),T=(0,Fn.Zp)(),v=f?"support":A?"marketplace":"delete",b=i.useState(v),g=b[0],E=b[1],y=i.useState(!1),L=y[0],N=y[1],j=i.useState(!1),C=j[0],P=j[1],D=i.useState(!1),R=D[0],O=D[1],w=i.useState(a),G=w[0],Y=w[1],B=i.useState(!1),M=B[0],k=B[1];i.useEffect((function(){Y(a)}),[a]),i.useEffect((function(){f||"support"!==g||E(A?"marketplace":"delete"),A||"marketplace"!==g||E(f?"support":"delete")}),[g,f,A]);var U=function(e){return function(n,t){return E(!!t&&e)}};return(0,r.jsxs)(u.A,{sx:{display:"flex",flexDirection:"column",gap:1},children:[(0,r.jsxs)(u.A,{children:[(0,r.jsxs)(u.A,{sx:{display:"flex",alignItems:"center",gap:1},children:[(0,r.jsx)(St.A,{sx:{color:"primary.main",fontSize:20}}),(0,r.jsx)(te.A,{variant:"h5",sx:{fontWeight:600,color:"primary.main"},children:m("DISPLAY_STRINGS.SETTINGS_TAB_AGENT_CONFIGURATION")})]}),(0,r.jsx)(te.A,{variant:"body2",color:"text.secondary",sx:{mt:.5},children:m("DISPLAY_STRINGS.SETTINGS_TAB_CUSTOMIZE_AI")})]}),f&&(0,r.jsxs)(bn.A,{expanded:"support"===g,onChange:U("support"),disableGutters:!0,elevation:0,sx:{border:"1px solid",borderColor:"divider",borderRadius:2,"&:before":{display:"none"}},children:[(0,r.jsx)(gn.A,{expandIcon:(0,r.jsx)(On.A,{sx:{color:"primary.main"}}),sx:{"& .MuiAccordionSummary-content":{color:"primary.main"}},children:(0,r.jsx)(mt,{icon:(0,r.jsx)(wn.A,{fontSize:"small",sx:{color:"primary.main"}}),title:m("DISPLAY_STRINGS.SETTINGS_TAB_INTERNAL_SUPPORT_TITLE")})}),(0,r.jsxs)(En.A,{children:[(0,r.jsx)(te.A,{variant:"body2",color:"text.secondary",sx:{mb:2},children:m("DISPLAY_STRINGS.SETTINGS_TAB_INTERNAL_SUPPORT_DESCRIPTION")}),(0,r.jsx)(Je.A,{variant:G?"outlined":"contained",color:"primary",sx:{borderRadius:2,px:2,py:1},onClick:function(){return _t(void 0,void 0,void 0,(function(){var e,n,t,r;return At(this,(function(i){switch(i.label){case 0:if(!p||M)return[2];if(!G)return N(!0),[2];if(!I)return console.warn("toggleInternalSupportUrl not provided."),[2];k(!0),e=G,Y(!1),i.label=1;case 1:return i.trys.push([1,3,4,5]),o="csrftoken",a=document.cookie.split("; ").find((function(e){return e.startsWith(o+"=")})),n=a?decodeURIComponent(a.split("=")[1]):"",[4,fetch(I,{method:"GET",headers:n?{"X-CSRFToken":n}:void 0,credentials:"include"})];case 2:if(!(t=i.sent()).ok)throw new Error("Failed (".concat(t.status,")"));return[3,5];case 3:return r=i.sent(),console.error(r),Y(e),[3,5];case 4:return k(!1),[7];case 5:return[2]}var o,a}))}))},disabled:!p||M,children:m(G?"DISPLAY_STRINGS.SETTINGS_TAB_REMOVE_INTERNAL_SUPPORT":"DISPLAY_STRINGS.SETTINGS_TAB_ENABLE_INTERNAL_SUPPORT")}),!p&&(0,r.jsx)(te.A,{variant:"caption",color:"text.secondary",sx:{display:"block",mt:1,fontWeight:500},children:m("DISPLAY_STRINGS.SETTINGS_TAB_ONLY_AGENCY_ADMINS")})]})]}),A&&(0,r.jsxs)(bn.A,{expanded:"marketplace"===g,onChange:U("marketplace"),disableGutters:!0,elevation:0,sx:{border:"1px solid",borderColor:"divider",borderRadius:2,"&:before":{display:"none"}},children:[(0,r.jsx)(gn.A,{expandIcon:(0,r.jsx)(On.A,{sx:{color:"primary.main"}}),sx:{"& .MuiAccordionSummary-content":{color:"primary.main"}},children:(0,r.jsx)(mt,{icon:(0,r.jsx)(pt.A,{fontSize:"small",sx:{color:"primary.main"}}),title:m("DISPLAY_STRINGS.SETTINGS_TAB_LAUNCH_MARKETPLACE_TITLE")})}),(0,r.jsxs)(En.A,{children:[(0,r.jsx)(te.A,{variant:"body2",color:"text.secondary",sx:{mb:2},children:m("DISPLAY_STRINGS.SETTINGS_TAB_LAUNCH_MARKETPLACE_DESCRIPTION")}),(0,r.jsx)(Je.A,{variant:"contained",color:"primary",sx:{borderRadius:2,minWidth:120},onClick:function(){T("/marketplace/chatbots/?agent_id=".concat(s))},children:m("DISPLAY_STRINGS.SETTINGS_TAB_LAUNCH")})]})]}),(0,r.jsxs)(bn.A,{expanded:"delete"===g,onChange:U("delete"),disableGutters:!0,elevation:0,sx:{border:"1px solid",borderColor:"divider",borderRadius:2,"&:before":{display:"none"}},children:[(0,r.jsx)(gn.A,{expandIcon:(0,r.jsx)(On.A,{sx:{color:"primary.main"}}),sx:{"& .MuiAccordionSummary-content":{color:"primary.main"}},children:(0,r.jsx)(mt,{icon:(0,r.jsx)(xt.A,{fontSize:"small",sx:{color:"primary.main"}}),title:m("DISPLAY_STRINGS.SETTINGS_TAB_DELETE_AGENT_TITLE")})}),(0,r.jsxs)(En.A,{children:[(0,r.jsx)(te.A,{variant:"body2",color:"text.secondary",sx:{mb:2},children:m("DISPLAY_STRINGS.SETTINGS_TAB_DELETE_UNDONE")}),(0,r.jsx)(Je.A,{variant:"contained",color:"error",fullWidth:!0,onClick:function(){P(!0)},disabled:!h,sx:{borderRadius:2,py:1.2},children:m("DISPLAY_STRINGS.SETTINGS_TAB_DELETE_AGENT_BUTTON")})]})]}),(0,r.jsx)(Hn.KKB,{isOpen:L,onClose:function(){return N(!1)},onConfirm:function(){N(!1),I&&(window.location.href=I)},title:m("DISPLAY_STRINGS.SETTINGS_TAB_INTERNAL_SUPPORT_MODAL_TITLE"),message:m("DISPLAY_STRINGS.SETTINGS_TAB_INTERNAL_SUPPORT_MODAL_BODY"),confirmButtonLabel:m("DISPLAY_STRINGS.SETTINGS_TAB_CONFIRM"),cancelButtonLabel:m("DISPLAY_STRINGS.SETTINGS_TAB_CLOSE"),confirmButtonDisabled:!I,showLoader:!1}),(0,r.jsx)(Hn.KKB,{isOpen:C,onClose:function(){return!R&&P(!1)},onConfirm:function(){return _t(void 0,void 0,void 0,(function(){var e;return At(this,(function(n){switch(n.label){case 0:if(!t||R)return[2];O(!0),n.label=1;case 1:return n.trys.push([1,3,4,5]),[4,(0,ft.fj)(t)];
1case 2:return n.sent(),T("/chatbot/all/"),[3,5];case 3:return e=n.sent(),console.error(e),[3,5];case 4:return O(!1),P(!1),[7];case 5:return[2]}}))}))},title:m("DISPLAY_STRINGS.SETTINGS_TAB_DELETE_MODAL_TITLE"),message:m("DISPLAY_STRINGS.DELETE_AI_AGENT_CONFIRMATION"),confirmButtonLabel:m(R?"DISPLAY_STRINGS.SETTINGS_TAB_DELETING":"DISPLAY_STRINGS.SETTINGS_TAB_DELETE"),cancelButtonLabel:m("DISPLAY_STRINGS.SETTINGS_TAB_CLOSE"),confirmButtonDisabled:!t||R,showLoader:R})]})},vt=function(){return vt=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var i in n=arguments[t])Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i]);return e},vt.apply(this,arguments)};!function(e){e.AI_AGENT="AI_AGENT",e.MASTERCHAT="MASTERCHAT",e.SETTINGS="SETTINGS"}(It||(It={}));var bt,gt,Et=function(e){var n,t,o,a,l,s,d,h,S,p,f,_,A,I,m,T,v,b,g,E,y,L,N,j,C,P,D,R,O=e.chatbotId,w=e.detailData,G=i.useState(It.AI_AGENT),Y=G[0],B=G[1],M=(0,c.Bd)().t,k=function(e){return(0,r.jsx)(In.A,vt({disableRipple:!0,sx:{textTransform:"none",fontWeight:500,minHeight:44,px:2,"&.Mui-selected":{fontWeight:600}}},e))};if(!w)return(0,r.jsx)(ne.A,{variant:"outlined",sx:{borderRadius:2,overflow:"hidden"},children:(0,r.jsx)(u.A,{sx:{p:3},children:(0,r.jsx)(te.A,{color:"error",children:"Failed to load chatbot details."})})});var U=null!==(t=null===(n=null==w?void 0:w.chatbot)||void 0===n?void 0:n.uuid)&&void 0!==t?t:"",z=null!==(a=null===(o=null==w?void 0:w.flags)||void 0===o?void 0:o.isApiAccessible)&&void 0!==a&&a,W=null!==(s=null===(l=null==w?void 0:w.chatbot)||void 0===l?void 0:l.visibility)&&void 0!==s?s:"",H=null!==(h=null===(d=null==w?void 0:w.chatbot)||void 0===d?void 0:d.visibilityLabel)&&void 0!==h?h:"",F=null!==(S=null==w?void 0:w.baseUrl)&&void 0!==S?S:"undefined"!=typeof window?window.location.origin:"",K=null!==(p=null==w?void 0:w.chatbot.availableInMasterChat)&&void 0!==p&&p,J=(null==w?void 0:w.masterChatName)||"MasterChat",V=null!==(f=null==w?void 0:w.permissions.masterChatPermission)&&void 0!==f&&f;i.useEffect((function(){V||Y!==It.MASTERCHAT||B(It.AI_AGENT)}),[V,Y]);var q="/en/chatbot/api/v1/master-chat-availability/".concat(O),Q=null!==(A=null===(_=null==w?void 0:w.flags)||void 0===_?void 0:_.disabledMasterChatSwitch)&&void 0!==A&&A,$=null!==(m=null===(I=null==w?void 0:w.chatbot)||void 0===I?void 0:I.isInternalSupportForAgency)&&void 0!==m&&m,X=null!==(T=null==w?void 0:w.marketplaceChatbotId)&&void 0!==T?T:-1,Z=null!==(b=null===(v=null==w?void 0:w.permissions)||void 0===v?void 0:v.canDelete)&&void 0!==b&&b,ee=null!==(E=null===(g=null==w?void 0:w.permissions)||void 0===g?void 0:g.isRequesterAgencyAdmin)&&void 0!==E&&E,re=null!==(L=null===(y=null==w?void 0:w.permissions)||void 0===y?void 0:y.isRequesterAgencyUser)&&void 0!==L&&L||null!==(j=null===(N=null==w?void 0:w.permissions)||void 0===N?void 0:N.isRequesterAgencyOwner)&&void 0!==j&&j,ie=null!==(P=null===(C=null==w?void 0:w.permissions)||void 0===C?void 0:C.isRequesterAgencyUser)&&void 0!==P&&P||null!==(R=null===(D=null==w?void 0:w.permissions)||void 0===D?void 0:D.isRequesterAgencyOwner)&&void 0!==R&&R,oe=(0,x.BY)(),ae=F?"".concat(F,"/").concat(oe,"/chatbot/toggle-internal-support/").concat(O):void 0;return(0,r.jsxs)(ne.A,{variant:"outlined",sx:{borderRadius:2,overflow:"hidden"},children:[(0,r.jsx)(u.A,{sx:{px:2,borderBottom:1,borderColor:"divider"},children:(0,r.jsxs)(mn.A,{value:Y,onChange:function(e,n){B(n)},"aria-label":"Chatbot detail right panel tabs",variant:"standard",TabIndicatorProps:{style:{height:3,borderRadius:3}},sx:{minHeight:44,"& .MuiTabs-flexContainer":{gap:1}},children:[(0,r.jsx)(k,{label:"AI Agent",value:It.AI_AGENT}),V&&(0,r.jsx)(k,{label:J,value:It.MASTERCHAT}),(0,r.jsx)(k,{label:"Settings",value:It.SETTINGS})]})}),(0,r.jsxs)(u.A,{sx:{p:3},children:[Y===It.AI_AGENT&&(0,r.jsx)(tt,{chatbotId:O,uuid:U,baseUrl:F,isApiAccessible:z,apiDocsUrl:"/en/api-docs/chatbot/message/",visibility:W,visibilityLabel:H,isRequesterAgencyAdmin:ee}),Y===It.MASTERCHAT&&V&&(0,r.jsx)(ht,{chatbotId:O,enabled:K,masterChatName:J,masterChatAvailabilityUrl:q,disabledSwitch:Q,disabledReason:Q?M("DISPLAY_STRINGS.MASTER_CHAT_TAB_VAULT_KEY_REQUIRED"):""}),Y===It.SETTINGS&&(0,r.jsx)(Tt,{chatbotId:O,uuid:U,isInternalSupportForAgency:$,marketplaceChatbotId:X,canDelete:Z,isRequesterAgencyAdm
1in:ee,showInternalSupportSection:re,showMarketplaceSection:ie,toggleInternalSupportUrl:ae})]})]})},yt=t(982),Lt=t(82317),Nt=t(16003),jt=t(38451),Ct="public",Pt="private",Dt="private_but_website_embeddable",Rt=function(){return[{value:Ct,label:jt.Ay.t("DISPLAY_STRINGS.PRIVACY_PUBLIC")},{value:Pt,label:jt.Ay.t("DISPLAY_STRINGS.PRIVACY_PRIVATE")},{value:Dt,label:jt.Ay.t("DISPLAY_STRINGS.PRIVACY_WEBSITE_EMBEDDABLE")}]},Ot="none",wt="initial_messages_popup",Gt="chatwidget_popup",Yt="left",Bt="right",Mt="channel",kt="widget",Ut="sms",zt="tab",Wt={CHANNELS:"channels",CONNECTORS:"connectors"},Ht=function(e){return Object.values(Wt).includes(e)},Ft="feature",Kt="grid",Jt="active",Vt="placeholder",qt="route",Qt="upgrade",$t="pending",Xt="active",Zt="error",er="awaiting_auth",nr="streamable_http",tr="sse",rr="none",ir="bearer",or="api_key",ar="oauth2",lr="end_user_oauth",sr="payments",cr="ecommerce",dr="accounting",ur="crm",hr="support",Sr="communication",pr="marketing",xr="analytics",fr="scheduling",_r="automation",Ar="productivity",Ir="database",mr="developer",Tr="other",vr=[sr,cr,dr,ur,hr,Sr,pr,xr,fr,_r,Ar,Ir,mr,Tr],br=((bt={})[sr]="DISPLAY_STRINGS.MCP_CATEGORY_PAYMENTS",bt[cr]="DISPLAY_STRINGS.MCP_CATEGORY_ECOMMERCE",bt[dr]="DISPLAY_STRINGS.MCP_CATEGORY_ACCOUNTING",bt[ur]="DISPLAY_STRINGS.MCP_CATEGORY_CRM",bt[hr]="DISPLAY_STRINGS.MCP_CATEGORY_SUPPORT",bt[Sr]="DISPLAY_STRINGS.MCP_CATEGORY_COMMUNICATION",bt[pr]="DISPLAY_STRINGS.MCP_CATEGORY_MARKETING",bt[xr]="DISPLAY_STRINGS.MCP_CATEGORY_ANALYTICS",bt[fr]="DISPLAY_STRINGS.MCP_CATEGORY_SCHEDULING",bt[_r]="DISPLAY_STRINGS.MCP_CATEGORY_AUTOMATION",bt[Ar]="DISPLAY_STRINGS.MCP_CATEGORY_PRODUCTIVITY",bt[Ir]="DISPLAY_STRINGS.MCP_CATEGORY_DATABASE",bt[mr]="DISPLAY_STRINGS.MCP_CATEGORY_DEVELOPER",bt[Tr]="DISPLAY_STRINGS.MCP_CATEGORY_OTHER",bt),gr=function(e){var n;return jt.Ay.t(null!==(n=br[e])&&void 0!==n?n:br[Tr])},Er="X-API-Key",yr=["https://","http://"],Lr=yr[0],Nr=function(){return[{value:nr,label:jt.Ay.t("DISPLAY_STRINGS.MCP_TRANSPORT_STREAMABLE_HTTP")},{value:tr,label:jt.Ay.t("DISPLAY_STRINGS.MCP_TRANSPORT_SSE")}]},jr="dynamic",Cr="manual",Pr=function(e){return function(n){return(0,Fn.tW)(e,{chatbotId:String(n)})}},Dr=[{key:"chat_widget",variant:Ft,titleKey:"DISPLAY_STRINGS.CHANNEL_CHAT_WIDGET",descriptionKey:"DISPLAY_STRINGS.CHANNEL_CHAT_WIDGET_DESC",iconKey:"chatWidget",status:Jt,permission:me.Qp.CAN_EMBED_CHATBOT.value,hasToggle:!0,accent:"primary",primaryAction:{kind:qt,labelKey:"DISPLAY_STRINGS.MANAGE",to:(gt=kt,function(e){return"".concat((0,Kn.Op)(e),"?").concat(Mt,"=").concat(gt)})}},{key:"help_page",variant:Ft,titleKey:"DISPLAY_STRINGS.CHANNEL_HELP_PAGE",descriptionKey:"DISPLAY_STRINGS.CHANNEL_HELP_PAGE_DESC",iconKey:"helpPage",status:Jt,accent:"warning",primaryAction:{kind:qt,labelKey:"DISPLAY_STRINGS.SETUP",external:!0,to:function(e){return"".concat(y.n.MASTER_CHAT.DASHBOARD,"?chatbot_id=").concat(e)}}},{key:"email",variant:Kt,titleKey:"DISPLAY_STRINGS.CHANNEL_EMAIL",descriptionKey:"DISPLAY_STRINGS.CHANNEL_EMAIL_DESC",iconKey:"email",status:Vt,primaryAction:{kind:Qt,labelKey:"DISPLAY_STRINGS.UPGRADE_TO_ENABLE"}},{key:"shopify",variant:Kt,titleKey:"DISPLAY_STRINGS.CHANNEL_SHOPIFY",descriptionKey:"DISPLAY_STRINGS.CHANNEL_SHOPIFY_DESC",iconKey:"shopify",status:Vt,primaryAction:{kind:Qt,labelKey:"DISPLAY_STRINGS.UPGRADE_TO_ENABLE"}},{key:"whatsapp",variant:Kt,titleKey:"DISPLAY_STRINGS.WHATSAPP",descriptionKey:"DISPLAY_STRINGS.CHANNEL_WHATSAPP_DESC",iconKey:"whatsapp",status:Jt,permission:me.Qp.CAN_UPDATE_INTEGRATIONS.value,primaryAction:{kind:qt,labelKey:"DISPLAY_STRINGS.CONNECT",to:Pr(Nt.b.CHATBOT_INTEGRATIONS_WHATSAPP)}},{key:"messenger",variant:Kt,titleKey:"DISPLAY_STRINGS.CHANNEL_MESSENGER",descriptionKey:"DISPLAY_STRINGS.CHANNEL_MESSENGER_DESC",iconKey:"messenger",status:Jt,permission:me.Qp.CAN_UPDATE_INTEGRATIONS.value,primaryAction:{kind:qt,labelKey:"DISPLAY_STRINGS.CONNECT",to:Pr(Nt.b.CHATBOT_INTEGRATIONS_FACEBOOK)}},{key:"instagram",variant:Kt,titleKey:"DISPLAY_STRINGS.INSTAGRAM",descriptionKey:"DISPLAY_STRINGS.CHANNEL_INSTAGRAM_DESC",iconKey:"instagram",status:Jt,permission:me.Qp.CAN_UPDATE_INTEGRATIONS.value,primaryAction:{kind:qt,labelKey:"DISPLAY_STRINGS.CONNECT",to:Pr(Nt.b.CHATBOT_INTEGRATIONS_INSTAGRAM)}},{key:"zendesk",variant:Kt,titleKey:"DISPLAY_STRINGS.CHANNEL_ZENDESK",de
1scriptionKey:"DISPLAY_STRINGS.CHANNEL_ZENDESK_DESC",iconKey:"zendesk",status:Vt,primaryAction:{kind:Qt,labelKey:"DISPLAY_STRINGS.UPGRADE_TO_ENABLE"}},{key:"slack",variant:Kt,titleKey:"DISPLAY_STRINGS.CHANNEL_SLACK",descriptionKey:"DISPLAY_STRINGS.CHANNEL_SLACK_DESC",iconKey:"slack",status:Vt,primaryAction:{kind:Qt,labelKey:"DISPLAY_STRINGS.UPGRADE_TO_ENABLE"}},{key:"wordpress",variant:Kt,titleKey:"DISPLAY_STRINGS.CHANNEL_WORDPRESS",descriptionKey:"DISPLAY_STRINGS.CHANNEL_WORDPRESS_DESC",iconKey:"wordpress",status:Vt,primaryAction:{kind:Qt,labelKey:"DISPLAY_STRINGS.UPGRADE_TO_ENABLE"}},{key:"api",variant:Kt,titleKey:"DISPLAY_STRINGS.CHANNEL_API",descriptionKey:"DISPLAY_STRINGS.CHANNEL_API_DESC",iconKey:"api",status:Jt,primaryAction:{kind:qt,labelKey:"DISPLAY_STRINGS.CONNECT",external:!0,to:function(){return Nt.b.API_DOCS}}},{key:"zapier",variant:Kt,titleKey:"DISPLAY_STRINGS.CHANNEL_ZAPIER",descriptionKey:"DISPLAY_STRINGS.CHANNEL_ZAPIER_DESC",iconKey:"zapier",status:Vt,primaryAction:{kind:Qt,labelKey:"DISPLAY_STRINGS.UPGRADE_TO_ENABLE"}}],Rr=new Set(["help_page"]),Or=Dr.filter((function(e){return!Rr.has(e.key)})),wr=Or.filter((function(e){return e.variant===Ft})),Gr=Or.filter((function(e){return e.variant===Kt})).sort((function(e,n){return Number(e.status===Vt)-Number(n.status===Vt)})),Yr=t(80202),Br=function(e,n,t,r){return new(t||(t=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function l(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){var n;e.done?i(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(a,l)}s((r=r.apply(e,n||[])).next())}))},Mr=function(e,n){var t,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=l(0),a.throw=l(1),a.return=l(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function l(l){return function(s){return function(l){if(t)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(o=0)),o;)try{if(t=1,r&&(i=2&l[0]?r.return:l[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,l[1])).done)return i;switch(r=0,i&&(l=[2&l[0],i.value]),l[0]){case 0:case 1:i=l;break;case 4:return o.label++,{value:l[1],done:!1};case 5:o.label++,r=l[1],l=[0];continue;case 7:l=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==l[0]&&2!==l[0])){o=0;continue}if(3===l[0]&&(!i||l[1]>i[0]&&l[1]<i[3])){o.label=l[1];break}if(6===l[0]&&o.label<i[1]){o.label=i[1],i=l;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(l);break}i[2]&&o.ops.pop(),o.trys.pop();continue}l=n.call(e,o)}catch(e){l=[6,e],r=0}finally{t=i=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,s])}}};function kr(e){var n=e.code,t=e.codeId,i=e.onCopy;return(0,r.jsxs)(o.azJ,{className:"mt-2",children:[(0,r.jsx)(o.azJ,{className:"d-flex justify-content-end",children:(0,r.jsx)(o.K0,{size:"small",onClick:i,"aria-label":"copy-".concat(t),children:(0,r.jsx)(W.A,{fontSize:"small"})})}),(0,r.jsx)(o.azJ,{component:"pre",id:t,sx:{mt:0,mb:0,p:2,color:"text.primary",backgroundColor:"action.hover",border:1,borderColor:"divider",fontFamily:"monospace",whiteSpace:"break-spaces",overflowWrap:"anywhere"},children:n})]})}function Ur(e){var n=this,t=e.open,i=e.onClose,a=e.settings,l=e.widgetPosition,s=(0,c.Bd)().t,d=(0,Yr.BY)(),u=(null==a?void 0:a.name)||"Chat Agent",h=(null==a?void 0:a.uuid)||"",S=h?function(e,n,t){return'<iframe\n    width="100%"\n    height="600"\n    frameborder="0"\n    title="Chat Agent - '.concat(e,'"\n    allow="microphone; clipboard-read; clipboard-write"\n    src="').concat(window.location.origin,"/").concat(t,"/chatbot/embed/").concat(n,'"\n></iframe>')}(u,h,d):"",p=h?function(e,n,t){return'<script\n    data-position="'.concat(t,'"\n    data-domain="').concat(window.location.origin,'"\n    data-language="').concat(n,'"\n    data-id="').concat(e,'"\n    src="').concat(window.location.origin,'/static/chatbot/js/chatbubble.js"\n><\/script>')}(h,d,l):"",f=function(e){return Br(n,void 0,void 0,(function(){return Mr(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,navigator.clipboard.writeText(e)];case 1:return n.sent(),(0,x.Sx)("",s("DISPLAY_STRINGS.EMBED_CODE_COPIED"),"success"),[3,3];case 2:return n.sent(),(0,x.Sx)("",s("DISPLAY_STRINGS.GENERIC_ERROR"),"error"),[3,3];case 3:return[2]}}
1))}))};return(0,r.jsxs)(o.lGe,{open:t,onClose:i,fullWidth:!0,maxWidth:"md",children:[(0,r.jsx)(o.L33,{children:s("DISPLAY_LABELS.EMBED_WEBSITE_TITLE")}),(0,r.jsxs)(o.Cff,{dividers:!0,children:[(0,r.jsx)(o.azJ,{className:"alert alert-warning py-2",children:(0,r.jsx)("small",{children:s("DISPLAY_LABELS.EMBED_WEBSITE_DOMAIN_NOTE")})}),(0,r.jsxs)(o.o5u,{component:"div",children:[s("DISPLAY_LABELS.EMBED_WEBSITE_IFRAME_INSTRUCTION"),(0,r.jsx)(kr,{code:S,codeId:"chatbotEmbeddableIframe",onCopy:function(){return f(S)}})]}),(0,r.jsxs)(o.azJ,{sx:{my:3,position:"relative",textAlign:"center"},children:[(0,r.jsx)("hr",{}),(0,r.jsx)(o.o5u,{component:"span",sx:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",px:2,backgroundColor:"background.paper",color:"text.secondary"},children:s("DISPLAY_LABELS.AUTH_OR")})]}),(0,r.jsxs)(o.o5u,{component:"div",children:[s("DISPLAY_LABELS.EMBED_WEBSITE_SCRIPT_INSTRUCTION"),(0,r.jsx)(kr,{code:p,codeId:"chatBubbleScript",onCopy:function(){return f(p)}})]})]}),(0,r.jsx)(o.azJ,{sx:{px:3,py:2,display:"flex",justifyContent:"flex-end"},children:(0,r.jsx)("button",{className:"btn btn-primary-soft",type:"button",onClick:i,children:s("DISPLAY_LABELS.CLOSE")})})]})}var zr=function(e){var n,t=e.chatbot,a=e.disabled,d=e.settings,u=(0,c.Bd)().t,h=(0,l.cG)(t).data,S=i.useState(Ct),f=S[0],_=S[1],A=i.useState(""),I=A[0],m=A[1],T=i.useState(Bt),v=T[0],b=T[1],g=i.useState(!1),E=g[0],y=g[1],L=i.useState(!1),N=L[0],j=L[1],C=i.useState(!1),P=C[0],D=C[1],R=i.useState(!0),O=R[0],G=R[1],Y=i.useState(!1),B=Y[0],M=Y[1],k=Rt(),U=[{value:Yt,label:jt.Ay.t("DISPLAY_STRINGS.BOTTOM_LEFT")},{value:Bt,label:jt.Ay.t("DISPLAY_STRINGS.BOTTOM_RIGHT")}],z=[{value:!0,label:u("DISPLAY_STRINGS.SHOW_ONLY_ONCE")},{value:!1,label:u("DISPLAY_STRINGS.SHOW_EVERY_TIME")}],W=[{value:!0,label:u("DISPLAY_STRINGS.AUTO_REFRESH_ENABLED")},{value:!1,label:u("DISPLAY_STRINGS.AUTO_REFRESH_DISABLED")}],H=[{value:!0,label:u("DISPLAY_STRINGS.PAGE_CONTEXT_ENABLED")},{value:!1,label:u("DISPLAY_STRINGS.PAGE_CONTEXT_DISABLED")}];(0,i.useEffect)((function(){(null==d?void 0:d.domains)&&m(d.domains.join(",")),(null==d?void 0:d.visibility)&&_(d.visibility),(null==d?void 0:d.widget_position)&&b(d.widget_position),void 0!==(null==d?void 0:d.show_popup_messages_only_once)&&y(d.show_popup_messages_only_once),d&&void 0!==d.auto_refresh_enabled?G(d.auto_refresh_enabled):G(!0),d&&void 0!==d.page_context_enabled?M(d.page_context_enabled):M(!1)}),[d]);var F=(0,p.n)({mutationFn:function(e){var n=e.chatbotId;if(void 0===d)return Promise.resolve();var t={visibility:f,domains:I?I.split(",").map((function(e){return e.trim()})):[],widget_position:v,show_popup_messages_only_once:E,auto_refresh_enabled:O,page_context_enabled:B};return w(n,t)},onSuccess:function(){j(!1),(0,x.Sx)("",u("DISPLAY_STRINGS.CHATBOT_SETTINGS_UPDATED_SUCCESS"),"success")},onError:function(){j(!1),(0,x.Sx)("",u("DISPLAY_STRINGS.FAILED_TO_UPDATE_CHATBOT_SETTINGS"),"error")},onSettled:function(){return j(!1)},onMutate:function(){return j(!0)}});return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(o.$nd,{sx:function(e){return{margin:"10px 0px 20px 0px",backgroundColor:e.palette.primary.main+"33",color:e.palette.primary.main,"&:hover":{backgroundColor:e.palette.primary.dark,color:e.palette.primary.contrastText}}},type:"button",onClick:function(e){e.currentTarget.blur(),D(!0)},disabled:a||N,children:u("DISPLAY_STRINGS.GET_EMBEDDABLE_CODE")}),(0,r.jsxs)("div",{children:[(0,r.jsxs)(o.o5u,{variant:"body2",sx:{marginBottom:1,display:"inline-flex",alignItems:"center"},color:"primary",className:"fw-bolder",children:[u("DISPLAY_STRINGS.CHATBOT_VISIBILITY"),(0,r.jsx)(o.m_M,{placement:"top",title:u("DISPLAY_STRINGS.CHATBOT_VISIBILITY_TOOLTIP"),children:(0,r.jsx)(s.R2,{sx:{marginLeft:"5px",fontSize:"16px",verticalAlign:"middle"}})})]}),(0,r.jsx)(o.l6P,{disabled:a||N,sx:{width:"100%","& .MuiSelect-select":{padding:"10px"},marginBottom:1},value:f,onChange:function(e){_(e.target.value)},displayEmpty:!0,children:k.map((function(e){return(0,r.jsx)(o.Drp,{dense:!0,value:e.value,children:(0,r.jsx)(o.o5u,{variant:"body2",children:e.label})},e.value)}))}),(0,r.jsxs)(o.o5u,{variant:"body2",sx:{marginBottom:1,display:"inline-flex",alignItems:"center",marginTop:2},color:"primary",className:"fw-bolder",children:[u("DISPLAY_STRINGS.WIDGET_BUBBLE_POSITION"),(0,r.jsx)(o.m_M,{placement:"top",title:u("DISPLAY_STRINGS.WIDGET_BUBBLE_POSITION_TOOLTIP"),children:(0,r.jsx)(s.R2,{s
1x:{marginLeft:"5px",fontSize:"16px",verticalAlign:"middle"}})})]}),(0,r.jsx)(o.l6P,{disabled:a||N,sx:{width:"100%","& .MuiSelect-select":{padding:"10px"},marginBottom:1},value:v,onChange:function(e){b(e.target.value)},displayEmpty:!0,children:U.map((function(e){return(0,r.jsx)(o.Drp,{dense:!0,value:e.value,children:(0,r.jsx)(o.o5u,{variant:"body2",children:e.label})},e.value)}))}),(0,r.jsxs)(o.o5u,{variant:"body2",sx:{marginBottom:1,display:"inline-flex",alignItems:"center",marginTop:2},color:"primary",className:"fw-bolder",children:[u("DISPLAY_STRINGS.POPUP_MESSAGES_DISPLAY_SETTINGS"),(0,r.jsx)(o.m_M,{placement:"top",title:u("DISPLAY_STRINGS.POPUP_MESSAGES_DISPLAY_SETTINGS_TOOLTIP"),children:(0,r.jsx)(s.R2,{sx:{marginLeft:"5px",fontSize:"16px",verticalAlign:"middle"}})})]}),(0,r.jsx)(o.l6P,{disabled:a||N,sx:{width:"100%","& .MuiSelect-select":{padding:"10px"}},value:E?"true":"false",onChange:function(e){y("true"===e.target.value)},displayEmpty:!0,children:z.map((function(e){return(0,r.jsx)(o.Drp,{dense:!0,value:String(e.value),children:(0,r.jsx)(o.o5u,{variant:"body2",children:e.label})},String(e.value))}))}),(0,r.jsxs)(o.o5u,{variant:"body2",sx:{marginBottom:1,display:"inline-flex",alignItems:"center",marginTop:2},color:"primary",className:"fw-bolder",children:[u("DISPLAY_STRINGS.AUTO_REFRESH_BEHAVIOR"),(0,r.jsx)(o.m_M,{placement:"top",title:u("DISPLAY_STRINGS.AUTO_REFRESH_BEHAVIOR_TOOLTIP"),children:(0,r.jsx)(s.R2,{sx:{marginLeft:"5px",fontSize:"16px",verticalAlign:"middle"}})})]}),(0,r.jsx)(o.l6P,{disabled:a||N,sx:{width:"100%","& .MuiSelect-select":{padding:"10px"}},value:O?"true":"false",onChange:function(e){G("true"===e.target.value)},displayEmpty:!0,children:W.map((function(e){return(0,r.jsx)(o.Drp,{dense:!0,value:String(e.value),children:(0,r.jsx)(o.o5u,{variant:"body2",children:e.label})},String(e.value))}))}),(0,r.jsx)(o.o5u,{variant:"caption",sx:{display:"block",color:"text.secondary",marginTop:.5,marginBottom:.5},children:u(O?"DISPLAY_STRINGS.AUTO_REFRESH_ENABLED_DESCRIPTION":"DISPLAY_STRINGS.AUTO_REFRESH_DISABLED_DESCRIPTION")}),O&&(null===(n=null==h?void 0:h.nudgeSettings)||void 0===n?void 0:n.nudgeEnabled)&&(0,r.jsxs)(o.FcD,{severity:"warning",sx:{mt:1},children:[(0,r.jsxs)(o.azJ,{component:"span",sx:{color:"warning.main",fontWeight:700},children:[u("DISPLAY_STRINGS.WARNING_LABEL")," "]}),u("DISPLAY_STRINGS.AUTO_REFRESH_NUDGE_WARNING")]}),(0,r.jsxs)(o.o5u,{variant:"body2",sx:{marginBottom:1,display:"inline-flex",alignItems:"center",marginTop:2},color:"primary",className:"fw-bolder",children:[u("DISPLAY_STRINGS.PAGE_CONTEXT_BEHAVIOR"),(0,r.jsx)(o.m_M,{placement:"top",title:u("DISPLAY_STRINGS.PAGE_CONTEXT_BEHAVIOR_TOOLTIP"),children:(0,r.jsx)(s.R2,{sx:{marginLeft:"5px",fontSize:"16px",verticalAlign:"middle"}})})]}),(0,r.jsx)(o.l6P,{disabled:a||N,sx:{width:"100%","& .MuiSelect-select":{padding:"10px"}},value:B?"true":"false",onChange:function(e){M("true"===e.target.value)},displayEmpty:!0,children:H.map((function(e){return(0,r.jsx)(o.Drp,{dense:!0,value:String(e.value),children:(0,r.jsx)(o.o5u,{variant:"body2",children:e.label})},String(e.value))}))}),(0,r.jsx)(o.o5u,{variant:"caption",sx:{display:"block",color:"text.secondary",marginTop:.5,marginBottom:.5},children:u(B?"DISPLAY_STRINGS.PAGE_CONTEXT_ENABLED_DESCRIPTION":"DISPLAY_STRINGS.PAGE_CONTEXT_DISABLED_DESCRIPTION")}),f===Dt&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(o.o5u,{variant:"body2",sx:{marginBottom:1,marginTop:2},color:"primary",className:"fw-bolder",children:[u("DISPLAY_STRINGS.ALLOWED_DOMAINS"),(0,r.jsx)(o.m_M,{placement:"top",title:u("DISPLAY_STRINGS.ALLOWED_DOMAINS_TOOLTIP"),children:(0,r.jsx)(s.R2,{sx:{marginLeft:"5px",fontSize:"16px",verticalAlign:"middle"}})})]}),(0,r.jsx)(o.A_L,{disabled:a||N,sx:{width:"100%","& .MuiInputBase-root":{padding:"10px"}},value:I,multiline:!0,maxRows:3,onChange:function(e){return m(e.target.value)},placeholder:u("DISPLAY_STRINGS.ALLOWED_DOMAINS_PLACEHOLDER")})]}),(0,r.jsx)(o.$nd,{sx:{marginTop:2},onClick:function(){null!==t&&(j(!0),F.mutate({chatbotId:t}))},variant:"contained",color:"primary",disabled:a||N,children:u("DISPLAY_STRINGS.UPDATE")})]}),(0,r.jsx)(Ur,{open:P,onClose:function(){return D(!1)},settings:d,widgetPosition:v})]})},Wr=function(){return Wr=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var i in n=arguments[t])Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i]);return e},Wr.apply(this,arguments)},Hr=function(e,n,t,r){return new(t||(t=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function l(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){var n;e.done?i(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(a,l)}s((r=r.apply(e,n||[])).next())}))},Fr=function(e,n){var t,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=l(0),a.throw=l(1),a.return=l(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function l(l){return function(s){return function(l){if(t)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(o=0)),o;)try{if(t=1,r&&(i=2&l[0]?r.return:l[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,l[1])).done)return i;switch(r=0,i&&(l=[2&l[0],i.value]),l[0]){case 0:case 1:i=l;break;case 4:return o.label++,{value:l[1],done:!1};case 5:o.label++,r=l[1],l=[0];continue;case 7:l=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==l[0]&&2!==l[0])){o=0;continue}if(3===l[0]&&(!i||l[1]>i[0]&&l[1]<i[3])){o.label=l[1];break}if(6===l[0]&&o.label<i[1]){o.label=i[1],i=l;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(l);break}i[2]&&o.ops.pop(),o.trys.pop();continue}l=n.call(e,o)}catch(e){l=[6,e],r=0}finally{t=i=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,s])}}};var Kr=function(e){var n=this,t=e.chatbot,a=e.disabled,l=e.settings,d=(0,c.Bd)().t,u=[{value:wt,label:jt.Ay.t("DISPLAY_STRINGS.INITIAL_MESSAGES_POPUP")},{value:Gt,label:jt.Ay.t("DISPLAY_STRINGS.CHATWIDGET_POPUP")}],h=i.useState({popup_type:Ot,initial_message_popup_delay:-1,chatwidget_popup_delay:-1,initial_message:d("DISPLAY_STRINGS.DEFAULT_INITIAL_MESSAGE"),mobile_popup_type:Ot,mobile_initial_message_popup_delay:-1,mobile_chatwidget_popup_delay:-1,mobile_initial_message:d("DISPLAY_STRINGS.DEFAULT_INITIAL_MESSAGE")}),S=h[0],f=h[1],_=i.useState(!1),A=_[0],I=_[1],m=i.useState("desktop"),T=m[0],v=m[1];(0,i.useEffect)((function(){var e,n,t,r;l&&f({popup_type:l.popup_type||Ot,initial_message_popup_delay:null!==(e=l.initial_message_popup_delay)&&void 0!==e?e:-1,chatwidget_popup_delay:null!==(n=l.chatwidget_popup_delay)&&void 0!==n?n:-1,initial_message:l.initial_message||d("DISPLAY_STRINGS.DEFAULT_INITIAL_MESSAGE"),mobile_popup_type:l.mobile_popup_type||Ot,mobile_initial_message_popup_delay:null!==(t=l.mobile_initial_message_popup_delay)&&void 0!==t?t:-1,mobile_chatwidget_popup_delay:null!==(r=l.mobile_chatwidget_popup_delay)&&void 0!==r?r:-1,mobile_initial_message:l.mobile_initial_message||d("DISPLAY_STRINGS.DEFAULT_INITIAL_MESSAGE")})}),[l,d]);var b=(0,p.n)({mutationFn:function(e){return Hr(n,[e],void 0,(function(e){var n=e.chatbotId,t=e.settingsToUpdate;return Fr(this,(function(e){return n?(console.log("Sending settings to server:",t),[2,w(n,t)]):[2,Promise.resolve()]}))}))},onSuccess:function(){I(!1),(0,x.Sx)("",d("DISPLAY_STRINGS.POPUP_SETTINGS_UPDATED_SUCCESS"),"success")},onError:function(e){console.error("Update error:",e),I(!1),(0,x.Sx)("",d("DISPLAY_STRINGS.FAILED_TO_UPDATE_POPUP_SETTINGS"),"error")},onSettled:function(){return I(!1)},onMutate:function(){return I(!0)}}),g=function(){return"desktop"===T?{popup_type:S.popup_type,initial_message_popup_delay:S.initial_message_popup_delay,chatwidget_popup_delay:S.
1chatwidget_popup_delay,initial_message:S.initial_message}:{popup_type:S.mobile_popup_type,initial_message_popup_delay:S.mobile_initial_message_popup_delay,chatwidget_popup_delay:S.mobile_chatwidget_popup_delay,initial_message:S.mobile_initial_message}},E=g();return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(o.azJ,{sx:{mb:2},children:(0,r.jsxs)(o.IzF,{exclusive:!0,value:T,onChange:function(e,n){null!==n&&v(n)},"aria-label":d("DISPLAY_STRINGS.WIDGET_VIEW_MODE"),size:"small",color:"primary",children:[(0,r.jsx)(o.ffE,{value:"desktop","aria-label":d("DISPLAY_STRINGS.DESKTOP_SETTINGS"),children:d("DISPLAY_STRINGS.DESKTOP_SETTINGS")}),(0,r.jsx)(o.ffE,{value:"mobile","aria-label":d("DISPLAY_STRINGS.MOBILE_SETTINGS"),children:d("DISPLAY_STRINGS.MOBILE_SETTINGS")})]})}),(0,r.jsxs)(o.fPr,{container:!0,justifyContent:"space-between",alignItems:"center",sx:function(e){return{backgroundColor:e.palette.primary.main+"13",borderRadius:2}},className:"mt-2 mb-4",children:[(0,r.jsx)(o.o5u,{variant:"body2",className:"fw-bolder p-2",children:d("DISPLAY_STRINGS.ENABLE_POPUP_FOR",{viewMode:d("desktop"===T?"DISPLAY_STRINGS.DESKTOP":"DISPLAY_STRINGS.MOBILE")})}
1),(0,r.jsx)(o.dOG,{disabled:a||A,checked:E.popup_type!==Ot,onChange:function(){if(null!==t){var e=g().popup_type===Ot?wt:Ot,n=Wr({},S);"desktop"===T?n.popup_type=e:n.mobile_popup_type=e,f(n);var r="desktop"===T?{popup_type:e}:{mobile_popup_type:e};b.mutate({chatbotId:t,settingsToUpdate:r})}}})]}),E.popup_type!==Ot&&(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"d-flex justify-content-between",children:(0,r.jsxs)(o.o5u,{variant:"body2",sx:{marginBottom:1,display:"inline-flex",alignItems:"center"},color:"primary",className:"fw-bolder",children:[d("DISPLAY_STRINGS.SELECT_POPUP_TYPE_FOR",{viewMode:d("desktop"===T?"DISPLAY_STRINGS.DESKTOP":"DISPLAY_STRINGS.MOBILE")}),(0,r.jsx)(o.m_M,{placement:"top",title:d("DISPLAY_STRINGS.SELECT_POPUP_TYPE_TOOLTIP"),children:(0,r.jsx)(s.R2,{sx:{marginLeft:"5px",fontSize:"16px",verticalAlign:"middle"}})})]})}),(0,r.jsx)(o.l6P,{disabled:a||A,sx:{width:"100%","& .MuiSelect-select":{padding:"10px"},marginBottom:1},value:E.popup_type,onChange:function(e){var n=Wr({},S);"desktop"===T?n.popup_type=e.target.value:n.mobile_popup_type=e.target.value,f(n)},children:u.map((function(e){return(0,r.jsx)(o.Drp,{dense:!0,value:e.value,children:(0,r.jsx)(o.o5u,{variant:"body2",children:e.label})},e.value)}))}),(0,r.jsxs)("div",{children:[E.popup_type===wt&&(0,r.jsxs)(o.fPr,{size:12,sx:{marginBottom:"16px"},children:[(0,r.jsxs)(o.o5u,{variant:"body2",sx:{marginBottom:1,display:"inline-flex",alignItems:"center"},color:"primary",className:"fw-bolder",children:[d("DISPLAY_STRINGS.INITIAL_MESSAGES_POPUP_MESSAGES_FOR",{viewMode:d("desktop"===T?"DISPLAY_STRINGS.DESKTOP":"DISPLAY_STRINGS.MOBILE")}),(0,r.jsx)(o.m_M,{placement:"top",title:d("DISPLAY_STRINGS.INITIAL_MESSAGES_POPUP_TOOLTIP"),children:(0,r.jsx)(s.R2,{sx:{marginLeft:"5px",fontSize:"16px",verticalAlign:"middle"}})})]}),(0,r.jsx)(o.A_L,{fullWidth:!0,id:"initialMessage",name:"initialMessage",multiline:!0,maxRows:4,value:E.initial_message,disabled:a||A,onChange:function(e){var n=Wr({},S);"desktop"===T?n.initial_message=e.target.value:n.mobile_initial_message=e.target.value,f(n)},placeholder:d("DISPLAY_STRINGS.ENTER_INITIAL_MESSAGE_PLACEHOLDER"),sx:{"& .MuiInputBase-root":{padding:"10px"}}})]}),(0,r.jsxs)(o.o5u,{variant:"body2",sx:{marginBottom:1,display:"inline-flex",alignItems:"center"},color:"primary",className:"fw-bolder",children:[E.popup_type===wt?d("DISPLAY_STRINGS.INITIAL_MESSAGES_POPUP_DELAY_FOR",{viewMode:d("desktop"===T?"DISPLAY_STRINGS.DESKTOP":"DISPLAY_STRINGS.MOBILE")}):d("DISPLAY_STRINGS.CHAT_WIDGET_POPUP_DELAY_FOR",{viewMode:d("desktop"===T?"DISPLAY_STRINGS.DESKTOP":"DISPLAY_STRINGS.MOBILE")}),(0,r.jsx)(o.m_M,{placement:"top",title:d("DISPLAY_STRINGS.POPUP_DELAY_TOOLTIP"),children:(0,r.jsx)(s.R2,{sx:{marginLeft:"5px",fontSize:"16px",verticalAlign:"middle"}})})]}),(0,r.jsx)(o.A_L,{disabled:a||A,size:"small",sx:{width:"100%","& input":{fontSize:"small"},marginTop:2},value:E.popup_type===wt?E.initial_message_popup_delay:E.chatwidget_popup_delay,type:"number",inputProps:{min:-1},onChange:function(e){var n=Wr({},S),t=parseInt(e.target.value);"desktop"===T?E.popup_type===wt?n.initial_message_popup_delay=t:n.chatwidget_popup_delay=t:E.popup_type===wt?n.mobile_initial_message_popup_delay=t:n.mobile_chatwidget_popup_delay=t,f(n)}})]}),(0,r.jsx)(o.$nd,{sx:{marginTop:1},onClick:function(){if(null!==t){var e="desktop"===T?{popup_type:S.popup_type,initial_message_popup_delay:S.initial_message_popup_delay,chatwidget_popup_delay:S.chatwidget_popup_delay,initial_message:S.initial_message}:{mobile_popup_type:S.mobile_popup_type,mobile_initial_message_popup_delay:S.mobile_initial_message_popup_delay,mobile_chatwidget_popup_delay:S.mobile_chatwidget_popup_delay,mobile_initial_message:S.mobile_initial_message};b.mutate({chatbotId:t,settingsToUpdate:e})}},variant:"contained",color:"primary",disabled:a||A,children:d("DISPLAY_STRINGS.UPDATE")})]})]})},Jr=t(94632),Vr=t(50764),qr=t(64778),Qr=t(60551),$r=t(98163),Xr=t(33402),Zr=function(e,n,t,r){return new(t||(t=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function l(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){var n;e.done?i(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(a,l)}s((r=r.apply(e,n||[])).next())}))},ei=function(e,n){var t,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=l(0),a.throw=l(1),a.return=l(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function l(l){return function(s){return function(l){if(t)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(o=0)),o;)try{if(t=1,r&&(i=2&l[0]?r.return:l[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,l[1])).done)return i;switch(r=0,i&&(l=[2&l[0],i.value]),l[0]){case 0:case 1:i=l;break;case 4:return o.label++,{value:l[1],done:!1};case 5:o.label++,r=l[1],l=[0];continue;case 7:l=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==l[0]&&2!==l[0])){o=0;continue}if(3===l[0]&&(!i||l[1]>i[0]&&l[1]<i[3])){o.label=l[1];break}if(6===l[0]&&o.label<i[1]){o.label=i[1],i=l;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(l);break}i[2]&&o.ops.pop(),o.trys.pop();continue}l=n.call(e,o)}catch(e){l=[6,e],r=0}finally{t=i=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,s])}}};var ni,ti,ri=function(e){var n=this,t=e.chatbot,o=(0,c.Bd)().t,a=(0,i.useState)(""),l=a[0],s=a[1],d=(0,i.useState)(null),u=d[0],h=d[1],S=(0,i.useState)(!1),p=S[0],x=S[1],f=(0,i.useState)(!1),_=f[0],A=f[1],I=(0,i.useState)("STOP, UNSUBSCRIBE, 
1CANCEL, END, QUIT"),m=I[0],T=I[1],v=(0,i.useState)("You have been unsubscribed and will no longer receive SMS messages. Reply START to re-subscribe."),b=v[0],g=v[1],E=(0,Xr.MS)("",!0),L=E.data,N=E.isLoading,j=(null!=L?L:[]).map((function(e){return{value:e.number,label:e.number,id:e.id}}));return(0,i.useEffect)((function(){Qr.A.get(y.n.CHATBOT.SMS_SETTINGS(t)).then((function(e){var n,t,r,i,o=e.data;o&&Object.keys(o).length&&(x(null!==(n=o.sms_enabled)&&void 0!==n&&n),A(null!==(t=o.auto_reply)&&void 0!==t&&t),T(null!==(r=o.opt_out_keywords)&&void 0!==r?r:""),g(null!==(i=o.opt_out_message)&&void 0!==i?i:""),o.phone_number_id&&h(o.phone_number_id),o.phone_number&&s(o.phone_number))}))}),[t]),(0,r.jsxs)(Hn.azJ,{children:[(0,r.jsx)(Hn.azJ,{sx:{mb:2},children:(0,r.jsx)($r.A,{hideAccountsPanel:!0,smsOnly:!0})}),(0,r.jsx)(Hn.ZpM,{variant:"outlined",sx:{mb:2},children:(0,r.jsxs)(Hn.Wux,{sx:{p:3,"&:last-child":{pb:3}},children:[(0,r.jsx)(Hn.o5u,{variant:"subtitle1",fontWeight:600,sx:{mb:.5},children:o("DISPLAY_STRINGS.SMS_ASSIGN_PHONE_NUMBER")}),(0,r.jsx)(Hn.o5u,{variant:"body2",color:"text.secondary",sx:{mb:2},children:o("DISPLAY_STRINGS.SMS_ASSIGN_PHONE_NUMBER_DESCRIPTION")}),(0,r.jsxs)(Hn.fPr,{container:!0,direction:"column",spacing:2,children:[(0,r.jsxs)(Hn.fPr,{size:{xs:12},children:[(0,r.jsx)(Hn.JU7,{name:o("DISPLAY_STRINGS.SMS_PHONE_NUMBER_LABEL"),ignoreSpace:!0}),(0,r.jsx)(Jr.A,{id:"phoneNumber",isClearable:!0,isSearchable:!0,isLoading:N,options:j,selectedValue:l,selectedLabel:"",onChange:function(e){var n;s(e);var t=j.find((function(n){return n.value===e}));h(null!==(n=null==t?void 0:t.id)&&void 0!==n?n:null)},placeholder:o(N?"DISPLAY_STRINGS.LOADING":"DISPLAY_STRINGS.SMS_SELECT_PHONE_NUMBER")})]}),(0,r.jsxs)(Hn.fPr,{size:{xs:12},children:[(0,r.jsx)(Hn.o5u,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:1},children:o("DISPLAY_STRINGS.SMS_A2P_NUMBERS_ONLY_NOTE")}),(0,r.jsx)(Hn.$nd,{variant:"contained",onClick:function(){return Zr(n,void 0,void 0,(function(){var e,n,r;return ei(this,(function(i){switch(i.label){case 0:if(!u)return[2];i.label=1;case 1:return i.trys.push([1,3,,4]),[4,Qr.A.post(y.n.CHATBOT.SMS_SETTINGS(t),{phone_number_id:u})];case 2:return i.sent(),(0,Yr.vd)(o("DISPLAY_STRINGS.SMS_PHONE_NUMBER_SAVED")),[3,4];case 3:return e=i.sent(),(0,Yr.ag)((null===(r=null===(n=null==e?void 0:e.response)||void 0===n?void 0:n.data)||void 0===r?void 0:r.message)||o("DISPLAY_STRINGS.SOMETHING_WENT_WRONG")),[3,4];case 4:return[2]}}
1))}))},disabled:!l,children:o("DISPLAY_STRINGS.SMS_SAVE_PHONE_NUMBER")})]})]})]})}),(0,r.jsx)(Hn.ZpM,{variant:"outlined",sx:{mb:2},children:(0,r.jsx)(Hn.Wux,{sx:{p:3,"&:last-child":{pb:3}},children:(0,r.jsxs)(Hn.FcD,{severity:"info",icon:(0,r.jsx)(Vr.A,{}),sx:{alignItems:"flex-start"},children:[(0,r.jsx)(Hn.XL1,{sx:{fontWeight:600},children:o("DISPLAY_STRINGS.SMS_A2P_TITLE")}),(0,r.jsx)(Hn.o5u,{variant:"body2",sx:{mb:1},children:o("DISPLAY_STRINGS.SMS_A2P_DESCRIPTION")}),(0,r.jsxs)(Hn.azJ,{component:"ul",sx:{pl:2,m:0,mb:1},children:[(0,r.jsx)("li",{children:(0,r.jsxs)(Hn.o5u,{variant:"body2",children:[o("DISPLAY_STRINGS.SMS_A2P_STEP_1_PRE")," ",(0,r.jsx)(Hn.azJ,{component:"a",href:"https://console.twilio.com",target:"_blank",rel:"noopener noreferrer",sx:{fontWeight:600,color:"inherit"},children:o("DISPLAY_STRINGS.SMS_A2P_TWILIO_CONSOLE")})]})}),(0,r.jsx)("li",{children:(0,r.jsx)(Hn.o5u,{variant:"body2",children:o("DISPLAY_STRINGS.SMS_A2P_STEP_2")})}),(0,r.jsx)("li",{children:(0,r.jsx)(Hn.o5u,{variant:"body2",children:o("DISPLAY_STRINGS.SMS_A2P_STEP_3")})})]}),(0,r.jsxs)(Hn.azJ,{component:"a",href:"https://help.twilio.com/articles/1260800720410",target:"_blank",rel:"noopener noreferrer",sx:{color:"primary.main",fontWeight:500},children:[o("DISPLAY_STRINGS.SMS_A2P_LEARN_MORE")," →"]})]})})}),(0,r.jsx)(Hn.ZpM,{variant:"outlined",sx:{mb:2},children:(0,r.jsxs)(Hn.Wux,{sx:{p:3,"&:last-child":{pb:3}},children:[(0,r.jsx)(Hn.o5u,{variant:"subtitle1",fontWeight:600,sx:{mb:.5},children:o("DISPLAY_STRINGS.SMS_SETTINGS_TITLE")}),(0,r.jsx)(Hn.o5u,{variant:"body2",color:"text.secondary",sx:{mb:2},children:o("DISPLAY_STRINGS.SMS_SETTINGS_DESCRIPTION")}),(0,r.jsxs)(Hn.azJ,{sx:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",mb:2},children:[(0,r.jsxs)(Hn.azJ,{children:[(0,r.jsx)(Hn.o5u,{variant:"body2",fontWeight:500,children:o("DISPLAY_STRINGS.SMS_ENABLE_SMS_CHANNEL")}),(0,r.jsx)(Hn.o5u,{variant:"caption",color:"text.secondary",children:o("DISPLAY_STRINGS.SMS_ENABLE_SMS_CHANNEL_DESCRIPTION")})]}),(0,r.jsx)(ie.A,{checked:p,onChange:function(e){return x(e.target.checked)}})]}),(0,r.jsxs)(Hn.azJ,{sx:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",mb:2.5},children:[(0,r.jsxs)(Hn.azJ,{children:[(0,r.jsx)(Hn.o5u,{variant:"body2",fontWeight:500,children:o("DISPLAY_STRINGS.SMS_AUTO_REPLY")}),(0,r.jsx)(Hn.o5u,{variant:"caption",color:"text.secondary",children:o("DISPLAY_STRINGS.SMS_AUTO_REPLY_DESCRIPTION")})]}),(0,r.jsx)(ie.A,{checked:_,onChange:function(e){return A(e.target.checked)}})]}),(0,r.jsxs)(Hn.fPr,{container:!0,direction:"column",spacing:2,sx:{mb:2},children:[(0,r.jsxs)(Hn.fPr,{size:{xs:12},children:[(0,r.jsx)(Hn.JU7,{name:o("DISPLAY_STRINGS.SMS_OPT_OUT_KEYWORDS"),ignoreSpace:!0}),(0,r.jsx)(Hn.A_L,{id:"optOutKeywords",fullWidth:!0,value:m,onChange:function(e){return T(e.target.value)},variant:"outlined",sx:{width:"100%","& #optOutKeywords":{padding:"10px"}}}),(0,r.jsx)(Hn.o5u,{variant:"caption",color:"text.secondary",sx:{mt:.5,display:"block"},children:o("DISPLAY_STRINGS.SMS_OPT_OUT_KEYWORDS_HELPER")})]}),(0,r.jsxs)(Hn.fPr,{size:{xs:12},children:[(0,r.jsx)(Hn.JU7,{name:o("DISPLAY_STRINGS.SMS_OPT_OUT_CONFIRMATION_MESSAGE"),ignoreSpace:!0}),(0,r.jsx)(Hn.A_L,{id:"optOutConfirmationMessage",fullWidth:!0,multiline:!0,rows:3,value:b,onChange:function(e){return g(e.target.value)},variant:"outlined",sx:{width:"100%"}})]})]}),(0,r.jsx)(Hn.$nd,{variant:"contained",onClick:function(){return Zr(n,void 0,void 0,(function(){var e,n,r;return ei(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,Qr.A.post(y.n.CHATBOT.SMS_SETTINGS(t),{sms_enabled:p,auto_reply:_,opt_out_keywords:m,opt_out_message:b})];case 1:return i.sent(),(0,Yr.vd)(o("DISPLAY_STRINGS.SMS_SETTINGS_SAVED")),[3,3];case 2:return e=i.sent(),(0,Yr.ag)((null===(r=null===(n=null==e?void 0:e.response)||void 0===n?void 0:n.data)||void 0===r?void 0:r.message)||o("DISPLAY_STRINGS.SOMETHING_WENT_WRONG")),[3,3];case 3:return[2]}}
1))}))},children:o("DISPLAY_STRINGS.SMS_SAVE_SETTINGS")})]})}),(0,r.jsx)(Hn.ZpM,{variant:"outlined",children:(0,r.jsxs)(Hn.Wux,{sx:{p:3,"&:last-child":{pb:3}},children:[(0,r.jsx)(Hn.o5u,{variant:"subtitle1",fontWeight:600,sx:{mb:2},children:o("DISPLAY_STRINGS.SMS_CONNECTED_NUMBERS")}),l?(0,r.jsxs)(Hn.azJ,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[(0,r.jsx)(qr.A,{color:"primary"}),(0,r.jsx)(Hn.o5u,{variant:"body2",fontWeight:500,children:l})]}):(0,r.jsxs)(Hn.azJ,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",py:4,color:"text.secondary"},children:[(0,r.jsx)(qr.A,{sx:{fontSize:48,mb:1.5,opacity:.4}}),(0,r.jsx)(Hn.o5u,{variant:"body2",fontWeight:500,children:o("DISPLAY_STRINGS.SMS_NO_PHONE_NUMBERS_CONNECTED")}),(0,r.jsx)(Hn.o5u,{variant:"caption",color:"text.secondary",sx:{mt:.5,textAlign:"center"},children:o("DISPLAY_STRINGS.SMS_NO_PHONE_NUMBERS_CONNECTED_DESCRIPTION")})]})]})})]})},ii=t(45152),oi=function(e){var n=e.icon,t=e.title,i=e.description,a=e.accent,l=void 0===a?"primary":a,s=e.preview,c=e.action,d=e.toggle;return(0,r.jsxs)(o.ZpM,{variant:"outlined",sx:{display:"flex",flexDirection:"column",height:"100%",borderColor:"divider",overflow:"hidden",transition:function(e){return e.transitions.create(["box-shadow","border-color"],{duration:e.transitions.duration.shorter})},"&:hover":{borderColor:"primary.main",boxShadow:function(e){return e.shadows[2]}}},children:[(0,r.jsx)(o.azJ,{sx:{height:120,display:"flex",alignItems:"center",justifyContent:"center",px:3,background:function(e){return"linear-gradient(135deg, ".concat((0,o.X4A)(e.palette[l].main,.16)," 0%, ").concat((0,o.X4A)(e.palette[l].light,.05)," 100%)")},color:function(e){return(0,o.X4A)(e.palette[l].main,.85)}},children:null!=s?s:(0,r.jsx)(o.azJ,{sx:{display:"inline-flex",fontSize:40,lineHeight:0},children:n})}),(0,r.jsxs)(o.Wux,{sx:{flex:1,display:"flex",flexDirection:"column",gap:1,p:2.5,"&:last-child":{pb:2.5}},children:[(0,r.jsxs)(o.azJ,{sx:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:1},children:[(0,r.jsxs)(o.azJ,{children:[(0,r.jsx)(o.o5u,{variant:"subtitle1",color:"text.primary",fontWeight:600,children:t}),(0,r.jsx)(o.o5u,{variant:"body2",color:"text.secondary",sx:{mt:.5},children:i})]}),d&&(0,r.jsx)(o.dOG,{checked:d.checked,onChange:function(e){return d.onChange(e.target.checked)},disabled:d.disabled,color:"primary",inputProps:d.ariaLabel?{"aria-label":d.ariaLabel}:void 0})]}),c&&(0,r.jsx)(o.azJ,{sx:{mt:"auto",pt:.5},children:(0,ii.E)(c)})]})]})},ai=t(79943),li={chatWidget:s.Pl,helpPage:s.bc,email:s.Ps,shopify:ai.M6,phone:s.NW,whatsapp:ai._g,messenger:ai.DU,instagram:ai.ML,zendesk:ai.Yt,slack:ai.ms,wordpress:ai.NJ,api:s.jI,zapier:ai.tn},si=function(e){var n=e.iconKey,t=e.size,i=void 0===t?26:t,o=li[n];return(0,r.jsx)(o,{style:{fontSize:i,width:"1em",height:"1em"}})},ci=function(){return ci=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var i in n=arguments[t])Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i]);return e},ci.apply(this,arguments)},di={bgcolor:"background.paper",borderRadius:1.5,boxShadow:function(e){return e.shadows[3]}},ui=function(e){var n=e.title,t=e.description;return(0,r.jsxs)(o.azJ,{sx:{mb:2.5},children:[(0,r.jsx)(o.o5u,{variant:"subtitle1",color:"text.primary",fontWeight:600,children:n}),t&&(0,r.jsx)(o.o5u,{variant:"body2",color:"text.secondary",sx:{mt:.5},children:t})]})},hi=function(e){var n=e.permission,t=e.loadingSkeleton,i=e.onBack,a=e.children,l=(0,c.Bd)().t;return(0,r.jsxs)(o.azJ,{children:[(0,r.jsx)(o.$nd,{startIcon:(0,r.jsx)(s.v$,{}),onClick:i,sx:{mb:2},color:"primary",children:l("DISPLAY_STRINGS.BACK")}),(0,r.jsx)(o.ZpM,{children:(0,r.jsx)(o.Wux,{sx:{p:3,"&:last-child":{pb:3}},children:(0,r.jsx)(o.L0s,{permission:n,loadingSkeleton:t,children:a})})})]})},Si=t(59326),pi=((ni={})[Xt]={labelKey:"DISPLAY_STRINGS.MCP_STATUS_ACTIVE",color:"success"},ni[$t]={labelKey:"DISPLAY_STRINGS.MCP_STATUS_PENDING",color:"warning"},ni[Zt]={labelKey:"DISPLAY_STRINGS.MCP_STATUS_ERROR",color:"error"},ni[er]={labelKey:"DISPLAY_STRINGS.MCP_AWAITING_AUTH",color:"info"},ni),xi=function(e){var n=e.status,t=e.detail,i=e.isEnabled,a=void 0===i||i,l=(0,c.Bd)().t,s=pi[n],d=l(a?s.labelKey:"DISPLAY_STRINGS.MCP_STATUS_DISABLED");return(0,r.jsx)(o.m_M,{title:t||d,children:(0,r.jsx)(o.vu3,{size:"x-small",variant:"outlined",color:a?s.color:"default",label:d})})},fi=t(48513),_i=function(e){for(var n={},t=0,r=e;t<r.length;t++){var i=r[t],o=fi.Yj().trim().required(jt.Ay.t("VALIDATION_ERRORS.MCP_INPUT_REQUIRED",{field:i.label}));"full_url"===i.kind&&(o=o.matches(/^https:\/\//i,jt.Ay.t("VALIDATION_ERRORS.MCP_SERVER_URL_INVALID"))),i.pattern&&(o=o.matches(new RegExp("^(?:".concat(i.pattern,")$")),jt.Ay.t("VALIDATION_ERRORS.MCP_INPUT_INVALID",{field:i.label}))),n[i.key]=o}return fi.Ik().shape(n)},Ai=function(){return Ai=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var i in n=arguments[t])Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i]);return e},Ai.apply(this,arguments)}
1,Ii=new Set(["alias","server_url","description","transport","auth_method","bearer_token","api_key","api_key_header","oauth_client_id","oauth_client_secret","oauth_scope","timeout"]),mi=function(e){var n=yr.find((function(n){return e.toLowerCase().startsWith(n)}));return n?{scheme:n,rest:e.slice(n.length)}:{scheme:Lr,rest:e}},Ti={alias:"",server_scheme:Lr,server_url:"",description:"",transport:nr,auth_method:rr,bearer_token:"",api_key:"",api_key_header:Er,oauth_registration_mode:jr,oauth_client_id:"",oauth_client_secret:"",oauth_scope:"",extra_headers:{},timeout:30},vi=function(e){var n,t,r,i;if(!e)return Ti;var o=mi(null!==(n=e.server_url)&&void 0!==n?n:""),a=o.scheme,l=o.rest;return Ai(Ai({},Ti),{alias:e.name,server_scheme:a,server_url:l,description:null!==(t=e.description)&&void 0!==t?t:"",transport:e.transport,auth_method:e.auth_method,api_key_header:null!==(r=e.default_api_key_header)&&void 0!==r?r:Er,oauth_registration_mode:e.requires_user_oauth_app?Cr:Ti.oauth_registration_mode,extra_headers:Object.fromEntries((null!==(i=e.header_inputs)&&void 0!==i?i:[]).map((function(e){return[e.key,""]})))})},bi=function(e){var n,t,i,a,l=e.open,s=e.chatbot,d=e.onClose,u=e.prefill,h=(0,c.Bd)().t,f=(t=s,i=(0,S.jE)(),(0,p.n)({mutationFn:function(e){return D(void 0,void 0,void 0,(function(){var n;return R(this,(function(t){switch(t.label){case 0:return[4,E.nv.post(y.n.MCP.CONNECTIONS,e)];case 1:return n=t.sent().data,[4,E.nv.post(y.n.MCP.CONNECTION_SYNC(n.id))];case 2:return[2,t.sent().data]}}))}))},onSuccess:function(){i.invalidateQueries({queryKey:[N,t]}),i.invalidateQueries({queryKey:[C]})}})),_=(0,p.n)({mutationFn:function(e){return D(void 0,void 0,void 0,(function(){return R(this,(function(n){switch(n.label){case 0:return[4,E.nv.post(y.n.MCP.CONNECTIONS,e)];case 1:return[2,n.sent().data]}}))}))}}),A=Nr(),I=[{value:rr,label:jt.Ay.t("DISPLAY_STRINGS.MCP_AUTH_NONE")},{value:ir,label:jt.Ay.t("DISPLAY_STRINGS.MCP_AUTH_BEARER")},{value:or,label:jt.Ay.t("DISPLAY_STRINGS.MCP_AUTH_API_KEY")},{value:ar,label:jt.Ay.t("DISPLAY_STRINGS.MCP_AUTH_OAUTH2")}],m=[{value:jr,label:jt.Ay.t("DISPLAY_STRINGS.MCP_OAUTH_MODE_DYNAMIC")},{value:Cr,label:jt.Ay.t("DISPLAY_STRINGS.MCP_OAUTH_MODE_MANUAL")}],T=Boolean(u),v=Boolean(null==u?void 0:u.requires_user_oauth_app),g=f.isPending||_.isPending;return(0,r.jsxs)(o.lGe,{open:l,onClose:d,fullWidth:!0,maxWidth:"sm",children:[(0,r.jsx)(o.L33,{children:T?h("DISPLAY_STRINGS.MCP_CONNECT_TITLE",{name:null==u?void 0:u.name}):h("DISPLAY_STRINGS.ADD_MCP_CONNECTION")}),(0,r.jsx)(o.l1m,{enableReinitialize:!0,initialValues:vi(u),validationSchema:(a=null!==(n=null==u?void 0:u.header_inputs)&&void 0!==n?n:[],void 0===a&&(a=[]),fi.Ik().shape({alias:fi.Yj().trim().required(jt.Ay.t("VALIDATION_ERRORS.MCP_ALIAS_REQUIRED")),server_url:fi.Yj().trim().required(jt.Ay.t("VALIDATION_ERRORS.MCP_SERVER_URL_REQUIRED")).matches(/^[^\s/:?#]+\.[^\s/:?#]+(:\d+)?(\/\S*)?$/,jt.Ay.t("VALIDATION_ERRORS.MCP_SERVER_URL_INVALID")),server_scheme:fi.Yj().required(),transport:fi.Yj().required(),auth_method:fi.Yj().required(),bearer_token:fi.Yj().when("auth_method",{is:ir,then:function(e){return e.required(jt.Ay.t("VALIDATION_ERRORS.MCP_BEARER_TOKEN_REQUIRED"))},otherwise:function(e){return e.notRequired()}}),api_key:fi.Yj().when("auth_method",{is:or,then:function(e){return e.required(jt.Ay.t("VALIDATION_ERRORS.MCP_API_KEY_REQUIRED"))},otherwise:function(e){return e.notRequired()}}),api_key_header:fi.Yj().notRequired(),oauth_registration_mode:fi.Yj().notRequired(),oauth_client_id:fi.Yj().when(["auth_method","oauth_registration_mode"],{is:function(e,n){return e===ar&&n===Cr},then:function(e){return e.trim().required(jt.Ay.t("VALIDATION_ERRORS.MCP_OAUTH_CLIENT_ID_REQUIRED"))},otherwise:function(e){return e.notRequired()}}),oauth_client_secret:fi.Yj().notRequired(),oauth_scope:fi.Yj().notRequired(),extra_headers:fi.Ik().shape(Object.fromEntries(a.map((function(e){var n=fi.Yj().trim().required(jt.Ay.t("VALIDATION_ERRORS.MCP_INPUT_REQUIRED",{field:e.label}));return e.pattern&&(n=n.matches(new RegExp("^(?:".concat(e.pattern,")$")),jt.Ay.t("VALIDATION_ERRORS.MCP_INPUT_INVALID",{field:e.label}))),[e.key,n]})))),description:fi.Yj().notRequired(),timeout:fi.ai().typeError(jt.Ay.t("VALIDATION_ERRORS.MCP_TIMEOUT_RANGE")).min(1,jt.Ay.t("VALIDATION_ERRORS.MCP_TIMEOUT_RANGE")).max(30,jt.Ay.t("VALIDATION_ERRORS.MCP_TIMEOUT_RANGE")).required(jt.Ay.t("VALIDATION_ERRORS.MCP_TIMEOUT_RANGE"))})),onSubmit:function(e,n){var t,r=n.resetForm,i=n.setErrors,o=e.auth_method===ar&&e.oauth_registration_mode===Cr,a=Ai(Ai(Ai(Ai(Ai({chatbot:s,alias:e.alias.trim(),server_url:"".concat(e.server_scheme).concat(e.server_url.trim()),description:e.description.trim()||void 0,transport:e.transport,auth_method:e.auth_method,timeout:Number(e.timeout)},u?{official_connector_key:u.key}:{}),(t=Object.fromEntries(Object.entries(e.extra_headers||{}).map((function(e){var n=e[0],t=e[1];return[n,String(t).trim()]})).filter((function(e){return e[1]}))),Object.keys(t).length?{extra_headers:t}:{})),e.auth_method===ir&&e.bearer_token?{bearer_token:e.bearer_token}:{}),e.auth_method===or?{api_key:e.api_key,api_key_header:e.api_key_header.trim()||null}:{}),o?Ai(Ai({oauth_client_id:e.oauth_client_id.trim()},e.oauth_client_secret?{oauth_client_secret:e.oauth_client_secret}:{}),e.oauth_scope.trim()?{oauth_scope:e.oauth_scope.trim()}:{}):{}),l=function(e){var n=function(e){var n,t={},r=[],i=null===(n=null==e?void 0:e.response)||void 0===n?void 0:n.data;if(i&&"object"==typeof i&&!Array.isArray(i))for(var o=0,a=Object.entries(i);o<a.length;o++){var l=a[o],s=l[0],c=l[1],d=Array.isArray(c)?String(c[0]):String(c);Ii.has(s)?t[s]=d:r.push(d)}return{fieldErrors:t,otherMessages:r}}(e),t=n.fieldErrors,r=n.otherMessages;Object.keys(t).length&&i(t),Object.keys(t).length&&!r.length||(0,x.Sx)("",r[0]||h("DISPLAY_STRINGS.MCP_CONNECTION_CREATE_FAILED"),"error")};e.auth_method!==ar?f.mutate(a,{onSuccess:function(e){var n;e.status===Zt?(0,x.Sx)(h("DISPLAY_STRINGS.MCP_CONNECTION_SYNC_FAILED"),null!==(n=e.error)&&void 0!==n?n:"","warning"):(0,x.Sx)("",h("DISPLAY_STRINGS.MCP_CONNECTION_CREATED"),"success"),r(),d()},onError:l}):_.mutate(a,{onSuccess:function(e){r(),d(),window.location.href=y.n.MCP.CONNECTION_OAUTH_START(e.id)},onError:l})},children:function(e){var n;return(0,r.jsxs)(b.lV,{children:[(0,r.jsx)(o.Cff,{dividers:!0,children:(0,r.jsxs)(o.BJc,{spacing:2,children:[(0,r.jsx)(o.A_L,{fullWidth:!0,name:"alias",label:h("DISPLAY_STRINGS.NAME"),value:e.values.alias,onChange:e.handleChange,onBlur:e.handleBlur,error:e.touched.alias&&Boolean(e.errors.alias),helperText:e.touched.alias&&e.errors.alias}),(0,r.jsx)(o.A_L,{fullWidth:!0,name:"server_url",label:h("DISPLAY_STRINGS.MCP_SERVER_URL_LABEL"),placeholder:"example.com/mcp",value:e.values.server_url,onChange:function(n){var t=mi(n.target.value),r=t.scheme,i=t.rest;e.setFieldValue("server_scheme",r),e.setFieldValue("server_url",i)},onBlur:e.handleBlur,InputLabelProps:{shrink:!0},InputProps:{readOnly:T,startAdornment:(0,r.jsx)(o.l6P,{name:"server_scheme",value:e.values.server_scheme,onChange:e.handleChange,disabled:T,variant:"standard",disableUnderline:!0,"aria-label":h("DISPLAY_STRINGS.MCP_URL_SCHEME_LABEL"),sx:{mr:1,color:"text.secondary","& .MuiSelect-select":{pl:0,py:0}},children:yr.map((function(e){return(0,r.jsx)(o.Drp,{value:e,children:e},e)}))})},error:e.touched.server_url&&Boolean(e.errors.server_url),helperText:e.touched.server_url&&e.errors.server_url}),(0,r.jsx)(o.A_L,{fullWidth:!0,name:"description",label:h("DISPLAY_STRINGS.DESCRIPTION"),value:e.values.description,onChange:e.handleChange}),(0,r.jsx)(o.A_L,{select:!0,fullWidth:!0,name:"transport",label:h("DISPLAY_STRINGS.MCP_TRANSPORT_LABEL"),value:e.values.transport,onChange:e.handleChange,disabled:T,children:A.map((function(e){return(0,r.jsx)(o.Drp,{value:e.value,children:e.label},e.value)}))}),(0,r.jsx)(o.A_L,{select:!0,fullWidth:!0,name:"auth_method",label:h("DISPLAY_STRINGS.MCP_AUTH_METHOD_LABEL"),value:e.values.auth_method,onChange:e.handleChange,disabled:T,children:I.map((function(e){return(0,r.jsx)(o.Drp,{value:e.value,children:e.label},e.value)}))}),e.values.auth_method===ir&&(0,r.jsx)(o.A_L,{fullWidth:!0,type:"password",name:"bearer_token",label:h("DISPLAY_STRINGS.MCP_BEARER_TOKEN_LABEL"),value:e.values.bearer_token,onChange:e.handleChange,onBlur:e.handleBlur,error:e.touched.bearer_token&&Boolean(e.errors.bearer_token),helperText:e.touched.bearer_token&&e.errors.bearer_token}),e.values.auth_method===or&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(o.A_L,{fullWidth:!0,type:"password",name:"api_key",label:h("DISPLAY_STRINGS.MCP_API_KEY_LABEL"),value:e.values.api_key,onChange:e.handleChange,onBlur:e.handleBlur,error:e.touched.api_key&&Boolean(e.errors.api_key),helperText:e.touched.api_key&&e.errors.api_key}),(0,r.jsx)(o.A_L,{fullWidth:!0,name:"api_key_header",label:h("DISPLAY_STRINGS.MCP_API_KEY_HEADER_LABEL"),value:e.values.api_key_header,onCh
1ange:e.handleChange})]}),(null!==(n=null==u?void 0:u.header_inputs)&&void 0!==n?n:[]).map((function(n){var t,i,a,l=e.errors.extra_headers,s=e.touched.extra_headers,c=(null==s?void 0:s[n.key])?null==l?void 0:l[n.key]:void 0;return(0,r.jsx)(o.A_L,{fullWidth:!0,name:"extra_headers.".concat(n.key),label:n.label,placeholder:null!==(t=n.placeholder)&&void 0!==t?t:"",value:null!==(a=null===(i=e.values.extra_headers)||void 0===i?void 0:i[n.key])&&void 0!==a?a:"",onChange:e.handleChange,onBlur:e.handleBlur,error:Boolean(c),helperText:c||n.help_text||""},n.key)})),e.values.auth_method===ar&&(0,r.jsxs)(r.Fragment,{children:[!v&&(0,r.jsx)(o.A_L,{select:!0,fullWidth:!0,name:"oauth_registration_mode",label:h("DISPLAY_STRINGS.MCP_OAUTH_MODE_LABEL"),value:e.values.oauth_registration_mode,onChange:e.handleChange,helperText:h("DISPLAY_STRINGS.MCP_OAUTH_REDIRECT_HINT"),children:m.map((function(e){return(0,r.jsx)(o.Drp,{value:e.value,children:e.label},e.value)}))}),e.values.oauth_registration_mode===Cr&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(o.A_L,{fullWidth:!0,name:"oauth_client_id",label:h("DISPLAY_STRINGS.MCP_OAUTH_CLIENT_ID_LABEL"),value:e.values.oauth_client_id,onChange:e.handleChange,onBlur:e.handleBlur,error:e.touched.oauth_client_id&&Boolean(e.errors.oauth_client_id),helperText:e.touched.oauth_client_id&&e.errors.oauth_client_id}),(0,r.jsx)(o.A_L,{fullWidth:!0,type:"password",name:"oauth_client_secret",label:h("DISPLAY_STRINGS.MCP_OAUTH_CLIENT_SECRET_LABEL"),value:e.values.oauth_client_secret,onChange:e.handleChange}),(0,r.jsx)(o.A_L,{fullWidth:!0,name:"oauth_scope",label:h("DISPLAY_STRINGS.MCP_OAUTH_SCOPE_LABEL"),placeholder:h("DISPLAY_STRINGS.MCP_OAUTH_SCOPE_PLACEHOLDER"),value:e.values.oauth_scope,onChange:e.handleChange})]})]}),(0,r.jsx)(o.A_L,{fullWidth:!0,type:"number",name:"timeout",label:h("DISPLAY_STRINGS.MCP_TIMEOUT_LABEL"),value:e.values.timeout,onChange:e.handleChange,onBlur:e.handleBlur,error:e.touched.timeout&&Boolean(e.errors.timeout),helperText:e.touched.timeout&&e.errors.timeout})]})}),(0,r.jsx)(o.iin,{children:(0,r.jsxs)(o.azJ,{sx:{display:"flex",gap:1},children:[(0,r.jsx)(o.$nd,{onClick:d,color:"inherit",children:h("DISPLAY_STRINGS.CANCEL")}),(0,r.jsx)(o.$nd,{type:"submit",variant:"contained",disabled:g,children:h("DISPLAY_STRINGS.MCP_ADD_SUBMIT")})]})})]})}})]})},gi=t(17577),Ei=function(e){var n=e.text,t=(0,c.Bd)().t,a=(0,i.useState)(!1),l=a[0],s=a[1],d=(0,i.useState)(!1),u=d[0],h=d[1],S=(0,i.useRef)(null);return(0,i.useEffect)((function(){var e=S.current;e&&!l&&h(e.scrollHeight>e.clientHeight+1)}),[n,l]),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(o.o5u,{ref:S,variant:"body2",color:"text.secondary",sx:l?void 0:{display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},children:n}),(u||l)&&(0,r.jsx)(o.N_E,{component:"button",type:"button",variant:"caption",onClick:function(){return s((function(e){return!e}))},sx:{mt:.25},children:t(l?"DISPLAY_STRINGS.SHOW_LESS":"DISPLAY_LABELS.SHOW_MORE")})]})},yi=function(e){var n,t,a,l,s,d,u,h=e.connection,f=e.icon,_=e.chatbot,A=e.onClose,I=(0,c.Bd)().t,m=function(e){return(0,g.I)({queryKey:[j,e],queryFn:function(){return D(void 0,void 0,void 0,(function(){var n,t,r,i,o;return R(this,(function(a){switch(a.label){case 0:return[4,E.nv.get(y.n.MCP.CONNECTION_TOOLS(e))];case 1:return n=a.sent(),[2,{granted:null!==(r=null===(t=n.data)||void 0===t?void 0:t.granted)&&void 0!==r?r:[],not_allowed:null!==(o=null===(i=n.data)||void 0===i?void 0:i.not_allowed)&&void 0!==o?o:[]}]}}))}))},enabled:null!==e,retry:!1})}(null!==(n=null==h?void 0:h.id)&&void 0!==n?n:null),T=m.data,v=m.isLoading,b=function(e){var n=(0,S.jE)();return(0,p.n)({mutationFn:function(n){return D(void 0,[n],void 0,(function(n){var t=n.toolId,r=n.patch;return R(this,(function(n){switch(n.label){case 0:return[4,E.nv.patch(y.n.MCP.CONNECTION_TOOL_DETAIL(e,t),r)];case 1:return[2,n.sent().data]}}))}))},onSuccess:function(){return B(n,e)}})}(null!==(t=null==h?void 0:h.id)&&void 0!==t?t:0),L=function(e){var n=(0,S.jE)();return(0,p.n)({mutationFn:function(n){return D(void 0,void 0,void 0,(function(){return R(this,(function(t){switch(t.label){case 0:return[4,E.nv.patch(y.n.MCP.CONNECTION_TOOLS_BULK(e),n)];case 1:return[2,t.sent().data]}}))}))},onSuccess:function(){return B(n,e)}})}(null!==(a=null==h?void 0:h.id)&&void 0!==a?a:0),C=(d=_,u=(0,S.jE)(),(0,p.n)({mutationFn:function(e){return D(void 0,void 0,void 0,(function(){return R(this,(function(n){switch(n.label){case 0:return[4,E.nv.delete(y.n.MCP.CONNECTION_DETAIL(e))];case 1:return n.sent(),[2]}}))}))}
1,onSuccess:function(){u.invalidateQueries({queryKey:[N,d]})}})),P=null!==(l=null==T?void 0:T.granted)&&void 0!==l?l:[],O=null!==(s=null==T?void 0:T.not_allowed)&&void 0!==s?s:[],w=P.length>0&&P.every((function(e){return e.is_enabled})),G=P.length>0&&P.every((function(e){return!e.is_enabled})),Y=(null==h?void 0:h.auth_method)===ar,M=(null==h?void 0:h.status)===er;return(0,r.jsx)(o._s,{anchor:"right",open:Boolean(h),onClose:A,sx:{"& .MuiDrawer-paper":{width:{xs:"100%",sm:480}}},children:(0,r.jsxs)(o.azJ,{sx:{display:"flex",flexDirection:"column",height:"100%"},children:[(0,r.jsxs)(o.azJ,{sx:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:1.5,p:2.5,borderBottom:1,borderColor:"divider"},children:[(0,r.jsxs)(o.azJ,{sx:{display:"flex",gap:1.5,minWidth:0},children:[f&&(0,r.jsx)(o.azJ,{sx:{lineHeight:0,mt:.25,flexShrink:0},children:f}),(0,r.jsxs)(o.azJ,{sx:{minWidth:0},children:[(0,r.jsxs)(o.o5u,{variant:"h6",fontWeight:600,noWrap:!0,children:[null==h?void 0:h.alias," — ",I("DISPLAY_STRINGS.MCP_TOOLS_TITLE")]}),h&&(0,r.jsx)(o.azJ,{sx:{mt:.25},children:(0,r.jsx)(xi,{status:h.status,detail:h.last_error,isEnabled:h.is_enabled})})]})]}),(0,r.jsx)(o.K0,{onClick:A,size:"small","aria-label":I("DISPLAY_LABELS.CLOSE_BUTTON"),sx:{flexShrink:0},children:(0,r.jsx)(Un.A,{fontSize:"small"})})]}),(0,r.jsxs)(o.azJ,{sx:{flex:1,overflowY:"auto",p:2.5},children:[v&&(0,r.jsx)(o.BJc,{spacing:1,children:Array.from({length:3}).map((function(e,n){return(0,r.jsx)(o.EAD,{variant:"rounded",height:56},n)}))}),!v&&0===P.length&&0===O.length&&(0,r.jsx)(o.o5u,{variant:"body2",color:"text.secondary",children:I("DISPLAY_STRINGS.MCP_NO_TOOLS")}),!v&&G&&(0,r.jsx)(o.FcD,{severity:"info",sx:{mb:2},children:I("DISPLAY_STRINGS.MCP_ALL_TOOLS_OFF_NOTICE")}),!v&&P.length>0&&(0,r.jsx)(o.azJ,{sx:{display:"flex",justifyContent:"flex-end",pb:1.5,mb:.5,borderBottom:1,borderColor:"divider"},children:(0,r.jsx)(o.N_E,{component:"button",type:"button",variant:"body2",disabled:L.isPending,onClick:function(){return L.mutate({is_enabled:!w})},children:I(w?"DISPLAY_STRINGS.DESELECT_ALL":"DISPLAY_STRINGS.SELECT_ALL")})}),!v&&P.map((function(e,n){return(0,r.jsxs)(i.Fragment,{children:[n>0&&(0,r.jsx)(o.cGx,{sx:{my:1.5}}),(0,r.jsxs)(o.azJ,{sx:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:2},children:[(0,r.jsxs)(o.azJ,{sx:{minWidth:0},children:[(0,r.jsx)(o.o5u,{variant:"subtitle2",children:e.provider_name}),e.description&&(0,r.jsx)(Ei,{text:e.description})]}),(0,r.jsx)(o.dOG,{size:"small",color:"primary",checked:e.is_enabled,onChange:function(n){return b.mutate({toolId:e.id,patch:{is_enabled:n.target.checked}})},inputProps:{"aria-label":e.provider_name},sx:{flexShrink:0}})]})]},e.id)})),!v&&O.length>0&&(0,r.jsxs)(o.azJ,{sx:{mt:P.length>0?3:0},children:[(0,r.jsxs)(o.o5u,{variant:"subtitle2",sx:{mb:.5},children:[I("DISPLAY_STRINGS.MCP_TOOLS_NOT_ALLOWED")," (",O.length,")"]}),(0,r.jsx)(o.o5u,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:1.5},children:I("DISPLAY_STRINGS.MCP_TOOLS_NOT_ALLOWED_NOTE")}),(0,r.jsx)(o.azJ,{sx:{display:"flex",flexWrap:"wrap",gap:.75},children:O.map((function(e){return(0,r.jsx)(Ke.A,{title:e.description||"",disableHoverListener:!e.description,disableFocusListener:!e.description,children:(0,r.jsx)(gi.A,{label:e.name||e.source_name,size:"x-small",variant:"outlined",color:"default",sx:{opacity:.6}})},e.source_name)}))})]})]}),(0,r.jsx)(o.azJ,{sx:{p:2.5,borderTop:1,borderColor:"divider"},children:(0,r.jsxs)(o.BJc,{direction:"row",spacing:1.5,children:[Y&&(0,r.jsx)(o.$nd,{fullWidth:!0,variant:"outlined",onClick:function(){h&&window.location.assign(y.n.MCP.CONNECTION_OAUTH_START(h.id))},children:I(M?"DISPLAY_STRINGS.MCP_AUTHORIZE":"DISPLAY_STRINGS.MCP_REAUTHORIZE")}),(0,r.jsx)(o.$nd,{fullWidth:!0,color:"error",variant:"outlined",onClick:function(){h&&C.mutate(h.id,{onSuccess:function(){(0,x.Sx)("",I("DISPLAY_STRINGS.MCP_CONNECTION_DELETED"),"success"),A()},onError:function(){return(0,x.Sx)("",I("DISPLAY_STRINGS.MCP_CONNECTION_DELETE_FAILED"),"error")}})},disabled:C.isPending,children:I("DISPLAY_STRINGS.MCP_DELETE_CONNECTION")})]})})]})})},Li=function(e,n){var t,r=function(e){return n.lowercase?e.toLowerCase():e},i=e.trim();if(!i||"full_url"===n.kind)return r(i);for(var o=i.replace(/^[a-z][a-z0-9+.-]*:\/\//i,"").replace(/^[^@/]*@/,""),a=0,l=null!==(t=n.paste_patterns)&&void 0!==t?t:[];a<l.length;a++){var s=l[a];try{var c=new RegExp(s,"i").exec(o);if(null==c?void 0:c[1])return r(c[1])}catch(e){}}return r(o.split(/[/?#]/)[0].split(":")[0])},Ni=function(e){var n,t=e.name;return(0,r.jsx)(o.euF,{variant:"rounded",sx:{width:26,height:26,fontSize:13,fontWeight:600,bgcolor:"grey.200",color:"text.secondary"},children:(null!==(n=t.trim()[0])&&void 0!==n?n:"?").toUpperCase()})}
1,ji=function(e){var n=e.connector,t=e.onConnect,i=e.onOpenDetails,o=e.isConnecting,a=void 0!==o&&o,l=e.isConnected,s=void 0!==l&&l,d=(0,c.Bd)().t,u=(0,r.jsx)(ai.FQ,{name:n.logo_key,size:26}),h=Si.b[n.logo_key]?u:(0,r.jsx)(Ni,{name:n.name}),S=s?d("DISPLAY_STRINGS.MCP_CONNECTOR_CONNECTED"):d(function(e){switch(e.auth_method){case ar:return"DISPLAY_STRINGS.MCP_CONNECT_WITH";case ir:case or:return"DISPLAY_STRINGS.MCP_CONNECTOR_SETUP";default:return"DISPLAY_STRINGS.MCP_CONNECTOR_ADD"}}(n),{name:n.name});return(0,r.jsx)(ii.A,{icon:h,title:n.name,description:n.description,onCardClick:i?function(){return i(n)}:void 0,action:{label:S,variant:"outlined",disabled:a||s,onClick:function(){return t(n)}}})},Ci=t(67735),Pi=function(e,n,t){if(t||2===arguments.length)for(var r,i=0,o=n.length;i<o;i++)!r&&i in n||(r||(r=Array.prototype.slice.call(n,0,i)),r[i]=n[i]);return e.concat(r||Array.prototype.slice.call(n))},Di=((ti={})[rr]="DISPLAY_STRINGS.MCP_AUTH_NONE",ti[ir]="DISPLAY_STRINGS.MCP_AUTH_BEARER",ti[or]="DISPLAY_STRINGS.MCP_AUTH_API_KEY",ti[ar]="DISPLAY_STRINGS.MCP_AUTH_OAUTH2",ti[lr]="DISPLAY_STRINGS.MCP_AUTH_END_USER_OAUTH",ti),Ri=function(e){switch(e.auth_method){case ar:return"DISPLAY_STRINGS.MCP_CONNECT_WITH";case ir:case or:return"DISPLAY_STRINGS.MCP_CONNECTOR_SETUP";default:return"DISPLAY_STRINGS.MCP_CONNECTOR_ADD"}},Oi=function(e){var n=e.label,t=e.children;return(0,r.jsxs)(o.azJ,{sx:{display:"flex",flexDirection:"column",gap:.25},children:[(0,r.jsx)(o.o5u,{variant:"caption",color:"text.secondary",children:n}),(0,r.jsx)(o.azJ,{sx:{fontSize:"0.875rem"},children:t})]})},wi=function(e){var n,t,i,a,l,s,d,u,h=e.connector,S=e.isConnected,p=void 0!==S&&S,f=e.isConnecting,_=void 0!==f&&f,A=e.onConnect,I=e.onClose,m=(0,c.Bd)().t,T=Boolean(h),v=h?null!==(t=null===(n=Nr().find((function(e){return e.value===h.transport})))||void 0===n?void 0:n.label)&&void 0!==t?t:h.transport:"",b=h?m(null!==(i=Di[h.auth_method])&&void 0!==i?i:"")||h.auth_method:"",g=(null==h?void 0:h.server_url)||(null==h?void 0:h.url_template)||"";return(0,r.jsx)(o._s,{anchor:"right",open:T,onClose:I,sx:{"& .MuiDrawer-paper":{width:{xs:"100%",sm:480}}},children:h&&(0,r.jsxs)(o.azJ,{sx:{display:"flex",flexDirection:"column",height:"100%"},children:[(0,r.jsxs)(o.azJ,{sx:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:1.5,p:2.5,borderBottom:1,borderColor:"divider"},children:[(0,r.jsxs)(o.azJ,{sx:{display:"flex",gap:1.5,minWidth:0},children:[(0,r.jsx)(o.azJ,{sx:{lineHeight:0,mt:.25},children:Si.b[h.logo_key]?(0,r.jsx)(ai.FQ,{name:h.logo_key,size:32}):(0,r.jsx)(o.euF,{variant:"rounded",sx:{width:32,height:32,fontSize:15,fontWeight:600,bgcolor:"grey.200",color:"text.secondary"},children:(null!==(a=h.name.trim()[0])&&void 0!==a?a:"?").toUpperCase()})}),(0,r.jsxs)(o.azJ,{sx:{minWidth:0},children:[(0,r.jsx)(o.o5u,{variant:"h6",fontWeight:600,noWrap:!0,children:h.name}),(0,r.jsxs)(o.azJ,{sx:{display:"flex",alignItems:"center",gap:.75,mt:.25},children:[(0,r.jsx)(o.vu3,{size:"small",variant:"outlined",label:gr(h.category)}),p&&(0,r.jsx)(o.vu3,{size:"small",color:"success",label:m("DISPLAY_STRINGS.MCP_CONNECTOR_CONNECTED")})]})]})]}),(0,r.jsx)(o.K0,{onClick:I,size:"small","aria-label":m("DISPLAY_LABELS.CLOSE_BUTTON"),children:(0,r.jsx)(Un.A,{fontSize:"small"})})]}),(0,r.jsxs)(o.azJ,{sx:{flex:1,overflowY:"auto",p:2.5},children:[(0,r.jsx)(o.o5u,{variant:"subtitle2",gutterBottom:!0,children:m("DISPLAY_STRINGS.MCP_CONNECTOR_ABOUT")}),(0,r.jsx)(o.o5u,{variant:"body2",color:"text.secondary",children:h.description}),h.setup_instructions&&(0,r.jsx)(o.o5u,{variant:"body2",color:"text.secondary",sx:{mt:1},children:h.setup_instructions}),(0,r.jsx)(o.cGx,{sx:{my:2.5}}),(0,r.jsx)(o.o5u,{variant:"subtitle2",gutterBottom:!0,children:m("DISPLAY_STRINGS.MCP_CONNECTOR_DETAILS")}),(0,r.jsxs)(o.azJ,{sx:{display:"flex",flexDirection:"column",gap:1.5},children:[(0,r.jsx)(Oi,{label:m("DISPLAY_STRINGS.MCP_AUTH_METHOD_LABEL"),children:b}),(0,r.jsx)(Oi,{label:m("DISPLAY_STRINGS.MCP_CONNECTOR_TRANSPORT"),children:v}),Pi(Pi([],null!==(l=h.url_inputs)&&void 0!==l?l:[],!0),null!==(s=h.header_inputs)&&void 0!==s?s:[],!0).length>0&&(0,r.jsx)(Oi,{label:m("DISPLAY_STRINGS.MCP_CONNECTOR_REQUIRES_INPUTS"),children:Pi(Pi([],null!==(d=h.url_inputs)&&void 0!==d?d:[],!0),null!==(u=h.header_inputs)&&void 0!==u?u:[],!0).map((function(e){return e.label})).join(", ")}),g&&(0,r.jsx)(Oi,{label:m("DISPLAY_STRINGS.MCP_SERVER_URL_LABEL"),children:(0,r.jsxs)(o.azJ,{sx:{display:"flex",alignItems:"center",gap:.5,minWidth:0},children:[(0,r.jsx)(o.o5u,{variant:"body2",sx:{wordBreak:"break-all",color:"text.secondary"},children:g}),(0,r.jsx)(o.m_M,{title:m("DISPLAY_STRINGS.MCP_COPIED"),children:(0,r.jsx)(o.K0,{size:"small",onClick:function(){var e;
1g&&(null===(e=navigator.clipboard)||void 0===e||e.writeText(g),(0,x.Sx)("",m("DISPLAY_STRINGS.MCP_COPIED"),"success"))},"aria-label":m("DISPLAY_STRINGS.MCP_SERVER_URL_LABEL"),children:(0,r.jsx)(W.A,{sx:{fontSize:15}})})})]})}),h.provider_docs_url&&(0,r.jsxs)(o.N_E,{href:h.provider_docs_url,target:"_blank",rel:"noopener",variant:"body2",sx:{display:"inline-flex",alignItems:"center",gap:.5},children:[m("DISPLAY_STRINGS.MCP_CONNECTOR_DOCS"),(0,r.jsx)(Ci.A,{sx:{fontSize:15}})]})]}),(0,r.jsx)(o.cGx,{sx:{my:2.5}}),(0,r.jsxs)(o.o5u,{variant:"subtitle2",gutterBottom:!0,children:[m("DISPLAY_STRINGS.MCP_CONNECTOR_TOOLS"),h.tools.length>0&&" (".concat(h.tools.length,")")]}),0===h.tools.length?(0,r.jsx)(o.o5u,{variant:"body2",color:"text.secondary",children:m("DISPLAY_STRINGS.MCP_CONNECTOR_TOOLS_EMPTY")}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(o.o5u,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:1},children:m("DISPLAY_STRINGS.MCP_CONNECTOR_TOOLS_NOTE")}),(0,r.jsx)(o.azJ,{sx:{display:"flex",flexWrap:"wrap",gap:.75},children:h.tools.map((function(e){return(0,r.jsx)(o.m_M,{title:e.description||"",disableHoverListener:!e.description,disableFocusListener:!e.description,children:(0,r.jsx)(o.vu3,{label:e.name||e.source_name,size:"x-small",variant:"outlined",color:"default"})},e.source_name)}))})]})]}),(0,r.jsx)(o.azJ,{sx:{p:2.5,borderTop:1,borderColor:"divider"},children:(0,r.jsx)(o.$nd,{fullWidth:!0,variant:"contained",disabled:_||p,onClick:function(){return A(h)},children:p?m("DISPLAY_STRINGS.MCP_CONNECTOR_CONNECTED"):m(Ri(h),{name:h.name})})})]})})},Gi=function(){return(0,r.jsxs)(o.ZpM,{variant:"outlined",sx:{display:"flex",flexDirection:"column",justifyContent:"space-between",height:"100%",borderColor:"divider"},children:[(0,r.jsxs)(o.Wux,{sx:{flex:1},children:[(0,r.jsxs)(o.azJ,{sx:{display:"flex",alignItems:"center",gap:1.25,mb:1},children:[(0,r.jsx)(o.EAD,{variant:"rounded",width:26,height:26}),(0,r.jsx)(o.EAD,{variant:"text",width:"55%",sx:{fontSize:"1rem"}})]}),(0,r.jsx)(o.EAD,{variant:"text",width:"100%"}),(0,r.jsx)(o.EAD,{variant:"text",width:"80%"})]}),(0,r.jsx)(o.waF,{sx:{px:2,pb:2,pt:0},children:(0,r.jsx)(o.EAD,{variant:"rounded",width:96,height:30})})]})},Yi=function(e){var n,t,a,l,s,d,u=e.chatbot,h=e.connections,f=e.searchTerm,_=void 0===f?"":f,A=e.categoryFilter,I=void 0===A?"":A,m=(0,c.Bd)().t,T=Y(),v=T.data,g=T.isLoading,L=(s=u,d=(0,S.jE)(),(0,p.n)({mutationFn:function(e){return D(void 0,[e],void 0,(function(e){var n=e.key,t=e.inputs;return R(this,(function(e){switch(e.label){case 0:return[4,E.nv.post(y.n.MCP.OFFICIAL_CONNECTOR_CONNECT(n),P({chatbot:s},t&&Object.keys(t).length?{inputs:t}:{}))];case 1:return[2,e.sent().data]}}))}))},onSuccess:function(e){e.authorization_url||(d.invalidateQueries({queryKey:[N,s]}),d.invalidateQueries({queryKey:[C]}))}})),j=(0,i.useState)(null),O=j[0],w=j[1],G=(0,i.useState)(null),B=G[0],M=G[1],k=(0,i.useState)(null),U=k[0],z=k[1],W=(0,i.useState)(null),H=W[0],F=W[1],K=(0,i.useMemo)((function(){for(var e=new Set,n=new Set,t=0,r=null!=h?h:[];t<r.length;t++){var i=r[t];i.server_url&&e.add(i.server_url),i.official_connector&&n.add(i.official_connector)}return{connectedUrls:e,connectedKeys:n}}),[h]),J=K.connectedUrls,V=K.connectedKeys,q=function(e){return V.has(e.key)||!!e.server_url&&J.has(e.server_url)},Q=(0,i.useMemo)((function(){for(var e,n,t=_.trim().toLowerCase(),r=new Map,i=0,o=null!=v?v:[];i<o.length;i++){var a=o[i];if(!q(a)&&((!I||a.category===I)&&(!t||a.name.toLowerCase().includes(t)||(null!==(e=a.description)&&void 0!==e?e:"").toLowerCase().includes(t)))){var l=null!==(n=r.get(a.category))&&void 0!==n?n:[];l.push(a),r.set(a.category,l)}}return r}),[v,_,I,V,J]),$=Q.size>0,X=Boolean(_.trim()||I),Z=function(e,n,t){L.mutate({key:e.key,inputs:n},{onSuccess:function(e){e.authorization_url?window.location.assign(e.authorization_url):(M(null),(0,x.Sx)("",m("DISPLAY_STRINGS.MCP_CONNECTION_CREATED"),"success"))},onError:function(e){var n=function(e){var n,t=null===(n=null==e?void 0:e.response)||void 0===n?void 0:n.data;if(t&&"object"==typeof t){var r=t.inputs;if(Array.isArray(r)&&r.length)return String(r[0]);if("string"==typeof r)return r}return null}(e);
1n&&t?t(n):(0,x.Sx)("",m("DISPLAY_STRINGS.MCP_CONNECTOR_CONNECT_FAILED"),"error")}})},ee=function(e){var n;if(e.auth_method!==ir&&e.auth_method!==or&&!e.requires_user_oauth_app)return(null===(n=e.url_inputs)||void 0===n?void 0:n.length)?(z(null),void M(e)):void Z(e);w(e)},ne=L.isPending?null===(n=L.variables)||void 0===n?void 0:n.key:void 0;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(o.fPr,{size:12,sx:{mt:2},children:(0,r.jsx)(ui,{title:m("DISPLAY_STRINGS.MCP_MARKETPLACE_TITLE"),description:m("DISPLAY_STRINGS.MCP_MARKETPLACE_DESC")})}),g&&(I?[I]:vr.slice(0,3)).map((function(e){return(0,r.jsxs)(i.Fragment,{children:[(0,r.jsx)(o.fPr,{size:12,children:(0,r.jsx)(o.o5u,{variant:"overline",color:"text.secondary",sx:{display:"block",mt:1},children:gr(e)})}),Array.from({length:4}).map((function(n,t){return(0,r.jsx)(o.fPr,{size:{lg:3,sm:6,xs:12},children:(0,r.jsx)(Gi,{})},"skeleton-".concat(e,"-").concat(t))}))]},"skeleton-".concat(e))})),!g&&vr.map((function(e){var n=Q.get(e);return n&&0!==n.length?(0,r.jsxs)(i.Fragment,{children:[(0,r.jsx)(o.fPr,{size:12,children:(0,r.jsx)(o.o5u,{variant:"overline",color:"text.secondary",sx:{display:"block",mt:1},children:gr(e)})}),n.map((function(e){return(0,r.jsx)(o.fPr,{size:{lg:3,sm:6,xs:12},children:(0,r.jsx)(ji,{connector:e,onConnect:ee,onOpenDetails:F,isConnecting:ne===e.key,isConnected:q(e)})},e.key)}))]},e):null})),!g&&X&&!$&&(0,r.jsx)(o.fPr,{size:12,children:(0,r.jsx)(o.o5u,{variant:"body2",color:"text.secondary",sx:{py:3,textAlign:"center"},children:m("DISPLAY_STRINGS.MCP_NO_RESULTS")})}),(0,r.jsx)(wi,{connector:H,isConnected:!!H&&q(H),isConnecting:Boolean(H)&&ne===(null==H?void 0:H.key),onConnect:function(e){F(null),ee(e)},onClose:function(){return F(null)}}),(0,r.jsx)(bi,{open:Boolean(O),chatbot:u,prefill:O,onClose:function(){return w(null)}}),(0,r.jsxs)(o.lGe,{open:Boolean(B),onClose:function(){return M(null)},fullWidth:!0,maxWidth:"xs",children:[(0,r.jsx)(o.L33,{children:m("DISPLAY_STRINGS.MCP_CONNECT_TITLE",{name:null!==(t=null==B?void 0:B.name)&&void 0!==t?t:""})}),(0,r.jsx)(o.l1m,{enableReinitialize:!0,initialValues:Object.fromEntries((null!==(a=null==B?void 0:B.url_inputs)&&void 0!==a?a:[]).map((function(e){return[e.key,""]}))),validationSchema:_i(null!==(l=null==B?void 0:B.url_inputs)&&void 0!==l?l:[]),onSubmit:function(e){if(B){var n=Object.fromEntries(Object.entries(e).map((function(e){var n=e[0],t=e[1];return[n,String(t).trim()]})));Z(B,n,z)}},children:function(e){var n,t=B?function(e,n){var t,r=e.url_template,i=(null!==(t=e.url_inputs)&&void 0!==t?t:[]).filter((function(e){return"full_url"!==e.kind}));return r&&0!==i.length?i.reduce((function(e,t){var r,i=(null!==(r=n[t.key])&&void 0!==r?r:"").trim()||t.placeholder||t.key;return e.split("{".concat(t.key,"}")).join(i)}),r):null}(B,e.values):null;return(0,r.jsxs)(b.lV,{children:[(0,r.jsx)(o.Cff,{dividers:!0,children:(0,r.jsxs)(o.azJ,{sx:{display:"flex",flexDirection:"column",gap:2},children:[(null!==(n=null==B?void 0:B.url_inputs)&&void 0!==n?n:[]).map((function(n,t){var i,a,l=e.touched[n.key]?e.errors[n.key]:void 0,s=0===t?U:null;return(0,r.jsx)(o.A_L,{fullWidth:!0,autoFocus:0===t,name:n.key,label:n.label,placeholder:null!==(i=n.placeholder)&&void 0!==i?i:"",helperText:l||s||n.help_text||"",error:Boolean(l)||Boolean(s),value:null!==(a=e.values[n.key])&&void 0!==a?a:"",onChange:function(n){z(null),e.handleChange(n)},onPaste:function(t){var r=t.clipboardData.getData("text"),i=Li(r,n);i&&i!==r&&(t.preventDefault(),z(null),e.setFieldValue(n.key,i))},onBlur:function(t){var r,i=String(null!==(r=e.values[n.key])&&void 0!==r?r:""),o=Li(i,n);o!==i&&e.setFieldValue(n.key,o),e.handleBlur(t)}},n.key)})),t&&(0,r.jsxs)(o.azJ,{children:[(0,r.jsx)(o.o5u,{variant:"caption",color:"text.secondary",sx:{display:"block"},children:m("DISPLAY_STRINGS.MCP_SERVER_URL_LABEL")}),(0,r.jsx)(o.o5u,{variant:"caption",color:"text.secondary",sx:{fontFamily:"monospace",wordBreak:"break-all"},children:t})]})]})}),(0,r.jsx)(o.iin,{children:(0,r.jsxs)(o.azJ,{sx:{display:"flex",gap:1},children:[(0,r.jsx)(o.$nd,{onClick:function(){return M(null)},color:"inherit",children:m("DISPLAY_STRINGS.CANCEL")}),(0,r.jsx)(o.$nd,{type:"submit",variant:"contained",disabled:L.isPending,children:m("DISPLAY_STRINGS.MCP_CONNECTOR_ADD")})]})})]})}})]})]})},Bi=function(){return Bi=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var i in n=arguments[t])Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i]);return e},Bi.apply(this,arguments)},Mi=function(e,n,t){if(t||2===arguments.length)for(var r,i=0,o=n.length;i<o;i++)!r&&i in n||(r||(r=Array.prototype.slice.call(n,0,i)),r[i]=n[i]);return e.concat(r||Array.prototype.slice.call(n))},ki="mcp_oauth",Ui=36,zi="0.875rem",Wi=function(e){var n,t,a=e.chatbot,l=(0,c.Bd)().t,d=(0,vn.A)(),u=(0,S.jE)(),h=(0,Fn.ok)(),f=h[0],_=h[1],A=G(a),I=A.data,m=A.isLoading,T=Y().data,v=function(e){var n=(0,S.jE)(),t=[N,e];return(0,p.n)({mutationFn:function(e){return D(void 0,[e],void 0,(function(e){var n=e.id,t=e.is_enabled;return R(this,(function(e){switch(e.label){case 0:return[4,E.nv.patch(y.n.MCP.CONNECTION_TOGGLE(n),{is_enabled:t})];case 1:return[2,e.sent().data]}}))}))},onMutate:function(e){return D(void 0,[e],void 0,(function(e){var r,i=e.id,o=e.is_enabled;return R(this,(function(e){switch(e.label){case 0:return[4,n.cancelQueries({queryKey:t})];case 1:return e.sent(),r=n.getQueryData(t),n.setQueryData(t,(function(e){return null==e?void 0:e.map((function(e){return e.id===i?P(P({},e),{is_enabled:o}):e}))})),[2,{previous:r}]}}))}))},onError:function(e,r,i){(null==i?void 0:i.previous)&&n.setQueryData(t,i.previous)},onSettled:function(){n.invalidateQueries({queryKey:t})}})}(a),b=(0,i.useMemo)((function(){for(var e=new Map,n=0,t=null!=T?T:[];n<t.length;n++){var r=t[n];e.set(r.key,r.logo_key)}return e}),[T]),g=function(e,n){void 0===n&&(n=34);var t=e.official_connector?b.get(e.official_connector):void 0;return t&&Si.b[t]?(0,r.jsx)(ai.FQ,{name:t,size:n}):(0,r.jsx)(s.Wv,{style:{fontSize:n}})},L=(0,i.useState)(!1),j=L[0],O=L[1],w=(0,i.useState)(null),B=w[0],M=w[1],k=null!==(n=(null!=I?I:[]).find((function(e){return e.id===B})))&&void 0!==n?n:null,U=(0,i.useState)(""),z=U[0],W=U[1],H=(0,i.useState)(""),F=H[0],K=H[1],J=Mi([{value:"",label:l("DISPLAY_STRINGS.MCP_FILTER_ALL_TYPES")}],vr.map((function(e){return{value:e,label:gr(e)}})),!0),V=null===(t=J.find((function(e){return e.value===F})))||void 0===t?void 0:t.label,q=(0,i.useRef)(!1);(0,i.useEffect)((function(){var e=f.get(ki);if(e&&!q.current){q.current=!0,"success"===e?(0,x.Sx)("",l("DISPLAY_STRINGS.MCP_OAUTH_SUCCESS"),"success"):(0,x.Sx)("",l("DISPLAY_STRINGS.MCP_OAUTH_ERROR"),"error"),u.invali
1dateQueries({queryKey:[N,a]}),u.invalidateQueries({queryKey:[C]});var n=new URLSearchParams(f);n.delete(ki),_(n,{replace:!0})}}),[f,_,u,a,l]);var Q=function(e){return e.auth_method===ar&&e.status===er},$=(0,r.jsx)(Yi,{chatbot:a,connections:I,searchTerm:z,categoryFilter:F}),X=z.trim().toLowerCase(),Z=(null!=I?I:[]).filter((function(e){var n,t;return!X||(null===(n=e.alias)||void 0===n?void 0:n.toLowerCase().includes(X))||(null===(t=e.server_url)||void 0===t?void 0:t.toLowerCase().includes(X))})),ee=(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(o.fPr,{size:12,sx:{mt:2},children:(0,r.jsx)(ui,{title:l("DISPLAY_STRINGS.MCP_INTEGRATIONS"),description:l("DISPLAY_STRINGS.MCP_INTEGRATIONS_DESC")})}),Z.map((function(e){var n;return(0,r.jsx)(o.fPr,{size:{lg:3,sm:6,xs:12},children:(0,r.jsx)(ii.A,{icon:g(e),title:e.alias,description:e.description||e.server_url,status:(0,r.jsx)(xi,{status:e.status,detail:e.last_error,isEnabled:e.is_enabled}),onCardClick:function(){return M(e.id)},action:Q(e)?{label:l("DISPLAY_STRINGS.MCP_AUTHORIZE"),onClick:function(){return window.location.assign(y.n.MCP.CONNECTION_OAUTH_START(e.id))}}:void 0,toggle:{checked:e.is_enabled,onChange:function(n){return function(e,n){v.mutate({id:e.id,is_enabled:n},{onError:function(){return(0,x.Sx)("",l("DISPLAY_STRINGS.MCP_CONNECTION_UPDATE_FAILED"),"error")}})}(e,n)},disabled:v.isPending&&(null===(n=v.variables)||void 0===n?void 0:n.id)===e.id,ariaLabel:e.alias,label:l("DISPLAY_LABELS.ENABLED"),tooltip:l("DISPLAY_STRINGS.MCP_TOGGLE_HELP")}})},e.id)}))]}),ne=!m&&Z.length>0;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(o.fPr,{size:12,children:(0,r.jsxs)(o.azJ,{sx:{display:"flex",flexWrap:"wrap",gap:1.5,alignItems:"center",justifyContent:"space-between",mb:1},children:[(0,r.jsxs)(o.azJ,{sx:{display:"flex",flexWrap:"wrap",gap:1,alignItems:"center",flex:1,minWidth:0},children:[(0,r.jsx)(o.DOo,{value:z,onChange:W,placeholder:l("DISPLAY_STRINGS.MCP_FILTER_SEARCH_PLACEHOLDER"),sx:{"& .MuiInputBase-root":{height:Ui,minWidth:{xs:"100%",sm:240},fontSize:zi,backgroundColor:d.palette.background.paper}}}),(0,r.jsx)(o.azJ,{sx:{minWidth:{xs:"100%",sm:200}},children:(0,r.jsx)(o._8Q,{options:J,selectedValue:F,selectedLabel:V,onChange:K,placeholder:l("DISPLAY_STRINGS.MCP_FILTER_TYPE_LABEL"),styles:{control:function(e){return Bi(Bi({},e),{minHeight:Ui,height:Ui,fontSize:zi,borderColor:d.palette.divider,borderRadius:d.shape.borderRadius,boxShadow:"none"})},valueContainer:function(e){return Bi(Bi({},e),{height:Ui,padding:"0 8px"})},indicatorsContainer:function(e){return Bi(Bi({},e),{height:Ui})},indicatorSeparator:function(){return{display:"none"}},dropdownIndicator:function(e){return Bi(Bi({},e),{padding:6,color:d.palette.action.active})},placeholder:function(e){return Bi(Bi({},e),{fontSize:zi,color:d.palette.text.secondary})}}})})]}),(0,r.jsx)(o.$nd,{variant:"outlined",size:"small",startIcon:(0,r.jsx)(s.OM,{}),onClick:function(){return O(!0)},sx:{height:Ui,fontSize:zi,flexShrink:0},children:l("DISPLAY_STRINGS.ADD_MCP_CONNECTION")})]})}),ne?(0,r.jsxs)(r.Fragment,{children:[ee,$]}):$,(0,r.jsx)(bi,{open:j,chatbot:a,onClose:function(){return O(!1)}}),(0,r.jsx)(yi,{connection:k,icon:k?g(k,32):null,chatbot:a,onClose:function(){return M(null)}})]})};var Hi=function(){var e=(0,c.Bd)().t,n=Rt();return(0,r.jsxs)(o.azJ,{children:[(0,r.jsxs)(o.azJ,{sx:{mb:2.5},children:[(0,r.jsx)(o.EAD,{variant:"text",width:180,height:28}),(0,r.jsx)(o.EAD,{variant:"text",width:"60%",height:20,sx:{mt:.5}})]}),(0,r.jsx)(o.$nd,{sx:function(e){return{margin:"10px 0px 20px 0px",backgroundColor:e.palette.primary.main+"33",color:e.palette.primary.main}},type:"button",disabled:!0,children:e("DISPLAY_STRINGS.GET_EMBEDDABLE_CODE")}),(0,r.jsxs)(o.azJ,{children:[(0,r.jsxs)(o.o5u,{variant:"body2",sx:{marginBottom:1,display:"inline-flex",alignItems:"center"},color:"primary",className:"fw-bolder",children:[e("DISPLAY_STRINGS.CHATBOT_VISIBILITY"),(0,r.jsx)(s.R2,{sx:{marginLeft:"5px",fontSize:"16px",verticalAlign:"middle"}})]}),(0,r.jsx)(o.l6P,{disabled:!0,value:n[0].value,sx:{width:"100%","& .MuiSelect-select":{padding:"10px"},marginBottom:1},displayEmpty:!0,children:n.map((function(e){return(0,r.jsx)(o.Drp,{dense:!0,value:e.value,children:(0,r.jsx)(o.o5u,{variant:"body2",children:e.label})},e.value)}))}),(0,r.jsx)(o.$nd,{sx:{marginTop:1},variant:"contained",color:"primary",disabled:!0,children:e("DISPLAY_STRINGS.UPDATE")})]})]})};function Fi(){var e=(0,c.Bd)().t;return(0,r.jsxs)(o.fPr,{container:!0,spacing:2,justifyContent:"space-between",alignItems:"center",sx:{border:"1px solid",borderColor:"divider",borderRadius:1,p:2,mb:2},children:[(0,r.jsxs)(o.fPr,{container:!0,spacing:2,alignItems:"center",children:[(0,r.jsx)(o.fPr,{children:(0,r.jsx)(o.EAD,{variant:"circular",width:40,height:40})}),(0,r.jsxs)("div",{children:[(0,r.jsx)(o.EAD,{variant:"text",width:100}),(0,r.jsx)(o.EAD,{variant:"text",width:200})]})]}),(0,r.jsx)("div",{children:(0,r.jsx)(o.$nd,{disabled:!0,variant:"outlined",children:e("DISPLAY_STRINGS.CONNECT")})})]})}var Ki=function(){return(0,r.jsxs)(o.azJ,{children:[(0,r.jsx)(o.azJ,{sx:{mb:2.5},children:(0,r.jsx)(o.EAD,{variant:"text",width:180,height:28})}),(0,r.jsx)(Fi,{}),(0,r.jsx)(Fi,{}),(0,r.jsx)(Fi,{})]})},Ji={chat_widget:(0,r.jsx)((function(){var e,n,t,i=(0,c.Bd)().t;return(0,r.jsxs)(o.azJ,{sx:ci(ci({},di),{width:"78%",maxWidth:260,p:1.25,display:"flex",flexDirection:"column",gap:.75}),children:[(0,r.jsxs)(o.azJ,{sx:{display:"flex",alignItems:"center",gap:.75},children:[(0,r.jsx)(o.azJ,{sx:{width:11,height:11,borderRadius:.5,bgcolor:"primary.main",flexShrink:0}}),(0,r.jsx)(o.o5u,{variant:"caption",noWrap:!0,sx:{fontWeight:600,color:"text.primary"},children:i("DISPLAY_STRINGS.PREVIEW_CHAT_WIDGET_TITLE")})]}),(e="90%",n=7,t="grey.200",(0,r.jsx)(o.azJ,{sx:{width:e,height:n,borderRadius:1,bgcolor:t}})),(0,r.jsx)(o.azJ,{sx:{width:"70%",height:13,borderRadius:1,alignSelf:"center",bgcolor:function(e){return(0,o.X4A)(e.palette.primary.main,.55)}}})]})}),{}),help_page:(0,r.jsx)((function(){var e=(0,c.Bd)().t;return(0,r.jsxs)(o.azJ,{sx:ci(ci({},di),{width:"82%",maxWidth:280,overflow:"hidden"}),children:[(0,r.jsx)(o.azJ,{sx:{display:"flex",gap:.5,px:1,py:.75,borderBottom:"1px solid",borderColor:"divider"},children:["error.light","warning.light","success.light"].map((function(e){return(0,r.jsx)(o.azJ,{sx:{width:6,height:6,borderRadius:"50%",bgcolor:e}},e)}))}),(0,r.jsxs)(o.azJ,{sx:{p:1.25,display:"flex",flexDirection:"column",alignItems:"center",gap:.75},children:[(0,r.jsx)(o.o5u,{variant:"caption",noWrap:!0,sx:{fontWeight:600,color:"text.primary"},children:e("DISPLAY_STRINGS.PREVIEW_HELP_TITLE")}),(0,r.jsx)(o.azJ,{sx:{width:"85%",height:20,px:1,display:"flex",alignItems:"center",borderRadius:1,border:"1px solid",borderColor:"divider"},children:(0,r.jsx)(o.o5u,{variant:"caption",noWrap:!0,sx:{color:"text.secondary"},children:e("DISPLAY_STRINGS.PREVIEW_HELP_INPUT")})})]})]})}),{})},Vi=function(e){var n,t,a,l=e.chatbot,s=(0,c.Bd)().t,d=(0,Fn.Zp)(),u=(0,S.jE)(),h=(0,Fn.ok)(),f=h[0],_=h[1],A=(0,F.Jd)().userDetails,I=Boolean(null==A?void 0:A.isSubaccountUser),m=null!==(n=null==A?void 0:A.permissions)&&void 0!==n?n:[],T=(0,x.jr)().focus,v=f.get(Mt),b=null!=v?v:T?kt:null,g=O(l),E=g.data,y=g.isLoading,N=f.get(zt),j=Ht(N)?N:Wt.CHANNELS,C=(0,i.useCallback)((function(e,n){return _((function(n){var t=new URLSearchParams(n);return t.set(zt,String(e)),t}),n)}),[_]),P=G(l).data,D=(0,p.n)({mutationFn:function(e){return w(l,{visibility:e})}
1,onSuccess:function(){u.invalidateQueries({queryKey:[L,l]}),(0,x.Sx)("",s("DISPLAY_STRINGS.CHATBOT_SETTINGS_UPDATED_SUCCESS"),"success")},onError:function(){(0,x.Sx)("",s("DISPLAY_STRINGS.FAILED_TO_UPDATE_CHATBOT_SETTINGS"),"error")}});(0,i.useEffect)((function(){if(T&&b===kt&&!y){var e=document.getElementById(T);e&&(e.scrollIntoView({behavior:"smooth"}),e.classList.add("pulse-opacity-animation"),setTimeout((function(){e.classList.remove("pulse-opacity-animation")}),2e3))}}),[y,T,b]),(0,i.useEffect)((function(){b||Ht(N)||C(Wt.CHANNELS,{replace:!0})}),[b,N,C]);var R=function(){return d("".concat((0,Kn.Op)(l),"?").concat(zt,"=").concat(Wt.CHANNELS))},Y=function(e){return Boolean(I&&e.permission&&!m.includes(e.permission))},B=function(e){if(e.primaryAction.kind===Qt)return{label:s("DISPLAY_STRINGS.SAAS_COMING_SOON"),variant:"outlined",disabled:!0};if(function(e){return"SMS_NOTIFICATIONS"===e.featureFlag&&!Lt.s.SMS_NOTIFICATIONS}(e))return{label:s("DISPLAY_STRINGS.UPGRADE_TO_ENABLE"),variant:"outlined",onClick:function(){return d(Nt.b.BILLING)}};var n=e.primaryAction,t=Y(e);return{label:s(n.labelKey),variant:"outlined",disabled:t,disabledTooltip:t?s("DISPLAY_STRINGS.PERMISSION_DENIED"):void 0,onClick:function(){var e=n.to(l);n.external?window.location.assign(e):d(e)}}};if(b===kt)return(0,r.jsxs)(hi,{onBack:R,loadingSkeleton:(0,r.jsx)(Hi,{}),permission:me.Qp.CAN_EMBED_CHATBOT.value,children:[(0,r.jsx)(ui,{title:s("DISPLAY_STRINGS.EMBED_AI_AGENT"),description:s("DISPLAY_STRINGS.EMBED_AI_AGENT_DESCRIPTION")}),(0,r.jsx)(zr,{settings:E,disabled:y,chatbot:l}),(0,r.jsx)(o.cGx,{sx:{my:4}}),(0,r.jsxs)(o.azJ,{id:"chat-widget-settings",children:[(0,r.jsx)(ui,{title:s("DISPLAY_STRINGS.CHAT_WIDGET_SETTINGS")}),(0,r.jsx)(Kr,{settings:E,disabled:y,chatbot:l})]})]});if(b===Ut&&Lt.s.SMS_NOTIFICATIONS)return(0,r.jsxs)(hi,{onBack:R,loadingSkeleton:(0,r.jsx)(Ki,{}),permission:me.Qp.CAN_UPDATE_INTEGRATIONS.value,children:[(0,r.jsx)(ui,{title:s("DISPLAY_STRINGS.CHANNEL_PHONE")}),(0,r.jsx)(ri,{chatbot:l})]});var M=(null!==(t=null==E?void 0:E.visibility)&&void 0!==t?t:Ct)!==Pt,k=null!==(a=null==P?void 0:P.length)&&void 0!==a?a:0,U=k?"".concat(s("DISPLAY_STRINGS.INTEGRATION_TAB_CONNECTORS")," (").concat(k,")"):s("DISPLAY_STRINGS.INTEGRATION_TAB_CONNECTORS"),z=[{id:Wt.CHANNELS,label:s("DISPLAY_STRINGS.INTEGRATION_TAB_CHANNELS"),isActive:j===Wt.CHANNELS},{id:Wt.CONNECTORS,label:U,isActive:j===Wt.CONNECTORS}];return(0,r.jsx)(o.ZpM,{children:(0,r.jsxs)(o.Wux,{children:[(0,r.jsx)(o.azJ,{sx:{mb:2},children:(0,r.jsx)(o.qIE,{tabs:z,selectedTab:j,onTabChange:C})}),(0,r.jsxs)(o.fPr,{container:!0,spacing:2,children:[j===Wt.CHANNELS&&(0,r.jsxs)(r.Fragment,{children:[wr.map((function(e){var n;return(0,r.jsx)(o.fPr,{size:{md:6,xs:12},children:(0,r.jsx)(oi,{icon:(0,r.jsx)(si,{iconKey:e.iconKey,size:40}),preview:Ji[e.key],title:s(e.titleKey),description:s(e.descriptionKey),accent:null!==(n=e.accent)&&void 0!==n?n:"primary",action:B(e),toggle:e.hasToggle?{checked:M,onChange:function(e){return D.mutate(e?Ct:Pt)},disabled:y||D.isPending||Y(e),ariaLabel:s(e.titleKey)}:void 0})},e.key)})),Gr.map((function(e){return(0,r.jsx)(o.fPr,{size:{lg:3,sm:6,xs:12},children:(0,r.jsx)(ii.A,{icon:(0,r.jsx)(si,{iconKey:e.iconKey,size:32}),title:s(e.titleKey),description:s(e.descriptionKey),badgeLabel:e.badgeKey?s(e.badgeKey):void 0,action:B(e)})},e.key)}))]}),j===Wt.CONNECTORS&&(0,r.jsx)(Wi,{chatbot:l})]})]})})},qi=(0,o.I4L)(o.fPr)((function(){return{border:"1px solid #e0e0e0",padding:15,borderRadius:10,marginBottom:15}}));var Qi=function(e){var n=e.icon,t=e.title,i=e.descriptiom,a=e.link,l=(0,c.Bd)().t,s=(0,Fn.Zp)(),d=(0,Fn.zy)();return(0,r.jsxs)(qi,{container:!0,spacing:2,justifyContent:"space-between",alignItems:"center",children:[(0,r.jsxs)(o.fPr,{container:!0,spacing:2,alignItems:"center",children:[n,(0,r.jsxs)("div",{children:[(0,r.jsx)(o.o5u,{variant:"subtitle1",className:"fw-bold",children:t}),(0,r.jsx)(o.o5u,{variant:"body2",children:i})]})]}),(0,r.jsx)("div",{children:(0,r.jsx)(o.$nd,{onClick:function(){s("".concat(d.pathname.replace(/\/$/,""),"/").concat(a,"/"))},variant:"outlined",children:l("DISPLAY_STRINGS.CONNECT")})})]})};var $i=function(){var e=(0,c.Bd)().t;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Qi,{icon:(0,r.jsx)(s.Nb,{fontSize:"large"}),title:e("DISPLAY_STRINGS.FACEBOOK_MESSENGER"),descriptiom:e("DISPLAY_STRINGS.FACEBOOK_MESSENGER_DESCRIPTION"),link:"facebook"}),(0,r.jsx)(Qi,{icon:(0,r.jsx)(s.LO,{fontSize:"large"}),title:e("DISPLAY_STRINGS.WHATSAPP"),descriptiom:e("DISPLAY_STRINGS.WHATSAPP_DESCRIPTION"),link:"whatsapp"}),(0,r.jsx)(Qi,{icon:(0,r.jsx)(s.pd,{fontSize:"large"}),title:e("DISPLAY_STRINGS.INSTAGRAM"),descriptiom:e("DISPLAY_STRINGS.INSTAGRAM_DESCRIPTION"),link:"instagram"})]})},Xi=function(e){var n,t=e.chatbot,a=(0,c.Bd)().t,l=(0,F.Jd)().userDetails,s=Boolean(null==l?void 0:l.isSubaccountUser),d=null!==(n=null==l?void 0:l.permissions)&&void 0!==n?n:[],u=d.includes(me.Qp.CAN_EMBED_CHATBOT.value),h=d.includes(me.Qp.CAN_UPDATE_INTEGRATIONS.value),S=(0,x.jr)().focus,p=(0,i.useState)(S?"embed":"meta"),f=p[0],_=p[1];(0,i.useEffect)((function(){s&&("embed"===f&&u||("meta"===f||"sms"===f)&&h||(u?_("embed"):h&&_("meta")))}),[s,u,h,f]);var A=O(t),I=A.data,m=A.isLoading;return(0,i.useEffect)((function(){if(S&&"embed"===f&&!m){var e=document.getElementById(S);e&&(e.scrollIntoView({behavior:"smooth"}),e.classList.add("pulse-opacity-animation"),setTimeout((function(){e.classList.remove("pulse-opacity-animation")}),2e3))}}),[m,S,f]),(0,r.jsx)(o.fPr,{container:!0,spacing:2,justifyContent:"center",children:(0,r.jsx)(o.fPr,{container:!0,spacing:2,size:12,children:(0,r.jsx)(o.fPr,{size:12,children:(0,r.jsxs)(o.ZpM,{children:[(0,r.jsx)(o.azJ,{sx:{px:2,py:1.5,borderBottom:"1px solid",borderColor:"divider"},children:(0,r.jsxs)(o.IzF,{value:f,exclusive:!0,onChange:function(e,n){
1null!==n&&_(n)},"aria-label":a("DISPLAY_STRINGS.INTEGRATION_TABS"),size:"small",color:"primary",children:[(!s||u)&&(0,r.jsx)(o.POx,{component:o.ffE,permission:me.Qp.CAN_EMBED_CHATBOT.value,value:"embed","aria-label":a("DISPLAY_STRINGS.EMBED_CHATBOT"),children:a("DISPLAY_STRINGS.EMBED_AI_AGENT")}),(!s||h)&&(0,r.jsx)(o.POx,{component:o.ffE,permission:me.Qp.CAN_UPDATE_INTEGRATIONS.value,value:"meta","aria-label":a("DISPLAY_STRINGS.META_INTEGRATIONS"),children:a("DISPLAY_STRINGS.META_INTEGRATIONS")}),Lt.s.SMS_NOTIFICATIONS&&(!s||h)&&(0,r.jsx)(o.POx,{component:o.ffE,permission:me.Qp.CAN_UPDATE_INTEGRATIONS.value,value:"sms","aria-label":a("DISPLAY_STRINGS.SMS_TWILIO_TAB"),children:a("DISPLAY_STRINGS.SMS_TWILIO_TAB")})]})}),(0,r.jsxs)(o.Wux,{sx:{p:3,"&:last-child":{pb:3},position:"relative"},children:["embed"===f&&(0,r.jsxs)(o.L0s,{loadingSkeleton:(0,r.jsx)(Hi,{}),permission:me.Qp.CAN_EMBED_CHATBOT.value,children:[(0,r.jsx)(ui,{title:a("DISPLAY_STRINGS.EMBED_AI_AGENT"),description:a("DISPLAY_STRINGS.EMBED_AI_AGENT_DESCRIPTION")}),(0,r.jsx)(zr,{settings:I,disabled:m,chatbot:t}),(0,r.jsx)(o.cGx,{sx:{my:4}}),(0,r.jsxs)(o.azJ,{id:"chat-widget-settings",children:[(0,r.jsx)(ui,{title:a("DISPLAY_STRINGS.CHAT_WIDGET_SETTINGS")}),(0,r.jsx)(Kr,{settings:I,disabled:m,chatbot:t})]})]}),"meta"===f&&(0,r.jsxs)(o.L0s,{loadingSkeleton:(0,r.jsx)(Ki,{}),permission:me.Qp.CAN_UPDATE_INTEGRATIONS.value,children:[(0,r.jsx)(ui,{title:a("DISPLAY_STRINGS.META_INTEGRATIONS")}),(0,r.jsx)($i,{})]}),"sms"===f&&(0,r.jsxs)(o.L0s,{loadingSkeleton:(0,r.jsx)(Ki,{}),permission:me.Qp.CAN_UPDATE_INTEGRATIONS.value,children:[(0,r.jsx)(ui,{title:a("DISPLAY_STRINGS.SMS_TWILIO_TAB")}),(0,r.jsx)(ri,{chatbot:t})]})]})]})})})})},Zi=function(e){var n=e.chatbot,t=(0,F.Jd)(),i=t.userDetails;return t.isLoading?(0,r.jsx)(Hi,{}):function(e){var n;return!!e&&(!!(null===(n=e.permissions)||void 0===n?void 0:n.includes(me.Qp.CAN_USE_MCP_INTEGRATIONS.value))||!e.isSubaccountUser&&Boolean(e.canUseMcpIntegrations))}(i)?(0,r.jsx)(Vi,{chatbot:n}):(0,r.jsx)(Xi,{chatbot:n})},eo=t(54450),no=function(){return no=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var i in n=arguments[t])Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i]);return e},no.apply(this,arguments)},to=function(e,n,t){if(t||2===arguments.length)for(var r,i=0,o=n.length;i<o;i++)!r&&i in n||(r||(r=Array.prototype.slice.call(n,0,i)),r[i]=n[i]);return e.concat(r||Array.prototype.slice.call(n))},ro=function(e){var n=e.fields,t=e.onFieldsChange,a=(0,c.Bd)().t,l=(0,i.useState)(1),d=l[0],u=l[1],h=(0,i.useState)({dataValue:"",dataType:""}),S=h[0],p=h[1],x=(0,i.useState)(!1),f=x[0],_=x[1],A=(0,i.useState)(null),I=A[0],m=A[1],T=250,v=[{value:"string",label:a("DISPLAY_LABELS.DATA_TYPE_STRING")},{value:"number",label:a("DISPLAY_LABELS.DATA_TYPE_NUMBER")},{value:"boolean",label:a("DISPLAY_LABELS.DATA_TYPE_BOOLEAN")}],b=function(){I&&S.dataValue&&S.dataType&&(t(n.map((function(e){return e.id===I?no(no({},e),S):e}))),m(null),p({dataValue:"",dataType:""}))};return(0,r.jsx)(o.ZpM,{sx:{mt:4,borderRadius:2},children:(0,r.jsxs)(o.Wux,{children:[(0,r.jsx)(o.o5u,{variant:"h6",fontWeight:"bold",gutterBottom:!0,color:"primary",children:a("DISPLAY_LABELS.LEAD_COLLECTION_FIELDS")}),(0,r.jsx)(o.o5u,{color:"text.secondary",sx:{mb:3},children:a("DISPLAY_STRINGS.LEAD_COLLECTION_FIELDS_DESCRIPTION")}),(n.length>0||f)&&(0,r.jsx)(o.K3K,{component:o.tu9,variant:"outlined",children:(0,r.jsxs)(o.XIK,{size:"small",children:[(0,r.jsx)(o.ndF,{children:(0,r.jsxs)(o.Hjg,{children:[(0,r.jsx)(o.nA6,{sx:{fontWeight:700,padding:"8px 16px"},children:a("DISPLAY_LABELS.DATA_VALUE")}),(0,r.jsx)(o.nA6,{sx:{fontWeight:700,padding:"8px 16px"},children:a("DISPLAY_LABELS.DATA_TYPE")}),(0,r.jsx)(o.nA6,{align:"right",sx:{fontWeight:700,padding:"8px 16px"},children:a("DISPLAY_LABELS.ACTION")})]})}),(0,r.jsxs)(o.BFY,{children:[n.map((function(e){var i;return(0,r.jsx)(o.Hjg,{children:I===e.id?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(o.nA6,{width:T,sx:{padding:"8px 16px"},children:(0,r.jsx)(o.A_L,{size:"small",value:S.dataValue,onChange:function(e){return p(no(no({},S),{dataValue:e.target.value}))}})}),(0,r.jsx)(o.nA6,{width:T,sx:{padding:"8px 16px"},children:(0,r.jsx)(o.A_L,{select:!0,size:"small",value:S.dataType,onCh
1ange:function(e){return p(no(no({},S),{dataType:e.target.value}))},children:v.map((function(e){return(0,r.jsx)(o.Drp,{value:e.value,children:e.label},e.value)}))})}),(0,r.jsxs)(o.nA6,{align:"right",sx:{padding:"8px 16px"},children:[(0,r.jsx)(o.K0,{size:"small",color:"success",onClick:b,children:(0,r.jsx)(s.Jl,{})}),(0,r.jsx)(o.K0,{size:"small",color:"error",onClick:function(){return m(null)},children:(0,r.jsx)(s.bm,{})})]})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(o.nA6,{width:T,sx:{fontWeight:500,padding:"8px 16px"},children:e.dataValue}),(0,r.jsx)(o.nA6,{width:T,sx:{fontWeight:500,padding:"8px 16px"},children:(null===(i=v.find((function(n){return n.value===e.dataType})))||void 0===i?void 0:i.label)||e.dataType}),(0,r.jsxs)(o.nA6,{align:"right",sx:{padding:"8px 16px"},children:[(0,r.jsx)(o.K0,{size:"small",color:"primary",onClick:function(){return function(e){p({dataValue:e.dataValue,dataType:e.dataType}),m(e.id),_(!1)}(e)},sx:{mr:1},children:(0,r.jsx)(s.ff,{})}),(0,r.jsx)(o.K0,{size:"small",color:"error",onClick:function(){return r=e.id,void t(n.filter((function(e){return e.id!==r})));var r},children:(0,r.jsx)(s.ep,{})})]})]})},e.id)})),f&&(0,r.jsxs)(o.Hjg,{children:[(0,r.jsx)(o.nA6,{sx:{padding:"8px 16px"},children:(0,r.jsx)(o.A_L,{fullWidth:!0,size:"small",value:S.dataValue,onChange:function(e){return p(no(no({},S),{dataValue:e.target.value}))},placeholder:a("DISPLAY_STRINGS.ENTER_DATA_VALUE_PLACEHOLDER")})}),(0,r.jsx)(o.nA6,{sx:{padding:"8px 16px"},children:(0,r.jsx)(o.A_L,{select:!0,fullWidth:!0,size:"small",value:S.dataType,onChange:function(e){return p(no(no({},S),{dataType:e.target.value}))},placeholder:a("DISPLAY_STRINGS.SELECT_DATA_TYPE_PLACEHOLDER"),children:v.map((function(e){return(0,r.jsx)(o.Drp,{value:e.value,children:e.label},e.value)}))})}),(0,r.jsxs)(o.nA6,{align:"right",sx:{padding:"8px 16px"},children:[(0,r.jsx)(o.K0,{size:"small",color:"success",onClick:function(){S.dataValue&&S.dataType&&(t(to(to([],n,!0),[no(no({},S),{id:d,required:!1,dataValue:S.dataValue,dataType:S.dataType})],!1)),u(d+1),_(!1),p({dataValue:"",dataType:""}))},children:(0,r.jsx)(s.Jl,{})}),(0,r.jsx)(o.K0,{size:"small",color:"error",onClick:function(){_(!1),p({dataValue:"",dataType:""})},children:(0,r.jsx)(s.bm,{})})]})]})]})]})}),(0,r.jsx)(o.azJ,{sx:{display:"flex",justifyContent:"flex-end",mt:2},children:(0,r.jsx)(o.$nd,{variant:"contained",color:"primary",startIcon:(0,r.jsx)(s.OM,{}),onClick:function(){_(!0),p({dataValue:"",dataType:""})},disabled:f,children:a("DISPLAY_LABELS.ADD_DATA_VALUE")})})]})})},io=t(55655),oo=(0,i.forwardRef)((function(e,n){var t=e.emails,a=e.onEmailsChange,l=e.webhookUrl,d=void 0===l?"":l,u=e.onWebhookChange,h=void 0===u?function(){}:u,S=e.leads,p=e.chatbotID,f=e.setErrors,_=e.errors,A=e.notifyPartialLeads,I=e.onNotifyPartialLeadsChange,m=e.smsEnabled,T=void 0!==m&&m,v=e.onSmsToggleChange,b=void 0===v?function(){}:v,g=e.smsPhoneNumber,E=void 0===g?"":g,y=e.onSmsPhoneChange,L=void 0===y?function(){}:y,N=(0,c.Bd)().t,j=(0,i.useState)(""),C=j[0],P=j[1],D=(0,i.useState)(""),R=D[0],O=D[1],w=(0,i.useRef)(null),G=(0,i.useState)(!1),Y=G[0],B=G[1],M=(0,i.useState)(!1),k=(M[0],M[1],(0,F.fL)().themeMode),U=function(){if(!S||0===S.length)return(N("DISPLAY_STRINGS.DATA_COLLECTION_INSTRUCTIONS_PREFIX")+"\n"+N("DISPLAY_STRINGS.DATA_COLLECTION_INSTRUCTIONS_CONTENT",{leads:"{{{leads}}}"})).trim();var e,n=S.map((function(e){return"{{".concat(e,"}}")}));e=1===n.length?n[0]:2===n.length?n.join(" and "):n.slice(0,-1).join(", ")+", and "+n[n.length-1];var t=N("DISPLAY_STRINGS.DATA_COLLECTION_INSTRUCTIONS_CONTENT",{leads:"{{{leads}}}"}).replace("{{{leads}}}",e);return(N("DISPLAY_STRINGS.DATA_COLLECTION_INSTRUCTIONS_PREFIX")+"\n"+t).trim()}();(0,i.useImperativeHandle)(n,(function(){return{triggerEnterPress:function(){return new Promise((function(e){if(C.trim()){if(!z(C))return O(N("VALIDATION_ERRORS.EMAIL_INVALID")),void e({valid:!1});var n="".concat(t?t+", ":"").concat(C);a(n),P(""),O(""),e({valid:!0,updatedEmails:n})}else e({valid:!0})}))},hasEmailInput:function(){return!!C.trim()}}}));var z=function(e){return/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i.test(e)};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(o.ZpM,{sx:{borderRadius:2},variant:"outlined",children:(0,r.jsxs)(o.Wux,{children:[(0,r.jsxs)(o.o5u,{variant:"h6",fontWeight:"bold",gutterBottom:!0,color:"primary",children:[(0,r.jsx)(s.$0,{sx:{mr:1,verticalAlign:"middle"}}),N("DISPLAY_LABELS.GET_NOTIFIED_IMMEDIATELY")]}),(0,r.jsx)(o.o5u,{color:"text.secondary",sx:{mb:3},children:N("DISPLAY_STRINGS.GET_NOTIFIED_IMMEDIATELY_DESCRIPTION")}),(0,r.jsx)(o.o5u,{variant:"body2",sx:{mt:2,mb:2,color:"text.secondary"},children:N("DISPLAY_STRINGS.PROMPT_INSTRUCTIONS_DESCRIPTION")}),(0,r.jsx)(o.o5u,{fontWeight:"bold",color:"primary",children:N("DISPLAY_LABELS.PROMPT_INSTRUCTIONS")}),(0,r.jsxs)(o.azJ,{sx:{p:2,bgcolor:"dark"===k?"#222":"#f5f7fa",borderRadius:2,position:"relative",mb:3},children:[(0,r.jsx)(o.azJ,{component:"pre",sx:{fontFamily:"monospace",typography:"body1",background:"dark"===k?"#222":"#f5f7fa",borderRadius:2,whiteSpace:"pre-wrap",wordBreak:"break-word",color:"dark"===k?"#e0e0e0":"#000000"},children:U}),(0,r.jsx)(o.m_M,{title:N(Y?"DISPLAY_STRINGS.COPIED_TOOLTIP":"DISPLAY_STRINGS.COPY_TOOLTIP"),placement:"top",children:(0,r.jsx)(o.K0,{size:"small",sx:{position:"absolute",top:8,right:8},onClick:function(){navigator.clipboard.writeText(U),B(!0),setTimeout((function(){return B(!1)}),2e3)},children:(0,r.jsx)(W.A,{fontSize:"small"})})})]}),(0,r.jsx)(o.azJ,{sx:{mt:2}
1,children:(0,r.jsx)(o.ip9,{control:(0,r.jsx)(o.dOG,{checked:A,onChange:function(e){return I(e.target.checked)},color:"primary"}),label:(0,r.jsxs)(o.azJ,{sx:{display:"flex",alignItems:"center",gap:.5},children:[(0,r.jsx)(o.o5u,{variant:"body2",color:"text.secondary",children:N("DISPLAY_LABELS.NOTIFY_PARTIAL_LEADS")}),(0,r.jsx)(o.m_M,{title:N("DISPLAY_STRINGS.NOTIFY_PARTIAL_LEADS_TOOLTIP"),placement:"top",children:(0,r.jsx)(io.A,{sx:{fontSize:16,color:"text.secondary",cursor:"pointer"}})})]})})})]})}),(0,r.jsx)(o.ZpM,{sx:{mt:4,borderRadius:2},variant:"outlined",children:(0,r.jsxs)(o.Wux,{children:[(0,r.jsxs)(o.azJ,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:.5},children:[(0,r.jsxs)(o.o5u,{variant:"h6",fontWeight:"bold",gutterBottom:!0,color:"primary",children:[(0,r.jsx)(s.$0,{sx:{mr:1,verticalAlign:"middle"}}),N("DISPLAY_LABELS.EMAIL_NOTIFICATIONS")]}),(0,r.jsx)(o.rrq,{emailType:ee.D.LEAD_COLLECTION,chatbotId:p})]}),(0,r.jsx)(o.o5u,{color:"text.secondary",sx:{mb:3},children:N("DISPLAY_STRINGS.EMAIL_NOTIFICATIONS_DESCRIPTION")}),(0,r.jsx)(o.azJ,{sx:{mb:2},children:(0,x._6)(t).filter((function(e){return""!==e.trim()})).map((function(e,n){return(0,r.jsx)(o.vu3,{label:e,onDelete:function(){return n=e,r=(0,x._6)(t).filter((function(e){return e!==n})),void a(r.join(", "));var n,r},color:"primary",variant:"outlined",size:"small",sx:{mr:1,mb:1,backgroundColor:"transparent","&:hover":{backgroundColor:"rgba(33, 150, 243, 0.08)"}}},n)}))}),(0,r.jsx)(o.A_L,{inputRef:w,label:N("DISPLAY_STRINGS.EMAIL"),placeholder:N("DISPLAY_STRINGS.ENTER_EMAIL_PRESS_ENTER"),variant:"outlined",fullWidth:!0,size:"small",value:C,onChange:function(e){P(e.target.value),O("")},onKeyDown:function(e){if("Enter"===e.key&&""!==C.trim()){if(e.preventDefault(),!z(C))return void O(N("VALIDATION_ERRORS.EMAIL_INVALID"));a("".concat(t?t+", ":"").concat(C)),P(""),O("")}},error:!!R,helperText:R,slotProps:{inputLabel:{shrink:!0}}})]})}),(0,r.jsx)(o.ZpM,{sx:{mt:4,borderRadius:2},variant:"outlined",children:(0,r.jsxs)(o.Wux,{children:[(0,r.jsxs)(o.azJ,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:.5},children:[(0,r.jsxs)(o.o5u,{variant:"h6",fontWeight:"bold",color:"primary",children:[(0,r.jsx)(s.TM,{sx:{mr:1,verticalAlign:"middle"}}),N("DISPLAY_STRINGS.WEBHOOK_URL")]}),(0,r.jsx)(o.A8K,{webhook_type:ee.c.LEAD_COLLECTED_VIA_CHATBOT,chatbotId:p})]}),(0,r.jsx)(o.o5u,{color:"text.secondary",sx:{mb:3},children:N("DISPLAY_STRINGS.WEBHOOK_URL_DESCRIPTION")}),(0,r.jsx)(o.A_L,{label:N("DISPLAY_STRINGS.WEBHOOK_URL"),placeholder:N("DISPLAY_STRINGS.WEBHOOK_URL_PLACEHOLDER"),variant:"outlined",fullWidth:!0,size:"small",value:d,onChange:function(e){f({}),e.target.value.length>1e3&&f({webhookUrl:N("VALIDATION_ERRORS.WEBHOOK_URL_MAX_LENGTH")}),h(e.target.value)},error:!!_.webhookUrl,helperText:_.webhookUrl,slotProps:{inputLabel:{shrink:!0}}})]})}),Lt.s.SMS_NOTIFICATIONS&&(0,r.jsx)(o.ZpM,{sx:{mt:4,borderRadius:2},variant:"outlined",children:(0,r.jsxs)(o.Wux,{children:[(0,r.jsxs)(o.azJ,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:.5},children:[(0,r.jsxs)(o.o5u,{variant:"h6",fontWeight:"bold",color:"primary",children:[(0,r.jsx)(s.$0,{sx:{mr:1,verticalAlign:"middle"}}),"SMS Notifications"]}),(0,r.jsx)(o.dOG,{checked:T,onChange:function(e){return b(e.target.checked)},color:"primary"})]}),(0,r.jsx)(o.o5u,{color:"text.secondary",sx:{mb:3},children:"Receive an SMS on your phone number when a lead is collected."}),(0,r.jsx)(o.A_L,{label:"Phone Number",placeholder:"+1234567890",variant:"outlined",fullWidth:!0,size:"small",value:E,disabled:!T,onChange:function(e){return L(e.target.value)},slotProps:{inputLabel:{shrink:!0}}})]})})]})})),ao=oo,lo=function(){return lo=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var i in n=arguments[t])Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i]);return e},lo.apply(this,arguments)},so=function(e,n,t){if(t||2===arguments.length)for(var r,i=0,o=n.length;i<o;i++)!r&&i in n||(r||(r=Array.prototype.slice.call(n,0,i)),r[i]=n[i]);return e.concat(r||Array.prototype.slice.call(n))},co=function(e){var n=e.open,t=e.onClose,a=e.onAdd,l=e.editingField,d=(0,c.Bd)().t,u=(0,i.useState)({label:"",type:"text",required:!1,options:[]}),h=u[0],S=u[1],p=(0,i.useState)({label:"",value:""}
1),x=p[0],f=p[1],_=(0,i.useState)(!1),A=_[0],I=_[1],m=(0,i.useState)(null),T=m[0],v=m[1],b=[{value:"text",label:d("DISPLAY_LABELS.FIELD_TYPE_TEXT")},{value:"email",label:d("DISPLAY_LABELS.FIELD_TYPE_EMAIL")},{value:"number",label:d("DISPLAY_LABELS.FIELD_TYPE_NUMBER")},{value:"checkbox",label:d("DISPLAY_LABELS.FIELD_TYPE_CHECKBOX")},{value:"dropdown",label:d("DISPLAY_LABELS.FIELD_TYPE_DROPDOWN")}];i.useEffect((function(){S(l?{label:l.label,type:l.type,required:l.required,options:l.options||[]}:{label:"",type:"text",required:!1,options:[]}),I(!1),v(null),f({label:"",value:""})}),[l,n]);return(0,r.jsxs)(o.lGe,{open:n,onClose:t,maxWidth:"xs",fullWidth:!0,children:[(0,r.jsxs)(o.L33,{sx:{fontWeight:"bold",pb:1,m:0,p:2,display:"flex",justifyContent:"space-between",alignItems:"center",color:"primary.main"},children:[d(l?"DISPLAY_LABELS.EDIT_FORM_FIELD":"DISPLAY_LABELS.ADD_FORM_FIELD"),(0,r.jsx)(o.K0,{"aria-label":"close",onClick:t,sx:{position:"absolute",right:8,top:8,color:function(e){return e.palette.grey[500]}},children:(0,r.jsx)(s.bm,{})})]}),(0,r.jsxs)(o.Cff,{children:[(0,r.jsx)(o.A_L,{fullWidth:!0,label:d("DISPLAY_LABELS.FIELD_LABEL"),value:h.label,onChange:function(e){return S(lo(lo({},h),{label:e.target.value}))},margin:"normal",size:"small"}),(0,r.jsx)(o.A_L,{select:!0,fullWidth:!0,label:d("DISPLAY_LABELS.FIELD_TYPE"),value:h.type,onChange:function(e){S(lo(lo({},h),{type:e.target.value})),"dropdown"!==e.target.value&&(I(!1),v(null))},margin:"normal",size:"small",children:b.map((function(e){return(0,r.jsx)(o.Drp,{value:e.value,children:e.label},e.value)}))}),(0,r.jsx)(o.ip9,{control:(0,r.jsx)(o.Sc0,{checked:h.required,onChange:function(e){return S(lo(lo({},h),{required:e.target.checked}))}}),label:d("DISPLAY_LABELS.REQUIRED_FIELD"),sx:{mt:1}}),"dropdown"===h.type&&(0,r.jsxs)(o.azJ,{sx:{mt:3},children:[(0,r.jsx)(o.cGx,{sx:{mb:2}}),(0,r.jsxs)(o.azJ,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2},children:[(0,r.jsx)(o.o5u,{variant:"subtitle2",fontWeight:"bold",children:d("DISPLAY_LABELS.DROPDOWN_OPTIONS")}),(0,r.jsx)(o.$nd,{size:"small",startIcon:(0,r.jsx)(s.OM,{}),onClick:function(){I(!0),v(null),f({label:"",value:""})},variant:"outlined",disabled:A,children:d("DISPLAY_LABELS.ADD_ITEM")})]}),A&&(0,r.jsxs)(o.azJ,{sx:{p:2,mb:2,border:"1px solid",borderColor:"divider",borderRadius:1,backgroundColor:"action.hover"},children:[(0,r.jsx)(o.o5u,{variant:"caption",color:"text.secondary",sx:{mb:1,display:"block"},children:d(null!==T?"DISPLAY_STRINGS.EDITING_OPTION":"DISPLAY_STRINGS.ADDING_NEW_OPTION")}),(0,r.jsxs)(o.azJ,{sx:{display:"flex",gap:2,mb:2},children:[(0,r.jsx)(o.A_L,{fullWidth:!0,label:d("DISPLAY_LABELS.OPTION_LABEL"),value:x.label,onChange:function(e){return f(lo(lo({},x),{label:e.target.value}))},size:"small"}),(0,r.jsx)(o.A_L,{fullWidth:!0,label:d("DISPLAY_LABELS.VALUE"),value:x.value,onChange:function(e){return f(lo(lo({},x),{value:e.target.value}))},size:"small"})]}),(0,r.jsxs)(o.azJ,{sx:{display:"flex",gap:1,justifyContent:"flex-end"},children:[(0,r.jsx)(o.K0,{size:"small",onClick:function(){I(!1),v(null),f({label:"",value:""})},sx:{color:"error.main","&:hover":{backgroundColor:"error.light"}},children:(0,r.jsx)(s.bm,{})}),(0,r.jsx)(o.K0,{size:"small",onClick:function(){if(x.label&&x.value){if(null!==T){var e=so([],h.options||[],!0);e[T]=x,S(lo(lo({},h),{options:e})),v(null)}else S(lo(lo({},h),{options:so(so([],h.options||[],!0),[x],!1)}));f({label:"",value:""}),I(!1)}},disabled:!x.label||!x.value,sx:{color:"success.main","&:hover":{backgroundColor:"success.light"}},children:(0,r.jsx)(s.Jl,{})})]})]}),h.options&&h.options.length>0&&(0,r.jsx)(o.azJ,{sx:{mt:2},children:h.options.map((function(e,n){return(0,r.jsxs)(o.azJ,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",p:1.5,mb:1,border:"1px solid",borderColor:"divider",borderRadius:1,"&:hover":{backgroundColor:"action.hover"}},children:[(0,r.jsxs)(o.azJ,{sx:{flex:1},children:[(0,r.jsx)(o.o5u,{variant:"body2",fontWeight:"medium",children:e.label}),(0,r.jsxs)(o.o5u,{variant:"caption",color:"text.secondary",children:[d("DISPLAY_LABELS.VALUE"),": ",e.value]})]}),(0,r.jsxs)(o.azJ,{sx:{display:"flex",gap:.5},children:[(0,r.jsx)(o.K0,{size:"small",onClick:function(){return function(e){var n,t=null===(n=h.options)||void 0===n?void 0:n[e];t&&(f({label:t.label,value:t.value}),v(e),I(!0))}(n)},disabled:A,sx:{color:"primary.main","&:hover":{backgroundColor:"primary.light"},"&:disabled":{color:"action.disabled"}},children:(0,r.jsx)(s.ff,{fontSize:"small"})}),(0,r.jsx)(o.K0,{size:"small",onClick:function(){return function(e){var n,t=(null===(n=h.options)||void 0===n?void 0:n.filter((function(n,t){return t!==e})))||[];S(lo(lo({},h),{options:t}))}(n)},sx:{color:"error.main","&:hover":{backgroundColor:"error.light"}},children:(0,r.jsx)(s.ep,{fontSize:"small"})})]})]},n)}))}),h.options&&0===h.options.length&&!A&&(0,r.jsx)(o.o5u,{variant:"body2",color:"text.secondary",sx:{mt:1},children:d("DISPLAY_STRINGS.NO_OPTIONS_ADDED")})]})]}),(0,r.jsxs)(o.iin,{sx:{p:2,pt:1},children:[(0,r.jsx)(o.$nd,{onClick:t,variant:"outlined",color:"primary",children:d("DISPLAY_STRINGS.CANCEL")}),(0,r.jsx)(o.$nd,{onClick:function(){if(h.label){if("dropdown"===h.type&&(!h.options||0===h.options.length))return void alert(d("DISPLAY_STRINGS.DROPDOWN_NEEDS_OPTIONS"));a(lo(lo({},h),{id:(null==l?void 0:l.id)||Date.now().toString()})),t()}},variant:"contained",color:"primary",startIcon:l?void 0:(0,r.jsx)(s.OM,{}),children:d(l?"DISPLAY_LABELS.UPDATE_FIELD":"DISPLAY_LABELS.ADD_FIELD")})]})]})},uo=function(e,n,t){if(t||2===arguments.length)for(var r,i=0,o=n.length;i<o;i++)!r&&i in n||(r||(r=Array.prototype.slice.call(n,0,i)),r[i]=n[i]);return e.concat(r||Array.prototype.slice.call(n))},ho=function(e){var n=e.fields,t=e.onFieldsChange,a=e.chatbotId,l=(0,c.Bd)().t,d=(0,i.useState)(!1),u=d[0],h=d[1],S=(0,i.useState)(null),p=S[0],f=S[1];return(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(o.ZpM,{sx:{mt:4,borderRadius:2},children:(0,r.jsxs)(o.Wux,{children:[(0,r.jsx)(o.o5u,{variant:"h6",fontWeight:"bold",gutterBottom:!0,color:"primary",children:l("DISPLAY_LABELS.CREATE_LEAD_COLLECTION_FORM")}),(0,r.jsx)(o.o5u,{color:"text.secondary",sx:{mb:3},children:l("DISPLAY_STRINGS.LEAD_COLLECTION_FORM_DESCRIPTION")}),(0,r.jsxs)(o.azJ,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2},children:[n.length>0&&(0,r.jsx)(o.o5u,{variant:"subtitle1",fontWeight:600,color:"primary",children:l("DISPLAY_LABELS.FORM_FIELDS")}),(0,r.jsxs)(o.azJ,{sx:{display:"flex",ml:0===n.length?"auto":0,gap:1},children:[(0,r.jsx)(o.$nd,{variant:"outlined",size:"small",startIcon:(0,r.jsx)(s.vM,{}),sx:{borderColor:"divider",color:"primary",boxShadow:"0 1px 2px rgba(0,0,0,0.08)","&:hover":{backgroundColor:"grey.100",borderColor:"grey.400",boxShadow:"0 1px 2px rgba(0,0,0,0.12)"}},onClick:function(){var e=y.n.CHATBOT.WIDGET_CONFIGURATIONS_PAGE(a,De.S9.CUSTOM_CSS);(0,x.dg)(e)},disabled:0===n.length,children:l("DISPLAY_LABELS.CUSTOMIZE_STYLE")}),(0,r.jsx)(o.$nd,{startIcon:(0,r.jsx)(s.OM,{}),onClick:function(){return h(!0)},variant:"contained",color:"primary",size:"small",children:l("DISPLAY_LABELS.ADD_FIELD")})]})]}),n.map((function(e){return(0,r.jsxs)(o.tu9,{elevation:0,sx:{p:1.5,mb:2,border:"1px solid",borderColor:"divider",borderRadius:2,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[(0,r.jsxs)(o.azJ,{children:[(0,r.jsx)(o.o5u,{fontWeight:600,color:"primary",children:e.label}),(0,r.jsxs)(o.o5u,{variant:"body2",color:"text.secondary",sx:{mt:.5},children:[e.type.charAt(0).toUpperCase()+e.type.slice(1),e.required&&" • ".concat(l("DISPLAY_LABELS.REQUIRED"))]})]}),(0,r.jsxs)(o.azJ,{children:[(0,r.jsx)(o.$nd,{size:"small",onClick:function(){return function(e){f(e),h(!0)}(e)},sx:{mr:1},children:l("DISPLAY_STRINGS.EDIT")}),(0,r.jsx)(o.$nd,{size:"small",onClick:function(){return r=e.id,void t(n.filter((function(e){return e.id!==r})));var r},sx:{color:"error.main"},children:l("DISPLAY_STRINGS.DELETE")})]})]},e.id)})),(0,r.jsx)(co,{open:u,onClose:function(){h(!1),f(null)},onAdd:function(e){p?(t(n.map((function(n){return n.id===p.id?e:n}))),f(null)):t(uo(uo([],n,!0),[e],!1))},editingField:p})]})})})},So=t(79668),po=t(56581),xo=function(e,n,t,r){return new(t||(t=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function l(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){var n;e.done?i(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(a,l)}s((r=r.apply(e,n||[])).next())}))},fo=function(e,n){var t,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=l(0),a.throw=l(1),a.return=l(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function l(l){return function(s){return function(l){if(t)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(o=0)),o;)try{if(t=1,r&&(i=2&l[0]?r.return:l[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,l[1])).done)return i;switch(r=0,i&&(l=[2&l[0],i.value]),l[0]){case 0:case 1:i=l;break;case 4:return o.label++,{value:l[1],done:!1};case 5:o.label++,r=l[1],l=[0];continue;case 7:l=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==l[0]&&2!==l[0])){o=0;continue}if(3===l[0]&&(!i||l[1]>i[0]&&l[1]<i[3])){o.label=l[1];break}if(6===l[0]&&o.label<i[1]){o.label=i[1],i=l;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(l);break}i[2]&&o.ops.pop(),o.trys.pop();continue}l=n.call(e,o)}catch(e){l=[6,e],r=0}finally{t=i=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,s])}}},_o=function(e){var n=e.open,t=e.onClose,a=e.chatbotId,l=(0,c.Bd)().t,d=(0,i.useState)(!1),u=d[0],h=d[1],S=(0,So.cG)(a,u),p=S.data,f=S.isLoading,_=S.error,A=(null==p?void 0:p.rows)&&p.rows.length>0,I=(0,i.useMemo)((function(){return(null==p?void 0:p.columns)?p.columns:[]}),[null==p?void 0:p.columns]);return _?(0,r.jsx)(o.lGe,{open:n,onClose:t,children:(0,r.jsx)(o.Cff,{children:(0,r.jsx)(o.o5u,{color:"error",children:l("DISPLAY_STRINGS.ERROR_LOADING_LEADS_DATA")})})}):(0,r.jsxs)(o.lGe,{open:n,onClose:t,maxWidth:A?"xl":"sm",fullWidth:!0,PaperProps:{sx:{height:A?"80vh":"auto",maxHeight:A?"80vh":"400px"}},children:[(0,r.jsxs)(o.L33,{sx:{m:0,p:2,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[(0,r.jsx)(o.o5u,{variant:"h6",component:"div",fontWeight:"bold",color:"primary",children:l("DISPLAY_LABELS.COLLECTED_LEADS")}),(0,r.jsx)(o.K0,{"aria-label":"close",onClick:t,children:(0,r.jsx)(s.bm,{})})]}),(0,r.jsxs)(o.Cff,{sx:{p:2},children:[(0,r.jsx)(o.azJ,{display:"flex",justifyContent:"flex-end",mb:1,children:(0,r.jsxs)("div",{className:"form-check mt-1",children:[(0,r.jsx)("input",{type:"checkbox",id:"includeArchivedConversationsLeads-".concat(a),checked:u,onChange:function(e){return h(e.target.checked)},className:"form-check-input"}),(0,r.jsx)("label",{style:{fontSize:14},htmlFor:"includeArchivedConversationsLeads-".concat(a),className:"form-check-label",children:l("DISPLAY_STRINGS.SHOW_OLD_LEADS","Show Old Leads")})]})}),f?(0,r.jsx)(o.azJ,{sx:{display:"flex",justifyContent:"center",p:3},children:(0,r.jsx)(o.PaH,{})}):A?(0,r.jsx)(o.K3K,{component:o.tu9,sx:{maxHeight:"calc(85vh - 200px)",overflowX:"auto",overflowY:"auto"},children:(0,r.jsxs)(o.XIK,{stickyHeader:!0,children:[(0,r.jsx)(o.ndF,{children:(0,r.jsx)(o.Hjg,{children:I.map((function(e){return(0,r.jsx)(o.nA6,{sx:{fontWeight:600,whiteSpace:"nowrap",minWidth:"100px"},children:(0,x.wy)(e)},e)}))})}),(0,r.jsx)(o.BFY,{children:null==p?void 0:p.rows.map((function(e,n){return(0,r.jsx)(o.Hjg,{children:I.map((function(t){return"created_at"===t?(0,r.jsx)(o.nA6,{sx:{whiteSpace:"nowrap"},children:(0,x.y3)(e[t])},"".concat(n,"-").concat(t)):(0,r.jsx)(o.nA6,{sx:{whiteSpace:"nowrap"},children:(i=e[t],Array.isArray(i)?(0,r.jsx)(o.azJ,{children:i.map((function(e,n){return(0,r.jsx)(o.azJ,{sx:{mb:1,pb:1,borderBottom:n<i.length-1?"1px solid #e0e0e0":"none"},children:"object"==typeof e&&null!==e?Object.entries(e).map((function(e){var n=e[0],t=e[1];return(0,r.jsxs)(o.azJ,{children:[(0,r.jsxs)("strong",{children:[n,":"]})," ",(0,r.jsx)(po.yk,{value:t})]},n)})):(0,r.jsx)(po.yk,{value:e})},n)}))}):"object"==typeof i&&null!==i?(0,r.jsx)(o.azJ,{children:Object.entries(i).map((function(e){var n=e[0],t=e[1];return(0,r.jsxs)(o.azJ,{sx:{mb:.5},children:[(0,r.jsxs)("strong",{children:[n,":"]})," ",(0,r.jsx)(po.yk,{value:t})]},n)}))}):(0,r.jsx)(po.yk,{value:i}))},"".concat(n,"-").concat(t));var i}))},n)}))})]})}):(0,r.jsxs)(o.azJ,{sx:{display:"flex",justifyContent:"center",alignItems:"center",flexDirection:"column",gap:2,p:4,borderRadius:2,my:2},children:[(0,r.jsx)(o.o5u,{variant:"h6",fontWeight:"bold",children:l("DISPLAY_STRINGS.NO_LEADS_COLLECTED")}),(0,r.jsx)(o.o5u,{children:l("DISPLAY_STRINGS.LEADS_WILL_APPEAR_AFTER_COLLECTION")})]})]}),(0,r.jsxs)(o.iin,{sx:{display:"flex",justifyContent:"flex-end",gap:1},children:[(0,r.jsx)(o.$nd,{onClick:t,variant:"outlined",color:"primary",children:l("DISPLAY_LABELS.CLOSE_BUTTON")}),A&&(0,r.jsx)(o.$nd,{startIcon:(0,r.jsx)(s.nK,{}),onClick:function(){return xo(void 0,void 0,void 0,(function(){var e;return fo(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,(0,So.Sr)(a,u)];case 1:return n.sent(),[3,3];case 2:return e=n.sent(),console.error("Error exporting leads:",e),[3,3];case 3:return[2]}}
1))}))},variant:"contained",color:"primary",children:l("DISPLAY_STRINGS.EXPORT_AS_CSV")})]})]})},Ao=function(){return(0,r.jsxs)(o.azJ,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2},children:[(0,r.jsx)(o.EAD,{variant:"text",width:250,height:40}),(0,r.jsx)(o.EAD,{variant:"rectangular",width:180,height:40})]})},Io=function(){return(0,r.jsx)(o.ZpM,{sx:{mb:3},children:(0,r.jsxs)(o.Wux,{children:[(0,r.jsx)(o.EAD,{variant:"text",width:"40%",height:32,sx:{mb:2}}),[1,2,3].map((function(e){return(0,r.jsxs)(o.azJ,{sx:{display:"flex",mb:2,alignItems:"center"},children:[(0,r.jsx)(o.EAD,{variant:"rectangular",width:24,height:24,sx:{mr:2}}),(0,r.jsx)(o.EAD,{variant:"text",width:"60%",height:24})]},e)})),(0,r.jsx)(o.EAD,{variant:"rectangular",width:120,height:36})]})})},mo=function(){return(0,r.jsx)(o.ZpM,{sx:{mb:3},children:(0,r.jsxs)(o.Wux,{children:[(0,r.jsx)(o.EAD,{variant:"text",width:"60%",height:32,sx:{mb:3}}),(0,r.jsxs)(o.azJ,{sx:{mb:3},children:[(0,r.jsx)(o.EAD,{variant:"text",width:"30%",height:24,sx:{mb:1}}),(0,r.jsx)(o.EAD,{variant:"rectangular",height:56})]}),(0,r.jsxs)(o.azJ,{sx:{mb:2},children:[(0,r.jsx)(o.EAD,{variant:"text",width:"30%",height:24,sx:{mb:1}}),(0,r.jsx)(o.EAD,{variant:"rectangular",height:56})]})]})})},To=function(){var e=(0,vn.A)();return(0,r.jsx)(o.azJ,{sx:{mb:2},children:(0,r.jsx)(o.EAD,{variant:"rectangular",width:250,height:40,sx:{borderRadius:2,backgroundColor:"dark"===e.palette.mode?(0,je.X4)(e.palette.common.white,.08):"#e2e8f0"}})})},vo=function(){return vo=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var i in n=arguments[t])Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i]);return e},vo.apply(this,arguments)},bo=function(e,n,t,r){return new(t||(t=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function l(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){var n;e.done?i(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(a,l)}s((r=r.apply(e,n||[])).next())}))},go=function(e,n){var t,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=l(0),a.throw=l(1),a.return=l(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function l(l){return function(s){return function(l){if(t)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(o=0)),o;)try{if(t=1,r&&(i=2&l[0]?r.return:l[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,l[1])).done)return i;switch(r=0,i&&(l=[2&l[0],i.value]),l[0]){case 0:case 1:i=l;break;case 4:return o.label++,{value:l[1],done:!1};case 5:o.label++,r=l[1],l=[0];continue;case 7:l=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==l[0]&&2!==l[0])){o=0;continue}if(3===l[0]&&(!i||l[1]>i[0]&&l[1]<i[3])){o.label=l[1];break}if(6===l[0]&&o.label<i[1]){o.label=i[1],i=l;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(l);break}i[2]&&o.ops.pop(),o.trys.pop();continue}l=n.call(e,o)}catch(e){l=[6,e],r=0}finally{t=i=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,s])}}},Eo=function(e){var n=e.leads,t=e.onTest,a=e.webhookUrl,l=e.emails,d=e.onClose,u=e.smsEnabled,h=void 0!==u&&u,S=(0,c.Bd)().t,p=(0,i.useState)(n.reduce((function(e,n){var t;return vo(vo({},e),((t={})[n.field_name]="",t))}),{})),x=p[0],f=p[1],_=(0,i.useState)(!1),A=_[0],I=_[1],m=a.trim()||l.trim()||h,T=(0,r.jsx)(o.$nd,{variant:"contained",color:"primary",onClick:function(){return bo(void 0,void 0,void 0,(function(){return go(this,(function(e){switch(e.label){case 0:if(!m)return[2];I(!0),e.label=1;case 1:return e.trys.push([1,,3,4]),[4,t({test_data:x,webhook_url:a,notification_emails:l})];case 2:return e.sent(),[3,4];case 3:return I(!1),[7];case 4:return[2]}}
1))}))},disabled:A||!m,children:S(A?"DISPLAY_STRINGS.SENDING_TEST_NOTIFICATION":"DISPLAY_LABELS.SEND_TEST_NOTIFICATION")});return(0,r.jsx)(o.ZpM,{sx:{mt:4,borderRadius:2},variant:"outlined",children:(0,r.jsxs)(o.Wux,{children:[(0,r.jsxs)(o.o5u,{variant:"h6",fontWeight:"bold",gutterBottom:!0,color:"primary",children:[(0,r.jsx)(s.$0,{sx:{mr:1,verticalAlign:"middle"}}),S("DISPLAY_LABELS.TEST_LEAD_NOTIFICATION")]}),(0,r.jsx)(o.o5u,{color:"text.secondary",sx:{mb:3},children:S("DISPLAY_STRINGS.TEST_LEAD_NOTIFICATION_DESCRIPTION")}),0===n.length?(0,r.jsx)(o.o5u,{color:"text.secondary",sx:{my:4,textAlign:"center"},children:S("DISPLAY_STRINGS.NO_LEAD_FIELDS_FOR_CHAT_COLLECTION")}):n.map((function(e){return(0,r.jsxs)(o.xA9,{container:!0,spacing:2,sx:{mb:2},children:[(0,r.jsx)(o.xA9,{item:!0,xs:6,children:(0,r.jsxs)(o.xA9,{container:!0,children:[(0,r.jsx)(o.xA9,{item:!0,xs:6,children:(0,r.jsx)(o.o5u,{fontWeight:"medium",children:e.field_name})}),(0,r.jsx)(o.xA9,{item:!0,xs:6,children:(0,r.jsxs)(o.o5u,{color:"text.secondary",children:["(",e.field_type,")"]})})]})}),(0,r.jsx)(o.xA9,{item:!0,xs:6,children:(0,r.jsx)(o.A_L,{fullWidth:!0,size:"small",placeholder:S("DISPLAY_STRINGS.ENTER_TEST_VALUE_PLACEHOLDER",{fieldName:e.field_name}),value:x[e.field_name],onChange:function(n){return t=e.field_name,r=n.target.value,void f((function(e){var n;return vo(vo({},e),((n={})[t]=r,n))}));var t,r}})})]},e.field_name)})),(0,r.jsxs)(o.azJ,{sx:{display:"flex",justifyContent:"flex-end",mt:3,gap:2},children:[(0,r.jsx)(o.$nd,{variant:"outlined",onClick:d,children:S("DISPLAY_STRINGS.CANCEL")}),m?T:(0,r.jsx)(o.m_M,{title:S("DISPLAY_STRINGS.NOTIFICATION_METHOD_REQUIRED_TOOLTIP"),placement:"top",arrow:!0,children:(0,r.jsx)("span",{children:T})})]})]})})},yo=function(){return yo=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var i in n=arguments[t])Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i]);return e},yo.apply(this,arguments)},Lo=function(e,n,t,r){return new(t||(t=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function l(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){var n;e.done?i(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(a,l)}s((r=r.apply(e,n||[])).next())}))},No=function(e,n){var t,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=l(0),a.throw=l(1),a.return=l(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function l(l){return function(s){return function(l){if(t)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(o=0)),o;)try{if(t=1,r&&(i=2&l[0]?r.return:l[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,l[1])).done)return i;switch(r=0,i&&(l=[2&l[0],i.value]),l[0]){case 0:case 1:i=l;break;case 4:return o.label++,{value:l[1],done:!1};case 5:o.label++,r=l[1],l=[0];continue;case 7:l=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==l[0]&&2!==l[0])){o=0;continue}if(3===l[0]&&(!i||l[1]>i[0]&&l[1]<i[3])){o.label=l[1];break}if(6===l[0]&&o.label<i[1]){o.label=i[1],i=l;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(l);break}i[2]&&o.ops.pop(),o.trys.pop();continue}l=n.call(e,o)}catch(e){l=[6,e],r=0}finally{t=i=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,s])}}},jo=function(e,n,t){if(t||2===arguments.length)for(var r,i=0,o=n.length;i<o;i++)!r&&i in n||(r||(r=Array.prototype.slice.call(n,0,i)),r[i]=n[i]);return e.concat(r||Array.prototype.slice.call(n))},Co=function(e){return{id:e.id.toString(),label:e.dataValue,type:e.dataType,required:e.required,options:e.options}},Po=function(e){return{id:parseInt(e.id||Date.now().toString()),dataValue:e.label,dataType:e.type,required:e.required,collection_method:"collect_in_form",options:e.options}},Do=function(e){var n=e.chatbotID,t=e.embedded,a=void 0!==t&&t,l=e.hideHeader,d=void 0!==l&&l,u=(0,c.Bd)().t,h=(0,So.ul)(n),S=h.data,f=h.isLoading,_=(0,i.useState)({open:!1,message:"",severity:"success"}),A=_[0],I=_[1],m=function(){I(yo(yo({},A),{open:!1}))},T=(0,p.n)({mutationFn:function(e){return(0,So.uF)(n,e)},onSuccess:function(){(0,x.vd)(u("DISPLAY_STRINGS.SETTINGS_UPDATED_SUCCESS"))},onError:function(){(0,x.ag)(u("DISPLAY_STRINGS.FAILED_TO_SAVE_SETTINGS"))}}),v=(0,i.useState)(""),b=v[0],g=v[1],E=(0,i.useState)(""),y=E[0],L=E[1],N=(0,i.useState)("chat"),j=N[0],C=N[1],P=(0,i.useState)(!1),D=P[0],R=P[1],O=(0,i.useState)([]),w=O[0],G=O[1],Y=(0,i.useState)({}
1),B=Y[0],M=Y[1],k=(0,i.useState)(!1),U=k[0],z=(k[1],(0,i.useState)(!1)),W=z[0],H=z[1],F=(0,i.useState)([]),K=F[0],J=F[1],V=(0,i.useState)([]),q=V[0],Q=V[1],$=(0,i.useRef)(null),X=(0,i.useState)(!0),Z=X[0],ee=X[1],ne=(0,i.useState)(!1),te=ne[0],re=ne[1],ie=(0,i.useState)(!1),oe=ie[0],ae=ie[1],le=(0,i.useState)(""),se=le[0],ce=le[1];(0,i.useEffect)((function(){var e;if(S&&(g(S.notification_emails||""),L(S.webhook_url||""),ee(null===(e=S.notify_partial_leads)||void 0===e||e),ae(S.lead_sms_notification_enabled||!1),ce(S.lead_sms_phone_number||""),S.fields&&S.fields.length>0)){var n=S.fields.map((function(e){return{field_name:e.field_name,field_type:e.field_type,is_required:e.is_required,collection_method:e.collection_method,options:e.options}}));G(n)}}),[S]),(0,i.useEffect)((function(){W&&(ue(),H(!1))}),[W,w]),(0,i.useEffect)((function(){var e=w.filter((function(e){return"chat"===j?"collect_in_chat"===e.collection_method:"collect_in_form"===e.collection_method})).map((function(e,n){return{id:n+1,dataValue:(t=e).field_name,dataType:t.field_type,required:t.is_required,options:t.options};var t}));J(e),Q(e.map(Co))}),[w,j]);var de=function(e){var n=w.filter((function(e){return"chat"===j?"collect_in_chat"!==e.collection_method:"collect_in_form"!==e.collection_method})),t=e.map((function(e){return{field_name:e.dataValue,field_type:e.dataType,collection_method:"chat"===j?"collect_in_chat":"collect_in_form",is_required:"chat"!==j&&e.required,options:e.options||[]}}));G(jo(jo([],n,!0),t,!0)),H(!0)},ue=function(){return Lo(void 0,void 0,void 0,(function(){var e,t,r,i,o,a;return No(this,(function(l){switch(l.label){case 0:return l.trys.push([0,3,,4]),e=b,(null===(o=$.current)||void 0===o?void 0:o.hasEmailInput())?[4,null===(a=$.current)||void 0===a?void 0:a.triggerEnterPress()]:[3,2];case 1:if(!(t=l.sent()).valid)return[2];t.updatedEmails&&(e=t.updatedEmails),l.label=2;case 2:return r={fields:w.map((function(e){return{field_name:e.field_name,field_type:e.field_type,is_required:e.is_required,collection_method:e.collection_method,chatbot:n,options:e.options}})),webhook_url:y,notification_emails:e,notify_partial_leads:Z,lead_sms_notification_enabled:oe,lead_sms_phone_number:se},T.mutate(r),[3,4];case 3:return i=l.sent(),console.error("Error saving changes:",i),[3,4];case 4:return[2]}}
1))}))},he=w.filter((function(e){return"collect_in_chat"===e.collection_method}));return f&&!S?(0,r.jsxs)(o.mcf,{maxWidth:!a&&"xl",disableGutters:a,sx:{py:a?0:4},children:[(0,r.jsx)(Ao,{}),(0,r.jsx)(To,{}),(0,r.jsx)(Io,{}),(0,r.jsx)(mo,{})]}):(0,r.jsxs)(o.mcf,{maxWidth:!a&&"xl",disableGutters:a,sx:{py:a?0:4},children:[!d&&(0,r.jsx)(o.azJ,{sx:{display:"flex",mb:2.5},children:(0,r.jsxs)(o.azJ,{children:[(0,r.jsx)(o.o5u,{variant:"h6",fontWeight:"bold",color:"primary",children:u("DISPLAY_LABELS.LEAD_COLLECTION_SETTINGS")}),(0,r.jsx)(o.o5u,{color:"text.secondary",sx:{mt:.75},children:"Configure lead capture fields, notification channels, and lead collection behavior."})]})}),(0,r.jsxs)(o.azJ,{sx:{mb:2},display:"flex",alignItems:"center",justifyContent:"space-between",children:[(0,r.jsx)(o.azJ,{children:(0,r.jsxs)(o.IzF,{value:j,exclusive:!0,onChange:function(e,n){null!==n&&C(n)},"aria-label":"lead collection method",size:"small",color:"primary",children:[(0,r.jsx)(o.ffE,{value:"chat","aria-label":"collect in chat",children:u("DISPLAY_LABELS.COLLECT_IN_CHAT")}),(0,r.jsx)(o.ffE,{value:"form","aria-label":"collect in form",children:u("DISPLAY_LABELS.COLLECT_IN_FORM")})]})}),(0,r.jsx)(o.$nd,{variant:"contained",color:"primary",startIcon:(0,r.jsx)(s.bv,{}),onClick:function(){return R(!0)},sx:{whiteSpace:"nowrap",flexShrink:0},children:u("DISPLAY_LABELS.VIEW_COLLECTED_LEADS")})]}),"chat"===j?(0,r.jsx)(ro,{fields:K,onFieldsChange:de}):(0,r.jsx)(ho,{fields:q,onFieldsChange:function(e){var n=e.map(Po);de(n)},chatbotId:n}),(0,r.jsx)(o.ZpM,{sx:{mt:4},children:(0,r.jsxs)(o.Wux,{children:[(0,r.jsx)(ao,{ref:$,emails:b,onEmailsChange:g,webhookUrl:y,errors:B,setErrors:M,onWebhookChange:L,leads:w.filter((function(e){return"collect_in_chat"===e.collection_method})).map((function(e){return e.field_name})),chatbotID:n,notifyPartialLeads:Z,onNotifyPartialLeadsChange:ee,smsEnabled:oe,onSmsToggleChange:ae,smsPhoneNumber:se,onSmsPhoneChange:ce}),te&&(0,r.jsx)(Eo,{leads:he,onTest:function(e){return Lo(void 0,void 0,void 0,(function(){var t;return No(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,(0,So.kb)(n,e)];case 1:return r.sent(),I({open:!0,message:u("DISPLAY_STRINGS.TEST_NOTIFICATION_SENT_SUCCESS"),severity:"success"}),re(!1),[3,3];case 2:return t=r.sent(),console.error("Error sending test notification:",t),I({open:!0,message:u("DISPLAY_STRINGS.FAILED_TO_SEND_TEST_NOTIFICATION"),severity:"error"}),[3,3];case 3:return[2]}}
1))}))},webhookUrl:y,emails:b,onClose:function(){return re(!1)},smsEnabled:oe}),(0,r.jsxs)(o.azJ,{sx:{display:"flex",justifyContent:"flex-end",mt:3,gap:2},children:[(0,r.jsx)(o.$nd,{variant:"outlined",color:"primary",onClick:function(){return re(!te)},children:u("DISPLAY_LABELS.TEST_NOTIFICATION")}),(0,r.jsx)(o.$nd,{variant:"contained",color:"primary",disabled:U||!!Object.keys(B).length,onClick:ue,sx:{paddingX:2,paddingY:1},children:u(U?"DISPLAY_STRINGS.SAVING":"DISPLAY_LABELS.SAVE_CHANGES")})]})]})}),(0,r.jsx)(o.qb_,{open:A.open,autoHideDuration:3e3,onClose:m,anchorOrigin:{vertical:"top",horizontal:"right"},children:(0,r.jsx)(o.FcD,{onClose:m,severity:A.severity,sx:{backgroundColor:"#00AC69",width:"100%",color:"white"},children:A.message})}),(0,r.jsx)(_o,{open:D,onClose:function(){return R(!1)},chatbotId:n})]})},Ro=t(17071),Oo=(t(11443),t(98752)),wo=t(50212),Go=t(14017),Yo=function(){return Yo=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var i in n=arguments[t])Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i]);return e},Yo.apply(this,arguments)},Bo=function(e,n,t,r){return new(t||(t=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function l(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){var n;e.done?i(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(a,l)}s((r=r.apply(e,n||[])).next())}))},Mo=function(e,n){var t,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=l(0),a.throw=l(1),a.return=l(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function l(l){return function(s){return function(l){if(t)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(o=0)),o;)try{if(t=1,r&&(i=2&l[0]?r.return:l[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,l[1])).done)return i;switch(r=0,i&&(l=[2&l[0],i.value]),l[0]){case 0:case 1:i=l;break;case 4:return o.label++,{value:l[1],done:!1};case 5:o.label++,r=l[1],l=[0];continue;case 7:l=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==l[0]&&2!==l[0])){o=0;continue}if(3===l[0]&&(!i||l[1]>i[0]&&l[1]<i[3])){o.label=l[1];break}if(6===l[0]&&o.label<i[1]){o.label=i[1],i=l;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(l);break}i[2]&&o.ops.pop(),o.trys.pop();continue}l=n.call(e,o)}catch(e){l=[6,e],r=0}finally{t=i=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,s])}}},ko=function(e){var n=e.chatbotId,t=e.functionId,o=e.isUpdate,a=void 0!==o&&o,l=(0,i.useState)(!1),s=l[0],d=l[1],h=(0,i.useState)(null),S=h[0],p=h[1],f=(0,i.useState)({}),_=f[0],A=f[1],I=(0,c.Bd)().t,m=(0,Fn.Zp)(),T=function(e){for(var n=0,t=Object.values(e||{});n<t.length;n++){var r=t[n];if(Array.isArray(r)&&r.length>0)return String(r[0]);if("string"==typeof r&&r)return r;if(r&&"object"==typeof r){var i=T(r);if(i)return i}}return""};(0,i.useEffect)((function(){if(a&&t){Bo(void 0,void 0,void 0,(function(){var e,r,i,o;return Mo(this,(function(a){switch(a.label){case 0:d(!0),a.label=1;case 1:return a.trys.push([1,3,4,5]),[4,(0,Oo.Y1)(n,t)];case 2:return e=a.sent(),p(e),[3,5];case 3:return r=a.sent(),(0,x.ag)((null===(o=null===(i=r.response)||void 0===i?void 0:i.data)||void 0===o?void 0:o.detail)||I("DISPLAY_STRINGS.FUNCTION_UPDATE_FAILED")),[3,5];case 4:return d(!1),[7];case 5:return[2]}}
1))}))}}),[a,t,n]),(0,i.useEffect)((function(){var e=sessionStorage.getItem("functionTemplateToUse");e&&(p(JSON.parse(e)),sessionStorage.removeItem("functionTemplateToUse"))}),[]);return(0,r.jsx)(u.A,{sx:{pt:2,pb:4},children:s&&!S&&a?(0,r.jsx)(Go.Oq,{}):(0,r.jsx)(X.A,{initialData:S,functionId:t,onSubmit:function(e){return Bo(void 0,void 0,void 0,(function(){var r,i,o,l,s,c,u,h,S,p,f;return Mo(this,(function(_){switch(_.label){case 0:d(!0),A({}),_.label=1;case 1:_.trys.push([1,6,7,8]),r=Yo({},e),i={parameters:{type:"object",properties:{},required:[]}};try{(o="string"==typeof r.parameters?JSON.parse(r.parameters):r.parameters).parameters||(o={parameters:o}),l={parameters:{type:o.parameters.type||i.parameters.type,properties:o.parameters.properties||i.parameters.properties,required:o.parameters.required||i.parameters.required}},r.parameters=JSON.stringify(l)}catch(e){r.parameters=JSON.stringify(i)}return r.static_parameters&&"string"!=typeof r.static_parameters&&(r.static_parameters=JSON.stringify(r.static_parameters)),a&&t?[4,(0,Oo.d$)(n,t,r)]:[3,3];case 2:return c=_.sent(),[3,5];case 3:return[4,(0,Oo.OH)(n,r)];case 4:c=_.sent(),_.label=5;case 5:return(s=c).success?(s.message&&(0,x.vd)(s.message),u=s.redirectUrl||"/chatbot/".concat(n,"/tools/?tab=custom_tools"),(0,wo.DV)(u,m)||(window.location.href=u),[3,8]):(A(s.errors||{}),(p=s.message||T(s.errors||{}))&&(0,x.ag)(p),[2]);case 6:return h=_.sent(),S=(0,x.Cb)((null===(f=h.response)||void 0===f?void 0:f.data)||{}),A(S.errors||{}),(p=S.message||S.detail||T(S.errors||{})||I(a?"DISPLAY_STRINGS.FUNCTION_UPDATE_FAILED":"DISPLAY_STRINGS.FUNCTION_CREATE_FAILED"))&&(0,x.ag)(p),[3,8];case 7:return d(!1),[7];case 8:return[2]}}
1))}))},onCancel:function(){m("/chatbot/".concat(n,"/tools/?tab=custom_tools"))},isUpdate:a,isLoading:s,serverErrors:_})})},Uo=t(88458),zo=t(33559),Wo=t(7736),Ho=t(90451),Fo=t(30017),Ko=t(96509),Jo=t(76776),Vo=t(45924),qo=t(67076),Qo=t(64901),$o=t(69656),Xo=t(61105),Zo=t(77358),ea=t(23020),na=t(28454),ta=t(64998),ra=t(10857),ia=t(27610),oa=function(){return oa=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var i in n=arguments[t])Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i]);return e},oa.apply(this,arguments)},aa=function(e,n,t,r){return new(t||(t=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function l(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){var n;e.done?i(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(a,l)}s((r=r.apply(e,n||[])).next())}))},la=function(e,n){var t,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=l(0),a.throw=l(1),a.return=l(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function l(l){return function(s){return function(l){if(t)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(o=0)),o;)try{if(t=1,r&&(i=2&l[0]?r.return:l[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,l[1])).done)return i;switch(r=0,i&&(l=[2&l[0],i.value]),l[0]){case 0:case 1:i=l;break;case 4:return o.label++,{value:l[1],done:!1};case 5:o.label++,r=l[1],l=[0];continue;case 7:l=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==l[0]&&2!==l[0])){o=0;continue}if(3===l[0]&&(!i||l[1]>i[0]&&l[1]<i[3])){o.label=l[1];break}if(6===l[0]&&o.label<i[1]){o.label=i[1],i=l;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(l);break}i[2]&&o.ops.pop(),o.trys.pop();continue}l=n.call(e,o)}catch(e){l=[6,e],r=0}finally{t=i=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,s])}}},sa=(0,Tn.Ay)(Fo.A)((function(e){var n=e.theme;return{fontWeight:500,color:n.palette.text.secondary,padding:"16px",borderBottom:"1px solid ".concat(n.palette.divider)}})),ca=(0,Tn.Ay)(Fo.A)((function(e){var n=e.theme;return{fontWeight:600,backgroundColor:n.palette.action.hover,color:n.palette.text.secondary,padding:"10px",borderBottom:"1px solid ".concat(n.palette.divider)}})),da=(0,Tn.Ay)(Nn.A)((function(e){return{color:e.theme.palette.text.secondary,padding:"4px"}})),ua=(0,Tn.Ay)(Ko.A)((function(e){return{"&:hover":{backgroundColor:e.theme.palette.action.hover}}})),ha=(0,Tn.Ay)(gi.A)((function(e){e.theme;return{fontSize:"0.8rem",height:"24px",fontWeight:600}})),Sa=function(e){switch(null==e?void 0:e.toUpperCase()){case"GET":return"primary";case"POST":return"success";case"PUT":return"warning";case"DELETE":return"error";default:return"default"}},pa=function(e){var n=e.chatbotId,t=e.searchTerm,o=e.entriesPerPage,a=e.page,l=e.onEntriesPerPageChange,s=e.onPageChange,d=(0,Fn.Zp)(),h=(0,i.useState)([]),S=h[0],p=h[1],x=(0,i.useState)(!0),f=x[0],_=x[1],A=(0,i.useState)(!1),I=A[0],m=A[1],T=(0,i.useState)(null),v=T[0],b=T[1],g=(0,c.Bd)().t,E=(0,i.useState)({open:!1,message:"",severity:"success"}),y=E[0],L=E[1],N=function(){L(oa(oa({},y),{open:!1}))};(0,i.useEffect)((function(){aa(void 0,void 0,void 0,(function(){var e;return la(this,(function(t){switch(t.label){case 0:return t.trys.push([0,,2,3]),_(!0),[4,(0,Oo.Xd)(n)];case 1:return e=t.sent(),p(e.functions||[]),[3,3];case 2:return _(!1),[7];case 3:return[2]}}
1))}))}),[n]);var j=function(e,n){s(n)},C=S.filter((function(e){return e.alias.toLowerCase().includes(t.toLowerCase())})),P=C.slice((a-1)*o,a*o),D=Math.ceil(C.length/o)||1,R=0===C.length?0:(a-1)*o+1,O=Math.min(a*o,C.length),w=function(){m(!1),b(null)};return f?(0,r.jsx)(Go.O1,{}):0===S.length?(0,r.jsx)(u.A,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:200,textAlign:"center",bgcolor:"background.paper",borderRadius:1,p:3},children:(0,r.jsx)(te.A,{variant:"body1",color:"text.secondary",children:g("DISPLAY_STRINGS.NO_CUSTOM_FUNCTIONS_FOUND")})}):(0,r.jsxs)(u.A,{sx:{width:"100%"},children:[(0,r.jsx)(Jo.A,{component:ne.A,sx:{boxShadow:"none",maxHeight:440,overflow:"auto"},children:(0,r.jsxs)(Vo.A,{stickyHeader:!0,children:[(0,r.jsx)(qo.A,{children:(0,r.jsxs)(Ko.A,{children:[(0,r.jsx)(ca,{children:g("DISPLAY_STRINGS.FUNCTION_NAME")}),(0,r.jsx)(ca,{children:g("DISPLAY_LABELS.REQUEST_TYPE")}),(0,r.jsx)(ca,{children:g("DISPLAY_STRINGS.URL")}),(0,r.jsx)(ca,{align:"right",children:g("DISPLAY_STRINGS.ACTIONS")})]})}),(0,r.jsx)(Qo.A,{children:P.length>0?P.map((function(e){return(0,r.jsxs)(ua,{children:[(0,r.jsx)(sa,{children:e.alias}),(0,r.jsx)(sa,{children:(0,r.jsx)(ha,{label:e.method,size:"small",color:Sa(e.method),variant:"outlined"})}),(0,r.jsx)(sa,{children:e.value}),(0,r.jsx)(sa,{align:"right",children:(0,r.jsxs)(u.A,{sx:{display:"flex",justifyContent:"flex-end"},children:[(0,r.jsx)(da,{onClick:function(){return t=e.id,void d("/chatbot/".concat(n,"/tools/update/").concat(t,"/"));var t},children:(0,r.jsx)(ta.A,{color:"primary",fontSize:"small"})}),(0,r.jsx)(da,{onClick:function(){return n=e.id,b(n),void m(!0);var n},children:(0,r.jsx)(ra.A,{color:"error",fontSize:"small"})})]})})]},e.id)})):(0,r.jsx)(Ko.A,{children:(0,r.jsx)(sa,{colSpan:4,align:"center",children:g(t?"DISPLAY_STRINGS.NO_MATCHING_FUNCTIONS_FOUND":"DISPLAY_STRINGS.NO_FUNCTIONS_AVAILABLE")})})})]})}),(0,r.jsxs)(u.A,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mt:2},children:[(0,r.jsxs)(u.A,{sx:{display:"flex",alignItems:"center"},children:[(0,r.jsx)(te.A,{variant:"body2",sx:{mr:1},children:g("DISPLAY_STRINGS.SHOW")}),(0,r.jsx)(oe.A,{variant:"outlined",size:"small",sx:{minWidth:80},children:(0,r.jsx)(Oe.A,{value:o,onChange:function(e){l(e.target.value),s(ia._U)},displayEmpty:!0,children:ia.A3.map((function(e){return(0,r.jsx)(we.A,{value:e,children:e},e)}))})}),(0,r.jsx)(te.A,{variant:"body2",sx:{ml:1},children:g("DISPLAY_STRINGS.ENTRIES")})]}),(0,r.jsx)(te.A,{variant:"body2",children:g("DISPLAY_STRINGS.SHOWING_ENTRIES",{start:C.length>0?R:0,end:C.length>0?O:0,total:C.length})}),(0,r.jsxs)(u.A,{sx:{display:"flex",alignItems:"center"},children:[(0,r.jsx)(Nn.A,{disabled:1===a,onClick:function(){return j(0,a-1)},size:"small",children:(0,r.jsx)(na.A,{})}),(0,r.jsx)($o.A,{count:D,page:a,onChange:j,hideNextButton:!0,hidePrevButton:!0,size:"small"}),(0,r.jsx)(Nn.A,{disabled:a>=D||0===C.length,onClick:function(){return j(0,a+1)},size:"small",children:(0,r.jsx)(ea.A,{})})]})]}),(0,r.jsxs)(jn.A,{open:I,onClose:w,children:[(0,r.jsx)(Cn.A,{children:g("DISPLAY_STRINGS.DELETE_FUNCTION")}),(0,r.jsx)(Pn.A,{children:(0,r.jsx)(Xo.A,{children:g("DISPLAY_STRINGS.DELETE_FUNCTION_CONFIRMATION")})}),(0,r.jsxs)(Dn.A,{children:[(0,r.jsx)(Je.A,{onClick:w,children:g("DISPLAY_STRINGS.CANCEL")}),(0,r.jsx)(Je.A,{onClick:function(){return aa(void 0,void 0,void 0,(function(){var e;return la(this,(function(t){switch(t.label){case 0:if(null===v)return[2];t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,(0,Oo.Vy)(n,v)];case 2:return t.sent(),p(S.filter((function(e){return e.id!==v}))),L({open:!0,message:g("DISPLAY_STRINGS.FUNCTION_DELETED_SUCCESS"),severity:"success"}),[3,5];case 3:return e=t.sent(),L({open:!0,message:g("DISPLAY_STRINGS.FUNCTION_DELETE_FAILED",{error:e instanceof Error?e.message:g("DISPLAY_STRINGS.UNKNOWN_ERROR")}),severity:"error"}),[3,5];case 4:return m(!1),b(null),[7];case 5:return[2]}}
1))}))},color:"error",autoFocus:!0,children:g("DISPLAY_STRINGS.DELETE")})]})]}),(0,r.jsx)(Zo.A,{open:y.open,autoHideDuration:3e3,onClose:N,anchorOrigin:{vertical:"top",horizontal:"right"},children:(0,r.jsx)(Ln.A,{onClose:N,severity:y.severity,sx:{backgroundColor:"success"===y.severity?"#00AC69":void 0,width:"100%",color:"success"===y.severity?"white":void 0},children:y.message})})]})},xa=t(81971),fa=t(50616),_a=function(){return _a=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var i in n=arguments[t])Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i]);return e},_a.apply(this,arguments)},Aa=function(e,n,t,r){return new(t||(t=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function l(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){var n;e.done?i(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(a,l)}s((r=r.apply(e,n||[])).next())}))},Ia=function(e,n){var t,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=l(0),a.throw=l(1),a.return=l(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function l(l){return function(s){return function(l){if(t)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(o=0)),o;)try{if(t=1,r&&(i=2&l[0]?r.return:l[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,l[1])).done)return i;switch(r=0,i&&(l=[2&l[0],i.value]),l[0]){case 0:case 1:i=l;break;case 4:return o.label++,{value:l[1],done:!1};case 5:o.label++,r=l[1],l=[0];continue;case 7:l=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==l[0]&&2!==l[0])){o=0;continue}if(3===l[0]&&(!i||l[1]>i[0]&&l[1]<i[3])){o.label=l[1];break}if(6===l[0]&&o.label<i[1]){o.label=i[1],i=l;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(l);break}i[2]&&o.ops.pop(),o.trys.pop();continue}l=n.call(e,o)}catch(e){l=[6,e],r=0}finally{t=i=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,s])}}},ma=((0,Tn.Ay)(Ye.A)((function(e){var n=e.theme;return{"& .MuiOutlinedInput-root":{"& fieldset":{borderColor:n.palette.divider},"&:hover fieldset":{borderColor:n.palette.primary.light},"&.Mui-focused fieldset":{borderColor:n.palette.primary.main}},"& .MuiInputBase-inputMultiline":{fontFamily:"monospace",fontSize:"0.9rem",lineHeight:1.5}}})),function(e){var n=e.chatbotId,t=(0,i.useState)(""),o=t[0],a=t[1],l=(0,i.useState)(!0),s=l[0],d=l[1],h=(0,i.useState)(!1),S=h[0],p=h[1],x=(0,c.Bd)().t,f=(0,i.useState)({open:!1,message:"",severity:"success"}),_=f[0],A=f[1],I=function(){A(_a(_a({},_),{open:!1}))};(0,i.useEffect)((function(){Aa(void 0,void 0,void 0,(function(){var e;return Ia(this,(function(t){switch(t.label){case 0:return t.trys.push([0,,2,3]),d(!0),[4,(0,Oo.Xd)(n)];case 1:return e=t.sent(),a(e.base_system_message||""),[3,3];case 2:return d(!1),[7];case 3:return[2]}}
1))}))}),[n]);return s?(0,r.jsxs)(ne.A,{elevation:0,sx:function(e){return{p:3,mt:4,borderRadius:2,border:"1px solid ".concat(e.palette.divider)}},children:[(0,r.jsx)(xa.A,{variant:"text",width:"34%",height:32}),(0,r.jsx)(xa.A,{variant:"text",width:"72%",height:22}),(0,r.jsx)(xa.A,{variant:"text",width:"64%",height:22}),(0,r.jsx)(xa.A,{variant:"rounded",height:180,sx:{mt:2,mb:2}}),(0,r.jsx)(u.A,{sx:{display:"flex",justifyContent:"flex-end"},children:(0,r.jsx)(xa.A,{variant:"rounded",width:144,height:36})})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(ne.A,{elevation:0,sx:function(e){return{p:3,mt:4,borderRadius:2,border:"1px solid ".concat(e.palette.divider)}},children:[(0,r.jsx)(te.A,{variant:"h6",component:"h2",gutterBottom:!0,fontWeight:600,color:"primary",children:x("DISPLAY_LABELS.BASE_SYSTEM_PROMPT")}),(0,r.jsx)(te.A,{variant:"body2",color:"text.secondary",paragraph:!0,children:x("DISPLAY_STRINGS.BASE_SYSTEM_PROMPT_DESCRIPTION")}),(0,r.jsx)(Ye.A,{fullWidth:!0,multiline:!0,minRows:6,maxRows:10,value:o,onChange:function(e){return a(e.target.value)},placeholder:x("DISPLAY_STRINGS.BASE_SYSTEM_PROMPT_PLACEHOLDER"),variant:"outlined",sx:{mb:2}}),(0,r.jsx)(u.A,{sx:{display:"flex",justifyContent:"flex-end"},children:(0,r.jsx)(Je.A,{variant:"contained",color:"primary",onClick:function(){return Aa(void 0,void 0,void 0,(function(){return Ia(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,3,4]),p(!0),[4,(0,Oo.$O)(n,o)];case 1:return e.sent(),A({open:!0,message:x("DISPLAY_STRINGS.SYSTEM_MESSAGE_SAVED"),severity:"success"}),[3,4];case 2:return e.sent(),A({open:!0,message:x("DISPLAY_STRINGS.SYSTEM_MESSAGE_SAVE_FAILED"),severity:"error"}),[3,4];case 3:return p(!1),[7];case 4:return[2]}}
1))}))},disabled:S,children:S?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(fa.A,{size:16,sx:{mr:1,color:"inherit"}}),x("DISPLAY_STRINGS.SAVING")]}):x("DISPLAY_LABELS.SAVE_CHANGES")})})]}),(0,r.jsx)(Zo.A,{open:_.open,autoHideDuration:3e3,onClose:I,anchorOrigin:{vertical:"top",horizontal:"right"},children:(0,r.jsx)(Ln.A,{onClose:I,severity:_.severity,sx:{backgroundColor:"success"===_.severity?"#00AC69":void 0,width:"100%",color:"success"===_.severity?"white":void 0},children:_.message})})]})}),Ta=t(77214),va=function(e){try{return new Date(e).toLocaleString()}catch(n){return e}},ba=function(e){var n=e.open,t=e.onClose,o=e.history,a=(0,i.useState)(""),l=a[0],s=a[1],d=(0,i.useState)(1),h=d[0],S=d[1],p=(0,i.useState)(10),x=p[0],f=p[1],_=(0,c.Bd)().t;(0,i.useEffect)((function(){n&&(s(""),S(1))}),[n]);var A=function(e){if(!e)return"";try{var n=JSON.parse(e);return JSON.stringify(n,null,2)}catch(n){return String(e)}},I=function(e,n){S(n)},m=o.filter((function(e){var n=l.toLowerCase(),t=!(!e.name||"string"!=typeof e.name)&&e.name.toLowerCase().includes(n),r=!(!e.request_payload||"string"!=typeof e.request_payload)&&e.request_payload.toLowerCase().includes(n),i=!(!e.response_body||"string"!=typeof e.response_body)&&e.response_body.toLowerCase().includes(n),o=!(!e.error_message||"string"!=typeof e.error_message)&&e.error_message.toLowerCase().includes(n),a=!(!e.created_at||"string"!=typeof e.created_at)&&va(e.created_at).toLowerCase().includes(n),s=void 0!==e.response_status&&String(e.response_status).includes(l);return t||r||i||o||a||s})),T=m.slice((h-1)*x,h*x),v=Math.ceil(m.length/x)||1,b=0===m.length?0:(h-1)*x+1,g=Math.min(h*x,m.length);return(0,r.jsxs)(jn.A,{open:n,onClose:t,maxWidth:!1,PaperProps:{sx:{width:"90vw",height:"85vh",maxWidth:"1400px",maxHeight:"900px"}},"aria-labelledby":"function-history-modal-title",children:[(0,r.jsx)(Cn.A,{id:"function-history-modal-title",color:"primary",children:_("DISPLAY_STRINGS.CUSTOM_FUNCTIONS_HISTORY")}),(0,r.jsxs)(Pn.A,{sx:{display:"flex",flexDirection:"column",p:3},children:[(0,r.jsxs)(u.A,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2},children:[(0,r.jsxs)(u.A,{sx:{display:"flex",alignItems:"center"},children:[(0,r.jsx)(te.A,{variant:"body2",sx:{mr:1},children:_("DISPLAY_STRINGS.SHOW")}),(0,r.jsx)(oe.A,{variant:"outlined",size:"small",sx:{minWidth:80},children:(0,r.jsx)(Oe.A,{value:x,onChange:function(e){f(e.target.value),S(1)},displayEmpty:!0,children:[5,10,25,50,100].map((function(e){return(0,r.jsx)(we.A,{value:e,children:e},e)}))})}),(0,r.jsx)(te.A,{variant:"body2",sx:{ml:1},children:_("DISPLAY_STRINGS.ENTRIES")})]}),(0,r.jsxs)(u.A,{children:[(0,r.jsxs)(te.A,{variant:"body2",sx:{mb:.5},children:[_("DISPLAY_STRINGS.SEARCH"),":"]}),(0,r.jsx)(Ye.A,{size:"small",value:l,onChange:function(e){s(e.target.value),S(1)},InputProps:{startAdornment:(0,r.jsx)(Uo.A,{position:"start",children:(0,r.jsx)(Ta.A,{fontSize:"small"})})},placeholder:_("DISPLAY_STRINGS.SEARCH_FUNCTION_HISTORY_PLACEHOLDER"),sx:{width:280}})]})]}),(0,r.jsx)(Jo.A,{component:ne.A,sx:{flex:1,maxHeight:"calc(100% - 100px)"},children:(0,r.jsxs)(Vo.A,{stickyHeader:!0,children:[(0,r.jsx)(qo.A,{children:(0,r.jsxs)(Ko.A,{children:[(0,r.jsx)(Fo.A,{width:"10%",children:_("DISPLAY_LABELS.FUNCTION_ALIAS")}),(0,r.jsx)(Fo.A,{width:"25%",children:_("DISPLAY_LABELS.PARAMETERS")}),(0,r.jsx)(Fo.A,{width:"20%",children:_("DISPLAY_STRINGS.RESPONSE_DATA")}),(0,r.jsx)(Fo.A,{width:"15%",children:_("DISPLAY_STRINGS.RESPONSE_STATUS")}),(0,r.jsx)(Fo.A,{width:"15%",children:_("DISPLAY_STRINGS.ERROR_MESSAGE")}),(0,r.jsx)(Fo.A,{width:"15%",children:_("DISPLAY_STRINGS.SENT_AT")})]})}),(0,r.jsx)(Qo.A,{children:T.length>0?T.map((function(e){return(0,r.jsxs)(Ko.A,{children:[(0,r.jsx)(Fo.A,{children:e.name||_("DISPLAY_STRINGS.NOT_AVAILABLE")}),(0,r.jsx)(Fo.A,{children:(0,r.jsx)(u.A,{component:"pre",sx:{maxWidth:"100%",overflow:"auto",typography:"body2",whiteSpace:"pre-wrap",wordBreak:"break-word",m:0},children:A(e.request_payload)})}),(0,r.jsx)(Fo.A,{children:(0,r.jsx)(u.A,{component:"pre",sx:{maxWidth:"100%",overflow:"auto",typography:"body2",whiteSpace:"pre-wrap",wordBreak:"break-word",m:0},children:A(e.response_body)})}),(0,r.jsxs)(Fo.A,{children:[e.response_status||_("DISPLAY_STRINGS.NOT_AVAILABLE"),e.response_status&&(e.response_status>=200&&e.response_status<300?(0,r.jsx)(gi.A,{label:_("DISPLAY_STRINGS.SUCCESS"),color:"success",size:"small",sx:{ml:1}}):(0,r.jsx)(gi.A,{label:_("DISPLAY_STRINGS.FAILED"),color:"error",size:"small",sx:{ml:1}}))]}),(0,r.jsx)(Fo.A,{children:e.error_message||""}),(0,r.jsx)(Fo.A,{children:va(e.created_at)})]},e.id)})):(0,r.jsx)(Ko.A,{children:(0,r.jsx)(Fo.A,{colSpan:6,align:"center",children:(0,r.jsx)(te.A,{variant:"body2",color:"text.secondary",children:_(l?"DISPLAY_STRINGS.NO_MATCHING_HISTORY_FOUND":"DISPLAY_STRINGS.NO_HISTORY_AVAILABLE")})})})})]})}),(0,r.jsxs)(u.A,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mt:2},children:[(0,r.jsx)(te.A,{variant:"body2",children:_("DISPLAY_STRINGS.SHOWING_ENTRIES",{start:m.length>0?b:0,end:m.length>
10?g:0,total:m.length})}),(0,r.jsxs)(u.A,{sx:{display:"flex",alignItems:"center"},children:[(0,r.jsx)(Nn.A,{disabled:1===h,onClick:function(e){return I(0,h-1)},size:"small",children:(0,r.jsx)(na.A,{})}),(0,r.jsx)($o.A,{count:v,page:h,onChange:I,hideNextButton:!0,hidePrevButton:!0,size:"small"}),(0,r.jsx)(Nn.A,{disabled:h>=v||0===m.length,onClick:function(e){return I(0,h+1)},size:"small",children:(0,r.jsx)(ea.A,{})})]})]})]}),(0,r.jsx)(Dn.A,{children:(0,r.jsx)(Je.A,{onClick:t,color:"primary",variant:"contained",children:_("DISPLAY_LABELS.CLOSE_BUTTON")})})]})},ga=t(1912),Ea=t(11075),ya=function(e){var n=e.chatbotId,t=(0,c.Bd)().t,a=(0,Fn.Zp)(),l=(0,i.useState)(""),s=l[0],d=l[1],u=(0,i.useState)(!1),h=u[0],S=u[1],p=(0,Oo.f6)(s),f=p.data,_=p.isLoading;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(o.DOo,{onSearch:d,value:s,fullWidth:!0}),(0,r.jsxs)(o.azJ,{sx:{marginTop:2},children:[_&&(0,r.jsx)(o.nD3,{children:(0,r.jsxs)(o.Xo_,{sx:{"& .MuiAccordionSummary-content":{display:"block"}},expandIcon:(0,r.jsx)(On.A,{}),children:[(0,r.jsx)(o.EAD,{variant:"text",width:100}),(0,r.jsx)(o.EAD,{variant:"text",width:200})]})}),!_&&(null==f?void 0:f.map((function(e){return(0,r.jsx)(o.azJ,{sx:{marginBottom:2},children:(0,r.jsxs)(o.nD3,{sx:{"& .MuiAccordionSummary-content":{display:"block"}},variant:"outlined",expanded:h===e.alias,onChange:function(n,t){S(!!t&&e.alias)},children:[(0,r.jsxs)(o.Xo_,{expandIcon:(0,r.jsx)(On.A,{}),children:[(0,r.jsx)(o.o5u,{variant:"h5",fontWeight:"bold",children:(0,x.wy)(e.alias)}),(0,r.jsx)(o.o5u,{variant:"body2",color:"text.secondary",children:e.description||"No description"})]}),(0,r.jsxs)(o.ZiS,{children:[(0,r.jsxs)(o.azJ,{sx:{display:"flex",alignItems:"center"},children:[(0,r.jsx)(ha,{label:e.method,size:"small",color:Sa(e.method),variant:"outlined"}),(0,r.jsx)(o.o5u,{sx:{marginLeft:1},variant:"body2",children:e.value})]}),(0,r.jsxs)(o.ZpM,{variant:"outlined",sx:{marginTop:1,padding:2},children:[(0,r.jsxs)(o.azJ,{display:"flex",alignItems:"center",justifyContent:"space-between",children:[(0,r.jsx)(o.o5u,{variant:"body2",fontWeight:"bold",marginBottom:1,children:t("DISPLAY_STRINGS.PROMPT_INSTRUCTIONS")}),(0,r.jsx)(o.K0,{size:"small",onClick:function(){(0,x.eM)(e.prompt_instructions)},children:(0,r.jsx)(ga.A,{fontSize:"small"})})]}),(0,r.jsx)(o.o5u,{variant:"body2",children:e.prompt_instructions}),(0,r.jsx)(o.o5u,{variant:"body2",color:"error",marginTop:1,children:t("DISPLAY_STRINGS.PROMPT_INSTRUCTIONS_REMEMBER")})]}),(0,r.jsxs)(o.azJ,{sx:{display:"flex",justifyContent:"flex-end",alignItems:"center",marginTop:2,gap:1},children:[e.tutorial_url&&(0,r.jsx)(o.$nd,{variant:"outlined",color:"primary",startIcon:(0,r.jsx)(Ea.A,{}),onClick:function(){return n=e.tutorial_url,void window.open(n,"_blank","noopener,noreferrer");var n},children:t("DISPLAY_STRINGS.VIEW_TUTORIAL")}),(0,r.jsxs)(o.$nd,{variant:"contained",color:"primary",onClick:function(){sessionStorage.setItem("functionTemplateToUse",JSON.stringify(e)),a("/chatbot/".concat(n,"/tools/create/"))},children:[t("DISPLAY_STRINGS.USE_TEMPLATE"),(0,r.jsx)(Ee.A,{fontSize:"small",sx:{marginLeft:1}})]})]})]})]},e.alias)},e.alias)}))),!_&&0===(null==f?void 0:f.length)&&(0,r.jsx)(o.o5u,{color:"text.secondary",variant:"body2",align:"center",children:t("DISPLAY_STRINGS.NO_FUNCTION_TEMPLATES_FOUND")})]})]})},La=t(95426),Na=t(18529),ja=t(449),Ca=t(3625);var Pa=function(e){var n=e.chatbotId,t=e.values,l=e.errors,s=e.touched,d=e.setFieldValue,h=e.isLoading,S=e.legacySchedulingEnabled,p=void 0!==S&&S,f=(0,F.fL)().theme,_=(0,c.Bd)().t,A=(0,i.useState)(!0),I=A[0],m=A[1],T="eu"===(null==t?void 0:t.calComRegion),v=T?"calComEuApiKey":"calComApiKey",g=T?(null==t?void 0:t.calComEuApiKey)||"":(null==t?void 0:t.calComApiKey)||"",E=(0,Oo.xL)(n,g,(null==t?void 0:t.calComRegion)||"global"),y=E.data,L=E.isLoading,N=E.isError,j=E.error,C=L||h;(0,i.useEffect)((function(){N&&(0,x.ag)(_("DISPLAY_LABELS.CALCOM_API_KEY_ERROR"))}),[N,j,_]);var P=(null==y?void 0:y.eventTypes.map((function(e){return{label:"".concat(e.title," (").concat(e.length," mins)"),value:e.id.toString(),id:e.id,title:e.title,length:e.length}})))||[];return(0,r.jsxs)(bn.A,{variant:"outlined",expanded:!!t.useCalComScheduler,onChange:function(){},sx:{mb:2,backgroundColor:f.palette.background.paper},children:[(0,r.jsxs)(gn.A,{sx:{"& .MuiAccordionSummary-content":{display:"block"}},children:[(0,r.jsxs)(u.A,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"},children:[(0,r.jsxs)(u.A,{sx:{display:"flex",alignItems:"center",gap:1},children:[(0,r.jsx)(te.A,{variant:"subtitle1",color:"primary.main",fontWeight:600,children:_("DISPLAY_LABELS.CALCOM_SCHEDULER_TIT
1LE")}),(0,r.jsx)(gi.A,{label:_("DISPLAY_LABELS.CALCOM_PREMIUM"),size:"small",color:"primary",sx:{height:20,fontSize:"0.7rem"}})]}),(0,r.jsx)(Ke.A,{title:p?_("DISPLAY_LABELS.CALCOM_DISABLE_LEGACY_FIRST"):"",arrow:!0,placement:"top",children:(0,r.jsx)("span",{children:(0,r.jsx)(ie.A,{checked:t.useCalComScheduler,disabled:p,onChange:function(e,n){p||(d("useCalComScheduler",n),d("useCalendlyScheduler",!1))}})})})]}),(0,r.jsx)(te.A,{variant:"body1",children:_("DISPLAY_LABELS.CALCOM_SCHEDULER_DESCRIPTION")})]}),(0,r.jsxs)(En.A,{children:[(0,r.jsx)(o.JU7,{helptext:_("DISPLAY_LABELS.CALCOM_REGION_HELPTEXT"),name:_("DISPLAY_LABELS.CALCOM_REGION_LABEL")}),(0,r.jsxs)(Oe.A,{value:t.calComRegion||"global",onChange:function(e){d("calComRegion",e.target.value),d("calComEventTypeId","")},size:"small",fullWidth:!0,disabled:C,children:[(0,r.jsx)(we.A,{value:"global",children:(0,r.jsx)(te.A,{variant:"body1",children:_("DISPLAY_LABELS.CALCOM_REGION_GLOBAL")})}),(0,r.jsx)(we.A,{value:"eu",children:(0,r.jsx)(te.A,{variant:"body1",children:_("DISPLAY_LABELS.CALCOM_REGION_EU")})})]}),(0,r.jsx)(o.JU7,{helptext:_("DISPLAY_LABELS.CALCOM_API_KEY_HELPTEXT"),name:_("DISPLAY_LABELS.CALCOM_API_KEY_LABEL"),style:{marginTop:15}}),(0,r.jsx)(b.D0,{name:v,component:Ye.A,disabled:C,value:g,onChange:function(e){d(v,e.target.value),d("calComEventTypeId","")},size:"small",fullWidth:!0,placeholder:_("DISPLAY_LABELS.CALCOM_API_KEY_PLACEHOLDER"),type:I?"password":"text",InputProps:{endAdornment:(0,r.jsx)(Nn.A,{size:"small",onClick:function(){return m(!I)},children:I?(0,r.jsx)(Ca.A,{fontSize:"small"}):(0,r.jsx)(ja.A,{fontSize:"small"})})}}),(0,a.P)(s.calComApiKey,l.calComApiKey),(0,r.jsx)(o.JU7,{helptext:_("DISPLAY_LABELS.CALCOM_EVENT_TYPE_HELPTEXT"),name:_("DISPLAY_LABELS.CALCOM_EVENT_TYPE_LABEL"),style:{marginTop:15}}),(0,r.jsxs)(Oe.A,{value:t.calComEventTypeId||"",onChange:function(e){d("calComEventTypeId",e.target.value)},size:"small",fullWidth:!0,displayEmpty:!0,disabled:C||!t.calComApiKey,renderValue:function(e){var n=P.find((function(n){return n.value===e}));return(0,r.jsx)(te.A,{variant:"body1",children:(null==n?void 0:n.label)||_("DISPLAY_LABELS.CALCOM_EVENT_TYPE_SELECT")})},children:[P.map((function(e){return(0,r.jsx)(we.A,{value:e.value,children:(0,r.jsx)(te.A,{variant:"body1",children:e.label})},e.value)})),0===P.length&&(0,r.jsx)(we.A,{value:"",children:(0,r.jsx)(te.A,{variant:"body1",children:t.calComApiKey?_("DISPLAY_LABELS.CALCOM_EVENT_TYPE_LOADING"):_("DISPLAY_LABELS.CALCOM_EVENT_TYPE_API_KEY_REQUIRED")}
1)})]}),(0,a.P)(s.calComEventTypeId,l.calComEventTypeId),(0,r.jsx)(o.JU7,{helptext:_("DISPLAY_LABELS.CALCOM_TIMEZONE_HELPTEXT"),name:_("DISPLAY_LABELS.TIMEZONE"),style:{marginTop:15}}),(0,r.jsx)(o._8Q,{options:(0,Na.qt)(),selectedValue:t.timezone||"UTC",isDisabled:C,onChange:function(e){return d("timezone",e)},isSearchable:!0,isClearable:!1,selectedLabel:Na.Bu[t.timezone]||"UTC"}),(0,r.jsxs)(u.A,{sx:{my:3},children:[(0,r.jsx)(o.JU7,{name:_("DISPLAY_LABELS.CALCOM_PROMPT_LABEL"),helptext:_("DISPLAY_LABELS.CALCOM_PROMPT_HELPTEXT"),style:{marginTop:15}}),(0,r.jsxs)(u.A,{sx:{position:"relative"},children:[(0,r.jsx)(X.H,{fullWidth:!0,multiline:!0,rows:16,value:ia.lM,size:"small",InputProps:{readOnly:!0}}),(0,r.jsx)(u.A,{sx:{position:"absolute",right:20,top:10},children:(0,r.jsx)(Nn.A,{size:"small",onClick:function(){(0,x.eM)(ia.lM,_("DISPLAY_LABELS.SCHEDULER_SAMPLE_PROMPT_COPIED"))},children:(0,r.jsx)(W.A,{fontSize:"small"})})})]}),(0,r.jsxs)(te.A,{variant:"caption",sx:{display:"block",mt:1},children:[(0,r.jsxs)("strong",{style:{color:"red"},children:[_("DISPLAY_LABELS.CALCOM_PROMPT_IMPORTANT")," "]}),(0,r.jsx)("strong",{children:_("DISPLAY_LABELS.CALCOM_PROMPT_COPY_INSTRUCTION")}),_("DISPLAY_LABELS.CALCOM_PROMPT_TWEAK_INSTRUCTION")]})]})]})]})};var Da=function(e){var n=e.chatbotId,t=e.values,i=e.setFieldValue,o=e.errors,a=e.touched,l=e.isLoading,s=e.legacySchedulingEnabled,c=void 0!==s&&s;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(u.A,{sx:{my:2},children:(0,r.jsx)(La.A,{chatbotId:n,values:t,errors:o,touched:a,setFieldValue:i,isLoading:l,legacySchedulingEnabled:c})}),(0,r.jsx)(u.A,{sx:{my:2},children:(0,r.jsx)(Pa,{chatbotId:n,values:t,errors:o,touched:a,setFieldValue:i,isLoading:l,legacySchedulingEnabled:c})})]})},Ra=t(47496),Oa=function(){return Oa=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var i in n=arguments[t])Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i]);return e},Oa.apply(this,arguments)},wa=function(e,n,t,r){return new(t||(t=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function l(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){var n;e.done?i(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(a,l)}s((r=r.apply(e,n||[])).next())}))},Ga=function(e,n){var t,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=l(0),a.throw=l(1),a.return=l(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function l(l){return function(s){return function(l){if(t)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(o=0)),o;)try{if(t=1,r&&(i=2&l[0]?r.return:l[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,l[1])).done)return i;switch(r=0,i&&(l=[2&l[0],i.value]),l[0]){case 0:case 1:i=l;break;case 4:return o.label++,{value:l[1],done:!1};case 5:o.label++,r=l[1],l=[0];continue;case 7:l=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==l[0]&&2!==l[0])){o=0;continue}if(3===l[0]&&(!i||l[1]>i[0]&&l[1]<i[3])){o.label=l[1];break}if(6===l[0]&&o.label<i[1]){o.label=i[1],i=l;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(l);break}i[2]&&o.ops.pop(),o.trys.pop();continue}l=n.call(e,o)}catch(e){l=[6,e],r=0}finally{t=i=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,s])}}},Ya=function(e,n,t){if(t||2===arguments.length)for(var r,i=0,o=n.length;i<o;i++)!r&&i in n||(r||(r=Array.prototype.slice.call(n,0,i)),r[i]=n[i]);return e.concat(r||Array.prototype.slice.call(n))},Ba=0,Ma=1,ka="leads",Ua="scheduling",za="custom_tools",Wa=function(e){var n,t,a,l,s=e.chatbotId,d=(0,Fn.Zp)(),h=(0,F.Jd)().userDetails,S=(0,i.useState)(!1),p=S[0],f=S[1],_=(0,i.useState)(""),A=_[0],I=_[1],m=(0,i.useState)(ia.yQ),T=m[0],v=m[1],g=(0,i.useState)(ia._U),E=g[0],y=g[1],L=(0,i.useState)([]),N=L[0],j=L[1],C=(0,i.useState)(Ba),P=C[0],D=C[1],R=new URLSearchParams(location.search).get("tab"),O=(0,c.Bd)().t,w=Boolean(null==h?void 0:h.isAgencyUser),G=Boolean(null==h?void 0:h.isSubaccountUser),Y=!!(null==h?void 0:h.isNonWhiteLabel)&&"nwl_free"===(null==h?void 0:h.subscribedPlanKey),B=null!==(t=null==h?void 0:h.permissions)&&void 0!==t?t:[],M=B.includes(me.Qp.CAN_UPDATE_LEADS.value),k=B.includes(me.Qp.CAN_UPDATE_SCHEDULING.value),U=B.includes(me.Qp.CAN_UPDATE_FUNCTIONS.value),z=(0,i.useState)(R||ka),W=z[0],H=z[1];(0,i.useEffect)((function(){G&&(W===ka&&M||W===Ua&&k||W===za&&U||(M?H(ka):k?H(Ua):U&&H(za)))}),[G,M,k,U]);var K=(0,Oo.aK)(s,W===Ua),J=K.data,V=K.isLoading,q=K.refetch,Q=(0,Oo.Ly)(s,W===Ua),$=Q.data,X=Q.isLoading,Z=Q.refetch,ee=(0,Oo.L_)(s),re=(0,Oo.SU)(s),ie=[{id:ka,label:O("DISPLAY_STRINGS.LEADS"),isActive:W===ka,hidden:G&&!M},{id:Ua,label:O("DISPLAY_STRINGS.SCHEDULING"),isActive:W===Ua,hidden:G&&!k},{id:za,label:O("DISPLAY_STRINGS.CUSTOM_TOOLS"),isActive:W===za,hidden:G&&!U}].filter((function(e){return!e.hidden})),oe=((n={}
1)[ka]={title:O("DISPLAY_LABELS.LEAD_COLLECTION_SETTINGS"),description:"Configure lead capture fields, notification channels, and lead collection behavior."},n[Ua]={title:O("DISPLAY_STRINGS.SCHEDULING"),description:"Configure scheduling and automation actions used by your Chat Agent."},n[za]={title:O("DISPLAY_LABELS.AI_AGENT_CUSTOM_FUNCTIONS"),description:O("DISPLAY_STRINGS.CUSTOM_FUNCTIONS_DESCRIPTION")},n),ae=Ya([{id:Ba,label:O("DISPLAY_STRINGS.MY_FUNCTIONS"),isActive:P===Ba}],w?[{id:Ma,label:O("DISPLAY_STRINGS.FUNCTION_TEMPLATES"),isActive:P===Ma}]:[],!0),le={useCalendlyScheduler:!1,calendlyApiKey:"",calendlyEventTypeUri:"",calendlyLocationKind:"",useCalComScheduler:!1,calComApiKey:"",calComEuApiKey:"",calComEventTypeId:"",calComRegion:"global",timezone:"UTC",legacySchedulingEnabled:!1},se=Oa(Oa(Oa(Oa({},le),J||{}),$||{}),{legacySchedulingEnabled:null!==(l=null!==(a=null==J?void 0:J.legacySchedulingEnabled)&&void 0!==a?a:null==$?void 0:$.legacySchedulingEnabled)&&void 0!==l?l:le.legacySchedulingEnabled});(0,i.useEffect)((function(){if(U&&W===za&&p){wa(void 0,void 0,void 0,(function(){var e,n;return Ga(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,(0,Oo.Xd)(s)];case 1:return e=t.sent(),j(e.custom_functions_history||[]),[3,3];case 2:return n=t.sent(),console.error("Error loading function history:",n),[3,3];case 3:return[2]}}
1))}))}}),[W,U,s,p]);return(0,r.jsxs)(u.A,{sx:{pb:4},children:[(0,r.jsxs)(ne.A,{elevation:0,sx:{p:3,borderRadius:2},children:[(0,r.jsx)(o.qIE,{tabs:ie,selectedTab:W,onTabChange:function(e){H(e),(0,x.y4)("tab",e)},sx:{mb:3}}),(0,r.jsxs)("div",{style:{position:"relative"},children:[Y&&(0,r.jsx)("div",{style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",backgroundColor:"rgba(0, 0, 0, 0.7)",zIndex:1e3,display:"flex",alignItems:"center",justifyContent:"center",cursor:"not-allowed",pointerEvents:"all",padding:"24px"},children:(0,r.jsx)(o.QIW,{})}),W!==ka&&(0,r.jsx)(u.A,{sx:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:2,mb:3,px:{xs:1,md:2}},children:(0,r.jsxs)(u.A,{sx:{flex:1,minWidth:0},children:[(0,r.jsx)(te.A,{variant:"h6",fontWeight:"bold",color:"primary",children:oe[W].title}),(0,r.jsx)(te.A,{color:"text.secondary",sx:{mt:.75},children:oe[W].description})]})}),(0,r.jsx)(u.A,{sx:{display:W===ka?"block":"none",px:{xs:1,md:2}},children:(0,r.jsx)(o.L0s,{permission:me.Qp.CAN_UPDATE_LEADS.value,loadingSkeleton:(0,r.jsx)(u.A,{sx:{minHeight:420}}),children:(0,r.jsx)(Do,{chatbotID:s,embedded:!0})})}),W!==ka&&(W===Ua?(0,r.jsx)(o.L0s,{permission:me.Qp.CAN_UPDATE_SCHEDULING.value,loadingSkeleton:(0,r.jsx)(u.A,{sx:{minHeight:420}}),children:(0,r.jsx)(o.l1m,{initialValues:se,validationSchema:Ra.s0,onSubmit:function(e,n){return wa(void 0,[e,n],void 0,(function(e,n){var t,r,i,o,a,l=n.setSubmitting;return Ga(this,(function(n){switch(n.label){case 0:return n.trys.push([0,3,4,5]),t={chatbotId:s,useCalendlyScheduler:e.useCalendlyScheduler,calendlyApiKey:e.calendlyApiKey||"",calendlyEventTypeUri:e.calendlyEventTypeUri||"",calendlyLocationKind:e.calendlyLocationKind||"",calendlyPhysicalLocation:e.calendlyPhysicalLocation},[4,ee.mutateAsync(t)];case 1:return n.sent(),r={chatbotId:s,useCalComScheduler:e.useCalComScheduler,calComApiKey:e.calComApiKey||"",calComEuApiKey:e.calComEuApiKey||"",calComEventTypeId:e.calComEventTypeId||"",calComRegion:e.calComRegion||"global",timezone:e.timezone||"UTC"},[4,re.mutateAsync(r)];case 2:return n.sent(),(0,x.vd)("General actions settings saved successfully"),q(),Z(),[3,5];case 3:return i=n.sent(),console.error("Error saving settings:",i),(0,x.ag)((null===(a=null===(o=null==i?void 0:i.response)||void 0===o?void 0:o.data)||void 0===a?void 0:a.error)||"Failed to save settings. Please try again."),[3,5];case 4:return l(!1),[7];case 5:return[2]}}
1))}))},enableReinitialize:!0,children:function(e){return(0,r.jsx)(b.lV,{children:(0,r.jsxs)(u.A,{sx:{px:{xs:1,md:2}},children:[(0,r.jsx)(Da,{chatbotId:s,values:e.values,setFieldValue:e.setFieldValue,errors:e.errors,touched:e.touched,isLoading:e.isSubmitting||V||X,legacySchedulingEnabled:e.values.legacySchedulingEnabled}),(0,r.jsx)(u.A,{sx:{display:"flex",justifyContent:"flex-end",mt:3},children:(0,r.jsx)(Je.A,{type:"submit",variant:"contained",color:"primary",startIcon:(0,r.jsx)(Ho.A,{}),disabled:e.isSubmitting||V||X,sx:{borderRadius:1},children:e.isSubmitting?"Saving...":"Save Settings"})})]})})}})}):(0,r.jsx)(o.L0s,{permission:me.Qp.CAN_UPDATE_FUNCTIONS.value,loadingSkeleton:(0,r.jsx)(u.A,{sx:{minHeight:420}}),children:U?(0,r.jsxs)(u.A,{sx:{px:{xs:1,md:2}},children:[(0,r.jsx)(o.qIE,{tabs:ae,selectedTab:P,onTabChange:function(e){D(e)},sx:{marginBottom:2}}),P===Ba&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(u.A,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:1.5,mb:2.5,flexWrap:"wrap"},children:[(0,r.jsx)(Ye.A,{size:"small",value:A,onChange:function(e){I(e.target.value),y(ia._U)},InputProps:{startAdornment:(0,r.jsx)(Uo.A,{position:"start",children:(0,r.jsx)(Ta.A,{fontSize:"small"})})},placeholder:O("DISPLAY_STRINGS.SEARCH_FUNCTIONS_PLACEHOLDER"),sx:{width:250}}),(0,r.jsxs)(u.A,{sx:{display:"flex",justifyContent:"flex-end",gap:1.5},children:[(0,r.jsx)(Je.A,{variant:"outlined",color:"primary",startIcon:(0,r.jsx)(Wo.A,{}),onClick:function(){f(!0)},sx:{borderRadius:1,whiteSpace:"nowrap"},children:O("DISPLAY_LABELS.VIEW_HISTORY")}),(0,r.jsx)(Je.A,{variant:"contained",color:"primary",startIcon:(0,r.jsx)(zo.A,{}),onClick:function(){d("/chatbot/".concat(s,"/tools/create/"))},sx:{borderRadius:1,whiteSpace:"nowrap"},children:O("DISPLAY_LABELS.NEW_FUNCTION")})]})]}),(0,r.jsx)(pa,{chatbotId:s,searchTerm:A,entriesPerPage:T,page:E,onEntriesPerPageChange:function(e){v(e),y(ia._U)},onPageChange:function(e){y(e)}}),(0,r.jsx)(ma,{chatbotId:s})]}),w&&P===Ma&&(0,r.jsx)(ya,{chatbotId:s})]}):(0,r.jsx)(u.A,{sx:{minHeight:420}})}))]})]}),(0,r.jsx)(ba,{open:p,onClose:function(){return f(!1)},history:N})]})}},81491:function(e,n,t){t.d(n,{Dx:function(){return r},dj:function(){return o},fg:function(){return i},k_:function(){return a},zq:function(){return l}});var r=20,i={TRACES:0,EVALUATED_CONVERSATIONS:1},o={success:{color:"success",labelKey:"DISPLAY_LABELS.OBSERVABILITY_STATUS_SUCCESS"},error:{color:"error",labelKey:"DISPLAY_LABELS.OBSERVABILITY_STATUS_ERROR"},aborted:{color:"warning",labelKey:"DISPLAY_LABELS.OBSERVABILITY_STATUS_ABORTED"},pending:{color:"default",labelKey:"DISPLAY_LABELS.OBSERVABILITY_STATUS_PENDING"}},a={llm:{color:"primary",labelKey:"DISPLAY_LABELS.OBSERVABILITY_KIND_LLM"},tool:{color:"info",labelKey:"DISPLAY_LABELS.OBSERVABILITY_KIND_TOOL"},knowledge_base:{color:"secondary",labelKey:"DISPLAY_LABELS.OBSERVABILITY_KIND_KB"},final_answer:{color:"success",labelKey:"DISPLAY_LABELS.OBSERVABILITY_KIND_FINAL"},error:{color:"error",labelKey:"DISPLAY_LABELS.OBSERVABILITY_KIND_ERROR"}},l=[{value:"",labelKey:"DISPLAY_LABELS.OBSERVABILITY_FILTER_ALL_STATUS"},{value:"success",labelKey:"DISPLAY_LABELS.OBSERVABILITY_STATUS_SUCCESS"},{value:"error",labelKey:"DISPLAY_LABELS.OBSERVABILITY_STATUS_ERROR"},{value:"aborted",labelKey:"DISPLAY_LABELS.OBSERVABILITY_STATUS_ABORTED"},{value:"pending",labelKey:"DISPLAY_LABELS.OBSERVABILITY_STATUS_PENDING"}]},56581:function(e,n,t){t.d(n,{yk:function(){return u}});var r=t(78685),i=(t(2057),t(78166)),o=t(26088),a=t(16657),l=t(19124),s=42,c=24;function d(e,n){if(e.length<=n)return e;var t=Math.ceil((n-1)/2),r=Math.floor((n-1)/2);return"".concat(e.slice(0,t),"…").concat(e.slice(e.length-r))}function u(e){var n=e.value,t=e.maxChars,u=void 0===t?s:t,h=(0,a.Bd)().t;if("boolean"==typeof n)return(0,r.jsx)(i.vu3,{size:"small",variant:"outlined",color:n?"success":"default",label:h(n?"DISPLAY_STRINGS.YES":"DISPLAY_STRINGS.NO")});if(null==n||""===n)return(0,r.jsx)(i.o5u,{component:"span",variant:"body2",color:"text.disabled",children:"—"});var S=String(n),p=function(e){return/^(https?:)?\/\//i.test(e.trim())}(S),x=p?function(e){var n,t=e.trim();
1try{var r=new URL(t.startsWith("//")?"https:".concat(t):t),i=r.pathname.split("/").filter(Boolean),o=null!==(n=i[i.length-1])&&void 0!==n?n:"";if(!o)return r.hostname;var a=o;try{a=decodeURIComponent(o)}catch(e){}var l=i.length>1?"/…/":"/";return"".concat(r.hostname).concat(l).concat(d(a,c))}catch(e){return d(t,s)}}(S):d(S,u),f=x!==S,_=p?(0,r.jsx)(i.N_E,{href:S,target:"_blank",rel:"noopener noreferrer",variant:"body2",sx:{wordBreak:"break-word"},children:x}):(0,r.jsx)(i.o5u,{component:"span",variant:"body2",sx:{wordBreak:"break-word"},children:x});return(0,r.jsxs)(i.BJc,{direction:"row",alignItems:"center",spacing:.5,sx:{display:"inline-flex",maxWidth:"100%",verticalAlign:"middle"},children:[(0,r.jsx)(i.azJ,{sx:{minWidth:0,flexGrow:1},children:f?(0,r.jsx)(i.m_M,{title:S,arrow:!0,placement:"top",children:_}):_}),f&&(0,r.jsx)(i.m_M,{title:h("DISPLAY_STRINGS.COPY_TOOLTIP"),arrow:!0,children:(0,r.jsx)(i.K0,{size:"small","aria-label":h("DISPLAY_STRINGS.COPY_TOOLTIP"),onClick:function(){return(0,l.eM)(S)},children:(0,r.jsx)(o.A,{fontSize:"inherit"})})})]})}},8081:function(e,n,t){t.d(n,{CH:function(){return i},Zd:function(){return o}});var r=["[sent an image]","[sent a file]"],i=function(e){return r.includes((null!=e?e:"").trim())},o=function(e,n){var t=null!=e?e:"";return n&&i(t)?"":t}},12566:function(e,n,t){t.d(n,{D:function(){return i},c:function(){return r}});var r={GENERAL:"gereral",DNS_SETUP:"dns_setup",LEAD_COLLECTED_VIA_FORM:"lead_collected_via_form",LEAD_COLLECTED_VIA_CHATBOT:"lead_collected_via_chatbot",NEW_USER_WHITE_LABEL_SIGNUP:"user_signed_up",ONBOARDING_COMPLETION:"onboarding_completion",FREE_TRIAL_CREDITS_REFILLED:"free_trial_credits_refilled",FREE_TRIAL_COMPLETED:"free_trial_completed",ONBOARDING_REGISTRATION_REVIEW:"onboarding_registration_review",MATOMO_PROFILE:"matomo_profile",APPOINTMENT_SCHEDULED:"appointment_scheduled",CONVERSATION_SUMMARY:"conversation_summary",CUSTOM_FUNCTIONS:"custom_functions",AGENCY_USAGE:"agency_usage",AGENCY_REVENUE:"agency_revenue",ACCOUNT_SUMMARY:"account_summary",SUBSCRIPTION_STATUS:"subscription_status",PHONE_NUMBER_VERIFIED:"phone_number_verified",NEW_CREDIT_CARD_TRIAL_STARTED:"new_credit_card_trial_started",PAYMENT_RECEIVED:"payment_received",PAYMENT_FAILED_PAST_DUE:"payment_failed_past_due",PLAN_CANCELLATION_REQUEST:"plan_cancellation_request",FACEBOOK_ADS:"facebook_ads",CC_FREE_TRIAL_SUBSCRIBED:"cc_free_trial_subscription_started",HUMAN_HANDED_OFF:"human_handed_off"},i={LEAD_COLLECTION:1,CONVERSATION_SUMMARY:2,AGENCY_NEW_USER_SIGNUP:3,AGENCY_USAGE:4,AGENCY_REVENUE:5,AGENCY_SUBSCRIPTION_STATUS:6}},82317:function(e,n,t){t.d(n,{s:function(){return r}});var r={SMS_NOTIFICATIONS:!1}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.