@mcp-graph-workflow/mcp-graph 5.9.0 → 5.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/dist/api/routes/siebel.d.ts.map +1 -1
  2. package/dist/api/routes/siebel.js +36 -0
  3. package/dist/api/routes/siebel.js.map +1 -1
  4. package/dist/core/rag/node-indexer.d.ts +1 -1
  5. package/dist/core/rag/node-indexer.d.ts.map +1 -1
  6. package/dist/core/rag/node-indexer.js +31 -19
  7. package/dist/core/rag/node-indexer.js.map +1 -1
  8. package/dist/mcp/tools/import-graph.d.ts.map +1 -1
  9. package/dist/mcp/tools/import-graph.js +11 -3
  10. package/dist/mcp/tools/import-graph.js.map +1 -1
  11. package/dist/mcp/tools/node.d.ts.map +1 -1
  12. package/dist/mcp/tools/node.js +2 -1
  13. package/dist/mcp/tools/node.js.map +1 -1
  14. package/dist/mcp/tools/reindex-knowledge.d.ts.map +1 -1
  15. package/dist/mcp/tools/reindex-knowledge.js +2 -1
  16. package/dist/mcp/tools/reindex-knowledge.js.map +1 -1
  17. package/dist/schemas/knowledge.schema.d.ts +2 -0
  18. package/dist/schemas/knowledge.schema.d.ts.map +1 -1
  19. package/dist/schemas/knowledge.schema.js +1 -1
  20. package/dist/schemas/knowledge.schema.js.map +1 -1
  21. package/dist/web/dashboard/dist/assets/benchmark-tab-DE9sF83l.js +1 -0
  22. package/dist/web/dashboard/dist/assets/{constants-z0QkAiYv.js → constants-lq4BIQN3.js} +1 -1
  23. package/dist/web/dashboard/dist/assets/context-tab-BDBUYfAA.js +1 -0
  24. package/dist/web/dashboard/dist/assets/{gitnexus-tab-DDw7DUED.js → gitnexus-tab-Yn1v6B3B.js} +16 -16
  25. package/dist/web/dashboard/dist/assets/graph-section-C6dzE7Vr.js +1 -0
  26. package/dist/web/dashboard/dist/assets/graph-tab-eIpG9sGq.js +1 -0
  27. package/dist/web/dashboard/dist/assets/graph-utils-Cq350VUG.js +1 -0
  28. package/dist/web/dashboard/dist/assets/{index-F9dY4AG_.js → index-BjE9IIVd.js} +2 -2
  29. package/dist/web/dashboard/dist/assets/index-CsH_Hv51.js +208 -0
  30. package/dist/web/dashboard/dist/assets/index-p238Jynp.css +1 -0
  31. package/dist/web/dashboard/dist/assets/index-ruquw1ns.js +1 -0
  32. package/dist/web/dashboard/dist/assets/{insights-tab-YN7G6mjm.js → insights-tab-iSZItsRP.js} +15 -15
  33. package/dist/web/dashboard/dist/assets/journey-tab-GXibD334.js +1 -0
  34. package/dist/web/dashboard/dist/assets/logs-tab-DROI_l7-.js +2 -0
  35. package/dist/web/dashboard/dist/assets/memories-tab-DUMqEP5R.js +1 -0
  36. package/dist/web/dashboard/dist/assets/prd-backlog-tab-DIQ0Fmr_.js +1 -0
  37. package/dist/web/dashboard/dist/assets/siebel-tab-Ci5KiOA6.js +4 -0
  38. package/dist/web/dashboard/dist/assets/sif-parse.worker-DZrybOHz.js +4 -0
  39. package/dist/web/dashboard/dist/assets/skills-tab-EfuAQFRT.js +1 -0
  40. package/dist/web/dashboard/dist/assets/{style-Da3qWU01.js → style-DF9Y1aXX.js} +1 -1
  41. package/dist/web/dashboard/dist/index.html +5 -2
  42. package/package.json +2 -2
  43. package/dist/web/dashboard/dist/assets/benchmark-tab-BoMsoQjO.js +0 -1
  44. package/dist/web/dashboard/dist/assets/context-tab-BLT4qQ77.js +0 -1
  45. package/dist/web/dashboard/dist/assets/graph-tab-DG9Q6nko.js +0 -1
  46. package/dist/web/dashboard/dist/assets/graph-utils-BpYHKE87.js +0 -1
  47. package/dist/web/dashboard/dist/assets/index-Cu23WCcu.css +0 -1
  48. package/dist/web/dashboard/dist/assets/index-DtkPX5ZZ.js +0 -55
  49. package/dist/web/dashboard/dist/assets/journey-tab-BcweuR82.js +0 -1
  50. package/dist/web/dashboard/dist/assets/logs-tab-BjdAURdy.js +0 -2
  51. package/dist/web/dashboard/dist/assets/memories-tab-CQ2xM2aw.js +0 -1
  52. package/dist/web/dashboard/dist/assets/prd-backlog-tab-CIeCpE1a.js +0 -1
  53. package/dist/web/dashboard/dist/assets/siebel-tab-bj5CT4-Z.js +0 -3
  54. package/dist/web/dashboard/dist/assets/skills-tab-Bgk72mKO.js +0 -1
@@ -0,0 +1 @@
1
+ import{r as c,a as k,j as e}from"./index-CsH_Hv51.js";import{u as F,a as P,i as H,B as z,C as L,M as R,H as J,P as O}from"./style-DF9Y1aXX.js";import"./index-BjE9IIVd.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"},V={navigation:"#6c757d",form_submit:"#2196f3",redirect:"#ff9800",back:"#9e9e9e"},D=280,W=220,X=c.memo(function({data:o}){const{screen:a,screenshotUrl:s,onSelect:l}=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:()=>l(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"})]})}),Y={journeyScreen:X};function B(t,o){var i;const a=new Map,s=new Map;for(const n of t)a.set(n.id,[]),s.set(n.id,0);for(const n of o)(i=a.get(n.from))==null||i.push(n.to),s.set(n.to,(s.get(n.to)??0)+1);const l=[],r=[],f=new Set;for(const n of t)(s.get(n.id)??0)===0&&r.push(n.id);for(;r.length>0;){const n=[...r];l.push(n),r.length=0;for(const d of n){f.add(d);for(const x of a.get(d)??[])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 n of t)f.has(n.id)||(l.length===0&&l.push([]),l[l.length-1].push(n.id));const j=new Map(t.map(n=>[n.id,n])),u=D+60,v=W+80,y=[];for(let n=0;n<l.length;n++){const d=l[n],b=-(d.length*u)/2+u/2;for(let N=0;N<d.length;N++){const m=j.get(d[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:n*v},data:{screen:m,screenshotUrl:m.screenshot?`/api/v1/journey/screenshots/_/${m.screenshot}`:void 0,onSelect:()=>{}}})}}return y}function G(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:V[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:l}){return l?e.jsx("div",{className:"flex items-center justify-center h-full text-muted",children:"Loading journey maps..."}):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,l]=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 i=JSON.parse(s);await k.importJourneyMap(i),a(),o(),l("")}catch(i){f(i instanceof Error?i.message:"Import failed")}finally{u(!1)}},y=i=>{var x;const n=(x=i.target.files)==null?void 0:x[0];if(!n)return;const d=new FileReader;d.onload=()=>l(d.result),d.readAsText(n)};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:i=>l(i.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),[l,r]=c.useState(null),[f,j]=c.useState(null),[u,v]=c.useState(null),[y,i]=c.useState(!1),[n,d]=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{d(!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(!l)return null;if(!u)return l;const p=l.variants.find(g=>g.id===u);if(!p)return l;const h=new Set(p.path);return{...l,screens:l.screens.filter(g=>h.has(g.id)),edges:l.edges.filter(g=>h.has(g.from)&&h.has(g.to))}},[l,u]);c.useEffect(()=>{if(!w){b([]),C([]);return}const h=B(w.screens,w.edges).map(g=>({...g,data:{...g.data,onSelect:j}}));b(h),C(G(w.edges))},[w,b,C]);const I=c.useCallback(()=>{d(!0),S()},[S]);return n||t.length===0?e.jsxs(e.Fragment,{children:[e.jsx(T,{maps:t,selectedId:a,onSelect:s,onImport:()=>i(!0),loading:n}),e.jsx(_,{open:y,onClose:()=>i(!1),onImported:I})]}):e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsx(T,{maps:t,selectedId:a,onSelect:s,onImport:()=>i(!0),loading:!1}),l&&e.jsx(U,{variants:l.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:Y,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(L,{position:"bottom-left"}),e.jsx(R,{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:()=>i(!1),onImported:I})]})}export{ee as JourneyTab};
@@ -0,0 +1,2 @@
1
+ import{r as s,a as v,j as t}from"./index-CsH_Hv51.js";function w(){const[r,o]=s.useState([]),[c,h]=s.useState(!0),d=s.useRef(0),p=s.useCallback(async()=>{try{const{logs:n}=await v.getLogs();o(n),n.length>0&&(d.current=n[n.length-1].id)}finally{h(!1)}},[]),x=s.useCallback(async()=>{await v.clearLogs(),o([]),d.current=0},[]);return s.useEffect(()=>{p()},[p]),s.useEffect(()=>{const n=new EventSource("/api/v1/events"),i=m=>{try{const l=JSON.parse(m.data),a={id:l.payload.id,level:l.payload.level,message:l.payload.message,context:l.payload.context,timestamp:l.timestamp};a.id>d.current&&(d.current=a.id,o(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 y(r){return new Date(r).toLocaleTimeString("en-US",{hour12:!1})}function L(r){return!r||Object.keys(r).length===0?"":Object.entries(r).map(([o,c])=>`${o}="${String(c)}"`).join(" ")}function j(r){return r.map(o=>{const c=L(o.context);return`[${y(o.timestamp)}] [${o.level.toUpperCase()}] ${o.message}${c?" "+c:""}`}).join(`
2
+ `)}function O(){const{logs:r,loading:o,clearLogs:c,refresh:h}=w(),[d,p]=s.useState("all"),[x,n]=s.useState(""),[i,m]=s.useState(!0),l=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&&l.current&&(l.current.scrollTop=l.current.scrollHeight)},[a,i]);const b=s.useCallback(()=>{if(!l.current)return;const{scrollTop:e,scrollHeight:u,clientHeight:g}=l.current,f=u-e-g<40;m(f)},[]),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),f=document.createElement("a");f.href=g,f.download=`mcp-graph-logs-${new Date().toISOString().slice(0,19).replace(/:/g,"-")}.txt`,f.click(),URL.revokeObjectURL(g)},[a]),S=s.useCallback(async()=>{await c()},[c]);return o?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:()=>m(!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:S,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:l,onScroll:b,className:"flex-1 overflow-y-auto font-mono text-xs p-2","data-testid":"log-list",children:a.length===0?t.jsx("div",{className:"flex items-center justify-center h-full text-muted",children:"No logs to display"}):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:y(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:L(e.context)})]},e.id))})]})}export{O as LogsTab};
@@ -0,0 +1 @@
1
+ import{r as i,a as g,j as e}from"./index-CsH_Hv51.js";function b(t){const c=[];for(const a of t){const l=a.name.split("/");let n=c;for(let o=0;o<l.length;o++){const s=l[o],d=l.slice(0,o+1).join("/"),x=o===l.length-1;let r=n.find(f=>f.name===s);r||(r={name:s,path:d,children:[]},x&&(r.memory=a),n.push(r)),x&&!r.memory&&(r.memory=a),n=r.children}}return c}function S(){const[t,c]=i.useState([]),[a,l]=i.useState(null),[n,o]=i.useState(null),[s,d]=i.useState(!0),x=i.useCallback(async()=>{try{d(!0);const r=await g.getMemories().catch(()=>[]);c(r)}catch(r){o(r instanceof Error?r.message:"Failed to load")}finally{d(!1)}},[]);return i.useEffect(()=>{x()},[x]),s?e.jsx("div",{className:"flex items-center justify-center h-full text-muted",children:"Loading Memories..."}):n?e.jsxs("div",{className:"flex items-center justify-center h-full text-danger",children:["Failed to load: ",n]}):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:t.length>0}),e.jsxs("span",{className:"text-[10px] text-muted",children:[t.length," memories"]})]}),e.jsxs("div",{className:"flex flex-1 min-h-0",children:[e.jsx(v,{memories:t,selectedMemory:a,onSelect:l}),e.jsx("div",{className:"flex-1 min-w-0 overflow-auto",children:e.jsx(y,{selectedMemory:a})})]})]})}function N({label:t,active:c}){const a=c?"var(--color-success)":"var(--color-text-muted)",l=c?"Active":"No data";return e.jsxs("span",{className:"text-[10px] font-medium px-2 py-0.5 rounded-full",style:{background:`${a}20`,color:a},children:[t,": ",l]})}function v({memories:t,selectedMemory:c,onSelect:a}){const[l,n]=i.useState(""),[o,s]=i.useState(!1),[d,x]=i.useState(new Set),r=i.useMemo(()=>{if(!l.trim())return t;const m=l.toLowerCase();return t.filter(p=>p.name.toLowerCase().includes(m))},[t,l]),f=i.useMemo(()=>b(r),[r]),j=i.useCallback(m=>{x(p=>{const u=new Set(p);return u.has(m)?u.delete(m):u.add(m),u})},[]);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:()=>s(!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:()=>s(!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:l,onChange:m=>n(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:t.length===0?e.jsx("div",{className:"px-2 py-4 text-center text-muted",children:"No memories"}):e.jsx(h,{nodes:f,depth:0,expandedPaths:d,onToggle:j,selectedMemory:c,onSelect:a})})]})}function h({nodes:t,depth:c,expandedPaths:a,onToggle:l,selectedMemory:n,onSelect:o}){return e.jsx(e.Fragment,{children:t.map(s=>{const d=s.children.length>0,x=a.has(s.path),r=s.memory!=null&&(n==null?void 0:n.name)===s.memory.name;return e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>{d&&l(s.path),s.memory&&o(s.memory)},className:`w-full text-left px-2 py-0.5 flex items-center gap-1 hover:bg-surface-elevated transition-colors ${r?"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:s.name})]}),d&&x&&e.jsx(h,{nodes:s.children,depth:c+1,expandedPaths:a,onToggle:l,selectedMemory:n,onSelect:o})]},s.path)})})}function y({selectedMemory:t}){return t?e.jsxs("div",{className:"p-4",children:[e.jsx("div",{className:"flex items-center gap-2 mb-3 pb-2 border-b border-edge",children:e.jsx("span",{className:"text-sm font-semibold",children:t.name})}),e.jsx("pre",{className:"text-xs whitespace-pre-wrap text-muted font-mono leading-relaxed",children:t.content})]}):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",children:"Project memories appear as navigable files"})]})})}export{S as MemoriesTab};
@@ -0,0 +1 @@
1
+ import{r,j as e}from"./index-CsH_Hv51.js";import{R as _,u as M,a as E,b as P,i as T,B,C as D}from"./style-DF9Y1aXX.js";import{S as w}from"./constants-lq4BIQN3.js";import{b as R,g as F,t as $,c as z,d as I,W as L,e as A,N as O}from"./graph-utils-Cq350VUG.js";import"./index-BjE9IIVd.js";import"./index-ruquw1ns.js";const V=r.memo(function({graph:i,onNodeClick:j}){const{groups:y,nextTask:g,nodeMap:b}=r.useMemo(()=>{const a=i.nodes.filter(s=>s.type==="task"||s.type==="subtask"),u=new Map(i.nodes.map(s=>[s.id,s])),m=new Set(i.nodes.filter(s=>s.status==="done").map(s=>s.id)),f=a.filter(s=>s.status!=="backlog"&&s.status!=="ready"||s.blocked?!1:i.edges.filter(d=>d.from===s.id&&d.relationType==="depends_on").every(d=>m.has(d.to)));f.sort((s,t)=>s.priority-t.priority);const c=new Map;for(const s of a){const t=s.parentId||"__root__";c.has(t)||c.set(t,[]),c.get(t).push(s)}for(const s of c.values())s.sort((t,d)=>t.priority-d.priority);return{groups:c,nextTask:f[0]||null,nodeMap:u}},[i]);return i.nodes.filter(a=>a.type==="task"||a.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:[g&&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:g.title})]}),Array.from(y.entries()).map(([a,u])=>{const m=a!=="__root__"?b.get(a):null,f=m?m.title:"Ungrouped Tasks",c=u.filter(t=>t.status==="done").length,s=Math.round(c/u.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:f}),e.jsxs("span",{className:"text-[10px] text-muted",children:[c,"/",u.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}})}),u.map(t=>{const d=(g==null?void 0:g.id)===t.id,N=w[t.status]||"#9e9e9e",v=i.edges.filter(n=>n.from===t.id&&n.relationType==="depends_on").map(n=>{var l;return((l=b.get(n.to))==null?void 0:l.title)||n.to});return e.jsxs("div",{onClick:()=>j(t),className:`mx-1 mb-1 px-2 py-1.5 rounded cursor-pointer hover:bg-surface-elevated transition-colors ${d?"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:`${N}20`,color:N},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})]}),v.length>0&&e.jsxs("div",{className:"text-[10px] text-muted mt-0.5 truncate pl-1",children:["Depends on: ",v.join(", ")]})]},t.id)})]},a)})]})}),W={workflowNode:A},U={workflowEdge:L},Z={hideAttribution:!0};function G({graph:o}){const[i,j,y]=M([]),[g,b,a]=E([]),[u,m]=r.useState(null),[f,c]=r.useState(new Set),s=r.useRef(!0),{fitView:t}=P(),d=r.useMemo(()=>R(o.nodes,o.edges),[o.nodes,o.edges]),N=r.useCallback(l=>{c(x=>{const p=new Set(x);return p.has(l)?p.delete(l):p.add(l),p})},[]);r.useEffect(()=>{const l=F(o.nodes,f,d),x=$(l,void 0,d,f,N),p=new Set(x.map(S=>S.id)),k=z(o.edges,p),h=I(x,k,"TB");j(h.nodes),b(h.edges),s.current?s.current=!1:setTimeout(()=>t({duration:300}),50)},[o,j,b,f,d,N,t]);const C=r.useCallback((l,x)=>{m(x.data.sourceNode)},[]),v=r.useCallback(l=>{m(l)},[]),n=r.useMemo(()=>{const l=o.nodes.length,x=o.nodes.filter(h=>h.status==="done").length,p=o.nodes.filter(h=>h.status==="in_progress").length,k=o.nodes.filter(h=>h.status==="blocked").length;return{total:l,done:x,inProgress:p,blocked:k,pctDone:l?Math.round(x/l*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 ",i.length," of ",o.nodes.length," nodes — click ▶ to expand"]})}),o.nodes.length>0?e.jsxs(T,{nodes:i,edges:g,onNodesChange:y,onEdgesChange:a,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:[n.done,"/",n.total," done (",n.pctDone,"%)"]}),e.jsxs("span",{className:"text-muted",children:[n.inProgress," in progress, ",n.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:`${n.pctDone}%`,background:w.done}}),e.jsx("div",{className:"h-full transition-all",style:{width:`${n.total?Math.round(n.inProgress/n.total*100):0}%`,background:w.in_progress}})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:e.jsx(V,{graph:o,onNodeClick:v})})]}),u&&e.jsx(O,{node:u,onClose:()=>m(null)})]})}function Y({graph:o}){return e.jsx(_,{children:e.jsx(G,{graph:o})})}export{Y as PrdBacklogTab};
@@ -0,0 +1,4 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/graph-section-C6dzE7Vr.js","assets/index-CsH_Hv51.js","assets/index-p238Jynp.css","assets/style-DF9Y1aXX.js","assets/index-BjE9IIVd.js","assets/style-BZV40eAE.css","assets/constants-lq4BIQN3.js","assets/index-ruquw1ns.js"])))=>i.map(i=>d[i]);
2
+ import{r as s,j as e,a as S,_ as L}from"./index-CsH_Hv51.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
+
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-C6dzE7Vr.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,4 @@
1
+ (function(){"use strict";const U=":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",te=U+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040",ne="["+U+"]["+te+"]*",se=new RegExp("^"+ne+"$");function W(n,e){const t=[];let s=e.exec(n);for(;s;){const i=[];i.startIndex=e.lastIndex-s[0].length;const r=s.length;for(let u=0;u<r;u++)i.push(s[u]);t.push(i),s=e.exec(n)}return t}const x=function(n){const e=se.exec(n);return!(e===null||typeof e>"u")};function re(n){return typeof n<"u"}const k=["hasOwnProperty","toString","valueOf","__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__"],Y=["__proto__","constructor","prototype"],ie={allowBooleanAttributes:!1,unpairedTags:[]};function oe(n,e){e=Object.assign({},ie,e);const t=[];let s=!1,i=!1;n[0]==="\uFEFF"&&(n=n.substr(1));for(let r=0;r<n.length;r++)if(n[r]==="<"&&n[r+1]==="?"){if(r+=2,r=G(n,r),r.err)return r}else if(n[r]==="<"){let u=r;if(r++,n[r]==="!"){r=X(n,r);continue}else{let a=!1;n[r]==="/"&&(a=!0,r++);let o="";for(;r<n.length&&n[r]!==">"&&n[r]!==" "&&n[r]!==" "&&n[r]!==`
2
+ `&&n[r]!=="\r";r++)o+=n[r];if(o=o.trim(),o[o.length-1]==="/"&&(o=o.substring(0,o.length-1),r--),!de(o)){let c;return o.trim().length===0?c="Invalid space after '<'.":c="Tag '"+o+"' is an invalid name.",h("InvalidTag",c,g(n,r))}const f=le(n,r);if(f===!1)return h("InvalidAttr","Attributes for '"+o+"' have open quote.",g(n,r));let l=f.value;if(r=f.index,l[l.length-1]==="/"){const c=r-l.length;l=l.substring(0,l.length-1);const p=Z(l,e);if(p===!0)s=!0;else return h(p.err.code,p.err.msg,g(n,c+p.err.line))}else if(a)if(f.tagClosed){if(l.trim().length>0)return h("InvalidTag","Closing tag '"+o+"' can't have attributes or invalid starting.",g(n,u));if(t.length===0)return h("InvalidTag","Closing tag '"+o+"' has not been opened.",g(n,u));{const c=t.pop();if(o!==c.tagName){let p=g(n,c.tagStartPos);return h("InvalidTag","Expected closing tag '"+c.tagName+"' (opened in line "+p.line+", col "+p.col+") instead of closing tag '"+o+"'.",g(n,u))}t.length==0&&(i=!0)}}else return h("InvalidTag","Closing tag '"+o+"' doesn't have proper closing.",g(n,r));else{const c=Z(l,e);if(c!==!0)return h(c.err.code,c.err.msg,g(n,r-l.length+c.err.line));if(i===!0)return h("InvalidXml","Multiple possible root nodes found.",g(n,r));e.unpairedTags.indexOf(o)!==-1||t.push({tagName:o,tagStartPos:u}),s=!0}for(r++;r<n.length;r++)if(n[r]==="<")if(n[r+1]==="!"){r++,r=X(n,r);continue}else if(n[r+1]==="?"){if(r=G(n,++r),r.err)return r}else break;else if(n[r]==="&"){const c=he(n,r);if(c==-1)return h("InvalidChar","char '&' is not expected.",g(n,r));r=c}else if(i===!0&&!z(n[r]))return h("InvalidXml","Extra text at the end",g(n,r));n[r]==="<"&&r--}}else{if(z(n[r]))continue;return h("InvalidChar","char '"+n[r]+"' is not expected.",g(n,r))}if(s){if(t.length==1)return h("InvalidTag","Unclosed tag '"+t[0].tagName+"'.",g(n,t[0].tagStartPos));if(t.length>0)return h("InvalidXml","Invalid '"+JSON.stringify(t.map(r=>r.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1})}else return h("InvalidXml","Start tag expected.",1);return!0}function z(n){return n===" "||n===" "||n===`
3
+ `||n==="\r"}function G(n,e){const t=e;for(;e<n.length;e++)if(n[e]=="?"||n[e]==" "){const s=n.substr(t,e-t);if(e>5&&s==="xml")return h("InvalidXml","XML declaration allowed only at the start of the document.",g(n,e));if(n[e]=="?"&&n[e+1]==">"){e++;break}else continue}return e}function X(n,e){if(n.length>e+5&&n[e+1]==="-"&&n[e+2]==="-"){for(e+=3;e<n.length;e++)if(n[e]==="-"&&n[e+1]==="-"&&n[e+2]===">"){e+=2;break}}else if(n.length>e+8&&n[e+1]==="D"&&n[e+2]==="O"&&n[e+3]==="C"&&n[e+4]==="T"&&n[e+5]==="Y"&&n[e+6]==="P"&&n[e+7]==="E"){let t=1;for(e+=8;e<n.length;e++)if(n[e]==="<")t++;else if(n[e]===">"&&(t--,t===0))break}else if(n.length>e+9&&n[e+1]==="["&&n[e+2]==="C"&&n[e+3]==="D"&&n[e+4]==="A"&&n[e+5]==="T"&&n[e+6]==="A"&&n[e+7]==="["){for(e+=8;e<n.length;e++)if(n[e]==="]"&&n[e+1]==="]"&&n[e+2]===">"){e+=2;break}}return e}const ae='"',ue="'";function le(n,e){let t="",s="",i=!1;for(;e<n.length;e++){if(n[e]===ae||n[e]===ue)s===""?s=n[e]:s!==n[e]||(s="");else if(n[e]===">"&&s===""){i=!0;break}t+=n[e]}return s!==""?!1:{value:t,index:e,tagClosed:i}}const fe=new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`,"g");function Z(n,e){const t=W(n,fe),s={};for(let i=0;i<t.length;i++){if(t[i][1].length===0)return h("InvalidAttr","Attribute '"+t[i][2]+"' has no space in starting.",_(t[i]));if(t[i][3]!==void 0&&t[i][4]===void 0)return h("InvalidAttr","Attribute '"+t[i][2]+"' is without value.",_(t[i]));if(t[i][3]===void 0&&!e.allowBooleanAttributes)return h("InvalidAttr","boolean attribute '"+t[i][2]+"' is not allowed.",_(t[i]));const r=t[i][2];if(!pe(r))return h("InvalidAttr","Attribute '"+r+"' is an invalid name.",_(t[i]));if(!Object.prototype.hasOwnProperty.call(s,r))s[r]=1;else return h("InvalidAttr","Attribute '"+r+"' is repeated.",_(t[i]))}return!0}function ce(n,e){let t=/\d/;for(n[e]==="x"&&(e++,t=/[\da-fA-F]/);e<n.length;e++){if(n[e]===";")return e;if(!n[e].match(t))break}return-1}function he(n,e){if(e++,n[e]===";")return-1;if(n[e]==="#")return e++,ce(n,e);let t=0;for(;e<n.length;e++,t++)if(!(n[e].match(/\w/)&&t<20)){if(n[e]===";")break;return-1}return e}function h(n,e,t){return{err:{code:n,msg:e,line:t.line||t,col:t.col}}}function pe(n){return x(n)}function de(n){return x(n)}function g(n,e){const t=n.substring(0,e).split(/\r?\n/);return{line:t.length,col:t[t.length-1].length+1}}function _(n){return n.startIndex+n[1].length}const J=n=>k.includes(n)?"__"+n:n,ge={preserveOrder:!1,attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0},tagValueProcessor:function(n,e){return e},attributeValueProcessor:function(n,e){return e},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(n,e,t){return n},captureMetaData:!1,maxNestedTags:100,strictReservedNames:!0,jPath:!0,onDangerousProperty:J};function Ee(n,e){if(typeof n!="string")return;const t=n.toLowerCase();if(k.some(s=>t===s.toLowerCase()))throw new Error(`[SECURITY] Invalid ${e}: "${n}" is a reserved JavaScript keyword that could cause prototype pollution`);if(Y.some(s=>t===s.toLowerCase()))throw new Error(`[SECURITY] Invalid ${e}: "${n}" is a reserved JavaScript keyword that could cause prototype pollution`)}function K(n){return typeof n=="boolean"?{enabled:n,maxEntitySize:1e4,maxExpansionDepth:10,maxTotalExpansions:1e3,maxExpandedLength:1e5,maxEntityCount:100,allowedTags:null,tagFilter:null}:typeof n=="object"&&n!==null?{enabled:n.enabled!==!1,maxEntitySize:Math.max(1,n.maxEntitySize??1e4),maxExpansionDepth:Math.max(1,n.maxExpansionDepth??10),maxTotalExpansions:Math.max(1,n.maxTotalExpansions??1e3),maxExpandedLength:Math.max(1,n.maxExpandedLength??1e5),maxEntityCount:Math.max(1,n.maxEntityCount??100),allowedTags:n.allowedTags??null,tagFilter:n.tagFilter??null}:K(!0)}const be=function(n){const e=Object.assign({},ge,n),t=[{value:e.attributeNamePrefix,name:"attributeNamePrefix"},{value:e.attributesGroupName,name:"attributesGroupName"},{value:e.textNodeName,name:"textNodeName"},{value:e.cdataPropName,name:"cdataPropName"},{value:e.commentPropName,name:"commentPropName"}];for(const{value:s,name:i}of t)s&&Ee(s,i);return e.onDangerousProperty===null&&(e.onDangerousProperty=J),e.processEntities=K(e.processEntities),e.stopNodes&&Array.isArray(e.stopNodes)&&(e.stopNodes=e.stopNodes.map(s=>typeof s=="string"&&s.startsWith("*.")?".."+s.substring(2):s)),e};let v;typeof Symbol!="function"?v="@@xmlMetadata":v=Symbol("XML Node Metadata");class m{constructor(e){this.tagname=e,this.child=[],this[":@"]=Object.create(null)}add(e,t){e==="__proto__"&&(e="#__proto__"),this.child.push({[e]:t})}addChild(e,t){e.tagname==="__proto__"&&(e.tagname="#__proto__"),e[":@"]&&Object.keys(e[":@"]).length>0?this.child.push({[e.tagname]:e.child,":@":e[":@"]}):this.child.push({[e.tagname]:e.child}),t!==void 0&&(this.child[this.child.length-1][v]={startIndex:t})}static getMetaDataSymbol(){return v}}class ye{constructor(e){this.suppressValidationErr=!e,this.options=e}readDocType(e,t){const s=Object.create(null);let i=0;if(e[t+3]==="O"&&e[t+4]==="C"&&e[t+5]==="T"&&e[t+6]==="Y"&&e[t+7]==="P"&&e[t+8]==="E"){t=t+9;let r=1,u=!1,a=!1,o="";for(;t<e.length;t++)if(e[t]==="<"&&!a){if(u&&T(e,"!ENTITY",t)){t+=7;let f,l;if([f,l,t]=this.readEntityExp(e,t+1,this.suppressValidationErr),l.indexOf("&")===-1){if(this.options.enabled!==!1&&this.options.maxEntityCount!=null&&i>=this.options.maxEntityCount)throw new Error(`Entity count (${i+1}) exceeds maximum allowed (${this.options.maxEntityCount})`);const c=f.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");s[f]={regx:RegExp(`&${c};`,"g"),val:l},i++}}else if(u&&T(e,"!ELEMENT",t)){t+=8;const{index:f}=this.readElementExp(e,t+1);t=f}else if(u&&T(e,"!ATTLIST",t))t+=8;else if(u&&T(e,"!NOTATION",t)){t+=9;const{index:f}=this.readNotationExp(e,t+1,this.suppressValidationErr);t=f}else if(T(e,"!--",t))a=!0;else throw new Error("Invalid DOCTYPE");r++,o=""}else if(e[t]===">"){if(a?e[t-1]==="-"&&e[t-2]==="-"&&(a=!1,r--):r--,r===0)break}else e[t]==="["?u=!0:o+=e[t];if(r!==0)throw new Error("Unclosed DOCTYPE")}else throw new Error("Invalid Tag instead of DOCTYPE");return{entities:s,i:t}}readEntityExp(e,t){t=b(e,t);const s=t;for(;t<e.length&&!/\s/.test(e[t])&&e[t]!=='"'&&e[t]!=="'";)t++;let i=e.substring(s,t);if(C(i),t=b(e,t),!this.suppressValidationErr){if(e.substring(t,t+6).toUpperCase()==="SYSTEM")throw new Error("External entities are not supported");if(e[t]==="%")throw new Error("Parameter entities are not supported")}let r="";if([t,r]=this.readIdentifierVal(e,t,"entity"),this.options.enabled!==!1&&this.options.maxEntitySize!=null&&r.length>this.options.maxEntitySize)throw new Error(`Entity "${i}" size (${r.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`);return t--,[i,r,t]}readNotationExp(e,t){t=b(e,t);const s=t;for(;t<e.length&&!/\s/.test(e[t]);)t++;let i=e.substring(s,t);!this.suppressValidationErr&&C(i),t=b(e,t);const r=e.substring(t,t+6).toUpperCase();if(!this.suppressValidationErr&&r!=="SYSTEM"&&r!=="PUBLIC")throw new Error(`Expected SYSTEM or PUBLIC, found "${r}"`);t+=r.length,t=b(e,t);let u=null,a=null;if(r==="PUBLIC")[t,u]=this.readIdentifierVal(e,t,"publicIdentifier"),t=b(e,t),(e[t]==='"'||e[t]==="'")&&([t,a]=this.readIdentifierVal(e,t,"systemIdentifier"));else if(r==="SYSTEM"&&([t,a]=this.readIdentifierVal(e,t,"systemIdentifier"),!this.suppressValidationErr&&!a))throw new Error("Missing mandatory system identifier for SYSTEM notation");return{notationName:i,publicIdentifier:u,systemIdentifier:a,index:--t}}readIdentifierVal(e,t,s){let i="";const r=e[t];if(r!=='"'&&r!=="'")throw new Error(`Expected quoted string, found "${r}"`);t++;const u=t;for(;t<e.length&&e[t]!==r;)t++;if(i=e.substring(u,t),e[t]!==r)throw new Error(`Unterminated ${s} value`);return t++,[t,i]}readElementExp(e,t){t=b(e,t);const s=t;for(;t<e.length&&!/\s/.test(e[t]);)t++;let i=e.substring(s,t);if(!this.suppressValidationErr&&!x(i))throw new Error(`Invalid element name: "${i}"`);t=b(e,t);let r="";if(e[t]==="E"&&T(e,"MPTY",t))t+=4;else if(e[t]==="A"&&T(e,"NY",t))t+=2;else if(e[t]==="("){t++;const u=t;for(;t<e.length&&e[t]!==")";)t++;if(r=e.substring(u,t),e[t]!==")")throw new Error("Unterminated content model")}else if(!this.suppressValidationErr)throw new Error(`Invalid Element Expression, found "${e[t]}"`);return{elementName:i,contentModel:r.trim(),index:t}}readAttlistExp(e,t){t=b(e,t);let s=t;for(;t<e.length&&!/\s/.test(e[t]);)t++;let i=e.substring(s,t);for(C(i),t=b(e,t),s=t;t<e.length&&!/\s/.test(e[t]);)t++;let r=e.substring(s,t);if(!C(r))throw new Error(`Invalid attribute name: "${r}"`);t=b(e,t);let u="";if(e.substring(t,t+8).toUpperCase()==="NOTATION"){if(u="NOTATION",t+=8,t=b(e,t),e[t]!=="(")throw new Error(`Expected '(', found "${e[t]}"`);t++;let o=[];for(;t<e.length&&e[t]!==")";){const f=t;for(;t<e.length&&e[t]!=="|"&&e[t]!==")";)t++;let l=e.substring(f,t);if(l=l.trim(),!C(l))throw new Error(`Invalid notation name: "${l}"`);o.push(l),e[t]==="|"&&(t++,t=b(e,t))}if(e[t]!==")")throw new Error("Unterminated list of notations");t++,u+=" ("+o.join("|")+")"}else{const o=t;for(;t<e.length&&!/\s/.test(e[t]);)t++;u+=e.substring(o,t);const f=["CDATA","ID","IDREF","IDREFS","ENTITY","ENTITIES","NMTOKEN","NMTOKENS"];if(!this.suppressValidationErr&&!f.includes(u.toUpperCase()))throw new Error(`Invalid attribute type: "${u}"`)}t=b(e,t);let a="";return e.substring(t,t+8).toUpperCase()==="#REQUIRED"?(a="#REQUIRED",t+=8):e.substring(t,t+7).toUpperCase()==="#IMPLIED"?(a="#IMPLIED",t+=7):[t,a]=this.readIdentifierVal(e,t,"ATTLIST"),{elementName:i,attributeName:r,attributeType:u,defaultValue:a,index:t}}}const b=(n,e)=>{for(;e<n.length&&/\s/.test(n[e]);)e++;return e};function T(n,e,t){for(let s=0;s<e.length;s++)if(e[s]!==n[t+s+1])return!1;return!0}function C(n){if(x(n))return n;throw new Error(`Invalid entity name ${n}`)}const Ne=/^[-+]?0x[a-fA-F0-9]+$/,me=/^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/,Te={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0,infinity:"original"};function we(n,e={}){if(e=Object.assign({},Te,e),!n||typeof n!="string")return n;let t=n.trim();if(t.length===0)return n;if(e.skipLike!==void 0&&e.skipLike.test(t))return n;if(t==="0")return 0;if(e.hex&&Ne.test(t))return Ce(t,16);if(isFinite(t)){if(t.includes("e")||t.includes("E"))return Se(n,t,e);{const s=me.exec(t);if(s){const i=s[1]||"",r=s[2];let u=_e(s[3]);const a=i?n[r.length+1]===".":n[r.length]===".";if(!e.leadingZeros&&(r.length>1||r.length===1&&!a))return n;{const o=Number(t),f=String(o);if(o===0)return o;if(f.search(/[eE]/)!==-1)return e.eNotation?o:n;if(t.indexOf(".")!==-1)return f==="0"||f===u||f===`${i}${u}`?o:n;let l=r?u:t;return r?l===f||i+l===f?o:n:l===f||l===i+f?o:n}}else return n}}else return Pe(n,Number(t),e)}const Ie=/^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;function Se(n,e,t){if(!t.eNotation)return n;const s=e.match(Ie);if(s){let i=s[1]||"";const r=s[3].indexOf("e")===-1?"E":"e",u=s[2],a=i?n[u.length+1]===r:n[u.length]===r;return u.length>1&&a?n:u.length===1&&(s[3].startsWith(`.${r}`)||s[3][0]===r)?Number(e):u.length>0?t.leadingZeros&&!a?(e=(s[1]||"")+s[3],Number(e)):n:Number(e)}else return n}function _e(n){return n&&n.indexOf(".")!==-1&&(n=n.replace(/0+$/,""),n==="."?n="0":n[0]==="."?n="0"+n:n[n.length-1]==="."&&(n=n.substring(0,n.length-1))),n}function Ce(n,e){if(parseInt)return parseInt(n,e);if(Number.parseInt)return Number.parseInt(n,e);if(window&&window.parseInt)return window.parseInt(n,e);throw new Error("parseInt, Number.parseInt, window.parseInt are not supported")}function Pe(n,e,t){const s=e===1/0;switch(t.infinity.toLowerCase()){case"null":return null;case"infinity":return e;case"string":return s?"Infinity":"-Infinity";case"original":default:return n}}function Oe(n){return typeof n=="function"?n:Array.isArray(n)?e=>{for(const t of n)if(typeof t=="string"&&e===t||t instanceof RegExp&&t.test(e))return!0}:()=>!1}class q{constructor(e,t={}){this.pattern=e,this.separator=t.separator||".",this.segments=this._parse(e),this._hasDeepWildcard=this.segments.some(s=>s.type==="deep-wildcard"),this._hasAttributeCondition=this.segments.some(s=>s.attrName!==void 0),this._hasPositionSelector=this.segments.some(s=>s.position!==void 0)}_parse(e){const t=[];let s=0,i="";for(;s<e.length;)e[s]===this.separator?s+1<e.length&&e[s+1]===this.separator?(i.trim()&&(t.push(this._parseSegment(i.trim())),i=""),t.push({type:"deep-wildcard"}),s+=2):(i.trim()&&t.push(this._parseSegment(i.trim())),i="",s++):(i+=e[s],s++);return i.trim()&&t.push(this._parseSegment(i.trim())),t}_parseSegment(e){const t={type:"tag"};let s=null,i=e;const r=e.match(/^([^\[]+)(\[[^\]]*\])(.*)$/);if(r&&(i=r[1]+r[3],r[2])){const l=r[2].slice(1,-1);l&&(s=l)}let u,a=i;if(i.includes("::")){const l=i.indexOf("::");if(u=i.substring(0,l).trim(),a=i.substring(l+2).trim(),!u)throw new Error(`Invalid namespace in pattern: ${e}`)}let o,f=null;if(a.includes(":")){const l=a.lastIndexOf(":"),c=a.substring(0,l).trim(),p=a.substring(l+1).trim();["first","last","odd","even"].includes(p)||/^nth\(\d+\)$/.test(p)?(o=c,f=p):o=a}else o=a;if(!o)throw new Error(`Invalid segment pattern: ${e}`);if(t.tag=o,u&&(t.namespace=u),s)if(s.includes("=")){const l=s.indexOf("=");t.attrName=s.substring(0,l).trim(),t.attrValue=s.substring(l+1).trim()}else t.attrName=s.trim();if(f){const l=f.match(/^nth\((\d+)\)$/);l?(t.position="nth",t.positionValue=parseInt(l[1],10)):t.position=f}return t}get length(){return this.segments.length}hasDeepWildcard(){return this._hasDeepWildcard}hasAttributeCondition(){return this._hasAttributeCondition}hasPositionSelector(){return this._hasPositionSelector}toString(){return this.pattern}}const Ae=new Set(["push","pop","reset","updateCurrent","restore"]);class Me{constructor(e={}){this.separator=e.separator||".",this.path=[],this.siblingStacks=[]}push(e,t=null,s=null){if(this.path.length>0){const l=this.path[this.path.length-1];l.values=void 0}const i=this.path.length;this.siblingStacks[i]||(this.siblingStacks[i]=new Map);const r=this.siblingStacks[i],u=s?`${s}:${e}`:e,a=r.get(u)||0;let o=0;for(const l of r.values())o+=l;r.set(u,a+1);const f={tag:e,position:o,counter:a};s!=null&&(f.namespace=s),t!=null&&(f.values=t),this.path.push(f)}pop(){if(this.path.length===0)return;const e=this.path.pop();return this.siblingStacks.length>this.path.length+1&&(this.siblingStacks.length=this.path.length+1),e}updateCurrent(e){if(this.path.length>0){const t=this.path[this.path.length-1];e!=null&&(t.values=e)}}getCurrentTag(){return this.path.length>0?this.path[this.path.length-1].tag:void 0}getCurrentNamespace(){return this.path.length>0?this.path[this.path.length-1].namespace:void 0}getAttrValue(e){var s;return this.path.length===0||(s=this.path[this.path.length-1].values)==null?void 0:s[e]}hasAttr(e){if(this.path.length===0)return!1;const t=this.path[this.path.length-1];return t.values!==void 0&&e in t.values}getPosition(){return this.path.length===0?-1:this.path[this.path.length-1].position??0}getCounter(){return this.path.length===0?-1:this.path[this.path.length-1].counter??0}getIndex(){return this.getPosition()}getDepth(){return this.path.length}toString(e,t=!0){const s=e||this.separator;return this.path.map(i=>t&&i.namespace?`${i.namespace}:${i.tag}`:i.tag).join(s)}toArray(){return this.path.map(e=>e.tag)}reset(){this.path=[],this.siblingStacks=[]}matches(e){const t=e.segments;return t.length===0?!1:e.hasDeepWildcard()?this._matchWithDeepWildcard(t):this._matchSimple(t)}_matchSimple(e){if(this.path.length!==e.length)return!1;for(let t=0;t<e.length;t++){const s=e[t],i=this.path[t],r=t===this.path.length-1;if(!this._matchSegment(s,i,r))return!1}return!0}_matchWithDeepWildcard(e){let t=this.path.length-1,s=e.length-1;for(;s>=0&&t>=0;){const i=e[s];if(i.type==="deep-wildcard"){if(s--,s<0)return!0;const r=e[s];let u=!1;for(let a=t;a>=0;a--){const o=a===this.path.length-1;if(this._matchSegment(r,this.path[a],o)){t=a-1,s--,u=!0;break}}if(!u)return!1}else{const r=t===this.path.length-1;if(!this._matchSegment(i,this.path[t],r))return!1;t--,s--}}return s<0}_matchSegment(e,t,s){if(e.tag!=="*"&&e.tag!==t.tag||e.namespace!==void 0&&e.namespace!=="*"&&e.namespace!==t.namespace)return!1;if(e.attrName!==void 0){if(!s||!t.values||!(e.attrName in t.values))return!1;if(e.attrValue!==void 0){const i=t.values[e.attrName];if(String(i)!==String(e.attrValue))return!1}}if(e.position!==void 0){if(!s)return!1;const i=t.counter??0;if(e.position==="first"&&i!==0)return!1;if(e.position==="odd"&&i%2!==1)return!1;if(e.position==="even"&&i%2!==0)return!1;if(e.position==="nth"&&i!==e.positionValue)return!1}return!0}snapshot(){return{path:this.path.map(e=>({...e})),siblingStacks:this.siblingStacks.map(e=>new Map(e))}}restore(e){this.path=e.path.map(t=>({...t})),this.siblingStacks=e.siblingStacks.map(t=>new Map(t))}readOnly(){const e=this;return new Proxy(e,{get(t,s,i){if(Ae.has(s))return()=>{throw new TypeError(`Cannot call '${s}' on a read-only Matcher. Obtain a writable instance to mutate state.`)};const r=Reflect.get(t,s,i);return s==="path"||s==="siblingStacks"?Object.freeze(Array.isArray(r)?r.map(u=>u instanceof Map?Object.freeze(new Map(u)):Object.freeze({...u})):r):typeof r=="function"?r.bind(t):r},set(t,s){throw new TypeError(`Cannot set property '${String(s)}' on a read-only Matcher.`)},deleteProperty(t,s){throw new TypeError(`Cannot delete property '${String(s)}' from a read-only Matcher.`)}})}}function xe(n,e){if(!n)return{};const t=e.attributesGroupName?n[e.attributesGroupName]:n;if(!t)return{};const s={};for(const i in t)if(i.startsWith(e.attributeNamePrefix)){const r=i.substring(e.attributeNamePrefix.length);s[r]=t[i]}else s[i]=t[i];return s}function ve(n){if(!n||typeof n!="string")return;const e=n.indexOf(":");if(e!==-1&&e>0){const t=n.substring(0,e);if(t!=="xmlns")return t}}class $e{constructor(e){if(this.options=e,this.currentNode=null,this.tagsNodeStack=[],this.docTypeEntities={},this.lastEntities={apos:{regex:/&(apos|#39|#x27);/g,val:"'"},gt:{regex:/&(gt|#62|#x3E);/g,val:">"},lt:{regex:/&(lt|#60|#x3C);/g,val:"<"},quot:{regex:/&(quot|#34|#x22);/g,val:'"'}},this.ampEntity={regex:/&(amp|#38|#x26);/g,val:"&"},this.htmlEntities={space:{regex:/&(nbsp|#160);/g,val:" "},cent:{regex:/&(cent|#162);/g,val:"¢"},pound:{regex:/&(pound|#163);/g,val:"£"},yen:{regex:/&(yen|#165);/g,val:"¥"},euro:{regex:/&(euro|#8364);/g,val:"€"},copyright:{regex:/&(copy|#169);/g,val:"©"},reg:{regex:/&(reg|#174);/g,val:"®"},inr:{regex:/&(inr|#8377);/g,val:"₹"},num_dec:{regex:/&#([0-9]{1,7});/g,val:(t,s)=>H(s,10,"&#")},num_hex:{regex:/&#x([0-9a-fA-F]{1,6});/g,val:(t,s)=>H(s,16,"&#x")}},this.addExternalEntities=je,this.parseXml=Fe,this.parseTextData=ke,this.resolveNameSpace=Ve,this.buildAttributesMap=Re,this.isItStopNode=Ye,this.replaceEntitiesValue=Ue,this.readStopNodeData=Ge,this.saveTextToParentTag=We,this.addChild=Be,this.ignoreAttributesFn=Oe(this.options.ignoreAttributes),this.entityExpansionCount=0,this.currentExpandedLength=0,this.matcher=new Me,this.readonlyMatcher=this.matcher.readOnly(),this.isCurrentNodeStopNode=!1,this.options.stopNodes&&this.options.stopNodes.length>0){this.stopNodeExpressions=[];for(let t=0;t<this.options.stopNodes.length;t++){const s=this.options.stopNodes[t];typeof s=="string"?this.stopNodeExpressions.push(new q(s)):s instanceof q&&this.stopNodeExpressions.push(s)}}}}function je(n){const e=Object.keys(n);for(let t=0;t<e.length;t++){const s=e[t],i=s.replace(/[.\-+*:]/g,"\\.");this.lastEntities[s]={regex:new RegExp("&"+i+";","g"),val:n[s]}}}function ke(n,e,t,s,i,r,u){if(n!==void 0&&(this.options.trimValues&&!s&&(n=n.trim()),n.length>0)){u||(n=this.replaceEntitiesValue(n,e,t));const a=this.options.jPath?t.toString():t,o=this.options.tagValueProcessor(e,n,a,i,r);return o==null?n:typeof o!=typeof n||o!==n?o:this.options.trimValues?L(n,this.options.parseTagValue,this.options.numberParseOptions):n.trim()===n?L(n,this.options.parseTagValue,this.options.numberParseOptions):n}}function Ve(n){if(this.options.removeNSPrefix){const e=n.split(":"),t=n.charAt(0)==="/"?"/":"";if(e[0]==="xmlns")return"";e.length===2&&(n=t+e[1])}return n}const Le=new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`,"gm");function Re(n,e,t){if(this.options.ignoreAttributes!==!0&&typeof n=="string"){const s=W(n,Le),i=s.length,r={},u={};for(let a=0;a<i;a++){const o=this.resolveNameSpace(s[a][1]),f=s[a][4];if(o.length&&f!==void 0){let l=f;this.options.trimValues&&(l=l.trim()),l=this.replaceEntitiesValue(l,t,this.readonlyMatcher),u[o]=l}}Object.keys(u).length>0&&typeof e=="object"&&e.updateCurrent&&e.updateCurrent(u);for(let a=0;a<i;a++){const o=this.resolveNameSpace(s[a][1]),f=this.options.jPath?e.toString():this.readonlyMatcher;if(this.ignoreAttributesFn(o,f))continue;let l=s[a][4],c=this.options.attributeNamePrefix+o;if(o.length)if(this.options.transformAttributeName&&(c=this.options.transformAttributeName(c)),c=Q(c,this.options),l!==void 0){this.options.trimValues&&(l=l.trim()),l=this.replaceEntitiesValue(l,t,this.readonlyMatcher);const p=this.options.jPath?e.toString():this.readonlyMatcher,y=this.options.attributeValueProcessor(o,l,p);y==null?r[c]=l:typeof y!=typeof l||y!==l?r[c]=y:r[c]=L(l,this.options.parseAttributeValue,this.options.numberParseOptions)}else this.options.allowBooleanAttributes&&(r[c]=!0)}if(!Object.keys(r).length)return;if(this.options.attributesGroupName){const a={};return a[this.options.attributesGroupName]=r,a}return r}}const Fe=function(n){n=n.replace(/\r\n?/g,`
4
+ `);const e=new m("!xml");let t=e,s="";this.matcher.reset(),this.entityExpansionCount=0,this.currentExpandedLength=0;const i=new ye(this.options.processEntities);for(let r=0;r<n.length;r++)if(n[r]==="<")if(n[r+1]==="/"){const a=w(n,">",r,"Closing Tag is not closed.");let o=n.substring(r+2,a).trim();if(this.options.removeNSPrefix){const l=o.indexOf(":");l!==-1&&(o=o.substr(l+1))}o=R(this.options.transformTagName,o,"",this.options).tagName,t&&(s=this.saveTextToParentTag(s,t,this.readonlyMatcher));const f=this.matcher.getCurrentTag();if(o&&this.options.unpairedTags.indexOf(o)!==-1)throw new Error(`Unpaired tag can not be used as closing tag: </${o}>`);f&&this.options.unpairedTags.indexOf(f)!==-1&&(this.matcher.pop(),this.tagsNodeStack.pop()),this.matcher.pop(),this.isCurrentNodeStopNode=!1,t=this.tagsNodeStack.pop(),s="",r=a}else if(n[r+1]==="?"){let a=V(n,r,!1,"?>");if(!a)throw new Error("Pi Tag is not closed.");if(s=this.saveTextToParentTag(s,t,this.readonlyMatcher),!(this.options.ignoreDeclaration&&a.tagName==="?xml"||this.options.ignorePiTags)){const o=new m(a.tagName);o.add(this.options.textNodeName,""),a.tagName!==a.tagExp&&a.attrExpPresent&&(o[":@"]=this.buildAttributesMap(a.tagExp,this.matcher,a.tagName)),this.addChild(t,o,this.readonlyMatcher,r)}r=a.closeIndex+1}else if(n.substr(r+1,3)==="!--"){const a=w(n,"-->",r+4,"Comment is not closed.");if(this.options.commentPropName){const o=n.substring(r+4,a-2);s=this.saveTextToParentTag(s,t,this.readonlyMatcher),t.add(this.options.commentPropName,[{[this.options.textNodeName]:o}])}r=a}else if(n.substr(r+1,2)==="!D"){const a=i.readDocType(n,r);this.docTypeEntities=a.entities,r=a.i}else if(n.substr(r+1,2)==="!["){const a=w(n,"]]>",r,"CDATA is not closed.")-2,o=n.substring(r+9,a);s=this.saveTextToParentTag(s,t,this.readonlyMatcher);let f=this.parseTextData(o,t.tagname,this.readonlyMatcher,!0,!1,!0,!0);f==null&&(f=""),this.options.cdataPropName?t.add(this.options.cdataPropName,[{[this.options.textNodeName]:o}]):t.add(this.options.textNodeName,f),r=a+2}else{let a=V(n,r,this.options.removeNSPrefix);if(!a){const d=n.substring(Math.max(0,r-50),Math.min(n.length,r+50));throw new Error(`readTagExp returned undefined at position ${r}. Context: "${d}"`)}let o=a.tagName;const f=a.rawTagName;let l=a.tagExp,c=a.attrExpPresent,p=a.closeIndex;if({tagName:o,tagExp:l}=R(this.options.transformTagName,o,l,this.options),this.options.strictReservedNames&&(o===this.options.commentPropName||o===this.options.cdataPropName||o===this.options.textNodeName||o===this.options.attributesGroupName))throw new Error(`Invalid tag name: ${o}`);t&&s&&t.tagname!=="!xml"&&(s=this.saveTextToParentTag(s,t,this.readonlyMatcher,!1));const y=t;y&&this.options.unpairedTags.indexOf(y.tagname)!==-1&&(t=this.tagsNodeStack.pop(),this.matcher.pop());let P=!1;l.length>0&&l.lastIndexOf("/")===l.length-1&&(P=!0,o[o.length-1]==="/"?(o=o.substr(0,o.length-1),l=o):l=l.substr(0,l.length-1),c=o!==l);let E=null,O;O=ve(f),o!==e.tagname&&this.matcher.push(o,{},O),o!==l&&c&&(E=this.buildAttributesMap(l,this.matcher,o),E&&xe(E,this.options)),o!==e.tagname&&(this.isCurrentNodeStopNode=this.isItStopNode(this.stopNodeExpressions,this.matcher));const S=r;if(this.isCurrentNodeStopNode){let d="";if(P)r=a.closeIndex;else if(this.options.unpairedTags.indexOf(o)!==-1)r=a.closeIndex;else{const M=this.readStopNodeData(n,f,p+1);if(!M)throw new Error(`Unexpected end of ${f}`);r=M.i,d=M.tagContent}const A=new m(o);E&&(A[":@"]=E),A.add(this.options.textNodeName,d),this.matcher.pop(),this.isCurrentNodeStopNode=!1,this.addChild(t,A,this.readonlyMatcher,S)}else{if(P){({tagName:o,tagExp:l}=R(this.options.transformTagName,o,l,this.options));const d=new m(o);E&&(d[":@"]=E),this.addChild(t,d,this.readonlyMatcher,S),this.matcher.pop(),this.isCurrentNodeStopNode=!1}else if(this.options.unpairedTags.indexOf(o)!==-1){const d=new m(o);E&&(d[":@"]=E),this.addChild(t,d,this.readonlyMatcher,S),this.matcher.pop(),this.isCurrentNodeStopNode=!1,r=a.closeIndex;continue}else{const d=new m(o);if(this.tagsNodeStack.length>this.options.maxNestedTags)throw new Error("Maximum nested tags exceeded");this.tagsNodeStack.push(t),E&&(d[":@"]=E),this.addChild(t,d,this.readonlyMatcher,S),t=d}s="",r=p}}else s+=n[r];return e.child};function Be(n,e,t,s){this.options.captureMetaData||(s=void 0);const i=this.options.jPath?t.toString():t,r=this.options.updateTag(e.tagname,i,e[":@"]);r===!1||(typeof r=="string"&&(e.tagname=r),n.addChild(e,s))}function Ue(n,e,t){const s=this.options.processEntities;if(!s||!s.enabled)return n;if(s.allowedTags){const i=this.options.jPath?t.toString():t;if(!(Array.isArray(s.allowedTags)?s.allowedTags.includes(e):s.allowedTags(e,i)))return n}if(s.tagFilter){const i=this.options.jPath?t.toString():t;if(!s.tagFilter(e,i))return n}for(const i of Object.keys(this.docTypeEntities)){const r=this.docTypeEntities[i],u=n.match(r.regx);if(u){if(this.entityExpansionCount+=u.length,s.maxTotalExpansions&&this.entityExpansionCount>s.maxTotalExpansions)throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${s.maxTotalExpansions}`);const a=n.length;if(n=n.replace(r.regx,r.val),s.maxExpandedLength&&(this.currentExpandedLength+=n.length-a,this.currentExpandedLength>s.maxExpandedLength))throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${s.maxExpandedLength}`)}}for(const i of Object.keys(this.lastEntities)){const r=this.lastEntities[i],u=n.match(r.regex);if(u&&(this.entityExpansionCount+=u.length,s.maxTotalExpansions&&this.entityExpansionCount>s.maxTotalExpansions))throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${s.maxTotalExpansions}`);n=n.replace(r.regex,r.val)}if(n.indexOf("&")===-1)return n;if(this.options.htmlEntities)for(const i of Object.keys(this.htmlEntities)){const r=this.htmlEntities[i],u=n.match(r.regex);if(u&&(this.entityExpansionCount+=u.length,s.maxTotalExpansions&&this.entityExpansionCount>s.maxTotalExpansions))throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${s.maxTotalExpansions}`);n=n.replace(r.regex,r.val)}return n=n.replace(this.ampEntity.regex,this.ampEntity.val),n}function We(n,e,t,s){return n&&(s===void 0&&(s=e.child.length===0),n=this.parseTextData(n,e.tagname,t,!1,e[":@"]?Object.keys(e[":@"]).length!==0:!1,s),n!==void 0&&n!==""&&e.add(this.options.textNodeName,n),n=""),n}function Ye(n,e){if(!n||n.length===0)return!1;for(let t=0;t<n.length;t++)if(e.matches(n[t]))return!0;return!1}function ze(n,e,t=">"){let s,i="";for(let r=e;r<n.length;r++){let u=n[r];if(s)u===s&&(s="");else if(u==='"'||u==="'")s=u;else if(u===t[0])if(t[1]){if(n[r+1]===t[1])return{data:i,index:r}}else return{data:i,index:r};else u===" "&&(u=" ");i+=u}}function w(n,e,t,s){const i=n.indexOf(e,t);if(i===-1)throw new Error(s);return i+e.length-1}function V(n,e,t,s=">"){const i=ze(n,e+1,s);if(!i)return;let r=i.data;const u=i.index,a=r.search(/\s/);let o=r,f=!0;a!==-1&&(o=r.substring(0,a),r=r.substring(a+1).trimStart());const l=o;if(t){const c=o.indexOf(":");c!==-1&&(o=o.substr(c+1),f=o!==i.data.substr(c+1))}return{tagName:o,tagExp:r,closeIndex:u,attrExpPresent:f,rawTagName:l}}function Ge(n,e,t){const s=t;let i=1;for(;t<n.length;t++)if(n[t]==="<")if(n[t+1]==="/"){const r=w(n,">",t,`${e} is not closed`);if(n.substring(t+2,r).trim()===e&&(i--,i===0))return{tagContent:n.substring(s,t),i:r};t=r}else if(n[t+1]==="?")t=w(n,"?>",t+1,"StopNode is not closed.");else if(n.substr(t+1,3)==="!--")t=w(n,"-->",t+3,"StopNode is not closed.");else if(n.substr(t+1,2)==="![")t=w(n,"]]>",t,"StopNode is not closed.")-2;else{const r=V(n,t,">");r&&((r&&r.tagName)===e&&r.tagExp[r.tagExp.length-1]!=="/"&&i++,t=r.closeIndex)}}function L(n,e,t){if(e&&typeof n=="string"){const s=n.trim();return s==="true"?!0:s==="false"?!1:we(n,t)}else return re(n)?n:""}function H(n,e,t){const s=Number.parseInt(n,e);return s>=0&&s<=1114111?String.fromCodePoint(s):t+n+";"}function R(n,e,t,s){if(n){const i=n(e);t===e&&(t=i),e=i}return e=Q(e,s),{tagName:e,tagExp:t}}function Q(n,e){if(Y.includes(n))throw new Error(`[SECURITY] Invalid name: "${n}" is a reserved JavaScript keyword that could cause prototype pollution`);return k.includes(n)?e.onDangerousProperty(n):n}const F=m.getMetaDataSymbol();function Xe(n,e){if(!n||typeof n!="object")return{};if(!e)return n;const t={};for(const s in n)if(s.startsWith(e)){const i=s.substring(e.length);t[i]=n[s]}else t[s]=n[s];return t}function Ze(n,e,t,s){return D(n,e,t,s)}function D(n,e,t,s){let i;const r={};for(let u=0;u<n.length;u++){const a=n[u],o=Je(a);if(o!==void 0&&o!==e.textNodeName){const f=Xe(a[":@"]||{},e.attributeNamePrefix);t.push(o,f)}if(o===e.textNodeName)i===void 0?i=a[o]:i+=""+a[o];else{if(o===void 0)continue;if(a[o]){let f=D(a[o],e,t,s);const l=qe(f,e);if(a[":@"]?Ke(f,a[":@"],s,e):Object.keys(f).length===1&&f[e.textNodeName]!==void 0&&!e.alwaysCreateTextNode?f=f[e.textNodeName]:Object.keys(f).length===0&&(e.alwaysCreateTextNode?f[e.textNodeName]="":f=""),a[F]!==void 0&&typeof f=="object"&&f!==null&&(f[F]=a[F]),r[o]!==void 0&&Object.prototype.hasOwnProperty.call(r,o))Array.isArray(r[o])||(r[o]=[r[o]]),r[o].push(f);else{const c=e.jPath?s.toString():s;e.isArray(o,c,l)?r[o]=[f]:r[o]=f}o!==void 0&&o!==e.textNodeName&&t.pop()}}}return typeof i=="string"?i.length>0&&(r[e.textNodeName]=i):i!==void 0&&(r[e.textNodeName]=i),r}function Je(n){const e=Object.keys(n);for(let t=0;t<e.length;t++){const s=e[t];if(s!==":@")return s}}function Ke(n,e,t,s){if(e){const i=Object.keys(e),r=i.length;for(let u=0;u<r;u++){const a=i[u],o=a.startsWith(s.attributeNamePrefix)?a.substring(s.attributeNamePrefix.length):a,f=s.jPath?t.toString()+"."+o:t;s.isArray(a,f,!0,!0)?n[a]=[e[a]]:n[a]=e[a]}}}function qe(n,e){const{textNodeName:t}=e,s=Object.keys(n).length;return!!(s===0||s===1&&(n[t]||typeof n[t]=="boolean"||n[t]===0))}class He{constructor(e){this.externalEntities={},this.options=be(e)}parse(e,t){if(typeof e!="string"&&e.toString)e=e.toString();else if(typeof e!="string")throw new Error("XML data is accepted in String or Bytes[] form.");if(t){t===!0&&(t={});const r=oe(e,t);if(r!==!0)throw Error(`${r.err.msg}:${r.err.line}:${r.err.col}`)}const s=new $e(this.options);s.addExternalEntities(this.externalEntities);const i=s.parseXml(e);return this.options.preserveOrder||i===void 0?i:Ze(i,this.options,s.matcher,s.readonlyMatcher)}addEntity(e,t){if(t.indexOf("&")!==-1)throw new Error("Entity value can't have '&'");if(e.indexOf("&")!==-1||e.indexOf(";")!==-1)throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '&#xD;'");if(t==="&")throw new Error("An entity with value '&' is not permitted");this.externalEntities[e]=t}static getMetaDataSymbol(){return m.getMetaDataSymbol()}}const Qe={APPLET:"applet",BUSINESS_COMPONENT:"business_component",BUSINESS_OBJECT:"business_object",VIEW:"view",SCREEN:"screen",WORKFLOW:"workflow",INTEGRATION_OBJECT:"integration_object",BUSINESS_SERVICE:"business_service",WEB_TEMPLATE:"web_template",PICK_LIST:"pick_list",TABLE:"table"},De={FIELD:"field",COLUMN:"column",CONTROL:"control",LIST_COLUMN:"list_column",LINK:"link",APPLET_WEB_TEMPLATE:"web_template",VIEW_WEB_TEMPLATE:"web_template",VIEW_APPLET:"applet",SCREEN_VIEW:"view",APPLET_METHOD_MENU_ITEM:"menu_item",BUSINESS_OBJECT_COMPONENT:"business_component",BUSINESS_SERVICE_METHOD:"business_service",WORKFLOW_STEP:"workflow",INTEGRATION_COMPONENT:"business_component"},et=new Set(["NAME","INACTIVE"]);function $(n,e){const t=n[e];return Array.isArray(t)?t:t!=null?[t]:[]}function I(n,e){const t=n[`@_${e}`];return t!=null?String(t):void 0}function ee(n){const e=[];for(const[t,s]of Object.entries(n))t.startsWith("@_")&&!et.has(t.slice(2))&&e.push({name:t.slice(2),value:String(s)});return e}function tt(n,e){const t=[];for(const[s,i]of Object.entries(De))for(const r of $(n,s)){const u=r,a=I(u,"NAME");a&&t.push({name:a,type:i,properties:ee(u),children:[],parentName:e})}return t}function N(n,e){var t;return(t=n.properties.find(s=>s.name===e))==null?void 0:t.value}function nt(n){const e=[],t=new Map;for(const s of n)t.set(`${s.type}:${s.name}`,s);for(const s of n){if(s.type==="applet"){const i=N(s,"BUS_COMP");i&&t.has(`business_component:${i}`)&&e.push({from:{name:s.name,type:"applet"},to:{name:i,type:"business_component"},relationType:"references",inferred:!0})}if(s.type==="view"){const i=N(s,"BUS_OBJECT");i&&t.has(`business_object:${i}`)&&e.push({from:{name:s.name,type:"view"},to:{name:i,type:"business_object"},relationType:"references",inferred:!0});for(const r of s.children)if(r.type==="applet"){const u=N(r,"APPLET")??r.name;t.has(`applet:${u}`)&&e.push({from:{name:s.name,type:"view"},to:{name:u,type:"applet"},relationType:"contains",inferred:!0})}}if(s.type==="screen"){for(const i of s.children)if(i.type==="view"){const r=N(i,"VIEW")??i.name;t.has(`view:${r}`)&&e.push({from:{name:s.name,type:"screen"},to:{name:r,type:"view"},relationType:"contains",inferred:!0})}}if(s.type==="business_object"){for(const i of s.children)if(i.type==="business_component"){const r=N(i,"BUS_COMP")??i.name;t.has(`business_component:${r}`)&&e.push({from:{name:s.name,type:"business_object"},to:{name:r,type:"business_component"},relationType:"contains",inferred:!0})}}if(s.type==="workflow"){const i=N(s,"BUS_OBJECT");i&&t.has(`business_object:${i}`)&&e.push({from:{name:s.name,type:"workflow"},to:{name:i,type:"business_object"},relationType:"references",inferred:!0});for(const r of s.children){const u=N(r,"BUS_SERVICE");u&&t.has(`business_service:${u}`)&&e.push({from:{name:s.name,type:"workflow"},to:{name:u,type:"business_service"},relationType:"uses",inferred:!0})}}if(s.type==="integration_object"){const i=N(s,"BUS_COMP");i&&t.has(`business_component:${i}`)&&e.push({from:{name:s.name,type:"integration_object"},to:{name:i,type:"business_component"},relationType:"references",inferred:!0})}if(s.type==="business_component"){const i=N(s,"TABLE");i&&e.push({from:{name:s.name,type:"business_component"},to:{name:i,type:"table"},relationType:"based_on",inferred:!0});for(const r of s.children)if(r.type==="link"){const u=N(r,"CHILD_BC");u&&t.has(`business_component:${u}`)&&e.push({from:{name:s.name,type:"business_component"},to:{name:u,type:"business_component"},relationType:"linked_to",inferred:!0})}}}return e}self.onmessage=n=>{const{type:e,content:t,fileName:s}=n.data;if(e==="parse")try{self.postMessage({type:"progress",status:"parsing",progress:20});const r=new He({ignoreAttributes:!1,attributeNamePrefix:"@_",allowBooleanAttributes:!0,parseAttributeValue:!1,isArray:()=>!0}).parse(t);self.postMessage({type:"progress",status:"extracting",progress:50});const u=$(r,"REPOSITORY");if(u.length===0){self.postMessage({type:"error",message:"SIF file missing REPOSITORY root element"});return}const a=u[0],o=I(a,"NAME")??"Unknown",f=$(a,"PROJECT"),l=f.length>0?I(f[0],"NAME"):void 0,c=[];for(const E of f){const O=E,S=I(O,"NAME")??"Unknown";for(const[d,A]of Object.entries(Qe))for(const M of $(O,d)){const j=M,B=I(j,"NAME");B&&c.push({name:B,type:A,project:S,properties:ee(j),children:tt(j,B),inactive:I(j,"INACTIVE")==="Y"||void 0})}}self.postMessage({type:"progress",status:"inferring",progress:80});const p=nt(c),y=[...new Set(c.map(E=>E.type))],P={metadata:{fileName:s,repositoryName:o,projectName:l,objectCount:c.length,objectTypes:y,extractedAt:new Date().toISOString()},objects:c,dependencies:p};self.postMessage({type:"progress",status:"done",progress:100}),self.postMessage({type:"result",data:P})}catch(i){self.postMessage({type:"error",message:i instanceof Error?i.message:String(i)})}}})();
@@ -0,0 +1 @@
1
+ import{r as l,a as w,j as e}from"./index-CsH_Hv51.js";import{P,L as O}from"./constants-lq4BIQN3.js";function D(){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([w.getSkills(),w.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 v=l.useCallback(async(r,m)=>{s(k=>k.map(y=>y.name===r?{...y,enabled:m}:y));try{await w.toggleSkill(r,m)}catch{d()}},[d]),p=l.useCallback(async r=>{await w.createCustomSkill(r),d()},[d]),N=l.useCallback(async(r,m)=>{await w.updateCustomSkill(r,m),d()},[d]),j=l.useCallback(async r=>{await w.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:v,createSkill:p,updateSkill:N,deleteSkill:j}}function A({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 F=["know-me","software-design","security","testing","cost-reducer","research","ddd","frontend-design","other"];function z({open:t,onClose:s,onSubmit:u,editSkill:n}){const[i,c]=l.useState(""),[x,b]=l.useState(""),[h,f]=l.useState("know-me"),[d,v]=l.useState(["IMPLEMENT"]),[p,N]=l.useState(""),[j,g]=l.useState(!1),[r,m]=l.useState(null);l.useEffect(()=>{n?(c(n.name),b(n.description),f(n.category),v(n.phases??["IMPLEMENT"]),N("")):(c(""),b(""),f("know-me"),v(["IMPLEMENT"]),N("")),m(null)},[n,t]);const k=l.useCallback(a=>{v(C=>C.includes(a)?C.filter(T=>T!==a):[...C,a])},[]),y=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:F.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:O.map(a=>e.jsx("button",{type:"button",onClick:()=>k(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=>N(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:y,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 S({value:t,label:s}){return e.jsxs("div",{className:"p-3 rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow 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 _({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 B({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(_,{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}=D(),[v,p]=l.useState(null),[N,j]=l.useState(!1),[g,r]=l.useState(null),m=l.useCallback(async o=>{await d(o),p(null)},[d]),k=l.useCallback(o=>{p(null),r(o),j(!0)},[]),y=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.jsx("div",{className:"flex items-center justify-center h-full text-muted",children:"Loading skills..."});const a=t.filter(o=>o.source==="built-in").length,C=t.filter(o=>o.source==="custom").length,T=t.filter(o=>o.enabled).length,M=new Map;for(const o of O){const E=t.filter($=>{var R;return(R=$.phases)==null?void 0:R.includes(o)});E.length>0&&M.set(o,E)}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(S,{value:t.length,label:"Total Skills"}),e.jsx(S,{value:a,label:"Built-in"}),e.jsx(S,{value:C,label:"Custom"}),e.jsx(S,{value:T,label:"Enabled"}),e.jsx(S,{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,E])=>e.jsx(B,{phase:o,skills:E,onToggle:b,onSkillClick:p},o)),L.length>0&&e.jsx(B,{phase:"Other",skills:L,onToggle:b,onSkillClick:p})]}),e.jsx(A,{skill:v,onClose:()=>p(null),onToggle:b,onDelete:m,onEdit:k}),e.jsx(z,{open:N,onClose:()=>{j(!1),r(null)},onSubmit:y,editSkill:g})]})}export{Y as SkillsTab};