@mcp-graph-workflow/mcp-graph 5.20.1 → 5.22.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/web/dashboard/dist/assets/benchmark-tab-D7nae4k4.js +1 -0
- package/dist/web/dashboard/dist/assets/circle-alert-vaRHjxbG.js +6 -0
- package/dist/web/dashboard/dist/assets/context-tab-DRUGmBRL.js +1 -0
- package/dist/web/dashboard/dist/assets/{gitnexus-tab-Caz7v7Mn.js → gitnexus-tab-h8BwIua3.js} +10 -10
- package/dist/web/dashboard/dist/assets/{graph-section-B2T_NMja.js → graph-section-C4ymXtzh.js} +1 -1
- package/dist/web/dashboard/dist/assets/graph-tab-C6nWMQkR.js +6 -0
- package/dist/web/dashboard/dist/assets/{graph-utils-CpifDP5W.js → graph-utils-DkRXfigF.js} +1 -1
- package/dist/web/dashboard/dist/assets/{index-C9AGF8Ai.js → index-BW0cq1-5.js} +1 -1
- package/dist/web/dashboard/dist/assets/index-CvAguK65.css +1 -0
- package/dist/web/dashboard/dist/assets/index-DSPPavjF.js +218 -0
- package/dist/web/dashboard/dist/assets/{index-BPPSD6wP.js → index-DmT4Jne7.js} +1 -1
- package/dist/web/dashboard/dist/assets/{insights-tab-8XuKAe-4.js → insights-tab-CL9LCuow.js} +15 -15
- package/dist/web/dashboard/dist/assets/journey-tab-CbJSfdpz.js +1 -0
- package/dist/web/dashboard/dist/assets/languages-tab-Vjkz6r99.js +70 -0
- package/dist/web/dashboard/dist/assets/loader-circle-CrUmRfZB.js +6 -0
- package/dist/web/dashboard/dist/assets/{logs-tab-Y5DvtoGU.js → logs-tab-CeH_wY9u.js} +2 -2
- package/dist/web/dashboard/dist/assets/lsp-tab-BLIpJrAk.js +49 -0
- package/dist/web/dashboard/dist/assets/memories-tab-BHOvEW0o.js +1 -0
- package/dist/web/dashboard/dist/assets/prd-backlog-tab-BBUG4V7M.js +1 -0
- package/dist/web/dashboard/dist/assets/refresh-cw-DRsAUgYq.js +6 -0
- package/dist/web/dashboard/dist/assets/{siebel-tab-Bkeox_-_.js → siebel-tab-DZXhcoUu.js} +3 -3
- package/dist/web/dashboard/dist/assets/skills-tab-_A8OYt_b.js +1 -0
- package/dist/web/dashboard/dist/assets/{style-Cca8j3c-.js → style-DpBYmOVU.js} +1 -1
- package/dist/web/dashboard/dist/assets/triangle-alert-N0TixBQV.js +16 -0
- package/dist/web/dashboard/dist/index.html +2 -2
- package/package.json +1 -1
- package/dist/web/dashboard/dist/assets/benchmark-tab-BxKC16Rh.js +0 -1
- package/dist/web/dashboard/dist/assets/context-tab-CyTA0xHn.js +0 -1
- package/dist/web/dashboard/dist/assets/graph-tab-H8UjUBJg.js +0 -1
- package/dist/web/dashboard/dist/assets/index-CW7bjrwy.js +0 -218
- package/dist/web/dashboard/dist/assets/index-DDQD2WTj.css +0 -1
- package/dist/web/dashboard/dist/assets/journey-tab-L-g_jwf1.js +0 -1
- package/dist/web/dashboard/dist/assets/languages-tab-171i5Bxw.js +0 -63
- package/dist/web/dashboard/dist/assets/lsp-tab-Dprc5zKc.js +0 -64
- package/dist/web/dashboard/dist/assets/memories-tab-DvgKhmWu.js +0 -1
- package/dist/web/dashboard/dist/assets/prd-backlog-tab-OHV_0-dF.js +0 -1
- package/dist/web/dashboard/dist/assets/skills-tab-DCHjQiA2.js +0 -1
- package/dist/web/dashboard/dist/assets/triangle-alert-uww45pBS.js +0 -11
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as c,a as k,j as e}from"./index-DSPPavjF.js";import{u as F,a as P,i as H,B as z,C as R,M as V,H as J,P as O}from"./style-DpBYmOVU.js";import"./index-BW0cq1-5.js";const M={landing:"#2196f3",form:"#ff9800",selection:"#4caf50",listing:"#9c27b0",comparison:"#e91e63",detail:"#00bcd4",map:"#009688",calculator:"#ffc107",confirmation:"#3f51b5",success:"#4caf50",dashboard:"#607d8b",page:"#757575"},W={navigation:"#6c757d",form_submit:"#2196f3",redirect:"#ff9800",back:"#9e9e9e"},D=280,X=220,Y=c.memo(function({data:o}){const{screen:a,screenshotUrl:s,onSelect:n}=o,r=M[a.screenType]??"#757575";return e.jsxs(e.Fragment,{children:[e.jsx(J,{type:"target",position:O.Top,className:"!w-2 !h-2"}),e.jsxs("div",{className:"bg-surface border-2 rounded-lg shadow-md hover:shadow-lg transition-shadow cursor-pointer overflow-hidden",style:{borderColor:r,width:D},onClick:()=>n(a),children:[e.jsxs("div",{className:"relative w-full bg-surface-elevated",style:{height:140},children:[s?e.jsx("img",{src:s,alt:a.title,className:"w-full h-full object-cover",loading:"lazy"}):e.jsx("div",{className:"flex items-center justify-center h-full text-muted text-xs",children:"No screenshot"}),e.jsx("span",{className:"absolute top-1.5 left-1.5 text-[9px] font-bold uppercase px-1.5 py-0.5 rounded text-white",style:{background:r},children:a.screenType})]}),e.jsxs("div",{className:"p-2",children:[e.jsx("div",{className:"text-sm font-semibold leading-tight line-clamp-1",children:a.title}),a.url&&e.jsx("div",{className:"text-[10px] text-muted truncate mt-0.5",children:a.url}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[a.fields&&a.fields.length>0&&e.jsxs("span",{className:"text-[9px] px-1 py-0.5 rounded bg-surface-elevated text-muted",children:[a.fields.length," fields"]}),a.ctas&&a.ctas.length>0&&e.jsxs("span",{className:"text-[9px] px-1 py-0.5 rounded bg-surface-elevated text-muted",children:[a.ctas.length," CTAs"]})]})]})]}),e.jsx(J,{type:"source",position:O.Bottom,className:"!w-2 !h-2"})]})}),B={journeyScreen:Y};function G(t,o){var d;const a=new Map,s=new Map;for(const l of t)a.set(l.id,[]),s.set(l.id,0);for(const l of o)(d=a.get(l.from))==null||d.push(l.to),s.set(l.to,(s.get(l.to)??0)+1);const n=[],r=[],f=new Set;for(const l of t)(s.get(l.id)??0)===0&&r.push(l.id);for(;r.length>0;){const l=[...r];n.push(l),r.length=0;for(const i of l){f.add(i);for(const x of a.get(i)??[])if(!f.has(x)){const b=(s.get(x)??1)-1;s.set(x,b),b<=0&&!f.has(x)&&r.push(x)}}}for(const l of t)f.has(l.id)||(n.length===0&&n.push([]),n[n.length-1].push(l.id));const j=new Map(t.map(l=>[l.id,l])),u=D+60,v=X+80,y=[];for(let l=0;l<n.length;l++){const i=n[l],b=-(i.length*u)/2+u/2;for(let N=0;N<i.length;N++){const m=j.get(i[N]);m&&y.push({id:m.id,type:"journeyScreen",position:{x:m.positionX!==0?m.positionX:b+N*u,y:m.positionY!==0?m.positionY:l*v},data:{screen:m,screenshotUrl:m.screenshot?`/api/v1/journey/screenshots/_/${m.screenshot}`:void 0,onSelect:()=>{}}})}}return y}function L(t){return t.map(o=>({id:o.id,source:o.from,target:o.to,label:o.label??"",type:"smoothstep",animated:o.type==="form_submit",style:{stroke:W[o.type]??"#6c757d",strokeWidth:2},labelStyle:{fontSize:10,fill:"var(--color-text-muted)"},labelBgStyle:{fill:"var(--color-bg)",fillOpacity:.8}}))}function $({screen:t,onClose:o}){const a=M[t.screenType]??"#757575";return e.jsxs("div",{className:"w-80 h-full border-l border-edge bg-surface overflow-y-auto p-4 flex flex-col gap-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-bold uppercase px-2 py-0.5 rounded text-white",style:{background:a},children:t.screenType}),e.jsx("button",{onClick:o,className:"text-muted hover:text-foreground",children:"X"})]}),e.jsx("h3",{className:"text-lg font-semibold",children:t.title}),t.url&&e.jsx("div",{className:"text-xs text-muted break-all",children:t.url}),t.description&&e.jsx("p",{className:"text-sm text-muted",children:t.description}),t.screenshot&&e.jsx("div",{className:"rounded-lg overflow-hidden border border-edge",children:e.jsx("img",{src:`/api/v1/journey/screenshots/_/${t.screenshot}`,alt:t.title,className:"w-full"})}),t.fields&&t.fields.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"text-xs font-semibold uppercase text-muted mb-1.5",children:["Form Fields (",t.fields.length,")"]}),e.jsx("div",{className:"space-y-1.5",children:t.fields.map(s=>e.jsxs("div",{className:"flex items-center gap-2 text-sm bg-surface-alt rounded px-2 py-1",children:[e.jsx("span",{className:"font-mono text-xs text-accent",children:s.type}),e.jsx("span",{children:s.label??s.name}),s.required&&e.jsx("span",{className:"text-[9px] text-red-400 font-bold",children:"*"})]},s.name))})]}),t.ctas&&t.ctas.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"text-xs font-semibold uppercase text-muted mb-1.5",children:["CTAs (",t.ctas.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-1",children:t.ctas.map(s=>e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-accent text-white",children:s},s))})]}),t.metadata&&Object.keys(t.metadata).length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-semibold uppercase text-muted mb-1.5",children:"Metadata"}),e.jsx("pre",{className:"text-[10px] bg-surface-alt rounded p-2 overflow-x-auto",children:JSON.stringify(t.metadata,null,2)})]})]})}function T({maps:t,selectedId:o,onSelect:a,onImport:s,loading:n}){return n?e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 border-b border-edge bg-surface-alt",children:[e.jsx("div",{className:"h-4 w-16 rounded bg-surface animate-pulse"}),e.jsx("div",{className:"h-7 flex-1 rounded bg-surface animate-pulse"}),e.jsx("div",{className:"h-7 w-20 rounded bg-surface animate-pulse"})]}),e.jsx("div",{className:"flex-1 bg-surface-alt animate-pulse rounded-lg m-4"})]}):t.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4 text-muted",children:[e.jsx("div",{className:"text-5xl",children:"🗺"}),e.jsx("p",{className:"text-sm font-medium",children:"No journey maps yet"}),e.jsx("p",{className:"text-xs text-center max-w-xs",children:"Import a journey map JSON file or capture website screens to create a journey flow visualization."}),e.jsx("button",{onClick:s,className:"px-4 py-2 rounded-lg bg-accent text-white text-sm hover:opacity-90 transition-opacity",children:"Import Journey Map"})]}):e.jsxs("div",{className:"flex items-center gap-2 p-2 border-b border-edge bg-surface-alt",children:[e.jsx("label",{className:"text-xs font-medium text-muted",children:"Journey:"}),e.jsx("select",{value:o??"",onChange:r=>a(r.target.value),className:"text-sm bg-surface border border-edge rounded px-2 py-1 flex-1",children:t.map(r=>e.jsx("option",{value:r.id,children:r.name},r.id))}),e.jsx("button",{onClick:s,className:"text-xs px-2 py-1 rounded bg-surface-elevated hover:bg-edge text-muted",children:"+ Import"})]})}function U({variants:t,activeVariant:o,onSelect:a}){return t.length===0?null:e.jsxs("div",{className:"flex items-center gap-2 p-2 border-b border-edge",children:[e.jsx("label",{className:"text-xs font-medium text-muted",children:"Variant:"}),e.jsx("button",{onClick:()=>a(null),className:`text-xs px-2 py-1 rounded ${o===null?"bg-accent text-white":"bg-surface-elevated text-muted"}`,children:"All"}),t.map(s=>e.jsx("button",{onClick:()=>a(s.id),className:`text-xs px-2 py-1 rounded ${o===s.id?"bg-accent text-white":"bg-surface-elevated text-muted"}`,title:s.description,children:s.name},s.id))]})}function _({open:t,onClose:o,onImported:a}){const[s,n]=c.useState(""),[r,f]=c.useState(null),[j,u]=c.useState(!1);if(!t)return null;const v=async()=>{f(null),u(!0);try{const d=JSON.parse(s);await k.importJourneyMap(d),a(),o(),n("")}catch(d){f(d instanceof Error?d.message:"Import failed")}finally{u(!1)}},y=d=>{var x;const l=(x=d.target.files)==null?void 0:x[0];if(!l)return;const i=new FileReader;i.onload=()=>n(i.result),i.readAsText(l)};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:e.jsxs("div",{className:"bg-surface rounded-lg shadow-xl w-full max-w-lg p-6 max-h-[80vh] overflow-y-auto",children:[e.jsx("h2",{className:"text-lg font-semibold mb-4",children:"Import Journey Map"}),e.jsxs("div",{className:"mb-3",children:[e.jsx("label",{className:"block text-sm font-medium mb-1",children:"Upload JSON file"}),e.jsx("input",{type:"file",accept:".json",onChange:y,className:"text-sm"})]}),e.jsxs("div",{className:"mb-3",children:[e.jsx("label",{className:"block text-sm font-medium mb-1",children:"Or paste JSON"}),e.jsx("textarea",{value:s,onChange:d=>n(d.target.value),rows:10,className:"w-full text-xs font-mono bg-surface-alt border border-edge rounded p-2",placeholder:'{"journey": {"name": "..."}, "screens": [...], "edges": [...]}'})]}),r&&e.jsx("div",{className:"text-sm text-danger mb-3",children:r}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{onClick:o,className:"px-3 py-1.5 text-sm rounded-lg border border-edge hover:bg-surface-alt",children:"Cancel"}),e.jsx("button",{onClick:v,disabled:!s.trim()||j,className:"px-3 py-1.5 text-sm rounded-lg bg-accent text-white hover:opacity-90 disabled:opacity-50",children:j?"Importing...":"Import"})]})]})})}const q={hideAttribution:!0};function ee(){const[t,o]=c.useState([]),[a,s]=c.useState(null),[n,r]=c.useState(null),[f,j]=c.useState(null),[u,v]=c.useState(null),[y,d]=c.useState(!1),[l,i]=c.useState(!0),[x,b,N]=F([]),[m,C,A]=P([]),S=c.useCallback(async()=>{try{const p=await k.getJourneyMaps();o(p.maps),p.maps.length>0&&!a&&s(p.maps[0].id)}catch{o([])}finally{i(!1)}},[a]),E=c.useCallback(async p=>{try{const h=await k.getJourneyMap(p);r(h)}catch{r(null)}},[]);c.useEffect(()=>{S()},[S]),c.useEffect(()=>{a&&E(a)},[a,E]);const w=c.useMemo(()=>{if(!n)return null;if(!u)return n;const p=n.variants.find(g=>g.id===u);if(!p)return n;const h=new Set(p.path);return{...n,screens:n.screens.filter(g=>h.has(g.id)),edges:n.edges.filter(g=>h.has(g.from)&&h.has(g.to))}},[n,u]);c.useEffect(()=>{if(!w){b([]),C([]);return}const h=G(w.screens,w.edges).map(g=>({...g,data:{...g.data,onSelect:j}}));b(h),C(L(w.edges))},[w,b,C]);const I=c.useCallback(()=>{i(!0),S()},[S]);return l||t.length===0?e.jsxs(e.Fragment,{children:[e.jsx(T,{maps:t,selectedId:a,onSelect:s,onImport:()=>d(!0),loading:l}),e.jsx(_,{open:y,onClose:()=>d(!1),onImported:I})]}):e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsx(T,{maps:t,selectedId:a,onSelect:s,onImport:()=>d(!0),loading:!1}),n&&e.jsx(U,{variants:n.variants,activeVariant:u,onSelect:v}),e.jsxs("div",{className:"flex-1 flex min-h-0",children:[e.jsx("div",{className:"flex-1",children:e.jsxs(H,{nodes:x,edges:m,onNodesChange:N,onEdgesChange:A,nodeTypes:B,proOptions:q,fitView:!0,minZoom:.1,maxZoom:3,defaultViewport:{x:0,y:0,zoom:.7},children:[e.jsx(z,{color:"var(--color-border)",gap:20}),e.jsx(R,{position:"bottom-left"}),e.jsx(V,{nodeColor:p=>{const h=p.data;return M[h.screen.screenType]??"#757575"},maskColor:"rgba(0,0,0,0.1)",position:"bottom-right"})]})}),f&&e.jsx($,{screen:f,onClose:()=>j(null)})]}),e.jsx(_,{open:y,onClose:()=>d(!1),onImported:I})]})}export{ee as JourneyTab};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import{c as b,r as o,a as k,j as e,d as E,u as D,L as P}from"./index-DSPPavjF.js";import{L as T}from"./loader-circle-CrUmRfZB.js";import{T as I,C as F,a as J}from"./triangle-alert-N0TixBQV.js";import{R as A}from"./refresh-cw-DRsAUgYq.js";/**
|
|
2
|
+
* @license lucide-react v1.7.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const H=[["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"}]],O=b("arrow-left-right",H);/**
|
|
7
|
+
* @license lucide-react v1.7.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/const V=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],B=b("check",V);/**
|
|
12
|
+
* @license lucide-react v1.7.0 - ISC
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the ISC license.
|
|
15
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
+
*/const G=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],U=b("circle-check-big",G);/**
|
|
17
|
+
* @license lucide-react v1.7.0 - ISC
|
|
18
|
+
*
|
|
19
|
+
* This source code is licensed under the ISC license.
|
|
20
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
+
*/const q=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]],W=b("clock",q);/**
|
|
22
|
+
* @license lucide-react v1.7.0 - ISC
|
|
23
|
+
*
|
|
24
|
+
* This source code is licensed under the ISC license.
|
|
25
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
+
*/const Y=[["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"}]],K=b("copy",Y);/**
|
|
27
|
+
* @license lucide-react v1.7.0 - ISC
|
|
28
|
+
*
|
|
29
|
+
* This source code is licensed under the ISC license.
|
|
30
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
+
*/const Q=[["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"}]],X=b("cpu",Q);/**
|
|
32
|
+
* @license lucide-react v1.7.0 - ISC
|
|
33
|
+
*
|
|
34
|
+
* This source code is licensed under the ISC license.
|
|
35
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
36
|
+
*/const Z=[["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"}]],ee=b("eye",Z);/**
|
|
37
|
+
* @license lucide-react v1.7.0 - ISC
|
|
38
|
+
*
|
|
39
|
+
* This source code is licensed under the ISC license.
|
|
40
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
41
|
+
*/const te=[["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"}]],se=b("file-code-corner",te);/**
|
|
42
|
+
* @license lucide-react v1.7.0 - ISC
|
|
43
|
+
*
|
|
44
|
+
* This source code is licensed under the ISC license.
|
|
45
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
46
|
+
*/const ae=[["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"}]],re=b("inbox",ae);/**
|
|
47
|
+
* @license lucide-react v1.7.0 - ISC
|
|
48
|
+
*
|
|
49
|
+
* This source code is licensed under the ISC license.
|
|
50
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
51
|
+
*/const ne=[["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"}]],de=b("play",ne);/**
|
|
52
|
+
* @license lucide-react v1.7.0 - ISC
|
|
53
|
+
*
|
|
54
|
+
* This source code is licensed under the ISC license.
|
|
55
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
56
|
+
*/const le=[["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=b("rotate-ccw",le);/**
|
|
57
|
+
* @license lucide-react v1.7.0 - ISC
|
|
58
|
+
*
|
|
59
|
+
* This source code is licensed under the ISC license.
|
|
60
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
61
|
+
*/const ce=[["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"}]],ie=b("shield",ce);/**
|
|
62
|
+
* @license lucide-react v1.7.0 - ISC
|
|
63
|
+
*
|
|
64
|
+
* This source code is licensed under the ISC license.
|
|
65
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
66
|
+
*/const xe=[["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"}]],me=b("trash-2",xe),L={phase:"idle",analysis:null,prepareResult:null,finalizeResult:null,error:null,loading:!1};function ue(){var m;const[s,a]=o.useState(L),r=o.useCallback(async(u,h,p="snippet")=>{a(d=>({...d,phase:"analyzing",loading:!0,error:null}));try{const l=new Promise((j,t)=>setTimeout(()=>t(new Error("Analysis timed out after 30s. Please try again.")),3e4)),g=await Promise.race([k.translationCreateJob(u,h,p),l]);a({phase:"prepared",analysis:g.analysis,prepareResult:g,finalizeResult:null,error:null,loading:!1})}catch(d){a(l=>({...l,phase:"error",error:d instanceof Error?d.message:"Analysis failed",loading:!1}))}},[]),n=o.useCallback(async u=>{var p;const h=(p=s.prepareResult)==null?void 0:p.jobId;if(!h){a(d=>({...d,phase:"error",error:"No active job to finalize"}));return}a(d=>({...d,phase:"finalizing",loading:!0,error:null}));try{const d=await k.translationFinalize(h,u);a(l=>({...l,phase:"done",finalizeResult:d,loading:!1}))}catch(d){a(l=>({...l,phase:"error",error:d instanceof Error?d.message:"Finalize failed",loading:!1}))}},[(m=s.prepareResult)==null?void 0:m.jobId]),c=o.useCallback(()=>{a(L)},[]);return[s,{analyze:r,finalize:n,reset:c}]}function pe(){const[s,a]=o.useState([]),[r,n]=o.useState(null),[c,m]=o.useState(!0),[u,h]=o.useState(null),p=o.useCallback(async()=>{m(!0),h(null);try{const[l,g]=await Promise.all([k.translationListJobs(),k.translationStats()]);a(l.jobs),n(g)}catch(l){h(l instanceof Error?l.message:"Failed to load history")}finally{m(!1)}},[]),d=o.useCallback(async l=>{try{await k.translationDeleteJob(l),a(j=>j.filter(t=>t.id!==l));const g=await k.translationStats();n(g)}catch(g){h(g instanceof Error?g.message:"Delete failed")}},[]);return o.useEffect(()=>{p()},[p]),[{jobs:s,stats:r,loading:c,error:u},{refresh:p,deleteJob:d}]}const he=["python","javascript","typescript","java","csharp","go","rust","ruby","php","swift","kotlin","scala","cpp"],ge=["snippet","function","module"];function fe({sourceCode:s,setSourceCode:a,targetLanguage:r,setTargetLanguage:n,scope:c,setScope:m,generatedCode:u,setGeneratedCode:h,translation:p,onAnalyze:d,onFinalize:l,onReset:g}){var i;const{phase:j,prepareResult:t,error:x,loading:y}=p,N=j==="idle"||j==="error",w=j==="prepared",C=j==="done",[S,z]=o.useState(!1),$=()=>{t!=null&&t.prompt&&(navigator.clipboard.writeText(t.prompt),z(!0),setTimeout(()=>z(!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:[!N&&!w&&!C&&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:f=>a(f.target.value),placeholder:"// Paste your code here...",rows:10,disabled:!N,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:[(i=p.analysis)!=null&&i.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:p.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:f=>n(f.target.value),disabled:!N,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:he.map(f=>e.jsx("option",{value:f,children:f},f))}),e.jsx("div",{className:"flex gap-1",children:ge.map(f=>e.jsx("button",{onClick:()=>m(f),disabled:!N,className:`flex-1 px-2 py-1.5 text-[10px] font-medium rounded-md border transition-colors disabled:opacity-50 ${c===f?"border-accent bg-accent/10 text-accent":"border-edge bg-surface text-muted hover:text-foreground"}`,children:f},f))})]}),N&&e.jsxs("button",{onClick:d,disabled:!s.trim()||y,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:[y?e.jsx(T,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(de,{className:"w-3.5 h-3.5"}),y?"Analyzing...":"Analyze"]}),(w||C)&&e.jsxs("button",{onClick:g,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"]})]})]})]}),x&&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:x}),w&&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.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:$,className:`flex items-center gap-1 px-2 py-1 text-[10px] rounded border transition-all duration-200 ${S?"border-green-500/30 text-green-500 bg-green-500/5":"border-edge text-muted hover:text-foreground"}`,children:[S?e.jsx(B,{className:"w-3 h-3"}):e.jsx(K,{className:"w-3 h-3"}),S?"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:t.prompt.length>3e3?t.prompt.slice(0,3e3)+`
|
|
67
|
+
|
|
68
|
+
... (truncated, use Copy for full prompt)`:t.prompt}),e.jsx("textarea",{value:u,onChange:f=>h(f.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:l,disabled:!u.trim()||y,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:[y?e.jsx(T,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(U,{className:"w-3.5 h-3.5"}),y?"Finalizing...":"Finalize Translation"]})]})]})]})}function R({value:s,max:a=100,label:r}){const n=Math.min(100,Math.round(s/a*100)),c=n>=80?"bg-green-500":n>=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:[n,"%"]})]}),e.jsx("div",{className:"h-1.5 rounded-full bg-surface overflow-hidden",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":`${r}: ${n}%`,children:e.jsx("div",{className:`h-full rounded-full ${c} transition-all duration-500`,style:{width:`${n}%`}})})]})}function be({analysis:s}){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(X,{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(R,{value:s.complexityScore,label:"Complexity"}),e.jsx(R,{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(a=>e.jsxs("span",{className:"px-1.5 py-0.5 text-[10px] rounded border border-edge bg-surface text-foreground",title:`count: ${a.count}, confidence: ${Math.round(a.confidence*100)}%`,children:[a.canonicalName," ",e.jsxs("span",{className:"text-muted",children:["x",a.count]})]},a.canonicalName))})]}),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(I,{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 je({score:s}){const a=Math.round(s*100),r=a>=80?"bg-green-500/10 text-green-500":a>=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:[a,"%"]})}const ye={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 Ne({result:s}){if(!s)return null;const{evidence:a}=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(ie,{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(je,{score:a.confidenceScore})]}),e.jsxs("div",{className:"p-4 space-y-4",children:[a.translatedConstructs.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[e.jsx(se,{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:a.translatedConstructs.map((r,n)=>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})]},n))})]})]}),a.risks.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[e.jsx(I,{className:"w-3 h-3 text-yellow-500"}),e.jsxs("p",{className:"text-[10px] text-muted font-medium",children:["Risks (",a.risks.length,")"]})]}),e.jsx("div",{className:"space-y-1.5",children:a.risks.map((r,n)=>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 ${ye[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})]})]},n))})]}),a.humanReviewPoints.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[e.jsx(ee,{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:a.humanReviewPoints.map((r,n)=>e.jsx("li",{children:r},n))})]}),a.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:a.diff})]})]})]})}const ve={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 we(s){const a=Date.now(),r=new Date(s).getTime(),n=a-r,c=Math.floor(n/6e4);if(c<1)return"just now";if(c<60)return`${c}m ago`;const m=Math.floor(c/60);if(m<24)return`${m}h ago`;const u=Math.floor(m/24);return u<7?`${u}d ago`:new Date(s).toLocaleDateString()}function M({label:s,value:a,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:a})]})}function _(){return e.jsx("tr",{className:"border-b border-edge/50",children:Array.from({length:7}).map((s,a)=>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}%`}})},a))})}function Ce({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?`
|
|
69
|
+
...`:""]})]}),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?`
|
|
70
|
+
...`:""]})]}),!s.sourceCode&&!s.targetCode&&e.jsx("p",{className:"text-[10px] text-muted col-span-2",children:"No code details available for this job."})]})})})}function ke({state:s,actions:a,showInsights:r}){const{jobs:n,stats:c,loading:m,error:u}=s,[h,p]=o.useState(null),[d,l]=o.useState(null),g=t=>{d===t?(l(null),a.deleteJob(t)):(l(t),setTimeout(()=>l(x=>x===t?null:x),3e3))},j=t=>{p(x=>x===t?null:t)};return m&&n.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((t,x)=>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"})]},x))}),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(_,{}),e.jsx(_,{}),e.jsx(_,{})]})})]})]}):u?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:u}),e.jsxs("button",{onClick:()=>void a.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(A,{className:"w-3 h-3"})," Retry"]})]}):e.jsxs("div",{className:"space-y-4",children:[c&&e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-5 gap-3",children:[e.jsx(M,{label:"Total Jobs",value:c.totalJobs}),e.jsx(M,{label:"Completed",value:c.done,accent:"text-green-500"}),e.jsx(M,{label:"Failed",value:c.failed,accent:c.failed>0?"text-red-500":"text-foreground"}),e.jsx(M,{label:"Pending",value:c.pending,accent:c.pending>0?"text-yellow-500":"text-foreground"}),e.jsx(M,{label:"Avg Confidence",value:`${Math.round(c.avgConfidence*100)}%`})]}),r&&n.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(E,{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(n.reduce((t,x)=>{const y=`${x.sourceLanguage} → ${x.targetLanguage}`;return t[y]=(t[y]??0)+1,t},{})).sort(([,t],[,x])=>x-t).map(([t,x])=>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:t}),e.jsxs("span",{className:"text-muted ml-1.5",children:["x",x]})]},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.jsxs("h3",{className:"text-xs font-semibold text-foreground",children:["Translation Jobs (",n.length,")"]}),e.jsx("button",{onClick:()=>void a.refresh(),className:"p-1 rounded text-muted hover:text-foreground transition-colors cursor-pointer",title:"Refresh",children:e.jsx(A,{className:`w-3.5 h-3.5 ${m?"animate-spin":""}`})})]}),n.length===0?e.jsxs("div",{className:"px-4 py-12 flex flex-col items-center justify-center gap-3 text-center",children:[e.jsx(re,{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:n.map(t=>e.jsxs(e.Fragment,{children:[e.jsxs("tr",{onClick:()=>j(t.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===t.id?e.jsx(F,{className:"w-3 h-3"}):e.jsx(J,{className:"w-3 h-3"})}),e.jsx("td",{className:"px-4 py-1.5 font-mono text-muted",title:t.id,children:t.id.slice(0,8)}),e.jsxs("td",{className:"px-4 py-1.5",children:[e.jsx("span",{className:"text-foreground",children:t.sourceLanguage}),e.jsx("span",{className:"text-muted mx-1",children:"→"}),e.jsx("span",{className:"text-accent",children:t.targetLanguage})]}),e.jsx("td",{className:"px-4 py-1.5 text-muted",children:t.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 ${ve[t.status]}`,children:t.status})}),e.jsx("td",{className:"px-4 py-1.5 text-muted",children:t.confidenceScore!=null?`${Math.round(t.confidenceScore*100)}%`:"—"}),e.jsx("td",{className:"px-4 py-1.5 text-muted",title:new Date(t.createdAt).toLocaleString(),children:we(t.createdAt)}),e.jsx("td",{className:"px-4 py-1.5 text-right",onClick:x=>x.stopPropagation(),children:e.jsx("button",{onClick:()=>g(t.id),className:`px-2 py-0.5 rounded text-[10px] transition-all cursor-pointer ${d===t.id?"bg-red-500/10 text-red-400 font-medium border border-red-500/30":"text-muted hover:text-red-400"}`,title:d===t.id?"Click again to confirm":"Delete job",children:d===t.id?"Confirm?":e.jsx(me,{className:"w-3 h-3"})})})]},t.id),h===t.id&&e.jsx(Ce,{job:t},`${t.id}-details`)]}))})]})})]})]})}const Se=[{id:"convert",label:"Convert",icon:e.jsx(O,{className:"w-3.5 h-3.5"})},{id:"history",label:"History",icon:e.jsx(W,{className:"w-3.5 h-3.5"})},{id:"insights",label:"Insights",icon:e.jsx(E,{className:"w-3.5 h-3.5"})}],v={sourceCode:"",targetLanguage:"python",scope:"snippet",generatedCode:""};function _e(){const[s,a]=o.useState("convert"),[r,n]=ue(),[c,m]=pe(),[u,h]=o.useState(v.sourceCode),[p,d]=o.useState(v.targetLanguage),[l,g]=o.useState(v.scope),[j,t]=o.useState(v.generatedCode),x=o.useCallback(i=>{v.sourceCode=i,h(i)},[]),y=o.useCallback(i=>{v.targetLanguage=i,d(i)},[]),N=o.useCallback(i=>{v.scope=i,g(i)},[]),w=o.useCallback(i=>{v.generatedCode=i,t(i)},[]),C=r.phase;D(o.useCallback(i=>{i.startsWith("translation:")&&C!=="analyzing"&&C!=="finalizing"&&m.refresh()},[m,C]));const S=()=>{n.analyze(u,p,l)},z=()=>{n.finalize(j).then(()=>m.refresh())},$=()=>{n.reset(),x(""),w(""),y("python"),N("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(P,{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:Se.map(i=>e.jsxs("button",{onClick:()=>a(i.id),className:`flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-t transition-colors ${s===i.id?"bg-accent text-white":"text-muted hover:text-foreground hover:bg-surface"}`,children:[i.icon,i.label]},i.id))}),s==="convert"&&e.jsxs("div",{className:"space-y-4",children:[e.jsx(fe,{sourceCode:u,setSourceCode:x,targetLanguage:p,setTargetLanguage:y,scope:l,setScope:N,generatedCode:j,setGeneratedCode:w,translation:r,onAnalyze:S,onFinalize:z,onReset:$}),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(T,{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(T,{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(be,{analysis:r.analysis})}),r.finalizeResult&&e.jsx("div",{className:"animate-in fade-in-0 duration-300",style:{animationFillMode:"both"},children:e.jsx(Ne,{result:r.finalizeResult})})]}),(s==="history"||s==="insights")&&e.jsx(ke,{state:c,actions:m,showInsights:s==="insights"})]})})}export{_e as LanguagesTab};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{c}from"./index-DSPPavjF.js";/**
|
|
2
|
+
* @license lucide-react v1.7.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const e=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],a=c("loader-circle",e);export{a as L};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as s,a as v,j as t}from"./index-
|
|
2
|
-
`)}function O(){const{logs:r,loading:
|
|
1
|
+
import{r as s,a as v,j as t}from"./index-DSPPavjF.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
|
+
`)}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};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import{c as $,r as n,a as R,j as e,C as X}from"./index-DSPPavjF.js";import{C as Z}from"./circle-alert-vaRHjxbG.js";import{R as z}from"./refresh-cw-DRsAUgYq.js";import{T as A,C as me,a as ue}from"./triangle-alert-N0TixBQV.js";/**
|
|
2
|
+
* @license lucide-react v1.7.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const he=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],fe=$("circle",he);/**
|
|
7
|
+
* @license lucide-react v1.7.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/const pe=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]],ee=$("file-code",pe);/**
|
|
12
|
+
* @license lucide-react v1.7.0 - ISC
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the ISC license.
|
|
15
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
+
*/const ge=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],be=$("file-text",ge);/**
|
|
17
|
+
* @license lucide-react v1.7.0 - ISC
|
|
18
|
+
*
|
|
19
|
+
* This source code is licensed under the ISC license.
|
|
20
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
+
*/const je=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],te=$("info",je);/**
|
|
22
|
+
* @license lucide-react v1.7.0 - ISC
|
|
23
|
+
*
|
|
24
|
+
* This source code is licensed under the ISC license.
|
|
25
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
+
*/const ye=[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]],Ne=$("lightbulb",ye);/**
|
|
27
|
+
* @license lucide-react v1.7.0 - ISC
|
|
28
|
+
*
|
|
29
|
+
* This source code is licensed under the ISC license.
|
|
30
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
+
*/const ve=[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]],V=$("list",ve);/**
|
|
32
|
+
* @license lucide-react v1.7.0 - ISC
|
|
33
|
+
*
|
|
34
|
+
* This source code is licensed under the ISC license.
|
|
35
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
36
|
+
*/const we=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],se=$("pencil",we);/**
|
|
37
|
+
* @license lucide-react v1.7.0 - ISC
|
|
38
|
+
*
|
|
39
|
+
* This source code is licensed under the ISC license.
|
|
40
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
41
|
+
*/const ke=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],K=$("search",ke);/**
|
|
42
|
+
* @license lucide-react v1.7.0 - ISC
|
|
43
|
+
*
|
|
44
|
+
* This source code is licensed under the ISC license.
|
|
45
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
46
|
+
*/const Ce=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],ae=$("server",Ce),J=300*1e3;function Se(){const t=new Map;return{get(s){const a=t.get(s);if(a){if(Date.now()-a.timestamp>J){t.delete(s);return}return a.data}},set(s,a){if(t.set(s,{data:a,timestamp:Date.now()}),t.size>200){const r=Date.now();for(const[i,h]of t)r-h.timestamp>J&&t.delete(i)}}}}function $e(){const[t,s]=n.useState(null),[a,r]=n.useState(null),[i,h]=n.useState(!0),[y,o]=n.useState(null),[k,c]=n.useState([]),[E,L]=n.useState(null),[_,D]=n.useState(null),[I,S]=n.useState([]),[F,v]=n.useState([]),[p,g]=n.useState(null),[w,d]=n.useState(!1),f=n.useRef(Se()).current,H=n.useCallback(async()=>{try{const l=await R.getLspLanguages();s(l)}catch(l){o(l instanceof Error?l.message:"Failed to load LSP languages")}},[]),M=n.useCallback(async()=>{try{const l=await R.getLspStatus();r(l)}catch{r({ok:!0,bridgeInitialized:!1,servers:{}})}},[]),C=n.useCallback(async()=>{h(!0),o(null),await Promise.all([H(),M()]),h(!1)},[H,M]);n.useEffect(()=>{C()},[C]),n.useEffect(()=>{const l=setInterval(()=>{M()},1e4);return()=>clearInterval(l)},[M]);const ce=n.useCallback(async(l,b,j)=>{const m=`def:${l}:${b}:${j}`,u=f.get(m);if(u){c(u);return}d(!0);try{const N=(await R.lspDefinition(l,b,j)).definitions??[];f.set(m,N),c(N)}catch(x){o(x instanceof Error?x.message:"Definition lookup failed")}finally{d(!1)}},[f]),le=n.useCallback(async(l,b,j)=>{const m=`refs:${l}:${b}:${j}`,u=f.get(m);if(u){L(u);return}d(!0);try{const x=await R.lspReferences(l,b,j),N={total:x.totalReferences??0,refs:x.references??[],byFile:x.byFile??{}};f.set(m,N),L(N)}catch(x){o(x instanceof Error?x.message:"References lookup failed")}finally{d(!1)}},[f]),ie=n.useCallback(async(l,b,j)=>{const m=`hover:${l}:${b}:${j}`,u=f.get(m);if(u!==void 0){D(u);return}d(!0);try{const N=(await R.lspHover(l,b,j)).hover??null;f.set(m,N),D(N)}catch(x){o(x instanceof Error?x.message:"Hover lookup failed")}finally{d(!1)}},[f]),oe=n.useCallback(async l=>{const b=`diag:${l}`,j=f.get(b);if(j){S(j);return}d(!0);try{const u=(await R.lspDiagnostics(l)).diagnostics??[];f.set(b,u),S(u)}catch(m){o(m instanceof Error?m.message:"Diagnostics lookup failed")}finally{d(!1)}},[f]),de=n.useCallback(async l=>{const b=`sym:${l}`,j=f.get(b);if(j){v(j);return}d(!0);try{const u=(await R.lspSymbols(l)).symbols??[];f.set(b,u),v(u)}catch(m){o(m instanceof Error?m.message:"Symbols lookup failed")}finally{d(!1)}},[f]),xe=n.useCallback(async(l,b,j,m)=>{d(!0),g(null);try{const x=(await R.lspRename(l,b,j,m)).edit;x!=null&&x.changes?g(x.changes.map(N=>{var P,B,O,q,U,G,W,Y;return{file:N.file,startLine:(((B=(P=N.range)==null?void 0:P.start)==null?void 0:B.line)??0)+1,startCharacter:((q=(O=N.range)==null?void 0:O.start)==null?void 0:q.character)??0,endLine:(((G=(U=N.range)==null?void 0:U.end)==null?void 0:G.line)??0)+1,endCharacter:((Y=(W=N.range)==null?void 0:W.end)==null?void 0:Y.character)??0,newText:N.newText}})):g([])}catch(u){o(u instanceof Error?u.message:"Rename failed")}finally{d(!1)}},[]);return{languages:t,status:a,loading:i,error:y,operationLoading:w,definitions:k,references:E,hover:_,diagnostics:I,symbols:F,renameResult:p,refresh:C,goToDefinition:ce,findReferences:le,getHover:ie,getDiagnostics:oe,getSymbols:de,rename:xe}}const Le=[{id:"status",label:"Status",icon:ae},{id:"explorer",label:"Symbol Explorer",icon:K},{id:"diagnostics",label:"Diagnostics",icon:A},{id:"symbols",label:"Symbols",icon:V}],Q={1:{icon:Z,color:"text-danger",label:"Error"},2:{icon:A,color:"text-warning",label:"Warning"},3:{icon:te,color:"text-accent",label:"Info"},4:{icon:Ne,color:"text-muted",label:"Hint"}};function Re({status:t}){const s={ready:{bg:"bg-success/15",text:"text-success"},starting:{bg:"bg-warning/15",text:"text-warning"},stopped:{bg:"bg-muted/15",text:"text-muted"},error:{bg:"bg-danger/15",text:"text-danger"}},a=t??"not installed",r=s[a]??{bg:"bg-muted/10",text:"text-muted",border:"border-dashed"};return e.jsxs("span",{className:`inline-flex items-center gap-1 text-[10px] font-medium px-2 py-0.5 rounded-full ${r.bg} ${r.text} ${r.border??""} border border-current/20`,children:[e.jsx(fe,{className:"w-2 h-2 fill-current"}),a]})}function Ee({lang:t,serverStatus:s}){const a=Math.round(t.confidence*100);return e.jsxs("div",{className:"p-4 rounded-xl border border-edge bg-surface-alt shadow-sm hover:shadow-md transition-shadow space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ee,{className:"w-4 h-4 text-accent"}),e.jsx("span",{className:"text-sm font-semibold capitalize",children:t.languageId})]}),e.jsxs("span",{className:"text-[10px] font-medium px-2 py-0.5 rounded-full bg-accent/10 text-accent",children:[t.fileCount," files"]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-[10px] text-muted",children:[e.jsx("span",{children:"Confidence"}),e.jsxs("span",{children:[a,"%"]})]}),e.jsx("div",{className:"h-1 rounded-full bg-edge overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full bg-accent transition-all duration-300",style:{width:`${a}%`}})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[10px] text-muted",children:"Server"}),e.jsx(Re,{status:s})]}),e.jsxs("div",{className:"text-[10px] text-muted",children:["Detected via: ",e.jsx("span",{className:"text-foreground",children:t.detectedVia})]}),t.serverCommand&&e.jsxs("div",{className:"text-[10px] text-muted truncate",title:t.serverCommand,children:["Command: ",e.jsx("code",{className:"text-foreground font-mono",children:t.serverCommand})]}),t.configFile&&e.jsxs("div",{className:"text-[10px] text-muted truncate",title:t.configFile,children:["Config: ",e.jsx("code",{className:"text-foreground font-mono",children:t.configFile})]})]})}function De({hover:t}){return e.jsxs("div",{className:"p-4 rounded-xl border border-edge bg-surface-alt space-y-2",children:[e.jsx("h4",{className:"text-xs font-semibold text-muted uppercase tracking-wider",children:"Hover Info"}),t.signature?e.jsx("pre",{className:"text-sm font-mono bg-surface p-3 rounded-lg overflow-x-auto border border-edge whitespace-pre-wrap",children:t.signature}):e.jsx("p",{className:"text-sm text-muted",children:"No signature available"}),t.documentation&&e.jsx("div",{className:"text-xs text-muted whitespace-pre-wrap",children:t.documentation}),t.language&&e.jsxs("span",{className:"text-[10px] text-muted",children:["Language: ",t.language]})]})}function ne({title:t,locations:s}){return e.jsxs("div",{className:"p-4 rounded-xl border border-edge bg-surface-alt space-y-2",children:[e.jsxs("h4",{className:"text-xs font-semibold text-muted uppercase tracking-wider",children:[t," (",s.length,")"]}),s.length===0?e.jsx("p",{className:"text-sm text-muted",children:"No results found"}):e.jsx("ul",{className:"space-y-1",children:s.map((a,r)=>e.jsxs("li",{className:"flex items-center gap-2 text-xs py-1.5 px-2 rounded-lg hover:bg-surface-elevated transition-colors",children:[e.jsx(be,{className:"w-3 h-3 text-muted flex-shrink-0"}),e.jsx("span",{className:"font-mono text-foreground truncate",title:a.file,children:a.file}),e.jsxs("span",{className:"text-muted flex-shrink-0",children:[":",a.startLine,":",a.startCharacter]}),a.hint&&e.jsx("span",{className:"text-accent text-[10px] ml-auto truncate",children:a.hint})]},`${a.file}-${a.startLine}-${a.startCharacter}-${r}`))})]})}function Me({references:t}){const s=Object.entries(t.byFile).sort(([,a],[,r])=>r-a);return e.jsxs("div",{className:"space-y-3",children:[e.jsx(ne,{title:"References",locations:t.refs}),s.length>0&&e.jsxs("div",{className:"p-4 rounded-xl border border-edge bg-surface-alt space-y-2",children:[e.jsxs("h4",{className:"text-xs font-semibold text-muted uppercase tracking-wider",children:["By File (",t.total," total)"]}),e.jsx("ul",{className:"space-y-1",children:s.map(([a,r])=>e.jsxs("li",{className:"flex items-center justify-between text-xs py-1 px-2 rounded-lg hover:bg-surface-elevated transition-colors",children:[e.jsx("span",{className:"font-mono truncate text-foreground",title:a,children:a}),e.jsx("span",{className:"text-muted flex-shrink-0 ml-2",children:r})]},a))})]})]})}function _e({diagnostic:t}){const s=Q[t.severity]??Q[3],a=s.icon;return e.jsxs("div",{className:"flex items-start gap-3 py-2.5 px-3 rounded-lg border border-edge bg-surface-alt hover:shadow-sm transition-shadow",children:[e.jsx(a,{className:`w-4 h-4 flex-shrink-0 mt-0.5 ${s.color}`}),e.jsxs("div",{className:"flex-1 min-w-0 space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("span",{className:"text-xs font-mono text-muted",children:[t.file,":",t.startLine,":",t.startCharacter]}),t.source&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-surface-elevated text-muted border border-edge",children:t.source}),t.code&&e.jsxs("span",{className:"text-[10px] font-mono text-muted",children:["[",t.code,"]"]})]}),e.jsx("p",{className:"text-sm text-foreground",children:t.message})]}),e.jsx("span",{className:`text-[10px] font-medium flex-shrink-0 ${s.color}`,children:s.label})]})}const Ie={Function:"bg-accent/15 text-accent",Method:"bg-accent/15 text-accent",Class:"bg-warning/15 text-warning",Interface:"bg-success/15 text-success",Enum:"bg-danger/15 text-danger",Variable:"bg-muted/15 text-muted",Property:"bg-muted/15 text-muted",Constant:"bg-success/15 text-success",Module:"bg-warning/15 text-warning",Namespace:"bg-warning/15 text-warning"};function re({symbol:t,depth:s}){const[a,r]=n.useState(s<2),i=t.children&&t.children.length>0,h=Ie[t.kind]??"bg-muted/10 text-muted";return e.jsxs("div",{children:[e.jsxs("button",{type:"button",onClick:()=>i&&r(!a),className:`flex items-center gap-2 w-full text-left py-1.5 px-2 rounded-lg hover:bg-surface-elevated transition-colors text-xs ${i?"cursor-pointer":"cursor-default"}`,style:{paddingLeft:`${s*16+8}px`},children:[i?a?e.jsx(me,{className:"w-3 h-3 text-muted flex-shrink-0"}):e.jsx(ue,{className:"w-3 h-3 text-muted flex-shrink-0"}):e.jsx("span",{className:"w-3 flex-shrink-0"}),e.jsx("span",{className:`text-[10px] font-medium px-1.5 py-0.5 rounded ${h} flex-shrink-0`,children:t.kind}),e.jsx("span",{className:"font-mono text-foreground truncate",children:t.name}),e.jsxs("span",{className:"text-muted ml-auto flex-shrink-0",children:[t.startLine,"-",t.endLine]})]}),a&&i&&t.children.map((y,o)=>e.jsx(re,{symbol:y,depth:s+1},`${y.name}-${y.startLine}-${o}`))]})}function Fe({symbols:t}){return t.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted",children:[e.jsx(X,{className:"w-8 h-8 mb-2 opacity-40"}),e.jsx("p",{className:"text-sm",children:"No symbols found for this file"})]}):e.jsx("div",{className:"rounded-xl border border-edge bg-surface-alt overflow-hidden divide-y divide-edge",children:t.map((s,a)=>e.jsx(re,{symbol:s,depth:0},`${s.name}-${s.startLine}-${a}`))})}function ze({languages:t,status:s}){return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 px-4 pt-4",children:[e.jsx(ae,{className:"w-4 h-4 text-muted"}),e.jsx("span",{className:"text-xs text-muted",children:"Bridge:"}),e.jsx("span",{className:`text-xs font-medium ${s!=null&&s.bridgeInitialized?"text-success":"text-warning"}`,children:s!=null&&s.bridgeInitialized?"Initialized":"Not initialized"})]}),t.detected.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-muted",children:[e.jsx(ee,{className:"w-10 h-10 mb-3 opacity-40"}),e.jsx("p",{className:"text-sm",children:"No languages detected in this project"}),e.jsx("p",{className:"text-xs mt-1",children:"The LSP bridge will detect languages from project configuration files"})]}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 p-4",children:t.detected.map(a=>e.jsx(Ee,{lang:a,serverStatus:s==null?void 0:s.servers[a.languageId]},a.languageId))}),t.supportedLanguages.length>0&&e.jsxs("div",{className:"px-4 py-2 text-xs text-muted border-t border-edge",children:["Supported: ",t.supportedLanguages.join(", ")]})]})}function Te({edits:t}){return e.jsxs("div",{className:"p-4 rounded-xl border border-edge bg-surface-alt space-y-2",children:[e.jsxs("h4",{className:"text-xs font-semibold text-muted uppercase tracking-wider",children:["Rename Edits (",t.length,")"]}),t.length===0?e.jsx("p",{className:"text-sm text-muted",children:"No edits produced — the symbol may not support rename"}):e.jsx("ul",{className:"space-y-1",children:t.map((s,a)=>e.jsxs("li",{className:"flex items-center gap-2 text-xs py-1.5 px-2 rounded-lg hover:bg-surface-elevated transition-colors",children:[e.jsx(se,{className:"w-3 h-3 text-warning flex-shrink-0"}),e.jsx("span",{className:"font-mono text-foreground truncate",title:s.file,children:s.file}),e.jsxs("span",{className:"text-muted flex-shrink-0",children:[":",s.startLine,":",s.startCharacter]}),e.jsx("span",{className:"text-accent ml-auto text-[10px] truncate",children:s.newText})]},`${s.file}-${s.startLine}-${a}`))})]})}function He({goToDefinition:t,findReferences:s,getHover:a,rename:r,operationLoading:i,definitions:h,references:y,hover:o,renameResult:k}){const[c,E]=n.useState(""),[L,_]=n.useState(""),[D,I]=n.useState(""),[S,F]=n.useState(""),v=parseInt(L,10)||0,p=parseInt(D,10)||0,g=c.trim().length>0&&v>0,w=g&&S.trim().length>0,d=n.useCallback(()=>{g&&t(c.trim(),v,p)},[c,v,p,g,t]),T=n.useCallback(()=>{g&&s(c.trim(),v,p)},[c,v,p,g,s]),f=n.useCallback(()=>{g&&a(c.trim(),v,p)},[c,v,p,g,a]),H=n.useCallback(()=>{w&&r(c.trim(),v,p,S.trim())},[c,v,p,S,w,r]),M=o!==null||h.length>0||y!==null||k!==null;return e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx("input",{placeholder:"File path (e.g. src/main.ts)",value:c,onChange:C=>E(C.target.value),className:"flex-1 min-w-[200px] px-3 py-2 text-sm border border-edge rounded-lg bg-surface font-mono focus:outline-none focus:ring-1 focus:ring-accent"}),e.jsx("input",{placeholder:"Line",type:"number",min:1,value:L,onChange:C=>_(C.target.value),className:"w-20 px-3 py-2 text-sm border border-edge rounded-lg bg-surface text-center focus:outline-none focus:ring-1 focus:ring-accent"}),e.jsx("input",{placeholder:"Col",type:"number",min:0,value:D,onChange:C=>I(C.target.value),className:"w-20 px-3 py-2 text-sm border border-edge rounded-lg bg-surface text-center focus:outline-none focus:ring-1 focus:ring-accent"})]}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs("button",{type:"button",onClick:d,disabled:!g||i,className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-lg bg-accent text-white hover:bg-accent-light disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[e.jsx(X,{className:"w-3.5 h-3.5"}),"Definition"]}),e.jsxs("button",{type:"button",onClick:T,disabled:!g||i,className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-lg border border-edge hover:bg-surface-elevated disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[e.jsx(K,{className:"w-3.5 h-3.5"}),"References"]}),e.jsxs("button",{type:"button",onClick:f,disabled:!g||i,className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-lg border border-edge hover:bg-surface-elevated disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[e.jsx(te,{className:"w-3.5 h-3.5"}),"Hover"]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("input",{placeholder:"New name",value:S,onChange:C=>F(C.target.value),className:"w-32 px-2 py-1.5 text-xs border border-edge rounded-lg bg-surface font-mono focus:outline-none focus:ring-1 focus:ring-warning"}),e.jsxs("button",{type:"button",onClick:H,disabled:!w||i,className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-lg border border-warning text-warning hover:bg-warning/10 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[e.jsx(se,{className:"w-3.5 h-3.5"}),"Rename"]})]})]}),i&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted py-2",children:[e.jsx(z,{className:"w-3 h-3 animate-spin"}),e.jsx("span",{children:"Loading..."})]}),!i&&M&&e.jsxs("div",{className:"space-y-3",children:[o&&e.jsx(De,{hover:o}),h.length>0&&e.jsx(ne,{title:"Definitions",locations:h}),y&&e.jsx(Me,{references:y}),k&&e.jsx(Te,{edits:k})]}),!i&&!M&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-muted",children:[e.jsx(K,{className:"w-10 h-10 mb-3 opacity-40"}),e.jsx("p",{className:"text-sm",children:"Enter a file path and position to explore symbols"}),e.jsx("p",{className:"text-xs mt-1",children:"Use Definition, References, Hover, or Rename to inspect code"})]})]})}function Ae({getDiagnostics:t,operationLoading:s,diagnostics:a}){const[r,i]=n.useState(""),[h,y]=n.useState(!1),o=n.useCallback(()=>{r.trim()&&(y(!0),t(r.trim()))},[r,t]),k=n.useCallback(c=>{c.key==="Enter"&&o()},[o]);return e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{placeholder:"File path (e.g. src/main.ts)",value:r,onChange:c=>i(c.target.value),onKeyDown:k,className:"flex-1 px-3 py-2 text-sm border border-edge rounded-lg bg-surface font-mono focus:outline-none focus:ring-1 focus:ring-accent"}),e.jsxs("button",{type:"button",onClick:o,disabled:!r.trim()||s,className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-lg bg-accent text-white hover:bg-accent-light disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[e.jsx(A,{className:"w-3.5 h-3.5"}),"Load"]})]}),s&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted py-2",children:[e.jsx(z,{className:"w-3 h-3 animate-spin"}),e.jsx("span",{children:"Loading diagnostics..."})]}),!s&&a.length>0&&e.jsx("div",{className:"space-y-2",children:a.map((c,E)=>e.jsx(_e,{diagnostic:c},`${c.file}-${c.startLine}-${c.startCharacter}-${E}`))}),!s&&a.length===0&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-muted",children:[e.jsx(A,{className:"w-10 h-10 mb-3 opacity-40"}),h?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm",children:"No diagnostics found for this file"}),e.jsx("p",{className:"text-xs mt-1",children:"The file may be error-free or the language server may not support diagnostics"})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm",children:"Enter a file path to load diagnostics"}),e.jsx("p",{className:"text-xs mt-1",children:"View errors, warnings, and hints from the language server"})]})]})]})}function Ve({getSymbols:t,operationLoading:s,symbols:a}){const[r,i]=n.useState(""),[h,y]=n.useState(!1),o=n.useCallback(()=>{r.trim()&&(y(!0),t(r.trim()))},[r,t]),k=n.useCallback(c=>{c.key==="Enter"&&o()},[o]);return e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{placeholder:"File path (e.g. src/main.ts)",value:r,onChange:c=>i(c.target.value),onKeyDown:k,className:"flex-1 px-3 py-2 text-sm border border-edge rounded-lg bg-surface font-mono focus:outline-none focus:ring-1 focus:ring-accent"}),e.jsxs("button",{type:"button",onClick:o,disabled:!r.trim()||s,className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-lg bg-accent text-white hover:bg-accent-light disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[e.jsx(V,{className:"w-3.5 h-3.5"}),"Load"]})]}),s&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted py-2",children:[e.jsx(z,{className:"w-3 h-3 animate-spin"}),e.jsx("span",{children:"Loading symbols..."})]}),!s&&h&&e.jsx(Fe,{symbols:a}),!s&&!h&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-muted",children:[e.jsx(V,{className:"w-10 h-10 mb-3 opacity-40"}),e.jsx("p",{className:"text-sm",children:"Enter a file path to explore document symbols"}),e.jsx("p",{className:"text-xs mt-1",children:"View functions, classes, interfaces, and other symbols"})]})]})}function qe(){const{languages:t,status:s,loading:a,error:r,operationLoading:i,definitions:h,references:y,hover:o,diagnostics:k,symbols:c,renameResult:E,refresh:L,goToDefinition:_,findReferences:D,getHover:I,getDiagnostics:S,getSymbols:F,rename:v}=$e(),[p,g]=n.useState("status");return r&&!t?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4",children:[e.jsx(Z,{className:"w-10 h-10 text-danger"}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"Failed to load LSP data"}),e.jsx("p",{className:"text-xs text-muted mt-1",children:r})]}),e.jsxs("button",{type:"button",onClick:()=>void L(),className:"flex items-center gap-1.5 px-4 py-2 text-xs font-medium rounded-md border border-edge text-muted hover:text-foreground transition-colors cursor-pointer",children:[e.jsx(z,{className:"w-3 h-3"}),"Retry"]})]}):a||!t?e.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-edge bg-surface-alt",children:[e.jsx("div",{className:"flex items-center gap-1",children:Array.from({length:4}).map((w,d)=>e.jsx("div",{className:"h-7 w-28 rounded-lg bg-surface animate-pulse"},d))}),e.jsx("div",{className:"h-7 w-20 rounded-lg bg-surface animate-pulse"})]}),e.jsx("div",{className:"flex-1 p-4",children:e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Array.from({length:3}).map((w,d)=>e.jsx("div",{className:"h-44 rounded-xl border border-edge bg-surface-alt animate-pulse"},d))})})]}):e.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-edge bg-surface-alt",children:[e.jsx("div",{className:"flex items-center gap-1",children:Le.map(w=>{const d=w.icon,T=p===w.id;return e.jsxs("button",{type:"button",onClick:()=>g(w.id),className:`
|
|
47
|
+
inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-lg transition-colors
|
|
48
|
+
${T?"bg-accent/10 text-accent":"text-muted hover:bg-surface-elevated hover:text-foreground"}
|
|
49
|
+
`,children:[e.jsx(d,{className:"w-3.5 h-3.5"}),w.label]},w.id)})}),e.jsxs("button",{type:"button",onClick:()=>void L(),className:"inline-flex items-center gap-1.5 px-2.5 py-1.5 text-xs rounded-lg border border-edge hover:bg-surface-elevated transition-colors",title:"Refresh LSP data",children:[e.jsx(z,{className:`w-3 h-3 ${a?"animate-spin":""}`}),e.jsx("span",{className:"hidden sm:inline",children:"Refresh"})]})]}),r&&e.jsx("div",{className:"px-4 py-2 text-xs text-danger bg-danger/5 border-b border-danger/20",children:r}),e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[p==="status"&&e.jsx(ze,{languages:t,status:s}),p==="explorer"&&e.jsx(He,{goToDefinition:_,findReferences:D,getHover:I,rename:v,operationLoading:i,definitions:h,references:y,hover:o,renameResult:E}),p==="diagnostics"&&e.jsx(Ae,{getDiagnostics:S,operationLoading:i,diagnostics:k}),p==="symbols"&&e.jsx(Ve,{getSymbols:F,operationLoading:i,symbols:c})]})]})}export{qe as LspTab};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as i,a as j,j as e}from"./index-DSPPavjF.js";function b(s){const c=[];for(const l of s){const r=l.name.split("/");let a=c;for(let o=0;o<r.length;o++){const t=r[o],d=r.slice(0,o+1).join("/"),x=o===r.length-1;let n=a.find(u=>u.name===t);n||(n={name:t,path:d,children:[]},x&&(n.memory=l),a.push(n)),x&&!n.memory&&(n.memory=l),a=n.children}}return c}function C(){const[s,c]=i.useState([]),[l,r]=i.useState(null),[a,o]=i.useState(null),[t,d]=i.useState(!0),x=i.useCallback(async()=>{try{d(!0);const n=await j.getMemories().catch(()=>[]);c(n)}catch(n){o(n instanceof Error?n.message:"Failed to load")}finally{d(!1)}},[]);return i.useEffect(()=>{x()},[x]),t?e.jsxs("div",{className:"h-full flex",children:[e.jsxs("div",{className:"w-64 border-r border-edge bg-surface-alt p-2 space-y-2",children:[e.jsx("div",{className:"h-4 w-16 rounded bg-surface animate-pulse"}),e.jsx("div",{className:"h-6 w-full rounded bg-surface animate-pulse"}),Array.from({length:6}).map((n,u)=>e.jsx("div",{className:"h-4 rounded bg-surface animate-pulse",style:{width:`${50+Math.random()*40}%`,marginLeft:`${u%3*12}px`}},u))]}),e.jsx("div",{className:"flex-1 flex items-center justify-center text-muted text-xs",children:"Loading memories..."})]}):a?e.jsxs("div",{className:"flex items-center justify-center h-full text-danger",children:["Failed to load: ",a]}):e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 border-b border-edge bg-surface-alt",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Memories"}),e.jsx(N,{label:"Memories",active:s.length>0}),e.jsxs("span",{className:"text-[10px] text-muted",children:[s.length," memories"]})]}),e.jsxs("div",{className:"flex flex-1 min-h-0",children:[e.jsx(v,{memories:s,selectedMemory:l,onSelect:r}),e.jsx("div",{className:"flex-1 min-w-0 overflow-auto",children:e.jsx(y,{selectedMemory:l})})]})]})}function N({label:s,active:c}){const l=c?"var(--color-success)":"var(--color-text-muted)",r=c?"Active":"No data";return e.jsxs("span",{className:"text-[10px] font-medium px-2 py-0.5 rounded-full",style:{background:`${l}20`,color:l},children:[s,": ",r]})}function v({memories:s,selectedMemory:c,onSelect:l}){const[r,a]=i.useState(""),[o,t]=i.useState(!1),[d,x]=i.useState(new Set),n=i.useMemo(()=>{if(!r.trim())return s;const m=r.toLowerCase();return s.filter(p=>p.name.toLowerCase().includes(m))},[s,r]),u=i.useMemo(()=>b(n),[n]),g=i.useCallback(m=>{x(p=>{const f=new Set(p);return f.has(m)?f.delete(m):f.add(m),f})},[]);return o?e.jsx("div",{className:"w-8 border-r border-edge bg-surface-alt flex flex-col items-center pt-2",children:e.jsx("button",{onClick:()=>t(!1),className:"text-[10px] text-muted hover:text-foreground rotate-90",title:"Expand file explorer",children:"Files"})}):e.jsxs("div",{className:"w-64 border-r border-edge bg-surface-alt flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-2 py-1.5 border-b border-edge",children:[e.jsx("span",{className:"text-[10px] font-semibold text-muted uppercase tracking-wider",children:"Files"}),e.jsx("button",{onClick:()=>t(!0),className:"text-[10px] text-muted hover:text-foreground",title:"Collapse",children:"✕"})]}),e.jsx("div",{className:"px-2 py-1.5 border-b border-edge",children:e.jsx("input",{type:"text",value:r,onChange:m=>a(m.target.value),placeholder:"Search files...",className:"w-full text-[11px] px-2 py-1 rounded bg-surface border border-edge focus:outline-none focus:border-accent"})}),e.jsx("div",{className:"flex-1 overflow-y-auto text-[11px]",children:s.length===0?e.jsx("div",{className:"px-2 py-4 text-center text-muted",children:"No memories"}):e.jsx(h,{nodes:u,depth:0,expandedPaths:d,onToggle:g,selectedMemory:c,onSelect:l})})]})}function h({nodes:s,depth:c,expandedPaths:l,onToggle:r,selectedMemory:a,onSelect:o}){return e.jsx(e.Fragment,{children:s.map(t=>{const d=t.children.length>0,x=l.has(t.path),n=t.memory!=null&&(a==null?void 0:a.name)===t.memory.name;return e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>{d&&r(t.path),t.memory&&o(t.memory)},className:`w-full text-left px-2 py-0.5 flex items-center gap-1 hover:bg-surface-elevated transition-colors cursor-pointer ${n?"bg-accent15 text-accent":"text-foreground"}`,style:{paddingLeft:`${c*12+8}px`},children:[d?e.jsx("span",{className:"w-3 text-[9px] text-muted",children:x?"▾":"▸"}):e.jsx("span",{className:"w-3 text-[9px] text-muted",children:"·"}),e.jsx("span",{className:"truncate",children:t.name})]}),d&&x&&e.jsx(h,{nodes:t.children,depth:c+1,expandedPaths:l,onToggle:r,selectedMemory:a,onSelect:o})]},t.path)})})}function y({selectedMemory:s}){const[c,l]=i.useState(!1);if(!s)return e.jsx("div",{className:"flex items-center justify-center h-full text-muted",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-sm mb-1",children:"Select a memory from the explorer"}),e.jsx("p",{className:"text-xs text-muted/60",children:"Project memories appear as navigable files"})]})});const r=()=>{navigator.clipboard.writeText(s.content),l(!0),setTimeout(()=>l(!1),2e3)},a=s.name.split("/");return e.jsxs("div",{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-1 mb-2 text-[10px] text-muted",children:[e.jsx("span",{children:"memories"}),a.map((o,t)=>e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{children:"/"}),e.jsx("span",{className:t===a.length-1?"text-foreground font-medium":"",children:o})]},t))]}),e.jsxs("div",{className:"flex items-center justify-between mb-3 pb-2 border-b border-edge",children:[e.jsx("span",{className:"text-sm font-semibold",children:a[a.length-1]}),e.jsx("button",{onClick:r,className:`text-[10px] px-2 py-0.5 rounded border transition-all cursor-pointer ${c?"border-green-500/30 text-green-500 bg-green-500/5":"border-edge text-muted hover:text-foreground"}`,children:c?"Copied!":"Copy"})]}),e.jsx("pre",{className:"text-xs whitespace-pre-wrap text-muted font-mono leading-relaxed",children:s.content})]})}export{C as MemoriesTab};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as c,j as e}from"./index-DSPPavjF.js";import{R as _,u as M,a as E,b as P,i as T,B,C as D}from"./style-DpBYmOVU.js";import{S as w}from"./constants-lq4BIQN3.js";import{b as R,g as F,t as $,c as z,d as A,W as I,e as L,N as O}from"./graph-utils-DkRXfigF.js";import"./index-BW0cq1-5.js";import"./index-DmT4Jne7.js";const V=c.memo(function({graph:d,onNodeClick:N}){const{groups:m,nextTask:f,nodeMap:j}=c.useMemo(()=>{const r=d.nodes.filter(s=>s.type==="task"||s.type==="subtask"),x=new Map(d.nodes.map(s=>[s.id,s])),p=new Set(d.nodes.filter(s=>s.status==="done").map(s=>s.id)),h=r.filter(s=>s.status!=="backlog"&&s.status!=="ready"||s.blocked?!1:d.edges.filter(a=>a.from===s.id&&a.relationType==="depends_on").every(a=>p.has(a.to)));h.sort((s,t)=>s.priority-t.priority);const i=new Map;for(const s of r){const t=s.parentId||"__root__";i.has(t)||i.set(t,[]),i.get(t).push(s)}for(const s of i.values())s.sort((t,a)=>t.priority-a.priority);return{groups:i,nextTask:h[0]||null,nodeMap:x}},[d]);return d.nodes.filter(r=>r.type==="task"||r.type==="subtask").length===0?e.jsx("div",{className:"p-4 text-center text-muted",children:"No tasks in backlog."}):e.jsxs("div",{className:"p-2",children:[f&&e.jsxs("div",{className:"mb-3 px-3 py-2 bg-accent10 border border-accent rounded-lg",children:[e.jsx("span",{className:"text-xs font-medium text-accent",children:"Next:"})," ",e.jsx("span",{className:"text-sm font-semibold",children:f.title})]}),Array.from(m.entries()).map(([r,x])=>{const p=r!=="__root__"?j.get(r):null,h=p?p.title:"Ungrouped Tasks",i=x.filter(t=>t.status==="done").length,s=Math.round(i/x.length*100);return e.jsxs("div",{className:"mb-3",children:[e.jsxs("div",{className:"flex items-center justify-between px-2 py-1",children:[e.jsx("h4",{className:"text-xs font-semibold truncate",children:h}),e.jsxs("span",{className:"text-[10px] text-muted",children:[i,"/",x.length]})]}),e.jsx("div",{className:"h-1 mx-2 mb-1 bg-surface-elevated rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full",style:{width:`${s}%`,background:w.done}})}),x.map(t=>{const a=(f==null?void 0:f.id)===t.id,v=w[t.status]||"#9e9e9e",y=d.edges.filter(l=>l.from===t.id&&l.relationType==="depends_on").map(l=>{var n;return((n=j.get(l.to))==null?void 0:n.title)||l.to});return e.jsxs("div",{onClick:()=>N(t),className:`mx-1 mb-1 px-2 py-1.5 rounded cursor-pointer hover:bg-surface-elevated transition-colors ${a?"ring-1 ring-accent":""}`,children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[9px] px-1 py-0.5 rounded font-medium shrink-0",style:{background:`${v}20`,color:v},children:t.status.replace("_"," ")}),e.jsx("span",{className:"text-xs truncate flex-1",children:t.title}),e.jsxs("span",{className:"text-[10px] text-muted",children:["P",t.priority]}),t.xpSize&&e.jsx("span",{className:"text-[10px] text-muted",children:t.xpSize})]}),y.length>0&&e.jsxs("div",{className:"text-[10px] text-muted mt-0.5 truncate pl-1",children:["Depends on: ",y.join(", ")]})]},t.id)})]},r)})]})}),W={workflowNode:L},U={workflowEdge:I},Z={hideAttribution:!0};function G({graph:o}){const[d,N,m]=M([]),[f,j,r]=E([]),[x,p]=c.useState(null),[h,i]=c.useState(new Set),s=c.useRef(!0),{fitView:t}=P(),a=c.useMemo(()=>R(o.nodes,o.edges),[o.nodes,o.edges]),v=c.useCallback(n=>{i(u=>{const b=new Set(u);return b.has(n)?b.delete(n):b.add(n),b})},[]);c.useEffect(()=>{const n=F(o.nodes,h,a),u=$(n,void 0,a,h,v),b=new Set(u.map(S=>S.id)),k=z(o.edges,b),g=A(u,k,"TB");N(g.nodes),j(g.edges),s.current?s.current=!1:setTimeout(()=>t({duration:300}),50)},[o,N,j,h,a,v,t]);const C=c.useCallback((n,u)=>{p(u.data.sourceNode)},[]),y=c.useCallback(n=>{p(n)},[]),l=c.useMemo(()=>{const n=o.nodes.length,u=o.nodes.filter(g=>g.status==="done").length,b=o.nodes.filter(g=>g.status==="in_progress").length,k=o.nodes.filter(g=>g.status==="blocked").length;return{total:n,done:u,inProgress:b,blocked:k,pctDone:n?Math.round(u/n*100):0}},[o.nodes]);return e.jsxs("div",{className:"flex h-full",children:[e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col",children:[e.jsx("div",{className:"px-3 py-1.5 bg-surface-alt border-b border-edge flex items-center gap-2 text-xs relative z-10",children:e.jsxs("span",{className:"text-muted",children:["Showing ",d.length," of ",o.nodes.length," nodes — click ▶ to expand"]})}),o.nodes.length>0?e.jsxs(T,{nodes:d,edges:f,onNodesChange:m,onEdgesChange:r,onNodeClick:C,nodeTypes:W,edgeTypes:U,nodesDraggable:!1,nodesConnectable:!1,fitView:!0,minZoom:.1,maxZoom:2,proOptions:Z,children:[e.jsx(B,{gap:16,size:1}),e.jsx(D,{showInteractive:!1})]}):e.jsx("div",{className:"flex items-center justify-center h-full text-muted",children:"Import a PRD to see the workflow"})]}),e.jsxs("div",{className:"w-96 border-l border-edge flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-edge bg-surface-alt",children:[e.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[e.jsxs("span",{children:[l.done,"/",l.total," done (",l.pctDone,"%)"]}),e.jsxs("span",{className:"text-muted",children:[l.inProgress," in progress, ",l.blocked," blocked"]})]}),e.jsxs("div",{className:"h-2 bg-surface-elevated rounded-full overflow-hidden flex",children:[e.jsx("div",{className:"h-full transition-all",style:{width:`${l.pctDone}%`,background:w.done}}),e.jsx("div",{className:"h-full transition-all",style:{width:`${l.total?Math.round(l.inProgress/l.total*100):0}%`,background:w.in_progress}})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:e.jsx(V,{graph:o,onNodeClick:y})})]}),x&&e.jsx(O,{node:x,onClose:()=>p(null)})]})}function Y({graph:o,loading:d,error:N,onRetry:m}){return d||!o?e.jsxs("div",{className:"flex h-full",children:[e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col",children:[e.jsx("div",{className:"px-3 py-1.5 bg-surface-alt border-b border-edge",children:e.jsx("div",{className:"h-3 w-48 rounded bg-surface animate-pulse"})}),e.jsx("div",{className:"flex-1 bg-surface-alt animate-pulse"})]}),e.jsxs("div",{className:"w-96 border-l border-edge flex flex-col",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-edge bg-surface-alt space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("div",{className:"h-4 w-28 rounded bg-surface animate-pulse"}),e.jsx("div",{className:"h-4 w-40 rounded bg-surface animate-pulse"})]}),e.jsx("div",{className:"h-2 rounded-full bg-surface animate-pulse"})]}),e.jsx("div",{className:"flex-1 p-3 space-y-3",children:Array.from({length:6}).map((f,j)=>e.jsx("div",{className:"h-14 rounded-lg border border-edge bg-surface-alt animate-pulse"},j))})]})]}):N?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"Failed to load PRD & Backlog"}),e.jsx("p",{className:"text-xs text-muted mt-1",children:N})]}),m&&e.jsx("button",{type:"button",onClick:m,className:"flex items-center gap-1.5 px-4 py-2 text-xs font-medium rounded-md border border-edge text-muted hover:text-foreground transition-colors cursor-pointer",children:"Retry"})]}):o?e.jsx(_,{children:e.jsx(G,{graph:o})}):e.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-3 text-muted",children:[e.jsx("p",{className:"text-xs",children:"No graph data available"}),m&&e.jsx("button",{type:"button",onClick:m,className:"text-xs px-3 py-1.5 rounded border border-edge hover:text-foreground transition-colors cursor-pointer",children:"Retry"})]})}export{Y as PrdBacklogTab};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{c as e}from"./index-DSPPavjF.js";/**
|
|
2
|
+
* @license lucide-react v1.7.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const c=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],a=e("refresh-cw",c);export{a as R};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/graph-section-
|
|
2
|
-
import{r as s,j as e,a as S,_ as L}from"./index-CW7bjrwy.js";import{e as k}from"./constants-lq4BIQN3.js";const D=[{id:"upload",label:"Upload",icon:"M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5m-13.5-9L12 3m0 0l4.5 4.5M12 3v13.5"},{id:"objects",label:"Objects",icon:"M3.75 12h16.5m-16.5 3.75h16.5M3.75 19.5h16.5M5.625 4.5h12.75a1.875 1.875 0 010 3.75H5.625a1.875 1.875 0 010-3.75z"},{id:"graph",label:"Graph",icon:"M7.5 14.25v2.25m3-4.5v4.5m3-6.75v6.75m3-9v9M6 20.25h12A2.25 2.25 0 0020.25 18V6A2.25 2.25 0 0018 3.75H6A2.25 2.25 0 003.75 6v12A2.25 2.25 0 006 20.25z"},{id:"generation",label:"Generation",icon:"M9.813 15.904L9 18.75l-.813-2.846a4.5 4.5 0 00-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 003.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 003.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 00-3.09 3.09zM18.259 8.715L18 9.75l-.259-1.035a3.375 3.375 0 00-2.455-2.456L14.25 6l1.036-.259a3.375 3.375 0 002.455-2.456L18 2.25l.259 1.035a3.375 3.375 0 002.455 2.456L21.75 6l-1.036.259a3.375 3.375 0 00-2.455 2.456z"}],T=s.memo(function({activeSection:t,onSectionChange:a,objectCount:d}){return e.jsxs("nav",{className:"w-48 flex-shrink-0 border-r border-edge bg-surface-alt flex flex-col","aria-label":"Siebel sections",children:[e.jsx("div",{className:"px-3 py-3 border-b border-edge",children:e.jsx("h2",{className:"text-xs font-semibold uppercase text-muted tracking-wider",children:"Siebel"})}),e.jsx("div",{className:"flex-1 py-1",children:D.map(u=>e.jsxs("button",{onClick:()=>a(u.id),"aria-label":`Navigate to ${u.label}`,className:`w-full flex items-center gap-2.5 px-3 py-2 text-xs font-medium transition-colors cursor-pointer ${t===u.id?"bg-accent/10 text-accent border-r-2 border-accent":"text-muted hover:text-foreground hover:bg-surface"}`,children:[e.jsx("svg",{className:"w-4 h-4 flex-shrink-0",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:u.icon})}),e.jsx("span",{children:u.label}),u.id==="objects"&&d>0&&e.jsx("span",{className:"ml-auto text-[10px] px-1.5 py-0.5 rounded-full bg-surface text-muted",children:d})]},u.id))})]})});function E(){const[o,t]=s.useState([]),[a,d]=s.useState([]),[u,x]=s.useState(!0),[b,h]=s.useState(null),c=s.useCallback(async()=>{try{x(!0),h(null);const[m,l]=await Promise.all([S.siebelGetObjects({limit:100}).catch(()=>({objects:[],total:0})),S.siebelGetTemplates().catch(()=>({templates:[]}))]);t(m.objects),d(l.templates)}catch(m){h(m instanceof Error?m.message:"Failed to load Siebel data")}finally{x(!1)}},[]);return s.useEffect(()=>{c()},[c]),{objects:o,templates:a,loading:u,error:b,refresh:c}}function P(o){const[t,a]=s.useState(""),[d,u]=s.useState(["business_component"]),[x,b]=s.useState(""),[h,c]=s.useState(null),[m,l]=s.useState(""),[n,i]=s.useState(null),[g,v]=s.useState(!1),N=s.useCallback(f=>{u(y=>y.includes(f)?y.filter(w=>w!==f):[...y,f])},[]),j=s.useCallback(async()=>{if(t.trim()){v(!0),i(null);try{const f=await S.siebelPrepareGeneration({description:t,objectTypes:d,basedOnProject:x||void 0});c(f.prompt)}catch(f){c(`Error: ${f instanceof Error?f.message:String(f)}`)}finally{v(!1)}}},[t,d,x]),r=s.useCallback(async()=>{if(m.trim()){v(!0);try{const f=await S.siebelFinalizeGeneration({generatedXml:m,description:t,objectTypes:d});i(f),o==null||o()}catch(f){i({sifContent:"",objects:[],validation:{status:"invalid",messages:[{level:"error",message:f instanceof Error?f.message:String(f)}],score:0},metadata:{generatedAt:new Date().toISOString(),requestDescription:t,objectCount:0}})}finally{v(!1)}}},[m,t,d,o]),p=s.useCallback(()=>{if(!(n!=null&&n.sifContent))return;const f=new Blob([n.sifContent],{type:"application/xml"}),y=URL.createObjectURL(f),w=document.createElement("a");w.href=y,w.download="generated.sif",w.click(),URL.revokeObjectURL(y)},[n]);return{description:t,setDescription:a,selectedTypes:d,toggleType:N,project:x,setProject:b,prompt:h,xml:m,setXml:l,result:n,loading:g,prepare:j,finalize:r,download:p}}function I(){const[o,t]=s.useState(null),[a,d]=s.useState(0),[u,x]=s.useState("idle"),[b,h]=s.useState(null),c=s.useRef(null);s.useEffect(()=>()=>{var n;(n=c.current)==null||n.terminate()},[]);const m=s.useCallback(n=>{t(null),h(null),d(0),x("reading"),n.text().then(i=>{var v;d(10),x("parsing"),(v=c.current)==null||v.terminate();const g=new Worker(new URL("/assets/sif-parse.worker-DZrybOHz.js",import.meta.url),{type:"module"});c.current=g,g.onmessage=N=>{const j=N.data;j.type==="progress"?(d(j.progress),x(j.status)):j.type==="result"?(t(j.data),x("done"),d(100),g.terminate(),c.current=null):j.type==="error"&&(h(j.message),x("error"),g.terminate(),c.current=null)},g.onerror=N=>{h(N.message||"Worker error"),x("error"),g.terminate(),c.current=null},g.postMessage({type:"parse",content:i,fileName:n.name})}).catch(i=>{h(i instanceof Error?i.message:"Failed to read file"),x("error")})},[]),l=s.useCallback(()=>{var n;(n=c.current)==null||n.terminate(),c.current=null,t(null),d(0),x("idle"),h(null)},[]);return{parse:m,result:o,progress:a,status:u,error:b,reset:l}}const F={idle:"",reading:"Reading file...",parsing:"Parsing XML...",extracting:"Extracting objects...",inferring:"Inferring dependencies...",done:"Done!",error:"Error"},R=s.memo(function({status:t,progress:a,error:d}){if(t==="idle")return null;const u=t==="error",x=t==="done";return e.jsxs("div",{className:"space-y-1.5",role:"status","aria-live":"polite",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsx("span",{className:u?"text-red-500":x?"text-green-500":"text-muted",children:u?d:F[t]}),!u&&e.jsxs("span",{className:"text-[10px] text-muted",children:[a,"%"]})]}),!u&&e.jsx("div",{className:"h-1.5 rounded-full bg-surface overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full transition-all duration-300 ${x?"bg-green-500":"bg-accent"}`,style:{width:`${a}%`}})})]})});function $({onUploaded:o}){const[t,a]=s.useState(null),[d,u]=s.useState(!1),[x,b]=s.useState(!1),h=s.useRef(null),c=s.useRef(null),m=I();s.useEffect(()=>{if(m.status!=="done"||!m.result)return;const r=m.result.metadata.fileName;(async()=>{try{l.current&&(await S.siebelImportSif(l.current,r,!0),l.current=null,o())}catch{}})()},[m.status,m.result,o]);const l=s.useRef(null),n=s.useCallback(r=>{r.text().then(p=>{l.current=p,m.parse(r)}).catch(()=>{(async()=>{try{const p=await r.text();await S.siebelImportSif(p,r.name,!0),o()}catch{}})()})},[m,o]),i=s.useCallback(async r=>{try{a("Uploading documentation...");const p=await S.siebelUploadDocs(r);a(`Indexed: ${p.fileName} (${p.chunksIndexed} chunks)`),o()}catch(p){a(`Error: ${p instanceof Error?p.message:String(p)}`)}},[o]),g=s.useCallback(r=>{var f;const p=(f=r.target.files)==null?void 0:f[0];p&&n(p),h.current&&(h.current.value="")},[n]),v=s.useCallback(r=>{var f;const p=(f=r.target.files)==null?void 0:f[0];p&&i(p),c.current&&(c.current.value="")},[i]),N=s.useCallback((r,p,f)=>{r.preventDefault(),f(!1);const y=r.dataTransfer.files[0];y&&p(y)},[]),j=s.useCallback(r=>{r.preventDefault(),r.stopPropagation()},[]);return e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold mb-1",children:"Upload & Context"}),e.jsx("p",{className:"text-xs text-muted",children:"Upload SIF files and documentation to build RAG context for generation"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:`relative border-2 border-dashed rounded-lg p-6 text-center transition-colors cursor-pointer ${d?"border-accent bg-accent/5":"border-edge hover:border-accent/50"}`,onDragEnter:r=>{j(r),u(!0)},onDragOver:r=>{j(r),u(!0)},onDragLeave:r=>{j(r),u(!1)},onDrop:r=>N(r,n,u),onClick:()=>{var r;return(r=h.current)==null?void 0:r.click()},role:"button",tabIndex:0,onKeyDown:r=>{var p;(r.key==="Enter"||r.key===" ")&&((p=h.current)==null||p.click())},"aria-label":"Upload SIF file",children:[e.jsx("input",{ref:h,type:"file",accept:".sif,.xml",onChange:g,className:"hidden",tabIndex:-1}),e.jsx("svg",{className:"w-8 h-8 mx-auto mb-2 text-muted",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m6.75 12l-3-3m0 0l-3 3m3-3v6m-1.5-15H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})}),e.jsx("p",{className:"text-xs font-medium",children:"SIF File (.sif, .xml)"}),e.jsx("p",{className:"text-[10px] text-muted mt-1",children:"Drop here or click to browse"})]}),e.jsxs("div",{className:`relative border-2 border-dashed rounded-lg p-6 text-center transition-colors cursor-pointer ${x?"border-accent bg-accent/5":"border-edge hover:border-accent/50"}`,onDragEnter:r=>{j(r),b(!0)},onDragOver:r=>{j(r),b(!0)},onDragLeave:r=>{j(r),b(!1)},onDrop:r=>N(r,i,b),onClick:()=>{var r;return(r=c.current)==null?void 0:r.click()},role:"button",tabIndex:0,onKeyDown:r=>{var p;(r.key==="Enter"||r.key===" ")&&((p=c.current)==null||p.click())},"aria-label":"Upload documentation file",children:[e.jsx("input",{ref:c,type:"file",accept:".pdf,.html,.htm,.txt,.md,.doc,.docx",onChange:v,className:"hidden",tabIndex:-1}),e.jsx("svg",{className:"w-8 h-8 mx-auto mb-2 text-muted",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 6.042A8.967 8.967 0 006 3.75c-1.052 0-2.062.18-3 .512v14.25A8.987 8.987 0 016 18c2.305 0 4.408.867 6 2.292m0-14.25a8.966 8.966 0 016-2.292c1.052 0 2.062.18 3 .512v14.25A8.987 8.987 0 0018 18a8.967 8.967 0 00-6 2.292m0-14.25v14.25"})}),e.jsx("p",{className:"text-xs font-medium",children:"Documentation"}),e.jsx("p",{className:"text-[10px] text-muted mt-1",children:"PDF, HTML, DOC, DOCX, TXT, MD"})]})]}),m.status!=="idle"&&e.jsx(R,{status:m.status,progress:m.progress,error:m.error}),t&&e.jsx("div",{className:`px-3 py-2 rounded-md text-xs ${t.startsWith("Error")?"bg-red-500/10 text-red-500":"bg-green-500/10 text-green-500"}`,role:"status","aria-live":"polite",children:t})]})}const C=36;function M({objects:o}){const[t,a]=s.useState(""),[d,u]=s.useState(new Set),x=s.useDeferredValue(t),b=s.useDeferredValue(d),h=s.useMemo(()=>{const l=new Set;for(const n of o)n.siebelType&&l.add(n.siebelType);return[...l].sort()},[o]),c=s.useMemo(()=>{let l=o;if(x){const n=x.toLowerCase();l=l.filter(i=>{var g;return i.title.toLowerCase().includes(n)||((g=i.siebelProject)==null?void 0:g.toLowerCase().includes(n))||i.contentPreview.toLowerCase().includes(n)})}return b.size>0&&(l=l.filter(n=>n.siebelType&&b.has(n.siebelType))),l},[o,x,b]),m=l=>{u(n=>{const i=new Set(n);return i.has(l)?i.delete(l):i.add(l),i})};return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"p-4 space-y-3 border-b border-edge",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("h3",{className:"text-sm font-semibold",children:["Indexed Siebel Objects",e.jsxs("span",{className:"ml-2 text-xs font-normal text-muted",children:[c.length,c.length!==o.length?` / ${o.length}`:""," objects"]})]})}),e.jsx("input",{type:"text",value:t,onChange:l=>a(l.target.value),placeholder:"Search objects...","aria-label":"Search Siebel objects",className:"w-full px-3 py-1.5 text-xs rounded-md border border-edge bg-surface text-foreground placeholder:text-muted focus:outline-none focus:ring-1 focus:ring-accent"}),h.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1",children:h.map(l=>{const n=k[l]||"#6b7280",i=d.has(l);return e.jsx("button",{onClick:()=>m(l),"aria-label":`Filter by ${l}`,"aria-pressed":i,className:"px-2 py-0.5 text-[10px] rounded-md border transition-colors cursor-pointer",style:{borderColor:i?n:"var(--color-border)",backgroundColor:i?`${n}15`:"transparent",color:i?n:"var(--color-text-muted)"},children:l.replace(/_/g," ")},l)})})]}),c.length===0?e.jsx("div",{className:"flex-1 flex items-center justify-center text-xs text-muted",children:o.length===0?"No Siebel objects indexed yet. Upload a .sif file.":"No objects match the current filters."}):e.jsx("div",{className:"flex-1 overflow-auto",style:{contentVisibility:"auto",containIntrinsicSize:`0 ${c.length*C}px`},children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{className:"sticky top-0 bg-surface-alt z-10",children:e.jsxs("tr",{className:"border-b border-edge",children:[e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Name"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Type"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Project"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Preview"})]})}),e.jsx("tbody",{children:c.map((l,n)=>{const i=k[l.siebelType??""]||"#6b7280";return e.jsxs("tr",{className:"border-b border-edge hover:bg-surface transition-colors",style:{height:C},children:[e.jsx("td",{className:"px-4 py-1.5 font-mono",children:l.title}),e.jsx("td",{className:"px-4 py-1.5",children:e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px]",style:{backgroundColor:`${i}15`,color:i},children:l.siebelType??l.sourceType})}),e.jsx("td",{className:"px-4 py-1.5 text-muted",children:l.siebelProject??"-"}),e.jsx("td",{className:"px-4 py-1.5 text-muted truncate max-w-xs",children:l.contentPreview})]},n)})})]})})]})}function O({templates:o,gen:t}){return e.jsx("div",{className:"h-full overflow-auto",children:e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold mb-1",children:"SIF Generation"}),e.jsx("p",{className:"text-xs text-muted",children:"Describe what you need, generate context for the LLM, then validate the output"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium mb-1",htmlFor:"gen-description",children:"Description"}),e.jsx("textarea",{id:"gen-description",value:t.description,onChange:a=>t.setDescription(a.target.value),placeholder:"e.g., Create a Business Component for Service Requests with fields: SR Number, Status, Priority",rows:3,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"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium mb-1.5",children:"Object Types"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:o.map(a=>e.jsx("button",{onClick:()=>t.toggleType(a.type),"aria-label":`Toggle ${a.type}`,"aria-pressed":t.selectedTypes.includes(a.type),className:`px-2 py-1 text-[10px] rounded-md border transition-colors cursor-pointer ${t.selectedTypes.includes(a.type)?"bg-accent text-white border-accent":"bg-transparent text-muted border-edge hover:border-accent"}`,children:a.type.replace(/_/g," ")},a.type))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium mb-1",htmlFor:"gen-project",children:"Base Project (optional)"}),e.jsx("input",{id:"gen-project",value:t.project,onChange:a=>t.setProject(a.target.value),placeholder:"e.g., Account (SSE)",className:"w-full px-3 py-1.5 text-xs rounded-md border border-edge bg-surface text-foreground placeholder:text-muted focus:outline-none focus:ring-1 focus:ring-accent"})]}),e.jsx("button",{onClick:t.prepare,disabled:!t.description.trim()||t.loading,className:"px-4 py-1.5 text-xs font-medium rounded-md bg-accent text-white hover:opacity-90 disabled:opacity-50 transition-opacity cursor-pointer disabled:cursor-not-allowed",children:t.loading&&!t.prompt?"Generating Context...":"Generate Context & Prompt"}),t.prompt&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("label",{className:"text-xs font-medium",children:"Generated Prompt (copy to LLM)"}),e.jsx("button",{onClick:()=>navigator.clipboard.writeText(t.prompt??""),"aria-label":"Copy prompt to clipboard",className:"text-[10px] px-2 py-0.5 rounded bg-surface text-muted hover:text-foreground border border-edge cursor-pointer transition-colors",children:"Copy"})]}),e.jsxs("pre",{className:"text-[10px] p-3 rounded-md bg-surface border border-edge max-h-48 overflow-auto whitespace-pre-wrap text-muted",children:[t.prompt.slice(0,3e3),t.prompt.length>3e3&&`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/graph-section-C4ymXtzh.js","assets/index-DSPPavjF.js","assets/index-CvAguK65.css","assets/style-DpBYmOVU.js","assets/index-BW0cq1-5.js","assets/style-BZV40eAE.css","assets/constants-lq4BIQN3.js","assets/index-DmT4Jne7.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as s,j as e,a as S,_ as L}from"./index-DSPPavjF.js";import{e as k}from"./constants-lq4BIQN3.js";const D=[{id:"upload",label:"Upload",icon:"M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5m-13.5-9L12 3m0 0l4.5 4.5M12 3v13.5"},{id:"objects",label:"Objects",icon:"M3.75 12h16.5m-16.5 3.75h16.5M3.75 19.5h16.5M5.625 4.5h12.75a1.875 1.875 0 010 3.75H5.625a1.875 1.875 0 010-3.75z"},{id:"graph",label:"Graph",icon:"M7.5 14.25v2.25m3-4.5v4.5m3-6.75v6.75m3-9v9M6 20.25h12A2.25 2.25 0 0020.25 18V6A2.25 2.25 0 0018 3.75H6A2.25 2.25 0 003.75 6v12A2.25 2.25 0 006 20.25z"},{id:"generation",label:"Generation",icon:"M9.813 15.904L9 18.75l-.813-2.846a4.5 4.5 0 00-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 003.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 003.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 00-3.09 3.09zM18.259 8.715L18 9.75l-.259-1.035a3.375 3.375 0 00-2.455-2.456L14.25 6l1.036-.259a3.375 3.375 0 002.455-2.456L18 2.25l.259 1.035a3.375 3.375 0 002.455 2.456L21.75 6l-1.036.259a3.375 3.375 0 00-2.455 2.456z"}],T=s.memo(function({activeSection:t,onSectionChange:a,objectCount:d}){return e.jsxs("nav",{className:"w-48 flex-shrink-0 border-r border-edge bg-surface-alt flex flex-col","aria-label":"Siebel sections",children:[e.jsx("div",{className:"px-3 py-3 border-b border-edge",children:e.jsx("h2",{className:"text-xs font-semibold uppercase text-muted tracking-wider",children:"Siebel"})}),e.jsx("div",{className:"flex-1 py-1",children:D.map(u=>e.jsxs("button",{onClick:()=>a(u.id),"aria-label":`Navigate to ${u.label}`,className:`w-full flex items-center gap-2.5 px-3 py-2 text-xs font-medium transition-colors cursor-pointer ${t===u.id?"bg-accent/10 text-accent border-r-2 border-accent":"text-muted hover:text-foreground hover:bg-surface"}`,children:[e.jsx("svg",{className:"w-4 h-4 flex-shrink-0",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:u.icon})}),e.jsx("span",{children:u.label}),u.id==="objects"&&d>0&&e.jsx("span",{className:"ml-auto text-[10px] px-1.5 py-0.5 rounded-full bg-surface text-muted",children:d})]},u.id))})]})});function E(){const[o,t]=s.useState([]),[a,d]=s.useState([]),[u,x]=s.useState(!0),[b,h]=s.useState(null),c=s.useCallback(async()=>{try{x(!0),h(null);const[m,l]=await Promise.all([S.siebelGetObjects({limit:100}).catch(()=>({objects:[],total:0})),S.siebelGetTemplates().catch(()=>({templates:[]}))]);t(m.objects),d(l.templates)}catch(m){h(m instanceof Error?m.message:"Failed to load Siebel data")}finally{x(!1)}},[]);return s.useEffect(()=>{c()},[c]),{objects:o,templates:a,loading:u,error:b,refresh:c}}function P(o){const[t,a]=s.useState(""),[d,u]=s.useState(["business_component"]),[x,b]=s.useState(""),[h,c]=s.useState(null),[m,l]=s.useState(""),[n,i]=s.useState(null),[g,v]=s.useState(!1),N=s.useCallback(f=>{u(y=>y.includes(f)?y.filter(w=>w!==f):[...y,f])},[]),j=s.useCallback(async()=>{if(t.trim()){v(!0),i(null);try{const f=await S.siebelPrepareGeneration({description:t,objectTypes:d,basedOnProject:x||void 0});c(f.prompt)}catch(f){c(`Error: ${f instanceof Error?f.message:String(f)}`)}finally{v(!1)}}},[t,d,x]),r=s.useCallback(async()=>{if(m.trim()){v(!0);try{const f=await S.siebelFinalizeGeneration({generatedXml:m,description:t,objectTypes:d});i(f),o==null||o()}catch(f){i({sifContent:"",objects:[],validation:{status:"invalid",messages:[{level:"error",message:f instanceof Error?f.message:String(f)}],score:0},metadata:{generatedAt:new Date().toISOString(),requestDescription:t,objectCount:0}})}finally{v(!1)}}},[m,t,d,o]),p=s.useCallback(()=>{if(!(n!=null&&n.sifContent))return;const f=new Blob([n.sifContent],{type:"application/xml"}),y=URL.createObjectURL(f),w=document.createElement("a");w.href=y,w.download="generated.sif",w.click(),URL.revokeObjectURL(y)},[n]);return{description:t,setDescription:a,selectedTypes:d,toggleType:N,project:x,setProject:b,prompt:h,xml:m,setXml:l,result:n,loading:g,prepare:j,finalize:r,download:p}}function I(){const[o,t]=s.useState(null),[a,d]=s.useState(0),[u,x]=s.useState("idle"),[b,h]=s.useState(null),c=s.useRef(null);s.useEffect(()=>()=>{var n;(n=c.current)==null||n.terminate()},[]);const m=s.useCallback(n=>{t(null),h(null),d(0),x("reading"),n.text().then(i=>{var v;d(10),x("parsing"),(v=c.current)==null||v.terminate();const g=new Worker(new URL("/assets/sif-parse.worker-DZrybOHz.js",import.meta.url),{type:"module"});c.current=g,g.onmessage=N=>{const j=N.data;j.type==="progress"?(d(j.progress),x(j.status)):j.type==="result"?(t(j.data),x("done"),d(100),g.terminate(),c.current=null):j.type==="error"&&(h(j.message),x("error"),g.terminate(),c.current=null)},g.onerror=N=>{h(N.message||"Worker error"),x("error"),g.terminate(),c.current=null},g.postMessage({type:"parse",content:i,fileName:n.name})}).catch(i=>{h(i instanceof Error?i.message:"Failed to read file"),x("error")})},[]),l=s.useCallback(()=>{var n;(n=c.current)==null||n.terminate(),c.current=null,t(null),d(0),x("idle"),h(null)},[]);return{parse:m,result:o,progress:a,status:u,error:b,reset:l}}const F={idle:"",reading:"Reading file...",parsing:"Parsing XML...",extracting:"Extracting objects...",inferring:"Inferring dependencies...",done:"Done!",error:"Error"},R=s.memo(function({status:t,progress:a,error:d}){if(t==="idle")return null;const u=t==="error",x=t==="done";return e.jsxs("div",{className:"space-y-1.5",role:"status","aria-live":"polite",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsx("span",{className:u?"text-red-500":x?"text-green-500":"text-muted",children:u?d:F[t]}),!u&&e.jsxs("span",{className:"text-[10px] text-muted",children:[a,"%"]})]}),!u&&e.jsx("div",{className:"h-1.5 rounded-full bg-surface overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full transition-all duration-300 ${x?"bg-green-500":"bg-accent"}`,style:{width:`${a}%`}})})]})});function $({onUploaded:o}){const[t,a]=s.useState(null),[d,u]=s.useState(!1),[x,b]=s.useState(!1),h=s.useRef(null),c=s.useRef(null),m=I();s.useEffect(()=>{if(m.status!=="done"||!m.result)return;const r=m.result.metadata.fileName;(async()=>{try{l.current&&(await S.siebelImportSif(l.current,r,!0),l.current=null,o())}catch{}})()},[m.status,m.result,o]);const l=s.useRef(null),n=s.useCallback(r=>{r.text().then(p=>{l.current=p,m.parse(r)}).catch(()=>{(async()=>{try{const p=await r.text();await S.siebelImportSif(p,r.name,!0),o()}catch{}})()})},[m,o]),i=s.useCallback(async r=>{try{a("Uploading documentation...");const p=await S.siebelUploadDocs(r);a(`Indexed: ${p.fileName} (${p.chunksIndexed} chunks)`),o()}catch(p){a(`Error: ${p instanceof Error?p.message:String(p)}`)}},[o]),g=s.useCallback(r=>{var f;const p=(f=r.target.files)==null?void 0:f[0];p&&n(p),h.current&&(h.current.value="")},[n]),v=s.useCallback(r=>{var f;const p=(f=r.target.files)==null?void 0:f[0];p&&i(p),c.current&&(c.current.value="")},[i]),N=s.useCallback((r,p,f)=>{r.preventDefault(),f(!1);const y=r.dataTransfer.files[0];y&&p(y)},[]),j=s.useCallback(r=>{r.preventDefault(),r.stopPropagation()},[]);return e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold mb-1",children:"Upload & Context"}),e.jsx("p",{className:"text-xs text-muted",children:"Upload SIF files and documentation to build RAG context for generation"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:`relative border-2 border-dashed rounded-lg p-6 text-center transition-colors cursor-pointer ${d?"border-accent bg-accent/5":"border-edge hover:border-accent/50"}`,onDragEnter:r=>{j(r),u(!0)},onDragOver:r=>{j(r),u(!0)},onDragLeave:r=>{j(r),u(!1)},onDrop:r=>N(r,n,u),onClick:()=>{var r;return(r=h.current)==null?void 0:r.click()},role:"button",tabIndex:0,onKeyDown:r=>{var p;(r.key==="Enter"||r.key===" ")&&((p=h.current)==null||p.click())},"aria-label":"Upload SIF file",children:[e.jsx("input",{ref:h,type:"file",accept:".sif,.xml",onChange:g,className:"hidden",tabIndex:-1}),e.jsx("svg",{className:"w-8 h-8 mx-auto mb-2 text-muted",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m6.75 12l-3-3m0 0l-3 3m3-3v6m-1.5-15H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})}),e.jsx("p",{className:"text-xs font-medium",children:"SIF File (.sif, .xml)"}),e.jsx("p",{className:"text-[10px] text-muted mt-1",children:"Drop here or click to browse"})]}),e.jsxs("div",{className:`relative border-2 border-dashed rounded-lg p-6 text-center transition-colors cursor-pointer ${x?"border-accent bg-accent/5":"border-edge hover:border-accent/50"}`,onDragEnter:r=>{j(r),b(!0)},onDragOver:r=>{j(r),b(!0)},onDragLeave:r=>{j(r),b(!1)},onDrop:r=>N(r,i,b),onClick:()=>{var r;return(r=c.current)==null?void 0:r.click()},role:"button",tabIndex:0,onKeyDown:r=>{var p;(r.key==="Enter"||r.key===" ")&&((p=c.current)==null||p.click())},"aria-label":"Upload documentation file",children:[e.jsx("input",{ref:c,type:"file",accept:".pdf,.html,.htm,.txt,.md,.doc,.docx",onChange:v,className:"hidden",tabIndex:-1}),e.jsx("svg",{className:"w-8 h-8 mx-auto mb-2 text-muted",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 6.042A8.967 8.967 0 006 3.75c-1.052 0-2.062.18-3 .512v14.25A8.987 8.987 0 016 18c2.305 0 4.408.867 6 2.292m0-14.25a8.966 8.966 0 016-2.292c1.052 0 2.062.18 3 .512v14.25A8.987 8.987 0 0018 18a8.967 8.967 0 00-6 2.292m0-14.25v14.25"})}),e.jsx("p",{className:"text-xs font-medium",children:"Documentation"}),e.jsx("p",{className:"text-[10px] text-muted mt-1",children:"PDF, HTML, DOC, DOCX, TXT, MD"})]})]}),m.status!=="idle"&&e.jsx(R,{status:m.status,progress:m.progress,error:m.error}),t&&e.jsx("div",{className:`px-3 py-2 rounded-md text-xs ${t.startsWith("Error")?"bg-red-500/10 text-red-500":"bg-green-500/10 text-green-500"}`,role:"status","aria-live":"polite",children:t})]})}const C=36;function M({objects:o}){const[t,a]=s.useState(""),[d,u]=s.useState(new Set),x=s.useDeferredValue(t),b=s.useDeferredValue(d),h=s.useMemo(()=>{const l=new Set;for(const n of o)n.siebelType&&l.add(n.siebelType);return[...l].sort()},[o]),c=s.useMemo(()=>{let l=o;if(x){const n=x.toLowerCase();l=l.filter(i=>{var g;return i.title.toLowerCase().includes(n)||((g=i.siebelProject)==null?void 0:g.toLowerCase().includes(n))||i.contentPreview.toLowerCase().includes(n)})}return b.size>0&&(l=l.filter(n=>n.siebelType&&b.has(n.siebelType))),l},[o,x,b]),m=l=>{u(n=>{const i=new Set(n);return i.has(l)?i.delete(l):i.add(l),i})};return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"p-4 space-y-3 border-b border-edge",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("h3",{className:"text-sm font-semibold",children:["Indexed Siebel Objects",e.jsxs("span",{className:"ml-2 text-xs font-normal text-muted",children:[c.length,c.length!==o.length?` / ${o.length}`:""," objects"]})]})}),e.jsx("input",{type:"text",value:t,onChange:l=>a(l.target.value),placeholder:"Search objects...","aria-label":"Search Siebel objects",className:"w-full px-3 py-1.5 text-xs rounded-md border border-edge bg-surface text-foreground placeholder:text-muted focus:outline-none focus:ring-1 focus:ring-accent"}),h.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1",children:h.map(l=>{const n=k[l]||"#6b7280",i=d.has(l);return e.jsx("button",{onClick:()=>m(l),"aria-label":`Filter by ${l}`,"aria-pressed":i,className:"px-2 py-0.5 text-[10px] rounded-md border transition-colors cursor-pointer",style:{borderColor:i?n:"var(--color-border)",backgroundColor:i?`${n}15`:"transparent",color:i?n:"var(--color-text-muted)"},children:l.replace(/_/g," ")},l)})})]}),c.length===0?e.jsx("div",{className:"flex-1 flex items-center justify-center text-xs text-muted",children:o.length===0?"No Siebel objects indexed yet. Upload a .sif file.":"No objects match the current filters."}):e.jsx("div",{className:"flex-1 overflow-auto",style:{contentVisibility:"auto",containIntrinsicSize:`0 ${c.length*C}px`},children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{className:"sticky top-0 bg-surface-alt z-10",children:e.jsxs("tr",{className:"border-b border-edge",children:[e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Name"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Type"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Project"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Preview"})]})}),e.jsx("tbody",{children:c.map((l,n)=>{const i=k[l.siebelType??""]||"#6b7280";return e.jsxs("tr",{className:"border-b border-edge hover:bg-surface transition-colors",style:{height:C},children:[e.jsx("td",{className:"px-4 py-1.5 font-mono",children:l.title}),e.jsx("td",{className:"px-4 py-1.5",children:e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px]",style:{backgroundColor:`${i}15`,color:i},children:l.siebelType??l.sourceType})}),e.jsx("td",{className:"px-4 py-1.5 text-muted",children:l.siebelProject??"-"}),e.jsx("td",{className:"px-4 py-1.5 text-muted truncate max-w-xs",children:l.contentPreview})]},n)})})]})})]})}function O({templates:o,gen:t}){return e.jsx("div",{className:"h-full overflow-auto",children:e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold mb-1",children:"SIF Generation"}),e.jsx("p",{className:"text-xs text-muted",children:"Describe what you need, generate context for the LLM, then validate the output"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium mb-1",htmlFor:"gen-description",children:"Description"}),e.jsx("textarea",{id:"gen-description",value:t.description,onChange:a=>t.setDescription(a.target.value),placeholder:"e.g., Create a Business Component for Service Requests with fields: SR Number, Status, Priority",rows:3,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"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium mb-1.5",children:"Object Types"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:o.map(a=>e.jsx("button",{onClick:()=>t.toggleType(a.type),"aria-label":`Toggle ${a.type}`,"aria-pressed":t.selectedTypes.includes(a.type),className:`px-2 py-1 text-[10px] rounded-md border transition-colors cursor-pointer ${t.selectedTypes.includes(a.type)?"bg-accent text-white border-accent":"bg-transparent text-muted border-edge hover:border-accent"}`,children:a.type.replace(/_/g," ")},a.type))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium mb-1",htmlFor:"gen-project",children:"Base Project (optional)"}),e.jsx("input",{id:"gen-project",value:t.project,onChange:a=>t.setProject(a.target.value),placeholder:"e.g., Account (SSE)",className:"w-full px-3 py-1.5 text-xs rounded-md border border-edge bg-surface text-foreground placeholder:text-muted focus:outline-none focus:ring-1 focus:ring-accent"})]}),e.jsx("button",{onClick:t.prepare,disabled:!t.description.trim()||t.loading,className:"px-4 py-1.5 text-xs font-medium rounded-md bg-accent text-white hover:opacity-90 disabled:opacity-50 transition-opacity cursor-pointer disabled:cursor-not-allowed",children:t.loading&&!t.prompt?"Generating Context...":"Generate Context & Prompt"}),t.prompt&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("label",{className:"text-xs font-medium",children:"Generated Prompt (copy to LLM)"}),e.jsx("button",{onClick:()=>navigator.clipboard.writeText(t.prompt??""),"aria-label":"Copy prompt to clipboard",className:"text-[10px] px-2 py-0.5 rounded bg-surface text-muted hover:text-foreground border border-edge cursor-pointer transition-colors",children:"Copy"})]}),e.jsxs("pre",{className:"text-[10px] p-3 rounded-md bg-surface border border-edge max-h-48 overflow-auto whitespace-pre-wrap text-muted",children:[t.prompt.slice(0,3e3),t.prompt.length>3e3&&`
|
|
3
3
|
|
|
4
|
-
... (truncated for display)`]})]}),t.prompt&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium mb-1",htmlFor:"gen-xml",children:"Paste LLM-generated SIF XML"}),e.jsx("textarea",{id:"gen-xml",value:t.xml,onChange:a=>t.setXml(a.target.value),placeholder:'Paste the XML output from the LLM here (starting with <?xml version="1.0"...)',rows:8,className:"w-full px-3 py-2 text-xs font-mono rounded-md border border-edge bg-surface text-foreground placeholder:text-muted focus:outline-none focus:ring-1 focus:ring-accent"}),e.jsx("button",{onClick:t.finalize,disabled:!t.xml.trim()||t.loading,className:"mt-2 px-4 py-1.5 text-xs font-medium rounded-md bg-green-600 text-white hover:opacity-90 disabled:opacity-50 transition-opacity cursor-pointer disabled:cursor-not-allowed",children:t.loading?"Validating...":"Validate & Finalize"})]}),t.result&&e.jsxs("div",{className:`rounded-md border p-4 space-y-2 ${t.result.validation.status==="valid"?"border-green-500/30 bg-green-500/5":t.result.validation.status==="warnings"?"border-yellow-500/30 bg-yellow-500/5":"border-red-500/30 bg-red-500/5"}`,role:"status",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`text-sm font-bold ${t.result.validation.status==="valid"?"text-green-500":t.result.validation.status==="warnings"?"text-yellow-500":"text-red-500"}`,children:t.result.validation.status==="valid"?"Valid":t.result.validation.status==="warnings"?"Warnings":"Invalid"}),e.jsxs("span",{className:"text-xs text-muted",children:["Score: ",t.result.validation.score,"/100"]}),e.jsxs("span",{className:"text-xs text-muted",children:[t.result.metadata.objectCount," objects"]})]}),t.result.validation.status!=="invalid"&&e.jsx("button",{onClick:t.download,"aria-label":"Download generated SIF file",className:"px-3 py-1 text-xs font-medium rounded-md bg-accent text-white hover:opacity-90 cursor-pointer transition-opacity",children:"Download SIF"})]}),t.result.objects.length>0&&e.jsxs("div",{className:"text-xs text-muted",children:["Objects: ",t.result.objects.map(a=>`${a.type}:${a.name}`).join(", ")]}),t.result.validation.messages.length>0&&e.jsx("ul",{className:"space-y-0.5",children:t.result.validation.messages.map((a,d)=>e.jsxs("li",{className:`text-[10px] ${a.level==="error"?"text-red-500":a.level==="warning"?"text-yellow-600":"text-muted"}`,children:["[",a.level,"] ",a.message,a.objectName&&` (${a.objectName})`]},d))})]})]})})}const G=s.lazy(()=>L(()=>import("./graph-section-
|
|
4
|
+
... (truncated for display)`]})]}),t.prompt&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium mb-1",htmlFor:"gen-xml",children:"Paste LLM-generated SIF XML"}),e.jsx("textarea",{id:"gen-xml",value:t.xml,onChange:a=>t.setXml(a.target.value),placeholder:'Paste the XML output from the LLM here (starting with <?xml version="1.0"...)',rows:8,className:"w-full px-3 py-2 text-xs font-mono rounded-md border border-edge bg-surface text-foreground placeholder:text-muted focus:outline-none focus:ring-1 focus:ring-accent"}),e.jsx("button",{onClick:t.finalize,disabled:!t.xml.trim()||t.loading,className:"mt-2 px-4 py-1.5 text-xs font-medium rounded-md bg-green-600 text-white hover:opacity-90 disabled:opacity-50 transition-opacity cursor-pointer disabled:cursor-not-allowed",children:t.loading?"Validating...":"Validate & Finalize"})]}),t.result&&e.jsxs("div",{className:`rounded-md border p-4 space-y-2 ${t.result.validation.status==="valid"?"border-green-500/30 bg-green-500/5":t.result.validation.status==="warnings"?"border-yellow-500/30 bg-yellow-500/5":"border-red-500/30 bg-red-500/5"}`,role:"status",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`text-sm font-bold ${t.result.validation.status==="valid"?"text-green-500":t.result.validation.status==="warnings"?"text-yellow-500":"text-red-500"}`,children:t.result.validation.status==="valid"?"Valid":t.result.validation.status==="warnings"?"Warnings":"Invalid"}),e.jsxs("span",{className:"text-xs text-muted",children:["Score: ",t.result.validation.score,"/100"]}),e.jsxs("span",{className:"text-xs text-muted",children:[t.result.metadata.objectCount," objects"]})]}),t.result.validation.status!=="invalid"&&e.jsx("button",{onClick:t.download,"aria-label":"Download generated SIF file",className:"px-3 py-1 text-xs font-medium rounded-md bg-accent text-white hover:opacity-90 cursor-pointer transition-opacity",children:"Download SIF"})]}),t.result.objects.length>0&&e.jsxs("div",{className:"text-xs text-muted",children:["Objects: ",t.result.objects.map(a=>`${a.type}:${a.name}`).join(", ")]}),t.result.validation.messages.length>0&&e.jsx("ul",{className:"space-y-0.5",children:t.result.validation.messages.map((a,d)=>e.jsxs("li",{className:`text-[10px] ${a.level==="error"?"text-red-500":a.level==="warning"?"text-yellow-600":"text-muted"}`,children:["[",a.level,"] ",a.message,a.objectName&&` (${a.objectName})`]},d))})]})]})})}const G=s.lazy(()=>L(()=>import("./graph-section-C4ymXtzh.js"),__vite__mapDeps([0,1,2,3,4,5,6,7])).then(o=>({default:o.GraphSection})));function A(){return e.jsx("div",{className:"flex items-center justify-center h-full text-muted text-xs",children:"Loading..."})}function U(){const[o,t]=s.useState("upload"),{objects:a,templates:d,loading:u,error:x,refresh:b}=E(),h=P(b),[c,m]=s.useState([]),[l,n]=s.useState([]),i=s.useCallback(async()=>{try{const v=await S.siebelGetGraph();m(v.objects),n(v.dependencies)}catch{}},[]);s.useEffect(()=>{i()},[i]);const g=s.useCallback(()=>{b(),i()},[b,i]);return u?e.jsx("div",{className:"flex items-center justify-center h-full text-muted",children:"Loading Siebel..."}):x?e.jsx("div",{className:"flex items-center justify-center h-full text-danger",children:x}):e.jsxs("div",{className:"h-full flex",children:[e.jsx(T,{activeSection:o,onSectionChange:t,objectCount:a.length}),e.jsxs("main",{className:"flex-1 min-w-0 overflow-hidden",children:[o==="upload"&&e.jsx($,{onUploaded:g}),o==="objects"&&e.jsx(M,{objects:a}),o==="graph"&&e.jsx(s.Suspense,{fallback:e.jsx(A,{}),children:e.jsx(G,{objects:c,dependencies:l})}),o==="generation"&&e.jsx(O,{templates:d,gen:h})]})]})}export{U as SiebelTab};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as l,a as k,j as e}from"./index-DSPPavjF.js";import{P,L as B}from"./constants-lq4BIQN3.js";function $(){const[t,s]=l.useState([]),[u,n]=l.useState([]),[i,c]=l.useState(0),[x,b]=l.useState(!0),[h,f]=l.useState(null),d=l.useCallback(async()=>{b(!0),f(null);try{const[r,m]=await Promise.all([k.getSkills(),k.getRecommendations().catch(()=>({recommendations:[]}))]);s(r.skills),c(r.totalTokens),n(m.recommendations)}catch(r){f(r instanceof Error?r.message:"Failed to load skills")}finally{b(!1)}},[]);l.useEffect(()=>{d()},[d]);const N=l.useCallback(async(r,m)=>{s(C=>C.map(w=>w.name===r?{...w,enabled:m}:w));try{await k.toggleSkill(r,m)}catch{d()}},[d]),p=l.useCallback(async r=>{await k.createCustomSkill(r),d()},[d]),y=l.useCallback(async(r,m)=>{await k.updateCustomSkill(r,m),d()},[d]),j=l.useCallback(async r=>{await k.deleteCustomSkill(r),d()},[d]),g=t.filter(r=>r.enabled).reduce((r,m)=>r+m.estimatedTokens,0);return{skills:t,recommendations:u,totalTokens:i,activeTokens:g,loading:x,error:h,refresh:d,toggleSkill:N,createSkill:p,updateSkill:y,deleteSkill:j}}function D({skill:t,onClose:s,onToggle:u,onDelete:n,onEdit:i}){return t?e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:c=>{c.target===c.currentTarget&&s()},children:e.jsxs("div",{className:"bg-surface rounded-lg shadow-xl w-full max-w-lg p-6 max-h-[80vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h2",{className:"text-lg font-semibold truncate",children:t.name}),e.jsx("button",{onClick:s,className:"text-muted hover:text-foreground text-xl",children:"×"})]}),e.jsx("p",{className:"text-sm text-muted mb-4",children:t.description}),e.jsxs("div",{className:"flex flex-wrap gap-2 mb-4",children:[e.jsx("span",{className:`px-2 py-0.5 rounded text-[10px] font-medium ${t.source==="built-in"?"bg-blue-500/10 text-blue-500":t.source==="custom"?"bg-purple-500/10 text-purple-500":"bg-gray-500/10 text-gray-500"}`,children:t.source}),e.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] font-medium bg-edge text-muted",children:t.category}),e.jsxs("span",{className:"px-2 py-0.5 rounded text-[10px] font-medium bg-edge text-muted",children:[t.estimatedTokens.toLocaleString()," tokens"]})]}),t.phases&&t.phases.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5 mb-4",children:t.phases.map(c=>{const x=P[c]??"#6b7280";return e.jsx("span",{className:"px-2 py-0.5 rounded-full text-[10px] font-medium",style:{background:`${x}20`,color:x},children:c},c)})}),e.jsx("div",{className:"flex items-center gap-3 mb-4 p-3 rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt",children:e.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:t.enabled,onChange:c=>u(t.name,c.target.checked),className:"w-4 h-4 accent-accent"}),t.enabled?"Enabled":"Disabled"]})}),t.source==="custom"&&e.jsxs("div",{className:"flex gap-2",children:[i&&e.jsx("button",{onClick:()=>i(t),className:"px-3 py-1.5 text-sm border border-edge rounded hover:bg-surface-elevated",children:"Edit"}),n&&t.id&&e.jsx("button",{onClick:()=>n(t.id),className:"px-3 py-1.5 text-sm text-red-500 border border-red-500/30 rounded hover:bg-red-500/10",children:"Delete"})]})]})}):null}const _=["know-me","software-design","security","testing","cost-reducer","research","ddd","frontend-design","other"];function F({open:t,onClose:s,onSubmit:u,editSkill:n}){const[i,c]=l.useState(""),[x,b]=l.useState(""),[h,f]=l.useState("know-me"),[d,N]=l.useState(["IMPLEMENT"]),[p,y]=l.useState(""),[j,g]=l.useState(!1),[r,m]=l.useState(null);l.useEffect(()=>{n?(c(n.name),b(n.description),f(n.category),N(n.phases??["IMPLEMENT"]),y("")):(c(""),b(""),f("know-me"),N(["IMPLEMENT"]),y("")),m(null)},[n,t]);const C=l.useCallback(a=>{N(S=>S.includes(a)?S.filter(T=>T!==a):[...S,a])},[]),w=l.useCallback(async()=>{if(!i.trim()||!x.trim()||!p.trim()||d.length===0){m("All fields are required and at least one phase must be selected.");return}g(!0),m(null);try{await u({name:i.trim(),description:x.trim(),category:h,phases:d,instructions:p.trim()}),s()}catch(a){m(a instanceof Error?a.message:"Failed to save skill")}finally{g(!1)}},[i,x,h,d,p,u,s]);return t?e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:a=>{a.target===a.currentTarget&&s()},children:e.jsxs("div",{className:"bg-surface rounded-lg shadow-xl w-full max-w-lg p-6 max-h-[85vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h2",{className:"text-lg font-semibold",children:n?"Edit Skill":"Create Custom Skill"}),e.jsx("button",{onClick:s,className:"text-muted hover:text-foreground text-xl",children:"×"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted mb-1",children:"Name"}),e.jsx("input",{type:"text",value:i,onChange:a=>c(a.target.value),placeholder:"my-workflow",disabled:!!n,className:"w-full px-3 py-2 text-sm rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt disabled:opacity-50"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted mb-1",children:"Description"}),e.jsx("input",{type:"text",value:x,onChange:a=>b(a.target.value),placeholder:"What does this skill do?",className:"w-full px-3 py-2 text-sm rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted mb-1",children:"Category"}),e.jsx("select",{value:h,onChange:a=>f(a.target.value),className:"w-full px-3 py-2 text-sm rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt",children:_.map(a=>e.jsx("option",{value:a,children:a},a))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted mb-1",children:"Phases"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:B.map(a=>e.jsx("button",{type:"button",onClick:()=>C(a),className:`px-2 py-1 text-[10px] font-medium rounded-full border transition-colors ${d.includes(a)?"bg-accent/10 border-accent text-accent":"border-edge text-muted hover:border-foreground"}`,children:a},a))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted mb-1",children:"Instructions"}),e.jsx("textarea",{value:p,onChange:a=>y(a.target.value),rows:6,placeholder:"Instructions for the AI agent when this skill is active...",className:"w-full px-3 py-2 text-sm rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt resize-y"})]}),r&&e.jsx("div",{className:"text-sm p-2 rounded bg-red-500/10 text-red-500",children:r}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{onClick:s,className:"px-3 py-1.5 text-sm border border-edge rounded hover:bg-surface-elevated",children:"Cancel"}),e.jsx("button",{onClick:w,disabled:j,className:"px-3 py-1.5 text-sm bg-accent text-white rounded hover:opacity-90 disabled:opacity-50",children:j?"Saving...":n?"Update":"Create"})]})]})]})}):null}const I=4e3;function E({value:t,label:s}){return e.jsxs("div",{className:"p-3 rounded-xl border border-edge bg-surface-alt text-center","data-testid":"metric-card",children:[e.jsx("div",{className:"text-xl font-bold",children:t}),e.jsx("div",{className:"text-[10px] text-muted uppercase",children:s})]})}function z({phase:t}){const s=P[t]??"#6b7280";return e.jsx("span",{className:"px-2 py-0.5 rounded-full text-[10px] font-medium",style:{background:`${s}20`,color:s},children:t})}function G({source:t}){const s={"built-in":"bg-accent/10 text-accent",filesystem:"bg-muted/10 text-muted",custom:"bg-purple-500/10 text-purple-500"};return e.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-medium ${s[t]}`,children:t})}function H({skill:t,onToggle:s,onClick:u}){return e.jsxs("div",{className:`p-3 rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt cursor-pointer hover:border-accent/50 transition-all ${t.enabled?"":"opacity-50"}`,onClick:()=>u(t),children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[e.jsx("span",{className:"text-sm font-medium truncate",children:t.name}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsx("input",{type:"checkbox",checked:t.enabled,onChange:n=>{n.stopPropagation(),s(t.name,n.target.checked)},onClick:n=>n.stopPropagation(),className:"w-3.5 h-3.5 accent-accent"}),e.jsx(G,{source:t.source}),e.jsxs("span",{className:"text-[10px] text-muted",children:[t.estimatedTokens.toLocaleString()," tok"]})]})]}),e.jsx("p",{className:"text-xs text-muted line-clamp-2",children:t.description})]})}function A({phase:t,skills:s,onToggle:u,onSkillClick:n}){const[i,c]=l.useState(!0),x=P[t]??"#6b7280",b=s.filter(h=>h.enabled).length;return e.jsxs("div",{className:"rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>c(!i),className:"w-full flex items-center justify-between px-3 py-2 text-xs font-medium hover:bg-surface-elevated transition-colors",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:x}}),t,e.jsxs("span",{className:"px-1.5 py-0.5 rounded-full bg-edge text-[10px]",children:[b,"/",s.length]})]}),e.jsx("span",{className:"text-muted",children:i?"▲":"▼"})]}),i&&e.jsx("div",{className:"px-3 pb-3 space-y-2",children:s.map(h=>e.jsx(H,{skill:h,onToggle:u,onClick:n},h.name))})]})}function U({rec:t}){return e.jsxs("div",{className:"p-3 rounded-lg bg-surface-alt border border-accent/30",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-sm font-medium",children:t.skill}),e.jsx(z,{phase:t.phase})]}),e.jsx("p",{className:"text-xs text-muted",children:t.reason})]})}function q({totalTokens:t,activeTokens:s}){const u=Math.min(s/I,1),n=Math.min(t/I,1),i=Math.round(u*100),c=u>.8?"#ef4444":u>.5?"#f59e0b":"#10b981";return e.jsxs("div",{"data-testid":"token-budget-bar",className:"p-4 rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-muted uppercase",children:"Token Budget"}),e.jsxs("span",{className:"text-xs text-muted",children:[s.toLocaleString()," active / ",t.toLocaleString()," total (",i,"%)"]})]}),e.jsxs("div",{className:"w-full h-2 rounded-full bg-edge relative",children:[e.jsx("div",{className:"h-full rounded-full absolute top-0 left-0 opacity-30",style:{width:`${Math.round(n*100)}%`,background:"#6b7280"}}),e.jsx("div",{className:"h-full rounded-full absolute top-0 left-0 transition-all",style:{width:`${i}%`,background:c}})]})]})}function Y(){const{skills:t,recommendations:s,totalTokens:u,activeTokens:n,loading:i,error:c,refresh:x,toggleSkill:b,createSkill:h,updateSkill:f,deleteSkill:d}=$(),[N,p]=l.useState(null),[y,j]=l.useState(!1),[g,r]=l.useState(null),m=l.useCallback(async o=>{await d(o),p(null)},[d]),C=l.useCallback(o=>{p(null),r(o),j(!0)},[]),w=l.useCallback(async o=>{g!=null&&g.id?await f(g.id,o):await h(o),r(null)},[g,h,f]);if(c)return e.jsxs("div",{className:"flex items-center justify-center h-full text-danger",children:["Failed to load skills: ",c]});if(i)return e.jsxs("div",{className:"p-6 max-w-5xl mx-auto space-y-6",children:[e.jsx("div",{className:"h-5 w-32 rounded bg-surface animate-pulse"}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-5 gap-3",children:Array.from({length:5}).map((o,v)=>e.jsx("div",{className:"h-20 rounded-xl border border-edge bg-surface-alt animate-pulse"},v))}),e.jsx("div",{className:"h-8 rounded bg-surface animate-pulse"}),e.jsx("div",{className:"space-y-2",children:Array.from({length:4}).map((o,v)=>e.jsx("div",{className:"h-16 rounded-xl border border-edge bg-surface-alt animate-pulse"},v))})]});const a=t.filter(o=>o.source==="built-in").length,S=t.filter(o=>o.source==="custom").length,T=t.filter(o=>o.enabled).length,M=new Map;for(const o of B){const v=t.filter(O=>{var R;return(R=O.phases)==null?void 0:R.includes(o)});v.length>0&&M.set(o,v)}const L=t.filter(o=>!o.phases||o.phases.length===0);return e.jsxs("div",{className:"p-6 max-w-6xl mx-auto space-y-6 overflow-y-auto h-full",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Skills"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>{r(null),j(!0)},className:"text-xs px-3 py-1.5 rounded-lg border border-accent text-accent hover:bg-accent/10 transition-colors",children:"+ Custom Skill"}),e.jsx("button",{onClick:()=>void x(),className:"text-xs px-3 py-1.5 rounded-lg bg-accent text-white hover:opacity-90 transition-opacity",children:"Refresh"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-5 gap-3","data-testid":"skills-stats",children:[e.jsx(E,{value:t.length,label:"Total Skills"}),e.jsx(E,{value:a,label:"Built-in"}),e.jsx(E,{value:S,label:"Custom"}),e.jsx(E,{value:T,label:"Enabled"}),e.jsx(E,{value:n.toLocaleString(),label:"Active Tokens"})]}),e.jsx(q,{totalTokens:u,activeTokens:n}),s.length>0&&e.jsxs("div",{"data-testid":"recommendations-section",className:"space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-muted uppercase",children:["Recommendations (",s.length,")"]}),e.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-2",children:s.map(o=>e.jsx(U,{rec:o},o.skill))})]}),e.jsxs("div",{"data-testid":"skills-by-phase",className:"space-y-3",children:[e.jsx("h3",{className:"text-xs font-semibold text-muted uppercase",children:"Skills by Lifecycle Phase"}),[...M.entries()].map(([o,v])=>e.jsx(A,{phase:o,skills:v,onToggle:b,onSkillClick:p},o)),L.length>0&&e.jsx(A,{phase:"Other",skills:L,onToggle:b,onSkillClick:p})]}),e.jsx(D,{skill:N,onClose:()=>p(null),onToggle:b,onDelete:m,onEdit:C}),e.jsx(F,{open:y,onClose:()=>{j(!1),r(null)},onSubmit:w,editSkill:g})]})}export{Y as SkillsTab};
|