1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8422],{77276:(e,t,s)=>{s.d(t,{A:()=>c});var a=s(37876);s(14232);var l=s(63154),i=s(34007),n=s(31462),d=s(46976),r=s(35384);function c(e){let{label:t,value:s,currentValue:c,color:h,tooltip:o,className:u,previousValue:_,sparkData:m,footnote:x,loading:p=!1,onClick:j}=e,b="number"==typeof s?s:"number"==typeof c?c:null,g=null!=_&&_>0&&null!=b,v=g?(b-_)/_*100:0,N=v>0,y=0===v,f=N||y?"#10B981":"#EF4444",w="spark-".concat(String(t||"").replace(/\s+/g,"-").toLowerCase());return p?(0,a.jsxs)("div",{className:"dash-stat-card".concat(u?" ".concat(u):""),children:[(0,a.jsx)("div",{className:"dash-stat-card-skeleton-label"}),(0,a.jsx)("div",{className:"dash-stat-card-skeleton-value"})]}):(0,a.jsxs)("div",{className:"dash-stat-card".concat(u?" ".concat(u):"").concat(j?" dash-stat-card--clickable":""),onClick:j,role:j?"button":void 0,tabIndex:j?0:void 0,onKeyDown:j?e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),j())}:void 0,children:[(0,a.jsxs)("div",{className:"dash-stat-card-header",children:[(0,a.jsxs)("span",{className:"dash-stat-card-label",children:[t,o&&(0,a.jsx)(r.A,{text:o})]}),g&&!y&&(0,a.jsxs)("span",{className:"dash-stat-card-change ".concat(N?"dash-positive":"dash-negative"),children:[N?(0,a.jsx)(l.avw,{className:"dash-change-icon"}):(0,a.jsx)(l.RFQ,{className:"dash-change-icon"}),Math.abs(v).toFixed(1),"%"]}),g&&y&&(0,a.jsxs)("span",{className:"dash-stat-card-change dash-neutral",children:[(0,a.jsx)(l.oev,{className:"dash-change-icon"}),"0%"]})]}),(0,a.jsx)("div",{className:"dash-stat-card-value",style:h?{color:h}:void 0,children:s}),x&&(0,a.jsx)("div",{className:"dash-stat-card-footnote",children:x}),m&&m.length>1&&(0,a.jsx)("div",{className:"dash-stat-card-spark",children:(0,a.jsx)(i.u,{width:"100%",height:40,children:(0,a.jsxs)(n.Q,{data:m,margin:{top:2,right:0,left:0,bottom:0},children:[(0,a.jsx)("defs",{children:(0,a.jsxs)("linearGradient",{id:w,x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,a.jsx)("stop",{offset:"0%",stopColor:f,stopOpacity:.3}),(0,a.jsx)("stop",{offset:"100%",stopColor:f,stopOpacity:.02})]})}),(0,a.jsx)(d.G,{type:"monotone",dataKey:"value",stroke:f,strokeWidth:1.5,fill:"url(#".concat(w,")")})]})})})]})}},78422:(e,t,s)=>{s.r(t),s.d(t,{default:()=>v});var a=s(37876),l=s(14232),i=s(76628),n=s(77564),d=s(77276),r=s(46271),c=s(68852),h=s(84219);function o(e){let{userNames:t}=e,[s,n]=(0,l.useState)([]),[d,r]=(0,l.useState)(!1),[c,o]=(0,l.useState)(null),[u,_]=(0,l.useState)(""),[m,x]=(0,l.useState)(null),[p,j]=(0,l.useState)("");(0,l.useEffect)(()=>{let e=!1;return i.http.get("/api/chat/ai-reply-examples").then(t=>{var s;e||n((null==(s=t.data)?void 0:s.examples)||[])}).catch(()=>{e||j("Could not load taught replies.")}).finally(()=>{e||r(!0)}),()=>{e=!0}},[]);let b=async e=>{var t,s,a;let l=u.trim();if(l){x(e);try{let s=null==(t=(await i.http.put("/api/chat/ai-reply-examples?id=".concat(encodeURIComponent(e)),{reply:l})).data)?void 0:t.example;n(t=>t.map(t=>t.id===e?{...t,reply:(null==s?void 0:s.reply)||l}:t)),o(null)}catch(e){j((null==e||null==(a=e.response)||null==(s=a.data)?void 0:s.error)||"Could not save the change.")}finally{x(null)}}},g=async e=>{x(e);try{await i.http.delete("/api/chat/ai-reply-examples?id=".concat(encodeURIComponent(e))),n(t=>t.filter(t=>t.id!==e))}catch(e){var t,s;j((null==e||null==(s=e.response)||null==(t=s.data)?void 0:t.error)||"Could not delete the example.")}finally{x(null)}};return(0,a.jsxs)("div",{className:"dash-ai-assist__section",children:[(0,a.jsx)("h3",{children:"Taught replies"}),(0,a.jsx)("p",{className:"dash-ai-assist__desc",children:'Taught: saved by agents with "Suggest a better reply" (newest 20 go to the AI). Learned: replies agents actually sent after editing a suggestion (newest 10 go to the AI, 50 kept).'}),p&&(0,a.jsx)("p",{className:"dash-subtitle",children:p}),(0,a.jsx)("div",{className:"lite-table-wrap",children:(0,a.jsxs)("table",{className:"lite-table",children:[(0,a.jsx)("thead",{className:"lite-table__head",children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{className:"lite-table__th",children:"When"}),(0,a.jsx)("th",{className:"lite-table__th",children:"Source"}),(0,a.jsx)("th",{className:"lite-table__th",children:"Saved by"}),(0,a.jsx)("th",{className:"lite-table__th",children:"Visitor said"}),(0,a.jsx)("th",{className:"lite-table__th",children:"Preferred reply"}),(0,a.jsx)("th",{className:"lite-table__th lite-table__th--right",children:"Actions"})]})}),(0,a.jsxs)("tbody",{children:[d&&0===s.length&&(0,a.jsx)("tr",{className:"lite-table__tr",children:(0,a.jsx)("td",{className:"lite-table__td",colSpan:6,children:"No taught replies yet."})}),s.map(e=>{let s=c===e.id,l=m===e.id;return(0,a.jsxs)("tr",{className:"lite-table__tr",children:[(0,a.jsx)("td",{className:"lite-table__td",children:e.createdAt?new Date(e.createdAt).toLocaleStr
1ing():""}),(0,a.jsx)("td",{className:"lite-table__td",children:"sent"===e.source?"Learned":"Taught"}),(0,a.jsx)("td",{className:"lite-table__td",children:(null==t?void 0:t.get(e.userId))||e.userName||e.userId}),(0,a.jsx)("td",{className:"lite-table__td dash-ai-assist__text",children:e.visitorMessage}),(0,a.jsx)("td",{className:"lite-table__td dash-ai-assist__text",children:s?(0,a.jsx)("textarea",{className:"dash-ai-assist__edit",value:u,onChange:e=>_(e.target.value),rows:3,maxLength:4e3,disabled:l}):e.reply}),(0,a.jsx)("td",{className:"lite-table__td lite-table__td--actions",children:s?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(h.A,{size:"mini",variant:"primary",onClick:()=>b(e.id),disabled:l||!u.trim(),children:"Save"})," ",(0,a.jsx)(h.A,{size:"mini",variant:"ghost",onClick:()=>o(null),disabled:l,children:"Cancel"})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(h.A,{size:"mini",variant:"ghost",onClick:()=>{o(e.id),_(e.reply||""),j("")},disabled:l,children:"Edit"})," ",(0,a.jsx)(h.A,{size:"mini",variant:"danger",onClick:()=>g(e.id),disabled:l,children:"Delete"})]})})]},e.id)})]})]})})]})}let u={"legacy:inbox_suggestion":"Legacy social inbox: AI summary & reply","lite:inbox_suggestion":"Lite inbox: AI summary & reply","lite:ticket_ai_reply":"Lite ticketing: AI reply drafts"},_=[{value:"all",label:"All AI drafts"},...Object.entries(u).map(e=>{let[t,s]=e;return{value:t,label:s}})],m=e=>"".concat(e.surface||"legacy",":").concat(e.feature),x={totals:[],daily:[],byUser:[],byTeam:[],recent:[]};function p(e,t,s){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"events";return e.filter(e=>("all"===t||m(e)===t)&&s(e)).reduce((e,t)=>e+Number(t[a]||0),0)}function j(e,t){return t?"".concat(Math.round(e/t*100),"%"):"0%"}function b(e,t,s){let a=new Map;return e.filter(e=>"all"===s||m(e)===s).forEach(e=>{let s=e[t],l=a.get(s)||{id:s,shown:0,inserted:0,refreshes:0,replies:0,used:0,edited:0};["shown","inserted","refreshes","replies","used","edited"].forEach(t=>{l[t]+=Number(e[t]||0)}),a.set(s,l)}),[...a.values()].sort((e,t)=>t.replies-e.replies||t.shown-e.shown)}function g(e){return String(e||"").replace(/<[^>]*>/g," ").replace(/\s+/g," ").trim()}function v(){let e=(0,n.default)(e=>e.userTenantData),[t,s]=(0,l.useState)("30d"),[h,v]=(0,l.useState)("all"),[N,y]=(0,l.useState)(x),[f,w]=(0,l.useState)(!0),[A,S]=(0,l.useState)("");(0,l.useEffect)(()=>{let e=!1;return w(!0),S(""),i.http.get("/api/lite/ai-assist-stats?range=".concat(t)).then(t=>{e||y({...x,...t.data||{}})}).catch(()=>{e||S("Could not load AI draft statistics.")}).finally(()=>{e||w(!1)}),()=>{e=!0}},[t]);let k=(0,l.useMemo)(()=>{let t=new Map;((null==e?void 0:e.teamMembers)||[]).forEach(e=>{let s=(null==e?void 0:e.uid)||(null==e?void 0:e.id),a=[null==e?void 0:e.name,[null==e?void 0:e.firstName,null==e?void 0:e.lastName].filter(Boolean).join(" "),null==e?void 0:e.email,s].map(e=>"string"==typeof e?e.trim():"").find(Boolean);s&&t.set(s,a||s)});let s=new Map;return((null==e?void 0:e.allTeams)||[]).forEach(e=>{(null==e?void 0:e.id)&&s.set(e.id,e.name||e.id)}),{users:t,teams:s}},[e]),C=N.totals,I=p(C,h,e=>"generated"===e.event_type),E=p(C,h,e=>"served_stored"===e.event_type||"served_cached"===e.event_type),M=p(C,h,e=>"shown"===e.event_type),T=p(C,h,e=>"add_to_chat"===e.event_type),L=p(C,h,e=>"reply_sent"===e.event_type),U=p(C,h,e=>"reply_sent"===e.event_type,"used"),R=p(C,h,e=>"reply_sent"===e.event_type,"edited"),z=p(C,h,e=>"error"===e.event_type),D=p(C,h,e=>"generated"===e.event_type,"input_tokens")+p(C,h,e=>"generated"===e.event_type,"output_tokens"),F=p(C,h,e=>"generated"===e.event_type,"confidence_samples"),O=C.filter(e=>("all"===h||m(e)===h)&&"generated"===e.event_type).reduce((e,t)=>e+Number(t.avg_confidence||0)*Number(t.confidence_samples||0),0),P=F?Math.round(O/F):0,B=b(N.byTeam,"team_id",h),G=b(N.byUser,"user_id",h),W=N.recent.filter(e=>"all"===h||m(e)===h),K="lite-table__th lite-table__th--right",Q=e=>(0,a.jsx)("td",{className:"lite-table__td lite-table__td--right",children:e}),V=(e,t,s)=>(0,a.jsx)("div",{className:"lite-table-wrap",children:(0,a.jsxs)("table",{className:"lite-table",children:[(0,a.jsx)("thead",{className:"lite-table__head",children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{className:"lite-table__th",children:t}),(0,a.jsx)("th",{className:K,children:"Shown"}),(0,a.jsx)("th",{className:K,children:"Inserted"}),(0,a.jsx)("th",{className:K,children:"Replies sent"}),(0,a.jsx)("th",{className:K,children:"Used"}),(0,a.jsx)("th",{className:K,children:"Edited"})]})}),(0,a.jsxs)("tbody",{children:[0===e.length&&(0,a.jsx)("tr",{className:"lite-table__tr",children:(0,a.jsx)("td",{className:"lite-table__td",colSpan:6,children:"No usage in this period."})}),e.map(e=>(0,a.jsxs)("tr",{className:"lite-table__tr",children:[(0,a.jsx)("td",{className:"lite-table__td",children:s.get(e.id)||e.id}),Q(e.shown),Q(e.inserted),Q(e.replies),Q("".concat(e.used," (").concat(j(e.used,e.replies),")")),Q("".concat(e.edited," (").concat(j(e.edited,e.replies),")"))]},e.id))]})]})});return(0,a.jsxs)("div",{className:"dash-ai-assist",children:[(0,a.jsxs)("div",{className:"dash-header",children:[(0,a.jsxs)("div",{className:"dash-header-left",children:[(0,a.jsx)("h1",{className:"dash-title",children:"AI draft statistics"}),(0,a.jsx)("p",{className:"dash-subtitle",children:"AI drafts generated, how often agents use them, and what was actually sent."})]}
1),(0,a.jsxs)("div",{className:"dash-header-controls",children:[(0,a.jsx)(r.A,{size:"small",options:_,value:h,onChange:v}),(0,a.jsx)(c.A,{selected:t,onChange:s})]})]}),A&&(0,a.jsx)("p",{className:"dash-subtitle",children:A}),(0,a.jsxs)("div",{className:"dash-ai-assist__cards",children:[(0,a.jsx)(d.A,{label:"Generations",value:I,loading:f,tooltip:"Model calls made"}),(0,a.jsx)(d.A,{label:"Reused without AI",value:E,loading:f,tooltip:"Stored or cached results served instead of a new generation"}),(0,a.jsx)(d.A,{label:"Shown to agents",value:M,loading:f}),(0,a.jsx)(d.A,{label:"Inserted",value:T,loading:f,tooltip:"Suggestion placed in the composer"}),(0,a.jsx)(d.A,{label:"Replies sent with a suggestion",value:L,loading:f}),(0,a.jsx)(d.A,{label:"Used as is",value:L?Math.round(U/L*100):0,loading:f,tooltip:"".concat(U," of ").concat(L," sent replies used the suggestion")}),(0,a.jsx)(d.A,{label:"Edited before sending",value:L?Math.round(R/L*100):0,loading:f,tooltip:"".concat(R," of ").concat(L," sent replies were edited")}),(0,a.jsx)(d.A,{label:"Tokens",value:D,loading:f,footnote:z?"".concat(z," failed generations"):void 0}),(0,a.jsx)(d.A,{label:"Avg confidence",value:P,loading:f,tooltip:F?"The model's own 0 to 100 estimate, over ".concat(F," generated replies"):"No generations with a confidence value yet"})]}),(0,a.jsxs)("div",{className:"dash-ai-assist__section",children:[(0,a.jsx)("h3",{children:"Per team"}),V(B,"Team",k.teams)]}),(0,a.jsxs)("div",{className:"dash-ai-assist__section",children:[(0,a.jsx)("h3",{children:"Per user"}),V(G,"User",k.users)]}),(0,a.jsx)(o,{userNames:k.users}),(0,a.jsxs)("div",{className:"dash-ai-assist__section",children:[(0,a.jsx)("h3",{children:"Latest sent replies"}),(0,a.jsx)("div",{className:"lite-table-wrap",children:(0,a.jsxs)("table",{className:"lite-table",children:[(0,a.jsx)("thead",{className:"lite-table__head",children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{className:"lite-table__th",children:"When"}),(0,a.jsx)("th",{className:"lite-table__th",children:"User"}),(0,a.jsx)("th",{className:"lite-table__th",children:"Product"}),(0,a.jsx)("th",{className:"lite-table__th",children:"Suggested"}),(0,a.jsx)("th",{className:"lite-table__th",children:"Sent"}),(0,a.jsx)("th",{className:"lite-table__th",children:"Outcome"}),(0,a.jsx)("th",{className:"lite-table__th lite-table__th--right",children:"Confidence"})]})}),(0,a.jsxs)("tbody",{children:[0===W.length&&(0,a.jsx)("tr",{className:"lite-table__tr",children:(0,a.jsx)("td",{className:"lite-table__td",colSpan:7,children:"No replies sent with a suggestion in this period."})}),W.map((e,t)=>(0,a.jsxs)("tr",{className:"lite-table__tr",children:[(0,a.jsx)("td",{className:"lite-table__td",children:String(e.event_time).slice(0,16)}),(0,a.jsx)("td",{className:"lite-table__td",children:k.users.get(e.user_id)||e.user_id||"System"}),(0,a.jsx)("td",{className:"lite-table__td",children:u[m(e)]||m(e)}),(0,a.jsx)("td",{className:"lite-table__td dash-ai-assist__text",children:g(e.suggested_reply)}),(0,a.jsx)("td",{className:"lite-table__td dash-ai-assist__text",children:g(e.sent_reply)}),(0,a.jsx)("td",{className:"lite-table__td",children:Number(e.edited)?"Edited":Number(e.used)?"Used as is":"Own reply"}),(0,a.jsx)("td",{className:"lite-table__td lite-table__td--right",children:Number(e.confidence)?"".concat(e.confidence,"%"):""})]},"".concat(e.event_time,"-").concat(t)))]})]})})]})]})}}}]);
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.