@mcp-graph-workflow/mcp-graph 5.32.0 → 5.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/router.d.ts.map +1 -1
- package/dist/api/router.js +2 -0
- package/dist/api/router.js.map +1 -1
- package/dist/api/routes/code-graph.d.ts.map +1 -1
- package/dist/api/routes/code-graph.js +3 -1
- package/dist/api/routes/code-graph.js.map +1 -1
- package/dist/api/routes/davinci.d.ts +3 -0
- package/dist/api/routes/davinci.d.ts.map +1 -0
- package/dist/api/routes/davinci.js +188 -0
- package/dist/api/routes/davinci.js.map +1 -0
- package/dist/core/analyzer/ac-coverage.d.ts +16 -0
- package/dist/core/analyzer/ac-coverage.d.ts.map +1 -0
- package/dist/core/analyzer/ac-coverage.js +38 -0
- package/dist/core/analyzer/ac-coverage.js.map +1 -0
- package/dist/core/analyzer/asset-blockers.d.ts +23 -0
- package/dist/core/analyzer/asset-blockers.d.ts.map +1 -0
- package/dist/core/analyzer/asset-blockers.js +50 -0
- package/dist/core/analyzer/asset-blockers.js.map +1 -0
- package/dist/core/analyzer/concurrency-risk.d.ts +26 -0
- package/dist/core/analyzer/concurrency-risk.d.ts.map +1 -0
- package/dist/core/analyzer/concurrency-risk.js +99 -0
- package/dist/core/analyzer/concurrency-risk.js.map +1 -0
- package/dist/core/analyzer/config-coverage.d.ts +20 -0
- package/dist/core/analyzer/config-coverage.d.ts.map +1 -0
- package/dist/core/analyzer/config-coverage.js +49 -0
- package/dist/core/analyzer/config-coverage.js.map +1 -0
- package/dist/core/analyzer/contract-coverage.d.ts +22 -0
- package/dist/core/analyzer/contract-coverage.d.ts.map +1 -0
- package/dist/core/analyzer/contract-coverage.js +51 -0
- package/dist/core/analyzer/contract-coverage.js.map +1 -0
- package/dist/core/analyzer/data-integrity.d.ts +22 -0
- package/dist/core/analyzer/data-integrity.d.ts.map +1 -0
- package/dist/core/analyzer/data-integrity.js +80 -0
- package/dist/core/analyzer/data-integrity.js.map +1 -0
- package/dist/core/analyzer/economy-simulator.d.ts +33 -0
- package/dist/core/analyzer/economy-simulator.d.ts.map +1 -0
- package/dist/core/analyzer/economy-simulator.js +162 -0
- package/dist/core/analyzer/economy-simulator.js.map +1 -0
- package/dist/core/analyzer/formula-consistency.d.ts +25 -0
- package/dist/core/analyzer/formula-consistency.d.ts.map +1 -0
- package/dist/core/analyzer/formula-consistency.js +82 -0
- package/dist/core/analyzer/formula-consistency.js.map +1 -0
- package/dist/core/analyzer/metric-coverage.d.ts +22 -0
- package/dist/core/analyzer/metric-coverage.d.ts.map +1 -0
- package/dist/core/analyzer/metric-coverage.js +52 -0
- package/dist/core/analyzer/metric-coverage.js.map +1 -0
- package/dist/core/analyzer/performance-budget-check.d.ts +22 -0
- package/dist/core/analyzer/performance-budget-check.d.ts.map +1 -0
- package/dist/core/analyzer/performance-budget-check.js +40 -0
- package/dist/core/analyzer/performance-budget-check.js.map +1 -0
- package/dist/core/analyzer/risk-assessment.d.ts.map +1 -1
- package/dist/core/analyzer/risk-assessment.js +9 -0
- package/dist/core/analyzer/risk-assessment.js.map +1 -1
- package/dist/core/analyzer/scenario-coverage.d.ts +19 -0
- package/dist/core/analyzer/scenario-coverage.d.ts.map +1 -0
- package/dist/core/analyzer/scenario-coverage.js +59 -0
- package/dist/core/analyzer/scenario-coverage.js.map +1 -0
- package/dist/core/analyzer/state-completeness.d.ts +22 -0
- package/dist/core/analyzer/state-completeness.d.ts.map +1 -0
- package/dist/core/analyzer/state-completeness.js +76 -0
- package/dist/core/analyzer/state-completeness.js.map +1 -0
- package/dist/core/code/code-indexer.d.ts +1 -1
- package/dist/core/code/code-indexer.d.ts.map +1 -1
- package/dist/core/code/code-indexer.js +50 -3
- package/dist/core/code/code-indexer.js.map +1 -1
- package/dist/core/code/code-store.js +3 -3
- package/dist/core/code/code-store.js.map +1 -1
- package/dist/core/code/code-types.d.ts +4 -4
- package/dist/core/code/treesitter/treesitter-manager.d.ts.map +1 -1
- package/dist/core/code/treesitter/treesitter-manager.js +2 -0
- package/dist/core/code/treesitter/treesitter-manager.js.map +1 -1
- package/dist/core/davinci/build-runner.d.ts +37 -0
- package/dist/core/davinci/build-runner.d.ts.map +1 -0
- package/dist/core/davinci/build-runner.js +239 -0
- package/dist/core/davinci/build-runner.js.map +1 -0
- package/dist/core/davinci/davinci-parser.d.ts +6 -0
- package/dist/core/davinci/davinci-parser.d.ts.map +1 -0
- package/dist/core/davinci/davinci-parser.js +218 -0
- package/dist/core/davinci/davinci-parser.js.map +1 -0
- package/dist/core/davinci/davinci-store.d.ts +49 -0
- package/dist/core/davinci/davinci-store.d.ts.map +1 -0
- package/dist/core/davinci/davinci-store.js +121 -0
- package/dist/core/davinci/davinci-store.js.map +1 -0
- package/dist/core/davinci/davinci-types.d.ts +241 -0
- package/dist/core/davinci/davinci-types.d.ts.map +1 -0
- package/dist/core/davinci/davinci-types.js +123 -0
- package/dist/core/davinci/davinci-types.js.map +1 -0
- package/dist/core/davinci/davinci-validators.d.ts +16 -0
- package/dist/core/davinci/davinci-validators.d.ts.map +1 -0
- package/dist/core/davinci/davinci-validators.js +86 -0
- package/dist/core/davinci/davinci-validators.js.map +1 -0
- package/dist/core/davinci/descriptor-generator.d.ts +19 -0
- package/dist/core/davinci/descriptor-generator.d.ts.map +1 -0
- package/dist/core/davinci/descriptor-generator.js +52 -0
- package/dist/core/davinci/descriptor-generator.js.map +1 -0
- package/dist/core/davinci/plugin-generator.d.ts +29 -0
- package/dist/core/davinci/plugin-generator.d.ts.map +1 -0
- package/dist/core/davinci/plugin-generator.js +86 -0
- package/dist/core/davinci/plugin-generator.js.map +1 -0
- package/dist/core/davinci/plugin-type-detector.d.ts +15 -0
- package/dist/core/davinci/plugin-type-detector.d.ts.map +1 -0
- package/dist/core/davinci/plugin-type-detector.js +114 -0
- package/dist/core/davinci/plugin-type-detector.js.map +1 -0
- package/dist/core/davinci/pom-generator.d.ts +4 -0
- package/dist/core/davinci/pom-generator.d.ts.map +1 -0
- package/dist/core/davinci/pom-generator.js +179 -0
- package/dist/core/davinci/pom-generator.js.map +1 -0
- package/dist/core/davinci/template-registry.d.ts +25 -0
- package/dist/core/davinci/template-registry.d.ts.map +1 -0
- package/dist/core/davinci/template-registry.js +280 -0
- package/dist/core/davinci/template-registry.js.map +1 -0
- package/dist/core/davinci/variable-resolver.d.ts +9 -0
- package/dist/core/davinci/variable-resolver.d.ts.map +1 -0
- package/dist/core/davinci/variable-resolver.js +62 -0
- package/dist/core/davinci/variable-resolver.js.map +1 -0
- package/dist/core/designer/adr-validator.d.ts.map +1 -1
- package/dist/core/designer/adr-validator.js +12 -4
- package/dist/core/designer/adr-validator.js.map +1 -1
- package/dist/core/designer/tech-risk-assessor.d.ts +5 -1
- package/dist/core/designer/tech-risk-assessor.d.ts.map +1 -1
- package/dist/core/designer/tech-risk-assessor.js +39 -11
- package/dist/core/designer/tech-risk-assessor.js.map +1 -1
- package/dist/core/designer/traceability-matrix.d.ts.map +1 -1
- package/dist/core/designer/traceability-matrix.js +14 -3
- package/dist/core/designer/traceability-matrix.js.map +1 -1
- package/dist/core/graph/auto-sequence.d.ts +10 -0
- package/dist/core/graph/auto-sequence.d.ts.map +1 -0
- package/dist/core/graph/auto-sequence.js +29 -0
- package/dist/core/graph/auto-sequence.js.map +1 -0
- package/dist/core/graph/csv-export.d.ts +7 -0
- package/dist/core/graph/csv-export.d.ts.map +1 -0
- package/dist/core/graph/csv-export.js +43 -0
- package/dist/core/graph/csv-export.js.map +1 -0
- package/dist/core/graph/graph-types.d.ts +2 -2
- package/dist/core/graph/graph-types.d.ts.map +1 -1
- package/dist/core/graph/mermaid-export.d.ts +1 -1
- package/dist/core/graph/mermaid-export.d.ts.map +1 -1
- package/dist/core/graph/mermaid-export.js +101 -0
- package/dist/core/graph/mermaid-export.js.map +1 -1
- package/dist/core/importer/prd-to-graph.d.ts.map +1 -1
- package/dist/core/importer/prd-to-graph.js +8 -1
- package/dist/core/importer/prd-to-graph.js.map +1 -1
- package/dist/core/listener/backlog-health.d.ts.map +1 -1
- package/dist/core/listener/backlog-health.js +15 -3
- package/dist/core/listener/backlog-health.js.map +1 -1
- package/dist/core/parser/classify.d.ts +4 -0
- package/dist/core/parser/classify.d.ts.map +1 -1
- package/dist/core/parser/classify.js +18 -0
- package/dist/core/parser/classify.js.map +1 -1
- package/dist/core/parser/extract.d.ts.map +1 -1
- package/dist/core/parser/extract.js +22 -4
- package/dist/core/parser/extract.js.map +1 -1
- package/dist/core/parser/prd-diff.d.ts +23 -0
- package/dist/core/parser/prd-diff.d.ts.map +1 -0
- package/dist/core/parser/prd-diff.js +55 -0
- package/dist/core/parser/prd-diff.js.map +1 -0
- package/dist/core/parser/read-swagger.d.ts.map +1 -1
- package/dist/core/parser/read-swagger.js +6 -0
- package/dist/core/parser/read-swagger.js.map +1 -1
- package/dist/core/parser/segment.d.ts +5 -0
- package/dist/core/parser/segment.d.ts.map +1 -1
- package/dist/core/parser/segment.js +70 -0
- package/dist/core/parser/segment.js.map +1 -1
- package/dist/core/planner/auto-ready.d.ts +19 -0
- package/dist/core/planner/auto-ready.d.ts.map +1 -0
- package/dist/core/planner/auto-ready.js +39 -0
- package/dist/core/planner/auto-ready.js.map +1 -0
- package/dist/core/planner/planning-report.d.ts +13 -1
- package/dist/core/planner/planning-report.d.ts.map +1 -1
- package/dist/core/planner/planning-report.js +53 -2
- package/dist/core/planner/planning-report.js.map +1 -1
- package/dist/core/planner/sprint-health.d.ts +22 -0
- package/dist/core/planner/sprint-health.d.ts.map +1 -0
- package/dist/core/planner/sprint-health.js +41 -0
- package/dist/core/planner/sprint-health.js.map +1 -0
- package/dist/core/siebel/sif-parser.d.ts.map +1 -1
- package/dist/core/siebel/sif-parser.js +6 -0
- package/dist/core/siebel/sif-parser.js.map +1 -1
- package/dist/core/siebel/wsdl-parser.d.ts.map +1 -1
- package/dist/core/siebel/wsdl-parser.js +6 -0
- package/dist/core/siebel/wsdl-parser.js.map +1 -1
- package/dist/core/store/migrations.d.ts.map +1 -1
- package/dist/core/store/migrations.js +17 -0
- package/dist/core/store/migrations.js.map +1 -1
- package/dist/core/store/sqlite-store.d.ts +6 -0
- package/dist/core/store/sqlite-store.d.ts.map +1 -1
- package/dist/core/store/sqlite-store.js +54 -3
- package/dist/core/store/sqlite-store.js.map +1 -1
- package/dist/core/templates/template-engine.d.ts +36 -0
- package/dist/core/templates/template-engine.d.ts.map +1 -0
- package/dist/core/templates/template-engine.js +104 -0
- package/dist/core/templates/template-engine.js.map +1 -0
- package/dist/core/translation/generators/universal-generator.d.ts.map +1 -1
- package/dist/core/translation/generators/universal-generator.js +187 -9
- package/dist/core/translation/generators/universal-generator.js.map +1 -1
- package/dist/core/translation/language-detect.d.ts.map +1 -1
- package/dist/core/translation/language-detect.js +37 -14
- package/dist/core/translation/language-detect.js.map +1 -1
- package/dist/docs-manifest.json +68 -5
- package/dist/mcp/app-factory.js +1 -1
- package/dist/mcp/app-factory.js.map +1 -1
- package/dist/mcp/tools/analyze.d.ts.map +1 -1
- package/dist/mcp/tools/analyze.js +100 -1
- package/dist/mcp/tools/analyze.js.map +1 -1
- package/dist/mcp/tools/davinci-analyze.d.ts +4 -0
- package/dist/mcp/tools/davinci-analyze.d.ts.map +1 -0
- package/dist/mcp/tools/davinci-analyze.js +31 -0
- package/dist/mcp/tools/davinci-analyze.js.map +1 -0
- package/dist/mcp/tools/davinci-build.d.ts +4 -0
- package/dist/mcp/tools/davinci-build.d.ts.map +1 -0
- package/dist/mcp/tools/davinci-build.js +43 -0
- package/dist/mcp/tools/davinci-build.js.map +1 -0
- package/dist/mcp/tools/davinci-convert.d.ts +4 -0
- package/dist/mcp/tools/davinci-convert.d.ts.map +1 -0
- package/dist/mcp/tools/davinci-convert.js +61 -0
- package/dist/mcp/tools/davinci-convert.js.map +1 -0
- package/dist/mcp/tools/edge.d.ts.map +1 -1
- package/dist/mcp/tools/edge.js +81 -3
- package/dist/mcp/tools/edge.js.map +1 -1
- package/dist/mcp/tools/export.d.ts.map +1 -1
- package/dist/mcp/tools/export.js +17 -4
- package/dist/mcp/tools/export.js.map +1 -1
- package/dist/mcp/tools/import-prd.d.ts.map +1 -1
- package/dist/mcp/tools/import-prd.js +89 -2
- package/dist/mcp/tools/import-prd.js.map +1 -1
- package/dist/mcp/tools/index.d.ts.map +1 -1
- package/dist/mcp/tools/index.js +12 -0
- package/dist/mcp/tools/index.js.map +1 -1
- package/dist/mcp/tools/node.d.ts.map +1 -1
- package/dist/mcp/tools/node.js +127 -6
- package/dist/mcp/tools/node.js.map +1 -1
- package/dist/mcp/tools/plan-sprint.d.ts.map +1 -1
- package/dist/mcp/tools/plan-sprint.js +6 -2
- package/dist/mcp/tools/plan-sprint.js.map +1 -1
- package/dist/mcp/tools/show.d.ts.map +1 -1
- package/dist/mcp/tools/show.js +11 -4
- package/dist/mcp/tools/show.js.map +1 -1
- package/dist/mcp/tools/template.d.ts +4 -0
- package/dist/mcp/tools/template.d.ts.map +1 -0
- package/dist/mcp/tools/template.js +137 -0
- package/dist/mcp/tools/template.js.map +1 -0
- package/dist/schemas/analyzer-schema.d.ts +2 -2
- package/dist/schemas/designer-schema.d.ts +21 -0
- package/dist/schemas/designer-schema.d.ts.map +1 -1
- package/dist/schemas/designer-schema.js +2 -0
- package/dist/schemas/designer-schema.js.map +1 -1
- package/dist/schemas/edge.schema.d.ts +6 -0
- package/dist/schemas/edge.schema.d.ts.map +1 -1
- package/dist/schemas/edge.schema.js +2 -0
- package/dist/schemas/edge.schema.js.map +1 -1
- package/dist/schemas/graph.schema.d.ts +13 -0
- package/dist/schemas/graph.schema.d.ts.map +1 -1
- package/dist/schemas/node.schema.d.ts +20 -0
- package/dist/schemas/node.schema.d.ts.map +1 -1
- package/dist/schemas/node.schema.js +3 -0
- package/dist/schemas/node.schema.js.map +1 -1
- package/dist/schemas/siebel.schema.d.ts +13 -13
- package/dist/web/dashboard/dist/assets/{benchmark-tab-en-UkR66.js → benchmark-tab-Aqr2Xzu5.js} +1 -1
- package/dist/web/dashboard/dist/assets/{circle-alert-5GIBBP3L.js → circle-alert-BJTyaShp.js} +1 -1
- package/dist/web/dashboard/dist/assets/constants-DLyESMjx.js +1 -0
- package/dist/web/dashboard/dist/assets/{context-tab-DjfwQik8.js → context-tab-CbmHGGZh.js} +1 -1
- package/dist/web/dashboard/dist/assets/davinci-tab-krxsY7Pp.js +10 -0
- package/dist/web/dashboard/dist/assets/{docs-tab-gEBzBEEV.js → docs-tab-AautK0dL.js} +1 -1
- package/dist/web/dashboard/dist/assets/file-code-DVOtQrhl.js +11 -0
- package/dist/web/dashboard/dist/assets/{gitnexus-tab-BE2pi0xe.js → gitnexus-tab-D5xRYU3u.js} +1 -1
- package/dist/web/dashboard/dist/assets/{graph-section-Cwx-Bmeh.js → graph-section-D5y4S3T1.js} +1 -1
- package/dist/web/dashboard/dist/assets/{graph-tab-BcS75lY0.js → graph-tab-tmjyMc4q.js} +1 -1
- package/dist/web/dashboard/dist/assets/{graph-utils-OY_fOvB3.js → graph-utils-BlwoHdjR.js} +1 -1
- package/dist/web/dashboard/dist/assets/index-BcMjWikL.css +1 -0
- package/dist/web/dashboard/dist/assets/{index-4X4gmCkA.js → index-C13O-yj1.js} +1 -1
- package/dist/web/dashboard/dist/assets/{index-1aGs8JPI.js → index-CAOXRHQq.js} +1 -1
- package/dist/web/dashboard/dist/assets/{index-C3Kad9YO.js → index-DrvFzUJS.js} +24 -19
- package/dist/web/dashboard/dist/assets/{insights-tab-CP2uIpid.js → insights-tab-9sq9NfBt.js} +1 -1
- package/dist/web/dashboard/dist/assets/{journey-tab-ChwNK_8S.js → journey-tab-ujeAoAsS.js} +1 -1
- package/dist/web/dashboard/dist/assets/{languages-tab-DnBvSh4N.js → languages-tab-DT-46f7p.js} +24 -39
- package/dist/web/dashboard/dist/assets/{loader-circle-Bxe_TLXv.js → loader-circle-DQz_g7p_.js} +1 -1
- package/dist/web/dashboard/dist/assets/{logs-tab-BH86QvKe.js → logs-tab-DHj9jG6G.js} +1 -1
- package/dist/web/dashboard/dist/assets/{lsp-tab-DUpaQXtx.js → lsp-tab-DGIm2cTM.js} +3 -3
- package/dist/web/dashboard/dist/assets/{memories-tab-CkwtNv3t.js → memories-tab-DT7JcHgq.js} +1 -1
- package/dist/web/dashboard/dist/assets/{prd-backlog-tab-CPJanaVF.js → prd-backlog-tab-CLzQ5p_3.js} +1 -1
- package/dist/web/dashboard/dist/assets/{refresh-cw-DL1dUrhF.js → refresh-cw-C0EeXZ6n.js} +1 -1
- package/dist/web/dashboard/dist/assets/{siebel-tab-D7x34UXy.js → siebel-tab-67cdoYQ_.js} +3 -3
- package/dist/web/dashboard/dist/assets/{sif-parse.worker-DZrybOHz.js → sif-parse.worker-Cty_N-lP.js} +3 -3
- package/dist/web/dashboard/dist/assets/{skills-tab-BuqCMS29.js → skills-tab-DL8-pMo9.js} +1 -1
- package/dist/web/dashboard/dist/assets/{style-iy_ryTT6.js → style-DeKQIW_i.js} +1 -1
- package/dist/web/dashboard/dist/assets/triangle-alert-cibtv50e.js +16 -0
- package/dist/web/dashboard/dist/assets/upload-CZI9Zosi.js +16 -0
- package/dist/web/dashboard/dist/index.html +2 -2
- package/package.json +3 -1
- package/dist/web/dashboard/dist/assets/constants-Dd6A34aQ.js +0 -1
- package/dist/web/dashboard/dist/assets/index-BVhCKhGJ.css +0 -1
- package/dist/web/dashboard/dist/assets/triangle-alert-CPzksLkC.js +0 -26
package/dist/web/dashboard/dist/assets/{languages-tab-DnBvSh4N.js → languages-tab-DT-46f7p.js}
RENAMED
|
@@ -1,123 +1,108 @@
|
|
|
1
|
-
import{c as N,r as p,a as v,j as e,e as H,B as G,u as oe,L as ce,G as B}from"./index-
|
|
1
|
+
import{c as N,r as p,a as v,j as e,e as H,B as G,u as oe,L as ce,G as B}from"./index-DrvFzUJS.js";import{i as de,B as ie,C as xe}from"./style-DeKQIW_i.js";import{d as Z}from"./index-CAOXRHQq.js";import{L as $}from"./loader-circle-DQz_g7p_.js";import{C as ue,U as me,a as pe}from"./upload-CZI9Zosi.js";import{T as J,C as K,S as te}from"./triangle-alert-cibtv50e.js";import{R as V}from"./refresh-cw-C0EeXZ6n.js";import{C as W,F as se}from"./file-code-DVOtQrhl.js";import"./index-C13O-yj1.js";/**
|
|
2
2
|
* @license lucide-react v1.7.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
5
5
|
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const
|
|
6
|
+
*/const he=[["path",{d:"M8 3 4 7l4 4",key:"9rb6wj"}],["path",{d:"M4 7h16",key:"6tx8e3"}],["path",{d:"m16 21 4-4-4-4",key:"siv7j2"}],["path",{d:"M20 17H4",key:"h6l3hr"}]],ge=N("arrow-left-right",he);/**
|
|
7
7
|
* @license lucide-react v1.7.0 - ISC
|
|
8
8
|
*
|
|
9
9
|
* This source code is licensed under the ISC license.
|
|
10
10
|
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const
|
|
11
|
+
*/const fe=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],be=N("arrow-left",fe);/**
|
|
12
12
|
* @license lucide-react v1.7.0 - ISC
|
|
13
13
|
*
|
|
14
14
|
* This source code is licensed under the ISC license.
|
|
15
15
|
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const
|
|
16
|
+
*/const je=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],D=N("check",je);/**
|
|
17
17
|
* @license lucide-react v1.7.0 - ISC
|
|
18
18
|
*
|
|
19
19
|
* This source code is licensed under the ISC license.
|
|
20
20
|
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
-
*/const
|
|
21
|
+
*/const Ne=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],ae=N("circle-check",Ne);/**
|
|
22
22
|
* @license lucide-react v1.7.0 - ISC
|
|
23
23
|
*
|
|
24
24
|
* This source code is licensed under the ISC license.
|
|
25
25
|
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
-
*/const
|
|
26
|
+
*/const ye=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]],ve=N("clock",ye);/**
|
|
27
27
|
* @license lucide-react v1.7.0 - ISC
|
|
28
28
|
*
|
|
29
29
|
* This source code is licensed under the ISC license.
|
|
30
30
|
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
-
*/const
|
|
31
|
+
*/const we=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],q=N("copy",we);/**
|
|
32
32
|
* @license lucide-react v1.7.0 - ISC
|
|
33
33
|
*
|
|
34
34
|
* This source code is licensed under the ISC license.
|
|
35
35
|
* See the LICENSE file in the root directory of this source tree.
|
|
36
|
-
*/const
|
|
36
|
+
*/const Ce=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],ke=N("cpu",Ce);/**
|
|
37
37
|
* @license lucide-react v1.7.0 - ISC
|
|
38
38
|
*
|
|
39
39
|
* This source code is licensed under the ISC license.
|
|
40
40
|
* See the LICENSE file in the root directory of this source tree.
|
|
41
|
-
*/const
|
|
41
|
+
*/const Se=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],E=N("download",Se);/**
|
|
42
42
|
* @license lucide-react v1.7.0 - ISC
|
|
43
43
|
*
|
|
44
44
|
* This source code is licensed under the ISC license.
|
|
45
45
|
* See the LICENSE file in the root directory of this source tree.
|
|
46
|
-
*/const
|
|
46
|
+
*/const Me=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Le=N("eye",Me);/**
|
|
47
47
|
* @license lucide-react v1.7.0 - ISC
|
|
48
48
|
*
|
|
49
49
|
* This source code is licensed under the ISC license.
|
|
50
50
|
* See the LICENSE file in the root directory of this source tree.
|
|
51
|
-
*/const
|
|
51
|
+
*/const Re=[["path",{d:"M13.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v11.5",key:"4pqfef"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M8 12v-1",key:"1ej8lb"}],["path",{d:"M8 18v-2",key:"qcmpov"}],["path",{d:"M8 7V6",key:"1nbb54"}],["circle",{cx:"8",cy:"20",r:"2",key:"ckkr5m"}]],$e=N("file-archive",Re);/**
|
|
52
52
|
* @license lucide-react v1.7.0 - ISC
|
|
53
53
|
*
|
|
54
54
|
* This source code is licensed under the ISC license.
|
|
55
55
|
* See the LICENSE file in the root directory of this source tree.
|
|
56
|
-
*/const
|
|
56
|
+
*/const ze=[["path",{d:"M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35",key:"1wthlu"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m5 16-3 3 3 3",key:"331omg"}],["path",{d:"m9 22 3-3-3-3",key:"lsp7cz"}]],Fe=N("file-code-corner",ze);/**
|
|
57
57
|
* @license lucide-react v1.7.0 - ISC
|
|
58
58
|
*
|
|
59
59
|
* This source code is licensed under the ISC license.
|
|
60
60
|
* See the LICENSE file in the root directory of this source tree.
|
|
61
|
-
*/const
|
|
61
|
+
*/const Te=[["path",{d:"M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8",key:"14sh0y"}],["path",{d:"M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z",key:"1970lx"}],["path",{d:"M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1",key:"l4dndm"}]],Ae=N("files",Te);/**
|
|
62
62
|
* @license lucide-react v1.7.0 - ISC
|
|
63
63
|
*
|
|
64
64
|
* This source code is licensed under the ISC license.
|
|
65
65
|
* See the LICENSE file in the root directory of this source tree.
|
|
66
|
-
*/const
|
|
66
|
+
*/const Pe=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],De=N("folder",Pe);/**
|
|
67
67
|
* @license lucide-react v1.7.0 - ISC
|
|
68
68
|
*
|
|
69
69
|
* This source code is licensed under the ISC license.
|
|
70
70
|
* See the LICENSE file in the root directory of this source tree.
|
|
71
|
-
*/const
|
|
71
|
+
*/const Ee=[["polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12",key:"o97t9d"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}]],_e=N("inbox",Ee);/**
|
|
72
72
|
* @license lucide-react v1.7.0 - ISC
|
|
73
73
|
*
|
|
74
74
|
* This source code is licensed under the ISC license.
|
|
75
75
|
* See the LICENSE file in the root directory of this source tree.
|
|
76
|
-
*/const
|
|
76
|
+
*/const Ie=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],re=N("play",Ie);/**
|
|
77
77
|
* @license lucide-react v1.7.0 - ISC
|
|
78
78
|
*
|
|
79
79
|
* This source code is licensed under the ISC license.
|
|
80
80
|
* See the LICENSE file in the root directory of this source tree.
|
|
81
|
-
*/const
|
|
81
|
+
*/const Ue=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],Oe=N("rotate-ccw",Ue);/**
|
|
82
82
|
* @license lucide-react v1.7.0 - ISC
|
|
83
83
|
*
|
|
84
84
|
* This source code is licensed under the ISC license.
|
|
85
85
|
* See the LICENSE file in the root directory of this source tree.
|
|
86
|
-
*/const
|
|
86
|
+
*/const Ge=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],Be=N("shield",Ge);/**
|
|
87
87
|
* @license lucide-react v1.7.0 - ISC
|
|
88
88
|
*
|
|
89
89
|
* This source code is licensed under the ISC license.
|
|
90
90
|
* See the LICENSE file in the root directory of this source tree.
|
|
91
|
-
*/const
|
|
91
|
+
*/const Ve=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],He=N("sparkles",Ve);/**
|
|
92
92
|
* @license lucide-react v1.7.0 - ISC
|
|
93
93
|
*
|
|
94
94
|
* This source code is licensed under the ISC license.
|
|
95
95
|
* See the LICENSE file in the root directory of this source tree.
|
|
96
|
-
*/const Be=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],Ve=N("shield",Be);/**
|
|
97
|
-
* @license lucide-react v1.7.0 - ISC
|
|
98
|
-
*
|
|
99
|
-
* This source code is licensed under the ISC license.
|
|
100
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
101
|
-
*/const He=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],Je=N("sparkles",He);/**
|
|
102
|
-
* @license lucide-react v1.7.0 - ISC
|
|
103
|
-
*
|
|
104
|
-
* This source code is licensed under the ISC license.
|
|
105
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
106
|
-
*/const qe=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],Ke=N("trash-2",qe);/**
|
|
107
|
-
* @license lucide-react v1.7.0 - ISC
|
|
108
|
-
*
|
|
109
|
-
* This source code is licensed under the ISC license.
|
|
110
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
111
|
-
*/const We=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],Ze=N("upload",We),X={phase:"idle",analysis:null,prepareResult:null,finalizeResult:null,error:null,loading:!1};function Xe(){var n;const[s,t]=p.useState(X),r=p.useCallback(async(i,h,m="snippet")=>{t(c=>({...c,phase:"analyzing",loading:!0,error:null}));try{const x=new Promise((b,l)=>setTimeout(()=>l(new Error("Analysis timed out after 30s. Please try again.")),3e4)),u=await Promise.race([v.translationCreateJob(i,h,m),x]);t({phase:"prepared",analysis:u.analysis,prepareResult:u,finalizeResult:null,error:null,loading:!1})}catch(c){t(x=>({...x,phase:"error",error:c instanceof Error?c.message:"Analysis failed",loading:!1}))}},[]),o=p.useCallback(async i=>{var m;const h=(m=s.prepareResult)==null?void 0:m.jobId;if(!h){t(c=>({...c,phase:"error",error:"No active job to finalize"}));return}t(c=>({...c,phase:"finalizing",loading:!0,error:null}));try{const c=await v.translationFinalize(h,i);t(x=>({...x,phase:"done",finalizeResult:c,loading:!1}))}catch(c){t(x=>({...x,phase:"error",error:c instanceof Error?c.message:"Finalize failed",loading:!1}))}},[(n=s.prepareResult)==null?void 0:n.jobId]),a=p.useCallback(()=>{t(X)},[]);return[s,{analyze:r,finalize:o,reset:a}]}function Qe(){const[s,t]=p.useState([]),[r,o]=p.useState(null),[a,n]=p.useState(!0),[i,h]=p.useState(null),m=p.useCallback(async()=>{n(!0),h(null);try{const[x,u]=await Promise.all([v.translationListJobs(),v.translationStats()]);t(x.jobs),o(u)}catch(x){h(x instanceof Error?x.message:"Failed to load history")}finally{n(!1)}},[]),c=p.useCallback(async x=>{try{await v.translationDeleteJob(x),t(b=>b.filter(l=>l.id!==x));const u=await v.translationStats();o(u)}catch(u){h(u instanceof Error?u.message:"Delete failed")}},[]);return p.useEffect(()=>{m()},[m]),[{jobs:s,stats:r,loading:a,error:i},{refresh:m,deleteJob:c}]}const Q={mode:"idle",project:null,files:[],summary:null,selectedFileId:null,error:null,loading:!1};function Ye(){var b;const[s,t]=p.useState(Q),r=p.useRef(null),o=p.useCallback(async(l,d,g)=>{t(f=>({...f,mode:"uploading",loading:!0,error:null}));try{const f=await v.translationUploadProject(l,d,g);r.current=f.project.id,t({mode:"ready",project:f.project,files:f.files,summary:null,selectedFileId:null,error:null,loading:!1})}catch(f){t(y=>({...y,mode:"error",error:f instanceof Error?f.message:"Upload failed",loading:!1}))}},[]),a=p.useCallback(async l=>{t(d=>({...d,loading:!0,error:null}));try{const d=await v.translationGetProject(l);r.current=d.project.id,t({mode:"ready",project:d.project,files:d.files,summary:null,selectedFileId:null,error:null,loading:!1})}catch(d){t(g=>({...g,mode:"error",error:d instanceof Error?d.message:"Failed to load project",loading:!1}))}},[]),n=p.useCallback(l=>{t(d=>({...d,selectedFileId:l}))},[]),i=p.useCallback(async l=>{const d=r.current;if(!d){t(g=>({...g,mode:"error",error:"No active project"}));return}t(g=>({...g,loading:!0,error:null}));try{await v.translationPrepareFiles(d,l);const g=await v.translationGetProject(d);t(f=>({...f,project:g.project,files:g.files,loading:!1}))}catch(g){t(f=>({...f,error:g instanceof Error?g.message:"Prepare failed",loading:!1}))}},[]),h=p.useCallback(async(l,d)=>{const g=r.current;if(!g){t(f=>({...f,mode:"error",error:"No active project"}));return}t(f=>({...f,loading:!0,error:null}));try{await v.translationFinalizeFile(g,l,d);const f=await v.translationGetProject(g);t(y=>({...y,project:f.project,files:f.files,loading:!1}))}catch(f){t(y=>({...y,error:f instanceof Error?f.message:"Finalize failed",loading:!1}))}},[]),m=p.useCallback(async()=>{var d;const l=r.current;if(!l){t(g=>({...g,mode:"error",error:"No active project"}));return}t(g=>({...g,loading:!0,error:null}));try{const g=await v.translationDownloadProject(l),f=(d=s.project)!=null&&d.name?`${s.project.name}-translated.zip`:"translated-project.zip",y=URL.createObjectURL(g),C=document.createElement("a");C.href=y,C.download=f,C.click(),URL.revokeObjectURL(y),t(k=>({...k,loading:!1}))}catch(g){t(f=>({...f,error:g instanceof Error?g.message:"Download failed",loading:!1}))}},[(b=s.project)==null?void 0:b.name]),c=p.useCallback(async l=>{const d=r.current;if(!d){t(g=>({...g,mode:"error",error:"No active project"}));return}t(g=>({...g,loading:!0,error:null}));try{const g=await v.translationDownloadFile(d,l),f=s.files.find(M=>M.id===l),y=f!=null&&f.filePath?f.filePath.split("/").pop()??"translated-file":"translated-file",C=URL.createObjectURL(g),k=document.createElement("a");k.href=C,k.download=y,k.click(),URL.revokeObjectURL(C),t(M=>({...M,loading:!1}))}catch(g){t(f=>({...f,error:g instanceof Error?g.message:"File download failed",loading:!1}))}},[s.files]),x=p.useCallback(async()=>{const l=r.current;if(!l){t(d=>({...d,mode:"error",error:"No active project"}));return}t(d=>({...d,loading:!0,error:null}));try{const d=await v.translationProjectSummary(l);t(g=>({...g,summary:d,loading:!1}))}catch(d){t(g=>({...g,error:d instanceof Error?d.message:"Failed to refresh summary",loading:!1}))}},[]),u=p.useCallback(()=>{r.current=null,t(Q)},[]);return[s,{upload:o,loadProject:a,selectFile:n,prepareFiles:i,finalizeFile:h,downloadProject:m,downloadFile:c,refreshSummary:x,reset:u}]}const et=["python","javascript","typescript","java","csharp","go","rust","ruby","php","swift","kotlin","scala","cpp"];function tt({sourceCode:s,setSourceCode:t,targetLanguage:r,setTargetLanguage:o,generatedCode:a,setGeneratedCode:n,translation:i,onAnalyze:h,onFinalize:m,onReset:c}){var M,T,L;const{phase:x,prepareResult:u,error:b,loading:l}=i,d=x==="idle"||x==="error",g=x==="prepared",f=x==="done",[y,C]=p.useState(!1),k=()=>{u!=null&&u.prompt&&(navigator.clipboard.writeText(u.prompt),C(!0),setTimeout(()=>C(!1),2e3))};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-lg border border-edge bg-surface-alt",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-edge",children:[e.jsx("h3",{className:"text-xs font-semibold text-foreground",children:"Source Code"}),e.jsx("p",{className:"text-[10px] text-muted mt-0.5",children:"Paste the code you want to translate"})]}),e.jsxs("div",{className:"p-4 relative",children:[!d&&!g&&!f&&e.jsx("div",{className:"absolute inset-0 bg-surface/20 backdrop-blur-[1px] rounded-lg z-10 pointer-events-none"}),e.jsx("textarea",{value:s,onChange:w=>t(w.target.value),placeholder:"// Paste your code here...",rows:10,disabled:!d,className:"w-full px-3 py-2 text-xs rounded-md border border-edge bg-surface text-foreground placeholder:text-muted focus:outline-none focus:ring-1 focus:ring-accent font-mono disabled:opacity-60 disabled:cursor-not-allowed disabled:bg-surface/50"}),e.jsxs("div",{className:"flex items-center gap-3 mt-3",children:[e.jsxs("div",{className:"flex-1 grid grid-cols-3 gap-3",children:[(M=i.analysis)!=null&&M.detectedLanguage?e.jsxs("div",{className:"px-3 py-1.5 text-xs rounded-md border border-edge bg-surface/50 text-muted flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[10px] text-muted/70",children:"from:"}),e.jsx("span",{className:"text-foreground font-medium",children:i.analysis.detectedLanguage})]}):e.jsx("div",{className:"px-3 py-1.5 text-xs rounded-md border border-edge/50 bg-surface/30 text-muted/50 flex items-center gap-1.5",children:e.jsx("span",{className:"text-[10px]",children:"from: auto-detect"})}),e.jsx("select",{value:r,onChange:w=>o(w.target.value),disabled:!d,className:"px-3 py-1.5 text-xs rounded-md border border-edge bg-surface text-foreground focus:outline-none focus:ring-1 focus:ring-accent disabled:opacity-50",children:et.map(w=>e.jsx("option",{value:w,children:w},w))})]}),d&&e.jsxs("button",{onClick:h,disabled:!s.trim()||l,className:"flex items-center gap-1.5 px-4 py-1.5 text-xs font-medium rounded-md bg-accent text-white hover:opacity-90 disabled:opacity-50 transition-opacity",children:[l?e.jsx(z,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(re,{className:"w-3.5 h-3.5"}),l?"Analyzing...":"Analyze"]}),(g||f)&&e.jsxs("button",{onClick:c,className:"flex items-center gap-1.5 px-4 py-1.5 text-xs font-medium rounded-md border border-edge text-muted hover:text-foreground transition-colors",children:[e.jsx(Ge,{className:"w-3.5 h-3.5"}),"New"]}),f&&((L=(T=i.finalizeResult)==null?void 0:T.job)==null?void 0:L.targetCode)&&e.jsxs("button",{onClick:()=>{var j,P;const w=(P=(j=i.finalizeResult)==null?void 0:j.job)==null?void 0:P.targetCode;if(!w)return;const I=new Blob([w],{type:"text/plain"}),A=URL.createObjectURL(I),$=document.createElement("a");$.href=A,$.download="translated.txt",$.click(),URL.revokeObjectURL(A)},className:"flex items-center gap-1.5 px-3 py-1.5 rounded-md border border-green-500/30 text-green-500 text-xs font-medium hover:bg-green-500/5 transition-colors",children:[e.jsx(_,{className:"w-3 h-3"}),"Download"]})]})]})]}),b&&e.jsx("div",{className:"px-4 py-3 rounded-lg border border-red-500/30 bg-red-500/5 text-xs text-red-400",children:b}),g&&u&&e.jsxs("div",{className:"rounded-lg border border-edge bg-surface-alt",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-edge flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-semibold text-foreground",children:"AI Prompt"}),e.jsx("p",{className:"text-[10px] text-muted mt-0.5",children:"Copy this prompt, generate the code with AI, then paste the result below"})]}),e.jsxs("button",{onClick:k,className:`flex items-center gap-1 px-2 py-1 text-[10px] rounded border transition-all duration-200 ${y?"border-green-500/30 text-green-500 bg-green-500/5":"border-edge text-muted hover:text-foreground"}`,children:[y?e.jsx(D,{className:"w-3 h-3"}):e.jsx(W,{className:"w-3 h-3"}),y?"Copied!":"Copy"]})]}),e.jsxs("div",{className:"p-4 space-y-3",children:[e.jsx("pre",{className:"text-[10px] p-3 rounded-md bg-surface border border-edge max-h-48 overflow-auto whitespace-pre-wrap text-muted font-mono",children:u.prompt.length>3e3?u.prompt.slice(0,3e3)+`
|
|
96
|
+
*/const Je=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],Ke=N("trash-2",Je),X={phase:"idle",analysis:null,prepareResult:null,finalizeResult:null,error:null,loading:!1};function We(){var n;const[s,t]=p.useState(X),r=p.useCallback(async(i,h,m="snippet")=>{t(c=>({...c,phase:"analyzing",loading:!0,error:null}));try{const x=new Promise((b,l)=>setTimeout(()=>l(new Error("Analysis timed out after 30s. Please try again.")),3e4)),u=await Promise.race([v.translationCreateJob(i,h,m),x]);t({phase:"prepared",analysis:u.analysis,prepareResult:u,finalizeResult:null,error:null,loading:!1})}catch(c){t(x=>({...x,phase:"error",error:c instanceof Error?c.message:"Analysis failed",loading:!1}))}},[]),o=p.useCallback(async i=>{var m;const h=(m=s.prepareResult)==null?void 0:m.jobId;if(!h){t(c=>({...c,phase:"error",error:"No active job to finalize"}));return}t(c=>({...c,phase:"finalizing",loading:!0,error:null}));try{const c=await v.translationFinalize(h,i);t(x=>({...x,phase:"done",finalizeResult:c,loading:!1}))}catch(c){t(x=>({...x,phase:"error",error:c instanceof Error?c.message:"Finalize failed",loading:!1}))}},[(n=s.prepareResult)==null?void 0:n.jobId]),a=p.useCallback(()=>{t(X)},[]);return[s,{analyze:r,finalize:o,reset:a}]}function qe(){const[s,t]=p.useState([]),[r,o]=p.useState(null),[a,n]=p.useState(!0),[i,h]=p.useState(null),m=p.useCallback(async()=>{n(!0),h(null);try{const[x,u]=await Promise.all([v.translationListJobs(),v.translationStats()]);t(x.jobs),o(u)}catch(x){h(x instanceof Error?x.message:"Failed to load history")}finally{n(!1)}},[]),c=p.useCallback(async x=>{try{await v.translationDeleteJob(x),t(b=>b.filter(l=>l.id!==x));const u=await v.translationStats();o(u)}catch(u){h(u instanceof Error?u.message:"Delete failed")}},[]);return p.useEffect(()=>{m()},[m]),[{jobs:s,stats:r,loading:a,error:i},{refresh:m,deleteJob:c}]}const Q={mode:"idle",project:null,files:[],summary:null,selectedFileId:null,error:null,loading:!1};function Ze(){var b;const[s,t]=p.useState(Q),r=p.useRef(null),o=p.useCallback(async(l,d,g)=>{t(f=>({...f,mode:"uploading",loading:!0,error:null}));try{const f=await v.translationUploadProject(l,d,g);r.current=f.project.id,t({mode:"ready",project:f.project,files:f.files,summary:null,selectedFileId:null,error:null,loading:!1})}catch(f){t(y=>({...y,mode:"error",error:f instanceof Error?f.message:"Upload failed",loading:!1}))}},[]),a=p.useCallback(async l=>{t(d=>({...d,loading:!0,error:null}));try{const d=await v.translationGetProject(l);r.current=d.project.id,t({mode:"ready",project:d.project,files:d.files,summary:null,selectedFileId:null,error:null,loading:!1})}catch(d){t(g=>({...g,mode:"error",error:d instanceof Error?d.message:"Failed to load project",loading:!1}))}},[]),n=p.useCallback(l=>{t(d=>({...d,selectedFileId:l}))},[]),i=p.useCallback(async l=>{const d=r.current;if(!d){t(g=>({...g,mode:"error",error:"No active project"}));return}t(g=>({...g,loading:!0,error:null}));try{await v.translationPrepareFiles(d,l);const g=await v.translationGetProject(d);t(f=>({...f,project:g.project,files:g.files,loading:!1}))}catch(g){t(f=>({...f,error:g instanceof Error?g.message:"Prepare failed",loading:!1}))}},[]),h=p.useCallback(async(l,d)=>{const g=r.current;if(!g){t(f=>({...f,mode:"error",error:"No active project"}));return}t(f=>({...f,loading:!0,error:null}));try{await v.translationFinalizeFile(g,l,d);const f=await v.translationGetProject(g);t(y=>({...y,project:f.project,files:f.files,loading:!1}))}catch(f){t(y=>({...y,error:f instanceof Error?f.message:"Finalize failed",loading:!1}))}},[]),m=p.useCallback(async()=>{var d;const l=r.current;if(!l){t(g=>({...g,mode:"error",error:"No active project"}));return}t(g=>({...g,loading:!0,error:null}));try{const g=await v.translationDownloadProject(l),f=(d=s.project)!=null&&d.name?`${s.project.name}-translated.zip`:"translated-project.zip",y=URL.createObjectURL(g),C=document.createElement("a");C.href=y,C.download=f,C.click(),URL.revokeObjectURL(y),t(k=>({...k,loading:!1}))}catch(g){t(f=>({...f,error:g instanceof Error?g.message:"Download failed",loading:!1}))}},[(b=s.project)==null?void 0:b.name]),c=p.useCallback(async l=>{const d=r.current;if(!d){t(g=>({...g,mode:"error",error:"No active project"}));return}t(g=>({...g,loading:!0,error:null}));try{const g=await v.translationDownloadFile(d,l),f=s.files.find(M=>M.id===l),y=f!=null&&f.filePath?f.filePath.split("/").pop()??"translated-file":"translated-file",C=URL.createObjectURL(g),k=document.createElement("a");k.href=C,k.download=y,k.click(),URL.revokeObjectURL(C),t(M=>({...M,loading:!1}))}catch(g){t(f=>({...f,error:g instanceof Error?g.message:"File download failed",loading:!1}))}},[s.files]),x=p.useCallback(async()=>{const l=r.current;if(!l){t(d=>({...d,mode:"error",error:"No active project"}));return}t(d=>({...d,loading:!0,error:null}));try{const d=await v.translationProjectSummary(l);t(g=>({...g,summary:d,loading:!1}))}catch(d){t(g=>({...g,error:d instanceof Error?d.message:"Failed to refresh summary",loading:!1}))}},[]),u=p.useCallback(()=>{r.current=null,t(Q)},[]);return[s,{upload:o,loadProject:a,selectFile:n,prepareFiles:i,finalizeFile:h,downloadProject:m,downloadFile:c,refreshSummary:x,reset:u}]}const Xe=["python","javascript","typescript","java","csharp","go","rust","ruby","php","swift","kotlin","scala","cpp"];function Qe({sourceCode:s,setSourceCode:t,targetLanguage:r,setTargetLanguage:o,generatedCode:a,setGeneratedCode:n,translation:i,onAnalyze:h,onFinalize:m,onReset:c}){var M,T,L;const{phase:x,prepareResult:u,error:b,loading:l}=i,d=x==="idle"||x==="error",g=x==="prepared",f=x==="done",[y,C]=p.useState(!1),k=()=>{u!=null&&u.prompt&&(navigator.clipboard.writeText(u.prompt),C(!0),setTimeout(()=>C(!1),2e3))};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-lg border border-edge bg-surface-alt",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-edge",children:[e.jsx("h3",{className:"text-xs font-semibold text-foreground",children:"Source Code"}),e.jsx("p",{className:"text-[10px] text-muted mt-0.5",children:"Paste the code you want to translate"})]}),e.jsxs("div",{className:"p-4 relative",children:[!d&&!g&&!f&&e.jsx("div",{className:"absolute inset-0 bg-surface/20 backdrop-blur-[1px] rounded-lg z-10 pointer-events-none"}),e.jsx("textarea",{value:s,onChange:w=>t(w.target.value),placeholder:"// Paste your code here...",rows:10,disabled:!d,className:"w-full px-3 py-2 text-xs rounded-md border border-edge bg-surface text-foreground placeholder:text-muted focus:outline-none focus:ring-1 focus:ring-accent font-mono disabled:opacity-60 disabled:cursor-not-allowed disabled:bg-surface/50"}),e.jsxs("div",{className:"flex items-center gap-3 mt-3",children:[e.jsxs("div",{className:"flex-1 grid grid-cols-3 gap-3",children:[(M=i.analysis)!=null&&M.detectedLanguage?e.jsxs("div",{className:"px-3 py-1.5 text-xs rounded-md border border-edge bg-surface/50 text-muted flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[10px] text-muted/70",children:"from:"}),e.jsx("span",{className:"text-foreground font-medium",children:i.analysis.detectedLanguage})]}):e.jsx("div",{className:"px-3 py-1.5 text-xs rounded-md border border-edge/50 bg-surface/30 text-muted/50 flex items-center gap-1.5",children:e.jsx("span",{className:"text-[10px]",children:"from: auto-detect"})}),e.jsx("select",{value:r,onChange:w=>o(w.target.value),disabled:!d,className:"px-3 py-1.5 text-xs rounded-md border border-edge bg-surface text-foreground focus:outline-none focus:ring-1 focus:ring-accent disabled:opacity-50",children:Xe.map(w=>e.jsx("option",{value:w,children:w},w))})]}),d&&e.jsxs("button",{onClick:h,disabled:!s.trim()||l,className:"flex items-center gap-1.5 px-4 py-1.5 text-xs font-medium rounded-md bg-accent text-white hover:opacity-90 disabled:opacity-50 transition-opacity",children:[l?e.jsx($,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(re,{className:"w-3.5 h-3.5"}),l?"Analyzing...":"Analyze"]}),(g||f)&&e.jsxs("button",{onClick:c,className:"flex items-center gap-1.5 px-4 py-1.5 text-xs font-medium rounded-md border border-edge text-muted hover:text-foreground transition-colors",children:[e.jsx(Oe,{className:"w-3.5 h-3.5"}),"New"]}),f&&((L=(T=i.finalizeResult)==null?void 0:T.job)==null?void 0:L.targetCode)&&e.jsxs("button",{onClick:()=>{var j,P;const w=(P=(j=i.finalizeResult)==null?void 0:j.job)==null?void 0:P.targetCode;if(!w)return;const I=new Blob([w],{type:"text/plain"}),A=URL.createObjectURL(I),R=document.createElement("a");R.href=A,R.download="translated.txt",R.click(),URL.revokeObjectURL(A)},className:"flex items-center gap-1.5 px-3 py-1.5 rounded-md border border-green-500/30 text-green-500 text-xs font-medium hover:bg-green-500/5 transition-colors",children:[e.jsx(E,{className:"w-3 h-3"}),"Download"]})]})]})]}),b&&e.jsx("div",{className:"px-4 py-3 rounded-lg border border-red-500/30 bg-red-500/5 text-xs text-red-400",children:b}),g&&u&&e.jsxs("div",{className:"rounded-lg border border-edge bg-surface-alt",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-edge flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-semibold text-foreground",children:"AI Prompt"}),e.jsx("p",{className:"text-[10px] text-muted mt-0.5",children:"Copy this prompt, generate the code with AI, then paste the result below"})]}),e.jsxs("button",{onClick:k,className:`flex items-center gap-1 px-2 py-1 text-[10px] rounded border transition-all duration-200 ${y?"border-green-500/30 text-green-500 bg-green-500/5":"border-edge text-muted hover:text-foreground"}`,children:[y?e.jsx(D,{className:"w-3 h-3"}):e.jsx(q,{className:"w-3 h-3"}),y?"Copied!":"Copy"]})]}),e.jsxs("div",{className:"p-4 space-y-3",children:[e.jsx("pre",{className:"text-[10px] p-3 rounded-md bg-surface border border-edge max-h-48 overflow-auto whitespace-pre-wrap text-muted font-mono",children:u.prompt.length>3e3?u.prompt.slice(0,3e3)+`
|
|
112
97
|
|
|
113
|
-
... (truncated, use Copy for full prompt)`:u.prompt}),e.jsx("textarea",{value:a,onChange:w=>n(w.target.value),placeholder:"// Paste the AI-generated code here...",rows:8,className:"w-full px-3 py-2 text-xs rounded-md border border-edge bg-surface text-foreground placeholder:text-muted focus:outline-none focus:ring-1 focus:ring-accent font-mono"}),e.jsxs("button",{onClick:m,disabled:!a.trim()||l,className:"flex items-center gap-1.5 px-4 py-1.5 text-xs font-medium rounded-md bg-green-600 text-white hover:opacity-90 disabled:opacity-50 transition-opacity",children:[l?e.jsx(z,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(be,{className:"w-3.5 h-3.5"}),l?"Finalizing...":"Finalize Translation"]})]})]})]})}function st(s){const t=s.totalConstructs;if(t===0)return{percentage:100,ruleCount:0,aiCount:0,total:0,aiConstructs:[]};const r=s.ambiguousConstructs??[],o=r.length,n=s.constructs.map(h=>h.canonicalName).filter(h=>!r.includes(h)).length,i=t>0?Math.round((t-o)/t*100):100;return{percentage:Math.min(100,Math.max(0,i)),ruleCount:n,aiCount:o,total:t,aiConstructs:r}}function at(s){return s>=90?{border:"border-green-500/30",bg:"bg-green-500/5",text:"text-green-500",bar:"bg-green-500"}:s>=50?{border:"border-yellow-500/30",bg:"bg-yellow-500/5",text:"text-yellow-500",bar:"bg-yellow-500"}:{border:"border-red-500/30",bg:"bg-red-500/5",text:"text-red-500",bar:"bg-red-500"}}function E({analysis:s,deterministicPct:t,totalConstructs:r,isProjectLevel:o,onDownload:a,aiPrompt:n}){const[i,h]=p.useState(!1),m=s?st(s):{percentage:t??0,ruleCount:Math.round((t??0)/100*(r??0)),aiCount:Math.round((100-(t??0))/100*(r??0)),total:r??0,aiConstructs:[]},c=at(m.percentage),x=m.percentage===100,u=100-m.percentage,b=p.useCallback(()=>{n&&navigator.clipboard.writeText(n).then(()=>{h(!0),setTimeout(()=>h(!1),2e3)})},[n]);return m.total===0&&!t?null:e.jsxs("div",{className:`rounded-lg border ${c.border} ${c.bg} p-4 space-y-3`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:`text-3xl font-bold ${c.text}`,children:[m.percentage,"%"]}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-xs font-semibold text-foreground",children:[o?"Project ":"","Deterministic Translation"]}),e.jsxs("p",{className:"text-[10px] text-muted",children:[m.ruleCount,"/",m.total," constructs by rules",m.aiCount>0&&` · ${m.aiCount} need AI`]})]})]}),x&&e.jsxs("span",{className:"flex items-center gap-1 px-2 py-1 rounded-md bg-green-500/10 text-green-500 text-[10px] font-medium",children:[e.jsx(ae,{className:"w-3 h-3"}),"No AI Required"]})]}),e.jsxs("div",{className:"h-2.5 rounded-full bg-surface overflow-hidden flex",role:"progressbar","aria-valuenow":m.percentage,"aria-valuemin":0,"aria-valuemax":100,"aria-label":`Deterministic translation: ${m.percentage}%`,children:[m.percentage>0&&e.jsx("div",{className:`h-full ${c.bar} transition-all duration-500`,style:{width:`${m.percentage}%`}}),u>0&&e.jsx("div",{className:"h-full bg-yellow-500/60 transition-all duration-500",style:{width:`${u}%`}})]}),e.jsxs("div",{className:"flex items-center gap-4 text-[10px]",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:`w-2 h-2 rounded-full ${c.bar}`}),e.jsxs("span",{className:"text-muted",children:["Rule-based (",m.ruleCount,")"]})]}),m.aiCount>0&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-yellow-500/60"}),e.jsxs("span",{className:"text-muted",children:["AI-assisted (",m.aiCount,")"]})]})]}),m.aiConstructs.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:m.aiConstructs.map(l=>e.jsxs("span",{className:"flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded border border-yellow-500/30 bg-yellow-500/5 text-yellow-500",children:[e.jsx(Je,{className:"w-2.5 h-2.5"}),l]},l))}),e.jsx("div",{className:"flex items-center gap-2 pt-1",children:x&&a?e.jsxs("button",{onClick:a,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-md bg-green-600 text-white text-xs font-medium hover:bg-green-700 transition-colors w-full justify-center",children:[e.jsx(_,{className:"w-3.5 h-3.5"}),"Ready to Download"]}):e.jsxs(e.Fragment,{children:[n&&e.jsxs("button",{onClick:b,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-md bg-accent/10 text-accent text-xs font-medium hover:bg-accent/20 transition-colors",children:[i?e.jsx(D,{className:"w-3.5 h-3.5"}):e.jsx(W,{className:"w-3.5 h-3.5"}),i?"Copied!":`Copy AI Prompt for ${m.aiCount} construct${m.aiCount!==1?"s":""}`]}),a&&e.jsxs("button",{onClick:a,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-md border border-edge text-foreground text-xs font-medium hover:bg-surface transition-colors",children:[e.jsx(_,{className:"w-3.5 h-3.5"}),"Download Partial"]})]})})]})}const rt={python:".py",typescript:".ts",javascript:".js",java:".java",go:".go",rust:".rs",csharp:".cs",ruby:".rb",php:".php",swift:".swift",kotlin:".kt",scala:".scala",cpp:".cpp",lua:".lua",dart:".dart",elixir:".ex",haskell:".hs"};function Y({value:s,max:t=100,label:r}){const o=Math.min(100,Math.round(s/t*100)),a=o>=80?"bg-green-500":o>=50?"bg-yellow-500":"bg-red-500";return e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex justify-between text-[10px]",children:[e.jsx("span",{className:"text-muted",children:r}),e.jsxs("span",{className:"text-foreground font-medium",children:[o,"%"]})]}),e.jsx("div",{className:"h-1.5 rounded-full bg-surface overflow-hidden",role:"progressbar","aria-valuenow":o,"aria-valuemin":0,"aria-valuemax":100,"aria-label":`${r}: ${o}%`,children:e.jsx("div",{className:`h-full rounded-full ${a} transition-all duration-500`,style:{width:`${o}%`}})})]})}function ne({analysis:s,deterministicCode:t,targetLanguage:r}){return s?e.jsxs("div",{className:"rounded-lg border border-edge bg-surface-alt",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-edge flex items-center gap-2",children:[e.jsx(Se,{className:"w-3.5 h-3.5 text-accent"}),e.jsx("h3",{className:"text-xs font-semibold text-foreground",children:"Analysis Results"})]}),e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"px-2 py-0.5 text-[10px] font-medium rounded bg-accent/10 text-accent",children:s.detectedLanguage}),s.detectedConfidence!=null&&e.jsxs("span",{className:"text-[10px] text-muted",children:[Math.round(s.detectedConfidence*100),"% confidence"]}),e.jsxs("span",{className:"text-[10px] text-muted",children:[s.totalConstructs," constructs detected"]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(Y,{value:s.complexityScore,label:"Complexity"}),e.jsx(Y,{value:s.estimatedTranslatability,label:"Translatability"})]}),s.constructs.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] text-muted mb-2",children:"Detected Constructs"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.constructs.map(o=>e.jsxs("span",{className:"px-1.5 py-0.5 text-[10px] rounded border border-edge bg-surface text-foreground",title:`count: ${o.count}, confidence: ${Math.round(o.confidence*100)}%`,children:[o.canonicalName," ",e.jsxs("span",{className:"text-muted",children:["x",o.count]})]},o.canonicalName))})]}),e.jsx(E,{analysis:s,onDownload:t?()=>{const o=new Blob([t],{type:"text/plain"}),a=URL.createObjectURL(o),n=document.createElement("a");n.href=a;const i=r?rt[r]??".txt":".txt";n.download=`translated${i}`,n.click(),URL.revokeObjectURL(a)}:void 0}),s.ambiguousConstructs&&s.ambiguousConstructs.length>0&&e.jsxs("div",{className:"flex items-start gap-2 px-3 py-2 rounded-md border border-yellow-500/30 bg-yellow-500/5",children:[e.jsx(J,{className:"w-3.5 h-3.5 text-yellow-500 mt-0.5 shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-medium text-yellow-500",children:"Ambiguous Constructs"}),e.jsx("p",{className:"text-[10px] text-muted mt-0.5",children:s.ambiguousConstructs.join(", ")})]})]})]})]}):null}function nt({score:s}){const t=Math.round(s*100),r=t>=80?"bg-green-500/10 text-green-500":t>=50?"bg-yellow-500/10 text-yellow-500":"bg-red-500/10 text-red-500";return e.jsxs("span",{className:`px-2 py-0.5 text-xs font-semibold rounded ${r}`,children:[t,"%"]})}const lt={high:"bg-red-500/10 text-red-500",medium:"bg-yellow-500/10 text-yellow-500",low:"bg-blue-500/10 text-blue-500"};function ot({result:s}){if(!s)return null;const{evidence:t}=s;return e.jsxs("div",{className:"rounded-lg border border-green-500/30 bg-surface-alt",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-edge flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ve,{className:"w-3.5 h-3.5 text-green-500"}),e.jsx("h3",{className:"text-xs font-semibold text-foreground",children:"Translation Evidence"})]}),e.jsx(nt,{score:t.confidenceScore})]}),e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsx(E,{deterministicPct:Math.round(t.confidenceScore*100),totalConstructs:t.translatedConstructs.length+t.risks.length}),t.translatedConstructs.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[e.jsx(Te,{className:"w-3 h-3 text-muted"}),e.jsx("p",{className:"text-[10px] text-muted font-medium",children:"Translated Constructs"})]}),e.jsxs("table",{className:"w-full text-[10px]",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-edge",children:[e.jsx("th",{className:"text-left px-2 py-1 font-medium text-muted",children:"Source"}),e.jsx("th",{className:"text-left px-2 py-1 font-medium text-muted",children:"Target"}),e.jsx("th",{className:"text-left px-2 py-1 font-medium text-muted",children:"Method"})]})}),e.jsx("tbody",{children:t.translatedConstructs.map((r,o)=>e.jsxs("tr",{className:"border-b border-edge/50",children:[e.jsx("td",{className:"px-2 py-1 font-mono text-foreground",children:r.source}),e.jsx("td",{className:"px-2 py-1 font-mono text-accent",children:r.target}),e.jsx("td",{className:"px-2 py-1 text-muted",children:r.method})]},o))})]})]}),t.risks.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[e.jsx(J,{className:"w-3 h-3 text-yellow-500"}),e.jsxs("p",{className:"text-[10px] text-muted font-medium",children:["Risks (",t.risks.length,")"]})]}),e.jsx("div",{className:"space-y-1.5",children:t.risks.map((r,o)=>e.jsxs("div",{className:"flex items-start gap-2 px-2 py-1.5 rounded border border-edge/50 bg-surface",children:[e.jsx("span",{className:`shrink-0 px-1.5 py-0.5 rounded text-[10px] font-medium ${lt[r.severity]??"bg-surface text-muted"}`,children:r.severity}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] font-medium text-foreground",children:r.construct}),e.jsx("span",{className:"text-[10px] text-muted ml-1",children:r.message})]})]},o))})]}),t.humanReviewPoints.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[e.jsx($e,{className:"w-3 h-3 text-muted"}),e.jsx("p",{className:"text-[10px] text-muted font-medium",children:"Human Review Points"})]}),e.jsx("ul",{className:"space-y-1 text-[10px] text-muted list-disc list-inside",children:t.humanReviewPoints.map((r,o)=>e.jsx("li",{children:r},o))})]}),t.diff&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] text-muted font-medium mb-2",children:"Diff"}),e.jsx("pre",{className:"text-[10px] p-3 rounded-md bg-surface border border-edge max-h-64 overflow-auto whitespace-pre-wrap text-muted font-mono",children:t.diff})]})]})]})}const ct={pending:"bg-yellow-500/10 text-yellow-500",analyzing:"bg-blue-500/10 text-blue-500",translating:"bg-indigo-500/10 text-indigo-500",validating:"bg-purple-500/10 text-purple-500",done:"bg-green-500/10 text-green-500",failed:"bg-red-500/10 text-red-500"};function dt(s){const t=Date.now(),r=new Date(s).getTime(),o=t-r,a=Math.floor(o/6e4);if(a<1)return"just now";if(a<60)return`${a}m ago`;const n=Math.floor(a/60);if(n<24)return`${n}h ago`;const i=Math.floor(n/24);return i<7?`${i}d ago`:new Date(s).toLocaleDateString()}function R({label:s,value:t,accent:r}){return e.jsxs("div",{className:"rounded-lg border border-edge bg-surface-alt px-4 py-3",children:[e.jsx("p",{className:"text-[10px] text-muted",children:s}),e.jsx("p",{className:`text-lg font-semibold ${r??"text-foreground"}`,children:t})]})}function U(){return e.jsx("tr",{className:"border-b border-edge/50",children:Array.from({length:7}).map((s,t)=>e.jsx("td",{className:"px-4 py-2",children:e.jsx("div",{className:"h-3 rounded bg-surface animate-pulse",style:{width:`${40+Math.random()*40}%`}})},t))})}function it({job:s}){return e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:"px-4 py-3 bg-surface/50",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[s.sourceCode&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-medium text-muted mb-1",children:"Source Code"}),e.jsxs("pre",{className:"text-[10px] p-2 rounded-md bg-surface border border-edge max-h-40 overflow-auto whitespace-pre-wrap font-mono text-foreground",children:[s.sourceCode.slice(0,500),s.sourceCode.length>500?`
|
|
98
|
+
... (truncated, use Copy for full prompt)`:u.prompt}),e.jsx("textarea",{value:a,onChange:w=>n(w.target.value),placeholder:"// Paste the AI-generated code here...",rows:8,className:"w-full px-3 py-2 text-xs rounded-md border border-edge bg-surface text-foreground placeholder:text-muted focus:outline-none focus:ring-1 focus:ring-accent font-mono"}),e.jsxs("button",{onClick:m,disabled:!a.trim()||l,className:"flex items-center gap-1.5 px-4 py-1.5 text-xs font-medium rounded-md bg-green-600 text-white hover:opacity-90 disabled:opacity-50 transition-opacity",children:[l?e.jsx($,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(ue,{className:"w-3.5 h-3.5"}),l?"Finalizing...":"Finalize Translation"]})]})]})]})}function Ye(s){const t=s.totalConstructs;if(t===0)return{percentage:100,ruleCount:0,aiCount:0,total:0,aiConstructs:[]};const r=s.ambiguousConstructs??[],o=r.length,n=s.constructs.map(h=>h.canonicalName).filter(h=>!r.includes(h)).length,i=t>0?Math.round((t-o)/t*100):100;return{percentage:Math.min(100,Math.max(0,i)),ruleCount:n,aiCount:o,total:t,aiConstructs:r}}function et(s){return s>=90?{border:"border-green-500/30",bg:"bg-green-500/5",text:"text-green-500",bar:"bg-green-500"}:s>=50?{border:"border-yellow-500/30",bg:"bg-yellow-500/5",text:"text-yellow-500",bar:"bg-yellow-500"}:{border:"border-red-500/30",bg:"bg-red-500/5",text:"text-red-500",bar:"bg-red-500"}}function _({analysis:s,deterministicPct:t,totalConstructs:r,isProjectLevel:o,onDownload:a,aiPrompt:n}){const[i,h]=p.useState(!1),m=s?Ye(s):{percentage:t??0,ruleCount:Math.round((t??0)/100*(r??0)),aiCount:Math.round((100-(t??0))/100*(r??0)),total:r??0,aiConstructs:[]},c=et(m.percentage),x=m.percentage===100,u=100-m.percentage,b=p.useCallback(()=>{n&&navigator.clipboard.writeText(n).then(()=>{h(!0),setTimeout(()=>h(!1),2e3)})},[n]);return m.total===0&&!t?null:e.jsxs("div",{className:`rounded-lg border ${c.border} ${c.bg} p-4 space-y-3`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:`text-3xl font-bold ${c.text}`,children:[m.percentage,"%"]}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-xs font-semibold text-foreground",children:[o?"Project ":"","Deterministic Translation"]}),e.jsxs("p",{className:"text-[10px] text-muted",children:[m.ruleCount,"/",m.total," constructs by rules",m.aiCount>0&&` · ${m.aiCount} need AI`]})]})]}),x&&e.jsxs("span",{className:"flex items-center gap-1 px-2 py-1 rounded-md bg-green-500/10 text-green-500 text-[10px] font-medium",children:[e.jsx(ae,{className:"w-3 h-3"}),"No AI Required"]})]}),e.jsxs("div",{className:"h-2.5 rounded-full bg-surface overflow-hidden flex",role:"progressbar","aria-valuenow":m.percentage,"aria-valuemin":0,"aria-valuemax":100,"aria-label":`Deterministic translation: ${m.percentage}%`,children:[m.percentage>0&&e.jsx("div",{className:`h-full ${c.bar} transition-all duration-500`,style:{width:`${m.percentage}%`}}),u>0&&e.jsx("div",{className:"h-full bg-yellow-500/60 transition-all duration-500",style:{width:`${u}%`}})]}),e.jsxs("div",{className:"flex items-center gap-4 text-[10px]",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:`w-2 h-2 rounded-full ${c.bar}`}),e.jsxs("span",{className:"text-muted",children:["Rule-based (",m.ruleCount,")"]})]}),m.aiCount>0&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-yellow-500/60"}),e.jsxs("span",{className:"text-muted",children:["AI-assisted (",m.aiCount,")"]})]})]}),m.aiConstructs.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:m.aiConstructs.map(l=>e.jsxs("span",{className:"flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded border border-yellow-500/30 bg-yellow-500/5 text-yellow-500",children:[e.jsx(He,{className:"w-2.5 h-2.5"}),l]},l))}),e.jsx("div",{className:"flex items-center gap-2 pt-1",children:x&&a?e.jsxs("button",{onClick:a,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-md bg-green-600 text-white text-xs font-medium hover:bg-green-700 transition-colors w-full justify-center",children:[e.jsx(E,{className:"w-3.5 h-3.5"}),"Ready to Download"]}):e.jsxs(e.Fragment,{children:[n&&e.jsxs("button",{onClick:b,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-md bg-accent/10 text-accent text-xs font-medium hover:bg-accent/20 transition-colors",children:[i?e.jsx(D,{className:"w-3.5 h-3.5"}):e.jsx(q,{className:"w-3.5 h-3.5"}),i?"Copied!":`Copy AI Prompt for ${m.aiCount} construct${m.aiCount!==1?"s":""}`]}),a&&e.jsxs("button",{onClick:a,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-md border border-edge text-foreground text-xs font-medium hover:bg-surface transition-colors",children:[e.jsx(E,{className:"w-3.5 h-3.5"}),"Download Partial"]})]})})]})}const tt={python:".py",typescript:".ts",javascript:".js",java:".java",go:".go",rust:".rs",csharp:".cs",ruby:".rb",php:".php",swift:".swift",kotlin:".kt",scala:".scala",cpp:".cpp",lua:".lua",dart:".dart",elixir:".ex",haskell:".hs"};function Y({value:s,max:t=100,label:r}){const o=Math.min(100,Math.round(s/t*100)),a=o>=80?"bg-green-500":o>=50?"bg-yellow-500":"bg-red-500";return e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex justify-between text-[10px]",children:[e.jsx("span",{className:"text-muted",children:r}),e.jsxs("span",{className:"text-foreground font-medium",children:[o,"%"]})]}),e.jsx("div",{className:"h-1.5 rounded-full bg-surface overflow-hidden",role:"progressbar","aria-valuenow":o,"aria-valuemin":0,"aria-valuemax":100,"aria-label":`${r}: ${o}%`,children:e.jsx("div",{className:`h-full rounded-full ${a} transition-all duration-500`,style:{width:`${o}%`}})})]})}function ne({analysis:s,deterministicCode:t,targetLanguage:r}){return s?e.jsxs("div",{className:"rounded-lg border border-edge bg-surface-alt",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-edge flex items-center gap-2",children:[e.jsx(ke,{className:"w-3.5 h-3.5 text-accent"}),e.jsx("h3",{className:"text-xs font-semibold text-foreground",children:"Analysis Results"})]}),e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"px-2 py-0.5 text-[10px] font-medium rounded bg-accent/10 text-accent",children:s.detectedLanguage}),s.detectedConfidence!=null&&e.jsxs("span",{className:"text-[10px] text-muted",children:[Math.round(s.detectedConfidence*100),"% confidence"]}),e.jsxs("span",{className:"text-[10px] text-muted",children:[s.totalConstructs," constructs detected"]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(Y,{value:s.complexityScore,label:"Complexity"}),e.jsx(Y,{value:s.estimatedTranslatability,label:"Translatability"})]}),s.constructs.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] text-muted mb-2",children:"Detected Constructs"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.constructs.map(o=>e.jsxs("span",{className:"px-1.5 py-0.5 text-[10px] rounded border border-edge bg-surface text-foreground",title:`count: ${o.count}, confidence: ${Math.round(o.confidence*100)}%`,children:[o.canonicalName," ",e.jsxs("span",{className:"text-muted",children:["x",o.count]})]},o.canonicalName))})]}),e.jsx(_,{analysis:s,onDownload:t?()=>{const o=new Blob([t],{type:"text/plain"}),a=URL.createObjectURL(o),n=document.createElement("a");n.href=a;const i=r?tt[r]??".txt":".txt";n.download=`translated${i}`,n.click(),URL.revokeObjectURL(a)}:void 0}),s.ambiguousConstructs&&s.ambiguousConstructs.length>0&&e.jsxs("div",{className:"flex items-start gap-2 px-3 py-2 rounded-md border border-yellow-500/30 bg-yellow-500/5",children:[e.jsx(J,{className:"w-3.5 h-3.5 text-yellow-500 mt-0.5 shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-medium text-yellow-500",children:"Ambiguous Constructs"}),e.jsx("p",{className:"text-[10px] text-muted mt-0.5",children:s.ambiguousConstructs.join(", ")})]})]})]})]}):null}function st({score:s}){const t=Math.round(s*100),r=t>=80?"bg-green-500/10 text-green-500":t>=50?"bg-yellow-500/10 text-yellow-500":"bg-red-500/10 text-red-500";return e.jsxs("span",{className:`px-2 py-0.5 text-xs font-semibold rounded ${r}`,children:[t,"%"]})}const at={high:"bg-red-500/10 text-red-500",medium:"bg-yellow-500/10 text-yellow-500",low:"bg-blue-500/10 text-blue-500"};function rt({result:s}){if(!s)return null;const{evidence:t}=s;return e.jsxs("div",{className:"rounded-lg border border-green-500/30 bg-surface-alt",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-edge flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Be,{className:"w-3.5 h-3.5 text-green-500"}),e.jsx("h3",{className:"text-xs font-semibold text-foreground",children:"Translation Evidence"})]}),e.jsx(st,{score:t.confidenceScore})]}),e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsx(_,{deterministicPct:Math.round(t.confidenceScore*100),totalConstructs:t.translatedConstructs.length+t.risks.length}),t.translatedConstructs.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[e.jsx(Fe,{className:"w-3 h-3 text-muted"}),e.jsx("p",{className:"text-[10px] text-muted font-medium",children:"Translated Constructs"})]}),e.jsxs("table",{className:"w-full text-[10px]",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-edge",children:[e.jsx("th",{className:"text-left px-2 py-1 font-medium text-muted",children:"Source"}),e.jsx("th",{className:"text-left px-2 py-1 font-medium text-muted",children:"Target"}),e.jsx("th",{className:"text-left px-2 py-1 font-medium text-muted",children:"Method"})]})}),e.jsx("tbody",{children:t.translatedConstructs.map((r,o)=>e.jsxs("tr",{className:"border-b border-edge/50",children:[e.jsx("td",{className:"px-2 py-1 font-mono text-foreground",children:r.source}),e.jsx("td",{className:"px-2 py-1 font-mono text-accent",children:r.target}),e.jsx("td",{className:"px-2 py-1 text-muted",children:r.method})]},o))})]})]}),t.risks.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[e.jsx(J,{className:"w-3 h-3 text-yellow-500"}),e.jsxs("p",{className:"text-[10px] text-muted font-medium",children:["Risks (",t.risks.length,")"]})]}),e.jsx("div",{className:"space-y-1.5",children:t.risks.map((r,o)=>e.jsxs("div",{className:"flex items-start gap-2 px-2 py-1.5 rounded border border-edge/50 bg-surface",children:[e.jsx("span",{className:`shrink-0 px-1.5 py-0.5 rounded text-[10px] font-medium ${at[r.severity]??"bg-surface text-muted"}`,children:r.severity}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] font-medium text-foreground",children:r.construct}),e.jsx("span",{className:"text-[10px] text-muted ml-1",children:r.message})]})]},o))})]}),t.humanReviewPoints.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[e.jsx(Le,{className:"w-3 h-3 text-muted"}),e.jsx("p",{className:"text-[10px] text-muted font-medium",children:"Human Review Points"})]}),e.jsx("ul",{className:"space-y-1 text-[10px] text-muted list-disc list-inside",children:t.humanReviewPoints.map((r,o)=>e.jsx("li",{children:r},o))})]}),t.diff&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] text-muted font-medium mb-2",children:"Diff"}),e.jsx("pre",{className:"text-[10px] p-3 rounded-md bg-surface border border-edge max-h-64 overflow-auto whitespace-pre-wrap text-muted font-mono",children:t.diff})]})]})]})}const nt={pending:"bg-yellow-500/10 text-yellow-500",analyzing:"bg-blue-500/10 text-blue-500",translating:"bg-indigo-500/10 text-indigo-500",validating:"bg-purple-500/10 text-purple-500",done:"bg-green-500/10 text-green-500",failed:"bg-red-500/10 text-red-500"};function lt(s){const t=Date.now(),r=new Date(s).getTime(),o=t-r,a=Math.floor(o/6e4);if(a<1)return"just now";if(a<60)return`${a}m ago`;const n=Math.floor(a/60);if(n<24)return`${n}h ago`;const i=Math.floor(n/24);return i<7?`${i}d ago`:new Date(s).toLocaleDateString()}function z({label:s,value:t,accent:r}){return e.jsxs("div",{className:"rounded-lg border border-edge bg-surface-alt px-4 py-3",children:[e.jsx("p",{className:"text-[10px] text-muted",children:s}),e.jsx("p",{className:`text-lg font-semibold ${r??"text-foreground"}`,children:t})]})}function U(){return e.jsx("tr",{className:"border-b border-edge/50",children:Array.from({length:7}).map((s,t)=>e.jsx("td",{className:"px-4 py-2",children:e.jsx("div",{className:"h-3 rounded bg-surface animate-pulse",style:{width:`${40+Math.random()*40}%`}})},t))})}function ot({job:s}){return e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:"px-4 py-3 bg-surface/50",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[s.sourceCode&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-medium text-muted mb-1",children:"Source Code"}),e.jsxs("pre",{className:"text-[10px] p-2 rounded-md bg-surface border border-edge max-h-40 overflow-auto whitespace-pre-wrap font-mono text-foreground",children:[s.sourceCode.slice(0,500),s.sourceCode.length>500?`
|
|
114
99
|
...`:""]})]}),s.targetCode&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-medium text-muted mb-1",children:"Translated Code"}),e.jsxs("pre",{className:"text-[10px] p-2 rounded-md bg-surface border border-green-500/20 max-h-40 overflow-auto whitespace-pre-wrap font-mono text-foreground",children:[s.targetCode.slice(0,500),s.targetCode.length>500?`
|
|
115
|
-
...`:""]})]}),!s.sourceCode&&!s.targetCode&&e.jsx("p",{className:"text-[10px] text-muted col-span-2",children:"No code details available for this job."})]})})})}function
|
|
100
|
+
...`:""]})]}),!s.sourceCode&&!s.targetCode&&e.jsx("p",{className:"text-[10px] text-muted col-span-2",children:"No code details available for this job."})]})})})}function ct({state:s,actions:t,showInsights:r}){const{jobs:o,stats:a,loading:n,error:i}=s,[h,m]=p.useState(null),[c,x]=p.useState(null),u=l=>{c===l?(x(null),t.deleteJob(l)):(x(l),setTimeout(()=>x(d=>d===l?null:d),3e3))},b=l=>{m(d=>d===l?null:l)};return n&&o.length===0?e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-5 gap-3",children:Array.from({length:5}).map((l,d)=>e.jsxs("div",{className:"rounded-lg border border-edge bg-surface-alt px-4 py-3 animate-pulse",children:[e.jsx("div",{className:"h-2 w-16 rounded bg-surface mb-2"}),e.jsx("div",{className:"h-5 w-10 rounded bg-surface"})]},d))}),e.jsxs("div",{className:"rounded-lg border border-edge bg-surface-alt",children:[e.jsx("div",{className:"px-4 py-3 border-b border-edge",children:e.jsx("div",{className:"h-3 w-32 rounded bg-surface animate-pulse"})}),e.jsx("table",{className:"w-full",children:e.jsxs("tbody",{children:[e.jsx(U,{}),e.jsx(U,{}),e.jsx(U,{})]})})]})]}):i?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 gap-3",children:[e.jsx("p",{className:"text-xs text-red-400",children:i}),e.jsxs("button",{onClick:()=>void t.refresh(),className:"flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-md border border-edge text-muted hover:text-foreground transition-colors cursor-pointer",children:[e.jsx(V,{className:"w-3 h-3"})," Retry"]})]}):e.jsxs("div",{className:"space-y-4",children:[a&&e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-5 gap-3",children:[e.jsx(z,{label:"Total Jobs",value:a.totalJobs}),e.jsx(z,{label:"Completed",value:a.done,accent:"text-green-500"}),e.jsx(z,{label:"Failed",value:a.failed,accent:a.failed>0?"text-red-500":"text-foreground"}),e.jsx(z,{label:"Pending",value:a.pending,accent:a.pending>0?"text-yellow-500":"text-foreground"}),e.jsx(z,{label:"Avg Confidence",value:`${Math.round(a.avgConfidence*100)}%`})]}),r&&o.length>0&&e.jsxs("div",{className:"rounded-lg border border-edge bg-surface-alt",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-edge flex items-center gap-2",children:[e.jsx(H,{className:"w-3.5 h-3.5 text-accent"}),e.jsx("h3",{className:"text-xs font-semibold text-foreground",children:"Translation Pairs"})]}),e.jsx("div",{className:"p-4",children:e.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(o.reduce((l,d)=>{const g=`${d.sourceLanguage} → ${d.targetLanguage}`;return l[g]=(l[g]??0)+1,l},{})).sort(([,l],[,d])=>d-l).map(([l,d])=>e.jsxs("span",{className:"px-2 py-1 text-[10px] rounded-md border border-edge bg-surface cursor-pointer hover:border-accent/50 transition-colors",children:[e.jsx("span",{className:"font-medium text-foreground",children:l}),e.jsxs("span",{className:"text-muted ml-1.5",children:["x",d]})]},l))})})]}),e.jsxs("div",{className:"rounded-lg border border-edge bg-surface-alt",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-edge flex items-center justify-between",children:[e.jsxs("h3",{className:"text-xs font-semibold text-foreground",children:["Translation Jobs (",o.length,")"]}),e.jsx("button",{onClick:()=>void t.refresh(),className:"p-1 rounded text-muted hover:text-foreground transition-colors cursor-pointer",title:"Refresh",children:e.jsx(V,{className:`w-3.5 h-3.5 ${n?"animate-spin":""}`})})]}),o.length===0?e.jsxs("div",{className:"px-4 py-12 flex flex-col items-center justify-center gap-3 text-center",children:[e.jsx(_e,{className:"w-8 h-8 text-muted/40"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted",children:"No translation jobs yet"}),e.jsx("p",{className:"text-[10px] text-muted/60 mt-1",children:"Start by translating some code in the Convert tab"})]})]}):e.jsx("div",{className:"overflow-auto max-h-96",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{className:"sticky top-0 bg-surface-alt shadow-sm",children:e.jsxs("tr",{className:"border-b border-edge",children:[e.jsx("th",{className:"text-left px-4 py-2 font-medium text-muted w-6"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium text-muted",children:"ID"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium text-muted",children:"Languages"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium text-muted",children:"Scope"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium text-muted",children:"Status"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium text-muted",children:"Confidence"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium text-muted",children:"Created"}),e.jsx("th",{className:"text-right px-4 py-2 font-medium text-muted"})]})}),e.jsx("tbody",{children:o.map(l=>e.jsxs(e.Fragment,{children:[e.jsxs("tr",{onClick:()=>b(l.id),className:"border-b border-edge/50 hover:bg-surface transition-colors cursor-pointer",children:[e.jsx("td",{className:"px-4 py-1.5 text-muted",children:h===l.id?e.jsx(W,{className:"w-3 h-3"}):e.jsx(K,{className:"w-3 h-3"})}),e.jsx("td",{className:"px-4 py-1.5 font-mono text-muted",title:l.id,children:l.id.slice(0,8)}),e.jsxs("td",{className:"px-4 py-1.5",children:[e.jsx("span",{className:"text-foreground",children:l.sourceLanguage}),e.jsx("span",{className:"text-muted mx-1",children:"→"}),e.jsx("span",{className:"text-accent",children:l.targetLanguage})]}),e.jsx("td",{className:"px-4 py-1.5 text-muted",children:l.scope}),e.jsx("td",{className:"px-4 py-1.5",children:e.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-medium ${nt[l.status]}`,children:l.status})}),e.jsx("td",{className:"px-4 py-1.5 text-muted",children:l.confidenceScore!=null?`${Math.round(l.confidenceScore*100)}%`:"—"}),e.jsx("td",{className:"px-4 py-1.5 text-muted",title:new Date(l.createdAt).toLocaleString(),children:lt(l.createdAt)}),e.jsx("td",{className:"px-4 py-1.5 text-right",onClick:d=>d.stopPropagation(),children:e.jsx("button",{onClick:()=>u(l.id),className:`px-2 py-0.5 rounded text-[10px] transition-all cursor-pointer ${c===l.id?"bg-red-500/10 text-red-400 font-medium border border-red-500/30":"text-muted hover:text-red-400"}`,title:c===l.id?"Click again to confirm":"Delete job",children:c===l.id?"Confirm?":e.jsx(Ke,{className:"w-3 h-3"})})})]},l.id),h===l.id&&e.jsx(ot,{job:l},`${l.id}-details`)]}))})]})})]})]})}function dt({onUpload:s,loading:t,disabled:r}){const[o,a]=p.useState(!1),n=p.useRef(null),i=p.useCallback(u=>{u.preventDefault(),u.stopPropagation(),!r&&!t&&a(!0)},[r,t]),h=p.useCallback(u=>{u.preventDefault(),u.stopPropagation(),a(!1)},[]),m=p.useCallback(u=>{if(u.preventDefault(),u.stopPropagation(),a(!1),r||t)return;const b=u.dataTransfer.files[0];b&&b.name.endsWith(".zip")&&s(b)},[r,t,s]),c=p.useCallback(()=>{var u;!r&&!t&&((u=n.current)==null||u.click())},[r,t]),x=p.useCallback(u=>{var l;const b=(l=u.target.files)==null?void 0:l[0];b&&b.name.endsWith(".zip")&&s(b),u.target.value=""},[s]);return e.jsxs("div",{role:"button",tabIndex:r?-1:0,className:`
|
|
116
101
|
flex flex-col items-center justify-center gap-2 rounded-lg border-2 border-dashed
|
|
117
102
|
px-4 py-5 text-center transition-colors cursor-pointer
|
|
118
103
|
${o?"border-accent bg-accent/5":"border-edge bg-surface"}
|
|
119
104
|
${r||t?"opacity-50 cursor-not-allowed":"hover:border-accent/60"}
|
|
120
|
-
`,onDragOver:i,onDragLeave:h,onDrop:m,onClick:c,onKeyDown:u=>{(u.key==="Enter"||u.key===" ")&&c()},children:[e.jsx("input",{ref:n,type:"file",accept:".zip",className:"hidden",onChange:x,disabled:r||t}),t?e.jsxs(e.Fragment,{children:[e.jsx(
|
|
105
|
+
`,onDragOver:i,onDragLeave:h,onDrop:m,onClick:c,onKeyDown:u=>{(u.key==="Enter"||u.key===" ")&&c()},children:[e.jsx("input",{ref:n,type:"file",accept:".zip",className:"hidden",onChange:x,disabled:r||t}),t?e.jsxs(e.Fragment,{children:[e.jsx($,{className:"h-6 w-6 animate-spin text-accent"}),e.jsx("span",{className:"text-sm text-muted",children:"Uploading..."})]}):e.jsxs(e.Fragment,{children:[o?e.jsx($e,{className:"h-6 w-6 text-accent"}):e.jsx(me,{className:"h-6 w-6 text-muted"}),e.jsxs("span",{className:"text-sm text-muted",children:["Drop a ",e.jsx("code",{className:"text-xs",children:".zip"})," file or click to browse"]})]})]})}const ee={done:"bg-green-500",analyzed:"bg-yellow-500",translating:"bg-blue-500",analyzing:"bg-blue-500",failed:"bg-red-500",pending:"bg-gray-500"};function it(s){const t={children:[]};for(const o of s){const a=o.filePath.split("/");let n=t;for(let i=0;i<a.length;i++){const h=a[i],m=i===a.length-1,c=a.slice(0,i+1).join("/");if(m)n.children.push({name:h,path:c,isDir:!1,children:[],file:o});else{let x=n.children.find(u=>u.isDir&&u.name===h);x||(x={name:h,path:c,isDir:!0,children:[]},n.children.push(x)),n=x}}}const r=o=>{const a=[...o].sort((n,i)=>n.isDir!==i.isDir?n.isDir?-1:1:n.name.localeCompare(i.name));for(const n of a)n.isDir&&(n.children=r(n.children));return a};return r(t.children)}function xt(s){const t={};for(const r of s)t[r.status]=(t[r.status]??0)+1;return t}function le(s,t){const r=t.toLowerCase(),o=[];for(const a of s)if(a.isDir){const n=le(a.children,t);n.length>0&&o.push({...a,children:n})}else a.path.toLowerCase().includes(r)&&o.push(a);return o}const ut=p.memo(function s({node:t,depth:r,selectedFileId:o,onSelectFile:a,expandedPaths:n,onToggle:i}){var l,d,g;const h=n.has(t.path),m=!t.isDir&&((l=t.file)==null?void 0:l.id)===o,c=r*16+8;if(t.isDir)return e.jsxs("div",{style:{contentVisibility:"auto"},children:[e.jsxs("button",{type:"button",className:"flex w-full items-center gap-1.5 rounded px-1 py-0.5 text-sm text-muted hover:bg-surface-hover",style:{paddingLeft:c},onClick:()=>i(t.path),children:[h?e.jsx(W,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(K,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx(De,{className:"h-3.5 w-3.5 shrink-0 text-yellow-500/80"}),e.jsx("span",{className:"truncate",children:t.name})]}),h&&t.children.map(f=>e.jsx(s,{node:f,depth:r+1,selectedFileId:o,onSelectFile:a,expandedPaths:n,onToggle:i},f.path))]});const x=((d=t.file)==null?void 0:d.status)??"pending",u=(g=t.file)==null?void 0:g.confidenceScore,b=ee[x]??ee.pending;return e.jsxs("button",{type:"button",className:`
|
|
121
106
|
flex w-full items-center gap-1.5 rounded px-1 py-0.5 text-sm transition-colors
|
|
122
107
|
${m?"bg-accent/10 border border-accent text-foreground":"text-muted hover:bg-surface-hover border border-transparent"}
|
|
123
|
-
`,style:{paddingLeft:c,contentVisibility:"auto"},onClick:()=>t.file&&a(t.file.id),children:[e.jsx("span",{className:`h-2 w-2 shrink-0 rounded-full ${b}`}),e.jsx(se,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"truncate",children:t.name}),u!=null&&e.jsxs("span",{className:"ml-auto shrink-0 text-xs text-muted",children:[Math.round(u*100),"%"]})]})});function gt({files:s,selectedFileId:t,onSelectFile:r}){const[o,a]=p.useState(""),[n,i]=p.useState(new Set),h=p.useMemo(()=>mt(s),[s]),m=p.useMemo(()=>o.trim()?le(h,o.trim()):h,[h,o]),c=p.useMemo(()=>pt(s),[s]),x=p.useCallback(d=>{i(g=>{const f=new Set(g);return f.has(d)?f.delete(d):f.add(d),f})},[]),u=(c.done??0)+(c.analyzed??0),b=c.translating??0,l=c.failed??0;return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"text-xs text-muted px-1",children:[s.length," files: ",u," ready, ",b," need AI, ",l," error"]}),e.jsxs("div",{className:"relative",children:[e.jsx(te,{className:"absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted"}),e.jsx("input",{type:"text",placeholder:"Filter files...",value:o,onChange:d=>a(d.target.value),className:"w-full rounded border border-edge bg-surface py-1 pl-7 pr-2 text-sm text-foreground placeholder:text-muted focus:border-accent focus:outline-none"})]}),e.jsxs("div",{className:"overflow-y-auto max-h-[60vh]",children:[m.map(d=>e.jsx(ht,{node:d,depth:0,selectedFileId:t,onSelectFile:r,expandedPaths:n,onToggle:x},d.path)),m.length===0&&e.jsx("div",{className:"py-4 text-center text-xs text-muted",children:"No files match your filter"})]})]})}function ft(s,t){if(t){const c=t.translatedFiles,x=t.pendingFiles+t.analyzedFiles;return{totalFiles:t.totalFiles,deterministicCount:c,needsAiCount:x,errorCount:t.failedFiles,avgConfidence:t.overallConfidence,deterministicPct:t.deterministicPct}}const r=s.length;if(r===0)return{totalFiles:0,deterministicCount:0,needsAiCount:0,errorCount:0,avgConfidence:0,deterministicPct:0};const o=s.filter(c=>c.deterministic===!0).length,a=s.filter(c=>c.status==="failed").length,n=s.filter(c=>c.deterministic===!1&&c.status!=="failed").length,i=s.filter(c=>c.confidenceScore!=null),h=i.length>0?i.reduce((c,x)=>c+(x.confidenceScore??0),0)/i.length:0,m=r>0?Math.round(o/r*100):0;return{totalFiles:r,deterministicCount:o,needsAiCount:n,errorCount:a,avgConfidence:h,deterministicPct:m}}function F({icon:s,value:t,label:r,colorClass:o="text-foreground"}){return e.jsxs("div",{className:"rounded-lg border border-edge bg-surface-alt px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[s,e.jsx("span",{className:`text-xl font-bold ${o}`,children:t})]}),e.jsx("p",{className:"text-[10px] text-muted",children:r})]})}function bt({project:s,files:t,summary:r,onPrepareAll:o,onDownloadAll:a,loading:n}){const i=ft(t,r),h=i.deterministicPct===100&&i.totalFiles>0;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-5 gap-3",children:[e.jsx(F,{icon:e.jsx(Pe,{className:"w-3.5 h-3.5 text-accent"}),value:i.totalFiles,label:"Total Files"}),e.jsx(F,{icon:e.jsx(ae,{className:"w-3.5 h-3.5 text-green-500"}),value:i.deterministicCount,label:"Deterministic",colorClass:"text-green-500"}),e.jsx(F,{icon:e.jsx(J,{className:"w-3.5 h-3.5 text-yellow-500"}),value:i.needsAiCount,label:"Needs AI",colorClass:"text-yellow-500"}),e.jsx(F,{icon:e.jsx(ye,{className:"w-3.5 h-3.5 text-red-500"}),value:i.errorCount,label:"Errors",colorClass:"text-red-500"}),e.jsx(F,{icon:e.jsx(H,{className:"w-3.5 h-3.5 text-accent"}),value:`${Math.round(i.avgConfidence*100)}%`,label:"Avg Confidence"})]}),e.jsx(E,{isProjectLevel:!0,deterministicPct:i.deterministicPct,totalConstructs:i.totalFiles}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:o,disabled:n||i.totalFiles===0,className:"flex items-center gap-1.5 px-4 py-2 rounded-md bg-accent text-white text-xs font-medium hover:bg-accent/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[e.jsx(re,{className:"w-3.5 h-3.5"}),"Convert All"]}),e.jsxs("button",{onClick:a,disabled:n||i.totalFiles===0,className:`flex items-center gap-1.5 px-4 py-2 rounded-md text-xs font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed ${h?"bg-green-600 text-white hover:bg-green-700":"border border-edge text-foreground hover:bg-surface"}`,children:[e.jsx(_,{className:"w-3.5 h-3.5"}),"Download All .zip"]})]})]})}function jt({file:s,prompt:t,onBack:r,onFinalize:o,loading:a}){const[n,i]=p.useState(""),[h,m]=p.useState(!1),c=s.status==="done",x=p.useCallback(()=>{t&&navigator.clipboard.writeText(t).then(()=>{m(!0),setTimeout(()=>m(!1),2e3)})},[t]),u=p.useCallback(()=>{n.trim()&&o(n.trim())},[n,o]);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("button",{onClick:r,className:"flex items-center gap-1.5 text-xs text-muted hover:text-foreground transition-colors",children:[e.jsx(he,{className:"w-3.5 h-3.5"}),"Back to project"]}),e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-md border border-edge bg-surface-alt",children:[e.jsx(se,{className:"w-4 h-4 text-accent shrink-0"}),e.jsx("span",{className:"text-xs font-mono text-foreground truncate",children:s.filePath})]}),s.analysis&&e.jsx(ne,{analysis:s.analysis}),e.jsx(E,{analysis:s.analysis,aiPrompt:t}),t&&e.jsxs("div",{className:"rounded-lg border border-edge bg-surface-alt",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-edge flex items-center justify-between",children:[e.jsx("h3",{className:"text-xs font-semibold text-foreground",children:"AI Prompt"}),e.jsxs("button",{onClick:x,className:"flex items-center gap-1 px-2 py-1 rounded text-[10px] text-muted hover:text-foreground hover:bg-surface transition-colors",children:[h?e.jsx(D,{className:"w-3 h-3"}):e.jsx(W,{className:"w-3 h-3"}),h?"Copied!":"Copy"]})]}),e.jsx("pre",{className:"p-4 text-[11px] text-foreground/80 overflow-x-auto whitespace-pre-wrap font-mono leading-relaxed max-h-60 overflow-y-auto",children:t})]}),c&&e.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 rounded-lg border border-green-500/30 bg-green-500/5",children:[e.jsx(D,{className:"w-4 h-4 text-green-500 shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-green-500",children:"Translation Complete"}),s.confidenceScore!=null&&e.jsxs("p",{className:"text-[10px] text-muted mt-0.5",children:["Confidence: ",Math.round(s.confidenceScore*100),"%"]})]})]}),!c&&e.jsxs("div",{className:"rounded-lg border border-edge bg-surface-alt",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-edge",children:[e.jsx("h3",{className:"text-xs font-semibold text-foreground",children:"Generated Code"}),e.jsx("p",{className:"text-[10px] text-muted mt-0.5",children:"Paste the AI-generated translation below to finalize this file."})]}),e.jsxs("div",{className:"p-4 space-y-3",children:[e.jsx("textarea",{value:n,onChange:b=>i(b.target.value),placeholder:"Paste generated code here...",className:"w-full h-48 px-3 py-2 rounded-md border border-edge bg-surface text-xs font-mono text-foreground placeholder:text-muted/50 resize-y focus:outline-none focus:ring-1 focus:ring-accent/50"}),e.jsx("button",{onClick:u,disabled:a||!n.trim(),className:"flex items-center gap-1.5 px-4 py-2 rounded-md bg-accent text-white text-xs font-medium hover:bg-accent/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:"Finalize Translation"})]})]})]})}function Nt({project:s,files:t,summary:r,selectedFileId:o,onSelectFile:a,onPrepareAll:n,onDownloadAll:i,onFinalizeFile:h,prompts:m,loading:c}){const x=o?t.find(l=>l.id===o)??null:null,u=()=>{a(null)},b=l=>{o&&h(o,l)};return e.jsxs("div",{className:"flex h-full flex-col md:flex-row",children:[e.jsx("div",{className:"w-full md:w-60 border-b md:border-b-0 md:border-r border-edge overflow-hidden flex flex-col shrink-0",children:e.jsx(gt,{files:t,selectedFileId:o,onSelectFile:a})}),e.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:x?e.jsx(jt,{file:x,prompt:m==null?void 0:m[x.id],onBack:u,onFinalize:b,loading:c}):e.jsx(bt,{project:s,files:t,summary:r,onPrepareAll:n,onDownloadAll:i,loading:c})})]})}const yt={knowledge:null,searchResults:[],loading:!1,error:null};function vt(){const[s,t]=p.useState(yt),r=p.useCallback(async()=>{t(a=>({...a,loading:!0,error:null}));try{const a=await v.translationGetKnowledge();t(n=>({...n,knowledge:a,loading:!1}))}catch(a){t(n=>({...n,error:a instanceof Error?a.message:"Failed to load knowledge stats",loading:!1}))}},[]),o=p.useCallback(async a=>{t(n=>({...n,loading:!0,error:null}));try{const n=await v.translationSearchKnowledge(a);t(i=>({...i,searchResults:n.results,loading:!1}))}catch(n){t(i=>({...i,error:n instanceof Error?n.message:"Search failed",loading:!1}))}},[]);return p.useEffect(()=>{r()},[r]),[s,{search:o,refresh:r}]}function O({label:s,value:t}){return e.jsxs("div",{className:"rounded-lg border border-edge bg-surface-alt px-4 py-3",children:[e.jsx("p",{className:"text-[10px] text-muted",children:s}),e.jsx("p",{className:"text-lg font-semibold text-foreground",children:t})]})}function wt({entry:s,expanded:t,onToggle:r,onSearch:o}){const a=s.metadata,n=s.confidence!=null?Math.round(s.confidence*100):null,i=n!=null?n>=80?"text-green-500":n>=50?"text-yellow-500":"text-red-500":"text-muted",h=(a==null?void 0:a.riskCount)??0;return e.jsxs("div",{className:"rounded-lg border border-edge bg-surface-alt px-4 py-3 cursor-pointer transition-colors hover:border-accent/30",onClick:r,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[t?e.jsx(q,{className:"w-3.5 h-3.5 text-muted flex-shrink-0"}):e.jsx(K,{className:"w-3.5 h-3.5 text-muted flex-shrink-0"}),e.jsx("p",{className:"text-xs font-medium text-foreground truncate flex-1",children:s.title}),e.jsx("span",{className:"text-[10px] text-muted flex-shrink-0",children:new Date(s.createdAt).toLocaleDateString()})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-1.5 ml-5",children:[s.sourceLanguage&&s.targetLanguage&&e.jsxs("span",{className:"text-[10px] text-muted",children:[s.sourceLanguage," → ",s.targetLanguage]}),n!=null&&e.jsxs("span",{className:`text-[10px] ${i}`,children:[n,"%"]})]}),t&&e.jsxs("div",{className:"mt-2 pt-2 border-t border-edge space-y-2 ml-5",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[a!=null&&a.sourceLanguage?e.jsx("span",{className:"px-2 py-0.5 text-[10px] rounded bg-blue-500/10 text-blue-400",children:String(a.sourceLanguage)}):null,e.jsx("span",{className:"text-[10px] text-muted",children:"→"}),a!=null&&a.targetLanguage?e.jsx("span",{className:"px-2 py-0.5 text-[10px] rounded bg-green-500/10 text-green-400",children:String(a.targetLanguage)}):null,a!=null&&a.scope?e.jsx("span",{className:"px-2 py-0.5 text-[10px] rounded bg-accent/10 text-accent",children:String(a.scope)}):null]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 text-[10px]",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-muted",children:"Confidence: "}),e.jsxs("span",{className:i,children:[n??"—","%"]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted",children:"Constructs: "}),e.jsx("span",{className:"text-foreground",children:(a==null?void 0:a.constructCount)??"—"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted",children:"Risks: "}),e.jsx("span",{className:h>0?"text-yellow-500":"text-green-500",children:h})]})]}),e.jsx("button",{type:"button",onClick:m=>{m.stopPropagation(),o(s.title)},className:"text-[10px] text-accent hover:text-accent/80 transition-colors",children:"View in Search"})]})]})}function Ct(){var u,b,l;const[s,{search:t,refresh:r}]=vt(),[o,a]=p.useState(""),[n,i]=p.useState(null),h=d=>{d.preventDefault(),t(o)},m=()=>{r()},c=s.searchResults&&s.searchResults.length>0?s.searchResults:((u=s.knowledge)==null?void 0:u.recentEntries)??[],x=s.searchResults&&s.searchResults.length>0;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("form",{onSubmit:h,className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(te,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted"}),e.jsx("input",{type:"text",value:o,onChange:d=>a(d.target.value),placeholder:"Search knowledge base...",className:"w-full pl-8 pr-3 py-1.5 text-xs rounded-md border border-edge bg-surface text-foreground placeholder:text-muted focus:outline-none focus:border-accent/50"})]}),e.jsxs("button",{type:"button",onClick:m,disabled:s.loading,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-md border border-edge text-muted hover:text-foreground transition-colors cursor-pointer disabled:opacity-50",title:"Reindex knowledge",children:[e.jsx(V,{className:`w-3.5 h-3.5 ${s.loading?"animate-spin":""}`}),"Reindex"]})]}),s.loading&&!s.knowledge&&e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(z,{className:"w-6 h-6 text-muted animate-spin"})}),!s.loading&&!s.knowledge&&c.length===0&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 gap-3 text-center",children:[e.jsx(G,{className:"w-12 h-12 text-muted/40"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted",children:"No learnings yet."}),e.jsx("p",{className:"text-[10px] text-muted/60 mt-1",children:"Complete some translations to build the knowledge base."})]})]}),s.knowledge&&e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsx(O,{label:"Total Entries",value:s.knowledge.totalDocuments??0}),e.jsx(O,{label:"Language Pairs",value:((b=s.knowledge.byLanguagePair)==null?void 0:b.length)??0}),e.jsx(O,{label:"Avg Confidence",value:s.knowledge.avgConfidence!=null?`${Math.round(s.knowledge.avgConfidence*100)}%`:"—"})]}),((l=s.knowledge)==null?void 0:l.byLanguagePair)&&s.knowledge.byLanguagePair.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.knowledge.byLanguagePair.map(d=>e.jsxs("span",{className:"px-2 py-0.5 text-[10px] font-medium rounded bg-accent/10 text-accent",children:[d.pair," (",d.count,")"]},d.pair))}),c.length>0&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(G,{className:"w-3.5 h-3.5 text-accent"}),e.jsx("h3",{className:"text-xs font-semibold text-foreground",children:x?"Search Results":"Recent Entries"}),e.jsxs("span",{className:"text-[10px] text-muted",children:["(",c.length,")"]})]}),c.length>0&&e.jsx("div",{className:"space-y-2 max-h-80 overflow-auto",children:c.map(d=>e.jsx(wt,{entry:d,expanded:n===d.id,onToggle:()=>i(n===d.id?null:d.id),onSearch:g=>{a(g),t(g)}},d.id))})]})}const kt=[{id:"convert",label:"Convert",icon:e.jsx(me,{className:"w-3.5 h-3.5"})},{id:"history",label:"History",icon:e.jsx(we,{className:"w-3.5 h-3.5"})},{id:"insights",label:"Insights",icon:e.jsx(H,{className:"w-3.5 h-3.5"})},{id:"knowledge",label:"Knowledge",icon:e.jsx(G,{className:"w-3.5 h-3.5"})},{id:"graph",label:"Graph",icon:e.jsx(B,{className:"w-3.5 h-3.5"})}],S={sourceCode:"",targetLanguage:"python",scope:"snippet",generatedCode:""};function St({jobs:s}){const t=p.useMemo(()=>s.filter(a=>a.status==="done"&&a.confidenceScore!=null),[s]),{flowNodes:r,flowEdges:o}=p.useMemo(()=>{if(t.length===0)return{flowNodes:[],flowEdges:[]};const a=new Set,n=new Map;for(const c of t){a.add(c.sourceLanguage),a.add(c.targetLanguage);const x=`${c.sourceLanguage}->${c.targetLanguage}`,u=n.get(x)??{count:0,totalConf:0};u.count++,u.totalConf+=c.confidenceScore??0,n.set(x,u)}const i=[...a].map(c=>({id:c,data:{label:c},position:{x:0,y:0},style:{background:"rgba(99, 102, 241, 0.1)",border:"1px solid rgba(99, 102, 241, 0.3)",borderRadius:"8px",padding:"8px 16px",color:"#a5b4fc",fontSize:"12px",fontWeight:600}})),h=[...n.entries()].map(([c,x])=>{const[u,b]=c.split("->"),l=Math.round(x.totalConf/x.count*100),d=l>=80?"#22c55e":l>=50?"#eab308":"#ef4444";return{id:c,source:u,target:b,label:`x${x.count} · ${l}%`,style:{stroke:d,strokeWidth:2},labelStyle:{fill:"#9ca3af",fontSize:10},labelBgStyle:{fill:"#1e1e2e",fillOpacity:.9},animated:!0}}),m=new Z.graphlib.Graph().setDefaultEdgeLabel(()=>({}));return m.setGraph({rankdir:"LR",nodesep:80,ranksep:150}),i.forEach(c=>m.setNode(c.id,{width:120,height:40})),h.forEach(c=>m.setEdge(c.source,c.target)),Z.layout(m),i.forEach(c=>{const x=m.node(c.id);c.position={x:x.x-60,y:x.y-20}}),{flowNodes:i,flowEdges:h}},[t]);return t.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx(B,{className:"w-12 h-12 text-muted mx-auto mb-3"}),e.jsx("p",{className:"text-sm text-muted",children:"Translation graph visualization"}),e.jsx("p",{className:"text-[10px] text-muted mt-1",children:"Complete some translations to see the relationship graph"})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(B,{className:"w-4 h-4 text-accent"}),e.jsx("h3",{className:"text-xs font-semibold text-foreground",children:"Translation Flow Graph"}),e.jsxs("span",{className:"text-[10px] text-muted",children:["(",t.length," completed translations)"]})]}),e.jsx("div",{style:{height:400},className:"rounded-lg border border-edge bg-surface-alt",children:e.jsxs(de,{nodes:r,edges:o,fitView:!0,proOptions:{hideAttribution:!0},style:{background:"transparent"},children:[e.jsx(ie,{color:"#333",gap:20}),e.jsx(xe,{showInteractive:!1})]})})]})}function At(){var $;const[s,t]=p.useState("convert"),[r,o]=Xe(),[a,n]=Qe(),[i,h]=Ye(),[m,c]=p.useState(S.sourceCode),[x,u]=p.useState(S.targetLanguage),[b,l]=p.useState(S.scope),[d,g]=p.useState(S.generatedCode),f=p.useCallback(j=>{S.sourceCode=j,c(j)},[]),y=p.useCallback(j=>{S.targetLanguage=j,u(j)},[]),C=p.useCallback(j=>{S.scope=j,l(j)},[]),k=p.useCallback(j=>{S.generatedCode=j,g(j)},[]),M=i.mode!=="idle",T=p.useCallback(j=>{h.upload(j,x)},[h,x]),L=r.phase;oe(p.useCallback(j=>{j.startsWith("translation:")&&L!=="analyzing"&&L!=="finalizing"&&n.refresh()},[n,L]));const w=()=>{o.analyze(m,x,"module")},I=()=>{o.finalize(d).then(()=>n.refresh())},A=()=>{o.reset(),f(""),k(""),y("python"),C("snippet")};return e.jsx("div",{className:"h-full overflow-auto",children:e.jsxs("div",{className:"p-4 space-y-4 max-w-5xl mx-auto",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ce,{className:"w-5 h-5 text-accent"}),e.jsx("h2",{className:"text-sm font-semibold text-foreground",children:"Language Convert"}),e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-warning/10 text-warning rounded-full",children:"Beta"})]}),e.jsx("div",{className:"flex gap-1 border-b border-edge pb-1",children:kt.map(j=>e.jsxs("button",{onClick:()=>t(j.id),className:`flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-t transition-colors ${s===j.id?"bg-accent text-white":"text-muted hover:text-foreground hover:bg-surface"}`,children:[j.icon,j.label]},j.id))}),s==="convert"&&e.jsxs("div",{className:"space-y-4",children:[e.jsx(ut,{onUpload:T,loading:i.loading}),M?e.jsx(Nt,{project:i.project,files:i.files,summary:i.summary,selectedFileId:i.selectedFileId,onSelectFile:h.selectFile,onPrepareAll:()=>void h.prepareFiles(),onDownloadAll:()=>void h.downloadProject(),onFinalizeFile:(j,P)=>void h.finalizeFile(j,P),loading:i.loading}):e.jsxs(e.Fragment,{children:[e.jsx(tt,{sourceCode:m,setSourceCode:f,targetLanguage:x,setTargetLanguage:y,generatedCode:d,setGeneratedCode:k,translation:r,onAnalyze:w,onFinalize:I,onReset:A}),r.phase==="analyzing"&&e.jsxs("div",{className:"rounded-lg border-2 border-accent/40 bg-accent/5 p-5 transition-all duration-300",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 rounded-full bg-accent/20 animate-ping"}),e.jsx(z,{className:"w-5 h-5 text-accent animate-spin relative"})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-xs font-semibold text-foreground",children:"Analyzing your code..."}),e.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[e.jsx("span",{className:"text-[10px] text-accent font-medium",children:"Detecting language"}),e.jsx("span",{className:"text-[10px] text-muted",children:"→"}),e.jsx("span",{className:"text-[10px] text-muted",children:"Analyzing constructs"}),e.jsx("span",{className:"text-[10px] text-muted",children:"→"}),e.jsx("span",{className:"text-[10px] text-muted",children:"Generating prompt"})]})]})]}),e.jsx("div",{className:"mt-3 h-1 rounded-full bg-surface overflow-hidden",children:e.jsx("div",{className:"h-full bg-accent/60 rounded-full animate-pulse",style:{width:"60%"}})})]}),r.phase==="finalizing"&&e.jsx("div",{className:"rounded-lg border-2 border-green-500/40 bg-green-500/5 p-5 transition-all duration-300",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(z,{className:"w-5 h-5 text-green-500 animate-spin"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-foreground",children:"Finalizing translation..."}),e.jsx("p",{className:"text-[10px] text-muted mt-1",children:"Validating output and generating evidence pack"})]})]})}),r.analysis&&e.jsx("div",{className:"animate-in fade-in-0 duration-300",style:{animationFillMode:"both"},children:e.jsx(ne,{analysis:r.analysis,deterministicCode:($=r.prepareResult)==null?void 0:$.deterministicCode,targetLanguage:S.targetLanguage})}),r.finalizeResult&&e.jsx("div",{className:"animate-in fade-in-0 duration-300",style:{animationFillMode:"both"},children:e.jsx(ot,{result:r.finalizeResult})})]})]}),(s==="history"||s==="insights")&&e.jsx(xt,{state:a,actions:n,showInsights:s==="insights"}),s==="knowledge"&&e.jsx(Ct,{}),s==="graph"&&e.jsx(St,{jobs:a.jobs})]})})}export{At as LanguagesTab};
|
|
108
|
+
`,style:{paddingLeft:c,contentVisibility:"auto"},onClick:()=>t.file&&a(t.file.id),children:[e.jsx("span",{className:`h-2 w-2 shrink-0 rounded-full ${b}`}),e.jsx(se,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"truncate",children:t.name}),u!=null&&e.jsxs("span",{className:"ml-auto shrink-0 text-xs text-muted",children:[Math.round(u*100),"%"]})]})});function mt({files:s,selectedFileId:t,onSelectFile:r}){const[o,a]=p.useState(""),[n,i]=p.useState(new Set),h=p.useMemo(()=>it(s),[s]),m=p.useMemo(()=>o.trim()?le(h,o.trim()):h,[h,o]),c=p.useMemo(()=>xt(s),[s]),x=p.useCallback(d=>{i(g=>{const f=new Set(g);return f.has(d)?f.delete(d):f.add(d),f})},[]),u=(c.done??0)+(c.analyzed??0),b=c.translating??0,l=c.failed??0;return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"text-xs text-muted px-1",children:[s.length," files: ",u," ready, ",b," need AI, ",l," error"]}),e.jsxs("div",{className:"relative",children:[e.jsx(te,{className:"absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted"}),e.jsx("input",{type:"text",placeholder:"Filter files...",value:o,onChange:d=>a(d.target.value),className:"w-full rounded border border-edge bg-surface py-1 pl-7 pr-2 text-sm text-foreground placeholder:text-muted focus:border-accent focus:outline-none"})]}),e.jsxs("div",{className:"overflow-y-auto max-h-[60vh]",children:[m.map(d=>e.jsx(ut,{node:d,depth:0,selectedFileId:t,onSelectFile:r,expandedPaths:n,onToggle:x},d.path)),m.length===0&&e.jsx("div",{className:"py-4 text-center text-xs text-muted",children:"No files match your filter"})]})]})}function pt(s,t){if(t){const c=t.translatedFiles,x=t.pendingFiles+t.analyzedFiles;return{totalFiles:t.totalFiles,deterministicCount:c,needsAiCount:x,errorCount:t.failedFiles,avgConfidence:t.overallConfidence,deterministicPct:t.deterministicPct}}const r=s.length;if(r===0)return{totalFiles:0,deterministicCount:0,needsAiCount:0,errorCount:0,avgConfidence:0,deterministicPct:0};const o=s.filter(c=>c.deterministic===!0).length,a=s.filter(c=>c.status==="failed").length,n=s.filter(c=>c.deterministic===!1&&c.status!=="failed").length,i=s.filter(c=>c.confidenceScore!=null),h=i.length>0?i.reduce((c,x)=>c+(x.confidenceScore??0),0)/i.length:0,m=r>0?Math.round(o/r*100):0;return{totalFiles:r,deterministicCount:o,needsAiCount:n,errorCount:a,avgConfidence:h,deterministicPct:m}}function F({icon:s,value:t,label:r,colorClass:o="text-foreground"}){return e.jsxs("div",{className:"rounded-lg border border-edge bg-surface-alt px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[s,e.jsx("span",{className:`text-xl font-bold ${o}`,children:t})]}),e.jsx("p",{className:"text-[10px] text-muted",children:r})]})}function ht({project:s,files:t,summary:r,onPrepareAll:o,onDownloadAll:a,loading:n}){const i=pt(t,r),h=i.deterministicPct===100&&i.totalFiles>0;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-5 gap-3",children:[e.jsx(F,{icon:e.jsx(Ae,{className:"w-3.5 h-3.5 text-accent"}),value:i.totalFiles,label:"Total Files"}),e.jsx(F,{icon:e.jsx(ae,{className:"w-3.5 h-3.5 text-green-500"}),value:i.deterministicCount,label:"Deterministic",colorClass:"text-green-500"}),e.jsx(F,{icon:e.jsx(J,{className:"w-3.5 h-3.5 text-yellow-500"}),value:i.needsAiCount,label:"Needs AI",colorClass:"text-yellow-500"}),e.jsx(F,{icon:e.jsx(pe,{className:"w-3.5 h-3.5 text-red-500"}),value:i.errorCount,label:"Errors",colorClass:"text-red-500"}),e.jsx(F,{icon:e.jsx(H,{className:"w-3.5 h-3.5 text-accent"}),value:`${Math.round(i.avgConfidence*100)}%`,label:"Avg Confidence"})]}),e.jsx(_,{isProjectLevel:!0,deterministicPct:i.deterministicPct,totalConstructs:i.totalFiles}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:o,disabled:n||i.totalFiles===0,className:"flex items-center gap-1.5 px-4 py-2 rounded-md bg-accent text-white text-xs font-medium hover:bg-accent/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[e.jsx(re,{className:"w-3.5 h-3.5"}),"Convert All"]}),e.jsxs("button",{onClick:a,disabled:n||i.totalFiles===0,className:`flex items-center gap-1.5 px-4 py-2 rounded-md text-xs font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed ${h?"bg-green-600 text-white hover:bg-green-700":"border border-edge text-foreground hover:bg-surface"}`,children:[e.jsx(E,{className:"w-3.5 h-3.5"}),"Download All .zip"]})]})]})}function gt({file:s,prompt:t,onBack:r,onFinalize:o,loading:a}){const[n,i]=p.useState(""),[h,m]=p.useState(!1),c=s.status==="done",x=p.useCallback(()=>{t&&navigator.clipboard.writeText(t).then(()=>{m(!0),setTimeout(()=>m(!1),2e3)})},[t]),u=p.useCallback(()=>{n.trim()&&o(n.trim())},[n,o]);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("button",{onClick:r,className:"flex items-center gap-1.5 text-xs text-muted hover:text-foreground transition-colors",children:[e.jsx(be,{className:"w-3.5 h-3.5"}),"Back to project"]}),e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-md border border-edge bg-surface-alt",children:[e.jsx(se,{className:"w-4 h-4 text-accent shrink-0"}),e.jsx("span",{className:"text-xs font-mono text-foreground truncate",children:s.filePath})]}),s.analysis&&e.jsx(ne,{analysis:s.analysis}),e.jsx(_,{analysis:s.analysis,aiPrompt:t}),t&&e.jsxs("div",{className:"rounded-lg border border-edge bg-surface-alt",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-edge flex items-center justify-between",children:[e.jsx("h3",{className:"text-xs font-semibold text-foreground",children:"AI Prompt"}),e.jsxs("button",{onClick:x,className:"flex items-center gap-1 px-2 py-1 rounded text-[10px] text-muted hover:text-foreground hover:bg-surface transition-colors",children:[h?e.jsx(D,{className:"w-3 h-3"}):e.jsx(q,{className:"w-3 h-3"}),h?"Copied!":"Copy"]})]}),e.jsx("pre",{className:"p-4 text-[11px] text-foreground/80 overflow-x-auto whitespace-pre-wrap font-mono leading-relaxed max-h-60 overflow-y-auto",children:t})]}),c&&e.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 rounded-lg border border-green-500/30 bg-green-500/5",children:[e.jsx(D,{className:"w-4 h-4 text-green-500 shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-green-500",children:"Translation Complete"}),s.confidenceScore!=null&&e.jsxs("p",{className:"text-[10px] text-muted mt-0.5",children:["Confidence: ",Math.round(s.confidenceScore*100),"%"]})]})]}),!c&&e.jsxs("div",{className:"rounded-lg border border-edge bg-surface-alt",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-edge",children:[e.jsx("h3",{className:"text-xs font-semibold text-foreground",children:"Generated Code"}),e.jsx("p",{className:"text-[10px] text-muted mt-0.5",children:"Paste the AI-generated translation below to finalize this file."})]}),e.jsxs("div",{className:"p-4 space-y-3",children:[e.jsx("textarea",{value:n,onChange:b=>i(b.target.value),placeholder:"Paste generated code here...",className:"w-full h-48 px-3 py-2 rounded-md border border-edge bg-surface text-xs font-mono text-foreground placeholder:text-muted/50 resize-y focus:outline-none focus:ring-1 focus:ring-accent/50"}),e.jsx("button",{onClick:u,disabled:a||!n.trim(),className:"flex items-center gap-1.5 px-4 py-2 rounded-md bg-accent text-white text-xs font-medium hover:bg-accent/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:"Finalize Translation"})]})]})]})}function ft({project:s,files:t,summary:r,selectedFileId:o,onSelectFile:a,onPrepareAll:n,onDownloadAll:i,onFinalizeFile:h,prompts:m,loading:c}){const x=o?t.find(l=>l.id===o)??null:null,u=()=>{a(null)},b=l=>{o&&h(o,l)};return e.jsxs("div",{className:"flex h-full flex-col md:flex-row",children:[e.jsx("div",{className:"w-full md:w-60 border-b md:border-b-0 md:border-r border-edge overflow-hidden flex flex-col shrink-0",children:e.jsx(mt,{files:t,selectedFileId:o,onSelectFile:a})}),e.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:x?e.jsx(gt,{file:x,prompt:m==null?void 0:m[x.id],onBack:u,onFinalize:b,loading:c}):e.jsx(ht,{project:s,files:t,summary:r,onPrepareAll:n,onDownloadAll:i,loading:c})})]})}const bt={knowledge:null,searchResults:[],loading:!1,error:null};function jt(){const[s,t]=p.useState(bt),r=p.useCallback(async()=>{t(a=>({...a,loading:!0,error:null}));try{const a=await v.translationGetKnowledge();t(n=>({...n,knowledge:a,loading:!1}))}catch(a){t(n=>({...n,error:a instanceof Error?a.message:"Failed to load knowledge stats",loading:!1}))}},[]),o=p.useCallback(async a=>{t(n=>({...n,loading:!0,error:null}));try{const n=await v.translationSearchKnowledge(a);t(i=>({...i,searchResults:n.results,loading:!1}))}catch(n){t(i=>({...i,error:n instanceof Error?n.message:"Search failed",loading:!1}))}},[]);return p.useEffect(()=>{r()},[r]),[s,{search:o,refresh:r}]}function O({label:s,value:t}){return e.jsxs("div",{className:"rounded-lg border border-edge bg-surface-alt px-4 py-3",children:[e.jsx("p",{className:"text-[10px] text-muted",children:s}),e.jsx("p",{className:"text-lg font-semibold text-foreground",children:t})]})}function Nt({entry:s,expanded:t,onToggle:r,onSearch:o}){const a=s.metadata,n=s.confidence!=null?Math.round(s.confidence*100):null,i=n!=null?n>=80?"text-green-500":n>=50?"text-yellow-500":"text-red-500":"text-muted",h=(a==null?void 0:a.riskCount)??0;return e.jsxs("div",{className:"rounded-lg border border-edge bg-surface-alt px-4 py-3 cursor-pointer transition-colors hover:border-accent/30",onClick:r,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[t?e.jsx(W,{className:"w-3.5 h-3.5 text-muted flex-shrink-0"}):e.jsx(K,{className:"w-3.5 h-3.5 text-muted flex-shrink-0"}),e.jsx("p",{className:"text-xs font-medium text-foreground truncate flex-1",children:s.title}),e.jsx("span",{className:"text-[10px] text-muted flex-shrink-0",children:new Date(s.createdAt).toLocaleDateString()})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-1.5 ml-5",children:[s.sourceLanguage&&s.targetLanguage&&e.jsxs("span",{className:"text-[10px] text-muted",children:[s.sourceLanguage," → ",s.targetLanguage]}),n!=null&&e.jsxs("span",{className:`text-[10px] ${i}`,children:[n,"%"]})]}),t&&e.jsxs("div",{className:"mt-2 pt-2 border-t border-edge space-y-2 ml-5",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[a!=null&&a.sourceLanguage?e.jsx("span",{className:"px-2 py-0.5 text-[10px] rounded bg-blue-500/10 text-blue-400",children:String(a.sourceLanguage)}):null,e.jsx("span",{className:"text-[10px] text-muted",children:"→"}),a!=null&&a.targetLanguage?e.jsx("span",{className:"px-2 py-0.5 text-[10px] rounded bg-green-500/10 text-green-400",children:String(a.targetLanguage)}):null,a!=null&&a.scope?e.jsx("span",{className:"px-2 py-0.5 text-[10px] rounded bg-accent/10 text-accent",children:String(a.scope)}):null]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 text-[10px]",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-muted",children:"Confidence: "}),e.jsxs("span",{className:i,children:[n??"—","%"]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted",children:"Constructs: "}),e.jsx("span",{className:"text-foreground",children:(a==null?void 0:a.constructCount)??"—"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted",children:"Risks: "}),e.jsx("span",{className:h>0?"text-yellow-500":"text-green-500",children:h})]})]}),e.jsx("button",{type:"button",onClick:m=>{m.stopPropagation(),o(s.title)},className:"text-[10px] text-accent hover:text-accent/80 transition-colors",children:"View in Search"})]})]})}function yt(){var u,b,l;const[s,{search:t,refresh:r}]=jt(),[o,a]=p.useState(""),[n,i]=p.useState(null),h=d=>{d.preventDefault(),t(o)},m=()=>{r()},c=s.searchResults&&s.searchResults.length>0?s.searchResults:((u=s.knowledge)==null?void 0:u.recentEntries)??[],x=s.searchResults&&s.searchResults.length>0;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("form",{onSubmit:h,className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(te,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted"}),e.jsx("input",{type:"text",value:o,onChange:d=>a(d.target.value),placeholder:"Search knowledge base...",className:"w-full pl-8 pr-3 py-1.5 text-xs rounded-md border border-edge bg-surface text-foreground placeholder:text-muted focus:outline-none focus:border-accent/50"})]}),e.jsxs("button",{type:"button",onClick:m,disabled:s.loading,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-md border border-edge text-muted hover:text-foreground transition-colors cursor-pointer disabled:opacity-50",title:"Reindex knowledge",children:[e.jsx(V,{className:`w-3.5 h-3.5 ${s.loading?"animate-spin":""}`}),"Reindex"]})]}),s.loading&&!s.knowledge&&e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx($,{className:"w-6 h-6 text-muted animate-spin"})}),!s.loading&&!s.knowledge&&c.length===0&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 gap-3 text-center",children:[e.jsx(G,{className:"w-12 h-12 text-muted/40"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted",children:"No learnings yet."}),e.jsx("p",{className:"text-[10px] text-muted/60 mt-1",children:"Complete some translations to build the knowledge base."})]})]}),s.knowledge&&e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsx(O,{label:"Total Entries",value:s.knowledge.totalDocuments??0}),e.jsx(O,{label:"Language Pairs",value:((b=s.knowledge.byLanguagePair)==null?void 0:b.length)??0}),e.jsx(O,{label:"Avg Confidence",value:s.knowledge.avgConfidence!=null?`${Math.round(s.knowledge.avgConfidence*100)}%`:"—"})]}),((l=s.knowledge)==null?void 0:l.byLanguagePair)&&s.knowledge.byLanguagePair.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.knowledge.byLanguagePair.map(d=>e.jsxs("span",{className:"px-2 py-0.5 text-[10px] font-medium rounded bg-accent/10 text-accent",children:[d.pair," (",d.count,")"]},d.pair))}),c.length>0&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(G,{className:"w-3.5 h-3.5 text-accent"}),e.jsx("h3",{className:"text-xs font-semibold text-foreground",children:x?"Search Results":"Recent Entries"}),e.jsxs("span",{className:"text-[10px] text-muted",children:["(",c.length,")"]})]}),c.length>0&&e.jsx("div",{className:"space-y-2 max-h-80 overflow-auto",children:c.map(d=>e.jsx(Nt,{entry:d,expanded:n===d.id,onToggle:()=>i(n===d.id?null:d.id),onSearch:g=>{a(g),t(g)}},d.id))})]})}const vt=[{id:"convert",label:"Convert",icon:e.jsx(ge,{className:"w-3.5 h-3.5"})},{id:"history",label:"History",icon:e.jsx(ve,{className:"w-3.5 h-3.5"})},{id:"insights",label:"Insights",icon:e.jsx(H,{className:"w-3.5 h-3.5"})},{id:"knowledge",label:"Knowledge",icon:e.jsx(G,{className:"w-3.5 h-3.5"})},{id:"graph",label:"Graph",icon:e.jsx(B,{className:"w-3.5 h-3.5"})}],S={sourceCode:"",targetLanguage:"python",scope:"snippet",generatedCode:""};function wt({jobs:s}){const t=p.useMemo(()=>s.filter(a=>a.status==="done"&&a.confidenceScore!=null),[s]),{flowNodes:r,flowEdges:o}=p.useMemo(()=>{if(t.length===0)return{flowNodes:[],flowEdges:[]};const a=new Set,n=new Map;for(const c of t){a.add(c.sourceLanguage),a.add(c.targetLanguage);const x=`${c.sourceLanguage}->${c.targetLanguage}`,u=n.get(x)??{count:0,totalConf:0};u.count++,u.totalConf+=c.confidenceScore??0,n.set(x,u)}const i=[...a].map(c=>({id:c,data:{label:c},position:{x:0,y:0},style:{background:"rgba(99, 102, 241, 0.1)",border:"1px solid rgba(99, 102, 241, 0.3)",borderRadius:"8px",padding:"8px 16px",color:"#a5b4fc",fontSize:"12px",fontWeight:600}})),h=[...n.entries()].map(([c,x])=>{const[u,b]=c.split("->"),l=Math.round(x.totalConf/x.count*100),d=l>=80?"#22c55e":l>=50?"#eab308":"#ef4444";return{id:c,source:u,target:b,label:`x${x.count} · ${l}%`,style:{stroke:d,strokeWidth:2},labelStyle:{fill:"#9ca3af",fontSize:10},labelBgStyle:{fill:"#1e1e2e",fillOpacity:.9},animated:!0}}),m=new Z.graphlib.Graph().setDefaultEdgeLabel(()=>({}));return m.setGraph({rankdir:"LR",nodesep:80,ranksep:150}),i.forEach(c=>m.setNode(c.id,{width:120,height:40})),h.forEach(c=>m.setEdge(c.source,c.target)),Z.layout(m),i.forEach(c=>{const x=m.node(c.id);c.position={x:x.x-60,y:x.y-20}}),{flowNodes:i,flowEdges:h}},[t]);return t.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx(B,{className:"w-12 h-12 text-muted mx-auto mb-3"}),e.jsx("p",{className:"text-sm text-muted",children:"Translation graph visualization"}),e.jsx("p",{className:"text-[10px] text-muted mt-1",children:"Complete some translations to see the relationship graph"})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(B,{className:"w-4 h-4 text-accent"}),e.jsx("h3",{className:"text-xs font-semibold text-foreground",children:"Translation Flow Graph"}),e.jsxs("span",{className:"text-[10px] text-muted",children:["(",t.length," completed translations)"]})]}),e.jsx("div",{style:{height:400},className:"rounded-lg border border-edge bg-surface-alt",children:e.jsxs(de,{nodes:r,edges:o,fitView:!0,proOptions:{hideAttribution:!0},style:{background:"transparent"},children:[e.jsx(ie,{color:"#333",gap:20}),e.jsx(xe,{showInteractive:!1})]})})]})}function Tt(){var R;const[s,t]=p.useState("convert"),[r,o]=We(),[a,n]=qe(),[i,h]=Ze(),[m,c]=p.useState(S.sourceCode),[x,u]=p.useState(S.targetLanguage),[b,l]=p.useState(S.scope),[d,g]=p.useState(S.generatedCode),f=p.useCallback(j=>{S.sourceCode=j,c(j)},[]),y=p.useCallback(j=>{S.targetLanguage=j,u(j)},[]),C=p.useCallback(j=>{S.scope=j,l(j)},[]),k=p.useCallback(j=>{S.generatedCode=j,g(j)},[]),M=i.mode!=="idle",T=p.useCallback(j=>{h.upload(j,x)},[h,x]),L=r.phase;oe(p.useCallback(j=>{j.startsWith("translation:")&&L!=="analyzing"&&L!=="finalizing"&&n.refresh()},[n,L]));const w=()=>{o.analyze(m,x,"module")},I=()=>{o.finalize(d).then(()=>n.refresh())},A=()=>{o.reset(),f(""),k(""),y("python"),C("snippet")};return e.jsx("div",{className:"h-full overflow-auto",children:e.jsxs("div",{className:"p-4 space-y-4 max-w-5xl mx-auto",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ce,{className:"w-5 h-5 text-accent"}),e.jsx("h2",{className:"text-sm font-semibold text-foreground",children:"Language Convert"}),e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-warning/10 text-warning rounded-full",children:"Beta"})]}),e.jsx("div",{className:"flex gap-1 border-b border-edge pb-1",children:vt.map(j=>e.jsxs("button",{onClick:()=>t(j.id),className:`flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-t transition-colors ${s===j.id?"bg-accent text-white":"text-muted hover:text-foreground hover:bg-surface"}`,children:[j.icon,j.label]},j.id))}),s==="convert"&&e.jsxs("div",{className:"space-y-4",children:[e.jsx(dt,{onUpload:T,loading:i.loading}),M?e.jsx(ft,{project:i.project,files:i.files,summary:i.summary,selectedFileId:i.selectedFileId,onSelectFile:h.selectFile,onPrepareAll:()=>void h.prepareFiles(),onDownloadAll:()=>void h.downloadProject(),onFinalizeFile:(j,P)=>void h.finalizeFile(j,P),loading:i.loading}):e.jsxs(e.Fragment,{children:[e.jsx(Qe,{sourceCode:m,setSourceCode:f,targetLanguage:x,setTargetLanguage:y,generatedCode:d,setGeneratedCode:k,translation:r,onAnalyze:w,onFinalize:I,onReset:A}),r.phase==="analyzing"&&e.jsxs("div",{className:"rounded-lg border-2 border-accent/40 bg-accent/5 p-5 transition-all duration-300",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 rounded-full bg-accent/20 animate-ping"}),e.jsx($,{className:"w-5 h-5 text-accent animate-spin relative"})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-xs font-semibold text-foreground",children:"Analyzing your code..."}),e.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[e.jsx("span",{className:"text-[10px] text-accent font-medium",children:"Detecting language"}),e.jsx("span",{className:"text-[10px] text-muted",children:"→"}),e.jsx("span",{className:"text-[10px] text-muted",children:"Analyzing constructs"}),e.jsx("span",{className:"text-[10px] text-muted",children:"→"}),e.jsx("span",{className:"text-[10px] text-muted",children:"Generating prompt"})]})]})]}),e.jsx("div",{className:"mt-3 h-1 rounded-full bg-surface overflow-hidden",children:e.jsx("div",{className:"h-full bg-accent/60 rounded-full animate-pulse",style:{width:"60%"}})})]}),r.phase==="finalizing"&&e.jsx("div",{className:"rounded-lg border-2 border-green-500/40 bg-green-500/5 p-5 transition-all duration-300",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx($,{className:"w-5 h-5 text-green-500 animate-spin"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-foreground",children:"Finalizing translation..."}),e.jsx("p",{className:"text-[10px] text-muted mt-1",children:"Validating output and generating evidence pack"})]})]})}),r.analysis&&e.jsx("div",{className:"animate-in fade-in-0 duration-300",style:{animationFillMode:"both"},children:e.jsx(ne,{analysis:r.analysis,deterministicCode:(R=r.prepareResult)==null?void 0:R.deterministicCode,targetLanguage:S.targetLanguage})}),r.finalizeResult&&e.jsx("div",{className:"animate-in fade-in-0 duration-300",style:{animationFillMode:"both"},children:e.jsx(rt,{result:r.finalizeResult})})]})]}),(s==="history"||s==="insights")&&e.jsx(ct,{state:a,actions:n,showInsights:s==="insights"}),s==="knowledge"&&e.jsx(yt,{}),s==="graph"&&e.jsx(wt,{jobs:a.jobs})]})})}export{Tt as LanguagesTab};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as s,a as v,j as t}from"./index-
|
|
1
|
+
import{r as s,a as v,j as t}from"./index-DrvFzUJS.js";function S(){const[r,l]=s.useState([]),[c,h]=s.useState(!0),d=s.useRef(0),p=s.useCallback(async()=>{try{const{logs:n}=await v.getLogs();l(n),n.length>0&&(d.current=n[n.length-1].id)}finally{h(!1)}},[]),x=s.useCallback(async()=>{await v.clearLogs(),l([]),d.current=0},[]);return s.useEffect(()=>{p()},[p]),s.useEffect(()=>{const n=new EventSource("/api/v1/events"),i=f=>{try{const o=JSON.parse(f.data),a={id:o.payload.id,level:o.payload.level,message:o.payload.message,context:o.payload.context,timestamp:o.timestamp};a.id>d.current&&(d.current=a.id,l(b=>[...b,a]))}catch{}};return n.addEventListener("log:entry",i),n.onerror=()=>{n.close(),setTimeout(()=>{},5e3)},()=>n.close()},[]),{logs:r,loading:c,clearLogs:x,refresh:p}}const k={info:"bg-blue-500/20 text-blue-400",warn:"bg-yellow-500/20 text-yellow-400",error:"bg-red-500/20 text-red-400",success:"bg-green-500/20 text-green-400",debug:"bg-gray-500/20 text-gray-400"},E=["info","warn","error","success","debug"];function L(r){return new Date(r).toLocaleTimeString("en-US",{hour12:!1})}function y(r){return!r||Object.keys(r).length===0?"":Object.entries(r).map(([l,c])=>`${l}="${String(c)}"`).join(" ")}function j(r){return r.map(l=>{const c=y(l.context);return`[${L(l.timestamp)}] [${l.level.toUpperCase()}] ${l.message}${c?" "+c:""}`}).join(`
|
|
2
2
|
`)}function O(){const{logs:r,loading:l,clearLogs:c,refresh:h}=S(),[d,p]=s.useState("all"),[x,n]=s.useState(""),[i,f]=s.useState(!0),o=s.useRef(null),a=s.useMemo(()=>{let e=r;if(d!=="all"&&(e=e.filter(u=>u.level===d)),x.trim()){const u=x.toLowerCase();e=e.filter(g=>g.message.toLowerCase().includes(u))}return e},[r,d,x]);s.useEffect(()=>{i&&o.current&&(o.current.scrollTop=o.current.scrollHeight)},[a,i]);const b=s.useCallback(()=>{if(!o.current)return;const{scrollTop:e,scrollHeight:u,clientHeight:g}=o.current,m=u-e-g<40;f(m)},[]),C=s.useCallback(async()=>{const e=j(a);await navigator.clipboard.writeText(e)},[a]),N=s.useCallback(()=>{const e=j(a),u=new Blob([e],{type:"text/plain"}),g=URL.createObjectURL(u),m=document.createElement("a");m.href=g,m.download=`mcp-graph-logs-${new Date().toISOString().slice(0,19).replace(/:/g,"-")}.txt`,m.click(),URL.revokeObjectURL(g)},[a]),w=s.useCallback(async()=>{await c()},[c]);return l?t.jsx("div",{className:"flex items-center justify-center h-full text-muted",children:"Loading logs..."}):t.jsxs("div",{className:"flex flex-col h-full","data-testid":"logs-tab",children:[t.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-edge bg-surface-alt",children:[t.jsxs("select",{value:d,onChange:e=>p(e.target.value),className:"px-2 py-1 text-sm rounded border border-edge bg-surface text-foreground","data-testid":"log-level-filter",children:[t.jsx("option",{value:"all",children:"All Levels"}),E.map(e=>t.jsx("option",{value:e,children:e.charAt(0).toUpperCase()+e.slice(1)},e))]}),t.jsx("input",{type:"text",value:x,onChange:e=>n(e.target.value),placeholder:"Search logs...",className:"flex-1 px-2 py-1 text-sm rounded border border-edge bg-surface text-foreground placeholder:text-muted","data-testid":"log-search"}),t.jsx("button",{onClick:()=>f(!i),className:`px-2 py-1 text-xs rounded border ${i?"border-accent text-accent":"border-edge text-muted"}`,title:i?"Auto-scroll enabled":"Auto-scroll paused",children:i?"Auto-scroll ON":"Auto-scroll OFF"}),t.jsx("button",{onClick:C,className:"px-2 py-1 text-xs rounded border border-edge text-muted hover:text-foreground",title:"Copy all visible logs",children:"Copy"}),t.jsx("button",{onClick:N,className:"px-2 py-1 text-xs rounded border border-edge text-muted hover:text-foreground",title:"Download logs as .txt",children:"Download"}),t.jsx("button",{onClick:w,className:"px-2 py-1 text-xs rounded border border-red-500/30 text-red-400 hover:bg-red-500/10",title:"Clear all logs",children:"Clear"}),t.jsx("button",{onClick:()=>void h(),className:"px-2 py-1 text-xs rounded border border-edge text-muted hover:text-foreground",title:"Refresh logs",children:"Refresh"}),t.jsxs("span",{className:"text-xs text-muted",children:[a.length," entries"]})]}),t.jsx("div",{ref:o,onScroll:b,className:"flex-1 overflow-y-auto font-mono text-xs p-2","data-testid":"log-list",children:a.length===0?t.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-2 text-muted",children:[t.jsx("p",{className:"text-xs",children:"No logs to display"}),t.jsx("p",{className:"text-[10px] text-muted/60",children:"Logs appear when mcp-graph tools are executed"})]}):a.map(e=>t.jsxs("div",{className:"flex items-start gap-2 py-0.5 hover:bg-surface-alt",children:[t.jsx("span",{className:"text-muted shrink-0",children:L(e.timestamp)}),t.jsx("span",{className:`px-1.5 py-0 rounded text-[10px] font-semibold uppercase shrink-0 ${k[e.level]}`,children:e.level}),t.jsx("span",{className:"text-foreground",children:e.message}),e.context&&Object.keys(e.context).length>0&&t.jsx("span",{className:"text-muted",children:y(e.context)})]},e.id))})]})}export{O as LogsTab};
|