@l10nmonster/server 3.0.0-alpha.15 → 3.0.0-alpha.17

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/index.js CHANGED
@@ -1,20 +1,3 @@
1
- // Global unhandled promise rejection handler for server
2
- process.on('unhandledRejection', (reason, promise) => {
3
- console.error('🚨 Unhandled Promise Rejection in L10n Monster Server:');
4
- console.error('Promise:', promise);
5
- console.error('Reason:', reason);
6
- if (reason instanceof Error && reason.stack) {
7
- console.error('Stack trace:', reason.stack);
8
- }
9
- // In server context, log but don't exit immediately to allow graceful handling
10
- console.error('This should be investigated and fixed!');
11
- });
12
-
13
- // Global uncaught exception handler
14
- process.on('uncaughtException', (error) => {
15
- console.error('🚨 Uncaught Exception in L10n Monster Server:', error);
16
- });
17
-
18
1
  import express from 'express';
19
2
  import cors from 'cors';
20
3
  import path from 'path';
@@ -27,7 +10,7 @@ import { setupChannelRoutes } from './routes/sources.js';
27
10
  import { setupTmRoutes } from './routes/tm.js';
28
11
  import { setupProviderRoute } from './routes/providers.js';
29
12
  import { setupDispatcherRoutes } from './routes/dispatcher.js';
30
- import { logVerbose } from '@l10nmonster/core';
13
+ import { logVerbose, consoleLog } from '@l10nmonster/core';
31
14
 
32
15
  const serverPackage = JSON.parse(readFileSync(path.join(import.meta.dirname, 'package.json'), 'utf-8'));
33
16
 
@@ -56,6 +39,7 @@ export default class ServeAction {
56
39
  // === Middleware ===
57
40
  app.use(cors());
58
41
  app.use(express.json());
42
+ app.use(express.json({ limit: '10mb' }));
59
43
 
60
44
  // === API Routes ===
61
45
  const apiRouter = express.Router();
@@ -78,7 +62,7 @@ export default class ServeAction {
78
62
  extensionRouter[method](path, handler);
79
63
  }
80
64
  app.use(`/api/ext/${name}`, extensionRouter);
81
- logVerbose`Mounted extension ${name} at /api/ext/${name}`;
65
+ consoleLog`Mounted extension ${name} at /api/ext/${name}`;
82
66
  }
83
67
 
84
68
  // API 404 handler - must come before the UI catch-all
@@ -105,21 +89,21 @@ export default class ServeAction {
105
89
  const server = app.listen(...listenArgs, async () => {
106
90
  const address = server.address();
107
91
 
108
- console.log(`🚀 L10n Monster Server v${serverPackage.version} started\n`);
92
+ consoleLog`L10n Monster Server v${serverPackage.version} started 🚀\n`;
109
93
 
110
94
  // Handle Unix domain sockets (string) vs TCP sockets (AddressInfo)
111
95
  if (typeof address === 'string') {
112
- console.log(' Listening on Unix socket:');
113
- console.log(` - ${address}`);
96
+ consoleLog` Listening on Unix socket:`;
97
+ consoleLog` - ${address}`;
114
98
 
115
99
  if (options.open && options.ui) {
116
- console.log('\n ⚠️ Cannot open browser for Unix domain socket. Please access the server manually.');
100
+ consoleLog`\n ⚠️ Cannot open browser for Unix domain socket. Please access the server manually.`;
117
101
  }
118
102
  } else {
119
103
  const boundPort = address.port;
120
104
  const boundAddress = address.address;
121
105
 
122
- console.log(' Available at:');
106
+ consoleLog` Available at:`;
123
107
 
124
108
  // Determine what URLs to show and what to open
125
109
  let openHost = host || 'localhost'; // Default to localhost for opening
@@ -127,8 +111,8 @@ export default class ServeAction {
127
111
  // If listening on all interfaces (0.0.0.0 or ::)
128
112
  if (!host || boundAddress === '0.0.0.0' || boundAddress === '::') {
129
113
  // Show localhost first
130
- console.log(` - http://localhost:${boundPort}`);
131
- console.log(` - http://127.0.0.1:${boundPort}`);
114
+ consoleLog` - http://localhost:${boundPort}`;
115
+ consoleLog` - http://127.0.0.1:${boundPort}`;
132
116
 
133
117
  // Get all network interfaces
134
118
  const interfaces = os.networkInterfaces();
@@ -136,29 +120,29 @@ export default class ServeAction {
136
120
  for (const addr of addresses) {
137
121
  // Skip internal interfaces and IPv6 link-local addresses
138
122
  if (!addr.internal && addr.family === 'IPv4') {
139
- console.log(` - http://${addr.address}:${boundPort} (${name})`);
123
+ consoleLog` - http://${addr.address}:${boundPort} (${name})`;
140
124
  }
141
125
  }
142
126
  }
143
127
  } else {
144
128
  // Specific address was bound
145
129
  openHost = boundAddress; // Use the bound address for opening
146
- console.log(` - http://${boundAddress}:${boundPort}`);
130
+ consoleLog` - http://${boundAddress}:${boundPort}`;
147
131
 
148
132
  // Also show localhost if we bound to 127.0.0.1
149
133
  if (boundAddress === '127.0.0.1') {
150
- console.log(` - http://localhost:${boundPort}`);
134
+ consoleLog` - http://localhost:${boundPort}`;
151
135
  }
152
136
  }
153
137
 
154
138
  if (options.open) {
155
139
  const openUrl = `http://${openHost}:${boundPort}`;
156
- console.log('');
157
- console.log(` Opening browser at: ${openUrl}`);
140
+ consoleLog``;
141
+ consoleLog` Opening browser at: ${openUrl}`;
158
142
  await open(openUrl);
159
143
  }
160
144
  }
161
- console.log('');
145
+ consoleLog``;
162
146
  });
163
147
 
164
148
  // Handle server binding errors
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@l10nmonster/server",
3
- "version": "3.0.0-alpha.15",
3
+ "version": "3.0.0-alpha.17",
4
4
  "description": "L10n Monster Manager",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -11,7 +11,7 @@
11
11
  "cors": "^2.8.5",
12
12
  "dotenv": "^17",
13
13
  "express": "^5.1.0",
14
- "lucide-react": "^0.525.0",
14
+ "lucide-react": "^0.553.0",
15
15
  "next-themes": "^0.4.6",
16
16
  "open": "^10.1.1",
17
17
  "react": "^19.1.0",
@@ -61,21 +61,21 @@
61
61
  "@types/react-dom": "^19.0.2",
62
62
  "@typescript-eslint/eslint-plugin": "^8.0.0",
63
63
  "@typescript-eslint/parser": "^8.0.0",
64
- "@vitejs/plugin-react": "^4.4.1",
65
- "@vitest/coverage-v8": "^3.1.2",
66
- "@vitest/ui": "^3.1.2",
64
+ "@vitejs/plugin-react": "^5",
65
+ "@vitest/coverage-v8": "^4",
66
+ "@vitest/ui": "^4",
67
67
  "eslint": "^9",
68
68
  "eslint-config-prettier": "^10",
69
69
  "eslint-plugin-prettier": "^5.0.0",
70
70
  "eslint-plugin-react": "^7.35.0",
71
- "eslint-plugin-react-hooks": "^5",
72
- "jsdom": "^26.1.0",
71
+ "eslint-plugin-react-hooks": "^7",
72
+ "jsdom": "^27",
73
73
  "prettier": "^3.5.0",
74
74
  "supertest": "^7.0.0",
75
75
  "typescript": "^5.7.3",
76
76
  "vite": "^7",
77
77
  "vite-tsconfig-paths": "^5.1.4",
78
- "vitest": "^3.1.2"
78
+ "vitest": "^4"
79
79
  },
80
80
  "engines": {
81
81
  "node": ">=22.11.0"
@@ -1,85 +1,114 @@
1
1
  import { logInfo, logVerbose } from '@l10nmonster/core';
2
2
 
3
+ async function createJob(mm, sourceLang, targetLang, guids, provider) {
4
+ logVerbose`Creating job with ${guids.length} TUs for provider ${provider}`;
5
+
6
+ // Expand TUs from guids to full TU data
7
+ const tm = mm.tmm.getTM(sourceLang, targetLang);
8
+ const expandedTus = await tm.queryByGuids(guids);
9
+
10
+ // Call the MonsterManager dispatcher with single provider
11
+ const jobs = await mm.dispatcher.createJobs(
12
+ { sourceLang, targetLang, tus: expandedTus },
13
+ { providerList: [provider], skipQualityCheck: true, skipGroupCheck: true }
14
+ );
15
+
16
+ // Find the job for this provider (if accepted)
17
+ const job = jobs.find(j => j.translationProvider === provider);
18
+
19
+ if (!job) {
20
+ logVerbose`Provider ${provider} did not accept any TUs`;
21
+ return null;
22
+ }
23
+
24
+ return job;
25
+ }
26
+
3
27
  export function setupDispatcherRoutes(router, mm) {
4
- router.post('/dispatcher/createJobs', async (req, res) => {
5
- logInfo`/dispatcher/createJobs`;
6
-
28
+ router.post('/dispatcher/estimateJob', async (req, res) => {
29
+ logInfo`/dispatcher/estimateJob`;
30
+
7
31
  try {
8
- const { sourceLang, targetLang, tus, providerList } = req.body;
9
-
32
+ const { sourceLang, targetLang, guids, provider } = req.body;
33
+
10
34
  // Validate required parameters
11
- if (!sourceLang || !targetLang || !tus || !providerList) {
35
+ if (!sourceLang || !targetLang || !guids || !provider) {
12
36
  return res.status(400).json({
13
- error: 'Missing required parameters: sourceLang, targetLang, tus, providerList'
37
+ error: 'Missing required parameters: sourceLang, targetLang, guids, provider'
14
38
  });
15
39
  }
16
-
17
- // Validate that tus is an array
18
- if (!Array.isArray(tus)) {
19
- return res.status(400).json({
20
- error: 'tus must be an array'
21
- });
22
- }
23
-
24
- // Validate that providerList is an array
25
- if (!Array.isArray(providerList)) {
40
+
41
+ // Validate that guids is an array
42
+ if (!Array.isArray(guids)) {
26
43
  return res.status(400).json({
27
- error: 'providerList must be an array'
44
+ error: 'guids must be an array'
28
45
  });
29
46
  }
30
-
31
- logVerbose`Fetching content of ${tus.length} TUs`;
32
- const tm = mm.tmm.getTM(sourceLang, targetLang);
33
- const guidsByChannel = {};
34
- for (const tu of tus) {
35
- const channel = tu.channel ?? '';
36
- guidsByChannel[channel] ??= new Set();
37
- guidsByChannel[channel].add(tu.guid);
38
- }
39
- const expandedTus = [];
40
- for (const [ channel, tus ] of Object.entries(guidsByChannel)) {
41
- const tusForChannel = await tm.queryByGuids(Array.from(tus), channel.length > 0 ? channel : undefined);
42
- expandedTus.push(tusForChannel);
47
+
48
+ // Create job with provider
49
+ const job = await createJob(mm, sourceLang, targetLang, guids, provider);
50
+
51
+ if (!job) {
52
+ return res.json(null);
43
53
  }
44
- // Call the MonsterManager dispatcher
45
- const jobs = await mm.dispatcher.createJobs({ sourceLang, targetLang, tus: expandedTus.flat(1) }, { providerList, skipQualityCheck: true, skipGroupCheck: true });
46
-
47
- logVerbose`Created ${jobs?.length || 0} jobs successfully`;
48
- res.json(jobs);
54
+
55
+ // Return job with guids array instead of full tus to minimize payload
56
+ const { tus: jobTus, ...jobWithoutTus } = job;
57
+ const estimatedJob = {
58
+ ...jobWithoutTus,
59
+ guids: jobTus.map(tu => tu.guid)
60
+ };
61
+
62
+ logVerbose`Estimated job with ${estimatedJob.guids.length} TUs`;
63
+ res.json(estimatedJob);
49
64
  } catch (error) {
50
- logInfo`Error creating jobs: ${error.message}`;
65
+ logInfo`Error estimating job: ${error.message}`;
51
66
  res.status(500).json({
52
- error: 'Failed to create jobs',
67
+ error: 'Failed to estimate job',
53
68
  message: error.message
54
69
  });
55
70
  }
56
71
  });
57
72
 
58
- router.post('/dispatcher/startJobs', async (req, res) => {
59
- logInfo`/dispatcher/startJobs`;
60
-
73
+ router.post('/dispatcher/startJob', async (req, res) => {
74
+ logInfo`/dispatcher/startJob`;
75
+
61
76
  try {
62
- const { jobs, instructions } = req.body;
63
-
77
+ const { sourceLang, targetLang, guids, provider, jobName, instructions } = req.body;
78
+
64
79
  // Validate required parameters
65
- if (!jobs || !Array.isArray(jobs)) {
80
+ if (!sourceLang || !targetLang || !guids || !provider) {
81
+ return res.status(400).json({
82
+ error: 'Missing required parameters: sourceLang, targetLang, guids, provider'
83
+ });
84
+ }
85
+
86
+ // Validate that guids is an array
87
+ if (!Array.isArray(guids)) {
66
88
  return res.status(400).json({
67
- error: 'Missing or invalid jobs parameter (must be an array)'
89
+ error: 'guids must be an array'
68
90
  });
69
91
  }
70
-
71
- logVerbose`Starting ${jobs.length} jobs with instructions: ${instructions || 'none'}`;
72
-
73
- // Call the MonsterManager dispatcher
74
- const result = await mm.dispatcher.startJobs(jobs, { instructions });
75
-
76
- logVerbose`Started ${result?.length || 0} jobs`;
92
+
93
+ // Create job with provider
94
+ const job = await createJob(mm, sourceLang, targetLang, guids, provider);
95
+
96
+ if (!job) {
97
+ return res.status(400).json({
98
+ error: `Provider ${provider} did not accept any TUs`
99
+ });
100
+ }
101
+
102
+ // Start the job
103
+ const result = await mm.dispatcher.startJobs([job], { jobName, instructions });
104
+
105
+ logVerbose`Started job with name: ${jobName || 'none'} and instructions: ${instructions || 'none'}`;
77
106
  res.json(result);
78
-
107
+
79
108
  } catch (error) {
80
- logInfo`Error starting jobs: ${error.message}`;
109
+ logInfo`Error starting job: ${error.message}`;
81
110
  res.status(500).json({
82
- error: 'Failed to start jobs',
111
+ error: 'Failed to start job',
83
112
  message: error.message
84
113
  });
85
114
  }
package/routes/tm.js CHANGED
@@ -65,7 +65,7 @@ export function setupTmRoutes(router, mm) {
65
65
  router.get('/tm/search', async (req, res) => {
66
66
  logInfo`/tm/search`;
67
67
  try {
68
- const { sourceLang, targetLang, page, limit, guid, nid, jobGuid, rid, sid, channel, nsrc, ntgt, notes, tconf, q, translationProvider, onlyTNotes, minTS, maxTS } = req.query;
68
+ const { sourceLang, targetLang, page, limit, guid, nid, jobGuid, rid, sid, channel, nsrc, ntgt, notes, tconf, q, translationProvider, onlyTNotes, active, minTS, maxTS } = req.query;
69
69
  const tm = mm.tmm.getTM(sourceLang, targetLang);
70
70
  const limitInt = limit ? parseInt(limit, 10) : 100;
71
71
  const pageInt = page ? parseInt(page, 10) : 1;
@@ -86,6 +86,7 @@ export function setupTmRoutes(router, mm) {
86
86
  maxTS,
87
87
  translationProvider: processSearchTerm(translationProvider),
88
88
  onlyTNotes: onlyTNotes === '1',
89
+ ...(active === '1' && { maxRank: 1 }),
89
90
  });
90
91
  logVerbose`Returned TM search results for ${data.length} entries`;
91
92
  res.json({ data, page: pageInt, limit: limitInt });
@@ -1 +1 @@
1
- import{r as o,j as e,B as c,T as a,V as h,F as C,v as b}from"./vendor-BVSmEsOp.js";import{g as S}from"./index-Dl1WS_Lc.js";const T=()=>{const[i,p]=o.useState({}),[x,l]=o.useState(!0),d=()=>{try{const t=sessionStorage.getItem("tmCart");return t?JSON.parse(t):{}}catch(t){return console.error("Error loading cart:",t),{}}},u=t=>{sessionStorage.setItem("tmCart",JSON.stringify(t)),window.dispatchEvent(new Event("cartUpdated"))},n=()=>{l(!0);const t=d();p(t),l(!1)},f=(t,r)=>{const s=d();s[t]&&(Array.isArray(s[t])?(s[t].splice(r,1),s[t].length===0&&delete s[t]):(s[t].tus.splice(r,1),s[t].tus.length===0&&delete s[t]),u(s),n())},j=()=>{u({}),n()},m=()=>Object.values(i).reduce((t,r)=>Array.isArray(r)?t+r.length:t+(r.tus?r.tus.length:0),0);if(o.useEffect(()=>{n()},[]),x)return e.jsx(c,{py:6,px:6,children:e.jsx(a,{children:"Loading cart..."})});const g=m();return e.jsx(c,{py:6,px:6,children:e.jsxs(h,{gap:6,align:"stretch",children:[e.jsxs(C,{align:"center",justify:"space-between",children:[e.jsx(a,{fontSize:"2xl",fontWeight:"bold",children:"Translation Memory Cart"}),g>0&&e.jsx(b,{colorPalette:"red",variant:"outline",onClick:j,children:"Empty Cart"})]}),g===0?e.jsxs(c,{p:8,textAlign:"center",borderWidth:"1px",borderRadius:"lg",bg:"bg.muted",children:[e.jsx(a,{fontSize:"lg",color:"fg.default",mb:2,children:"Your cart is empty"}),e.jsx(a,{color:"fg.muted",children:"Add translation units from the TM pages to get started"})]}):e.jsx(h,{gap:6,align:"stretch",children:Object.entries(i).map(([t,r])=>e.jsx(S,{langPairKey:t,tus:r,onRemoveTU:f},t))})]})})};export{T as default};
1
+ import{r as o,j as e,B as c,T as a,V as h,F as C,v as b}from"./vendor-BAKw9_tP.js";import{g as S}from"./index-CuIl8QRT.js";const T=()=>{const[i,p]=o.useState({}),[x,l]=o.useState(!0),d=()=>{try{const t=sessionStorage.getItem("tmCart");return t?JSON.parse(t):{}}catch(t){return console.error("Error loading cart:",t),{}}},u=t=>{sessionStorage.setItem("tmCart",JSON.stringify(t)),window.dispatchEvent(new Event("cartUpdated"))},n=()=>{l(!0);const t=d();p(t),l(!1)},f=(t,r)=>{const s=d();s[t]&&(Array.isArray(s[t])?(s[t].splice(r,1),s[t].length===0&&delete s[t]):(s[t].tus.splice(r,1),s[t].tus.length===0&&delete s[t]),u(s),n())},j=()=>{u({}),n()},m=()=>Object.values(i).reduce((t,r)=>Array.isArray(r)?t+r.length:t+(r.tus?r.tus.length:0),0);if(o.useEffect(()=>{n()},[]),x)return e.jsx(c,{py:6,px:6,children:e.jsx(a,{children:"Loading cart..."})});const g=m();return e.jsx(c,{py:6,px:6,children:e.jsxs(h,{gap:6,align:"stretch",children:[e.jsxs(C,{align:"center",justify:"space-between",children:[e.jsx(a,{fontSize:"2xl",fontWeight:"bold",children:"Translation Memory Cart"}),g>0&&e.jsx(b,{colorPalette:"red",variant:"outline",onClick:j,children:"Empty Cart"})]}),g===0?e.jsxs(c,{p:8,textAlign:"center",borderWidth:"1px",borderRadius:"lg",bg:"bg.muted",children:[e.jsx(a,{fontSize:"lg",color:"fg.default",mb:2,children:"Your cart is empty"}),e.jsx(a,{color:"fg.muted",children:"Add translation units from the TM pages to get started"})]}):e.jsx(h,{gap:6,align:"stretch",children:Object.entries(i).map(([t,r])=>e.jsx(S,{langPairKey:t,tus:r,onRemoveTU:f},t))})]})})};export{T as default};
@@ -0,0 +1 @@
1
+ import{a9 as C,r as F,i as R,j as e,B as n,S as L,T as r,A as T,V as x,F as c,a0 as w,g as f,v as D,a7 as N,a8 as U}from"./vendor-BAKw9_tP.js";import{f as B}from"./index-CuIl8QRT.js";function W(i){return i.map(a=>typeof a=="string"?a:`{{${a.t}}}`).join("")}function u(i){return new Date(i).toLocaleString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})}function J(i){return i===0?"Free":i==null?"Unknown":`$${i.toFixed(2)}`}function G(i){if(!i)return null;const a=/(https:\/\/[^\s]+)/g;return i.split(a).map((s,j)=>s.match(a)?e.jsx(r,{as:"a",href:s,target:"_blank",rel:"noopener noreferrer",color:"blue.600",textDecoration:"underline",_hover:{color:"blue.800"},children:s},j):s)}const q=()=>{const{jobGuid:i}=C(),[a,p]=F.useState({}),{data:s,isLoading:j,error:S}=R({queryKey:["job",i],queryFn:()=>B(`/api/tm/job/${i}`),retry:(t,o)=>o?.status===404?!1:t<3});if(j)return e.jsx(n,{display:"flex",justifyContent:"center",mt:10,children:e.jsx(L,{size:"xl"})});if(S)return e.jsx(n,{mt:5,px:6,children:e.jsxs(n,{p:4,bg:"red.subtle",borderRadius:"md",borderWidth:"1px",borderColor:"red.muted",children:[e.jsx(r,{fontWeight:"bold",color:"red.600",mb:2,children:"Error"}),e.jsx(r,{color:"red.600",children:S?.message||"Failed to fetch job data"})]})});if(!s)return e.jsx(n,{mt:5,px:6,children:e.jsx(T,{status:"warning",children:e.jsxs(n,{children:[e.jsx(r,{fontWeight:"bold",children:"Job Not Found"}),e.jsxs(r,{children:["Job with GUID ",i," was not found."]})]})})});const P=t=>{switch(t?.toLowerCase()){case"done":case"completed":return"green";case"failed":case"error":return"red";case"in-progress":case"running":return"orange";default:return"gray"}},A=(t,o)=>{const h=new Set(["jobGuid","guid","rid","sid","nsrc","ntgt","notes","q","prj"]),b=Object.entries(t).filter(([l])=>!h.has(l)),y=t.guid||o,m=a[y]||!1;return e.jsx(n,{p:4,borderWidth:"1px",borderRadius:"lg",bg:"white",shadow:"sm",mb:4,children:e.jsxs(x,{gap:3,align:"stretch",children:[e.jsx(c,{justify:"space-between",align:"start",wrap:"wrap",children:e.jsxs(x,{gap:1,align:"stretch",children:[e.jsxs(c,{align:"center",gap:2,children:[e.jsx(r,{fontSize:"xs",fontWeight:"bold",color:"fg.muted",children:"GUID:"}),e.jsx(r,{fontSize:"xs",fontFamily:"mono",color:"blue.600",wordBreak:"break-all",children:t.guid})]}),t.rid&&e.jsxs(c,{align:"center",gap:2,children:[e.jsx(r,{fontSize:"xs",fontWeight:"bold",color:"fg.muted",children:"RID:"}),e.jsx(r,{fontSize:"xs",fontFamily:"mono",color:"blue.600",wordBreak:"break-all",children:t.rid})]}),t.sid&&e.jsxs(c,{align:"center",gap:2,children:[e.jsx(r,{fontSize:"xs",fontWeight:"bold",color:"fg.muted",children:"SID:"}),e.jsx(r,{fontSize:"xs",fontFamily:"mono",color:"blue.600",children:t.sid})]})]})}),e.jsxs(n,{children:[e.jsx(r,{fontSize:"xs",fontWeight:"bold",color:"fg.muted",children:"Source:"}),e.jsx(r,{fontSize:"sm",p:2,bg:"blue.subtle",borderRadius:"md",dir:s.sourceLang?.startsWith("he")||s.sourceLang?.startsWith("ar")?"rtl":"ltr",children:Array.isArray(t.nsrc)?W(t.nsrc):t.nsrc})]}),e.jsxs(n,{children:[e.jsx(r,{fontSize:"xs",fontWeight:"bold",color:"fg.muted",children:"Target:"}),e.jsx(r,{fontSize:"sm",p:2,bg:"green.subtle",borderRadius:"md",dir:s.targetLang?.startsWith("he")||s.targetLang?.startsWith("ar")?"rtl":"ltr",children:Array.isArray(t.ntgt)?W(t.ntgt):t.ntgt})]}),t.notes&&e.jsxs(n,{children:[e.jsx(r,{fontSize:"xs",fontWeight:"bold",color:"fg.muted",children:"Notes:"}),e.jsxs(n,{p:2,bg:"yellow.subtle",borderRadius:"md",children:[t.notes.desc&&e.jsx(r,{fontSize:"xs",mb:2,whiteSpace:"pre-wrap",children:t.notes.desc}),t.notes.ph&&e.jsxs(n,{children:[e.jsx(r,{fontSize:"xs",fontWeight:"bold",mb:1,children:"Placeholders:"}),Object.entries(t.notes.ph).map(([l,d])=>e.jsxs(n,{mb:1,children:[e.jsx(r,{fontSize:"xs",fontFamily:"mono",color:"blue.600",children:l}),e.jsxs(r,{fontSize:"xs",color:"gray.600",children:[d.desc," (e.g., ",d.sample,")"]})]},l))]})]})]}),b.length>0&&e.jsxs(n,{children:[e.jsxs(c,{align:"center",justify:"space-between",mb:2,children:[e.jsx(D,{size:"xs",variant:"ghost",onClick:()=>p(l=>({...l,[y]:!m})),p:1,children:e.jsx(r,{fontSize:"xs",color:"blue.600",children:m?"Hide additional properties":`Show ${b.length} additional properties`})}),e.jsxs(w,{gap:2,children:[t.prj&&e.jsx(f,{size:"sm",colorPalette:"purple",children:t.prj}),t.q&&e.jsxs(f,{size:"sm",colorPalette:"blue",children:["Q: ",t.q]})]})]}),e.jsx(N,{open:m,children:e.jsx(U,{children:e.jsx(n,{p:3,bg:"gray.subtle",borderRadius:"md",children:b.map(([l,d])=>{let g=d;return l==="ts"&&typeof d=="number"?g=u(d):typeof d=="object"?g=JSON.stringify(d,null,2):g=String(d),e.jsxs(c,{align:"start",mb:2,gap:2,children:[e.jsxs(r,{fontSize:"xs",fontWeight:"bold",color:"gray.600",minW:"fit-content",children:[l,":"]}),e.jsx(r,{fontSize:"xs",fontFamily:"mono",color:"blue.600",flex:"1",wordBreak:"break-all",children:g})]},l)})})})})]})]})},t.guid||o)},k=new Set(["jobGuid","sourceLang","targetLang","translationProvider","updatedAt","taskName","inflight","status","statusDescription","tus","estimatedCost"]),z=Object.entries(s).filter(([t])=>!k.has(t));return e.jsxs(n,{p:6,minH:"100vh",bg:"gray.50",children:[e.jsxs(r,{fontSize:"3xl",fontWeight:"bold",mb:6,color:"fg.default",children:["Job ",s.jobGuid]}),e.jsxs(x,{gap:6,align:"stretch",maxW:"6xl",mx:"auto",children:[e.jsx(n,{p:6,bg:"white",borderRadius:"lg",shadow:"sm",children:e.jsxs(x,{gap:4,align:"stretch",children:[e.jsxs(c,{justify:"space-between",align:"center",wrap:"wrap",children:[e.jsxs(w,{gap:6,wrap:"wrap",align:"center",children:[e.jsxs(n,{children:[e.jsx(r,{fontSize:"sm",fontWeight:"bold",color:"fg.muted",children:"Language Pair:"}),e.jsxs(r,{fontSize:"sm",children:[s.sourceLang," → ",s.targetLang]})]}),e.jsxs(n,{children:[e.jsx(r,{fontSize:"sm",fontWeight:"bold",color:"fg.muted",children:"Provider:"}),e.jsx(r,{fontSize:"sm",children:s.translationProvider})]}),s.updatedAt&&e.jsxs(n,{children:[e.jsx(r,{fontSize:"sm",fontWeight:"bold",color:"fg.muted",children:"Updated:"}),e.jsx(r,{fontSize:"sm",children:u(new Date(s.updatedAt).getTime())})]}),s.taskName&&e.jsxs(n,{children:[e.jsx(r,{fontSize:"sm",fontWeight:"bold",color:"fg.muted",children:"Task:"}),e.jsx(r,{fontSize:"sm",children:s.taskName})]}),s.estimatedCost!==void 0&&e.jsxs(n,{children:[e.jsx(r,{fontSize:"sm",fontWeight:"bold",color:"fg.muted",children:"Estimated Cost:"}),e.jsx(r,{fontSize:"sm",children:J(s.estimatedCost)})]}),s.inflight?.length>0&&e.jsxs(f,{colorPalette:"orange",size:"sm",children:[s.inflight.length," TUs In Flight"]})]}),e.jsxs(n,{textAlign:"right",children:[e.jsx(f,{size:"lg",colorPalette:P(s.status),children:s.status?.toUpperCase()}),s.statusDescription&&e.jsx(r,{fontSize:"xs",color:"fg.muted",mt:1,children:G(s.statusDescription)})]})]}),z.length>0&&e.jsxs(n,{mt:4,pt:4,borderTop:"1px",borderColor:"border.default",children:[e.jsx(r,{fontSize:"sm",fontWeight:"bold",color:"fg.muted",mb:3,children:"Additional Properties"}),e.jsx(n,{bg:"gray.subtle",p:3,borderRadius:"md",children:z.map(([t,o])=>{let h=o;return t==="ts"&&typeof o=="number"?h=u(o):typeof o=="object"?h=JSON.stringify(o,null,2):h=String(o),e.jsxs(c,{align:"start",mb:2,gap:2,children:[e.jsxs(r,{fontSize:"xs",fontWeight:"bold",color:"gray.600",minW:"fit-content",children:[t,":"]}),e.jsx(r,{fontSize:"xs",fontFamily:"mono",color:"blue.600",flex:"1",wordBreak:"break-all",children:h})]},t)})})]})]})}),s.inflight?.length>0&&e.jsxs(n,{p:4,bg:"orange.subtle",borderRadius:"lg",borderWidth:"1px",borderColor:"orange.muted",children:[e.jsx(r,{fontSize:"sm",fontWeight:"bold",color:"orange.700",mb:2,children:"Translation In Progress"}),e.jsxs(r,{fontSize:"sm",color:"orange.600",children:[s.inflight.length," translation unit",s.inflight.length===1?"":"s"," ",s.inflight.length===1?"is":"are"," still being translated."]})]}),e.jsxs(n,{children:[e.jsxs(r,{fontSize:"xl",fontWeight:"bold",mb:4,children:["Translation Units (",s.tus?.length||0,")"]}),s.tus?.length>0?s.tus.map((t,o)=>A(t,o)):e.jsx(n,{p:6,bg:"white",borderRadius:"lg",textAlign:"center",children:e.jsx(r,{color:"fg.muted",children:"No translation units found."})})]})]})]})};export{q as default};
@@ -1 +1 @@
1
- import{a0 as m,r as l,i as P,Y as y,j as r,B as t,S as g,A as S,T as p,F as b}from"./vendor-BVSmEsOp.js";import{d as E,e as F,f as w}from"./index-Dl1WS_Lc.js";const q=()=>{const[x,d]=m(),[o,a]=l.useState(()=>x.get("provider")||null),{data:f={},isLoading:h,error:n}=P({queryKey:["info"],queryFn:()=>w("/api/info")}),c=f.providers||[],i=l.useMemo(()=>c.slice().sort((e,s)=>{const v=typeof e=="object"&&e?.id?e.id:e,j=typeof s=="object"&&s?.id?s.id:s;return v.localeCompare(j)}),[c]);y.useEffect(()=>{if(i.length>0&&!o){const e=i[0],s=typeof e=="object"&&e?.id?e.id:e;a(s),d({provider:s},{replace:!0})}},[i,o,d]);const u=e=>{a(e),d({provider:e})};return h?r.jsx(t,{display:"flex",justifyContent:"center",mt:10,children:r.jsx(g,{size:"xl"})}):n?r.jsx(t,{mt:5,px:6,children:r.jsx(S,{status:"error",children:r.jsxs(t,{children:[r.jsx(p,{fontWeight:"bold",children:"Error"}),r.jsx(p,{children:n?.message||"Failed to fetch provider data"})]})})}):r.jsx(t,{py:6,px:6,children:r.jsx(t,{borderWidth:"1px",borderRadius:"lg",bg:"white",shadow:"sm",overflow:"hidden",minH:"70vh",children:r.jsxs(b,{children:[r.jsx(E,{providers:i,selectedProvider:o,onProviderSelect:u}),r.jsx(F,{providerId:o})]})})})};export{q as default};
1
+ import{a1 as m,r as l,i as P,Z as y,j as r,B as t,S as g,A as S,T as p,F as b}from"./vendor-BAKw9_tP.js";import{d as E,e as F,f as w}from"./index-CuIl8QRT.js";const q=()=>{const[x,d]=m(),[o,a]=l.useState(()=>x.get("provider")||null),{data:f={},isLoading:h,error:n}=P({queryKey:["info"],queryFn:()=>w("/api/info")}),c=f.providers||[],i=l.useMemo(()=>c.slice().sort((e,s)=>{const v=typeof e=="object"&&e?.id?e.id:e,j=typeof s=="object"&&s?.id?s.id:s;return v.localeCompare(j)}),[c]);y.useEffect(()=>{if(i.length>0&&!o){const e=i[0],s=typeof e=="object"&&e?.id?e.id:e;a(s),d({provider:s},{replace:!0})}},[i,o,d]);const u=e=>{a(e),d({provider:e})};return h?r.jsx(t,{display:"flex",justifyContent:"center",mt:10,children:r.jsx(g,{size:"xl"})}):n?r.jsx(t,{mt:5,px:6,children:r.jsx(S,{status:"error",children:r.jsxs(t,{children:[r.jsx(p,{fontWeight:"bold",children:"Error"}),r.jsx(p,{children:n?.message||"Failed to fetch provider data"})]})})}):r.jsx(t,{py:6,px:6,children:r.jsx(t,{borderWidth:"1px",borderRadius:"lg",bg:"white",shadow:"sm",overflow:"hidden",minH:"70vh",children:r.jsxs(b,{children:[r.jsx(E,{providers:i,selectedProvider:o,onProviderSelect:u}),r.jsx(F,{providerId:o})]})})})};export{q as default};
@@ -1 +1 @@
1
- import{i as m,j as e,B as t,S as g,A as y,T as n,V as C,r as x,I as E,a6 as w,a7 as z,G as W}from"./vendor-BVSmEsOp.js";import{S as D,f as b}from"./index-Dl1WS_Lc.js";const L=({channelId:a})=>{const[d,f]=x.useState(!1),[i,h]=x.useState(!0),c=x.useRef(null);x.useEffect(()=>{const s=new IntersectionObserver(l=>{l.forEach(j=>{j.isIntersecting&&(f(!0),s.disconnect())})},{rootMargin:"200px",threshold:0});return c.current&&s.observe(c.current),()=>s.disconnect()},[]);const{data:r,isLoading:p,error:u}=m({queryKey:["channel",a],queryFn:()=>b(`/api/channel/${a}`),enabled:d}),o=r?.projects||[];return r?.ts,r?.store,e.jsxs(t,{ref:c,p:6,borderWidth:"2px",borderRadius:"lg",bg:"white",borderColor:"green.200",minW:"600px",maxW:"1200px",w:"100%",children:[e.jsxs(t,{display:"flex",alignItems:"center",gap:3,flexWrap:"wrap",mb:6,pb:4,borderBottom:"2px",borderColor:"green.100",children:[e.jsx(E,{"aria-label":i?"Collapse channel":"Expand channel",onClick:()=>h(!i),variant:"ghost",size:"sm",children:i?"▼":"▶"}),e.jsxs(t,{children:[e.jsx(n,{fontSize:"sm",color:"fg.muted",mb:1,children:"Channel"}),e.jsx(n,{fontSize:"lg",fontWeight:"bold",color:"green.600",children:a})]}),r&&e.jsx(t,{flex:"1",textAlign:"right",children:(()=>{const s=r?.ts,l=r?.store;if(!s)return e.jsx(n,{fontSize:"sm",color:"fg.muted",children:"Never snapped"});const S=new Date(s).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});return e.jsxs(e.Fragment,{children:[e.jsxs(n,{fontSize:"sm",color:"fg.muted",children:["Snapped on ",S]}),l&&e.jsxs(n,{fontSize:"sm",color:"fg.muted",children:["Imported from snap store"," ",e.jsx(n,{as:"span",fontWeight:"bold",color:"blue.600",children:l})]})]})})()}),p&&e.jsx(g,{size:"md"})]}),e.jsx(w,{open:i,children:e.jsx(z,{children:u?e.jsx(y,{status:"error",children:e.jsxs(t,{children:[e.jsxs(n,{fontWeight:"bold",children:["Error loading channel ",a]}),e.jsx(n,{children:u.message||"Unknown error"})]})}):p?e.jsx(t,{display:"flex",justifyContent:"center",py:8,children:e.jsx(n,{color:"fg.muted",children:"Loading channel data..."})}):o&&o.length>0?e.jsx(W,{templateColumns:{base:"1fr",lg:"repeat(auto-fit, minmax(600px, 1fr))"},gap:4,justifyItems:"center",children:o.sort((s,l)=>new Date(l.lastModified)-new Date(s.lastModified)).map((s,l)=>e.jsx(D,{item:s,channelId:a},l))}):o&&o.length===0?e.jsx(t,{display:"flex",justifyContent:"center",py:8,children:e.jsx(n,{color:"fg.muted",children:"This channel has no projects"})}):d?e.jsx(t,{display:"flex",justifyContent:"center",py:8,children:e.jsx(n,{color:"fg.muted",children:"No content available for this channel"})}):e.jsx(t,{display:"flex",justifyContent:"center",py:8,children:e.jsx(n,{color:"fg.muted",children:"Scroll down to load content..."})})})}),!i&&o&&o.length>0&&e.jsx(t,{display:"flex",justifyContent:"center",py:4,children:e.jsxs(n,{fontSize:"sm",color:"gray.600",fontStyle:"italic",children:[o.length," project",o.length!==1?"s":""," (collapsed)"]})})]})},I=()=>{const{data:a,isLoading:d,error:f}=m({queryKey:["info"],queryFn:()=>b("/api/info")}),i=a?.channels?.map(r=>r.id)||[],h=d,c=f;return h?e.jsx(t,{display:"flex",justifyContent:"center",mt:10,children:e.jsx(g,{size:"xl"})}):c?e.jsx(t,{mt:5,px:6,children:e.jsx(y,{status:"error",children:e.jsxs(t,{children:[e.jsx(n,{fontWeight:"bold",children:"Error"}),e.jsx(n,{children:c})]})})}):e.jsx(t,{py:6,px:6,children:e.jsxs(C,{gap:6,align:"center",children:[i.map(r=>e.jsx(L,{channelId:r},r)),i.length===0&&!h&&e.jsx(n,{mt:4,color:"fg.muted",children:"No channels found."})]})})};export{I as default};
1
+ import{i as m,j as e,B as t,S as g,A as y,T as n,V as C,r as x,I as E,a7 as w,a8 as z,G as W}from"./vendor-BAKw9_tP.js";import{S as D,f as b}from"./index-CuIl8QRT.js";const L=({channelId:a})=>{const[d,f]=x.useState(!1),[i,h]=x.useState(!0),c=x.useRef(null);x.useEffect(()=>{const s=new IntersectionObserver(l=>{l.forEach(j=>{j.isIntersecting&&(f(!0),s.disconnect())})},{rootMargin:"200px",threshold:0});return c.current&&s.observe(c.current),()=>s.disconnect()},[]);const{data:r,isLoading:p,error:u}=m({queryKey:["channel",a],queryFn:()=>b(`/api/channel/${a}`),enabled:d}),o=r?.projects||[];return r?.ts,r?.store,e.jsxs(t,{ref:c,p:6,borderWidth:"2px",borderRadius:"lg",bg:"white",borderColor:"green.200",minW:"600px",maxW:"1200px",w:"100%",children:[e.jsxs(t,{display:"flex",alignItems:"center",gap:3,flexWrap:"wrap",mb:6,pb:4,borderBottom:"2px",borderColor:"green.100",children:[e.jsx(E,{"aria-label":i?"Collapse channel":"Expand channel",onClick:()=>h(!i),variant:"ghost",size:"sm",children:i?"▼":"▶"}),e.jsxs(t,{children:[e.jsx(n,{fontSize:"sm",color:"fg.muted",mb:1,children:"Channel"}),e.jsx(n,{fontSize:"lg",fontWeight:"bold",color:"green.600",children:a})]}),r&&e.jsx(t,{flex:"1",textAlign:"right",children:(()=>{const s=r?.ts,l=r?.store;if(!s)return e.jsx(n,{fontSize:"sm",color:"fg.muted",children:"Never snapped"});const S=new Date(s).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});return e.jsxs(e.Fragment,{children:[e.jsxs(n,{fontSize:"sm",color:"fg.muted",children:["Snapped on ",S]}),l&&e.jsxs(n,{fontSize:"sm",color:"fg.muted",children:["Imported from snap store"," ",e.jsx(n,{as:"span",fontWeight:"bold",color:"blue.600",children:l})]})]})})()}),p&&e.jsx(g,{size:"md"})]}),e.jsx(w,{open:i,children:e.jsx(z,{children:u?e.jsx(y,{status:"error",children:e.jsxs(t,{children:[e.jsxs(n,{fontWeight:"bold",children:["Error loading channel ",a]}),e.jsx(n,{children:u.message||"Unknown error"})]})}):p?e.jsx(t,{display:"flex",justifyContent:"center",py:8,children:e.jsx(n,{color:"fg.muted",children:"Loading channel data..."})}):o&&o.length>0?e.jsx(W,{templateColumns:{base:"1fr",lg:"repeat(auto-fit, minmax(600px, 1fr))"},gap:4,justifyItems:"center",children:o.sort((s,l)=>new Date(l.lastModified)-new Date(s.lastModified)).map((s,l)=>e.jsx(D,{item:s,channelId:a},l))}):o&&o.length===0?e.jsx(t,{display:"flex",justifyContent:"center",py:8,children:e.jsx(n,{color:"fg.muted",children:"This channel has no projects"})}):d?e.jsx(t,{display:"flex",justifyContent:"center",py:8,children:e.jsx(n,{color:"fg.muted",children:"No content available for this channel"})}):e.jsx(t,{display:"flex",justifyContent:"center",py:8,children:e.jsx(n,{color:"fg.muted",children:"Scroll down to load content..."})})})}),!i&&o&&o.length>0&&e.jsx(t,{display:"flex",justifyContent:"center",py:4,children:e.jsxs(n,{fontSize:"sm",color:"gray.600",fontStyle:"italic",children:[o.length," project",o.length!==1?"s":""," (collapsed)"]})})]})},I=()=>{const{data:a,isLoading:d,error:f}=m({queryKey:["info"],queryFn:()=>b("/api/info")}),i=a?.channels?.map(r=>r.id)||[],h=d,c=f;return h?e.jsx(t,{display:"flex",justifyContent:"center",mt:10,children:e.jsx(g,{size:"xl"})}):c?e.jsx(t,{mt:5,px:6,children:e.jsx(y,{status:"error",children:e.jsxs(t,{children:[e.jsx(n,{fontWeight:"bold",children:"Error"}),e.jsx(n,{children:c})]})})}):e.jsx(t,{py:6,px:6,children:e.jsxs(C,{gap:6,align:"center",children:[i.map(r=>e.jsx(L,{channelId:r},r)),i.length===0&&!h&&e.jsx(n,{mt:4,color:"fg.muted",children:"No channels found."})]})})};export{I as default};
@@ -1 +1 @@
1
- import{a8 as C,u as w,r as b,ad as B,j as e,B as r,S as g,A as z,T as n,L as v,h as M,g as D,F as E}from"./vendor-BVSmEsOp.js";import{a as I,f as L}from"./index-Dl1WS_Lc.js";const k=()=>{const{channelId:l,prj:f}=C(),p=w(),h=b.useRef(null),{data:j,isLoading:S,error:m,fetchNextPage:u,hasNextPage:d,isFetchingNextPage:x}=B({queryKey:["projectTOC",l,f],queryFn:async({pageParam:t=0})=>{const c=await L(`/api/channel/${l}/${f}?offset=${t}&limit=100`);return{data:c,offset:t,limit:100,hasMore:c.length===100}},getNextPageParam:t=>t.hasMore?t.offset+t.limit:void 0,staleTime:3e4}),a=j?.pages.flatMap(t=>t.data)||[];b.useEffect(()=>{if(!d||x)return;const t=new IntersectionObserver(s=>{s[0].isIntersecting&&u()},{rootMargin:"100px",threshold:0});return h.current&&t.observe(h.current),()=>t.disconnect()},[d,x,u]);const A=t=>new Date(t).toLocaleString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"}),y=t=>{const s=new Date,c=new Date(t),o=Math.floor((s-c)/1e3),i=new Intl.RelativeTimeFormat("en",{numeric:"auto",style:"short"});return o<60?i.format(-o,"second"):o<3600?i.format(-Math.floor(o/60),"minute"):o<86400?i.format(-Math.floor(o/3600),"hour"):o<2592e3?i.format(-Math.floor(o/86400),"day"):o<31536e3?i.format(-Math.floor(o/2592e3),"month"):i.format(-Math.floor(o/31536e3),"year")};return S?e.jsx(r,{display:"flex",justifyContent:"center",mt:10,children:e.jsx(g,{size:"xl"})}):m?e.jsx(r,{mt:5,px:6,children:e.jsx(z,{status:"error",children:e.jsxs(r,{children:[e.jsx(n,{fontWeight:"bold",children:"Error"}),e.jsx(n,{children:m?.message||"Failed to fetch project data"})]})})}):e.jsxs(r,{py:6,px:6,children:[e.jsx(I,{channelId:l,project:f,onBackClick:()=>p("/sources"),backLabel:"Back to sources"}),a.length===0?e.jsx(r,{p:8,borderWidth:"1px",borderRadius:"md",bg:"white",textAlign:"center",children:e.jsx(n,{color:"fg.muted",children:"No resources found for this project."})}):e.jsxs(r,{bg:"white",borderRadius:"lg",shadow:"sm",overflow:"auto",maxH:"78vh",children:[e.jsxs(r,{as:"table",w:"100%",fontSize:"sm",children:[e.jsx(r,{as:"thead",bg:"blue.subtle",borderBottom:"2px",borderColor:"blue.muted",position:"sticky",top:0,zIndex:1,children:e.jsxs(r,{as:"tr",children:[e.jsx(r,{as:"th",p:4,textAlign:"left",borderBottom:"1px",borderColor:"border.default",children:e.jsx(n,{fontSize:"sm",fontWeight:"bold",color:"blue.600",children:"RESOURCE ID"})}),e.jsx(r,{as:"th",p:4,textAlign:"left",borderBottom:"1px",borderColor:"border.default",children:e.jsx(n,{fontSize:"sm",fontWeight:"bold",color:"blue.600",children:"SOURCE LANGUAGE"})}),e.jsx(r,{as:"th",p:4,textAlign:"center",borderBottom:"1px",borderColor:"border.default",children:e.jsx(n,{fontSize:"sm",fontWeight:"bold",color:"blue.600",children:"SEGMENTS"})}),e.jsx(r,{as:"th",p:4,textAlign:"center",borderBottom:"1px",borderColor:"border.default",children:e.jsx(n,{fontSize:"sm",fontWeight:"bold",color:"blue.600",children:"LAST MODIFIED"})})]})}),e.jsx(r,{as:"tbody",children:a.sort((t,s)=>new Date(s.modifiedAt)-new Date(t.modifiedAt)).map((t,s)=>e.jsxs(r,{as:"tr",_hover:{bg:"gray.subtle"},children:[e.jsx(r,{as:"td",p:4,borderBottom:"1px",borderColor:"border.subtle",children:e.jsx(v,{as:M,to:`/sources/${l}?rid=${encodeURIComponent(t.rid)}`,fontSize:"sm",fontFamily:"mono",color:"blue.600",wordBreak:"break-all",_hover:{textDecoration:"underline"},children:t.rid})}),e.jsx(r,{as:"td",p:4,borderBottom:"1px",borderColor:"border.subtle",children:e.jsx(D,{colorPalette:"purple",size:"sm",children:t.sourceLang})}),e.jsx(r,{as:"td",p:4,borderBottom:"1px",borderColor:"border.subtle",textAlign:"center",children:e.jsx(n,{fontSize:"sm",fontWeight:"semibold",color:"orange.600",children:t.segmentCount.toLocaleString()})}),e.jsx(r,{as:"td",p:4,borderBottom:"1px",borderColor:"border.subtle",textAlign:"center",children:e.jsx(n,{fontSize:"sm",color:"fg.muted",title:A(t.modifiedAt),children:y(t.modifiedAt)})})]},`${t.rid}-${s}`))})]}),d&&e.jsx(r,{ref:h,p:4,textAlign:"center",children:x&&e.jsxs(E,{justify:"center",align:"center",gap:2,children:[e.jsx(g,{size:"sm"}),e.jsx(n,{fontSize:"sm",color:"fg.muted",children:"Loading more resources..."})]})}),!d&&a.length>0&&e.jsx(r,{p:4,textAlign:"center",children:e.jsxs(n,{fontSize:"sm",color:"fg.muted",children:["All ",a.length," resources loaded"]})})]})]})};export{k as default};
1
+ import{a9 as C,u as w,r as b,ad as B,j as e,B as r,S as g,A as z,T as n,L as v,h as M,g as D,F as E}from"./vendor-BAKw9_tP.js";import{a as I,f as L}from"./index-CuIl8QRT.js";const k=()=>{const{channelId:l,prj:f}=C(),p=w(),h=b.useRef(null),{data:j,isLoading:S,error:m,fetchNextPage:u,hasNextPage:d,isFetchingNextPage:x}=B({queryKey:["projectTOC",l,f],queryFn:async({pageParam:t=0})=>{const c=await L(`/api/channel/${l}/${f}?offset=${t}&limit=100`);return{data:c,offset:t,limit:100,hasMore:c.length===100}},getNextPageParam:t=>t.hasMore?t.offset+t.limit:void 0,staleTime:3e4}),a=j?.pages.flatMap(t=>t.data)||[];b.useEffect(()=>{if(!d||x)return;const t=new IntersectionObserver(s=>{s[0].isIntersecting&&u()},{rootMargin:"100px",threshold:0});return h.current&&t.observe(h.current),()=>t.disconnect()},[d,x,u]);const A=t=>new Date(t).toLocaleString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"}),y=t=>{const s=new Date,c=new Date(t),o=Math.floor((s-c)/1e3),i=new Intl.RelativeTimeFormat("en",{numeric:"auto",style:"short"});return o<60?i.format(-o,"second"):o<3600?i.format(-Math.floor(o/60),"minute"):o<86400?i.format(-Math.floor(o/3600),"hour"):o<2592e3?i.format(-Math.floor(o/86400),"day"):o<31536e3?i.format(-Math.floor(o/2592e3),"month"):i.format(-Math.floor(o/31536e3),"year")};return S?e.jsx(r,{display:"flex",justifyContent:"center",mt:10,children:e.jsx(g,{size:"xl"})}):m?e.jsx(r,{mt:5,px:6,children:e.jsx(z,{status:"error",children:e.jsxs(r,{children:[e.jsx(n,{fontWeight:"bold",children:"Error"}),e.jsx(n,{children:m?.message||"Failed to fetch project data"})]})})}):e.jsxs(r,{py:6,px:6,children:[e.jsx(I,{channelId:l,project:f,onBackClick:()=>p("/sources"),backLabel:"Back to sources"}),a.length===0?e.jsx(r,{p:8,borderWidth:"1px",borderRadius:"md",bg:"white",textAlign:"center",children:e.jsx(n,{color:"fg.muted",children:"No resources found for this project."})}):e.jsxs(r,{bg:"white",borderRadius:"lg",shadow:"sm",overflow:"auto",maxH:"78vh",children:[e.jsxs(r,{as:"table",w:"100%",fontSize:"sm",children:[e.jsx(r,{as:"thead",bg:"blue.subtle",borderBottom:"2px",borderColor:"blue.muted",position:"sticky",top:0,zIndex:1,children:e.jsxs(r,{as:"tr",children:[e.jsx(r,{as:"th",p:4,textAlign:"left",borderBottom:"1px",borderColor:"border.default",children:e.jsx(n,{fontSize:"sm",fontWeight:"bold",color:"blue.600",children:"RESOURCE ID"})}),e.jsx(r,{as:"th",p:4,textAlign:"left",borderBottom:"1px",borderColor:"border.default",children:e.jsx(n,{fontSize:"sm",fontWeight:"bold",color:"blue.600",children:"SOURCE LANGUAGE"})}),e.jsx(r,{as:"th",p:4,textAlign:"center",borderBottom:"1px",borderColor:"border.default",children:e.jsx(n,{fontSize:"sm",fontWeight:"bold",color:"blue.600",children:"SEGMENTS"})}),e.jsx(r,{as:"th",p:4,textAlign:"center",borderBottom:"1px",borderColor:"border.default",children:e.jsx(n,{fontSize:"sm",fontWeight:"bold",color:"blue.600",children:"LAST MODIFIED"})})]})}),e.jsx(r,{as:"tbody",children:a.sort((t,s)=>new Date(s.modifiedAt)-new Date(t.modifiedAt)).map((t,s)=>e.jsxs(r,{as:"tr",_hover:{bg:"gray.subtle"},children:[e.jsx(r,{as:"td",p:4,borderBottom:"1px",borderColor:"border.subtle",children:e.jsx(v,{as:M,to:`/sources/${l}?rid=${encodeURIComponent(t.rid)}`,fontSize:"sm",fontFamily:"mono",color:"blue.600",wordBreak:"break-all",_hover:{textDecoration:"underline"},children:t.rid})}),e.jsx(r,{as:"td",p:4,borderBottom:"1px",borderColor:"border.subtle",children:e.jsx(D,{colorPalette:"purple",size:"sm",children:t.sourceLang})}),e.jsx(r,{as:"td",p:4,borderBottom:"1px",borderColor:"border.subtle",textAlign:"center",children:e.jsx(n,{fontSize:"sm",fontWeight:"semibold",color:"orange.600",children:t.segmentCount.toLocaleString()})}),e.jsx(r,{as:"td",p:4,borderBottom:"1px",borderColor:"border.subtle",textAlign:"center",children:e.jsx(n,{fontSize:"sm",color:"fg.muted",title:A(t.modifiedAt),children:y(t.modifiedAt)})})]},`${t.rid}-${s}`))})]}),d&&e.jsx(r,{ref:h,p:4,textAlign:"center",children:x&&e.jsxs(E,{justify:"center",align:"center",gap:2,children:[e.jsx(g,{size:"sm"}),e.jsx(n,{fontSize:"sm",color:"fg.muted",children:"Loading more resources..."})]})}),!d&&a.length>0&&e.jsx(r,{p:4,textAlign:"center",children:e.jsxs(n,{fontSize:"sm",color:"fg.muted",children:["All ",a.length," resources loaded"]})})]})]})};export{k as default};
@@ -1 +1 @@
1
- import{a8 as K,u as V,a0 as _,r as x,i as R,j as e,B as t,A as B,T as o,S as Q,F as p,g as f,ae as X,af as Z,ag as I,ah as F,l as J,m as Y,n as ee,o as re,p as te,q as oe,s as se,t as le,v as ne,a9 as A,aa as W,ab as D}from"./vendor-BVSmEsOp.js";import{a as ie,r as P,b as ae,f as O}from"./index-Dl1WS_Lc.js";function de(m){return m.map((u,j)=>{if(typeof u=="string")return u;if(u.v){const g=u.t==="x"?"purple.600":"orange.600";return e.jsx(o,{as:"span",fontFamily:"mono",color:g,fontWeight:"bold",children:u.v},j)}else return`{{${u.t}}}`})}const xe=()=>{const{channelId:m}=K(),u=V(),[j]=_(),g=j.get("rid"),S=j.get("guid"),[k,M]=x.useState("segments"),w=x.useRef(null),[c,y]=x.useState(new Set),[b,L]=x.useState(""),{data:l,isLoading:G,error:v}=R({queryKey:["resource",m,g],queryFn:()=>O(`/api/resource/${m}?rid=${encodeURIComponent(g)}`),enabled:!!g}),{data:ce={}}=R({queryKey:["info"],queryFn:()=>O("/api/info")}),{defaultGroup:z,defaultFormat:C,segments:d}=x.useMemo(()=>{if(!l?.segments)return{defaultGroup:null,defaultFormat:null,segments:[]};const r={},i={};l.segments.forEach(a=>{const h=a.group||"(no group)",T=a.mf||"text";r[h]=(r[h]||0)+1,i[T]=(i[T]||0)+1});const s=Object.keys(r).reduce((a,h)=>r[a]>r[h]?a:h,Object.keys(r)[0]),n=Object.keys(i).reduce((a,h)=>i[a]>i[h]?a:h,Object.keys(i)[0]);return{defaultGroup:s,defaultFormat:n,segments:l.segments}},[l?.segments]),N=(r,i)=>{const s=new Set(c);i?s.add(r):s.delete(r),y(s)},E=r=>{if(r){const i=new Set(d.map((s,n)=>n));y(i)}else y(new Set)},U=()=>{if(!b){alert("Please select a target language first");return}const i=Array.from(c).map(s=>d[s]).map(s=>({guid:s.guid,rid:l.id,sid:s.sid,nsrc:s.nstr,notes:s.notes}));ae(l.sourceLang,b,m,i),y(new Set),L("")},q=d.length>0&&c.size===d.length,$=c.size>0&&c.size<d.length,H=x.useMemo(()=>l?.targetLangs?l.targetLangs.filter(r=>r!==l.sourceLang):[],[l?.targetLangs,l?.sourceLang]);return x.useEffect(()=>{S&&d.length>0&&w.current&&setTimeout(()=>{w.current&&w.current.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"})},100)},[S,d,k]),g?G?e.jsx(t,{display:"flex",justifyContent:"center",mt:10,children:e.jsx(Q,{size:"xl"})}):v?e.jsx(t,{mt:5,px:6,children:e.jsx(B,{status:"error",children:e.jsxs(t,{children:[e.jsx(o,{fontWeight:"bold",children:"Error"}),e.jsx(o,{children:v?.message||"Failed to fetch resource data"})]})})}):e.jsxs(t,{py:6,px:6,h:"100vh",display:"flex",flexDirection:"column",children:[e.jsx(ie,{channelId:l.channel,project:l.prj,resource:l.id,onBackClick:()=>u(`/sources/${m}/${l.prj}`),backLabel:"Back to project",extraContent:e.jsxs(p,{gap:4,align:"center",wrap:"wrap",children:[e.jsxs(t,{children:[e.jsx(o,{fontSize:"sm",color:"fg.muted",mb:1,children:"Source Language"}),e.jsx(f,{colorPalette:"blue",size:"sm",children:l.sourceLang})]}),e.jsxs(t,{children:[e.jsx(o,{fontSize:"sm",color:"fg.muted",mb:1,children:"Resource Format"}),e.jsx(f,{colorPalette:"purple",size:"sm",children:l.resourceFormat})]}),z&&e.jsxs(t,{children:[e.jsx(o,{fontSize:"sm",color:"fg.muted",mb:1,children:"Default Group"}),e.jsx(f,{colorPalette:"gray",size:"sm",children:z})]}),C&&e.jsxs(t,{children:[e.jsx(o,{fontSize:"sm",color:"fg.muted",mb:1,children:"Default Format"}),e.jsx(f,{colorPalette:"cyan",size:"sm",children:C})]}),e.jsxs(t,{children:[e.jsxs(o,{fontSize:"sm",color:"fg.muted",mb:1,children:["Target Languages (",l.targetLangs.length,")"]}),e.jsx(p,{wrap:"wrap",gap:1,children:l.targetLangs.map(r=>e.jsx(f,{colorPalette:"orange",size:"sm",children:r},r))})]}),l.modified&&e.jsxs(t,{children:[e.jsx(o,{fontSize:"sm",color:"fg.muted",mb:1,children:"Last Modified"}),e.jsx(o,{fontSize:"sm",color:"fg.default",title:new Date(l.modified).toLocaleString("en-US",{weekday:"long",year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:"short"}),children:(()=>{const r=new Date,i=new Date(l.modified),s=Math.floor((r-i)/1e3),n=new Intl.RelativeTimeFormat("en",{numeric:"auto",style:"short"});return s<60?n.format(-s,"second"):s<3600?n.format(-Math.floor(s/60),"minute"):s<86400?n.format(-Math.floor(s/3600),"hour"):s<2592e3?n.format(-Math.floor(s/86400),"day"):s<31536e3?n.format(-Math.floor(s/2592e3),"month"):n.format(-Math.floor(s/31536e3),"year")})()})]})]})}),e.jsx(t,{flex:"1",display:"flex",flexDirection:"column",children:e.jsxs(X,{value:k,onValueChange:r=>M(r.value),children:[e.jsxs(Z,{mb:4,children:[e.jsxs(I,{value:"segments",children:["Segments (",d.length,")"]}),e.jsx(I,{value:"raw",children:"Raw Content"})]}),e.jsxs(F,{value:"segments",flex:"1",display:"flex",flexDirection:"column",children:[c.size>0&&e.jsx(t,{bg:"blue.subtle",borderBottom:"1px",borderColor:"blue.muted",shadow:"md",borderLeft:"4px",borderLeftColor:"blue.500",px:6,py:4,mb:4,borderRadius:"md",children:e.jsxs(p,{align:"center",justify:"space-between",children:[e.jsxs(o,{fontSize:"md",fontWeight:"semibold",color:"blue.700",children:[c.size," ",c.size===1?"segment":"segments"," selected"]}),e.jsxs(p,{align:"center",gap:3,children:[e.jsx(o,{fontSize:"sm",color:"blue.600",children:"Target Language:"}),e.jsxs(J,{size:"sm",width:"200px",value:b?[b]:[],positioning:{strategy:"absolute",placement:"bottom-start",flip:!0,gutter:4},children:[e.jsxs(Y,{children:[e.jsx(o,{fontSize:"sm",flex:"1",textAlign:"left",children:b||"Select target language"}),e.jsx(ee,{})]}),e.jsx(re,{children:e.jsx(te,{zIndex:1e3,bg:"white",borderWidth:"1px",borderColor:"border.default",borderRadius:"md",shadow:"lg",maxH:"200px",overflow:"auto",children:H.map(r=>e.jsxs(oe,{item:r,value:r,onClick:()=>L(r),children:[e.jsx(se,{children:r}),e.jsx(le,{})]},r))})})]}),e.jsx(ne,{colorPalette:"blue",onClick:U,disabled:!b,size:"sm",children:"Add to Cart"})]})]})}),e.jsxs(t,{flex:"1",bg:"white",borderRadius:"lg",shadow:"sm",overflow:"auto",children:[e.jsxs(t,{as:"table",w:"100%",fontSize:"sm",tableLayout:"fixed",children:[e.jsx(t,{as:"thead",position:"sticky",top:0,bg:"blue.subtle",zIndex:1,borderBottom:"2px",borderColor:"blue.muted",shadow:"sm",children:e.jsxs(t,{as:"tr",children:[e.jsx(t,{as:"th",p:3,borderBottom:"1px",borderColor:"border.default",minW:"60px",textAlign:"center",children:e.jsxs(A,{checked:q,onCheckedChange:r=>E(r.checked),children:[e.jsx(W,{ref:r=>{r&&(r.indeterminate=$)}}),e.jsx(D,{})]})}),e.jsx(t,{as:"th",p:3,textAlign:"left",borderBottom:"1px",borderColor:"border.default",w:"12%",children:e.jsx(o,{fontSize:"sm",fontWeight:"bold",color:"blue.600",children:"GUID"})}),e.jsx(t,{as:"th",p:3,textAlign:"left",borderBottom:"1px",borderColor:"border.default",w:"8%",children:e.jsx(o,{fontSize:"sm",fontWeight:"bold",color:"blue.600",children:"NID"})}),e.jsx(t,{as:"th",p:3,textAlign:"left",borderBottom:"1px",borderColor:"border.default",w:"20%",children:e.jsx(o,{fontSize:"sm",fontWeight:"bold",color:"blue.600",children:"STRING ID"})}),e.jsx(t,{as:"th",p:3,textAlign:"left",borderBottom:"1px",borderColor:"border.default",w:"35%",children:e.jsx(o,{fontSize:"sm",fontWeight:"bold",color:"blue.600",children:"SOURCE TEXT"})}),e.jsx(t,{as:"th",p:3,textAlign:"left",borderBottom:"1px",borderColor:"border.default",w:"20%",children:e.jsx(o,{fontSize:"sm",fontWeight:"bold",color:"blue.600",children:"NOTES"})})]})}),e.jsx(t,{as:"tbody",children:d.map((r,i)=>{const s=S&&r.guid===S;return e.jsxs(t,{as:"tr",ref:s?w:null,bg:s?"yellow.subtle":"transparent",_hover:{bg:s?"yellow.muted":"gray.subtle"},borderLeft:s?"4px":"0",borderLeftColor:s?"yellow.solid":"transparent",children:[e.jsx(t,{as:"td",p:3,borderBottom:"1px",borderColor:"border.subtle",textAlign:"center",children:e.jsxs(A,{checked:c.has(i),onCheckedChange:n=>N(i,n.checked),children:[e.jsx(W,{}),e.jsx(D,{})]})}),e.jsx(t,{as:"td",p:3,borderBottom:"1px",borderColor:"border.subtle",children:e.jsx(o,{fontSize:"xs",fontFamily:"mono",color:"orange.600",userSelect:"all",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxW:"100px",title:r.guid,children:r.guid})}),e.jsx(t,{as:"td",p:3,borderBottom:"1px",borderColor:"border.subtle",children:e.jsx(o,{fontSize:"xs",fontFamily:"mono",color:"orange.600",userSelect:"all",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxW:"100px",title:r.nid||"",children:r.nid||""})}),e.jsx(t,{as:"td",p:3,borderBottom:"1px",borderColor:"border.subtle",children:e.jsx(o,{fontSize:"xs",fontFamily:"mono",color:"purple.600",wordBreak:"break-all",children:r.sid})}),e.jsxs(t,{as:"td",p:3,borderBottom:"1px",borderColor:"border.subtle",children:[e.jsx(o,{fontSize:"xs",noOfLines:3,children:de(r.nstr)}),(()=>{const n=r.group||"(no group)";return n!==z?e.jsxs(o,{fontSize:"xs",color:"gray.600",fontStyle:"italic",mt:1,children:["Group:",e.jsx(f,{colorPalette:"gray",size:"sm",ml:1,children:n})]}):null})(),(()=>{const n=r.mf||"text";return n!==C?e.jsxs(o,{fontSize:"xs",color:"gray.600",fontStyle:"italic",mt:1,children:["Format:",e.jsx(f,{colorPalette:"cyan",size:"sm",ml:1,children:n})]}):null})()]}),e.jsxs(t,{as:"td",p:3,borderBottom:"1px",borderColor:"border.subtle",children:[r.notes?.desc&&e.jsx(o,{fontSize:"xs",color:"gray.600",fontStyle:"italic",children:P(r.notes.desc)}),r.notes?.ph&&Object.keys(r.notes.ph).length>0&&e.jsxs(t,{mt:r.notes?.desc?2:0,children:[e.jsx(o,{fontSize:"xs",color:"gray.600",fontWeight:"semibold",mb:1,children:"Placeholders:"}),Object.entries(r.notes.ph).map(([n,a])=>e.jsxs(o,{fontSize:"xs",color:"gray.600",mb:1,children:[e.jsx(o,{as:"span",fontFamily:"mono",color:"purple.600",fontWeight:"bold",children:n}),": ",P(a.desc),a.sample&&e.jsxs(o,{as:"span",color:"gray.500",children:[" ",'(e.g., "',a.sample,'")']})]},n))]})]})]},r.guid)})})]}),d.length===0&&e.jsx(p,{justify:"center",p:8,children:e.jsx(o,{color:"fg.muted",children:"No segments found in this resource"})})]})]}),e.jsx(F,{value:"raw",flex:"1",display:"flex",flexDirection:"column",children:e.jsx(t,{flex:"1",bg:"white",borderRadius:"lg",shadow:"sm",overflow:"auto",p:4,children:e.jsx(t,{as:"pre",fontSize:"xs",fontFamily:"mono",bg:"gray.50",p:4,borderRadius:"md",overflow:"auto",whiteSpace:"pre-wrap",wordBreak:"break-word",border:"1px",borderColor:"border.default",children:l.raw||"No raw content available"})})})]})})]}):e.jsx(t,{mt:5,px:6,children:e.jsx(B,{status:"error",children:e.jsxs(t,{children:[e.jsx(o,{fontWeight:"bold",children:"Missing Resource ID"}),e.jsx(o,{children:"No resource ID specified in the URL."})]})})})};export{xe as default};
1
+ import{a9 as K,u as V,a1 as _,r as x,i as R,j as e,B as t,A as B,T as o,S as Q,F as p,g as f,ae as X,af as Z,ag as I,ah as F,l as J,m as Y,n as ee,o as re,p as te,q as oe,s as se,t as le,v as ne,aa as A,ab as W,ac as D}from"./vendor-BAKw9_tP.js";import{a as ie,r as P,b as ae,f as O}from"./index-CuIl8QRT.js";function de(m){return m.map((u,j)=>{if(typeof u=="string")return u;if(u.v){const g=u.t==="x"?"purple.600":"orange.600";return e.jsx(o,{as:"span",fontFamily:"mono",color:g,fontWeight:"bold",children:u.v},j)}else return`{{${u.t}}}`})}const xe=()=>{const{channelId:m}=K(),u=V(),[j]=_(),g=j.get("rid"),S=j.get("guid"),[k,M]=x.useState("segments"),w=x.useRef(null),[c,y]=x.useState(new Set),[b,L]=x.useState(""),{data:l,isLoading:G,error:v}=R({queryKey:["resource",m,g],queryFn:()=>O(`/api/resource/${m}?rid=${encodeURIComponent(g)}`),enabled:!!g}),{data:ce={}}=R({queryKey:["info"],queryFn:()=>O("/api/info")}),{defaultGroup:z,defaultFormat:C,segments:d}=x.useMemo(()=>{if(!l?.segments)return{defaultGroup:null,defaultFormat:null,segments:[]};const r={},i={};l.segments.forEach(a=>{const h=a.group||"(no group)",T=a.mf||"text";r[h]=(r[h]||0)+1,i[T]=(i[T]||0)+1});const s=Object.keys(r).reduce((a,h)=>r[a]>r[h]?a:h,Object.keys(r)[0]),n=Object.keys(i).reduce((a,h)=>i[a]>i[h]?a:h,Object.keys(i)[0]);return{defaultGroup:s,defaultFormat:n,segments:l.segments}},[l?.segments]),N=(r,i)=>{const s=new Set(c);i?s.add(r):s.delete(r),y(s)},E=r=>{if(r){const i=new Set(d.map((s,n)=>n));y(i)}else y(new Set)},U=()=>{if(!b){alert("Please select a target language first");return}const i=Array.from(c).map(s=>d[s]).map(s=>({guid:s.guid,rid:l.id,sid:s.sid,nsrc:s.nstr,notes:s.notes}));ae(l.sourceLang,b,m,i),y(new Set),L("")},q=d.length>0&&c.size===d.length,$=c.size>0&&c.size<d.length,H=x.useMemo(()=>l?.targetLangs?l.targetLangs.filter(r=>r!==l.sourceLang):[],[l?.targetLangs,l?.sourceLang]);return x.useEffect(()=>{S&&d.length>0&&w.current&&setTimeout(()=>{w.current&&w.current.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"})},100)},[S,d,k]),g?G?e.jsx(t,{display:"flex",justifyContent:"center",mt:10,children:e.jsx(Q,{size:"xl"})}):v?e.jsx(t,{mt:5,px:6,children:e.jsx(B,{status:"error",children:e.jsxs(t,{children:[e.jsx(o,{fontWeight:"bold",children:"Error"}),e.jsx(o,{children:v?.message||"Failed to fetch resource data"})]})})}):e.jsxs(t,{py:6,px:6,h:"100vh",display:"flex",flexDirection:"column",children:[e.jsx(ie,{channelId:l.channel,project:l.prj,resource:l.id,onBackClick:()=>u(`/sources/${m}/${l.prj}`),backLabel:"Back to project",extraContent:e.jsxs(p,{gap:4,align:"center",wrap:"wrap",children:[e.jsxs(t,{children:[e.jsx(o,{fontSize:"sm",color:"fg.muted",mb:1,children:"Source Language"}),e.jsx(f,{colorPalette:"blue",size:"sm",children:l.sourceLang})]}),e.jsxs(t,{children:[e.jsx(o,{fontSize:"sm",color:"fg.muted",mb:1,children:"Resource Format"}),e.jsx(f,{colorPalette:"purple",size:"sm",children:l.resourceFormat})]}),z&&e.jsxs(t,{children:[e.jsx(o,{fontSize:"sm",color:"fg.muted",mb:1,children:"Default Group"}),e.jsx(f,{colorPalette:"gray",size:"sm",children:z})]}),C&&e.jsxs(t,{children:[e.jsx(o,{fontSize:"sm",color:"fg.muted",mb:1,children:"Default Format"}),e.jsx(f,{colorPalette:"cyan",size:"sm",children:C})]}),e.jsxs(t,{children:[e.jsxs(o,{fontSize:"sm",color:"fg.muted",mb:1,children:["Target Languages (",l.targetLangs.length,")"]}),e.jsx(p,{wrap:"wrap",gap:1,children:l.targetLangs.map(r=>e.jsx(f,{colorPalette:"orange",size:"sm",children:r},r))})]}),l.modified&&e.jsxs(t,{children:[e.jsx(o,{fontSize:"sm",color:"fg.muted",mb:1,children:"Last Modified"}),e.jsx(o,{fontSize:"sm",color:"fg.default",title:new Date(l.modified).toLocaleString("en-US",{weekday:"long",year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:"short"}),children:(()=>{const r=new Date,i=new Date(l.modified),s=Math.floor((r-i)/1e3),n=new Intl.RelativeTimeFormat("en",{numeric:"auto",style:"short"});return s<60?n.format(-s,"second"):s<3600?n.format(-Math.floor(s/60),"minute"):s<86400?n.format(-Math.floor(s/3600),"hour"):s<2592e3?n.format(-Math.floor(s/86400),"day"):s<31536e3?n.format(-Math.floor(s/2592e3),"month"):n.format(-Math.floor(s/31536e3),"year")})()})]})]})}),e.jsx(t,{flex:"1",display:"flex",flexDirection:"column",children:e.jsxs(X,{value:k,onValueChange:r=>M(r.value),children:[e.jsxs(Z,{mb:4,children:[e.jsxs(I,{value:"segments",children:["Segments (",d.length,")"]}),e.jsx(I,{value:"raw",children:"Raw Content"})]}),e.jsxs(F,{value:"segments",flex:"1",display:"flex",flexDirection:"column",children:[c.size>0&&e.jsx(t,{bg:"blue.subtle",borderBottom:"1px",borderColor:"blue.muted",shadow:"md",borderLeft:"4px",borderLeftColor:"blue.500",px:6,py:4,mb:4,borderRadius:"md",children:e.jsxs(p,{align:"center",justify:"space-between",children:[e.jsxs(o,{fontSize:"md",fontWeight:"semibold",color:"blue.700",children:[c.size," ",c.size===1?"segment":"segments"," selected"]}),e.jsxs(p,{align:"center",gap:3,children:[e.jsx(o,{fontSize:"sm",color:"blue.600",children:"Target Language:"}),e.jsxs(J,{size:"sm",width:"200px",value:b?[b]:[],positioning:{strategy:"absolute",placement:"bottom-start",flip:!0,gutter:4},children:[e.jsxs(Y,{children:[e.jsx(o,{fontSize:"sm",flex:"1",textAlign:"left",children:b||"Select target language"}),e.jsx(ee,{})]}),e.jsx(re,{children:e.jsx(te,{zIndex:1e3,bg:"white",borderWidth:"1px",borderColor:"border.default",borderRadius:"md",shadow:"lg",maxH:"200px",overflow:"auto",children:H.map(r=>e.jsxs(oe,{item:r,value:r,onClick:()=>L(r),children:[e.jsx(se,{children:r}),e.jsx(le,{})]},r))})})]}),e.jsx(ne,{colorPalette:"blue",onClick:U,disabled:!b,size:"sm",children:"Add to Cart"})]})]})}),e.jsxs(t,{flex:"1",bg:"white",borderRadius:"lg",shadow:"sm",overflow:"auto",children:[e.jsxs(t,{as:"table",w:"100%",fontSize:"sm",tableLayout:"fixed",children:[e.jsx(t,{as:"thead",position:"sticky",top:0,bg:"blue.subtle",zIndex:1,borderBottom:"2px",borderColor:"blue.muted",shadow:"sm",children:e.jsxs(t,{as:"tr",children:[e.jsx(t,{as:"th",p:3,borderBottom:"1px",borderColor:"border.default",minW:"60px",textAlign:"center",children:e.jsxs(A,{checked:q,onCheckedChange:r=>E(r.checked),children:[e.jsx(W,{ref:r=>{r&&(r.indeterminate=$)}}),e.jsx(D,{})]})}),e.jsx(t,{as:"th",p:3,textAlign:"left",borderBottom:"1px",borderColor:"border.default",w:"12%",children:e.jsx(o,{fontSize:"sm",fontWeight:"bold",color:"blue.600",children:"GUID"})}),e.jsx(t,{as:"th",p:3,textAlign:"left",borderBottom:"1px",borderColor:"border.default",w:"8%",children:e.jsx(o,{fontSize:"sm",fontWeight:"bold",color:"blue.600",children:"NID"})}),e.jsx(t,{as:"th",p:3,textAlign:"left",borderBottom:"1px",borderColor:"border.default",w:"20%",children:e.jsx(o,{fontSize:"sm",fontWeight:"bold",color:"blue.600",children:"STRING ID"})}),e.jsx(t,{as:"th",p:3,textAlign:"left",borderBottom:"1px",borderColor:"border.default",w:"35%",children:e.jsx(o,{fontSize:"sm",fontWeight:"bold",color:"blue.600",children:"SOURCE TEXT"})}),e.jsx(t,{as:"th",p:3,textAlign:"left",borderBottom:"1px",borderColor:"border.default",w:"20%",children:e.jsx(o,{fontSize:"sm",fontWeight:"bold",color:"blue.600",children:"NOTES"})})]})}),e.jsx(t,{as:"tbody",children:d.map((r,i)=>{const s=S&&r.guid===S;return e.jsxs(t,{as:"tr",ref:s?w:null,bg:s?"yellow.subtle":"transparent",_hover:{bg:s?"yellow.muted":"gray.subtle"},borderLeft:s?"4px":"0",borderLeftColor:s?"yellow.solid":"transparent",children:[e.jsx(t,{as:"td",p:3,borderBottom:"1px",borderColor:"border.subtle",textAlign:"center",children:e.jsxs(A,{checked:c.has(i),onCheckedChange:n=>N(i,n.checked),children:[e.jsx(W,{}),e.jsx(D,{})]})}),e.jsx(t,{as:"td",p:3,borderBottom:"1px",borderColor:"border.subtle",children:e.jsx(o,{fontSize:"xs",fontFamily:"mono",color:"orange.600",userSelect:"all",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxW:"100px",title:r.guid,children:r.guid})}),e.jsx(t,{as:"td",p:3,borderBottom:"1px",borderColor:"border.subtle",children:e.jsx(o,{fontSize:"xs",fontFamily:"mono",color:"orange.600",userSelect:"all",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxW:"100px",title:r.nid||"",children:r.nid||""})}),e.jsx(t,{as:"td",p:3,borderBottom:"1px",borderColor:"border.subtle",children:e.jsx(o,{fontSize:"xs",fontFamily:"mono",color:"purple.600",wordBreak:"break-all",children:r.sid})}),e.jsxs(t,{as:"td",p:3,borderBottom:"1px",borderColor:"border.subtle",children:[e.jsx(o,{fontSize:"xs",noOfLines:3,children:de(r.nstr)}),(()=>{const n=r.group||"(no group)";return n!==z?e.jsxs(o,{fontSize:"xs",color:"gray.600",fontStyle:"italic",mt:1,children:["Group:",e.jsx(f,{colorPalette:"gray",size:"sm",ml:1,children:n})]}):null})(),(()=>{const n=r.mf||"text";return n!==C?e.jsxs(o,{fontSize:"xs",color:"gray.600",fontStyle:"italic",mt:1,children:["Format:",e.jsx(f,{colorPalette:"cyan",size:"sm",ml:1,children:n})]}):null})()]}),e.jsxs(t,{as:"td",p:3,borderBottom:"1px",borderColor:"border.subtle",children:[r.notes?.desc&&e.jsx(o,{fontSize:"xs",color:"gray.600",fontStyle:"italic",children:P(r.notes.desc)}),r.notes?.ph&&Object.keys(r.notes.ph).length>0&&e.jsxs(t,{mt:r.notes?.desc?2:0,children:[e.jsx(o,{fontSize:"xs",color:"gray.600",fontWeight:"semibold",mb:1,children:"Placeholders:"}),Object.entries(r.notes.ph).map(([n,a])=>e.jsxs(o,{fontSize:"xs",color:"gray.600",mb:1,children:[e.jsx(o,{as:"span",fontFamily:"mono",color:"purple.600",fontWeight:"bold",children:n}),": ",P(a.desc),a.sample&&e.jsxs(o,{as:"span",color:"gray.500",children:[" ",'(e.g., "',a.sample,'")']})]},n))]})]})]},r.guid)})})]}),d.length===0&&e.jsx(p,{justify:"center",p:8,children:e.jsx(o,{color:"fg.muted",children:"No segments found in this resource"})})]})]}),e.jsx(F,{value:"raw",flex:"1",display:"flex",flexDirection:"column",children:e.jsx(t,{flex:"1",bg:"white",borderRadius:"lg",shadow:"sm",overflow:"auto",p:4,children:e.jsx(t,{as:"pre",fontSize:"xs",fontFamily:"mono",bg:"gray.50",p:4,borderRadius:"md",overflow:"auto",whiteSpace:"pre-wrap",wordBreak:"break-word",border:"1px",borderColor:"border.default",children:l.raw||"No raw content available"})})})]})})]}):e.jsx(t,{mt:5,px:6,children:e.jsx(B,{status:"error",children:e.jsxs(t,{children:[e.jsx(o,{fontWeight:"bold",children:"Missing Resource ID"}),e.jsx(o,{children:"No resource ID specified in the URL."})]})})})};export{xe as default};
@@ -1 +1 @@
1
- import{u as z,a0 as R,r as c,i as k,j as e,B as n,S as P,A as $,T as s,F as L,a1 as q,a2 as T,a3 as B,a4 as F,a5 as I,I as M,a6 as A,a7 as H,L as G,h as K,G as N}from"./vendor-BVSmEsOp.js";import{P as U,f as v}from"./index-Dl1WS_Lc.js";const D=({channelId:o,hideComplete:h,calculateCompletionPercentage:u,hasIncompleteContent:m})=>{const[g,b]=c.useState(!1),[d,y]=c.useState(!0),f=c.useRef(null);c.useEffect(()=>{const r=new IntersectionObserver(i=>{i.forEach(l=>{l.isIntersecting&&(b(!0),r.disconnect())})},{rootMargin:"200px",threshold:0});return f.current&&r.observe(f.current),()=>r.disconnect()},[]);const{data:a,isLoading:C,error:S}=k({queryKey:["status",o],queryFn:()=>v(`/api/status/${o}`),enabled:g}),t=c.useMemo(()=>{if(!a||!h)return a;const r={};return Object.entries(a).forEach(([i,l])=>{const j={};Object.entries(l).forEach(([O,p])=>{const w={};Object.entries(p).forEach(([W,E])=>{m(E.pairSummaryByStatus)&&(w[W]=E)}),Object.keys(w).length>0&&(j[O]=w)}),Object.keys(j).length>0&&(r[i]=j)}),Object.keys(r).length>0?r:null},[a,h,m]),x=c.useMemo(()=>t?Object.values(t).reduce((r,i)=>r+Object.keys(i).length,0):0,[t]);return h&&!t&&a!==void 0?null:e.jsxs(n,{ref:f,mb:8,p:6,borderWidth:"2px",borderRadius:"lg",bg:"white",borderColor:"green.200",children:[e.jsxs(n,{display:"flex",alignItems:"center",gap:3,flexWrap:"wrap",mb:6,pb:4,borderBottom:"2px",borderColor:"green.100",children:[e.jsx(M,{"aria-label":d?"Collapse channel":"Expand channel",onClick:()=>y(!d),variant:"ghost",size:"sm",children:d?"▼":"▶"}),e.jsxs(n,{children:[e.jsx(s,{fontSize:"sm",color:"fg.muted",mb:1,children:"Channel"}),e.jsx(s,{fontSize:"lg",fontWeight:"bold",color:"green.600",children:o})]}),C&&e.jsx(P,{size:"md"})]}),e.jsx(A,{open:d,children:e.jsx(H,{children:S?e.jsx($,{status:"error",children:e.jsxs(n,{children:[e.jsxs(s,{fontWeight:"bold",children:["Error loading channel ",o]}),e.jsx(s,{children:S.message||"Unknown error"})]})}):C?e.jsx(n,{display:"flex",justifyContent:"center",py:8,children:e.jsx(s,{color:"fg.muted",children:"Loading channel data..."})}):t&&Object.keys(t).length>0?Object.entries(t).map(([r,i])=>Object.entries(i).map(([l,j])=>e.jsxs(n,{mb:6,p:4,borderWidth:"1px",borderRadius:"md",bg:"gray.50",borderColor:"border.default",children:[e.jsx(n,{display:"flex",alignItems:"center",gap:3,flexWrap:"wrap",mb:4,children:e.jsxs(G,{as:K,to:`/status/${o}/${r}/${l}`,fontSize:"lg",fontWeight:"semibold",color:"blue.600",_hover:{textDecoration:"underline"},children:[r," → ",l]})}),e.jsx(N,{templateColumns:"repeat(auto-fit, minmax(300px, 1fr))",gap:4,children:Object.entries(j).map(([O,p])=>e.jsx(U,{project:{translationStatus:p.details||[],pairSummary:p.pairSummary,pairSummaryByStatus:p.pairSummaryByStatus,projectName:O}},`${o}-${r}-${l}-${O}`))})]},`${r}-${l}`))):a&&Object.keys(a).length===0?e.jsx(n,{display:"flex",justifyContent:"center",py:8,children:e.jsx(s,{color:"fg.muted",children:"This channel has no projects"})}):g?e.jsx(n,{display:"flex",justifyContent:"center",py:8,children:e.jsx(s,{color:"fg.muted",children:"No content available for this channel"})}):e.jsx(n,{display:"flex",justifyContent:"center",py:8,children:e.jsx(s,{color:"fg.muted",children:"Scroll down to load content..."})})})}),!d&&t&&e.jsx(n,{display:"flex",justifyContent:"center",py:4,children:e.jsxs(s,{fontSize:"sm",color:"gray.600",fontStyle:"italic",children:[x," language pair",x!==1?"s":""," (collapsed)"]})})]})},J=()=>{z();const[o,h]=R(),[u,m]=c.useState(()=>o.get("hideComplete")==="true"),{data:g,isLoading:b,error:d}=k({queryKey:["info"],queryFn:()=>v("/api/info")}),y=g?.channels?.map(t=>t.id)||[],f=b,a=d;c.useEffect(()=>{const t=new URLSearchParams(o);u?t.set("hideComplete","true"):t.delete("hideComplete"),h(t,{replace:!0})},[u,o,h]);const C=t=>{const x=Object.values(t).reduce((r,i)=>r+i,0);return x===0?100:Math.round((t.translated||0)/x*100)},S=t=>(t.untranslated||0)>0||(t["in flight"]||0)>0||(t["low quality"]||0)>0;return b?e.jsx(n,{display:"flex",justifyContent:"center",mt:5,children:e.jsx(P,{size:"xl"})}):a?e.jsx(n,{mt:5,px:6,children:e.jsx($,{status:"error",children:e.jsxs(n,{children:[e.jsx(s,{fontWeight:"bold",children:"Error"}),e.jsx(s,{children:a})]})})}):e.jsxs(n,{py:6,px:6,children:[e.jsx(L,{align:"center",gap:3,mb:6,children:e.jsxs(q,{checked:u,onCheckedChange:t=>m(t.checked),children:[e.jsx(T,{}),e.jsx(B,{children:e.jsx(F,{})}),e.jsx(I,{children:e.jsx(s,{fontSize:"md",fontWeight:"medium",children:"Hide complete"})})]})}),y.map(t=>e.jsx(D,{channelId:t,hideComplete:u,calculateCompletionPercentage:C,hasIncompleteContent:S},t)),y.length===0&&!f&&e.jsx(s,{mt:4,color:"fg.muted",children:"No channels found."})]})};export{J as default};
1
+ import{u as z,a1 as R,r as c,i as k,j as e,B as n,S as P,A as $,T as s,F as L,a2 as q,a3 as T,a4 as B,a5 as F,a6 as I,I as M,a7 as A,a8 as H,L as G,h as K,G as N}from"./vendor-BAKw9_tP.js";import{P as U,f as v}from"./index-CuIl8QRT.js";const D=({channelId:o,hideComplete:h,calculateCompletionPercentage:u,hasIncompleteContent:m})=>{const[g,b]=c.useState(!1),[d,y]=c.useState(!0),f=c.useRef(null);c.useEffect(()=>{const r=new IntersectionObserver(i=>{i.forEach(l=>{l.isIntersecting&&(b(!0),r.disconnect())})},{rootMargin:"200px",threshold:0});return f.current&&r.observe(f.current),()=>r.disconnect()},[]);const{data:a,isLoading:C,error:S}=k({queryKey:["status",o],queryFn:()=>v(`/api/status/${o}`),enabled:g}),t=c.useMemo(()=>{if(!a||!h)return a;const r={};return Object.entries(a).forEach(([i,l])=>{const j={};Object.entries(l).forEach(([O,p])=>{const w={};Object.entries(p).forEach(([W,E])=>{m(E.pairSummaryByStatus)&&(w[W]=E)}),Object.keys(w).length>0&&(j[O]=w)}),Object.keys(j).length>0&&(r[i]=j)}),Object.keys(r).length>0?r:null},[a,h,m]),x=c.useMemo(()=>t?Object.values(t).reduce((r,i)=>r+Object.keys(i).length,0):0,[t]);return h&&!t&&a!==void 0?null:e.jsxs(n,{ref:f,mb:8,p:6,borderWidth:"2px",borderRadius:"lg",bg:"white",borderColor:"green.200",children:[e.jsxs(n,{display:"flex",alignItems:"center",gap:3,flexWrap:"wrap",mb:6,pb:4,borderBottom:"2px",borderColor:"green.100",children:[e.jsx(M,{"aria-label":d?"Collapse channel":"Expand channel",onClick:()=>y(!d),variant:"ghost",size:"sm",children:d?"▼":"▶"}),e.jsxs(n,{children:[e.jsx(s,{fontSize:"sm",color:"fg.muted",mb:1,children:"Channel"}),e.jsx(s,{fontSize:"lg",fontWeight:"bold",color:"green.600",children:o})]}),C&&e.jsx(P,{size:"md"})]}),e.jsx(A,{open:d,children:e.jsx(H,{children:S?e.jsx($,{status:"error",children:e.jsxs(n,{children:[e.jsxs(s,{fontWeight:"bold",children:["Error loading channel ",o]}),e.jsx(s,{children:S.message||"Unknown error"})]})}):C?e.jsx(n,{display:"flex",justifyContent:"center",py:8,children:e.jsx(s,{color:"fg.muted",children:"Loading channel data..."})}):t&&Object.keys(t).length>0?Object.entries(t).map(([r,i])=>Object.entries(i).map(([l,j])=>e.jsxs(n,{mb:6,p:4,borderWidth:"1px",borderRadius:"md",bg:"gray.50",borderColor:"border.default",children:[e.jsx(n,{display:"flex",alignItems:"center",gap:3,flexWrap:"wrap",mb:4,children:e.jsxs(G,{as:K,to:`/status/${o}/${r}/${l}`,fontSize:"lg",fontWeight:"semibold",color:"blue.600",_hover:{textDecoration:"underline"},children:[r," → ",l]})}),e.jsx(N,{templateColumns:"repeat(auto-fit, minmax(300px, 1fr))",gap:4,children:Object.entries(j).map(([O,p])=>e.jsx(U,{project:{translationStatus:p.details||[],pairSummary:p.pairSummary,pairSummaryByStatus:p.pairSummaryByStatus,projectName:O}},`${o}-${r}-${l}-${O}`))})]},`${r}-${l}`))):a&&Object.keys(a).length===0?e.jsx(n,{display:"flex",justifyContent:"center",py:8,children:e.jsx(s,{color:"fg.muted",children:"This channel has no projects"})}):g?e.jsx(n,{display:"flex",justifyContent:"center",py:8,children:e.jsx(s,{color:"fg.muted",children:"No content available for this channel"})}):e.jsx(n,{display:"flex",justifyContent:"center",py:8,children:e.jsx(s,{color:"fg.muted",children:"Scroll down to load content..."})})})}),!d&&t&&e.jsx(n,{display:"flex",justifyContent:"center",py:4,children:e.jsxs(s,{fontSize:"sm",color:"gray.600",fontStyle:"italic",children:[x," language pair",x!==1?"s":""," (collapsed)"]})})]})},J=()=>{z();const[o,h]=R(),[u,m]=c.useState(()=>o.get("hideComplete")==="true"),{data:g,isLoading:b,error:d}=k({queryKey:["info"],queryFn:()=>v("/api/info")}),y=g?.channels?.map(t=>t.id)||[],f=b,a=d;c.useEffect(()=>{const t=new URLSearchParams(o);u?t.set("hideComplete","true"):t.delete("hideComplete"),h(t,{replace:!0})},[u,o,h]);const C=t=>{const x=Object.values(t).reduce((r,i)=>r+i,0);return x===0?100:Math.round((t.translated||0)/x*100)},S=t=>(t.untranslated||0)>0||(t["in flight"]||0)>0||(t["low quality"]||0)>0;return b?e.jsx(n,{display:"flex",justifyContent:"center",mt:5,children:e.jsx(P,{size:"xl"})}):a?e.jsx(n,{mt:5,px:6,children:e.jsx($,{status:"error",children:e.jsxs(n,{children:[e.jsx(s,{fontWeight:"bold",children:"Error"}),e.jsx(s,{children:a})]})})}):e.jsxs(n,{py:6,px:6,children:[e.jsx(L,{align:"center",gap:3,mb:6,children:e.jsxs(q,{checked:u,onCheckedChange:t=>m(t.checked),children:[e.jsx(T,{}),e.jsx(B,{children:e.jsx(F,{})}),e.jsx(I,{children:e.jsx(s,{fontSize:"md",fontWeight:"medium",children:"Hide complete"})})]})}),y.map(t=>e.jsx(D,{channelId:t,hideComplete:u,calculateCompletionPercentage:C,hasIncompleteContent:S},t)),y.length===0&&!f&&e.jsx(s,{mt:4,color:"fg.muted",children:"No channels found."})]})};export{J as default};
@@ -0,0 +1 @@
1
+ import{a9 as G,u as J,r as a,i as K,j as e,B as t,S as v,A as _,T as o,F,v as q,aa as k,ab as A,ac as R,V as f,K as b,L as H,h as M,b as Q,c as X,d as Y,e as Z,f as ee}from"./vendor-BAKw9_tP.js";import{f as re}from"./index-CuIl8QRT.js";function B(j){return j.map(l=>typeof l=="string"?l:`{{${l.t}}}`).join("")}const ne=()=>{const{channelId:j,sourceLang:l,targetLang:m}=G();J();const[d,S]=a.useState(new Set),[W,I]=a.useState({guid:"",channel:"",prj:"",rid:"",sid:"",nsrc:"",group:""}),[u,T]=a.useState({guid:"",channel:"",prj:"",rid:"",sid:"",nsrc:"",group:""}),w=a.useRef(),C=a.useRef(null),c=a.useRef({}),{data:z=[],isLoading:y,isError:L,error:D}=K({queryKey:["statusDetail",j,l,m],queryFn:()=>re(`/api/status/${j}/${l}/${m}`)}),h=a.useMemo(()=>z.length?z.filter(r=>Object.entries(W).every(([s,n])=>{if(!n.trim())return!0;const i=r[s];return i==null?!1:s==="nsrc"&&Array.isArray(i)?B(i).toLowerCase().includes(n.toLowerCase()):String(i).toLowerCase().includes(n.toLowerCase())})):[],[z,W]),x=a.useCallback(r=>{C.current=r},[]),p=a.useCallback(()=>{C.current=null},[]),g=a.useCallback((r,s)=>{T(n=>({...n,[r]:s})),S(new Set),clearTimeout(w.current),w.current=setTimeout(()=>{I(n=>({...n,[r]:s}))},300)},[]),O=(r,s)=>{const n=new Set(d);s?n.add(r):n.delete(r),S(n)},$=r=>{if(r){const s=new Set(h.map((n,i)=>i));S(s)}else S(new Set)},E=()=>{const r=sessionStorage.getItem("statusCart");return r?JSON.parse(r):{}},N=r=>{sessionStorage.setItem("statusCart",JSON.stringify(r))},P=()=>{const r=E(),s=`${l}|${m}`;r[s]||(r[s]={sourceLang:l,targetLang:m,tus:[]});const n=Array.from(d).map(i=>h[i]);r[s].tus.push(...n),N(r),S(new Set),window.dispatchEvent(new Event("cartUpdated"))},U=h.length>0&&d.size===h.length,V=d.size>0&&d.size<h.length;return a.useEffect(()=>{if(C.current&&c.current[C.current]){const r=c.current[C.current];setTimeout(()=>{if(r&&document.contains(r)){r.focus();const s=r.value.length;r.setSelectionRange(s,s)}},10)}},[h]),a.useEffect(()=>()=>{w.current&&clearTimeout(w.current)},[]),y?e.jsx(t,{display:"flex",justifyContent:"center",mt:10,children:e.jsx(v,{size:"xl"})}):L?e.jsx(t,{mt:5,px:6,children:e.jsx(_,{status:"error",children:e.jsxs(t,{children:[e.jsx(o,{fontWeight:"bold",children:"Error"}),e.jsx(o,{children:D?.message||"Failed to fetch status data"})]})})}):e.jsx(t,{py:6,px:6,children:e.jsxs(t,{p:6,borderWidth:"2px",borderRadius:"lg",bg:"white",borderColor:"green.200",children:[e.jsxs(t,{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap",mb:6,pb:4,borderBottom:"2px",borderColor:"green.100",children:[e.jsxs(t,{children:[e.jsx(o,{fontSize:"sm",color:"fg.muted",mb:1,children:"Channel"}),e.jsx(o,{fontSize:"lg",fontWeight:"bold",color:"green.600",children:j})]}),e.jsxs(t,{children:[e.jsx(o,{fontSize:"sm",color:"fg.muted",mb:1,children:"Language Pair"}),e.jsxs(F,{align:"center",gap:2,children:[e.jsxs(o,{fontSize:"lg",fontWeight:"semibold",color:"blue.600",children:[l," → ",m]}),y&&e.jsx(v,{size:"sm"})]})]}),e.jsxs(t,{children:[e.jsx(o,{fontSize:"sm",color:"fg.muted",mb:1,children:"Translation Units"}),e.jsxs(o,{fontSize:"lg",fontWeight:"medium",children:[h.length," of ",z.length," shown"]})]}),e.jsx(t,{ml:"auto",children:d.size>0&&e.jsxs(q,{colorPalette:"blue",onClick:P,children:["Add to Cart (",d.size," ",d.size===1?"TU":"TUs",")"]})})]}),e.jsxs(t,{bg:"white",borderRadius:"lg",shadow:"sm",overflow:"auto",h:"calc(100vh - 250px)",children:[e.jsxs(t,{as:"table",w:"100%",fontSize:"sm",children:[e.jsx(t,{as:"thead",position:"sticky",top:0,bg:"orange.subtle",zIndex:1,borderBottom:"2px",borderColor:"orange.muted",shadow:"sm",children:e.jsxs(t,{as:"tr",children:[e.jsx(t,{as:"th",p:3,borderBottom:"1px",borderColor:"border.default",minW:"60px",textAlign:"center",children:e.jsxs(k,{checked:U,onCheckedChange:r=>$(r.checked),children:[e.jsx(A,{ref:r=>{r&&(r.indeterminate=V)}}),e.jsx(R,{})]})}),e.jsx(t,{as:"th",p:3,borderBottom:"1px",borderColor:"border.default",minW:"120px",textAlign:"left",children:e.jsxs(f,{gap:2,align:"stretch",children:[e.jsx(o,{fontSize:"sm",fontWeight:"bold",color:"orange.600",children:"GUID"}),e.jsx(b,{size:"xs",placeholder:"Filter GUID...",value:u.guid,onChange:r=>g("guid",r.target.value),onFocus:()=>x("guid"),onBlur:p,ref:r=>{r&&(c.current.guid=r)},bg:"yellow.subtle"},"guid-input")]})}),e.jsx(t,{as:"th",p:3,borderBottom:"1px",borderColor:"border.default",minW:"120px",textAlign:"left",children:e.jsxs(f,{gap:2,align:"stretch",children:[e.jsx(o,{fontSize:"sm",fontWeight:"bold",color:"orange.600",children:"CHANNEL"}),e.jsx(b,{size:"xs",placeholder:"Filter channel...",value:u.channel,onChange:r=>g("channel",r.target.value),onFocus:()=>x("channel"),onBlur:p,ref:r=>{r&&(c.current.channel=r)},bg:"yellow.subtle"},"channel-input")]})}),e.jsx(t,{as:"th",p:3,borderBottom:"1px",borderColor:"border.default",minW:"120px",textAlign:"left",children:e.jsxs(f,{gap:2,align:"stretch",children:[e.jsx(o,{fontSize:"sm",fontWeight:"bold",color:"orange.600",children:"PRJ"}),e.jsx(b,{size:"xs",placeholder:"Filter project...",value:u.prj,onChange:r=>g("prj",r.target.value),onFocus:()=>x("prj"),onBlur:p,ref:r=>{r&&(c.current.prj=r)},bg:"yellow.subtle"},"prj-input")]})}),e.jsx(t,{as:"th",p:3,borderBottom:"1px",borderColor:"border.default",minW:"150px",textAlign:"left",children:e.jsxs(f,{gap:2,align:"stretch",children:[e.jsx(o,{fontSize:"sm",fontWeight:"bold",color:"orange.600",children:"RID"}),e.jsx(b,{size:"xs",placeholder:"Filter RID...",value:u.rid,onChange:r=>g("rid",r.target.value),onFocus:()=>x("rid"),onBlur:p,ref:r=>{r&&(c.current.rid=r)},bg:"yellow.subtle"},"rid-input")]})}),e.jsx(t,{as:"th",p:3,borderBottom:"1px",borderColor:"border.default",minW:"150px",textAlign:"left",children:e.jsxs(f,{gap:2,align:"stretch",children:[e.jsx(o,{fontSize:"sm",fontWeight:"bold",color:"orange.600",children:"SID"}),e.jsx(b,{size:"xs",placeholder:"Filter SID...",value:u.sid,onChange:r=>g("sid",r.target.value),onFocus:()=>x("sid"),onBlur:p,ref:r=>{r&&(c.current.sid=r)},bg:"yellow.subtle"},"sid-input")]})}),e.jsx(t,{as:"th",p:3,borderBottom:"1px",borderColor:"border.default",minW:"350px",textAlign:"left",children:e.jsxs(f,{gap:2,align:"stretch",children:[e.jsx(o,{fontSize:"sm",fontWeight:"bold",color:"orange.600",children:"NSRC"}),e.jsx(b,{size:"xs",placeholder:"Filter source...",value:u.nsrc,onChange:r=>g("nsrc",r.target.value),onFocus:()=>x("nsrc"),onBlur:p,ref:r=>{r&&(c.current.nsrc=r)},bg:"yellow.subtle",dir:l?.startsWith("he")||l?.startsWith("ar")?"rtl":"ltr"},"nsrc-input")]})}),e.jsx(t,{as:"th",p:3,borderBottom:"1px",borderColor:"border.default",minW:"120px",textAlign:"left",children:e.jsxs(f,{gap:2,align:"stretch",children:[e.jsx(o,{fontSize:"sm",fontWeight:"bold",color:"orange.600",children:"GROUP"}),e.jsx(b,{size:"xs",placeholder:"Filter group...",value:u.group,onChange:r=>g("group",r.target.value),onFocus:()=>x("group"),onBlur:p,ref:r=>{r&&(c.current.group=r)},bg:"yellow.subtle"},"group-input")]})})]})}),e.jsx(t,{as:"tbody",children:h.map((r,s)=>e.jsxs(t,{as:"tr",_hover:{bg:"gray.subtle"},children:[e.jsx(t,{as:"td",p:3,borderBottom:"1px",borderColor:"border.subtle",textAlign:"center",children:e.jsxs(k,{checked:d.has(s),onCheckedChange:n=>O(s,n.checked),children:[e.jsx(A,{}),e.jsx(R,{})]})}),e.jsx(t,{as:"td",p:3,borderBottom:"1px",borderColor:"border.subtle",children:e.jsx(o,{fontSize:"xs",fontFamily:"mono",color:"orange.600",userSelect:"all",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxW:"100px",children:r.guid})}),e.jsx(t,{as:"td",p:3,borderBottom:"1px",borderColor:"border.subtle",children:e.jsx(o,{fontSize:"xs",children:r.channel})}),e.jsx(t,{as:"td",p:3,borderBottom:"1px",borderColor:"border.subtle",children:e.jsx(o,{fontSize:"xs",children:r.prj})}),e.jsx(t,{as:"td",p:3,borderBottom:"1px",borderColor:"border.subtle",children:e.jsx(H,{as:M,to:`/sources/${r.channel}?rid=${encodeURIComponent(r.rid)}`,fontSize:"xs",fontFamily:"mono",color:"blue.600",wordBreak:"break-all",whiteSpace:"normal",_hover:{textDecoration:"underline"},children:r.rid})}),e.jsx(t,{as:"td",p:3,borderBottom:"1px",borderColor:"border.subtle",children:e.jsx(o,{fontSize:"xs",wordBreak:"break-all",whiteSpace:"normal",children:r.sid})}),e.jsx(t,{as:"td",p:3,borderBottom:"1px",borderColor:"border.subtle",children:r.notes&&(r.notes.desc?.trim()||r.notes.ph&&Object.keys(r.notes.ph).length>0)?e.jsxs(Q,{children:[e.jsx(X,{asChild:!0,children:e.jsx(o,{fontSize:"xs",noOfLines:2,cursor:"help",dir:l?.startsWith("he")||l?.startsWith("ar")?"rtl":"ltr",children:B(r.nsrc)})}),e.jsx(Y,{children:e.jsxs(Z,{maxW:"400px",bg:"yellow.100",borderWidth:"1px",borderColor:"yellow.300",shadow:"lg",children:[e.jsx(ee,{}),e.jsxs(t,{children:[r.notes.desc?.trim()&&e.jsx(o,{fontSize:"sm",mb:2,whiteSpace:"pre-wrap",color:"black",children:r.notes.desc}),r.notes.ph&&Object.keys(r.notes.ph).length>0&&e.jsxs(t,{children:[e.jsx(o,{fontSize:"xs",fontWeight:"bold",color:"gray.600",mb:1,children:"Placeholders:"}),Object.entries(r.notes.ph).map(([n,i])=>e.jsxs(t,{mb:1,children:[e.jsx(o,{fontSize:"xs",fontFamily:"mono",color:"blue.600",children:n}),e.jsxs(o,{fontSize:"xs",color:"gray.600",children:[i.desc," (e.g., ",i.sample,")"]})]},n))]})]})]})})]}):e.jsx(o,{fontSize:"xs",noOfLines:2,dir:l?.startsWith("he")||l?.startsWith("ar")?"rtl":"ltr",children:B(r.nsrc)})}),e.jsx(t,{as:"td",p:3,borderBottom:"1px",borderColor:"border.subtle",children:e.jsx(o,{fontSize:"xs",children:r.group})})]},`${r.guid}-${s}`))})]}),h.length===0&&!y&&e.jsx(F,{justify:"center",p:8,children:e.jsx(o,{color:"fg.muted",children:"No untranslated content found for the current filters"})})]})]})})};export{ne as default};
@@ -1 +1 @@
1
- import{u as g,r as x,i as m,j as e,B as t,S as f,A as C,T as a,a6 as v,ai as w,v as c,F as y,g as S,a7 as z,aj as $,V as h}from"./vendor-BVSmEsOp.js";import{L as B,f as L}from"./index-Dl1WS_Lc.js";const M=()=>e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M7.41 8.59L12 13.17l4.59-4.58L18 10l-6 6-6-6 1.41-1.41z"})}),P=()=>e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M7.41 15.41L12 10.83l4.59 4.58L18 14l-6-6-6 6z"})}),W=()=>{const u=g(),[o,p]=x.useState(!1),{data:i=[],isLoading:b,error:d}=m({queryKey:["tmStats"],queryFn:()=>L("/api/tm/stats")}),n=x.useMemo(()=>i.map(([r,l])=>({value:`${r}|${l}`,label:`${r} → ${l}`,sourceLang:r,targetLang:l})).sort((r,l)=>r.label.localeCompare(l.label)),[i]),j=s=>{if(s){const[r,l]=s.split("|");u(`/tm/${r}/${l}`)}};return b?e.jsx(t,{display:"flex",justifyContent:"center",mt:10,children:e.jsx(f,{size:"xl"})}):d?e.jsx(t,{mt:5,px:6,children:e.jsx(C,{status:"error",children:e.jsxs(t,{children:[e.jsx(a,{fontWeight:"bold",children:"Error"}),e.jsx(a,{children:d})]})})}):e.jsxs(t,{children:[n.length>0&&e.jsx(t,{bg:"blue.subtle",borderBottom:"1px",borderColor:"blue.muted",shadow:"md",borderLeft:"4px",borderLeftColor:"blue.500",children:e.jsxs(v,{open:o,onOpenChange:s=>p(s.open),children:[e.jsx(t,{px:6,py:4,children:e.jsxs(w,{as:c,variant:"ghost",size:"md",width:"full",justifyContent:"space-between",_hover:{bg:"blue.muted"},bg:"transparent",children:[e.jsxs(y,{align:"center",gap:3,children:[e.jsx(a,{fontSize:"md",fontWeight:"semibold",color:"blue.700",children:"Language Pairs"}),e.jsx(S,{colorPalette:"blue",variant:"subtle",size:"sm",children:n.length})]}),e.jsx(t,{color:"blue.600",children:o?e.jsx(P,{}):e.jsx(M,{})})]})}),e.jsx(z,{children:e.jsx(t,{px:6,pb:4,children:e.jsx($,{columns:{base:1,sm:2,md:3,lg:4,xl:5},gap:2,children:n.map(s=>e.jsx(c,{variant:"outline",size:"sm",onClick:()=>j(s.value),_hover:{bg:"blue.100",borderColor:"blue.400"},justifyContent:"flex-start",bg:"white",borderColor:"blue.200",children:e.jsx(a,{fontSize:"xs",color:"blue.700",children:s.label})},s.value))})})})]})}),e.jsx(t,{py:6,px:6,children:e.jsx(h,{gap:6,align:"stretch",children:n.length===0?e.jsx(t,{p:6,borderWidth:"1px",borderRadius:"md",bg:"white",textAlign:"center",children:e.jsx(a,{color:"fg.muted",children:"No translation memory data found."})}):e.jsx(h,{gap:6,align:"stretch",maxW:"800px",mx:"auto",w:"100%",children:n.map(({sourceLang:s,targetLang:r})=>e.jsx(B,{sourceLang:s,targetLang:r},`${s}-${r}`))})})})]})};export{W as default};
1
+ import{u as g,r as x,i as m,j as e,B as t,S as f,A as C,T as a,a7 as v,ai as w,v as c,F as y,g as S,a8 as z,aj as $,V as h}from"./vendor-BAKw9_tP.js";import{L as B,f as L}from"./index-CuIl8QRT.js";const M=()=>e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M7.41 8.59L12 13.17l4.59-4.58L18 10l-6 6-6-6 1.41-1.41z"})}),P=()=>e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M7.41 15.41L12 10.83l4.59 4.58L18 14l-6-6-6 6z"})}),W=()=>{const u=g(),[o,p]=x.useState(!1),{data:i=[],isLoading:b,error:d}=m({queryKey:["tmStats"],queryFn:()=>L("/api/tm/stats")}),n=x.useMemo(()=>i.map(([r,l])=>({value:`${r}|${l}`,label:`${r} → ${l}`,sourceLang:r,targetLang:l})).sort((r,l)=>r.label.localeCompare(l.label)),[i]),j=s=>{if(s){const[r,l]=s.split("|");u(`/tm/${r}/${l}`)}};return b?e.jsx(t,{display:"flex",justifyContent:"center",mt:10,children:e.jsx(f,{size:"xl"})}):d?e.jsx(t,{mt:5,px:6,children:e.jsx(C,{status:"error",children:e.jsxs(t,{children:[e.jsx(a,{fontWeight:"bold",children:"Error"}),e.jsx(a,{children:d})]})})}):e.jsxs(t,{children:[n.length>0&&e.jsx(t,{bg:"blue.subtle",borderBottom:"1px",borderColor:"blue.muted",shadow:"md",borderLeft:"4px",borderLeftColor:"blue.500",children:e.jsxs(v,{open:o,onOpenChange:s=>p(s.open),children:[e.jsx(t,{px:6,py:4,children:e.jsxs(w,{as:c,variant:"ghost",size:"md",width:"full",justifyContent:"space-between",_hover:{bg:"blue.muted"},bg:"transparent",children:[e.jsxs(y,{align:"center",gap:3,children:[e.jsx(a,{fontSize:"md",fontWeight:"semibold",color:"blue.700",children:"Language Pairs"}),e.jsx(S,{colorPalette:"blue",variant:"subtle",size:"sm",children:n.length})]}),e.jsx(t,{color:"blue.600",children:o?e.jsx(P,{}):e.jsx(M,{})})]})}),e.jsx(z,{children:e.jsx(t,{px:6,pb:4,children:e.jsx($,{columns:{base:1,sm:2,md:3,lg:4,xl:5},gap:2,children:n.map(s=>e.jsx(c,{variant:"outline",size:"sm",onClick:()=>j(s.value),_hover:{bg:"blue.100",borderColor:"blue.400"},justifyContent:"flex-start",bg:"white",borderColor:"blue.200",children:e.jsx(a,{fontSize:"xs",color:"blue.700",children:s.label})},s.value))})})})]})}),e.jsx(t,{py:6,px:6,children:e.jsx(h,{gap:6,align:"stretch",children:n.length===0?e.jsx(t,{p:6,borderWidth:"1px",borderRadius:"md",bg:"white",textAlign:"center",children:e.jsx(a,{color:"fg.muted",children:"No translation memory data found."})}):e.jsx(h,{gap:6,align:"stretch",maxW:"800px",mx:"auto",w:"100%",children:n.map(({sourceLang:s,targetLang:r})=>e.jsx(B,{sourceLang:s,targetLang:r},`${s}-${r}`))})})})]})};export{W as default};