PageSourceSearch

https://superwise.chat/_next/static/chunks/1821.3fef36d236b50bf4.js

js superwise.chat collected 2026-10-04 01:54:07 UTC 54,746 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1821],{1821:(e,s,t)=>{t.r(s),t.d(s,{GovernanceDrawer:()=>eM,MessageGovernanceDrawer:()=>eD.R});var a=t(95155),l=t(12115),n=t(17910),r=t(9058),i=t(37354),c=t(65229),d=t(6132),o=t(89559);let x={title:"Governance",tabs:{trust:"Trust & Control",trace:"Steps",policy:"Rules",search:"Sources",sage:"Sage"}};var m=t(31166),u=t(52799),w=t(77979),h=t(23838),p=t(96871),g=t(77801),f=t(76907),j=t(21420),b=t(26983),v=t(23327),N=t(45871);let y=e=>{let{breakdown:s}=e;if(0===s.total)return null;let t=void 0!==s.inference?[{label:"Inference",value:s.inference||0,category:"llm"},{label:"Retrieval",value:s.retrieval||0,category:"retrieval"},{label:"Tools",value:s.tools||0,category:"tool"},{label:"Governance",value:s.governance||0,category:"governance"}]:[{label:"LLM",value:s.llm||0,category:"llm"},{label:"Retrieval",value:s.retrieval||0,category:"retrieval"},{label:"Tool",value:s.tool||0,category:"tool"},{label:"Governance",value:s.governance||0,category:"governance"},{label:"External Research",value:s.external_research||0,category:"external_research"},{label:"Knowledge",value:s.knowledge||0,category:"knowledge"},{label:"Memory",value:s.memory||0,category:"memory"},{label:"Transform",value:s.transform||0,category:"transform"}].filter(e=>e.value>0);return(0,a.jsxs)("div",{className:"bg-sw-surface rounded-sw-md p-4",role:"region","aria-label":"swToken metrics",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,a.jsxs)("h4",{className:"text-sw-body font-semibold text-sw-text flex items-center gap-2",children:[(0,a.jsx)(b.A,{size:16}),"swTokens"]}),s.weight_model_version&&(0,a.jsx)(N.Bc,{children:(0,a.jsxs)(N.m_,{children:[(0,a.jsx)(N.k$,{asChild:!0,children:(0,a.jsxs)("div",{className:"flex items-center gap-1 cursor-default",tabIndex:0,children:[(0,a.jsxs)("span",{className:"sw-text-caption-muted",children:["v",s.weight_model_version]}),(0,a.jsx)(v.A,{size:12,className:"text-sw-text-muted","aria-hidden":"true"})]})}),(0,a.jsx)(N.ZI,{children:"Weight model version used for metering calculations (server-side only)"})]})})]}),(0,a.jsx)("div",{className:"text-sw-h1 font-bold text-sw-text mb-3",children:s.total.toLocaleString("en-US")}),(0,a.jsx)("div",{className:"space-y-2 text-sw-body",children:t.map(e=>(0,a.jsxs)("div",{className:"flex justify-between",children:[(0,a.jsxs)("span",{className:"text-sw-text-muted",children:[e.label,":"]}),(0,a.jsx)("span",{className:"text-sw-text",children:e.value.toLocaleString("en-US")})]},e.category))}),!s.weight_model_version&&(0,a.jsx)("div",{className:"mt-3 pt-3 border-t border-sw-border sw-text-caption-muted",children:"All calculations are server-sourced"})]})};var k=t(18518),A=t(94546);let _=e=>{let{data:s}=e,[t,r]=(0,l.useState)(null),[i,c]=(0,l.useState)(!1),[d,o]=(0,l.useState)(!1);return((0,l.useEffect)(()=>{var e;!d&&((null==(e=s.runtimeEvents)?void 0:e.length)||s.trustStatus||s.agentConfig||s.executionTrace||s.swTokens)&&(o(!0),c(!0),(0,A.getGovernanceInsight)(s).then(e=>{e.insight&&r(e.insight)}).catch(()=>{}).finally(()=>c(!1)))},[s,d]),i||t)?(0,a.jsxs)("div",{className:"bg-sw-surface rounded-sw-md p-sw-3 border border-sw-border/50",children:[(0,a.jsxs)("h4",{className:"text-sw-caption font-semibold text-sw-text mb-1.5 flex items-center gap-1.5",children:[(0,a.jsx)(n.A,{className:"w-3 h-3"}),"Governance Insight"]}),i?(0,a.jsxs)("div",{className:"flex items-center gap-sw-2 sw-text-caption-muted",children:[(0,a.jsx)(k.y$,{size:"xs"}),(0,a.jsx)("span",{children:"Analyzing governance posture..."})]}):(0,a.jsx)("div",{className:"text-sw-caption text-sw-text leading-relaxed whitespace-pre-line",children:t})]}):null},S=e=>{var s,t;let{data:n,runtimeEvents:r,thinkingSteps:i}=e,[c,d]=(0,l.useState)(!1),o=r.filter(e=>"thinking_step"===e.eventType),x=r.filter(e=>"thinking_step"!==e.eventType&&"assistant_message_final"!==e.eventType),m=function(e){let s=[],t=[];for(let n of e){var a,l;"receive"===(null!=(l=null==(a=n.payload)?void 0:a.phase)?l:"").toLowerCase()&&t.length>0&&(s.push(t),t=[]),t.push(n)}return t.length>0&&s.push(t),s}(o),u=null!=(t=m[m.length-1])?t:[],w=m.slice(0,-1),b=function(e){let s={};for(let t of e)s[t.phase]=t;return s}(i);return(0,a.jsxs)(h.av,{value:"trace",className:"flex-1 overflow-auto overscroll-contain px-sw-5 py-sw-4 space-y-5",children:[(()=>{var e;let s=null!=(e=n.guardrailResults)?e:[];if(0===s.length)return null;let t=s.some(e=>{var s,t;return(null==(s=e.decision)?void 0:s.toUpperCase())==="DENY"||(null==(t=e.decision)?void 0:t.toUpperCase())==="BLOCK"}),l=s.filter(e=>!e.passed).length;return t?(0,a.jsxs)("div",{className:"flex items-center gap-2 px-1 py-0.5","data-testid":"safety-outcome-blocked",children:[(0,a.jsx)(p.A,{size:14,className:"text-sw-error shrink-0"}),(0,a.jsx)("span",{className:"text-sw-body font-medium text-sw-error",children:"Blocked"})]}):l>0?(0,a.jsxs)("div",{className:"flex items-center gap-2 px-1 py-0.5","data-testid":"safety-outcome-flagged",children:[(0,a.jsx)(g.A,{size:14,className:"text-sw-warning-text shrink-0"}),(0,a.jsxs)("span",{className:"text-sw-body font-medium text-sw-warning-text",children:[l," check",l>1?"s":""," flagged"]})]}):(0,a.jsxs)("div",{className:"flex items-center gap-2 px-1 py-0.5","data-testid":"safety-outcome-passed",children:[(0,a.jsx)(f.A,{size:14,className:"text-sw-success-text shrink-0"}),(0,a.jsx)("span",{className:"text-sw-body font-medium text-sw-success-text",children:"All checks passed"})]})})(),(0,a.jsx)(_,{data:n}),r.length>0&&(0,a.jsxs)("div",{className:"space-y-2","data-testid":"governance-runtime-trace",children:[u.length>0&&(0,a.jsx)("div",{"data-testid":"governance-thinking-trace",children:(0,a.jsx)(j.u,{events:u.map(e=>{var s,t;return{payload:null!=(s=e.payload)?s:{},timestamp:null!=(t=e.timestamp)?t:new Date().toISOString()}}),thinkingStepMap:b})}),w.length>0&&(0,a.jsxs)(a.Fragment,{children:[c&&(0,a.jsx)("div",{className:"space-y-1 opacity-60",children:w.map((e,s)=>(0,a.jsx)("div",{children:(0,a.jsx)(j.u,{events:e.map(e=>{var s,t;return{payload:null!=(s=e.payload)?s:{},timestamp:null!=(t=e.timestamp)?t:new Date().toISOString()}}),thinkingStepMap:b})},s))}),(0,a.jsx)("button",{onClick:()=>d(e=>!e),className:"w-full sw-text-caption-muted hover:text-sw-text py-1 rounded-sw-sm border border-sw-border/40 hover:border-sw-border transition-colors",children:c?"Hide earlier turns":"See ".concat(w.length," earlier turn").concat(1!==w.length?"s":"")})]}),x.length>0&&(0,a.jsx)("div",{className:"space-y-0.5",children:x.map(e=>(0,a.jsx)("div",{className:"sw-text-caption-muted font-mono bg-sw-surface rounded-sw-sm px-2 py-1 truncate",children:(0,a.jsx)("span",{className:"text-sw-primary-text",children:e.eventType})},e.id))})]}),n.swTokens&&(0,a.jsx)(y,{breakdown:n.swTokens}
1),!n.swTokens&&(null==(s=n.executionTrace)?void 0:s.swtoken_ledger)&&(0,a.jsx)(y,{breakdown:{...n.executionTrace.swtoken_ledger.breakdown,total:n.executionTrace.swtoken_ledger.total}}),0===r.length&&0===i.length&&!n.swTokens&&(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center py-8 gap-sw-2 text-center",children:[(0,a.jsx)(f.A,{className:"w-5 h-5 text-sw-text-disabled"}),(0,a.jsx)("p",{className:"text-sw-body text-sw-text-muted",children:"No trace data available for this conversation yet."})]})]})};var C=t(11362),R=t(56154),T=t(79397),E=t(52056),M=t(4602);let D=e=>{var s,t,n;let{agentConfig:r}=e,[i,c]=(0,l.useState)(!1),[d,o]=(0,l.useState)("base"),x="business_assistant"===r.assistant_type?"SW Business Assistant":"Custom";return(0,a.jsxs)("div",{"data-testid":"agent-config-section",className:"space-y-3",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,a.jsx)("span",{className:"font-semibold text-sw-text",children:r.assistant_name}),(0,a.jsx)(u.E,{variant:"info",children:x}),r.is_locked&&(0,a.jsx)(u.E,{variant:"warning",children:"Locked"})]}),(r.persona_name||r.persona_tone)&&(0,a.jsxs)("div",{className:"sw-text-caption-muted space-y-1",children:[r.persona_name&&(0,a.jsxs)("p",{children:["Persona: ",(0,a.jsx)("span",{className:"text-sw-text",children:r.persona_name})]}),r.persona_tone&&(0,a.jsxs)("p",{children:["Tone: ",(0,a.jsx)("span",{className:"text-sw-text",children:r.persona_tone})]})]}),r.base_prompt&&(0,a.jsx)(m.$,{variant:"ghost",size:"sm",onClick:()=>c(!0),"aria-label":"Show full agent prompt",className:"h-auto p-0 text-sw-primary-text hover:underline",children:"Show full prompt"}),(0,a.jsx)(M.lG,{open:i,onOpenChange:c,children:(0,a.jsxs)(M.Cf,{size:"lg",padding:"none",className:"max-h-[80vh] overflow-hidden flex flex-col",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between px-sw-4 py-sw-3 border-b border-sw-border",children:[(0,a.jsx)(M.L3,{className:"font-semibold text-sw-text",children:"Agent Configuration"}),(0,a.jsx)(M.rr,{className:"sr-only",children:"View base prompt, persona augmentation, and merged system prompt for this agent."})]}),(0,a.jsxs)(h.tU,{value:d,onValueChange:e=>o(e),className:"flex flex-col flex-1 overflow-hidden",children:[(0,a.jsx)(h.j7,{className:"inline-flex h-auto items-center justify-start rounded-none border-b border-sw-border bg-transparent px-sw-4 gap-0",children:[{id:"base",label:"Base Prompt"},{id:"augmentation",label:"Persona Augmentation"},{id:"merged",label:"Merged (Final)"}].map(e=>(0,a.jsx)(h.Xi,{value:e.id,className:(0,w.cn)("px-sw-3 py-sw-2 text-sw-caption font-medium border-b-2 -mb-px transition-colors rounded-none bg-transparent shadow-none","data-[state=active]:border-sw-primary data-[state=active]:text-sw-primary data-[state=active]:bg-transparent","data-[state=inactive]:border-transparent data-[state=inactive]:text-sw-text-muted data-[state=inactive]:hover:text-sw-text"),children:e.label},e.id))}),(0,a.jsx)(h.av,{value:"base",className:"flex-1 overflow-auto p-sw-4 mt-0",children:(0,a.jsx)("pre",{className:"text-sw-caption text-sw-text whitespace-pre-wrap font-mono",children:null!=(s=r.base_prompt)?s:"(none)"})}),(0,a.jsx)(h.av,{value:"augmentation",className:"flex-1 overflow-auto p-sw-4 mt-0",children:(0,a.jsx)("pre",{className:"text-sw-caption text-sw-text whitespace-pre-wrap font-mono",children:null!=(t=r.persona_augmentation)?t:"(none)"})}),(0,a.jsx)(h.av,{value:"merged",className:"flex-1 overflow-auto p-sw-4 mt-0",children:(0,a.jsx)("pre",{className:"text-sw-caption text-sw-text whitespace-pre-wrap font-mono",children:null!=(n=r.merged_system_prompt)?n:"(none)"})})]})]})})]})},z={enforced:{color:"text-sw-error",textColor:"text-sw-error",bgColor:"bg-sw-error-bg",borderColor:"border-sw-error",icon:d.A},warning:{color:"text-sw-warning",textColor:"text-sw-warning-text",bgColor:"bg-sw-warning-bg",borderColor:"border-sw-warning",icon:E.A},info:{color:"text-sw-info",textColor:"text-sw-info-text",bgColor:"bg-sw-info-bg",borderColor:"border-sw-info",icon:v.A}},L=e=>{let{item:s,showValue:t=!1}=e,l=z[s.severity],n=l.icon;return(0,a.jsx)("div",{className:(0,w.cn)("p-sw-3 rounded-sw-md border",l.bgColor,l.borderColor,!s.enabled&&"opacity-50"),role:"listitem",children:(0,a.jsxs)("div",{className:"flex items-start gap-sw-2",children:[(0,a.jsx)(n,{className:(0,w.cn)("w-4 h-4 mt-0.5 flex-shrink-0",l.color)}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-sw-2",children:[(0,a.jsxs)("h4",{className:(0,w.cn)("font-medium text-sw-body",l.textColor),children:[s.name,!s.enabled&&(0,a.jsx)("span",{className:"ml-2 text-sw-caption opacity-70",children:"(disabled)"})]}),t&&"value"in s&&(0,a.jsx)("span",{className:(0,w.cn)("text-sw-caption font-mono px-sw-2 py-sw-1 rounded-sw-sm bg-sw-surface"),children:s.value})]}),(0,a.jsx)("p",{className:"sw-text-caption-muted mt-1",children:s.description}),"category"in s&&(0,a.jsxs)("p",{className:"sw-text-caption-muted mt-1",children:["Category: ",(0,a.jsx)("span",{className:"font-mono",children:s.category})]}),"scope"in s&&(0,a.jsxs)("p",{className:"sw-text-caption-muted mt-1",children:["Scope: ",(0,a.jsx)("span",{className:"font-mono",children:String(s.scope)})]})]})]})})};var P=t(57828),I=t(99708),F=t(5121);let O=(0,F.A)("ban",[["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]),U=(0,F.A)("message-square-off",[["path",{d:"M19 19H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.7.7 0 0 1 2 21.286V5a2 2 0 0 1 1.184-1.826",key:"1wyg69"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M8.656 3H20a2 2 0 0 1 2 2v11.344",key:"mhl4k6"}]]),G=(0,F.A)("languages",[["path",{d:"m5 8 6 6",key:"1wu5hv"}],["path",{d:"m4 14 6-6 2-3",key:"1k1g8d"}],["path",{d:"M2 5h12",key:"or177f"}],["path",{d:"M7 2h1",key:"1t2jsx"}],["path",{d:"m22 22-5-10-5 10",key:"don7ne"}],["path",{d:"M14 18h6",key:"1m8k6r"}]]),B=(0,F.A)("text-align-start",[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]]);var V=t(19408);let q={toxicity:E.A,pii_detection:P.A,detect_jailbreak:I.A,restricted_topics:O,allowed_topics:U,correct_language:G,string_check:B,competitor_check:V.A,unknown:f.A},H={toxicity:"Toxicity Detection",pii_detection:"PII Detection",detect_jailbreak:"Jailbreak Detection",restricted_topics:"Restricted Topics",allowed_topics:"Allowed Topics",correct_language:"Correct Language",string_check:"String Check",competitor_check:"Competitor Check",unknown:"Guardrail Check"},K=e=>{let{rules:s}=e;return 0===s.length?(0,a.jsxs)("div",{className:"text-center py-8 text-sw-text-muted",children:[(0,a.jsx)(f.A,{size:32,className:"mx-auto mb-2 opacity-50"}),(0,a.jsx)("p",{className:"text-sw-body",children:"No guardrail rules configured"})]}):(0,a.jsx)("div",{className:"space-y-3","data-testid":"active-guardrails-panel",children:s.map(e=>{var s,t,l,n,r;let i=null!=(n=q[e.type])?n:f.A,c=null!=(r=H[e.type])?r:e.type,d=function(e,s){let t=[];switch(e){case"toxicity":void 0!==s.threshold&&t.push("Threshold: ".concat(s.threshold)),s.val
1idation_method&&t.push("Method: ".concat(s.validation_method));break;case"pii_detection":Array.isArray(s.categories)&&t.push("Entities: ".concat(s.categories.join(", ")));break;case"restricted_topics":case"allowed_topics":Array.isArray(s.topics)&&t.push("Topics: ".concat(s.topics.join(", ")));break;case"string_check":Array.isArray(s.regex_pattern)&&t.push("Pattern: ".concat(s.regex_pattern.join(", ")));break;case"competitor_check":Array.isArray(s.competitor_names)&&t.push("Competitors: ".concat(s.competitor_names.join(", ")));break;case"correct_language":Array.isArray(s.language_codes)&&t.push("Language: ".concat(s.language_codes.join(", ")))}return t}(e.type,e.config),o=null==(s=e.lastResult)?void 0:s.passed,x=void 0!==e.lastResult;return(0,a.jsxs)("div",{className:(0,w.cn)("bg-sw-surface rounded-sw-md p-3 text-sw-body border-l-2",x&&o&&"border-sw-success",x&&!o&&"border-sw-primary",!x&&"border-sw-border"),children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-1.5",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(i,{size:14,className:"text-sw-text-muted"}),(0,a.jsx)("span",{className:"font-medium text-sw-text",children:c})]}),x&&(0,a.jsx)(u.E,{variant:o?"success":"error",icon:o?(0,a.jsx)(f.A,{size:10}):(0,a.jsx)(p.A,{size:10}),children:o?"passed":"violated"})]}),(0,a.jsx)("p",{className:"sw-caption text-sw-text-muted mb-1",children:e.name}),d.length>0&&(0,a.jsx)("div",{className:"space-y-0.5",children:d.map((e,s)=>(0,a.jsx)("p",{className:"sw-caption text-sw-text-muted font-mono",children:e},s))}),(null==(t=e.lastResult)?void 0:t.violations)&&e.lastResult.violations.length>0&&(0,a.jsx)("div",{className:"mt-1.5 space-y-0.5",children:e.lastResult.violations.map((e,s)=>(0,a.jsx)("p",{className:"sw-caption text-sw-error",children:e},s))}),(null==(l=e.lastResult)?void 0:l.timestamp)&&(0,a.jsx)("p",{className:"sw-caption text-sw-text-muted mt-1",children:new Date(e.lastResult.timestamp).toLocaleTimeString()})]},e.id)})})},X=e=>{var s,t,l,r,i,c,d,o,x,m,u,w,p,g,f,j,b,y,k,A,_,S,M,z,P;let{data:I,webSearchEnabled:F,trustStatus:O}=e,U=(null==O?void 0:O.thinking_enabled)!==void 0,G=(null==O?void 0:O.search_enabled)!==void 0||void 0!==F,B=U||G,V=(null!=(w=I.guardrailResults)?w:[]).map(e=>{var s,t,a;return{id:e.id,type:"unknown",name:null!=(t=null!=(s=e.name)?s:e.checkpoint)?t:"Guardrail Check",config:{},lastResult:void 0!==e.passed?{passed:e.passed,timestamp:new Date().toISOString(),violations:null!=(a=e.violations)?a:[],checkpoint:e.checkpoint,decision:e.decision}:void 0}}),q=I.agentConfig||(null!=(p=null==(s=I.guardianRules)?void 0:s.length)?p:0)>0||(null!=(g=null==(t=I.safetyPolicies)?void 0:t.length)?g:0)>0||(null!=(f=null==(l=I.capabilities)?void 0:l.length)?f:0)>0||(null!=(j=null==(r=I.limitations)?void 0:r.length)?j:0)>0||B||V.length>0;return(0,a.jsxs)(h.av,{value:"policy",className:"flex-1 overflow-auto overscroll-contain px-sw-5 py-sw-4 space-y-5",children:[!q&&(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center py-10 gap-2 text-center",children:[(0,a.jsx)(C.A,{className:"w-8 h-8 text-sw-text-disabled"}),(0,a.jsx)("p",{className:"text-sw-body text-sw-text-muted",children:"No policies active"}),(0,a.jsx)("p",{className:"text-sw-caption text-sw-text-disabled",children:"Policies will appear here when configured for this assistant."})]}),(I.agentConfig||(null!=(b=null==(i=I.guardianRules)?void 0:i.length)?b:0)>0)&&(0,a.jsxs)("div",{className:"flex items-center gap-2 px-1 py-0.5","data-testid":"rules-outcome-summary",children:[(0,a.jsx)(n.A,{size:14,className:"text-sw-text-muted shrink-0"}),(0,a.jsxs)("span",{className:"sw-text-body-default",children:[null!=(y=null==(c=I.agentConfig)?void 0:c.assistant_name)?y:"Default assistant",(null!=(k=null==(d=I.guardianRules)?void 0:d.length)?k:0)>0&&(0,a.jsxs)("span",{className:"text-sw-text-muted ml-1 font-normal",children:["\xb7 ",I.guardianRules.length," rule",I.guardianRules.length>1?"s":""," ","active"]})]})]}),I.agentConfig&&(0,a.jsx)("div",{"data-testid":"governance-persona",children:(0,a.jsx)(D,{agentConfig:I.agentConfig})}),B&&(0,a.jsxs)("div",{className:"flex items-center gap-sw-2 flex-wrap","data-testid":"trust-status-chips",children:[U&&(0,a.jsxs)("span",{className:"inline-flex items-center gap-1 text-sw-caption font-medium px-sw-2 py-sw-1 rounded-sw-sm ".concat(O.thinking_enabled?"bg-sw-info-bg text-sw-info-text":"bg-sw-surface text-sw-text-muted"),children:[(0,a.jsx)(R.A,{className:"w-3 h-3"}),"Thinking: ",O.thinking_enabled?"Active":"Off"]}),G&&(0,a.jsxs)("span",{"data-testid":"governance-web-search",className:"inline-flex items-center gap-1 text-sw-caption font-medium px-sw-2 py-sw-1 rounded-sw-sm ".concat((null!=(A=null==O?void 0:O.search_enabled)?A:F)?"bg-sw-success-bg text-sw-success-text":"bg-sw-surface text-sw-text-muted"),children:[(0,a.jsx)(T.A,{className:"w-3 h-3"}),"Search: ",(null!=(_=null==O?void 0:O.search_enabled)?_:F)?"Enabled":"Disabled"]})]}),V.length>0&&(0,a.jsxs)("div",{className:"bg-sw-surface rounded-sw-md p-sw-3 space-y-2 border border-sw-border/50",children:[(0,a.jsxs)("h4",{className:"text-sw-caption font-semibold text-sw-text flex items-center gap-1.5",children:[(0,a.jsx)(n.A,{className:"w-3 h-3 text-sw-primary-text"}),"Guardrail Results",(0,a.jsxs)("span",{className:"text-sw-text-muted font-normal",children:["(",V.length,")"]})]}),(0,a.jsx)(K,{rules:V})]}),(null!=(S=null==(o=I.guardianRules)?void 0:o.length)?S:0)>0&&(0,a.jsxs)("div",{className:"bg-sw-surface rounded-sw-md p-sw-3 space-y-2 border border-sw-border/50",children:[(0,a.jsxs)("h4",{className:"text-sw-caption font-semibold text-sw-text flex items-center gap-1.5",children:[(0,a.jsx)(n.A,{className:"w-3 h-3 text-sw-primary-text"}),"Safety Rules",(0,a.jsxs)("span",{className:"text-sw-text-muted font-normal",children:["(",I.guardianRules.length,")"]}),(0,a.jsx)(N.Bc,{children:(0,a.jsxs)(N.m_,{children:[(0,a.jsx)(N.k$,{asChild:!0,children:(0,a.jsx)(v.A,{size:12,className:"text-sw-text-muted cursor-help"})}),(0,a.jsx)(N.ZI,{children:"Enforced rules block the action. Warning rules flag it for review."})]})})]}),(0,a.jsx)("div",{className:"space-y-1",children:I.guardianRules.map(e=>(0,a.jsx)(L,{item:e},e.id))})]}),(null!=(M=null==(x=I.safetyPolicies)?void 0:x.length)?M:0)>0&&(0,a.jsxs)("div",{className:"bg-sw-surface rounded-sw-md p-sw-3 space-y-2 border border-sw-border/50",children:[(0,a.jsxs)("h4",{className:"text-sw-caption font-semibold text-sw-text flex items-center gap-1.5",children:[(0,a.jsx)(E.A,{className:"w-3 h-3 text-sw-warning"}),"Safety Policies",(0,a.jsxs)("span",{className:"text-sw-text-muted font-normal",children:["(",I.safetyPolicies.length,")"]})]}),(0,a.jsx)("div",{className:"space-y-1",children:I.safetyPolicies.map(e=>(0,a.jsx)(L,{item:e,showValue:!0},e.id))})]}),(null!=(z=null==(m=I.capabilities)?void 0:m.length)?z:0)>0&&(0,a.jsxs)("div",{className:"bg-sw-surface rounded-sw-md p-sw-3 space-y-2 border border-sw-border/50",children:[(0,a.jsxs)("h4",{className:"text-sw-caption font-semibold text-sw-text flex items-center gap-1.5 mb-1.5",children:[(0,a.jsx)(n.A,{className:"w-3 h-3 text-sw-primary-text"}),"Capabilities",(0,a.jsxs)("span",{className:"text-sw-text-muted font-normal",children:["(",I.capabilities.length,")"]})]}),I.capabilities.map(e=>(0,a.jsxs)("div",{className:"flex items-center justify-between text-sw-caption",children:[(0,a.jsx)("span",{className:"text-sw-text-muted",children:e.name}),(0,a.jsx)("span",{className:"font-medium ".concat(e.enabled?"text-sw-success-text":"text-sw-text-muted"),children:e.enabled?"Enabled":"Disabled"})]},e.id))]}),(null!=(P=null==(u=I.limitations)?void 0:u.length)?P:0)>0&&(0,a.jsxs)("div",{className:"bg-sw-surface rounded-sw-md p-sw-3 space-y-2 border border-sw-border/50",children:[(0,a.jsxs)("h4",{className:"text-sw-caption font-semibold text-sw-text flex items-center gap-1.5 mb-1.5",children:[(0,a.jsx)(E.A,{className:"w-3 h-3 text-sw-warning"}),"Limitations",(0,a.jsxs)("span",{className:"text-sw-text-muted font-normal",children:["(",I.limitations.length,")"]})]}),I.limitations.map(e=>(0,a.jsxs)("div",{className:"flex items-center justify-between text-sw-caption",children:[(0,a.jsx)("span",{className:"text-sw-text-muted",children:e.name}),(0,a.jsx)("span",{className:"text-sw-text font-medium",children:e.value})]},e.id))]})]})};var $=t(39068);let Q=(0,F.A)("brain-circuit",[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M9 13a4.5 4.5 0 0 0 3-4",key:"10igwf"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M12 13h4",key:"1ku699"}],["path",{d:"M12 18h6a2 2 0 0 1 2 2v1",key:"105ag5"}],["path",{d:"M12 8h8",key:"1lhi5i"}
1],["path",{d:"M16 8V5a2 2 0 0 1 2-2",key:"u6izg6"}],["circle",{cx:"16",cy:"13",r:".5",key:"ry7gng"}],["circle",{cx:"18",cy:"3",r:".5",key:"1aiba7"}],["circle",{cx:"20",cy:"21",r:".5",key:"yhc1fs"}],["circle",{cx:"20",cy:"8",r:".5",key:"1e43v0"}]]);var W=t(85710),Y=t(93499),Z=t(47937),J=t(86651),ee=t(12108),es=t(24033),et=t(66955);let ea=e=>{var s,t;let{data:n}=e,r="raw_queries"in n,[i,c]=(0,l.useState)(!r),d=r?n.intent:void 0,o=!r||n.searched,x=r?n.final_count:n.after_relevance_filter,m=r?n.filtered_count:n.filtering_details?n.filtering_details.by_relevance+n.filtering_details.by_guardrail:0,w=r&&null!=(s=n.raw_queries)?s:[],h=r&&null!=(t=n.source_types)?t:[];return(0,a.jsxs)("div",{className:"space-y-2","data-testid":"search-transparency-section",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>c(e=>!e),className:"w-full flex items-center justify-between text-sw-caption font-semibold text-sw-text hover:text-sw-primary-text transition-colors","aria-expanded":i,"aria-label":"Search transparency details",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[(0,a.jsx)(J.A,{className:"w-3 h-3"}),(0,a.jsx)("span",{children:"Search Transparency"})]}),i?(0,a.jsx)(ee.A,{className:"w-3 h-3"}):(0,a.jsx)(es.A,{className:"w-3 h-3"})]}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-2 text-sw-caption",children:[d&&(0,a.jsxs)(u.E,{variant:"default",children:["Intent: ",d]}),(0,a.jsx)(u.E,{variant:o?"info":"default",children:o?"Search performed":"Model sourced — no search"}),o&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(u.E,{variant:"success",children:[x," results"]}),m>0&&(0,a.jsxs)(u.E,{variant:"warning",children:[m," filtered"]})]})]}),i&&(0,a.jsxs)("div",{className:"space-y-3 pl-2 border-l-2 border-sw-border/50 mt-2",children:[w.length>0&&(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-sw-caption font-semibold text-sw-text-muted mb-1",children:"Queries"}),(0,a.jsx)("div",{className:"space-y-1",children:w.map((e,s)=>(0,a.jsxs)("div",{className:"text-sw-caption text-sw-text bg-sw-surface rounded-sw-sm px-2 py-1 font-mono truncate",children:['"',e,'"']},s))})]}),h.length>0&&(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)($.A,{className:"w-3 h-3 text-sw-text-muted flex-shrink-0"}),(0,a.jsxs)("span",{className:"sw-text-caption-muted",children:["Sources: ",h.join(", ")]})]}),!r&&(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-1 text-sw-caption",children:[(0,a.jsxs)("div",{className:"flex justify-between bg-sw-surface rounded-sw-sm px-2 py-1",children:[(0,a.jsx)("span",{className:"text-sw-text-muted",children:"Raw results:"}),(0,a.jsx)("span",{className:"text-sw-text font-mono",children:n.raw_results})]}),(0,a.jsxs)("div",{className:"flex justify-between bg-sw-surface rounded-sw-sm px-2 py-1",children:[(0,a.jsx)("span",{className:"text-sw-text-muted",children:"After dedup:"}),(0,a.jsx)("span",{className:"text-sw-text font-mono",children:n.after_dedup})]}),(0,a.jsxs)("div",{className:"flex justify-between bg-sw-surface rounded-sw-sm px-2 py-1",children:[(0,a.jsx)("span",{className:"text-sw-text-muted",children:"Final:"}),(0,a.jsx)("span",{className:"text-sw-success-text font-mono",children:n.after_relevance_filter})]}),void 0!==n.top_result_score&&(0,a.jsxs)("div",{className:"flex justify-between bg-sw-surface rounded-sw-sm px-2 py-1",children:[(0,a.jsx)("span",{className:"text-sw-text-muted",children:"Top score:"}),(0,a.jsx)("span",{className:"text-sw-text font-mono",children:n.top_result_score.toFixed(2)})]}),void 0!==n.min_score_threshold&&(0,a.jsxs)("div",{className:"flex justify-between bg-sw-surface rounded-sw-sm px-2 py-1",children:[(0,a.jsx)("span",{className:"text-sw-text-muted",children:"Min threshold:"}),(0,a.jsx)("span",{className:"text-sw-text font-mono",children:n.min_score_threshold.toFixed(2)})]})]}),n.filtering_details&&(0,a.jsxs)("details",{className:"mt-1",children:[(0,a.jsx)("summary",{className:"sw-text-caption-muted cursor-pointer hover:text-sw-text",children:"Filtering details"}),(0,a.jsxs)("div",{className:"mt-1 pl-2 space-y-0.5 border-l border-sw-border",children:[(0,a.jsxs)("div",{className:"sw-text-caption-muted flex justify-between",children:[(0,a.jsx)("span",{children:"Deduplicated:"}),(0,a.jsx)("span",{children:n.filtering_details.deduped})]}),(0,a.jsxs)("div",{className:"sw-text-caption-muted flex justify-between",children:[(0,a.jsx)("span",{children:"Below relevance threshold:"}),(0,a.jsx)("span",{children:n.filtering_details.by_relevance})]}),(0,a.jsxs)("div",{className:"sw-text-caption-muted flex justify-between",children:[(0,a.jsx)("span",{children:"Guardrail violations:"}),(0,a.jsx)("span",{children:n.filtering_details.by_guardrail})]})]})]})]}),r&&o&&(0,a.jsxs)("div",{children:[(0,a.jsxs)("p",{className:"text-sw-caption font-semibold text-sw-text-muted mb-1",children:[(0,a.jsx)(et.A,{className:"w-3 h-3 inline mr-1"}),"Filtering"]}),(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-1 text-sw-caption",children:[(0,a.jsxs)("div",{className:"flex justify-between bg-sw-surface rounded-sw-sm px-2 py-1",children:[(0,a.jsx)("span",{className:"text-sw-text-muted",children:"Fetched:"}),(0,a.jsx)("span",{className:"text-sw-text font-mono",children:n.total_fetched}
1)]}),n.dedup_count>0&&(0,a.jsxs)("div",{className:"flex justify-between bg-sw-surface rounded-sw-sm px-2 py-1",children:[(0,a.jsx)("span",{className:"text-sw-text-muted",children:"Deduped:"}),(0,a.jsxs)("span",{className:"text-sw-warning-text font-mono",children:["-",n.dedup_count]})]}),m>0&&(0,a.jsxs)("div",{className:"flex justify-between bg-sw-surface rounded-sw-sm px-2 py-1",children:[(0,a.jsx)("span",{className:"text-sw-text-muted",children:"Filtered:"}),(0,a.jsxs)("span",{className:"text-sw-warning-text font-mono",children:["-",m]})]}),(0,a.jsxs)("div",{className:"flex justify-between bg-sw-surface rounded-sw-sm px-2 py-1",children:[(0,a.jsx)("span",{className:"text-sw-text-muted",children:"Final:"}),(0,a.jsx)("span",{className:"text-sw-success-text font-mono",children:x})]}),void 0!==n.relevance_threshold&&(0,a.jsxs)("div",{className:"flex justify-between bg-sw-surface rounded-sw-sm px-2 py-1",children:[(0,a.jsx)("span",{className:"text-sw-text-muted",children:"Threshold:"}),(0,a.jsx)("span",{className:"text-sw-text font-mono",children:n.relevance_threshold})]})]})]})]})]})},el=e=>{let{source:s,url:t,relevance:l,sourceType:n}=e,r=function(e){if(e)try{let s=new URL(e);return"http:"===s.protocol||"https:"===s.protocol?e:void 0}catch(e){return}}(t);return(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2 py-1 group",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0 flex-1",children:["web"===n?(0,a.jsx)($.A,{size:12,className:"shrink-0 text-sw-info-text"}):"memory"===n?(0,a.jsx)(Q,{size:12,className:"shrink-0 text-sw-warning-text"}):(0,a.jsx)(W.A,{size:12,className:"shrink-0 text-sw-text-muted"}),r?(0,a.jsxs)("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:"text-sw-caption text-sw-primary-text hover:underline truncate flex items-center gap-1",title:r,children:[(0,a.jsx)("span",{className:"truncate",children:s}),(0,a.jsx)(Y.A,{size:10,className:"shrink-0 opacity-0 group-hover:opacity-100 transition-opacity"})]}):(0,a.jsx)("span",{className:"text-sw-caption text-sw-text truncate",children:s})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[n&&(0,a.jsx)(u.E,{variant:"web"===n?"info":"memory"===n?"warning":"default",children:n}),null!=l&&(0,a.jsxs)("span",{className:"sw-text-caption-muted tabular-nums w-8 text-right",children:[Math.round(100*l),"%"]})]})]})},en=e=>{var s;let{data:t,searchTransparency:l}=e,n=null!=(s=t.knowledgeRetrievals)?s:[],r=t.searchTransparency,i=[...n].sort((e,s)=>{var t,a;return(null!=(t=s.relevance)?t:0)-(null!=(a=e.relevance)?a:0)}),c=i.filter(e=>"web"===e.sourceType),d=i.filter(e=>"knowledge"===e.sourceType||"memory"===e.sourceType),o=n.length>0;return(0,a.jsxs)(h.av,{value:"search",className:"flex-1 overflow-auto overscroll-contain px-sw-5 py-sw-4 space-y-5",children:[o?(0,a.jsx)("div",{className:"px-sw-3 py-sw-2 rounded-sw-md bg-sw-surface border border-sw-border/50","data-testid":"sources-outcome-row",children:(0,a.jsxs)("div",{className:"space-y-1",children:[d.length>0&&(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(Z.A,{size:14,className:"shrink-0 text-sw-text-muted"}),(0,a.jsxs)("span",{className:"text-sw-body font-medium text-sw-text",children:[d.length," knowledge source",1!==d.length?"s":""]})]}),c.length>0&&(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)($.A,{size:14,className:"shrink-0 text-sw-text-muted"}),(0,a.jsxs)("span",{className:"text-sw-body font-medium text-sw-text",children:[c.length," web source",1!==c.length?"s":""]})]})]})}):(null==r?void 0:r.searched)===!1?(0,a.jsx)("div",{className:"px-sw-3 py-sw-2 rounded-sw-md bg-sw-surface border border-sw-border/50","data-testid":"sources-outcome-row",children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(Q,{size:14,className:"shrink-0 text-sw-text-muted"}),(0,a.jsx)("span",{className:"text-sw-body text-sw-text-muted",children:"No search — answered from model knowledge"})]})}):t.externalResearchUsed&&0===n.length?(0,a.jsx)("div",{className:"px-sw-3 py-sw-2 rounded-sw-md bg-sw-surface border border-sw-border/50","data-testid":"sources-outcome-row",children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)($.A,{size:14,className:"shrink-0 text-sw-text-muted"}),(0,a.jsx)("span",{className:"sw-text-body-default",children:"Web search was used"})]})}):null,l?(0,a.jsx)("div",{"data-testid":"governance-search-transparency",children:(0,a.jsx)(ea,{data:l})}):null,o&&(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("h4",{className:"text-sw-caption font-semibold text-sw-text flex items-center gap-1.5",children:[(0,a.jsx)(J.A,{className:"w-3 h-3 text-sw-primary-text"}),"Sources",(0,a.jsxs)("span",{className:"text-sw-text-muted font-normal",children:["(",n.length,")"]})]}),(0,a.jsx)("div",{className:"divide-y divide-sw-border/30",children:i.map(e=>(0,a.jsx)(el,{source:e.source,url:e.url,relevance:e.relevance,sourceType:e.sourceType},e.id))})]}),!l&&!o&&!t.externalResearchUsed&&(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center py-8 gap-sw-2 text-center",children:[(0,a.jsx)(J.A,{className:"w-5 h-5 text-sw-text-disabled"}),(0,a.jsx)("p",{className:"text-sw-body text-sw-text-muted",children:"No search activity for this conversation."})]})]})};var er=t(78874),ei=t(20508),ec=t(53842),ed=t(5917),eo=t(27937);let ex=e=>{let{level:s,failCount:t}=e,l="fail"===s,n="warn"===s,r=l?"text-sw-error":n?"text-sw-warning-text":"text-sw-success-text",i=l?"Response blocked":n?"".concat(t," check").concat(1!==t?"s":""," flagged"):"Protected";return(0,a.jsxs)("div",{className:(0,w.cn)("flex items-center gap-sw-3 rounded-sw-lg border p-sw-3 mb-sw-4",l?"bg-sw-error-bg border-sw-error":n?"bg-sw-warning-bg border-sw-warning":"bg-sw-success-bg border-sw-success"),children:[(0,a.jsx)("div",{className:(0,w.cn)("w-8 h-8 rounded-sw-full border-2 flex items-center justify-center shrink-0",l?"border-sw-error":n?"border-sw-warning":"border-sw-success"),"aria-hidden":"true",children:l?(0,a.jsx)(er.A,{className:(0,w.cn)("w-4 h-4",r)}):n?(0,a.jsx)(g.A,{className:(0,w.cn)("w-4 h-4",r)}):(0,a.jsx)(f.A,{className:(0,w.cn)("w-4 h-4",r)})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:(0,w.cn)("font-semibold sw-text-body-small",l?"text-sw-error":n?"text-sw-warning-text":"text-sw-success-text"),children:i}),(0,a.jsx)("p",{className:"sw-text-caption text-sw-text-muted mt-0.5",children:l?"A safety guardrail prevented this response":n?"Re
1sponse allowed \xb7 review recommended":"All governance controls active"})]})]})},em=e=>{let{icon:s,label:t,sub:l,status:n,chipLabel:r}=e;return(0,a.jsxs)("div",{className:"flex items-center gap-sw-3 px-sw-3 py-sw-3 border-b border-sw-border last:border-0",children:[(0,a.jsx)("div",{className:(0,w.cn)("w-7 h-7 rounded-sw-sm flex items-center justify-center shrink-0","fail"===n?"bg-sw-error-bg text-sw-error border border-sw-error/20":"warn"===n?"bg-sw-warning-bg text-sw-warning-text border border-sw-warning/20":"ok"===n?"bg-sw-success-bg text-sw-success-text border border-sw-success/20":"bg-sw-surface text-sw-text-muted border border-sw-border"),"aria-hidden":"true",children:s}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"sw-text-body-small font-medium text-sw-text",children:t}),(0,a.jsx)("p",{className:"sw-text-caption text-sw-text-muted",children:l})]}),(0,a.jsx)(u.E,{variant:"ok"===n?"success":"warn"===n?"warning":"fail"===n?"error":"default",className:"shrink-0",children:r})]})},eu=e=>{let{data:s,webSearchEnabled:t}=e,l=function(e,s){var t,l,n,r,i,c;let d=e.trustStatus,o=(null==d?void 0:d.search_enabled)!==void 0?d.search_enabled:s,x=null!=(r=null==(t=e.knowledgeRetrievals)?void 0:t.length)?r:0,m=null!=(i=e.guardrailResults)?i:[],u=m.filter(e=>!e.passed).length,w=m.filter(e=>e.passed).length,h=null!=(c=null==(l=e.agentConfig)?void 0:l.assistant_name)?c:"SW Business Assistant",p=null==(n=e.agentConfig)?void 0:n.persona_name,g=e.policyRetention?"Kept ".concat(e.policyRetention):"Standard retention",j=u>0?"".concat(u," check").concat(1!==u?"s":""," flagged"):w>0?"".concat(w," check").concat(1!==w?"s":""," passed"):"Input & output checked",v=[x>0?"".concat(x," source").concat(1!==x?"s":""," used"):"No external sources",!0===o?"+ web search":!1===o?"web search off":null].filter(Boolean).join(" \xb7 ");return[{icon:(0,a.jsx)(ei.A,{className:"w-3.5 h-3.5"}),label:"Assistant",sub:p?"".concat(h," \xb7 ").concat(p):h,status:"neutral",chipLabel:"Default"},{icon:(0,a.jsx)(f.A,{className:"w-3.5 h-3.5"}),label:"Safety",sub:j,status:u>0?"fail":w>0?"ok":"neutral",chipLabel:u>0?"✕ Blocked":w>0?"✓ Passed":"Default"},{icon:(0,a.jsx)(W.A,{className:"w-3.5 h-3.5"}),label:"Your data",sub:"Org-only \xb7 isolated to your account",status:"ok",chipLabel:"✓ Secure"},{icon:(0,a.jsx)(Z.A,{className:"w-3.5 h-3.5"}),label:"Knowledge",sub:v||"Org knowledge available",status:x>0?"ok":"neutral",chipLabel:x>0?"✓ Active":"Default"},{icon:(0,a.jsx)(ec.A,{className:"w-3.5 h-3.5"}),label:"Boundaries",sub:"No actions without your approval",status:"ok",chipLabel:"✓ Enforced"},{icon:(0,a.jsx)(b.A,{className:"w-3.5 h-3.5"}),label:"Retention",sub:g,status:"neutral",chipLabel:"Default"}]}(s,t);return(0,a.jsx)("div",{className:"rounded-sw-md border border-sw-border bg-sw-background mb-sw-4 overflow-hidden",children:l.map(e=>(0,a.jsx)(em,{...e},e.label))})},ew=e=>{var s,t;let{data:l}=e,n=function(e,s){let t=[],l=e.find(e=>"safety"===e.phase||"guardrail"===e.phase);if(s.length>0||l){let e=s.filter(e=>!e.passed).length,l=s.filter(e=>e.passed).length;t.push({label:e>0?"Safety: ".concat(e," flagged"):l>0?"Safety: ".concat(l," passed"):"Safety checked",status:e>0?"fail":"ok",icon:e>0?(0,a.jsx)(g.A,{className:"w-3 h-3 text-sw-error"}):(0,a.jsx)(f.A,{className:"w-3 h-3 text-sw-success-text"})})}let n=e.find(e=>"search"===e.phase||"retrieve"===e.phase||"knowledge"===e.phase);if(n){var r,i;let e=null!=(i=null!=(r=n.evidence_found)?r:n.queries_extracted)?i:0;t.push({label:e>0?"Retrieved ".concat(e," source").concat(1!==e?"s":""):"Searched knowledge",status:"ok",icon:(0,a.jsx)(Z.A,{className:"w-3 h-3 text-sw-text-muted"})})}return e.find(e=>"reason"===e.phase||"synthesize"===e.phase||"answer"===e.phase)&&t.push({label:"Response composed",status:"ok",icon:(0,a.jsx)(Q,{className:"w-3 h-3 text-sw-text-muted"})}),t.push({label:"No actions without you",status:"ok",icon:(0,a.jsx)(ec.A,{className:"w-3 h-3 text-sw-text-muted"})}),t}(null!=(s=l.thinkingSteps)?s:[],null!=(t=l.guardrailResults)?t:[]);return 0===n.length?null:(0,a.jsxs)("div",{className:"mt-sw-4","aria-label":"This turn",children:[(0,a.jsx)("p",{className:"sw-text-caption font-semibold text-sw-text-muted uppercase tracking-wider mb-sw-2",children:"This turn"}),(0,a.jsx)("div",{className:"flex flex-col gap-sw-2",children:n.map((e,s)=>(0,a.jsxs)("div",{className:"flex items-center gap-sw-2",children:[(0,a.jsx)("div",{className:(0,w.cn)("w-5 h-5 rounded-sw-full border-2 flex items-center justify-center shrink-0","fail"===e.status?"border-sw-error bg-sw-error-bg":"warn"===e.status?"border-sw-warning bg-sw-warning-bg":"border-sw-success bg-sw-success-bg"),"aria-hidden":"true",children:(0,a.jsx)(ed.A,{className:(0,w.cn)("w-3 h-3","fail"
1===e.status?"text-sw-error":"warn"===e.status?"text-sw-warning-text":"text-sw-success-text")})}),(0,a.jsxs)("span",{className:"flex items-center gap-1",children:[(0,a.jsx)("span",{className:"shrink-0",children:e.icon}),(0,a.jsx)("span",{className:(0,w.cn)("sw-text-caption","fail"===e.status?"text-sw-error":"warn"===e.status?"text-sw-warning-text":"text-sw-text"),children:e.label})]})]},s))})]})},eh=e=>{var s,t;let{data:r}=e,[i,c]=(0,l.useState)(!1),d=null!=(s=r.guardianRules)?s:[],o=null!=(t=r.safetyPolicies)?t:[],x=d.length+o.length;return 0===x?null:(0,a.jsxs)("div",{className:"mt-sw-4 border-t border-sw-border pt-sw-3",children:[(0,a.jsxs)("button",{type:"button",className:"flex items-center justify-between w-full sw-text-caption font-medium text-sw-text",onClick:()=>c(!i),"aria-expanded":i,children:[(0,a.jsxs)("span",{className:"flex items-center gap-sw-1",children:[(0,a.jsx)(T.A,{className:"w-3.5 h-3.5 text-sw-text-muted"}),"Rules & policies"]}),(0,a.jsxs)("span",{className:"flex items-center gap-1 text-sw-text-muted",children:[(0,a.jsx)("span",{className:"sw-text-caption",children:x}),i?(0,a.jsx)(es.A,{className:"w-3 h-3"}):(0,a.jsx)(eo.A,{className:"w-3 h-3"})]})]}),i&&(0,a.jsxs)("div",{className:"mt-sw-2 space-y-sw-1",children:[d.map(e=>(0,a.jsxs)("div",{className:"flex items-start gap-sw-2 py-0.5",children:[(0,a.jsx)(f.A,{className:"w-3 h-3 text-sw-success-text shrink-0 mt-0.5"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("span",{className:"sw-text-caption font-medium text-sw-text",children:e.name}),e.description&&(0,a.jsx)("p",{className:"sw-text-caption text-sw-text-muted",children:e.description})]})]},e.id)),o.map(e=>(0,a.jsxs)("div",{className:"flex items-start gap-sw-2 py-0.5",children:[(0,a.jsx)(n.A,{className:"w-3 h-3 text-sw-text-muted shrink-0 mt-0.5"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("span",{className:"sw-text-caption font-medium text-sw-text",children:e.name}),void 0!==e.value&&(0,a.jsxs)("span",{className:"ml-1 sw-text-caption text-sw-text-muted",children:["\xb7 ",String(e.value)]})]})]},e.id))]})]})},ep=e=>{var s;let{data:t}=e,[n,r]=(0,l.useState)(!1),i=null!=(s=t.knowledgeRetrievals)?s:[];return 0===i.length?null:(0,a.jsxs)("div",{className:"mt-sw-3 border-t border-sw-border pt-sw-3",children:[(0,a.jsxs)("button",{type:"button",className:"flex items-center justify-between w-full sw-text-caption font-medium text-sw-text",onClick:()=>r(!n),"aria-expanded":n,children:[(0,a.jsxs)("span",{className:"flex items-center gap-sw-1",children:[(0,a.jsx)(Z.A,{className:"w-3.5 h-3.5 text-sw-text-muted"}),"Sources used"]}),(0,a.jsxs)("span",{className:"flex items-center gap-1 text-sw-text-muted",children:[(0,a.jsx)("span",{className:"sw-text-caption",children:i.length}),n?(0,a.jsx)(es.A,{className:"w-3 h-3"}):(0,a.jsx)(eo.A,{className:"w-3 h-3"})]})]}),n&&(0,a.jsx)("div",{className:"mt-sw-2 space-y-0.5",children:i.map(e=>(0,a.jsxs)("div",{className:"flex items-center gap-sw-1 py-0.5",children:["web"===e.sourceType?(0,a.jsx)($.A,{className:"w-3 h-3 text-sw-info-text shrink-0"}):"memory"===e.sourceType?(0,a.jsx)(Q,{className:"w-3 h-3 text-sw-warning-text shrink-0"}):(0,a.jsx)(W.A,{className:"w-3 h-3 text-sw-text-muted shrink-0"}),(0,a.jsx)("span",{className:"sw-text-caption text-sw-text-muted truncate",children:e.source}),null!=e.relevance&&(0,a.jsxs)("span",{className:"sw-text-caption text-sw-text-disabled ml-auto shrink-0",children:[Math.round(100*e.relevance),"%"]})]},e.id))})]})},eg=e=>{var s;let{data:t}=e,[n,r]=(0,l.useState)(!1),i=null!=(s=t.thinkingSteps)?s:[];return 0===i.length?null:(0,a.jsxs)("div",{className:"mt-sw-3 border-t border-sw-border pt-sw-3",children:[(0,a.jsxs)("button",{type:"button",className:"flex items-center justify-between w-full sw-text-caption font-medium text-sw-text",onClick:()=>r(!n),"aria-expanded":n,children:[(0,a.jsxs)("span",{className:"flex items-center gap-sw-1",children:[(0,a.jsx)(Q,{className:"w-3.5 h-3.5 text-sw-text-muted"}),"Reasoning steps"]}),(0,a.jsxs)("span",{className:"flex items-center gap-1 text-sw-text-muted",children:[(0,a.jsx)("span",{className:"sw-text-caption",children:i.length}),n?(0,a.jsx)(es.A,{className:"w-3 h-3"}):(0,a.jsx)(eo.A,{className:"w-3 h-3"})]})]}),n&&(0,a.jsx)("div",{className:"mt-sw-2 space-y-sw-1",children:i.map((e,s)=>(0,a.jsxs)("div",{className:"flex items-start gap-sw-2 py-0.5",children:[(0,a.jsxs)("span",{className:"sw-text-caption text-sw-text-disabled 
1w-4 shrink-0 text-right",children:[s+1,"."]}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("span",{className:"sw-text-caption font-medium text-sw-text capitalize",children:e.phase}),e.substep&&(0,a.jsxs)("span",{className:"sw-text-caption text-sw-text-muted",children:[" \xb7 ",e.substep]}),null!=e.latency_ms&&(0,a.jsxs)("span",{className:"sw-text-caption text-sw-text-disabled ml-1",children:[e.latency_ms,"ms"]})]})]},s))})]})},ef=e=>{var s,t,l;let{data:n,drawerState:r,webSearchEnabled:i,onViewTechnicalDetails:c}=e,d=function(e){var s,t,a;let l=null!=(s=e.guardrailResults)?s:[],n=null!=(t=e.policyDecisions)?t:[],r=null!=(a=e.policyAlerts)?a:[];return l.some(e=>!e.passed)||n.some(e=>"DENY"===e.decision)||r.some(e=>"critical"===e.severity)?"fail":n.some(e=>"REQUIRE_APPROVAL"===e.decision||"REQUIRE_REDACTION"===e.decision)||r.some(e=>"warning"===e.severity)?"warn":"ok"}(n),o=null!=(s=n.guardrailResults)?s:[],x=null!=(t=n.policyDecisions)?t:[],m=null!=(l=n.policyAlerts)?l:[],u=o.filter(e=>!e.passed).length+x.filter(e=>"DENY"===e.decision).length,w=x.filter(e=>"REQUIRE_APPROVAL"===e.decision||"REQUIRE_REDACTION"===e.decision).length+m.filter(e=>"warning"===e.severity).length;return(0,a.jsxs)(h.av,{value:"trust",className:"flex-1 overflow-auto overscroll-contain px-sw-5 py-sw-4",children:[(0,a.jsx)(ex,{level:d,failCount:"warn"===d?w:u}),(0,a.jsx)(eu,{data:n,webSearchEnabled:i}),(0,a.jsx)(ew,{data:n}),"PINNED"===r?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eh,{data:n}),(0,a.jsx)(ep,{data:n}),(0,a.jsx)(eg,{data:n})]}):c&&(0,a.jsxs)("button",{type:"button",onClick:c,className:"flex items-center gap-1 mt-sw-4 sw-text-caption text-sw-text-muted hover:text-sw-text transition-colors",children:["View technical details",(0,a.jsx)(eo.A,{className:"w-3 h-3"})]})]})};var ej=t(20063),eb=t(37586),ev=t(18085),eN=t(54130),ey=t(11534),ek=t(88732),eA=t(88376),e_=t(40051),eS=t(95382),eC=t(25840),eR=t(75444);let eT=()=>{let{userId:e}=(0,eR.S)(),s=(0,ej.usePathname)(),[t,n]=(0,l.useState)(null),[r,i]=(0,l.useState)([]),[c,d]=(0,l.useState)(!0),[o,x]=(0,l.useState)(!1),[u,w]=(0,l.useState)(0),[h,p]=(0,l.useState)(""),[g,f]=(0,l.useState)(!1),[j,b]=(0,l.useState)(!1),v=(0,l.useRef)(null),N=(0,l.useCallback)(()=>{},[]);(0,l.useEffect)(()=>{let e=!1;return d(!0),x(!1),(async()=>{try{let s=await A.getMySageThread();if(e)return;n(s.conversationId);let t=await A.getConversationMessages(s.conversationId,{limit:100});if(e)return;i([...t.messages].reverse())}catch(s){e||x(!0)}finally{e||d(!1)}})(),()=>{e=!0}},[u]);let y=(0,l.useCallback)(async()=>{let e=h.trim();if(e&&!g){f(!0),b(!1);try{let t=await A.postMySageMessage(e,null!=s?s:void 0);i(e=>[...e,A.mapMessage(t.userMessage),A.mapMessage(t.assistantMessage)]),p("")}catch(e){b(!0)}finally{f(!1)}}},[h,g,s]),k=(0,l.useCallback)((s,t)=>(0,a.jsx)(ey.D,{message:s,conversationType:"chat",currentUserId:e,showSenderAvatar:!0,isLastMessage:t===r.length-1}),[e,r.length]),_=(0,l.useCallback)(()=>null,[]);return c?(0,a.jsxs)("div",{className:"px-sw-5 py-sw-4 space-y-2","aria-busy":"true","aria-label":"Loading Sage",children:[(0,a.jsx)(e_.vT,{}),(0,a.jsx)(e_.vT,{})]}):o||!t?(0,a.jsx)("div",{className:"px-sw-5 py-sw-4",children:(0,a.jsx)(eS.Z,{variant:"error",actions:[{label:"Retry",onClick:()=>w(e=>e+1)}],children:"Couldn't load Sage."})}):(0,a.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,a.jsx)("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:0===r.length?(0,a.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,a.jsx)(eA.p,{icon:eb.A,title:"Ask Sage",description:"Sage can help you understand the product and your account. Send a message to get started.",testId:"sage-panel-empty"})}):(0,a.jsx)(ek.i,{readOnly:!0,children:(0,a.jsx)("div",{className:"flex-1 min-h-0",children:(0,a.jsx)(eN.t,{messages:r,renderRow:k,renderTrailing:_,endRef:v,onScrollElReady:N,colClass:"px-sw-4"})})})}),(0,a.jsxs)("div",{className:"shrink-0 border-t border-sw-border p-sw-3 space-y-2",children:[j&&(0,a.jsx)("p",{className:"text-sw-caption text-sw-error",role:"alert",children:"Couldn't send that message. Try again."}),(0,a.jsxs)("div",{className:"flex items-end gap-2",children:[(0,a.jsx)(eC.T,{"aria-label":"Message Sage",placeholder:"Ask Sage about the product or your account…",value:h,onChange:e=>p(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),y())},textareaSize:"sm",className:"flex-1",disabled:g}),(0,a.jsx)(m.$,{variant:"primary",size:"sm",onClick:()=>void y(),disabled:g||0===h.trim().length,"aria-label":"Send message to Sage",children:(0,a.jsx)(ev.A,{size:14})})]})]})]})},eE=()=>(0,a.jsx)(h.av,{value:"sage",className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:(0,a.jsx)(eT,{})}),eM=e=>{var s,t,p,g,f,j;let{drawerState:b,entityType:v,entityId:N,entityLabel:y,data:k,onClose:A,onPin:_,onFullPanel:C,isLoading:R,error:T,onRetry:E,canViewGovernanceInternals:M=!0,enableSage:D=!1}=e,z="PINNED"===b,L=(0,l.useRef)(null),P=(0,l.useRef)(null);if((0,l.useEffect)(()=>
1{if("COLLAPSED"===b)return;P.current=document.activeElement;let e=setTimeout(()=>{if(!L.current)return;let e=L.current.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');null==e||e.focus()},200);return()=>clearTimeout(e)},[b]),(0,l.useEffect)(()=>{if("COLLAPSED"===b)return;let e=e=>{if("Escape"===e.key){var s;null==(s=P.current)||s.focus(),A()}};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[b,A]),"COLLAPSED"===b)return null;let I=null!=(p=k.runtimeEvents)?p:[],F=k.searchTransparency,O=null!=(g=k.thinkingSteps)?g:[],U=k.webSearchEnabled,G=k.trustStatus,B=(0,l.useMemo)(()=>"trust",[]),[V,q]=(0,l.useState)(B),H=(null!=(f=null==(s=k.guardianRules)?void 0:s.filter(e=>"enforced"===e.severity).length)?f:0)+(null!=(j=null==(t=k.safetyPolicies)?void 0:t.filter(e=>"enforced"===e.severity).length)?j:0),K=null!=k.searchTransparency,$=(0,w.cn)("px-sw-3 py-sw-2 text-xs font-medium border-b-2 -mb-px transition-colors rounded-none bg-transparent shadow-none","data-[state=active]:border-sw-primary data-[state=active]:text-sw-primary data-[state=active]:bg-transparent","data-[state=inactive]:border-transparent data-[state=inactive]:text-sw-text-muted data-[state=inactive]:hover:text-sw-text");return(0,a.jsxs)("aside",{ref:L,role:"complementary","aria-label":"Governance panel",className:"flex-1 min-h-0 flex flex-col bg-sw-background border-l border-sw-border",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between px-sw-4 py-sw-3 border-b border-sw-border",children:[(0,a.jsxs)("div",{className:"flex items-center gap-sw-2",children:[(0,a.jsx)(n.A,{className:"w-4 h-4 text-sw-primary-text"}),(0,a.jsx)("span",{className:"font-semibold sw-text-body-default",children:x.title})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[_&&(0,a.jsx)("button",{type:"button",onClick:_,"aria-label":z?"Unpin drawer":"Pin drawer","aria-pressed":z,className:"hidden sm:flex items-center justify-center p-1 min-h-11 min-w-11 rounded hover:bg-sw-surface",children:(0,a.jsx)(r.A,{className:"w-4 h-4 text-sw-text-muted"})}),C&&(0,a.jsx)("button",{type:"button",onClick:C,"aria-label":"Expand to full panel",className:"hidden sm:flex items-center justify-center p-1 min-h-11 min-w-11 rounded hover:bg-sw-surface",children:(0,a.jsx)(i.A,{className:"w-4 h-4 text-sw-text-muted"})}),(0,a.jsx)("button",{type:"button",onClick:()=>{var e;null==(e=P.current)||e.focus(),A()},className:"flex items-center justify-center p-1 min-h-11 min-w-11 rounded hover:bg-sw-surface","aria-label":"Close Governance panel",children:(0,a.jsx)(c.A,{className:"w-4 h-4 text-sw-text-muted"})})]})]}),(0,a.jsxs)("div",{className:"flex-1 overflow-hidden flex flex-col",children:[R&&(0,a.jsxs)("div",{className:"px-sw-5 py-sw-4 space-y-2","aria-busy":"true","aria-live":"polite","aria-label":"Loading governance data",children:[(0,a.jsx)("div",{className:"h-4 bg-sw-surface rounded animate-pulse w-3/4"}),(0,a.jsx)("div",{className:"h-4 bg-sw-surface rounded animate-pulse w-1/2"}),(0,a.jsx)("div",{className:"h-4 bg-sw-surface rounded animate-pulse w-2/3"})]}),!R&&T&&(0,a.jsx)("div",{className:"p-sw-4 rounded-sw-md bg-sw-error-bg border border-sw-error",children:(0,a.jsxs)("div",{className:"flex items-start gap-sw-2",children:[(0,a.jsx)(d.A,{className:"w-5 h-5 text-sw-error mt-0.5 shrink-0"}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("h3",{className:"font-semibold text-sw-body text-sw-error",children:"Failed to load governance data"}),(0,a.jsx)("p",{className:"text-sw-caption text-sw-error mt-1",children:T}),E&&(0,a.jsxs)(m.$,{variant:"secondary",size:"sm",onClick:E,className:"mt-3",children:[(0,a.jsx)(o.A,{className:"w-3 h-3 mr-1"}),"Retry"]})]})]})}),!R&&!T&&null===N&&(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center h-full gap-3 px-sw-5 text-center",children:[(0,a.jsx)(n.A,{className:"w-8 h-8 text-sw-text-disabled shrink-0"}),(0,a.jsx)("p",{className:"text-sw-body text-sw-text-muted text-sw-body",children:"Select a message to see its response details."})]}),!R&&!T&&null!==N&&(0,a.jsxs)(a.Fragment,{children:[y&&(0,a.jsx)("p",{className:"sw-text-caption-muted px-sw-5 pt-sw-3",children:y}),(0,a.jsxs)(h.tU,{value:V,onValueChange:e=>q(e),className:"flex flex-col flex-1 overflow-hidden",children:[(0,a.jsxs)(h.j7,{className:"inline-flex h-auto items-center justify-start rounded-none border-b border-sw-border bg-transparent px-sw-4 gap-0 shrink-0",children:[(0,a.jsx)(h.Xi,{value:"trust",className:$,children:x.tabs.trust}),M&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(h.Xi,{value:"trace",className:$,children:x.tabs.trace}),(0,a.jsxs)(h.Xi,{value:"policy",className:$,children:[x.tabs.policy,H>0&&(0,a.jsx)(u.E,{variant:"info",className:"ml-1 text-sw-caption px-1 py-0 h-4",children:H})]}),(0,a.jsxs)(h.Xi,{value:"search",className:$,children:[x.tabs.search,K&&(0,a.jsx)("span",{className:"ml-1 w-1.5 h-1.5 rounded-sw-full bg-sw-primary inline-block"})]})]}),D&&(0,a.jsx)(h.Xi,{value:"sage",className:$,"data-testid":"governance-sage-tab",children:x.tabs.sage})]}),(0,a.jsx)(ef,{data:k,drawerState:b,webSearchEnabled:U,onViewTechnicalDetails:M?()=>q("trace"):void 0}),M&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S,{data:k,runtimeEvents:I,thinkingSteps:O}),(0,a.jsx)(X,{data:k,webSearchEnabled:U,trustStatus:G}),(0,a.jsx)(en,{data:k,searchTransparency:F})]}),D&&(0,a.jsx)(eE,{})]})]})]})]})};var eD=t(3781)},11362:(e,s,t)=>{t.d(s,{A:()=>a});let a=(0,t(5121).A)("shield-off",[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71",key:"1jlk70"}],["path",{d:"M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264",key:"18rp1v"}]])}}]);

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.