totem-llm 0.3.4 → 0.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/lib/launcher.js +3 -2
  2. package/lib/setup.js +0 -1
  3. package/package.json +1 -1
  4. package/server/public/_index.html +7 -7
  5. package/server/public/assets/{404-56d107aa.js → 404-b9e84316.js} +1 -1
  6. package/server/public/assets/{RunDetailPage-da6aa377.js → RunDetailPage-f74368e1.js} +1 -1
  7. package/server/public/assets/{RunHistoryPage-2fcb4325.js → RunHistoryPage-432358df.js} +1 -1
  8. package/server/public/assets/{Trans-820f1dad.js → Trans-308f36d6.js} +1 -1
  9. package/server/public/assets/{cron-307d3fc6.js → cron-dfd47d9d.js} +1 -1
  10. package/server/public/assets/{files-676613ed.js → files-40998f84.js} +1 -1
  11. package/server/public/assets/{index-65184421.js → index-04b8b272.js} +1 -1
  12. package/server/public/assets/{index-ec3efa1e.js → index-0e2cd529.js} +1 -1
  13. package/server/public/assets/{index-671239cd.js → index-14be6ea8.js} +1 -1
  14. package/server/public/assets/{index-2aac91d0.js → index-1ee26989.js} +3 -3
  15. package/server/public/assets/{index-f9305828.js → index-202992ed.js} +1 -1
  16. package/server/public/assets/{index-df293c50.js → index-21157170.js} +1 -1
  17. package/server/public/assets/{index-72544df5.js → index-2317e7bf.js} +1 -1
  18. package/server/public/assets/{index-44ab5f11.js → index-28476ae3.js} +1 -1
  19. package/server/public/assets/{index-4750915e.js → index-2a122ffc.js} +1 -1
  20. package/server/public/assets/{index-d29fdeda.js → index-305b79a5.js} +1 -1
  21. package/server/public/assets/{index-d54b0575.js → index-34fe9c27.js} +1 -1
  22. package/server/public/assets/{index-3cb59d82.js → index-36acf56a.js} +1 -1
  23. package/server/public/assets/{index-a2978aa0.js → index-387c6117.js} +2 -2
  24. package/server/public/assets/{index-2d84e5fe.js → index-41afab73.js} +1 -1
  25. package/server/public/assets/{index-841db586.js → index-449280b3.js} +1 -1
  26. package/server/public/assets/{index-80edec8f.js → index-4aa70062.js} +1 -1
  27. package/server/public/assets/{index-cd6bc090.js → index-5911cdab.js} +1 -1
  28. package/server/public/assets/{index-efee6d1f.js → index-620c8910.js} +1 -1
  29. package/server/public/assets/{index-33ded078.js → index-6615fb87.js} +1 -1
  30. package/server/public/assets/{index-b49f94f1.js → index-69339b2c.js} +1 -1
  31. package/server/public/assets/{index-631fc042.js → index-70110b81.js} +1 -1
  32. package/server/public/assets/{index-574ed823.js → index-72879f52.js} +2 -2
  33. package/server/public/assets/{index-882e468e.js → index-7a4311ac.js} +1 -1
  34. package/server/public/assets/{index-fce187ac.js → index-823d8660.js} +1 -1
  35. package/server/public/assets/{index-1fe43260.js → index-874c0495.js} +1 -1
  36. package/server/public/assets/{index-6679334a.js → index-895c8c16.js} +1 -1
  37. package/server/public/assets/{index-6d56c896.js → index-93558484.js} +2 -2
  38. package/server/public/assets/{index-ed9034ac.js → index-988da2b0.js} +1 -1
  39. package/server/public/assets/{index-01932fa1.js → index-a14b4fe3.js} +1 -1
  40. package/server/public/assets/{index-0bf4fb6b.js → index-a8fe483a.js} +1 -1
  41. package/server/public/assets/{index-ae4f557d.js → index-aca9b702.js} +2 -2
  42. package/server/public/assets/{index-1c653bbf.js → index-b31c3faf.js} +2 -2
  43. package/server/public/assets/{index-4277cf52.js → index-c712996e.js} +1 -1
  44. package/server/public/assets/{index-391c1474.js → index-d948bb92.js} +3 -3
  45. package/server/public/assets/{index-a253e180.js → index-e28b4d22.js} +2 -2
  46. package/server/public/assets/{index-6bd7928a.js → index-ed14fe75.js} +1 -1
  47. package/server/public/assets/{index-e58bf860.js → index-f696a7cf.js} +1 -1
  48. package/server/public/assets/{index-4ce77c64.js → index-f6b98bbf.js} +1 -1
  49. package/server/public/assets/{index-27cc497c.js → index-fc994fe1.js} +1 -1
  50. package/server/public/assets/{main-0b9e408b.js → main-34958ff6.js} +1 -1
  51. package/server/public/assets/{mcpServers-1686e782.js → mcpServers-9495fe60.js} +1 -1
  52. package/server/public/assets/{moment-75486807.js → moment-49fc1b76.js} +1 -1
  53. package/server/public/assets/{purify-eb750cf4.js → purify-17c89583.js} +1 -1
  54. package/server/public/assets/{react-beautiful-dnd.esm-bb85eef1.js → react-beautiful-dnd.esm-149a7a55.js} +1 -1
  55. package/server/public/assets/{truncate-06273256.js → truncate-dd7b0c29.js} +1 -1
  56. package/server/public/favicon.ico +0 -0
  57. package/server/public/index.js +27 -27
  58. package/server/utils/files/multer.js +2 -8
@@ -1 +1 @@
1
- import{R as N,r as a,g as ye,u as w,j as e,h as te,k as $,I as je,W as L,c as C,l as G,p as M,C as U,A as _,m as q,D as ve,S as T,n as we,o as Ne,q as V,t as F,v as R,w as Se,x as se,y as re,z as ne,M as Q,B as ae,E as le,G as Ce,H as ie,J as oe,K,N as ce,O as Me,Q as ke,a as de,d as Ee,e as ue,f as Le,T as Fe,i as X,U as Ae,V as De,X as Pe}from"../index.js";import{a as Re}from"./index-6bd7928a.js";import{w as $e}from"./ChatText-35275002.js";import{D as ze}from"./Database-f1a76329.js";import{c as I,w as We}from"./types-e90e1137.js";import{H as Oe}from"./main-0b9e408b.js";import{h as Te}from"./moment-75486807.js";import{t as Ue}from"./truncate-06273256.js";import{P as Ve}from"./index-3cb59d82.js";import{T as Ie}from"./Trans-820f1dad.js";import{A as W}from"./admin-04b020fe.js";import{w as _e}from"./Gauge-e6762f4d.js";import"./XCircle-edfe554c.js";import"./File-b92df2f3.js";import"./Eye-9f033dc0.js";import"./index-4fb4d421.js";import"./react-beautiful-dnd.esm-bb85eef1.js";import"./communityHub-aba61686.js";import"./Brain-24e386d5.js";import"./Browser-1820fad0.js";const qe=new Map([["bold",N.createElement(N.Fragment,null,N.createElement("path",{d:"M234.38,210a123.36,123.36,0,0,0-60.78-53.23,76,76,0,1,0-91.2,0A123.36,123.36,0,0,0,21.62,210a12,12,0,1,0,20.77,12c18.12-31.32,50.12-50,85.61-50s67.49,18.69,85.61,50a12,12,0,0,0,20.77-12ZM76,96a52,52,0,1,1,52,52A52.06,52.06,0,0,1,76,96Z"}))],["duotone",N.createElement(N.Fragment,null,N.createElement("path",{d:"M192,96a64,64,0,1,1-64-64A64,64,0,0,1,192,96Z",opacity:"0.2"}),N.createElement("path",{d:"M230.92,212c-15.23-26.33-38.7-45.21-66.09-54.16a72,72,0,1,0-73.66,0C63.78,166.78,40.31,185.66,25.08,212a8,8,0,1,0,13.85,8c18.84-32.56,52.14-52,89.07-52s70.23,19.44,89.07,52a8,8,0,1,0,13.85-8ZM72,96a56,56,0,1,1,56,56A56.06,56.06,0,0,1,72,96Z"}))],["fill",N.createElement(N.Fragment,null,N.createElement("path",{d:"M230.93,220a8,8,0,0,1-6.93,4H32a8,8,0,0,1-6.92-12c15.23-26.33,38.7-45.21,66.09-54.16a72,72,0,1,1,73.66,0c27.39,8.95,50.86,27.83,66.09,54.16A8,8,0,0,1,230.93,220Z"}))],["light",N.createElement(N.Fragment,null,N.createElement("path",{d:"M229.19,213c-15.81-27.32-40.63-46.49-69.47-54.62a70,70,0,1,0-63.44,0C67.44,166.5,42.62,185.67,26.81,213a6,6,0,1,0,10.38,6C56.4,185.81,90.34,166,128,166s71.6,19.81,90.81,53a6,6,0,1,0,10.38-6ZM70,96a58,58,0,1,1,58,58A58.07,58.07,0,0,1,70,96Z"}))],["regular",N.createElement(N.Fragment,null,N.createElement("path",{d:"M230.92,212c-15.23-26.33-38.7-45.21-66.09-54.16a72,72,0,1,0-73.66,0C63.78,166.78,40.31,185.66,25.08,212a8,8,0,1,0,13.85,8c18.84-32.56,52.14-52,89.07-52s70.23,19.44,89.07,52a8,8,0,1,0,13.85-8ZM72,96a56,56,0,1,1,56,56A56.06,56.06,0,0,1,72,96Z"}))],["thin",N.createElement(N.Fragment,null,N.createElement("path",{d:"M227.46,214c-16.52-28.56-43-48.06-73.68-55.09a68,68,0,1,0-51.56,0c-30.64,7-57.16,26.53-73.68,55.09a4,4,0,0,0,6.92,4C55,184.19,89.62,164,128,164s73,20.19,92.54,54a4,4,0,0,0,3.46,2,3.93,3.93,0,0,0,2-.54A4,4,0,0,0,227.46,214ZM68,96a60,60,0,1,1,60,60A60.07,60.07,0,0,1,68,96Z"}))]]);var He=Object.defineProperty,Be=Object.defineProperties,Ze=Object.getOwnPropertyDescriptors,Y=Object.getOwnPropertySymbols,Ge=Object.prototype.hasOwnProperty,Qe=Object.prototype.propertyIsEnumerable,J=(s,t,r)=>t in s?He(s,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[t]=r,Ke=(s,t)=>{for(var r in t||(t={}))Ge.call(t,r)&&J(s,r,t[r]);if(Y)for(var r of Y(t))Qe.call(t,r)&&J(s,r,t[r]);return s},Xe=(s,t)=>Be(s,Ze(t));const me=a.forwardRef((s,t)=>N.createElement(ye,Xe(Ke({ref:t},s),{weights:qe})));me.displayName="User";function Ye({workspace:s,setHasChanges:t}){const{t:r}=w();return e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("label",{htmlFor:"name",className:"block input-label",children:r("common.workspaces-name")}),e.jsx("p",{className:"text-white text-opacity-60 text-xs font-medium py-1.5",children:r("general.names.description")})]}),e.jsx("input",{name:"name",type:"text",minLength:2,maxLength:80,defaultValue:s==null?void 0:s.name,className:"border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5",placeholder:"My Workspace",required:!0,autoComplete:"off",onChange:()=>t(!0)})]})}function Je({slug:s}){const[t,r]=a.useState([]),[i,l]=a.useState(-1),[n,d]=a.useState({heading:"",message:""}),[o,c]=a.useState(!1),[h,f]=a.useState(!0),{t:g}=w();a.useEffect(()=>{async function y(){if(!s)return;const v=await L.getSuggestedMessages(s);r(v),f(!1)}y()},[s]);const b=async()=>{const y=t.filter(E=>{var D,P;return((P=(D=E==null?void 0:E.message)==null?void 0:D.trim())==null?void 0:P.length)>0}),{success:v,error:S}=await L.setSuggestedMessages(s,y);if(!v){C(`Failed to update suggested chat messages: ${S}`,"error");return}r(y),l(-1),c(!1)},x=()=>{if(l(-1),t.length>=4){C("Maximum of 4 messages allowed.","warning");return}const y={heading:"",message:`${g("general.message.heading")} ${g("general.message.body")}`};d(y),r([...t,{...y}]),c(!0)},u=y=>{const v=[...t];v.splice(y,1),r(v),c(!0)},p=(y,v)=>{y.preventDefault(),l(v);const S=t[v];if(S.heading){const E={heading:"",message:`${S.heading} ${S.message}`};d(E),r(t.map((D,P)=>P===v?E:D))}else d({...S})},m=y=>{u(y),l(-1)},k=y=>{const v={...n,[y.target.name]:y.target.value};d(v);const S=t.map((E,D)=>D===i?{...E,[y.target.name]:y.target.value}:E);r(S),c(!0)};return h?e.jsxs("div",{className:"flex flex-col",children:[e.jsx("label",{className:"block input-label",children:g("general.message.title")}),e.jsx("p",{className:"text-white text-opacity-60 text-xs font-medium py-1.5",children:g("general.message.description")}),e.jsx("div",{className:"text-white text-opacity-60 text-sm font-medium mt-6",children:e.jsx(te,{size:"4"})})]}):e.jsxs("div",{className:"w-full mt-6",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("label",{className:"block input-label",children:g("general.message.title")}),e.jsx("p",{className:"text-white text-opacity-60 text-xs font-medium py-1.5",children:g("general.message.description")})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6 text-white/60 text-xs mt-2 w-full justify-center max-w-[600px]",children:t.map((y,v)=>e.jsxs("div",{className:"relative w-full",children:[e.jsx("button",{className:"transition-all duration-300 absolute z-10 text-neutral-700 bg-white rounded-full hover:bg-zinc-600 hover:border-zinc-600 hover:text-white border-transparent border shadow-lg ml-2",style:{top:-8,left:265},onClick:()=>m(v),children:e.jsx($,{className:"m-[1px]",size:20})}),e.jsx("button",{onClick:S=>p(S,v),className:`text-left p-2.5 border rounded-xl w-full border-white/20 bg-theme-settings-input-bg hover:bg-theme-sidebar-item-selected-gradient ${i===v?"border-sky-400":""}`,children:e.jsxs("p",{className:"line-clamp-2 text-theme-text-primary",children:[y!=null&&y.heading?`${y.heading} `:"",(y==null?void 0:y.message)??""]})},v)]},v))}),i>=0&&e.jsx("div",{className:"flex flex-col gap-y-4 mr-2 mt-8",children:e.jsxs("div",{className:"w-1/2",children:[e.jsx("label",{className:"text-white text-sm font-semibold block mb-2",children:"Message"}),e.jsx("input",{placeholder:"Message",className:"border-none bg-theme-settings-input-bg text-white placeholder:text-white/20 text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block p-2.5 w-full",value:n.message,name:"message",onChange:k})]})}),t.length<4&&e.jsxs("button",{type:"button",onClick:x,className:"flex gap-x-2 items-center justify-center mt-6 text-white text-sm hover:text-sky-400 transition-all duration-300",children:[g("general.message.add")," ",e.jsx(je,{className:"",size:24,weight:"fill"})]}),o&&e.jsx("div",{className:"flex justify-start py-6",children:e.jsx("button",{type:"button",className:"transition-all duration-300 border border-slate-200 px-4 py-2 rounded-lg text-white text-sm items-center flex gap-x-2 hover:bg-slate-200 hover:text-slate-800 focus:ring-gray-800",onClick:b,children:g("general.message.save")})})]})}function et({workspace:s,visible:t=!0}){const{slug:r}=G(),[i,l]=a.useState(!1),{t:n}=w(),d=async()=>{if(!window.confirm(`${n("general.delete.confirm-start")} ${s.name} ${n("general.delete.confirm-end")}`))return!1;if(l(!0),!await L.delete(s.slug)){C("Workspace could not be deleted!","error",{clear:!0}),l(!1);return}s.slug===r?window.location=M.home():window.location.reload()};return t?e.jsxs("div",{className:"flex flex-col mt-10",children:[e.jsx("label",{className:"block input-label",children:n("general.delete.title")}),e.jsx("p",{className:"text-theme-text-secondary text-xs font-medium py-1.5",children:n("general.delete.description")}),e.jsx("button",{disabled:i,onClick:d,type:"button",className:"w-60 mt-4 transition-all duration-300 border border-transparent rounded-lg whitespace-nowrap text-sm px-5 py-2.5 focus:z-10 bg-red-500/25 text-red-200 light:text-red-500 hover:light:text-[#FFFFFF] hover:text-[#FFFFFF] hover:bg-red-600 disabled:bg-red-600 disabled:text-red-200 disabled:animate-pulse",children:n(i?"general.delete.deleting":"general.delete.delete")})]}):null}function tt({slug:s,deletionProtected:t=!1}){const[r,i]=a.useState(null),[l,n]=a.useState(!1),[d,o]=a.useState(!1),[c,h]=a.useState(!0),f=a.useRef(null);a.useEffect(()=>{async function b(){const x=await L.bySlug(s);i(x),h(!1)}b()},[s]);const g=async b=>{o(!0),b.preventDefault();const x={},u=new FormData(f.current);for(var[p,m]of u.entries())x[p]=I(p,m);const{workspace:k,message:y}=await L.update(r.slug,x);k?C("Workspace updated!","success",{clear:!0}):C(`Error: ${y}`,"error",{clear:!0}),o(!1),n(!1)};return!r||c?null:e.jsxs("div",{className:"w-full relative",children:[e.jsxs("form",{ref:f,onSubmit:g,className:"w-1/2 flex flex-col gap-y-6",children:[l&&e.jsx("div",{className:"absolute top-0 right-0",children:e.jsx(U,{type:"submit",children:d?"Updating...":"Update Workspace"})}),e.jsx(Ye,{workspace:r,setHasChanges:n},r.slug)]}),e.jsx(Je,{slug:r.slug}),e.jsx(et,{workspace:r,visible:!t})]})}function st({workspace:s,setHasChanges:t}){const{t:r}=w();return e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-col gap-y-1 mb-4",children:[e.jsx("label",{htmlFor:"name",className:"block mb-2 input-label",children:r("chat.history.title")}),e.jsxs("p",{className:"text-white text-opacity-60 text-xs font-medium",children:[r("chat.history.desc-start"),e.jsxs("i",{children:[" ",r("chat.history.recommend")," "]}),r("chat.history.desc-end")]})]}),e.jsx("input",{name:"openAiHistory",type:"number",min:1,max:45,step:1,onWheel:i=>i.target.blur(),defaultValue:(s==null?void 0:s.openAiHistory)??20,className:"border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5",placeholder:"20",required:!0,autoComplete:"off",onChange:()=>t(!0)})]})}const Z={forWorkspace:async function(s){try{return await fetch(`${_}/workspace/${s}/prompt-history`,{method:"GET",headers:q()}).then(t=>t.json()).then(t=>t.history||[]).catch(t=>(console.error("Error fetching prompt history:",t),[]))}catch(t){return console.error("Error fetching prompt history:",t),[]}},clearAll:async function(s){try{return await fetch(`${_}/workspace/${s}/prompt-history`,{method:"DELETE",headers:q()}).then(t=>t.json()).catch(t=>(console.error("Error clearing prompt history:",t),{success:!1,error:t}))}catch(t){return console.error("Error clearing prompt history:",t),{success:!1,error:t}}},delete:async function(s){try{return await fetch(`${_}/workspace/prompt-history/${s}`,{method:"DELETE",headers:q()}).then(t=>t.json()).catch(t=>(console.error("Error deleting prompt history:",t),{success:!1,error:t}))}catch(t){return console.error("Error deleting prompt history:",t),{success:!1,error:t}}}},ee=200;function rt({id:s,prompt:t,modifiedAt:r,user:i,onRestore:l,setHistory:n,onPublishClick:d}){const{t:o}=w(),[c,h]=a.useState(!1),f=a.useRef(null),g=a.useRef(null),[b,x]=a.useState(!1),u=async p=>{if(window.confirm(o("chat.prompt.history.deleteConfirm"))){const{success:m}=await Z.delete(p);m&&n(k=>k.filter(y=>y.id!==p))}};return a.useEffect(()=>{const p=m=>{c&&!f.current.contains(m.target)&&!g.current.contains(m.target)&&h(!1)};return document.addEventListener("mousedown",p),()=>{document.removeEventListener("mousedown",p)}},[c]),e.jsxs("div",{className:"text-white",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"text-xs",children:[i&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-primary-button",children:i.username})," ",e.jsx("span",{className:"mx-1 text-white",children:"•"})]}),e.jsx("span",{className:"text-white opacity-50 light:opacity-100",children:Te(r).fromNow()})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",className:"border-none text-sm cursor-pointer text-theme-text-primary hover:text-primary-button",onClick:l,children:o("chat.prompt.history.restore")}),e.jsxs("div",{className:"relative",children:[e.jsx("button",{type:"button",ref:g,className:"border-none text-theme-text-secondary cursor-pointer hover:text-primary-button flex items-center justify-center",onClick:()=>h(!c),children:e.jsx(ve,{size:16,weight:"bold"})}),c&&e.jsxs("div",{ref:f,className:"absolute right-0 top-6 bg-theme-bg-popup-menu rounded-lg z-50 min-w-[200px]",children:[e.jsx("button",{type:"button",className:"px-[10px] py-[6px] text-sm text-white hover:bg-theme-sidebar-item-hover rounded-t-lg cursor-pointer border-none w-full text-left whitespace-nowrap",onClick:()=>{h(!1),d(t)},children:o("chat.prompt.history.publish")}),e.jsx("button",{type:"button",className:"px-[10px] py-[6px] text-sm text-white hover:bg-red-500/60 light:hover:bg-red-300/80 rounded-b-lg cursor-pointer border-none w-full text-left whitespace-nowrap",onClick:()=>{h(!1),u(s)},children:o("chat.prompt.history.delete")})]})]})]})]}),e.jsx("div",{className:"flex items-center mt-1",children:e.jsx("div",{className:"text-theme-text-primary text-sm font-medium break-all whitespace-pre-wrap",children:t.length>ee&&!b?e.jsxs(e.Fragment,{children:[Ue(t,ee)," ",e.jsx("button",{type:"button",className:"text-theme-text-secondary hover:text-primary-button border-none",onClick:()=>x(!b),children:o("chat.prompt.history.expand")})]}):t})})]})}const nt=a.forwardRef(function({show:t,workspaceSlug:r,onRestore:i,onClose:l,onPublishClick:n},d){const{t:o}=w(),[c,h]=a.useState([]),[f,g]=a.useState(!0);function b(){r&&(g(!0),Z.forWorkspace(r).then(u=>{h(u)}).catch(u=>{console.error(u)}).finally(()=>{g(!1)}))}function x(){r&&window.confirm(o("chat.prompt.history.clearAllConfirm"))&&Z.clearAll(r).then(({success:u})=>{u&&h([])}).catch(u=>{console.error(u)})}return a.useEffect(()=>{t&&r&&b()},[t,r]),e.jsxs("div",{ref:d,className:`fixed right-3 top-3 bottom-3 w-[375px] bg-theme-action-menu-bg light:bg-theme-home-update-card-bg rounded-xl py-4 px-4 z-[9999] overflow-y-hidden ${t?"translate-x-0 opacity-100 visible":"translate-x-full opacity-0 invisible"} transition-all duration-300`,children:[e.jsxs("div",{className:"sticky flex items-center justify-between",children:[e.jsx("div",{className:"text-theme-text-primary text-sm font-semibold",children:o("chat.prompt.history.title")}),e.jsxs("div",{className:"flex items-center gap-2",children:[c.length>0&&e.jsx("button",{type:"button",className:"text-sm font-medium text-theme-text-secondary cursor-pointer hover:text-primary-button border-none",onClick:x,children:o("chat.prompt.history.clearAll")}),e.jsx("button",{type:"button",className:"text-theme-text-secondary cursor-pointer hover:text-primary-button border-none",onClick:l,children:e.jsx($,{size:16,weight:"bold"})})]})]}),e.jsx("div",{className:"mt-4 flex flex-col gap-y-[14px] h-full overflow-y-scroll pb-[50px]",children:f?e.jsx(at,{}):c.length===0?e.jsx("div",{className:"flex text-theme-text-secondary text-sm text-center w-full h-full flex items-center justify-center",children:o("chat.prompt.history.noHistory")}):c.map(u=>e.jsx(rt,{id:u.id,...u,onRestore:()=>i(u.prompt),onPublishClick:n,setHistory:h},u.id))})]})});function at(){const s="var(--theme-bg-primary)",t="var(--theme-bg-secondary)";return e.jsx(T,{height:"85px",width:"100%",highlightColor:s,baseColor:t,count:8})}function lt({workspace:s,setHasChanges:t,hasChanges:r}){const{t:i}=w(),[l]=we(),n=Ne(s),[d,o]=a.useState(n),[c,h]=a.useState(n),[f,g]=a.useState(""),[b,x]=a.useState(!1),[u,p]=a.useState(!1),[m,k]=a.useState([]),y=a.useRef(null),v=a.useRef(null),S=a.useRef(null),{isOpen:E,closeModal:D,openModal:P}=V(),he=d!==c,xe=(c==null?void 0:c.trim())!==(n==null?void 0:n.trim()),pe=!b&&(d==null?void 0:d.trim().length)>=10&&(he||xe);a.useEffect(()=>{async function j(){const{variables:A}=await Se.getAll();k(A)}j(),l.get("action")==="focus-system-prompt"&&x(!0)},[l]),a.useEffect(()=>{r||h(d)},[r,d]),a.useEffect(()=>{b&&y.current&&y.current.focus()},[b]),a.useEffect(()=>{F.fetchDefaultSystemPrompt().then(({defaultSystemPrompt:j})=>g(j))},[]),a.useEffect(()=>{const j=A=>{v.current&&!v.current.contains(A.target)&&S.current&&!S.current.contains(A.target)&&p(!1)};return document.addEventListener("mousedown",j),()=>document.removeEventListener("mousedown",j)},[]);const fe=j=>{o(j),p(!1),t(!0)},be=j=>{P(),p(!1),setTimeout(()=>o(j),0)},ge=()=>{F.fetchDefaultSystemPrompt().then(({defaultSystemPrompt:j})=>{o(j),t(!0)})};return e.jsxs(e.Fragment,{children:[e.jsx(nt,{ref:v,workspaceSlug:s.slug,show:u,onRestore:fe,onPublishClick:be,onClose:()=>p(!1)}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsx("label",{htmlFor:"name",className:"block input-label",children:i("chat.prompt.title")})}),e.jsx("p",{className:"text-white text-opacity-60 text-xs font-medium py-1.5",children:i("chat.prompt.description")}),e.jsxs("p",{className:"text-white text-opacity-60 text-xs font-medium mb-2",children:["You can insert"," ",e.jsx(R,{to:M.settings.systemPromptVariables(),className:"text-primary-button",children:"prompt variables"})," ","like:"," ",m.slice(0,3).map((j,A)=>e.jsxs(a.Fragment,{children:[e.jsx("span",{className:"bg-theme-settings-input-bg px-1 py-0.5 rounded",children:`{${j.key}}`}),A<m.length-1&&", "]},j.key)),m.length>3&&e.jsxs(R,{to:M.settings.systemPromptVariables(),className:"text-primary-button",children:["+",m.length-3," more..."]})]})]}),e.jsx("input",{type:"hidden",name:"openAiPrompt",value:d}),e.jsxs("div",{className:"relative w-full flex flex-col items-end",children:[e.jsx("button",{ref:S,type:"button",className:"text-theme-text-secondary hover:text-white light:hover:text-black text-xs font-medium",onClick:j=>{j.preventDefault(),p(!u)},children:u?"Hide History":"View History"}),e.jsx("div",{className:"relative w-full",children:b?e.jsx("textarea",{ref:y,autoFocus:!0,rows:5,onFocus:j=>{const A=j.target.value.length;j.target.setSelectionRange(A,A)},onBlur:j=>{x(!1),o(j.target.value)},onChange:j=>{o(j.target.value),t(!0)},onPaste:j=>{o(j.target.value),t(!0)},style:{resize:"vertical",overflowY:"scroll",minHeight:"150px"},defaultValue:d,className:"border-none bg-theme-settings-input-bg text-white text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5 mt-2"}):e.jsx("div",{onClick:()=>x(!0),style:{resize:"vertical",overflowY:"scroll",minHeight:"150px"},className:"border-none bg-theme-settings-input-bg text-white text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5 mt-2",children:e.jsx(Oe,{className:"whitespace-pre-wrap",highlightClassName:"bg-cta-button p-0.5 rounded-md",searchWords:m.map(j=>`{${j.key}}`),autoEscape:!0,caseSensitive:!0,textToHighlight:d})})}),e.jsxs("div",{className:"w-full flex flex-row items-center justify-between pt-2",children:[d!==f&&e.jsx("button",{type:"button",onClick:ge,className:"text-theme-text-primary hover:text-white light:hover:text-black text-xs font-medium",children:"Restore to Default"}),e.jsx(it,{hidden:!pe,onClick:P})]})]})]}),e.jsx(Ve,{show:E,onClose:D,entityType:"system-prompt",entity:d})]})}function it({hidden:s=!1,onClick:t}){return s?null:e.jsx("button",{type:"button",onClick:t,className:"border-none text-primary-button hover:text-white light:hover:text-black text-xs font-medium",children:"Publish to Community Hub"})}function ot(s=null){switch(s){case"mistral":return{temp:0};default:return{temp:.7}}}function ct({settings:s,workspace:t,setHasChanges:r}){const i=ot(s==null?void 0:s.LLMProvider),{t:l}=w();return e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("label",{htmlFor:"name",className:"block input-label",children:l("chat.temperature.title")}),e.jsxs("p",{className:"text-white text-opacity-60 text-xs font-medium py-1.5",children:[l("chat.temperature.desc-start"),e.jsx("br",{}),l("chat.temperature.desc-end"),e.jsx("br",{}),e.jsx("br",{}),e.jsx("i",{children:l("chat.temperature.hint")})]})]}),e.jsx("input",{name:"openAiTemp",type:"number",min:0,step:.1,onWheel:n=>n.target.blur(),defaultValue:(t==null?void 0:t.openAiTemp)??i.temp,className:"border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5",placeholder:"0.7",required:!0,autoComplete:"off",onChange:()=>r(!0)})]})}function dt({workspace:s,setHasChanges:t}){const{t:r}=w(),{enabled:i}=se("agentMode"),[l,n]=a.useState((s==null?void 0:s.chatMode)||"chat");return i?e.jsxs("div",{children:[e.jsx("div",{className:"flex flex-col",children:e.jsx("label",{htmlFor:"chatMode",className:"block input-label",children:r("chat.mode.title")})}),e.jsxs("div",{className:"flex flex-col gap-y-1 mt-2",children:[e.jsxs("div",{className:"w-fit flex gap-x-1 items-center p-1 rounded-lg bg-theme-settings-input-bg ",children:[e.jsx("input",{type:"hidden",name:"chatMode",value:l}),e.jsx("button",{type:"button",disabled:l==="automatic",onClick:()=>{n("automatic"),t(!0)},className:"border-none transition-bg duration-200 px-6 py-1 text-md text-white/60 disabled:text-white bg-transparent disabled:bg-[#687280] rounded-md hover:bg-white/10",children:r("chat.mode.automatic.title")}),e.jsx("button",{type:"button",disabled:l==="chat",onClick:()=>{n("chat"),t(!0)},className:"border-none transition-bg duration-200 px-6 py-1 text-md text-white/60 disabled:text-white bg-transparent disabled:bg-[#687280] rounded-md hover:bg-white/10 light:hover:bg-black/10",children:r("chat.mode.chat.title")}),e.jsx("button",{type:"button",disabled:l==="query",onClick:()=>{n("query"),t(!0)},className:"border-none transition-bg duration-200 px-6 py-1 text-md text-white/60 disabled:text-white bg-transparent disabled:bg-[#687280] rounded-md hover:bg-white/10 light:hover:bg-black/10",children:r("chat.mode.query.title")})]}),e.jsx(ut,{chatMode:l})]})]}):null}function ut({chatMode:s="chat"}){const{t}=w();return e.jsxs("p",{className:"text-sm text-white/60",children:[e.jsx("b",{children:t(`chat.mode.${s}.title`)})," ",e.jsx(Ie,{i18nKey:`chat.mode.${s}.description`,components:{b:e.jsx("b",{}),br:e.jsx("br",{})}})]})}const mt=["default"];function ht({llm:s,availableLLMs:t,settings:r,checked:i,onClick:l}){const{isOpen:n,openModal:d,closeModal:o}=V(),{name:c,value:h,logo:f,description:g}=s,[b,x]=a.useState(r);a.useEffect(()=>{async function p(){if(n){const m=await F.keys();x(m??{})}}p()},[n]);function u(){if(!i){if((s.requiredConfig||[]).some(m=>!b[m])){d();return}l(h)}}return e.jsxs(e.Fragment,{children:[e.jsxs("div",{onClick:u,className:`w-full p-2 rounded-md hover:cursor-pointer hover:bg-theme-bg-secondary ${i?"bg-theme-bg-secondary":""}`,children:[e.jsx("input",{type:"checkbox",value:h,className:"peer hidden",checked:i,readOnly:!0,formNoValidate:!0}),e.jsxs("div",{className:"flex gap-x-4 items-center justify-between",children:[e.jsxs("div",{className:"flex gap-x-4 items-center",children:[e.jsx("img",{src:f,alt:`${c} logo`,className:"w-10 h-10 rounded-md"}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("div",{className:"text-sm font-semibold text-white",children:c}),e.jsx("div",{className:"mt-1 text-xs text-white/60",children:g})]})]}),i&&!mt.includes(h)&&e.jsx("button",{onClick:p=>{p.preventDefault(),d()},className:"p-2 text-white/60 hover:text-white hover:bg-theme-bg-hover rounded-md transition-all duration-300",title:"Edit Settings",children:e.jsx(re,{size:20,weight:"bold"})})]})]}),e.jsx(xt,{availableLLMs:t,isOpen:n,provider:h,closeModal:o,postSubmit:l,settings:b})]})}function xt({availableLLMs:s,isOpen:t,provider:r,closeModal:i,postSubmit:l,settings:n}){if(!t)return null;const d=s.find(c=>c.value===r);if(!d)return null;async function o(c){c.preventDefault(),c.stopPropagation();const h={},f=new FormData(c.target);for(var[g,b]of f.entries())h[g]=b;const{error:x}=await F.updateSystem(h);if(x){C(`Failed to save ${d.name} settings: ${x}`,"error");return}return i(),l(),!1}return ne.createPortal(e.jsx(Q,{isOpen:t,children:e.jsx("div",{className:"fixed inset-0 z-50 overflow-auto bg-black bg-opacity-50 flex items-center justify-center",children:e.jsxs("div",{className:"relative w-full max-w-2xl bg-theme-bg-secondary rounded-lg shadow border-2 border-theme-modal-border",children:[e.jsxs("div",{className:"relative p-6 border-b rounded-t border-theme-modal-border",children:[e.jsx("div",{className:"w-full flex gap-x-2 items-center",children:e.jsxs("h3",{className:"text-xl font-semibold text-white overflow-hidden overflow-ellipsis whitespace-nowrap",children:[d.name," Settings"]})}),e.jsx("button",{onClick:i,type:"button",className:"absolute top-4 right-4 transition-all duration-300 bg-transparent rounded-lg text-sm p-1 inline-flex items-center hover:bg-theme-modal-border hover:border-theme-modal-border hover:border-opacity-50 border-transparent border",children:e.jsx($,{size:24,weight:"bold",className:"text-white"})})]}),e.jsxs("form",{id:"provider-form",onSubmit:o,children:[e.jsx("div",{className:"px-7 py-6",children:e.jsxs("div",{className:"space-y-6 max-h-[60vh] overflow-y-auto p-1",children:[e.jsxs("p",{className:"text-sm text-white/60",children:["To use ",d.name," as this workspace's LLM you need to set it up first."]}),e.jsx("div",{children:d.options(n,{credentialsOnly:!0})})]})}),e.jsxs("div",{className:"flex justify-between items-center mt-6 pt-6 border-t border-theme-modal-border px-7 pb-6",children:[e.jsx("button",{type:"button",onClick:i,className:"transition-all duration-300 text-white hover:bg-zinc-700 px-4 py-2 rounded-lg text-sm",children:"Cancel"}),e.jsx("button",{type:"submit",form:"provider-form",className:"transition-all duration-300 bg-white text-black hover:opacity-60 px-4 py-2 rounded-lg text-sm",children:"Save settings"})]})]})]})})}),document.getElementById("workspace-chat-settings-container"))}function pt({provider:s,workspace:t,setHasChanges:r}){const{defaultModels:i,customModels:l,loading:n}=ae(s),{t:d}=w();return le.includes(s)?null:n?e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-col mt-6",children:[e.jsx("label",{htmlFor:"name",className:"block input-label",children:d("chat.model.title")}),e.jsx("p",{className:"text-white text-opacity-60 text-xs font-medium py-1.5",children:d("chat.model.description")})]}),e.jsx("select",{name:"chatModel",required:!0,disabled:!0,className:"border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5",children:e.jsx("option",{disabled:!0,selected:!0,children:"-- waiting for models --"})})]}):e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-col mt-6",children:[e.jsx("label",{htmlFor:"name",className:"block input-label",children:d("chat.model.title")}),e.jsx("p",{className:"text-white text-opacity-60 text-xs font-medium py-1.5",children:d("chat.model.description")})]}),e.jsxs("select",{name:"chatModel",required:!0,onChange:()=>{r(!0)},className:"border-none bg-theme-settings-input-bg text-white text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5",children:[i.length>0&&e.jsx("optgroup",{label:"General models",children:i.map(o=>e.jsx("option",{value:o,selected:(t==null?void 0:t.chatModel)===o,children:o},o))}),Array.isArray(l)&&l.length>0&&e.jsx("optgroup",{label:"Discovered models",children:l.map(o=>e.jsx("option",{value:o.id,selected:(t==null?void 0:t.chatModel)===o.id,children:o.name||o.id},o.id))}),!Array.isArray(l)&&Object.keys(l).length>0&&e.jsx(e.Fragment,{children:Object.entries(l).map(([o,c])=>e.jsx("optgroup",{label:o,children:c.map(h=>e.jsx("option",{value:h.id,selected:(t==null?void 0:t.chatModel)===h.id,children:h.name||h.id},h.id))},o))})]})]})}function ft({workspace:s,setHasChanges:t}){const{t:r}=w(),[i,l]=a.useState([]),[n,d]=a.useState(!0);return a.useEffect(()=>{async function o(){const c=await Ce.getAll();l(c),d(!1)}o()},[]),n?e.jsx("div",{className:"mt-4",children:e.jsx("p",{className:"text-sm text-white text-opacity-60",children:r("model-router.router-selection.loading-routers")})}):i.length===0?e.jsx("div",{className:"mt-4",children:e.jsxs("p",{className:"text-sm text-white text-opacity-60",children:[r("model-router.router-selection.no-routers-prefix-workspace")," ",e.jsx(R,{to:M.settings.modelRouters(),className:"underline text-white",children:r("model-router.router-selection.no-routers-link")}),"."]})}):e.jsxs("div",{className:"mt-4 flex flex-col gap-y-1",children:[e.jsx("label",{className:"block input-label",children:r("model-router.router-selection.model-router-label")}),e.jsx("p",{className:"text-white text-opacity-60 text-xs font-medium py-1.5",children:r("model-router.router-selection.select-description")}),e.jsxs("select",{name:"router_id",defaultValue:(s==null?void 0:s.router_id)||"",onChange:()=>t(!0),className:"border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full max-w-[640px] p-2.5",required:!0,children:[e.jsx("option",{value:"",children:r("model-router.router-selection.select-router")}),i.map(o=>e.jsxs("option",{value:o.id,children:[o.name,o.description?` — ${o.description}`:""]},o.id))]})]})}const bt=["bedrock","azure","generic-openai"],gt=["default","huggingface","anythingllm-router"],yt=[],jt={name:"System default",value:"default",logo:oe,options:()=>e.jsx(N.Fragment,{}),description:"Use the system LLM preference for this workspace.",requiredConfig:[]},O=[jt,...ie].filter(s=>!yt.includes(s.value));function vt({settings:s,workspace:t,setHasChanges:r}){const[i,l]=a.useState([]),[n,d]=a.useState((t==null?void 0:t.chatProvider)??"default"),[o,c]=a.useState(""),[h,f]=a.useState(!1),g=a.useRef(null),{t:b}=w();function x(m){c(""),d(m),f(!1),r(!0)}function u(){o.length>0?(c(""),g.current&&(g.current.value="")):f(!h)}a.useEffect(()=>{const m=O.filter(k=>k.name.toLowerCase().includes(o.toLowerCase()));l(m)},[O,o,n]);const p=O.find(m=>m.value===n);return e.jsxs("div",{className:"border-b border-white/40 pb-8",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("label",{htmlFor:"name",className:"block input-label",children:b("chat.llm.title")}),e.jsx("p",{className:"text-white text-opacity-60 text-xs font-medium py-1.5",children:b("chat.llm.description")})]}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:"hidden",name:"chatProvider",value:n}),h&&e.jsx("div",{className:"fixed top-0 left-0 w-full h-full bg-black bg-opacity-70 backdrop-blur-sm z-10",onClick:()=>f(!1)}),h?e.jsx("div",{className:"absolute top-0 left-0 w-full max-w-[640px] max-h-[310px] min-h-[64px] bg-theme-settings-input-bg rounded-lg flex flex-col justify-between cursor-pointer border-2 border-primary-button z-20",children:e.jsxs("div",{className:"w-full flex flex-col gap-y-1",children:[e.jsxs("div",{className:"flex items-center sticky top-0 z-10 border-b border-[#9CA3AF] mx-4 bg-theme-settings-input-bg",children:[e.jsx(K,{size:20,weight:"bold",className:"absolute left-4 z-30 text-theme-text-primary -ml-4 my-2"}),e.jsx("input",{type:"text",name:"llm-search",autoComplete:"off",placeholder:b("chat.llm.search"),className:"border-none -ml-4 my-2 bg-transparent z-20 pl-12 h-[38px] w-full px-4 py-1 text-sm outline-none focus:outline-primary-button active:outline-primary-button outline-none text-theme-text-primary placeholder:text-theme-text-primary placeholder:font-medium",onChange:m=>c(m.target.value),ref:g,onKeyDown:m=>{m.key==="Enter"&&m.preventDefault()}}),e.jsx($,{size:20,weight:"bold",className:"cursor-pointer text-theme-text-primary hover:text-x-button",onClick:u})]}),e.jsx("div",{className:"flex-1 pl-4 pr-2 flex flex-col gap-y-1 overflow-y-auto white-scrollbar pb-4 max-h-[245px]",children:i.map(m=>e.jsx(ht,{llm:m,availableLLMs:O,settings:s,checked:n===m.value,onClick:()=>x(m.value)},m.name))})]})}):e.jsxs("button",{className:"w-full max-w-[640px] h-[64px] bg-theme-settings-input-bg rounded-lg flex items-center p-[14px] justify-between cursor-pointer border-2 border-transparent hover:border-primary-button transition-all duration-300",type:"button",onClick:()=>f(!0),children:[e.jsxs("div",{className:"flex gap-x-4 items-center",children:[e.jsx("img",{src:p.logo,alt:`${p.name} logo`,className:"w-10 h-10 rounded-md"}),e.jsxs("div",{className:"flex flex-col text-left",children:[e.jsx("div",{className:"text-sm font-semibold text-white",children:p.name}),e.jsx("div",{className:"mt-1 text-xs text-description",children:p.description})]})]}),e.jsx(ce,{size:24,weight:"bold",className:"text-white"})]})]}),e.jsx(wt,{selectedLLM:n,workspace:t,setHasChanges:r})]})}function wt({selectedLLM:s,workspace:t,setHasChanges:r}){return s==="anythingllm-router"?e.jsx(ft,{workspace:t,setHasChanges:r}):gt.includes(s)?s!=="default"?e.jsx("div",{className:"w-full h-10 justify-center items-center flex mt-4",children:e.jsxs("p",{className:"text-sm font-base text-white text-opacity-60 text-center",children:["Multi-model support is not supported for this provider yet.",e.jsx("br",{}),"This workspace will use"," ",e.jsx(R,{to:M.settings.llmPreference(),className:"underline",children:"the model set for the system."})]})}):null:bt.includes(s)?e.jsx(Nt,{workspace:t,setHasChanges:r}):e.jsx(pt,{provider:s,workspace:t,setHasChanges:r})}function Nt({workspace:s,setHasChanges:t}){const{t:r}=w();return e.jsxs("div",{className:"mt-4 flex flex-col gap-y-1",children:[e.jsx("label",{className:"block input-label",children:r("chat.model.title")}),e.jsx("p",{className:"text-white text-opacity-60 text-xs font-medium py-1.5",children:r("chat.model.description")}),e.jsx("input",{type:"text",name:"chatModel",defaultValue:(s==null?void 0:s.chatModel)||"",onChange:()=>t(!0),className:"border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5",placeholder:"Enter model name exactly as referenced in the API (e.g., gpt-3.5-turbo)"})]})}function St({workspace:s,setHasChanges:t}){const{t:r}=w();return e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("label",{htmlFor:"name",className:"block input-label",children:r("chat.refusal.title")}),e.jsxs("p",{className:"text-white text-opacity-60 text-xs font-medium py-1.5",children:[r("chat.refusal.desc-start")," ",e.jsx("code",{className:"border-none bg-theme-settings-input-bg p-0.5 rounded-sm",children:r("chat.refusal.query")})," ",r("chat.refusal.desc-end")]})]}),e.jsx("textarea",{name:"queryRefusalResponse",rows:2,defaultValue:Me(s),className:"border-none bg-theme-settings-input-bg placeholder:text-theme-settings-input-placeholder text-white text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5 mt-2",placeholder:"The text returned in query mode when there is no relevant context found for a response.",required:!0,wrap:"soft",autoComplete:"off",onChange:()=>t(!0)})]})}function Ct({workspace:s}){const[t,r]=a.useState({}),[i,l]=a.useState(!1),[n,d]=a.useState(!1),o=a.useRef(null);a.useEffect(()=>{async function h(){const f=await F.keys();r(f??{})}h()},[]);const c=async h=>{h.preventDefault(),d(!0);const f={},g=new FormData(o.current);for(var[b,x]of g.entries())f[b]=I(b,x);const{workspace:u,message:p}=await L.update(s.slug,f);u?(C("Workspace updated!","success",{clear:!0}),l(!1)):C(`Error: ${p}`,"error",{clear:!0}),d(!1)};return s?e.jsx("div",{id:"workspace-chat-settings-container",className:"relative",children:e.jsxs("form",{ref:o,onSubmit:c,id:"chat-settings-form",className:"w-1/2 flex flex-col gap-y-6",children:[i&&e.jsx("div",{className:"absolute top-0 right-0",children:e.jsx(U,{type:"submit",children:n?"Updating...":"Update Workspace"})}),e.jsx(vt,{settings:t,workspace:s,setHasChanges:l}),e.jsx(dt,{workspace:s,setHasChanges:l}),e.jsx(st,{workspace:s,setHasChanges:l}),e.jsx(lt,{workspace:s,setHasChanges:l,hasChanges:i}),e.jsx(St,{workspace:s,setHasChanges:l}),e.jsx(ct,{settings:t,workspace:s,setHasChanges:l})]})}):null}function Mt({workspace:s}){const{t}=w();return e.jsxs("div",{children:[e.jsx("h3",{className:"input-label",children:t("vector-workspace.identifier")}),e.jsx("p",{className:"text-white/60 text-xs font-medium py-1",children:" "}),e.jsx("p",{className:"text-white/60 text-sm",children:s==null?void 0:s.slug})]})}function kt({workspace:s,setHasChanges:t}){const{t:r}=w();return e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("label",{htmlFor:"name",className:"block input-label",children:r("vector-workspace.snippets.title")}),e.jsxs("p",{className:"text-white text-opacity-60 text-xs font-medium py-1.5",children:[r("vector-workspace.snippets.description"),e.jsx("br",{}),e.jsx("i",{children:r("vector-workspace.snippets.recommend")})]})]}),e.jsx("input",{name:"topN",type:"number",min:1,max:200,step:1,onWheel:i=>i.target.blur(),defaultValue:(s==null?void 0:s.topN)??4,className:"border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5 mt-2",placeholder:"4",required:!0,autoComplete:"off",onChange:()=>t(!0)})]})}function Et({workspace:s,setHasChanges:t}){const{t:r}=w();return e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("label",{htmlFor:"name",className:"block input-label",children:r("vector-workspace.doc.title")}),e.jsx("p",{className:"text-white text-opacity-60 text-xs font-medium py-1.5",children:r("vector-workspace.doc.description")})]}),e.jsxs("select",{name:"similarityThreshold",defaultValue:(s==null?void 0:s.similarityThreshold)??.25,className:"border-none bg-theme-settings-input-bg text-white text-sm mt-2 rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5",onChange:()=>t(!0),required:!0,children:[e.jsx("option",{value:0,children:r("vector-workspace.doc.zero")}),e.jsx("option",{value:.25,children:r("vector-workspace.doc.low")}),e.jsx("option",{value:.5,children:r("vector-workspace.doc.medium")}),e.jsx("option",{value:.75,children:r("vector-workspace.doc.high")})]})]})}function Lt({workspace:s}){const[t,r]=a.useState(!1),{t:i}=w(),l=async()=>{if(!window.confirm(`${i("vector-workspace.reset.confirm")}`))return!1;if(r(!0),!await L.wipeVectorDb(s.slug)){C(i("vector-workspace.reset.error"),i("vector-workspace.common.error"),{clear:!0}),r(!1);return}C(i("vector-workspace.reset.success"),i("vector-workspace.common.success"),{clear:!0}),r(!1)};return e.jsx("button",{disabled:t,onClick:l,type:"button",className:"w-60 transition-all duration-300 border border-transparent rounded-lg whitespace-nowrap text-sm px-5 py-2.5 focus:z-10 bg-red-500/25 text-red-200 light:text-red-500 hover:light:text-[#FFFFFF] hover:text-[#FFFFFF] hover:bg-red-600 disabled:bg-red-600 disabled:text-red-200 disabled:animate-pulse",children:i(t?"vector-workspace.reset.resetting":"vector-workspace.reset.reset")})}function Ft({reload:s,workspace:t}){const[r,i]=a.useState(null),{t:l}=w();return a.useEffect(()=>{async function n(){const d=await F.totalIndexes(t.slug);i(d)}n()},[t==null?void 0:t.slug,s]),r===null?e.jsxs("div",{children:[e.jsx("h3",{className:"input-label",children:l("general.vector.title")}),e.jsx("p",{className:"text-white text-opacity-60 text-xs font-medium py-1",children:l("general.vector.description")}),e.jsx("div",{className:"text-white text-opacity-60 text-sm font-medium",children:e.jsx(te,{size:"4"})})]}):e.jsxs("div",{children:[e.jsx("h3",{className:"input-label",children:l("general.vector.title")}),e.jsx("p",{className:"text-white text-opacity-60 text-sm font-medium",children:r})]})}const At=["lancedb"],Dt={default:{title:"Default",description:"This is the fastest performance, but may not return the most relevant results leading to model hallucinations."},rerank:{title:"Accuracy Optimized",description:"LLM responses may take longer to generate, but your responses will be more accurate and relevant."}};function Pt({workspace:s,setHasChanges:t}){var l;const[r,i]=a.useState((s==null?void 0:s.vectorSearchMode)??"default");return!(s!=null&&s.vectorDB)||!At.includes(s==null?void 0:s.vectorDB)?null:e.jsxs("div",{children:[e.jsx("div",{className:"flex flex-col",children:e.jsx("label",{htmlFor:"name",className:"block input-label",children:"Search Preference"})}),e.jsxs("select",{name:"vectorSearchMode",value:r,className:"border-none bg-theme-settings-input-bg text-white text-sm mt-2 rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5",onChange:n=>{i(n.target.value),t(!0)},required:!0,children:[e.jsx("option",{value:"default",children:"Default"}),e.jsx("option",{value:"rerank",children:"Accuracy Optimized"})]}),e.jsx("p",{className:"text-white text-opacity-60 text-xs font-medium py-1.5",children:(l=Dt[r])==null?void 0:l.description})]})}function Rt({workspace:s}){const[t,r]=a.useState(!1),[i,l]=a.useState(!1),n=a.useRef(null),d=async o=>{l(!0),o.preventDefault();const c={},h=new FormData(n.current);for(var[f,g]of h.entries())c[f]=I(f,g);const{workspace:b,message:x}=await L.update(s.slug,c);b?C("Workspace updated!","success",{clear:!0}):C(`Error: ${x}`,"error",{clear:!0}),l(!1),r(!1)};return s?e.jsx("div",{className:"w-full relative",children:e.jsxs("form",{ref:n,onSubmit:d,className:"w-1/2 flex flex-col gap-y-6",children:[t&&e.jsx("div",{className:"absolute top-0 right-0",children:e.jsx(U,{type:"submit",children:i?"Updating...":"Update Workspace"})}),e.jsxs("div",{className:"flex items-start gap-x-5",children:[e.jsx(Mt,{workspace:s}),e.jsx(Ft,{reload:!0,workspace:s})]}),e.jsx(Pt,{workspace:s,setHasChanges:r}),e.jsx(kt,{workspace:s,setHasChanges:r}),e.jsx(Et,{workspace:s,setHasChanges:r}),e.jsx(Lt,{workspace:s})]})}):null}function $t({closeModal:s,workspace:t,users:r}){const[i,l]=a.useState(""),[n,d]=a.useState((t==null?void 0:t.userIds)||[]),o=async u=>{u.preventDefault();const{success:p,error:m}=await W.updateUsersInWorkspace(t.id,n);p&&(C("Users updated successfully.","success"),setTimeout(()=>{window.location.reload()},1e3)),C(m,"error")},c=u=>{d(p=>p.includes(u)?p.filter(m=>m!==u):[...p,u])},h=()=>{n.length===x.length?d([]):d(x.map(u=>u.id))},f=()=>{d([])},g=u=>n.includes(u),b=u=>{l(u.target.value)},x=r.filter(u=>u.username.toLowerCase().includes(i.toLowerCase())).filter(u=>u.role!=="admin").filter(u=>u.role!=="manager");return e.jsx("div",{className:"relative w-full max-w-[550px] max-h-full",children:e.jsxs("div",{className:"w-full max-w-2xl bg-theme-bg-secondary rounded-lg shadow border-2 border-theme-modal-border overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b rounded-t border-theme-modal-border",children:[e.jsxs("div",{className:"flex items-center gap-x-4",children:[e.jsx("h3",{className:"text-base font-semibold text-white",children:"Users"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{onChange:b,className:"w-[400px] h-[34px] bg-theme-bg-primary rounded-[100px] text-white placeholder:text-theme-text-secondary text-sm px-10 pl-10",placeholder:"Search for a user"}),e.jsx(K,{size:16,weight:"bold",className:"text-white text-lg absolute left-3 top-1/2 transform -translate-y-1/2"})]})]}),e.jsx("button",{onClick:s,type:"button",className:"border-none bg-transparent rounded-lg text-sm p-1.5 ml-auto inline-flex items-center bg-sidebar-button hover:bg-theme-modal-border hover:border-theme-modal-border hover:border-opacity-50 border-transparent border",children:e.jsx($,{className:"text-white text-lg"})})]}),e.jsxs("form",{onSubmit:o,children:[e.jsx("div",{className:"py-[17px] px-[20px]",children:e.jsx("table",{className:"gap-y-[8px] flex flex-col max-h-[385px] overflow-y-auto no-scroll",children:x.length>0?x.map(u=>e.jsxs("tr",{className:"flex items-center gap-x-2 cursor-pointer",onClick:()=>c(u.id),children:[e.jsx("div",{className:"shrink-0 w-3 h-3 rounded border-[1px] border-solid border-white light:border-black flex justify-center items-center",role:"checkbox","aria-checked":g(u.id),tabIndex:0,children:g(u.id)&&e.jsx("div",{className:"w-2 h-2 bg-white light:bg-black rounded-[2px]"})}),e.jsx("p",{className:"text-theme-text-primary text-sm font-medium",children:u.username})]},u.id)):e.jsx("p",{className:"text-theme-text-secondary text-sm font-medium ",children:"No users found"})})}),e.jsxs("div",{className:"flex w-full justify-between items-center p-3 space-x-2 border-t rounded-b border-gray-500/50",children:[e.jsxs("div",{className:"flex items-center gap-x-2",children:[e.jsxs("button",{type:"button",onClick:h,className:"flex items-center gap-x-2 ml-2",children:[e.jsx("div",{className:"shrink-0 w-3 h-3 rounded border-[1px] border-white flex justify-center items-center cursor-pointer",role:"checkbox","aria-checked":n.length===x.length,tabIndex:0,children:n.length===x.length&&e.jsx("div",{className:"w-2 h-2 bg-white rounded-[2px]"})}),e.jsx("p",{className:"text-white text-sm font-medium",children:"Select All"})]}),n.length>0&&e.jsx("button",{type:"button",onClick:f,className:"flex items-center gap-x-2 ml-2",children:e.jsx("p",{className:"text-theme-text-secondary text-sm font-medium hover:text-theme-text-primary",children:"Unselect"})})]}),e.jsx("button",{type:"submit",className:"transition-all duration-300 text-xs px-2 py-1 font-semibold rounded-lg bg-primary-button hover:bg-secondary border-2 border-transparent hover:border-primary-button hover:text-white h-[32px] w-[68px] -mr-8 whitespace-nowrap shadow-[0_4px_14px_rgba(0,0,0,0.25)]",children:"Save"})]})]})]})})}function zt({user:s}){return e.jsx(e.Fragment,{children:e.jsxs("tr",{className:"bg-transparent text-theme-text-primary text-sm font-medium",children:[e.jsx("th",{scope:"row",className:"px-6 py-4 whitespace-nowrap",children:s.username}),e.jsx("td",{className:"px-6 py-4",children:ke(s.role)}),e.jsx("td",{className:"px-6 py-4",children:s.lastUpdatedAt})]})})}function Wt({workspace:s}){const[t,r]=a.useState(!0),[i,l]=a.useState([]),[n,d]=a.useState([]),[o,c]=a.useState(null),{isOpen:h,openModal:f,closeModal:g}=V();return a.useEffect(()=>{async function b(){const x=await W.users(),u=await W.workspaceUsers(s.id),p=await W.workspaces();c(p.find(m=>m.id===s.id)),d(u),l(x),r(!1)}b()},[s]),t?e.jsx(T,{height:"80vh",width:"100%",highlightColor:"var(--theme-bg-primary)",baseColor:"var(--theme-bg-secondary)",count:1,className:"w-full p-4 rounded-b-2xl rounded-tr-2xl rounded-tl-sm mt-6",containerClassName:"flex w-full"}):e.jsxs("div",{className:"flex justify-between -mt-3",children:[e.jsxs("table",{className:"w-full max-w-[700px] text-sm text-left rounded-lg",children:[e.jsx("thead",{className:"text-white text-opacity-80 text-xs leading-[18px] font-bold uppercase border-white/10 border-b border-opacity-60",children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",className:"px-6 py-3 rounded-tl-lg",children:"Username"}),e.jsx("th",{scope:"col",className:"px-6 py-3",children:"Role"}),e.jsx("th",{scope:"col",className:"px-6 py-3",children:"Date Added"}),e.jsx("th",{scope:"col",className:"px-6 py-3 rounded-tr-lg",children:" "})]})}),e.jsx("tbody",{children:n.length>0?n.map((b,x)=>e.jsx(zt,{user:b},x)):e.jsx("tr",{children:e.jsx("td",{className:"text-center py-4 text-white/80",colSpan:"4",children:"No workspace members"})})})]}),e.jsx(U,{onClick:f,children:"Manage Users"}),e.jsx(Q,{isOpen:h,children:e.jsx($t,{closeModal:g,users:i,workspace:o})})]})}const Ot=["default","none"];function Tt({llm:s,availableLLMs:t,settings:r,checked:i,onClick:l}){const{isOpen:n,openModal:d,closeModal:o}=V(),{name:c,value:h,logo:f,description:g}=s,[b,x]=a.useState(r);a.useEffect(()=>{async function p(){if(n){const m=await F.keys();x(m??{})}}p()},[n]);function u(){if(!i){if((s.requiredConfig||[]).some(m=>!b[m])){d();return}l(h)}}return e.jsxs(e.Fragment,{children:[e.jsxs("div",{onClick:u,className:`w-full p-2 rounded-md hover:cursor-pointer hover:bg-theme-bg-secondary ${i?"bg-theme-bg-secondary":""}`,children:[e.jsx("input",{type:"checkbox",value:h,className:"peer hidden",checked:i,readOnly:!0,formNoValidate:!0}),e.jsxs("div",{className:"flex gap-x-4 items-center justify-between",children:[e.jsxs("div",{className:"flex gap-x-4 items-center",children:[e.jsx("img",{src:f,alt:`${c} logo`,className:"w-10 h-10 rounded-md"}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("div",{className:"text-sm font-semibold text-white",children:c}),e.jsx("div",{className:"mt-1 text-xs text-white/60",children:g})]})]}),i&&h!=="none"&&!Ot.includes(h)&&e.jsx("button",{onClick:p=>{p.preventDefault(),d()},className:"border-none p-2 text-white/60 hover:text-white hover:bg-theme-bg-hover rounded-md transition-all duration-300",title:"Edit Settings",children:e.jsx(re,{size:20,weight:"bold"})})]})]}),e.jsx(Ut,{availableLLMs:t,isOpen:n,provider:h,closeModal:o,postSubmit:l,settings:b})]})}function Ut({availableLLMs:s,isOpen:t,provider:r,closeModal:i,postSubmit:l,settings:n}){if(!t)return null;const d=s.find(c=>c.value===r);if(!d)return null;async function o(c){c.preventDefault(),c.stopPropagation();const h={},f=new FormData(c.target);for(var[g,b]of f.entries())h[g]=b;const{error:x}=await F.updateSystem(h);if(x){C(`Failed to save ${d.name} settings: ${x}`,"error");return}return i(),l(),!1}return ne.createPortal(e.jsx(Q,{isOpen:t,children:e.jsx("div",{className:"fixed inset-0 z-50 overflow-auto bg-black bg-opacity-50 flex items-center justify-center",children:e.jsxs("div",{className:"relative w-full max-w-2xl bg-theme-bg-secondary rounded-lg shadow border-2 border-theme-modal-border",children:[e.jsxs("div",{className:"relative p-6 border-b rounded-t border-theme-modal-border",children:[e.jsx("div",{className:"w-full flex gap-x-2 items-center",children:e.jsxs("h3",{className:"text-xl font-semibold text-white overflow-hidden overflow-ellipsis whitespace-nowrap",children:[d.name," Settings"]})}),e.jsx("button",{onClick:i,type:"button",className:"absolute top-4 right-4 transition-all duration-300 bg-transparent rounded-lg text-sm p-1 inline-flex items-center hover:bg-theme-modal-border hover:border-theme-modal-border hover:border-opacity-50 border-transparent border",children:e.jsx($,{size:24,weight:"bold",className:"text-white"})})]}),e.jsxs("form",{id:"provider-form",onSubmit:o,children:[e.jsx("div",{className:"px-7 py-6",children:e.jsxs("div",{className:"space-y-6 max-h-[60vh] overflow-y-auto p-1",children:[e.jsxs("p",{className:"text-sm text-white/60",children:["To use ",d.name," as this workspace's agent LLM you need to set it up first."]}),e.jsx("div",{children:d.options(n,{credentialsOnly:!0})})]})}),e.jsxs("div",{className:"flex justify-between items-center mt-6 pt-6 border-t border-theme-modal-border px-7 pb-6",children:[e.jsx("button",{type:"button",onClick:i,className:"transition-all duration-300 text-white hover:bg-zinc-700 px-4 py-2 rounded-lg text-sm",children:"Cancel"}),e.jsxs("button",{type:"submit",form:"provider-form",className:"transition-all duration-300 bg-white text-black hover:opacity-60 px-4 py-2 rounded-lg text-sm",children:["Save ",d.name," settings"]})]})]})]})})}),document.getElementById("workspace-agent-settings-container"))}function H(s,t=""){return s==="openai"?["gpt-3.5-turbo-0301","gpt-4-turbo-2024-04-09","gpt-4-turbo","o1-preview","o1-preview-2024-09-12","o1-mini","o1-mini-2024-09-12","o3-mini","o3-mini-2025-01-31"].includes(t)===!1:!0}function Vt({provider:s,workspace:t,setHasChanges:r}){const{slug:i}=G(),{defaultModels:l,customModels:n,loading:d}=ae(s),{t:o}=w();return le.includes(s)?e.jsx("div",{className:"w-full h-10 justify-center items-center flex",children:e.jsxs("p",{className:"text-sm font-base text-white text-opacity-60 text-center",children:["Multi-model support is not supported for this provider yet.",e.jsx("br",{}),"Agent's will use"," ",e.jsx(R,{to:M.workspace.settings.chatSettings(i),className:"underline",children:"the model set for the workspace"})," ","or"," ",e.jsx(R,{to:M.settings.llmPreference(),className:"underline",children:"the model set for the system."})]})}):d?e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("label",{htmlFor:"name",className:"block input-label",children:o("agent.mode.chat.title")}),e.jsx("p",{className:"text-white text-opacity-60 text-xs font-medium py-1.5",children:o("agent.mode.chat.description")})]}),e.jsx("select",{name:"agentModel",required:!0,disabled:!0,className:"border-none bg-theme-settings-input-bg text-white text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5",children:e.jsx("option",{disabled:!0,selected:!0,children:o("agent.mode.wait")})})]}):e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("label",{htmlFor:"name",className:"block input-label",children:o("agent.mode.title")}),e.jsx("p",{className:"text-white text-opacity-60 text-xs font-medium py-1.5",children:o("agent.mode.description")})]}),e.jsxs("select",{name:"agentModel",required:!0,onChange:()=>{r(!0)},className:"border-none bg-theme-settings-input-bg text-white text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5",children:[l.length>0&&e.jsx("optgroup",{label:"General models",children:l.map(c=>H(s,c)?e.jsx("option",{value:c,selected:(t==null?void 0:t.agentModel)===c,children:c},c):null)}),Array.isArray(n)&&n.length>0&&e.jsx("optgroup",{label:"Custom models",children:n.map(c=>H(s,c.id)?e.jsx("option",{value:c.id,selected:(t==null?void 0:t.agentModel)===c.id,children:c.id},c.id):null)}),!Array.isArray(n)&&Object.keys(n).length>0&&e.jsx(e.Fragment,{children:Object.entries(n).map(([c,h])=>e.jsx("optgroup",{label:c,children:h.map(f=>H(s,f.id)?e.jsx("option",{value:f.id,selected:(t==null?void 0:t.agentModel)===f.id,children:f.name||f.id},f.id):null)},c))})]})]})}const It=["openai","anthropic","lmstudio","ollama","localai","groq","azure","koboldcpp","togetherai","openrouter","novita","mistral","perplexity","textgenwebui","generic-openai","bedrock","fireworksai","deepseek","ppio","litellm","apipie","xai","nvidia-nim","gemini","moonshotai","cometapi","foundry","zai","giteeai","cohere","docker-model-runner","privatemode","sambanova","lemonade","minimax","cerebras"],_t=["lmstudio","koboldcpp","ollama","localai","textgenwebui","docker-model-runner"],qt={name:"System Default",value:"none",logo:oe,options:()=>e.jsx(N.Fragment,{}),description:"Agents will use the workspace or system LLM unless otherwise specified.",requiredConfig:[]},B=[qt,...ie.filter(s=>It.includes(s.value))];function Ht({settings:s,workspace:t,setHasChanges:r}){const[i,l]=a.useState([]),[n,d]=a.useState((t==null?void 0:t.agentProvider)??"none"),[o,c]=a.useState(""),[h,f]=a.useState(!1),g=a.useRef(null),{t:b}=w();function x(m){c(""),d(m),f(!1),r(!0)}function u(){o.length>0?(c(""),g.current&&(g.current.value="")):f(!h)}a.useEffect(()=>{const m=B.filter(k=>k.name.toLowerCase().includes(o.toLowerCase()));l(m)},[o,n]);const p=B.find(m=>m.value===n);return e.jsxs("div",{className:"border-b border-white/40 pb-8",children:[_t.includes(n)&&e.jsx("div",{className:"flex flex-col md:flex-row md:items-center gap-x-2 text-white mb-4 bg-blue-800/30 w-fit rounded-lg px-4 py-2",children:e.jsxs("div",{className:"gap-x-2 flex items-center",children:[e.jsx(_e,{className:"shrink-0",size:25}),e.jsx("p",{className:"text-sm",children:b("agent.performance-warning")})]})}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("label",{htmlFor:"name",className:"block input-label",children:b("agent.provider.title")}),e.jsx("p",{className:"text-white text-opacity-60 text-xs font-medium py-1.5",children:b("agent.provider.description")})]}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:"hidden",name:"agentProvider",value:n}),h&&e.jsx("div",{className:"fixed top-0 left-0 w-full h-full bg-black bg-opacity-70 backdrop-blur-sm z-10",onClick:()=>f(!1)}),h?e.jsx("div",{className:"absolute top-0 left-0 w-full max-w-[640px] max-h-[310px] min-h-[64px] bg-theme-settings-input-bg rounded-lg flex flex-col justify-between cursor-pointer border-2 border-primary-button z-20",children:e.jsxs("div",{className:"w-full flex flex-col gap-y-1",children:[e.jsxs("div",{className:"flex items-center sticky top-0 z-10 border-b border-[#9CA3AF] mx-4 bg-theme-settings-input-bg",children:[e.jsx(K,{size:20,weight:"bold",className:"absolute left-4 z-30 text-theme-text-primary -ml-4 my-2"}),e.jsx("input",{type:"text",name:"llm-search",autoComplete:"off",placeholder:"Search available LLM providers",className:"border-none -ml-4 my-2 bg-transparent z-20 pl-12 h-[38px] w-full px-4 py-1 text-sm outline-none text-theme-text-primary placeholder:text-theme-text-primary placeholder:font-medium",onChange:m=>c(m.target.value),ref:g,onKeyDown:m=>{m.key==="Enter"&&m.preventDefault()}}),e.jsx($,{size:20,weight:"bold",className:"cursor-pointer text-theme-text-primary hover:text-x-button",onClick:u})]}),e.jsx("div",{className:"flex-1 pl-4 pr-2 flex flex-col gap-y-1 overflow-y-auto white-scrollbar pb-4 max-h-[245px]",children:i.map(m=>e.jsx(Tt,{llm:m,availableLLMs:B,settings:s,checked:n===m.value,onClick:()=>x(m.value)},m.name))})]})}):e.jsxs("button",{className:"w-full max-w-[640px] h-[64px] bg-theme-settings-input-bg rounded-lg flex items-center p-[14px] justify-between cursor-pointer border-2 border-transparent hover:border-primary-button transition-all duration-300",type:"button",onClick:()=>f(!0),children:[e.jsxs("div",{className:"flex gap-x-4 items-center",children:[e.jsx("img",{src:p.logo,alt:`${p.name} logo`,className:"w-10 h-10 rounded-md"}),e.jsxs("div",{className:"flex flex-col text-left",children:[e.jsx("div",{className:"text-sm font-semibold text-white",children:p.name}),e.jsx("div",{className:"mt-1 text-xs text-description",children:p.description})]})]}),e.jsx(ce,{size:24,weight:"bold",className:"text-white"})]})]}),n!=="none"&&e.jsx("div",{className:"mt-4 flex flex-col gap-y-1",children:e.jsx(Vt,{provider:n,workspace:t,setHasChanges:r})})]})}function Bt({workspace:s}){const{user:t}=de(),[r,i]=a.useState({}),[l,n]=a.useState(!1),[d,o]=a.useState(!1),[c,h]=a.useState(!0),f=a.useRef(null);a.useEffect(()=>{async function b(){const x=await F.keys();i(x??{}),h(!1)}b()},[]);const g=async b=>{o(!0),b.preventDefault();const x={workspace:{},system:{},env:{}},u=new FormData(f.current);for(var[p,m]of u.entries()){if(p.startsWith("system::")){const[v,S]=p.split("system::");x.system[S]=String(m);continue}if(p.startsWith("env::")){const[v,S]=p.split("env::");x.env[S]=String(m);continue}x.workspace[p]=I(p,m)}const{workspace:k,message:y}=await L.update(s.slug,x.workspace);await W.updateSystemPreferences(x.system),await F.updateSystem(x.env),k?C("Workspace updated!","success",{clear:!0}):C(`Error: ${y}`,"error",{clear:!0}),o(!1),n(!1)};return!s||c?e.jsx(Zt,{}):e.jsx("div",{id:"workspace-agent-settings-container",children:e.jsxs("form",{ref:f,onSubmit:g,onChange:()=>n(!0),id:"agent-settings-form",className:"w-1/2 flex flex-col gap-y-6",children:[e.jsx(Ht,{settings:r,workspace:s,setHasChanges:n}),(!t||(t==null?void 0:t.role)==="admin")&&e.jsx(e.Fragment,{children:!l&&e.jsxs("div",{className:"flex flex-col gap-y-4",children:[e.jsx("a",{className:"w-fit transition-all duration-300 border border-slate-200 px-5 py-2.5 rounded-lg text-white text-sm items-center flex gap-x-2 hover:bg-slate-200 hover:text-slate-800 focus:ring-gray-800",href:M.settings.agentSkills(),children:"Configure Agent Skills"}),e.jsx("p",{className:"text-white text-opacity-60 text-xs font-medium",children:"Customize and enhance the default agent's capabilities by enabling or disabling specific skills. These settings will be applied across all workspaces."})]})}),l&&e.jsx("button",{type:"submit",form:"agent-settings-form",className:"w-fit transition-all duration-300 border border-slate-200 px-5 py-2.5 rounded-lg text-white text-sm items-center flex gap-x-2 hover:bg-slate-200 hover:text-slate-800 focus:ring-gray-800",children:d?"Updating agent...":"Update workspace agent"})]})})}function Zt(){return e.jsx("div",{id:"workspace-agent-settings-container",children:e.jsxs("div",{className:"w-1/2 flex flex-col gap-y-6",children:[e.jsx(T,{height:100,width:"100%",count:2,highlightColor:"var(--theme-bg-primary)",baseColor:"var(--theme-bg-secondary)",enableAnimation:!0,containerClassName:"flex flex-col gap-y-1"}),e.jsx("div",{className:"bg-white/10 h-[1px] w-full"}),e.jsx(T,{height:100,width:"100%",count:2,highlightColor:"var(--theme-bg-primary)",baseColor:"var(--theme-bg-secondary)",enableAnimation:!0,containerClassName:"flex flex-col gap-y-1 mt-4"})]})})}const Gt={"general-appearance":tt,"chat-settings":Ct,"vector-database":Rt,members:Wt,"agent-config":Bt};function fs(){const{loading:s,requiresAuth:t,mode:r}=Ee();return s?e.jsx(ue,{}):t!==!1?e.jsx(e.Fragment,{children:t!==null&&e.jsx(Le,{mode:r})}):e.jsx(Qt,{})}function Qt(){const{t:s}=w(),{slug:t,tab:r}=G(),{user:i}=de(),l=se("agentMode"),[n,d]=a.useState(null),[o,c]=a.useState(!1),[h,f]=a.useState(!0);if(a.useEffect(()=>{async function b(){if(!t)return;const x=await L.bySlug(t);if(!x){f(!1);return}const u=await F.keys(),p=await L.getSuggestedMessages(t);d({...x,vectorDB:u==null?void 0:u.VectorDB,suggestedMessages:p}),c((u==null?void 0:u.WorkspaceDeletionProtection)===!0),f(!1)}b()},[t,r]),h)return e.jsx(ue,{});if(r==="agent-config"&&!l.enabled)return e.jsx(Fe,{to:M.workspace.settings.generalAppearance(t),replace:!0});const g=Gt[r];return e.jsxs("div",{className:"w-screen h-screen overflow-hidden bg-zinc-950 light:bg-slate-50 flex",children:[!X&&e.jsx(Re,{}),e.jsxs("div",{style:{height:X?"100%":"calc(100% - 32px)"},className:"transition-all duration-500 relative md:ml-[2px] md:mr-[16px] md:my-[16px] md:rounded-[16px] bg-theme-bg-secondary w-full h-full overflow-y-scroll",children:[e.jsxs("div",{className:"flex gap-x-10 pt-6 pb-4 ml-16 mr-8 border-b-2 border-white light:border-theme-chat-input-border border-opacity-10",children:[e.jsx(R,{to:M.workspace.chat(t),className:"absolute top-2 left-2 md:top-4 md:left-4 transition-all duration-300 p-2 rounded-full text-white bg-theme-sidebar-footer-icon hover:bg-theme-sidebar-footer-icon-hover z-10",children:e.jsx(Ae,{className:"h-5 w-5",weight:"fill"})}),e.jsx(z,{title:s("workspaces—settings.general"),icon:e.jsx(De,{className:"h-6 w-6"}),to:M.workspace.settings.generalAppearance(t)}),e.jsx(z,{title:s("workspaces—settings.chat"),icon:e.jsx($e,{className:"h-6 w-6"}),to:M.workspace.settings.chatSettings(t)}),e.jsx(z,{title:s("workspaces—settings.vector"),icon:e.jsx(ze,{className:"h-6 w-6"}),to:M.workspace.settings.vectorDatabase(t),visible:l.enabled}),e.jsx(z,{title:s("workspaces—settings.members"),icon:e.jsx(me,{className:"h-6 w-6"}),to:M.workspace.settings.members(t),visible:["admin","manager"].includes(i==null?void 0:i.role)}),e.jsx(z,{title:s("workspaces—settings.agent"),icon:e.jsx(We,{className:"h-6 w-6"}),to:M.workspace.settings.agentConfig(t),visible:l.enabled})]}),e.jsx("div",{className:"px-16 py-6",children:e.jsx(g,{slug:t,workspace:n,deletionProtected:o})})]})]})}function z({title:s,icon:t,to:r,visible:i=!0}){return i?e.jsxs(Pe,{to:r,className:({isActive:l})=>`${l?"text-sky-400 pb-4 border-b-[4px] -mb-[19px] border-sky-400":"text-white/60 hover:text-sky-400"} flex gap-x-2 items-center font-medium`,children:[t,e.jsx("div",{children:s})]}):null}export{fs as default};
1
+ import{R as N,r as a,g as ye,u as w,j as e,h as te,k as $,I as je,W as L,c as C,l as G,p as M,C as U,A as _,m as q,D as ve,S as T,n as we,o as Ne,q as V,t as F,v as R,w as Se,x as se,y as re,z as ne,M as Q,B as ae,E as le,G as Ce,H as ie,J as oe,K,N as ce,O as Me,Q as ke,a as de,d as Ee,e as ue,f as Le,T as Fe,i as X,U as Ae,V as De,X as Pe}from"../index.js";import{a as Re}from"./index-ed14fe75.js";import{w as $e}from"./ChatText-35275002.js";import{D as ze}from"./Database-f1a76329.js";import{c as I,w as We}from"./types-e90e1137.js";import{H as Oe}from"./main-34958ff6.js";import{h as Te}from"./moment-49fc1b76.js";import{t as Ue}from"./truncate-dd7b0c29.js";import{P as Ve}from"./index-36acf56a.js";import{T as Ie}from"./Trans-308f36d6.js";import{A as W}from"./admin-04b020fe.js";import{w as _e}from"./Gauge-e6762f4d.js";import"./XCircle-edfe554c.js";import"./File-b92df2f3.js";import"./Eye-9f033dc0.js";import"./index-4fb4d421.js";import"./react-beautiful-dnd.esm-149a7a55.js";import"./communityHub-aba61686.js";import"./Brain-24e386d5.js";import"./Browser-1820fad0.js";const qe=new Map([["bold",N.createElement(N.Fragment,null,N.createElement("path",{d:"M234.38,210a123.36,123.36,0,0,0-60.78-53.23,76,76,0,1,0-91.2,0A123.36,123.36,0,0,0,21.62,210a12,12,0,1,0,20.77,12c18.12-31.32,50.12-50,85.61-50s67.49,18.69,85.61,50a12,12,0,0,0,20.77-12ZM76,96a52,52,0,1,1,52,52A52.06,52.06,0,0,1,76,96Z"}))],["duotone",N.createElement(N.Fragment,null,N.createElement("path",{d:"M192,96a64,64,0,1,1-64-64A64,64,0,0,1,192,96Z",opacity:"0.2"}),N.createElement("path",{d:"M230.92,212c-15.23-26.33-38.7-45.21-66.09-54.16a72,72,0,1,0-73.66,0C63.78,166.78,40.31,185.66,25.08,212a8,8,0,1,0,13.85,8c18.84-32.56,52.14-52,89.07-52s70.23,19.44,89.07,52a8,8,0,1,0,13.85-8ZM72,96a56,56,0,1,1,56,56A56.06,56.06,0,0,1,72,96Z"}))],["fill",N.createElement(N.Fragment,null,N.createElement("path",{d:"M230.93,220a8,8,0,0,1-6.93,4H32a8,8,0,0,1-6.92-12c15.23-26.33,38.7-45.21,66.09-54.16a72,72,0,1,1,73.66,0c27.39,8.95,50.86,27.83,66.09,54.16A8,8,0,0,1,230.93,220Z"}))],["light",N.createElement(N.Fragment,null,N.createElement("path",{d:"M229.19,213c-15.81-27.32-40.63-46.49-69.47-54.62a70,70,0,1,0-63.44,0C67.44,166.5,42.62,185.67,26.81,213a6,6,0,1,0,10.38,6C56.4,185.81,90.34,166,128,166s71.6,19.81,90.81,53a6,6,0,1,0,10.38-6ZM70,96a58,58,0,1,1,58,58A58.07,58.07,0,0,1,70,96Z"}))],["regular",N.createElement(N.Fragment,null,N.createElement("path",{d:"M230.92,212c-15.23-26.33-38.7-45.21-66.09-54.16a72,72,0,1,0-73.66,0C63.78,166.78,40.31,185.66,25.08,212a8,8,0,1,0,13.85,8c18.84-32.56,52.14-52,89.07-52s70.23,19.44,89.07,52a8,8,0,1,0,13.85-8ZM72,96a56,56,0,1,1,56,56A56.06,56.06,0,0,1,72,96Z"}))],["thin",N.createElement(N.Fragment,null,N.createElement("path",{d:"M227.46,214c-16.52-28.56-43-48.06-73.68-55.09a68,68,0,1,0-51.56,0c-30.64,7-57.16,26.53-73.68,55.09a4,4,0,0,0,6.92,4C55,184.19,89.62,164,128,164s73,20.19,92.54,54a4,4,0,0,0,3.46,2,3.93,3.93,0,0,0,2-.54A4,4,0,0,0,227.46,214ZM68,96a60,60,0,1,1,60,60A60.07,60.07,0,0,1,68,96Z"}))]]);var He=Object.defineProperty,Be=Object.defineProperties,Ze=Object.getOwnPropertyDescriptors,Y=Object.getOwnPropertySymbols,Ge=Object.prototype.hasOwnProperty,Qe=Object.prototype.propertyIsEnumerable,J=(s,t,r)=>t in s?He(s,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[t]=r,Ke=(s,t)=>{for(var r in t||(t={}))Ge.call(t,r)&&J(s,r,t[r]);if(Y)for(var r of Y(t))Qe.call(t,r)&&J(s,r,t[r]);return s},Xe=(s,t)=>Be(s,Ze(t));const me=a.forwardRef((s,t)=>N.createElement(ye,Xe(Ke({ref:t},s),{weights:qe})));me.displayName="User";function Ye({workspace:s,setHasChanges:t}){const{t:r}=w();return e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("label",{htmlFor:"name",className:"block input-label",children:r("common.workspaces-name")}),e.jsx("p",{className:"text-white text-opacity-60 text-xs font-medium py-1.5",children:r("general.names.description")})]}),e.jsx("input",{name:"name",type:"text",minLength:2,maxLength:80,defaultValue:s==null?void 0:s.name,className:"border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5",placeholder:"My Workspace",required:!0,autoComplete:"off",onChange:()=>t(!0)})]})}function Je({slug:s}){const[t,r]=a.useState([]),[i,l]=a.useState(-1),[n,d]=a.useState({heading:"",message:""}),[o,c]=a.useState(!1),[h,f]=a.useState(!0),{t:g}=w();a.useEffect(()=>{async function y(){if(!s)return;const v=await L.getSuggestedMessages(s);r(v),f(!1)}y()},[s]);const b=async()=>{const y=t.filter(E=>{var D,P;return((P=(D=E==null?void 0:E.message)==null?void 0:D.trim())==null?void 0:P.length)>0}),{success:v,error:S}=await L.setSuggestedMessages(s,y);if(!v){C(`Failed to update suggested chat messages: ${S}`,"error");return}r(y),l(-1),c(!1)},x=()=>{if(l(-1),t.length>=4){C("Maximum of 4 messages allowed.","warning");return}const y={heading:"",message:`${g("general.message.heading")} ${g("general.message.body")}`};d(y),r([...t,{...y}]),c(!0)},u=y=>{const v=[...t];v.splice(y,1),r(v),c(!0)},p=(y,v)=>{y.preventDefault(),l(v);const S=t[v];if(S.heading){const E={heading:"",message:`${S.heading} ${S.message}`};d(E),r(t.map((D,P)=>P===v?E:D))}else d({...S})},m=y=>{u(y),l(-1)},k=y=>{const v={...n,[y.target.name]:y.target.value};d(v);const S=t.map((E,D)=>D===i?{...E,[y.target.name]:y.target.value}:E);r(S),c(!0)};return h?e.jsxs("div",{className:"flex flex-col",children:[e.jsx("label",{className:"block input-label",children:g("general.message.title")}),e.jsx("p",{className:"text-white text-opacity-60 text-xs font-medium py-1.5",children:g("general.message.description")}),e.jsx("div",{className:"text-white text-opacity-60 text-sm font-medium mt-6",children:e.jsx(te,{size:"4"})})]}):e.jsxs("div",{className:"w-full mt-6",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("label",{className:"block input-label",children:g("general.message.title")}),e.jsx("p",{className:"text-white text-opacity-60 text-xs font-medium py-1.5",children:g("general.message.description")})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6 text-white/60 text-xs mt-2 w-full justify-center max-w-[600px]",children:t.map((y,v)=>e.jsxs("div",{className:"relative w-full",children:[e.jsx("button",{className:"transition-all duration-300 absolute z-10 text-neutral-700 bg-white rounded-full hover:bg-zinc-600 hover:border-zinc-600 hover:text-white border-transparent border shadow-lg ml-2",style:{top:-8,left:265},onClick:()=>m(v),children:e.jsx($,{className:"m-[1px]",size:20})}),e.jsx("button",{onClick:S=>p(S,v),className:`text-left p-2.5 border rounded-xl w-full border-white/20 bg-theme-settings-input-bg hover:bg-theme-sidebar-item-selected-gradient ${i===v?"border-sky-400":""}`,children:e.jsxs("p",{className:"line-clamp-2 text-theme-text-primary",children:[y!=null&&y.heading?`${y.heading} `:"",(y==null?void 0:y.message)??""]})},v)]},v))}),i>=0&&e.jsx("div",{className:"flex flex-col gap-y-4 mr-2 mt-8",children:e.jsxs("div",{className:"w-1/2",children:[e.jsx("label",{className:"text-white text-sm font-semibold block mb-2",children:"Message"}),e.jsx("input",{placeholder:"Message",className:"border-none bg-theme-settings-input-bg text-white placeholder:text-white/20 text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block p-2.5 w-full",value:n.message,name:"message",onChange:k})]})}),t.length<4&&e.jsxs("button",{type:"button",onClick:x,className:"flex gap-x-2 items-center justify-center mt-6 text-white text-sm hover:text-sky-400 transition-all duration-300",children:[g("general.message.add")," ",e.jsx(je,{className:"",size:24,weight:"fill"})]}),o&&e.jsx("div",{className:"flex justify-start py-6",children:e.jsx("button",{type:"button",className:"transition-all duration-300 border border-slate-200 px-4 py-2 rounded-lg text-white text-sm items-center flex gap-x-2 hover:bg-slate-200 hover:text-slate-800 focus:ring-gray-800",onClick:b,children:g("general.message.save")})})]})}function et({workspace:s,visible:t=!0}){const{slug:r}=G(),[i,l]=a.useState(!1),{t:n}=w(),d=async()=>{if(!window.confirm(`${n("general.delete.confirm-start")} ${s.name} ${n("general.delete.confirm-end")}`))return!1;if(l(!0),!await L.delete(s.slug)){C("Workspace could not be deleted!","error",{clear:!0}),l(!1);return}s.slug===r?window.location=M.home():window.location.reload()};return t?e.jsxs("div",{className:"flex flex-col mt-10",children:[e.jsx("label",{className:"block input-label",children:n("general.delete.title")}),e.jsx("p",{className:"text-theme-text-secondary text-xs font-medium py-1.5",children:n("general.delete.description")}),e.jsx("button",{disabled:i,onClick:d,type:"button",className:"w-60 mt-4 transition-all duration-300 border border-transparent rounded-lg whitespace-nowrap text-sm px-5 py-2.5 focus:z-10 bg-red-500/25 text-red-200 light:text-red-500 hover:light:text-[#FFFFFF] hover:text-[#FFFFFF] hover:bg-red-600 disabled:bg-red-600 disabled:text-red-200 disabled:animate-pulse",children:n(i?"general.delete.deleting":"general.delete.delete")})]}):null}function tt({slug:s,deletionProtected:t=!1}){const[r,i]=a.useState(null),[l,n]=a.useState(!1),[d,o]=a.useState(!1),[c,h]=a.useState(!0),f=a.useRef(null);a.useEffect(()=>{async function b(){const x=await L.bySlug(s);i(x),h(!1)}b()},[s]);const g=async b=>{o(!0),b.preventDefault();const x={},u=new FormData(f.current);for(var[p,m]of u.entries())x[p]=I(p,m);const{workspace:k,message:y}=await L.update(r.slug,x);k?C("Workspace updated!","success",{clear:!0}):C(`Error: ${y}`,"error",{clear:!0}),o(!1),n(!1)};return!r||c?null:e.jsxs("div",{className:"w-full relative",children:[e.jsxs("form",{ref:f,onSubmit:g,className:"w-1/2 flex flex-col gap-y-6",children:[l&&e.jsx("div",{className:"absolute top-0 right-0",children:e.jsx(U,{type:"submit",children:d?"Updating...":"Update Workspace"})}),e.jsx(Ye,{workspace:r,setHasChanges:n},r.slug)]}),e.jsx(Je,{slug:r.slug}),e.jsx(et,{workspace:r,visible:!t})]})}function st({workspace:s,setHasChanges:t}){const{t:r}=w();return e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-col gap-y-1 mb-4",children:[e.jsx("label",{htmlFor:"name",className:"block mb-2 input-label",children:r("chat.history.title")}),e.jsxs("p",{className:"text-white text-opacity-60 text-xs font-medium",children:[r("chat.history.desc-start"),e.jsxs("i",{children:[" ",r("chat.history.recommend")," "]}),r("chat.history.desc-end")]})]}),e.jsx("input",{name:"openAiHistory",type:"number",min:1,max:45,step:1,onWheel:i=>i.target.blur(),defaultValue:(s==null?void 0:s.openAiHistory)??20,className:"border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5",placeholder:"20",required:!0,autoComplete:"off",onChange:()=>t(!0)})]})}const Z={forWorkspace:async function(s){try{return await fetch(`${_}/workspace/${s}/prompt-history`,{method:"GET",headers:q()}).then(t=>t.json()).then(t=>t.history||[]).catch(t=>(console.error("Error fetching prompt history:",t),[]))}catch(t){return console.error("Error fetching prompt history:",t),[]}},clearAll:async function(s){try{return await fetch(`${_}/workspace/${s}/prompt-history`,{method:"DELETE",headers:q()}).then(t=>t.json()).catch(t=>(console.error("Error clearing prompt history:",t),{success:!1,error:t}))}catch(t){return console.error("Error clearing prompt history:",t),{success:!1,error:t}}},delete:async function(s){try{return await fetch(`${_}/workspace/prompt-history/${s}`,{method:"DELETE",headers:q()}).then(t=>t.json()).catch(t=>(console.error("Error deleting prompt history:",t),{success:!1,error:t}))}catch(t){return console.error("Error deleting prompt history:",t),{success:!1,error:t}}}},ee=200;function rt({id:s,prompt:t,modifiedAt:r,user:i,onRestore:l,setHistory:n,onPublishClick:d}){const{t:o}=w(),[c,h]=a.useState(!1),f=a.useRef(null),g=a.useRef(null),[b,x]=a.useState(!1),u=async p=>{if(window.confirm(o("chat.prompt.history.deleteConfirm"))){const{success:m}=await Z.delete(p);m&&n(k=>k.filter(y=>y.id!==p))}};return a.useEffect(()=>{const p=m=>{c&&!f.current.contains(m.target)&&!g.current.contains(m.target)&&h(!1)};return document.addEventListener("mousedown",p),()=>{document.removeEventListener("mousedown",p)}},[c]),e.jsxs("div",{className:"text-white",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"text-xs",children:[i&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-primary-button",children:i.username})," ",e.jsx("span",{className:"mx-1 text-white",children:"•"})]}),e.jsx("span",{className:"text-white opacity-50 light:opacity-100",children:Te(r).fromNow()})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",className:"border-none text-sm cursor-pointer text-theme-text-primary hover:text-primary-button",onClick:l,children:o("chat.prompt.history.restore")}),e.jsxs("div",{className:"relative",children:[e.jsx("button",{type:"button",ref:g,className:"border-none text-theme-text-secondary cursor-pointer hover:text-primary-button flex items-center justify-center",onClick:()=>h(!c),children:e.jsx(ve,{size:16,weight:"bold"})}),c&&e.jsxs("div",{ref:f,className:"absolute right-0 top-6 bg-theme-bg-popup-menu rounded-lg z-50 min-w-[200px]",children:[e.jsx("button",{type:"button",className:"px-[10px] py-[6px] text-sm text-white hover:bg-theme-sidebar-item-hover rounded-t-lg cursor-pointer border-none w-full text-left whitespace-nowrap",onClick:()=>{h(!1),d(t)},children:o("chat.prompt.history.publish")}),e.jsx("button",{type:"button",className:"px-[10px] py-[6px] text-sm text-white hover:bg-red-500/60 light:hover:bg-red-300/80 rounded-b-lg cursor-pointer border-none w-full text-left whitespace-nowrap",onClick:()=>{h(!1),u(s)},children:o("chat.prompt.history.delete")})]})]})]})]}),e.jsx("div",{className:"flex items-center mt-1",children:e.jsx("div",{className:"text-theme-text-primary text-sm font-medium break-all whitespace-pre-wrap",children:t.length>ee&&!b?e.jsxs(e.Fragment,{children:[Ue(t,ee)," ",e.jsx("button",{type:"button",className:"text-theme-text-secondary hover:text-primary-button border-none",onClick:()=>x(!b),children:o("chat.prompt.history.expand")})]}):t})})]})}const nt=a.forwardRef(function({show:t,workspaceSlug:r,onRestore:i,onClose:l,onPublishClick:n},d){const{t:o}=w(),[c,h]=a.useState([]),[f,g]=a.useState(!0);function b(){r&&(g(!0),Z.forWorkspace(r).then(u=>{h(u)}).catch(u=>{console.error(u)}).finally(()=>{g(!1)}))}function x(){r&&window.confirm(o("chat.prompt.history.clearAllConfirm"))&&Z.clearAll(r).then(({success:u})=>{u&&h([])}).catch(u=>{console.error(u)})}return a.useEffect(()=>{t&&r&&b()},[t,r]),e.jsxs("div",{ref:d,className:`fixed right-3 top-3 bottom-3 w-[375px] bg-theme-action-menu-bg light:bg-theme-home-update-card-bg rounded-xl py-4 px-4 z-[9999] overflow-y-hidden ${t?"translate-x-0 opacity-100 visible":"translate-x-full opacity-0 invisible"} transition-all duration-300`,children:[e.jsxs("div",{className:"sticky flex items-center justify-between",children:[e.jsx("div",{className:"text-theme-text-primary text-sm font-semibold",children:o("chat.prompt.history.title")}),e.jsxs("div",{className:"flex items-center gap-2",children:[c.length>0&&e.jsx("button",{type:"button",className:"text-sm font-medium text-theme-text-secondary cursor-pointer hover:text-primary-button border-none",onClick:x,children:o("chat.prompt.history.clearAll")}),e.jsx("button",{type:"button",className:"text-theme-text-secondary cursor-pointer hover:text-primary-button border-none",onClick:l,children:e.jsx($,{size:16,weight:"bold"})})]})]}),e.jsx("div",{className:"mt-4 flex flex-col gap-y-[14px] h-full overflow-y-scroll pb-[50px]",children:f?e.jsx(at,{}):c.length===0?e.jsx("div",{className:"flex text-theme-text-secondary text-sm text-center w-full h-full flex items-center justify-center",children:o("chat.prompt.history.noHistory")}):c.map(u=>e.jsx(rt,{id:u.id,...u,onRestore:()=>i(u.prompt),onPublishClick:n,setHistory:h},u.id))})]})});function at(){const s="var(--theme-bg-primary)",t="var(--theme-bg-secondary)";return e.jsx(T,{height:"85px",width:"100%",highlightColor:s,baseColor:t,count:8})}function lt({workspace:s,setHasChanges:t,hasChanges:r}){const{t:i}=w(),[l]=we(),n=Ne(s),[d,o]=a.useState(n),[c,h]=a.useState(n),[f,g]=a.useState(""),[b,x]=a.useState(!1),[u,p]=a.useState(!1),[m,k]=a.useState([]),y=a.useRef(null),v=a.useRef(null),S=a.useRef(null),{isOpen:E,closeModal:D,openModal:P}=V(),he=d!==c,xe=(c==null?void 0:c.trim())!==(n==null?void 0:n.trim()),pe=!b&&(d==null?void 0:d.trim().length)>=10&&(he||xe);a.useEffect(()=>{async function j(){const{variables:A}=await Se.getAll();k(A)}j(),l.get("action")==="focus-system-prompt"&&x(!0)},[l]),a.useEffect(()=>{r||h(d)},[r,d]),a.useEffect(()=>{b&&y.current&&y.current.focus()},[b]),a.useEffect(()=>{F.fetchDefaultSystemPrompt().then(({defaultSystemPrompt:j})=>g(j))},[]),a.useEffect(()=>{const j=A=>{v.current&&!v.current.contains(A.target)&&S.current&&!S.current.contains(A.target)&&p(!1)};return document.addEventListener("mousedown",j),()=>document.removeEventListener("mousedown",j)},[]);const fe=j=>{o(j),p(!1),t(!0)},be=j=>{P(),p(!1),setTimeout(()=>o(j),0)},ge=()=>{F.fetchDefaultSystemPrompt().then(({defaultSystemPrompt:j})=>{o(j),t(!0)})};return e.jsxs(e.Fragment,{children:[e.jsx(nt,{ref:v,workspaceSlug:s.slug,show:u,onRestore:fe,onPublishClick:be,onClose:()=>p(!1)}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsx("label",{htmlFor:"name",className:"block input-label",children:i("chat.prompt.title")})}),e.jsx("p",{className:"text-white text-opacity-60 text-xs font-medium py-1.5",children:i("chat.prompt.description")}),e.jsxs("p",{className:"text-white text-opacity-60 text-xs font-medium mb-2",children:["You can insert"," ",e.jsx(R,{to:M.settings.systemPromptVariables(),className:"text-primary-button",children:"prompt variables"})," ","like:"," ",m.slice(0,3).map((j,A)=>e.jsxs(a.Fragment,{children:[e.jsx("span",{className:"bg-theme-settings-input-bg px-1 py-0.5 rounded",children:`{${j.key}}`}),A<m.length-1&&", "]},j.key)),m.length>3&&e.jsxs(R,{to:M.settings.systemPromptVariables(),className:"text-primary-button",children:["+",m.length-3," more..."]})]})]}),e.jsx("input",{type:"hidden",name:"openAiPrompt",value:d}),e.jsxs("div",{className:"relative w-full flex flex-col items-end",children:[e.jsx("button",{ref:S,type:"button",className:"text-theme-text-secondary hover:text-white light:hover:text-black text-xs font-medium",onClick:j=>{j.preventDefault(),p(!u)},children:u?"Hide History":"View History"}),e.jsx("div",{className:"relative w-full",children:b?e.jsx("textarea",{ref:y,autoFocus:!0,rows:5,onFocus:j=>{const A=j.target.value.length;j.target.setSelectionRange(A,A)},onBlur:j=>{x(!1),o(j.target.value)},onChange:j=>{o(j.target.value),t(!0)},onPaste:j=>{o(j.target.value),t(!0)},style:{resize:"vertical",overflowY:"scroll",minHeight:"150px"},defaultValue:d,className:"border-none bg-theme-settings-input-bg text-white text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5 mt-2"}):e.jsx("div",{onClick:()=>x(!0),style:{resize:"vertical",overflowY:"scroll",minHeight:"150px"},className:"border-none bg-theme-settings-input-bg text-white text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5 mt-2",children:e.jsx(Oe,{className:"whitespace-pre-wrap",highlightClassName:"bg-cta-button p-0.5 rounded-md",searchWords:m.map(j=>`{${j.key}}`),autoEscape:!0,caseSensitive:!0,textToHighlight:d})})}),e.jsxs("div",{className:"w-full flex flex-row items-center justify-between pt-2",children:[d!==f&&e.jsx("button",{type:"button",onClick:ge,className:"text-theme-text-primary hover:text-white light:hover:text-black text-xs font-medium",children:"Restore to Default"}),e.jsx(it,{hidden:!pe,onClick:P})]})]})]}),e.jsx(Ve,{show:E,onClose:D,entityType:"system-prompt",entity:d})]})}function it({hidden:s=!1,onClick:t}){return s?null:e.jsx("button",{type:"button",onClick:t,className:"border-none text-primary-button hover:text-white light:hover:text-black text-xs font-medium",children:"Publish to Community Hub"})}function ot(s=null){switch(s){case"mistral":return{temp:0};default:return{temp:.7}}}function ct({settings:s,workspace:t,setHasChanges:r}){const i=ot(s==null?void 0:s.LLMProvider),{t:l}=w();return e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("label",{htmlFor:"name",className:"block input-label",children:l("chat.temperature.title")}),e.jsxs("p",{className:"text-white text-opacity-60 text-xs font-medium py-1.5",children:[l("chat.temperature.desc-start"),e.jsx("br",{}),l("chat.temperature.desc-end"),e.jsx("br",{}),e.jsx("br",{}),e.jsx("i",{children:l("chat.temperature.hint")})]})]}),e.jsx("input",{name:"openAiTemp",type:"number",min:0,step:.1,onWheel:n=>n.target.blur(),defaultValue:(t==null?void 0:t.openAiTemp)??i.temp,className:"border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5",placeholder:"0.7",required:!0,autoComplete:"off",onChange:()=>r(!0)})]})}function dt({workspace:s,setHasChanges:t}){const{t:r}=w(),{enabled:i}=se("agentMode"),[l,n]=a.useState((s==null?void 0:s.chatMode)||"chat");return i?e.jsxs("div",{children:[e.jsx("div",{className:"flex flex-col",children:e.jsx("label",{htmlFor:"chatMode",className:"block input-label",children:r("chat.mode.title")})}),e.jsxs("div",{className:"flex flex-col gap-y-1 mt-2",children:[e.jsxs("div",{className:"w-fit flex gap-x-1 items-center p-1 rounded-lg bg-theme-settings-input-bg ",children:[e.jsx("input",{type:"hidden",name:"chatMode",value:l}),e.jsx("button",{type:"button",disabled:l==="automatic",onClick:()=>{n("automatic"),t(!0)},className:"border-none transition-bg duration-200 px-6 py-1 text-md text-white/60 disabled:text-white bg-transparent disabled:bg-[#687280] rounded-md hover:bg-white/10",children:r("chat.mode.automatic.title")}),e.jsx("button",{type:"button",disabled:l==="chat",onClick:()=>{n("chat"),t(!0)},className:"border-none transition-bg duration-200 px-6 py-1 text-md text-white/60 disabled:text-white bg-transparent disabled:bg-[#687280] rounded-md hover:bg-white/10 light:hover:bg-black/10",children:r("chat.mode.chat.title")}),e.jsx("button",{type:"button",disabled:l==="query",onClick:()=>{n("query"),t(!0)},className:"border-none transition-bg duration-200 px-6 py-1 text-md text-white/60 disabled:text-white bg-transparent disabled:bg-[#687280] rounded-md hover:bg-white/10 light:hover:bg-black/10",children:r("chat.mode.query.title")})]}),e.jsx(ut,{chatMode:l})]})]}):null}function ut({chatMode:s="chat"}){const{t}=w();return e.jsxs("p",{className:"text-sm text-white/60",children:[e.jsx("b",{children:t(`chat.mode.${s}.title`)})," ",e.jsx(Ie,{i18nKey:`chat.mode.${s}.description`,components:{b:e.jsx("b",{}),br:e.jsx("br",{})}})]})}const mt=["default"];function ht({llm:s,availableLLMs:t,settings:r,checked:i,onClick:l}){const{isOpen:n,openModal:d,closeModal:o}=V(),{name:c,value:h,logo:f,description:g}=s,[b,x]=a.useState(r);a.useEffect(()=>{async function p(){if(n){const m=await F.keys();x(m??{})}}p()},[n]);function u(){if(!i){if((s.requiredConfig||[]).some(m=>!b[m])){d();return}l(h)}}return e.jsxs(e.Fragment,{children:[e.jsxs("div",{onClick:u,className:`w-full p-2 rounded-md hover:cursor-pointer hover:bg-theme-bg-secondary ${i?"bg-theme-bg-secondary":""}`,children:[e.jsx("input",{type:"checkbox",value:h,className:"peer hidden",checked:i,readOnly:!0,formNoValidate:!0}),e.jsxs("div",{className:"flex gap-x-4 items-center justify-between",children:[e.jsxs("div",{className:"flex gap-x-4 items-center",children:[e.jsx("img",{src:f,alt:`${c} logo`,className:"w-10 h-10 rounded-md"}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("div",{className:"text-sm font-semibold text-white",children:c}),e.jsx("div",{className:"mt-1 text-xs text-white/60",children:g})]})]}),i&&!mt.includes(h)&&e.jsx("button",{onClick:p=>{p.preventDefault(),d()},className:"p-2 text-white/60 hover:text-white hover:bg-theme-bg-hover rounded-md transition-all duration-300",title:"Edit Settings",children:e.jsx(re,{size:20,weight:"bold"})})]})]}),e.jsx(xt,{availableLLMs:t,isOpen:n,provider:h,closeModal:o,postSubmit:l,settings:b})]})}function xt({availableLLMs:s,isOpen:t,provider:r,closeModal:i,postSubmit:l,settings:n}){if(!t)return null;const d=s.find(c=>c.value===r);if(!d)return null;async function o(c){c.preventDefault(),c.stopPropagation();const h={},f=new FormData(c.target);for(var[g,b]of f.entries())h[g]=b;const{error:x}=await F.updateSystem(h);if(x){C(`Failed to save ${d.name} settings: ${x}`,"error");return}return i(),l(),!1}return ne.createPortal(e.jsx(Q,{isOpen:t,children:e.jsx("div",{className:"fixed inset-0 z-50 overflow-auto bg-black bg-opacity-50 flex items-center justify-center",children:e.jsxs("div",{className:"relative w-full max-w-2xl bg-theme-bg-secondary rounded-lg shadow border-2 border-theme-modal-border",children:[e.jsxs("div",{className:"relative p-6 border-b rounded-t border-theme-modal-border",children:[e.jsx("div",{className:"w-full flex gap-x-2 items-center",children:e.jsxs("h3",{className:"text-xl font-semibold text-white overflow-hidden overflow-ellipsis whitespace-nowrap",children:[d.name," Settings"]})}),e.jsx("button",{onClick:i,type:"button",className:"absolute top-4 right-4 transition-all duration-300 bg-transparent rounded-lg text-sm p-1 inline-flex items-center hover:bg-theme-modal-border hover:border-theme-modal-border hover:border-opacity-50 border-transparent border",children:e.jsx($,{size:24,weight:"bold",className:"text-white"})})]}),e.jsxs("form",{id:"provider-form",onSubmit:o,children:[e.jsx("div",{className:"px-7 py-6",children:e.jsxs("div",{className:"space-y-6 max-h-[60vh] overflow-y-auto p-1",children:[e.jsxs("p",{className:"text-sm text-white/60",children:["To use ",d.name," as this workspace's LLM you need to set it up first."]}),e.jsx("div",{children:d.options(n,{credentialsOnly:!0})})]})}),e.jsxs("div",{className:"flex justify-between items-center mt-6 pt-6 border-t border-theme-modal-border px-7 pb-6",children:[e.jsx("button",{type:"button",onClick:i,className:"transition-all duration-300 text-white hover:bg-zinc-700 px-4 py-2 rounded-lg text-sm",children:"Cancel"}),e.jsx("button",{type:"submit",form:"provider-form",className:"transition-all duration-300 bg-white text-black hover:opacity-60 px-4 py-2 rounded-lg text-sm",children:"Save settings"})]})]})]})})}),document.getElementById("workspace-chat-settings-container"))}function pt({provider:s,workspace:t,setHasChanges:r}){const{defaultModels:i,customModels:l,loading:n}=ae(s),{t:d}=w();return le.includes(s)?null:n?e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-col mt-6",children:[e.jsx("label",{htmlFor:"name",className:"block input-label",children:d("chat.model.title")}),e.jsx("p",{className:"text-white text-opacity-60 text-xs font-medium py-1.5",children:d("chat.model.description")})]}),e.jsx("select",{name:"chatModel",required:!0,disabled:!0,className:"border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5",children:e.jsx("option",{disabled:!0,selected:!0,children:"-- waiting for models --"})})]}):e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-col mt-6",children:[e.jsx("label",{htmlFor:"name",className:"block input-label",children:d("chat.model.title")}),e.jsx("p",{className:"text-white text-opacity-60 text-xs font-medium py-1.5",children:d("chat.model.description")})]}),e.jsxs("select",{name:"chatModel",required:!0,onChange:()=>{r(!0)},className:"border-none bg-theme-settings-input-bg text-white text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5",children:[i.length>0&&e.jsx("optgroup",{label:"General models",children:i.map(o=>e.jsx("option",{value:o,selected:(t==null?void 0:t.chatModel)===o,children:o},o))}),Array.isArray(l)&&l.length>0&&e.jsx("optgroup",{label:"Discovered models",children:l.map(o=>e.jsx("option",{value:o.id,selected:(t==null?void 0:t.chatModel)===o.id,children:o.name||o.id},o.id))}),!Array.isArray(l)&&Object.keys(l).length>0&&e.jsx(e.Fragment,{children:Object.entries(l).map(([o,c])=>e.jsx("optgroup",{label:o,children:c.map(h=>e.jsx("option",{value:h.id,selected:(t==null?void 0:t.chatModel)===h.id,children:h.name||h.id},h.id))},o))})]})]})}function ft({workspace:s,setHasChanges:t}){const{t:r}=w(),[i,l]=a.useState([]),[n,d]=a.useState(!0);return a.useEffect(()=>{async function o(){const c=await Ce.getAll();l(c),d(!1)}o()},[]),n?e.jsx("div",{className:"mt-4",children:e.jsx("p",{className:"text-sm text-white text-opacity-60",children:r("model-router.router-selection.loading-routers")})}):i.length===0?e.jsx("div",{className:"mt-4",children:e.jsxs("p",{className:"text-sm text-white text-opacity-60",children:[r("model-router.router-selection.no-routers-prefix-workspace")," ",e.jsx(R,{to:M.settings.modelRouters(),className:"underline text-white",children:r("model-router.router-selection.no-routers-link")}),"."]})}):e.jsxs("div",{className:"mt-4 flex flex-col gap-y-1",children:[e.jsx("label",{className:"block input-label",children:r("model-router.router-selection.model-router-label")}),e.jsx("p",{className:"text-white text-opacity-60 text-xs font-medium py-1.5",children:r("model-router.router-selection.select-description")}),e.jsxs("select",{name:"router_id",defaultValue:(s==null?void 0:s.router_id)||"",onChange:()=>t(!0),className:"border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full max-w-[640px] p-2.5",required:!0,children:[e.jsx("option",{value:"",children:r("model-router.router-selection.select-router")}),i.map(o=>e.jsxs("option",{value:o.id,children:[o.name,o.description?` — ${o.description}`:""]},o.id))]})]})}const bt=["bedrock","azure","generic-openai"],gt=["default","huggingface","anythingllm-router"],yt=[],jt={name:"System default",value:"default",logo:oe,options:()=>e.jsx(N.Fragment,{}),description:"Use the system LLM preference for this workspace.",requiredConfig:[]},O=[jt,...ie].filter(s=>!yt.includes(s.value));function vt({settings:s,workspace:t,setHasChanges:r}){const[i,l]=a.useState([]),[n,d]=a.useState((t==null?void 0:t.chatProvider)??"default"),[o,c]=a.useState(""),[h,f]=a.useState(!1),g=a.useRef(null),{t:b}=w();function x(m){c(""),d(m),f(!1),r(!0)}function u(){o.length>0?(c(""),g.current&&(g.current.value="")):f(!h)}a.useEffect(()=>{const m=O.filter(k=>k.name.toLowerCase().includes(o.toLowerCase()));l(m)},[O,o,n]);const p=O.find(m=>m.value===n);return e.jsxs("div",{className:"border-b border-white/40 pb-8",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("label",{htmlFor:"name",className:"block input-label",children:b("chat.llm.title")}),e.jsx("p",{className:"text-white text-opacity-60 text-xs font-medium py-1.5",children:b("chat.llm.description")})]}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:"hidden",name:"chatProvider",value:n}),h&&e.jsx("div",{className:"fixed top-0 left-0 w-full h-full bg-black bg-opacity-70 backdrop-blur-sm z-10",onClick:()=>f(!1)}),h?e.jsx("div",{className:"absolute top-0 left-0 w-full max-w-[640px] max-h-[310px] min-h-[64px] bg-theme-settings-input-bg rounded-lg flex flex-col justify-between cursor-pointer border-2 border-primary-button z-20",children:e.jsxs("div",{className:"w-full flex flex-col gap-y-1",children:[e.jsxs("div",{className:"flex items-center sticky top-0 z-10 border-b border-[#9CA3AF] mx-4 bg-theme-settings-input-bg",children:[e.jsx(K,{size:20,weight:"bold",className:"absolute left-4 z-30 text-theme-text-primary -ml-4 my-2"}),e.jsx("input",{type:"text",name:"llm-search",autoComplete:"off",placeholder:b("chat.llm.search"),className:"border-none -ml-4 my-2 bg-transparent z-20 pl-12 h-[38px] w-full px-4 py-1 text-sm outline-none focus:outline-primary-button active:outline-primary-button outline-none text-theme-text-primary placeholder:text-theme-text-primary placeholder:font-medium",onChange:m=>c(m.target.value),ref:g,onKeyDown:m=>{m.key==="Enter"&&m.preventDefault()}}),e.jsx($,{size:20,weight:"bold",className:"cursor-pointer text-theme-text-primary hover:text-x-button",onClick:u})]}),e.jsx("div",{className:"flex-1 pl-4 pr-2 flex flex-col gap-y-1 overflow-y-auto white-scrollbar pb-4 max-h-[245px]",children:i.map(m=>e.jsx(ht,{llm:m,availableLLMs:O,settings:s,checked:n===m.value,onClick:()=>x(m.value)},m.name))})]})}):e.jsxs("button",{className:"w-full max-w-[640px] h-[64px] bg-theme-settings-input-bg rounded-lg flex items-center p-[14px] justify-between cursor-pointer border-2 border-transparent hover:border-primary-button transition-all duration-300",type:"button",onClick:()=>f(!0),children:[e.jsxs("div",{className:"flex gap-x-4 items-center",children:[e.jsx("img",{src:p.logo,alt:`${p.name} logo`,className:"w-10 h-10 rounded-md"}),e.jsxs("div",{className:"flex flex-col text-left",children:[e.jsx("div",{className:"text-sm font-semibold text-white",children:p.name}),e.jsx("div",{className:"mt-1 text-xs text-description",children:p.description})]})]}),e.jsx(ce,{size:24,weight:"bold",className:"text-white"})]})]}),e.jsx(wt,{selectedLLM:n,workspace:t,setHasChanges:r})]})}function wt({selectedLLM:s,workspace:t,setHasChanges:r}){return s==="anythingllm-router"?e.jsx(ft,{workspace:t,setHasChanges:r}):gt.includes(s)?s!=="default"?e.jsx("div",{className:"w-full h-10 justify-center items-center flex mt-4",children:e.jsxs("p",{className:"text-sm font-base text-white text-opacity-60 text-center",children:["Multi-model support is not supported for this provider yet.",e.jsx("br",{}),"This workspace will use"," ",e.jsx(R,{to:M.settings.llmPreference(),className:"underline",children:"the model set for the system."})]})}):null:bt.includes(s)?e.jsx(Nt,{workspace:t,setHasChanges:r}):e.jsx(pt,{provider:s,workspace:t,setHasChanges:r})}function Nt({workspace:s,setHasChanges:t}){const{t:r}=w();return e.jsxs("div",{className:"mt-4 flex flex-col gap-y-1",children:[e.jsx("label",{className:"block input-label",children:r("chat.model.title")}),e.jsx("p",{className:"text-white text-opacity-60 text-xs font-medium py-1.5",children:r("chat.model.description")}),e.jsx("input",{type:"text",name:"chatModel",defaultValue:(s==null?void 0:s.chatModel)||"",onChange:()=>t(!0),className:"border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5",placeholder:"Enter model name exactly as referenced in the API (e.g., gpt-3.5-turbo)"})]})}function St({workspace:s,setHasChanges:t}){const{t:r}=w();return e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("label",{htmlFor:"name",className:"block input-label",children:r("chat.refusal.title")}),e.jsxs("p",{className:"text-white text-opacity-60 text-xs font-medium py-1.5",children:[r("chat.refusal.desc-start")," ",e.jsx("code",{className:"border-none bg-theme-settings-input-bg p-0.5 rounded-sm",children:r("chat.refusal.query")})," ",r("chat.refusal.desc-end")]})]}),e.jsx("textarea",{name:"queryRefusalResponse",rows:2,defaultValue:Me(s),className:"border-none bg-theme-settings-input-bg placeholder:text-theme-settings-input-placeholder text-white text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5 mt-2",placeholder:"The text returned in query mode when there is no relevant context found for a response.",required:!0,wrap:"soft",autoComplete:"off",onChange:()=>t(!0)})]})}function Ct({workspace:s}){const[t,r]=a.useState({}),[i,l]=a.useState(!1),[n,d]=a.useState(!1),o=a.useRef(null);a.useEffect(()=>{async function h(){const f=await F.keys();r(f??{})}h()},[]);const c=async h=>{h.preventDefault(),d(!0);const f={},g=new FormData(o.current);for(var[b,x]of g.entries())f[b]=I(b,x);const{workspace:u,message:p}=await L.update(s.slug,f);u?(C("Workspace updated!","success",{clear:!0}),l(!1)):C(`Error: ${p}`,"error",{clear:!0}),d(!1)};return s?e.jsx("div",{id:"workspace-chat-settings-container",className:"relative",children:e.jsxs("form",{ref:o,onSubmit:c,id:"chat-settings-form",className:"w-1/2 flex flex-col gap-y-6",children:[i&&e.jsx("div",{className:"absolute top-0 right-0",children:e.jsx(U,{type:"submit",children:n?"Updating...":"Update Workspace"})}),e.jsx(vt,{settings:t,workspace:s,setHasChanges:l}),e.jsx(dt,{workspace:s,setHasChanges:l}),e.jsx(st,{workspace:s,setHasChanges:l}),e.jsx(lt,{workspace:s,setHasChanges:l,hasChanges:i}),e.jsx(St,{workspace:s,setHasChanges:l}),e.jsx(ct,{settings:t,workspace:s,setHasChanges:l})]})}):null}function Mt({workspace:s}){const{t}=w();return e.jsxs("div",{children:[e.jsx("h3",{className:"input-label",children:t("vector-workspace.identifier")}),e.jsx("p",{className:"text-white/60 text-xs font-medium py-1",children:" "}),e.jsx("p",{className:"text-white/60 text-sm",children:s==null?void 0:s.slug})]})}function kt({workspace:s,setHasChanges:t}){const{t:r}=w();return e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("label",{htmlFor:"name",className:"block input-label",children:r("vector-workspace.snippets.title")}),e.jsxs("p",{className:"text-white text-opacity-60 text-xs font-medium py-1.5",children:[r("vector-workspace.snippets.description"),e.jsx("br",{}),e.jsx("i",{children:r("vector-workspace.snippets.recommend")})]})]}),e.jsx("input",{name:"topN",type:"number",min:1,max:200,step:1,onWheel:i=>i.target.blur(),defaultValue:(s==null?void 0:s.topN)??4,className:"border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5 mt-2",placeholder:"4",required:!0,autoComplete:"off",onChange:()=>t(!0)})]})}function Et({workspace:s,setHasChanges:t}){const{t:r}=w();return e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("label",{htmlFor:"name",className:"block input-label",children:r("vector-workspace.doc.title")}),e.jsx("p",{className:"text-white text-opacity-60 text-xs font-medium py-1.5",children:r("vector-workspace.doc.description")})]}),e.jsxs("select",{name:"similarityThreshold",defaultValue:(s==null?void 0:s.similarityThreshold)??.25,className:"border-none bg-theme-settings-input-bg text-white text-sm mt-2 rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5",onChange:()=>t(!0),required:!0,children:[e.jsx("option",{value:0,children:r("vector-workspace.doc.zero")}),e.jsx("option",{value:.25,children:r("vector-workspace.doc.low")}),e.jsx("option",{value:.5,children:r("vector-workspace.doc.medium")}),e.jsx("option",{value:.75,children:r("vector-workspace.doc.high")})]})]})}function Lt({workspace:s}){const[t,r]=a.useState(!1),{t:i}=w(),l=async()=>{if(!window.confirm(`${i("vector-workspace.reset.confirm")}`))return!1;if(r(!0),!await L.wipeVectorDb(s.slug)){C(i("vector-workspace.reset.error"),i("vector-workspace.common.error"),{clear:!0}),r(!1);return}C(i("vector-workspace.reset.success"),i("vector-workspace.common.success"),{clear:!0}),r(!1)};return e.jsx("button",{disabled:t,onClick:l,type:"button",className:"w-60 transition-all duration-300 border border-transparent rounded-lg whitespace-nowrap text-sm px-5 py-2.5 focus:z-10 bg-red-500/25 text-red-200 light:text-red-500 hover:light:text-[#FFFFFF] hover:text-[#FFFFFF] hover:bg-red-600 disabled:bg-red-600 disabled:text-red-200 disabled:animate-pulse",children:i(t?"vector-workspace.reset.resetting":"vector-workspace.reset.reset")})}function Ft({reload:s,workspace:t}){const[r,i]=a.useState(null),{t:l}=w();return a.useEffect(()=>{async function n(){const d=await F.totalIndexes(t.slug);i(d)}n()},[t==null?void 0:t.slug,s]),r===null?e.jsxs("div",{children:[e.jsx("h3",{className:"input-label",children:l("general.vector.title")}),e.jsx("p",{className:"text-white text-opacity-60 text-xs font-medium py-1",children:l("general.vector.description")}),e.jsx("div",{className:"text-white text-opacity-60 text-sm font-medium",children:e.jsx(te,{size:"4"})})]}):e.jsxs("div",{children:[e.jsx("h3",{className:"input-label",children:l("general.vector.title")}),e.jsx("p",{className:"text-white text-opacity-60 text-sm font-medium",children:r})]})}const At=["lancedb"],Dt={default:{title:"Default",description:"This is the fastest performance, but may not return the most relevant results leading to model hallucinations."},rerank:{title:"Accuracy Optimized",description:"LLM responses may take longer to generate, but your responses will be more accurate and relevant."}};function Pt({workspace:s,setHasChanges:t}){var l;const[r,i]=a.useState((s==null?void 0:s.vectorSearchMode)??"default");return!(s!=null&&s.vectorDB)||!At.includes(s==null?void 0:s.vectorDB)?null:e.jsxs("div",{children:[e.jsx("div",{className:"flex flex-col",children:e.jsx("label",{htmlFor:"name",className:"block input-label",children:"Search Preference"})}),e.jsxs("select",{name:"vectorSearchMode",value:r,className:"border-none bg-theme-settings-input-bg text-white text-sm mt-2 rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5",onChange:n=>{i(n.target.value),t(!0)},required:!0,children:[e.jsx("option",{value:"default",children:"Default"}),e.jsx("option",{value:"rerank",children:"Accuracy Optimized"})]}),e.jsx("p",{className:"text-white text-opacity-60 text-xs font-medium py-1.5",children:(l=Dt[r])==null?void 0:l.description})]})}function Rt({workspace:s}){const[t,r]=a.useState(!1),[i,l]=a.useState(!1),n=a.useRef(null),d=async o=>{l(!0),o.preventDefault();const c={},h=new FormData(n.current);for(var[f,g]of h.entries())c[f]=I(f,g);const{workspace:b,message:x}=await L.update(s.slug,c);b?C("Workspace updated!","success",{clear:!0}):C(`Error: ${x}`,"error",{clear:!0}),l(!1),r(!1)};return s?e.jsx("div",{className:"w-full relative",children:e.jsxs("form",{ref:n,onSubmit:d,className:"w-1/2 flex flex-col gap-y-6",children:[t&&e.jsx("div",{className:"absolute top-0 right-0",children:e.jsx(U,{type:"submit",children:i?"Updating...":"Update Workspace"})}),e.jsxs("div",{className:"flex items-start gap-x-5",children:[e.jsx(Mt,{workspace:s}),e.jsx(Ft,{reload:!0,workspace:s})]}),e.jsx(Pt,{workspace:s,setHasChanges:r}),e.jsx(kt,{workspace:s,setHasChanges:r}),e.jsx(Et,{workspace:s,setHasChanges:r}),e.jsx(Lt,{workspace:s})]})}):null}function $t({closeModal:s,workspace:t,users:r}){const[i,l]=a.useState(""),[n,d]=a.useState((t==null?void 0:t.userIds)||[]),o=async u=>{u.preventDefault();const{success:p,error:m}=await W.updateUsersInWorkspace(t.id,n);p&&(C("Users updated successfully.","success"),setTimeout(()=>{window.location.reload()},1e3)),C(m,"error")},c=u=>{d(p=>p.includes(u)?p.filter(m=>m!==u):[...p,u])},h=()=>{n.length===x.length?d([]):d(x.map(u=>u.id))},f=()=>{d([])},g=u=>n.includes(u),b=u=>{l(u.target.value)},x=r.filter(u=>u.username.toLowerCase().includes(i.toLowerCase())).filter(u=>u.role!=="admin").filter(u=>u.role!=="manager");return e.jsx("div",{className:"relative w-full max-w-[550px] max-h-full",children:e.jsxs("div",{className:"w-full max-w-2xl bg-theme-bg-secondary rounded-lg shadow border-2 border-theme-modal-border overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b rounded-t border-theme-modal-border",children:[e.jsxs("div",{className:"flex items-center gap-x-4",children:[e.jsx("h3",{className:"text-base font-semibold text-white",children:"Users"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{onChange:b,className:"w-[400px] h-[34px] bg-theme-bg-primary rounded-[100px] text-white placeholder:text-theme-text-secondary text-sm px-10 pl-10",placeholder:"Search for a user"}),e.jsx(K,{size:16,weight:"bold",className:"text-white text-lg absolute left-3 top-1/2 transform -translate-y-1/2"})]})]}),e.jsx("button",{onClick:s,type:"button",className:"border-none bg-transparent rounded-lg text-sm p-1.5 ml-auto inline-flex items-center bg-sidebar-button hover:bg-theme-modal-border hover:border-theme-modal-border hover:border-opacity-50 border-transparent border",children:e.jsx($,{className:"text-white text-lg"})})]}),e.jsxs("form",{onSubmit:o,children:[e.jsx("div",{className:"py-[17px] px-[20px]",children:e.jsx("table",{className:"gap-y-[8px] flex flex-col max-h-[385px] overflow-y-auto no-scroll",children:x.length>0?x.map(u=>e.jsxs("tr",{className:"flex items-center gap-x-2 cursor-pointer",onClick:()=>c(u.id),children:[e.jsx("div",{className:"shrink-0 w-3 h-3 rounded border-[1px] border-solid border-white light:border-black flex justify-center items-center",role:"checkbox","aria-checked":g(u.id),tabIndex:0,children:g(u.id)&&e.jsx("div",{className:"w-2 h-2 bg-white light:bg-black rounded-[2px]"})}),e.jsx("p",{className:"text-theme-text-primary text-sm font-medium",children:u.username})]},u.id)):e.jsx("p",{className:"text-theme-text-secondary text-sm font-medium ",children:"No users found"})})}),e.jsxs("div",{className:"flex w-full justify-between items-center p-3 space-x-2 border-t rounded-b border-gray-500/50",children:[e.jsxs("div",{className:"flex items-center gap-x-2",children:[e.jsxs("button",{type:"button",onClick:h,className:"flex items-center gap-x-2 ml-2",children:[e.jsx("div",{className:"shrink-0 w-3 h-3 rounded border-[1px] border-white flex justify-center items-center cursor-pointer",role:"checkbox","aria-checked":n.length===x.length,tabIndex:0,children:n.length===x.length&&e.jsx("div",{className:"w-2 h-2 bg-white rounded-[2px]"})}),e.jsx("p",{className:"text-white text-sm font-medium",children:"Select All"})]}),n.length>0&&e.jsx("button",{type:"button",onClick:f,className:"flex items-center gap-x-2 ml-2",children:e.jsx("p",{className:"text-theme-text-secondary text-sm font-medium hover:text-theme-text-primary",children:"Unselect"})})]}),e.jsx("button",{type:"submit",className:"transition-all duration-300 text-xs px-2 py-1 font-semibold rounded-lg bg-primary-button hover:bg-secondary border-2 border-transparent hover:border-primary-button hover:text-white h-[32px] w-[68px] -mr-8 whitespace-nowrap shadow-[0_4px_14px_rgba(0,0,0,0.25)]",children:"Save"})]})]})]})})}function zt({user:s}){return e.jsx(e.Fragment,{children:e.jsxs("tr",{className:"bg-transparent text-theme-text-primary text-sm font-medium",children:[e.jsx("th",{scope:"row",className:"px-6 py-4 whitespace-nowrap",children:s.username}),e.jsx("td",{className:"px-6 py-4",children:ke(s.role)}),e.jsx("td",{className:"px-6 py-4",children:s.lastUpdatedAt})]})})}function Wt({workspace:s}){const[t,r]=a.useState(!0),[i,l]=a.useState([]),[n,d]=a.useState([]),[o,c]=a.useState(null),{isOpen:h,openModal:f,closeModal:g}=V();return a.useEffect(()=>{async function b(){const x=await W.users(),u=await W.workspaceUsers(s.id),p=await W.workspaces();c(p.find(m=>m.id===s.id)),d(u),l(x),r(!1)}b()},[s]),t?e.jsx(T,{height:"80vh",width:"100%",highlightColor:"var(--theme-bg-primary)",baseColor:"var(--theme-bg-secondary)",count:1,className:"w-full p-4 rounded-b-2xl rounded-tr-2xl rounded-tl-sm mt-6",containerClassName:"flex w-full"}):e.jsxs("div",{className:"flex justify-between -mt-3",children:[e.jsxs("table",{className:"w-full max-w-[700px] text-sm text-left rounded-lg",children:[e.jsx("thead",{className:"text-white text-opacity-80 text-xs leading-[18px] font-bold uppercase border-white/10 border-b border-opacity-60",children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",className:"px-6 py-3 rounded-tl-lg",children:"Username"}),e.jsx("th",{scope:"col",className:"px-6 py-3",children:"Role"}),e.jsx("th",{scope:"col",className:"px-6 py-3",children:"Date Added"}),e.jsx("th",{scope:"col",className:"px-6 py-3 rounded-tr-lg",children:" "})]})}),e.jsx("tbody",{children:n.length>0?n.map((b,x)=>e.jsx(zt,{user:b},x)):e.jsx("tr",{children:e.jsx("td",{className:"text-center py-4 text-white/80",colSpan:"4",children:"No workspace members"})})})]}),e.jsx(U,{onClick:f,children:"Manage Users"}),e.jsx(Q,{isOpen:h,children:e.jsx($t,{closeModal:g,users:i,workspace:o})})]})}const Ot=["default","none"];function Tt({llm:s,availableLLMs:t,settings:r,checked:i,onClick:l}){const{isOpen:n,openModal:d,closeModal:o}=V(),{name:c,value:h,logo:f,description:g}=s,[b,x]=a.useState(r);a.useEffect(()=>{async function p(){if(n){const m=await F.keys();x(m??{})}}p()},[n]);function u(){if(!i){if((s.requiredConfig||[]).some(m=>!b[m])){d();return}l(h)}}return e.jsxs(e.Fragment,{children:[e.jsxs("div",{onClick:u,className:`w-full p-2 rounded-md hover:cursor-pointer hover:bg-theme-bg-secondary ${i?"bg-theme-bg-secondary":""}`,children:[e.jsx("input",{type:"checkbox",value:h,className:"peer hidden",checked:i,readOnly:!0,formNoValidate:!0}),e.jsxs("div",{className:"flex gap-x-4 items-center justify-between",children:[e.jsxs("div",{className:"flex gap-x-4 items-center",children:[e.jsx("img",{src:f,alt:`${c} logo`,className:"w-10 h-10 rounded-md"}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("div",{className:"text-sm font-semibold text-white",children:c}),e.jsx("div",{className:"mt-1 text-xs text-white/60",children:g})]})]}),i&&h!=="none"&&!Ot.includes(h)&&e.jsx("button",{onClick:p=>{p.preventDefault(),d()},className:"border-none p-2 text-white/60 hover:text-white hover:bg-theme-bg-hover rounded-md transition-all duration-300",title:"Edit Settings",children:e.jsx(re,{size:20,weight:"bold"})})]})]}),e.jsx(Ut,{availableLLMs:t,isOpen:n,provider:h,closeModal:o,postSubmit:l,settings:b})]})}function Ut({availableLLMs:s,isOpen:t,provider:r,closeModal:i,postSubmit:l,settings:n}){if(!t)return null;const d=s.find(c=>c.value===r);if(!d)return null;async function o(c){c.preventDefault(),c.stopPropagation();const h={},f=new FormData(c.target);for(var[g,b]of f.entries())h[g]=b;const{error:x}=await F.updateSystem(h);if(x){C(`Failed to save ${d.name} settings: ${x}`,"error");return}return i(),l(),!1}return ne.createPortal(e.jsx(Q,{isOpen:t,children:e.jsx("div",{className:"fixed inset-0 z-50 overflow-auto bg-black bg-opacity-50 flex items-center justify-center",children:e.jsxs("div",{className:"relative w-full max-w-2xl bg-theme-bg-secondary rounded-lg shadow border-2 border-theme-modal-border",children:[e.jsxs("div",{className:"relative p-6 border-b rounded-t border-theme-modal-border",children:[e.jsx("div",{className:"w-full flex gap-x-2 items-center",children:e.jsxs("h3",{className:"text-xl font-semibold text-white overflow-hidden overflow-ellipsis whitespace-nowrap",children:[d.name," Settings"]})}),e.jsx("button",{onClick:i,type:"button",className:"absolute top-4 right-4 transition-all duration-300 bg-transparent rounded-lg text-sm p-1 inline-flex items-center hover:bg-theme-modal-border hover:border-theme-modal-border hover:border-opacity-50 border-transparent border",children:e.jsx($,{size:24,weight:"bold",className:"text-white"})})]}),e.jsxs("form",{id:"provider-form",onSubmit:o,children:[e.jsx("div",{className:"px-7 py-6",children:e.jsxs("div",{className:"space-y-6 max-h-[60vh] overflow-y-auto p-1",children:[e.jsxs("p",{className:"text-sm text-white/60",children:["To use ",d.name," as this workspace's agent LLM you need to set it up first."]}),e.jsx("div",{children:d.options(n,{credentialsOnly:!0})})]})}),e.jsxs("div",{className:"flex justify-between items-center mt-6 pt-6 border-t border-theme-modal-border px-7 pb-6",children:[e.jsx("button",{type:"button",onClick:i,className:"transition-all duration-300 text-white hover:bg-zinc-700 px-4 py-2 rounded-lg text-sm",children:"Cancel"}),e.jsxs("button",{type:"submit",form:"provider-form",className:"transition-all duration-300 bg-white text-black hover:opacity-60 px-4 py-2 rounded-lg text-sm",children:["Save ",d.name," settings"]})]})]})]})})}),document.getElementById("workspace-agent-settings-container"))}function H(s,t=""){return s==="openai"?["gpt-3.5-turbo-0301","gpt-4-turbo-2024-04-09","gpt-4-turbo","o1-preview","o1-preview-2024-09-12","o1-mini","o1-mini-2024-09-12","o3-mini","o3-mini-2025-01-31"].includes(t)===!1:!0}function Vt({provider:s,workspace:t,setHasChanges:r}){const{slug:i}=G(),{defaultModels:l,customModels:n,loading:d}=ae(s),{t:o}=w();return le.includes(s)?e.jsx("div",{className:"w-full h-10 justify-center items-center flex",children:e.jsxs("p",{className:"text-sm font-base text-white text-opacity-60 text-center",children:["Multi-model support is not supported for this provider yet.",e.jsx("br",{}),"Agent's will use"," ",e.jsx(R,{to:M.workspace.settings.chatSettings(i),className:"underline",children:"the model set for the workspace"})," ","or"," ",e.jsx(R,{to:M.settings.llmPreference(),className:"underline",children:"the model set for the system."})]})}):d?e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("label",{htmlFor:"name",className:"block input-label",children:o("agent.mode.chat.title")}),e.jsx("p",{className:"text-white text-opacity-60 text-xs font-medium py-1.5",children:o("agent.mode.chat.description")})]}),e.jsx("select",{name:"agentModel",required:!0,disabled:!0,className:"border-none bg-theme-settings-input-bg text-white text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5",children:e.jsx("option",{disabled:!0,selected:!0,children:o("agent.mode.wait")})})]}):e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("label",{htmlFor:"name",className:"block input-label",children:o("agent.mode.title")}),e.jsx("p",{className:"text-white text-opacity-60 text-xs font-medium py-1.5",children:o("agent.mode.description")})]}),e.jsxs("select",{name:"agentModel",required:!0,onChange:()=>{r(!0)},className:"border-none bg-theme-settings-input-bg text-white text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5",children:[l.length>0&&e.jsx("optgroup",{label:"General models",children:l.map(c=>H(s,c)?e.jsx("option",{value:c,selected:(t==null?void 0:t.agentModel)===c,children:c},c):null)}),Array.isArray(n)&&n.length>0&&e.jsx("optgroup",{label:"Custom models",children:n.map(c=>H(s,c.id)?e.jsx("option",{value:c.id,selected:(t==null?void 0:t.agentModel)===c.id,children:c.id},c.id):null)}),!Array.isArray(n)&&Object.keys(n).length>0&&e.jsx(e.Fragment,{children:Object.entries(n).map(([c,h])=>e.jsx("optgroup",{label:c,children:h.map(f=>H(s,f.id)?e.jsx("option",{value:f.id,selected:(t==null?void 0:t.agentModel)===f.id,children:f.name||f.id},f.id):null)},c))})]})]})}const It=["openai","anthropic","lmstudio","ollama","localai","groq","azure","koboldcpp","togetherai","openrouter","novita","mistral","perplexity","textgenwebui","generic-openai","bedrock","fireworksai","deepseek","ppio","litellm","apipie","xai","nvidia-nim","gemini","moonshotai","cometapi","foundry","zai","giteeai","cohere","docker-model-runner","privatemode","sambanova","lemonade","minimax","cerebras"],_t=["lmstudio","koboldcpp","ollama","localai","textgenwebui","docker-model-runner"],qt={name:"System Default",value:"none",logo:oe,options:()=>e.jsx(N.Fragment,{}),description:"Agents will use the workspace or system LLM unless otherwise specified.",requiredConfig:[]},B=[qt,...ie.filter(s=>It.includes(s.value))];function Ht({settings:s,workspace:t,setHasChanges:r}){const[i,l]=a.useState([]),[n,d]=a.useState((t==null?void 0:t.agentProvider)??"none"),[o,c]=a.useState(""),[h,f]=a.useState(!1),g=a.useRef(null),{t:b}=w();function x(m){c(""),d(m),f(!1),r(!0)}function u(){o.length>0?(c(""),g.current&&(g.current.value="")):f(!h)}a.useEffect(()=>{const m=B.filter(k=>k.name.toLowerCase().includes(o.toLowerCase()));l(m)},[o,n]);const p=B.find(m=>m.value===n);return e.jsxs("div",{className:"border-b border-white/40 pb-8",children:[_t.includes(n)&&e.jsx("div",{className:"flex flex-col md:flex-row md:items-center gap-x-2 text-white mb-4 bg-blue-800/30 w-fit rounded-lg px-4 py-2",children:e.jsxs("div",{className:"gap-x-2 flex items-center",children:[e.jsx(_e,{className:"shrink-0",size:25}),e.jsx("p",{className:"text-sm",children:b("agent.performance-warning")})]})}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("label",{htmlFor:"name",className:"block input-label",children:b("agent.provider.title")}),e.jsx("p",{className:"text-white text-opacity-60 text-xs font-medium py-1.5",children:b("agent.provider.description")})]}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:"hidden",name:"agentProvider",value:n}),h&&e.jsx("div",{className:"fixed top-0 left-0 w-full h-full bg-black bg-opacity-70 backdrop-blur-sm z-10",onClick:()=>f(!1)}),h?e.jsx("div",{className:"absolute top-0 left-0 w-full max-w-[640px] max-h-[310px] min-h-[64px] bg-theme-settings-input-bg rounded-lg flex flex-col justify-between cursor-pointer border-2 border-primary-button z-20",children:e.jsxs("div",{className:"w-full flex flex-col gap-y-1",children:[e.jsxs("div",{className:"flex items-center sticky top-0 z-10 border-b border-[#9CA3AF] mx-4 bg-theme-settings-input-bg",children:[e.jsx(K,{size:20,weight:"bold",className:"absolute left-4 z-30 text-theme-text-primary -ml-4 my-2"}),e.jsx("input",{type:"text",name:"llm-search",autoComplete:"off",placeholder:"Search available LLM providers",className:"border-none -ml-4 my-2 bg-transparent z-20 pl-12 h-[38px] w-full px-4 py-1 text-sm outline-none text-theme-text-primary placeholder:text-theme-text-primary placeholder:font-medium",onChange:m=>c(m.target.value),ref:g,onKeyDown:m=>{m.key==="Enter"&&m.preventDefault()}}),e.jsx($,{size:20,weight:"bold",className:"cursor-pointer text-theme-text-primary hover:text-x-button",onClick:u})]}),e.jsx("div",{className:"flex-1 pl-4 pr-2 flex flex-col gap-y-1 overflow-y-auto white-scrollbar pb-4 max-h-[245px]",children:i.map(m=>e.jsx(Tt,{llm:m,availableLLMs:B,settings:s,checked:n===m.value,onClick:()=>x(m.value)},m.name))})]})}):e.jsxs("button",{className:"w-full max-w-[640px] h-[64px] bg-theme-settings-input-bg rounded-lg flex items-center p-[14px] justify-between cursor-pointer border-2 border-transparent hover:border-primary-button transition-all duration-300",type:"button",onClick:()=>f(!0),children:[e.jsxs("div",{className:"flex gap-x-4 items-center",children:[e.jsx("img",{src:p.logo,alt:`${p.name} logo`,className:"w-10 h-10 rounded-md"}),e.jsxs("div",{className:"flex flex-col text-left",children:[e.jsx("div",{className:"text-sm font-semibold text-white",children:p.name}),e.jsx("div",{className:"mt-1 text-xs text-description",children:p.description})]})]}),e.jsx(ce,{size:24,weight:"bold",className:"text-white"})]})]}),n!=="none"&&e.jsx("div",{className:"mt-4 flex flex-col gap-y-1",children:e.jsx(Vt,{provider:n,workspace:t,setHasChanges:r})})]})}function Bt({workspace:s}){const{user:t}=de(),[r,i]=a.useState({}),[l,n]=a.useState(!1),[d,o]=a.useState(!1),[c,h]=a.useState(!0),f=a.useRef(null);a.useEffect(()=>{async function b(){const x=await F.keys();i(x??{}),h(!1)}b()},[]);const g=async b=>{o(!0),b.preventDefault();const x={workspace:{},system:{},env:{}},u=new FormData(f.current);for(var[p,m]of u.entries()){if(p.startsWith("system::")){const[v,S]=p.split("system::");x.system[S]=String(m);continue}if(p.startsWith("env::")){const[v,S]=p.split("env::");x.env[S]=String(m);continue}x.workspace[p]=I(p,m)}const{workspace:k,message:y}=await L.update(s.slug,x.workspace);await W.updateSystemPreferences(x.system),await F.updateSystem(x.env),k?C("Workspace updated!","success",{clear:!0}):C(`Error: ${y}`,"error",{clear:!0}),o(!1),n(!1)};return!s||c?e.jsx(Zt,{}):e.jsx("div",{id:"workspace-agent-settings-container",children:e.jsxs("form",{ref:f,onSubmit:g,onChange:()=>n(!0),id:"agent-settings-form",className:"w-1/2 flex flex-col gap-y-6",children:[e.jsx(Ht,{settings:r,workspace:s,setHasChanges:n}),(!t||(t==null?void 0:t.role)==="admin")&&e.jsx(e.Fragment,{children:!l&&e.jsxs("div",{className:"flex flex-col gap-y-4",children:[e.jsx("a",{className:"w-fit transition-all duration-300 border border-slate-200 px-5 py-2.5 rounded-lg text-white text-sm items-center flex gap-x-2 hover:bg-slate-200 hover:text-slate-800 focus:ring-gray-800",href:M.settings.agentSkills(),children:"Configure Agent Skills"}),e.jsx("p",{className:"text-white text-opacity-60 text-xs font-medium",children:"Customize and enhance the default agent's capabilities by enabling or disabling specific skills. These settings will be applied across all workspaces."})]})}),l&&e.jsx("button",{type:"submit",form:"agent-settings-form",className:"w-fit transition-all duration-300 border border-slate-200 px-5 py-2.5 rounded-lg text-white text-sm items-center flex gap-x-2 hover:bg-slate-200 hover:text-slate-800 focus:ring-gray-800",children:d?"Updating agent...":"Update workspace agent"})]})})}function Zt(){return e.jsx("div",{id:"workspace-agent-settings-container",children:e.jsxs("div",{className:"w-1/2 flex flex-col gap-y-6",children:[e.jsx(T,{height:100,width:"100%",count:2,highlightColor:"var(--theme-bg-primary)",baseColor:"var(--theme-bg-secondary)",enableAnimation:!0,containerClassName:"flex flex-col gap-y-1"}),e.jsx("div",{className:"bg-white/10 h-[1px] w-full"}),e.jsx(T,{height:100,width:"100%",count:2,highlightColor:"var(--theme-bg-primary)",baseColor:"var(--theme-bg-secondary)",enableAnimation:!0,containerClassName:"flex flex-col gap-y-1 mt-4"})]})})}const Gt={"general-appearance":tt,"chat-settings":Ct,"vector-database":Rt,members:Wt,"agent-config":Bt};function fs(){const{loading:s,requiresAuth:t,mode:r}=Ee();return s?e.jsx(ue,{}):t!==!1?e.jsx(e.Fragment,{children:t!==null&&e.jsx(Le,{mode:r})}):e.jsx(Qt,{})}function Qt(){const{t:s}=w(),{slug:t,tab:r}=G(),{user:i}=de(),l=se("agentMode"),[n,d]=a.useState(null),[o,c]=a.useState(!1),[h,f]=a.useState(!0);if(a.useEffect(()=>{async function b(){if(!t)return;const x=await L.bySlug(t);if(!x){f(!1);return}const u=await F.keys(),p=await L.getSuggestedMessages(t);d({...x,vectorDB:u==null?void 0:u.VectorDB,suggestedMessages:p}),c((u==null?void 0:u.WorkspaceDeletionProtection)===!0),f(!1)}b()},[t,r]),h)return e.jsx(ue,{});if(r==="agent-config"&&!l.enabled)return e.jsx(Fe,{to:M.workspace.settings.generalAppearance(t),replace:!0});const g=Gt[r];return e.jsxs("div",{className:"w-screen h-screen overflow-hidden bg-zinc-950 light:bg-slate-50 flex",children:[!X&&e.jsx(Re,{}),e.jsxs("div",{style:{height:X?"100%":"calc(100% - 32px)"},className:"transition-all duration-500 relative md:ml-[2px] md:mr-[16px] md:my-[16px] md:rounded-[16px] bg-theme-bg-secondary w-full h-full overflow-y-scroll",children:[e.jsxs("div",{className:"flex gap-x-10 pt-6 pb-4 ml-16 mr-8 border-b-2 border-white light:border-theme-chat-input-border border-opacity-10",children:[e.jsx(R,{to:M.workspace.chat(t),className:"absolute top-2 left-2 md:top-4 md:left-4 transition-all duration-300 p-2 rounded-full text-white bg-theme-sidebar-footer-icon hover:bg-theme-sidebar-footer-icon-hover z-10",children:e.jsx(Ae,{className:"h-5 w-5",weight:"fill"})}),e.jsx(z,{title:s("workspaces—settings.general"),icon:e.jsx(De,{className:"h-6 w-6"}),to:M.workspace.settings.generalAppearance(t)}),e.jsx(z,{title:s("workspaces—settings.chat"),icon:e.jsx($e,{className:"h-6 w-6"}),to:M.workspace.settings.chatSettings(t)}),e.jsx(z,{title:s("workspaces—settings.vector"),icon:e.jsx(ze,{className:"h-6 w-6"}),to:M.workspace.settings.vectorDatabase(t),visible:l.enabled}),e.jsx(z,{title:s("workspaces—settings.members"),icon:e.jsx(me,{className:"h-6 w-6"}),to:M.workspace.settings.members(t),visible:["admin","manager"].includes(i==null?void 0:i.role)}),e.jsx(z,{title:s("workspaces—settings.agent"),icon:e.jsx(We,{className:"h-6 w-6"}),to:M.workspace.settings.agentConfig(t),visible:l.enabled})]}),e.jsx("div",{className:"px-16 py-6",children:e.jsx(g,{slug:t,workspace:n,deletionProtected:o})})]})]})}function z({title:s,icon:t,to:r,visible:i=!0}){return i?e.jsxs(Pe,{to:r,className:({isActive:l})=>`${l?"text-sky-400 pb-4 border-b-[4px] -mb-[19px] border-sky-400":"text-white/60 hover:text-sky-400"} flex gap-x-2 items-center font-medium`,children:[t,e.jsx("div",{children:s})]}):null}export{fs as default};
@@ -1 +1 @@
1
- import{r as o,j as e,R as L,aQ as S,I as F,k as E,u as N,s as I,c as v,t as y,a as z,aR as _,a1 as k,i as R}from"../index.js";import{A as j}from"./admin-04b020fe.js";function U({icon:s,url:p,onSave:x,onRemove:f}){const[r,a]=o.useState(s||"Plus"),[t,l]=o.useState(p||""),[u,h]=o.useState(!1),[b,i]=o.useState(!1),n=o.useRef(null);o.useEffect(()=>{a(s||"Plus"),l(p||""),i(!1)},[s,p]),o.useEffect(()=>{function d(C){n.current&&!n.current.contains(C.target)&&h(!1)}return document.addEventListener("mousedown",d),()=>document.removeEventListener("mousedown",d)},[n]);const m=d=>{d.preventDefault(),r!=="Plus"&&t&&(x(r,t),i(!1))},c=()=>{f(),a("Plus"),l(""),i(!1)},g=d=>{a(d),h(!1),i(!0)},w=d=>{l(d.target.value),i(!0)};return e.jsxs("form",{onSubmit:m,className:"flex items-center gap-x-1.5",children:[e.jsxs("div",{className:"relative",ref:n,children:[e.jsx("div",{className:"h-[34px] w-[34px] bg-theme-settings-input-bg rounded-full flex items-center justify-center cursor-pointer hover:outline-primary-button hover:outline",onClick:()=>h(!u),children:L.createElement(S[r]||F,{className:"h-5 w-5",weight:r==="Plus"?"bold":"fill",color:"var(--theme-sidebar-footer-icon-fill)"})}),u&&e.jsx("div",{className:"absolute z-10 grid grid-cols-4 bg-theme-settings-input-bg mt-2 rounded-md w-[150px] h-[78px] overflow-y-auto border border-white/20 shadow-lg",children:Object.keys(S).map(d=>e.jsx("button",{type:"button",className:"flex justify-center items-center border border-transparent hover:bg-theme-sidebar-footer-icon-hover hover:border-slate-100 light:hover:border-black/80 rounded-full p-2",onClick:()=>g(d),children:L.createElement(S[d],{className:"h-5 w-5",weight:"fill",color:"var(--theme-sidebar-footer-icon-fill)"})},d))})]}),e.jsx("input",{type:"url",value:t,onChange:w,placeholder:"https://example.com",className:"border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-md p-2.5 w-[300px] h-[32px] focus:outline-primary-button active:outline-primary-button outline-none",required:!0}),r!=="Plus"&&e.jsx(e.Fragment,{children:b?e.jsx("button",{type:"submit",className:"text-sky-400 px-2 py-2 rounded-md text-sm font-bold hover:text-sky-500",children:"Save"}):e.jsx("button",{type:"button",onClick:c,className:"hover:text-red-500 text-white/80 px-2 py-2 rounded-md text-sm font-bold",children:e.jsx(E,{size:20})})})]})}function A(){const[s,p]=o.useState(Array(3).fill(null)),{t:x}=N();o.useEffect(()=>{async function a(){const{settings:t}=await j.systemPreferencesByFields(["footer_data"]),l=t==null?void 0:t.footer_data;if(l){const u=I(l,[]);p(h=>{const b=[...h];return u.forEach((i,n)=>{b[n]=i}),b})}}a()},[]);const f=async a=>{const{success:t,error:l}=await j.updateSystemPreferences({footer_data:JSON.stringify(a.filter(u=>u!==null))});if(!t){v(`Failed to update footer icons - ${l}`,"error",{clear:!0});return}window.localStorage.removeItem(y.cacheKeys.footerIcons),p(a),v("Successfully updated footer icons.","success",{clear:!0})},r=a=>{const t=[...s];t[a]=null,f(t)};return e.jsxs("div",{className:"flex flex-col gap-y-0.5 my-4",children:[e.jsx("p",{className:"text-sm leading-6 font-semibold text-white",children:x("customization.items.sidebar-footer.title")}),e.jsx("p",{className:"text-xs text-white/60",children:x("customization.items.sidebar-footer.description")}),e.jsxs("div",{className:"mt-2 flex gap-x-3 font-medium text-white text-sm",children:[e.jsx("div",{children:x("customization.items.sidebar-footer.icon")}),e.jsx("div",{children:x("customization.items.sidebar-footer.link")})]}),e.jsx("div",{className:"mt-2 flex flex-col gap-y-[10px]",children:s.map((a,t)=>e.jsx(U,{icon:a==null?void 0:a.icon,url:a==null?void 0:a.url,onSave:(l,u)=>{const h=[...s];h[t]={icon:l,url:u},f(h)},onRemove:()=>r(t)},t))})]})}function P(){const{user:s}=z(),[p,x]=o.useState(!0),[f,r]=o.useState(!1),[a,t]=o.useState(""),[l,u]=o.useState(""),{t:h}=N();o.useEffect(()=>{(async()=>{const m=await y.fetchSupportEmail();t(m.email||""),u(m.email||""),x(!1)})()},[]);const b=async(n,m=null)=>{n.preventDefault();let c=m;m===null&&(c=new FormData(n.target).get("supportEmail"));const{success:g,error:w}=await j.updateSystemPreferences({support_email:c});if(g)v("Successfully updated support email.","success"),window.localStorage.removeItem(y.cacheKeys.supportEmail),t(c),u(c),r(!1);else{v(`Failed to update support email: ${w}`,"error");return}},i=n=>{t(n.target.value),r(!0)};return p||!(s!=null&&s.role)?null:e.jsxs("form",{className:"flex flex-col gap-y-0.5 mt-4",onSubmit:b,children:[e.jsx("p",{className:"text-sm leading-6 font-semibold text-white",children:h("customization.items.support-email.title")}),e.jsx("p",{className:"text-xs text-white/60",children:h("customization.items.support-email.description")}),e.jsxs("div",{className:"flex items-center gap-x-4",children:[e.jsx("input",{name:"supportEmail",type:"email",className:"border-none bg-theme-settings-input-bg mt-2 text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-fit py-2 px-4",placeholder:"support@mycompany.com",required:!0,autoComplete:"off",onChange:i,value:a}),l!==""&&e.jsx("button",{type:"button",onClick:n=>b(n,""),className:"text-white text-base font-medium hover:text-opacity-60",children:"Clear"})]}),f&&e.jsx("button",{type:"submit",className:"transition-all mt-2 w-fit duration-300 border border-slate-200 px-5 py-2.5 rounded-lg text-white text-sm items-center flex gap-x-2 hover:bg-slate-200 hover:text-slate-800 focus:ring-gray-800",children:"Save"})]})}function D(){const{t:s}=N(),{logo:p,setLogo:x}=_(),[f,r]=o.useState(""),[a,t]=o.useState(!0),l=o.useRef(null);o.useEffect(()=>{async function i(){r(p||"");const n=await y.isDefaultLogo();t(n)}i()},[p]);const u=async i=>{const n=i.target.files[0];if(!n)return!1;const m=URL.createObjectURL(n);r(m);const c=new FormData;c.append("logo",n);const{success:g,error:w}=await y.uploadLogo(c);if(!g){v(`Failed to upload logo: ${w}`,"error"),r(p);return}const{logoURL:d}=await y.fetchLogo();x(d),v("Image uploaded successfully.","success"),t(!1)},h=async()=>{r(""),t(!0);const{success:i,error:n}=await y.removeCustomLogo();if(!i){console.error("Failed to remove logo:",n),v(`Failed to remove logo: ${n}`,"error");const{logoURL:c}=await y.fetchLogo();r(c),t(!1);return}const{logoURL:m}=await y.fetchLogo();x(m),v("Image successfully removed.","success")},b=()=>{var i;(i=l.current)==null||i.click()};return e.jsxs("div",{className:"flex flex-col gap-y-0.5 my-4",children:[e.jsx("p",{className:"text-sm leading-6 font-semibold text-white",children:s("customization.items.logo.title")}),e.jsx("p",{className:"text-xs text-white/60",children:s("customization.items.logo.description")}),a?e.jsx("div",{className:"flex md:flex-row flex-col items-center",children:e.jsx("div",{className:"flex flex-row gap-x-8",children:e.jsxs("label",{className:"mt-3 transition-all duration-300 hover:opacity-60",hidden:!a,children:[e.jsx("input",{id:"logo-upload",type:"file",accept:"image/*",className:"hidden",onChange:u}),e.jsx("div",{className:"w-80 py-4 bg-theme-settings-input-bg rounded-2xl border-2 border-dashed border-theme-text-secondary border-opacity-60 justify-center items-center inline-flex cursor-pointer",htmlFor:"logo-upload",children:e.jsxs("div",{className:"flex flex-col items-center justify-center",children:[e.jsx("div",{className:"rounded-full bg-white/40",children:e.jsx(F,{className:"w-6 h-6 text-black/80 m-2"})}),e.jsx("div",{className:"text-theme-text-primary text-opacity-80 text-sm font-semibold py-1",children:s("customization.items.logo.add")}),e.jsx("div",{className:"text-theme-text-secondary text-opacity-60 text-xs font-medium py-1",children:s("customization.items.logo.recommended")})]})})]})})}):e.jsx("div",{className:"flex md:flex-row flex-col items-center relative",children:e.jsxs("div",{className:"group w-80 h-[130px] mt-3 overflow-hidden",children:[e.jsx("img",{src:f,alt:"Uploaded Logo",className:"w-full h-full object-cover border-2 border-theme-text-secondary border-opacity-60 p-1 rounded-2xl"}),e.jsxs("div",{className:"absolute w-80 top-0 left-0 right-0 bottom-0 flex flex-col gap-y-3 justify-center items-center rounded-2xl mt-3 bg-black bg-opacity-80 opacity-0 group-hover:opacity-100 transition-opacity duration-300 ease-in-out border-2 border-transparent hover:border-white",children:[e.jsx("button",{onClick:b,className:"text-[#FFFFFF] text-base font-medium hover:text-opacity-60 mx-2",children:s("customization.items.logo.replace")}),e.jsx("input",{id:"logo-upload",type:"file",accept:"image/*",className:"hidden",onChange:u,ref:l}),e.jsx("button",{onClick:h,className:"text-[#FFFFFF] text-base font-medium hover:text-opacity-60 mx-2",children:s("customization.items.logo.remove")})]})]})})]})}function O(){const{t:s}=N(),[p,x]=o.useState(!0),[f,r]=o.useState(!1),[a,t]=o.useState(""),[l,u]=o.useState(""),[h,b]=o.useState(!1);o.useEffect(()=>{(async()=>{const c=await y.keys();if(!(c!=null&&c.MultiUserMode)&&!(c!=null&&c.RequiresAuth))return b(!1),!1;const{appName:g}=await y.fetchCustomAppName();t(g||""),u(g||""),b(!0),x(!1)})()},[]);const i=async(m,c=null)=>{m.preventDefault();let g=c;c===null&&(g=new FormData(m.target).get("customAppName"));const{success:w,error:d}=await j.updateSystemPreferences({custom_app_name:g});if(w)v("Successfully updated custom app name.","success"),window.localStorage.removeItem(y.cacheKeys.customAppName),t(g),u(g),r(!1);else{v(`Failed to update custom app name: ${d}`,"error");return}},n=m=>{t(m.target.value),r(!0)};return!h||p?null:e.jsxs("form",{className:"flex flex-col gap-y-0.5 mt-4",onSubmit:i,children:[e.jsx("p",{className:"text-sm leading-6 font-semibold text-white",children:s("customization.items.app-name.title")}),e.jsx("p",{className:"text-xs text-white/60",children:s("customization.items.app-name.description")}),e.jsxs("div",{className:"flex items-center gap-x-4",children:[e.jsx("input",{name:"customAppName",type:"text",className:"border-none bg-theme-settings-input-bg mt-2 text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-fit py-2 px-4",placeholder:"AnythingLLM",required:!0,autoComplete:"off",onChange:n,value:a}),l!==""&&e.jsx("button",{type:"button",onClick:m=>i(m,""),className:"text-white text-base font-medium hover:text-opacity-60",children:"Clear"})]}),f&&e.jsx("button",{type:"submit",className:"transition-all mt-2 w-fit duration-300 border border-slate-200 px-5 py-2.5 rounded-lg text-white text-sm items-center flex gap-x-2 hover:bg-slate-200 hover:text-slate-800 focus:ring-gray-800",children:"Save"})]})}function M(){const{t:s}=N(),[p,x]=o.useState(!1),[f,r]=o.useState({title:null,faviconUrl:null});o.useEffect(()=>{j.systemPreferencesByFields(["meta_page_title","meta_page_favicon"]).then(({settings:t})=>{r({title:t==null?void 0:t.meta_page_title,faviconUrl:t==null?void 0:t.meta_page_favicon})})},[]);async function a(t){t.preventDefault(),await j.updateSystemPreferences({meta_page_title:f.title??null,meta_page_favicon:f.faviconUrl??null}),v("Site preferences updated! They will reflect on page reload.","success",{clear:!0}),x(!1)}return e.jsxs("form",{className:"flex flex-col gap-y-0.5 my-4 border-t border-white border-opacity-20 light:border-black/20 pt-6",onChange:()=>x(!0),onSubmit:a,children:[e.jsx("p",{className:"text-sm leading-6 font-semibold text-white",children:s("customization.items.browser-appearance.title")}),e.jsx("p",{className:"text-xs text-white/60",children:s("customization.items.browser-appearance.description")}),e.jsxs("div",{className:"w-fit",children:[e.jsx("p",{className:"text-sm leading-6 font-medium text-white mt-2",children:s("customization.items.browser-appearance.tab.title")}),e.jsx("p",{className:"text-xs text-white/60",children:s("customization.items.browser-appearance.tab.description")}),e.jsx("div",{className:"flex items-center gap-x-4",children:e.jsx("input",{name:"meta_page_title",type:"text",className:"border-none bg-theme-settings-input-bg mt-2 text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-fit py-2 px-4",placeholder:"AnythingLLM | Your personal LLM trained on anything",autoComplete:"off",onChange:t=>{r(l=>({...l,title:t.target.value}))},value:f.title??"AnythingLLM | Your personal LLM trained on anything"})})]}),e.jsxs("div",{className:"w-fit",children:[e.jsx("p",{className:"text-sm leading-6 font-medium text-white mt-2",children:s("customization.items.browser-appearance.favicon.title")}),e.jsx("p",{className:"text-xs text-white/60",children:s("customization.items.browser-appearance.favicon.description")}),e.jsxs("div",{className:"flex items-center gap-x-2",children:[e.jsx("img",{src:f.faviconUrl??"/favicon.png",onError:t=>t.target.src="/favicon.png",className:"h-10 w-10 rounded-lg mt-2",alt:"Site favicon"}),e.jsx("input",{name:"meta_page_favicon",type:"url",className:"border-none bg-theme-settings-input-bg mt-2 text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-fit py-2 px-4",placeholder:"url to your image",onChange:t=>{r(l=>({...l,faviconUrl:t.target.value}))},autoComplete:"off",value:f.faviconUrl??""})]})]}),p&&e.jsx("button",{type:"submit",className:"transition-all mt-2 w-fit duration-300 border border-slate-200 px-5 py-2.5 rounded-lg text-white text-sm items-center flex gap-x-2 hover:bg-slate-200 hover:text-slate-800 focus:ring-gray-800",children:"Save"})]})}function T(){const{t:s}=N();return e.jsxs("div",{className:"w-screen h-screen overflow-hidden bg-theme-bg-container flex",children:[e.jsx(k,{}),e.jsx("div",{style:{height:R?"100%":"calc(100% - 32px)"},className:"relative md:ml-[2px] md:mr-[16px] md:my-[16px] md:rounded-[16px] bg-theme-bg-secondary w-full h-full overflow-y-scroll p-4 md:p-0",children:e.jsxs("div",{className:"flex flex-col w-full px-1 md:pl-6 md:pr-[86px] md:py-6 py-16",children:[e.jsxs("div",{className:"w-full flex flex-col gap-y-1 pb-6 border-white light:border-theme-sidebar-border border-b-2 border-opacity-10",children:[e.jsx("div",{className:"items-center",children:e.jsx("p",{className:"text-lg leading-6 font-bold text-white",children:s("customization.branding.title")})}),e.jsx("p",{className:"text-xs leading-[18px] font-base text-white text-opacity-60",children:s("customization.branding.description")})]}),e.jsx(O,{}),e.jsx(D,{}),e.jsx(A,{}),e.jsx(P,{}),e.jsx(M,{})]})})]})}export{T as default};
1
+ import{r as o,j as e,R as L,aR as S,I as F,k as E,u as N,s as I,c as v,t as y,a as z,aS as _,a1 as k,i as R}from"../index.js";import{A as j}from"./admin-04b020fe.js";function U({icon:s,url:p,onSave:x,onRemove:f}){const[r,a]=o.useState(s||"Plus"),[t,l]=o.useState(p||""),[u,h]=o.useState(!1),[b,i]=o.useState(!1),n=o.useRef(null);o.useEffect(()=>{a(s||"Plus"),l(p||""),i(!1)},[s,p]),o.useEffect(()=>{function d(C){n.current&&!n.current.contains(C.target)&&h(!1)}return document.addEventListener("mousedown",d),()=>document.removeEventListener("mousedown",d)},[n]);const m=d=>{d.preventDefault(),r!=="Plus"&&t&&(x(r,t),i(!1))},c=()=>{f(),a("Plus"),l(""),i(!1)},g=d=>{a(d),h(!1),i(!0)},w=d=>{l(d.target.value),i(!0)};return e.jsxs("form",{onSubmit:m,className:"flex items-center gap-x-1.5",children:[e.jsxs("div",{className:"relative",ref:n,children:[e.jsx("div",{className:"h-[34px] w-[34px] bg-theme-settings-input-bg rounded-full flex items-center justify-center cursor-pointer hover:outline-primary-button hover:outline",onClick:()=>h(!u),children:L.createElement(S[r]||F,{className:"h-5 w-5",weight:r==="Plus"?"bold":"fill",color:"var(--theme-sidebar-footer-icon-fill)"})}),u&&e.jsx("div",{className:"absolute z-10 grid grid-cols-4 bg-theme-settings-input-bg mt-2 rounded-md w-[150px] h-[78px] overflow-y-auto border border-white/20 shadow-lg",children:Object.keys(S).map(d=>e.jsx("button",{type:"button",className:"flex justify-center items-center border border-transparent hover:bg-theme-sidebar-footer-icon-hover hover:border-slate-100 light:hover:border-black/80 rounded-full p-2",onClick:()=>g(d),children:L.createElement(S[d],{className:"h-5 w-5",weight:"fill",color:"var(--theme-sidebar-footer-icon-fill)"})},d))})]}),e.jsx("input",{type:"url",value:t,onChange:w,placeholder:"https://example.com",className:"border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-md p-2.5 w-[300px] h-[32px] focus:outline-primary-button active:outline-primary-button outline-none",required:!0}),r!=="Plus"&&e.jsx(e.Fragment,{children:b?e.jsx("button",{type:"submit",className:"text-sky-400 px-2 py-2 rounded-md text-sm font-bold hover:text-sky-500",children:"Save"}):e.jsx("button",{type:"button",onClick:c,className:"hover:text-red-500 text-white/80 px-2 py-2 rounded-md text-sm font-bold",children:e.jsx(E,{size:20})})})]})}function A(){const[s,p]=o.useState(Array(3).fill(null)),{t:x}=N();o.useEffect(()=>{async function a(){const{settings:t}=await j.systemPreferencesByFields(["footer_data"]),l=t==null?void 0:t.footer_data;if(l){const u=I(l,[]);p(h=>{const b=[...h];return u.forEach((i,n)=>{b[n]=i}),b})}}a()},[]);const f=async a=>{const{success:t,error:l}=await j.updateSystemPreferences({footer_data:JSON.stringify(a.filter(u=>u!==null))});if(!t){v(`Failed to update footer icons - ${l}`,"error",{clear:!0});return}window.localStorage.removeItem(y.cacheKeys.footerIcons),p(a),v("Successfully updated footer icons.","success",{clear:!0})},r=a=>{const t=[...s];t[a]=null,f(t)};return e.jsxs("div",{className:"flex flex-col gap-y-0.5 my-4",children:[e.jsx("p",{className:"text-sm leading-6 font-semibold text-white",children:x("customization.items.sidebar-footer.title")}),e.jsx("p",{className:"text-xs text-white/60",children:x("customization.items.sidebar-footer.description")}),e.jsxs("div",{className:"mt-2 flex gap-x-3 font-medium text-white text-sm",children:[e.jsx("div",{children:x("customization.items.sidebar-footer.icon")}),e.jsx("div",{children:x("customization.items.sidebar-footer.link")})]}),e.jsx("div",{className:"mt-2 flex flex-col gap-y-[10px]",children:s.map((a,t)=>e.jsx(U,{icon:a==null?void 0:a.icon,url:a==null?void 0:a.url,onSave:(l,u)=>{const h=[...s];h[t]={icon:l,url:u},f(h)},onRemove:()=>r(t)},t))})]})}function P(){const{user:s}=z(),[p,x]=o.useState(!0),[f,r]=o.useState(!1),[a,t]=o.useState(""),[l,u]=o.useState(""),{t:h}=N();o.useEffect(()=>{(async()=>{const m=await y.fetchSupportEmail();t(m.email||""),u(m.email||""),x(!1)})()},[]);const b=async(n,m=null)=>{n.preventDefault();let c=m;m===null&&(c=new FormData(n.target).get("supportEmail"));const{success:g,error:w}=await j.updateSystemPreferences({support_email:c});if(g)v("Successfully updated support email.","success"),window.localStorage.removeItem(y.cacheKeys.supportEmail),t(c),u(c),r(!1);else{v(`Failed to update support email: ${w}`,"error");return}},i=n=>{t(n.target.value),r(!0)};return p||!(s!=null&&s.role)?null:e.jsxs("form",{className:"flex flex-col gap-y-0.5 mt-4",onSubmit:b,children:[e.jsx("p",{className:"text-sm leading-6 font-semibold text-white",children:h("customization.items.support-email.title")}),e.jsx("p",{className:"text-xs text-white/60",children:h("customization.items.support-email.description")}),e.jsxs("div",{className:"flex items-center gap-x-4",children:[e.jsx("input",{name:"supportEmail",type:"email",className:"border-none bg-theme-settings-input-bg mt-2 text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-fit py-2 px-4",placeholder:"support@mycompany.com",required:!0,autoComplete:"off",onChange:i,value:a}),l!==""&&e.jsx("button",{type:"button",onClick:n=>b(n,""),className:"text-white text-base font-medium hover:text-opacity-60",children:"Clear"})]}),f&&e.jsx("button",{type:"submit",className:"transition-all mt-2 w-fit duration-300 border border-slate-200 px-5 py-2.5 rounded-lg text-white text-sm items-center flex gap-x-2 hover:bg-slate-200 hover:text-slate-800 focus:ring-gray-800",children:"Save"})]})}function D(){const{t:s}=N(),{logo:p,setLogo:x}=_(),[f,r]=o.useState(""),[a,t]=o.useState(!0),l=o.useRef(null);o.useEffect(()=>{async function i(){r(p||"");const n=await y.isDefaultLogo();t(n)}i()},[p]);const u=async i=>{const n=i.target.files[0];if(!n)return!1;const m=URL.createObjectURL(n);r(m);const c=new FormData;c.append("logo",n);const{success:g,error:w}=await y.uploadLogo(c);if(!g){v(`Failed to upload logo: ${w}`,"error"),r(p);return}const{logoURL:d}=await y.fetchLogo();x(d),v("Image uploaded successfully.","success"),t(!1)},h=async()=>{r(""),t(!0);const{success:i,error:n}=await y.removeCustomLogo();if(!i){console.error("Failed to remove logo:",n),v(`Failed to remove logo: ${n}`,"error");const{logoURL:c}=await y.fetchLogo();r(c),t(!1);return}const{logoURL:m}=await y.fetchLogo();x(m),v("Image successfully removed.","success")},b=()=>{var i;(i=l.current)==null||i.click()};return e.jsxs("div",{className:"flex flex-col gap-y-0.5 my-4",children:[e.jsx("p",{className:"text-sm leading-6 font-semibold text-white",children:s("customization.items.logo.title")}),e.jsx("p",{className:"text-xs text-white/60",children:s("customization.items.logo.description")}),a?e.jsx("div",{className:"flex md:flex-row flex-col items-center",children:e.jsx("div",{className:"flex flex-row gap-x-8",children:e.jsxs("label",{className:"mt-3 transition-all duration-300 hover:opacity-60",hidden:!a,children:[e.jsx("input",{id:"logo-upload",type:"file",accept:"image/*",className:"hidden",onChange:u}),e.jsx("div",{className:"w-80 py-4 bg-theme-settings-input-bg rounded-2xl border-2 border-dashed border-theme-text-secondary border-opacity-60 justify-center items-center inline-flex cursor-pointer",htmlFor:"logo-upload",children:e.jsxs("div",{className:"flex flex-col items-center justify-center",children:[e.jsx("div",{className:"rounded-full bg-white/40",children:e.jsx(F,{className:"w-6 h-6 text-black/80 m-2"})}),e.jsx("div",{className:"text-theme-text-primary text-opacity-80 text-sm font-semibold py-1",children:s("customization.items.logo.add")}),e.jsx("div",{className:"text-theme-text-secondary text-opacity-60 text-xs font-medium py-1",children:s("customization.items.logo.recommended")})]})})]})})}):e.jsx("div",{className:"flex md:flex-row flex-col items-center relative",children:e.jsxs("div",{className:"group w-80 h-[130px] mt-3 overflow-hidden",children:[e.jsx("img",{src:f,alt:"Uploaded Logo",className:"w-full h-full object-cover border-2 border-theme-text-secondary border-opacity-60 p-1 rounded-2xl"}),e.jsxs("div",{className:"absolute w-80 top-0 left-0 right-0 bottom-0 flex flex-col gap-y-3 justify-center items-center rounded-2xl mt-3 bg-black bg-opacity-80 opacity-0 group-hover:opacity-100 transition-opacity duration-300 ease-in-out border-2 border-transparent hover:border-white",children:[e.jsx("button",{onClick:b,className:"text-[#FFFFFF] text-base font-medium hover:text-opacity-60 mx-2",children:s("customization.items.logo.replace")}),e.jsx("input",{id:"logo-upload",type:"file",accept:"image/*",className:"hidden",onChange:u,ref:l}),e.jsx("button",{onClick:h,className:"text-[#FFFFFF] text-base font-medium hover:text-opacity-60 mx-2",children:s("customization.items.logo.remove")})]})]})})]})}function O(){const{t:s}=N(),[p,x]=o.useState(!0),[f,r]=o.useState(!1),[a,t]=o.useState(""),[l,u]=o.useState(""),[h,b]=o.useState(!1);o.useEffect(()=>{(async()=>{const c=await y.keys();if(!(c!=null&&c.MultiUserMode)&&!(c!=null&&c.RequiresAuth))return b(!1),!1;const{appName:g}=await y.fetchCustomAppName();t(g||""),u(g||""),b(!0),x(!1)})()},[]);const i=async(m,c=null)=>{m.preventDefault();let g=c;c===null&&(g=new FormData(m.target).get("customAppName"));const{success:w,error:d}=await j.updateSystemPreferences({custom_app_name:g});if(w)v("Successfully updated custom app name.","success"),window.localStorage.removeItem(y.cacheKeys.customAppName),t(g),u(g),r(!1);else{v(`Failed to update custom app name: ${d}`,"error");return}},n=m=>{t(m.target.value),r(!0)};return!h||p?null:e.jsxs("form",{className:"flex flex-col gap-y-0.5 mt-4",onSubmit:i,children:[e.jsx("p",{className:"text-sm leading-6 font-semibold text-white",children:s("customization.items.app-name.title")}),e.jsx("p",{className:"text-xs text-white/60",children:s("customization.items.app-name.description")}),e.jsxs("div",{className:"flex items-center gap-x-4",children:[e.jsx("input",{name:"customAppName",type:"text",className:"border-none bg-theme-settings-input-bg mt-2 text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-fit py-2 px-4",placeholder:"AnythingLLM",required:!0,autoComplete:"off",onChange:n,value:a}),l!==""&&e.jsx("button",{type:"button",onClick:m=>i(m,""),className:"text-white text-base font-medium hover:text-opacity-60",children:"Clear"})]}),f&&e.jsx("button",{type:"submit",className:"transition-all mt-2 w-fit duration-300 border border-slate-200 px-5 py-2.5 rounded-lg text-white text-sm items-center flex gap-x-2 hover:bg-slate-200 hover:text-slate-800 focus:ring-gray-800",children:"Save"})]})}function M(){const{t:s}=N(),[p,x]=o.useState(!1),[f,r]=o.useState({title:null,faviconUrl:null});o.useEffect(()=>{j.systemPreferencesByFields(["meta_page_title","meta_page_favicon"]).then(({settings:t})=>{r({title:t==null?void 0:t.meta_page_title,faviconUrl:t==null?void 0:t.meta_page_favicon})})},[]);async function a(t){t.preventDefault(),await j.updateSystemPreferences({meta_page_title:f.title??null,meta_page_favicon:f.faviconUrl??null}),v("Site preferences updated! They will reflect on page reload.","success",{clear:!0}),x(!1)}return e.jsxs("form",{className:"flex flex-col gap-y-0.5 my-4 border-t border-white border-opacity-20 light:border-black/20 pt-6",onChange:()=>x(!0),onSubmit:a,children:[e.jsx("p",{className:"text-sm leading-6 font-semibold text-white",children:s("customization.items.browser-appearance.title")}),e.jsx("p",{className:"text-xs text-white/60",children:s("customization.items.browser-appearance.description")}),e.jsxs("div",{className:"w-fit",children:[e.jsx("p",{className:"text-sm leading-6 font-medium text-white mt-2",children:s("customization.items.browser-appearance.tab.title")}),e.jsx("p",{className:"text-xs text-white/60",children:s("customization.items.browser-appearance.tab.description")}),e.jsx("div",{className:"flex items-center gap-x-4",children:e.jsx("input",{name:"meta_page_title",type:"text",className:"border-none bg-theme-settings-input-bg mt-2 text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-fit py-2 px-4",placeholder:"AnythingLLM | Your personal LLM trained on anything",autoComplete:"off",onChange:t=>{r(l=>({...l,title:t.target.value}))},value:f.title??"AnythingLLM | Your personal LLM trained on anything"})})]}),e.jsxs("div",{className:"w-fit",children:[e.jsx("p",{className:"text-sm leading-6 font-medium text-white mt-2",children:s("customization.items.browser-appearance.favicon.title")}),e.jsx("p",{className:"text-xs text-white/60",children:s("customization.items.browser-appearance.favicon.description")}),e.jsxs("div",{className:"flex items-center gap-x-2",children:[e.jsx("img",{src:f.faviconUrl??"/favicon.png",onError:t=>t.target.src="/favicon.png",className:"h-10 w-10 rounded-lg mt-2",alt:"Site favicon"}),e.jsx("input",{name:"meta_page_favicon",type:"url",className:"border-none bg-theme-settings-input-bg mt-2 text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-fit py-2 px-4",placeholder:"url to your image",onChange:t=>{r(l=>({...l,faviconUrl:t.target.value}))},autoComplete:"off",value:f.faviconUrl??""})]})]}),p&&e.jsx("button",{type:"submit",className:"transition-all mt-2 w-fit duration-300 border border-slate-200 px-5 py-2.5 rounded-lg text-white text-sm items-center flex gap-x-2 hover:bg-slate-200 hover:text-slate-800 focus:ring-gray-800",children:"Save"})]})}function T(){const{t:s}=N();return e.jsxs("div",{className:"w-screen h-screen overflow-hidden bg-theme-bg-container flex",children:[e.jsx(k,{}),e.jsx("div",{style:{height:R?"100%":"calc(100% - 32px)"},className:"relative md:ml-[2px] md:mr-[16px] md:my-[16px] md:rounded-[16px] bg-theme-bg-secondary w-full h-full overflow-y-scroll p-4 md:p-0",children:e.jsxs("div",{className:"flex flex-col w-full px-1 md:pl-6 md:pr-[86px] md:py-6 py-16",children:[e.jsxs("div",{className:"w-full flex flex-col gap-y-1 pb-6 border-white light:border-theme-sidebar-border border-b-2 border-opacity-10",children:[e.jsx("div",{className:"items-center",children:e.jsx("p",{className:"text-lg leading-6 font-bold text-white",children:s("customization.branding.title")})}),e.jsx("p",{className:"text-xs leading-[18px] font-base text-white text-opacity-60",children:s("customization.branding.description")})]}),e.jsx(O,{}),e.jsx(D,{}),e.jsx(A,{}),e.jsx(P,{}),e.jsx(M,{})]})})]})}export{T as default};