1import{o as B,r as o,j as e,k as c,T as a,C as P,l as L}from"./index-D-AFl6v8.js";import{L as R,D as z}from"./index-CfApN3LR.js";import{x as D,y as N}from"./superadmin-B2KQJapW.js";import{S as h}from"./Stack-7YBloGKc.js";import{M as $}from"./message-circle-DmiCuR6m.js";import{A as E,T as f}from"./TextField-DdZmIhxv.js";import{P as q}from"./createLucideIcon-L7O1RZew.js";import{F as X}from"./FormControlLabel-HApM5u4z.js";import{S as G}from"./Switch-k4p5AR7T.js";import{S as H}from"./Slider-CTyxO3Cq.js";import{S as J}from"./save-Bj6mRjJH.js";import"./index-BZruhSgt.js";import"./send-D6l0clPM.js";import"./Link-DQbJ92mW.js";import"./createSvgIcon-DLxHainh.js";import"./check-X8X9CWkw.js";import"./x-BTs_WrB8.js";import"./Modal-CRLh7o4j.js";import"./server-Dz7pqCYN.js";import"./wrench-Bn1myMGq.js";import"./Drawer-CBLHdxOe.js";import"./styled-C-2iXfty.js";import"./useThemeProps-DgQP1pEg.js";import"./SwitchBase-YvJ2Pi69.js";const n="#0066FF";function ge(){const{auth:u}=B(),i=(u==null?void 0:u.token)??"",[,g]=o.useState(null),[_,b]=o.useState(!0),[d,S]=o.useState(!1),[j,l]=o.useState(null),[A,p]=o.useState(!1),[m,v]=o.useState(!0),[C,y]=o.useState("xilos"),[k,T]=o.useState(""),[x,M]=o.use
1State(.3),[W,w]=o.useState(1024),F=o.useCallback(async()=>{var s,r;if(i){b(!0),l(null);try{const t=await D(i);g(t),v(t.enabled),y(t.model_id||"xilos"),T(t.system_prompt||""),M(t.temperature),w(t.max_tokens)}catch(t){l(((r=(s=t==null?void 0:t.response)==null?void 0:s.data)==null?void 0:r.detail)||t.message||"Failed to load config")}finally{b(!1)}}},[i]);o.useEffect(()=>{F()},[F]);const I=async()=>{var s,r;if(i){S(!0),l(null),p(!1);try{const t=await N(i,{enabled:m,model_id:C||null,system_prompt:k||null,temperature:x,max_tokens:W});g(t),p(!0),setTimeout(()=>p(!1),3e3)}catch(t){l(((r=(s=t==null?void 0:t.response)==null?void 0:s.data)==null?void 0:r.detail)||t.message||"Failed to save")}finally{S(!1)}}};return e.jsx(R,{children:e.jsxs(c,{sx:{maxWidth:720,mx:"auto",p:{xs:2,sm:4}},children:[e.jsxs(h,{direction:"row",alignItems:"center",gap:1.5,mb:3,children:[e.jsx($,{size:24,color:n}),e.jsx(a,{variant:"h5",sx:{fontWeight:700},children:"Support Chat"})]}),e.jsx(a,{variant:"body2",color:"text.secondary",sx:{mb:3},children:"Configure the floating help chatbot that appears in WorkBench. The chatbot answers user questions and links to relevant documentation."}),j&&e.jsx(E,{severity:"error",sx:{mb:2,borderRadius:2},onClose:()=>l(null),children:j}),A&&e.jsx(E,{severity:"success",sx:{mb:2,borderRadius:2},children:"Support chat configuration saved."}),_?e.jsx(c,{sx:{textAlign:"center",py:8},children:e.jsx(P,{size:32})}):e.jsx(q,{variant:"outlined",sx:{p:3,borderRadius:2},children:e.jsxs(h,{spacing:3,children:[e.jsx(X,{control:e.jsx(G,{checked:m,onChange:s=>v(s.target.checked),sx:{"& .MuiSwitch-thumb":{backgroundColor:m?n:void 0},"& .Mui-checked + .MuiSwitch-track":{backgroundColor:`${n}80`}}}),label:e.jsxs(c,{children:[e.jsx(a,{variant:"body2",fontWeight:600,children:"Enable Support Chat"}),e.jsx(a,{variant:"caption",color:"text.secondary",children:"When enabled, a floating help icon appears in WorkBench"})]})}),e.jsx(z,{}),e.jsx(f,{label:"Model ID",value:C,onChange:s=>y(s.target.value),helperText:"The Xilos model to use for support chat responses (e.g., 'xilos', 'gpt-4o')",size:"small",fullWidth:!0}),e.jsxs(c,{children:[e.jsxs(a,{variant:"body2",fontWeight:600,gutterBottom:!0,children:["Temperature: ",x.toFixed(1)]}),e.jsx(H,{value:x,onChange:(s,r)=>M(r),min:0,max:1,step:.1,sx:{color:n,"& .MuiSlider-thumb":{border:`2px solid ${n}`}}}),e.jsxs(h,{direction:"row",justifyContent:"space-between",children:[e.jsx(a,{variant:"caption",color:"text.secondary",children:"Precise"}),e.jsx(a,{variant:"caption",color:"text.secondary",children:"Creative"})]})]}),e.jsx(f,{label:"Max Tokens",type:"number",value:W,onChange:s=>w(Number(s.target.value)),helperText:"Maximum response length (100-4096)",size:"small",inputProps:{min:100,max:4096},fullWidth:!0}),e.jsx(z,{}),e.jsx(f,{label:"System Prompt",value:k,onChange:s=>T(s.target.value),helperText:"Instructions for the support chatbot. Leave empty for the default.",multiline:!0,rows:4,size:"small",fullWidth:!0}),e.jsx(L,{variant:"contained",onClick:I,disabled:d,startIcon:d?e.jsx(P,{size:16}):e.jsx(J,{size:16}),sx:{bgcolor:n,"&:hover":{bgcolor:"#0044CC"},borderRadius:1.5,textTransform:"none",fontWeight:600,alignSelf:"flex-start"},children:d?"Saving...":"Save Configuration"})]})})]})})}export{ge as default};
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.