totem-llm 0.1.7 → 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.
- package/README.md +14 -2
- package/bin/totem-llm.js +2 -2
- package/collector/index.js +11 -1
- package/lib/config.js +2 -2
- package/lib/setup.js +1 -1
- package/package.json +1 -1
- package/server/index.js +11 -1
- package/server/models/systemSettings.js +1 -1
- package/server/models/workspace.js +2 -2
- package/server/public/assets/{404-b5c6b0dc.js → 404-56d107aa.js} +1 -1
- package/server/public/assets/RunDetailPage-da6aa377.js +1 -0
- package/server/public/assets/RunHistoryPage-2fcb4325.js +1 -0
- package/server/public/assets/{Trans-ca8f9cfe.js → Trans-820f1dad.js} +1 -1
- package/server/public/assets/{cron-1f15870f.js → cron-307d3fc6.js} +1 -1
- package/server/public/assets/{files-e19b0187.js → files-676613ed.js} +1 -1
- package/server/public/assets/index-01932fa1.js +1 -0
- package/server/public/assets/{index-a6e642d7.js → index-0bf4fb6b.js} +1 -1
- package/server/public/assets/index-166e238c.js +1 -0
- package/server/public/assets/{index-f86e167c.js → index-1c653bbf.js} +2 -2
- package/server/public/assets/index-1fe43260.js +1 -0
- package/server/public/assets/index-27cc497c.js +1 -0
- package/server/public/assets/{index-9cc77cb6.js → index-2aac91d0.js} +3 -3
- package/server/public/assets/index-2d84e5fe.js +1 -0
- package/server/public/assets/index-33ded078.js +1 -0
- package/server/public/assets/{index-2f526c2a.js → index-3cb59d82.js} +1 -1
- package/server/public/assets/{index-92d3b7bc.js → index-4277cf52.js} +1 -1
- package/server/public/assets/index-44ab5f11.js +1 -0
- package/server/public/assets/index-4750915e.js +1 -0
- package/server/public/assets/{index-ab72b353.js → index-574ed823.js} +2 -2
- package/server/public/assets/{index-3a2c5fd7.js → index-631fc042.js} +1 -1
- package/server/public/assets/index-65184421.js +1 -0
- package/server/public/assets/index-6679334a.js +1 -0
- package/server/public/assets/{index-6cdecde9.js → index-6bd7928a.js} +9 -9
- package/server/public/assets/index-6d56c896.js +18 -0
- package/server/public/assets/{index-925792fe.js → index-72544df5.js} +1 -1
- package/server/public/assets/index-80edec8f.js +1 -0
- package/server/public/assets/index-83825216.js +1 -0
- package/server/public/assets/index-841db586.js +1 -0
- package/server/public/assets/index-882e468e.js +1 -0
- package/server/public/assets/{index-ab35fb74.js → index-8c2371f5.js} +1 -1
- package/server/public/assets/{index-ed1cf67c.js → index-9ab52cfb.js} +2 -2
- package/server/public/assets/{index-ad8e77d2.js → index-a2978aa0.js} +2 -2
- package/server/public/assets/index-a29a8c19.js +3 -0
- package/server/public/assets/{index-62fee0f9.js → index-ae4f557d.js} +2 -2
- package/server/public/assets/{index-8132c765.js → index-b49f94f1.js} +1 -1
- package/server/public/assets/{index-3003ac1a.js → index-c453ccc8.js} +1 -1
- package/server/public/assets/index-cd6bc090.js +1 -0
- package/server/public/assets/{index-c391a2fa.js → index-d1d3d69a.js} +1 -1
- package/server/public/assets/index-d29fdeda.js +1 -0
- package/server/public/assets/index-d54b0575.js +1 -0
- package/server/public/assets/index-dcc00e8c.js +3 -0
- package/server/public/assets/index-e58bf860.js +1 -0
- package/server/public/assets/index-ec3efa1e.js +1 -0
- package/server/public/assets/index-ed9034ac.js +1 -0
- package/server/public/assets/{index-92574f3a.js → index-efee6d1f.js} +1 -1
- package/server/public/assets/index-f9305828.js +1 -0
- package/server/public/assets/index-fce187ac.js +1 -0
- package/server/public/assets/{main-8ad4162f.js → main-0b9e408b.js} +1 -1
- package/server/public/assets/{mcpServers-a175e8cf.js → mcpServers-1686e782.js} +1 -1
- package/server/public/assets/{moment-8a59df1b.js → moment-75486807.js} +1 -1
- package/server/public/assets/{purify-fbc9e8e2.js → purify-eb750cf4.js} +1 -1
- package/server/public/assets/{react-beautiful-dnd.esm-45ea8487.js → react-beautiful-dnd.esm-bb85eef1.js} +1 -1
- package/server/public/assets/{truncate-352eb33b.js → truncate-06273256.js} +1 -1
- package/server/public/index.js +27 -27
- package/server/utils/AiProviders/ollama/index.js +2 -0
- package/server/utils/chats/agents.js +7 -1
- package/server/utils/telegramBot/utils/verification.js +1 -1
- package/totem.features.cjs +5 -108
- package/server/public/assets/RunDetailPage-74b1e63a.js +0 -1
- package/server/public/assets/RunHistoryPage-9609436a.js +0 -1
- package/server/public/assets/index-25b2660c.js +0 -1
- package/server/public/assets/index-2a7c0b04.js +0 -1
- package/server/public/assets/index-3643e990.js +0 -1
- package/server/public/assets/index-39899779.js +0 -1
- package/server/public/assets/index-51f23c79.js +0 -1
- package/server/public/assets/index-56bb11a0.js +0 -1
- package/server/public/assets/index-65801ac6.js +0 -1
- package/server/public/assets/index-6710499a.js +0 -1
- package/server/public/assets/index-73aba4c6.js +0 -3
- package/server/public/assets/index-837868b3.js +0 -1
- package/server/public/assets/index-86e8a6b4.js +0 -1
- package/server/public/assets/index-8e43159f.js +0 -1
- package/server/public/assets/index-994c849a.js +0 -1
- package/server/public/assets/index-9f71774b.js +0 -1
- package/server/public/assets/index-9f7dabd6.js +0 -1
- package/server/public/assets/index-a0e2be61.js +0 -1
- package/server/public/assets/index-ac4d4b42.js +0 -1
- package/server/public/assets/index-c9b59c35.js +0 -1
- package/server/public/assets/index-dad0fb8d.js +0 -18
- package/server/public/assets/index-dd210692.js +0 -1
- package/server/public/assets/index-e28b0ead.js +0 -1
- package/server/public/assets/index-e4e9a9bd.js +0 -3
- package/server/public/assets/index-e6c540e1.js +0 -1
- package/server/public/assets/index-f984ef26.js +0 -1
- package/server/public/assets/index-fb26b60a.js +0 -1
package/README.md
CHANGED
|
@@ -13,6 +13,8 @@ While local AI is the core focus, Totem LLM supports both local and cloud-based
|
|
|
13
13
|
|
|
14
14
|
### 1. Install the package
|
|
15
15
|
|
|
16
|
+
Search for `terminal` in your applications and open it. Then run:
|
|
17
|
+
|
|
16
18
|
```bash
|
|
17
19
|
npm install -g totem-llm
|
|
18
20
|
```
|
|
@@ -25,7 +27,7 @@ This downloads Totem LLM and installs all server and collector dependencies auto
|
|
|
25
27
|
totem-llm start
|
|
26
28
|
```
|
|
27
29
|
|
|
28
|
-
On first run this performs one-time setup (creates
|
|
30
|
+
On first run this performs one-time setup (creates `~/totem-llm/`, migrates the database) then launches the server and document collector. Open [http://localhost:3001](http://localhost:3001) to access the UI.
|
|
29
31
|
|
|
30
32
|
### 3. Install to Desktop (optional)
|
|
31
33
|
|
|
@@ -40,7 +42,17 @@ totem-llm setup Run first-time setup without starting
|
|
|
40
42
|
totem-llm --help Show all options
|
|
41
43
|
```
|
|
42
44
|
|
|
43
|
-
> **Storage**: All data is kept in
|
|
45
|
+
> **Storage**: All data is kept in `~/totem-llm/` by default. Override with `TOTEM_STORAGE_DIR=/your/path totem-llm start`.
|
|
46
|
+
|
|
47
|
+
### Troubleshooting
|
|
48
|
+
|
|
49
|
+
**npm not found after node.js install**:
|
|
50
|
+
|
|
51
|
+
Common on windows, you may need to run `npm.cmd` instead of just `npm`
|
|
52
|
+
|
|
53
|
+
**totem-llm command not found after install**:
|
|
54
|
+
|
|
55
|
+
Run `npx.cmd totem-llm start` instead of `totem-llm start`, or add the npm global bin directory to your PATH.
|
|
44
56
|
|
|
45
57
|
> **Windows (PowerShell)**: If you see `cannot be loaded because running scripts is disabled`, run this once in PowerShell then retry:
|
|
46
58
|
> ```powershell
|
package/bin/totem-llm.js
CHANGED
|
@@ -64,7 +64,7 @@ function printHelp() {
|
|
|
64
64
|
|
|
65
65
|
Your Private AI
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
|
|
68
68
|
Usage:
|
|
69
69
|
totem-llm [command] [options]
|
|
70
70
|
|
|
@@ -80,7 +80,7 @@ Options:
|
|
|
80
80
|
--force (setup only) Regenerate configuration even if it already exists
|
|
81
81
|
|
|
82
82
|
Environment Variables:
|
|
83
|
-
TOTEM_STORAGE_DIR Override storage directory (default:
|
|
83
|
+
TOTEM_STORAGE_DIR Override storage directory (default: ~/totem-llm)
|
|
84
84
|
SERVER_PORT Override server port
|
|
85
85
|
COLLECTOR_PORT Override collector port (default: 8888)
|
|
86
86
|
|
package/collector/index.js
CHANGED
|
@@ -2,11 +2,21 @@ process.env.NODE_ENV === "development"
|
|
|
2
2
|
? require("dotenv").config({ path: `.env.${process.env.NODE_ENV}` })
|
|
3
3
|
: require("dotenv").config();
|
|
4
4
|
|
|
5
|
+
const os = require("os");
|
|
6
|
+
const path = require("path");
|
|
7
|
+
const { mkdirSync } = require("fs");
|
|
8
|
+
if (!process.env.STORAGE_DIR) {
|
|
9
|
+
process.env.STORAGE_DIR = path.join(os.homedir(), "totem-llm");
|
|
10
|
+
}
|
|
11
|
+
// Ensure all required storage subdirectories exist
|
|
12
|
+
for (const sub of ["documents", "vector-cache", "models", "direct-uploads", "generated-files", "comkey", "tmp"]) {
|
|
13
|
+
mkdirSync(path.join(process.env.STORAGE_DIR, sub), { recursive: true });
|
|
14
|
+
}
|
|
15
|
+
|
|
5
16
|
require("./utils/logger")();
|
|
6
17
|
const express = require("express");
|
|
7
18
|
const bodyParser = require("body-parser");
|
|
8
19
|
const cors = require("cors");
|
|
9
|
-
const path = require("path");
|
|
10
20
|
const { ACCEPTED_MIMES } = require("./utils/constants");
|
|
11
21
|
const { reqBody, getCollectorPort } = require("./utils/http");
|
|
12
22
|
const { processSingleFile } = require("./processSingleFile");
|
package/lib/config.js
CHANGED
|
@@ -4,10 +4,10 @@ import { existsSync, readFileSync } from "fs";
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Returns the storage directory where user data (database, documents, models, etc.) lives.
|
|
7
|
-
* Controlled by TOTEM_STORAGE_DIR env var; defaults to
|
|
7
|
+
* Controlled by TOTEM_STORAGE_DIR env var; defaults to ~/totem-llm.
|
|
8
8
|
*/
|
|
9
9
|
export function getStorageDir() {
|
|
10
|
-
return process.env.TOTEM_STORAGE_DIR ?? join(homedir(), "
|
|
10
|
+
return process.env.TOTEM_STORAGE_DIR ?? join(homedir(), "totem-llm");
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
/** Path to the persisted .env file inside the storage directory. */
|
package/lib/setup.js
CHANGED
|
@@ -108,7 +108,7 @@ async function runMigrations(serverDir, env) {
|
|
|
108
108
|
/**
|
|
109
109
|
* First-run (and subsequent startup) setup:
|
|
110
110
|
* 1. Creates storage directory + subdirectories
|
|
111
|
-
* 2. Generates secrets and writes
|
|
111
|
+
* 2. Generates secrets and writes ~/totem-llm/.env (skipped if already present)
|
|
112
112
|
* 3. Runs Prisma migrations (idempotent)
|
|
113
113
|
*
|
|
114
114
|
* @param {{ packageRoot: string, force?: boolean }} opts
|
package/package.json
CHANGED
package/server/index.js
CHANGED
|
@@ -2,11 +2,21 @@ process.env.NODE_ENV === "development"
|
|
|
2
2
|
? require("dotenv").config({ path: `.env.${process.env.NODE_ENV}` })
|
|
3
3
|
: require("dotenv").config();
|
|
4
4
|
|
|
5
|
+
const os = require("os");
|
|
6
|
+
const path = require("path");
|
|
7
|
+
const { mkdirSync } = require("fs");
|
|
8
|
+
if (!process.env.STORAGE_DIR) {
|
|
9
|
+
process.env.STORAGE_DIR = path.join(os.homedir(), "totem-llm");
|
|
10
|
+
}
|
|
11
|
+
// Ensure all required storage subdirectories exist
|
|
12
|
+
for (const sub of ["documents", "vector-cache", "models", "direct-uploads", "generated-files", "comkey", "tmp", "assets"]) {
|
|
13
|
+
mkdirSync(path.join(process.env.STORAGE_DIR, sub), { recursive: true });
|
|
14
|
+
}
|
|
15
|
+
|
|
5
16
|
require("./utils/logger")();
|
|
6
17
|
const express = require("express");
|
|
7
18
|
const bodyParser = require("body-parser");
|
|
8
19
|
const cors = require("cors");
|
|
9
|
-
const path = require("path");
|
|
10
20
|
const { reqBody } = require("./utils/http");
|
|
11
21
|
const { systemEndpoints } = require("./endpoints/system");
|
|
12
22
|
const { workspaceEndpoints } = require("./endpoints/workspaces");
|
|
@@ -36,7 +36,7 @@ function mergeStringField(target, source, fieldName, validator = null) {
|
|
|
36
36
|
const SystemSettings = {
|
|
37
37
|
/** A default system prompt that is used when no other system prompt is set or available to the function caller. */
|
|
38
38
|
saneDefaultSystemPrompt:
|
|
39
|
-
"
|
|
39
|
+
"You are Totem LLM. You are an AI that prioritizes consistent behavior with your history.",
|
|
40
40
|
protectedFields: ["multi_user_mode", "hub_api_key", "onboarding_complete"],
|
|
41
41
|
publicFields: [
|
|
42
42
|
"footer_data",
|
|
@@ -96,7 +96,7 @@ const Workspace = {
|
|
|
96
96
|
},
|
|
97
97
|
chatMode: (value) => {
|
|
98
98
|
if (!value || !Workspace.VALID_CHAT_MODES.includes(value))
|
|
99
|
-
return "
|
|
99
|
+
return "chat";
|
|
100
100
|
return value;
|
|
101
101
|
},
|
|
102
102
|
chatProvider: (value) => {
|
|
@@ -214,7 +214,7 @@ const Workspace = {
|
|
|
214
214
|
const workspace = await prisma.workspaces.create({
|
|
215
215
|
data: {
|
|
216
216
|
name: this.validations.name(name),
|
|
217
|
-
chatMode: "
|
|
217
|
+
chatMode: "chat",
|
|
218
218
|
...this.validateFields(additionalFields),
|
|
219
219
|
slug,
|
|
220
220
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,
|
|
1
|
+
import{j as e,K as t,X as s,c0 as a}from"../index.js";function l(){return e.jsxs("div",{className:"flex flex-col items-center justify-center min-h-screen bg-theme-bg-primary text-theme-text-primary gap-4 p-4 md:p-8 w-full",children:[e.jsx(t,{className:"w-16 h-16 text-theme-text-secondary"}),e.jsx("h1",{className:"text-xl md:text-2xl font-bold text-center",children:"404 - Page Not Found"}),e.jsx("p",{className:"text-theme-text-secondary text-center px-4",children:"The page you're looking for doesn't exist or has been moved."}),e.jsx("div",{className:"flex flex-col md:flex-row gap-3 md:gap-4 mt-4 w-full md:w-auto",children:e.jsxs(s,{to:"/",className:"flex items-center justify-center gap-2 px-4 py-2 bg-theme-bg-secondary text-theme-text-primary rounded-lg hover:bg-theme-sidebar-item-hover transition-all duration-300 w-full md:w-auto",children:[e.jsx(a,{className:"w-4 h-4"}),"Go Home"]})})]})}export{l as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as o,j as t,ab as G,aE as $,aM as K,V as C,u as y,aK as I,s as X,a5 as q,a4 as U,bK as V,b$ as B,c as j,l as W,b as Y,p as T,a1 as Z,i as Q,aZ as ee,bG as te,at as D}from"../index.js";import{I as se}from"./Brain-24e386d5.js";import{w as le}from"./ChatText-35275002.js";import{I as ne}from"./File-b92df2f3.js";import{R as ae}from"./Stop-4b47ae05.js";import{S as f,u as re}from"./usePolling-417bb099.js";import{c as ie,S as oe,T as J,a as de,b as ce,r as _}from"./files-676613ed.js";import{C as ue}from"./Copy-d323e545.js";import{H as xe,D as S}from"./purify-eb750cf4.js";import{t as E}from"./truncate-06273256.js";import{h as L}from"./moment-75486807.js";/* empty css */function w({title:e,icon:s,children:l,defaultOpen:n=!1,copyableContent:a=null}){const[i,r]=o.useState(n);return t.jsxs("div",{className:"border border-zinc-700 light:border-slate-400 rounded-lg overflow-hidden",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("button",{type:"button",onClick:()=>r(!i),className:"border-none flex-1 h-12 flex items-center gap-2 px-[18px] hover:bg-white/5 light:hover:bg-slate-100 transition-colors text-left",children:[i?t.jsx(G,{className:"h-4 w-4 text-zinc-50 light:text-slate-950"}):t.jsx($,{className:"h-4 w-4 text-zinc-50 light:text-slate-950"}),t.jsx(s,{className:"h-4 w-4 text-zinc-50 light:text-slate-950"}),t.jsx("span",{className:"text-sm font-medium text-zinc-50 light:text-slate-950",children:e})]}),a&&t.jsx(he,{content:a})]}),i&&t.jsx("div",{className:"px-[18px] py-3 border-t border-zinc-700 light:border-slate-400",children:l})]})}function he({content:e}){const[s,l]=o.useState(!1),n=async()=>{await ie(e),l(!0),setTimeout(()=>l(!1),2e3)};return t.jsx("button",{type:"button",onClick:n,disabled:s,className:"h-12 px-4 flex items-center hover:bg-white/5 light:hover:bg-slate-100 transition-colors",children:s?t.jsx(K,{size:20,className:"text-green-500"}):t.jsx(ue,{size:20,className:"text-zinc-50 light:text-slate-950"})})}const F=5e3;function H(e){return e?"github":"github-dark"}function O(e){const s=typeof e=="string"?X(e,e):e;if(typeof s!="object"||s===null)return null;const l=JSON.stringify(s,null,2),n=E(l,F),a=xe.highlight(n,{language:"json"}).value;return{__html:S.sanitize(a)}}function me({toolCall:e}){const[s,l]=o.useState(!1);return t.jsxs("div",{className:"border border-white/5 rounded-lg p-3 bg-theme-bg-primary/30",children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(C,{className:"h-3.5 w-3.5 text-blue-400"}),t.jsx("span",{className:"text-sm font-medium text-theme-text-primary",children:e.toolName})]}),t.jsx(ge,{toolCall:e})]}),t.jsx(pe,{toolCall:e}),t.jsx(be,{toolCall:e,showResult:s,setShowResult:l})]})}function ge({toolCall:e}){return e.timestamp?t.jsx("span",{className:"text-xs text-theme-text-secondary",children:L(e.timestamp).format("LTS")}):null}function pe({toolCall:e}){const{t:s}=y(),{isLight:l}=I();if(!e.arguments)return null;const n=O(e.arguments);return t.jsxs("div",{className:"mb-2",children:[t.jsx("span",{className:"text-xs text-theme-text-secondary",children:s("scheduledJobs.toolCall.arguments")}),n?t.jsx("pre",{className:`text-xs rounded-lg p-2 mt-1 overflow-x-auto white-scrollbar tool-call-scrollbar hljs ${H(l)}`,dangerouslySetInnerHTML:n}):t.jsx("pre",{className:"text-xs text-theme-text-primary bg-theme-bg-primary/50 rounded p-2 mt-1 overflow-x-auto white-scrollbar tool-call-scrollbar",children:typeof e.arguments=="string"?e.arguments:JSON.stringify(e.arguments,null,2)})]})}function be({toolCall:e,showResult:s,setShowResult:l}){const{t:n}=y(),{isLight:a}=I();if(!e.result)return null;const i=typeof e.result=="string"?e.result:JSON.stringify(e.result,null,2),r=E(i,F),d=O(i);return i?t.jsxs("div",{children:[t.jsx("button",{type:"button",onClick:()=>l(!s),className:"border-none text-xs text-blue-400 hover:text-blue-300 transition-colors",children:n(s?"scheduledJobs.toolCall.hideResult":"scheduledJobs.toolCall.showResult")}),s&&(d?t.jsx("pre",{className:`text-xs rounded-lg p-2 mt-1 overflow-x-auto max-h-64 overflow-y-auto whitespace-pre-wrap white-scrollbar tool-call-scrollbar hljs ${H(a)}`,dangerouslySetInnerHTML:d}):t.jsx("pre",{className:"text-xs text-theme-text-primary bg-theme-bg-primary/50 rounded p-2 mt-1 overflow-x-auto max-h-64 overflow-y-auto whitespace-pre-wrap white-scrollbar tool-call-scrollbar",children:r}))]}):null}const R={pptx:{badge:"PPT",bg:"bg-orange-100",text:"text-orange-800",label:e=>e("scheduledJobs.file.types.powerpoint")},ppt:{badge:"PPT",bg:"bg-orange-100",text:"text-orange-800",label:e=>e("scheduledJobs.file.types.powerpoint")},pdf:{badge:"PDF",bg:"bg-red-100",text:"text-red-800",label:e=>e("scheduledJobs.file.types.pdf")},doc:{badge:"DOC",bg:"bg-blue-100",text:"text-blue-800",label:e=>e("scheduledJobs.file.types.word")},docx:{badge:"DOC",bg:"bg-blue-100",text:"text-blue-800",label:e=>e("scheduledJobs.file.types.word")},xls:{badge:"XLS",bg:"bg-green-100",text:"text-green-800",label:e=>e("scheduledJobs.file.types.spreadsheet")},xlsx:{badge:"XLS",bg:"bg-green-100",text:"text-green-800",label:e=>e("scheduledJobs.file.types.spreadsheet")},csv:{badge:"CSV",bg:"bg-green-100",text:"text-green-800",label:e=>e("scheduledJobs.file.types.spreadsheet")},default:{badge:"FILE",bg:"bg-zinc-200",text:"text-zinc-800",label:e=>e("scheduledJobs.file.types.generic")}};function fe(e,s){var a,i;const l=((i=(a=e==null?void 0:e.split("."))==null?void 0:a.pop())==null?void 0:i.toLowerCase())??"txt",n=R[l]||R.default;return{...n,type:n.label(s)}}function je({file:e}){const{t:s}=y(),[l,n]=o.useState(!1),{badge:a,bg:i,text:r,type:d}=fe(e.filename,s),u=async()=>{if(!(l||!e.storageFilename)){n(!0);try{const h=await oe.download(e.storageFilename);if(!h)throw new Error("Failed to download file");const{saveAs:m}=await B(()=>import("../index.js").then(g=>g.F),["index.js","index.css"]);m(h,e.filename||e.storageFilename)}catch{j(s("scheduledJobs.file.downloadFailed"),"error")}finally{n(!1)}}};return t.jsxs("div",{className:"flex items-center justify-between bg-zinc-800 light:bg-slate-100 rounded-lg p-3",children:[t.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[t.jsx("div",{className:`${i} ${r} rounded-lg flex items-center justify-center shrink-0 h-10 w-10 text-xs font-semibold`,children:a}),t.jsxs("div",{className:"flex flex-col min-w-0",children:[t.jsx("p",{className:"text-sm text-white light:text-slate-950 truncate",children:e.filename||s("scheduledJobs.file.unknown")}),t.jsxs("p",{className:"text-sm text-zinc-400 light:text-slate-600",children:[q(e.fileSize,!0,1),e.fileSize&&d?" · ":"",d]})]})]}),t.jsx("button",{type:"button",onClick:u,disabled:l,title:s("scheduledJobs.file.download"),"aria-label":s("scheduledJobs.file.download"),className:"border-none text-zinc-400 light:text-slate-600 hover:text-zinc-50 light:hover:text-slate-950 transition-colors shrink-0 ml-4 disabled:opacity-50",children:l?t.jsx(U,{size:16,weight:"bold",className:"animate-spin"}):t.jsx(V,{size:16,weight:"bold"})})]})}function Me(){const{t:e}=y(),{id:s,runId:l}=W(),n=Y(),[a,i]=o.useState(!0),[r,d]=o.useState(null),[u,h]=o.useState(null),[m,g]=o.useState(!1),[N,p]=o.useState(!1);o.useEffect(()=>{v()},[l]);const v=async()=>{const c=await f.getRun(l);d(c.run),h(c.job),i(!1),c.run&&!c.run.readAt&&f.markRunRead(l)},P=(r==null?void 0:r.status)==="running"||(r==null?void 0:r.status)==="queued";re(v,3e3,P);const M=async()=>{g(!0);const{workspaceSlug:c,threadSlug:b,error:k}=await f.continueInThread(l);if(k||!c||!b){j(k||e("scheduledJobs.runDetail.threadFailed"),"error"),g(!1);return}n(T.workspace.thread(c,b))},A=async()=>{p(!0);const{success:c,error:b}=await f.killRun(l);if(p(!1),!c){j(b||e("scheduledJobs.toast.killFailed"),"error");return}j(e("scheduledJobs.toast.killed"),"success"),v()};if(a)return t.jsx(z,{children:t.jsx("p",{className:"text-zinc-400 light:text-slate-600 text-sm",children:e("scheduledJobs.runDetail.loading")})});if(!r)return t.jsx(z,{children:t.jsx("p",{className:"text-zinc-400 light:text-slate-600 text-sm",children:e("scheduledJobs.runDetail.notFound")})});const x=r.result||{};return t.jsxs(z,{children:[t.jsx(ye,{t:e,job:u,run:r,result:x,continuing:m,killing:N,onBack:()=>n(T.settings.scheduledJobRuns(s)),onContinueInThread:M,onKillRun:A}),t.jsxs("div",{className:"mt-6 space-y-4",children:[t.jsx(we,{t:e,prompt:u==null?void 0:u.prompt}),t.jsx(Ne,{t:e,error:r==null?void 0:r.error}),t.jsx(ve,{t:e,result:x}),t.jsx(Je,{t:e,result:x}),t.jsx(ze,{t:e,result:x}),t.jsx(Se,{t:e,result:x}),t.jsx(ke,{t:e,metrics:x==null?void 0:x.metrics})]})]})}function z({children:e}){return t.jsxs("div",{className:"w-screen h-screen overflow-hidden bg-theme-bg-container flex",children:[t.jsx(Z,{}),t.jsx("div",{style:{height:Q?"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:t.jsx("div",{className:"flex flex-col w-full px-1 md:pl-6 md:pr-[50px] md:py-6 py-16",children:e})})]})}function ye({t:e,job:s,run:l,result:n,continuing:a,killing:i,onBack:r,onContinueInThread:d,onKillRun:u}){function h(){return{completed:{text:e("scheduledJobs.status.completed"),style:"text-green-400 light:text-green-600"},failed:{text:e("scheduledJobs.status.failed"),style:"text-red-400 light:text-red-600"},timed_out:{text:e("scheduledJobs.status.timed_out"),style:"text-orange-400 light:text-orange-600"},running:{text:e("scheduledJobs.status.running"),style:"text-yellow-400 light:text-yellow-600"},queued:{text:e("scheduledJobs.status.queued"),style:"text-blue-400 light:text-blue-600"},default:{text:"—",style:"text-zinc-400 light:text-slate-600"}}}const m=h(),{text:g,style:N}=m[l.status]||m.default,p=["running","queued"].includes(l.status);return t.jsxs("div",{className:"w-full flex items-end justify-between gap-x-4 pb-6 border-white/10 light:border-zinc-300 border-b-2",children:[t.jsxs("div",{className:"flex flex-col gap-y-2",children:[t.jsxs("button",{type:"button",onClick:r,className:"border-none flex items-center gap-2 text-zinc-400 light:text-slate-600 hover:text-zinc-50 light:hover:text-slate-950 text-sm transition-colors w-fit",children:[t.jsx(ee,{className:"h-4 w-4"}),e("scheduledJobs.runDetail.back")]}),t.jsx("p",{className:"text-lg leading-7 font-semibold text-zinc-50 light:text-slate-950",children:e("scheduledJobs.runDetail.runHeading",{name:(s==null?void 0:s.name)||e("scheduledJobs.runDetail.unknownJob"),id:l.id})}),t.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[t.jsx("span",{className:N,children:g}),t.jsx("span",{className:"text-zinc-400 light:text-slate-600",children:L(l.startedAt).format("LTS")}),n.duration&&t.jsx("span",{className:"text-zinc-400 light:text-slate-600",children:e("scheduledJobs.runDetail.duration",{value:te(n.duration/1e3)})})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[p&&t.jsxs("button",{type:"button",onClick:u,disabled:i,title:e("scheduledJobs.runDetail.stopJob"),className:"border-none h-9 px-5 rounded-lg bg-red-500/20 text-red-400 light:bg-red-100 light:text-red-600 text-sm font-medium hover:bg-red-500/30 light:hover:bg-red-200 transition-colors disabled:opacity-50 shrink-0 flex items-center gap-2",children:[t.jsx(ae,{className:"h-4 w-4",weight:"bold"}),e(i?"scheduledJobs.runDetail.killing":"scheduledJobs.runDetail.stopJob")]}),l.status==="completed"&&t.jsx("button",{type:"button",onClick:d,disabled:a,className:"border-none h-9 px-5 rounded-lg bg-zinc-50 text-zinc-950 light:bg-slate-900 light:text-white text-sm font-medium hover:bg-zinc-200 light:hover:bg-slate-800 transition-colors disabled:opacity-50 shrink-0",children:e(a?"scheduledJobs.runDetail.creating":"scheduledJobs.runDetail.continueInThread")})]})]})}function we({t:e,prompt:s}){return t.jsxs("div",{className:"border border-zinc-700 light:border-slate-400 rounded-lg p-[18px]",children:[t.jsx("p",{className:"text-sm font-medium text-white light:text-slate-950 uppercase tracking-[1.4px] mb-1",children:e("scheduledJobs.runDetail.sections.prompt")}),t.jsx("p",{className:"text-sm text-zinc-400 light:text-slate-600 whitespace-pre-wrap",children:s||"—"})]})}function Ne({t:e,error:s}){return s?t.jsxs("div",{className:"border border-red-500/20 light:border-red-300 rounded-lg p-[18px] bg-red-500/5 light:bg-red-50",children:[t.jsx("p",{className:"text-sm font-medium text-red-400 light:text-red-600 uppercase tracking-[1.4px] mb-1",children:e("scheduledJobs.runDetail.sections.error")}),t.jsx("p",{className:"text-sm text-red-300 light:text-red-700",children:s})]}):null}function ve({t:e,result:s}){return!s.thoughts||s.thoughts.length===0?null:t.jsx(w,{title:e("scheduledJobs.runDetail.sections.thinking",{count:s.thoughts.length}),icon:se,children:t.jsx("div",{className:"space-y-2",children:s.thoughts.map((l,n)=>t.jsxs("div",{className:"flex items-start gap-2 text-sm text-theme-text-secondary",children:[t.jsxs("span",{className:"text-xs text-theme-text-secondary/50 mt-0.5 min-w-[20px]",children:[n+1,"."]}),t.jsx("span",{children:l})]},n))})})}function Je({t:e,result:s}){return!s.toolCalls||s.toolCalls.length===0?null:t.jsx(w,{title:e("scheduledJobs.runDetail.sections.toolCalls",{count:s.toolCalls.length}),icon:C,children:t.jsx("div",{className:"space-y-3",children:s.toolCalls.map((l,n)=>t.jsx(me,{toolCall:l},n))})})}function ze({t:e,result:s}){const l=s.outputs||[];return l.length===0?null:t.jsx(w,{title:e("scheduledJobs.runDetail.sections.files",{count:l.length}),icon:ne,defaultOpen:!0,children:t.jsx("div",{className:"space-y-2",children:l.map((n,a)=>t.jsx(je,{file:n.payload,type:n.type},a))})})}function Se({t:e,result:s}){var a;if(!s.text)return null;let l=null,n=s.text;return s.text.match(J)&&(l=(a=s.text.match(J))==null?void 0:a[0],l&&(l=l.replace(de,"").replace(ce,"").trim()),n=s.text.replace(J,"")),t.jsxs(w,{title:e("scheduledJobs.runDetail.sections.response"),icon:le,defaultOpen:!0,copyableContent:n,children:[l&&t.jsx("div",{className:"text-sm text-zinc-50/50 light:text-slate-950/50 markdown border-l-2 border-zinc-700 light:border-slate-400 pl-2 mb-4",children:t.jsx("span",{dangerouslySetInnerHTML:{__html:S.sanitize(_(l))}})}),t.jsx("div",{className:"text-sm text-zinc-50 light:text-slate-950 markdown",dangerouslySetInnerHTML:{__html:S.sanitize(_(n))}})]})}function ke({t:e,metrics:s}){if(!s||Object.keys(s).length===0||!s.prompt_tokens||!s.completion_tokens)return null;function l(n){return n.model?t.jsxs("span",{className:"font-mono text-xs font-normal text-zinc-50/50 light:text-slate-950/50",children:["(",n.model,")"]}):null}return t.jsxs("div",{className:"border border-zinc-700 light:border-slate-400 rounded-lg p-[18px]",children:[t.jsxs("p",{className:"text-sm font-semibold text-zinc-400 light:text-slate-600 uppercase tracking-[1.4px] mb-1",children:[e("scheduledJobs.runDetail.sections.metrics")," ",l(s)]}),t.jsxs("div",{className:"flex gap-6 text-sm text-zinc-400 light:text-slate-600",children:[s.prompt_tokens!=null&&t.jsxs("span",{children:[e("scheduledJobs.runDetail.metrics.promptTokens")," ",t.jsx("span",{className:"text-zinc-50 light:text-slate-950",children:D(s.prompt_tokens)})]}),s.completion_tokens!=null&&t.jsxs("span",{children:[e("scheduledJobs.runDetail.metrics.completionTokens")," ",t.jsx("span",{className:"text-zinc-50 light:text-slate-950",children:D(s.completion_tokens)})]})]})]})}export{Me as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as h,j as t,b as j,r as d,p as N,b_ as z,bG as S,c as o,l as R,a1 as k,i as H,aZ as A}from"../index.js";import{S as x,u as q}from"./usePolling-417bb099.js";import{R as C}from"./Stop-4b47ae05.js";import{h as y}from"./moment-75486807.js";import{h as T}from"./cron-307d3fc6.js";function D(e){return{completed:{text:e("scheduledJobs.status.completed"),style:"font-medium text-white light:text-slate-950"},failed:{text:e("scheduledJobs.status.failed"),style:"text-red-400 light:text-red-600"},timed_out:{text:e("scheduledJobs.status.timed_out"),style:"text-red-400 light:text-red-600"},running:{text:e("scheduledJobs.status.running"),style:"italic text-zinc-400 light:text-slate-600"},queued:{text:e("scheduledJobs.status.queued"),style:"italic text-zinc-400 light:text-slate-600"},default:{text:"—",style:"text-zinc-400 light:text-slate-600"}}}function I({status:e}){const{t:l}=h(),s=D(l),{text:a,style:n}=s[e]||s.default;return t.jsx("span",{className:`text-sm ${n}`,children:a})}function P(e){if(!e.completedAt||!e.startedAt)return"—";const l=y.duration(y(e.completedAt).diff(y(e.startedAt)));return S(l.asSeconds())}function _({run:e,jobId:l,onKilled:s}){const{t:a}=h(),n=j(),[m,c]=d.useState(!1),g=!e.readAt&&!["running","queued"].includes(e.status),p=["running","queued"].includes(e.status),u=async b=>{b.stopPropagation(),c(!0);const{success:r,error:f}=await x.killRun(e.id);if(c(!1),!r){o(f||a("scheduledJobs.toast.killFailed"),"error");return}o(a("scheduledJobs.toast.killed"),"success"),s==null||s()};return t.jsxs("button",{type:"button",onClick:()=>n(N.settings.scheduledJobRunDetail(l,e.id)),className:"border-none flex items-center px-4 h-14 hover:bg-white/5 light:hover:bg-slate-200 transition-colors text-left w-full",children:[t.jsxs("div",{className:"w-[200px] flex items-center gap-2 relative",children:[g&&t.jsx(z,{weight:"fill",className:"h-2 w-2 text-blue-400 light:text-blue-600 absolute -left-4"}),p&&t.jsx("button",{type:"button",onClick:u,disabled:m,title:a("scheduledJobs.runHistory.stopJob"),className:"border-none ml-2 p-1.5 rounded bg-red-500/20 text-red-400 light:bg-red-100 light:text-red-600 hover:bg-red-500/30 light:hover:bg-red-200 transition-colors disabled:opacity-50",children:t.jsx(C,{className:"h-3.5 w-3.5",weight:"bold"})}),t.jsx(I,{status:e.status})]}),t.jsx("span",{className:"w-[260px] text-sm font-medium text-white light:text-slate-950 truncate",children:new Date(e.startedAt).toLocaleString()}),t.jsx("span",{className:"w-[160px] text-sm font-medium text-white light:text-slate-950 truncate",children:P(e)}),t.jsx("span",{className:`flex-1 text-sm truncate pr-4 ${e.error?"text-red-400 light:text-red-600 italic":"font-medium text-white light:text-slate-950"}`,children:e.error||"—"})]})}function B(){const{t:e}=h(),{id:l}=R(),[s,a]=d.useState(null),[n,m]=d.useState([]),[c,g]=d.useState(!0),[p,u]=d.useState(!1),b=n.some(i=>i.status==="queued"||i.status==="running"),r=async()=>{const{runs:i}=await x.runs(l);m(i||[]),g(!1)};d.useEffect(()=>{x.get(l).then(({job:i})=>a(i)),r()},[l]),q(r,5e3);const f=async()=>{u(!0);const{success:i,skipped:v,error:J}=await x.trigger(l);if(u(!1),!i){o(J||e("scheduledJobs.toast.triggerFailed"),"error");return}v?o(e("scheduledJobs.toast.triggerSkipped","A run is already in progress for this job"),"info"):o(e("scheduledJobs.toast.triggered"),"success"),r()};return c?t.jsx(w,{job:s,children:t.jsx("div",{className:"flex flex-col items-center justify-center gap-8 py-24 text-center",children:t.jsx("p",{className:"text-zinc-400 light:text-slate-600 text-sm",children:e("scheduledJobs.loading")})})}):t.jsx(w,{job:s,children:t.jsxs("div",{className:"pt-8",children:[t.jsxs("div",{className:"flex items-center px-4 pb-[18px] text-xs font-semibold uppercase tracking-[1.4px] text-zinc-400 light:text-slate-600",children:[t.jsx("span",{className:"w-[200px]",children:e("scheduledJobs.runHistory.table.status")}),t.jsx("span",{className:"w-[260px]",children:e("scheduledJobs.runHistory.table.started")}),t.jsx("span",{className:"w-[160px]",children:e("scheduledJobs.runHistory.table.duration")}),t.jsx("span",{className:"flex-1",children:e("scheduledJobs.runHistory.table.error")})]}),t.jsx("div",{className:"h-px w-full bg-white/10 light:bg-slate-300"}),n.length===0?t.jsxs("div",{className:"flex flex-col items-center justify-center gap-8 py-24 text-center",children:[t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx("p",{className:"text-base font-semibold text-zinc-50 light:text-slate-950",children:e("scheduledJobs.runHistory.emptyTitle")}),t.jsx("p",{className:"text-sm font-medium text-zinc-400 light:text-slate-600",children:e("scheduledJobs.runHistory.emptySubtitle")})]}),t.jsx("button",{type:"button",onClick:f,disabled:p||b,className:"border-none h-9 px-5 rounded-lg bg-zinc-50 text-zinc-950 light:bg-slate-900 light:text-white text-sm font-medium hover:bg-zinc-200 light:hover:bg-slate-800 transition-colors disabled:opacity-50",children:e("scheduledJobs.runHistory.runNow")})]}):t.jsx("div",{className:"flex flex-col divide-y divide-white/5 light:divide-slate-200",children:n.map(i=>t.jsx(_,{run:i,jobId:s==null?void 0:s.id,onKilled:r},i.id))})]})})}function w({job:e,children:l}){const{t:s,i18n:a}=h(),n=j();return t.jsxs("div",{className:"w-screen h-screen overflow-hidden bg-theme-bg-container flex",children:[t.jsx(k,{}),t.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:t.jsxs("div",{className:"flex flex-col w-full px-1 md:pl-6 md:pr-[50px] md:py-6 py-16",children:[t.jsxs("div",{className:"w-full flex flex-col gap-y-2 pb-6 border-white/10 light:border-slate-300 border-b-2",children:[t.jsxs("button",{type:"button",onClick:()=>n(N.settings.scheduledJobs()),className:"border-none flex items-center gap-2 text-zinc-400 light:text-slate-600 hover:text-zinc-50 light:hover:text-slate-950 text-sm transition-colors w-fit",children:[t.jsx(A,{className:"h-4 w-4"}),s("scheduledJobs.runHistory.back")]}),t.jsx("p",{className:"text-lg leading-7 font-semibold text-zinc-50 light:text-slate-950",children:s("scheduledJobs.runHistory.title",{name:(e==null?void 0:e.name)||"..."})}),t.jsxs("p",{className:"text-xs text-zinc-400 light:text-slate-600",children:[s("scheduledJobs.runHistory.schedule")," ",t.jsx("code",{children:T(e==null?void 0:e.schedule,a.language)||"—"})]})]}),l]})})]})}export{B as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{aS as M,by as J,bz as U,r as x,bA as D,bB as S,bC as V,bD as L,bE as X}from"../index.js";var Y={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0};const Z=M(Y);var q=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;function I(e){var t={type:"tag",name:"",voidElement:!1,attrs:{},children:[]},n=e.match(/<\/?([^\s]+?)[/\s>]/);if(n&&(t.name=n[1],(Z[n[1]]||e.charAt(e.length-2)==="/")&&(t.voidElement=!0),t.name.startsWith("!--"))){var i=e.indexOf("-->");return{type:"comment",comment:i!==-1?e.slice(4,i):""}}for(var f=new RegExp(q),r=null;(r=f.exec(e))!==null;)if(r[0].trim())if(r[1]){var c=r[1].trim(),l=[c,""];c.indexOf("=")>-1&&(l=c.split("=")),t.attrs[l[0]]=l[1],f.lastIndex--}else r[2]&&(t.attrs[r[2]]=r[3].trim().substring(1,r[3].length-1));return t}var G=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,Q=/^\s*$/,_=Object.create(null);function W(e,t){switch(t.type){case"text":return e+t.content;case"tag":return e+="<"+t.name+(t.attrs?function(n){var i=[];for(var f in n)i.push(f+'="'+n[f]+'"');return i.length?" "+i.join(" "):""}(t.attrs):"")+(t.voidElement?"/>":">"),t.voidElement?e:e+t.children.reduce(W,"")+"</"+t.name+">";case"comment":return e+"<!--"+t.comment+"-->"}}var R={parse:function(e,t){t||(t={}),t.components||(t.components=_);var n,i=[],f=[],r=-1,c=!1;if(e.indexOf("<")!==0){var l=e.indexOf("<");i.push({type:"text",content:l===-1?e:e.substring(0,l)})}return e.replace(G,function(u,m){if(c){if(u!=="</"+n.name+">")return;c=!1}var v,b=u.charAt(1)!=="/",A=u.startsWith("<!--"),E=m+u.length,$=e.charAt(E);if(A){var h=I(u);return r<0?(i.push(h),i):((v=f[r]).children.push(h),i)}if(b&&(r++,(n=I(u)).type==="tag"&&t.components[n.name]&&(n.type="component",c=!0),n.voidElement||c||!$||$==="<"||n.children.push({type:"text",content:e.slice(E,e.indexOf("<",E))}),r===0&&i.push(n),(v=f[r-1])&&v.children.push(n),f[r]=n),(!b||n.voidElement)&&(r>-1&&(n.voidElement||n.name===u.slice(2,-1))&&(r--,n=r===-1?i:f[r]),!c&&$!=="<"&&$)){v=r===-1?i:f[r].children;var p=e.indexOf("<",E),o=e.slice(E,p===-1?void 0:p);Q.test(o)&&(o=" "),(p>-1&&r+v.length>=0||o!==" ")&&v.push({type:"text",content:o})}}),i},stringify:function(e){return e.reduce(function(t,n){return t+W("",n)},"")}};const B=(e,t)=>{if(!e)return!1;const n=e.props?e.props.children:e.children;return t?n.length>0:!!n},H=e=>{if(!e)return[];const t=e.props?e.props.children:e.children;return e.props&&e.props.i18nIsDynamicList?P(t):t},ee=e=>Array.isArray(e)&&e.every(x.isValidElement),P=e=>Array.isArray(e)?e:[e],te=(e,t)=>{const n={...t};return n.props=Object.assign(e.props,t.props),n},z=(e,t)=>{if(!e)return"";let n="";const i=P(e),f=t.transSupportBasicHtmlNodes&&t.transKeepBasicHtmlNodesFor?t.transKeepBasicHtmlNodesFor:[];return i.forEach((r,c)=>{if(D(r))n+=`${r}`;else if(x.isValidElement(r)){const{props:l,type:u}=r,m=Object.keys(l).length,v=f.indexOf(u)>-1,b=l.children;if(!b&&v&&!m)n+=`<${u}/>`;else if(!b&&(!v||m)||l.i18nIsDynamicList)n+=`<${c}></${c}>`;else if(v&&m===1&&D(b))n+=`<${u}>${b}</${u}>`;else{const A=z(b,t);n+=`<${c}>${A}</${c}>`}}else if(r===null)S("Trans: the passed in value is invalid - seems you passed in a null child.");else if(V(r)){const{format:l,...u}=r,m=Object.keys(u);if(m.length===1){const v=l?`${m[0]}, ${l}`:m[0];n+=`{{${v}}}`}else S("react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.",r)}else S("Trans: the passed in value is invalid - seems you passed in a variable like {number} - please pass in variables for interpolation as full objects like {{number}}.",r)}),n},ne=(e,t,n,i,f,r)=>{if(t==="")return[];const c=i.transKeepBasicHtmlNodesFor||[],l=t&&new RegExp(c.map(p=>`<${p}`).join("|")).test(t);if(!e&&!l&&!r)return[t];const u={},m=p=>{P(p).forEach(a=>{D(a)||(B(a)?m(H(a)):V(a)&&!x.isValidElement(a)&&Object.assign(u,a))})};m(e);const v=R.parse(`<0>${t}</0>`),b={...u,...f},A=(p,o,a)=>{const g=H(p),C=$(g,o.children,a);return ee(g)&&C.length===0||p.props&&p.props.i18nIsDynamicList?g:C},E=(p,o,a,g,C)=>{p.dummy?(p.children=o,a.push(x.cloneElement(p,{key:g},C?void 0:o))):a.push(...x.Children.map([p],d=>{const s={...d.props};return delete s.i18nIsDynamicList,x.createElement(d.type,{...s,key:g,ref:d.ref},C?null:o)}))},$=(p,o,a)=>{const g=P(p);return P(o).reduce((d,s,T)=>{const N=s.children&&s.children[0]&&s.children[0].content&&n.services.interpolator.interpolate(s.children[0].content,b,n.language);if(s.type==="tag"){let k=g[parseInt(s.name,10)];a.length===1&&!k&&(k=a[0][s.name]),k||(k={});const y=Object.keys(s.attrs).length!==0?te({props:s.attrs},k):k,w=x.isValidElement(y),j=w&&B(s,!0)&&!s.voidElement,F=l&&V(y)&&y.dummy&&!w,K=V(e)&&Object.hasOwnProperty.call(e,s.name);if(D(y)){const O=n.services.interpolator.interpolate(y,b,n.language);d.push(O)}else if(B(y)||j){const O=A(y,s,a);E(y,O,d,T)}else if(F){const O=$(g,s.children,a);E(y,O,d,T)}else if(Number.isNaN(parseFloat(s.name)))if(K){const O=A(y,s,a);E(y,O,d,T,s.voidElement)}else if(i.transSupportBasicHtmlNodes&&c.indexOf(s.name)>-1)if(s.voidElement)d.push(x.createElement(s.name,{key:`${s.name}-${T}`}));else{const O=$(g,s.children,a);d.push(x.createElement(s.name,{key:`${s.name}-${T}`},O))}else if(s.voidElement)d.push(`<${s.name} />`);else{const O=$(g,s.children,a);d.push(`<${s.name}>${O}</${s.name}>`)}else if(V(y)&&!w){const O=s.children[0]?N:null;O&&d.push(O)}else E(y,N,d,T,s.children.length!==1||!N)}else if(s.type==="text"){const k=i.transWrapTextNodes,y=r?i.unescape(n.services.interpolator.interpolate(s.content,b,n.language)):n.services.interpolator.interpolate(s.content,b,n.language);k?d.push(x.createElement(k,{key:`${s.name}-${T}`},y)):d.push(y)}return d},[])},h=$([{dummy:!0,children:e||[]}],v,P(e||[]));return H(h[0])};function se(e){let{children:t,count:n,parent:i,i18nKey:f,context:r,tOptions:c={},values:l,defaults:u,components:m,ns:v,i18n:b,t:A,shouldUnescape:E,...$}=e;const h=b||L();if(!h)return J("You will need to pass in an i18next instance by using i18nextReactModule"),t;const p=A||h.t.bind(h)||(j=>j),o={...U(),...h.options&&h.options.react};let a=v||p.ns||h.options&&h.options.defaultNS;a=D(a)?[a]:a||["translation"];const g=z(t,o),C=u||g||o.transEmptyNodeValue||f,{hashTransKey:d}=o,s=f||(d?d(g||C):g||C);h.options&&h.options.interpolation&&h.options.interpolation.defaultVariables&&(l=l&&Object.keys(l).length>0?{...l,...h.options.interpolation.defaultVariables}:{...h.options.interpolation.defaultVariables});const T=l||n!==void 0||!t?c.interpolation:{interpolation:{...c.interpolation,prefix:"#$?",suffix:"?$#"}},N={...c,context:r||c.context,count:n,...l,...T,defaultValue:C,ns:a},k=s?p(s,N):C;m&&Object.keys(m).forEach(j=>{const F=m[j];if(typeof F.type=="function"||!F.props||!F.props.children||k.indexOf(`${j}/>`)<0&&k.indexOf(`${j} />`)<0)return;function K(){return x.createElement(x.Fragment,null,F)}m[j]=x.createElement(K)});const y=ne(m||t,k,h,o,N,E),w=i!==void 0?i:o.defaultTransParent;return w?x.createElement(w,$,y):y}function ae(e){let{children:t,count:n,parent:i,i18nKey:f,context:r,tOptions:c={},values:l,defaults:u,components:m,ns:v,i18n:b,t:A,shouldUnescape:E,...$}=e;const{i18n:h,defaultNS:p}=x.useContext(X)||{},o=b||h||L(),a=A||o&&o.t.bind(o);return se({children:t,count:n,parent:i,i18nKey:f,context:r,tOptions:c,values:l,defaults:u,components:m,ns:v||a&&a.ns||p||o&&o.options&&o.options.defaultNS,i18n:o,t:A,shouldUnescape:E,...$})}export{ae as T};
|