1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[213],{620:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>M});var i=r(37876),s=r(19277),l=r(39822),n=r(20529),o=r(30488),a=r(43123),c=r(32485),d=r(14232),u=r(1924),g=r(92146),h=r(72953),p=r(77362),x=r(44448),m=r(9463),j=r(8091),b=r(76839),v=r(47199),f=r(68495),y=r(70294),_=r(39584),k=r(59969),S=r(61385),w=r(91553),z=r(40950),C=r(82703),E=r(66238);let T=e=>{let{label:t,children:r}=e,{resolvedTheme:s}=(0,C.j)();return(0,i.jsxs)(u.T,{gap:2,align:"stretch",flex:1,children:[(0,i.jsx)(o.E,{fontSize:"2xs",color:"gray.500",textTransform:"uppercase",letterSpacing:"wide",children:t}),(0,i.jsx)(u.T,{gap:2,align:"stretch",children:r})]})},A=e=>{let{value:t,label:r,color:s,percentage:n,icon:a}=e,{resolvedTheme:c}=(0,C.j)();return(0,i.jsxs)(g.z,{gap:1,px:2,py:1,borderWidth:"1px",borderRadius:"md",borderColor:E.kY.blockBorderColor[c],bg:E.kY.blockBgColor2[c],w:"100%",justifyContent:"flex-start",children:[a&&(0,i.jsx)(l.a,{color:s,children:a}),(0,i.jsx)(o.E,{fontSize:"xs",fontWeight:"bold",color:s,children:t}),n&&(0,i.jsxs)(o.E,{fontSize:"2xs",color:"gray.500",children:["(",n,")"]}),r&&(0,i.jsx)(o.E,{fontSize:"xs",color:"gray.500",children:r})]})},D=e=>{var t;let{agentId:r,isDisabled:s=!1}=e,[n,c]=(0,d.useState)((()=>{let e=new Date;return e.setDate(e.getDate()-7),(0,_.GP)(e,"yyyy-MM-dd")})()),[D,W]=(0,d.useState)((0,_.GP)(new Date,"yyyy-MM-dd")),[q,M]=(0,d.useState)(!1),[N,P]=(0,d.useState)(!1),[X,R]=(0,d.useState)(!1),[Y,B]=(0,d.useState)(!1),[I,O]=(0,d.useState)(null),[V,$]=(0,d.useState)(new Set),[F,H]=(0,d.useState)(""),[J,G]=(0,d.useState)(""),[K,Q]=(0,d.useState)(null),[L,U]=(0,d.useState)(""),[Z,ee]=(0,d.useState)(""),[et,er]=(0,d.useState)([]),[ei,es]=(0,d.useState)(null),{data:el,mutate:en}=(0,k.QH)(r||null),{data:eo,error:ea,isLoading:ec,mutate:ed}=(0,k.__)(r||null,n,D,!0,20),{trigger:eu,isMutating:eg}=(0,k.V9)(r||null),{trigger:eh,isMutating:ep}=(0,k.HA)(r||null),{trigger:ex}=(0,k.YM)(r||null),{trigger:em,isMutating:ej}=(0,k.Wg)(r||null),{resolvedTheme:eb}=(0,C.j)(),ev=!!(n&&D&&n<=D),ef=()=>{en(),ed()},ey=async e=>{let t=null==el?void 0:el.find(t=>t.id===e.id);if(t)try{await eh({topic_id:e.id,is_active:!t.is_active}),ef(),S.X.create({title:t.is_active?"Topic deactivated":"Topic activated",description:"The topic has been ".concat(t.is_active?"deactivated":"activated","."),type:"success",duration:2e3,closable:!0})}catch(e){console.error(e),S.X.create({title:"Error updating topic",description:e.message||"An error occurred. Please try again.",type:"error",duration:3e3,closable:!0})}},e_=()=>{M(!1),H(""),G("")},ek=async()=>{if(!F.trim())return void S.X.create({title:"Validation Error",description:"Topic name is required.",type:"error",duration:3e3,closable:!0});try{await eu({name:F,description:J}),e_(),ef(),S.X.create({title:"Topic created successfully",description:"The topic has been added.",type:"success",duration:3e3,closable:!0})}catch(e){console.error(e),S.X.create({title:"Error creating topic",description:e.message||"An error occurred. Please try again.",type:"error",duration:3e3,closable:!0})}},eS=()=>{P(!1),Q(null),U(""),ee("")},ew=async()=>{if(!L.trim())return void S.X.create({title:"Validation Error",description:"Topic name is required.",type:"error",duration:3e3,closable:!0});if(K)try{await eh({topic_id:K,name:L,description:Z}),eS(),ef(),S.X.create({title:"Topic updated successfully",description:"The topic has been updated.",type:"success",duration:3e3,closable:!0})}catch(e){console.error(e),S.X.create({title:"Error updating topic",description:e.message||"An error occurred. Please try again.",type:"error",duration:3e3,closable:!0})}},ez=()=>{R(!1),er([]),es(null)},eC=e=>{et.includes(e)?(er(et.filter(t=>t!==e)),ei===e&&es(null)):er([...et,e])},eE=async()=>{if(!ei)return void S.X.create({title:"Validation Error",description:"Please select a target topic to merge into.",type:"error",duration:3e3,closable:!0});let e=et.filter(e=>e!==ei);if(0===e.length)return void S.X.create({title:"Validation Error",description:"Please select at least one topic to merge into the target.",type:"error",duration:3e3,closable:!0});try{await em({source_topic_ids:e,target_topic_id:ei}),ez(),ef(),S.X.create({title:"Topics merged successfully",description:"".concat(e.length," topic(s) have been merged."),type:"success",duration:3e3,closable:!0})}catch(e){console.error(e),S.X.create({title:"Error merging topics",description:e.message||"An error occurred. Please try again.",type:"error",duration:3e3,closable:!0})}},eT=()=>{B(!1),O(null),$(new Set)},eA=e=>{var t,r,i,s;return null!=(s=null!=(i=null==(t=e.stats)?void 0:t.total_questions)?i:null==(r=e.stats)?void 0:r.volume)?s:0};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(u.T,{gap:6,align:"stretch",children:[(0,i.jsxs)(g.z,{gap:2,children:[(0,i.jsxs)(h.$,{colorScheme:"blue",onClick:()=>{H(""),G(""),M(!0)},disabled:s,size:"sm",children:[(0,i.jsx)(y.GGD,{}),(0,i.jsx)(o.E,{fontSize:"sm",ml:2,children:"Add New Topic"})]}),eo&&eo.topics.length>=2&&(0,i.jsxs)(h.$,{variant:"outline",onClick:()=>{er([]),es(null),R(!0)},disabled:s,size:"sm",children:[(0,i.jsx)(y.EPw,{}),(0,i.jsx)(o.E,{fontSize:"sm",ml:2,children:"Merge Topics"})]})]}),(0,i.jsxs)(g.z,{gap:4,flexWrap:"wrap",alignItems:"flex-end",children:[(0,i.jsxs)(l.a,{children:[(0,i.jsx)(o.E,{fontSize:"sm",mb:1,color:"dark"===eb?"gray.400":"gray.600",children:"Start Date"}),(0,i.jsx)(p.p,{type:"date",value:n,onChange:e=>c(e.target.value),size:"sm",w:"160px"})]}),(0,i.jsxs)(l.a,{children:[(0,i.jsx)(o.E,{fontSize:"sm",mb:1,color:"dark"===eb?"gray.400":"gray.600",children:"End Date"}),(0,i.jsx)(p.p,{type:"date",value:D,onChange:e=>W(e.target.value),size:"sm",w:"160px"})]})]}),!ev&&n&&D&&(0,i.jsx)(l.a,{p:3,borderRadius:"md",bg:"dark"===eb?"red.900":"red.50",borderWidth:"1px",borderColor:"dark"===eb?"red.700":"red.200",children:(0,i.jsx)(o.E,{fontSize:"sm",color:"dark"===eb?"red.200":"red.800",children:"Start date must be before or equal to end date"})}),ec&&(0,i.jsx)(l.a,{display:"flex",justifyContent:"center",alignItems:"center",py:8,children:(0,i.jsx)(o.E,{children:"Loading topics..."})}),ea&&(0,i.jsx)(l.a,{textAlign:"center",py:8,p:4,borderWidth:"1px",borderRadius:"lg",borderColor:"red.300",bg:"dark"===eb?"red.900":"red.50",children:(0,i.jsxs)(o.E,{color:"red.600",children:["Error loading topics: ",ea instanceof Error?ea.message:"Unknown error"]})}),!ec&&!ea&&eo&&ev&&eo.topics.filter(e=>eA(e)>0).length>0&&(()=>{let e=eo.topics.reduce((e,t)=>
1e+eA(t),0);return(0,i.jsx)(l.a,{borderWidth:"1px",borderRadius:"md",children:(0,i.jsx)(a.s,{direction:"column",children:eo.topics.filter(e=>eA(e)>0).map((t,r,n)=>{var a,c,p,b,v,_,k,S,z,C,E,D,W,q,M,N,X,R,Y,I,V,$,F,H,J,G,K,L,Z,et,er,ei,es,en,eo,ea,ec,ed,eu,eg,eh,ep,em,ej,ev,e_,ek,eS;let ew=(e=>{var t;let r=null==el?void 0:el.find(t=>t.id===e);return null==(t=null==r?void 0:r.is_active)||t})(t.id),ez=(e=>{var t;let r=null==el?void 0:el.find(t=>t.id===e);return null!=(t=null==r?void 0:r.source)?t:"manual"})(t.id),eC=eA(t),eE=e>0?(eC/e*100).toFixed(0):"0";return(0,i.jsxs)(d.Fragment,{children:[(0,i.jsx)(l.a,{p:4,children:(0,i.jsxs)(g.z,{justifyContent:"space-between",alignItems:"flex-start",gap:4,children:[(0,i.jsxs)(u.T,{gap:2,align:"flex-start",flex:1,children:[(0,i.jsxs)(g.z,{gap:3,children:[(0,i.jsx)(l.a,{onClick:e=>{e.stopPropagation(),s||ey(t)},cursor:s?"not-allowed":"pointer",children:(0,i.jsxs)(x.lq,{checked:ew,onCheckedChange:()=>{s||ey(t)},disabled:s,size:"md",children:[(0,i.jsx)(x.tD,{}),(0,i.jsx)(x.oO,{})]})}),(0,i.jsx)(o.E,{fontSize:"sm",fontWeight:"bold",children:t.name}),(0,i.jsx)(f.f8,{colorPalette:"manual"===ez?"blue":"purple",size:"sm",variant:"subtle",children:(0,i.jsx)(f.d1,{children:"manual"===ez?"Manually Added":"AI Added"})})]}),t.description&&(0,i.jsx)(o.E,{fontSize:"sm",color:"gray.500",children:t.description}),(0,i.jsx)(l.a,{p:3,borderRadius:"md",bg:"dark"===eb?"whiteAlpha.50":"blackAlpha.50",w:"100%",children:(0,i.jsxs)(g.z,{gap:4,alignItems:"stretch",w:"100%",children:[(0,i.jsxs)(T,{label:"Volume",children:[(0,i.jsx)(A,{value:eC,label:"Sessions"}),(0,i.jsx)(A,{value:"".concat(eE,"%"),label:"of Total"})]}),(0,i.jsxs)(T,{label:"Rating",children:[(0,i.jsx)(A,{value:(null==(a=t.stats)?void 0:a.avg_rating)!=null?t.stats.avg_rating.toFixed(1):"N/A",label:"Avg",color:(null==(c=t.stats)?void 0:c.avg_rating)!=null&&t.stats.avg_rating>=4?"green.500":(null==(p=t.stats)?void 0:p.avg_rating)!=null&&t.stats.avg_rating>=3?"yellow.500":"orange.500"}),(0,i.jsx)(A,{value:null!=(es=null==(v=t.stats)||null==(b=v.high_rating)?void 0:b.count)?es:0,label:"High (4-5)",color:"green.500",percentage:"".concat((null!=(en=null==(k=t.stats)||null==(_=k.high_rating)?void 0:_.percentage)?en:0).toFixed(1),"%")}),(0,i.jsx)(A,{value:null!=(eo=null==(z=t.stats)||null==(S=z.low_rating)?void 0:S.count)?eo:0,label:"Low (1-3)",color:"orange.400",percentage:"".concat((null!=(ea=null==(E=t.stats)||null==(C=E.low_rating)?void 0:C.percentage)?ea:0).toFixed(1),"%")}),(0,i.jsx)(A,{value:null!=(ec=null==(q=t.stats)||null==(W=q.rating_distribution)||null==(D=W.null)?void 0:D.count)?ec:0,label:"Not Rated",color:"gray.400",percentage:"".concat((null!=(ed=null==(X=t.stats)||null==(N=X.rating_distribution)||null==(M=N.null)?void 0:M.percentage)?ed:0).toFixed(1),"%")})]}),(0,i.jsxs)(T,{label:"AI Tags",children:[(0,i.jsx)(A,{value:null!=(eu=null==(Y=t.stats)||null==(R=Y.missed)?void 0:R.count)?eu:0,label:"Missed",color:"red.500",percentage:"".concat(null!=(eg=null==(V=t.stats)||null==(I=V.missed)?void 0:I.percentage)?eg:0,"%"),icon:(0,i.jsx)(y.y3G,{size:12})}),(0,i.jsx)(A,{value:null!=(eh=null==(F=t.stats)||null==($=F.escalated)?void 0:$.count)?eh:0,label:"Escalated",color:"orange.500",percentage:"".concat(null!=(ep=null==(J=t.stats)||null==(H=J.escalated)?void 0:H.percentage)?ep:0,"%"),icon:(0,i.jsx)(y.qdV,{size:12})})]}),(null==(G=t.stats)?void 0:G.resolution_feedback)&&(0,i.jsxs)(T,{label:"Resolution",children:[(0,i.jsx)(A,{value:null!=(em=null==(K=t.stats.resolution_feedback.resolved)?void 0:K.count)?em:0,label:"Yes",color:"green.500",percentage:"".concat(null!=(ej=null==(L=t.stats.resolution_feedback.resolved)?void 0:L.percentage)?ej:0,"%")}),(0,i.jsx)(A,{value:null!=(ev=null==(Z=t.stats.resolution_feedback.unresolved)?void 0:Z.count)?ev:0,label:"No",color:"orange.500",percentage:"".concat(null!=(e_=null==(et=t.stats.resolution_feedback.unresolved)?void 0:et.percentage)?e_:0,"%")}),(0,i.jsx)(A,{value:null!=(ek=null==(er=t.stats.resolution_feedback.null)?void 0:er.count)?ek:0,label:"Null",color:"gray.400",percentage:"".concat(null!=(eS=null==(ei=t.stats.resolution_feedback.null)?void 0:ei.percentage)?eS:0,"%")})]})]})})]}),(0,i.jsxs)(g.z,{gap:1,children:[(0,i.jsxs)(h.$,{size:"sm",variant:"ghost",onClick:()=>{O(t),B(!0)},disabled:!t.sample_questions||0===t.sample_questions.length,children:[(0,i.jsx)(y.Vap,{size:14}),(0,i.jsx)(o.E,{ml:1,fontSize:"xs",children:"Questions"})]}),(0,i.jsx)(m.K,{"aria-label":"Edit Topic",size:"sm",variant:"ghost",colorPalette:"gray",onClick:()=>(e=>{Q(e.id),U(e.name),ee(e.description||""),P(!0)})(t),disabled:s,children:(0,i.jsx)(y.WXf,{})}),(0,i.jsx)(w.A,{triggerDelete:()=>
1ex({topic_id:t.id}),alertMessage:"Are you sure you want to delete this topic? Messages referencing this topic will have their topic reference removed.",mutate:ef,variant:"icon",iconSize:"sm",isDisabled:s})]})]})}),r<n.length-1&&(0,i.jsx)(j.w,{})]},t.id)})})})})(),!ec&&!ea&&eo&&ev&&0===eo.topics.filter(e=>eA(e)>0).length&&(0,i.jsxs)(l.a,{p:8,textAlign:"center",borderWidth:"1px",borderRadius:"md",borderStyle:"dashed",children:[(0,i.jsx)(o.E,{color:"gray.500",mb:2,children:"No topics with data found"}),(0,i.jsx)(o.E,{fontSize:"sm",color:"gray.400",children:"Topics will appear here once they have associated questions in the selected date range."})]})]}),(0,i.jsx)(z.A,{isOpen:q,onClose:e_,title:"Add New Topic",onSubmit:ek,isSubmitting:eg,submitButtonText:"Create Topic",isDisabled:s,children:(0,i.jsxs)(u.T,{gap:4,align:"stretch",children:[(0,i.jsxs)(l.a,{children:[(0,i.jsx)(o.E,{fontSize:"sm",fontWeight:"semibold",mb:2,children:"Name"}),(0,i.jsx)(p.p,{type:"text",value:F,onChange:e=>H(e.target.value),placeholder:"Enter topic name",size:"sm",disabled:s})]}),(0,i.jsxs)(l.a,{children:[(0,i.jsx)(o.E,{fontSize:"sm",fontWeight:"semibold",mb:2,children:"Description"}),(0,i.jsx)(o.E,{fontSize:"xs",color:"gray.500",mb:2,children:"Optional description to help identify this topic."}),(0,i.jsx)(b.T,{value:J,onChange:e=>G(e.target.value),placeholder:"Enter topic description",size:"sm",height:"100px",disabled:s})]})]})}),(0,i.jsx)(z.A,{isOpen:N,onClose:eS,title:"Edit Topic",onSubmit:ew,isSubmitting:ep,submitButtonText:"Save Changes",isDisabled:s,children:(0,i.jsxs)(u.T,{gap:4,align:"stretch",children:[(0,i.jsxs)(l.a,{children:[(0,i.jsx)(o.E,{fontSize:"sm",fontWeight:"semibold",mb:2,children:"Name"}),(0,i.jsx)(p.p,{type:"text",value:L,onChange:e=>U(e.target.value),size:"sm",disabled:s})]}),(0,i.jsxs)(l.a,{children:[(0,i.jsx)(o.E,{fontSize:"sm",fontWeight:"semibold",mb:2,children:"Description"}),(0,i.jsx)(b.T,{value:Z,onChange:e=>ee(e.target.value),size:"sm",height:"100px",disabled:s})]})]})}),(0,i.jsx)(z.A,{isOpen:X,onClose:ez,title:"Merge Topics",onSubmit:eE,isSubmitting:ej,submitButtonText:"Merge Topics",isDisabled:s||et.length<2||!ei,children:(0,i.jsxs)(u.T,{gap:4,align:"stretch",children:[(0,i.jsxs)(l.a,{children:[(0,i.jsx)(o.E,{fontSize:"sm",fontWeight:"semibold",mb:2,children:"Select Topics to Merge"}),(0,i.jsx)(o.E,{fontSize:"xs",color:"gray.500",mb:4,children:"Select at least 2 topics. Messages from source topics will be moved to the target topic, and source topics will be deleted."}),eo&&eo.topics.length>0&&(0,i.jsx)(u.T,{gap:2,align:"stretch",children:eo.topics.map(e=>{let t=et.includes(e.id),r=ei===e.id;return(0,i.jsx)(l.a,{p:3,borderWidth:"1px",borderRadius:"md",borderColor:r?"green.500":t?"blue.500":"gray.200",bg:r?"dark"===eb?"green.900":"green.50":t?"dark"===eb?"blue.900":"blue.50":"transparent",cursor:"pointer",onClick:()=>eC(e.id),children:(0,i.jsxs)(g.z,{justify:"space-between",children:[(0,i.jsxs)(g.z,{gap:3,children:[(0,i.jsxs)(v.y8,{checked:t,onCheckedChange:()=>eC(e.id),children:[(0,i.jsx)(v.Ks,{}),(0,i.jsx)(v.v7,{})]}),(0,i.jsxs)(u.T,{gap:0,align:"flex-start",children:[(0,i.jsx)(o.E,{fontSize:"sm",fontWeight:"semibold",children:e.name}),(0,i.jsxs)(o.E,{fontSize:"xs",color:"gray.500",children:[eA(e)," sessions"]})]})]}),t&&(0,i.jsx)(h.$,{size:"xs",colorScheme:r?"green":"gray",variant:r?"solid":"outline",onClick:t=>{t.stopPropagation(),(e=>{et.includes(e)&&es(e)})(e.id)},children:r?"Target":"Set as Target"})]})},e.id)})})]}),et.length>=2&&ei&&(0,i.jsx)(l.a,{p:3,bg:"dark"===eb?"gray.800":"gray.100",borderRadius:"md",children:(0,i.jsxs)(o.E,{fontSize:"sm",color:"gray.600",children:[(0,i.jsx)(o.E,{as:"span",fontWeight:"semibold",children:"Summary: "}),et.length-1,' topic(s) will be merged into "',null==eo||null==(t=eo.topics.find(e=>e.id===ei))?void 0:t.name,'"']})})]})}),(0,i.jsx)(z.A,{isOpen:Y,onClose:eT,title:'Questions for "'.concat((null==I?void 0:I.name)||"Topic",'"'),onSubmit:eT,showActions:!1,isDisabled:!1,children:(0,i.jsx)(u.T,{gap:4,align:"stretch",children:I&&I.sample_questions&&I.sample_questions.length>0?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(o.E,{fontSize:"sm",color:"gray.500",mb:2,children:["Showing ",I.sample_questions.length," recent questions (most recent first). Click to expand answers."]}),I.sample_questions.map((e,t)=>{let r=V.has(t);return(0,i.jsxs)(l.a,{borderWidth:"1px",borderRadius:"md",borderColor:E.kY.blockBorderColor[eb],bg:E.kY.blockBgColor2[eb],overflow:"hidden",children:[(0,i.jsxs)(l.a,{p:3,cursor:"pointer",onClick:()=>(e=>{$(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})})(t),_hover:{bg:"dark"===eb?"whiteAlpha.100":"blackAlpha.50"},transition:"background 0.2s",children:[(0,i.jsxs)(g.z,{justify:"space-between",mb:2,children:[(0,i.jsxs)(g.z,{gap:2,children:[(0,i.jsx)(l.a,{color:"gray.500",children:r?(0,i.jsx)(y.fK4,{size:14}):(0,i.jsx)(y.fOo,{size:14})}),(0,i.jsx)(o.E,{fontSize:"xs",color:"gray.500",children:(e=>{if(!e)return"N/A";try{return(0,_.GP)(new Date(e),"MMM dd, yyyy HH:mm")}catch(t){return e}})(e.created_at)})]}),e.answer&&(0,i.jsx)(o.E,{fontSize:"2xs",color:"gray.400",children:r?"Click to collapse":"Click to see answer"})]}),(0,i.jsx)(o.E,{fontSize:"sm",whiteSpace:"pre-wrap",fontWeight:"medium",children:e.question})]}),r&&e.answer&&(0,i.jsxs)(l.a,{p:3,pt:0,borderTopWidth:"1px",borderTopColor:E.kY.blockBorderColor[eb],bg:"dark"===eb?"whiteAlpha.50":"blackAlpha.25",children:[(0,i.jsx)(o.E,{fontSize:"xs",fontWeight:"semibold",color:"gray.500",mb:1,mt:2,children:"Answer:"}),(0,i.jsx)(o.E,{fontSize:"sm",whiteSpace:"pre-wrap",color:"dark"===eb?"gray.300":"gray.700",children:e.answer})]}),r&&!e.answer&&(0,i.jsx)(l.a,{p:3,pt:0,borderTopWidth:"1px",borderTopColor:E.kY.blockBorderColor[eb],bg:"dark"===eb?"whiteAlpha.50":"blackAlpha.25",children:(0,i.jsx)(o.E,{fontSize:"sm",color:"gray.400",fontStyle:"italic",mt:2,children:"No answer recorded for this question."})})]},t)})]}):(0,i.jsx)(l.a,{p:8,textAlign:"center",children:(0,i.jsx)(o.E,{color:"gray.500",children:"No questions foun
1d for this topic in the selected date range."})})})})]})};var W=r(81033),q=r(90096);let M=(0,s.A)(function(){let e=(0,q._)(),t=(0,d.useContext)(W.j);return(null==t?void 0:t.isTester)?(0,i.jsxs)(l.a,{w:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:"400px",children:[(0,i.jsx)(n.D,{size:"lg",color:"red.500",mb:"4",children:"Access Denied"}),(0,i.jsx)(o.E,{fontSize:"md",color:"gray.600",children:"You do not have permission to access this page."})]}):(0,i.jsx)(a.s,{w:"100%",flexDirection:"column",alignItems:"center",children:(0,i.jsxs)(l.a,{w:"100%",position:"relative",children:[(0,i.jsx)(n.D,{size:"lg",children:"Topics"}),(0,i.jsx)(o.E,{mb:"6",fontSize:"sm",color:"gray.600",children:"View and manage conversation topics to better understand what your users are asking about."}),(0,i.jsx)(D,{agentId:e}),(0,i.jsx)(c.h,{my:"2rem"})]})})})},19277:(e,t,r)=>{"use strict";r.d(t,{A:()=>o});var i=r(37876),s=r(72943),l=r(14e3);r(14232);var n=r(19619);let o=e=>t=>{let r=(0,s.J)(),o=(0,l.useRouter)();return r.loading?(0,i.jsx)("div",{children:"Loading..."}):null===r?void o.push("/auth"):(0,i.jsx)(n.SessionAuth,{onSessionExpired:()=>o.refresh(),userContext:r.user||void 0,children:(0,i.jsx)(e,{...t})})}},40950:(e,t,r)=>{"use strict";r.d(t,{A:()=>u});var i=r(37876);r(14232);var s=r(44296),l=r(39822),n=r(43123),o=r(8091),a=r(72953),c=r(21379),d=r(66238);let u=e=>{let{isOpen:t,onClose:r,title:u,onSubmit:g,isSubmitting:h=!1,submitButtonText:p="Submit",children:x,showActions:m=!0,isDisabled:j=!1,playground:b=!1,headerRight:v}=e,{theme:f}=(0,c.D)(),y=d.kY.blockBgColor[f]||d.kY.blockBgColor.dark,_=d.kY.blockBorderColor[f]||d.kY.blockBorderColor.dark,k=d.kY.textColor[f]||d.kY.textColor.dark;return(0,i.jsxs)(s.Dz,{open:t,onOpenChange:e=>e.open?{}:r(),size:"full",motionPreset:"slide-in-right",children:[(0,i.jsx)(s.Xi,{}),(0,i.jsxs)(s.Cf,{bg:y,borderColor:_,width:"50vw",height:"100vh",position:"fixed",right:"0",top:"0",margin:"0",borderRadius:"0",children:[(0,i.jsx)(l.a,{position:"absolute",top:"16px",right:"16px",zIndex:10,children:(0,i.jsx)(s.tK,{})}),(0,i.jsx)(s.c7,{ml:0,fontSize:"sm",fontWeight:"semibold",color:k,children:(0,i.jsxs)(n.s,{justifyContent:"space-between",alignItems:"center",w:"100%",pr:8,children:[u,v]})}),b&&(0,i.jsx)(o.w,{width:"100%",mx:"auto",borderColor:"dark"===f?"gray.600":"white"}),(0,i.jsx)(s.R4,{pb:6,overflowY:"auto",children:x}),m?(0,i.jsxs)(s.Es,{children:[(0,i.jsx)(a.$,{colorScheme:"blue",mr:3,onClick:g,loading:h,disabled:j,title:j?"Admin permissions required":"",children:p}),(0,i.jsx)(a.$,{colorScheme:"blue",variant:"outline",onClick:r,children:"Cancel"})]}):(0,i.jsx)(s.Es,{children:(0,i.jsx)(a.$,{colorScheme:"blue",onClick:r,children:"Close"})})]})]})}},59969:(e,t,r)=>{"use strict";r.d(t,{HA:()=>c,QH:()=>o,V9:()=>a,Wg:()=>u,YM:()=>d,__:()=>g});var i=r(75656),s=r(34333),l=r(8863),n=r(72943);let o=e=>{let{user:t}=(0,n.J)();return(0,i.Ay)(t&&e?["/fetch_topics?agent_id=".concat(e),t.accessToken]:null,e=>(0,l.we)(e).then(e=>e.data))},a=e=>{let{user:t}=(0,n.J)();return(0,s.A)(t&&e?["/create_topic?agent_id=".concat(e),t.accessToken]:null,(e,t)=>{let{arg:r}=t;return(0,l.eh)(e,{arg:{name:r.name,description:r.description||""}})})},c=e=>{let{user:t}=(0,n.J)();return(0,s.A)(t&&e?["/edit_topic?agent_id=".concat(e),t.accessToken]:null,(e,t)=>{let[r,i]=e,{arg:s}=t,n={};void 0!==s.name&&(n.name=s.name),void 0!==s.description&&(n.description=s.description),void 0!==s.is_active&&(n.is_active=s.is_active);let[o,a]=r.split("?"),c="".concat(o,"/").concat(s.topic_id).concat(a?"?".concat(a):"");return(0,l.wf)([c,i],{arg:n})})},d=e=>{let{user:t}=(0,n.J)();return(0,s.A)(t&&e?["/delete_topic?agent_id=".concat(e),t.accessToken]:null,(e,t)=>{let[r,i]=e,{arg:s}=t,[n,o]=r.split("?"),a="".concat(n,"/").concat(s.topic_id).concat(o?"?".concat(o):"");return(0,l.Nw)([a,i],{arg:{}})})},u=e=>{let{user:t}=(0,n.J)();return(0,s.A)(t&&e?["/merge_topics?agent_id=".concat(e),t.accessToken]:null,(e,t)=>{let{arg:r}=t;return(0,l.eh)(e,{arg:{source_topic_ids:r.source_topic_ids,target_topic_id:r.target_topic_id}})})},g=function(e,t,r){let s=!(arguments.length>3)||void 0===arguments[3]||arguments[3],o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:10,{user:a}=(0,n.J)();return(0,i.Ay)(a&&e&&t&&r?["/get_topics_analytics?agent_id=".concat(e,"&start_date=").concat(t,"&end_date=").concat(r)+"&include_questions=".concat(s)+"&questions_limit=".concat(o),a.accessToken]:null,async e=>{var t,r,i,s;let n=(await (0,l.we)(e)).data,o=null!=(r=null==n||null==(t=n.topics)?void 0:t.map(e=>{var t,r,i,s;return{...e,stats:{...e.stats,total_questions:null!=(s=null!=(i=null==(t=e.stats)?void 0:t.total_questions)?i:null==(r=e.stats)?void 0:r.volume)?s:0}}}))?r:[],a=(null==n?void 0:n.summary)?{...n.summary,total_questions:null!=(s=null!=(i=n.summary.total_questions)?i:n.summary.total_volume)?s:0}:void 0;return{...n,topics:o,summary:null!=a?a:null==n?void 0:n.summary}})}}
1,77606:(e,t,r)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/agents/[agent_id]/topics",function(){return r(620)}])},91553:(e,t,r)=>{"use strict";r.d(t,{A:()=>g});var i=r(37876),s=r(14232),l=r(9463),n=r(30488),o=r(72953),a=r(44296),c=r(89099),d=r(70294),u=r(61385);let g=e=>{let{triggerDelete:t,alertMessage:r,deleteParams:g,redirectRoute:h,mutate:p,isDisabled:x=!1,buttonText:m="Delete",modalOnClose:j,variant:b="solid",className:v,iconSize:f="md"}=e,[y,_]=(0,s.useState)(!1),k=()=>_(!1),S=(0,s.useRef)(null),w=(0,c.useRouter)(),z=async()=>{try{let e=await t(g);u.X.create({title:"Success",description:e.message,type:"success",duration:9e3,closable:!0}),p&&p(),h&&w.push(h),k(),j&&j()}catch(e){console.error(e),u.X.create({title:"Error",description:e.message,type:"error",duration:9e3,closable:!0})}};return(0,i.jsxs)(i.Fragment,{children:["icon"===b?(0,i.jsx)(l.K,{className:v,colorPalette:"red","aria-label":"Delete",variant:"ghost",onClick:()=>_(!0),disabled:x,size:f,children:(0,i.jsx)(d.IXo,{})}):"underlined"===b?(0,i.jsx)(n.E,{className:v,cursor:"pointer",fontWeight:"bold",fontSize:"xs",onClick:()=>_(!0),opacity:x?.4:1,pointerEvents:x?"none":"auto",_hover:{textDecoration:"underline"},children:m}):(0,i.jsx)(o.$,{className:v,colorPalette:"red",variant:"solid"===b||"outline"===b||"ghost"===b||"subtle"===b||"surface"===b||"plain"===b?b:"solid",onClick:()=>_(!0),disabled:x,size:"sm",children:m}),(0,i.jsxs)(a.Dz,{open:y,onOpenChange:e=>e.open?_(!0):k(),placement:"center",motionPreset:"slide-in-bottom",children:[(0,i.jsx)(a.Xi,{}),(0,i.jsxs)(a.Cf,{maxW:"md",position:"fixed",top:"50%",left:"50%",transform:"translate(-50%, -50%)",margin:"0",children:[(0,i.jsx)(a.c7,{fontSize:"lg",fontWeight:"bold",children:"Confirm Deletion"}),(0,i.jsx)(a.R4,{children:(0,i.jsx)(n.E,{children:r})}),(0,i.jsxs)(a.Es,{gap:3,children:[(0,i.jsx)(o.$,{ref:S,onClick:k,variant:"outline",children:"Cancel"}),(0,i.jsx)(o.$,{colorPalette:"red",variant:"solid",onClick:z,children:m})]}),(0,i.jsx)(a.tK,{})]})]})]})}}},e=>{e.O(0,[0,166,584,299,636,593,792],()=>e(e.s=77606)),_N_E=e.O()}]);
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.