totem-llm 0.17.0 → 0.18.0
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.
- package/config/totem.features.json +4 -4
- package/package.json +1 -1
- package/server/.env +4 -4
- package/server/.env.example +6 -0
- package/server/endpoints/utils.js +3 -0
- package/server/public/assets/{index-026cbde1.js → index-0f333823.js} +1 -1
- package/server/public/assets/{index-93e01434.js → index-39624246.js} +1 -1
- package/server/public/assets/{index-ad41bc36.js → index-526070eb.js} +1 -1
- package/server/public/assets/{index-47d64ba1.js → index-f5ca717f.js} +1 -1
- package/server/public/index.js +53 -53
- package/server/public/venice.png +0 -0
- package/server/utils/AiProviders/openRouter/index.js +2 -2
- package/server/utils/AiProviders/venice/index.js +395 -0
- package/server/utils/agents/aibitat/index.js +2 -0
- package/server/utils/agents/aibitat/providers/index.js +2 -0
- package/server/utils/agents/aibitat/providers/ollama.js +27 -5
- package/server/utils/agents/aibitat/providers/venice.js +194 -0
- package/server/utils/agents/index.js +6 -0
- package/server/utils/boot/eagerLoadContextWindows.js +5 -0
- package/server/utils/helpers/customModels.js +51 -0
- package/server/utils/helpers/index.js +8 -0
- package/server/utils/helpers/updateENV.js +19 -0
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
"npm": {
|
|
94
94
|
"communityHub": false,
|
|
95
95
|
"modelRouter": false,
|
|
96
|
-
"llmProviders": ["ollama", "openrouter", "lmstudio", "generic-openai", "anthropic", "openai"],
|
|
96
|
+
"llmProviders": ["ollama", "openrouter", "lmstudio", "generic-openai", "anthropic", "openai", "venice"],
|
|
97
97
|
"brandingWhitelabel": false,
|
|
98
98
|
"filesystemAgent": true,
|
|
99
99
|
"documentationLink": false,
|
|
@@ -117,7 +117,7 @@
|
|
|
117
117
|
"L1": {
|
|
118
118
|
"communityHub": false,
|
|
119
119
|
"modelRouter": true,
|
|
120
|
-
"llmProviders": ["ollama", "openrouter", "lmstudio", "generic-openai", "anthropic", "openai"],
|
|
120
|
+
"llmProviders": ["ollama", "openrouter", "lmstudio", "generic-openai", "anthropic", "openai", "venice"],
|
|
121
121
|
"brandingWhitelabel": false,
|
|
122
122
|
"filesystemAgent": true,
|
|
123
123
|
"documentationLink": false,
|
|
@@ -141,7 +141,7 @@
|
|
|
141
141
|
"L2": {
|
|
142
142
|
"communityHub": false,
|
|
143
143
|
"modelRouter": true,
|
|
144
|
-
"llmProviders": ["ollama", "openrouter", "lmstudio", "generic-openai", "anthropic", "openai"],
|
|
144
|
+
"llmProviders": ["ollama", "openrouter", "lmstudio", "generic-openai", "anthropic", "openai", "venice"],
|
|
145
145
|
"brandingWhitelabel": true,
|
|
146
146
|
"filesystemAgent": true,
|
|
147
147
|
"documentationLink": true,
|
|
@@ -165,7 +165,7 @@
|
|
|
165
165
|
"source": {
|
|
166
166
|
"communityHub": true,
|
|
167
167
|
"modelRouter": true,
|
|
168
|
-
"llmProviders": ["ollama", "openrouter", "lmstudio", "generic-openai", "anthropic", "openai"],
|
|
168
|
+
"llmProviders": ["ollama", "openrouter", "lmstudio", "generic-openai", "anthropic", "openai", "venice"],
|
|
169
169
|
"brandingWhitelabel": true,
|
|
170
170
|
"filesystemAgent": true,
|
|
171
171
|
"documentationLink": true,
|
package/package.json
CHANGED
package/server/.env
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
# Auto-dump ENV from system call on
|
|
2
|
-
LLM_PROVIDER='
|
|
1
|
+
# Auto-dump ENV from system call on 15:27:55 GMT-0400 (Eastern Daylight Time)
|
|
2
|
+
LLM_PROVIDER='ollama'
|
|
3
3
|
OLLAMA_BASE_PATH='http://127.0.0.1:11434'
|
|
4
4
|
OLLAMA_MODEL_PREF='qwen3.5:2b'
|
|
5
|
-
|
|
5
|
+
OLLAMA_KEEP_ALIVE_TIMEOUT='300'
|
|
6
6
|
OLLAMA_AUTH_TOKEN='your-ollama-auth-token-here (optional, only for ollama running behind auth - Bearer token)'
|
|
7
7
|
VECTOR_DB='lancedb'
|
|
8
8
|
OPENROUTER_API_KEY='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'
|
|
@@ -15,5 +15,5 @@ STORAGE_DIR='/home/mike-diker/totem-llm'
|
|
|
15
15
|
SERVER_PORT='8686'
|
|
16
16
|
SIG_KEY='passphrase'
|
|
17
17
|
SIG_SALT='salt'
|
|
18
|
-
DATABASE_URL='file:../storage/
|
|
18
|
+
DATABASE_URL='file:../storage/totem-llm.db'
|
|
19
19
|
OLLAMA_RESPONSE_TIMEOUT='7200000 (optional, max timeout in milliseconds for ollama response to conclude. Default is 5min before aborting)'
|
package/server/.env.example
CHANGED
|
@@ -194,6 +194,12 @@ DATABASE_URL="file:../storage/totem-llm.db"
|
|
|
194
194
|
# CEREBRAS_API_KEY='your-cerebras-api-key-here'
|
|
195
195
|
# CEREBRAS_MODEL_PREF='gpt-oss-120b'
|
|
196
196
|
|
|
197
|
+
# LLM_PROVIDER='venice'
|
|
198
|
+
# VENICE_API_KEY='your-venice-api-key'
|
|
199
|
+
# VENICE_MODEL_PREF='zai-org-glm-5-1'
|
|
200
|
+
# VENICE_MODEL_TOKEN_LIMIT=8192
|
|
201
|
+
# VENICE_MAX_TOKENS=1024
|
|
202
|
+
|
|
197
203
|
# LLM_PROVIDER='anythingllm-router'
|
|
198
204
|
# MODEL_ROUTER_ID=1
|
|
199
205
|
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{r as c,j as e,p,C as h,c as d,W as I,ah as w,a7 as v,aM as S,aH as C,s as A,v as L,aO as T,a3 as F,i as N}from"../index.js";import{C as f}from"./communityHub-aba61686.js";import{r as H}from"./files-0f5d16df.js";import{p as P}from"./purify-ca43d85f.js";import{s as M}from"./index-ad41bc36.js";import{A as b}from"./agentFlows-e4124dd3.js";/* empty css */import"./Check-7e83fb0d.js";import"./Copy-d323e545.js";import"./index-c9a0d9d0.js";import"./truncate-24ce7b97.js";import"./XCircle-edfe554c.js";import"./moment-49fc1b76.js";import"./File-b92df2f3.js";import"./Eye-9f033dc0.js";import"./index-4fb4d421.js";import"./react-beautiful-dnd.esm-cf34cce5.js";import"./mcpServers-4f9690f1.js";import"./admin-04b020fe.js";import"./Database-f1a76329.js";import"./Trans-06928aa5.js";import"./Brain-24e386d5.js";import"./Browser-1820fad0.js";import"./index-c736791c.js";import"./index-bd540023.js";import"./WarningCircle-27467274.js";import"./index-8ba96f42.js";import"./Hammer-05b5ccc7.js";function U({settings:t,setSettings:l,setStep:s}){const[n,a]=c.useState(t.itemId),i=()=>{if(!n)return d("Please enter an item ID","error");l(r=>({...r,itemId:n})),s(x.itemId.next())};return e.jsx("div",{className:"flex-[2] flex flex-col gap-y-[18px] mt-10",children:e.jsx("div",{className:"bg-theme-bg-secondary rounded-xl flex-1 p-6",children:e.jsxs("div",{className:"w-full flex flex-col gap-y-2 max-w-[700px]",children:[e.jsx("h2",{className:"text-base text-theme-text-primary font-semibold",children:"Import an item from the community hub"}),e.jsxs("div",{className:"flex flex-col gap-y-[25px] text-theme-text-secondary text-sm",children:[e.jsx("p",{children:"The community hub is a place where you can find, share, and import agent-skills, system prompts, slash commands, and more!"}),e.jsx("p",{children:"These items are created by the AnythingLLM team and community, and are a great way to get started with AnythingLLM as well as extend AnythingLLM in a way that is customized to your needs."}),e.jsxs("p",{children:["There are both ",e.jsx("b",{children:"private"})," and ",e.jsx("b",{children:"public"})," items in the community hub. Private items are only visible to you, while public items are visible to everyone."]}),e.jsxs("p",{className:"p-4 bg-yellow-800/30 light:bg-orange-100 light:text-orange-500 light:border-orange-500 rounded-lg border border-yellow-500 text-yellow-500",children:["If you are pulling in a private item, make sure it is"," ",e.jsx("b",{children:"shared with a team"})," you belong to, and you have added a"," ",e.jsx("a",{href:p.communityHub.authentication(),className:"underline text-yellow-100 light:text-orange-500 font-semibold",children:"Connection Key."})]})]}),e.jsx("div",{className:"flex flex-col gap-y-2 mt-4",children:e.jsx("div",{className:"w-full flex flex-col gap-y-4",children:e.jsxs("div",{className:"flex flex-col w-full",children:[e.jsx("label",{className:"text-theme-text-primary text-sm font-semibold block mb-3",children:"Community Hub Item Import ID"}),e.jsx("input",{type:"text",value:n,onChange:r=>a(r.target.value),placeholder:"allm-community-id:agent-skill:1234567890",className:"border-none bg-theme-settings-input-bg text-theme-text-primary 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"})]})})}),e.jsx(h,{className:"text-dark-text w-full mt-[18px] h-[34px] hover:bg-accent",onClick:i,children:"Continue with import →"})]})})})}function z({item:t,setStep:l}){const[s,n]=c.useState(null),[a,i]=c.useState([]);c.useEffect(()=>{async function o(){const m=await I.all();i(m),n(m[0].slug)}o()},[]);async function r(){d("Applying system prompt to workspace...","info");const{error:o}=await f.applyItem(t.importId,{workspaceSlug:s});if(o)return d(`Failed to apply system prompt. ${o}`,"error",{clear:!0});d("System prompt applied to workspace.","success",{clear:!0}),l(x.completed.key)}return e.jsxs("div",{className:"flex flex-col mt-4 gap-y-4",children:[e.jsxs("div",{className:"flex flex-col gap-y-1",children:[e.jsxs("h2",{className:"text-base text-theme-text-primary font-semibold",children:['Review System Prompt "',t.name,'"']}),t.creatorUsername&&e.jsxs("p",{className:"text-white/60 light:text-theme-text-secondary text-xs font-mono",children:["Created by"," ",e.jsxs("a",{href:p.communityHub.profile(t.creatorUsername),target:"_blank",className:"hover:text-blue-500 hover:underline",rel:"noreferrer",children:["@",t.creatorUsername]})]})]}),e.jsxs("div",{className:"flex flex-col gap-y-[25px] text-white/80 light:text-theme-text-secondary text-sm",children:[e.jsx("p",{children:"System prompts are used to guide the behavior of the AI agents and can be applied to any existing workspace."}),e.jsxs("div",{className:"flex flex-col gap-y-2",children:[e.jsx("p",{className:"text-white/60 light:text-theme-text-secondary font-semibold",children:"Provided system prompt:"}),e.jsx("div",{className:"w-full text-theme-text-primary text-md flex flex-col max-h-[calc(300px)] overflow-y-auto",children:e.jsx("p",{className:"text-white/60 light:text-theme-text-secondary font-mono bg-zinc-900 light:bg-slate-200 px-2 py-1 rounded-md text-sm whitespace-pre-line",children:t.prompt})})]}),e.jsxs("div",{className:"flex flex-col w-60",children:[e.jsx("label",{className:"text-theme-text-primary text-sm font-semibold block mb-3",children:"Apply to Workspace"}),e.jsx("select",{name:"destinationWorkspaceSlug",required:!0,onChange:o=>n(o.target.value),className:"border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5",children:e.jsx("optgroup",{label:"Available workspaces",children:a.map(o=>e.jsx("option",{value:o.slug,children:o.name},o.id))})})]})]}),s&&e.jsx(h,{className:"text-dark-text w-full mt-[18px] h-[34px] hover:bg-accent",onClick:r,children:"Apply system prompt to workspace"})]})}function E({item:t,setStep:l}){async function s(){try{const{error:n}=await f.applyItem(t.importId);if(n)throw new Error(n);d(`Slash command ${t.command} imported successfully!`,"success"),l(x.completed.key)}catch(n){console.error(n),d(`Failed to import slash command. ${n.message}`,"error")}}return e.jsxs("div",{className:"flex flex-col mt-4 gap-y-4",children:[e.jsxs("div",{className:"flex flex-col gap-y-1",children:[e.jsxs("h2",{className:"text-base text-theme-text-primary font-semibold",children:['Review Slash Command "',t.name,'"']}),t.creatorUsername&&e.jsxs("p",{className:"text-white/60 text-xs font-mono",children:["Created by"," ",e.jsxs("a",{href:p.communityHub.profile(t.creatorUsername),target:"_blank",className:"hover:text-blue-500 hover:underline",rel:"noreferrer",children:["@",t.creatorUsername]})]})]}),e.jsxs("div",{className:"flex flex-col gap-y-[25px] text-white/80 light:text-theme-text-secondary text-sm",children:[e.jsxs("p",{children:["Slash commands are used to prefill information into a prompt while chatting with a AnythingLLM workspace.",e.jsx("br",{}),e.jsx("br",{}),"The slash command will be available during chatting by simply invoking it with"," ",e.jsx("code",{className:"font-mono bg-zinc-900 light:bg-slate-200 px-1 py-0.5 rounded-md text-sm",children:t.command})," ","like you would any other command."]}),e.jsxs("div",{className:"flex flex-col gap-y-2 mt-2",children:[e.jsx("div",{className:"w-full text-theme-text-primary text-md gap-x-2 flex items-center",children:e.jsx("p",{className:"text-white/60 light:text-theme-text-secondary w-fit font-mono bg-zinc-900 light:bg-slate-200 px-2 py-1 rounded-md text-sm whitespace-pre-line",children:t.command})}),e.jsx("div",{className:"w-full text-theme-text-primary text-md flex flex-col gap-y-2",children:e.jsx("p",{className:"text-white/60 light:text-theme-text-secondary font-mono bg-zinc-900 light:bg-slate-200 p-4 rounded-md text-sm whitespace-pre-line max-h-[calc(200px)] overflow-y-auto",children:t.prompt})})]})]}),e.jsx(h,{className:"text-dark-text w-full mt-[18px] h-[34px] hover:bg-accent",onClick:s,children:"Import slash command"})]})}function $({item:t,setSettings:l,setStep:s}){return e.jsxs("div",{className:"flex flex-col mt-4 gap-y-4",children:[e.jsxs("div",{className:"w-full flex items-center gap-x-2",children:[e.jsx(w,{size:24,className:"text-red-500"}),e.jsx("h2",{className:"text-base text-red-500 font-semibold",children:"Unsupported item"})]}),e.jsxs("div",{className:"flex flex-col gap-y-[25px] text-white/80 text-sm",children:[e.jsx("p",{children:"We found an item in the community hub, but we don't know what it is or it is not yet supported for import into AnythingLLM."}),e.jsxs("p",{children:["The item ID is: ",e.jsx("b",{children:t.id}),e.jsx("br",{}),"The item type is: ",e.jsx("b",{children:t.itemType})]}),e.jsx("p",{children:"Please contact support via email if you need help importing this item."})]}),e.jsx(h,{className:"text-dark-text w-full mt-[18px] h-[34px] hover:bg-accent",onClick:()=>{l({itemId:null,item:null}),s(x.itemId.key)},children:"Try another item"})]})}function D({item:t,settings:l,setStep:s}){const[n,a]=c.useState(!1);async function i(){try{a(!0);const{error:r}=await f.importBundleItem(l.itemId);if(r)throw new Error(r);d("Agent skill imported successfully!","success"),s(x.completed.key)}catch(r){console.error(r),d(`Failed to import agent skill. ${r.message}`,"error")}finally{a(!1)}}return c.useEffect(()=>{M()},[]),e.jsxs("div",{className:"flex flex-col mt-4 gap-y-4",children:[e.jsx("div",{className:"border border-white/10 light:border-orange-500/20 my-2 flex flex-col md:flex-row md:items-center gap-x-2 text-theme-text-primary light:text-orange-600 mb-4 bg-orange-800/30 light:bg-orange-500/10 rounded-lg px-4 py-2",children:e.jsxs("div",{className:"flex flex-col gap-y-2",children:[e.jsxs("div",{className:"gap-x-2 flex items-center",children:[e.jsx(w,{size:25}),e.jsxs("h1",{className:"text-lg font-semibold",children:[" ","Only import agent skills you trust"," "]})]}),e.jsx("p",{className:"text-sm",children:"Agent skills can execute code on your AnythingLLM instance, so only import agent skills from sources you trust. You should also review the code before importing. If you are unsure about what a skill does - don't import it!"})]})}),e.jsxs("div",{className:"flex flex-col gap-y-1",children:[e.jsxs("h2",{className:"text-base text-theme-text-primary font-semibold",children:['Review Agent Skill "',t.name,'"']}),t.creatorUsername&&e.jsxs("p",{className:"text-white/60 light:text-theme-text-secondary text-xs font-mono",children:["Created by"," ",e.jsxs("a",{href:p.communityHub.profile(t.creatorUsername),target:"_blank",className:"hover:text-blue-500 hover:underline",rel:"noreferrer",children:["@",t.creatorUsername]})]}),e.jsxs("div",{className:"flex gap-x-1",children:[t.verified?e.jsx("p",{className:"text-green-500 text-xs font-mono",children:"Verified code"}):e.jsx("p",{className:"text-red-500 text-xs font-mono",children:"This skill is not verified."}),e.jsx("a",{href:"https://docs.anythingllm.com/community-hub/faq#verification",target:"_blank",className:"text-xs font-mono text-blue-500 hover:underline",rel:"noreferrer",children:"Learn more →"})]})]}),e.jsx("div",{className:"flex flex-col gap-y-[25px] text-white/80 light:text-theme-text-secondary text-sm",children:e.jsxs("p",{children:["Agent skills unlock new capabilities for your AnythingLLM workspace via"," ",e.jsx("code",{className:"font-mono bg-zinc-900 light:bg-slate-200 px-1 py-0.5 rounded-md text-sm",children:"@agent"})," ","skills that can do specific tasks when invoked."]})}),e.jsx(W,{item:t}),e.jsxs(h,{disabled:n,className:"text-dark-text w-full mt-[18px] h-[34px] hover:bg-accent",onClick:i,children:[n?e.jsx(v,{size:16,className:"animate-spin"}):null,n?"Importing...":"Import agent skill"]})]})}function W({item:t}){const l=t.manifest.files||[],[s,n]=c.useState(0),[a,i]=c.useState(l[s]);function r(){s>0&&n(s-1)}function o(){s<l.length-1&&n(s+1)}function m(u){switch(u.name.split(".").pop()){case"js":return"javascript";case"json":return"json";case"md":return"markdown";default:return"text"}}return c.useEffect(()=>{l.length>0&&i((l==null?void 0:l[s])||l[0])},[s]),a?e.jsx("div",{className:"flex flex-col gap-y-2",children:e.jsxs("div",{className:"flex flex-col gap-y-2",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("button",{type:"button",className:`border-none bg-black/70 light:bg-slate-200 rounded-md p-1 text-white/60 light:text-theme-text-secondary text-xs font-mono ${s===0?"opacity-50 cursor-not-allowed":""}`,onClick:r,children:e.jsx(S,{size:16})}),e.jsxs("p",{className:"text-white/60 light:text-theme-text-secondary text-xs font-mono",children:[a.name," (",s+1," of ",l.length," files)"]}),e.jsx("button",{type:"button",className:`border-none bg-black/70 light:bg-slate-200 rounded-md p-1 text-white/60 light:text-theme-text-secondary text-xs font-mono ${s===l.length-1?"opacity-50 cursor-not-allowed":""}`,onClick:o,children:e.jsx(C,{size:16})})]}),e.jsx("span",{className:"whitespace-pre-line flex flex-col gap-y-1 text-sm leading-[20px] max-h-[500px] overflow-y-auto hljs text-theme-text-primary",dangerouslySetInnerHTML:{__html:P.sanitize(H(`\`\`\`${m(a)}
|
|
1
|
+
import{r as c,j as e,p,C as h,c as d,W as I,ah as w,a7 as v,aM as S,aH as C,s as A,v as L,aO as T,a3 as F,i as N}from"../index.js";import{C as f}from"./communityHub-aba61686.js";import{r as H}from"./files-0f5d16df.js";import{p as P}from"./purify-ca43d85f.js";import{s as M}from"./index-526070eb.js";import{A as b}from"./agentFlows-e4124dd3.js";/* empty css */import"./Check-7e83fb0d.js";import"./Copy-d323e545.js";import"./index-c9a0d9d0.js";import"./truncate-24ce7b97.js";import"./XCircle-edfe554c.js";import"./moment-49fc1b76.js";import"./File-b92df2f3.js";import"./Eye-9f033dc0.js";import"./index-4fb4d421.js";import"./react-beautiful-dnd.esm-cf34cce5.js";import"./mcpServers-4f9690f1.js";import"./admin-04b020fe.js";import"./Database-f1a76329.js";import"./Trans-06928aa5.js";import"./Brain-24e386d5.js";import"./Browser-1820fad0.js";import"./index-c736791c.js";import"./index-bd540023.js";import"./WarningCircle-27467274.js";import"./index-8ba96f42.js";import"./Hammer-05b5ccc7.js";function U({settings:t,setSettings:l,setStep:s}){const[n,a]=c.useState(t.itemId),i=()=>{if(!n)return d("Please enter an item ID","error");l(r=>({...r,itemId:n})),s(x.itemId.next())};return e.jsx("div",{className:"flex-[2] flex flex-col gap-y-[18px] mt-10",children:e.jsx("div",{className:"bg-theme-bg-secondary rounded-xl flex-1 p-6",children:e.jsxs("div",{className:"w-full flex flex-col gap-y-2 max-w-[700px]",children:[e.jsx("h2",{className:"text-base text-theme-text-primary font-semibold",children:"Import an item from the community hub"}),e.jsxs("div",{className:"flex flex-col gap-y-[25px] text-theme-text-secondary text-sm",children:[e.jsx("p",{children:"The community hub is a place where you can find, share, and import agent-skills, system prompts, slash commands, and more!"}),e.jsx("p",{children:"These items are created by the AnythingLLM team and community, and are a great way to get started with AnythingLLM as well as extend AnythingLLM in a way that is customized to your needs."}),e.jsxs("p",{children:["There are both ",e.jsx("b",{children:"private"})," and ",e.jsx("b",{children:"public"})," items in the community hub. Private items are only visible to you, while public items are visible to everyone."]}),e.jsxs("p",{className:"p-4 bg-yellow-800/30 light:bg-orange-100 light:text-orange-500 light:border-orange-500 rounded-lg border border-yellow-500 text-yellow-500",children:["If you are pulling in a private item, make sure it is"," ",e.jsx("b",{children:"shared with a team"})," you belong to, and you have added a"," ",e.jsx("a",{href:p.communityHub.authentication(),className:"underline text-yellow-100 light:text-orange-500 font-semibold",children:"Connection Key."})]})]}),e.jsx("div",{className:"flex flex-col gap-y-2 mt-4",children:e.jsx("div",{className:"w-full flex flex-col gap-y-4",children:e.jsxs("div",{className:"flex flex-col w-full",children:[e.jsx("label",{className:"text-theme-text-primary text-sm font-semibold block mb-3",children:"Community Hub Item Import ID"}),e.jsx("input",{type:"text",value:n,onChange:r=>a(r.target.value),placeholder:"allm-community-id:agent-skill:1234567890",className:"border-none bg-theme-settings-input-bg text-theme-text-primary 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"})]})})}),e.jsx(h,{className:"text-dark-text w-full mt-[18px] h-[34px] hover:bg-accent",onClick:i,children:"Continue with import →"})]})})})}function z({item:t,setStep:l}){const[s,n]=c.useState(null),[a,i]=c.useState([]);c.useEffect(()=>{async function o(){const m=await I.all();i(m),n(m[0].slug)}o()},[]);async function r(){d("Applying system prompt to workspace...","info");const{error:o}=await f.applyItem(t.importId,{workspaceSlug:s});if(o)return d(`Failed to apply system prompt. ${o}`,"error",{clear:!0});d("System prompt applied to workspace.","success",{clear:!0}),l(x.completed.key)}return e.jsxs("div",{className:"flex flex-col mt-4 gap-y-4",children:[e.jsxs("div",{className:"flex flex-col gap-y-1",children:[e.jsxs("h2",{className:"text-base text-theme-text-primary font-semibold",children:['Review System Prompt "',t.name,'"']}),t.creatorUsername&&e.jsxs("p",{className:"text-white/60 light:text-theme-text-secondary text-xs font-mono",children:["Created by"," ",e.jsxs("a",{href:p.communityHub.profile(t.creatorUsername),target:"_blank",className:"hover:text-blue-500 hover:underline",rel:"noreferrer",children:["@",t.creatorUsername]})]})]}),e.jsxs("div",{className:"flex flex-col gap-y-[25px] text-white/80 light:text-theme-text-secondary text-sm",children:[e.jsx("p",{children:"System prompts are used to guide the behavior of the AI agents and can be applied to any existing workspace."}),e.jsxs("div",{className:"flex flex-col gap-y-2",children:[e.jsx("p",{className:"text-white/60 light:text-theme-text-secondary font-semibold",children:"Provided system prompt:"}),e.jsx("div",{className:"w-full text-theme-text-primary text-md flex flex-col max-h-[calc(300px)] overflow-y-auto",children:e.jsx("p",{className:"text-white/60 light:text-theme-text-secondary font-mono bg-zinc-900 light:bg-slate-200 px-2 py-1 rounded-md text-sm whitespace-pre-line",children:t.prompt})})]}),e.jsxs("div",{className:"flex flex-col w-60",children:[e.jsx("label",{className:"text-theme-text-primary text-sm font-semibold block mb-3",children:"Apply to Workspace"}),e.jsx("select",{name:"destinationWorkspaceSlug",required:!0,onChange:o=>n(o.target.value),className:"border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5",children:e.jsx("optgroup",{label:"Available workspaces",children:a.map(o=>e.jsx("option",{value:o.slug,children:o.name},o.id))})})]})]}),s&&e.jsx(h,{className:"text-dark-text w-full mt-[18px] h-[34px] hover:bg-accent",onClick:r,children:"Apply system prompt to workspace"})]})}function E({item:t,setStep:l}){async function s(){try{const{error:n}=await f.applyItem(t.importId);if(n)throw new Error(n);d(`Slash command ${t.command} imported successfully!`,"success"),l(x.completed.key)}catch(n){console.error(n),d(`Failed to import slash command. ${n.message}`,"error")}}return e.jsxs("div",{className:"flex flex-col mt-4 gap-y-4",children:[e.jsxs("div",{className:"flex flex-col gap-y-1",children:[e.jsxs("h2",{className:"text-base text-theme-text-primary font-semibold",children:['Review Slash Command "',t.name,'"']}),t.creatorUsername&&e.jsxs("p",{className:"text-white/60 text-xs font-mono",children:["Created by"," ",e.jsxs("a",{href:p.communityHub.profile(t.creatorUsername),target:"_blank",className:"hover:text-blue-500 hover:underline",rel:"noreferrer",children:["@",t.creatorUsername]})]})]}),e.jsxs("div",{className:"flex flex-col gap-y-[25px] text-white/80 light:text-theme-text-secondary text-sm",children:[e.jsxs("p",{children:["Slash commands are used to prefill information into a prompt while chatting with a AnythingLLM workspace.",e.jsx("br",{}),e.jsx("br",{}),"The slash command will be available during chatting by simply invoking it with"," ",e.jsx("code",{className:"font-mono bg-zinc-900 light:bg-slate-200 px-1 py-0.5 rounded-md text-sm",children:t.command})," ","like you would any other command."]}),e.jsxs("div",{className:"flex flex-col gap-y-2 mt-2",children:[e.jsx("div",{className:"w-full text-theme-text-primary text-md gap-x-2 flex items-center",children:e.jsx("p",{className:"text-white/60 light:text-theme-text-secondary w-fit font-mono bg-zinc-900 light:bg-slate-200 px-2 py-1 rounded-md text-sm whitespace-pre-line",children:t.command})}),e.jsx("div",{className:"w-full text-theme-text-primary text-md flex flex-col gap-y-2",children:e.jsx("p",{className:"text-white/60 light:text-theme-text-secondary font-mono bg-zinc-900 light:bg-slate-200 p-4 rounded-md text-sm whitespace-pre-line max-h-[calc(200px)] overflow-y-auto",children:t.prompt})})]})]}),e.jsx(h,{className:"text-dark-text w-full mt-[18px] h-[34px] hover:bg-accent",onClick:s,children:"Import slash command"})]})}function $({item:t,setSettings:l,setStep:s}){return e.jsxs("div",{className:"flex flex-col mt-4 gap-y-4",children:[e.jsxs("div",{className:"w-full flex items-center gap-x-2",children:[e.jsx(w,{size:24,className:"text-red-500"}),e.jsx("h2",{className:"text-base text-red-500 font-semibold",children:"Unsupported item"})]}),e.jsxs("div",{className:"flex flex-col gap-y-[25px] text-white/80 text-sm",children:[e.jsx("p",{children:"We found an item in the community hub, but we don't know what it is or it is not yet supported for import into AnythingLLM."}),e.jsxs("p",{children:["The item ID is: ",e.jsx("b",{children:t.id}),e.jsx("br",{}),"The item type is: ",e.jsx("b",{children:t.itemType})]}),e.jsx("p",{children:"Please contact support via email if you need help importing this item."})]}),e.jsx(h,{className:"text-dark-text w-full mt-[18px] h-[34px] hover:bg-accent",onClick:()=>{l({itemId:null,item:null}),s(x.itemId.key)},children:"Try another item"})]})}function D({item:t,settings:l,setStep:s}){const[n,a]=c.useState(!1);async function i(){try{a(!0);const{error:r}=await f.importBundleItem(l.itemId);if(r)throw new Error(r);d("Agent skill imported successfully!","success"),s(x.completed.key)}catch(r){console.error(r),d(`Failed to import agent skill. ${r.message}`,"error")}finally{a(!1)}}return c.useEffect(()=>{M()},[]),e.jsxs("div",{className:"flex flex-col mt-4 gap-y-4",children:[e.jsx("div",{className:"border border-white/10 light:border-orange-500/20 my-2 flex flex-col md:flex-row md:items-center gap-x-2 text-theme-text-primary light:text-orange-600 mb-4 bg-orange-800/30 light:bg-orange-500/10 rounded-lg px-4 py-2",children:e.jsxs("div",{className:"flex flex-col gap-y-2",children:[e.jsxs("div",{className:"gap-x-2 flex items-center",children:[e.jsx(w,{size:25}),e.jsxs("h1",{className:"text-lg font-semibold",children:[" ","Only import agent skills you trust"," "]})]}),e.jsx("p",{className:"text-sm",children:"Agent skills can execute code on your AnythingLLM instance, so only import agent skills from sources you trust. You should also review the code before importing. If you are unsure about what a skill does - don't import it!"})]})}),e.jsxs("div",{className:"flex flex-col gap-y-1",children:[e.jsxs("h2",{className:"text-base text-theme-text-primary font-semibold",children:['Review Agent Skill "',t.name,'"']}),t.creatorUsername&&e.jsxs("p",{className:"text-white/60 light:text-theme-text-secondary text-xs font-mono",children:["Created by"," ",e.jsxs("a",{href:p.communityHub.profile(t.creatorUsername),target:"_blank",className:"hover:text-blue-500 hover:underline",rel:"noreferrer",children:["@",t.creatorUsername]})]}),e.jsxs("div",{className:"flex gap-x-1",children:[t.verified?e.jsx("p",{className:"text-green-500 text-xs font-mono",children:"Verified code"}):e.jsx("p",{className:"text-red-500 text-xs font-mono",children:"This skill is not verified."}),e.jsx("a",{href:"https://docs.anythingllm.com/community-hub/faq#verification",target:"_blank",className:"text-xs font-mono text-blue-500 hover:underline",rel:"noreferrer",children:"Learn more →"})]})]}),e.jsx("div",{className:"flex flex-col gap-y-[25px] text-white/80 light:text-theme-text-secondary text-sm",children:e.jsxs("p",{children:["Agent skills unlock new capabilities for your AnythingLLM workspace via"," ",e.jsx("code",{className:"font-mono bg-zinc-900 light:bg-slate-200 px-1 py-0.5 rounded-md text-sm",children:"@agent"})," ","skills that can do specific tasks when invoked."]})}),e.jsx(W,{item:t}),e.jsxs(h,{disabled:n,className:"text-dark-text w-full mt-[18px] h-[34px] hover:bg-accent",onClick:i,children:[n?e.jsx(v,{size:16,className:"animate-spin"}):null,n?"Importing...":"Import agent skill"]})]})}function W({item:t}){const l=t.manifest.files||[],[s,n]=c.useState(0),[a,i]=c.useState(l[s]);function r(){s>0&&n(s-1)}function o(){s<l.length-1&&n(s+1)}function m(u){switch(u.name.split(".").pop()){case"js":return"javascript";case"json":return"json";case"md":return"markdown";default:return"text"}}return c.useEffect(()=>{l.length>0&&i((l==null?void 0:l[s])||l[0])},[s]),a?e.jsx("div",{className:"flex flex-col gap-y-2",children:e.jsxs("div",{className:"flex flex-col gap-y-2",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("button",{type:"button",className:`border-none bg-black/70 light:bg-slate-200 rounded-md p-1 text-white/60 light:text-theme-text-secondary text-xs font-mono ${s===0?"opacity-50 cursor-not-allowed":""}`,onClick:r,children:e.jsx(S,{size:16})}),e.jsxs("p",{className:"text-white/60 light:text-theme-text-secondary text-xs font-mono",children:[a.name," (",s+1," of ",l.length," files)"]}),e.jsx("button",{type:"button",className:`border-none bg-black/70 light:bg-slate-200 rounded-md p-1 text-white/60 light:text-theme-text-secondary text-xs font-mono ${s===l.length-1?"opacity-50 cursor-not-allowed":""}`,onClick:o,children:e.jsx(C,{size:16})})]}),e.jsx("span",{className:"whitespace-pre-line flex flex-col gap-y-1 text-sm leading-[20px] max-h-[500px] overflow-y-auto hljs text-theme-text-primary",dangerouslySetInnerHTML:{__html:P.sanitize(H(`\`\`\`${m(a)}
|
|
2
2
|
${m(a)==="markdown"?a.content.replace(/```/g,"~~~"):a.content}
|
|
3
3
|
\`\`\``))}})]})}):null}function O({item:t,setStep:l}){const s=A(t.flow,{steps:[]}),[n,a]=c.useState(!1);async function i(){try{a(!0);const{success:r,error:o,flow:m}=await b.saveFlow(t.name,s);if(!r)throw new Error(o);m!=null&&m.uuid&&await b.toggleFlow(m.uuid,!0),d("Agent flow imported successfully!","success"),l(x.completed.key)}catch(r){console.error(r),d(`Failed to import agent flow. ${r.message}`,"error")}finally{a(!1)}}return e.jsxs("div",{className:"flex flex-col mt-4 gap-y-4",children:[e.jsxs("div",{className:"flex flex-col gap-y-1",children:[e.jsxs("h2",{className:"text-base text-theme-text-primary font-semibold",children:['Import Agent Flow "',t.name,'"']}),t.creatorUsername&&e.jsxs("p",{className:"text-white/60 light:text-theme-text-secondary text-xs font-mono",children:["Created by"," ",e.jsxs("a",{href:p.communityHub.profile(t.creatorUsername),target:"_blank",className:"hover:text-blue-500 hover:underline",rel:"noreferrer",children:["@",t.creatorUsername]})]})]}),e.jsxs("div",{className:"flex flex-col gap-y-[25px] text-white/80 light:text-theme-text-secondary text-sm",children:[e.jsx("p",{children:"Agent flows allow you to create reusable sequences of actions that can be triggered by your agent."}),e.jsxs("div",{className:"flex flex-col gap-y-2",children:[e.jsx("p",{className:"font-semibold",children:"Flow Details:"}),e.jsxs("p",{children:["Description: ",t.description]}),e.jsxs("p",{className:"font-semibold",children:["Steps (",s.steps.length,"):"]}),e.jsx("ul",{className:"list-disc pl-6",children:s.steps.map((r,o)=>e.jsx("li",{children:r.type},o))})]})]}),e.jsxs(h,{disabled:n,className:"text-dark-text w-full mt-[18px] h-[34px] hover:bg-accent",onClick:i,children:[n?e.jsx(v,{size:16,className:"animate-spin"}):null,n?"Importing...":"Import agent flow"]})]})}const j={"agent-skill":D,"system-prompt":z,"slash-command":E,"agent-flow":O,unknown:$};function R({importId:t,updateSettings:l}){const[s,n]=c.useState(null),[a,i]=c.useState(!1),[r,o]=c.useState(null);return c.useEffect(()=>{async function m(){if(!t)return;i(!0),await new Promise(g=>setTimeout(g,2e3));const{error:u,item:y}=await f.getItemFromImportId(t);u&&o(u),n(y),l(g=>({...g,item:y})),i(!1)}m()},[t]),{item:s,loading:a,error:r}}function _({settings:t,setSettings:l,setStep:s}){const{item:n,loading:a,error:i}=R({importId:t.itemId,updateSettings:l}),r=j[n==null?void 0:n.itemType]||j.unknown;return e.jsx("div",{className:"flex-[2] flex flex-col gap-y-[18px] mt-10",children:e.jsx("div",{className:"bg-theme-bg-secondary rounded-xl flex-1 p-6",children:e.jsxs("div",{className:"w-full flex flex-col gap-y-2 max-w-[700px]",children:[e.jsx("h2",{className:"text-base text-theme-text-primary font-semibold",children:"Review item"}),a&&e.jsx("div",{className:"flex h-[200px] w-full rounded-lg animate-pulse",children:e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx("p",{className:"text-sm text-theme-text-secondary",children:"Pulling item details from community hub..."})})}),!a&&i&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col gap-y-2 mt-8",children:[e.jsx("p",{className:"text-red-500",children:"An error occurred while fetching the item. Please try again later."}),e.jsx("p",{className:"text-red-500/80 text-sm font-mono",children:i})]}),e.jsx(h,{className:"text-dark-text w-full mt-[18px] h-[34px] hover:bg-accent",onClick:()=>{l({itemId:null,item:null}),s(x.itemId.key)},children:"Try another item"})]}),!a&&!i&&n&&e.jsx(r,{item:n,settings:t,setSettings:l,setStep:s})]})})})}function q({settings:t,setSettings:l,setStep:s}){return e.jsx("div",{className:"flex-[2] flex flex-col gap-y-[18px] mt-10",children:e.jsx("div",{className:"bg-theme-bg-secondary rounded-xl flex-1 p-6",children:e.jsxs("div",{className:"w-full flex flex-col gap-y-2 max-w-[700px]",children:[e.jsx("h2",{className:"text-base text-theme-text-primary font-semibold",children:"Community Hub Item Imported"}),e.jsxs("div",{className:"flex flex-col gap-y-[25px] text-theme-text-secondary text-sm",children:[e.jsxs("p",{children:['The "',t.item.name,'" ',t.item.itemType," has been imported successfully! It is now available in your AnythingLLM instance."]}),t.item.itemType==="agent-flow"&&e.jsxs(L,{to:p.settings.agentSkills(),className:"text-theme-text-primary hover:text-blue-500 hover:underline",children:['View "',t.item.name,'" in Agent Skills']}),e.jsxs("p",{children:["Any changes you make to this ",t.item.itemType," will not be reflected in the community hub. You can now modify as needed."]})]}),e.jsx(h,{className:"text-dark-text w-full mt-[18px] h-[34px] hover:bg-accent",onClick:()=>{l({item:null,itemId:null}),s(x.itemId.key)},children:"Import another item"})]})})})}const k={itemId:{key:"itemId",name:"1. Paste in Item ID",next:()=>"validation",component:({settings:t,setSettings:l,setStep:s})=>e.jsx(U,{settings:t,setSettings:l,setStep:s})},validation:{key:"validation",name:"2. Review item",next:()=>"completed",component:({settings:t,setSettings:l,setStep:s})=>e.jsx(_,{settings:t,setSettings:l,setStep:s})},completed:{key:"completed",name:"3. Completed",component:({settings:t,setSettings:l,setStep:s})=>e.jsx(q,{settings:t,setSettings:l,setStep:s})}};function B({setStep:t,children:l}){const s=T(),[n,a]=c.useState({itemId:null,item:null});return c.useEffect(()=>{function i(){s.get("id")&&(a({itemId:s.get("id")}),t(k.itemId.next()))}i()},[]),e.jsxs("div",{className:"w-screen h-screen overflow-hidden bg-theme-bg-container flex",children:[e.jsx(F,{}),e.jsx("div",{style:{height:N?"100%":"calc(100% - 32px)"},className:"relative md:ml-[2px] md:mr-[16px] md:my-[16px] md:rounded-[16px] w-full h-full overflow-y-scroll p-4 md:p-0",children:l(n,a,t)})]})}const x=k;function V({setStep:t,currentStep:l}){const s=Object.keys(x).indexOf(l);return e.jsx("div",{className:`bg-white/5 light:bg-white text-theme-text-primary rounded-xl py-1 px-4 shadow-lg ${N?"w-full":"min-w-[360px] w-fit"}`,children:Object.entries(x).map(([n,a],i)=>{const r=l===n,o=i===Object.keys(x).length-1,m=s===Object.keys(x).length-1||i<s;return e.jsxs("div",{className:["py-3 flex items-center justify-between transition-all duration-300",r?"rounded-t-xl":"",o?"":"border-b border-white/10 light:border-[#026AA2]/10"].join(" "),children:[m||r?e.jsx("button",{onClick:()=>t(n),className:"border-none hover:underline text-sm font-medium text-theme-text-primary",children:a.name}):e.jsx("div",{className:"text-sm text-theme-text-secondary font-medium",children:a.name}),e.jsx("div",{className:"flex items-center gap-x-2",children:m?e.jsx("div",{className:"w-[14px] h-[14px] rounded-full border border-[#32D583] flex items-center justify-center",children:e.jsx("div",{className:"w-[5.6px] h-[5.6px] rounded-full bg-[#6CE9A6]"})}):e.jsx("div",{className:`w-[14px] h-[14px] rounded-full border border-theme-text-primary ${r?"animate-pulse":"opacity-50"}`})})]},n)})})}function we(){const[t,l]=c.useState("itemId"),s=x.hasOwnProperty(t)?x[t]:x.itemId;return e.jsx(B,{setStep:l,children:(n,a,i)=>e.jsxs("div",{className:"flex flex-col w-full px-1 md:px-6 2xl: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-theme-text-primary",children:"Import a Community Item"})}),e.jsx("p",{className:"text-xs leading-[18px] font-base text-theme-text-secondary",children:"Import items from the AnythingLLM Community Hub to enhance your instance with community-created prompts, skills, and commands."})]}),e.jsxs("div",{className:"flex-1 flex flex-col 2xl:flex-row h-full",children:[e.jsx("div",{className:"flex flex-col gap-y-[18px] mt-10 w-full 2xl:w-[360px] 2xl:flex-shrink-0",children:e.jsx(V,{setStep:i,currentStep:t})}),e.jsx("div",{className:"flex-1 min-w-0 overflow-y-auto pb-[200px] 2xl:h-screen no-scroll",children:e.jsx("div",{className:"2xl:ml-8",children:s.component({settings:n,setSettings:a,setStep:i})})})]})]})})}export{we as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{R as S,r as a,g as je,u as N,j as e,h as te,k as $,I as ve,W as L,c as C,l as B,p as k,C as T,A as I,m as _,D as we,S as O,n as Ne,o as Se,q as U,t as F,v as R,w as Ce,x as se,y as re,z as ne,M as Z,B as ae,E as le,G as Me,H as ie,J as oe,K as G,N as ce,O as de,Q as ke,T as Ee,a as ue,d as Le,e as me,f as Fe,U as Ae,i as Q,V as De,X as Pe,Y as Re}from"../index.js";import{a as $e}from"./index-c9a0d9d0.js";import{w as ze}from"./ChatText-35275002.js";import{D as We}from"./Database-f1a76329.js";import{c as V,w as Oe}from"./types-e90e1137.js";import{H as Te}from"./main-b92080c5.js";import{h as Ue}from"./moment-49fc1b76.js";import{t as Ve}from"./truncate-24ce7b97.js";import{P as Ie}from"./index-bd540023.js";import{T as _e}from"./Trans-06928aa5.js";import{A as W}from"./admin-04b020fe.js";import{w as qe}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-cf34cce5.js";import"./communityHub-aba61686.js";import"./Brain-24e386d5.js";import"./Browser-1820fad0.js";const He=new Map([["bold",S.createElement(S.Fragment,null,S.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",S.createElement(S.Fragment,null,S.createElement("path",{d:"M192,96a64,64,0,1,1-64-64A64,64,0,0,1,192,96Z",opacity:"0.2"}),S.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",S.createElement(S.Fragment,null,S.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",S.createElement(S.Fragment,null,S.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",S.createElement(S.Fragment,null,S.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",S.createElement(S.Fragment,null,S.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 Be=Object.defineProperty,Ze=Object.defineProperties,Ge=Object.getOwnPropertyDescriptors,K=Object.getOwnPropertySymbols,Qe=Object.prototype.hasOwnProperty,Ke=Object.prototype.propertyIsEnumerable,X=(s,t,r)=>t in s?Be(s,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[t]=r,Xe=(s,t)=>{for(var r in t||(t={}))Qe.call(t,r)&&X(s,r,t[r]);if(K)for(var r of K(t))Ke.call(t,r)&&X(s,r,t[r]);return s},Ye=(s,t)=>Ze(s,Ge(t));const he=a.forwardRef((s,t)=>S.createElement(je,Ye(Xe({ref:t},s),{weights:He})));he.displayName="User";function Je({workspace:s,setHasChanges:t}){const{t:r}=N();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 et({slug:s}){const[t,r]=a.useState([]),[o,n]=a.useState(-1),[l,d]=a.useState({heading:"",message:""}),[c,i]=a.useState(!1),[h,f]=a.useState(!0),{t:g}=N();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(M=>{var D,P;return((P=(D=M==null?void 0:M.message)==null?void 0:D.trim())==null?void 0:P.length)>0}),{success:v,error:x}=await L.setSuggestedMessages(s,y);if(!v){C(`Failed to update suggested chat messages: ${x}`,"error");return}r(y),n(-1),i(!1)},m=()=>{if(n(-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}]),i(!0)},u=y=>{const v=[...t];v.splice(y,1),r(v),i(!0)},p=(y,v)=>{y.preventDefault(),n(v);const x=t[v];if(x.heading){const M={heading:"",message:`${x.heading} ${x.message}`};d(M),r(t.map((D,P)=>P===v?M:D))}else d({...x})},j=y=>{u(y),n(-1)},E=y=>{const v={...l,[y.target.name]:y.target.value};d(v);const x=t.map((M,D)=>D===o?{...M,[y.target.name]:y.target.value}:M);r(x),i(!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:()=>j(v),children:e.jsx($,{className:"m-[1px]",size:20})}),e.jsx("button",{onClick:x=>p(x,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 ${o===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))}),o>=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:l.message,name:"message",onChange:E})]})}),t.length<4&&e.jsxs("button",{type:"button",onClick:m,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(ve,{className:"",size:24,weight:"fill"})]}),c&&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 tt({workspace:s,visible:t=!0}){const{slug:r}=B(),[o,n]=a.useState(!1),{t:l}=N(),d=async()=>{if(!window.confirm(`${l("general.delete.confirm-start")} ${s.name} ${l("general.delete.confirm-end")}`))return!1;if(n(!0),!await L.delete(s.slug)){C("Workspace could not be deleted!","error",{clear:!0}),n(!1);return}s.slug===r?window.location=k.home():window.location.reload()};return t?e.jsxs("div",{className:"flex flex-col mt-10",children:[e.jsx("label",{className:"block input-label",children:l("general.delete.title")}),e.jsx("p",{className:"text-theme-text-secondary text-xs font-medium py-1.5",children:l("general.delete.description")}),e.jsx("button",{disabled:o,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:l(o?"general.delete.deleting":"general.delete.delete")})]}):null}function st({slug:s,deletionProtected:t=!1}){const[r,o]=a.useState(null),[n,l]=a.useState(!1),[d,c]=a.useState(!1),[i,h]=a.useState(!0),f=a.useRef(null);a.useEffect(()=>{async function b(){const m=await L.bySlug(s);o(m),h(!1)}b()},[s]);const g=async b=>{c(!0),b.preventDefault();const m={},u=new FormData(f.current);for(var[p,j]of u.entries())m[p]=V(p,j);const{workspace:E,message:y}=await L.update(r.slug,m);E?C("Workspace updated!","success",{clear:!0}):C(`Error: ${y}`,"error",{clear:!0}),c(!1),l(!1)};return!r||i?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:[n&&e.jsx("div",{className:"absolute top-0 right-0",children:e.jsx(T,{type:"submit",children:d?"Updating...":"Update Workspace"})}),e.jsx(Je,{workspace:r,setHasChanges:l},r.slug)]}),e.jsx(et,{slug:r.slug}),e.jsx(tt,{workspace:r,visible:!t})]})}function rt({workspace:s,setHasChanges:t}){const{t:r}=N();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:1e3,step:1,onWheel:o=>o.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 H={forWorkspace:async function(s){try{return await fetch(`${I}/workspace/${s}/prompt-history`,{method:"GET",headers:_()}).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(`${I}/workspace/${s}/prompt-history`,{method:"DELETE",headers:_()}).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(`${I}/workspace/prompt-history/${s}`,{method:"DELETE",headers:_()}).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}}}},Y=200;function nt({id:s,prompt:t,modifiedAt:r,user:o,onRestore:n,setHistory:l,onPublishClick:d}){const{t:c}=N(),[i,h]=a.useState(!1),f=a.useRef(null),g=a.useRef(null),[b,m]=a.useState(!1),u=async p=>{if(window.confirm(c("chat.prompt.history.deleteConfirm"))){const{success:j}=await H.delete(p);j&&l(E=>E.filter(y=>y.id!==p))}};return a.useEffect(()=>{const p=j=>{i&&!f.current.contains(j.target)&&!g.current.contains(j.target)&&h(!1)};return document.addEventListener("mousedown",p),()=>{document.removeEventListener("mousedown",p)}},[i]),e.jsxs("div",{className:"text-white",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"text-xs",children:[o&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-primary-button",children:o.username})," ",e.jsx("span",{className:"mx-1 text-white",children:"•"})]}),e.jsx("span",{className:"text-white opacity-50 light:opacity-100",children:Ue(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:n,children:c("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(!i),children:e.jsx(we,{size:16,weight:"bold"})}),i&&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:c("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:c("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>Y&&!b?e.jsxs(e.Fragment,{children:[Ve(t,Y)," ",e.jsx("button",{type:"button",className:"text-theme-text-secondary hover:text-primary-button border-none",onClick:()=>m(!b),children:c("chat.prompt.history.expand")})]}):t})})]})}const at=a.forwardRef(function({show:t,workspaceSlug:r,onRestore:o,onClose:n,onPublishClick:l},d){const{t:c}=N(),[i,h]=a.useState([]),[f,g]=a.useState(!0);function b(){r&&(g(!0),H.forWorkspace(r).then(u=>{h(u)}).catch(u=>{console.error(u)}).finally(()=>{g(!1)}))}function m(){r&&window.confirm(c("chat.prompt.history.clearAllConfirm"))&&H.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:c("chat.prompt.history.title")}),e.jsxs("div",{className:"flex items-center gap-2",children:[i.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:m,children:c("chat.prompt.history.clearAll")}),e.jsx("button",{type:"button",className:"text-theme-text-secondary cursor-pointer hover:text-primary-button border-none",onClick:n,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(lt,{}):i.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:c("chat.prompt.history.noHistory")}):i.map(u=>e.jsx(nt,{id:u.id,...u,onRestore:()=>o(u.prompt),onPublishClick:l,setHistory:h},u.id))})]})});function lt(){const s="var(--theme-bg-primary)",t="var(--theme-bg-secondary)";return e.jsx(O,{height:"85px",width:"100%",highlightColor:s,baseColor:t,count:8})}function it({workspace:s,setHasChanges:t,hasChanges:r}){const{t:o}=N(),[n]=Ne(),l=Se(s),[d,c]=a.useState(l),[i,h]=a.useState(l),[f,g]=a.useState(""),[b,m]=a.useState(!1),[u,p]=a.useState(!1),[j,E]=a.useState([]),y=a.useRef(null),v=a.useRef(null),x=a.useRef(null),{isOpen:M,closeModal:D,openModal:P}=U(),xe=d!==i,pe=(i==null?void 0:i.trim())!==(l==null?void 0:l.trim()),fe=!b&&(d==null?void 0:d.trim().length)>=10&&(xe||pe);a.useEffect(()=>{async function w(){const{variables:A}=await Ce.getAll();E(A)}w(),n.get("action")==="focus-system-prompt"&&m(!0)},[n]),a.useEffect(()=>{r||h(d)},[r,d]),a.useEffect(()=>{b&&y.current&&y.current.focus()},[b]),a.useEffect(()=>{F.fetchDefaultSystemPrompt().then(({defaultSystemPrompt:w})=>g(w))},[]),a.useEffect(()=>{const w=A=>{v.current&&!v.current.contains(A.target)&&x.current&&!x.current.contains(A.target)&&p(!1)};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[]);const be=w=>{c(w),p(!1),t(!0)},ge=w=>{P(),p(!1),setTimeout(()=>c(w),0)},ye=()=>{F.fetchDefaultSystemPrompt().then(({defaultSystemPrompt:w})=>{c(w),t(!0)})};return e.jsxs(e.Fragment,{children:[e.jsx(at,{ref:v,workspaceSlug:s.slug,show:u,onRestore:be,onPublishClick:ge,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:o("chat.prompt.title")})}),e.jsx("p",{className:"text-white text-opacity-60 text-xs font-medium py-1.5",children:o("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:k.settings.systemPromptVariables(),className:"text-primary-button",children:"prompt variables"})," ","like:"," ",j.slice(0,3).map((w,A)=>e.jsxs(a.Fragment,{children:[e.jsx("span",{className:"bg-theme-settings-input-bg px-1 py-0.5 rounded",children:`{${w.key}}`}),A<j.length-1&&", "]},w.key)),j.length>3&&e.jsxs(R,{to:k.settings.systemPromptVariables(),className:"text-primary-button",children:["+",j.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:x,type:"button",className:"text-theme-text-secondary hover:text-white light:hover:text-black text-xs font-medium",onClick:w=>{w.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:w=>{const A=w.target.value.length;w.target.setSelectionRange(A,A)},onBlur:w=>{m(!1),c(w.target.value)},onChange:w=>{c(w.target.value),t(!0)},onPaste:w=>{c(w.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:()=>m(!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(Te,{className:"whitespace-pre-wrap",highlightClassName:"bg-cta-button p-0.5 rounded-md",searchWords:j.map(w=>`{${w.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:ye,className:"text-theme-text-primary hover:text-white light:hover:text-black text-xs font-medium",children:"Restore to Default"}),e.jsx(ot,{hidden:!fe,onClick:P})]})]})]}),e.jsx(Ie,{show:M,onClose:D,entityType:"system-prompt",entity:d})]})}function ot({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 ct(s=null){switch(s){case"mistral":return{temp:0};default:return{temp:.7}}}function dt({settings:s,workspace:t,setHasChanges:r}){const o=ct(s==null?void 0:s.LLMProvider),{t:n}=N();return e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("label",{htmlFor:"name",className:"block input-label",children:n("chat.temperature.title")}),e.jsxs("p",{className:"text-white text-opacity-60 text-xs font-medium py-1.5",children:[n("chat.temperature.desc-start"),e.jsx("br",{}),n("chat.temperature.desc-end"),e.jsx("br",{}),e.jsx("br",{}),e.jsx("i",{children:n("chat.temperature.hint")})]})]}),e.jsx("input",{name:"openAiTemp",type:"number",min:0,step:.1,onWheel:l=>l.target.blur(),defaultValue:(t==null?void 0:t.openAiTemp)??o.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 ut({workspace:s,setHasChanges:t}){const{t:r}=N(),{enabled:o}=se("agentMode"),[n,l]=a.useState((s==null?void 0:s.chatMode)||"chat");return o?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:n}),e.jsx("button",{type:"button",disabled:n==="automatic",onClick:()=>{l("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:n==="chat",onClick:()=>{l("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:n==="query",onClick:()=>{l("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(mt,{chatMode:n})]})]}):null}function mt({chatMode:s="chat"}){const{t}=N();return e.jsxs("p",{className:"text-sm text-white/60",children:[e.jsx("b",{children:t(`chat.mode.${s}.title`)})," ",e.jsx(_e,{i18nKey:`chat.mode.${s}.description`,components:{b:e.jsx("b",{}),br:e.jsx("br",{})}})]})}const ht=["default"];function xt({llm:s,availableLLMs:t,settings:r,checked:o,onClick:n}){const{isOpen:l,openModal:d,closeModal:c}=U(),{name:i,value:h,logo:f,description:g}=s,[b,m]=a.useState(r);a.useEffect(()=>{async function p(){if(l){const j=await F.keys();m(j??{})}}p()},[l]);function u(){if(!o){if((s.requiredConfig||[]).some(j=>!b[j])){d();return}n(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 ${o?"bg-theme-bg-secondary":""}`,children:[e.jsx("input",{type:"checkbox",value:h,className:"peer hidden",checked:o,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:`${i} 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:i}),e.jsx("div",{className:"mt-1 text-xs text-white/60",children:g})]})]}),o&&!ht.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(pt,{availableLLMs:t,isOpen:l,provider:h,closeModal:c,postSubmit:n,settings:b})]})}function pt({availableLLMs:s,isOpen:t,provider:r,closeModal:o,postSubmit:n,settings:l}){if(!t)return null;const d=s.find(i=>i.value===r);if(!d)return null;async function c(i){i.preventDefault(),i.stopPropagation();const h={},f=new FormData(i.target);for(var[g,b]of f.entries())h[g]=b;const{error:m}=await F.updateSystem(h);if(m){C(`Failed to save ${d.name} settings: ${m}`,"error");return}return o(),n(),!1}return ne.createPortal(e.jsx(Z,{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:o,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:c,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(l,{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:o,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 ft({provider:s,workspace:t,setHasChanges:r}){const{defaultModels:o,customModels:n,loading:l}=ae(s),{t:d}=N();return le.includes(s)?null:l?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:[o.length>0&&e.jsx("optgroup",{label:"General models",children:o.map(c=>e.jsx("option",{value:c,selected:(t==null?void 0:t.chatModel)===c,children:c},c))}),Array.isArray(n)&&n.length>0&&e.jsx("optgroup",{label:"Discovered models",children:n.map(c=>e.jsx("option",{value:c.id,selected:(t==null?void 0:t.chatModel)===c.id,children:c.name||c.id},c.id))}),!Array.isArray(n)&&Object.keys(n).length>0&&e.jsx(e.Fragment,{children:Object.entries(n).map(([c,i])=>e.jsx("optgroup",{label:c,children:i.map(h=>e.jsx("option",{value:h.id,selected:(t==null?void 0:t.chatModel)===h.id,children:h.name||h.id},h.id))},c))})]})]})}function bt({workspace:s,setHasChanges:t}){const{t:r}=N(),[o,n]=a.useState([]),[l,d]=a.useState(!0);return a.useEffect(()=>{async function c(){const i=await Me.getAll();n(i),d(!1)}c()},[]),l?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")})}):o.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:k.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")}),o.map(c=>e.jsxs("option",{value:c.id,children:[c.name,c.description?` — ${c.description}`:""]},c.id))]})]})}const gt=["bedrock","azure","generic-openai"],yt=["default","huggingface","anythingllm-router"],jt=[],J={name:"System default",value:"default",logo:de,options:()=>e.jsx(S.Fragment,{}),description:"Use the system LLM preference for this workspace.",requiredConfig:[]};function vt({settings:s,workspace:t,setHasChanges:r}){var v;const n=((v=ie().llmProviders)==null?void 0:v.allowlist)??null,l=[J,...oe].filter(x=>!(jt.includes(x.value)||n&&!n.includes(x.value))),[d,c]=a.useState([]),[i,h]=a.useState((t==null?void 0:t.chatProvider)??"default"),[f,g]=a.useState(""),[b,m]=a.useState(!1),u=a.useRef(null),{t:p}=N();function j(x){g(""),h(x),m(!1),r(!0)}function E(){f.length>0?(g(""),u.current&&(u.current.value="")):m(!b)}a.useEffect(()=>{const x=l.filter(M=>M.name.toLowerCase().includes(f.toLowerCase()));c(x)},[l,f,i]);const y=l.find(x=>x.value===i)??J;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:p("chat.llm.title")}),e.jsx("p",{className:"text-white text-opacity-60 text-xs font-medium py-1.5",children:p("chat.llm.description")})]}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:"hidden",name:"chatProvider",value:i}),b&&e.jsx("div",{className:"fixed top-0 left-0 w-full h-full bg-black bg-opacity-70 backdrop-blur-sm z-10",onClick:()=>m(!1)}),b?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(G,{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:p("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:x=>g(x.target.value),ref:u,onKeyDown:x=>{x.key==="Enter"&&x.preventDefault()}}),e.jsx($,{size:20,weight:"bold",className:"cursor-pointer text-theme-text-primary hover:text-x-button",onClick:E})]}),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:d.map(x=>e.jsx(xt,{llm:x,availableLLMs:l,settings:s,checked:i===x.value,onClick:()=>j(x.value)},x.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:()=>m(!0),children:[e.jsxs("div",{className:"flex gap-x-4 items-center",children:[e.jsx("img",{src:y.logo,alt:`${y.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:y.name}),e.jsx("div",{className:"mt-1 text-xs text-description",children:y.description})]})]}),e.jsx(ce,{size:24,weight:"bold",className:"text-white"})]})]}),e.jsx(wt,{selectedLLM:i,workspace:t,setHasChanges:r})]})}function wt({selectedLLM:s,workspace:t,setHasChanges:r}){return s==="anythingllm-router"?e.jsx(bt,{workspace:t,setHasChanges:r}):yt.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:k.settings.llmPreference(),className:"underline",children:"the model set for the system."})]})}):null:gt.includes(s)?e.jsx(Nt,{workspace:t,setHasChanges:r}):e.jsx(ft,{provider:s,workspace:t,setHasChanges:r})}function Nt({workspace:s,setHasChanges:t}){const{t:r}=N();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}=N();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:ke(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({}),[o,n]=a.useState(!1),[l,d]=a.useState(!1),c=a.useRef(null);a.useEffect(()=>{async function h(){const f=await F.keys();r(f??{})}h()},[]);const i=async h=>{h.preventDefault(),d(!0);const f={},g=new FormData(c.current);for(var[b,m]of g.entries())f[b]=V(b,m);const{workspace:u,message:p}=await L.update(s.slug,f);u?(C("Workspace updated!","success",{clear:!0}),n(!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:c,onSubmit:i,id:"chat-settings-form",className:"w-1/2 flex flex-col gap-y-6",children:[o&&e.jsx("div",{className:"absolute top-0 right-0",children:e.jsx(T,{type:"submit",children:l?"Updating...":"Update Workspace"})}),e.jsx(vt,{settings:t,workspace:s,setHasChanges:n}),e.jsx(ut,{workspace:s,setHasChanges:n}),e.jsx(rt,{workspace:s,setHasChanges:n}),e.jsx(it,{workspace:s,setHasChanges:n,hasChanges:o}),e.jsx(St,{workspace:s,setHasChanges:n}),e.jsx(dt,{settings:t,workspace:s,setHasChanges:n})]})}):null}function Mt({workspace:s}){const{t}=N();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}=N();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:o=>o.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}=N();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:o}=N(),n=async()=>{if(!window.confirm(`${o("vector-workspace.reset.confirm")}`))return!1;if(r(!0),!await L.wipeVectorDb(s.slug)){C(o("vector-workspace.reset.error"),o("vector-workspace.common.error"),{clear:!0}),r(!1);return}C(o("vector-workspace.reset.success"),o("vector-workspace.common.success"),{clear:!0}),r(!1)};return e.jsx("button",{disabled:t,onClick:n,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:o(t?"vector-workspace.reset.resetting":"vector-workspace.reset.reset")})}function Ft({reload:s,workspace:t}){const[r,o]=a.useState(null),{t:n}=N();return a.useEffect(()=>{async function l(){const d=await F.totalIndexes(t.slug);o(d)}l()},[t==null?void 0:t.slug,s]),r===null?e.jsxs("div",{children:[e.jsx("h3",{className:"input-label",children:n("general.vector.title")}),e.jsx("p",{className:"text-white text-opacity-60 text-xs font-medium py-1",children:n("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:n("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 n;const[r,o]=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:l=>{o(l.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:(n=Dt[r])==null?void 0:n.description})]})}function Rt({workspace:s}){const[t,r]=a.useState(!1),[o,n]=a.useState(!1),l=a.useRef(null),d=async c=>{n(!0),c.preventDefault();const i={},h=new FormData(l.current);for(var[f,g]of h.entries())i[f]=V(f,g);const{workspace:b,message:m}=await L.update(s.slug,i);b?C("Workspace updated!","success",{clear:!0}):C(`Error: ${m}`,"error",{clear:!0}),n(!1),r(!1)};return s?e.jsx("div",{className:"w-full relative",children:e.jsxs("form",{ref:l,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(T,{type:"submit",children:o?"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[o,n]=a.useState(""),[l,d]=a.useState((t==null?void 0:t.userIds)||[]),c=async u=>{u.preventDefault();const{success:p,error:j}=await W.updateUsersInWorkspace(t.id,l);p&&(C("Users updated successfully.","success"),setTimeout(()=>{window.location.reload()},1e3)),C(j,"error")},i=u=>{d(p=>p.includes(u)?p.filter(j=>j!==u):[...p,u])},h=()=>{l.length===m.length?d([]):d(m.map(u=>u.id))},f=()=>{d([])},g=u=>l.includes(u),b=u=>{n(u.target.value)},m=r.filter(u=>u.username.toLowerCase().includes(o.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(G,{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:c,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:m.length>0?m.map(u=>e.jsxs("tr",{className:"flex items-center gap-x-2 cursor-pointer",onClick:()=>i(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":l.length===m.length,tabIndex:0,children:l.length===m.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"})]}),l.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:Ee(s.role)}),e.jsx("td",{className:"px-6 py-4",children:s.lastUpdatedAt})]})})}function Wt({workspace:s}){const[t,r]=a.useState(!0),[o,n]=a.useState([]),[l,d]=a.useState([]),[c,i]=a.useState(null),{isOpen:h,openModal:f,closeModal:g}=U();return a.useEffect(()=>{async function b(){const m=await W.users(),u=await W.workspaceUsers(s.id),p=await W.workspaces();i(p.find(j=>j.id===s.id)),d(u),n(m),r(!1)}b()},[s]),t?e.jsx(O,{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:l.length>0?l.map((b,m)=>e.jsx(zt,{user:b},m)):e.jsx("tr",{children:e.jsx("td",{className:"text-center py-4 text-white/80",colSpan:"4",children:"No workspace members"})})})]}),e.jsx(T,{onClick:f,children:"Manage Users"}),e.jsx(Z,{isOpen:h,children:e.jsx($t,{closeModal:g,users:o,workspace:c})})]})}const Ot=["default","none"];function Tt({llm:s,availableLLMs:t,settings:r,checked:o,onClick:n}){const{isOpen:l,openModal:d,closeModal:c}=U(),{name:i,value:h,logo:f,description:g}=s,[b,m]=a.useState(r);a.useEffect(()=>{async function p(){if(l){const j=await F.keys();m(j??{})}}p()},[l]);function u(){if(!o){if((s.requiredConfig||[]).some(j=>!b[j])){d();return}n(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 ${o?"bg-theme-bg-secondary":""}`,children:[e.jsx("input",{type:"checkbox",value:h,className:"peer hidden",checked:o,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:`${i} 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:i}),e.jsx("div",{className:"mt-1 text-xs text-white/60",children:g})]})]}),o&&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:l,provider:h,closeModal:c,postSubmit:n,settings:b})]})}function Ut({availableLLMs:s,isOpen:t,provider:r,closeModal:o,postSubmit:n,settings:l}){if(!t)return null;const d=s.find(i=>i.value===r);if(!d)return null;async function c(i){i.preventDefault(),i.stopPropagation();const h={},f=new FormData(i.target);for(var[g,b]of f.entries())h[g]=b;const{error:m}=await F.updateSystem(h);if(m){C(`Failed to save ${d.name} settings: ${m}`,"error");return}return o(),n(),!1}return ne.createPortal(e.jsx(Z,{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:o,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:c,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(l,{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:o,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 q(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:o}=B(),{defaultModels:n,customModels:l,loading:d}=ae(s),{t:c}=N();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:k.workspace.settings.chatSettings(o),className:"underline",children:"the model set for the workspace"})," ","or"," ",e.jsx(R,{to:k.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:c("agent.mode.chat.title")}),e.jsx("p",{className:"text-white text-opacity-60 text-xs font-medium py-1.5",children:c("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:c("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:c("agent.mode.title")}),e.jsx("p",{className:"text-white text-opacity-60 text-xs font-medium py-1.5",children:c("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:[n.length>0&&e.jsx("optgroup",{label:"General models",children:n.map(i=>q(s,i)?e.jsx("option",{value:i,selected:(t==null?void 0:t.agentModel)===i,children:i},i):null)}),Array.isArray(l)&&l.length>0&&e.jsx("optgroup",{label:"Custom models",children:l.map(i=>q(s,i.id)?e.jsx("option",{value:i.id,selected:(t==null?void 0:t.agentModel)===i.id,children:i.id},i.id):null)}),!Array.isArray(l)&&Object.keys(l).length>0&&e.jsx(e.Fragment,{children:Object.entries(l).map(([i,h])=>e.jsx("optgroup",{label:i,children:h.map(f=>q(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)},i))})]})]})}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"],ee={name:"System Default",value:"none",logo:de,options:()=>e.jsx(S.Fragment,{}),description:"Agents will use the workspace or system LLM unless otherwise specified.",requiredConfig:[]};function qt({settings:s,workspace:t,setHasChanges:r}){var v;const n=((v=ie().llmProviders)==null?void 0:v.allowlist)??null,l=[ee,...oe.filter(x=>!(!It.includes(x.value)||n&&!n.includes(x.value)))],[d,c]=a.useState([]),[i,h]=a.useState((t==null?void 0:t.agentProvider)??"none"),[f,g]=a.useState(""),[b,m]=a.useState(!1),u=a.useRef(null),{t:p}=N();function j(x){g(""),h(x),m(!1),r(!0)}function E(){f.length>0?(g(""),u.current&&(u.current.value="")):m(!b)}a.useEffect(()=>{const x=l.filter(M=>M.name.toLowerCase().includes(f.toLowerCase()));c(x)},[f,i]);const y=l.find(x=>x.value===i)??ee;return e.jsxs("div",{className:"border-b border-white/40 pb-8",children:[_t.includes(i)&&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(qe,{className:"shrink-0",size:25}),e.jsx("p",{className:"text-sm",children:p("agent.performance-warning")})]})}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("label",{htmlFor:"name",className:"block input-label",children:p("agent.provider.title")}),e.jsx("p",{className:"text-white text-opacity-60 text-xs font-medium py-1.5",children:p("agent.provider.description")})]}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:"hidden",name:"agentProvider",value:i}),b&&e.jsx("div",{className:"fixed top-0 left-0 w-full h-full bg-black bg-opacity-70 backdrop-blur-sm z-10",onClick:()=>m(!1)}),b?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(G,{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:x=>g(x.target.value),ref:u,onKeyDown:x=>{x.key==="Enter"&&x.preventDefault()}}),e.jsx($,{size:20,weight:"bold",className:"cursor-pointer text-theme-text-primary hover:text-x-button",onClick:E})]}),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:d.map(x=>e.jsx(Tt,{llm:x,availableLLMs:l,settings:s,checked:i===x.value,onClick:()=>j(x.value)},x.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:()=>m(!0),children:[e.jsxs("div",{className:"flex gap-x-4 items-center",children:[e.jsx("img",{src:y.logo,alt:`${y.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:y.name}),e.jsx("div",{className:"mt-1 text-xs text-description",children:y.description})]})]}),e.jsx(ce,{size:24,weight:"bold",className:"text-white"})]})]}),i!=="none"&&e.jsx("div",{className:"mt-4 flex flex-col gap-y-1",children:e.jsx(Vt,{provider:i,workspace:t,setHasChanges:r})})]})}function Ht({workspace:s}){const{user:t}=ue(),[r,o]=a.useState({}),[n,l]=a.useState(!1),[d,c]=a.useState(!1),[i,h]=a.useState(!0),f=a.useRef(null);a.useEffect(()=>{async function b(){const m=await F.keys();o(m??{}),h(!1)}b()},[]);const g=async b=>{c(!0),b.preventDefault();const m={workspace:{},system:{},env:{}},u=new FormData(f.current);for(var[p,j]of u.entries()){if(p.startsWith("system::")){const[v,x]=p.split("system::");m.system[x]=String(j);continue}if(p.startsWith("env::")){const[v,x]=p.split("env::");m.env[x]=String(j);continue}m.workspace[p]=V(p,j)}const{workspace:E,message:y}=await L.update(s.slug,m.workspace);await W.updateSystemPreferences(m.system),await F.updateSystem(m.env),E?C("Workspace updated!","success",{clear:!0}):C(`Error: ${y}`,"error",{clear:!0}),c(!1),l(!1)};return!s||i?e.jsx(Bt,{}):e.jsx("div",{id:"workspace-agent-settings-container",children:e.jsxs("form",{ref:f,onSubmit:g,onChange:()=>l(!0),id:"agent-settings-form",className:"w-1/2 flex flex-col gap-y-6",children:[e.jsx(qt,{settings:r,workspace:s,setHasChanges:l}),(!t||(t==null?void 0:t.role)==="admin")&&e.jsx(e.Fragment,{children:!n&&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:k.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."})]})}),n&&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 Bt(){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(O,{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(O,{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 Zt={"general-appearance":st,"chat-settings":Ct,"vector-database":Rt,members:Wt,"agent-config":Ht};function ps(){const{loading:s,requiresAuth:t,mode:r}=Le();return s?e.jsx(me,{}):t!==!1?e.jsx(e.Fragment,{children:t!==null&&e.jsx(Fe,{mode:r})}):e.jsx(Gt,{})}function Gt(){const{t:s}=N(),{slug:t,tab:r}=B(),{user:o}=ue(),n=se("agentMode"),[l,d]=a.useState(null),[c,i]=a.useState(!1),[h,f]=a.useState(!0);if(a.useEffect(()=>{async function b(){if(!t)return;const m=await L.bySlug(t);if(!m){f(!1);return}const u=await F.keys(),p=await L.getSuggestedMessages(t);d({...m,vectorDB:u==null?void 0:u.VectorDB,suggestedMessages:p}),i((u==null?void 0:u.WorkspaceDeletionProtection)===!0),f(!1)}b()},[t,r]),h)return e.jsx(me,{});if(r==="agent-config"&&!n.enabled)return e.jsx(Ae,{to:k.workspace.settings.generalAppearance(t),replace:!0});const g=Zt[r];return e.jsxs("div",{className:"w-screen h-screen overflow-hidden bg-zinc-950 light:bg-slate-50 flex",children:[!Q&&e.jsx($e,{}),e.jsxs("div",{style:{height:Q?"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:k.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(De,{className:"h-5 w-5",weight:"fill"})}),e.jsx(z,{title:s("workspaces—settings.general"),icon:e.jsx(Pe,{className:"h-6 w-6"}),to:k.workspace.settings.generalAppearance(t)}),e.jsx(z,{title:s("workspaces—settings.chat"),icon:e.jsx(ze,{className:"h-6 w-6"}),to:k.workspace.settings.chatSettings(t)}),e.jsx(z,{title:s("workspaces—settings.vector"),icon:e.jsx(We,{className:"h-6 w-6"}),to:k.workspace.settings.vectorDatabase(t),visible:n.enabled}),e.jsx(z,{title:s("workspaces—settings.members"),icon:e.jsx(he,{className:"h-6 w-6"}),to:k.workspace.settings.members(t),visible:["admin","manager"].includes(o==null?void 0:o.role)}),e.jsx(z,{title:s("workspaces—settings.agent"),icon:e.jsx(Oe,{className:"h-6 w-6"}),to:k.workspace.settings.agentConfig(t),visible:n.enabled})]}),e.jsx("div",{className:"px-16 py-6",children:e.jsx(g,{slug:t,workspace:l,deletionProtected:c})})]})]})}function z({title:s,icon:t,to:r,visible:o=!0}){return o?e.jsxs(Re,{to:r,className:({isActive:n})=>`${n?"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{ps as default};
|
|
1
|
+
import{R as S,r as a,g as je,u as N,j as e,h as te,k as $,I as ve,W as L,c as C,l as B,p as k,C as T,A as I,m as _,D as we,S as O,n as Ne,o as Se,q as U,t as F,v as R,w as Ce,x as se,y as re,z as ne,M as Z,B as ae,E as le,G as Me,H as ie,J as oe,K as G,N as ce,O as de,Q as ke,T as Ee,a as ue,d as Le,e as me,f as Fe,U as Ae,i as Q,V as De,X as Pe,Y as Re}from"../index.js";import{a as $e}from"./index-c9a0d9d0.js";import{w as ze}from"./ChatText-35275002.js";import{D as We}from"./Database-f1a76329.js";import{c as V,w as Oe}from"./types-e90e1137.js";import{H as Te}from"./main-b92080c5.js";import{h as Ue}from"./moment-49fc1b76.js";import{t as Ve}from"./truncate-24ce7b97.js";import{P as Ie}from"./index-bd540023.js";import{T as _e}from"./Trans-06928aa5.js";import{A as W}from"./admin-04b020fe.js";import{w as qe}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-cf34cce5.js";import"./communityHub-aba61686.js";import"./Brain-24e386d5.js";import"./Browser-1820fad0.js";const He=new Map([["bold",S.createElement(S.Fragment,null,S.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",S.createElement(S.Fragment,null,S.createElement("path",{d:"M192,96a64,64,0,1,1-64-64A64,64,0,0,1,192,96Z",opacity:"0.2"}),S.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",S.createElement(S.Fragment,null,S.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",S.createElement(S.Fragment,null,S.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",S.createElement(S.Fragment,null,S.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",S.createElement(S.Fragment,null,S.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 Be=Object.defineProperty,Ze=Object.defineProperties,Ge=Object.getOwnPropertyDescriptors,K=Object.getOwnPropertySymbols,Qe=Object.prototype.hasOwnProperty,Ke=Object.prototype.propertyIsEnumerable,X=(s,t,r)=>t in s?Be(s,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[t]=r,Xe=(s,t)=>{for(var r in t||(t={}))Qe.call(t,r)&&X(s,r,t[r]);if(K)for(var r of K(t))Ke.call(t,r)&&X(s,r,t[r]);return s},Ye=(s,t)=>Ze(s,Ge(t));const he=a.forwardRef((s,t)=>S.createElement(je,Ye(Xe({ref:t},s),{weights:He})));he.displayName="User";function Je({workspace:s,setHasChanges:t}){const{t:r}=N();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 et({slug:s}){const[t,r]=a.useState([]),[o,n]=a.useState(-1),[l,d]=a.useState({heading:"",message:""}),[c,i]=a.useState(!1),[h,f]=a.useState(!0),{t:g}=N();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(M=>{var D,P;return((P=(D=M==null?void 0:M.message)==null?void 0:D.trim())==null?void 0:P.length)>0}),{success:v,error:x}=await L.setSuggestedMessages(s,y);if(!v){C(`Failed to update suggested chat messages: ${x}`,"error");return}r(y),n(-1),i(!1)},m=()=>{if(n(-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}]),i(!0)},u=y=>{const v=[...t];v.splice(y,1),r(v),i(!0)},p=(y,v)=>{y.preventDefault(),n(v);const x=t[v];if(x.heading){const M={heading:"",message:`${x.heading} ${x.message}`};d(M),r(t.map((D,P)=>P===v?M:D))}else d({...x})},j=y=>{u(y),n(-1)},E=y=>{const v={...l,[y.target.name]:y.target.value};d(v);const x=t.map((M,D)=>D===o?{...M,[y.target.name]:y.target.value}:M);r(x),i(!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:()=>j(v),children:e.jsx($,{className:"m-[1px]",size:20})}),e.jsx("button",{onClick:x=>p(x,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 ${o===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))}),o>=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:l.message,name:"message",onChange:E})]})}),t.length<4&&e.jsxs("button",{type:"button",onClick:m,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(ve,{className:"",size:24,weight:"fill"})]}),c&&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 tt({workspace:s,visible:t=!0}){const{slug:r}=B(),[o,n]=a.useState(!1),{t:l}=N(),d=async()=>{if(!window.confirm(`${l("general.delete.confirm-start")} ${s.name} ${l("general.delete.confirm-end")}`))return!1;if(n(!0),!await L.delete(s.slug)){C("Workspace could not be deleted!","error",{clear:!0}),n(!1);return}s.slug===r?window.location=k.home():window.location.reload()};return t?e.jsxs("div",{className:"flex flex-col mt-10",children:[e.jsx("label",{className:"block input-label",children:l("general.delete.title")}),e.jsx("p",{className:"text-theme-text-secondary text-xs font-medium py-1.5",children:l("general.delete.description")}),e.jsx("button",{disabled:o,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:l(o?"general.delete.deleting":"general.delete.delete")})]}):null}function st({slug:s,deletionProtected:t=!1}){const[r,o]=a.useState(null),[n,l]=a.useState(!1),[d,c]=a.useState(!1),[i,h]=a.useState(!0),f=a.useRef(null);a.useEffect(()=>{async function b(){const m=await L.bySlug(s);o(m),h(!1)}b()},[s]);const g=async b=>{c(!0),b.preventDefault();const m={},u=new FormData(f.current);for(var[p,j]of u.entries())m[p]=V(p,j);const{workspace:E,message:y}=await L.update(r.slug,m);E?C("Workspace updated!","success",{clear:!0}):C(`Error: ${y}`,"error",{clear:!0}),c(!1),l(!1)};return!r||i?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:[n&&e.jsx("div",{className:"absolute top-0 right-0",children:e.jsx(T,{type:"submit",children:d?"Updating...":"Update Workspace"})}),e.jsx(Je,{workspace:r,setHasChanges:l},r.slug)]}),e.jsx(et,{slug:r.slug}),e.jsx(tt,{workspace:r,visible:!t})]})}function rt({workspace:s,setHasChanges:t}){const{t:r}=N();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:1e3,step:1,onWheel:o=>o.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 H={forWorkspace:async function(s){try{return await fetch(`${I}/workspace/${s}/prompt-history`,{method:"GET",headers:_()}).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(`${I}/workspace/${s}/prompt-history`,{method:"DELETE",headers:_()}).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(`${I}/workspace/prompt-history/${s}`,{method:"DELETE",headers:_()}).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}}}},Y=200;function nt({id:s,prompt:t,modifiedAt:r,user:o,onRestore:n,setHistory:l,onPublishClick:d}){const{t:c}=N(),[i,h]=a.useState(!1),f=a.useRef(null),g=a.useRef(null),[b,m]=a.useState(!1),u=async p=>{if(window.confirm(c("chat.prompt.history.deleteConfirm"))){const{success:j}=await H.delete(p);j&&l(E=>E.filter(y=>y.id!==p))}};return a.useEffect(()=>{const p=j=>{i&&!f.current.contains(j.target)&&!g.current.contains(j.target)&&h(!1)};return document.addEventListener("mousedown",p),()=>{document.removeEventListener("mousedown",p)}},[i]),e.jsxs("div",{className:"text-white",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"text-xs",children:[o&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-primary-button",children:o.username})," ",e.jsx("span",{className:"mx-1 text-white",children:"•"})]}),e.jsx("span",{className:"text-white opacity-50 light:opacity-100",children:Ue(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:n,children:c("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(!i),children:e.jsx(we,{size:16,weight:"bold"})}),i&&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:c("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:c("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>Y&&!b?e.jsxs(e.Fragment,{children:[Ve(t,Y)," ",e.jsx("button",{type:"button",className:"text-theme-text-secondary hover:text-primary-button border-none",onClick:()=>m(!b),children:c("chat.prompt.history.expand")})]}):t})})]})}const at=a.forwardRef(function({show:t,workspaceSlug:r,onRestore:o,onClose:n,onPublishClick:l},d){const{t:c}=N(),[i,h]=a.useState([]),[f,g]=a.useState(!0);function b(){r&&(g(!0),H.forWorkspace(r).then(u=>{h(u)}).catch(u=>{console.error(u)}).finally(()=>{g(!1)}))}function m(){r&&window.confirm(c("chat.prompt.history.clearAllConfirm"))&&H.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:c("chat.prompt.history.title")}),e.jsxs("div",{className:"flex items-center gap-2",children:[i.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:m,children:c("chat.prompt.history.clearAll")}),e.jsx("button",{type:"button",className:"text-theme-text-secondary cursor-pointer hover:text-primary-button border-none",onClick:n,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(lt,{}):i.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:c("chat.prompt.history.noHistory")}):i.map(u=>e.jsx(nt,{id:u.id,...u,onRestore:()=>o(u.prompt),onPublishClick:l,setHistory:h},u.id))})]})});function lt(){const s="var(--theme-bg-primary)",t="var(--theme-bg-secondary)";return e.jsx(O,{height:"85px",width:"100%",highlightColor:s,baseColor:t,count:8})}function it({workspace:s,setHasChanges:t,hasChanges:r}){const{t:o}=N(),[n]=Ne(),l=Se(s),[d,c]=a.useState(l),[i,h]=a.useState(l),[f,g]=a.useState(""),[b,m]=a.useState(!1),[u,p]=a.useState(!1),[j,E]=a.useState([]),y=a.useRef(null),v=a.useRef(null),x=a.useRef(null),{isOpen:M,closeModal:D,openModal:P}=U(),xe=d!==i,pe=(i==null?void 0:i.trim())!==(l==null?void 0:l.trim()),fe=!b&&(d==null?void 0:d.trim().length)>=10&&(xe||pe);a.useEffect(()=>{async function w(){const{variables:A}=await Ce.getAll();E(A)}w(),n.get("action")==="focus-system-prompt"&&m(!0)},[n]),a.useEffect(()=>{r||h(d)},[r,d]),a.useEffect(()=>{b&&y.current&&y.current.focus()},[b]),a.useEffect(()=>{F.fetchDefaultSystemPrompt().then(({defaultSystemPrompt:w})=>g(w))},[]),a.useEffect(()=>{const w=A=>{v.current&&!v.current.contains(A.target)&&x.current&&!x.current.contains(A.target)&&p(!1)};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[]);const be=w=>{c(w),p(!1),t(!0)},ge=w=>{P(),p(!1),setTimeout(()=>c(w),0)},ye=()=>{F.fetchDefaultSystemPrompt().then(({defaultSystemPrompt:w})=>{c(w),t(!0)})};return e.jsxs(e.Fragment,{children:[e.jsx(at,{ref:v,workspaceSlug:s.slug,show:u,onRestore:be,onPublishClick:ge,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:o("chat.prompt.title")})}),e.jsx("p",{className:"text-white text-opacity-60 text-xs font-medium py-1.5",children:o("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:k.settings.systemPromptVariables(),className:"text-primary-button",children:"prompt variables"})," ","like:"," ",j.slice(0,3).map((w,A)=>e.jsxs(a.Fragment,{children:[e.jsx("span",{className:"bg-theme-settings-input-bg px-1 py-0.5 rounded",children:`{${w.key}}`}),A<j.length-1&&", "]},w.key)),j.length>3&&e.jsxs(R,{to:k.settings.systemPromptVariables(),className:"text-primary-button",children:["+",j.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:x,type:"button",className:"text-theme-text-secondary hover:text-white light:hover:text-black text-xs font-medium",onClick:w=>{w.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:w=>{const A=w.target.value.length;w.target.setSelectionRange(A,A)},onBlur:w=>{m(!1),c(w.target.value)},onChange:w=>{c(w.target.value),t(!0)},onPaste:w=>{c(w.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:()=>m(!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(Te,{className:"whitespace-pre-wrap",highlightClassName:"bg-cta-button p-0.5 rounded-md",searchWords:j.map(w=>`{${w.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:ye,className:"text-theme-text-primary hover:text-white light:hover:text-black text-xs font-medium",children:"Restore to Default"}),e.jsx(ot,{hidden:!fe,onClick:P})]})]})]}),e.jsx(Ie,{show:M,onClose:D,entityType:"system-prompt",entity:d})]})}function ot({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 ct(s=null){switch(s){case"mistral":return{temp:0};default:return{temp:.7}}}function dt({settings:s,workspace:t,setHasChanges:r}){const o=ct(s==null?void 0:s.LLMProvider),{t:n}=N();return e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("label",{htmlFor:"name",className:"block input-label",children:n("chat.temperature.title")}),e.jsxs("p",{className:"text-white text-opacity-60 text-xs font-medium py-1.5",children:[n("chat.temperature.desc-start"),e.jsx("br",{}),n("chat.temperature.desc-end"),e.jsx("br",{}),e.jsx("br",{}),e.jsx("i",{children:n("chat.temperature.hint")})]})]}),e.jsx("input",{name:"openAiTemp",type:"number",min:0,step:.1,onWheel:l=>l.target.blur(),defaultValue:(t==null?void 0:t.openAiTemp)??o.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 ut({workspace:s,setHasChanges:t}){const{t:r}=N(),{enabled:o}=se("agentMode"),[n,l]=a.useState((s==null?void 0:s.chatMode)||"chat");return o?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:n}),e.jsx("button",{type:"button",disabled:n==="automatic",onClick:()=>{l("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:n==="chat",onClick:()=>{l("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:n==="query",onClick:()=>{l("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(mt,{chatMode:n})]})]}):null}function mt({chatMode:s="chat"}){const{t}=N();return e.jsxs("p",{className:"text-sm text-white/60",children:[e.jsx("b",{children:t(`chat.mode.${s}.title`)})," ",e.jsx(_e,{i18nKey:`chat.mode.${s}.description`,components:{b:e.jsx("b",{}),br:e.jsx("br",{})}})]})}const ht=["default"];function xt({llm:s,availableLLMs:t,settings:r,checked:o,onClick:n}){const{isOpen:l,openModal:d,closeModal:c}=U(),{name:i,value:h,logo:f,description:g}=s,[b,m]=a.useState(r);a.useEffect(()=>{async function p(){if(l){const j=await F.keys();m(j??{})}}p()},[l]);function u(){if(!o){if((s.requiredConfig||[]).some(j=>!b[j])){d();return}n(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 ${o?"bg-theme-bg-secondary":""}`,children:[e.jsx("input",{type:"checkbox",value:h,className:"peer hidden",checked:o,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:`${i} 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:i}),e.jsx("div",{className:"mt-1 text-xs text-white/60",children:g})]})]}),o&&!ht.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(pt,{availableLLMs:t,isOpen:l,provider:h,closeModal:c,postSubmit:n,settings:b})]})}function pt({availableLLMs:s,isOpen:t,provider:r,closeModal:o,postSubmit:n,settings:l}){if(!t)return null;const d=s.find(i=>i.value===r);if(!d)return null;async function c(i){i.preventDefault(),i.stopPropagation();const h={},f=new FormData(i.target);for(var[g,b]of f.entries())h[g]=b;const{error:m}=await F.updateSystem(h);if(m){C(`Failed to save ${d.name} settings: ${m}`,"error");return}return o(),n(),!1}return ne.createPortal(e.jsx(Z,{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:o,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:c,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(l,{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:o,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 ft({provider:s,workspace:t,setHasChanges:r}){const{defaultModels:o,customModels:n,loading:l}=ae(s),{t:d}=N();return le.includes(s)?null:l?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:[o.length>0&&e.jsx("optgroup",{label:"General models",children:o.map(c=>e.jsx("option",{value:c,selected:(t==null?void 0:t.chatModel)===c,children:c},c))}),Array.isArray(n)&&n.length>0&&e.jsx("optgroup",{label:"Discovered models",children:n.map(c=>e.jsx("option",{value:c.id,selected:(t==null?void 0:t.chatModel)===c.id,children:c.name||c.id},c.id))}),!Array.isArray(n)&&Object.keys(n).length>0&&e.jsx(e.Fragment,{children:Object.entries(n).map(([c,i])=>e.jsx("optgroup",{label:c,children:i.map(h=>e.jsx("option",{value:h.id,selected:(t==null?void 0:t.chatModel)===h.id,children:h.name||h.id},h.id))},c))})]})]})}function bt({workspace:s,setHasChanges:t}){const{t:r}=N(),[o,n]=a.useState([]),[l,d]=a.useState(!0);return a.useEffect(()=>{async function c(){const i=await Me.getAll();n(i),d(!1)}c()},[]),l?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")})}):o.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:k.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")}),o.map(c=>e.jsxs("option",{value:c.id,children:[c.name,c.description?` — ${c.description}`:""]},c.id))]})]})}const gt=["bedrock","azure","generic-openai"],yt=["default","huggingface","anythingllm-router"],jt=[],J={name:"System default",value:"default",logo:de,options:()=>e.jsx(S.Fragment,{}),description:"Use the system LLM preference for this workspace.",requiredConfig:[]};function vt({settings:s,workspace:t,setHasChanges:r}){var v;const n=((v=ie().llmProviders)==null?void 0:v.allowlist)??null,l=[J,...oe].filter(x=>!(jt.includes(x.value)||n&&!n.includes(x.value))),[d,c]=a.useState([]),[i,h]=a.useState((t==null?void 0:t.chatProvider)??"default"),[f,g]=a.useState(""),[b,m]=a.useState(!1),u=a.useRef(null),{t:p}=N();function j(x){g(""),h(x),m(!1),r(!0)}function E(){f.length>0?(g(""),u.current&&(u.current.value="")):m(!b)}a.useEffect(()=>{const x=l.filter(M=>M.name.toLowerCase().includes(f.toLowerCase()));c(x)},[l,f,i]);const y=l.find(x=>x.value===i)??J;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:p("chat.llm.title")}),e.jsx("p",{className:"text-white text-opacity-60 text-xs font-medium py-1.5",children:p("chat.llm.description")})]}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:"hidden",name:"chatProvider",value:i}),b&&e.jsx("div",{className:"fixed top-0 left-0 w-full h-full bg-black bg-opacity-70 backdrop-blur-sm z-10",onClick:()=>m(!1)}),b?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(G,{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:p("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:x=>g(x.target.value),ref:u,onKeyDown:x=>{x.key==="Enter"&&x.preventDefault()}}),e.jsx($,{size:20,weight:"bold",className:"cursor-pointer text-theme-text-primary hover:text-x-button",onClick:E})]}),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:d.map(x=>e.jsx(xt,{llm:x,availableLLMs:l,settings:s,checked:i===x.value,onClick:()=>j(x.value)},x.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:()=>m(!0),children:[e.jsxs("div",{className:"flex gap-x-4 items-center",children:[e.jsx("img",{src:y.logo,alt:`${y.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:y.name}),e.jsx("div",{className:"mt-1 text-xs text-description",children:y.description})]})]}),e.jsx(ce,{size:24,weight:"bold",className:"text-white"})]})]}),e.jsx(wt,{selectedLLM:i,workspace:t,setHasChanges:r})]})}function wt({selectedLLM:s,workspace:t,setHasChanges:r}){return s==="anythingllm-router"?e.jsx(bt,{workspace:t,setHasChanges:r}):yt.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:k.settings.llmPreference(),className:"underline",children:"the model set for the system."})]})}):null:gt.includes(s)?e.jsx(Nt,{workspace:t,setHasChanges:r}):e.jsx(ft,{provider:s,workspace:t,setHasChanges:r})}function Nt({workspace:s,setHasChanges:t}){const{t:r}=N();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}=N();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:ke(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({}),[o,n]=a.useState(!1),[l,d]=a.useState(!1),c=a.useRef(null);a.useEffect(()=>{async function h(){const f=await F.keys();r(f??{})}h()},[]);const i=async h=>{h.preventDefault(),d(!0);const f={},g=new FormData(c.current);for(var[b,m]of g.entries())f[b]=V(b,m);const{workspace:u,message:p}=await L.update(s.slug,f);u?(C("Workspace updated!","success",{clear:!0}),n(!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:c,onSubmit:i,id:"chat-settings-form",className:"w-1/2 flex flex-col gap-y-6",children:[o&&e.jsx("div",{className:"absolute top-0 right-0",children:e.jsx(T,{type:"submit",children:l?"Updating...":"Update Workspace"})}),e.jsx(vt,{settings:t,workspace:s,setHasChanges:n}),e.jsx(ut,{workspace:s,setHasChanges:n}),e.jsx(rt,{workspace:s,setHasChanges:n}),e.jsx(it,{workspace:s,setHasChanges:n,hasChanges:o}),e.jsx(St,{workspace:s,setHasChanges:n}),e.jsx(dt,{settings:t,workspace:s,setHasChanges:n})]})}):null}function Mt({workspace:s}){const{t}=N();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}=N();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:o=>o.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}=N();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:o}=N(),n=async()=>{if(!window.confirm(`${o("vector-workspace.reset.confirm")}`))return!1;if(r(!0),!await L.wipeVectorDb(s.slug)){C(o("vector-workspace.reset.error"),o("vector-workspace.common.error"),{clear:!0}),r(!1);return}C(o("vector-workspace.reset.success"),o("vector-workspace.common.success"),{clear:!0}),r(!1)};return e.jsx("button",{disabled:t,onClick:n,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:o(t?"vector-workspace.reset.resetting":"vector-workspace.reset.reset")})}function Ft({reload:s,workspace:t}){const[r,o]=a.useState(null),{t:n}=N();return a.useEffect(()=>{async function l(){const d=await F.totalIndexes(t.slug);o(d)}l()},[t==null?void 0:t.slug,s]),r===null?e.jsxs("div",{children:[e.jsx("h3",{className:"input-label",children:n("general.vector.title")}),e.jsx("p",{className:"text-white text-opacity-60 text-xs font-medium py-1",children:n("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:n("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 n;const[r,o]=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:l=>{o(l.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:(n=Dt[r])==null?void 0:n.description})]})}function Rt({workspace:s}){const[t,r]=a.useState(!1),[o,n]=a.useState(!1),l=a.useRef(null),d=async c=>{n(!0),c.preventDefault();const i={},h=new FormData(l.current);for(var[f,g]of h.entries())i[f]=V(f,g);const{workspace:b,message:m}=await L.update(s.slug,i);b?C("Workspace updated!","success",{clear:!0}):C(`Error: ${m}`,"error",{clear:!0}),n(!1),r(!1)};return s?e.jsx("div",{className:"w-full relative",children:e.jsxs("form",{ref:l,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(T,{type:"submit",children:o?"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[o,n]=a.useState(""),[l,d]=a.useState((t==null?void 0:t.userIds)||[]),c=async u=>{u.preventDefault();const{success:p,error:j}=await W.updateUsersInWorkspace(t.id,l);p&&(C("Users updated successfully.","success"),setTimeout(()=>{window.location.reload()},1e3)),C(j,"error")},i=u=>{d(p=>p.includes(u)?p.filter(j=>j!==u):[...p,u])},h=()=>{l.length===m.length?d([]):d(m.map(u=>u.id))},f=()=>{d([])},g=u=>l.includes(u),b=u=>{n(u.target.value)},m=r.filter(u=>u.username.toLowerCase().includes(o.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(G,{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:c,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:m.length>0?m.map(u=>e.jsxs("tr",{className:"flex items-center gap-x-2 cursor-pointer",onClick:()=>i(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":l.length===m.length,tabIndex:0,children:l.length===m.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"})]}),l.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:Ee(s.role)}),e.jsx("td",{className:"px-6 py-4",children:s.lastUpdatedAt})]})})}function Wt({workspace:s}){const[t,r]=a.useState(!0),[o,n]=a.useState([]),[l,d]=a.useState([]),[c,i]=a.useState(null),{isOpen:h,openModal:f,closeModal:g}=U();return a.useEffect(()=>{async function b(){const m=await W.users(),u=await W.workspaceUsers(s.id),p=await W.workspaces();i(p.find(j=>j.id===s.id)),d(u),n(m),r(!1)}b()},[s]),t?e.jsx(O,{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:l.length>0?l.map((b,m)=>e.jsx(zt,{user:b},m)):e.jsx("tr",{children:e.jsx("td",{className:"text-center py-4 text-white/80",colSpan:"4",children:"No workspace members"})})})]}),e.jsx(T,{onClick:f,children:"Manage Users"}),e.jsx(Z,{isOpen:h,children:e.jsx($t,{closeModal:g,users:o,workspace:c})})]})}const Ot=["default","none"];function Tt({llm:s,availableLLMs:t,settings:r,checked:o,onClick:n}){const{isOpen:l,openModal:d,closeModal:c}=U(),{name:i,value:h,logo:f,description:g}=s,[b,m]=a.useState(r);a.useEffect(()=>{async function p(){if(l){const j=await F.keys();m(j??{})}}p()},[l]);function u(){if(!o){if((s.requiredConfig||[]).some(j=>!b[j])){d();return}n(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 ${o?"bg-theme-bg-secondary":""}`,children:[e.jsx("input",{type:"checkbox",value:h,className:"peer hidden",checked:o,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:`${i} 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:i}),e.jsx("div",{className:"mt-1 text-xs text-white/60",children:g})]})]}),o&&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:l,provider:h,closeModal:c,postSubmit:n,settings:b})]})}function Ut({availableLLMs:s,isOpen:t,provider:r,closeModal:o,postSubmit:n,settings:l}){if(!t)return null;const d=s.find(i=>i.value===r);if(!d)return null;async function c(i){i.preventDefault(),i.stopPropagation();const h={},f=new FormData(i.target);for(var[g,b]of f.entries())h[g]=b;const{error:m}=await F.updateSystem(h);if(m){C(`Failed to save ${d.name} settings: ${m}`,"error");return}return o(),n(),!1}return ne.createPortal(e.jsx(Z,{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:o,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:c,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(l,{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:o,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 q(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:o}=B(),{defaultModels:n,customModels:l,loading:d}=ae(s),{t:c}=N();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:k.workspace.settings.chatSettings(o),className:"underline",children:"the model set for the workspace"})," ","or"," ",e.jsx(R,{to:k.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:c("agent.mode.chat.title")}),e.jsx("p",{className:"text-white text-opacity-60 text-xs font-medium py-1.5",children:c("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:c("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:c("agent.mode.title")}),e.jsx("p",{className:"text-white text-opacity-60 text-xs font-medium py-1.5",children:c("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:[n.length>0&&e.jsx("optgroup",{label:"General models",children:n.map(i=>q(s,i)?e.jsx("option",{value:i,selected:(t==null?void 0:t.agentModel)===i,children:i},i):null)}),Array.isArray(l)&&l.length>0&&e.jsx("optgroup",{label:"Custom models",children:l.map(i=>q(s,i.id)?e.jsx("option",{value:i.id,selected:(t==null?void 0:t.agentModel)===i.id,children:i.id},i.id):null)}),!Array.isArray(l)&&Object.keys(l).length>0&&e.jsx(e.Fragment,{children:Object.entries(l).map(([i,h])=>e.jsx("optgroup",{label:i,children:h.map(f=>q(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)},i))})]})]})}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","venice"],_t=["lmstudio","koboldcpp","ollama","localai","textgenwebui","docker-model-runner"],ee={name:"System Default",value:"none",logo:de,options:()=>e.jsx(S.Fragment,{}),description:"Agents will use the workspace or system LLM unless otherwise specified.",requiredConfig:[]};function qt({settings:s,workspace:t,setHasChanges:r}){var v;const n=((v=ie().llmProviders)==null?void 0:v.allowlist)??null,l=[ee,...oe.filter(x=>!(!It.includes(x.value)||n&&!n.includes(x.value)))],[d,c]=a.useState([]),[i,h]=a.useState((t==null?void 0:t.agentProvider)??"none"),[f,g]=a.useState(""),[b,m]=a.useState(!1),u=a.useRef(null),{t:p}=N();function j(x){g(""),h(x),m(!1),r(!0)}function E(){f.length>0?(g(""),u.current&&(u.current.value="")):m(!b)}a.useEffect(()=>{const x=l.filter(M=>M.name.toLowerCase().includes(f.toLowerCase()));c(x)},[f,i]);const y=l.find(x=>x.value===i)??ee;return e.jsxs("div",{className:"border-b border-white/40 pb-8",children:[_t.includes(i)&&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(qe,{className:"shrink-0",size:25}),e.jsx("p",{className:"text-sm",children:p("agent.performance-warning")})]})}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("label",{htmlFor:"name",className:"block input-label",children:p("agent.provider.title")}),e.jsx("p",{className:"text-white text-opacity-60 text-xs font-medium py-1.5",children:p("agent.provider.description")})]}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:"hidden",name:"agentProvider",value:i}),b&&e.jsx("div",{className:"fixed top-0 left-0 w-full h-full bg-black bg-opacity-70 backdrop-blur-sm z-10",onClick:()=>m(!1)}),b?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(G,{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:x=>g(x.target.value),ref:u,onKeyDown:x=>{x.key==="Enter"&&x.preventDefault()}}),e.jsx($,{size:20,weight:"bold",className:"cursor-pointer text-theme-text-primary hover:text-x-button",onClick:E})]}),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:d.map(x=>e.jsx(Tt,{llm:x,availableLLMs:l,settings:s,checked:i===x.value,onClick:()=>j(x.value)},x.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:()=>m(!0),children:[e.jsxs("div",{className:"flex gap-x-4 items-center",children:[e.jsx("img",{src:y.logo,alt:`${y.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:y.name}),e.jsx("div",{className:"mt-1 text-xs text-description",children:y.description})]})]}),e.jsx(ce,{size:24,weight:"bold",className:"text-white"})]})]}),i!=="none"&&e.jsx("div",{className:"mt-4 flex flex-col gap-y-1",children:e.jsx(Vt,{provider:i,workspace:t,setHasChanges:r})})]})}function Ht({workspace:s}){const{user:t}=ue(),[r,o]=a.useState({}),[n,l]=a.useState(!1),[d,c]=a.useState(!1),[i,h]=a.useState(!0),f=a.useRef(null);a.useEffect(()=>{async function b(){const m=await F.keys();o(m??{}),h(!1)}b()},[]);const g=async b=>{c(!0),b.preventDefault();const m={workspace:{},system:{},env:{}},u=new FormData(f.current);for(var[p,j]of u.entries()){if(p.startsWith("system::")){const[v,x]=p.split("system::");m.system[x]=String(j);continue}if(p.startsWith("env::")){const[v,x]=p.split("env::");m.env[x]=String(j);continue}m.workspace[p]=V(p,j)}const{workspace:E,message:y}=await L.update(s.slug,m.workspace);await W.updateSystemPreferences(m.system),await F.updateSystem(m.env),E?C("Workspace updated!","success",{clear:!0}):C(`Error: ${y}`,"error",{clear:!0}),c(!1),l(!1)};return!s||i?e.jsx(Bt,{}):e.jsx("div",{id:"workspace-agent-settings-container",children:e.jsxs("form",{ref:f,onSubmit:g,onChange:()=>l(!0),id:"agent-settings-form",className:"w-1/2 flex flex-col gap-y-6",children:[e.jsx(qt,{settings:r,workspace:s,setHasChanges:l}),(!t||(t==null?void 0:t.role)==="admin")&&e.jsx(e.Fragment,{children:!n&&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:k.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."})]})}),n&&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 Bt(){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(O,{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(O,{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 Zt={"general-appearance":st,"chat-settings":Ct,"vector-database":Rt,members:Wt,"agent-config":Ht};function ps(){const{loading:s,requiresAuth:t,mode:r}=Le();return s?e.jsx(me,{}):t!==!1?e.jsx(e.Fragment,{children:t!==null&&e.jsx(Fe,{mode:r})}):e.jsx(Gt,{})}function Gt(){const{t:s}=N(),{slug:t,tab:r}=B(),{user:o}=ue(),n=se("agentMode"),[l,d]=a.useState(null),[c,i]=a.useState(!1),[h,f]=a.useState(!0);if(a.useEffect(()=>{async function b(){if(!t)return;const m=await L.bySlug(t);if(!m){f(!1);return}const u=await F.keys(),p=await L.getSuggestedMessages(t);d({...m,vectorDB:u==null?void 0:u.VectorDB,suggestedMessages:p}),i((u==null?void 0:u.WorkspaceDeletionProtection)===!0),f(!1)}b()},[t,r]),h)return e.jsx(me,{});if(r==="agent-config"&&!n.enabled)return e.jsx(Ae,{to:k.workspace.settings.generalAppearance(t),replace:!0});const g=Zt[r];return e.jsxs("div",{className:"w-screen h-screen overflow-hidden bg-zinc-950 light:bg-slate-50 flex",children:[!Q&&e.jsx($e,{}),e.jsxs("div",{style:{height:Q?"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:k.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(De,{className:"h-5 w-5",weight:"fill"})}),e.jsx(z,{title:s("workspaces—settings.general"),icon:e.jsx(Pe,{className:"h-6 w-6"}),to:k.workspace.settings.generalAppearance(t)}),e.jsx(z,{title:s("workspaces—settings.chat"),icon:e.jsx(ze,{className:"h-6 w-6"}),to:k.workspace.settings.chatSettings(t)}),e.jsx(z,{title:s("workspaces—settings.vector"),icon:e.jsx(We,{className:"h-6 w-6"}),to:k.workspace.settings.vectorDatabase(t),visible:n.enabled}),e.jsx(z,{title:s("workspaces—settings.members"),icon:e.jsx(he,{className:"h-6 w-6"}),to:k.workspace.settings.members(t),visible:["admin","manager"].includes(o==null?void 0:o.role)}),e.jsx(z,{title:s("workspaces—settings.agent"),icon:e.jsx(Oe,{className:"h-6 w-6"}),to:k.workspace.settings.agentConfig(t),visible:n.enabled})]}),e.jsx("div",{className:"px-16 py-6",children:e.jsx(g,{slug:t,workspace:l,deletionProtected:c})})]})]})}function z({title:s,icon:t,to:r,visible:o=!0}){return o?e.jsxs(Re,{to:r,className:({isActive:n})=>`${n?"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{ps as default};
|