totem-llm 0.2.0 → 0.3.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.
Files changed (90) hide show
  1. package/README.md +12 -0
  2. package/package.json +1 -1
  3. package/server/models/systemSettings.js +1 -1
  4. package/server/models/workspace.js +2 -2
  5. package/server/public/assets/{404-b5c6b0dc.js → 404-56d107aa.js} +1 -1
  6. package/server/public/assets/RunDetailPage-da6aa377.js +1 -0
  7. package/server/public/assets/RunHistoryPage-2fcb4325.js +1 -0
  8. package/server/public/assets/{Trans-ca8f9cfe.js → Trans-820f1dad.js} +1 -1
  9. package/server/public/assets/{cron-1f15870f.js → cron-307d3fc6.js} +1 -1
  10. package/server/public/assets/{files-e19b0187.js → files-676613ed.js} +1 -1
  11. package/server/public/assets/index-01932fa1.js +1 -0
  12. package/server/public/assets/{index-a6e642d7.js → index-0bf4fb6b.js} +1 -1
  13. package/server/public/assets/index-166e238c.js +1 -0
  14. package/server/public/assets/{index-f86e167c.js → index-1c653bbf.js} +2 -2
  15. package/server/public/assets/index-1fe43260.js +1 -0
  16. package/server/public/assets/index-27cc497c.js +1 -0
  17. package/server/public/assets/{index-9cc77cb6.js → index-2aac91d0.js} +3 -3
  18. package/server/public/assets/index-2d84e5fe.js +1 -0
  19. package/server/public/assets/index-33ded078.js +1 -0
  20. package/server/public/assets/{index-2f526c2a.js → index-3cb59d82.js} +1 -1
  21. package/server/public/assets/{index-92d3b7bc.js → index-4277cf52.js} +1 -1
  22. package/server/public/assets/index-44ab5f11.js +1 -0
  23. package/server/public/assets/index-4750915e.js +1 -0
  24. package/server/public/assets/{index-ab72b353.js → index-574ed823.js} +2 -2
  25. package/server/public/assets/{index-3a2c5fd7.js → index-631fc042.js} +1 -1
  26. package/server/public/assets/index-65184421.js +1 -0
  27. package/server/public/assets/index-6679334a.js +1 -0
  28. package/server/public/assets/{index-6cdecde9.js → index-6bd7928a.js} +9 -9
  29. package/server/public/assets/index-6d56c896.js +18 -0
  30. package/server/public/assets/{index-925792fe.js → index-72544df5.js} +1 -1
  31. package/server/public/assets/index-80edec8f.js +1 -0
  32. package/server/public/assets/index-83825216.js +1 -0
  33. package/server/public/assets/index-841db586.js +1 -0
  34. package/server/public/assets/index-882e468e.js +1 -0
  35. package/server/public/assets/{index-ab35fb74.js → index-8c2371f5.js} +1 -1
  36. package/server/public/assets/{index-8eb228e2.js → index-9ab52cfb.js} +3 -3
  37. package/server/public/assets/{index-ad8e77d2.js → index-a2978aa0.js} +2 -2
  38. package/server/public/assets/index-a29a8c19.js +3 -0
  39. package/server/public/assets/{index-62fee0f9.js → index-ae4f557d.js} +2 -2
  40. package/server/public/assets/{index-8132c765.js → index-b49f94f1.js} +1 -1
  41. package/server/public/assets/{index-52850dde.js → index-c453ccc8.js} +1 -1
  42. package/server/public/assets/index-cd6bc090.js +1 -0
  43. package/server/public/assets/{index-c391a2fa.js → index-d1d3d69a.js} +1 -1
  44. package/server/public/assets/index-d29fdeda.js +1 -0
  45. package/server/public/assets/index-d54b0575.js +1 -0
  46. package/server/public/assets/index-dcc00e8c.js +3 -0
  47. package/server/public/assets/index-e58bf860.js +1 -0
  48. package/server/public/assets/index-ec3efa1e.js +1 -0
  49. package/server/public/assets/index-ed9034ac.js +1 -0
  50. package/server/public/assets/{index-92574f3a.js → index-efee6d1f.js} +1 -1
  51. package/server/public/assets/index-f9305828.js +1 -0
  52. package/server/public/assets/index-fce187ac.js +1 -0
  53. package/server/public/assets/{main-8ad4162f.js → main-0b9e408b.js} +1 -1
  54. package/server/public/assets/{mcpServers-a175e8cf.js → mcpServers-1686e782.js} +1 -1
  55. package/server/public/assets/{moment-8a59df1b.js → moment-75486807.js} +1 -1
  56. package/server/public/assets/{purify-fbc9e8e2.js → purify-eb750cf4.js} +1 -1
  57. package/server/public/assets/{react-beautiful-dnd.esm-45ea8487.js → react-beautiful-dnd.esm-bb85eef1.js} +1 -1
  58. package/server/public/assets/{truncate-352eb33b.js → truncate-06273256.js} +1 -1
  59. package/server/public/index.js +27 -27
  60. package/server/utils/AiProviders/ollama/index.js +2 -0
  61. package/server/utils/chats/agents.js +7 -1
  62. package/server/utils/telegramBot/utils/verification.js +1 -1
  63. package/totem.features.cjs +5 -108
  64. package/server/public/assets/RunDetailPage-74b1e63a.js +0 -1
  65. package/server/public/assets/RunHistoryPage-9609436a.js +0 -1
  66. package/server/public/assets/index-25b2660c.js +0 -1
  67. package/server/public/assets/index-2a7c0b04.js +0 -1
  68. package/server/public/assets/index-35b0a39b.js +0 -3
  69. package/server/public/assets/index-3643e990.js +0 -1
  70. package/server/public/assets/index-39899779.js +0 -1
  71. package/server/public/assets/index-51f23c79.js +0 -1
  72. package/server/public/assets/index-56bb11a0.js +0 -1
  73. package/server/public/assets/index-65801ac6.js +0 -1
  74. package/server/public/assets/index-6710499a.js +0 -1
  75. package/server/public/assets/index-73aba4c6.js +0 -3
  76. package/server/public/assets/index-837868b3.js +0 -1
  77. package/server/public/assets/index-86e8a6b4.js +0 -1
  78. package/server/public/assets/index-8e43159f.js +0 -1
  79. package/server/public/assets/index-994c849a.js +0 -1
  80. package/server/public/assets/index-9f71774b.js +0 -1
  81. package/server/public/assets/index-9f7dabd6.js +0 -1
  82. package/server/public/assets/index-a0e2be61.js +0 -1
  83. package/server/public/assets/index-ac4d4b42.js +0 -1
  84. package/server/public/assets/index-c9b59c35.js +0 -1
  85. package/server/public/assets/index-dad0fb8d.js +0 -18
  86. package/server/public/assets/index-dd210692.js +0 -1
  87. package/server/public/assets/index-e28b0ead.js +0 -1
  88. package/server/public/assets/index-e6c540e1.js +0 -1
  89. package/server/public/assets/index-f984ef26.js +0 -1
  90. package/server/public/assets/index-fb26b60a.js +0 -1
@@ -0,0 +1 @@
1
+ import{u as N,r as m,t as M,j as e,M as R,k,a4 as z,G as j,q as C,a1 as E,i as S,b as L,aY as P,c as D,p as F}from"../index.js";import{L as q}from"./index-8c2371f5.js";function y({isOpen:t,closeModal:a,onSuccess:o,router:l=null}){const{t:s}=N(),[g,r]=m.useState(null),[h,d]=m.useState(!1),[i,f]=m.useState(null),n=!!l;m.useEffect(()=>{t&&!n&&M.keys().then(c=>f(c))},[t,n]);const b=async c=>{c.preventDefault(),r(null),d(!0);const u=new FormData(c.target),x={name:u.get("name"),description:u.get("description"),fallback_provider:u.get("fallback_provider"),fallback_model:u.get("fallback_model"),cooldown_seconds:Number(u.get("cooldown_seconds")??30)};if(!x.name){r(s("model-router.new-router.name-required")),d(!1);return}if(!x.fallback_provider||!x.fallback_model){r(s("model-router.new-router.fallback-required")),d(!1);return}const{router:p,error:w}=n?await j.update(l.id,x):await j.create(x);d(!1),p?(o(),a()):r(w||(n?s("model-router.edit-router.toast-update-failed"):null))};return e.jsx(R,{isOpen:t,children:e.jsx("div",{className:"relative w-full max-w-2xl bg-zinc-900 light:bg-white rounded-[8px] shadow border border-zinc-700 light:border-slate-300",children:e.jsxs("form",{onSubmit:b,className:"flex flex-col gap-y-5 p-6",children:[e.jsxs("div",{className:"flex flex-col gap-y-1",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsx("h3",{className:"text-base font-semibold leading-6 text-white light:text-slate-950",children:n?s("model-router.edit-router.title",{name:l.name}):s("model-router.new-router.title")}),e.jsx("button",{onClick:a,type:"button",className:"border-none text-zinc-400 light:text-slate-500 hover:text-white light:hover:text-slate-900 transition-colors",children:e.jsx(k,{size:16,weight:"bold"})})]}),n&&(l==null?void 0:l.description)&&e.jsx("p",{className:"text-xs leading-4 text-zinc-400 light:text-slate-600 truncate",children:l.description})]}),e.jsxs("div",{className:"flex flex-col gap-y-1.5",children:[e.jsx("label",{className:"text-sm font-medium leading-5 text-white light:text-slate-950",children:s("model-router.new-router.name")}),e.jsx("input",{type:"text",name:"name",defaultValue:(l==null?void 0:l.name)||"",placeholder:s("model-router.new-router.name-placeholder"),className:"bg-zinc-800 light:bg-white light:border light:border-slate-300 text-white light:text-slate-700 placeholder:text-zinc-400 light:placeholder:text-slate-400 text-sm rounded-[8px] outline-none block w-full h-8 px-3.5",required:!0})]}),e.jsxs("div",{className:"flex flex-col gap-y-1.5",children:[e.jsx("label",{className:"text-sm font-medium leading-5 text-white light:text-slate-950",children:s("model-router.new-router.description")}),e.jsx("input",{type:"text",name:"description",defaultValue:(l==null?void 0:l.description)||"",placeholder:s("model-router.new-router.description-placeholder"),className:"bg-zinc-800 light:bg-white light:border light:border-slate-300 text-white light:text-slate-700 placeholder:text-zinc-400 light:placeholder:text-slate-400 text-sm rounded-[8px] outline-none block w-full h-8 px-3.5"})]}),e.jsx(q,{providerFieldName:"fallback_provider",modelFieldName:"fallback_model",label:s("model-router.new-router.fallback-label"),description:s("model-router.new-router.fallback-description"),defaultProvider:(l==null?void 0:l.fallback_provider)??(i==null?void 0:i.LLMProvider),defaultModel:(l==null?void 0:l.fallback_model)??(i==null?void 0:i.LLMModel)}),e.jsxs("div",{className:"flex flex-col gap-y-1.5",children:[e.jsx("label",{className:"text-sm font-medium leading-5 text-white light:text-slate-950",children:s("model-router.new-router.cooldown-label")}),e.jsx("input",{type:"number",name:"cooldown_seconds",defaultValue:(l==null?void 0:l.cooldown_seconds)??300,min:0,className:"bg-zinc-800 light:bg-white light:border light:border-slate-300 text-white light:text-slate-700 placeholder:text-zinc-400 light:placeholder:text-slate-400 text-sm rounded-[8px] outline-none block w-full h-8 px-3.5"}),e.jsx("p",{className:"text-xs leading-4 text-zinc-400 light:text-slate-600",children:s("model-router.new-router.cooldown-help")})]}),g&&e.jsxs("p",{className:"text-xs leading-4 text-red-400 light:text-red-600",children:["Error: ",g]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("button",{onClick:a,type:"button",className:"border border-zinc-600 light:border-slate-600 text-white light:text-slate-900 text-sm font-medium leading-5 rounded-[8px] h-[34px] px-3.5 hover:opacity-90 transition-opacity",children:s("model-router.new-router.cancel")}),e.jsx("button",{type:"submit",disabled:h,className:"border-none flex items-center gap-x-1.5 text-sm font-medium leading-5 bg-zinc-50 light:bg-slate-900 text-zinc-900 light:text-white rounded-[8px] h-[34px] px-3.5 hover:opacity-90 transition-opacity disabled:opacity-50 disabled:cursor-not-allowed",children:h?e.jsxs(e.Fragment,{children:[e.jsx(z,{className:"h-4 w-4 animate-spin"}),s("common.saving")]}):s(n?"model-router.edit-router.save":"model-router.new-router.create")})]})]})})})}function B(){const{t}=N(),{isOpen:a,openModal:o,closeModal:l}=C(),[s,g]=m.useState(!0),[r,h]=m.useState([]),[d,i]=m.useState(null),f=()=>{i(null),o()},n=p=>{i(p),o()},b=()=>{l(),i(null)},c=async()=>{const p=await j.getAll();h(p),g(!1)};m.useEffect(()=>{c()},[]);const u=p=>{h(w=>w.filter(_=>_.id!==p))},x=!s&&r.length===0;return s?e.jsx(v,{t,children:e.jsx(A,{})}):x?e.jsxs(v,{t,children:[e.jsx(V,{onCreateClick:f,t}),e.jsx(y,{isOpen:a,closeModal:b,onSuccess:c,router:d})]}):e.jsxs(v,{t,showAction:!x,onAction:f,children:[e.jsx(T,{routers:r,removeRouter:u,openEditModal:n}),e.jsx(y,{isOpen:a,closeModal:b,onSuccess:c,router:d})]})}function v({t,showAction:a,onAction:o,children:l}){return e.jsxs("div",{className:"w-screen h-screen overflow-hidden bg-zinc-950 light:bg-slate-50 flex md:mt-0 mt-6",children:[e.jsx(E,{}),e.jsx("div",{style:{height:S?"100%":"calc(100% - 32px)"},className:"relative md:ml-[2px] md:mr-[16px] md:my-[16px] md:rounded-2xl bg-zinc-900 light:bg-white light:border light:border-slate-300 w-full h-full overflow-y-scroll p-4 md:p-0",children:e.jsxs("div",{className:"flex flex-col w-full px-1 md:pl-6 md:pr-[50px] md:py-0 py-16",children:[e.jsxs("div",{className:"flex items-end justify-between pr-8 py-6 border-b border-white/20 light:border-slate-300",children:[e.jsxs("div",{className:"flex flex-col gap-y-2",children:[e.jsx("p",{className:"text-lg font-semibold leading-7 text-white light:text-slate-900",children:t("model-router.title")}),e.jsx("p",{className:"text-xs leading-4 text-zinc-400 light:text-slate-600 max-w-[700px]",children:t("model-router.description")})]}),a&&e.jsx("button",{onClick:o,className:"border-none shrink-0 flex items-center justify-center h-9 px-5 py-2.5 rounded-lg bg-slate-50 text-zinc-950 text-sm font-medium leading-5 hover:opacity-90 transition-opacity duration-200",children:t("model-router.new-router-button")})]}),e.jsxs("div",{className:"mt-8 flex flex-col",children:[e.jsxs("div",{className:"grid grid-cols-[2fr_2fr_1fr_1fr_88px] gap-x-4 px-4 text-sm font-semibold uppercase tracking-[1.4px] text-zinc-500 light:text-slate-500 leading-5",children:[e.jsx("span",{children:t("model-router.table.name")}),e.jsx("span",{children:t("model-router.table.fallback")}),e.jsx("span",{children:t("model-router.table.rules")}),e.jsx("span",{children:t("model-router.table.workspaces")}),e.jsx("span",{"aria-hidden":"true"})]}),e.jsx("div",{className:"mt-[18px] border-t border-white/20 light:border-slate-300"}),l]})]})})]})}function A(){return e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx(z,{className:"h-8 w-8 text-zinc-400 animate-spin"})})}function T({routers:t,removeRouter:a,openEditModal:o}){return e.jsx("div",{className:"flex flex-col",children:t.map((l,s)=>e.jsx(G,{router:l,removeRouter:a,onEdit:()=>o(l),showDivider:s<t.length-1},l.id))})}function V({onCreateClick:t,t:a}){return e.jsxs("div",{className:"flex flex-col items-center justify-center gap-8 py-28",children:[e.jsxs("div",{className:"flex flex-col items-center gap-1.5 text-center",children:[e.jsx("p",{className:"text-base font-semibold leading-6 text-zinc-50 light:text-slate-900",children:a("model-router.no-routers")}),e.jsx("p",{className:"text-sm font-medium leading-5 text-zinc-400 light:text-slate-500 max-w-[370px]",children:a("model-router.empty-description")})]}),e.jsx("button",{onClick:t,className:"border-none flex items-center justify-center h-9 px-5 py-2.5 rounded-lg bg-slate-50 text-zinc-950 text-sm font-medium leading-5 hover:opacity-90 transition-opacity duration-200",children:a("model-router.new-router-button")})]})}function G({router:t,removeRouter:a,onEdit:o,showDivider:l}){const{t:s}=N(),g=L(),r=async i=>{if(i.stopPropagation(),!window.confirm(s("model-router.delete-confirm",{name:t.name})))return;const{success:f,error:n}=await j.delete(t.id);f?a(t.id):D(s("model-router.toast-delete-failed",{error:n}),"error")},h=()=>g(F.settings.modelRouterRules(t.id)),d=i=>{i.stopPropagation(),o()};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{onClick:h,className:"group grid grid-cols-[2fr_2fr_1fr_1fr_88px] gap-x-4 items-center h-9 px-4 rounded-lg cursor-pointer hover:bg-white/5 light:hover:bg-slate-100 transition-colors",children:[e.jsx("span",{className:"text-sm font-medium leading-5 text-white light:text-slate-900 truncate",children:t.name}),e.jsxs("span",{className:"text-sm font-normal leading-5 text-zinc-400 light:text-slate-500 truncate",children:[t.fallback_provider,"/",t.fallback_model]}),e.jsx("span",{className:"text-sm font-normal leading-5 text-zinc-400 light:text-slate-500",children:t.ruleCount||0}),e.jsx("span",{className:"text-sm font-normal leading-5 text-zinc-400 light:text-slate-500",children:t.workspaceCount||0}),e.jsxs("div",{className:"flex items-center justify-end gap-[14px]",children:[e.jsx("button",{onClick:d,"aria-label":s("model-router.edit-router.title",{name:t.name}),className:"border-none text-zinc-400 light:text-slate-500 hover:text-white light:hover:text-slate-900 transition-colors",children:e.jsx(P,{size:16,weight:"bold"})}),e.jsx("button",{onClick:r,"aria-label":s("model-router.toast-deleted"),className:"border-none text-zinc-400 light:text-slate-500 hover:text-red-400 light:hover:text-red-500 transition-colors",children:e.jsx(k,{size:16,weight:"bold"})})]})]}),l&&e.jsx("div",{className:"border-t border-white/10 light:border-slate-200"})]})}export{B as default};
@@ -1 +1 @@
1
- import{r as a,j as e,I as $,a9 as z,l as H,b as U,p as O,aH as ce,a8 as de,v as me,aI as ue,c as S,a5 as fe}from"../index.js";import{B as V,a as o,P as pe,b as xe}from"./index-2f526c2a.js";import{A as I}from"./agentFlows-e4124dd3.js";import{L as he}from"./anything-llm-infinity-0d7244a1.js";import"./communityHub-aba61686.js";import"./Brain-24e386d5.js";import"./Browser-1820fad0.js";function ge(d){var f,g;const c=d[d.length-2];return c?((f=c==null?void 0:c.config)==null?void 0:f.directOutput)===!1||((g=c==null?void 0:c.config)==null?void 0:g.directOutput)===void 0:!0}function be({blocks:d,showBlockMenu:c,setShowBlockMenu:f,addBlock:g}){const h=a.useRef(null);return a.useEffect(()=>{function m(p){h.current&&!h.current.contains(p.target)&&f(!1)}return document.addEventListener("mousedown",m),()=>{document.removeEventListener("mousedown",m)}},[f]),ge(d)===!1?null:e.jsxs("div",{className:"relative mt-4 w-[280px] mx-auto pb-4",ref:h,children:[e.jsxs("button",{onClick:()=>f(!c),className:"transition-all duration-300 w-full p-2.5 bg-theme-action-menu-bg hover:bg-theme-action-menu-item-hover border border-white/10 rounded-lg text-white flex items-center justify-center gap-2 text-sm font-medium",children:[e.jsx($,{className:"w-4 h-4"}),"Add Block",e.jsx(z,{className:`w-3.5 h-3.5 transition-transform duration-300 ${c?"rotate-180":""}`})]}),c&&e.jsx("div",{className:"absolute left-0 right-0 mt-2 bg-theme-action-menu-bg border border-white/10 rounded-lg shadow-lg overflow-hidden z-10 animate-fadeUpIn",children:Object.entries(V).map(([m,p])=>m!==o.START&&m!==o.FINISH&&m!==o.FLOW_INFO&&e.jsxs("button",{onClick:()=>{g(m),f(!1)},className:"w-full p-2.5 flex items-center gap-3 hover:bg-theme-action-menu-item-hover text-white transition-colors duration-300 group",children:[e.jsx("div",{className:"w-7 h-7 rounded-lg bg-white/10 flex items-center justify-center",children:e.jsx("div",{className:"w-fit h-fit text-white",children:p.icon})}),e.jsxs("div",{className:"text-left flex-1",children:[e.jsx("div",{className:"text-sm font-medium",children:p.label}),e.jsx("div",{className:"text-xs text-white/60",children:p.description})]})]},m))})]})}function we({agentName:d,availableFlows:c=[],onNewFlow:f,onSaveFlow:g,onPublishFlow:h}){const{flowId:m=null}=H(),[p,N]=a.useState(!1),b=U(),j=a.useRef(null),v=c.filter(i=>i.uuid!==m).length>0;return a.useEffect(()=>{function i(u){j.current&&!j.current.contains(u.target)&&N(!1)}return document.addEventListener("mousedown",i),()=>{document.removeEventListener("mousedown",i)}},[]),e.jsx("div",{className:"absolute top-[calc(40px+16px)] left-4 right-4",children:e.jsxs("div",{className:"flex justify-between items-start max-w-[1700px] mx-auto",children:[e.jsxs("div",{className:"flex items-center gap-x-2",children:[e.jsx("button",{onClick:()=>b(O.settings.agentSkills()),className:"w-8 h-8 flex items-center justify-center rounded-full bg-theme-settings-input-bg border border-white/10 hover:bg-theme-action-menu-bg transition-colors duration-300",children:e.jsx(ce,{weight:"bold",className:"w-5 h-5 text-theme-text-primary"})}),e.jsxs("div",{className:"flex items-center bg-theme-settings-input-bg rounded-md border border-white/10 pointer-events-auto",ref:j,children:[e.jsxs("button",{onClick:()=>b(O.settings.agentSkills()),className:"!border-t-transparent !border-l-transparent !border-b-transparent flex items-center gap-x-2 px-4 py-2 border-r border-white/10 hover:bg-theme-action-menu-bg transition-colors duration-300",children:[e.jsx("img",{src:he,alt:"logo",className:"w-[20px] light:invert"}),e.jsx("span",{className:"text-theme-text-primary text-sm uppercase tracking-widest",children:"Builder"})]}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{disabled:!v,className:"border-none flex items-center justify-between gap-x-1 text-theme-text-primary text-sm px-4 py-2 enabled:hover:bg-theme-action-menu-bg transition-colors duration-300 min-w-[200px] max-w-[300px]",onClick:()=>{if(!d&&!v){const i=document.getElementById("agent-flow-name-input");i&&i.focus();return}N(!p)},children:[e.jsx("span",{className:`text-sm font-medium truncate ${d?"text-theme-text-primary ":"text-theme-text-secondary"}`,children:d||"Untitled Flow"}),v&&e.jsxs("div",{className:"flex flex-col ml-2 shrink-0",children:[e.jsx(de,{size:10}),e.jsx(z,{size:10})]})]}),p&&e.jsx("div",{className:"absolute top-full left-0 mt-1 w-full min-w-[200px] max-w-[350px] bg-theme-settings-input-bg border border-white/10 rounded-md shadow-lg z-50 animate-fadeUpIn",children:c.filter(i=>i.uuid!==m).map((i,u)=>e.jsx("button",{onClick:()=>{b(O.agents.editAgent(i.uuid)),N(!1)},className:"border-none w-full text-left px-2 py-1 text-sm text-theme-text-primary hover:bg-theme-action-menu-bg transition-colors duration-300",children:e.jsx("span",{className:"block truncate",children:(i==null?void 0:i.name)||"Untitled Flow"})},(i==null?void 0:i.uuid)||`flow-${u}`))})]})]})]}),e.jsxs("div",{className:"flex flex-col gap-y-1 items-end",children:[e.jsxs("div",{className:"flex items-center gap-x-[15px]",children:[e.jsxs("button",{onClick:f,className:"flex items-center gap-x-2 text-theme-text-primary text-sm font-medium px-3 py-2 rounded-lg border border-white bg-theme-settings-input-bg hover:bg-theme-action-menu-bg transition-colors duration-300",children:[e.jsx($,{className:"w-4 h-4"}),"New Flow"]}),e.jsx("button",{onClick:h,className:"px-3 py-2 rounded-lg text-sm font-medium flex items-center justify-center gap-2 border border-white/10 bg-theme-bg-primary text-theme-text-primary hover:bg-theme-action-menu-bg transition-all duration-300",children:"Publish"}),e.jsx("button",{onClick:g,className:"border-none bg-primary-button hover:opacity-80 text-black light:text-white px-3 py-2 rounded-lg text-sm font-medium transition-all duration-300 flex items-center justify-center gap-2",children:"Save"})]}),e.jsx(me,{to:"https://docs.anythingllm.com/agent-flows/overview",className:"text-theme-text-secondary text-sm hover:underline hover:text-cta-button flex items-center gap-x-1 w-fit float-right",children:"view documentation →"})]})]})})}const W=[{id:"flow_info",type:o.FLOW_INFO,config:{name:"",description:""},isExpanded:!0},{id:"start",type:o.START,config:{variables:[{name:"",value:""}]},isExpanded:!0},{id:"finish",type:o.FINISH,config:{},isExpanded:!1}];function Oe(){var P,B;const{flowId:d}=H(),{theme:c}=ue(),f=U(),[g,h]=a.useState(""),[m,p]=a.useState(""),[N,b]=a.useState(null),[j,v]=a.useState(!0),[i,u]=a.useState(W),[D,K]=a.useState("start"),[L,A]=a.useState(!1),[M,q]=a.useState([]),C=a.useRef(null),_=a.useRef(null),[Y,T]=a.useState(!1);a.useEffect(()=>{R()},[]),a.useEffect(()=>{d&&G(d)},[d]),a.useEffect(()=>{var s;const t=i.find(n=>n.type===o.FLOW_INFO);h(((s=t==null?void 0:t.config)==null?void 0:s.name)||"")},[i]);const R=async()=>{try{const{success:t,error:s,flows:n}=await I.listFlows();if(!t)throw new Error(s);q(n)}catch(t){console.error(t),S("Failed to load available flows","error",{clear:!0})}},G=async t=>{var s;try{const{success:n,error:r,flow:x}=await I.getFlow(t);if(!n)throw new Error(r);const w=[{id:"flow_info",type:o.FLOW_INFO,config:{name:x.config.name,description:x.config.description},isExpanded:!0},...x.config.steps.map((F,E)=>({id:E===0?"start":`block_${E}`,type:F.type,config:F.config,isExpanded:!0}))];((s=w[w.length-1])==null?void 0:s.type)!==o.FINISH&&w.push({id:"finish",type:o.FINISH,config:{},isExpanded:!1}),h(x.config.name),p(x.config.description),v(x.config.active??!0),b(x.uuid),u(w)}catch(n){console.error(n),S("Failed to load flow","error",{clear:!0})}},J=t=>{const s={id:`block_${i.length}`,type:t,config:{...V[t].defaultConfig},isExpanded:!0},n=[...i];n.splice(n.length-1,0,s),u(n),A(!1)},k=(t,s)=>{u(i.map(n=>n.id===t?{...n,config:{...n.config,...s}}:n))},Q=t=>{t!=="start"&&(u(i.filter(s=>s.id!==t)),D===t&&K("start"))},X=async()=>{var x,w,F,E;const t=i.find(l=>l.type===o.FLOW_INFO),s=(x=t==null?void 0:t.config)==null?void 0:x.name,n=(w=t==null?void 0:t.config)==null?void 0:w.description;if(!(s!=null&&s.trim())||!(n!=null&&n.trim())){t.isExpanded||(u(i.map(l=>l.type===o.FLOW_INFO?{...l,isExpanded:!0}:l)),await new Promise(l=>setTimeout(l,100))),s!=null&&s.trim()?n!=null&&n.trim()||(E=_.current)==null||E.focus():(F=C.current)==null||F.focus(),S("Please provide both a name and description for your flow","error",{clear:!0});return}const r={name:s,description:n,active:j,steps:i.filter(l=>l.type!==o.FINISH&&l.type!==o.FLOW_INFO).map(l=>({type:l.type,config:l.config}))};try{const{success:l,error:oe,flow:le}=await I.saveFlow(s,r,N);if(!l)throw new Error(oe);b(le.uuid),S("Agent flow saved successfully!","success",{clear:!0}),await R()}catch(l){console.error("Save error details:",l),S(`Failed to save agent flow. ${l.message}`,"error",{clear:!0})}},Z=t=>{u(i.map(s=>s.id===t?{...s,isExpanded:!s.isExpanded}:s))},ee=()=>{var s,n;const t=i.find(r=>r.type===o.START);return((n=(s=t==null?void 0:t.config)==null?void 0:s.variables)==null?void 0:n.filter(r=>r.name))||[]},te=(t,s,n="Select variable")=>e.jsxs("select",{value:t||"",onChange:r=>s(r.target.value),className:"w-full border-none bg-theme-settings-input-bg text-theme-text-primary text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none p-2.5",children:[e.jsx("option",{value:"",className:"bg-theme-bg-primary",children:n}),ee().map(r=>e.jsx("option",{value:r.name,className:"bg-theme-bg-primary",children:r.name},r.name))]}),se=t=>{i.forEach(s=>{if(s.type===o.START)return;let n=!1;const r={...s.config};r.responseVariable===t&&(r.responseVariable="",n=!0),r.resultVariable===t&&(r.resultVariable="",n=!0),n&&k(s.id,r)})},ne=()=>{d&&f(O.agents.builder()),h(""),p(""),b(null),v(!0),u(W)},ie=(t,s)=>{const n=[...i],[r]=n.splice(t,1);n.splice(s,0,r),u(n)},re=()=>{T(!0)},y=i.find(t=>t.type===o.FLOW_INFO),ae={name:((P=y==null?void 0:y.config)==null?void 0:P.name)||"",description:((B=y==null?void 0:y.config)==null?void 0:B.description)||"",steps:i.filter(t=>t.type!==o.FINISH&&t.type!==o.FLOW_INFO).map(t=>({type:t.type,config:t.config}))};return e.jsxs("div",{style:{backgroundImage:c==="light"?"radial-gradient(rgba(0, 0, 0, 0.1) 1px, transparent 0)":"radial-gradient(rgba(255, 255, 255, 0.1) 1px, transparent 0)",backgroundSize:"15px 15px",backgroundPosition:"-7.5px -7.5px"},className:"relative w-screen h-screen flex flex-col bg-theme-bg-primary overflow-clip",children:[e.jsx(pe,{show:Y,onClose:()=>T(!1),entityType:"agent-flow",entity:ae}),e.jsx(we,{agentName:g,availableFlows:M,onNewFlow:ne,onSaveFlow:X,onPublishFlow:re}),e.jsx("div",{className:"flex-1 min-h-0 p-6 overflow-y-auto",children:e.jsxs("div",{className:`max-w-xl mx-auto mt-14 ${L?"pb-52":""}`,children:[e.jsx(xe,{blocks:i,updateBlockConfig:k,removeBlock:Q,toggleBlockExpansion:Z,renderVariableSelect:te,onDeleteVariable:se,moveBlock:ie,refs:{nameRef:C,descriptionRef:_}}),e.jsx(be,{blocks:i,showBlockMenu:L,setShowBlockMenu:A,addBlock:J})]})}),e.jsx(fe,{id:"content-summarization-tooltip",place:"top",delayShow:300,className:"tooltip !text-xs z-99",children:e.jsxs("p",{className:"text-sm",children:["When enabled, long webpage content will be automatically summarized to reduce token usage.",e.jsx("br",{}),e.jsx("br",{}),"Note: This may affect data quality and remove specific details from the original content."]})})]})}export{Oe as default};
1
+ import{r as a,j as e,I as $,ab as z,l as U,b as V,p as O,aJ as ce,aa as de,v as me,aK as ue,c as S,a7 as fe}from"../index.js";import{B as H,a as o,P as pe,b as xe}from"./index-3cb59d82.js";import{A as I}from"./agentFlows-e4124dd3.js";import{L as he}from"./anything-llm-infinity-0d7244a1.js";import"./communityHub-aba61686.js";import"./Brain-24e386d5.js";import"./Browser-1820fad0.js";function ge(d){var f,g;const c=d[d.length-2];return c?((f=c==null?void 0:c.config)==null?void 0:f.directOutput)===!1||((g=c==null?void 0:c.config)==null?void 0:g.directOutput)===void 0:!0}function be({blocks:d,showBlockMenu:c,setShowBlockMenu:f,addBlock:g}){const h=a.useRef(null);return a.useEffect(()=>{function m(p){h.current&&!h.current.contains(p.target)&&f(!1)}return document.addEventListener("mousedown",m),()=>{document.removeEventListener("mousedown",m)}},[f]),ge(d)===!1?null:e.jsxs("div",{className:"relative mt-4 w-[280px] mx-auto pb-4",ref:h,children:[e.jsxs("button",{onClick:()=>f(!c),className:"transition-all duration-300 w-full p-2.5 bg-theme-action-menu-bg hover:bg-theme-action-menu-item-hover border border-white/10 rounded-lg text-white flex items-center justify-center gap-2 text-sm font-medium",children:[e.jsx($,{className:"w-4 h-4"}),"Add Block",e.jsx(z,{className:`w-3.5 h-3.5 transition-transform duration-300 ${c?"rotate-180":""}`})]}),c&&e.jsx("div",{className:"absolute left-0 right-0 mt-2 bg-theme-action-menu-bg border border-white/10 rounded-lg shadow-lg overflow-hidden z-10 animate-fadeUpIn",children:Object.entries(H).map(([m,p])=>m!==o.START&&m!==o.FINISH&&m!==o.FLOW_INFO&&e.jsxs("button",{onClick:()=>{g(m),f(!1)},className:"w-full p-2.5 flex items-center gap-3 hover:bg-theme-action-menu-item-hover text-white transition-colors duration-300 group",children:[e.jsx("div",{className:"w-7 h-7 rounded-lg bg-white/10 flex items-center justify-center",children:e.jsx("div",{className:"w-fit h-fit text-white",children:p.icon})}),e.jsxs("div",{className:"text-left flex-1",children:[e.jsx("div",{className:"text-sm font-medium",children:p.label}),e.jsx("div",{className:"text-xs text-white/60",children:p.description})]})]},m))})]})}function we({agentName:d,availableFlows:c=[],onNewFlow:f,onSaveFlow:g,onPublishFlow:h}){const{flowId:m=null}=U(),[p,N]=a.useState(!1),b=V(),j=a.useRef(null),v=c.filter(i=>i.uuid!==m).length>0;return a.useEffect(()=>{function i(u){j.current&&!j.current.contains(u.target)&&N(!1)}return document.addEventListener("mousedown",i),()=>{document.removeEventListener("mousedown",i)}},[]),e.jsx("div",{className:"absolute top-[calc(40px+16px)] left-4 right-4",children:e.jsxs("div",{className:"flex justify-between items-start max-w-[1700px] mx-auto",children:[e.jsxs("div",{className:"flex items-center gap-x-2",children:[e.jsx("button",{onClick:()=>b(O.settings.agentSkills()),className:"w-8 h-8 flex items-center justify-center rounded-full bg-theme-settings-input-bg border border-white/10 hover:bg-theme-action-menu-bg transition-colors duration-300",children:e.jsx(ce,{weight:"bold",className:"w-5 h-5 text-theme-text-primary"})}),e.jsxs("div",{className:"flex items-center bg-theme-settings-input-bg rounded-md border border-white/10 pointer-events-auto",ref:j,children:[e.jsxs("button",{onClick:()=>b(O.settings.agentSkills()),className:"!border-t-transparent !border-l-transparent !border-b-transparent flex items-center gap-x-2 px-4 py-2 border-r border-white/10 hover:bg-theme-action-menu-bg transition-colors duration-300",children:[e.jsx("img",{src:he,alt:"logo",className:"w-[20px] light:invert"}),e.jsx("span",{className:"text-theme-text-primary text-sm uppercase tracking-widest",children:"Builder"})]}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{disabled:!v,className:"border-none flex items-center justify-between gap-x-1 text-theme-text-primary text-sm px-4 py-2 enabled:hover:bg-theme-action-menu-bg transition-colors duration-300 min-w-[200px] max-w-[300px]",onClick:()=>{if(!d&&!v){const i=document.getElementById("agent-flow-name-input");i&&i.focus();return}N(!p)},children:[e.jsx("span",{className:`text-sm font-medium truncate ${d?"text-theme-text-primary ":"text-theme-text-secondary"}`,children:d||"Untitled Flow"}),v&&e.jsxs("div",{className:"flex flex-col ml-2 shrink-0",children:[e.jsx(de,{size:10}),e.jsx(z,{size:10})]})]}),p&&e.jsx("div",{className:"absolute top-full left-0 mt-1 w-full min-w-[200px] max-w-[350px] bg-theme-settings-input-bg border border-white/10 rounded-md shadow-lg z-50 animate-fadeUpIn",children:c.filter(i=>i.uuid!==m).map((i,u)=>e.jsx("button",{onClick:()=>{b(O.agents.editAgent(i.uuid)),N(!1)},className:"border-none w-full text-left px-2 py-1 text-sm text-theme-text-primary hover:bg-theme-action-menu-bg transition-colors duration-300",children:e.jsx("span",{className:"block truncate",children:(i==null?void 0:i.name)||"Untitled Flow"})},(i==null?void 0:i.uuid)||`flow-${u}`))})]})]})]}),e.jsxs("div",{className:"flex flex-col gap-y-1 items-end",children:[e.jsxs("div",{className:"flex items-center gap-x-[15px]",children:[e.jsxs("button",{onClick:f,className:"flex items-center gap-x-2 text-theme-text-primary text-sm font-medium px-3 py-2 rounded-lg border border-white bg-theme-settings-input-bg hover:bg-theme-action-menu-bg transition-colors duration-300",children:[e.jsx($,{className:"w-4 h-4"}),"New Flow"]}),e.jsx("button",{onClick:h,className:"px-3 py-2 rounded-lg text-sm font-medium flex items-center justify-center gap-2 border border-white/10 bg-theme-bg-primary text-theme-text-primary hover:bg-theme-action-menu-bg transition-all duration-300",children:"Publish"}),e.jsx("button",{onClick:g,className:"border-none bg-primary-button hover:opacity-80 text-black light:text-white px-3 py-2 rounded-lg text-sm font-medium transition-all duration-300 flex items-center justify-center gap-2",children:"Save"})]}),e.jsx(me,{to:"https://docs.anythingllm.com/agent-flows/overview",className:"text-theme-text-secondary text-sm hover:underline hover:text-cta-button flex items-center gap-x-1 w-fit float-right",children:"view documentation →"})]})]})})}const W=[{id:"flow_info",type:o.FLOW_INFO,config:{name:"",description:""},isExpanded:!0},{id:"start",type:o.START,config:{variables:[{name:"",value:""}]},isExpanded:!0},{id:"finish",type:o.FINISH,config:{},isExpanded:!1}];function Oe(){var P,B;const{flowId:d}=U(),{theme:c}=ue(),f=V(),[g,h]=a.useState(""),[m,p]=a.useState(""),[N,b]=a.useState(null),[j,v]=a.useState(!0),[i,u]=a.useState(W),[D,K]=a.useState("start"),[L,A]=a.useState(!1),[M,q]=a.useState([]),C=a.useRef(null),_=a.useRef(null),[J,T]=a.useState(!1);a.useEffect(()=>{R()},[]),a.useEffect(()=>{d&&Y(d)},[d]),a.useEffect(()=>{var s;const t=i.find(n=>n.type===o.FLOW_INFO);h(((s=t==null?void 0:t.config)==null?void 0:s.name)||"")},[i]);const R=async()=>{try{const{success:t,error:s,flows:n}=await I.listFlows();if(!t)throw new Error(s);q(n)}catch(t){console.error(t),S("Failed to load available flows","error",{clear:!0})}},Y=async t=>{var s;try{const{success:n,error:r,flow:x}=await I.getFlow(t);if(!n)throw new Error(r);const w=[{id:"flow_info",type:o.FLOW_INFO,config:{name:x.config.name,description:x.config.description},isExpanded:!0},...x.config.steps.map((F,E)=>({id:E===0?"start":`block_${E}`,type:F.type,config:F.config,isExpanded:!0}))];((s=w[w.length-1])==null?void 0:s.type)!==o.FINISH&&w.push({id:"finish",type:o.FINISH,config:{},isExpanded:!1}),h(x.config.name),p(x.config.description),v(x.config.active??!0),b(x.uuid),u(w)}catch(n){console.error(n),S("Failed to load flow","error",{clear:!0})}},G=t=>{const s={id:`block_${i.length}`,type:t,config:{...H[t].defaultConfig},isExpanded:!0},n=[...i];n.splice(n.length-1,0,s),u(n),A(!1)},k=(t,s)=>{u(i.map(n=>n.id===t?{...n,config:{...n.config,...s}}:n))},Q=t=>{t!=="start"&&(u(i.filter(s=>s.id!==t)),D===t&&K("start"))},X=async()=>{var x,w,F,E;const t=i.find(l=>l.type===o.FLOW_INFO),s=(x=t==null?void 0:t.config)==null?void 0:x.name,n=(w=t==null?void 0:t.config)==null?void 0:w.description;if(!(s!=null&&s.trim())||!(n!=null&&n.trim())){t.isExpanded||(u(i.map(l=>l.type===o.FLOW_INFO?{...l,isExpanded:!0}:l)),await new Promise(l=>setTimeout(l,100))),s!=null&&s.trim()?n!=null&&n.trim()||(E=_.current)==null||E.focus():(F=C.current)==null||F.focus(),S("Please provide both a name and description for your flow","error",{clear:!0});return}const r={name:s,description:n,active:j,steps:i.filter(l=>l.type!==o.FINISH&&l.type!==o.FLOW_INFO).map(l=>({type:l.type,config:l.config}))};try{const{success:l,error:oe,flow:le}=await I.saveFlow(s,r,N);if(!l)throw new Error(oe);b(le.uuid),S("Agent flow saved successfully!","success",{clear:!0}),await R()}catch(l){console.error("Save error details:",l),S(`Failed to save agent flow. ${l.message}`,"error",{clear:!0})}},Z=t=>{u(i.map(s=>s.id===t?{...s,isExpanded:!s.isExpanded}:s))},ee=()=>{var s,n;const t=i.find(r=>r.type===o.START);return((n=(s=t==null?void 0:t.config)==null?void 0:s.variables)==null?void 0:n.filter(r=>r.name))||[]},te=(t,s,n="Select variable")=>e.jsxs("select",{value:t||"",onChange:r=>s(r.target.value),className:"w-full border-none bg-theme-settings-input-bg text-theme-text-primary text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none p-2.5",children:[e.jsx("option",{value:"",className:"bg-theme-bg-primary",children:n}),ee().map(r=>e.jsx("option",{value:r.name,className:"bg-theme-bg-primary",children:r.name},r.name))]}),se=t=>{i.forEach(s=>{if(s.type===o.START)return;let n=!1;const r={...s.config};r.responseVariable===t&&(r.responseVariable="",n=!0),r.resultVariable===t&&(r.resultVariable="",n=!0),n&&k(s.id,r)})},ne=()=>{d&&f(O.agents.builder()),h(""),p(""),b(null),v(!0),u(W)},ie=(t,s)=>{const n=[...i],[r]=n.splice(t,1);n.splice(s,0,r),u(n)},re=()=>{T(!0)},y=i.find(t=>t.type===o.FLOW_INFO),ae={name:((P=y==null?void 0:y.config)==null?void 0:P.name)||"",description:((B=y==null?void 0:y.config)==null?void 0:B.description)||"",steps:i.filter(t=>t.type!==o.FINISH&&t.type!==o.FLOW_INFO).map(t=>({type:t.type,config:t.config}))};return e.jsxs("div",{style:{backgroundImage:c==="light"?"radial-gradient(rgba(0, 0, 0, 0.1) 1px, transparent 0)":"radial-gradient(rgba(255, 255, 255, 0.1) 1px, transparent 0)",backgroundSize:"15px 15px",backgroundPosition:"-7.5px -7.5px"},className:"relative w-screen h-screen flex flex-col bg-theme-bg-primary overflow-clip",children:[e.jsx(pe,{show:J,onClose:()=>T(!1),entityType:"agent-flow",entity:ae}),e.jsx(we,{agentName:g,availableFlows:M,onNewFlow:ne,onSaveFlow:X,onPublishFlow:re}),e.jsx("div",{className:"flex-1 min-h-0 p-6 overflow-y-auto",children:e.jsxs("div",{className:`max-w-xl mx-auto mt-14 ${L?"pb-52":""}`,children:[e.jsx(xe,{blocks:i,updateBlockConfig:k,removeBlock:Q,toggleBlockExpansion:Z,renderVariableSelect:te,onDeleteVariable:se,moveBlock:ie,refs:{nameRef:C,descriptionRef:_}}),e.jsx(be,{blocks:i,showBlockMenu:L,setShowBlockMenu:A,addBlock:G})]})}),e.jsx(fe,{id:"content-summarization-tooltip",place:"top",delayShow:300,className:"tooltip !text-xs z-99",children:e.jsxs("p",{className:"text-sm",children:["When enabled, long webpage content will be automatically summarized to reduce token usage.",e.jsx("br",{}),e.jsx("br",{}),"Note: This may affect data quality and remove specific details from the original content."]})})]})}export{Oe as default};
@@ -0,0 +1 @@
1
+ import{A as d,l as u,r as i,u as y,j as e,Y as j,Z as N,_ as E,t as S,$ as A,a0 as I,p as T,e as k,M as _}from"../index.js";const x={checkInvite:async s=>await fetch(`${d}/invite/${s}`,{method:"GET"}).then(t=>t.json()).catch(t=>(console.error(t),{invite:null,error:t.message})),acceptInvite:async(s,t={})=>await fetch(`${d}/invite/${s}`,{method:"POST",body:JSON.stringify(t)}).then(r=>r.json()).catch(r=>(console.error(r),{success:!1,error:r.message}))};function M(){const{code:s}=u(),[t,r]=i.useState(null),{t:n}=y(),o=async a=>{r(null),a.preventDefault();const l={},h=new FormData(a.target);for(var[p,f]of h.entries())l[p]=f;const{success:b,error:g}=await x.acceptInvite(s,l);if(b){const{valid:v,user:c,token:m,message:w}=await S.requestToken(l);v&&m&&c?(window.localStorage.setItem(A,JSON.stringify(c)),window.localStorage.setItem(I,m),window.location=T.home()):r(w);return}r(g)};return e.jsx("div",{className:"relative w-full max-w-2xl max-h-full",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.jsx("div",{className:"flex items-start justify-between p-4 border-b rounded-t border-theme-modal-border",children:e.jsx("h3",{className:"text-xl font-semibold text-theme-text-primary",children:"Create a new account"})}),e.jsxs("form",{onSubmit:o,children:[e.jsx("div",{className:"p-6 space-y-6 flex h-full w-full",children:e.jsxs("div",{className:"w-full flex flex-col gap-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"username",className:"block mb-2 text-sm font-medium text-theme-text-primary",children:"Username"}),e.jsx("input",{name:"username",type:"text",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",placeholder:"My username",minLength:j,maxLength:N,pattern:E,required:!0,autoComplete:"off"}),e.jsx("p",{className:"mt-2 text-xs text-theme-text-secondary",children:n("common.username_requirements")})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"password",className:"block mb-2 text-sm font-medium text-theme-text-primary",children:"Password"}),e.jsx("input",{name:"password",type:"password",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",placeholder:"Your password",required:!0,minLength:8,autoComplete:"off"})]}),t&&e.jsxs("p",{className:"text-red-400 text-sm",children:["Error: ",t]}),e.jsx("p",{className:"text-theme-text-secondary text-xs md:text-sm",children:"After creating your account you will be able to login with these credentials and start using workspaces."})]})}),e.jsx("div",{className:"flex w-full justify-between items-center p-6 space-x-2 border-t rounded-b border-theme-modal-border",children:e.jsx("button",{type:"submit",className:"w-full transition-all duration-300 border border-theme-text-primary px-4 py-2 rounded-lg text-theme-text-primary text-sm items-center flex gap-x-2 hover:bg-theme-text-primary hover:text-theme-bg-primary focus:ring-gray-800 text-center justify-center",children:"Accept Invitation"})})]})]})})}function R(){const{code:s}=u(),[t,r]=i.useState({status:"loading",message:null});return i.useEffect(()=>{async function n(){if(!s){r({status:"invalid",message:"No invite code provided."});return}const{invite:o,error:a}=await x.checkInvite(s);r({status:o?"valid":"invalid",message:a})}n()},[]),t.status==="loading"?e.jsx("div",{className:"w-screen h-screen overflow-hidden bg-theme-bg-container flex",children:e.jsx(k,{})}):t.status==="invalid"?e.jsx("div",{className:"w-screen h-screen overflow-hidden bg-theme-bg-container flex items-center justify-center",children:e.jsx("p",{className:"text-red-400 text-lg",children:t.message})}):e.jsx("div",{className:"w-screen h-screen overflow-hidden bg-theme-bg-container flex items-center justify-center",children:e.jsx(_,{isOpen:!0,children:e.jsx(M,{})})})}export{R as default};
@@ -1,4 +1,4 @@
1
- import{r as n,j as e,p as h,a$ as b,aU as f,u as w,k as g,q as j,$ as N,i as y,C as v,b0 as k,M as C,S,t as W}from"../index.js";import{A as d}from"./admin-04b020fe.js";function A({workspace:t,users:a,deletionProtected:s=!1}){var l;const r=n.useRef(null),c=async()=>{var o;if(!window.confirm(`Are you sure you want to delete ${t.name}?
1
+ import{r as n,j as e,p as h,b1 as b,aW as f,u as w,k as g,q as j,a1 as N,i as y,C as v,b2 as k,M as C,S as W,t as S}from"../index.js";import{A as d}from"./admin-04b020fe.js";function A({workspace:t,users:a,deletionProtected:s=!1}){var l;const r=n.useRef(null),c=async()=>{var o;if(!window.confirm(`Are you sure you want to delete ${t.name}?
2
2
  After you do this it will be unavailable in this instance of AnythingLLM.
3
3
 
4
- This action is irreversible.`))return!1;(o=r==null?void 0:r.current)==null||o.remove(),await d.deleteWorkspace(t.id)};return e.jsx(e.Fragment,{children:e.jsxs("tr",{ref:r,className:"bg-transparent text-white text-opacity-80 text-xs font-medium border-b border-white/10 h-10",children:[e.jsx("th",{scope:"row",className:"px-6 whitespace-nowrap",children:t.name}),e.jsx("td",{className:"px-6",children:e.jsxs("a",{href:h.workspace.chat(t.slug),target:"_blank",rel:"noreferrer",className:"text-white flex items-center hover:underline",children:[e.jsx(b,{className:"mr-2 w-4 h-4"})," ",t.slug]})}),e.jsx("td",{className:"px-6",children:e.jsx("a",{href:h.workspace.settings.members(t.slug),className:"text-white flex items-center underline",children:(l=t.userIds)==null?void 0:l.length})}),e.jsx("td",{className:"px-6",children:t.createdAt}),e.jsx("td",{className:"px-6",children:!s&&e.jsx("button",{onClick:c,className:"text-xs font-medium text-white/80 light:text-black/80 hover:light:text-red-500 hover:text-red-300 rounded-lg px-2 py-1 hover:bg-white hover:light:bg-red-50 hover:bg-opacity-10",children:e.jsx(f,{className:"h-5 w-5"})})})]})})}function M({closeModal:t}){const[a,s]=n.useState(null),{t:r}=w(),c=async l=>{s(null),l.preventDefault();const o=new FormData(l.target),{workspace:x,error:i}=await d.newWorkspace(o.get("name"));x&&window.location.reload(),s(i)};return 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.jsx("h3",{className:"text-xl font-semibold text-white overflow-hidden overflow-ellipsis whitespace-nowrap",children:"Create new workspace"})}),e.jsx("button",{onClick:t,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(g,{size:24,weight:"bold",className:"text-white"})})]}),e.jsx("div",{className:"p-6",children:e.jsxs("form",{onSubmit:c,children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"name",className:"block mb-2 text-sm font-medium text-white",children:r("common.workspaces-name")}),e.jsx("input",{name:"name",type:"text",className:"border-none bg-theme-settings-input-bg w-full 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",minLength:4,required:!0,autoComplete:"off"})]}),a&&e.jsxs("p",{className:"text-red-400 text-sm",children:["Error: ",a]}),e.jsx("p",{className:"text-white text-opacity-60 text-xs md:text-sm",children:"After creating this workspace only admins will be able to see it. You can add users after it has been created."})]}),e.jsxs("div",{className:"flex justify-between items-center mt-6 pt-6 border-t border-theme-modal-border",children:[e.jsx("button",{onClick:t,type:"button",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",className:"transition-all duration-300 bg-white text-black hover:opacity-60 px-4 py-2 rounded-lg text-sm",children:"Create workspace"})]})]})})]})})}function z(){const{isOpen:t,openModal:a,closeModal:s}=j();return e.jsxs("div",{className:"w-screen h-screen overflow-hidden bg-theme-bg-container flex",children:[e.jsx(N,{}),e.jsxs("div",{style:{height:y?"100%":"calc(100% - 32px)"},className:"relative md:ml-[2px] md:mr-[16px] md:my-[16px] md:rounded-[16px] bg-theme-bg-secondary w-full h-full overflow-y-scroll p-4 md:p-0",children:[e.jsxs("div",{className:"flex flex-col w-full px-1 md:pl-6 md:pr-[50px] md:py-6 py-16",children:[e.jsxs("div",{className:"w-full flex flex-col gap-y-1 pb-6 border-white/10 border-b-2",children:[e.jsx("div",{className:"items-center flex gap-x-4",children:e.jsx("p",{className:"text-lg leading-6 font-bold text-theme-text-primary",children:"Instance Workspaces"})}),e.jsx("p",{className:"text-xs leading-[18px] font-base text-theme-text-secondary",children:"These are all the workspaces that exist on this instance. Removing a workspace will delete all of its associated chats and settings."})]}),e.jsx("div",{className:"w-full justify-end flex",children:e.jsxs(v,{onClick:a,className:"mt-3 mr-0 mb-4 md:-mb-14 z-10",children:[e.jsx(k,{className:"h-4 w-4",weight:"bold"})," New Workspace"]})}),e.jsx("div",{className:"overflow-x-auto",children:e.jsx(D,{})})]}),e.jsx(C,{isOpen:t,children:e.jsx(M,{closeModal:s})})]})]})}function D(){const[t,a]=n.useState(!0),[s,r]=n.useState([]),[c,l]=n.useState([]),[o,x]=n.useState(!1);return n.useEffect(()=>{async function i(){const[p,u,m]=await Promise.all([d.users(),d.workspaces(),W.keys()]);r(p),l(u),x((m==null?void 0:m.WorkspaceDeletionProtection)===!0),a(!1)}i()},[]),t?e.jsx(S,{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("table",{className:"w-full text-xs text-left rounded-lg mt-6 min-w-[640px] border-spacing-0",children:[e.jsx("thead",{className:"text-theme-text-secondary text-xs leading-[18px] font-bold uppercase border-white/10 border-b",children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",className:"px-6 py-3 rounded-tl-lg",children:"Name"}),e.jsx("th",{scope:"col",className:"px-6 py-3",children:"Link"}),e.jsx("th",{scope:"col",className:"px-6 py-3",children:"Users"}),e.jsx("th",{scope:"col",className:"px-6 py-3",children:"Created On"}),e.jsx("th",{scope:"col",className:"px-6 py-3 rounded-tr-lg",children:" "})]})}),e.jsx("tbody",{children:c.map(i=>e.jsx(A,{workspace:i,users:s,deletionProtected:o},i.id))})]})}export{z as default};
4
+ This action is irreversible.`))return!1;(o=r==null?void 0:r.current)==null||o.remove(),await d.deleteWorkspace(t.id)};return e.jsx(e.Fragment,{children:e.jsxs("tr",{ref:r,className:"bg-transparent text-white text-opacity-80 text-xs font-medium border-b border-white/10 h-10",children:[e.jsx("th",{scope:"row",className:"px-6 whitespace-nowrap",children:t.name}),e.jsx("td",{className:"px-6",children:e.jsxs("a",{href:h.workspace.chat(t.slug),target:"_blank",rel:"noreferrer",className:"text-white flex items-center hover:underline",children:[e.jsx(b,{className:"mr-2 w-4 h-4"})," ",t.slug]})}),e.jsx("td",{className:"px-6",children:e.jsx("a",{href:h.workspace.settings.members(t.slug),className:"text-white flex items-center underline",children:(l=t.userIds)==null?void 0:l.length})}),e.jsx("td",{className:"px-6",children:t.createdAt}),e.jsx("td",{className:"px-6",children:!s&&e.jsx("button",{onClick:c,className:"text-xs font-medium text-white/80 light:text-black/80 hover:light:text-red-500 hover:text-red-300 rounded-lg px-2 py-1 hover:bg-white hover:light:bg-red-50 hover:bg-opacity-10",children:e.jsx(f,{className:"h-5 w-5"})})})]})})}function M({closeModal:t}){const[a,s]=n.useState(null),{t:r}=w(),c=async l=>{s(null),l.preventDefault();const o=new FormData(l.target),{workspace:x,error:i}=await d.newWorkspace(o.get("name"));x&&window.location.reload(),s(i)};return 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.jsx("h3",{className:"text-xl font-semibold text-white overflow-hidden overflow-ellipsis whitespace-nowrap",children:"Create new workspace"})}),e.jsx("button",{onClick:t,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(g,{size:24,weight:"bold",className:"text-white"})})]}),e.jsx("div",{className:"p-6",children:e.jsxs("form",{onSubmit:c,children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"name",className:"block mb-2 text-sm font-medium text-white",children:r("common.workspaces-name")}),e.jsx("input",{name:"name",type:"text",className:"border-none bg-theme-settings-input-bg w-full 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",minLength:4,required:!0,autoComplete:"off"})]}),a&&e.jsxs("p",{className:"text-red-400 text-sm",children:["Error: ",a]}),e.jsx("p",{className:"text-white text-opacity-60 text-xs md:text-sm",children:"After creating this workspace only admins will be able to see it. You can add users after it has been created."})]}),e.jsxs("div",{className:"flex justify-between items-center mt-6 pt-6 border-t border-theme-modal-border",children:[e.jsx("button",{onClick:t,type:"button",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",className:"transition-all duration-300 bg-white text-black hover:opacity-60 px-4 py-2 rounded-lg text-sm",children:"Create workspace"})]})]})})]})})}function z(){const{isOpen:t,openModal:a,closeModal:s}=j();return e.jsxs("div",{className:"w-screen h-screen overflow-hidden bg-theme-bg-container flex",children:[e.jsx(N,{}),e.jsxs("div",{style:{height:y?"100%":"calc(100% - 32px)"},className:"relative md:ml-[2px] md:mr-[16px] md:my-[16px] md:rounded-[16px] bg-theme-bg-secondary w-full h-full overflow-y-scroll p-4 md:p-0",children:[e.jsxs("div",{className:"flex flex-col w-full px-1 md:pl-6 md:pr-[50px] md:py-6 py-16",children:[e.jsxs("div",{className:"w-full flex flex-col gap-y-1 pb-6 border-white/10 border-b-2",children:[e.jsx("div",{className:"items-center flex gap-x-4",children:e.jsx("p",{className:"text-lg leading-6 font-bold text-theme-text-primary",children:"Instance Workspaces"})}),e.jsx("p",{className:"text-xs leading-[18px] font-base text-theme-text-secondary",children:"These are all the workspaces that exist on this instance. Removing a workspace will delete all of its associated chats and settings."})]}),e.jsx("div",{className:"w-full justify-end flex",children:e.jsxs(v,{onClick:a,className:"mt-3 mr-0 mb-4 md:-mb-14 z-10",children:[e.jsx(k,{className:"h-4 w-4",weight:"bold"})," New Workspace"]})}),e.jsx("div",{className:"overflow-x-auto",children:e.jsx(D,{})})]}),e.jsx(C,{isOpen:t,children:e.jsx(M,{closeModal:s})})]})]})}function D(){const[t,a]=n.useState(!0),[s,r]=n.useState([]),[c,l]=n.useState([]),[o,x]=n.useState(!1);return n.useEffect(()=>{async function i(){const[p,u,m]=await Promise.all([d.users(),d.workspaces(),S.keys()]);r(p),l(u),x((m==null?void 0:m.WorkspaceDeletionProtection)===!0),a(!1)}i()},[]),t?e.jsx(W,{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("table",{className:"w-full text-xs text-left rounded-lg mt-6 min-w-[640px] border-spacing-0",children:[e.jsx("thead",{className:"text-theme-text-secondary text-xs leading-[18px] font-bold uppercase border-white/10 border-b",children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",className:"px-6 py-3 rounded-tl-lg",children:"Name"}),e.jsx("th",{scope:"col",className:"px-6 py-3",children:"Link"}),e.jsx("th",{scope:"col",className:"px-6 py-3",children:"Users"}),e.jsx("th",{scope:"col",className:"px-6 py-3",children:"Created On"}),e.jsx("th",{scope:"col",className:"px-6 py-3 rounded-tr-lg",children:" "})]})}),e.jsx("tbody",{children:c.map(i=>e.jsx(A,{workspace:i,users:s,deletionProtected:o},i.id))})]})}export{z as default};
@@ -0,0 +1 @@
1
+ import{R as x,r as o,g as q,j as e,C as F,K as Z,k as K,a2 as D,N as R,J as B,t as k,c as N,a4 as U,Q as _,a5 as H,a3 as Q,a1 as G,i as V,h as X}from"../index.js";import{P as T,C as Y}from"./index-8ba96f42.js";const J=new Map([["bold",x.createElement(x.Fragment,null,x.createElement("path",{d:"M176,128a12,12,0,0,1-5.17,9.87l-52,36A12,12,0,0,1,100,164V92a12,12,0,0,1,18.83-9.87l52,36A12,12,0,0,1,176,128Zm60,0A108,108,0,1,1,128,20,108.12,108.12,0,0,1,236,128Zm-24,0a84,84,0,1,0-84,84A84.09,84.09,0,0,0,212,128Z"}))],["duotone",x.createElement(x.Fragment,null,x.createElement("path",{d:"M128,32a96,96,0,1,0,96,96A96,96,0,0,0,128,32ZM108,168V88l64,40Z",opacity:"0.2"}),x.createElement("path",{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm48.24-94.78-64-40A8,8,0,0,0,100,88v80a8,8,0,0,0,12.24,6.78l64-40a8,8,0,0,0,0-13.56ZM116,153.57V102.43L156.91,128Z"}))],["fill",x.createElement(x.Fragment,null,x.createElement("path",{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm40.55,110.58-52,36A8,8,0,0,1,104,164V92a8,8,0,0,1,12.55-6.58l52,36a8,8,0,0,1,0,13.16Z"}))],["light",x.createElement(x.Fragment,null,x.createElement("path",{d:"M128,26A102,102,0,1,0,230,128,102.12,102.12,0,0,0,128,26Zm0,192a90,90,0,1,1,90-90A90.1,90.1,0,0,1,128,218Zm47.18-95.09-64-40A6,6,0,0,0,102,88v80a6,6,0,0,0,9.18,5.09l64-40a6,6,0,0,0,0-10.18ZM114,157.17V98.83L160.68,128Z"}))],["regular",x.createElement(x.Fragment,null,x.createElement("path",{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm48.24-94.78-64-40A8,8,0,0,0,100,88v80a8,8,0,0,0,12.24,6.78l64-40a8,8,0,0,0,0-13.56ZM116,153.57V102.43L156.91,128Z"}))],["thin",x.createElement(x.Fragment,null,x.createElement("path",{d:"M128,28A100,100,0,1,0,228,128,100.11,100.11,0,0,0,128,28Zm0,192a92,92,0,1,1,92-92A92.1,92.1,0,0,1,128,220Zm46.12-95.39-64-40A4,4,0,0,0,104,88v80a4,4,0,0,0,2.06,3.5,4.06,4.06,0,0,0,1.94.5,4,4,0,0,0,2.12-.61l64-40a4,4,0,0,0,0-6.78ZM112,160.78V95.22L164.45,128Z"}))]]);var W=Object.defineProperty,ee=Object.defineProperties,te=Object.getOwnPropertyDescriptors,I=Object.getOwnPropertySymbols,le=Object.prototype.hasOwnProperty,se=Object.prototype.propertyIsEnumerable,z=(t,l,a)=>l in t?W(t,l,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[l]=a,ae=(t,l)=>{for(var a in l||(l={}))le.call(l,a)&&z(t,a,l[a]);if(I)for(var a of I(l))se.call(l,a)&&z(t,a,l[a]);return t},oe=(t,l)=>ee(t,te(l));const $=o.forwardRef((t,l)=>x.createElement(q,oe(ae({ref:l},t),{weights:J})));$.displayName="PlayCircle";function ne(){return e.jsx("div",{className:"w-full h-10 items-center flex",children:e.jsx("p",{className:"text-sm font-base text-white text-opacity-60",children:"There is no configuration needed for this provider."})})}const O=[{name:"System native",value:"native",logo:B,options:t=>e.jsx(ne,{settings:t}),description:"Uses your browser's built in STT service if supported."}];function re({settings:t}){var g;const[l,a]=o.useState(!1),[d,n]=o.useState(!1),[r,m]=o.useState(""),[u,i]=o.useState([]),[c,p]=o.useState((t==null?void 0:t.SpeechToTextProvider)||"native"),[f,h]=o.useState(!1),b=o.useRef(null),S=async s=>{s.preventDefault();const y=s.target,j={SpeechToTextProvider:c},P=new FormData(y);for(var[M,L]of P.entries())j[M]=L;const{error:w}=await k.updateSystem(j);a(!0),w?N(`Failed to save preferences: ${w}`,"error"):N("Speech-to-text preferences saved successfully.","success"),a(!1),n(!!w)},C=s=>{m(""),p(s),h(!1),n(!0)},A=()=>{r.length>0?(m(""),b.current&&(b.current.value="")):h(!f)};o.useEffect(()=>{const s=O.filter(y=>y.name.toLowerCase().includes(r.toLowerCase()));i(s)},[r,c]);const v=O.find(s=>s.value===c);return e.jsx("form",{onSubmit:S,className:"flex w-full",children:e.jsxs("div",{className:"flex flex-col w-full px-1 md:pl-6 md:pr-[50px] 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:"flex gap-x-4 items-center",children:e.jsx("p",{className:"text-lg leading-6 font-bold text-white",children:"Speech-to-text Preference"})}),e.jsx("p",{className:"text-xs leading-[18px] font-base text-white text-opacity-60",children:"Here you can specify what kind of text-to-speech and speech-to-text providers you would want to use in your AnythingLLM experience. By default, we use the browser's built in support for these services, but you may want to use others."})]}),e.jsx("div",{className:"w-full justify-end flex",children:d&&e.jsx(F,{onClick:()=>S(),className:"mt-3 mr-0 -mb-14 z-10",children:l?"Saving...":"Save changes"})}),e.jsx("div",{className:"text-base font-bold text-white mt-6 mb-4",children:"Provider"}),e.jsxs("div",{className:"relative",children:[f&&e.jsx("div",{className:"fixed top-0 left-0 w-full h-full bg-black bg-opacity-70 backdrop-blur-sm z-10",onClick:()=>h(!1)}),f?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(Z,{size:20,weight:"bold",className:"absolute left-4 z-30 text-theme-text-primary -ml-4 my-2"}),e.jsx("input",{type:"text",name:"stt-provider-search",autoComplete:"off",placeholder:"Search speech to text 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:s=>m(s.target.value),ref:b,onKeyDown:s=>{s.key==="Enter"&&s.preventDefault()}}),e.jsx(K,{size:20,weight:"bold",className:"cursor-pointer text-white hover:text-x-button",onClick:A})]}),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:u.map(s=>e.jsx(D,{name:s.name,value:s.value,image:s.logo,description:s.description,checked:c===s.value,onClick:()=>C(s.value)},s.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:()=>h(!0),children:[e.jsxs("div",{className:"flex gap-x-4 items-center",children:[e.jsx("img",{src:v.logo,alt:`${v.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:v.name}),e.jsx("div",{className:"mt-1 text-xs text-description",children:v.description})]})]}),e.jsx(R,{size:24,weight:"bold",className:"text-white"})]})]}),e.jsx("div",{onChange:()=>n(!0),className:"mt-4 flex flex-col gap-y-1",children:c&&((g=O.find(s=>s.value===c))==null?void 0:g.options(t))})]})})}const ie="/elevenlabs.png",ce="/piper.png",de="/generic-openai.png";function ue(){return e.jsx("div",{className:"w-full h-10 items-center flex",children:e.jsx("p",{className:"text-sm font-base text-white text-opacity-60",children:"There is no configuration needed for this provider."})})}function me(t){return t.replace(/\w\S*/g,function(l){return l.charAt(0).toUpperCase()+l.substr(1).toLowerCase()})}function xe({settings:t}){const l=t==null?void 0:t.TTSOpenAIKey;return e.jsxs("div",{className:"flex gap-x-4",children:[e.jsxs("div",{className:"flex flex-col w-60",children:[e.jsx("label",{className:"text-white text-sm font-semibold block mb-3",children:"API Key"}),e.jsx("input",{type:"password",name:"TTSOpenAIKey",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:"OpenAI API Key",defaultValue:l?"*".repeat(20):"",required:!0,autoComplete:"off",spellCheck:!1})]}),e.jsxs("div",{className:"flex flex-col w-60",children:[e.jsx("label",{className:"text-white text-sm font-semibold block mb-3",children:"Voice Model"}),e.jsx("select",{name:"TTSOpenAIVoiceModel",defaultValue:(t==null?void 0:t.TTSOpenAIVoiceModel)??"alloy",className:"border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5",children:["alloy","echo","fable","onyx","nova","shimmer"].map(a=>e.jsx("option",{value:a,children:me(a)},a))})]})]})}function pe({settings:t}){const[l,a]=o.useState(t==null?void 0:t.TTSElevenLabsKey),[d,n]=o.useState(t==null?void 0:t.TTSElevenLabsKey);return e.jsxs("div",{className:"flex gap-x-4",children:[e.jsxs("div",{className:"flex flex-col w-60",children:[e.jsx("label",{className:"text-white text-sm font-semibold block mb-3",children:"API Key"}),e.jsx("input",{type:"password",name:"TTSElevenLabsKey",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:"ElevenLabs API Key",defaultValue:t!=null&&t.TTSElevenLabsKey?"*".repeat(20):"",required:!0,autoComplete:"off",spellCheck:!1,onChange:r=>a(r.target.value),onBlur:()=>n(l)})]}),!(t!=null&&t.credentialsOnly)&&e.jsx(he,{settings:t,apiKey:d})]})}function he({apiKey:t,settings:l}){const[a,d]=o.useState({}),[n,r]=o.useState(!0);return o.useEffect(()=>{async function m(){r(!0);const{models:u}=await k.customModels("elevenlabs-tts",typeof t=="boolean"?null:t);if((u==null?void 0:u.length)>0){const i=u.reduce((c,p)=>(c[p.organization]=c[p.organization]||[],c[p.organization].push(p),c),{});d(i)}r(!1)}m()},[t]),n?e.jsxs("div",{className:"flex flex-col w-60",children:[e.jsx("label",{className:"text-white text-sm font-semibold block mb-3",children:"Chat Model Selection"}),e.jsx("select",{name:"TTSElevenLabsVoiceModel",disabled:!0,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("option",{disabled:!0,selected:!0,children:"-- loading available models --"})})]}):e.jsxs("div",{className:"flex flex-col w-60",children:[e.jsx("label",{className:"text-white text-sm font-semibold block mb-3",children:"Chat Model Selection"}),e.jsx("select",{name:"TTSElevenLabsVoiceModel",required:!0,className:"border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5",children:Object.keys(a).sort().map(m=>e.jsx("optgroup",{label:m,children:a[m].map(u=>e.jsx("option",{value:u.id,selected:u.id===(l==null?void 0:l.TTSElevenLabsVoiceModel),children:u.name},u.id))},m))})]})}function fe({settings:t}){return e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm font-base text-white text-opacity-60 mb-4",children:"All PiperTTS models will run in your browser locally. This can be resource intensive on lower-end devices."}),e.jsx("div",{className:"flex gap-x-4 items-center",children:e.jsx(ye,{settings:t})})]})}function be(t=[]){const l=t.reduce((a,d)=>{var r;const n=((r=d==null?void 0:d.language)==null?void 0:r.name_english)??"Unlisted";return a[n]=a[n]||[],a[n].push(d),a},{});return Object.entries(l)}function ve(t){var u;const{is_stored:l,name:a,quality:d,files:n}=t,r=Object.keys(n).find(i=>i.endsWith(".onnx")),m=((u=n==null?void 0:n[r])==null?void 0:u.size_bytes)||0;return`${l?"✔ ":""}${_(a)}-${d==="low"?"Low":"HQ"} (${H(m)})`}function ye({settings:t}){const[l,a]=o.useState(!0),[d,n]=o.useState([]),[r,m]=o.useState(t==null?void 0:t.TTSPiperTTSVoiceModel);function u(){T.flush().then(()=>N("All voices flushed from browser storage","info",{clear:!0})).catch(i=>console.error(i))}return o.useEffect(()=>{T.voices().then(i=>{if((i==null?void 0:i.length)!==0)return n(i);throw new Error("Could not fetch voices from web worker.")}).catch(i=>{console.error(i)}).finally(()=>a(!1))},[]),l?e.jsxs("div",{className:"flex flex-col w-60",children:[e.jsx("label",{className:"text-white text-sm font-semibold block mb-3",children:"Voice Model Selection"}),e.jsx("select",{name:"TTSPiperTTSVoiceModel",value:"",disabled:!0,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("option",{value:"",disabled:!0,children:"-- loading available models --"})})]}):e.jsxs("div",{className:"flex flex-col w-fit",children:[e.jsxs("div",{className:"flex flex-col w-60",children:[e.jsx("label",{className:"text-white text-sm font-semibold block mb-3",children:"Voice Model Selection"}),e.jsxs("div",{className:"flex items-center w-fit gap-x-4 mb-2",children:[e.jsx("select",{name:"TTSPiperTTSVoiceModel",required:!0,onChange:i=>m(i.target.value),value:r,className:"border-none flex-shrink-0 bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5",children:be(d).map(([i,c])=>e.jsx("optgroup",{label:i,children:c.map(p=>e.jsx("option",{value:p.key,children:ve(p)},p.key))},i))}),e.jsx(we,{voiceId:r})]}),e.jsx("p",{className:"text-xs text-white/40",children:'The "✔" indicates this model is already stored locally and does not need to be downloaded when run.'})]}),!!d.find(i=>i.is_stored)&&e.jsx("button",{type:"button",onClick:u,className:"w-fit border-none hover:text-white hover:underline text-white/40 text-sm my-4",children:"Flush voice cache"})]})}function we({voiceId:t}){const l=o.useRef(null),[a,d]=o.useState(!1),[n,r]=o.useState(!1),[m,u]=o.useState(null);async function i(c){var p,f;if(c.preventDefault(),a){(p=l==null?void 0:l.current)==null||p.pause();return}try{if(m)l.current.play();else{r(!0);const h=new T({voiceId:t}),b=await h.getAudioBlobForText("Hello, welcome to AnythingLLM!");u(b),r(!1),(f=h.worker)==null||f.terminate(),T._instance=null}}catch(h){console.error(h),r(!1),d(!1)}}return o.useEffect(()=>{function c(){l!=null&&l.current&&(l.current.addEventListener("play",()=>{d(!0)}),l.current.addEventListener("pause",()=>{l.current.currentTime=0,d(!1),u(null)}))}c()},[]),e.jsxs("button",{type:"button",onClick:i,disabled:n,className:"border-none text-zinc-300 flex items-center gap-x-1",children:[a?e.jsxs(e.Fragment,{children:[e.jsx(Y,{size:20,className:"flex-shrink-0"}),e.jsx("p",{className:"text-sm flex-shrink-0",children:"Stop demo"})]}):e.jsx(e.Fragment,{children:n?e.jsxs(e.Fragment,{children:[e.jsx(U,{size:20,className:"animate-spin flex-shrink-0"}),e.jsx("p",{className:"text-sm flex-shrink-0",children:"Loading voice"})]}):e.jsxs(e.Fragment,{children:[e.jsx($,{size:20,className:"flex-shrink-0 text-white"}),e.jsx("p",{className:"text-white text-sm flex-shrink-0",children:"Play sample"})]})}),e.jsx("audio",{ref:l,hidden:!0,src:m,autoPlay:!0,controls:!1})]})}function ge({settings:t}){return e.jsxs("div",{className:"w-full flex flex-col gap-y-7",children:[e.jsxs("div",{className:"flex gap-x-4",children:[e.jsxs("div",{className:"flex flex-col w-60",children:[e.jsx("div",{className:"flex justify-between items-start mb-2",children:e.jsx("label",{className:"text-white text-sm font-semibold",children:"Base URL"})}),e.jsx("input",{type:"url",name:"TTSOpenAICompatibleEndpoint",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:"http://localhost:7851/v1",defaultValue:t==null?void 0:t.TTSOpenAICompatibleEndpoint,required:!1,autoComplete:"off",spellCheck:!1}),e.jsx("p",{className:"text-xs leading-[18px] font-base text-white text-opacity-60 mt-2",children:"This should be the base URL of the OpenAI compatible TTS service you will generate TTS responses from."})]}),e.jsxs("div",{className:"flex flex-col w-60",children:[e.jsx("label",{className:"text-white text-sm font-semibold block mb-2",children:"API Key"}),e.jsx("input",{type:"password",name:"TTSOpenAICompatibleKey",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:"API Key",defaultValue:t!=null&&t.TTSOpenAICompatibleKey?"*".repeat(20):"",autoComplete:"off",spellCheck:!1}),e.jsx("p",{className:"text-xs leading-[18px] font-base text-white text-opacity-60 mt-2",children:"Some TTS services require an API key to generate TTS responses - this is optional if your service does not require one."})]})]}),e.jsxs("div",{className:"flex gap-x-4",children:[e.jsxs("div",{className:"flex flex-col w-60",children:[e.jsx("label",{className:"text-white text-sm font-semibold block mb-3",children:"TTS Model"}),e.jsx("input",{type:"text",name:"TTSOpenAICompatibleModel",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:"Your TTS model identifier",defaultValue:t==null?void 0:t.TTSOpenAICompatibleModel,required:!0,autoComplete:"off",spellCheck:!1}),e.jsxs("p",{className:"text-xs leading-[18px] font-base text-white text-opacity-60 mt-2",children:["Most TTS services will have several models available. This is the"," ",e.jsx("code",{children:"model"})," parameter you will use to select the model you want to use. Note: This is not the same as the voice model."]})]}),e.jsxs("div",{className:"flex flex-col w-60",children:[e.jsx("label",{className:"text-white text-sm font-semibold block mb-3",children:"Voice Model"}),e.jsx("input",{type:"text",name:"TTSOpenAICompatibleVoiceModel",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:"Your voice model identifier",defaultValue:t==null?void 0:t.TTSOpenAICompatibleVoiceModel,required:!0,autoComplete:"off",spellCheck:!1}),e.jsx("p",{className:"text-xs leading-[18px] font-base text-white text-opacity-60 mt-2",children:"Most TTS services will have several voice models available, this is the identifier for the voice model you want to use."})]})]})]})}const E=[{name:"System native",value:"native",logo:B,options:t=>e.jsx(ue,{settings:t}),description:"Uses your browser's built in TTS service if supported."},{name:"OpenAI",value:"openai",logo:Q,options:t=>e.jsx(xe,{settings:t}),description:"Use OpenAI's text to speech voices."},{name:"ElevenLabs",value:"elevenlabs",logo:ie,options:t=>e.jsx(pe,{settings:t}),description:"Use ElevenLabs's text to speech voices and technology."},{name:"PiperTTS",value:"piper_local",logo:ce,options:t=>e.jsx(fe,{settings:t}),description:"Run TTS models locally in your browser privately."},{name:"OpenAI Compatible",value:"generic-openai",logo:de,options:t=>e.jsx(ge,{settings:t}),description:"Connect to an OpenAI compatible TTS service running locally or remotely."}];function je({settings:t}){var g;const[l,a]=o.useState(!1),[d,n]=o.useState(!1),[r,m]=o.useState(""),[u,i]=o.useState([]),[c,p]=o.useState((t==null?void 0:t.TextToSpeechProvider)||"native"),[f,h]=o.useState(!1),b=o.useRef(null),S=async s=>{s==null||s.preventDefault();const y=s.target,j={TextToSpeechProvider:c},P=new FormData(y);for(var[M,L]of P.entries())j[M]=L;const{error:w}=await k.updateSystem(j);a(!0),w?N(`Failed to save preferences: ${w}`,"error"):N("Text-to-speech preferences saved successfully.","success"),a(!1),n(!!w)},C=s=>{m(""),p(s),h(!1),n(!0)},A=()=>{r.length>0?(m(""),b.current&&(b.current.value="")):h(!f)};o.useEffect(()=>{const s=E.filter(y=>y.name.toLowerCase().includes(r.toLowerCase()));i(s)},[r,c]);const v=E.find(s=>s.value===c);return e.jsx("form",{onSubmit:S,className:"flex w-full",children:e.jsxs("div",{className:"flex flex-col w-full px-1 md:pl-6 md:pr-[50px] 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:"flex gap-x-4 items-center",children:e.jsx("p",{className:"text-lg leading-6 font-bold text-white",children:"Text-to-speech Preference"})}),e.jsx("p",{className:"text-xs leading-[18px] font-base text-white text-opacity-60",children:"Here you can specify what kind of text-to-speech providers you would want to use in your AnythingLLM experience. By default, we use the browser's built in support for these services, but you may want to use others."})]}),e.jsx("div",{className:"w-full justify-end flex",children:d&&e.jsx(F,{className:"mt-3 mr-0 -mb-14 z-10",children:l?"Saving...":"Save changes"})}),e.jsx("div",{className:"text-base font-bold text-white mt-6 mb-4",children:"Provider"}),e.jsxs("div",{className:"relative",children:[f&&e.jsx("div",{className:"fixed top-0 left-0 w-full h-full bg-black bg-opacity-70 backdrop-blur-sm z-10",onClick:()=>h(!1)}),f?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(Z,{size:20,weight:"bold",className:"absolute left-4 z-30 text-theme-text-primary -ml-4 my-2"}),e.jsx("input",{type:"text",name:"tts-provider-search",autoComplete:"off",placeholder:"Search text to speech 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:s=>m(s.target.value),ref:b,onKeyDown:s=>{s.key==="Enter"&&s.preventDefault()}}),e.jsx(K,{size:20,weight:"bold",className:"cursor-pointer text-white hover:text-x-button",onClick:A})]}),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:u.map(s=>e.jsx(D,{name:s.name,value:s.value,image:s.logo,description:s.description,checked:c===s.value,onClick:()=>C(s.value)},s.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:()=>h(!0),children:[e.jsxs("div",{className:"flex gap-x-4 items-center",children:[e.jsx("img",{src:v.logo,alt:`${v.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:v.name}),e.jsx("div",{className:"mt-1 text-xs text-description",children:v.description})]})]}),e.jsx(R,{size:24,weight:"bold",className:"text-white"})]})]}),e.jsx("div",{onChange:()=>n(!0),className:"mt-4 flex flex-col gap-y-1",children:c&&((g=E.find(s=>s.value===c))==null?void 0:g.options(t))})]})})}function Te(){const[t,l]=o.useState(null),[a,d]=o.useState(!0);return o.useEffect(()=>{async function n(){const r=await k.keys();l(r),d(!1)}n()},[]),e.jsxs("div",{className:"w-screen h-screen overflow-hidden bg-theme-bg-container flex",children:[e.jsx(G,{}),a?e.jsx("div",{style:{height:V?"100%":"calc(100% - 32px)"},className:"relative md:ml-[2px] md:mr-[16px] md:my-[16px] md:rounded-[16px] bg-theme-bg-secondary w-full h-full overflow-y-scroll p-4 md:p-0",children:e.jsx("div",{className:"w-full h-full flex justify-center items-center",children:e.jsx(X,{})})}):e.jsxs("div",{style:{height:V?"100%":"calc(100% - 32px)"},className:"relative md:ml-[2px] md:mr-[16px] md:my-[16px] md:rounded-[16px] bg-theme-bg-secondary w-full h-full overflow-y-scroll p-4 md:p-0",children:[e.jsx(re,{settings:t}),e.jsx(je,{settings:t})]})]})}export{Te as default};
@@ -0,0 +1 @@
1
+ import{r as d,j as e,p as g,e as w,a1 as v,i as N,a6 as C,c as h}from"../index.js";import{C as f}from"./communityHub-aba61686.js";import{C as L}from"./index-efee6d1f.js";import{a as A,r as p,b}from"./index-b49f94f1.js";import"./Eye-9f033dc0.js";import"./truncate-06273256.js";const H={createdByMe:{agentSkills:{items:[]},systemPrompts:{items:[]},slashCommands:{items:[]},agentFlows:{items:[]}},teamItems:[]};function I({connectionKey:i}){const[r,c]=d.useState(!0),[n,o]=d.useState(H);return d.useEffect(()=>{(async()=>{if(console.log("fetching user items",i),!!i){c(!0);try{const{success:s,createdByMe:t,teamItems:a}=await f.fetchUserItems();s&&o({createdByMe:t,teamItems:a})}catch(s){console.error("Error fetching user items:",s)}finally{c(!1)}}})()},[i]),{loading:r,userItems:n}}function M({connectionKey:i}){const{loading:r,userItems:c}=I({connectionKey:i}),{createdByMe:n={},teamItems:o=[]}=c||{};if(r)return e.jsx(A,{});const l=s=>Object.values(s).some(t=>{var a;return((a=t==null?void 0:t.items)==null?void 0:a.length)>0});return e.jsxs("div",{className:"flex flex-col gap-y-8",children:[e.jsxs("div",{className:"w-full flex flex-col gap-y-1 pb-6 border-white border-b-2 border-opacity-10",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-lg leading-6 font-bold text-white",children:"Created by me"}),e.jsx("a",{href:g.communityHub.noPrivateItems(),target:"_blank",rel:"noreferrer",className:"text-primary-button hover:text-primary-button/80 text-sm",children:"Why can't I see my private items?"})]}),e.jsx("p",{className:"text-xs leading-[18px] font-base text-white text-opacity-60",children:"Items you have created and shared publicly on the AnythingLLM Community Hub."}),e.jsxs("div",{className:"flex flex-col gap-4 mt-4",children:[Object.keys(n).map(s=>{var t,a;return(a=(t=n[s])==null?void 0:t.items)!=null&&a.length?e.jsxs("div",{className:"rounded-lg w-full",children:[e.jsx("h3",{className:"text-white capitalize font-medium mb-3",children:p(s)}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-2",children:n[s].items.map(u=>e.jsx(b,{type:s,item:u},u.id))})]},s):null}),!l(n)&&e.jsx("p",{className:"text-white/60 text-xs text-center mt-4",children:"You haven't created any items yet."})]})]}),e.jsxs("div",{className:"w-full flex flex-col gap-y-1 pb-6 border-white border-b-2 border-opacity-10",children:[e.jsx("div",{className:"items-center",children:e.jsx("p",{className:"text-lg leading-6 font-bold text-white",children:"Items by team"})}),e.jsx("p",{className:"text-xs leading-[18px] font-base text-white text-opacity-60",children:"Public and private items shared with teams you belong to."}),e.jsx("div",{className:"flex flex-col gap-4 mt-4",children:o.map(s=>e.jsxs("div",{className:"flex flex-col gap-y-4",children:[e.jsx("h3",{className:"text-white text-sm font-medium",children:s.teamName}),Object.keys(s.items).map(t=>{var a,u;return(u=(a=s.items[t])==null?void 0:a.items)!=null&&u.length?e.jsxs("div",{className:"rounded-lg w-full",children:[e.jsx("h3",{className:"text-white capitalize font-medium mb-3",children:p(t)}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-2",children:s.items[t].items.map(y=>e.jsx(b,{type:t,item:y},y.id))})]},t):null}),!l(s.items)&&e.jsx("p",{className:"text-white/60 text-xs text-center mt-4",children:"No items shared with this team yet."})]},s.teamId))})]})]})}function S(){const[i,r]=d.useState(""),[c,n]=d.useState(!1),[o,l]=d.useState(""),[s,t]=d.useState(!0);async function a(){l(i),n(!1)}async function u(m){const x=m.target.value;l(x),n(!0)}async function y(){if(o!==i){t(!0);try{if(!(await f.updateSettings({hub_api_key:o})).success)return h("Failed to save API key","error");n(!1),h("API key saved successfully","success"),r(o)}catch(m){console.error(m),h("Failed to save API key","error")}finally{t(!1)}}}async function j(){t(!0);try{if(!(await f.updateSettings({hub_api_key:""})).success)return h("Failed to disconnect from hub","error");n(!1),h("Disconnected from AnythingLLM Community Hub","success"),r(""),l("")}catch(m){console.error(m),h("Failed to disconnect from hub","error")}finally{t(!1)}}return d.useEffect(()=>{(async()=>{t(!0);try{const{connectionKey:x}=await f.getSettings();r(x||""),l(x||"")}catch(x){console.error("Error fetching data:",x)}finally{t(!1)}})()},[]),{connectionKey:o,originalConnectionKey:i,loading:s,onConnectionKeyChange:u,updateConnectionKey:y,hasChanges:c,resetChanges:a,disconnectHub:j}}function F(){const{connectionKey:i,originalConnectionKey:r,loading:c,onConnectionKeyChange:n,updateConnectionKey:o,hasChanges:l,resetChanges:s,disconnectHub:t}=S();return c?e.jsx(w,{}):e.jsxs("div",{className:"w-screen h-screen overflow-hidden bg-theme-bg-container flex",children:[e.jsx(v,{}),e.jsx(L,{showing:l,onSave:o,onCancel:s}),e.jsx("div",{style:{height:N?"100%":"calc(100% - 32px)"},className:"relative md:ml-[2px] md:mr-[16px] md:my-[16px] md:rounded-[16px] bg-theme-bg-secondary w-full h-full overflow-y-scroll p-4 md:p-0",children:e.jsxs("div",{className:"flex flex-col w-full px-1 md:pl-6 md:pr-[86px] md:py-6 py-16",children:[e.jsxs("div",{className:"w-full flex flex-col gap-y-1 pb-6 border-white light:border-theme-sidebar-border border-b-2 border-opacity-10",children:[e.jsx("div",{className:"items-center",children:e.jsx("p",{className:"text-lg leading-6 font-bold text-theme-text-primary",children:"Your AnythingLLM Community Hub Account"})}),e.jsxs("p",{className:"text-xs leading-[18px] font-base text-theme-text-secondary",children:["Connecting your AnythingLLM Community Hub account allows you to access your ",e.jsx("b",{children:"private"})," AnythingLLM Community Hub items as well as upload your own items to the AnythingLLM Community Hub."]})]}),!i&&e.jsx("div",{className:"border border-theme-border my-2 flex flex-col md:flex-row md:items-center gap-x-2 text-theme-text-primary mb-4 bg-theme-settings-input-bg w-1/2 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(C,{size:25}),e.jsx("h1",{className:"text-lg font-semibold",children:"Why connect my AnythingLLM Community Hub account?"})]}),e.jsxs("p",{className:"text-sm text-theme-text-secondary",children:["Connecting your AnythingLLM Community Hub account allows you to pull in your ",e.jsx("b",{children:"private"})," items from the AnythingLLM Community Hub as well as upload your own items to the AnythingLLM Community Hub.",e.jsx("br",{}),e.jsx("br",{}),e.jsx("i",{children:"You do not need to connect your AnythingLLM Community Hub account to pull in public items from the AnythingLLM Community Hub."})]})]})}),e.jsx("div",{className:"mt-6 mb-12",children:e.jsxs("div",{className:"flex flex-col w-full max-w-[400px]",children:[e.jsx("label",{className:"text-theme-text-primary text-sm font-semibold block mb-2",children:"AnythingLLM Hub API Key"}),e.jsx("input",{type:"password",value:i||"",onChange:n,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",placeholder:"Enter your AnythingLLM Hub API key"}),e.jsxs("div",{className:"flex items-center justify-between mt-2",children:[e.jsxs("p",{className:"text-theme-text-secondary text-xs",children:["You can get your API key from your"," ",e.jsx("a",{href:g.communityHub.profile(),className:"underline text-primary-button",children:"AnythingLLM Community Hub profile page"}),"."]}),!!r&&e.jsx("button",{onClick:t,className:"border-none text-red-500 hover:text-red-600 text-sm font-medium transition-colors duration-200",children:"Disconnect"})]})]})}),!!r&&e.jsx("div",{className:"mt-6",children:e.jsx(M,{connectionKey:r})})]})})]})}export{F as default};
@@ -1,5 +1,5 @@
1
- import{j as e,r as d,a9 as D,q as j,s as v,aU as E,M as N,t as g,k as F,aJ as z,u as A,a_ as I,$ as J,i as H,aM as V,c as y,S as B}from"../index.js";import{t as C}from"./truncate-352eb33b.js";import{M as q,H as k,D as W}from"./purify-fbc9e8e2.js";import{I as Q}from"./github-dark-57c241de.js";const U=new q({html:!0,breaks:!0,highlight:function(t,s){if(s&&k.getLanguage(s))try{return k.highlight(t,{language:s}).value}catch{}return""}}),G=({thought:t})=>{const[s,r]=d.useState(!1);if(!t)return null;const a=t.replace(/<\/?think>/g,"").trim();return a?e.jsxs("div",{className:"mb-3",children:[e.jsxs("div",{onClick:()=>r(!s),className:"cursor-pointer flex items-center gap-x-2 text-theme-text-secondary hover:text-theme-text-primary transition-colors mb-2",children:[e.jsx(D,{size:14,weight:"bold",className:`transition-transform ${s?"rotate-180":""}`}),e.jsx("span",{className:"text-xs font-medium",children:"View thoughts"})]}),s&&e.jsx("div",{className:"bg-theme-bg-chat-input rounded-md p-3 border-l-2 border-theme-text-secondary/30",children:e.jsx("div",{className:"text-xs text-theme-text-secondary font-mono whitespace-pre-wrap",children:a})})]}):null};function K(t){const s=[];let r=0;return t.replace(/<think>([^]*?)<\/think>/g,(a,n,c)=>{c>r&&s.push({type:"normal",text:t.slice(r,c)}),s.push({type:"think",text:n}),r=c+a.length}),r<t.length&&s.push({type:"normal",text:t.slice(r)}),s}function X({content:t}){if(!t)return null;const s=K(t);return e.jsx("div",{className:"whitespace-normal",children:s.map((r,a)=>{const n=U.render(r.text);return r.type==="think"?e.jsx(G,{thought:r.text},a):e.jsx("div",{dangerouslySetInnerHTML:{__html:W.sanitize(n)}},a)})})}function Y({chat:t,onDelete:s}){var x,o,u,b;const{isOpen:r,openModal:a,closeModal:n}=j(),{isOpen:c,openModal:l,closeModal:p}=j(),m=async()=>{if(!window.confirm(`Are you sure you want to delete this chat?
1
+ import{j as e,r as d,ab as D,q as j,s as v,aW as E,M as N,t as g,k as F,aL as z,u as A,b0 as I,a1 as J,i as H,aO as V,c as y,S as B}from"../index.js";import{t as C}from"./truncate-06273256.js";import{M as W,H as k,D as q}from"./purify-eb750cf4.js";import{I as Q}from"./github-dark-57c241de.js";const G=new W({html:!0,breaks:!0,highlight:function(t,s){if(s&&k.getLanguage(s))try{return k.highlight(t,{language:s}).value}catch{}return""}}),K=({thought:t})=>{const[s,r]=d.useState(!1);if(!t)return null;const a=t.replace(/<\/?think>/g,"").trim();return a?e.jsxs("div",{className:"mb-3",children:[e.jsxs("div",{onClick:()=>r(!s),className:"cursor-pointer flex items-center gap-x-2 text-theme-text-secondary hover:text-theme-text-primary transition-colors mb-2",children:[e.jsx(D,{size:14,weight:"bold",className:`transition-transform ${s?"rotate-180":""}`}),e.jsx("span",{className:"text-xs font-medium",children:"View thoughts"})]}),s&&e.jsx("div",{className:"bg-theme-bg-chat-input rounded-md p-3 border-l-2 border-theme-text-secondary/30",children:e.jsx("div",{className:"text-xs text-theme-text-secondary font-mono whitespace-pre-wrap",children:a})})]}):null};function U(t){const s=[];let r=0;return t.replace(/<think>([^]*?)<\/think>/g,(a,n,c)=>{c>r&&s.push({type:"normal",text:t.slice(r,c)}),s.push({type:"think",text:n}),r=c+a.length}),r<t.length&&s.push({type:"normal",text:t.slice(r)}),s}function X({content:t}){if(!t)return null;const s=U(t);return e.jsx("div",{className:"whitespace-normal",children:s.map((r,a)=>{const n=G.render(r.text);return r.type==="think"?e.jsx(K,{thought:r.text},a):e.jsx("div",{dangerouslySetInnerHTML:{__html:q.sanitize(n)}},a)})})}function Y({chat:t,onDelete:s}){var x,o,u,b;const{isOpen:r,openModal:a,closeModal:n}=j(),{isOpen:c,openModal:l,closeModal:p}=j(),m=async()=>{if(!window.confirm(`Are you sure you want to delete this chat?
2
2
 
3
- This action is irreversible.`))return!1;await g.deleteChat(t.id),s(t.id)};return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{className:"bg-transparent text-white text-opacity-80 text-xs font-medium border-b border-white/10 h-10",children:[e.jsx("td",{className:"px-6 font-medium whitespace-nowrap text-white",children:t.id}),e.jsx("td",{className:"px-6 font-medium whitespace-nowrap text-white",children:(x=t.user)==null?void 0:x.username}),e.jsx("td",{className:"px-6",children:(o=t.workspace)==null?void 0:o.name}),e.jsx("td",{onClick:a,className:"px-6 border-transparent cursor-pointer transform transition-transform duration-200 hover:scale-105 hover:shadow-lg",children:C(t.prompt,40)}),e.jsx("td",{onClick:l,className:"px-6 cursor-pointer transform transition-transform duration-200 hover:scale-105 hover:shadow-lg",children:C((u=v(t.response,{}))==null?void 0:u.text,40)}),e.jsx("td",{className:"px-6",children:t.createdAt}),e.jsx("td",{className:"px-6 flex items-center gap-x-6 h-full mt-1",children:e.jsx("button",{onClick:m,className:"text-xs font-medium text-white/80 light:text-black/80 hover:light:text-red-500 hover:text-red-300 rounded-lg px-2 py-1 hover:bg-white hover:light:bg-red-50 hover:bg-opacity-10",children:e.jsx(E,{className:"h-5 w-5"})})})]}),e.jsx(N,{isOpen:r,children:e.jsx(M,{text:t.prompt,closeModal:n})}),e.jsx(N,{isOpen:c,children:e.jsx(M,{text:e.jsx(X,{content:(b=v(t.response,{}))==null?void 0:b.text}),closeModal:p})})]})}const M=({text:t,closeModal:s})=>e.jsx("div",{className:"relative w-full md:max-w-2xl 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.jsx("h3",{className:"text-xl font-semibold text-white",children:"Viewing Text"}),e.jsx("button",{onClick:s,type:"button",className:"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(F,{className:"text-white text-lg"})})]}),e.jsx("div",{className:"w-full p-6",children:e.jsx("pre",{className:"w-full h-[200px] py-2 px-4 whitespace-pre-line overflow-auto rounded-lg bg-zinc-900 light:bg-theme-bg-secondary border border-gray-500 text-white text-sm",children:t})})]})}),S={csv:{name:"CSV",mimeType:"text/csv",fileExtension:"csv",filenameFunc:()=>`anythingllm-chats-${new Date().toLocaleDateString()}`},json:{name:"JSON",mimeType:"application/json",fileExtension:"json",filenameFunc:()=>`anythingllm-chats-${new Date().toLocaleDateString()}`},jsonl:{name:"JSONL",mimeType:"application/jsonl",fileExtension:"jsonl",filenameFunc:()=>`anythingllm-chats-${new Date().toLocaleDateString()}-lines`},jsonAlpaca:{name:"JSON (Alpaca)",mimeType:"application/json",fileExtension:"json",filenameFunc:()=>`anythingllm-chats-${new Date().toLocaleDateString()}-alpaca`}};function ae(){const[t,s]=d.useState(!1),r=d.useRef(),a=d.useRef(),n=z(),[c,l]=d.useState(!0),[p,m]=d.useState([]),[x,o]=d.useState(Number(n.get("offset")||0)),[u,b]=d.useState(!1),{t:f}=A(),O=async i=>{const h=await g.exportChats(i,"workspace");if(h){const{name:w,mimeType:P,fileExtension:$,filenameFunc:L}=S[i],R=new Blob([h],{type:P});V.saveAs(R,`${L()}.${$}`),y(`Chats exported successfully as ${w}.`,"success")}else y("Failed to export chats.","error")},T=async()=>{if(!window.confirm(`Are you sure you want to clear all chats?
3
+ This action is irreversible.`))return!1;await g.deleteChat(t.id),s(t.id)};return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{className:"bg-transparent text-white text-opacity-80 text-xs font-medium border-b border-white/10 h-10",children:[e.jsx("td",{className:"px-6 font-medium whitespace-nowrap text-white",children:t.id}),e.jsx("td",{className:"px-6 font-medium whitespace-nowrap text-white",children:(x=t.user)==null?void 0:x.username}),e.jsx("td",{className:"px-6",children:(o=t.workspace)==null?void 0:o.name}),e.jsx("td",{onClick:a,className:"px-6 border-transparent cursor-pointer transform transition-transform duration-200 hover:scale-105 hover:shadow-lg",children:C(t.prompt,40)}),e.jsx("td",{onClick:l,className:"px-6 cursor-pointer transform transition-transform duration-200 hover:scale-105 hover:shadow-lg",children:C((u=v(t.response,{}))==null?void 0:u.text,40)}),e.jsx("td",{className:"px-6",children:t.createdAt}),e.jsx("td",{className:"px-6 flex items-center gap-x-6 h-full mt-1",children:e.jsx("button",{onClick:m,className:"text-xs font-medium text-white/80 light:text-black/80 hover:light:text-red-500 hover:text-red-300 rounded-lg px-2 py-1 hover:bg-white hover:light:bg-red-50 hover:bg-opacity-10",children:e.jsx(E,{className:"h-5 w-5"})})})]}),e.jsx(N,{isOpen:r,children:e.jsx(M,{text:t.prompt,closeModal:n})}),e.jsx(N,{isOpen:c,children:e.jsx(M,{text:e.jsx(X,{content:(b=v(t.response,{}))==null?void 0:b.text}),closeModal:p})})]})}const M=({text:t,closeModal:s})=>e.jsx("div",{className:"relative w-full md:max-w-2xl 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.jsx("h3",{className:"text-xl font-semibold text-white",children:"Viewing Text"}),e.jsx("button",{onClick:s,type:"button",className:"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(F,{className:"text-white text-lg"})})]}),e.jsx("div",{className:"w-full p-6",children:e.jsx("pre",{className:"w-full h-[200px] py-2 px-4 whitespace-pre-line overflow-auto rounded-lg bg-zinc-900 light:bg-theme-bg-secondary border border-gray-500 text-white text-sm",children:t})})]})}),S={csv:{name:"CSV",mimeType:"text/csv",fileExtension:"csv",filenameFunc:()=>`anythingllm-chats-${new Date().toLocaleDateString()}`},json:{name:"JSON",mimeType:"application/json",fileExtension:"json",filenameFunc:()=>`anythingllm-chats-${new Date().toLocaleDateString()}`},jsonl:{name:"JSONL",mimeType:"application/jsonl",fileExtension:"jsonl",filenameFunc:()=>`anythingllm-chats-${new Date().toLocaleDateString()}-lines`},jsonAlpaca:{name:"JSON (Alpaca)",mimeType:"application/json",fileExtension:"json",filenameFunc:()=>`anythingllm-chats-${new Date().toLocaleDateString()}-alpaca`}};function ae(){const[t,s]=d.useState(!1),r=d.useRef(),a=d.useRef(),n=z(),[c,l]=d.useState(!0),[p,m]=d.useState([]),[x,o]=d.useState(Number(n.get("offset")||0)),[u,b]=d.useState(!1),{t:f}=A(),O=async i=>{const h=await g.exportChats(i,"workspace");if(h){const{name:w,mimeType:P,fileExtension:_,filenameFunc:R}=S[i],$=new Blob([h],{type:P});V.saveAs($,`${R()}.${_}`),y(`Chats exported successfully as ${w}.`,"success")}else y("Failed to export chats.","error")},T=async()=>{if(!window.confirm(`Are you sure you want to clear all chats?
4
4
 
5
- This action is irreversible.`))return!1;await g.deleteChat(-1),m([]),y("Cleared all chats.","success")},_=()=>{s(!t)};return d.useEffect(()=>{function i(h){r.current&&!r.current.contains(h.target)&&!a.current.contains(h.target)&&s(!1)}return document.addEventListener("mousedown",i),()=>{document.removeEventListener("mousedown",i)}},[]),d.useEffect(()=>{async function i(){const{chats:h=[],hasPages:w=!1}=await g.chats(x);m(h),b(w),l(!1)}i()},[x]),e.jsx(I,{children:e.jsxs("div",{className:"w-screen h-screen overflow-hidden bg-theme-bg-container flex",children:[e.jsx(J,{}),e.jsx("div",{style:{height:H?"100%":"calc(100% - 32px)"},className:"relative md:ml-[2px] md:mr-[16px] md:my-[16px] md:rounded-[16px] bg-theme-bg-secondary w-full h-full overflow-y-scroll p-4 md:p-0",children:e.jsxs("div",{className:"flex flex-col w-full px-1 md:pl-6 md:pr-[50px] md:py-6 py-16",children:[e.jsxs("div",{className:"w-full flex flex-col gap-y-1 pb-6 border-white/10 border-b-2",children:[e.jsxs("div",{className:"flex flex-wrap gap-4 items-center",children:[e.jsx("p",{className:"text-lg leading-6 font-bold text-theme-text-primary",children:f("recorded.title")}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{ref:a,onClick:_,className:"flex items-center gap-x-2 px-4 py-1 rounded-lg bg-primary-button hover:light:bg-theme-bg-primary hover:text-theme-text-primary text-xs font-semibold hover:bg-secondary shadow-[0_4px_14px_rgba(0,0,0,0.25)] h-[34px] w-fit",children:[e.jsx(Q,{size:18,weight:"bold"}),f("recorded.export"),e.jsx(D,{size:18,weight:"bold"})]}),e.jsx("div",{ref:r,className:`${t?"slide-down":"slide-up hidden"} z-20 w-fit rounded-lg absolute top-full right-0 bg-secondary light:bg-theme-bg-secondary mt-2 shadow-md`,children:e.jsx("div",{className:"py-2",children:Object.entries(S).map(([i,h])=>e.jsx("button",{onClick:()=>{O(i),s(!1)},className:"w-full text-left px-4 py-2 text-white text-sm hover:bg-[#3D4147] light:hover:bg-theme-sidebar-item-hover",children:h.name},i))})})]}),p.length>0&&e.jsxs("button",{onClick:T,className:"flex items-center gap-x-2 px-4 py-1 border hover:border-transparent light:border-theme-sidebar-border border-white/40 text-white/40 light:text-theme-text-secondary rounded-lg bg-transparent hover:light:text-theme-bg-primary hover:text-theme-text-primary text-xs font-semibold hover:bg-red-500 shadow-[0_4px_14px_rgba(0,0,0,0.25)] h-[34px] w-fit",children:[e.jsx(E,{size:18,weight:"bold"}),"Clear Chats"]})]}),e.jsx("p",{className:"text-xs leading-[18px] font-base text-theme-text-secondary mt-2",children:f("recorded.description")})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsx(Z,{loading:c,chats:p,setChats:m,offset:x,setOffset:o,canNext:u,t:f})})]})})]})})}function Z({loading:t,chats:s,setChats:r,offset:a,setOffset:n,canNext:c,t:l}){const p=()=>{n(Math.max(a-1,0))},m=()=>{n(a+1)},x=async o=>{await g.deleteChat(o),r(u=>u.filter(b=>b.id!==o))};return t?e.jsx(B,{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",containerClassName:"flex w-full"}):e.jsxs(e.Fragment,{children:[e.jsxs("table",{className:"w-full text-xs text-left rounded-lg min-w-[640px] border-spacing-0",children:[e.jsx("thead",{className:"text-theme-text-secondary text-xs leading-[18px] font-bold uppercase border-white/10 border-b",children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",className:"px-6 py-3 rounded-tl-lg",children:l("recorded.table.id")}),e.jsx("th",{scope:"col",className:"px-6 py-3",children:l("recorded.table.by")}),e.jsx("th",{scope:"col",className:"px-6 py-3",children:l("recorded.table.workspace")}),e.jsx("th",{scope:"col",className:"px-6 py-3",children:l("recorded.table.prompt")}),e.jsx("th",{scope:"col",className:"px-6 py-3",children:l("recorded.table.response")}),e.jsx("th",{scope:"col",className:"px-6 py-3",children:l("recorded.table.at")}),e.jsx("th",{scope:"col",className:"px-6 py-3 rounded-tr-lg",children:" "})]})}),e.jsx("tbody",{children:!!s&&s.map(o=>e.jsx(Y,{chat:o,onDelete:x},o.id))})]}),e.jsxs("div",{className:"flex w-full justify-between items-center mt-6",children:[e.jsxs("button",{onClick:p,className:"px-4 py-2 rounded-lg border border-theme-text-secondary text-theme-text-secondary text-sm items-center flex gap-x-2 hover:bg-theme-text-secondary hover:text-theme-bg-secondary disabled:invisible",disabled:a===0,children:[" ","Previous Page"]}),e.jsx("button",{onClick:m,className:"px-4 py-2 rounded-lg border border-slate-200 text-slate-200 light:text-theme-text-secondary light:border-theme-sidebar-border text-sm items-center flex gap-x-2 hover:bg-slate-200 hover:text-slate-800 disabled:invisible",disabled:!c,children:"Next Page"})]})]})}export{ae as default};
5
+ This action is irreversible.`))return!1;await g.deleteChat(-1),m([]),y("Cleared all chats.","success")},L=()=>{s(!t)};return d.useEffect(()=>{function i(h){r.current&&!r.current.contains(h.target)&&!a.current.contains(h.target)&&s(!1)}return document.addEventListener("mousedown",i),()=>{document.removeEventListener("mousedown",i)}},[]),d.useEffect(()=>{async function i(){const{chats:h=[],hasPages:w=!1}=await g.chats(x);m(h),b(w),l(!1)}i()},[x]),e.jsx(I,{children:e.jsxs("div",{className:"w-screen h-screen overflow-hidden bg-theme-bg-container flex",children:[e.jsx(J,{}),e.jsx("div",{style:{height:H?"100%":"calc(100% - 32px)"},className:"relative md:ml-[2px] md:mr-[16px] md:my-[16px] md:rounded-[16px] bg-theme-bg-secondary w-full h-full overflow-y-scroll p-4 md:p-0",children:e.jsxs("div",{className:"flex flex-col w-full px-1 md:pl-6 md:pr-[50px] md:py-6 py-16",children:[e.jsxs("div",{className:"w-full flex flex-col gap-y-1 pb-6 border-white/10 border-b-2",children:[e.jsxs("div",{className:"flex flex-wrap gap-4 items-center",children:[e.jsx("p",{className:"text-lg leading-6 font-bold text-theme-text-primary",children:f("recorded.title")}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{ref:a,onClick:L,className:"flex items-center gap-x-2 px-4 py-1 rounded-lg bg-primary-button hover:light:bg-theme-bg-primary hover:text-theme-text-primary text-xs font-semibold hover:bg-secondary shadow-[0_4px_14px_rgba(0,0,0,0.25)] h-[34px] w-fit",children:[e.jsx(Q,{size:18,weight:"bold"}),f("recorded.export"),e.jsx(D,{size:18,weight:"bold"})]}),e.jsx("div",{ref:r,className:`${t?"slide-down":"slide-up hidden"} z-20 w-fit rounded-lg absolute top-full right-0 bg-secondary light:bg-theme-bg-secondary mt-2 shadow-md`,children:e.jsx("div",{className:"py-2",children:Object.entries(S).map(([i,h])=>e.jsx("button",{onClick:()=>{O(i),s(!1)},className:"w-full text-left px-4 py-2 text-white text-sm hover:bg-[#3D4147] light:hover:bg-theme-sidebar-item-hover",children:h.name},i))})})]}),p.length>0&&e.jsxs("button",{onClick:T,className:"flex items-center gap-x-2 px-4 py-1 border hover:border-transparent light:border-theme-sidebar-border border-white/40 text-white/40 light:text-theme-text-secondary rounded-lg bg-transparent hover:light:text-theme-bg-primary hover:text-theme-text-primary text-xs font-semibold hover:bg-red-500 shadow-[0_4px_14px_rgba(0,0,0,0.25)] h-[34px] w-fit",children:[e.jsx(E,{size:18,weight:"bold"}),"Clear Chats"]})]}),e.jsx("p",{className:"text-xs leading-[18px] font-base text-theme-text-secondary mt-2",children:f("recorded.description")})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsx(Z,{loading:c,chats:p,setChats:m,offset:x,setOffset:o,canNext:u,t:f})})]})})]})})}function Z({loading:t,chats:s,setChats:r,offset:a,setOffset:n,canNext:c,t:l}){const p=()=>{n(Math.max(a-1,0))},m=()=>{n(a+1)},x=async o=>{await g.deleteChat(o),r(u=>u.filter(b=>b.id!==o))};return t?e.jsx(B,{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",containerClassName:"flex w-full"}):e.jsxs(e.Fragment,{children:[e.jsxs("table",{className:"w-full text-xs text-left rounded-lg min-w-[640px] border-spacing-0",children:[e.jsx("thead",{className:"text-theme-text-secondary text-xs leading-[18px] font-bold uppercase border-white/10 border-b",children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",className:"px-6 py-3 rounded-tl-lg",children:l("recorded.table.id")}),e.jsx("th",{scope:"col",className:"px-6 py-3",children:l("recorded.table.by")}),e.jsx("th",{scope:"col",className:"px-6 py-3",children:l("recorded.table.workspace")}),e.jsx("th",{scope:"col",className:"px-6 py-3",children:l("recorded.table.prompt")}),e.jsx("th",{scope:"col",className:"px-6 py-3",children:l("recorded.table.response")}),e.jsx("th",{scope:"col",className:"px-6 py-3",children:l("recorded.table.at")}),e.jsx("th",{scope:"col",className:"px-6 py-3 rounded-tr-lg",children:" "})]})}),e.jsx("tbody",{children:!!s&&s.map(o=>e.jsx(Y,{chat:o,onDelete:x},o.id))})]}),e.jsxs("div",{className:"flex w-full justify-between items-center mt-6",children:[e.jsxs("button",{onClick:p,className:"px-4 py-2 rounded-lg border border-theme-text-secondary text-theme-text-secondary text-sm items-center flex gap-x-2 hover:bg-theme-text-secondary hover:text-theme-bg-secondary disabled:invisible",disabled:a===0,children:[" ","Previous Page"]}),e.jsx("button",{onClick:m,className:"px-4 py-2 rounded-lg border border-slate-200 text-slate-200 light:text-theme-text-secondary light:border-theme-sidebar-border text-sm items-center flex gap-x-2 hover:bg-slate-200 hover:text-slate-800 disabled:invisible",disabled:!c,children:"Next Page"})]})]})}export{ae as default};
@@ -0,0 +1 @@
1
+ import{j as e,u as z,a6 as A,a7 as D,r as o,q as H,a1 as Z,i as V,h as F,C as $,K as U,k as Y,N as X,M as _,au as J,av as ee,aw as P,ax as te,ay as le,az as ae,aA as oe,aB as se,aC as ne,t as B,c as S}from"../index.js";import{C as re}from"./index-4277cf52.js";function ie({name:t,value:r,image:c,description:n,checked:d,onClick:h}){return e.jsxs("div",{onClick:()=>h(r),className:`w-full p-2 rounded-md hover:cursor-pointer hover:bg-theme-bg-secondary ${d?"bg-theme-bg-secondary":""}`,children:[e.jsx("input",{type:"checkbox",value:r,className:"peer hidden",checked:d,readOnly:!0,formNoValidate:!0}),e.jsxs("div",{className:"flex gap-x-4 items-center",children:[e.jsx("img",{src:c,alt:`${t} 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:t}),e.jsx("div",{className:"mt-1 text-xs text-description",children:n})]})]})]})}function ce(){const{t}=z();return e.jsx("div",{className:"w-full h-10 items-center flex",children:e.jsx("p",{className:"text-sm font-base text-white text-opacity-60",children:t("vector.provider.description")})})}function de({settings:t}){return e.jsx("div",{className:"w-full flex flex-col gap-y-7",children:e.jsxs("div",{className:"w-full flex items-center gap-[36px] mt-1.5",children:[e.jsxs("div",{className:"flex flex-col w-60",children:[e.jsx("label",{className:"text-white text-sm font-semibold block mb-3",children:"Chroma Endpoint"}),e.jsx("input",{type:"url",name:"ChromaEndpoint",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:"http://localhost:8000",defaultValue:t==null?void 0:t.ChromaEndpoint,required:!0,autoComplete:"off",spellCheck:!1})]}),e.jsxs("div",{className:"flex flex-col w-60",children:[e.jsx("label",{className:"text-white text-sm font-semibold block mb-3",children:"API Header"}),e.jsx("input",{name:"ChromaApiHeader",autoComplete:"off",type:"text",defaultValue:t==null?void 0:t.ChromaApiHeader,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:"X-Api-Key"})]}),e.jsxs("div",{className:"flex flex-col w-60",children:[e.jsx("label",{className:"text-white text-sm font-semibold block mb-3",children:"API Key"}),e.jsx("input",{name:"ChromaApiKey",autoComplete:"off",type:"password",defaultValue:t!=null&&t.ChromaApiKey?"*".repeat(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:"sk-myApiKeyToAccessMyChromaInstance"})]})]})})}function ue({settings:t}){return e.jsx("div",{className:"w-full flex flex-col gap-y-7",children:e.jsxs("div",{className:"w-full flex items-center gap-[36px] mt-1.5",children:[e.jsxs("div",{className:"flex flex-col w-60",children:[e.jsx("label",{className:"text-white text-sm font-semibold block mb-3",children:"API Key"}),e.jsx("input",{type:"password",name:"ChromaCloudApiKey",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:"ck-your-api-key-here",defaultValue:t!=null&&t.ChromaCloudApiKey?"*".repeat(20):"",required:!0,autoComplete:"off",spellCheck:!1})]}),e.jsxs("div",{className:"flex flex-col w-60",children:[e.jsx("label",{className:"text-white text-sm font-semibold block mb-3",children:"Tenant ID"}),e.jsx("input",{name:"ChromaCloudTenant",autoComplete:"off",type:"text",defaultValue:t==null?void 0:t.ChromaCloudTenant,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:"your-tenant-id-here",required:!0})]}),e.jsxs("div",{className:"flex flex-col w-60",children:[e.jsx("label",{className:"text-white text-sm font-semibold block mb-3",children:"Database Name"}),e.jsx("input",{name:"ChromaCloudDatabase",autoComplete:"off",type:"text",defaultValue:t==null?void 0:t.ChromaCloudDatabase,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:"your-database-name",required:!0})]})]})})}function me({settings:t}){return e.jsx("div",{className:"w-full flex flex-col gap-y-7",children:e.jsxs("div",{className:"w-full flex items-center gap-[36px] mt-1.5",children:[e.jsxs("div",{className:"flex flex-col w-60",children:[e.jsx("label",{className:"text-white text-sm font-semibold block mb-3",children:"Pinecone DB API Key"}),e.jsx("input",{type:"password",name:"PineConeKey",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:"Pinecone API Key",defaultValue:t!=null&&t.PineConeKey?"*".repeat(20):"",required:!0,autoComplete:"off",spellCheck:!1})]}),e.jsxs("div",{className:"flex flex-col w-60",children:[e.jsx("label",{className:"text-white text-sm font-semibold block mb-3",children:"Pinecone Index Name"}),e.jsx("input",{type:"text",name:"PineConeIndex",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-index",defaultValue:t==null?void 0:t.PineConeIndex,required:!0,autoComplete:"off",spellCheck:!1})]})]})})}function pe({settings:t}){return e.jsx("div",{className:"w-full flex flex-col gap-y-7",children:e.jsxs("div",{className:"w-full flex items-center gap-[36px] mt-1.5",children:[e.jsxs("div",{className:"flex flex-col w-60",children:[e.jsx("label",{className:"text-white text-sm font-semibold block mb-3",children:"Weaviate Endpoint"}),e.jsx("input",{type:"url",name:"WeaviateEndpoint",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:"http://localhost:8080",defaultValue:t==null?void 0:t.WeaviateEndpoint,required:!0,autoComplete:"off",spellCheck:!1})]}),e.jsxs("div",{className:"flex flex-col w-60",children:[e.jsx("label",{className:"text-white text-sm font-semibold block mb-3",children:"API Key"}),e.jsx("input",{type:"password",name:"WeaviateApiKey",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:"sk-123Abcweaviate",defaultValue:t!=null&&t.WeaviateApiKey?"*".repeat(20):"",autoComplete:"off",spellCheck:!1})]})]})})}function xe({settings:t}){return e.jsx("div",{className:"w-full flex flex-col gap-y-7",children:e.jsxs("div",{className:"w-full flex items-center gap-[36px] mt-1.5",children:[e.jsxs("div",{className:"flex flex-col w-60",children:[e.jsx("label",{className:"text-white text-sm font-semibold block mb-3",children:"QDrant API Endpoint"}),e.jsx("input",{type:"url",name:"QdrantEndpoint",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:"http://localhost:6633",defaultValue:t==null?void 0:t.QdrantEndpoint,required:!0,autoComplete:"off",spellCheck:!1})]}),e.jsxs("div",{className:"flex flex-col w-60",children:[e.jsx("label",{className:"text-white text-sm font-semibold block mb-3",children:"API Key"}),e.jsx("input",{type:"password",name:"QdrantApiKey",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:"wOeqxsYP4....1244sba",defaultValue:t!=null&&t.QdrantApiKey?"*".repeat(20):"",autoComplete:"off",spellCheck:!1})]})]})})}function he({settings:t}){return e.jsx("div",{className:"w-full flex flex-col gap-y-7",children:e.jsxs("div",{className:"w-full flex items-center gap-[36px] mt-1.5",children:[e.jsxs("div",{className:"flex flex-col w-60",children:[e.jsx("label",{className:"text-white text-sm font-semibold block mb-3",children:"Milvus DB Address"}),e.jsx("input",{type:"text",name:"MilvusAddress",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:"http://localhost:19530",defaultValue:t==null?void 0:t.MilvusAddress,required:!0,autoComplete:"off",spellCheck:!1})]}),e.jsxs("div",{className:"flex flex-col w-60",children:[e.jsx("label",{className:"text-white text-sm font-semibold block mb-3",children:"Milvus Username"}),e.jsx("input",{type:"text",name:"MilvusUsername",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:"username",defaultValue:t==null?void 0:t.MilvusUsername,autoComplete:"off",spellCheck:!1})]}),e.jsxs("div",{className:"flex flex-col w-60",children:[e.jsx("label",{className:"text-white text-sm font-semibold block mb-3",children:"Milvus Password"}),e.jsx("input",{type:"password",name:"MilvusPassword",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:"password",defaultValue:t!=null&&t.MilvusPassword?"*".repeat(20):"",autoComplete:"off",spellCheck:!1})]})]})})}function fe({settings:t}){return e.jsx("div",{className:"w-full flex flex-col gap-y-4",children:e.jsxs("div",{className:"w-full flex items-center gap-[36px] mt-1.5",children:[e.jsxs("div",{className:"flex flex-col w-60",children:[e.jsx("label",{className:"text-white text-sm font-semibold block mb-3",children:"Cluster Endpoint"}),e.jsx("input",{type:"text",name:"ZillizEndpoint",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:"https://sample.api.gcp-us-west1.zillizcloud.com",defaultValue:t==null?void 0:t.ZillizEndpoint,required:!0,autoComplete:"off",spellCheck:!1})]}),e.jsxs("div",{className:"flex flex-col w-60",children:[e.jsx("label",{className:"text-white text-sm font-semibold block mb-3",children:"API Token"}),e.jsx("input",{type:"password",name:"ZillizApiToken",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:"Zilliz cluster API Token",defaultValue:t!=null&&t.ZillizApiToken?"*".repeat(20):"",autoComplete:"off",spellCheck:!1})]})]})})}function be({settings:t}){return e.jsx("div",{className:"w-full flex flex-col gap-y-7",children:e.jsxs("div",{className:"w-full flex items-center gap-[36px] mt-1.5",children:[e.jsxs("div",{className:"flex flex-col w-60",children:[e.jsx("label",{className:"text-white text-sm font-semibold block mb-3",children:"Astra DB Endpoint"}),e.jsx("input",{type:"url",name:"AstraDBEndpoint",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:"Astra DB API endpoint",defaultValue:t==null?void 0:t.AstraDBEndpoint,required:!0,autoComplete:"off",spellCheck:!1})]}),e.jsxs("div",{className:"flex flex-col w-60",children:[e.jsx("label",{className:"text-white text-sm font-semibold block mb-3",children:"Astra DB Application Token"}),e.jsx("input",{type:"password",name:"AstraDBApplicationToken",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:"AstraCS:...",defaultValue:t!=null&&t.AstraDBApplicationToken?"*".repeat(20):"",required:!0,autoComplete:"off",spellCheck:!1})]})]})})}function we({settings:t}){return e.jsx("div",{className:"w-full flex flex-col gap-y-7",children:e.jsxs("div",{className:"w-full flex items-center gap-[36px] mt-1.5",children:[e.jsxs("div",{className:"flex flex-col w-96",children:[e.jsxs("div",{className:"flex items-center gap-x-1 mb-3",children:[e.jsx("label",{className:"text-white text-sm font-semibold block",children:"Postgres Connection String"}),e.jsx(A,{size:16,className:"text-theme-text-secondary cursor-pointer","data-tooltip-id":"pgvector-connection-string-tooltip","data-tooltip-place":"right"}),e.jsx(D,{delayHide:300,id:"pgvector-connection-string-tooltip",className:"max-w-md z-99",clickable:!0,children:e.jsxs("p",{className:"text-md whitespace-pre-line break-words",children:["This is the connection string for the Postgres database in the format of ",e.jsx("br",{}),e.jsx("code",{children:"postgresql://username:password@host:port/database"}),e.jsx("br",{}),e.jsx("br",{}),"The user for the database must have the following permissions:",e.jsxs("ul",{className:"list-disc list-inside",children:[e.jsx("li",{children:"Read access to the database"}),e.jsx("li",{children:"Read access to the database schema"}),e.jsx("li",{children:"Create access to the database"})]}),e.jsx("br",{}),e.jsx("b",{children:"You must have the pgvector extension installed on the database."})]})})]}),e.jsx("input",{type:"text",name:"PGVectorConnectionString",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:"postgresql://username:password@host:port/database",defaultValue:t!=null&&t.PGVectorConnectionString?"*".repeat(20):"",required:!0,autoComplete:"off",spellCheck:!1})]}),e.jsxs("div",{className:"flex flex-col w-60",children:[e.jsxs("div",{className:"flex items-center gap-x-1 mb-3",children:[e.jsx("label",{className:"text-white text-sm font-semibold block",children:"Vector Table Name"}),e.jsx(A,{size:16,className:"text-theme-text-secondary cursor-pointer","data-tooltip-id":"pgvector-table-name-tooltip","data-tooltip-place":"right"}),e.jsx(D,{delayHide:300,id:"pgvector-table-name-tooltip",className:"max-w-md z-99",clickable:!0,children:e.jsxs("p",{className:"text-md whitespace-pre-line break-words",children:["This is the name of the table in the Postgres database that will store the vectors.",e.jsx("br",{}),e.jsx("br",{}),"By default, the table name is ",e.jsx("code",{children:"anythingllm_vectors"}),".",e.jsx("br",{}),e.jsx("br",{}),e.jsx("b",{children:"This table must not already exist on the database - it will be created automatically."})]})})]}),e.jsx("input",{type:"text",name:"PGVectorTableName",autoComplete:"off",defaultValue:t==null?void 0:t.PGVectorTableName,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:"vector_table"})]})]})})}const x=[{name:"LanceDB",value:"lancedb",logo:J,options:t=>e.jsx(ce,{}),description:"100% local vector DB that runs on the same instance as AnythingLLM."},{name:"PGVector",value:"pgvector",logo:ee,options:t=>e.jsx(we,{settings:t}),description:"Vector search powered by PostgreSQL."},{name:"Chroma",value:"chroma",logo:P,options:t=>e.jsx(de,{settings:t}),description:"Open source vector database you can host yourself or on the cloud."},{name:"Chroma Cloud",value:"chromacloud",logo:P,options:t=>e.jsx(ue,{settings:t}),description:"Fully managed Chroma cloud service with enterprise features and support."},{name:"Pinecone",value:"pinecone",logo:te,options:t=>e.jsx(me,{settings:t}),description:"100% cloud-based vector database for enterprise use cases."},{name:"Zilliz Cloud",value:"zilliz",logo:le,options:t=>e.jsx(fe,{settings:t}),description:"Cloud hosted vector database built for enterprise with SOC 2 compliance."},{name:"QDrant",value:"qdrant",logo:ae,options:t=>e.jsx(xe,{settings:t}),description:"Open source local and distributed cloud vector database."},{name:"Weaviate",value:"weaviate",logo:oe,options:t=>e.jsx(pe,{settings:t}),description:"Open source local and cloud hosted multi-modal vector database."},{name:"Milvus",value:"milvus",logo:se,options:t=>e.jsx(he,{settings:t}),description:"Open-source, highly scalable, and blazing fast."},{name:"AstraDB",value:"astra",logo:ne,options:t=>e.jsx(be,{settings:t}),description:"Vector Search for Real-world GenAI."}];function je(){var C;const[t,r]=o.useState(!1),[c,n]=o.useState(!1),[d,h]=o.useState(!1),[u,E]=o.useState({}),[M,T]=o.useState(!0),[f,b]=o.useState(""),[O,K]=o.useState([]),[s,y]=o.useState(null),[w,m]=o.useState(!1),v=o.useRef(null),{isOpen:I,openModal:L,closeModal:j}=H(),{t:i}=z(),g=async l=>{l.preventDefault(),s!==(u==null?void 0:u.VectorDB)&&c&&d?L():await N()},N=async()=>{r(!0);const l=document.getElementById("vectordb-form"),a={},W=new FormData(l);a.VectorDB=s;for(var[G,R]of W.entries())a[G]=R;const{error:k}=await B.updateSystem(a);k?(S(`Failed to save vector database settings: ${k}`,"error"),n(!0)):(S("Vector database preferences saved successfully.","success"),n(!1)),r(!1),j()},q=l=>{b(""),y(l),m(!1),n(!0)},Q=()=>{f.length>0?(b(""),v.current&&(v.current.value="")):m(!w)};o.useEffect(()=>{async function l(){const a=await B.keys();E(a),y((a==null?void 0:a.VectorDB)||"lancedb"),h((a==null?void 0:a.HasExistingEmbeddings)||!1),T(!1)}l()},[]),o.useEffect(()=>{const l=x.filter(a=>a.name.toLowerCase().includes(f.toLowerCase()));K(l)},[f,s]);const p=x.find(l=>l.value===s)??x[0];return e.jsxs("div",{className:"w-screen h-screen overflow-hidden bg-theme-bg-container flex",children:[e.jsx(Z,{}),M?e.jsx("div",{style:{height:V?"100%":"calc(100% - 32px)"},className:"relative md:ml-[2px] md:mr-[16px] md:my-[16px] md:rounded-[16px] bg-theme-bg-secondary w-full h-full overflow-y-scroll p-4 md:p-0",children:e.jsx("div",{className:"w-full h-full flex justify-center items-center",children:e.jsx(F,{})})}):e.jsx("div",{style:{height:V?"100%":"calc(100% - 32px)"},className:"relative md:ml-[2px] md:mr-[16px] md:my-[16px] md:rounded-[16px] bg-theme-bg-secondary w-full h-full overflow-y-scroll p-4 md:p-0",children:e.jsx("form",{id:"vectordb-form",onSubmit:g,className:"flex w-full",children:e.jsxs("div",{className:"flex flex-col w-full px-1 md:pl-6 md:pr-[50px] py-16 md:py-6",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:"flex gap-x-4 items-center",children:e.jsx("p",{className:"text-lg leading-6 font-bold text-white",children:i("vector.title")})}),e.jsx("p",{className:"text-xs leading-[18px] font-base text-white text-opacity-60",children:i("vector.description")})]}),e.jsx("div",{className:"w-full justify-end flex",children:c&&e.jsx($,{onClick:()=>g(),className:"mt-3 mr-0 -mb-14 z-10",children:i(t?"common.saving":"common.save")})}),e.jsx("div",{className:"text-base font-bold text-white mt-6 mb-4",children:i("vector.provider.title")}),e.jsxs("div",{className:"relative",children:[w&&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)}),w?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(U,{size:20,weight:"bold",className:"absolute left-4 z-30 text-theme-text-primary -ml-4 my-2"}),e.jsx("input",{type:"text",name:"vdb-search",autoComplete:"off",placeholder:"Search all vector database 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:l=>b(l.target.value),ref:v,onKeyDown:l=>{l.key==="Enter"&&l.preventDefault()}}),e.jsx(Y,{size:20,weight:"bold",className:"cursor-pointer text-white hover:text-x-button",onClick:Q})]}),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:O.map(l=>e.jsx(ie,{name:l.name,value:l.value,image:l.logo,description:l.description,checked:s===l.value,onClick:()=>q(l.value)},l.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:p.logo,alt:`${p.name} logo`,className:"w-10 h-10 rounded-md"}),e.jsxs("div",{className:"flex flex-col text-left",children:[e.jsx("div",{className:"text-sm font-semibold text-white",children:p.name}),e.jsx("div",{className:"mt-1 text-xs text-description",children:p.description})]})]}),e.jsx(X,{size:24,weight:"bold",className:"text-white"})]})]}),e.jsx("div",{onChange:()=>n(!0),className:"mt-4 flex flex-col gap-y-1",children:s&&((C=x.find(l=>l.value===s))==null?void 0:C.options(u))})]})})}),e.jsx(_,{isOpen:I,children:e.jsx(re,{warningText:"Switching the vector database will reset all previously embedded documents in all workspaces.\\n\\nConfirming will clear all embeddings from your vector database and remove all documents from your workspaces. Your uploaded documents will not be deleted, they will be available for re-embedding.",onClose:j,onConfirm:N})})]})}export{je as default};
@@ -0,0 +1 @@
1
+ import{u as g,j as e,I as U,k as B,r as N,M as W,a4 as I,c as C,G as k,aH as Y,aY as G,aW as Z,q as J,l as Q,b as H,p as V,a1 as X,i as R,aZ as ee}from"../index.js";import{D as te,a as le,C as re,P as oe}from"./react-beautiful-dnd.esm-bb85eef1.js";import{L as ae}from"./index-8c2371f5.js";import{t as K}from"./truncate-06273256.js";import{T as D}from"./Trans-820f1dad.js";const P=["conversationTokenCount","conversationMessageCount","currentHour"],L=["hasImageAttachment"];function se(t){return[{value:"promptContent",label:t("model-router.rule-form.prop-prompt-content")},{value:"conversationTokenCount",label:t("model-router.rule-form.prop-token-count")},{value:"conversationMessageCount",label:t("model-router.rule-form.prop-message-count")},{value:"currentHour",label:t("model-router.rule-form.prop-current-hour")},{value:"hasImageAttachment",label:t("model-router.rule-form.prop-has-image")}]}function ne(t){return[{value:"contains",label:t("model-router.rule-form.cmp-contains")},{value:"matches",label:t("model-router.rule-form.cmp-matches-regex")},{value:"eq",label:t("model-router.rule-form.cmp-equals")},{value:"neq",label:t("model-router.rule-form.cmp-not-equals")}]}function ie(t){return[{value:"gt",label:t("model-router.rule-form.cmp-greater-than")},{value:"gte",label:t("model-router.rule-form.cmp-greater-than-or-equal")},{value:"lt",label:t("model-router.rule-form.cmp-less-than")},{value:"lte",label:t("model-router.rule-form.cmp-less-than-or-equal")},{value:"eq",label:t("model-router.rule-form.cmp-equals")},{value:"neq",label:t("model-router.rule-form.cmp-not-equals")},{value:"between",label:t("model-router.rule-form.cmp-between")}]}function T(t,l){return P.includes(l)?ie(t):ne(t)}function ce(t,l,a){return a==="between"?t(l==="currentHour"?"model-router.rule-form.placeholder-between-hour":"model-router.rule-form.placeholder-between-numeric"):l==="currentHour"?t("model-router.rule-form.placeholder-hour"):l==="conversationMessageCount"?t("model-router.rule-form.placeholder-message-count"):P.includes(l)?t("model-router.rule-form.placeholder-numeric"):t(a==="contains"?"model-router.rule-form.placeholder-contains":a==="matches"?"model-router.rule-form.placeholder-matches":"model-router.rule-form.placeholder-default")}function $(t,l,a){return P.includes(l)?null:a==="contains"?t("model-router.rule-form.help-contains"):a==="matches"?t("model-router.rule-form.help-matches"):null}function de({conditionLogic:t,setConditionLogic:l,conditions:a,setConditions:r}){const{t:c}=g(),n=(o,i)=>{r(u=>u.map((x,h)=>h===o?{...x,...i}:x))},s=()=>{r(o=>[...o,{property:"",comparator:"",value:""}])},m=o=>{r(i=>i.filter((u,x)=>x!==o))},d=()=>{l(o=>o==="AND"?"OR":"AND")};return e.jsxs("div",{className:"flex flex-col gap-y-1.5 items-start",children:[e.jsx("div",{className:"flex flex-col gap-y-5 w-full",children:a.map((o,i)=>e.jsx(me,{condition:o,showLabels:i===0,logicBadge:i===0?null:e.jsx(ue,{value:t,onClick:d}),onChange:u=>n(i,u),onRemove:a.length>1?()=>m(i):null},i))}),e.jsx("button",{type:"button",onClick:s,"aria-label":c("model-router.rule-form.add-condition"),className:"border-none mt-3 bg-zinc-800 light:bg-slate-900 text-white light:text-white rounded-md p-1 hover:opacity-90 transition-opacity",children:e.jsx(U,{size:16,weight:"bold"})})]})}function ue({value:t,onClick:l}){return e.jsx("button",{type:"button",onClick:l,className:"border-none shrink-0 self-start bg-zinc-700 light:bg-slate-200 text-white light:text-slate-950 text-xs font-medium leading-4 tracking-[1.2px] uppercase px-2.5 py-1.5 rounded-md hover:opacity-80 transition-opacity",children:t})}function me({condition:t,showLabels:l,logicBadge:a,onChange:r,onRemove:c}){const{t:n}=g(),s=L.includes(t.property),m=o=>{if(L.includes(o)){r({property:o,comparator:"eq",value:"true"});return}const i=T(n,t.property),u=T(n,o),x=!!t.comparator&&u.some(h=>h.value===t.comparator)&&i.some(h=>h.value===t.comparator);r({property:o,comparator:x?t.comparator:"",value:L.includes(t.property)?"":t.value})},d=se(n);return e.jsxs("div",{className:"flex items-end gap-x-5",children:[a,e.jsxs("div",{className:`grid flex-1 ${s?"grid-cols-2":"grid-cols-3"} gap-x-5`,children:[e.jsx(E,{label:l?n("model-router.rule-form.property-label"):null,children:e.jsxs("select",{value:t.property,onChange:o=>m(o.target.value),className:"bg-zinc-800 light:bg-white light:border light:border-slate-300 text-white light:text-slate-700 text-sm rounded-[8px] outline-none block w-full h-8 px-3.5",required:!0,children:[e.jsx("option",{value:"",children:n("model-router.rule-form.property-select")}),d.map(o=>e.jsx("option",{value:o.value,children:o.label},o.value))]})}),s?e.jsx(E,{label:l?n("model-router.rule-form.value-label"):null,children:e.jsx(xe,{value:t.value,onChange:o=>r({value:o})})}):e.jsx(pe,{condition:t,onChange:r,showLabels:l})]}),c&&e.jsx("button",{type:"button",onClick:c,"aria-label":n("model-router.rule-form.remove-condition"),className:`border-none shrink-0 self-start ${l?"mt-[34px]":"mt-2"} text-zinc-400 light:text-slate-500 hover:text-red-400 light:hover:text-red-500 transition-colors`,children:e.jsx(B,{size:16,weight:"bold"})})]})}function E({label:t,children:l}){return e.jsxs("div",{className:"flex flex-col gap-y-1.5",children:[t&&e.jsx("label",{className:"text-sm font-medium leading-5 text-white light:text-slate-950",children:t}),l]})}function xe({value:t,onChange:l}){const{t:a}=g();return e.jsxs("select",{value:t||"true",onChange:r=>l(r.target.value),className:"bg-zinc-800 light:bg-white light:border light:border-slate-300 text-white light:text-slate-700 text-sm rounded-[8px] outline-none block w-full h-8 px-3.5",required:!0,children:[e.jsx("option",{value:"true",children:a("model-router.rule-form.bool-true")}),e.jsx("option",{value:"false",children:a("model-router.rule-form.bool-false")})]})}function pe({condition:t,onChange:l,showLabels:a}){const{t:r}=g(),c=T(r,t.property);return e.jsxs(e.Fragment,{children:[e.jsx(E,{label:a?r("model-router.rule-form.comparator-label"):null,children:e.jsxs("select",{value:t.comparator,onChange:n=>l({comparator:n.target.value}),className:"bg-zinc-800 light:bg-white light:border light:border-slate-300 text-white light:text-slate-700 text-sm rounded-[8px] outline-none block w-full h-8 px-3.5",required:!0,children:[e.jsx("option",{value:"",children:r("model-router.rule-form.comparator-select")}),c.map(n=>e.jsx("option",{value:n.value,children:n.label},n.value))]})}),e.jsxs(E,{label:a?r("model-router.rule-form.value-label"):null,children:[e.jsx("input",{type:"text",value:t.value,onChange:n=>l({value:n.target.value}),placeholder:ce(r,t.property,t.comparator),className:`bg-zinc-800 light:bg-white light:border light:border-slate-300 text-white light:text-slate-700 placeholder:text-zinc-400 light:placeholder:text-slate-400 text-sm rounded-[8px] outline-none block w-full h-8 px-3.5 ${t.comparator==="matches"?"font-mono":""}`,required:!0}),$(r,t.property,t.comparator)&&e.jsx("p",{className:"text-xs leading-4 text-zinc-400 light:text-slate-600",children:$(r,t.property,t.comparator)})]})]})}function he({existingRule:t}){const{t:l}=g();return e.jsxs("div",{className:"flex flex-col gap-y-1.5",children:[e.jsx("label",{className:"text-sm font-medium leading-5 text-white light:text-slate-950",children:l("model-router.rule-form.match-description-label")}),e.jsx("textarea",{name:"description",defaultValue:(t==null?void 0:t.description)||"",placeholder:l("model-router.rule-form.match-description-placeholder"),rows:2,className:"bg-zinc-800 light:bg-white light:border light:border-slate-300 text-white light:text-slate-700 placeholder:text-zinc-400 light:placeholder:text-slate-400 text-sm rounded-[8px] outline-none block w-full px-3.5 py-2.5 resize-none",required:!0}),e.jsx("p",{className:"text-xs leading-4 text-zinc-400 light:text-slate-600",children:l("model-router.rule-form.match-description-help")})]})}function fe(t){return[{value:"calculated",label:t("model-router.rule-form.type-calculated-label"),description:t("model-router.rule-form.type-calculated-description")},{value:"llm",label:t("model-router.rule-form.type-llm-label"),description:t("model-router.rule-form.type-llm-description")}]}function ge(){return{property:"",comparator:"",value:""}}function be(t){return t.toLowerCase().replace(/[^a-z0-9_]/g,"_").replace(/_+/g,"_").replace(/^_|_$/g,"")}function ve({isOpen:t,closeModal:l,routerId:a,existingRule:r=null,nextPriority:c,onSaved:n}){var y;const{t:s}=g(),m=fe(s),d=!!r,[o,i]=N.useState(!1),[u,x]=N.useState((r==null?void 0:r.type)||"calculated"),[h,M]=N.useState((r==null?void 0:r.condition_logic)||"AND"),[_,q]=N.useState(Array.isArray(r==null?void 0:r.conditions)&&r.conditions.length?r.conditions:[ge()]),p=async f=>{f.preventDefault(),i(!0);const j=new FormData(f.target),S=be(j.get("title")||"");if(!S){C(s("model-router.rule-form.title-required"),"error"),i(!1);return}const b={title:S,type:u,route_provider:j.get("route_provider"),route_model:j.get("route_model"),priority:d?r.priority:Number(c)};if(u==="calculated"){const v=_.findIndex(w=>!w.property||!w.comparator||!String(w.value??"").trim());if(v!==-1){C(s("model-router.rule-form.conditions-incomplete",{index:v+1}),"error"),i(!1);return}b.condition_logic=h,b.conditions=_,b.description=null}else u==="llm"&&(b.description=j.get("description"),b.condition_logic=null,b.conditions=null);let z;d?z=await k.updateRule(a,r.id,b):z=await k.createRule(a,b),i(!1),z.rule?(n(),l()):C(z.error||s("model-router.rule-form.toast-save-failed"),"error")};return e.jsx(W,{isOpen:t,children:e.jsx("div",{className:"relative w-full max-w-3xl bg-zinc-900 light:bg-white rounded-[8px] shadow border border-zinc-700 light:border-slate-300",children:e.jsxs("form",{onSubmit:p,className:"flex flex-col gap-y-5 p-6",children:[e.jsxs("div",{className:"flex flex-col gap-y-1",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsx("h3",{className:"text-base font-semibold leading-6 text-white light:text-slate-950",children:s("model-router.rules.title")}),e.jsx("button",{onClick:l,type:"button",className:"border-none text-zinc-400 light:text-slate-500 hover:text-white light:hover:text-slate-900 transition-colors",children:e.jsx(B,{size:16,weight:"bold"})})]}),e.jsx("p",{className:"text-xs leading-4 text-zinc-400 light:text-slate-600",children:s("model-router.rules.description")})]}),e.jsxs("div",{className:"flex flex-col gap-y-5 max-h-[60vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex gap-x-5 items-start",children:[e.jsxs("div",{className:"flex flex-col gap-y-1.5 w-[500px]",children:[e.jsx("label",{className:"text-sm font-medium leading-5 text-white light:text-slate-950",children:s("model-router.rule-form.title-label")}),e.jsx("input",{type:"text",name:"title",defaultValue:(r==null?void 0:r.title)||"",placeholder:"e.g. route_code_to_claude",className:"bg-zinc-800 light:bg-white light:border light:border-slate-300 text-white light:text-slate-700 placeholder:text-zinc-400 light:placeholder:text-slate-400 text-sm rounded-[8px] outline-none block w-full h-8 px-3.5 font-mono",required:!0})]}),e.jsxs("div",{className:"flex flex-col gap-y-1.5 w-[300px]",children:[e.jsx("label",{className:"text-sm font-medium leading-5 text-white light:text-slate-950",children:s("model-router.rule-form.rule-type")}),e.jsx("select",{value:u,onChange:f=>x(f.target.value),className:"bg-zinc-800 light:bg-white light:border light:border-slate-300 text-white light:text-slate-700 text-sm rounded-[8px] outline-none block w-full h-8 px-3.5",children:m.map(f=>e.jsx("option",{value:f.value,children:f.label},f.value))}),e.jsx("p",{className:"text-xs leading-4 text-zinc-400 light:text-slate-600",children:(y=m.find(f=>f.value===u))==null?void 0:y.description})]})]}),u==="calculated"?e.jsx(de,{conditionLogic:h,setConditionLogic:M,conditions:_,setConditions:q}):e.jsx(he,{existingRule:r}),e.jsx(ae,{providerFieldName:"route_provider",modelFieldName:"route_model",label:s("model-router.rule-form.route-to-label"),description:s("model-router.rule-form.route-to-description"),defaultProvider:(r==null?void 0:r.route_provider)||"",defaultModel:(r==null?void 0:r.route_model)||""})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("button",{type:"button",onClick:l,className:"border border-zinc-600 light:border-slate-600 text-white light:text-slate-900 text-sm font-medium leading-5 rounded-[8px] h-[34px] px-3.5 hover:opacity-90 transition-opacity",children:s("model-router.rule-form.cancel")}),e.jsx("button",{type:"submit",disabled:o,className:"border-none flex items-center gap-x-1.5 text-sm font-medium leading-5 bg-zinc-50 light:bg-slate-900 text-zinc-900 light:text-white rounded-[8px] h-[34px] px-3.5 hover:opacity-90 transition-opacity disabled:opacity-50 disabled:cursor-not-allowed",children:o?e.jsxs(e.Fragment,{children:[e.jsx(I,{className:"h-4 w-4 animate-spin"}),s("model-router.rule-form.saving")]}):s(d?"model-router.rule-form.update-rule":"model-router.rule-form.create-rule")})]})]})})})}const je={gt:">",gte:">=",lt:"<",lte:"<=",eq:"=",neq:"!="};function ye(t){return{contains:t("model-router.rules.comparator-contains"),matches:t("model-router.rules.comparator-matches"),between:t("model-router.rules.comparator-between"),...je}}function A(t,l){return ye(t)[l]||l}function F({rule:t,isEditing:l,onEdit:a,onDelete:r,onToggle:c,dragHandleProps:n}){const{t:s}=g(),m=!t.enabled;return e.jsxs("div",{className:`group flex items-center gap-3 px-3 py-2 rounded-lg bg-zinc-800 light:bg-slate-100 transition-colors ${l?"ring-1 ring-blue-500/60":""} ${m?"opacity-50":""}`,children:[n?e.jsx("div",{...n,className:"cursor-grab shrink-0 text-zinc-400 light:text-slate-500 hover:text-white light:hover:text-slate-700 transition-colors","aria-label":s("model-router.rules.aria-drag-to-reorder"),children:e.jsx(te,{size:24,weight:"bold"})}):e.jsx("div",{className:"shrink-0 w-6"}),n&&e.jsxs("p",{className:"shrink-0 text-sm font-semibold text-zinc-400 light:text-slate-500 tabular-nums",children:["#",t.priority]}),e.jsxs("div",{className:"flex flex-col flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium leading-5 text-white light:text-slate-900 truncate",children:t.title}),t.type==="llm"?e.jsx("span",{className:"shrink-0 text-[10px] font-medium px-1.5 py-0.5 rounded bg-fuchsia-500/20 text-fuchsia-400 light:bg-fuchsia-100 light:text-fuchsia-700",children:s("model-router.rules.badge-llm")}):e.jsx("span",{className:"shrink-0 text-[10px] font-medium px-1.5 py-0.5 rounded bg-blue-500/20 text-blue-400 light:bg-blue-100 light:text-blue-700",children:s("model-router.rules.badge-calculated")})]}),t.type==="llm"?e.jsx(Ne,{rule:t}):e.jsx(we,{rule:t})]}),e.jsxs("div",{className:"flex items-center gap-x-3 shrink-0",children:[e.jsx(Y,{enabled:t.enabled,onChange:c,size:"md"}),e.jsx("button",{onClick:a,className:"border-none text-zinc-400 light:text-slate-500 hover:text-white light:hover:text-slate-900 transition-colors","aria-label":s("model-router.rules.aria-edit-rule"),children:e.jsx(G,{size:16,weight:"bold"})}),e.jsx("button",{onClick:r,className:"border-none text-zinc-400 light:text-slate-500 hover:text-red-400 light:hover:text-red-500 transition-colors","aria-label":s("model-router.rules.aria-delete-rule"),children:e.jsx(Z,{size:16,weight:"bold"})})]})]})}function Ne({rule:t}){return e.jsx("p",{className:"text-sm font-medium leading-5 text-zinc-400 light:text-slate-500 truncate",children:e.jsx(D,{i18nKey:"model-router.rules.llm-rule-body",values:{description:K(t.description,100),route:`${t.route_provider}/${t.route_model}`},components:{desc:e.jsx("span",{className:"font-mono text-fuchsia-400 light:text-fuchsia-500"}),route:e.jsx("span",{className:"text-zinc-200 light:text-slate-700"})}})})}function we({rule:t}){const{t:l}=g(),a=Array.isArray(t.conditions)?t.conditions:[],r=`${t.route_provider}/${t.route_model}`;if(a.length===0)return e.jsx("p",{className:"text-sm font-medium leading-5 text-zinc-400 light:text-slate-500 truncate",children:e.jsx(D,{i18nKey:"model-router.rules.calculated-no-conditions",values:{route:r},components:{route:e.jsx("span",{className:"text-zinc-200 light:text-slate-700"})}})});if(a.length===1){const s=a[0];return e.jsx("p",{className:"text-sm font-medium leading-5 text-zinc-400 light:text-slate-500 truncate",children:e.jsx(D,{i18nKey:"model-router.rules.calculated-single-condition",values:{property:s.property,comparator:A(l,s.comparator),value:s.value,route:r},components:{prop:e.jsx("span",{className:"font-mono text-blue-400 light:text-blue-500"}),val:e.jsx("span",{className:"font-mono text-blue-400 light:text-blue-500"}),route:e.jsx("span",{className:"text-zinc-200 light:text-slate-700"})}})})}const c=t.condition_logic==="OR"?"any":"all",n=a.map(s=>`${s.property} ${A(l,s.comparator)} "${s.value}"`).join(" AND ");return e.jsx("p",{className:"text-sm font-medium leading-5 text-zinc-400 light:text-slate-500 truncate",children:e.jsx(D,{i18nKey:"model-router.rules.calculated-multi-condition",values:{quantifier:l(`model-router.rules.quantifier-${c}`),conditions:K(n,100),route:r},components:{cond:e.jsx("span",{className:"font-mono text-blue-400 light:text-blue-500"}),route:e.jsx("span",{className:"text-zinc-200 light:text-slate-700"})}})})}function ze({rules:t,editingRule:l,onEdit:a,onDelete:r,onToggle:c,onDragEnd:n}){const{t:s}=g(),m=t.filter(o=>o.type==="calculated"),d=t.filter(o=>o.type==="llm");return e.jsxs("div",{className:"mt-6 flex flex-col gap-y-6",children:[m.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-wider text-zinc-500 light:text-slate-400 mb-2",children:s("model-router.rules.calculated-section-label")}),e.jsx(le,{onDragEnd:n,children:e.jsx(re,{droppableId:"calculated-rules",children:o=>e.jsxs("div",{ref:o.innerRef,...o.droppableProps,className:"flex flex-col gap-y-2",children:[m.map((i,u)=>e.jsx(oe,{draggableId:i.id.toString(),index:u,children:(x,h)=>e.jsx("div",{ref:x.innerRef,...x.draggableProps,className:h.isDragging?"opacity-60":"",children:e.jsx(F,{rule:i,isEditing:(l==null?void 0:l.id)===i.id,onEdit:()=>a(i),onDelete:()=>r(i),onToggle:()=>c(i),dragHandleProps:x.dragHandleProps})})},i.id)),o.placeholder]})})})]}),d.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-wider text-zinc-500 light:text-slate-400 mb-2",children:s("model-router.rules.llm-section-label")}),e.jsx("div",{className:"flex flex-col gap-y-2",children:d.map(o=>e.jsx(F,{rule:o,isEditing:(l==null?void 0:l.id)===o.id,onEdit:()=>a(o),onDelete:()=>r(o),onToggle:()=>c(o)},o.id))})]})]})}function Ce({onCreateRule:t}){const{t:l}=g();return e.jsxs("div",{className:"flex flex-col items-center justify-center gap-8 py-28",children:[e.jsxs("div",{className:"flex flex-col items-center gap-1.5 text-center",children:[e.jsx("p",{className:"text-base font-semibold leading-6 text-zinc-50 light:text-slate-900",children:l("model-router.rules.no-rules")}),e.jsx("p",{className:"text-sm font-medium leading-5 text-zinc-400 light:text-slate-500 max-w-[370px]",children:l("model-router.rules.empty-description")})]}),e.jsx("button",{onClick:t,className:"border-none flex items-center justify-center h-9 px-5 py-2.5 rounded-lg bg-slate-50 text-zinc-950 text-sm font-medium leading-5 hover:opacity-90 transition-opacity duration-200",children:l("model-router.rules.new-rule-button")})]})}function ke({routerId:t,routerName:l,rules:a,onRulesChanged:r}){const{t:c}=g(),{isOpen:n,openModal:s,closeModal:m}=J(),[d,o]=N.useState(null),i=()=>{o(null),s()},u=p=>{o(p),s()},x=()=>{m(),o(null)},h=async p=>{if(!window.confirm(c("model-router.rules.delete-confirm",{title:p.title})))return;const{success:y}=await k.deleteRule(t,p.id);y?r():C(c("model-router.rules.toast-delete-failed"),"error")},M=async p=>{const{rule:y}=await k.updateRule(t,p.id,{enabled:!p.enabled});y&&r()},_=async p=>{if(!p.destination)return;const y=a.filter(v=>v.type==="calculated"),f=a.filter(v=>v.type==="llm"),j=Array.from(y),[S]=j.splice(p.source.index,1);j.splice(p.destination.index,0,S);const b=[...j.map((v,w)=>({id:v.id,priority:w+1})),...f.map((v,w)=>({id:v.id,priority:j.length+w+1}))],{success:z}=await k.reorderRules(t,b);z?r():C(c("model-router.rules.toast-reorder-failed"),"error")},q=a&&a.length>0;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-end justify-between pb-6 border-b border-white/20 light:border-slate-300",children:[e.jsxs("div",{className:"flex flex-col gap-y-2",children:[e.jsx("p",{className:"text-lg font-semibold leading-7 text-white light:text-slate-900",children:l?c("model-router.rules.title-with-name",{name:l}):c("model-router.rules.title")}),e.jsx("p",{className:"text-xs leading-4 text-zinc-400 light:text-slate-600 max-w-[700px]",children:c("model-router.rules.description")})]}),q&&e.jsx("button",{onClick:i,className:"border-none shrink-0 flex items-center justify-center h-9 px-5 py-2.5 rounded-lg bg-slate-50 text-zinc-950 text-sm font-medium leading-5 hover:opacity-90 transition-opacity duration-200",children:c("model-router.rules.add-rule")})]}),q?e.jsx(ze,{rules:a,editingRule:d,onEdit:u,onDelete:h,onToggle:M,onDragEnd:_}):e.jsx(Ce,{onCreateRule:i}),n&&e.jsx(ve,{isOpen:n,closeModal:x,routerId:t,existingRule:d,nextPriority:((a==null?void 0:a.length)||0)+1,onSaved:r},(d==null?void 0:d.id)??"new")]})}function Me(){const{t}=g(),{id:l}=Q(),a=H(),[r,c]=N.useState(!0),[n,s]=N.useState(null),m=async()=>{const{router:d,error:o}=await k.get(l);if(!d){C(o||"Router not found","error"),a(V.settings.modelRouters());return}s(d),c(!1)};return N.useEffect(()=>{m()},[l]),r?e.jsx(O,{t,children:e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx(I,{className:"h-8 w-8 text-zinc-400 light:text-slate-400 animate-spin"})})}):e.jsx(O,{t,children:e.jsx(ke,{routerId:n.id,routerName:n.name,rules:n.rules||[],onRulesChanged:m})})}function O({t,children:l}){const a=H();return e.jsxs("div",{className:"w-screen h-screen overflow-hidden bg-zinc-950 light:bg-slate-50 flex md:mt-0 mt-6",children:[e.jsx(X,{}),e.jsx("div",{style:{height:R?"100%":"calc(100% - 32px)"},className:"relative md:ml-[2px] md:mr-[16px] md:my-[16px] md:rounded-2xl bg-zinc-900 light:bg-white light:border light:border-slate-300 w-full h-full overflow-y-scroll p-4 md:p-0",children:e.jsxs("div",{className:"flex flex-col w-full px-1 md:pl-6 md:pr-[50px] md:py-6 py-16",children:[e.jsxs("button",{onClick:()=>a(V.settings.modelRouters()),className:"border-none flex items-center gap-x-2 text-zinc-400 light:text-slate-500 hover:text-white light:hover:text-slate-900 text-sm mb-4 transition-colors",children:[e.jsx(ee,{className:"h-4 w-4"}),t("model-router.edit-router.back-to-routers")]}),l]})})]})}export{Me as default};