@l10nmonster/server 3.0.0-alpha.8 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/.releaserc.json +1 -1
  2. package/CHANGELOG.md +38 -0
  3. package/CLAUDE.md +808 -0
  4. package/index.js +121 -17
  5. package/package.json +9 -8
  6. package/routes/dispatcher.js +116 -0
  7. package/routes/info.js +25 -0
  8. package/routes/providers.js +17 -0
  9. package/routes/sources.js +49 -7
  10. package/routes/status.js +27 -27
  11. package/routes/tm.js +156 -6
  12. package/ui/dist/assets/Cart-CiY5V__G.js +1 -0
  13. package/ui/dist/assets/Job-D-5ikxga.js +1 -0
  14. package/ui/dist/assets/Providers-BZVmclS1.js +1 -0
  15. package/ui/dist/assets/Sources-BwZ8Vub0.js +1 -0
  16. package/ui/dist/assets/SourcesDetail-CXgslRDb.js +1 -0
  17. package/ui/dist/assets/SourcesResource-Br3Bspz2.js +1 -0
  18. package/ui/dist/assets/Status-Bx0Ui7d2.js +1 -0
  19. package/ui/dist/assets/StatusDetail-BzJ2TIme.js +1 -0
  20. package/ui/dist/assets/TMByProvider-B2MrTxO0.js +1 -0
  21. package/ui/dist/assets/TMDetail-BxbKr57p.js +1 -0
  22. package/ui/dist/assets/TMToc-CQ1zhmPh.js +1 -0
  23. package/ui/dist/assets/Welcome-Tp-UfiIW.js +1 -0
  24. package/ui/dist/assets/index-543A5WcJ.js +1 -0
  25. package/ui/dist/assets/index-CPrLFF-N.js +2 -0
  26. package/ui/dist/assets/vendor-BVgSJH5C.js +19 -0
  27. package/ui/dist/index.html +3 -1
  28. package/ui/dist/assets/Sources-D0R-Sgwf.js +0 -1
  29. package/ui/dist/assets/Status-XBRD-MuK.js +0 -1
  30. package/ui/dist/assets/TM-DZ2x6--n.js +0 -1
  31. package/ui/dist/assets/Welcome-p4gi31Lo.js +0 -1
  32. package/ui/dist/assets/api-DXOYnFyU.js +0 -1
  33. package/ui/dist/assets/badge-CveKztw5.js +0 -1
  34. package/ui/dist/assets/grid-DetiGbYY.js +0 -1
  35. package/ui/dist/assets/index-Ce8PP-0Z.js +0 -76
  36. package/ui/dist/assets/v-stack-CQ6LIfdw.js +0 -1
package/routes/tm.js CHANGED
@@ -1,12 +1,162 @@
1
+ import { logInfo, logVerbose, logError } from '@l10nmonster/core';
2
+
3
+ // Helper function to process search terms - handles exact vs partial matching
4
+ function processSearchTerm(term) {
5
+ if (!term) return undefined;
6
+
7
+ // Check if term is surrounded by double quotes
8
+ if (term.startsWith('"') && term.endsWith('"') && term.length >= 2) {
9
+ // Extract the content inside quotes for exact match
10
+ return term.slice(1, -1);
11
+ }
12
+
13
+ // Default partial match behavior
14
+ return `%${term}%`;
15
+ }
16
+
17
+ // Helper function to parse multi-value parameters (comma-separated)
18
+ function parseMultiValue(value) {
19
+ if (!value) return undefined;
20
+ const values = value.split(',').map(v => v.trim()).filter(Boolean);
21
+ return values.length > 0 ? values : undefined;
22
+ }
23
+
1
24
  export function setupTmRoutes(router, mm) {
25
+ router.get('/tm/toc', async (req, res) => {
26
+ logInfo`/tm/toc`;
27
+ try {
28
+ const stats = await mm.tmm.getStats();
29
+ logVerbose`Returned TM table of contents`;
30
+ res.json(stats);
31
+ } catch (error) {
32
+ logError`Error in /tm/toc: ${error.message}`;
33
+ res.status(500).json({
34
+ error: 'Failed to get TM table of contents',
35
+ message: error.message
36
+ });
37
+ }
38
+ });
39
+
2
40
  router.get('/tm/stats', async (req, res) => {
3
- const tmInfo = {};
4
- const availableLangPairs = (await mm.tmm.getAvailableLangPairs()).sort();
5
- for (const [sourceLang, targetLang] of availableLangPairs) {
41
+ logInfo`/tm/stats`;
42
+ try {
43
+ const availableLangPairs = (await mm.tmm.getAvailableLangPairs()).sort();
44
+ logVerbose`Returned ${availableLangPairs.length} language pairs`;
45
+ res.json(availableLangPairs);
46
+ } catch (error) {
47
+ logError`Error in /tm/stats: ${error.message}`;
48
+ res.status(500).json({
49
+ error: 'Failed to get TM stats',
50
+ message: error.message
51
+ });
52
+ }
53
+ });
54
+
55
+ router.get('/tm/stats/:sourceLang/:targetLang', async (req, res) => {
56
+ logInfo`/tm/stats/${req.params.sourceLang}/${req.params.targetLang}`;
57
+ try {
58
+ const tm = mm.tmm.getTM(req.params.sourceLang, req.params.targetLang);
59
+ const stats = await tm.getStats();
60
+ logVerbose`Returned TM stats for ${req.params.sourceLang}->${req.params.targetLang}`;
61
+ res.json(stats);
62
+ } catch (error) {
63
+ logError`Error in /tm/stats/${req.params.sourceLang}/${req.params.targetLang}: ${error.message}`;
64
+ res.status(500).json({
65
+ error: 'Failed to get TM stats for language pair',
66
+ message: error.message
67
+ });
68
+ }
69
+ });
70
+
71
+ router.get('/tm/lowCardinalityColumns/:sourceLang/:targetLang', async (req, res) => {
72
+ const { sourceLang, targetLang } = req.params;
73
+ logInfo`/tm/lowCardinalityColumns/${sourceLang}/${targetLang}`;
74
+ try {
75
+ const tm = mm.tmm.getTM(sourceLang, targetLang);
76
+ const data = await tm.getLowCardinalityColumns();
77
+ logVerbose`Returned TM low cardinality columns for ${sourceLang}->${targetLang}`;
78
+ res.json({ channel: mm.rm.channelIds, ...data });
79
+ } catch (error) {
80
+ logError`Error in /tm/lowCardinalityColumns/${sourceLang}/${targetLang}: ${error.message}`;
81
+ res.status(500).json({
82
+ error: 'Failed to get low cardinality columns',
83
+ message: error.message
84
+ });
85
+ }
86
+ });
87
+ router.get('/tm/search', async (req, res) => {
88
+ logInfo`/tm/search`;
89
+ try {
90
+ const { sourceLang, targetLang, page, limit, guid, nid, jobGuid, rid, sid, channel, nsrc, ntgt, notes, tconf, q, translationProvider, onlyTNotes, active, minTS, maxTS, tmStore, group, includeTechnicalColumns, onlyLeveraged } = req.query;
6
91
  const tm = mm.tmm.getTM(sourceLang, targetLang);
7
- tmInfo[sourceLang] ??= {};
8
- tmInfo[sourceLang][targetLang] = tm.getStats();
92
+ const limitInt = limit ? parseInt(limit, 10) : 100;
93
+ const pageInt = page ? parseInt(page, 10) : 1;
94
+ const offset = (pageInt - 1) * limitInt;
95
+ const data = await tm.search(offset, limitInt, {
96
+ guid: processSearchTerm(guid),
97
+ nid: processSearchTerm(nid),
98
+ jobGuid: processSearchTerm(jobGuid),
99
+ rid: processSearchTerm(rid),
100
+ sid: processSearchTerm(sid),
101
+ channel: parseMultiValue(channel),
102
+ nsrc: processSearchTerm(nsrc),
103
+ ntgt: processSearchTerm(ntgt),
104
+ notes: processSearchTerm(notes),
105
+ tconf: parseMultiValue(tconf),
106
+ q: parseMultiValue(q),
107
+ minTS,
108
+ maxTS,
109
+ translationProvider: parseMultiValue(translationProvider),
110
+ tmStore: parseMultiValue(tmStore),
111
+ group: parseMultiValue(group),
112
+ includeTechnicalColumns: includeTechnicalColumns === '1',
113
+ onlyTNotes: onlyTNotes === '1',
114
+ onlyLeveraged: onlyLeveraged === '1',
115
+ ...(active === '1' && { maxRank: 1 }),
116
+ });
117
+ logVerbose`Returned TM search results for ${data.length} entries`;
118
+ res.json({ data, page: pageInt, limit: limitInt });
119
+ } catch (error) {
120
+ logError`Error in /tm/search: ${error.message}`;
121
+ logVerbose`Stack trace: ${error.stack}`;
122
+ res.status(500).json({
123
+ error: 'Failed to search translation memory',
124
+ message: error.message
125
+ });
126
+ }
127
+ });
128
+
129
+ router.get('/tm/job/:jobGuid', async (req, res) => {
130
+ logInfo`/tm/job/${req.params.jobGuid}`;
131
+
132
+ try {
133
+ const { jobGuid } = req.params;
134
+
135
+ if (!jobGuid) {
136
+ return res.status(400).json({
137
+ error: 'Missing jobGuid parameter'
138
+ });
139
+ }
140
+
141
+ const job = await mm.tmm.getJob(jobGuid);
142
+
143
+ if (!job) {
144
+ return res.status(404).json({
145
+ error: 'Job not found',
146
+ jobGuid
147
+ });
148
+ }
149
+
150
+ logVerbose`Returned job data for ${jobGuid}`;
151
+ res.json(job);
152
+
153
+ } catch (error) {
154
+ logError`Error fetching job ${req.params.jobGuid}: ${error.message}`;
155
+ res.status(500).json({
156
+ error: 'Failed to fetch job',
157
+ message: error.message
158
+ });
9
159
  }
10
- res.json(tmInfo);
11
160
  });
161
+
12
162
  }
@@ -0,0 +1 @@
1
+ import{r as o,j as e,B as c,T as a,V as p,F as C,a as b}from"./vendor-BVgSJH5C.js";import{i as S}from"./index-543A5WcJ.js";const T=()=>{const[i,g]=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();g(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 h=m();return e.jsx(c,{py:6,px:6,children:e.jsxs(p,{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"}),h>0&&e.jsx(b,{colorPalette:"red",variant:"outline",onClick:j,children:"Empty Cart"})]}),h===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(p,{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{al as F,r as R,u as A,j as e,B as n,S as L,T as r,V as x,F as c,af as w,d as f,a as T,w as D,x as B}from"./vendor-BVgSJH5C.js";import{a as N,f as U}from"./index-543A5WcJ.js";function W(o){return o.map(a=>typeof a=="string"?a:`{{${a.t}}}`).join("")}function u(o){return new Date(o).toLocaleString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})}function J(o){return o===0?"Free":o==null?"Unknown":`$${o.toFixed(2)}`}function G(o){if(!o)return null;const a=/(https:\/\/[^\s]+)/g;return o.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:o}=F(),[a,p]=R.useState({}),{data:s,isLoading:j,error:S}=A({queryKey:["job",o],queryFn:()=>U(`/api/tm/job/${o}`),retry:(t,i)=>i?.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.jsx(N,{error:S,fallbackMessage:"Failed to fetch job data"})});if(!s)return e.jsx(n,{mt:5,px:6,children:e.jsxs(n,{p:4,bg:"yellow.100",borderRadius:"md",borderWidth:"1px",borderColor:"yellow.300",children:[e.jsx(r,{fontWeight:"bold",color:"yellow.700",mb:2,children:"Job Not Found"}),e.jsxs(r,{color:"yellow.600",children:["Job with GUID ",o," 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"}},k=(t,i)=>{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||i,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(T,{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(D,{open:m,children:e.jsx(B,{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||i)},C=new Set(["jobGuid","sourceLang","targetLang","translationProvider","updatedAt","taskName","inflight","status","statusDescription","tus","estimatedCost"]),z=Object.entries(s).filter(([t])=>!C.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,i])=>{let h=i;return t==="ts"&&typeof i=="number"?h=u(i):typeof i=="object"?h=JSON.stringify(i,null,2):h=String(i),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,i)=>k(t,i)):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};
@@ -0,0 +1 @@
1
+ import{ag as m,r as l,u as j,R as P,j as r,B as i,S as y,F as g}from"./vendor-BVgSJH5C.js";import{a as S,g as b,h as E,f as F}from"./index-543A5WcJ.js";const B=()=>{const[p,a]=m(),[o,d]=l.useState(()=>p.get("provider")||null),{data:f={},isLoading:u,error:n}=j({queryKey:["info"],queryFn:()=>F("/api/info")}),c=f.providers||[],t=l.useMemo(()=>c.slice().sort((e,s)=>{const v=typeof e=="object"&&e?.id?e.id:e,h=typeof s=="object"&&s?.id?s.id:s;return v.localeCompare(h)}),[c]);P.useEffect(()=>{if(t.length>0&&!o){const e=t[0],s=typeof e=="object"&&e?.id?e.id:e;d(s),a({provider:s},{replace:!0})}},[t,o,a]);const x=e=>{d(e),a({provider:e})};return u?r.jsx(i,{display:"flex",justifyContent:"center",mt:10,children:r.jsx(y,{size:"xl"})}):n?r.jsx(i,{mt:5,px:6,children:r.jsx(S,{error:n,fallbackMessage:"Failed to fetch provider data"})}):r.jsx(i,{py:6,px:6,children:r.jsx(i,{borderWidth:"1px",borderRadius:"lg",bg:"white",shadow:"sm",overflow:"hidden",minH:"70vh",children:r.jsxs(g,{children:[r.jsx(b,{providers:t,selectedProvider:o,onProviderSelect:x}),r.jsx(E,{providerId:o})]})})})};export{B as default};
@@ -0,0 +1 @@
1
+ import{u as m,j as e,B as t,S as g,V as C,T as n,r as f,I as E,w,x as z,G as D}from"./vendor-BVgSJH5C.js";import{a as y,S as L,f as b}from"./index-543A5WcJ.js";const v=({channelId:l})=>{const[d,h]=f.useState(!1),[i,x]=f.useState(!0),c=f.useRef(null);f.useEffect(()=>{const s=new IntersectionObserver(a=>{a.forEach(j=>{j.isIntersecting&&(h(!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",l],queryFn:()=>b(`/api/channel/${l}`),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:()=>x(!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:l})]}),r&&e.jsx(t,{flex:"1",textAlign:"right",children:(()=>{const s=r?.ts,a=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]}),a&&e.jsxs(n,{fontSize:"sm",color:"fg.muted",children:["Imported from snap store"," ",e.jsx(n,{as:"span",fontWeight:"bold",color:"blue.600",children:a})]})]})})()}),p&&e.jsx(g,{size:"md"})]}),e.jsx(w,{open:i,children:e.jsx(z,{children:u?e.jsx(y,{error:u,title:`Error loading channel ${l}`}):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(D,{templateColumns:{base:"1fr",lg:"repeat(auto-fit, minmax(600px, 1fr))"},gap:4,justifyItems:"center",children:o.sort((s,a)=>new Date(a.lastModified)-new Date(s.lastModified)).map((s,a)=>e.jsx(L,{item:s,channelId:l},a))}):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)"]})})]})},B=()=>{const{data:l,isLoading:d,error:h}=m({queryKey:["info"],queryFn:()=>b("/api/info")}),i=l?.channels?.map(r=>r.id)||[],x=d,c=h;return x?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,{error:c})}):e.jsx(t,{py:6,px:6,children:e.jsxs(C,{gap:6,align:"center",children:[i.map(r=>e.jsx(v,{channelId:r},r)),i.length===0&&!x&&e.jsx(n,{mt:4,color:"fg.muted",children:"No channels found."})]})})};export{B as default};
@@ -0,0 +1 @@
1
+ import{al as C,A as B,r as b,ap as w,j as e,B as r,S as p,T as n,L as z,c as M,d as v,F as D}from"./vendor-BVgSJH5C.js";import{a as E,b as I,f as L}from"./index-543A5WcJ.js";const T=()=>{const{channelId:l,prj:f}=C(),g=B(),h=b.useRef(null),{data:j,isLoading:S,error:m,fetchNextPage:u,hasNextPage:a,isFetchingNextPage:x}=w({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}),d=j?.pages.flatMap(t=>t.data)||[];b.useEffect(()=>{if(!a||x)return;const t=new IntersectionObserver(s=>{s[0].isIntersecting&&u()},{rootMargin:"100px",threshold:0});return h.current&&t.observe(h.current),()=>t.disconnect()},[a,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(p,{size:"xl"})}):m?e.jsx(r,{mt:5,px:6,children:e.jsx(E,{error:m,fallbackMessage:"Failed to fetch project data"})}):e.jsxs(r,{py:6,px:6,children:[e.jsx(I,{channelId:l,project:f,onBackClick:()=>g("/sources"),backLabel:"Back to sources"}),d.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:d.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(z,{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(v,{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}`))})]}),a&&e.jsx(r,{ref:h,p:4,textAlign:"center",children:x&&e.jsxs(D,{justify:"center",align:"center",gap:2,children:[e.jsx(p,{size:"sm"}),e.jsx(n,{fontSize:"sm",color:"fg.muted",children:"Loading more resources..."})]})}),!a&&d.length>0&&e.jsx(r,{p:4,textAlign:"center",children:e.jsxs(n,{fontSize:"sm",color:"fg.muted",children:["All ",d.length," resources loaded"]})})]})]})};export{T as default};
@@ -0,0 +1 @@
1
+ import{al as K,A as Q,ag as V,r as x,u as R,j as e,B as t,S as _,F as p,T as s,d as f,aq as J,ar as X,as as B,at as I,E as Z,H as Y,J as ee,K as re,N as te,O as oe,Q as se,U as le,a as ne,am as F,an as A,ao as D}from"./vendor-BVgSJH5C.js";import{a as P,b as ae,r as W,c as ie,f as O}from"./index-543A5WcJ.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(s,{as:"span",fontFamily:"mono",color:g,fontWeight:"bold",children:u.v},j)}else return`{{${u.t}}}`})}const xe=()=>{const{channelId:m}=K(),u=Q(),[j]=V(),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:N,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={},a={};l.segments.forEach(i=>{const h=i.group||"(no group)",T=i.mf||"text";r[h]=(r[h]||0)+1,a[T]=(a[T]||0)+1});const o=Object.keys(r).reduce((i,h)=>r[i]>r[h]?i:h,Object.keys(r)[0]),n=Object.keys(a).reduce((i,h)=>a[i]>a[h]?i:h,Object.keys(a)[0]);return{defaultGroup:o,defaultFormat:n,segments:l.segments}},[l?.segments]),E=(r,a)=>{const o=new Set(c);a?o.add(r):o.delete(r),y(o)},G=r=>{if(r){const a=new Set(d.map((o,n)=>n));y(a)}else y(new Set)},U=()=>{if(!b){alert("Please select a target language first");return}const a=Array.from(c).map(o=>d[o]).map(o=>({guid:o.guid,rid:l.id,sid:o.sid,nsrc:o.nstr,notes:o.notes}));ie(l.sourceLang,b,m,a),y(new Set),L("")},q=d.length>0&&c.size===d.length,H=c.size>0&&c.size<d.length,$=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?N?e.jsx(t,{display:"flex",justifyContent:"center",mt:10,children:e.jsx(_,{size:"xl"})}):v?e.jsx(t,{mt:5,px:6,children:e.jsx(P,{error:v,fallbackMessage:"Failed to fetch resource data"})}):e.jsxs(t,{py:6,px:6,h:"100vh",display:"flex",flexDirection:"column",children:[e.jsx(ae,{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(s,{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(s,{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(s,{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(s,{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(s,{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(s,{fontSize:"sm",color:"fg.muted",mb:1,children:"Last Modified"}),e.jsx(s,{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,a=new Date(l.modified),o=Math.floor((r-a)/1e3),n=new Intl.RelativeTimeFormat("en",{numeric:"auto",style:"short"});return o<60?n.format(-o,"second"):o<3600?n.format(-Math.floor(o/60),"minute"):o<86400?n.format(-Math.floor(o/3600),"hour"):o<2592e3?n.format(-Math.floor(o/86400),"day"):o<31536e3?n.format(-Math.floor(o/2592e3),"month"):n.format(-Math.floor(o/31536e3),"year")})()})]})]})}),e.jsx(t,{flex:"1",display:"flex",flexDirection:"column",children:e.jsxs(J,{value:k,onValueChange:r=>M(r.value),children:[e.jsxs(X,{mb:4,children:[e.jsxs(B,{value:"segments",children:["Segments (",d.length,")"]}),e.jsx(B,{value:"raw",children:"Raw Content"})]}),e.jsxs(I,{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(s,{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(s,{fontSize:"sm",color:"blue.600",children:"Target Language:"}),e.jsxs(Z,{size:"sm",width:"200px",value:b?[b]:[],positioning:{strategy:"absolute",placement:"bottom-start",flip:!0,gutter:4},children:[e.jsxs(Y,{children:[e.jsx(s,{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:$.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(F,{checked:q,onCheckedChange:r=>G(r.checked),children:[e.jsx(A,{ref:r=>{r&&(r.indeterminate=H)}}),e.jsx(D,{})]})}),e.jsx(t,{as:"th",p:3,textAlign:"left",borderBottom:"1px",borderColor:"border.default",w:"12%",children:e.jsx(s,{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(s,{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(s,{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(s,{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(s,{fontSize:"sm",fontWeight:"bold",color:"blue.600",children:"NOTES"})})]})}),e.jsx(t,{as:"tbody",children:d.map((r,a)=>{const o=S&&r.guid===S;return e.jsxs(t,{as:"tr",ref:o?w:null,bg:o?"yellow.subtle":"transparent",_hover:{bg:o?"yellow.muted":"gray.subtle"},borderLeft:o?"4px":"0",borderLeftColor:o?"yellow.solid":"transparent",children:[e.jsx(t,{as:"td",p:3,borderBottom:"1px",borderColor:"border.subtle",textAlign:"center",children:e.jsxs(F,{checked:c.has(a),onCheckedChange:n=>E(a,n.checked),children:[e.jsx(A,{}),e.jsx(D,{})]})}),e.jsx(t,{as:"td",p:3,borderBottom:"1px",borderColor:"border.subtle",children:e.jsx(s,{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(s,{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(s,{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(s,{fontSize:"xs",noOfLines:3,children:de(r.nstr)}),(()=>{const n=r.group||"(no group)";return n!==z?e.jsxs(s,{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(s,{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(s,{fontSize:"xs",color:"gray.600",fontStyle:"italic",children:W(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(s,{fontSize:"xs",color:"gray.600",fontWeight:"semibold",mb:1,children:"Placeholders:"}),Object.entries(r.notes.ph).map(([n,i])=>e.jsxs(s,{fontSize:"xs",color:"gray.600",mb:1,children:[e.jsx(s,{as:"span",fontFamily:"mono",color:"purple.600",fontWeight:"bold",children:n}),": ",W(i.desc),i.sample&&e.jsxs(s,{as:"span",color:"gray.500",children:[" ",'(e.g., "',i.sample,'")']})]},n))]})]})]},r.guid)})})]}),d.length===0&&e.jsx(p,{justify:"center",p:8,children:e.jsx(s,{color:"fg.muted",children:"No segments found in this resource"})})]})]}),e.jsx(I,{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(P,{error:{message:"No resource ID specified in the URL."},title:"Missing Resource ID"})})};export{xe as default};
@@ -0,0 +1 @@
1
+ import{ag as B,r as c,u as O,j as e,B as n,S as T,F as S,T as d,ah as q,ai as R,aj as W,ak as F,w as D,x as L,L as M,c as H,G as K}from"./vendor-BVgSJH5C.js";import{a as A,M as G,P as _,f as w}from"./index-543A5WcJ.js";const N=({channelId:l,hideComplete:x,selectedLanguagePairs:u,calculateCompletionPercentage:z,hasIncompleteContent:p,expandAll:j})=>{const[r,C]=c.useState(!1);c.useEffect(()=>{j!==void 0&&C(j)},[j]);const[b,P]=c.useState(!1);c.useEffect(()=>{r&&!b&&P(!0)},[r,b]);const $=r||b,{data:a,isLoading:k,error:g}=O({queryKey:["status",l],queryFn:()=>w(`/api/status/${l}`),enabled:$}),f=c.useMemo(()=>{if(!a)return a;const i={};return Object.entries(a).forEach(([m,h])=>{const t={};Object.entries(h).forEach(([s,o])=>{if(u.length>0){const E=`${m} → ${s}`;if(!u.includes(E))return}const y={};Object.entries(o).forEach(([E,v])=>{x&&!p(v.pairSummaryByStatus)||(y[E]=v)}),Object.keys(y).length>0&&(t[s]=y)}),Object.keys(t).length>0&&(i[m]=t)}),Object.keys(i).length>0?i:null},[a,x,u,p]);return x&&!f&&a!==void 0?null:e.jsxs(n,{mb:4,p:r?6:4,borderWidth:"2px",borderRadius:"lg",bg:"white",borderColor:"green.200",children:[e.jsxs(n,{display:"flex",alignItems:"center",gap:3,cursor:"pointer",onClick:()=>C(!r),_hover:{bg:"gray.50"},borderRadius:"md",mx:-2,px:2,py:1,...r&&{mb:4,pb:4,borderBottom:"2px",borderColor:"green.100"},children:[e.jsx(d,{fontSize:"lg",color:"green.600",children:r?"▼":"▶"}),e.jsx(d,{fontSize:"lg",fontWeight:"bold",color:"green.600",children:l})]}),e.jsx(D,{open:r,children:e.jsx(L,{children:g?e.jsx(A,{error:g,title:`Error loading channel ${l}`}):k?e.jsxs(n,{display:"flex",flexDirection:"column",alignItems:"center",gap:3,py:8,children:[e.jsx(T,{size:"md"}),e.jsx(d,{color:"fg.muted",children:"Loading channel data..."})]}):f&&Object.keys(f).length>0?Object.entries(f).map(([i,m])=>Object.entries(m).map(([h,t])=>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(M,{as:H,to:`/status/${l}/${i}/${h}`,fontSize:"lg",fontWeight:"semibold",color:"blue.600",_hover:{textDecoration:"underline"},children:[i," → ",h]})}),e.jsx(K,{templateColumns:"repeat(auto-fit, minmax(420px, 1fr))",gap:4,children:Object.entries(t).map(([s,o])=>e.jsx(_,{project:{translatedDetails:o.translatedDetails||[],untranslatedDetails:o.untranslatedDetails||{},pairSummary:o.pairSummary,pairSummaryByStatus:o.pairSummaryByStatus,projectName:s},channelId:l,sourceLang:i,targetLang:h},`${l}-${i}-${h}-${s}`))})]},`${i}-${h}`))):a&&Object.keys(a).length===0?e.jsx(n,{display:"flex",justifyContent:"center",py:8,children:e.jsx(d,{color:"fg.muted",children:"This channel has no projects"})}):e.jsx(n,{display:"flex",justifyContent:"center",py:8,children:e.jsx(d,{color:"fg.muted",children:"No content available for this channel"})})})})]})},I=()=>{const[l,x]=B(),[u,z]=c.useState(()=>l.get("hideComplete")==="true"),[p,j]=c.useState(void 0),[r,C]=c.useState(()=>{const t=l.get("pairs");return t?t.split(",").map(s=>s.replace("*"," → ")):[]}),{data:b,isLoading:P,error:$}=O({queryKey:["info"],queryFn:()=>w("/api/info")}),{data:a}=O({queryKey:["tmStats"],queryFn:()=>w("/api/tm/stats")}),k=c.useMemo(()=>!a||!Array.isArray(a)?[]:a.map(([t,s])=>`${t} → ${s}`),[a]),g=b?.channels?.map(t=>t.id)||[],f=P,i=$;c.useEffect(()=>{const t=new URLSearchParams(l);if(u?t.set("hideComplete","true"):t.delete("hideComplete"),r.length>0){const s=r.map(o=>o.replace(" → ","*")).join(",");t.set("pairs",s)}else t.delete("pairs");x(t,{replace:!0})},[u,r,l,x]);const m=t=>{const s=Object.values(t).reduce((o,y)=>o+y,0);return s===0?100:Math.round((t.translated||0)/s*100)},h=t=>(t.untranslated||0)>0||(t["in flight"]||0)>0||(t["low quality"]||0)>0;return P?e.jsx(n,{display:"flex",justifyContent:"center",mt:5,children:e.jsx(T,{size:"xl"})}):i?e.jsx(n,{mt:5,px:6,children:e.jsx(A,{error:i})}):e.jsxs(n,{children:[e.jsx(n,{bg:"blue.subtle",borderBottom:"1px",borderColor:"blue.muted",shadow:"md",borderLeft:"4px",borderLeftColor:"blue.500",px:6,py:4,children:e.jsxs(S,{align:"center",justify:"space-between",children:[e.jsx(d,{fontSize:"md",fontWeight:"semibold",color:"blue.700",children:"Translation Status"}),e.jsxs(S,{align:"center",gap:6,children:[e.jsxs(S,{align:"center",gap:2,children:[e.jsx(d,{fontSize:"sm",color:"blue.600",children:"Expand All"}),e.jsxs(q,{checked:p===!0,onCheckedChange:t=>j(t.checked),size:"sm",colorPalette:"blue",children:[e.jsx(R,{}),e.jsx(W,{bg:p===!0?"blue.500":"gray.300",children:e.jsx(F,{})})]})]}),e.jsxs(S,{align:"center",gap:2,children:[e.jsx(d,{fontSize:"sm",color:"blue.600",children:"Hide Complete"}),e.jsxs(q,{checked:u,onCheckedChange:t=>z(t.checked),size:"sm",colorPalette:"blue",children:[e.jsx(R,{}),e.jsx(W,{bg:u?"blue.500":"gray.300",children:e.jsx(F,{})})]})]}),e.jsxs(S,{align:"center",gap:2,children:[e.jsx(d,{fontSize:"sm",color:"blue.600",children:"Language Pairs"}),e.jsx(n,{minW:"150px",children:e.jsx(G,{value:r,onChange:C,options:k,placeholder:"All"})})]})]})]})}),e.jsxs(n,{py:6,px:6,children:[g.map(t=>e.jsx(N,{channelId:t,hideComplete:u,selectedLanguagePairs:r,calculateCompletionPercentage:m,hasIncompleteContent:h,expandAll:p},t)),g.length===0&&!f&&e.jsx(d,{mt:4,color:"fg.muted",children:"No channels found."})]})]})};export{I as default};
@@ -0,0 +1 @@
1
+ import{al as J,A as _,ag as H,r as a,u as K,j as e,B as t,S as k,T as o,F,a as M,am as R,an as A,ao as I,V as f,a2 as b,L as Q,c as X,p as Y,q as Z,s as ee,t as re,v as te}from"./vendor-BVgSJH5C.js";import{a as oe,f as se}from"./index-543A5WcJ.js";function W(j){return j.map(l=>typeof l=="string"?l:`{{${l.t}}}`).join("")}const ae=()=>{const{channelId:j,sourceLang:l,targetLang:m}=J();_();const[T]=H(),S=T.get("prj"),[d,C]=a.useState(new Set),[v,L]=a.useState({guid:"",channel:"",prj:"",rid:"",sid:"",nsrc:"",group:""}),[u,$]=a.useState({guid:"",channel:"",prj:"",rid:"",sid:"",nsrc:"",group:""}),z=a.useRef(),w=a.useRef(null),c=a.useRef({}),{data:y=[],isLoading:B,isError:D,error:O}=K({queryKey:["statusDetail",j,l,m,S],queryFn:()=>se(`/api/status/${j}/${l}/${m}${S?`?prj=${encodeURIComponent(S)}`:""}`)}),h=a.useMemo(()=>y.length?y.filter(r=>Object.entries(v).every(([s,n])=>{if(!n.trim())return!0;const i=r[s];return i==null?!1:s==="nsrc"&&Array.isArray(i)?W(i).toLowerCase().includes(n.toLowerCase()):String(i).toLowerCase().includes(n.toLowerCase())})):[],[y,v]),x=a.useCallback(r=>{w.current=r},[]),p=a.useCallback(()=>{w.current=null},[]),g=a.useCallback((r,s)=>{$(n=>({...n,[r]:s})),C(new Set),clearTimeout(z.current),z.current=setTimeout(()=>{L(n=>({...n,[r]:s}))},300)},[]),P=(r,s)=>{const n=new Set(d);s?n.add(r):n.delete(r),C(n)},E=r=>{if(r){const s=new Set(h.map((n,i)=>i));C(s)}else C(new Set)},U=()=>{const r=sessionStorage.getItem("statusCart");return r?JSON.parse(r):{}},N=r=>{sessionStorage.setItem("statusCart",JSON.stringify(r))},V=()=>{const r=U(),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),C(new Set),window.dispatchEvent(new Event("cartUpdated"))},q=h.length>0&&d.size===h.length,G=d.size>0&&d.size<h.length;return a.useEffect(()=>{if(w.current&&c.current[w.current]){const r=c.current[w.current];setTimeout(()=>{if(r&&document.contains(r)){r.focus();const s=r.value.length;r.setSelectionRange(s,s)}},10)}},[h]),a.useEffect(()=>()=>{z.current&&clearTimeout(z.current)},[]),B?e.jsx(t,{display:"flex",justifyContent:"center",mt:10,children:e.jsx(k,{size:"xl"})}):D?e.jsx(t,{mt:5,px:6,children:e.jsx(oe,{error:O,fallbackMessage:"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]}),B&&e.jsx(k,{size:"sm"})]})]}),S&&e.jsxs(t,{children:[e.jsx(o,{fontSize:"sm",color:"fg.muted",mb:1,children:"Project"}),e.jsx(o,{fontSize:"lg",fontWeight:"semibold",color:"purple.600",children:S})]}),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 ",y.length," shown"]})]}),e.jsx(t,{ml:"auto",children:d.size>0&&e.jsxs(M,{colorPalette:"blue",onClick:V,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(R,{checked:q,onCheckedChange:r=>E(r.checked),children:[e.jsx(A,{ref:r=>{r&&(r.indeterminate=G)}}),e.jsx(I,{})]})}),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(R,{checked:d.has(s),onCheckedChange:n=>P(s,n.checked),children:[e.jsx(A,{}),e.jsx(I,{})]})}),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(Q,{as:X,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(Y,{children:[e.jsx(Z,{asChild:!0,children:e.jsx(o,{fontSize:"xs",noOfLines:2,cursor:"help",dir:l?.startsWith("he")||l?.startsWith("ar")?"rtl":"ltr",children:W(r.nsrc)})}),e.jsx(ee,{children:e.jsxs(re,{maxW:"400px",bg:"yellow.100",borderWidth:"1px",borderColor:"yellow.300",shadow:"lg",children:[e.jsx(te,{}),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:W(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&&!B&&e.jsx(F,{justify:"center",p:8,children:e.jsx(o,{color:"fg.muted",children:"No untranslated content found for the current filters"})})]})]})})};export{ae as default};
@@ -0,0 +1 @@
1
+ import{A as c,al as l,j as a,B as s,V as x,a as u,c as g}from"./vendor-BVgSJH5C.js";import{L as m,e as d}from"./index-543A5WcJ.js";const j=()=>{const r=c(),{sourceLang:e,targetLang:t}=l(),n=(o,i)=>{r(`/tm/providers/${o}/${i}`)};return a.jsxs(s,{children:[a.jsx(m,{onSelect:n,currentPair:{sourceLang:e,targetLang:t}}),a.jsx(s,{py:6,px:6,children:a.jsx(x,{gap:6,align:"stretch",maxW:"800px",mx:"auto",w:"100%",children:a.jsx(d,{sourceLang:e,targetLang:t,headerAction:a.jsx(u,{as:g,to:`/tm/${e}/${t}`,size:"sm",colorPalette:"blue",variant:"outline",children:"Search"})})})})]})};export{j as default};
@@ -0,0 +1 @@
1
+ import{al as _e,A as Le,ag as Ne,r as s,ap as Ue,u as qe,j as e,B as r,S as Q,F as I,T as o,am as _,an as L,ao as N,a as ne,V as g,a2 as B,au as Ge,av as Me,aw as Ee,ax as Ye,ay as Ve,az as He,aA as Qe,af as Ke,L as Je,c as Xe,p as ue,q as xe,s as ge,t as pe,v as be,aB as Ze}from"./vendor-BVgSJH5C.js";import{a as et,L as tt,M as U,d as rt,f as fe}from"./index-543A5WcJ.js";function se(l){return Array.isArray(l)?l.map(h=>typeof h=="string"?h:`{{${h.t}}}`).join(""):""}function K(l,h=""){return l==null?h:typeof l=="string"?l:typeof l=="number"||typeof l=="boolean"?String(l):h}const st=()=>{const{sourceLang:l,targetLang:h}=_e(),me=Le(),[c,le]=Ne(),[z,W]=s.useState(new Set),w=t=>{const n=c.get(t),i=n?n.split(",").filter(Boolean):[];return t==="tmStore"?i.map(j=>j==="__null__"?"New/Unassigned":j):i},[a,J]=s.useState(()=>({guid:c.get("guid")||"",nid:c.get("nid")||"",rid:c.get("rid")||"",sid:c.get("sid")||"",nsrc:c.get("nsrc")||"",ntgt:c.get("ntgt")||"",tconf:w("tconf"),q:w("q"),translationProvider:w("translationProvider"),tmStore:w("tmStore"),group:w("group"),jobGuid:c.get("jobGuid")||"",channel:w("channel"),minTS:c.get("minTS")||"",maxTS:c.get("maxTS")||""})),[b,je]=s.useState(()=>{const t=c.get("active");return t!==null?t==="1":!0}),[p,Se]=s.useState(()=>c.get("showTechnicalColumns")==="1"),[f,Ce]=s.useState(()=>c.get("showTNotes")==="1"),[m,we]=s.useState(()=>c.get("showOnlyLeveraged")==="1"),[x,X]=s.useState(()=>({guid:c.get("guid")||"",nid:c.get("nid")||"",rid:c.get("rid")||"",sid:c.get("sid")||"",nsrc:c.get("nsrc")||"",ntgt:c.get("ntgt")||"",tconf:w("tconf"),q:w("q"),translationProvider:w("translationProvider"),tmStore:w("tmStore"),group:w("group"),jobGuid:c.get("jobGuid")||"",channel:w("channel"),minTS:c.get("minTS")||"",maxTS:c.get("maxTS")||""})),M=s.useRef(),F=s.useRef(),P=s.useRef(),q=s.useRef(null),A=s.useRef({}),Z=s.useRef(null),G=s.useRef(null),[u,ie]=s.useState(!1),[E,Y]=s.useState(""),[V,H]=s.useState(""),[Te,ee]=s.useState(!1),ye=s.useMemo(()=>["tmSearch",l,h,a,b,f,m,p],[l,h,a,b,f,m,p]),{data:te,isLoading:D,isError:ve,error:ze,fetchNextPage:ae,hasNextPage:re,isFetchingNextPage:oe,isFetching:de}=Ue({queryKey:ye,queryFn:async({pageParam:t=1})=>{const n=new URLSearchParams({sourceLang:l,targetLang:h,page:t.toString(),limit:"100",...b&&{active:"1"},...f&&{onlyTNotes:"1"},...p&&{includeTechnicalColumns:"1"},...m&&{onlyLeveraged:"1"}});if(["guid","nid","rid","sid","nsrc","ntgt","jobGuid"].forEach(d=>{a[d]&&a[d].trim()!==""&&n.set(d,a[d])}),["channel","tconf","q","translationProvider","tmStore","group"].forEach(d=>{if(Array.isArray(a[d])&&a[d].length>0){let v=a[d];d==="tmStore"&&(v=v.map(S=>S==="New/Unassigned"?"__null__":S)),n.set(d,v.join(","))}}),a.minTS&&/^\d{1,2}\/\d{1,2}$/.test(a.minTS)){const d=new Date().getFullYear(),[v,S]=a.minTS.split("/"),O=new Date(`${d}-${v.padStart(2,"0")}-${S.padStart(2,"0")}T00:00:00`);n.set("minTS",O.getTime().toString())}if(a.maxTS&&/^\d{1,2}\/\d{1,2}$/.test(a.maxTS)){const d=new Date().getFullYear(),[v,S]=a.maxTS.split("/"),O=new Date(`${d}-${v.padStart(2,"0")}-${S.padStart(2,"0")}T23:59:59.999`);n.set("maxTS",O.getTime().toString())}return await fe(`/api/tm/search?${n}`)},getNextPageParam:(t,n)=>t.data.length===parseInt(t.limit)?n.length+1:void 0,staleTime:3e4,refetchOnWindowFocus:!1,placeholderData:Ze}),{data:k={}}=qe({queryKey:["lowCardinalityColumns",l,h],queryFn:()=>fe(`/api/tm/lowCardinalityColumns/${l}/${h}`),staleTime:300*1e3,enabled:!D}),y=s.useMemo(()=>te?.pages.flatMap(t=>!t||!Array.isArray(t.data)?[]:t.data)||[],[te]),We=s.useCallback(t=>{D||oe||(M.current&&M.current.disconnect(),M.current=new IntersectionObserver(n=>{n[0].isIntersecting&&re&&ae()}),t&&M.current.observe(t))},[D,oe,re,ae]),R=s.useCallback(t=>{q.current=t},[]),$=s.useCallback(()=>{q.current=null},[]),T=s.useCallback((t,n,i,j,ce)=>{const d=new URLSearchParams;Object.entries(t).forEach(([v,S])=>{if(Array.isArray(S)){if(S.length>0){let O=S;v==="tmStore"&&(O=S.map(he=>he==="New/Unassigned"?"__null__":he)),d.set(v,O.join(","))}}else typeof S=="string"&&S.trim()!==""&&d.set(v,S)}),n?Object.keys(Object.fromEntries(d)).length>0&&d.set("active","1"):d.set("active","0"),i&&d.set("showTechnicalColumns","1"),j&&d.set("showTNotes","1"),ce&&d.set("showOnlyLeveraged","1"),le(d,{replace:!0})},[le]),C=s.useCallback((t,n)=>{X(i=>({...i,[t]:n})),W(new Set),G.current&&(G.current.scrollTop=0),clearTimeout(F.current),F.current=setTimeout(()=>{const i={...a,[t]:n};J(i),clearTimeout(P.current),P.current=setTimeout(()=>{T(i,b,p,f,m)},200)},300)},[a,b,p,f,m,T]),Ae=(t,n)=>{const i=new Set(z);n?i.add(t):i.delete(t),W(i)},Be=t=>{if(t){const n=new Set(y.map((i,j)=>j));W(n)}else W(new Set)},Fe=()=>{const t=Array.from(z).map(n=>y[n]);rt(l,h,t),W(new Set)},Pe=y.length>0&&z.size===y.length,ke=z.size>0&&z.size<y.length;s.useEffect(()=>{if(q.current&&A.current[q.current]){const t=A.current[q.current];setTimeout(()=>{if(t&&document.contains(t)&&(t.focus(),typeof t.setSelectionRange=="function"&&t.value)){const n=t.value.length;t.setSelectionRange(n,n)}},10)}},[y]);const Re=s.useCallback(t=>{je(t),T(a,t,p,f,m)},[a,p,f,m,T]),$e=s.useCallback(t=>{Ce(t),W(new Set),T(a,b,p,t,m)},[a,b,p,m,T]),Ie=s.useCallback(t=>{we(t),W(new Set),T(a,b,p,f,t)},[a,b,p,f,T]),De=s.useCallback(t=>{Se(t),T(a,b,t,f,m)},[a,b,f,m,T]);if(s.useEffect(()=>()=>{F.current&&clearTimeout(F.current),P.current&&clearTimeout(P.current)},[]),s.useEffect(()=>(de?Z.current=setTimeout(()=>{ie(!0)},1e3):(clearTimeout(Z.current),ie(!1)),()=>clearTimeout(Z.current)),[de]),D&&y.length===0&&!te)return e.jsx(r,{display:"flex",justifyContent:"center",mt:10,children:e.jsx(Q,{size:"xl"})});if(ve)return e.jsx(r,{mt:5,px:6,children:e.jsx(et,{error:ze,fallbackMessage:"Failed to fetch translation memory data"})});const Oe=(t,n)=>{me(`/tm/${t}/${n}`)};return e.jsxs(r,{children:[e.jsx(tt,{onSelect:Oe,currentPair:{sourceLang:l,targetLang:h},triggerContent:e.jsxs(I,{align:"center",gap:3,children:[e.jsxs(o,{fontSize:"md",fontWeight:"semibold",color:"blue.700",children:[l," → ",h]}),D&&e.jsx(Q,{size:"sm"})]}),rightContent:e.jsxs(e.Fragment,{children:[e.jsxs(I,{align:"center",gap:2,children:[e.jsx(o,{fontSize:"sm",color:"blue.600",children:"Show Technical IDs"}),e.jsxs(_,{checked:p,onCheckedChange:t=>De(t.checked),size:"sm",disabled:u,children:[e.jsx(L,{}),e.jsx(N,{borderWidth:"2px",borderColor:"blue.400"})]})]}),e.jsxs(I,{align:"center",gap:2,children:[e.jsx(o,{fontSize:"sm",color:"blue.600",children:"Only Leveraged"}),e.jsxs(_,{checked:m,onCheckedChange:t=>Ie(t.checked),size:"sm",disabled:u,children:[e.jsx(L,{}),e.jsx(N,{borderWidth:"2px",borderColor:"blue.400"})]})]}),e.jsxs(I,{align:"center",gap:2,children:[e.jsx(o,{fontSize:"sm",color:"blue.600",children:"Only TNotes"}),e.jsxs(_,{checked:f,onCheckedChange:t=>$e(t.checked),size:"sm",disabled:u,children:[e.jsx(L,{}),e.jsx(N,{borderWidth:"2px",borderColor:"blue.400"})]})]}),z.size>0&&e.jsxs(ne,{colorPalette:"blue",onClick:Fe,disabled:u,children:["Add to Cart (",z.size," ",z.size===1?"TU":"TUs",")"]})]})}),e.jsxs(r,{ref:G,mx:6,mt:6,h:"calc(100vh - 140px)",bg:"white",borderRadius:"lg",shadow:"sm",overflow:"auto",position:"relative",children:[u&&e.jsx(r,{position:"absolute",top:0,left:0,bottom:0,minW:"100%",w:G.current?.scrollWidth?`${G.current.scrollWidth}px`:"100%",bg:"blackAlpha.400",display:"flex",alignItems:"center",zIndex:1500,borderRadius:"lg",children:e.jsx(r,{position:"sticky",left:"50%",transform:"translateX(-50%)",children:e.jsxs(g,{gap:3,bg:"white",p:6,borderRadius:"md",shadow:"lg",zIndex:1501,children:[e.jsx(Q,{size:"lg",color:"blue.500"}),e.jsx(o,{color:"fg.default",fontWeight:"medium",children:"Loading..."})]})})}),e.jsxs(r,{as:"table",w:"100%",fontSize:"sm",children:[e.jsx(r,{as:"thead",position:"sticky",top:0,bg:"blue.subtle",zIndex:1,borderBottom:"2px",borderColor:"blue.muted",shadow:"sm",children:e.jsxs(r,{as:"tr",children:[e.jsx(r,{as:"th",p:3,borderBottom:"1px",borderColor:"border.default",minW:"60px",textAlign:"center",children:e.jsxs(_,{checked:Pe,onCheckedChange:t=>Be(t.checked),disabled:u,children:[e.jsx(L,{ref:t=>{t&&(t.indeterminate=ke)}}),e.jsx(N,{borderWidth:"2px",borderColor:"blue.500"})]})}),p&&e.jsxs(e.Fragment,{children:[e.jsx(r,{as:"th",p:3,borderBottom:"1px",borderColor:"border.default",minW:"120px",textAlign:"left",children:e.jsxs(g,{gap:2,align:"stretch",children:[e.jsx(o,{fontSize:"sm",fontWeight:"bold",color:"blue.600",children:"guid"}),e.jsx(B,{size:"xs",placeholder:"Filter GUID...",value:x.guid,onChange:t=>C("guid",t.target.value),onFocus:()=>R("guid"),onBlur:$,ref:t=>{t&&(A.current.guid=t)},bg:"yellow.subtle",disabled:u},"guid-input")]})}),e.jsx(r,{as:"th",p:3,borderBottom:"1px",borderColor:"border.default",minW:"120px",textAlign:"left",children:e.jsxs(g,{gap:2,align:"stretch",children:[e.jsx(o,{fontSize:"sm",fontWeight:"bold",color:"blue.600",children:"nid"}),e.jsx(B,{size:"xs",placeholder:"Filter NID...",value:x.nid,onChange:t=>C("nid",t.target.value),onFocus:()=>R("nid"),onBlur:$,ref:t=>{t&&(A.current.nid=t)},bg:"yellow.subtle",disabled:u},"nid-input")]})}),e.jsx(r,{as:"th",p:3,borderBottom:"1px",borderColor:"border.default",minW:"120px",textAlign:"left",children:e.jsxs(g,{gap:2,align:"stretch",children:[e.jsx(o,{fontSize:"sm",fontWeight:"bold",color:"blue.600",children:"jobGuid"}),e.jsx(B,{size:"xs",placeholder:"Filter Job GUID...",value:x.jobGuid,onChange:t=>C("jobGuid",t.target.value),onFocus:()=>R("jobGuid"),onBlur:$,ref:t=>{t&&(A.current.jobGuid=t)},bg:"yellow.subtle",disabled:u},"jobGuid-input")]})}),e.jsx(r,{as:"th",p:3,borderBottom:"1px",borderColor:"border.default",minW:"150px",textAlign:"left",children:e.jsxs(g,{gap:2,align:"stretch",children:[e.jsx(o,{fontSize:"sm",fontWeight:"bold",color:"blue.600",children:"rid"}),e.jsx(B,{size:"xs",placeholder:"Filter RID...",value:x.rid,onChange:t=>C("rid",t.target.value),onFocus:()=>R("rid"),onBlur:$,ref:t=>{t&&(A.current.rid=t)},bg:"yellow.subtle",disabled:u},"rid-input")]})}),e.jsx(r,{as:"th",p:3,borderBottom:"1px",borderColor:"border.default",minW:"150px",textAlign:"left",children:e.jsxs(g,{gap:2,align:"stretch",children:[e.jsx(o,{fontSize:"sm",fontWeight:"bold",color:"blue.600",children:"sid"}),e.jsx(B,{size:"xs",placeholder:"Filter SID...",value:x.sid,onChange:t=>C("sid",t.target.value),onFocus:()=>R("sid"),onBlur:$,ref:t=>{t&&(A.current.sid=t)},bg:"yellow.subtle",disabled:u},"sid-input")]})}),e.jsx(r,{as:"th",p:3,borderBottom:"1px",borderColor:"border.default",minW:"120px",textAlign:"left",children:e.jsxs(g,{gap:2,align:"stretch",children:[e.jsx(o,{fontSize:"sm",fontWeight:"bold",color:"blue.600",children:"Group"}),e.jsx(U,{value:x.group,onChange:t=>C("group",t),options:k.group,placeholder:"Group...",disabled:u})]})}),e.jsx(r,{as:"th",p:3,borderBottom:"1px",borderColor:"border.default",minW:"120px",textAlign:"left",children:e.jsxs(g,{gap:2,align:"stretch",children:[e.jsx(o,{fontSize:"sm",fontWeight:"bold",color:"blue.600",children:"TM Store"}),e.jsx(U,{value:x.tmStore,onChange:t=>C("tmStore",t),options:(Array.isArray(k.tmStore)?k.tmStore:[]).map(t=>t==="__null__"?"New/Unassigned":K(t,String(t))),placeholder:"TM Store...",disabled:u})]})}),e.jsx(r,{as:"th",p:3,borderBottom:"1px",borderColor:"border.default",minW:"120px",textAlign:"left",children:e.jsxs(g,{gap:2,align:"stretch",children:[e.jsx(o,{fontSize:"sm",fontWeight:"bold",color:"blue.600",children:"Channel"}),e.jsx(U,{value:x.channel,onChange:t=>C("channel",t),options:k.channel,placeholder:"Channel...",disabled:u})]})})]}),e.jsx(r,{as:"th",p:3,borderBottom:"1px",borderColor:"border.default",minW:"350px",textAlign:"left",children:e.jsxs(g,{gap:2,align:"stretch",children:[e.jsx(o,{fontSize:"sm",fontWeight:"bold",color:"blue.600",textAlign:l?.startsWith("he")||l?.startsWith("ar")?"right":"left",children:"Source"}),e.jsx(B,{size:"xs",placeholder:"Filter source...",value:x.nsrc,onChange:t=>C("nsrc",t.target.value),onFocus:()=>R("nsrc"),onBlur:$,ref:t=>{t&&(A.current.nsrc=t)},bg:"yellow.subtle",dir:l?.startsWith("he")||l?.startsWith("ar")?"rtl":"ltr",disabled:u},"nsrc-input")]})}),e.jsx(r,{as:"th",p:3,borderBottom:"1px",borderColor:"border.default",minW:"350px",textAlign:"left",children:e.jsxs(g,{gap:2,align:"stretch",children:[e.jsx(o,{fontSize:"sm",fontWeight:"bold",color:"blue.600",textAlign:h?.startsWith("he")||h?.startsWith("ar")?"right":"left",children:"Target"}),e.jsx(B,{size:"xs",placeholder:"Filter target...",value:x.ntgt,onChange:t=>C("ntgt",t.target.value),onFocus:()=>R("ntgt"),onBlur:$,ref:t=>{t&&(A.current.ntgt=t)},bg:"yellow.subtle",dir:h?.startsWith("he")||h?.startsWith("ar")?"rtl":"ltr",disabled:u},"ntgt-input")]})}),e.jsx(r,{as:"th",p:3,borderBottom:"1px",borderColor:"border.default",minW:"60px",textAlign:"center",children:e.jsxs(g,{gap:2,align:"stretch",children:[e.jsx(o,{fontSize:"sm",fontWeight:"bold",color:"blue.600",children:"TConf"}),e.jsx(U,{value:x.tconf,onChange:t=>C("tconf",t),options:k.tconf,placeholder:"TConf...",disabled:u,sortNumeric:!0})]})}),e.jsx(r,{as:"th",p:3,borderBottom:"1px",borderColor:"border.default",minW:"40px",textAlign:"center",children:e.jsxs(g,{gap:2,align:"stretch",children:[e.jsx(o,{fontSize:"sm",fontWeight:"bold",color:"blue.600",children:"q"}),e.jsx(U,{value:x.q,onChange:t=>C("q",t),options:k.q,placeholder:"Quality...",disabled:u,sortNumeric:!0})]})}),e.jsx(r,{as:"th",p:3,borderBottom:"1px",borderColor:"border.default",minW:"120px",textAlign:"left",children:e.jsxs(g,{gap:2,align:"stretch",children:[e.jsx(o,{fontSize:"sm",fontWeight:"bold",color:"blue.600",children:"Provider"}),e.jsx(U,{value:x.translationProvider,onChange:t=>C("translationProvider",t),options:k.translationProvider,placeholder:"Provider...",disabled:u})]})}),e.jsx(r,{as:"th",p:3,borderBottom:"1px",borderColor:"border.default",minW:"80px",textAlign:"center",children:e.jsxs(g,{gap:2,align:"center",children:[e.jsx(o,{fontSize:"sm",fontWeight:"bold",color:"blue.600",children:"Active"}),e.jsxs(_,{checked:b,onCheckedChange:t=>Re(t.checked),size:"sm",disabled:u,children:[e.jsx(L,{}),e.jsx(N,{borderWidth:"2px",borderColor:"blue.400"})]})]})}),e.jsx(r,{as:"th",p:3,borderBottom:"1px",borderColor:"border.default",minW:"120px",textAlign:"center",children:e.jsxs(g,{gap:2,align:"stretch",children:[e.jsx(o,{fontSize:"sm",fontWeight:"bold",color:"blue.600",children:"Timestamp"}),e.jsxs(Ge,{open:Te,onOpenChange:t=>{ee(t.open),t.open&&(Y(x.minTS),H(x.maxTS))},children:[e.jsx(Me,{asChild:!0,children:e.jsx(o,{fontSize:"xs",cursor:"pointer",color:"blue.600",textDecoration:"underline",_hover:{color:"blue.700"},px:2,py:1,children:x.minTS||x.maxTS?`${x.minTS||"start"} → ${x.maxTS||"end"}`:"Filter dates..."})}),e.jsx(Ee,{children:e.jsxs(Ye,{children:[e.jsx(Ve,{}),e.jsx(He,{children:e.jsx(o,{fontSize:"sm",fontWeight:"semibold",children:"Date Range Filter"})}),e.jsx(Qe,{children:e.jsxs(g,{gap:3,align:"stretch",children:[e.jsxs(r,{children:[e.jsx(o,{fontSize:"xs",mb:1,color:"fg.muted",children:"From"}),e.jsx(B,{type:"date",size:"sm",value:E?(()=>{const[t,n]=E.split("/");return`${new Date().getFullYear()}-${t?.padStart(2,"0")}-${n?.padStart(2,"0")}`})():"",onChange:t=>{if(t.target.value){const[n,i,j]=t.target.value.split("-");Y(`${parseInt(i,10)}/${parseInt(j,10)}`),setTimeout(()=>t.target.blur(),0)}else Y("")}})]}),e.jsxs(r,{children:[e.jsx(o,{fontSize:"xs",mb:1,color:"fg.muted",children:"To"}),e.jsx(B,{type:"date",size:"sm",value:V?(()=>{const[t,n]=V.split("/");return`${new Date().getFullYear()}-${t?.padStart(2,"0")}-${n?.padStart(2,"0")}`})():"",onChange:t=>{if(t.target.value){const[n,i,j]=t.target.value.split("-");H(`${parseInt(i,10)}/${parseInt(j,10)}`),setTimeout(()=>t.target.blur(),0)}else H("")}})]}),e.jsxs(Ke,{gap:2,children:[e.jsx(ne,{size:"sm",variant:"outline",flex:1,onClick:()=>{X(t=>({...t,minTS:"",maxTS:""})),W(new Set),clearTimeout(F.current),F.current=setTimeout(()=>{const t={...a,minTS:"",maxTS:""};J(t),clearTimeout(P.current),P.current=setTimeout(()=>{T(t,b,p,f,m)},200)},300),Y(""),H(""),ee(!1)},children:"Clear"}),e.jsx(ne,{size:"sm",colorPalette:"blue",flex:1,onClick:()=>{X(t=>({...t,minTS:E,maxTS:V})),W(new Set),clearTimeout(F.current),F.current=setTimeout(()=>{const t={...a,minTS:E,maxTS:V};J(t),clearTimeout(P.current),P.current=setTimeout(()=>{T(t,b,p,f,m)},200)},300),ee(!1)},children:"Apply"})]})]})})]})})]})]})})]})}),e.jsx(r,{as:"tbody",children:y.map((t,n)=>e.jsxs(r,{as:"tr",ref:n===y.length-20?We:null,_hover:{bg:"gray.subtle"},children:[e.jsx(r,{as:"td",p:3,borderBottom:"1px",borderColor:"border.subtle",textAlign:"center",children:e.jsxs(_,{checked:z.has(n),onCheckedChange:i=>Ae(n,i.checked),disabled:u,children:[e.jsx(L,{}),e.jsx(N,{borderWidth:"1px",borderColor:"gray.400"})]})}),p&&e.jsxs(e.Fragment,{children:[e.jsx(r,{as:"td",p:3,borderBottom:"1px",borderColor:"border.subtle",children:e.jsx(o,{fontSize:"xs",fontFamily:"mono",color:"blue.600",userSelect:"all",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxW:"100px",children:t.guid})}),e.jsx(r,{as:"td",p:3,borderBottom:"1px",borderColor:"border.subtle",children:e.jsx(o,{fontSize:"xs",fontFamily:"mono",color:"purple.600",userSelect:"all",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxW:"100px",children:t.nid||""})}),e.jsx(r,{as:"td",p:3,borderBottom:"1px",borderColor:"border.subtle",children:e.jsx(o,{fontSize:"xs",fontFamily:"mono",color:"green.600",userSelect:"all",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxW:"100px",cursor:"pointer",_hover:{textDecoration:"underline"},onClick:i=>{i.preventDefault(),window.open(`/job/${t.jobGuid}`,"_blank")},children:t.jobGuid})}),e.jsx(r,{as:"td",p:3,borderBottom:"1px",borderColor:"border.subtle",children:e.jsx(o,{fontSize:"xs",wordBreak:"break-all",whiteSpace:"normal",children:t.rid})}),e.jsx(r,{as:"td",p:3,borderBottom:"1px",borderColor:"border.subtle",children:e.jsx(o,{fontSize:"xs",wordBreak:"break-all",whiteSpace:"normal",children:t.sid})}),e.jsx(r,{as:"td",p:3,borderBottom:"1px",borderColor:"border.subtle",children:e.jsx(o,{fontSize:"xs",color:t.group==="Unknown"||t.group==="Unassigned"?"gray.500":"fg.default",fontStyle:t.group==="Unknown"||t.group==="Unassigned"?"italic":"normal",children:t.group})}),e.jsx(r,{as:"td",p:3,borderBottom:"1px",borderColor:"border.subtle",children:e.jsx(o,{fontSize:"xs",fontFamily:"mono",color:K(t.tmStore)?"blue.600":"gray.500",fontStyle:K(t.tmStore)?"normal":"italic",children:K(t.tmStore,"New/Unassigned")})}),e.jsx(r,{as:"td",p:3,borderBottom:"1px",borderColor:"border.subtle",children:t.channel?e.jsx(Je,{as:Xe,to:`/sources/${t.channel}?rid=${encodeURIComponent(t.rid)}&guid=${encodeURIComponent(t.guid)}`,fontSize:"xs",color:"blue.600",_hover:{textDecoration:"underline"},children:t.channel}):e.jsx(o,{fontSize:"xs",children:t.channel})})]}),e.jsx(r,{as:"td",p:3,borderBottom:"1px",borderColor:"border.subtle",children:t.notes?e.jsxs(ue,{children:[e.jsx(xe,{asChild:!0,children:e.jsx(o,{fontSize:"xs",noOfLines:2,cursor:"help",dir:l?.startsWith("he")||l?.startsWith("ar")?"rtl":"ltr",children:se(t.nsrc)})}),e.jsx(ge,{children:e.jsxs(pe,{maxW:"400px",bg:"yellow.100",borderWidth:"1px",borderColor:"yellow.300",shadow:"lg",children:[e.jsx(be,{}),e.jsxs(r,{children:[t.notes.desc&&e.jsx(o,{fontSize:"sm",mb:2,whiteSpace:"pre-wrap",color:"black",children:t.notes.desc}),t.notes.ph&&e.jsxs(r,{children:[e.jsx(o,{fontSize:"xs",fontWeight:"bold",color:"gray.600",mb:1,children:"Placeholders:"}),Object.entries(t.notes.ph).map(([i,j])=>e.jsxs(r,{mb:1,children:[e.jsx(o,{fontSize:"xs",fontFamily:"mono",color:"blue.600",children:i}),e.jsxs(o,{fontSize:"xs",color:"gray.600",children:[j.desc," (e.g., ",j.sample,")"]})]},i))]})]})]})})]}):e.jsx(o,{fontSize:"xs",noOfLines:2,dir:l?.startsWith("he")||l?.startsWith("ar")?"rtl":"ltr",children:se(t.nsrc)})}),e.jsx(r,{as:"td",p:3,borderBottom:"1px",borderColor:"border.subtle",children:e.jsx(o,{fontSize:"xs",noOfLines:2,dir:h?.startsWith("he")||h?.startsWith("ar")?"rtl":"ltr",children:se(t.ntgt)})}),e.jsx(r,{as:"td",p:3,borderBottom:"1px",borderColor:"border.subtle",textAlign:"center",children:t.tnotes?e.jsxs(ue,{children:[e.jsx(xe,{asChild:!0,children:e.jsx(o,{fontSize:"xs",fontWeight:"bold",cursor:"help",children:t.tconf||""})}),e.jsx(ge,{children:e.jsxs(pe,{maxW:"400px",bg:"yellow.100",borderWidth:"1px",borderColor:"yellow.300",shadow:"lg",children:[e.jsx(be,{}),e.jsx(o,{fontSize:"sm",whiteSpace:"pre-wrap",color:"black",children:t.tnotes})]})})]}):e.jsx(o,{fontSize:"xs",children:t.tconf||""})}),e.jsx(r,{as:"td",p:3,borderBottom:"1px",borderColor:"border.subtle",textAlign:"center",children:e.jsx(o,{fontSize:"xs",children:t.q})}),e.jsx(r,{as:"td",p:3,borderBottom:"1px",borderColor:"border.subtle",children:e.jsx(o,{fontSize:"xs",children:t.translationProvider})}),e.jsx(r,{as:"td",p:3,borderBottom:"1px",borderColor:"border.subtle",textAlign:"center",children:t.active===1&&e.jsx(o,{fontSize:"lg",color:"green.500",children:"✓"})}),e.jsx(r,{as:"td",p:3,borderBottom:"1px",borderColor:"border.subtle",textAlign:"center",children:e.jsx(o,{fontSize:"xs",color:"fg.muted",children:t.ts?new Date(t.ts).toLocaleString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"}):""})})]},`${n}-${t.guid||t.nid||n}`))})]}),oe&&e.jsx(I,{justify:"center",p:4,children:e.jsx(Q,{size:"md"})}),!re&&y.length>0&&e.jsx(I,{justify:"center",p:4,children:e.jsx(o,{color:"fg.muted",fontSize:"sm",children:"No more results"})}),y.length===0&&!D&&e.jsx(I,{justify:"center",p:8,children:e.jsx(o,{color:"fg.muted",children:"No translation units found for the current filters"})})]})]})};export{st as default};
@@ -0,0 +1 @@
1
+ import{A as b,u as S,r as y,j as e,B as a,S as $,T as n,z,F as d,V as v,a as m,c as x}from"./vendor-BVgSJH5C.js";import{a as L,L as w,f as C}from"./index-543A5WcJ.js";const B=()=>{const f=b(),{data:l,isLoading:h,error:c}=S({queryKey:["tmToc"],queryFn:()=>C("/api/tm/toc")}),g=(t,r)=>{f(`/tm/${t}/${r}`)},u=y.useMemo(()=>{if(!l)return[];const t=[];for(const[r,o]of Object.entries(l))for(const[s,i]of Object.entries(o))t.push({sourceLang:r,targetLang:s,stores:i||[]});return t.sort((r,o)=>{const s=`${r.sourceLang} → ${r.targetLang}`,i=`${o.sourceLang} → ${o.targetLang}`;return s.localeCompare(i)})},[l]),p=t=>t?new Date(t).toLocaleString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"N/A",j=t=>t==null?"0":t.toLocaleString();return h?e.jsx(a,{display:"flex",justifyContent:"center",mt:10,children:e.jsx($,{size:"xl"})}):c?e.jsx(a,{mt:5,px:6,children:e.jsx(L,{error:c,fallbackMessage:"Failed to load TM data"})}):e.jsxs(a,{children:[e.jsx(w,{onSelect:g}),e.jsx(a,{py:6,px:6,children:u.length===0?e.jsx(a,{p:6,borderWidth:"1px",borderRadius:"md",bg:"white",textAlign:"center",children:e.jsx(n,{color:"fg.muted",children:"No translation memory data found."})}):e.jsx(z,{columns:{base:1,md:2,lg:3,xl:4},gap:4,children:u.map(({sourceLang:t,targetLang:r,stores:o})=>e.jsxs(d,{direction:"column",bg:"white",borderWidth:"1px",borderColor:"border.default",borderRadius:"lg",shadow:"sm",overflow:"hidden",h:"100%",children:[e.jsx(a,{bg:"blue.subtle",px:4,py:3,borderBottom:"1px",borderColor:"blue.muted",children:e.jsxs(n,{fontSize:"md",fontWeight:"semibold",color:"blue.700",children:[t," → ",r]})}),e.jsx(v,{align:"stretch",gap:2,p:4,flex:"1",children:o.length===0?e.jsx(n,{fontSize:"sm",color:"fg.muted",children:"No stores"}):o.map((s,i)=>e.jsxs(a,{children:[e.jsxs(d,{justify:"space-between",align:"baseline",children:[e.jsx(n,{fontSize:"sm",fontWeight:"medium",color:"fg.default",children:s.tmStore??"New/Unassigned"}),e.jsxs(n,{fontSize:"sm",color:"fg.muted",children:[j(s.jobCount)," jobs"]})]}),e.jsxs(n,{fontSize:"xs",color:"fg.muted",children:["Last job: ",p(s.lastUpdatedAt)]})]},i))}),e.jsxs(d,{px:4,py:3,borderTop:"1px",borderColor:"border.default",gap:2,justify:"flex-end",mt:"auto",children:[e.jsx(m,{as:x,to:`/tm/${t}/${r}`,size:"sm",colorPalette:"blue",variant:"outline",children:"Search"}),e.jsx(m,{as:x,to:`/tm/providers/${t}/${r}`,size:"sm",variant:"ghost",children:"Providers"})]})]},`${t}-${r}`))})})]})};export{B as default};
@@ -0,0 +1 @@
1
+ import{u as m,j as e,B as t,S as p,V as n,F as i,T as r,d,af as g}from"./vendor-BVgSJH5C.js";import{a as u,f as j}from"./index-543A5WcJ.js";const W=()=>{const{data:s,isLoading:x,error:c}=m({queryKey:["info"],queryFn:()=>j("/api/info")});return x?e.jsx(t,{display:"flex",justifyContent:"center",mt:20,children:e.jsx(p,{size:"xl"})}):c?e.jsx(t,{mt:10,px:6,children:e.jsx(u,{error:c})}):e.jsx(t,{py:8,px:6,children:e.jsxs(n,{gap:8,align:"stretch",maxW:"6xl",mx:"auto",children:[s&&e.jsx(t,{p:8,borderWidth:"1px",borderRadius:"xl",bg:"white",shadow:"lg",width:"100%",maxW:"500px",mx:"auto",position:"relative",background:"linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%)",borderColor:"border.default",children:e.jsxs(i,{direction:"column",gap:4,children:[e.jsxs(i,{align:"center",gap:4,children:[e.jsx("img",{src:"/logo.svg",alt:"L10n Monster",width:"60",height:"60"}),e.jsx(t,{children:e.jsx(r,{fontSize:"xl",fontWeight:"bold",color:"fg.default",lineHeight:"1.2",children:s.description})})]}),e.jsxs(n,{gap:3,align:"stretch",children:[e.jsxs(t,{children:[e.jsx(r,{fontSize:"xs",color:"fg.muted",textTransform:"uppercase",letterSpacing:"wide",mb:1,children:"Version"}),e.jsx(r,{fontSize:"lg",fontWeight:"semibold",color:"blue.600",children:s.version})]}),e.jsxs(t,{children:[e.jsx(r,{fontSize:"xs",color:"fg.muted",textTransform:"uppercase",letterSpacing:"wide",mb:1,children:"Project Directory"}),e.jsx(r,{fontSize:"xs",fontFamily:"mono",color:"fg.muted",wordBreak:"break-all",lineHeight:"1.3",children:s.baseDir})]})]}),e.jsx(t,{position:"absolute",top:"-10px",right:"-10px",width:"80px",height:"80px",bg:"blue.subtle",borderRadius:"full",opacity:"0.5",zIndex:"-1"})]})}),s&&e.jsxs(i,{direction:{base:"column",md:"row"},gap:6,align:"flex-start",children:[e.jsxs(t,{p:6,borderWidth:"1px",borderRadius:"lg",bg:"white",shadow:"sm",borderColor:"border.default",flex:{base:"none",md:"1"},children:[e.jsxs(r,{fontSize:"lg",fontWeight:"bold",mb:4,color:"fg.default",children:["Channels (",s.channels?.length||0,")"]}),e.jsxs(n,{gap:3,align:"stretch",children:[s.channels?.map((o,a)=>e.jsxs(t,{p:4,borderWidth:"1px",borderRadius:"md",borderColor:"border.subtle",bg:"bg.subtle",children:[e.jsxs(i,{justify:"space-between",align:"center",mb:3,children:[e.jsx(r,{fontSize:"sm",fontWeight:"semibold",color:"fg.default",children:o.id}),e.jsxs(d,{variant:"subtle",colorPalette:"purple",fontSize:"xs",children:[o.translationPolicies," ",o.translationPolicies===1?"policy":"policies"]})]}),e.jsxs(g,{gap:4,mb:3,flexWrap:"wrap",children:[e.jsxs(t,{children:[e.jsx(r,{fontSize:"xs",color:"fg.muted",mb:1,children:"Source"}),e.jsx(d,{variant:"subtle",colorPalette:"blue",fontSize:"xs",children:o.source})]}),e.jsxs(t,{children:[e.jsx(r,{fontSize:"xs",color:"fg.muted",mb:1,children:"Target"}),e.jsx(d,{variant:"subtle",colorPalette:"green",fontSize:"xs",children:o.target})]})]}),o.formatHandlers&&o.formatHandlers.length>0&&e.jsxs(t,{children:[e.jsx(r,{fontSize:"xs",color:"fg.muted",mb:2,children:"Format Handlers"}),e.jsx(n,{gap:2,align:"stretch",children:o.formatHandlers.map((l,h)=>e.jsxs(t,{p:2,bg:"white",borderRadius:"sm",borderWidth:"1px",children:[e.jsxs(i,{justify:"space-between",align:"center",mb:1,children:[e.jsxs(r,{fontSize:"xs",fontWeight:"medium",children:[l.id,l.resourceFilter&&` (${l.resourceFilter})`]}),l.defaultMessageFormat&&e.jsx(d,{variant:"outline",colorPalette:"orange",size:"sm",children:l.defaultMessageFormat})]}),l.messageFormats&&l.messageFormats.length>0&&e.jsx(g,{gap:1,flexWrap:"wrap",children:l.messageFormats.map((f,b)=>e.jsx(d,{variant:"subtle",colorPalette:"gray",size:"sm",children:f},b))})]},h))})]})]},a)),(!s.channels||s.channels.length===0)&&e.jsx(r,{fontSize:"sm",color:"fg.muted",children:"No channels configured"})]})]}),e.jsxs(n,{gap:6,align:"stretch",flex:{base:"none",md:"1"},children:[e.jsxs(t,{p:6,borderWidth:"1px",borderRadius:"lg",bg:"white",shadow:"sm",borderColor:"border.default",children:[e.jsxs(r,{fontSize:"lg",fontWeight:"bold",mb:4,color:"fg.default",children:["Snap Stores (",s.snapStores?.length||0,")"]}),e.jsxs(n,{gap:3,align:"stretch",children:[s.snapStores?.map((o,a)=>e.jsx(t,{p:3,borderWidth:"1px",borderRadius:"md",borderColor:"border.subtle",bg:"bg.subtle",children:e.jsxs(i,{justify:"space-between",align:"center",children:[e.jsx(r,{fontSize:"sm",fontWeight:"semibold",color:"fg.default",children:o.id}),e.jsx(d,{variant:"subtle",colorPalette:"orange",fontSize:"xs",children:o.type})]})},a)),(!s.snapStores||s.snapStores.length===0)&&e.jsx(r,{fontSize:"sm",color:"fg.muted",children:"No snap stores configured"})]})]}),e.jsxs(t,{p:6,borderWidth:"1px",borderRadius:"lg",bg:"white",shadow:"sm",borderColor:"border.default",children:[e.jsxs(r,{fontSize:"lg",fontWeight:"bold",mb:4,color:"fg.default",children:["TM Stores (",s.tmStores?.length||0,")"]}),e.jsxs(n,{gap:3,align:"stretch",children:[s.tmStores?.map((o,a)=>e.jsxs(t,{p:3,borderWidth:"1px",borderRadius:"md",borderColor:"border.subtle",bg:"bg.subtle",children:[e.jsxs(i,{justify:"space-between",align:"center",mb:2,children:[e.jsx(r,{fontSize:"sm",fontWeight:"semibold",color:"fg.default",children:o.id}),e.jsx(d,{variant:"subtle",colorPalette:"gray",fontSize:"xs",children:o.type})]}),e.jsxs(i,{gap:4,flexWrap:"wrap",fontSize:"xs",color:"fg.muted",children:[e.jsxs(r,{children:[e.jsx(r,{as:"span",fontWeight:"medium",children:"Access:"})," ",o.access]}),e.jsxs(r,{children:[e.jsx(r,{as:"span",fontWeight:"medium",children:"Partitioning:"})," ",o.partitioning]})]})]},a)),(!s.tmStores||s.tmStores.length===0)&&e.jsx(r,{fontSize:"sm",color:"fg.muted",children:"No TM stores configured"})]})]}),e.jsxs(t,{p:6,borderWidth:"1px",borderRadius:"lg",bg:"white",shadow:"sm",borderColor:"border.default",children:[e.jsxs(r,{fontSize:"lg",fontWeight:"bold",mb:4,color:"fg.default",children:["Providers (",s.providers?.length||0,")"]}),e.jsxs(n,{gap:3,align:"stretch",children:[s.providers?.map((o,a)=>e.jsx(t,{p:3,borderWidth:"1px",borderRadius:"md",borderColor:"border.subtle",bg:"bg.subtle",children:e.jsxs(i,{justify:"space-between",align:"center",children:[e.jsx(r,{fontSize:"sm",fontWeight:"semibold",color:"fg.default",children:o.id}),e.jsx(d,{variant:"subtle",colorPalette:"green",fontSize:"xs",children:o.type})]})},a)),(!s.providers||s.providers.length===0)&&e.jsx(r,{fontSize:"sm",color:"fg.muted",children:"No providers configured"})]})]})]})]})]})})};export{W as default};
@@ -0,0 +1 @@
1
+ import{j as e,R as ve,B as r,V as $,T as t,a as R,r as C,C as Te,b as Le,F as W,L as V,c as Y,d as D,e as me,f as be,g as _,h as L,i as pe,k as b,M as $e,l as Pe,P as Re,m as Me,n as Ee,o as re,u as G,G as he,p as ke,q as Ie,s as Fe,t as Oe,v as De,w as Se,x as ye,S as Z,I as Be,y as Ne,z as Je,A as Ue,D as fe,E as _e,H as qe,J as He,K as Qe,N as Ge,O as Ke,Q as Ve,U as Ye,W as se,X as oe,Y as ne,Z as le,_ as ie,$ as de,a0 as ae,a1 as ce,a2 as Ze,a3 as Xe}from"./vendor-BVgSJH5C.js";function dt({children:s}){return e.jsx(e.Fragment,{children:s})}class at extends ve.Component{constructor(o){super(o),this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(o){return{hasError:!0,error:o}}componentDidCatch(o,d){this.setState({errorInfo:d}),console.error("ErrorBoundary caught an error:",o,d)}handleReset=()=>{this.setState({hasError:!1,error:null,errorInfo:null})};render(){return this.state.hasError?e.jsx(r,{p:8,maxW:"800px",mx:"auto",mt:10,children:e.jsxs($,{gap:4,align:"stretch",children:[e.jsxs(r,{bg:"red.subtle",borderLeft:"4px",borderLeftColor:"red.500",p:6,borderRadius:"md",children:[e.jsx(t,{fontSize:"lg",fontWeight:"bold",color:"red.700",mb:2,children:"Something went wrong"}),e.jsx(t,{color:"red.600",mb:4,children:this.state.error?.message||"An unexpected error occurred"}),e.jsx(R,{colorPalette:"red",variant:"outline",size:"sm",onClick:this.handleReset,children:"Try Again"})]}),this.state.errorInfo&&e.jsxs(r,{bg:"gray.subtle",p:4,borderRadius:"md",overflow:"auto",maxH:"300px",children:[e.jsx(t,{fontSize:"sm",fontWeight:"bold",color:"fg.muted",mb:2,children:"Technical Details"}),e.jsx(t,{as:"pre",fontSize:"xs",fontFamily:"mono",whiteSpace:"pre-wrap",color:"fg.muted",children:this.state.errorInfo.componentStack})]})]})}):this.props.children}}async function K(s,o={}){try{const d=await fetch(s,o);if(!d.ok){let n;try{n=await d.json()}catch{}const c=n?.message||`HTTP error! status: ${d.status}`,x=new Error(c);throw x.status=d.status,x.response=d,x}return await d.json()}catch(d){if(console.error("API Fetch Error:",d),d.status||d.response)throw d;const n=new Error(d.message||"Network error");throw n.originalError=d,n}}const we=({error:s,fallbackMessage:o="An unexpected error occurred",title:d})=>{const n=s?.message?.includes("Failed to fetch")||s?.message?.includes("Network");return e.jsxs(r,{p:4,bg:"red.100",borderRadius:"md",borderWidth:"1px",borderColor:"red.300",children:[e.jsx(t,{fontWeight:"bold",color:"red.700",mb:2,children:d||(n?"Connection Error":"Error")}),e.jsx(t,{color:"red.600",children:n?"Unable to connect to the server. Please check that the L10n Monster server is running.":s?.message||o})]})},ct=({project:s,channelId:o,sourceLang:d,targetLang:n})=>{const[c,x]=C.useState(!1),[g,z]=C.useState(!1),{projectName:y,pairSummaryByStatus:a,translatedDetails:l,untranslatedDetails:h}=s,j={translated:a?.translated||0,"in flight":a?.["in flight"]||0,"low quality":a?.["low quality"]||0,untranslated:a?.untranslated||0},m=Object.values(j).reduce((u,v)=>u+v,0),f=m>0?Math.round(j.translated/m*100):0,S=m>0?Math.round(j["in flight"]/m*100):0,A=m>0?Math.round(j["low quality"]/m*100):0,w=m>0?Math.round(j.untranslated/m*100):0,I=o&&d&&n?`/status/${o}/${d}/${n}?prj=${encodeURIComponent(y)}`:null,M=[];l?.forEach((u,v)=>{const J=u.q===0?"in flight":u.q>=u.minQ?"translated":"low quality",k=J==="translated"?"green.solid":J==="in flight"?"blue.solid":"yellow.solid";M.push({key:`translated-${v}`,status:J,statusColor:k,group:null,q:u.q,minQ:u.minQ,res:u.res,seg:u.seg,words:u.words,chars:u.chars})});const P=[];Object.entries(h||{}).forEach(([u,v])=>{const J=u==="null"?"(no group)":u;v.forEach((k,X)=>{P.push({key:`untranslated-${u}-${X}`,group:J,minQ:k.minQ,res:k.res,seg:k.seg,words:k.words,chars:k.chars})})});const E=M.length>0,F=P.length>0,B=M.reduce((u,v)=>({seg:u.seg+(v.seg||0),words:u.words+(v.words||0),chars:u.chars+(v.chars||0)}),{seg:0,words:0,chars:0}),N=P.reduce((u,v)=>({seg:u.seg+(v.seg||0),words:u.words+(v.words||0),chars:u.chars+(v.chars||0)}),{seg:0,words:0,chars:0});return e.jsx(Te,{variant:"outline",bg:"yellow.subtle",children:e.jsxs(Le,{children:[e.jsxs(W,{align:"center",justify:"space-between",gap:2,mb:2,children:[I?e.jsx(V,{as:Y,to:I,fontSize:"sm",fontWeight:"semibold",color:"purple.600",_hover:{textDecoration:"underline"},children:y}):e.jsx(t,{fontSize:"sm",fontWeight:"semibold",children:y}),j.untranslated>0&&e.jsxs(D,{variant:"solid",colorPalette:"red",size:"sm",children:[j.untranslated.toLocaleString()," untranslated"]})]}),e.jsx(r,{mb:3,children:e.jsxs(W,{align:"center",gap:2,mb:1,children:[e.jsxs(r,{flex:"1",bg:"bg.muted",rounded:"full",height:"10px",position:"relative",overflow:"hidden",children:[e.jsx(r,{position:"absolute",top:"0",left:"0",height:"100%",width:`${f}%`,bg:"green.solid",transition:"width 0.3s ease"}),e.jsx(r,{position:"absolute",top:"0",left:`${f}%`,height:"100%",width:`${S}%`,bg:"blue.solid",transition:"width 0.3s ease"}),e.jsx(r,{position:"absolute",top:"0",left:`${f+S}%`,height:"100%",width:`${A}%`,bg:"yellow.solid",transition:"width 0.3s ease"}),e.jsx(r,{position:"absolute",top:"0",left:`${f+S+A}%`,height:"100%",width:`${w}%`,bg:"red.solid",transition:"width 0.3s ease"})]}),e.jsxs(t,{fontSize:"sm",color:"fg.muted",minW:"45px",children:[f,"%"]})]})}),e.jsx(r,{overflow:"auto",children:e.jsxs(me,{size:"sm",variant:"line",children:[e.jsx(be,{children:e.jsxs(_,{bg:"yellow.100",children:[e.jsx(L,{}),e.jsx(L,{textAlign:"right",children:"Min Q"}),e.jsx(L,{textAlign:"right",children:"Res"}),e.jsx(L,{textAlign:"right",children:"Strings"}),e.jsx(L,{textAlign:"right",children:"Words"}),e.jsx(L,{textAlign:"right",children:"Chars"})]})}),e.jsxs(pe,{children:[e.jsxs(_,{bg:"green.subtle",cursor:E?"pointer":"default",onClick:()=>E&&x(!c),_hover:E?{bg:"green.100"}:{},children:[e.jsx(b,{children:e.jsxs(W,{align:"center",gap:2,children:[E&&e.jsx(t,{fontSize:"xs",color:"green.700",children:c?"▼":"▶"}),e.jsx(t,{fontSize:"xs",fontWeight:"semibold",color:"green.700",children:"Translated"})]})}),e.jsx(b,{}),e.jsx(b,{}),e.jsx(b,{textAlign:"right",children:e.jsx(t,{fontSize:"xs",fontWeight:"medium",color:"green.700",children:B.seg.toLocaleString()})}),e.jsx(b,{textAlign:"right",children:e.jsx(t,{fontSize:"xs",fontWeight:"medium",color:"green.700",children:B.words.toLocaleString()})}),e.jsx(b,{textAlign:"right",children:e.jsx(t,{fontSize:"xs",fontWeight:"medium",color:"green.700",children:B.chars.toLocaleString()})})]}),c&&M.map(u=>e.jsxs(_,{bg:"green.50",children:[e.jsx(b,{pl:8,children:e.jsxs(t,{fontSize:"xs",color:"fg.muted",children:["Quality ",u.q]})}),e.jsx(b,{textAlign:"right",children:e.jsx(t,{fontSize:"xs",color:"fg.muted",children:u.minQ})}),e.jsx(b,{textAlign:"right",children:e.jsx(t,{fontSize:"xs",color:"fg.muted",children:u.res?.toLocaleString()||"—"})}),e.jsx(b,{textAlign:"right",children:e.jsx(t,{fontSize:"xs",color:"fg.muted",children:u.seg?.toLocaleString()})}),e.jsx(b,{textAlign:"right",children:e.jsx(t,{fontSize:"xs",color:"fg.muted",children:u.words?.toLocaleString()})}),e.jsx(b,{textAlign:"right",children:e.jsx(t,{fontSize:"xs",color:"fg.muted",children:u.chars?.toLocaleString()})})]},u.key)),N.seg>0&&e.jsxs(_,{bg:"red.subtle",cursor:F?"pointer":"default",onClick:()=>F&&z(!g),_hover:F?{bg:"red.100"}:{},children:[e.jsx(b,{children:e.jsxs(W,{align:"center",gap:2,children:[F&&e.jsx(t,{fontSize:"xs",color:"red.700",children:g?"▼":"▶"}),e.jsx(t,{fontSize:"xs",fontWeight:"semibold",color:"red.700",children:"Untranslated"})]})}),e.jsx(b,{}),e.jsx(b,{}),e.jsx(b,{textAlign:"right",children:e.jsx(t,{fontSize:"xs",fontWeight:"medium",color:"red.700",children:N.seg.toLocaleString()})}),e.jsx(b,{textAlign:"right",children:e.jsx(t,{fontSize:"xs",fontWeight:"medium",color:"red.700",children:N.words.toLocaleString()})}),e.jsx(b,{textAlign:"right",children:e.jsx(t,{fontSize:"xs",fontWeight:"medium",color:"red.700",children:N.chars.toLocaleString()})})]}),g&&P.map(u=>e.jsxs(_,{bg:"red.50",children:[e.jsx(b,{pl:8,children:e.jsx(t,{fontSize:"xs",color:"fg.muted",children:u.group})}),e.jsx(b,{textAlign:"right",children:e.jsx(t,{fontSize:"xs",color:"fg.muted",children:u.minQ})}),e.jsx(b,{textAlign:"right",children:e.jsx(t,{fontSize:"xs",color:"fg.muted",children:u.res?.toLocaleString()||"—"})}),e.jsx(b,{textAlign:"right",children:e.jsx(t,{fontSize:"xs",color:"fg.muted",children:u.seg?.toLocaleString()})}),e.jsx(b,{textAlign:"right",children:e.jsx(t,{fontSize:"xs",color:"fg.muted",children:u.words?.toLocaleString()})}),e.jsx(b,{textAlign:"right",children:e.jsx(t,{fontSize:"xs",color:"fg.muted",children:u.chars?.toLocaleString()})})]},u.key))]})]})})]})})},ht=({value:s=[],onChange:o,options:d=[],placeholder:n,disabled:c,sortNumeric:x=!1})=>{const g=s.length,z=g===0?n:g===1?s[0]:`${g} selected`,y=m=>{const f=String(m);s.includes(f)?o(s.filter(S=>S!==f)):o([...s,f])},a=m=>{m.stopPropagation(),o([])},l=m=>{m.stopPropagation(),o(d.map(f=>String(f)))},h=g===d.length,j=g>0&&g<d.length;return!d||d.length===0?e.jsx(r,{fontSize:"xs",px:2,py:1,bg:"gray.subtle",borderRadius:"sm",color:"fg.muted",children:"No options"}):e.jsxs($e,{closeOnSelect:!1,children:[e.jsx(Pe,{asChild:!0,children:e.jsx(R,{size:"xs",variant:"outline",bg:"yellow.subtle",borderColor:"border.default",fontWeight:"normal",w:"100%",justifyContent:"space-between",_hover:{bg:"yellow.muted"},disabled:c,children:e.jsxs(W,{align:"center",justify:"space-between",w:"100%",gap:1,children:[e.jsx(t,{fontSize:"xs",color:g>0?"fg.default":"fg.muted",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",children:z}),e.jsx(t,{fontSize:"xs",color:"fg.muted",children:"▼"})]})})}),e.jsx(Re,{children:e.jsx(Me,{children:e.jsxs(Ee,{minW:"150px",maxH:"250px",overflow:"auto",bg:"white",borderWidth:"1px",borderColor:"border.default",borderRadius:"md",shadow:"lg",zIndex:1e3,children:[d.length>1&&e.jsxs(e.Fragment,{children:[e.jsx(re,{value:"__select_all__",onClick:h?a:l,fontSize:"xs",children:e.jsxs(W,{align:"center",gap:2,children:[e.jsxs(r,{w:"14px",h:"14px",borderWidth:"1px",borderColor:g>0?"blue.500":"gray.300",borderRadius:"sm",bg:g>0?"blue.500":"white",display:"flex",alignItems:"center",justifyContent:"center",children:[h&&e.jsx(t,{color:"white",fontSize:"10px",lineHeight:"1",children:"✓"}),j&&e.jsx(t,{color:"white",fontSize:"10px",lineHeight:"1",children:"−"})]}),e.jsx(t,{children:"Select All"})]})}),g>0&&e.jsxs(re,{value:"__clear_all__",onClick:a,fontSize:"xs",color:"red.500",children:["Clear All (",g,")"]}),e.jsx(r,{h:"1px",bg:"gray.200",my:1})]}),d.slice().sort((m,f)=>x?Number(m)-Number(f):String(m).localeCompare(String(f))).map(m=>{const f=String(m),S=s.includes(f);return e.jsx(re,{value:f,onClick:()=>y(f),fontSize:"xs",children:e.jsxs(W,{align:"center",gap:2,children:[e.jsx(r,{w:"14px",h:"14px",borderWidth:"1px",borderColor:S?"blue.500":"gray.300",borderRadius:"sm",bg:S?"blue.500":"white",display:"flex",alignItems:"center",justifyContent:"center",children:S&&e.jsx(t,{color:"white",fontSize:"10px",lineHeight:"1",children:"✓"})}),e.jsx(t,{children:f})]})},f)})]})})})]})},xt=({item:s,channelId:o})=>{const[d,n]=C.useState(!1),c=s.prj??"default",{data:x,isLoading:g}=G({queryKey:["status",o],queryFn:()=>K(`/api/status/${o}`),enabled:d}),z=C.useMemo(()=>{if(!x)return null;const l=[];return Object.entries(x).forEach(([h,j])=>{Object.entries(j).forEach(([m,f])=>{if(f[c]){const A=f[c].pairSummaryByStatus||{},w=Object.values(A).reduce((F,B)=>F+B,0),I=A.translated||0,M=A["in flight"]||0,P=A["low quality"]||0,E=A.untranslated||0;l.push({sourceLang:h,targetLang:m,totalSegs:w,translated:I,inFlight:M,lowQuality:P,untranslated:E,pctTranslated:w>0?Math.round(I/w*100):0,pctInFlight:w>0?Math.round(M/w*100):0,pctLowQuality:w>0?Math.round(P/w*100):0,pctUntranslated:w>0?Math.round(E/w*100):0})}})}),l},[x,c]),y=l=>{const h=new Date,j=new Date(l),m=h-j,f=Math.floor(m/1e3),S=new Intl.RelativeTimeFormat("en",{numeric:"auto",style:"short"});return f<60?S.format(-f,"second"):f<3600?S.format(-Math.floor(f/60),"minute"):f<86400?S.format(-Math.floor(f/3600),"hour"):f<2592e3?S.format(-Math.floor(f/86400),"day"):f<31536e3?S.format(-Math.floor(f/2592e3),"month"):S.format(-Math.floor(f/31536e3),"year")},a=l=>new Date(l).toLocaleString("en-US",{weekday:"long",year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:"short"});return e.jsxs(r,{p:3,borderWidth:"1px",borderRadius:"md",borderColor:"border.default",bg:"yellow.subtle",w:"100%",children:[e.jsxs(he,{templateColumns:"30px 2fr 80px 3fr 80px 80px 100px",gap:4,alignItems:"center",children:[e.jsx(r,{cursor:"pointer",onClick:()=>n(!d),_hover:{bg:"yellow.100"},borderRadius:"sm",textAlign:"center",children:e.jsx(t,{fontSize:"md",color:"purple.600",children:d?"▼":"▶"})}),e.jsxs(r,{children:[e.jsx(t,{fontSize:"xs",color:"fg.muted",mb:1,children:"Project"}),e.jsx(V,{as:Y,to:`/sources/${o}/${c}`,fontSize:"sm",fontWeight:"semibold",color:"blue.600",_hover:{textDecoration:"underline"},children:c})]}),e.jsxs(r,{children:[e.jsx(t,{fontSize:"xs",color:"fg.muted",mb:1,children:"Source"}),e.jsx(D,{colorPalette:"blue",size:"sm",children:s.sourceLang})]}),e.jsxs(r,{children:[e.jsxs(t,{fontSize:"xs",color:"fg.muted",mb:1,children:["Targets (",s.targetLangs.length,")"]}),e.jsx(W,{wrap:"wrap",gap:1,children:s.targetLangs.map(l=>e.jsx(D,{colorPalette:"green",size:"sm",children:l},l))})]}),e.jsxs(r,{textAlign:"center",children:[e.jsx(t,{fontSize:"xs",color:"fg.muted",mb:1,children:"Resources"}),e.jsx(t,{fontSize:"sm",fontWeight:"bold",color:"orange.600",children:s.resCount.toLocaleString()})]}),e.jsxs(r,{textAlign:"center",children:[e.jsx(t,{fontSize:"xs",color:"fg.muted",mb:1,children:"Segments"}),e.jsx(t,{fontSize:"sm",fontWeight:"bold",color:"purple.600",children:s.segmentCount.toLocaleString()})]}),e.jsxs(r,{textAlign:"center",children:[e.jsx(t,{fontSize:"xs",color:"fg.muted",mb:1,children:"Modified"}),e.jsxs(ke,{children:[e.jsx(Ie,{asChild:!0,children:e.jsx(t,{fontSize:"xs",color:"fg.muted",cursor:"help",children:y(s.lastModified)})}),e.jsx(Fe,{children:e.jsxs(Oe,{children:[e.jsx(De,{}),e.jsx(t,{fontSize:"sm",children:a(s.lastModified)})]})})]})]})]}),e.jsx(Se,{open:d,children:e.jsx(ye,{children:e.jsx(r,{mt:3,pt:3,borderTop:"1px",borderColor:"yellow.300",children:g?e.jsxs(W,{justify:"center",py:4,children:[e.jsx(Z,{size:"sm"}),e.jsx(t,{ml:2,fontSize:"sm",color:"fg.muted",children:"Loading translation status..."})]}):z&&z.length>0?e.jsx(r,{overflow:"auto",children:e.jsxs(me,{size:"sm",variant:"line",children:[e.jsx(be,{children:e.jsxs(_,{bg:"purple.50",children:[e.jsx(L,{children:"Language Pair"}),e.jsx(L,{textAlign:"center",children:"Progress"}),e.jsx(L,{textAlign:"right",children:"Translated"}),e.jsx(L,{textAlign:"right",children:"In Flight"}),e.jsx(L,{textAlign:"right",children:"Low Q"}),e.jsx(L,{textAlign:"right",children:"Untranslated"}),e.jsx(L,{textAlign:"right",children:"Total"})]})}),e.jsx(pe,{children:z.map(l=>e.jsxs(_,{bg:"white",children:[e.jsx(b,{children:e.jsxs(V,{as:Y,to:`/status/${o}/${l.sourceLang}/${l.targetLang}?prj=${encodeURIComponent(c)}`,fontSize:"xs",fontWeight:"medium",color:"purple.600",_hover:{textDecoration:"underline"},children:[l.sourceLang," → ",l.targetLang]})}),e.jsx(b,{children:e.jsxs(W,{align:"center",gap:2,children:[e.jsxs(r,{flex:"1",minW:"80px",bg:"bg.muted",rounded:"full",height:"8px",position:"relative",overflow:"hidden",children:[e.jsx(r,{position:"absolute",top:"0",left:"0",height:"100%",width:`${l.pctTranslated}%`,bg:"green.solid"}),e.jsx(r,{position:"absolute",top:"0",left:`${l.pctTranslated}%`,height:"100%",width:`${l.pctInFlight}%`,bg:"blue.solid"}),e.jsx(r,{position:"absolute",top:"0",left:`${l.pctTranslated+l.pctInFlight}%`,height:"100%",width:`${l.pctLowQuality}%`,bg:"yellow.solid"}),e.jsx(r,{position:"absolute",top:"0",left:`${l.pctTranslated+l.pctInFlight+l.pctLowQuality}%`,height:"100%",width:`${l.pctUntranslated}%`,bg:"red.solid"})]}),e.jsxs(t,{fontSize:"xs",color:"fg.muted",minW:"35px",textAlign:"right",children:[l.pctTranslated,"%"]})]})}),e.jsx(b,{textAlign:"right",children:e.jsx(t,{fontSize:"xs",color:"green.600",fontWeight:"medium",children:l.translated.toLocaleString()})}),e.jsx(b,{textAlign:"right",children:e.jsx(t,{fontSize:"xs",color:l.inFlight>0?"blue.600":"fg.muted",children:l.inFlight.toLocaleString()})}),e.jsx(b,{textAlign:"right",children:e.jsx(t,{fontSize:"xs",color:l.lowQuality>0?"yellow.600":"fg.muted",children:l.lowQuality.toLocaleString()})}),e.jsx(b,{textAlign:"right",children:e.jsx(t,{fontSize:"xs",color:l.untranslated>0?"red.600":"fg.muted",fontWeight:l.untranslated>0?"medium":"normal",children:l.untranslated.toLocaleString()})}),e.jsx(b,{textAlign:"right",children:e.jsx(t,{fontSize:"xs",color:"fg.muted",children:l.totalSegs.toLocaleString()})})]},`${l.sourceLang}-${l.targetLang}`))})]})}):e.jsx(t,{fontSize:"sm",color:"fg.muted",textAlign:"center",py:2,children:"No translation status available"})})})})]})},et=(s,o)=>s?{snapText:`Snapped on ${new Date(s).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}`,importText:o?{text:"Imported from snap store ",store:o}:null}:{snapText:"Never snapped",importText:null},gt=({channelId:s,project:o,resource:d,onBackClick:n,backLabel:c="Back",snapTimestamp:x,snapStore:g,showSnapInfo:z=!1,extraContent:y=null})=>e.jsxs(r,{p:6,borderWidth:"2px",borderRadius:"lg",bg:"white",borderColor:"green.200",mb:6,children:[e.jsxs(r,{display:"flex",alignItems:"center",gap:3,flexWrap:"wrap",pb:4,borderBottom:"2px",borderColor:"green.100",children:[n&&e.jsx(Be,{"aria-label":c,onClick:n,variant:"ghost",size:"sm",children:"←"}),e.jsxs(r,{children:[e.jsx(t,{fontSize:"sm",color:"fg.muted",mb:1,children:"Channel"}),e.jsx(t,{fontSize:"lg",fontWeight:"bold",color:"green.600",children:s})]}),o&&e.jsxs(r,{children:[e.jsx(t,{fontSize:"sm",color:"fg.muted",mb:1,children:"Project"}),e.jsx(t,{fontSize:"lg",fontWeight:"semibold",color:"blue.600",children:o})]}),d&&e.jsxs(r,{flex:"1",children:[e.jsx(t,{fontSize:"sm",color:"fg.muted",mb:1,children:"Resource"}),e.jsx(t,{fontSize:"lg",fontWeight:"semibold",color:"purple.600",wordBreak:"break-all",children:d})]}),z&&!o&&!d&&e.jsx(r,{flex:"1",textAlign:"right",children:(()=>{const{snapText:a,importText:l}=et(x,g);return e.jsxs(e.Fragment,{children:[e.jsx(t,{fontSize:"sm",color:"fg.muted",children:a}),l&&e.jsxs(t,{fontSize:"sm",color:"fg.muted",children:[l.text,e.jsx(t,{as:"span",fontWeight:"bold",color:"blue.600",children:l.store})]})]})})()})]}),y&&e.jsx(r,{mt:6,children:y})]});function je(s){if(!s)return null;const o=/(https:\/\/[^\s]+)/g;return s.split(o).map((n,c)=>n.match(o)?e.jsx(t,{as:"a",href:n,target:"_blank",rel:"noopener noreferrer",color:"blue.600",textDecoration:"underline",_hover:{color:"blue.800"},children:n},`link-${c}`):n)}const ze="tmCart",tt=()=>{const s=sessionStorage.getItem(ze);return s?JSON.parse(s):{}},rt=s=>{sessionStorage.setItem(ze,JSON.stringify(s)),window.dispatchEvent(new Event("cartUpdated"))},st=(s,o,d,n=null)=>({guid:s.guid,channel:n||s.channel,sourceLang:o,targetLang:d,nsrc:s.nsrc,ntgt:s.ntgt}),Ce=(s,o,d,n=null)=>{const c=tt(),x=`${s}|${o}`;c[x]||(c[x]={sourceLang:s,targetLang:o,tus:[]});const g=d.map(z=>st(z,s,o,n));c[x].tus.push(...g),rt(c)},ut=Ce,ft=(s,o,d,n)=>{Ce(s,o,n,d)},ot=()=>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"})}),nt=()=>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"})}),jt=({onSelect:s,currentPair:o,triggerContent:d,rightContent:n,defaultOpen:c=!1})=>{const[x,g]=C.useState(c),{data:z=[]}=G({queryKey:["tmStats"],queryFn:()=>K("/api/tm/stats")}),y=C.useMemo(()=>z.map(([j,m])=>({value:`${j}|${m}`,label:`${j} → ${m}`,sourceLang:j,targetLang:m})).sort((j,m)=>j.label.localeCompare(m.label)),[z]),a=h=>{if(h&&s){const[j,m]=h.split("|");s(j,m),g(!1)}},l=h=>o&&h.sourceLang===o.sourceLang&&h.targetLang===o.targetLang;return y.length===0?null:e.jsx(r,{bg:"blue.subtle",borderBottom:"1px",borderColor:"blue.muted",shadow:"md",borderLeft:"4px",borderLeftColor:"blue.500",children:e.jsxs(Se,{open:x,onOpenChange:h=>g(h.open),children:[e.jsx(r,{px:6,py:4,children:e.jsxs(W,{align:"center",justify:"space-between",children:[e.jsxs(Ne,{as:R,variant:"ghost",size:"md",justifyContent:"flex-start",_hover:{bg:"blue.muted"},bg:"transparent",gap:2,children:[d||e.jsxs(W,{align:"center",gap:3,children:[e.jsx(t,{fontSize:"md",fontWeight:"semibold",color:"blue.700",children:"Language Pairs"}),e.jsx(D,{colorPalette:"blue",variant:"subtle",size:"sm",children:y.length})]}),e.jsx(r,{color:"blue.600",children:x?e.jsx(nt,{}):e.jsx(ot,{})})]}),n&&e.jsx(W,{align:"center",gap:3,children:n})]})}),e.jsx(ye,{children:e.jsx(r,{px:6,pb:4,children:e.jsx(Je,{columns:{base:1,sm:2,md:3,lg:4,xl:5},gap:2,children:y.map(h=>e.jsx(R,{variant:"outline",size:"sm",onClick:()=>a(h.value),_hover:{bg:"blue.100",borderColor:"blue.400"},justifyContent:"flex-start",bg:l(h)?"blue.100":"white",borderColor:l(h)?"blue.400":"blue.200",borderWidth:l(h)?"2px":"1px",children:e.jsx(t,{fontSize:"xs",color:"blue.700",children:h.label})},h.value))})})})]})})},lt=({sourceLang:s,targetLang:o,providers:d,headerAction:n})=>{Ue();const c=x=>{switch(x){case"done":return"green";case"pending":return"yellow";case"error":return"red";default:return"gray"}};return e.jsx(r,{p:6,borderWidth:"1px",borderRadius:"lg",bg:"white",shadow:"sm",w:"100%",children:e.jsxs($,{gap:4,align:"stretch",children:[e.jsxs(W,{justify:"space-between",align:"center",children:[e.jsxs(t,{fontSize:"lg",fontWeight:"bold",children:["Provider Breakdown: ",s," → ",o]}),n]}),e.jsx($,{gap:3,align:"stretch",children:d.map((x,g)=>e.jsx(r,{p:3,borderWidth:"1px",borderRadius:"md",borderColor:"border.default",bg:"yellow.subtle",children:e.jsxs(he,{templateColumns:{base:"minmax(0, 2fr) 1fr 1fr 1fr 1fr",md:"minmax(0, 3fr) 1fr 1fr 1fr 1fr"},gap:{base:1,md:2},alignItems:"center",overflow:"hidden",minWidth:"0",children:[e.jsxs(r,{minWidth:"0",overflow:"hidden",children:[e.jsx(t,{fontSize:"xs",color:"fg.muted",mb:1,children:"Provider"}),e.jsx(V,{as:Y,to:`/tm/${s}/${o}?translationProvider=${encodeURIComponent(x.translationProvider)}`,fontSize:"sm",fontWeight:"semibold",color:"blue.600",_hover:{textDecoration:"underline",color:"blue.700"},noOfLines:1,title:x.translationProvider,children:x.translationProvider})]}),e.jsxs(r,{textAlign:"center",children:[e.jsx(t,{fontSize:"xs",color:"fg.muted",mb:1,children:"Status"}),e.jsx(D,{colorPalette:c(x.status),size:"sm",children:x.status})]}),e.jsxs(r,{textAlign:"center",children:[e.jsx(t,{fontSize:"xs",color:"fg.muted",mb:1,children:"TUs"}),e.jsx(t,{fontSize:"sm",fontWeight:"bold",color:"purple.600",children:x.tuCount.toLocaleString()})]}),e.jsxs(r,{textAlign:"center",children:[e.jsx(t,{fontSize:"xs",color:"fg.muted",mb:1,children:"Unique"}),e.jsx(t,{fontSize:"sm",fontWeight:"bold",color:"orange.600",children:x.distinctGuids.toLocaleString()})]}),e.jsxs(r,{textAlign:"center",children:[e.jsx(t,{fontSize:"xs",color:"fg.muted",mb:1,children:"Jobs"}),e.jsx(t,{fontSize:"sm",fontWeight:"bold",color:"teal.600",children:x.jobCount.toLocaleString()})]})]})},g))})]})})},mt=({sourceLang:s,targetLang:o,headerAction:d})=>{const[n,c]=C.useState(!1),x=C.useRef(null);C.useEffect(()=>{const a=new IntersectionObserver(l=>{l.forEach(h=>{h.isIntersecting&&(c(!0),a.disconnect())})},{rootMargin:"200px",threshold:0});return x.current&&a.observe(x.current),()=>a.disconnect()},[]);const{data:g,isLoading:z,error:y}=G({queryKey:["tmStats",s,o],queryFn:()=>K(`/api/tm/stats/${s}/${o}`),enabled:n});return e.jsx(r,{ref:x,minH:"200px",children:y?e.jsx(we,{error:y,title:`Error loading ${s} → ${o}`}):z?e.jsx(r,{display:"flex",justifyContent:"center",alignItems:"center",minH:"200px",p:6,borderWidth:"1px",borderRadius:"lg",bg:"white",shadow:"sm",children:e.jsx(Z,{size:"md"})}):g?e.jsx(lt,{sourceLang:s,targetLang:o,providers:g,headerAction:d}):n?e.jsx(r,{display:"flex",justifyContent:"center",alignItems:"center",minH:"200px",p:6,borderWidth:"1px",borderRadius:"lg",bg:"white",shadow:"sm",children:e.jsx(t,{color:"fg.muted",children:"No data available"})}):e.jsx(r,{display:"flex",justifyContent:"center",alignItems:"center",minH:"200px",p:6,borderWidth:"1px",borderRadius:"lg",bg:"gray.50",shadow:"sm",children:e.jsx(t,{color:"fg.muted",fontSize:"sm",children:"Scroll down to load..."})})})},bt=({providers:s,selectedProvider:o,onProviderSelect:d})=>{const n=Array.isArray(s)?s:[];return e.jsxs(r,{width:"25%",flexShrink:0,borderRight:"1px",borderColor:"border.default",p:4,bg:"yellow.subtle",minH:"70vh",children:[e.jsx(t,{fontSize:"lg",fontWeight:"bold",mb:4,children:"Providers"}),e.jsxs($,{gap:2,align:"stretch",children:[n.map(c=>{const x=typeof c=="object"&&c?.id?c.id:c,g=typeof c=="object"&&c?.id?c.id:c,z=typeof c=="object"&&c?.type?c.type:null;return e.jsxs(r,{p:3,borderRadius:"md",cursor:"pointer",bg:o===g?"blue.subtle":"white",borderWidth:"1px",borderColor:o===g?"blue.600":"border.default",_hover:{bg:o===g?"blue.subtle":"gray.subtle"},onClick:()=>d(g),children:[e.jsx(t,{fontSize:"sm",fontWeight:"medium",noOfLines:2,children:x}),z&&e.jsx(t,{fontSize:"xs",color:"fg.muted",mt:1,children:z})]},g)}),n.length===0&&e.jsx(t,{color:"fg.muted",fontSize:"sm",textAlign:"center",mt:4,children:"No providers found"})]})]})},pt=({providerId:s})=>{const{data:o,isLoading:d,error:n}=G({queryKey:["provider",s],queryFn:()=>K(`/api/providers/${s}`),enabled:!!s});if(!s)return e.jsx(r,{width:"75%",p:6,textAlign:"center",children:e.jsx(t,{color:"fg.muted",children:"Select a provider to view details"})});if(d)return e.jsx(r,{width:"75%",p:6,display:"flex",justifyContent:"center",alignItems:"center",children:e.jsx(Z,{size:"lg"})});if(n)return e.jsx(r,{width:"75%",p:6,children:e.jsx(we,{error:n,fallbackMessage:"Failed to fetch provider details"})});if(!o)return e.jsx(r,{width:"75%",p:6,textAlign:"center",children:e.jsx(t,{color:"fg.muted",children:"Provider not found"})});const{info:c,properties:x}=o,g=a=>{if(!a)return a;const l={31:"#ef4444",32:"#22c55e",33:"#eab308",34:"#3b82f6",35:"#a855f7",36:"#06b6d4",39:"inherit"},h=[];let j=0,m="inherit";const f=/\u001B\[([0-9;]*)m/g;let S;for(;(S=f.exec(a))!==null;){if(S.index>j){const w=a.slice(j,S.index);h.push(e.jsx("span",{style:{color:m},children:w},`${j}-text`))}const A=S[1];l[A]&&(m=l[A]),j=S.index+S[0].length}if(j<a.length){const A=a.slice(j);h.push(e.jsx("span",{style:{color:m},children:A},`${j}-text`))}return h.length>0?h:a},z=a=>Array.isArray(a)?a.map((l,h)=>e.jsxs(r,{display:"flex",alignItems:"flex-start",gap:2,children:[e.jsx(t,{fontSize:"sm",color:"fg.muted",mt:"1px",children:"•"}),e.jsx(t,{fontSize:"sm",flex:"1",children:g(l)})]},h)):e.jsx(t,{fontSize:"sm",children:g(a)}),y=a=>typeof a=="object"&&a!==null?!Array.isArray(a)&&Object.values(a).every(h=>typeof h=="string")&&Object.keys(a).length>0?e.jsx(r,{borderWidth:"1px",borderRadius:"md",overflow:"hidden",bg:"white",shadow:"sm",children:e.jsxs(r,{as:"table",w:"100%",fontSize:"sm",children:[e.jsx(r,{as:"thead",bg:"blue.subtle",borderBottom:"1px",borderColor:"border.default",children:e.jsxs(r,{as:"tr",children:[e.jsx(r,{as:"th",p:2,textAlign:"left",fontWeight:"semibold",color:"blue.600",children:"Key"}),e.jsx(r,{as:"th",p:2,textAlign:"left",fontWeight:"semibold",color:"blue.600",children:"Value"})]})}),e.jsx(r,{as:"tbody",children:Object.entries(a).sort(([h],[j])=>h.localeCompare(j)).map(([h,j])=>e.jsxs(r,{as:"tr",_hover:{bg:"gray.subtle"},children:[e.jsx(r,{as:"td",p:2,borderBottom:"1px",borderColor:"border.subtle",fontFamily:"mono",fontSize:"xs",children:h}),e.jsx(r,{as:"td",p:2,borderBottom:"1px",borderColor:"border.subtle",fontSize:"xs",children:j})]},h))})]})}):e.jsx(r,{as:"pre",fontSize:"xs",bg:"bg.muted",p:2,borderRadius:"md",overflow:"auto",maxH:"200px",children:JSON.stringify(a,null,2)}):e.jsx(t,{fontSize:"sm",children:String(a)});return e.jsx(r,{width:"75%",p:6,overflow:"auto",children:e.jsxs($,{gap:6,align:"stretch",children:[e.jsx(r,{children:e.jsx(t,{fontSize:"2xl",fontWeight:"bold",mb:2,children:s})}),e.jsxs(r,{p:4,borderWidth:"1px",borderRadius:"lg",bg:"white",shadow:"sm",children:[e.jsx(t,{fontSize:"lg",fontWeight:"semibold",mb:4,children:"Properties"}),Object.keys(x).length===0?e.jsx(t,{color:"fg.muted",fontSize:"sm",children:"No properties available"}):e.jsx($,{gap:4,align:"stretch",children:Object.entries(x).sort(([a],[l])=>a.localeCompare(l)).map(([a,l])=>e.jsxs(r,{children:[e.jsxs(t,{fontSize:"sm",fontWeight:"bold",color:"blue.600",mb:2,children:[a,":"]}),e.jsx(r,{pl:4,children:y(l)})]},a))})]}),e.jsxs(r,{p:4,borderWidth:"1px",borderRadius:"lg",bg:"white",shadow:"sm",children:[e.jsx(t,{fontSize:"lg",fontWeight:"semibold",mb:4,children:"Information"}),e.jsxs(he,{templateColumns:"auto 1fr",gap:3,alignItems:"start",children:[e.jsx(t,{fontSize:"sm",fontWeight:"bold",color:"blue.600",children:"Type:"}),e.jsx(D,{colorPalette:"blue",size:"sm",children:c.type}),e.jsx(t,{fontSize:"sm",fontWeight:"bold",color:"blue.600",children:"Cost per Word:"}),e.jsx(t,{fontSize:"sm",children:c.costPerWord}),e.jsx(t,{fontSize:"sm",fontWeight:"bold",color:"blue.600",children:"Cost per MChar:"}),e.jsx(t,{fontSize:"sm",children:c.costPerMChar}),c.description&&e.jsxs(e.Fragment,{children:[e.jsx(t,{fontSize:"sm",fontWeight:"bold",color:"blue.600",children:"Description:"}),e.jsx(r,{children:z(c.description)})]})]})]})]})})},St=({langPairKey:s,tus:o,onRemoveTU:d})=>{const[n,c]=C.useState(""),[x,g]=C.useState(!1),[z,y]=C.useState(!1),[a,l]=C.useState(null),[h,j]=C.useState(""),[m,f]=C.useState(""),[S,A]=C.useState(""),[w,I]=C.useState(null),[M,P]=C.useState(!1),{data:E={},isLoading:F}=G({queryKey:["info"],queryFn:()=>K("/api/info")}),B=E.providers||[],N=fe({mutationFn:async({sourceLang:i,targetLang:p,guids:T,provider:O})=>{const U=await fetch("/api/dispatcher/estimateJob",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sourceLang:i,targetLang:p,guids:T,provider:O})});if(!U.ok){const ee=await U.json();throw new Error(ee.message||"Failed to estimate job")}return U.json()}}),u=fe({mutationFn:async({sourceLang:i,targetLang:p,guids:T,provider:O,jobName:U,instructions:ee})=>{const te=await fetch("/api/dispatcher/startJob",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sourceLang:i,targetLang:p,guids:T,provider:O,jobName:U,instructions:ee})});if(!te.ok){const Ae=await te.json();throw new Error(Ae.message||"Failed to start job")}return te.json()}});function v(i){return i.map(p=>typeof p=="string"?p:`{{${p.t}}}`).join("")}const J=async()=>{if(!n){alert("Please select a provider first");return}const i=Array.isArray(o)?o:o.tus,p=typeof n=="object"&&n?.id?n.id:n;try{const T=i.map(U=>U.guid),O=await N.mutateAsync({sourceLang:H,targetLang:Q,guids:T,provider:p});O?(l(O),j(""),f(""),g(!0)):(A(`Provider "${p}" did not accept any of the selected translation units.`),y(!0))}catch(T){A(`Failed to estimate job: ${T.message}`),y(!0)}},k=i=>{c(i)},X=async()=>{if(!a)return;const i=typeof n=="object"&&n?.id?n.id:n;try{const T=(await u.mutateAsync({sourceLang:H,targetLang:Q,guids:a.guids,provider:i,jobName:h||void 0,instructions:m||void 0}))[0];I(T),g(!1),P(!0)}catch(p){A(`Failed to start job: ${p.message}`),y(!0)}},xe=()=>{if(P(!1),I(null),l(null),j(""),f(""),a&&a.guids){const i=new Set(a.guids),p=Array.isArray(o)?o:o.tus;for(let T=p.length-1;T>=0;T--)i.has(p[T].guid)&&d(s,T)}},We=i=>i===0?"Free":i==null?"Unknown":`$${i.toFixed(2)}`,q=Array.isArray(o)?o:o.tus,H=Array.isArray(o)?s.split("|")[0]||s.split("→")[0]:o.sourceLang,Q=Array.isArray(o)?s.split("|")[1]||s.split("→").slice(1).join("→"):o.targetLang,ge=q.some(i=>i.ntgt!==void 0),ue=q.some(i=>i.channel!==void 0);return e.jsxs(r,{p:6,borderWidth:"1px",borderRadius:"lg",bg:"white",shadow:"sm",children:[e.jsxs($,{gap:4,align:"stretch",children:[e.jsx(r,{children:e.jsxs(W,{align:"center",justify:"space-between",mb:2,children:[e.jsxs(W,{align:"center",gap:3,children:[e.jsx(D,{colorPalette:"blue",size:"sm",children:H}),e.jsx(t,{color:"fg.muted",fontSize:"lg",children:"→"}),e.jsx(D,{colorPalette:"green",size:"sm",children:Q}),e.jsxs(W,{align:"center",gap:3,ml:4,children:[e.jsxs(_e,{size:"sm",width:"250px",value:n?[n]:[],onValueChange:i=>{},positioning:{strategy:"absolute",placement:"bottom-start",flip:!0,gutter:4},children:[e.jsxs(qe,{children:[e.jsx(t,{fontSize:"sm",flex:"1",textAlign:"left",children:typeof n=="object"&&n?.id?n.id:n||"Select Provider"}),e.jsx(He,{})]}),e.jsx(Qe,{children:e.jsx(Ge,{zIndex:1e3,bg:"white",borderWidth:"1px",borderColor:"border.default",borderRadius:"md",shadow:"lg",minW:"250px",maxH:"200px",overflow:"auto",children:F?e.jsxs(r,{p:3,textAlign:"center",children:[e.jsx(Z,{size:"sm"}),e.jsx(t,{fontSize:"sm",color:"fg.muted",mt:2,children:"Loading providers..."})]}):B.slice().sort((i,p)=>{const T=typeof i=="object"&&i?.id?i.id:i,O=typeof p=="object"&&p?.id?p.id:p;return T.localeCompare(O)}).map((i,p)=>e.jsxs(Ke,{item:i,value:i,onClick:()=>k(i),children:[e.jsx(Ve,{children:typeof i=="object"&&i?.id?i.id:i}),e.jsx(Ye,{})]},`provider-${p}-${typeof i=="string"?i:JSON.stringify(i)}`))})})]}),e.jsx(R,{size:"sm",colorPalette:"blue",onClick:J,disabled:!n,loading:N.isPending,children:"Create Job"})]})]}),e.jsxs(t,{fontSize:"sm",color:"fg.muted",children:[q.length," ",q.length===1?"TU":"TUs"]})]})}),e.jsx(r,{bg:"white",borderRadius:"md",overflow:"auto",children:e.jsxs(r,{as:"table",w:"100%",fontSize:"sm",children:[e.jsx(r,{as:"thead",bg:"blue.subtle",borderBottom:"2px",borderColor:"blue.muted",shadow:"sm",children:e.jsxs(r,{as:"tr",children:[e.jsx(r,{as:"th",p:3,borderBottom:"1px",borderColor:"border.default",textAlign:"left",minW:"120px",children:e.jsx(t,{fontSize:"sm",fontWeight:"bold",color:"blue.600",children:"GUID"})}),ue&&e.jsx(r,{as:"th",p:3,borderBottom:"1px",borderColor:"border.default",textAlign:"left",minW:"120px",children:e.jsx(t,{fontSize:"sm",fontWeight:"bold",color:"blue.600",children:"CHANNEL"})}),e.jsx(r,{as:"th",p:3,borderBottom:"1px",borderColor:"border.default",textAlign:"left",minW:"350px",children:e.jsx(t,{fontSize:"sm",fontWeight:"bold",color:"blue.600",children:"SOURCE"})}),ge&&e.jsx(r,{as:"th",p:3,borderBottom:"1px",borderColor:"border.default",textAlign:"left",minW:"350px",children:e.jsx(t,{fontSize:"sm",fontWeight:"bold",color:"blue.600",children:"TARGET"})}),e.jsx(r,{as:"th",p:3,borderBottom:"1px",borderColor:"border.default",textAlign:"center",minW:"100px",children:e.jsx(t,{fontSize:"sm",fontWeight:"bold",color:"blue.600",children:"ACTION"})})]})}),e.jsx(r,{as:"tbody",children:q.map((i,p)=>e.jsxs(r,{as:"tr",_hover:{bg:"gray.subtle"},children:[e.jsx(r,{as:"td",p:3,borderBottom:"1px",borderColor:"border.subtle",children:e.jsx(t,{fontSize:"xs",fontFamily:"mono",color:"blue.600",userSelect:"all",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxW:"100px",children:i.guid})}),ue&&e.jsx(r,{as:"td",p:3,borderBottom:"1px",borderColor:"border.subtle",children:e.jsx(t,{fontSize:"xs",children:i.channel||""})}),e.jsx(r,{as:"td",p:3,borderBottom:"1px",borderColor:"border.subtle",children:e.jsx(t,{fontSize:"xs",noOfLines:2,dir:H?.startsWith("he")||H?.startsWith("ar")?"rtl":"ltr",children:Array.isArray(i.nsrc)?v(i.nsrc):i.nsrc})}),ge&&e.jsx(r,{as:"td",p:3,borderBottom:"1px",borderColor:"border.subtle",children:e.jsx(t,{fontSize:"xs",noOfLines:2,dir:Q?.startsWith("he")||Q?.startsWith("ar")?"rtl":"ltr",children:Array.isArray(i.ntgt)?v(i.ntgt):i.ntgt||""})}),e.jsx(r,{as:"td",p:3,borderBottom:"1px",borderColor:"border.subtle",textAlign:"center",children:e.jsx(R,{size:"xs",colorPalette:"red",variant:"outline",onClick:()=>d(s,p),children:"Remove"})})]},`cart-tu-${p}-${typeof i.guid=="string"?i.guid:i.nid||p}`))})]})})]}),e.jsxs(se,{open:x,onOpenChange:i=>g(i.open),children:[e.jsx(oe,{}),e.jsx(ne,{children:e.jsxs(le,{maxW:"500px",children:[e.jsxs(ie,{children:[e.jsx(de,{children:"Job Created Successfully"}),e.jsx(ae,{})]}),e.jsx(ce,{children:a&&e.jsxs($,{gap:4,align:"stretch",children:[e.jsxs(r,{children:[e.jsxs(t,{fontSize:"lg",fontWeight:"bold",color:"green.600",mb:3,children:[a.guids?.length||0," TUs accepted out of ",q.length," sent"]}),e.jsxs($,{gap:2,align:"stretch",children:[e.jsxs(r,{children:[e.jsx(t,{fontSize:"sm",fontWeight:"semibold",color:"fg.default",display:"inline",children:"Provider: "}),e.jsx(t,{fontSize:"sm",color:"blue.600",fontFamily:"mono",display:"inline",children:typeof n=="object"&&n?.id?n.id:n})]}),e.jsxs(r,{children:[e.jsx(t,{fontSize:"sm",fontWeight:"semibold",color:"fg.default",display:"inline",children:"Estimated Cost: "}),e.jsx(t,{fontSize:"sm",color:"green.600",fontWeight:"medium",display:"inline",children:We(a.estimatedCost)})]}),a.statusDescription&&e.jsxs(r,{children:[e.jsx(t,{fontSize:"sm",fontWeight:"semibold",color:"fg.default",display:"inline",children:"Status: "}),e.jsx(t,{fontSize:"sm",color:"fg.muted",display:"inline",children:je(a.statusDescription)})]})]})]}),e.jsxs(r,{children:[e.jsx(t,{fontSize:"sm",fontWeight:"bold",mb:2,children:"Job Name (optional):"}),e.jsx(Ze,{placeholder:"Enter a name for this job...",value:h,onChange:i=>j(i.target.value)})]}),e.jsxs(r,{children:[e.jsx(t,{fontSize:"sm",fontWeight:"bold",mb:2,children:"Job Instructions (optional):"}),e.jsx(Xe,{placeholder:"Enter any specific instructions for this translation job...",value:m,onChange:i=>f(i.target.value),rows:3})]}),e.jsxs(W,{gap:3,children:[e.jsx(R,{colorPalette:"gray",variant:"outline",onClick:()=>{g(!1),l(null),j(""),f("")},flex:"1",disabled:u.isPending,children:"Cancel"}),e.jsx(R,{colorPalette:"green",onClick:X,loading:u.isPending,flex:"1",children:"Push Job"})]})]})})]})})]}),e.jsxs(se,{open:z,onOpenChange:i=>y(i.open),children:[e.jsx(oe,{}),e.jsx(ne,{children:e.jsxs(le,{maxW:"400px",children:[e.jsxs(ie,{children:[e.jsx(de,{children:"Job Creation Failed"}),e.jsx(ae,{})]}),e.jsx(ce,{children:e.jsxs($,{gap:4,align:"stretch",children:[e.jsx(t,{color:"red.600",children:S}),e.jsx(R,{colorPalette:"red",onClick:()=>y(!1),w:"100%",children:"Close"})]})})]})})]}),e.jsxs(se,{open:M,onOpenChange:i=>{i.open||xe()},children:[e.jsx(oe,{}),e.jsx(ne,{children:e.jsxs(le,{maxW:"400px",children:[e.jsxs(ie,{children:[e.jsx(de,{children:"Job Started Successfully"}),e.jsx(ae,{})]}),e.jsx(ce,{children:w&&e.jsxs($,{gap:4,align:"stretch",children:[e.jsx(r,{children:e.jsxs($,{gap:2,align:"stretch",children:[e.jsxs(r,{children:[e.jsx(t,{fontSize:"sm",fontWeight:"semibold",color:"fg.default",display:"inline",children:"Job ID: "}),e.jsx(t,{fontSize:"sm",fontFamily:"mono",color:"blue.600",cursor:"pointer",_hover:{textDecoration:"underline"},onClick:i=>{i.preventDefault(),window.open(`/job/${w.jobGuid}`,"_blank")},display:"inline",children:w.jobGuid})]}),e.jsxs(r,{children:[e.jsx(t,{fontSize:"sm",fontWeight:"semibold",color:"fg.default",display:"inline",children:"Provider: "}),e.jsx(t,{fontSize:"sm",color:"blue.600",fontFamily:"mono",display:"inline",children:w.translationProvider})]}),e.jsxs(r,{children:[e.jsx(t,{fontSize:"sm",fontWeight:"semibold",color:"fg.default",display:"inline",children:"Language Pair: "}),e.jsxs(t,{fontSize:"sm",color:"purple.600",fontWeight:"medium",display:"inline",children:[w.sourceLang," → ",w.targetLang]})]}),e.jsxs(r,{children:[e.jsx(t,{fontSize:"sm",fontWeight:"semibold",color:"fg.default",display:"inline",children:"Status: "}),e.jsx(t,{fontSize:"sm",fontWeight:"bold",color:w.status==="completed"?"green.600":"orange.600",display:"inline",children:w.status.toUpperCase()})]}),w.statusDescription&&e.jsxs(r,{children:[e.jsx(t,{fontSize:"sm",fontWeight:"semibold",color:"fg.default",mb:1,children:"Description:"}),e.jsx(t,{fontSize:"sm",color:"fg.muted",pl:2,borderLeft:"2px",borderColor:"blue.200",children:je(w.statusDescription)})]})]})}),e.jsx(r,{children:e.jsx(R,{colorPalette:"blue",onClick:xe,w:"100%",children:"Close & Remove TUs from Cart"})})]})})]})})]})]})};export{dt as C,at as E,jt as L,ht as M,ct as P,xt as S,we as a,gt as b,ft as c,ut as d,mt as e,K as f,bt as g,pt as h,St as i,je as r};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Welcome-Tp-UfiIW.js","assets/vendor-BVgSJH5C.js","assets/index-543A5WcJ.js","assets/Status-Bx0Ui7d2.js","assets/StatusDetail-BzJ2TIme.js","assets/Sources-BwZ8Vub0.js","assets/SourcesDetail-CXgslRDb.js","assets/SourcesResource-Br3Bspz2.js","assets/TMToc-CQ1zhmPh.js","assets/TMDetail-BxbKr57p.js","assets/TMByProvider-B2MrTxO0.js","assets/Providers-BZVmclS1.js","assets/Cart-CiY5V__G.js","assets/Job-D-5ikxga.js"])))=>i.map(i=>d[i]);
2
+ import{j as e,a4 as P,T as m,a as R,c as f,r as n,a5 as z,a6 as T,a7 as C,a8 as O,a9 as a,B as u,S as E,A,aa as w,F as _,ab as D,ac as I,R as M,ad as V,ae as W}from"./vendor-BVgSJH5C.js";import{E as N,C as B}from"./index-543A5WcJ.js";(function(){const x=document.createElement("link").relList;if(x&&x.supports&&x.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))j(r);new MutationObserver(r=>{for(const t of r)if(t.type==="childList")for(const s of t.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&j(s)}).observe(document,{childList:!0,subtree:!0});function h(r){const t={};return r.integrity&&(t.integrity=r.integrity),r.referrerPolicy&&(t.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?t.credentials="include":r.crossOrigin==="anonymous"?t.credentials="omit":t.credentials="same-origin",t}function j(r){if(r.ep)return;r.ep=!0;const t=h(r);fetch(r.href,t)}})();const U="modulepreload",q=function(g){return"/"+g},v={},l=function(x,h,j){let r=Promise.resolve();if(h&&h.length>0){let y=function(i){return Promise.all(i.map(c=>Promise.resolve(c).then(b=>({status:"fulfilled",value:b}),b=>({status:"rejected",reason:b}))))};document.getElementsByTagName("link");const s=document.querySelector("meta[property=csp-nonce]"),o=s?.nonce||s?.getAttribute("nonce");r=y(h.map(i=>{if(i=q(i),i in v)return;v[i]=!0;const c=i.endsWith(".css"),b=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${i}"]${b}`))return;const p=document.createElement("link");if(p.rel=c?"stylesheet":U,c||(p.as="script"),p.crossOrigin="",p.href=i,o&&p.setAttribute("nonce",o),document.head.appendChild(p),c)return new Promise((L,S)=>{p.addEventListener("load",L),p.addEventListener("error",()=>S(new Error(`Unable to preload CSS for ${i}`)))})}))}function t(s){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=s,window.dispatchEvent(o),!o.defaultPrevented)throw s}return r.then(s=>{for(const o of s||[])o.status==="rejected"&&t(o.reason);return x().catch(t)})},F=()=>e.jsxs(P,{maxWidth:"sm",textAlign:"center",mt:20,children:[e.jsx(m,{fontSize:"6xl",fontWeight:"bold",mb:4,children:"404"}),e.jsx(m,{fontSize:"2xl",fontWeight:"medium",mb:2,children:"Page Not Found"}),e.jsx(m,{color:"fg.muted",mb:8,children:"Sorry, the page you are looking for does not exist."}),e.jsx(R,{asChild:!0,colorPalette:"brand",size:"lg",children:e.jsx(f,{to:"/",children:"Go to Home"})})]}),H=n.lazy(()=>l(()=>import("./Welcome-Tp-UfiIW.js"),__vite__mapDeps([0,1,2]))),k=n.lazy(()=>l(()=>import("./Status-Bx0Ui7d2.js"),__vite__mapDeps([3,1,2]))),$=n.lazy(()=>l(()=>import("./StatusDetail-BzJ2TIme.js"),__vite__mapDeps([4,1,2]))),G=n.lazy(()=>l(()=>import("./Sources-BwZ8Vub0.js"),__vite__mapDeps([5,1,2]))),J=n.lazy(()=>l(()=>import("./SourcesDetail-CXgslRDb.js"),__vite__mapDeps([6,1,2]))),Q=n.lazy(()=>l(()=>import("./SourcesResource-Br3Bspz2.js"),__vite__mapDeps([7,1,2]))),K=n.lazy(()=>l(()=>import("./TMToc-CQ1zhmPh.js"),__vite__mapDeps([8,1,2]))),X=n.lazy(()=>l(()=>import("./TMDetail-BxbKr57p.js"),__vite__mapDeps([9,1,2]))),Y=n.lazy(()=>l(()=>import("./TMByProvider-B2MrTxO0.js"),__vite__mapDeps([10,1,2]))),Z=n.lazy(()=>l(()=>import("./Providers-BZVmclS1.js"),__vite__mapDeps([11,1,2]))),ee=n.lazy(()=>l(()=>import("./Cart-CiY5V__G.js"),__vite__mapDeps([12,1,2]))),te=n.lazy(()=>l(()=>import("./Job-D-5ikxga.js"),__vite__mapDeps([13,1,2])));function d({children:g}){A();const x=w(),[h,j]=n.useState(0),r=()=>{try{const s=sessionStorage.getItem("tmCart");if(s){const o=JSON.parse(s),y=Object.values(o).reduce((i,c)=>Array.isArray(c)?i+c.length:i+(c.tus?c.tus.length:0),0);j(y)}else j(0)}catch{j(0)}};n.useEffect(()=>{r();const s=()=>r(),o=()=>r();return window.addEventListener("storage",s),window.addEventListener("cartUpdated",o),()=>{window.removeEventListener("storage",s),window.removeEventListener("cartUpdated",o)}},[]);const t=s=>s==="/"?x.pathname==="/":x.pathname.startsWith(s);return e.jsxs(u,{minH:"100vh",bg:"bg.muted",children:[e.jsx(u,{bg:"white",borderBottom:"1px",borderColor:"border.default",children:e.jsx(u,{px:6,py:3,children:e.jsxs(_,{align:"center",justify:"space-between",children:[e.jsxs(_,{align:"center",gap:3,children:[e.jsx("img",{src:"/logo.svg",alt:"L10n Monster",width:"32",height:"32"}),e.jsx(D,{size:"lg",color:"fg.default",children:"L10n Monster"})]}),e.jsxs(_,{align:"center",gap:4,css:{"& a":{textDecoration:"none",color:"inherit"}},children:[e.jsx(f,{to:"/",children:e.jsx(u,{cursor:"pointer",px:3,py:1,borderRadius:"md",bg:t("/")?"blue.subtle":"transparent",_hover:{bg:t("/")?"blue.subtle":"gray.subtle"},children:e.jsx(m,{fontSize:"md",fontWeight:"medium",children:"Home"})})}),e.jsx(f,{to:"/status",children:e.jsx(u,{cursor:"pointer",px:3,py:1,borderRadius:"md",bg:t("/status")?"blue.subtle":"transparent",_hover:{bg:t("/status")?"blue.subtle":"gray.subtle"},children:e.jsx(m,{fontSize:"md",fontWeight:"medium",children:"Status"})})}),e.jsx(f,{to:"/sources",children:e.jsx(u,{cursor:"pointer",px:3,py:1,borderRadius:"md",bg:t("/sources")?"blue.subtle":"transparent",_hover:{bg:t("/sources")?"blue.subtle":"gray.subtle"},children:e.jsx(m,{fontSize:"md",fontWeight:"medium",children:"Sources"})})}),e.jsx(f,{to:"/tm",children:e.jsx(u,{cursor:"pointer",px:3,py:1,borderRadius:"md",bg:t("/tm")?"blue.subtle":"transparent",_hover:{bg:t("/tm")?"blue.subtle":"gray.subtle"},children:e.jsx(m,{fontSize:"md",fontWeight:"medium",children:"TM"})})}),e.jsx(f,{to:"/providers",children:e.jsx(u,{cursor:"pointer",px:3,py:1,borderRadius:"md",bg:t("/providers")?"blue.subtle":"transparent",_hover:{bg:t("/providers")?"blue.subtle":"gray.subtle"},children:e.jsx(m,{fontSize:"md",fontWeight:"medium",children:"Providers"})})})]}),e.jsx(f,{to:"/cart",css:{textDecoration:"none",color:"inherit"},children:e.jsxs(_,{align:"center",gap:2,px:3,py:1,bg:t("/cart")?"blue.subtle":h>0?"blue.muted":"gray.muted",borderRadius:"md",cursor:"pointer",_hover:{bg:"blue.subtle"},children:[e.jsx(u,{fontSize:"lg",children:"🛒"}),e.jsxs(m,{fontSize:"md",fontWeight:"medium",children:[h," ",h===1?"TU":"TUs"]})]})})]})})}),e.jsx(N,{children:e.jsx(n.Suspense,{fallback:e.jsx(u,{display:"flex",justifyContent:"center",mt:10,children:e.jsx(E,{size:"xl"})}),children:g})})]})}const re=new z({defaultOptions:{queries:{staleTime:300*1e3,gcTime:600*1e3,retry:1,retryDelay:1e3}}});function se(){return e.jsx(T,{client:re,children:e.jsx(C,{children:e.jsx(n.Suspense,{fallback:e.jsx(u,{display:"flex",justifyContent:"center",alignItems:"center",minH:"100vh",children:e.jsx(E,{size:"xl"})}),children:e.jsxs(O,{children:[e.jsx(a,{path:"/job/:jobGuid",element:e.jsx(te,{})}),e.jsx(a,{path:"/",element:e.jsx(d,{children:e.jsx(H,{})})}),e.jsx(a,{path:"/status",element:e.jsx(d,{children:e.jsx(k,{})})}),e.jsx(a,{path:"/status/:channelId/:sourceLang/:targetLang",element:e.jsx(d,{children:e.jsx($,{})})}),e.jsx(a,{path:"/sources",element:e.jsx(d,{children:e.jsx(G,{})})}),e.jsx(a,{path:"/sources/:channelId/:prj",element:e.jsx(d,{children:e.jsx(J,{})})}),e.jsx(a,{path:"/sources/:channelId",element:e.jsx(d,{children:e.jsx(Q,{})})}),e.jsx(a,{path:"/tm",element:e.jsx(d,{children:e.jsx(K,{})})}),e.jsx(a,{path:"/tm/providers/:sourceLang/:targetLang",element:e.jsx(d,{children:e.jsx(Y,{})})}),e.jsx(a,{path:"/tm/:sourceLang/:targetLang",element:e.jsx(d,{children:e.jsx(X,{})})}),e.jsx(a,{path:"/providers",element:e.jsx(d,{children:e.jsx(Z,{})})}),e.jsx(a,{path:"/cart",element:e.jsx(d,{children:e.jsx(ee,{})})}),e.jsx(a,{path:"*",element:e.jsx(F,{})})]})})})})}const ne=I.createRoot(document.getElementById("root"));ne.render(e.jsx(M.StrictMode,{children:e.jsx(V,{value:W,children:e.jsx(B,{children:e.jsx(se,{})})})}));