truecourse 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.mjs +9417 -712
- package/db/migrations/0000_common_guardsmen.sql +227 -0
- package/db/migrations/meta/0000_snapshot.json +1101 -87
- package/db/migrations/meta/_journal.json +2 -2
- package/package.json +1 -1
- package/public/404.html +2 -2
- package/public/_next/static/chunks/381-85180243c39f893f.js +1 -0
- package/public/_next/static/chunks/552-6917726d81ee49a3.js +1 -0
- package/public/_next/static/chunks/572-f3883e9a1f12af9b.js +1 -0
- package/public/_next/static/chunks/597-bdc49f9b0afbcc65.js +1 -0
- package/public/_next/static/chunks/7273c211-cf17e181dbeacc49.js +1 -0
- package/public/_next/static/chunks/a51c26f2-8f567e78114a65f0.js +1 -0
- package/public/_next/static/chunks/app/_not-found/page-7ce89933d9d660c3.js +1 -0
- package/public/_next/static/chunks/app/layout-7b61f0cc08a2b70c.js +1 -0
- package/public/_next/static/chunks/app/page-cfec34672a92b197.js +1 -0
- package/public/_next/static/chunks/app/repos/[[...slug]]/page-775a75a81164bb72.js +1 -0
- package/public/_next/static/chunks/framework-56b72e8a5f911564.js +1 -0
- package/public/_next/static/chunks/main-19f32cbfea665136.js +1 -0
- package/public/_next/static/chunks/main-app-11a30c55aba12d50.js +1 -0
- package/public/_next/static/chunks/pages/_app-23d1cfabc23fb6da.js +1 -0
- package/public/_next/static/chunks/pages/{_error-b3f1a96c07a42193.js → _error-647008f4bf4249c2.js} +1 -1
- package/public/_next/static/chunks/webpack-f20a7a6e701c70d8.js +1 -0
- package/public/_next/static/css/bfb5d4bf473c84ea.css +1 -0
- package/public/_next/static/{bPWCf-gzBKdFUdcy_Q1EJ → kWvBK3M_UdFRGPFgNFXnS}/_buildManifest.js +1 -1
- package/public/index.html +2 -2
- package/public/index.txt +10 -10
- package/public/logo.svg +29 -0
- package/public/repos.html +12 -1
- package/public/repos.txt +15 -15
- package/server.mjs +6525 -3626
- package/db/migrations/0000_daily_paper_doll.sql +0 -82
- package/public/_next/static/chunks/414-8318b3e90e55d32a.js +0 -1
- package/public/_next/static/chunks/597-63908a91b482ecc2.js +0 -1
- package/public/_next/static/chunks/7273c211-8e9085ce5065411a.js +0 -1
- package/public/_next/static/chunks/728-8bf3f63c2116a9f4.js +0 -1
- package/public/_next/static/chunks/a51c26f2-7912c8e37f20294d.js +0 -1
- package/public/_next/static/chunks/app/_not-found/page-2f5b5dd68feb177e.js +0 -1
- package/public/_next/static/chunks/app/layout-f77cd77fe41bf255.js +0 -1
- package/public/_next/static/chunks/app/page-59b2858b3b17446e.js +0 -1
- package/public/_next/static/chunks/app/repos/[[...slug]]/page-a9fc239dd01f7549.js +0 -1
- package/public/_next/static/chunks/framework-cd8a7ea2c29e04e3.js +0 -1
- package/public/_next/static/chunks/main-75f848718c47ce7f.js +0 -1
- package/public/_next/static/chunks/main-app-598d148dafd4bc32.js +0 -1
- package/public/_next/static/chunks/pages/_app-cbca4c5e73429fb7.js +0 -1
- package/public/_next/static/chunks/webpack-2f0ed87fd33e9d1c.js +0 -1
- package/public/_next/static/css/49e7ab4429e483d4.css +0 -1
- /package/public/_next/static/{bPWCf-gzBKdFUdcy_Q1EJ → kWvBK3M_UdFRGPFgNFXnS}/_ssgManifest.js +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[302],{40191:(e,t,a)=>{"use strict";a.d(t,{default:()=>tF});var r=a(6409),s=a(84669),l=a(19730),n=a(41540),o=a(95847),d=a(41791),i=a(8485),c=a(30553),u=a(88670),m=a(67832),x=a(76176),h=a(31264),p=a(35676),f=a(86669);function g(e){let{className:t,children:a,...s}=e;return(0,r.jsxs)(u.V,{"data-slot":"scroll-area",className:(0,f.cn)("relative",t),...s,children:[(0,r.jsx)(m.B,{"data-slot":"scroll-area-viewport",className:"size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1",children:a}),(0,r.jsx)(b,{}),(0,r.jsx)(x.I,{})]})}function b(e){let{className:t,orientation:a="vertical",...s}=e;return(0,r.jsx)(h.V,{"data-slot":"scroll-area-scrollbar","data-orientation":a,orientation:a,className:(0,f.cn)("flex touch-none p-px transition-colors select-none data-horizontal:h-2.5 data-horizontal:flex-col data-horizontal:border-t data-horizontal:border-t-transparent data-vertical:h-full data-vertical:w-2.5 data-vertical:border-l data-vertical:border-l-transparent",t),...s,children:(0,r.jsx)(p.l,{"data-slot":"scroll-area-thumb",className:"relative flex-1 rounded-full bg-border"})})}function y(e){let{children:t,isOpen:a,defaultWidth:l=387,minWidth:n=260,maxWidth:o=780}=e,[d,i]=(0,s.useState)(l),c=(0,s.useRef)(!1),u=(0,s.useCallback)(e=>{e.preventDefault(),c.current=!0;let t=e.clientX,a=e=>{c.current&&i(Math.min(o,Math.max(n,d+(t-e.clientX))))},r=()=>{c.current=!1,document.removeEventListener("mousemove",a),document.removeEventListener("mouseup",r)};document.addEventListener("mousemove",a),document.addEventListener("mouseup",r)},[d,n,o]);return a?(0,r.jsxs)("aside",{className:"relative flex-shrink-0 border-l border-border bg-card",style:{width:d},children:[(0,r.jsx)("div",{className:"absolute inset-y-0 left-0 z-10 w-1 cursor-col-resize hover:bg-primary/30 active:bg-primary/50",onMouseDown:u}),(0,r.jsx)(g,{className:"h-full",children:t})]}):null}var v=a(28197),j=a(4027),N=a(70461);let w=[{id:"violations",icon:v.A,label:"Violations"},{id:"rules",icon:j.A,label:"Rules"},{id:"files",icon:N.A,label:"Files"}];function k(e){let{activeTab:t,onTabChange:a,children:l,defaultWidth:n=350,minWidth:o=260}=e,[d,i]=(0,s.useState)(n),[c,u]=(0,s.useState)(800),m=(0,s.useRef)(!1);(0,s.useEffect)(()=>{let e=()=>Math.floor(.8*window.innerWidth);u(e());let t=()=>u(e());return window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[]);let x=(0,s.useCallback)(e=>{e.preventDefault(),m.current=!0;let t=e.clientX,a=e=>{m.current&&i(Math.min(c,Math.max(o,d+(e.clientX-t))))},r=()=>{m.current=!1,document.removeEventListener("mousemove",a),document.removeEventListener("mouseup",r)};document.addEventListener("mousemove",a),document.addEventListener("mouseup",r)},[d,o,c]);return(0,r.jsxs)("div",{className:"flex flex-shrink-0 h-full",children:[(0,r.jsx)("div",{className:"flex w-12 flex-col items-center gap-1 border-r border-border bg-card pt-2",children:w.map(e=>{let s=e.icon,l=t===e.id;return(0,r.jsxs)("button",{onClick:()=>a(l?null:e.id),className:"group relative flex h-10 w-10 items-center justify-center rounded-md transition-colors ".concat(l?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground"),"aria-label":e.label,children:[l&&(0,r.jsx)("div",{className:"absolute left-0 top-1.5 bottom-1.5 w-0.5 rounded-r bg-primary"}),(0,r.jsx)(s,{className:"h-5 w-5"})]},e.id)})}),null!==t&&(0,r.jsxs)("aside",{className:"relative flex-shrink-0 border-r border-border bg-card",style:{width:d},children:[(0,r.jsx)("div",{className:"flex h-10 items-center border-b border-border px-3",children:(0,r.jsx)("span",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"violations"===t?"Violations":"rules"===t?"Rules":"Files"})}),(0,r.jsx)("div",{className:"h-[calc(100%-40px)] overflow-hidden",children:l}),(0,r.jsx)("div",{className:"absolute inset-y-0 right-0 z-10 w-1 cursor-col-resize hover:bg-primary/30 active:bg-primary/50",onMouseDown:x})]})]})}var C=a(82759);a(75285);var S=a(74819),A=a(8984),M=a(55929),T=a(36661),I=a(29494),E=a(45784);function z(e){let{className:t,size:a="default",...s}=e;return(0,r.jsx)("div",{"data-slot":"card","data-size":a,className:(0,f.cn)("group/card flex flex-col gap-4 overflow-hidden rounded-xl bg-card py-4 text-sm text-card-foreground ring-1 ring-foreground/10 has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:gap-3 data-[size=sm]:py-3 data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl",t),...s})}function L(e){let{className:t,...a}=e;return(0,r.jsx)("div",{"data-slot":"card-content",className:(0,f.cn)("px-4 group-data-[size=sm]/card:px-3",t),...a})}let F={api:"Routes & Controllers",service:"Business Logic",data:"Database & ORM",external:"HTTP Clients"},D=[{layer:"api",color:"#3b82f6",label:F.api},{layer:"service",color:"#8b5cf6",label:F.service},{layer:"data",color:"#10b981",label:F.data},{layer:"external",color:"#f97316",label:F.external}],P={frontend:A.A,"api-server":M.A,worker:T.A,library:I.A,unknown:I.A},R="!bg-muted-foreground !border-none !w-[5px] !h-[5px] !z-10",X="!invisible",H=(0,s.memo)(function(e){let{id:t,data:a,selected:s}=e,{label:l,description:n,serviceInfo:o,insightCount:d,hasHighSeverity:i,onExplain:c,diffBadge:u}=a,m=P[o.type]||I.A,x=(0,C.d)({handleType:"target",handleId:"top"}),h=(0,C.d)({handleType:"source",handleId:"bottom"}),p=o.layers.map(e=>e.layer);return(0,r.jsxs)(z,{className:"relative min-w-[220px] !gap-0 !py-0 !overflow-visible rounded-md shadow-md transition-all !bg-card/80 ".concat(s?"border-primary ring-1 ring-primary/30":""),children:[(0,r.jsx)(C.h7,{type:"target",position:S.yX.Top,id:"top",className:x.length>0?R:X}),(0,r.jsxs)(L,{className:"p-3",children:[(0,r.jsxs)("div",{className:"flex items-start gap-3",children:[(0,r.jsx)("div",{className:"flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-lg bg-muted",children:(0,r.jsx)(m,{className:"h-5 w-5 text-primary"})}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)("h3",{className:"truncate text-sm font-bold text-foreground",children:l}),o.framework&&(0,r.jsx)("p",{className:"mt-0.5 text-[10px] italic text-muted-foreground",children:o.framework})]}),i&&(0,r.jsx)("div",{className:"flex-shrink-0",children:(0,r.jsx)(v.A,{className:"h-4 w-4 text-amber-500"})}),u&&(u.newCount>0||u.resolvedCount>0)&&(0,r.jsxs)("div",{className:"flex flex-shrink-0 gap-1",children:[u.newCount>0&&(0,r.jsxs)("span",{className:"group/diff relative inline-flex items-center rounded-full bg-amber-500/20 px-1.5 py-0.5 text-[9px] font-semibold text-amber-500",children:["+",u.newCount,(0,r.jsxs)("span",{className:"pointer-events-none absolute left-1/2 bottom-full mb-1 -translate-x-1/2 z-[9999] hidden group-hover/diff:block whitespace-nowrap rounded bg-popover border border-border px-2 py-1 text-[10px] text-popover-foreground shadow-lg",children:[u.newCount," new violation",1!==u.newCount?"s":""," from pending changes"]})]}),u.resolvedCount>0&&(0,r.jsxs)("span",{className:"group/diff relative inline-flex items-center rounded-full bg-emerald-500/20 px-1.5 py-0.5 text-[9px] font-semibold text-emerald-500",children:["-",u.resolvedCount,(0,r.jsxs)("span",{className:"pointer-events-none absolute left-1/2 bottom-full mb-1 -translate-x-1/2 z-[9999] hidden group-hover/diff:block whitespace-nowrap rounded bg-popover border border-border px-2 py-1 text-[10px] text-popover-foreground shadow-lg",children:[u.resolvedCount," violation",1!==u.resolvedCount?"s":""," resolved by pending changes"]})]})]})]}),(0,r.jsx)("div",{className:"mx-auto mt-2 w-2/3 border-t border-border"}),n&&(0,r.jsx)("p",{className:"mt-2 max-w-[240px] text-[10px] leading-tight text-muted-foreground",children:n}),p.length>0&&(0,r.jsx)("div",{className:"mt-2 flex flex-wrap gap-1",children:D.map(e=>{let{layer:t,label:a,color:s}=e;return p.includes(t)?(0,r.jsx)("span",{className:"inline-flex items-center rounded-sm border px-1.5 py-0.5 text-[9px] text-muted-foreground",style:{borderColor:s},children:a},t):null})}),d>0&&(0,r.jsxs)("div",{className:"mt-2 rounded-md bg-muted px-2 py-1 text-center text-[10px] text-muted-foreground",children:[d," insight",1!==d?"s":""]}),(0,r.jsx)("div",{className:"mx-auto mt-2 w-2/3 border-t border-border"}),(0,r.jsxs)("div",{className:"mt-2 flex items-center justify-between",children:[(0,r.jsxs)("span",{className:"text-[9px] text-muted-foreground",children:[o.fileCount," files"]}),c&&(0,r.jsxs)("button",{className:"flex items-center gap-1 rounded-sm border border-border bg-muted px-1.5 py-0.5 text-[9px] text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",onClick:e=>{e.stopPropagation(),c(t)},children:[(0,r.jsx)(E.A,{className:"h-2.5 w-2.5"}),"Explain"]})]})]}),(0,r.jsx)(C.h7,{type:"source",position:S.yX.Bottom,id:"bottom",className:h.length>0?R:X})]})});var B=a(98238),W=a(99372);let _="!bg-muted-foreground !border-none !w-[5px] !h-[5px] !z-10",V="!invisible",G=(0,s.memo)(function(e){let{id:t,data:a}=e,{label:l,fileCount:n,layerColor:o,fileNames:d=[],isContainer:i,isCollapsed:c,onToggleCollapse:u,moduleCount:m,violations:x=[],onExplain:h,diffBadge:p}=a,f=F[l]||l,{setEdges:g}=(0,C.VH)(),b=x.flatMap(e=>{var t;return(null==(t=e.edgeIds)?void 0:t.length)?e.edgeIds:e.edgeId?[e.edgeId]:[]}),y=(0,s.useCallback)(()=>{if(0===b.length)return;let e=new Set(b);g(t=>t.map(t=>e.has(t.id)?{...t,data:{...t.data,highlighted:!0}}:t))},[g,b]),j=(0,s.useCallback)(()=>{if(0===b.length)return;let e=new Set(b);g(t=>t.map(t=>e.has(t.id)?{...t,data:{...t.data,highlighted:!1}}:t))},[g,b]),N=(0,C.d)({handleType:"target",handleId:"top"}),w=(0,C.d)({handleType:"source",handleId:"bottom"}),k=(0,C.d)({handleType:"source",handleId:"right-src"}),A=(0,C.d)({handleType:"target",handleId:"right-tgt"}),M=x.length>0&&(0,r.jsxs)("div",{className:"group/violation relative shrink-0 pointer-events-auto nodrag",onMouseEnter:y,onMouseLeave:j,children:[(0,r.jsx)(v.A,{className:"h-3 w-3 text-red-500"}),(0,r.jsx)("div",{className:"pointer-events-none absolute left-1/2 bottom-full mb-1.5 -translate-x-1/2 z-[9999] hidden group-hover/violation:block",children:(0,r.jsxs)("div",{className:"rounded-md border border-red-500/30 bg-card px-2.5 py-2 shadow-lg w-[220px]",children:[(0,r.jsx)("p",{className:"text-[10px] font-semibold text-red-500 mb-1",children:"Layer Violation"}),x.map((e,t)=>(0,r.jsxs)("p",{className:"text-[10px] text-muted-foreground leading-tight",children:["Depends on ",(0,r.jsx)("span",{className:"font-medium text-foreground",children:F[e.targetLayer]||e.targetLayer})," — ",e.reason]},t))]})})]});if(i)return(0,r.jsxs)("div",{className:"rounded-md border border-border/50 bg-muted/20",style:{width:"100%",height:"100%"},children:[(0,r.jsx)(C.h7,{type:"target",position:S.yX.Top,id:"top",className:V}),(0,r.jsx)(C.h7,{type:"source",position:S.yX.Bottom,id:"bottom",className:V}),(0,r.jsx)(C.h7,{type:"source",position:S.yX.Right,id:"right-src",className:V}),(0,r.jsx)(C.h7,{type:"target",position:S.yX.Right,id:"right-tgt",className:V}),(0,r.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5",children:[u&&(0,r.jsx)("button",{className:"flex items-center justify-center text-muted-foreground hover:text-foreground transition-colors nodrag",onClick:e=>{e.stopPropagation(),u(t)},children:c?(0,r.jsx)(B.A,{className:"h-3 w-3"}):(0,r.jsx)(W.A,{className:"h-3 w-3"})}),(0,r.jsx)("div",{className:"h-2 w-2 rounded-full",style:{backgroundColor:o}}),(0,r.jsx)("span",{className:"text-[10px] font-medium text-muted-foreground",children:f}),c&&void 0!==m&&(0,r.jsxs)("span",{className:"text-[9px] text-muted-foreground/60 ml-auto",children:[m," modules"]}),p&&(p.newCount>0||p.resolvedCount>0)&&(0,r.jsxs)("div",{className:"ml-auto flex gap-1",children:[p.newCount>0&&(0,r.jsxs)("span",{className:"inline-flex items-center rounded-full bg-amber-500/20 px-1 py-0.5 text-[8px] font-semibold text-amber-500",children:["+",p.newCount]}),p.resolvedCount>0&&(0,r.jsxs)("span",{className:"inline-flex items-center rounded-full bg-emerald-500/20 px-1 py-0.5 text-[8px] font-semibold text-emerald-500",children:["-",p.resolvedCount]})]})]})]});let T=d.slice(0,5),I=d.length-5;return(0,r.jsxs)("div",{className:"rounded-md border bg-card/80 shadow-sm",style:{borderLeftWidth:3,borderLeftColor:o,minWidth:260},children:[(0,r.jsx)(C.h7,{type:"target",position:S.yX.Top,id:"top",className:N.length>0?_:V}),(0,r.jsx)(C.h7,{type:"source",position:S.yX.Bottom,id:"bottom",className:w.length>0?_:V}),(0,r.jsx)(C.h7,{type:"source",position:S.yX.Right,id:"right-src",className:k.length>0?_:V,style:{top:"75%"}}),(0,r.jsx)(C.h7,{type:"target",position:S.yX.Right,id:"right-tgt",className:A.length>0?_:V,style:{top:"25%"}}),(0,r.jsxs)("div",{className:"flex items-center justify-between px-3 py-1.5",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("div",{className:"h-2.5 w-2.5 rounded-full",style:{backgroundColor:o}}),(0,r.jsx)("span",{className:"text-xs font-medium text-foreground",children:f}),M]}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[p&&(p.newCount>0||p.resolvedCount>0)&&(0,r.jsxs)(r.Fragment,{children:[p.newCount>0&&(0,r.jsxs)("span",{className:"inline-flex items-center rounded-full bg-amber-500/20 px-1 py-0.5 text-[8px] font-semibold text-amber-500",children:["+",p.newCount]}),p.resolvedCount>0&&(0,r.jsxs)("span",{className:"inline-flex items-center rounded-full bg-emerald-500/20 px-1 py-0.5 text-[8px] font-semibold text-emerald-500",children:["-",p.resolvedCount]})]}),(0,r.jsxs)("span",{className:"text-[10px] text-muted-foreground",children:[n," files"]}),h&&(0,r.jsx)("button",{className:"flex items-center justify-center rounded-sm border border-border bg-muted p-0.5 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",onClick:e=>{e.stopPropagation(),h(t)},title:"Explain",children:(0,r.jsx)(E.A,{className:"h-2.5 w-2.5"})})]})]}),T.length>0&&(0,r.jsxs)("div",{className:"border-t border-border px-3 py-1",children:[T.map(e=>(0,r.jsx)("div",{className:"truncate text-[10px] text-muted-foreground leading-[18px]",children:e},e)),I>0&&(0,r.jsxs)("div",{className:"text-[10px] text-muted-foreground/60 leading-[18px]",children:["+",I," more"]})]})]})}),K={frontend:A.A,"api-server":M.A,worker:T.A,library:I.A,unknown:I.A},O=(0,s.memo)(function(e){let{data:t,selected:a}=e,{label:s,serviceType:l,framework:n,diffBadge:o}=t,d=K[l]||I.A;return(0,r.jsxs)("div",{className:"rounded-lg bg-muted/30 p-0 relative ".concat(a?"ring-1 ring-primary/30":"border border-border"),style:{width:"100%",height:"100%"},children:[(0,r.jsx)(C.h7,{type:"target",position:S.yX.Top,className:"!invisible"}),(0,r.jsxs)("div",{className:"flex items-center gap-2 border-b border-border px-3 py-2",children:[(0,r.jsx)(d,{className:"h-4 w-4 text-primary"}),(0,r.jsx)("span",{className:"text-xs font-bold text-foreground",children:s}),n&&(0,r.jsx)("span",{className:"text-[9px] italic text-muted-foreground",children:n}),o&&(o.newCount>0||o.resolvedCount>0)&&(0,r.jsxs)("div",{className:"ml-auto flex gap-1",children:[o.newCount>0&&(0,r.jsxs)("span",{className:"inline-flex items-center rounded-full bg-amber-500/20 px-1.5 py-0.5 text-[9px] font-semibold text-amber-500",children:["+",o.newCount]}),o.resolvedCount>0&&(0,r.jsxs)("span",{className:"inline-flex items-center rounded-full bg-emerald-500/20 px-1.5 py-0.5 text-[9px] font-semibold text-emerald-500",children:["-",o.resolvedCount]})]})]}),(0,r.jsx)(C.h7,{type:"source",position:S.yX.Bottom,className:"!invisible"})]})});var Q=a(59437),Y=a(14055);let $={postgres:"#336791",redis:"#DC382D",mongodb:"#47A248",mysql:"#4479A1",sqlite:"#003B57"},q={postgres:"PostgreSQL",redis:"Redis",mongodb:"MongoDB",mysql:"MySQL",sqlite:"SQLite"},Z=(0,s.memo)(function(e){let{id:t,data:a,selected:s}=e,{label:l,databaseType:n,tableCount:o,connectedServices:d,framework:i}=a,c=$[n]||"#6b7280",u=(0,C.d)({handleType:"target",handleId:"top"}),m=q[n]||n,x="redis"===n,h=x?Q.A:Y.A;return(0,r.jsxs)("div",{className:"min-w-[180px] rounded-lg bg-card/80 shadow-md transition-all ".concat(s?"ring-1 ring-primary/30":"border"),style:s?void 0:{borderColor:c},children:[(0,r.jsx)(C.h7,{type:"target",position:S.yX.Top,id:"top",className:u.length>0?"!border-none !w-[5px] !h-[5px] !z-10":"!invisible",style:u.length>0?{backgroundColor:c}:void 0}),(0,r.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2",children:[(0,r.jsx)("div",{className:"flex items-center justify-center rounded-md p-1.5",style:{backgroundColor:"".concat(c,"20")},children:(0,r.jsx)(h,{className:"h-4 w-4",style:{color:c}})}),(0,r.jsxs)("div",{className:"flex flex-col",children:[(0,r.jsx)("span",{className:"text-xs font-bold text-foreground",children:l}),(0,r.jsx)("span",{className:"text-[10px] text-muted-foreground",children:m})]})]}),(0,r.jsxs)("div",{className:"border-t border-border px-3 py-1.5 flex items-center justify-between",children:[(0,r.jsx)("span",{className:"text-[10px] text-muted-foreground",children:x?"Cache store":"".concat(o," table").concat(1!==o?"s":"")}),i&&(0,r.jsx)("span",{className:"text-[9px] italic text-muted-foreground",children:i})]}),d.length>0&&(0,r.jsx)("div",{className:"border-t border-border px-3 py-1",children:(0,r.jsxs)("span",{className:"text-[10px] text-muted-foreground",children:[d.length," service",1!==d.length?"s":""," connected"]})}),(0,r.jsx)(C.h7,{type:"source",position:S.yX.Bottom,className:"!invisible"})]})});var J=a(17995),U=a(44942),ee=a(68574);let et={class:J.A,interface:U.A,standalone:ee.A},ea="!bg-muted-foreground !border-none !w-[5px] !h-[5px] !z-10",er="!invisible",es=(0,s.memo)(function(e){let{id:t,data:a,selected:l}=e,{label:n,moduleKind:o,methodCount:d,layerColor:i,isDead:c,isContainer:u,isCollapsed:m,onToggleCollapse:x,violations:h,onExplain:p}=a,f=et[o]||ee.A,{setEdges:g}=(0,C.VH)(),b=(h||[]).flatMap(e=>e.edgeIds||[]),y=(0,s.useCallback)(()=>{if(0===b.length)return;let e=new Set(b);g(t=>t.map(t=>e.has(t.id)?{...t,data:{...t.data,highlighted:!0}}:t))},[g,b]),j=(0,s.useCallback)(()=>{if(0===b.length)return;let e=new Set(b);g(t=>t.map(t=>e.has(t.id)?{...t,data:{...t.data,highlighted:!1}}:t))},[g,b]),N=(0,C.d)({handleType:"target",handleId:"top"}),w=(0,C.d)({handleType:"source",handleId:"bottom"}),k=(0,C.d)({handleType:"source",handleId:"right-src"}),A=(0,C.d)({handleType:"target",handleId:"right-tgt"}),M=h&&h.length>0&&(0,r.jsxs)("div",{className:"group/violation relative shrink-0",onMouseEnter:y,onMouseLeave:j,children:[(0,r.jsx)(v.A,{className:"h-3 w-3 text-red-500"}),(0,r.jsx)("div",{className:"pointer-events-none absolute left-1/2 bottom-full mb-1.5 -translate-x-1/2 z-[9999] hidden group-hover/violation:block",children:(0,r.jsxs)("div",{className:"rounded-md border border-red-500/30 bg-card px-2.5 py-2 shadow-lg w-[220px]",children:[(0,r.jsx)("p",{className:"text-[10px] font-semibold text-red-500 mb-1",children:"Layer Violation"}),h.map((e,t)=>(0,r.jsx)("p",{className:"text-[10px] text-muted-foreground leading-tight",children:e.reason},t))]})})]}),T=c&&(0,r.jsxs)("div",{className:"group/dead relative shrink-0",children:[(0,r.jsx)(v.A,{className:"h-3 w-3 text-amber-500"}),(0,r.jsx)("div",{className:"pointer-events-none absolute left-1/2 bottom-full mb-1.5 -translate-x-1/2 z-[9999] hidden group-hover/dead:block",children:(0,r.jsxs)("div",{className:"rounded-md border border-amber-500/30 bg-card px-2.5 py-2 shadow-lg w-[200px]",children:[(0,r.jsx)("p",{className:"text-[10px] font-semibold text-amber-500 mb-1",children:"Dead Module"}),(0,r.jsxs)("p",{className:"text-[10px] text-muted-foreground leading-tight",children:[(0,r.jsx)("span",{className:"font-medium text-foreground",children:n})," has no incoming or outgoing dependencies — it may be unused or missing imports."]})]})})]});return u?(0,r.jsxs)("div",{className:"rounded-md border bg-muted/10 ".concat((null==h?void 0:h.length)?"border-red-500/60":c?"border-dashed border-amber-500/60":"border-border/50"),style:{width:"100%",height:"100%"},children:[(0,r.jsx)(C.h7,{type:"target",position:S.yX.Top,id:"top",className:N.length>0?ea:er}),(0,r.jsx)(C.h7,{type:"source",position:S.yX.Bottom,id:"bottom",className:w.length>0?ea:er}),(0,r.jsx)(C.h7,{type:"source",position:S.yX.Right,id:"right-src",className:k.length>0?ea:er}),(0,r.jsx)(C.h7,{type:"target",position:S.yX.Right,id:"right-tgt",className:A.length>0?ea:er}),(0,r.jsxs)("div",{className:"flex items-center gap-2 px-2.5 py-1",children:[x&&(0,r.jsx)("button",{className:"flex items-center justify-center text-muted-foreground hover:text-foreground transition-colors nodrag",onClick:e=>{e.stopPropagation(),x(t)},children:m?(0,r.jsx)(B.A,{className:"h-3 w-3"}):(0,r.jsx)(W.A,{className:"h-3 w-3"})}),(0,r.jsx)(f,{className:"h-2.5 w-2.5 text-muted-foreground"}),(0,r.jsx)("span",{className:"text-[10px] font-medium text-muted-foreground truncate",children:n}),M,T,(0,r.jsxs)("span",{className:"ml-auto shrink-0 text-[9px] text-muted-foreground/60",children:[d," ",1===d?"method":"methods"]})]})]}):(0,r.jsxs)("div",{className:"w-full overflow-hidden rounded-md shadow-sm transition-all border ".concat((null==h?void 0:h.length)?"border-red-500/60":c?"border-dashed border-amber-500/60 bg-card/60":"bg-card/80"," ").concat(l?"animate-border-pulse":""),children:[(0,r.jsx)(C.h7,{type:"target",position:S.yX.Top,id:"top",className:N.length>0?ea:er}),(0,r.jsx)(C.h7,{type:"source",position:S.yX.Bottom,id:"bottom",className:w.length>0?ea:er}),(0,r.jsx)(C.h7,{type:"source",position:S.yX.Right,id:"right-src",className:k.length>0?ea:er,style:{top:"75%"}}),(0,r.jsx)(C.h7,{type:"target",position:S.yX.Right,id:"right-tgt",className:A.length>0?ea:er,style:{top:"25%"}}),(0,r.jsxs)("div",{className:"flex items-center gap-2 px-2.5 py-1.5 min-w-0",children:[(0,r.jsx)(f,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),(0,r.jsx)("span",{className:"text-xs font-medium text-foreground truncate",children:n}),M,T,(0,r.jsxs)("span",{className:"ml-auto shrink-0 text-[10px] text-muted-foreground",children:[d," ",1===d?"method":"methods"]}),p&&(0,r.jsx)("button",{className:"flex items-center justify-center rounded-sm border border-border bg-muted p-0.5 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",onClick:e=>{e.stopPropagation(),p(t)},title:"Explain",children:(0,r.jsx)(E.A,{className:"h-2.5 w-2.5"})})]})]})}),el="!bg-muted-foreground !border-none !w-[4px] !h-[4px] !z-10",en="!invisible",eo=(0,s.memo)(function(e){let{id:t,data:a,selected:s}=e,{label:l,isAsync:n,isExported:o,paramCount:d,statementCount:i,maxNestingDepth:c,isDead:u,onExplain:m}=a,x=(0,C.d)({handleType:"target",handleId:"top"}),h=(0,C.d)({handleType:"source",handleId:"bottom"}),p=(0,C.d)({handleType:"source",handleId:"right-src"}),f=(0,C.d)({handleType:"target",handleId:"right-tgt"}),g=u&&(0,r.jsxs)("div",{className:"group/dead relative shrink-0",children:[(0,r.jsx)(v.A,{className:"h-2.5 w-2.5 text-amber-500"}),(0,r.jsx)("div",{className:"pointer-events-none absolute left-1/2 bottom-full mb-1.5 -translate-x-1/2 z-[9999] hidden group-hover/dead:block",children:(0,r.jsxs)("div",{className:"rounded-md border border-amber-500/30 bg-card px-2.5 py-2 shadow-lg w-[200px]",children:[(0,r.jsx)("p",{className:"text-[10px] font-semibold text-amber-500 mb-1",children:"Dead Method"}),(0,r.jsxs)("p",{className:"text-[10px] text-muted-foreground leading-tight",children:[(0,r.jsx)("span",{className:"font-medium text-foreground",children:l})," has no incoming or outgoing calls — it may be unused."]})]})})]});return(0,r.jsxs)("div",{className:"rounded transition-all overflow-hidden ".concat(u?"border border-dashed border-amber-500/60 bg-card/60":"border border-border/50 bg-card/80"," ").concat(s?"bg-card animate-border-pulse":""),style:{width:"100%",maxWidth:"100%"},children:[(0,r.jsx)(C.h7,{type:"target",position:S.yX.Top,id:"top",className:x.length>0?el:en}),(0,r.jsx)(C.h7,{type:"source",position:S.yX.Bottom,id:"bottom",className:h.length>0?el:en}),(0,r.jsx)(C.h7,{type:"source",position:S.yX.Right,id:"right-src",className:p.length>0?el:en,style:{top:"75%"}}),(0,r.jsx)(C.h7,{type:"target",position:S.yX.Right,id:"right-tgt",className:f.length>0?el:en,style:{top:"25%"}}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1 min-w-0",children:[n&&(0,r.jsx)(Q.A,{className:"h-2.5 w-2.5 shrink-0 text-yellow-500"}),(0,r.jsx)("span",{className:"text-[11px] truncate ".concat(o?"font-medium":""," text-foreground"),children:l}),(0,r.jsx)("span",{className:"ml-auto shrink-0"}),g,(null!=i&&i>30||null!=c&&c>4||d>=5)&&!u&&(0,r.jsx)(v.A,{className:"h-2.5 w-2.5 text-amber-500"}),m&&(0,r.jsx)("button",{className:"flex items-center justify-center rounded-sm border border-border bg-muted p-0.5 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",onClick:e=>{e.stopPropagation(),m(t)},title:"Explain",children:(0,r.jsx)(E.A,{className:"h-2.5 w-2.5"})})]})]})}),ed=(0,s.memo)(function(e){var t,a,s;let{id:l,sourceX:n,sourceY:o,targetX:d,targetY:i,sourcePosition:c,targetPosition:u,data:m,selected:x}=e;null==m||m.dependencyCount;let h=null!=(t=null==m?void 0:m.hasHttpCalls)&&t,p=null!=(a=null==m?void 0:m.isViolation)&&a,f=null!=(s=null==m?void 0:m.label)?s:"",g=(null==m?void 0:m.highlighted)===!0,b=(null==m?void 0:m.dimmed)===!0,y=(null==m?void 0:m.hidden)===!0,v=(null==m?void 0:m.edgeStyle)==="step",j=g||x,[N,w,k]=(v?S.oN:S.Fp)({sourceX:n,sourceY:o,targetX:d,targetY:i,sourcePosition:c,targetPosition:u,...v?{borderRadius:8}:{}}),A=p?"#ef4444":j?"var(--primary)":h?"#60a5fa":"var(--muted-foreground)",M="dep-arrow-".concat(l);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("defs",{children:(0,r.jsx)("marker",{id:M,viewBox:"0 0 10 10",refX:"8",refY:"5",markerWidth:"6",markerHeight:"6",orient:"auto",children:(0,r.jsx)("path",{d:"M 0 1 L 8 5 L 0 9 z",fill:A,opacity:y?0:b?.08:.6})})}),(0,r.jsx)("path",{id:l,d:N,fill:"none",stroke:A,strokeWidth:p?j?3:2:j?2:h?1.5:1,strokeDasharray:h?"8 4":"2 3",opacity:y?0:b?.08:j?1:.6,markerEnd:"url(#".concat(M,")"),className:b||y?"":"animate-edge-flow",style:{transition:"opacity 0.2s ease",pointerEvents:y?"none":void 0}}),f&&!b&&!y&&(0,r.jsx)(C.rV,{children:(0,r.jsx)("div",{style:{position:"absolute",transform:"translate(-50%, -50%) translate(".concat(w,"px, ").concat(k,"px)"),pointerEvents:"all"},className:"rounded bg-card px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground shadow-sm border border-border",children:f})})]})}),ei=(0,s.memo)(function(e){var t,a,s;let{id:l,sourceX:n,sourceY:o,targetX:d,targetY:i,sourcePosition:c,targetPosition:u,data:m,selected:x}=e,h=null!=(t=null==m?void 0:m.dependencyCount)?t:0,p=null!=(a=null==m?void 0:m.hasHttpCalls)&&a,f=null!=(s=null==m?void 0:m.isViolation)&&s,g=(null==m?void 0:m.highlighted)===!0,b=(null==m?void 0:m.dimmed)===!0,y=(null==m?void 0:m.hidden)===!0,v=(null==m?void 0:m.edgeStyle)==="step",j=c===u,[N,w,k]=j||v?(0,S.oN)({sourceX:n,sourceY:o,targetX:d,targetY:i,sourcePosition:c,targetPosition:u,borderRadius:8}):(0,S.Fp)({sourceX:n,sourceY:o,targetX:d,targetY:i,sourcePosition:c,targetPosition:u}),A=g||x,M=f?"#ef4444":A?"var(--primary)":p?"#60a5fa":"var(--muted-foreground)",T=y?0:b?.08:A?1:.6,I=j?"":p?"".concat(h," HTTP call").concat(1!==h?"s":""):"".concat(h," import").concat(1!==h?"s":""),E="layer-arrow-".concat(l);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("defs",{children:(0,r.jsx)("marker",{id:E,viewBox:"0 0 10 10",refX:"8",refY:"5",markerWidth:"6",markerHeight:"6",orient:"auto",children:(0,r.jsx)("path",{d:"M 0 1 L 8 5 L 0 9 z",fill:M,opacity:T})})}),(0,r.jsx)("path",{id:l,d:N,fill:"none",stroke:M,strokeWidth:f?A?3:2:A?2:p?1.5:1,strokeDasharray:p?"8 4":"2 3",opacity:T,markerEnd:"url(#".concat(E,")"),className:b||y?"":"animate-edge-flow",style:{transition:"opacity 0.2s ease",pointerEvents:y?"none":void 0}}),I&&!b&&!y&&(0,r.jsx)(C.rV,{children:(0,r.jsx)("div",{style:{position:"absolute",transform:"translate(-50%, -50%) translate(".concat(w,"px, ").concat(k,"px)"),pointerEvents:"all"},className:"rounded bg-card px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground shadow-sm border border-border z-10",children:I})})]})}),ec=(0,s.memo)(function(e){let{id:t,sourceX:a,sourceY:s,targetX:l,targetY:n,sourcePosition:o,targetPosition:d,data:i,selected:c}=e,u=(null==i?void 0:i.dimmed)===!0,m=(null==i?void 0:i.hidden)===!0,x=(null==i?void 0:i.edgeStyle)==="step",[h,p,f]=(x?S.oN:S.Fp)({sourceX:a,sourceY:s,targetX:l,targetY:n,sourcePosition:o,targetPosition:d,...x?{borderRadius:8}:{}}),g=c?"var(--primary)":"#f59e0b",b=m?0:u?.08:1,y="db-arrow-".concat(t);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("defs",{children:(0,r.jsx)("marker",{id:y,viewBox:"0 0 10 10",refX:"8",refY:"5",markerWidth:"6",markerHeight:"6",orient:"auto",children:(0,r.jsx)("path",{d:"M 0 1 L 8 5 L 0 9 z",fill:g,opacity:b})})}),(0,r.jsx)("path",{id:t,d:h,fill:"none",stroke:g,strokeWidth:c?2:1.5,strokeDasharray:"6 3",opacity:b,markerEnd:"url(#".concat(y,")"),className:u||m?"":"animate-edge-flow",style:{transition:"opacity 0.2s ease",pointerEvents:m?"none":void 0}}),!u&&!m&&(0,r.jsx)(C.rV,{children:(0,r.jsx)("div",{style:{position:"absolute",transform:"translate(-50%, -50%) translate(".concat(p,"px, ").concat(f,"px)"),pointerEvents:"all"},className:"rounded bg-card px-1.5 py-0.5 text-[10px] font-medium text-amber-500 shadow-sm border border-amber-500/30 z-10",children:(0,r.jsx)("span",{className:"flex items-center gap-1",children:"DB"})})})]})});var eu=a(31047),em=a(55608),ex=a(43503),eh=a(33159),ep=a(79143),ef=a(32867),eg=a(14846),eb=a(86858);function ey(e){let{className:t,orientation:a="horizontal",...s}=e;return(0,r.jsx)(eb.w,{"data-slot":"separator",orientation:a,className:(0,f.cn)("shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch",t),...s})}function ev(e){let{onAutoLayout:t,panMode:a,onTogglePanMode:s}=e,{zoomIn:l,zoomOut:n,fitView:o}=(0,C.VH)();return(0,r.jsxs)("div",{className:"absolute bottom-4 left-4 z-10 flex flex-col gap-1 rounded-lg border border-border bg-card p-1 shadow-md",children:[(0,r.jsx)(eg.$,{variant:"ghost",size:"icon-xs",onClick:()=>l(),"aria-label":"Zoom in",children:(0,r.jsx)(eu.A,{className:"h-4 w-4"})}),(0,r.jsx)(eg.$,{variant:"ghost",size:"icon-xs",onClick:()=>n(),"aria-label":"Zoom out",children:(0,r.jsx)(em.A,{className:"h-4 w-4"})}),(0,r.jsx)(ey,{}),(0,r.jsx)(eg.$,{variant:"ghost",size:"icon-xs",onClick:()=>o({padding:.3,duration:300}),"aria-label":"Fit view",children:(0,r.jsx)(ex.A,{className:"h-4 w-4"})}),t&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ey,{}),(0,r.jsx)(eg.$,{variant:"ghost",size:"icon-xs",onClick:()=>{t(),setTimeout(()=>o({padding:.3,duration:300}),50)},"aria-label":"Auto layout",children:(0,r.jsx)(eh.A,{className:"h-4 w-4"})})]}),s&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ey,{}),(0,r.jsx)(eg.$,{variant:"ghost",size:"icon-xs",onClick:s,"aria-label":a?"Switch to select mode":"Switch to move mode",title:a?"Switch to select mode":"Switch to move mode",children:a?(0,r.jsx)(ep.A,{className:"h-4 w-4"}):(0,r.jsx)(ef.A,{className:"h-4 w-4"})})]})]})}let ej=[{value:"services",label:"Services"},{value:"modules",label:"Modules"},{value:"methods",label:"Functions"}];function eN(e){let{level:t,onChange:a}=e;return(0,r.jsx)("div",{className:"flex items-center rounded-md border border-border bg-card shadow-sm",children:ej.map((e,s)=>{let{value:l,label:n}=e;return(0,r.jsx)("button",{className:"px-3 py-1.5 text-xs font-medium transition-colors ".concat(t===l?"bg-primary/20 text-primary":"text-muted-foreground hover:text-foreground"," ").concat(0===s?"rounded-l-md":""," ").concat(s===ej.length-1?"rounded-r-md":""),onClick:()=>a(l),children:n},l)})})}var ew=a(41717),ek=a(92552),eC=a(94109),eS=a(41619),eA=a(3897),eM=a(20432),eT=a(34279),eI=a.n(eT);let eE={service:H,layer:G,serviceGroup:O,database:Z,module:es,method:eo},ez={dependency:ed,violation:ed,intraLayer:ei,database:ec};function eL(e){let{initialNodes:t,initialEdges:a,onNodeSelect:l,onExplainNode:o,selectedNodeId:d,repoId:i,branch:c,onRefetch:u,depthLevel:m,onDepthChange:x,focusNodeId:h,focusKey:p,isDiffMode:f,diffResult:g,isDiffChecking:b,hasProgressBar:y,onEnterDiffMode:v,onExitDiffMode:j,highlightedNodeIds:N,savedCollapsedIds:w}=e,[k,S]=(0,s.useState)(!1),[A,M]=(0,s.useState)(()=>"off"!==localStorage.getItem("truecourse:animations")),[T,I]=(0,s.useState)(()=>localStorage.getItem("truecourse:edgeStyle")||"bezier"),[E,z]=(0,s.useState)(()=>"on"===localStorage.getItem("truecourse:focusMode")),[L,F]=(0,s.useState)(!0),D=(0,s.useRef)([]),{fitView:P}=(0,C.VH)(),[R,X,H]=(0,C.ck)(t),[B,W,_]=(0,C.fM)(a),{collapsedIds:V,toggle:G,expandAll:K,collapseAll:O,isBulkAction:Y}=function(e,t,a,r,l){let[n,o]=(0,s.useState)(new Set),d=(0,s.useRef)(!1),i=(0,s.useRef)(null),c=(0,s.useRef)(null);(0,s.useEffect)(()=>{if("services"===t||!e||void 0===l)return;let a="".concat(e,":").concat(t,":").concat(l.join(","));c.current!==a&&(c.current=a,o(new Set(l)))},[e,t,l]);let u=(0,s.useCallback)(function(a){let s=arguments.length>1&&void 0!==arguments[1]&&arguments[1];"services"!==t&&e&&(i.current&&clearTimeout(i.current),s?eM.dc(e,[...a],r,t).catch(()=>{}):i.current=setTimeout(()=>{eM.dc(e,[...a],r,t).catch(()=>{})},300))},[e,r,t]),m=(0,s.useCallback)(e=>{o(t=>{let a=new Set(t);return a.has(e)?a.delete(e):a.add(e),u(a),a})},[u]),x=(0,s.useCallback)(()=>{d.current=!0;let e=new Set;o(e),u(e,!0)},[u]);return{collapsedIds:n,toggle:m,expandAll:x,collapseAll:(0,s.useCallback)(()=>{d.current=!0;let e=new Set;for(let r of a)"layer"===r.type&&r.data.isContainer&&e.add(r.id),"methods"===t&&"module"===r.type&&r.data.isContainer&&e.add(r.id);o(e),u(e,!0)},[a,t,u]),isBulkAction:(0,s.useCallback)(()=>{let e=d.current;return d.current=!1,e},[])}}(i,m,t,c,w),$=(0,s.useCallback)(()=>{setTimeout(()=>{let e={};for(let t of D.current)"layer"!==t.type&&"module"!==t.type&&"method"!==t.type&&(e[t.id]=t.position);Object.keys(e).length>0&&eM.S(i,e,c,m)},600)},[i,c,m]),q=(0,s.useCallback)(e=>{G(e),$()},[G,$]),Z=(0,s.useCallback)(()=>{K(),$()},[K,$]),J=(0,s.useCallback)(()=>{O(),$()},[O,$]);D.current=R;let U=(0,s.useMemo)(()=>{let e=new Map;for(let a of t){let t=a.parentId;t&&"module"===a.type&&e.set(t,(e.get(t)||0)+1)}return e},[t]);(0,s.useMemo)(()=>{let e,r=e=>e===d||e===h;e="services"===m?t.map(e=>({...e,selected:r(e.id),data:{...e.data,onExplain:o}})):t.map(e=>"layer"===e.type&&e.data.isContainer?{...e,selected:r(e.id),data:{...e.data,isCollapsed:V.has(e.id),onToggleCollapse:q,moduleCount:U.get(e.id)||0}}:"module"===e.type&&e.data.isContainer?{...e,selected:r(e.id),data:{...e.data,onExplain:o,isCollapsed:V.has(e.id),onToggleCollapse:q}}:"module"===e.type||"method"===e.type?{...e,selected:r(e.id),data:{...e.data,onExplain:o}}:{...e,selected:r(e.id)});let s=a.map(e=>({...e,data:{...e.data,edgeStyle:T,hidden:E}}));if("services"!==m){let t=function(e,t,a,r){var s,l,n,o,d,i,c,u,m,x,h,p,f,g,b,y,v,j,N,w,k,C,S;let A=arguments.length>4&&void 0!==arguments[4]&&arguments[4];if("services"===r||0===a.size&&!A)return{nodes:e,edges:t};let M=new Map,T=new Map;for(let t of e){M.set(t.id,t);let e=t.parentId;if(e){let a=T.get(e)||[];a.push(t.id),T.set(e,a)}}let I=new Set;for(let e of a)!function e(t){for(let a of T.get(t)||[])I.add(a),e(a)}(e);let E=e.filter(e=>"serviceGroup"===e.type),z=new Map,L=new Map,F=new Set;for(let e of E){let t=(T.get(e.id)||[]).map(e=>M.get(e)).filter(e=>(null==e?void 0:e.type)==="layer").sort((e,t)=>e.position.y-t.position.y),m=0;for(let e of(t.length,t))if(0!==m&&L.set(e.id,m),a.has(e.id)){let t=32-((null==(s=e.style)?void 0:s.height)||(null!=(n=null==(l=e.measured)?void 0:l.height)?n:100));z.set(e.id,t),m+=t,F.add(e.id)}else if("methods"===r){let t=(T.get(e.id)||[]).map(e=>M.get(e)).filter(e=>(null==e?void 0:e.type)==="module").sort((e,t)=>e.position.y-t.position.y),r=[],s=-1/0;for(let e of t)Math.abs(e.position.y-s)>1&&(r.push([]),s=e.position.y),r[r.length-1].push(e);let l=0;for(let e of(t.length,r)){if(0!==l)for(let t of e)L.set(t.id,l);let t=0,r=0;for(let s of e){let e=(null==(o=s.style)?void 0:o.height)||(null!=(i=null==(d=s.measured)?void 0:d.height)?i:80);t=Math.max(t,e),a.has(s.id)?(z.set(s.id,32-e),r=Math.max(r,32)):r=Math.max(r,e)}let s=r-t;0!==s&&(l+=s)}0!==l&&(z.set(e.id,(z.get(e.id)||0)+l),m+=l)}0!==m&&z.set(e.id,m);let x=e.style,h=null!=(c=null==x?void 0:x.width)?c:500,p=0;for(let e of t){let t=z.get("__layerW__".concat(e.id));if(t)p=Math.max(p,t);else if(F.has(e.id))p=Math.max(p,260);else{let t=e.style;p=Math.max(p,null!=(u=null==t?void 0:t.width)?u:h-40)}}let f=p+40;f<h&&(F.add(e.id),z.set("__groupW__".concat(e.id),f))}let D=[];for(let t of e){if(I.has(t.id))continue;let e=t,r=L.get(t.id),s=z.get(t.id),l=a.has(t.id),n=F.has(t.id);if(r||s||l||n){let a=r?{...t.position,y:t.position.y+r}:t.position,o=t.style,d=o?{...o}:{};if(l){if(d={...d,height:32},"module"===t.type){let e=null!=(m=null==o?void 0:o.width)?m:236;d={...d,width:Math.min(e,236)}}}else s&&(null==o?void 0:o.height)&&(d={...d,height:o.height+s});if("serviceGroup"===t.type&&s){let e=null==o?void 0:o.height;e&&(d={...d,height:e+s})}if(n){if("serviceGroup"===t.type){let e=z.get("__groupW__".concat(t.id));d={...d,width:null!=e?e:300}}else if("layer"===t.type){let e=z.get("__layerW__".concat(t.id));d={...d,width:null!=e?e:260}}}e={...t,position:a,...Object.keys(d).length>0?{style:d}:{}}}D.push(e)}if(A){let e=D.filter(e=>"serviceGroup"===e.type||"database"===e.type);if(e.length>1){let a=new Set(e.map(e=>e.id)),r=new(eI()).graphlib.Graph;for(let t of(r.setGraph({rankdir:"TB",nodesep:150,ranksep:200,marginx:60,marginy:60}),r.setDefaultEdgeLabel(()=>({})),e)){let e=t.style;r.setNode(t.id,{width:null!=(f=null!=(p=null==e?void 0:e.width)?p:null==(x=t.measured)?void 0:x.width)?f:280,height:null!=(b=null!=(g=null==e?void 0:e.height)?g:null==(h=t.measured)?void 0:h.height)?b:120})}let s=new Set;for(let e of t){let t=X(e.source),l=X(e.target),n=t&&a.has(t)?t:a.has(e.source)?e.source:null,o=l&&a.has(l)?l:a.has(e.target)?e.target:null;if(n&&o&&n!==o){let e="".concat(n,"::").concat(o);s.has(e)||(s.add(e),r.setEdge(n,o))}}for(let e of(eI().layout(r),D)){if(!a.has(e.id))continue;let t=r.node(e.id);if(!t)continue;let s=e.style,l=null!=(N=null!=(j=null==s?void 0:s.width)?j:null==(y=e.measured)?void 0:y.width)?N:280,n=null!=(k=null!=(w=null==s?void 0:s.height)?w:null==(v=e.measured)?void 0:v.height)?k:120;e.position={x:t.x-l/2,y:t.y-n/2}}}}let P=new Set(D.map(e=>e.id));function R(e){if(P.has(e))return e;let t=M.get(e);if(!t)return null;let a=t.parentId;return a?R(a):null}function X(e){let t=M.get(e);for(;t;){if("serviceGroup"===t.type)return t.id;let e=t.parentId;if(!e)break;t=M.get(e)}return null}let H=new Map;for(let e of t){let t=R(e.source),a=R(e.target);if(!t||!a||t===a)continue;let r="".concat(t,"::").concat(a),s=H.get(r);if(s){let t=(null==(C=s.data)?void 0:C.dependencyCount)||0,a=(null==(S=e.data)?void 0:S.dependencyCount)||0;H.set(r,{...s,data:{...s.data,dependencyCount:t+a}})}else{let s=X(t),l=X(a),n=s&&l&&s===l,o=t!==e.source||a!==e.target,d=o?n?{sourceHandle:"right-src",targetHandle:"right-tgt"}:{sourceHandle:"bottom",targetHandle:"top"}:{};H.set(r,{...e,id:o?"promoted-".concat(r):e.id,source:t,target:a,...d})}}return{nodes:D,edges:[...H.values()]}}(e,s,V,m,!0);e=t.nodes,s=t.edges.map(e=>({...e,data:{...e.data,edgeStyle:T,hidden:E}}))}if(N&&N.size>0){let e=new Set;for(let t of s)(N.has(t.source)||N.has(t.target))&&e.add(t.id);s=s.map(t=>{var a;return{...t,data:{...t.data,dimmed:!e.has(t.id),hidden:E?!e.has(t.id):null==(a=t.data)?void 0:a.hidden}}})}X(e),W(s)},[t,a,X,W,o,d,h,m,T,V,q,U,E,N]);let ee=300*!!A;(0,s.useEffect)(()=>{let e=requestAnimationFrame(()=>{P({padding:.3,duration:ee})});return()=>cancelAnimationFrame(e)},[m,t,P,ee]),(0,s.useEffect)(()=>{let e=requestAnimationFrame(()=>{N&&N.size>0?P({nodes:[...N].map(e=>({id:e})),padding:.3,duration:ee}):P({padding:.3,duration:ee})});return()=>cancelAnimationFrame(e)},[N,P,ee]),(0,s.useEffect)(()=>{if(!Y())return;let e=requestAnimationFrame(()=>{P({padding:.3,duration:ee})});return()=>cancelAnimationFrame(e)},[V,P,ee,Y]),(0,s.useEffect)(()=>{if(!h)return;let e=D.current.find(e=>e.id===h);e&&(X(e=>e.map(e=>({...e,selected:e.id===h}))),setTimeout(()=>{if("serviceGroup"===e.type){let t=D.current.filter(t=>t.parentId===e.id).map(e=>e.id);P({nodes:[e.id,...t].map(e=>({id:e})),padding:.5,duration:ee})}else if("module"===e.type||"method"===e.type){let t=e.parentId;if(t){let e=D.current.filter(e=>e.parentId===t).map(e=>e.id);P({nodes:[{id:t},...e.map(e=>({id:e}))],padding:.3,duration:ee})}else P({nodes:[{id:h}],padding:1,duration:ee})}else P({nodes:[{id:h}],padding:1.5,duration:ee})},50))},[p,h,P,X]);let et=(0,s.useCallback)(()=>{let e={};for(let t of D.current)"layer"!==t.type&&"module"!==t.type&&"method"!==t.type&&(e[t.id]=t.position);0!==Object.keys(e).length&&(S(!0),eM.S(i,e,c,m).finally(()=>S(!1)))},[i,c,m]),ea=(0,s.useCallback)(()=>{eM.aE(i,c,m).then(()=>null==u?void 0:u()).catch(()=>{})},[i,c,m,u]),er=(0,s.useCallback)((e,t)=>{if(null==l||l(t.id),"services"===m)setTimeout(()=>{P({nodes:[{id:t.id}],padding:1.5,duration:ee})},50);else if("serviceGroup"===t.type){let e=D.current.filter(e=>e.parentId===t.id).map(e=>e.id),a=[t.id,...e];setTimeout(()=>{P({nodes:a.map(e=>({id:e})),padding:.5,duration:ee})},50)}else"database"===t.type&&setTimeout(()=>{P({nodes:[{id:t.id}],padding:1.5,duration:ee})},50)},[l,m,P,ee]),es=(0,s.useCallback)((e,t)=>{W(e=>{let a=new Set;for(let r of e)(r.source===t.id||r.target===t.id)&&a.add(r.id);let r=new Set(D.current.filter(e=>e.parentId===t.id).map(e=>e.id));for(let t of e)(r.has(t.source)||r.has(t.target))&&a.add(t.id);return e.map(e=>{var t;return{...e,data:{...e.data,dimmed:!a.has(e.id),hidden:E?!a.has(e.id):null==(t=e.data)?void 0:t.hidden}}})})},[W,E]),el=(0,s.useCallback)(()=>{W(e=>e.map(e=>{var t,a;return{...e,data:{...e.data,dimmed:(null==(t=e.data)||!t.dimmed)&&(null==(a=e.data)?void 0:a.dimmed),hidden:!!E}}}))},[W,E]),en=(0,s.useCallback)(()=>{null==l||l(null),W(e=>e.map(e=>({...e,data:{...e.data,dimmed:!1,hidden:E}}))),P({padding:.3,duration:ee})},[l,m,P,W,E,ee]);return(0,r.jsxs)("div",{className:"h-full w-full".concat(A?"":" no-animations"),children:[(0,r.jsxs)("div",{className:"absolute left-1/2 top-3 z-20 -translate-x-1/2 flex items-center gap-2",children:[(0,r.jsx)(eN,{level:m,onChange:x}),"services"!==m&&(0,r.jsx)("button",{onClick:()=>{V.size>0?Z():J()},className:"flex items-center justify-center rounded-md border border-border bg-card p-1.5 shadow-sm text-muted-foreground hover:text-foreground transition-colors",title:V.size>0?"Expand All":"Collapse All",children:V.size>0?(0,r.jsx)(ex.A,{className:"h-3.5 w-3.5"}):(0,r.jsx)(ew.A,{className:"h-3.5 w-3.5"})}),(0,r.jsx)("button",{onClick:()=>z(e=>{let t=!e;return localStorage.setItem("truecourse:focusMode",t?"on":"off"),t}),className:"flex items-center justify-center rounded-md border border-border bg-card p-1.5 shadow-sm text-muted-foreground hover:text-foreground transition-colors",title:E?"Show all edges":"Show edges on hover only",children:(0,r.jsx)(ek.A,{className:"h-3.5 w-3.5 ".concat(E?"opacity-40":"")})}),(0,r.jsx)("button",{onClick:()=>I(e=>{let t="bezier"===e?"step":"bezier";return localStorage.setItem("truecourse:edgeStyle",t),t}),className:"flex items-center justify-center rounded-md border border-border bg-card p-1.5 shadow-sm text-muted-foreground hover:text-foreground transition-colors",title:"bezier"===T?"Switch to L-shaped edges":"Switch to curved edges",children:"bezier"===T?(0,r.jsx)(eC.A,{className:"h-3.5 w-3.5"}):(0,r.jsx)(eS.A,{className:"h-3.5 w-3.5"})}),(0,r.jsx)("button",{onClick:()=>M(e=>{let t=!e;return localStorage.setItem("truecourse:animations",t?"on":"off"),t}),className:"flex items-center justify-center rounded-md border border-border bg-card p-1.5 shadow-sm text-muted-foreground hover:text-foreground transition-colors",title:A?"Disable animations":"Enable animations",children:A?(0,r.jsx)(Q.A,{className:"h-3.5 w-3.5"}):(0,r.jsx)(eA.A,{className:"h-3.5 w-3.5"})}),k&&(0,r.jsx)("div",{className:"mt-2 rounded-md border border-border bg-card px-3 py-1 text-xs text-muted-foreground shadow-sm text-center",children:"Saving..."})]}),(0,r.jsxs)(C.Gc,{nodes:R,edges:B,onNodesChange:H,onEdgesChange:_,onNodeClick:er,onNodeMouseEnter:es,onNodeMouseLeave:el,onNodeDragStop:et,onPaneClick:en,nodeTypes:eE,edgeTypes:ez,nodesConnectable:!1,nodesDraggable:!L,elementsSelectable:!L,minZoom:.1,maxZoom:2,proOptions:{hideAttribution:!0},children:[(0,r.jsx)(C.VS,{variant:C._5.Dots,gap:20,size:1}),(0,r.jsx)(C.of,{nodeStrokeWidth:3,className:"!bg-card !border-border",maskColor:"rgba(0, 0, 0, 0.1)"}),(0,r.jsx)(ev,{onAutoLayout:ea,panMode:L,onTogglePanMode:()=>F(e=>!e)})]}),f&&!g&&!b&&(0,r.jsxs)("div",{className:"absolute ".concat(y?"bottom-24":"bottom-4"," left-1/2 z-20 -translate-x-1/2 rounded-lg border border-amber-500/30 bg-card px-4 py-2.5 shadow-lg text-xs text-muted-foreground"),children:["Diff mode — click ",(0,r.jsx)("span",{className:"font-medium text-foreground",children:"Analyze"})," to compare pending changes against your last analysis"]}),f&&b&&(0,r.jsxs)("div",{className:"absolute ".concat(y?"bottom-24":"bottom-4"," left-1/2 z-20 -translate-x-1/2 rounded-lg border border-amber-500/30 bg-card px-4 py-2.5 shadow-lg text-xs text-muted-foreground flex items-center gap-2"),children:[(0,r.jsx)(n.A,{className:"h-3 w-3 animate-spin"}),"Scanning pending changes..."]}),f&&g&&!b&&(0,r.jsxs)("div",{className:"absolute ".concat(y?"bottom-24":"bottom-4"," left-1/2 z-20 -translate-x-1/2 rounded-lg border border-amber-500/30 bg-card px-4 py-2 shadow-lg flex items-center gap-3 text-xs"),children:[(0,r.jsxs)("span",{className:"text-amber-500 font-medium",children:["+",g.summary.newCount," new"]}),(0,r.jsxs)("span",{className:"text-emerald-500 font-medium",children:["-",g.summary.resolvedCount," resolved"]}),(0,r.jsxs)("span",{className:"border-l border-border pl-3 text-muted-foreground",children:[g.changedFiles.length," file",1!==g.changedFiles.length?"s":""," changed"]})]})]})}function eF(e){return(0,r.jsx)(C.Ln,{children:(0,r.jsx)(eL,{...e})})}var eD=a(1122),eP=a(70893),eR=a(88974),eX=a(1879),eH=a(77033),eB=a(70113);let eW=(0,a(40268).F)("group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!",{variants:{variant:{default:"bg-primary text-primary-foreground [a]:hover:bg-primary/80",secondary:"bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80",destructive:"bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20",outline:"border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground",ghost:"hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50",link:"text-primary underline-offset-4 hover:underline"}},defaultVariants:{variant:"default"}});function e_(e){let{className:t,variant:a="default",render:r,...s}=e;return(0,eB.C)({defaultTagName:"span",props:(0,eH.v6)({className:(0,f.cn)(eW({variant:a}),t)},s),render:r,state:{slot:"badge",variant:a}})}let eV={info:"border-l-blue-500",low:"border-l-amber-500",medium:"border-l-orange-500",high:"border-l-red-500",critical:"border-l-red-600"},eG={info:"bg-blue-500/10 text-blue-600 dark:text-blue-400",low:"bg-amber-500/10 text-amber-600 dark:text-amber-400",medium:"bg-orange-500/10 text-orange-600 dark:text-orange-400",high:"bg-red-500/10 text-red-600 dark:text-red-400",critical:"bg-red-600/10 text-red-700 dark:text-red-500"};function eK(e){let{insight:t,onLocateNode:a,isResolved:l,diffStatus:n}=e,[o,d]=(0,s.useState)(!1),[i,c]=(0,s.useState)(!1),u=async()=>{t.fixPrompt&&(await navigator.clipboard.writeText(t.fixPrompt),d(!0),setTimeout(()=>d(!1),2e3))},m=t.targetMethodId||t.targetModuleId||t.targetDatabaseId||t.targetServiceId,x=t.targetMethodName||t.targetModuleName||t.targetDatabaseName||t.targetServiceName,h=t.targetMethodId?"methods":t.targetModuleId?"modules":void 0;return(0,r.jsx)(z,{className:"border-l-4 rounded-sm p-3 ".concat(eV[t.severity]||"border-l-gray-500"),children:(0,r.jsxs)(L,{className:"p-0",children:[(0,r.jsxs)("div",{className:"mb-1.5 flex items-center gap-2",children:[n&&(0,r.jsx)(e_,{className:"rounded-sm px-2 py-0.5 text-[10px] font-semibold uppercase ".concat("new"===n?"bg-amber-500/10 text-amber-600 dark:text-amber-400 border border-amber-500/30":"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border border-emerald-500/30"),children:n}),(0,r.jsx)(e_,{className:"rounded-sm px-2 py-0.5 text-[10px] font-semibold uppercase ".concat(eG[t.severity]||""),children:t.type}),(0,r.jsx)(e_,{className:"rounded-sm px-1.5 py-0.5 text-[10px] font-medium ".concat(eG[t.severity]||""),children:t.severity}),a&&m&&(0,r.jsxs)(eg.$,{variant:"outline",size:"xs",onClick:()=>a(m,h),className:"ml-auto text-[10px] text-muted-foreground hover:text-foreground",title:"Locate ".concat(x||"target"," in graph"),children:[(0,r.jsx)(eD.A,{className:"h-3 w-3"}),"Locate"]})]}),(0,r.jsx)("h4",{className:"text-sm font-bold ".concat(l?"line-through opacity-60 text-muted-foreground":"text-foreground"),children:t.title}),(0,r.jsx)("p",{className:"mt-1 text-xs leading-relaxed text-muted-foreground",children:t.content}),(t.targetServiceName||t.targetDatabaseName)&&(0,r.jsxs)("p",{className:"mt-2 text-[10px] text-muted-foreground",children:["Target:"," ",(0,r.jsx)("span",{className:"font-medium text-foreground",children:t.targetServiceName||t.targetDatabaseName}),t.targetModuleName&&(0,r.jsxs)(r.Fragment,{children:[" / ",(0,r.jsx)("span",{className:"font-medium text-foreground",children:t.targetModuleName})]}),t.targetMethodName&&(0,r.jsxs)(r.Fragment,{children:[" / ",(0,r.jsx)("span",{className:"font-medium text-foreground",children:t.targetMethodName})]})]}),t.fixPrompt&&!l&&(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsxs)(eg.$,{variant:"outline",size:"xs",onClick:()=>c(e=>!e),className:"text-[10px] text-muted-foreground hover:text-foreground",children:[i?(0,r.jsx)(eP.A,{className:"h-3 w-3"}):(0,r.jsx)(W.A,{className:"h-3 w-3"}),"Fix Prompt"]}),(0,r.jsx)(eg.$,{variant:"outline",size:"xs",onClick:u,className:"text-[10px] text-muted-foreground hover:text-foreground",children:o?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eR.A,{className:"h-3 w-3 text-emerald-500"}),"Copied!"]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eX.A,{className:"h-3 w-3"}),"Copy Fix"]})})]}),i&&(0,r.jsx)("pre",{className:"mt-1.5 rounded-md bg-muted px-2.5 py-2 text-[10px] leading-relaxed text-muted-foreground whitespace-pre-wrap break-words",children:t.fixPrompt})]})]})})}var eO=a(34992),eQ=a(79817),eY=a(88526),e$=a(87891),eq=a(76978),eZ=a(94565),eJ=a(95990),eU=a(95694);let e0={tableNode:function(e){var t,a,s;let{data:l,selected:n}=e,o=null!=(s=null==(t=l.insights)?void 0:t.length)?s:0,d=null==(a=l.insights)?void 0:a.some(e=>"high"===e.severity||"critical"===e.severity);return(0,r.jsxs)("div",{className:"relative rounded-lg border bg-card shadow-md min-w-[180px] max-w-[260px] ".concat(n?"border-primary ring-1 ring-primary/30":o>0?"border-amber-500/50":"border-border"),children:[l.hasTargetEdge&&(0,r.jsx)(C.h7,{type:"target",position:S.yX.Left,className:"!w-2 !h-2 !bg-primary !border-background"}),l.hasSourceEdge&&(0,r.jsx)(C.h7,{type:"source",position:S.yX.Right,className:"!w-2 !h-2 !bg-primary !border-background"}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5 border-b border-border bg-amber-500/10 px-3 py-1.5 rounded-t-lg",children:[(0,r.jsx)("span",{className:"text-xs font-semibold text-foreground flex-1",children:l.label}),o>0&&(0,r.jsxs)("div",{className:"group relative flex items-center gap-1",children:[(0,r.jsx)(v.A,{className:"h-3 w-3 ".concat(d?"text-red-500":"text-amber-500")}),(0,r.jsx)("span",{className:"text-[9px] font-medium ".concat(d?"text-red-500":"text-amber-500"),children:o}),(0,r.jsx)("div",{className:"pointer-events-none absolute left-full top-1/2 -translate-y-1/2 ml-2 z-50 hidden group-hover:block",children:(0,r.jsx)("div",{className:"rounded-md border border-border bg-card px-2.5 py-2 shadow-lg w-[260px]",children:l.insights.map((e,t)=>(0,r.jsxs)("div",{className:"text-[10px] text-muted-foreground leading-tight py-0.5",children:[(0,r.jsxs)("span",{className:"font-medium ".concat("critical"===e.severity||"high"===e.severity?"text-red-500":"medium"===e.severity?"text-amber-500":"text-muted-foreground"),children:["[",e.severity,"]"]})," ",e.title]},t))})})]})]}),(0,r.jsx)("div",{className:"px-1 py-1",children:l.columns.map(e=>(0,r.jsxs)("div",{className:"flex items-center gap-1 px-2 py-0.5 text-[10px] rounded hover:bg-muted/50",children:[e.isPrimaryKey&&(0,r.jsx)(eZ.A,{className:"h-2.5 w-2.5 text-amber-500 flex-shrink-0"}),e.isForeignKey&&!e.isPrimaryKey&&(0,r.jsx)(eJ.A,{className:"h-2.5 w-2.5 text-blue-500 flex-shrink-0"}),!e.isPrimaryKey&&!e.isForeignKey&&(0,r.jsx)("span",{className:"w-2.5 flex-shrink-0"}),(0,r.jsx)("span",{className:"font-medium text-foreground",children:e.name}),(0,r.jsx)("span",{className:"ml-auto text-muted-foreground",children:e.type}),e.isNullable&&(0,r.jsx)("span",{className:"text-muted-foreground/60",children:"?"})]},e.name))})]})}},e1={crowsfoot:function(e){var t,a;let{id:s,sourceX:l,sourceY:n,targetX:o,targetY:d,sourcePosition:i,targetPosition:c,data:u}=e,[m,x,h]=(0,S.Fp)({sourceX:l,sourceY:n,targetX:o,targetY:d,sourcePosition:i,targetPosition:c}),p=null!=(t=null==u?void 0:u.sourceCardinality)?t:"one",f=null!=(a=null==u?void 0:u.targetCardinality)?a:"one",g="cf-source-".concat(s),b="cf-target-".concat(s);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("defs",{children:["one"===p&&(0,r.jsx)("marker",{id:g,viewBox:"0 0 12 12",refX:"0",refY:"6",markerWidth:"10",markerHeight:"10",orient:"auto-start-reverse",children:(0,r.jsx)("line",{x1:"6",y1:"2",x2:"6",y2:"10",className:"stroke-muted-foreground",strokeWidth:"1.5",fill:"none"})}),"many"===p&&(0,r.jsxs)("marker",{id:g,viewBox:"0 0 16 16",refX:"0",refY:"8",markerWidth:"12",markerHeight:"12",orient:"auto-start-reverse",children:[(0,r.jsx)("line",{x1:"10",y1:"2",x2:"2",y2:"8",className:"stroke-muted-foreground",strokeWidth:"1.5",fill:"none"}),(0,r.jsx)("line",{x1:"2",y1:"8",x2:"10",y2:"14",className:"stroke-muted-foreground",strokeWidth:"1.5",fill:"none"}),(0,r.jsx)("line",{x1:"2",y1:"8",x2:"10",y2:"8",className:"stroke-muted-foreground",strokeWidth:"1.5",fill:"none"})]}),"one"===f&&(0,r.jsx)("marker",{id:b,viewBox:"0 0 12 12",refX:"12",refY:"6",markerWidth:"10",markerHeight:"10",orient:"auto-start-reverse",children:(0,r.jsx)("line",{x1:"6",y1:"2",x2:"6",y2:"10",className:"stroke-muted-foreground",strokeWidth:"1.5",fill:"none"})}),"many"===f&&(0,r.jsxs)("marker",{id:b,viewBox:"0 0 16 16",refX:"16",refY:"8",markerWidth:"12",markerHeight:"12",orient:"auto-start-reverse",children:[(0,r.jsx)("line",{x1:"6",y1:"2",x2:"14",y2:"8",className:"stroke-muted-foreground",strokeWidth:"1.5",fill:"none"}),(0,r.jsx)("line",{x1:"14",y1:"8",x2:"6",y2:"14",className:"stroke-muted-foreground",strokeWidth:"1.5",fill:"none"}),(0,r.jsx)("line",{x1:"14",y1:"8",x2:"6",y2:"8",className:"stroke-muted-foreground",strokeWidth:"1.5",fill:"none"})]})]}),(0,r.jsx)("path",{id:s,d:m,fill:"none",className:"stroke-muted-foreground",strokeWidth:1.5,opacity:.6,markerStart:"url(#".concat(g,")"),markerEnd:"url(#".concat(b,")")}),(null==u?void 0:u.label)&&(0,r.jsx)(C.rV,{children:(0,r.jsx)("div",{style:{position:"absolute",transform:"translate(-50%, -50%) translate(".concat(x,"px, ").concat(h,"px)"),pointerEvents:"none"},className:"rounded bg-card px-1.5 py-0.5 text-[9px] text-muted-foreground border border-border",children:u.label})})]})}};function e5(e,t,a){let r=new(eI()).graphlib.Graph;for(let t of(r.setGraph({rankdir:"LR",ranksep:100,nodesep:50}),r.setDefaultEdgeLabel(()=>({})),e)){let e=a.get(t.id)||100;r.setNode(t.id,{width:200,height:e})}for(let e of t)r.setEdge(e.source,e.target);return eI().layout(r),e.map(e=>{let t=r.node(e.id),s=a.get(e.id)||100;return{...e,position:{x:t.x-100,y:t.y-s/2}}})}function e2(e){let{insights:t,isFullscreen:a}=e,[l,n]=(0,s.useState)(!1),{zoom:o}=(0,C.kW)(),d=t.some(e=>"high"===e.severity||"critical"===e.severity);return(0,r.jsxs)("div",{className:"absolute left-3 top-3 z-10 origin-top-left",style:a?{transform:"scale(".concat(o,")")}:void 0,children:[(0,r.jsxs)("button",{onClick:()=>n(!l),className:"flex items-center gap-1.5 rounded-md border px-2.5 py-1.5 text-[11px] font-medium shadow-sm transition-colors ".concat(d?"border-red-500/30 bg-red-500/10 text-red-500":"border-amber-500/30 bg-amber-500/10 text-amber-500"),title:a?void 0:"".concat(t.length," database issue").concat(1!==t.length?"s":""),children:[(0,r.jsx)(v.A,{className:"h-3 w-3"}),a&&(0,r.jsxs)(r.Fragment,{children:[t.length," database issue",1!==t.length?"s":"",l?(0,r.jsx)(eP.A,{className:"h-3 w-3"}):(0,r.jsx)(W.A,{className:"h-3 w-3"})]}),!a&&(0,r.jsx)("span",{className:"text-[9px]",children:t.length})]}),l&&a&&(0,r.jsx)("div",{className:"mt-1 rounded-md border border-border bg-card px-2.5 py-2 shadow-lg w-[280px]",children:t.map((e,t)=>(0,r.jsxs)("div",{className:"text-[10px] text-muted-foreground leading-tight py-0.5",children:[(0,r.jsxs)("span",{className:"font-medium ".concat("critical"===e.severity||"high"===e.severity?"text-red-500":"medium"===e.severity?"text-amber-500":"text-muted-foreground"),children:["[",e.severity,"]"]})," ",e.title]},t))})]})}function e3(e){let{schema:t,insights:a=[],isFullscreen:l}=e,{initialNodes:n,edges:o}=(0,s.useMemo)(()=>{let e=new Set(t.relations.map(e=>e.sourceTable)),r=new Set(t.relations.map(e=>e.targetTable)),s=new Map;for(let e of a)if(e.targetTable){let t=s.get(e.targetTable)||[];t.push({title:e.title,severity:e.severity}),s.set(e.targetTable,t)}let l=t.tables.map(t=>({id:t.name,type:"tableNode",data:{label:t.name,columns:t.columns,primaryKey:t.primaryKey,hasSourceEdge:e.has(t.name),hasTargetEdge:r.has(t.name),insights:s.get(t.name)},position:{x:0,y:0},sourcePosition:S.yX.Right,targetPosition:S.yX.Left})),n=t.relations.map((e,t)=>{let a=function(e){switch(e){case"one-to-one":return{source:"one",target:"one",label:"1:1"};case"one-to-many":return{source:"many",target:"one",label:"1:N"};case"many-to-many":return{source:"many",target:"many",label:"N:N"};default:return{source:"one",target:"one",label:""}}}(e.relationType);return{id:"rel-".concat(t),source:e.sourceTable,target:e.targetTable,type:"crowsfoot",data:{sourceCardinality:a.source,targetCardinality:a.target,label:e.foreignKeyColumn}}}),o=new Map;for(let e of t.tables)o.set(e.name,28+18*e.columns.length+8);return{initialNodes:e5(l,n,o),edges:n}},[t,a]),d=(0,s.useMemo)(()=>a.filter(e=>e.targetDatabaseId&&!e.targetTable).map(e=>({title:e.title,severity:e.severity})),[a]),[i,c,u]=(0,C.ck)(n),m=(0,s.useCallback)(()=>{let e=new Map;for(let a of t.tables)e.set(a.name,28+18*a.columns.length+8);c(t=>e5(t,o,e))},[t,o,c]);return(0,r.jsxs)("div",{className:"h-full w-full relative",children:[d.length>0&&(0,r.jsx)(e2,{insights:d,isFullscreen:l}),(0,r.jsx)(C.Gc,{nodes:i,onNodesChange:u,edges:o,nodeTypes:e0,edgeTypes:e1,fitView:!0,fitViewOptions:{padding:.3},minZoom:.2,maxZoom:3,nodesDraggable:!0,nodesConnectable:!1,elementsSelectable:!0,proOptions:{hideAttribution:!0},children:(0,r.jsx)(C.VS,{gap:16,size:1})}),(0,r.jsx)(ev,{onAutoLayout:m})]})}function e4(e){let{schema:t,insights:a,isFullscreen:s}=e;return(0,r.jsx)(C.Ln,{children:(0,r.jsx)(e3,{schema:t,insights:a,isFullscreen:s})})}function e8(e){let{repoId:t,databaseId:a,insights:l=[]}=e,[n,o]=(0,s.useState)(null),[d,i]=(0,s.useState)(!0),[c,u]=(0,s.useState)(null),[m,x]=(0,s.useState)("diagram"),[h,p]=(0,s.useState)(!1);return((0,s.useEffect)(()=>{if(!h)return;let e=e=>{"Escape"===e.key&&p(!1)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[h]),(0,s.useEffect)(()=>{i(!0),eM.rr(t,a).then(o).catch(()=>o(null)).finally(()=>i(!1))},[t,a]),d)?(0,r.jsx)("div",{className:"flex items-center justify-center p-8 text-sm text-muted-foreground",children:"Loading schema..."}):n&&0!==n.tables.length?(0,r.jsxs)("div",{className:"flex flex-col h-full",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 border-b border-border px-4 py-3",children:[(0,r.jsx)(Y.A,{className:"h-4 w-4 text-primary"}),(0,r.jsx)("span",{className:"text-sm font-semibold text-foreground",children:n.name}),(0,r.jsxs)("span",{className:"text-xs text-muted-foreground",children:[n.tables.length," table",1!==n.tables.length?"s":""]}),(0,r.jsxs)("div",{className:"ml-auto flex items-center gap-1.5",children:[(0,r.jsxs)("div",{className:"flex items-center gap-0.5 rounded-md border border-border p-0.5",children:[(0,r.jsx)("button",{onClick:()=>x("diagram"),className:"rounded px-1.5 py-0.5 text-[10px] transition-colors ".concat("diagram"===m?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"),title:"ER Diagram",children:(0,r.jsx)(eQ.A,{className:"h-3 w-3"})}),(0,r.jsx)("button",{onClick:()=>x("list"),className:"rounded px-1.5 py-0.5 text-[10px] transition-colors ".concat("list"===m?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"),title:"Table List",children:(0,r.jsx)(eY.A,{className:"h-3 w-3"})})]}),(0,r.jsx)("button",{onClick:()=>{x("diagram"),p(!0)},className:"rounded p-1 text-muted-foreground hover:text-foreground hover:bg-accent transition-colors",title:"Expand to fullscreen",children:(0,r.jsx)(e$.A,{className:"h-3.5 w-3.5"})})]})]}),"diagram"===m&&(0,r.jsx)("div",{className:"flex-1 min-h-0",children:(0,r.jsx)(e4,{schema:n,insights:l,isFullscreen:!1})}),"list"===m&&(0,r.jsx)("div",{className:"flex-1 overflow-y-auto",children:n.tables.map(e=>{let t=c===e.name,a=n.relations.filter(t=>t.sourceTable===e.name||t.targetTable===e.name);return(0,r.jsxs)("div",{className:"border-b border-border",children:[(0,r.jsxs)("button",{className:"flex w-full items-center gap-2 px-4 py-2 text-left hover:bg-accent/50 transition-colors",onClick:()=>u(t?null:e.name),children:[t?(0,r.jsx)(W.A,{className:"h-3 w-3 text-muted-foreground"}):(0,r.jsx)(B.A,{className:"h-3 w-3 text-muted-foreground"}),(0,r.jsx)(eq.A,{className:"h-3.5 w-3.5 text-amber-500"}),(0,r.jsx)("span",{className:"text-xs font-medium text-foreground",children:e.name}),(0,r.jsxs)("span",{className:"text-[10px] text-muted-foreground ml-auto",children:[e.columns.length," col",1!==e.columns.length?"s":""]})]}),t&&(0,r.jsxs)("div",{className:"px-4 pb-3",children:[(0,r.jsx)("div",{className:"rounded-md border border-border overflow-hidden",children:(0,r.jsxs)("table",{className:"w-full text-[11px]",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{className:"bg-muted/50",children:[(0,r.jsx)("th",{className:"text-left px-2 py-1 font-medium text-muted-foreground",children:"Column"}),(0,r.jsx)("th",{className:"text-left px-2 py-1 font-medium text-muted-foreground",children:"Type"}),(0,r.jsx)("th",{className:"text-center px-2 py-1 font-medium text-muted-foreground w-8"})]})}),(0,r.jsx)("tbody",{children:e.columns.map(e=>(0,r.jsxs)("tr",{className:"border-t border-border",children:[(0,r.jsxs)("td",{className:"px-2 py-1 text-foreground flex items-center gap-1",children:[e.isPrimaryKey&&(0,r.jsx)(eZ.A,{className:"h-2.5 w-2.5 text-amber-500 flex-shrink-0"}),e.isForeignKey&&(0,r.jsx)(eJ.A,{className:"h-2.5 w-2.5 text-blue-500 flex-shrink-0"}),(0,r.jsx)("span",{children:e.name})]}),(0,r.jsx)("td",{className:"px-2 py-1 text-muted-foreground",children:e.type}),(0,r.jsx)("td",{className:"px-2 py-1 text-center text-muted-foreground",children:e.isNullable&&(0,r.jsx)("span",{className:"text-[9px]",children:"?"})})]},e.name))})]})}),a.length>0&&(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsx)("div",{className:"text-[10px] font-medium text-muted-foreground mb-1",children:"Relations"}),a.map((e,t)=>(0,r.jsxs)("div",{className:"flex items-center gap-1 text-[10px] text-muted-foreground",children:[(0,r.jsx)(eJ.A,{className:"h-2.5 w-2.5 text-blue-500"}),(0,r.jsxs)("span",{children:[e.sourceTable,".",e.foreignKeyColumn," → ",e.targetTable]}),(0,r.jsxs)("span",{className:"text-[9px] italic",children:["(",e.relationType,")"]})]},t))]})]})]},e.name)})}),h&&(0,eO.createPortal)((0,r.jsxs)("div",{className:"fixed inset-0 z-50 flex flex-col bg-background",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 border-b border-border px-6 py-3",children:[(0,r.jsx)(Y.A,{className:"h-4 w-4 text-primary"}),(0,r.jsx)("span",{className:"text-sm font-semibold text-foreground",children:n.name}),(0,r.jsxs)("span",{className:"text-xs text-muted-foreground",children:[n.tables.length," table",1!==n.tables.length?"s":"",n.relations.length>0&&" \xb7 ".concat(n.relations.length," relation").concat(1!==n.relations.length?"s":"")]}),(0,r.jsx)("button",{onClick:()=>p(!1),className:"ml-auto rounded p-1.5 text-muted-foreground hover:text-foreground hover:bg-accent transition-colors",title:"Close (Esc)",children:(0,r.jsx)(eU.A,{className:"h-4 w-4"})})]}),(0,r.jsx)("div",{className:"flex-1 min-h-0",children:(0,r.jsx)(e4,{schema:n,insights:l,isFullscreen:!0})})]}),document.body)]}):(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center p-8 text-sm text-muted-foreground gap-2",children:[(0,r.jsx)(Y.A,{className:"h-8 w-8 opacity-50"}),(0,r.jsx)("span",{children:"No schema detected"})]})}function e6(e){let{insights:t,isLoading:a,repoId:l,selectedService:o,selectedServiceName:d,selectedDatabaseId:c,isDiffMode:u,diffResult:m,onLocateNode:x,resolveNodeIdByName:h,selectedPath:p,nodeFilePathMap:f}=e,[g,b]=(0,s.useState)(264),y=(0,s.useRef)(!1),j=(0,s.useCallback)(e=>{e.preventDefault(),y.current=!0;let t=e.clientY,a=e=>{y.current&&b(Math.min(500,Math.max(120,g+(t-e.clientY))))},r=()=>{y.current=!1,document.removeEventListener("mousemove",a),document.removeEventListener("mouseup",r)};document.addEventListener("mousemove",a),document.addEventListener("mouseup",r)},[g]),N=(0,s.useMemo)(()=>{if(!u||!m)return null;let e=[];for(let t of m.newInsights){let a=t.targetServiceName&&h?h(t.targetServiceName,"service"):null,r=t.targetModuleName&&h?h(t.targetModuleName,"module"):null,s=t.targetMethodName&&h?h(t.targetMethodName,"method"):null;e.push({insight:{id:"new-".concat(e.length),type:t.type,title:t.title,content:t.content,severity:t.severity,targetServiceId:a,targetServiceName:t.targetServiceName,targetModuleId:r,targetModuleName:t.targetModuleName,targetMethodId:s,targetMethodName:t.targetMethodName,fixPrompt:t.fixPrompt,createdAt:new Date().toISOString()},diffStatus:"new"})}for(let t of m.resolvedInsights||[])e.push({insight:t,diffStatus:"resolved"});let t={critical:0,high:1,medium:2,low:3,info:4},a={service:0,module:1,function:2,database:3};return e.sort((e,r)=>{var s,l,n,o;let d=("new"!==e.diffStatus)-("new"!==r.diffStatus);if(0!==d)return d;let i=(null!=(s=t[e.insight.severity])?s:5)-(null!=(l=t[r.insight.severity])?l:5);if(0!==i)return i;let c=(null!=(n=a[e.insight.type])?n:9)-(null!=(o=a[r.insight.type])?o:9);return 0!==c?c:new Date(r.insight.createdAt).getTime()-new Date(e.insight.createdAt).getTime()}),e},[u,m,h]),w=(0,s.useMemo)(()=>p&&f?t.filter(e=>{let t=e.targetMethodId||e.targetModuleId||e.targetServiceId;if(!t)return!0;let a=f.get(t);if(!a||a.includes(p))return!0;let r=a.split("/");for(let e=r.length-1;e>=1;e--){let t=r.slice(e).join("/");if(p.startsWith(t+"/")||p===t)return!0}return!1}):t,[t,p,f]);return(0,r.jsx)("div",{className:"flex h-full flex-col overflow-hidden",children:(0,r.jsxs)("div",{className:"min-h-0 flex-1 flex flex-col overflow-hidden",children:[(0,r.jsx)("div",{className:"overflow-y-auto p-3 flex-1",children:u&&null!==N?(0,r.jsxs)(r.Fragment,{children:[(null==m?void 0:m.isStale)&&(0,r.jsxs)("div",{className:"mb-3 flex items-center gap-2 rounded-md border border-amber-500/30 bg-amber-500/5 px-3 py-2 text-xs text-amber-600 dark:text-amber-400",children:[(0,r.jsx)(i.A,{className:"h-3.5 w-3.5 shrink-0"}),"Baseline analysis has changed. Click Analyze to refresh."]}),0===N.length?(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[(0,r.jsx)(v.A,{className:"mb-3 h-8 w-8 text-muted-foreground"}),(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:"No diff results yet. Click Analyze to compare your working tree against the baseline."})]}):(0,r.jsx)("div",{className:"space-y-3",children:N.map(e=>{let{insight:t,diffStatus:a}=e;return(0,r.jsx)(eK,{insight:t,onLocateNode:x,isResolved:"resolved"===a,diffStatus:a},t.id)})})]}):(0,r.jsxs)(r.Fragment,{children:[o&&(0,r.jsxs)("div",{className:"mb-3 rounded-md bg-muted px-3 py-1.5 text-xs text-muted-foreground",children:["Filtered by:"," ",(0,r.jsx)("span",{className:"font-medium text-foreground",children:d||o})]}),a?(0,r.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,r.jsx)(n.A,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):0===w.length?(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[(0,r.jsx)(v.A,{className:"mb-3 h-8 w-8 text-muted-foreground"}),(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:p?"No violations in this path":o?"No violations for this service":"No violations yet. Run an analysis to detect violations."})]}):(0,r.jsx)("div",{className:"space-y-3",children:w.map(e=>(0,r.jsx)(eK,{insight:e,onLocateNode:x},e.id))})]})}),c&&!u&&(0,r.jsxs)("div",{className:"relative flex-shrink-0 border-t border-border",style:{height:g},children:[(0,r.jsx)("div",{className:"absolute inset-x-0 top-0 z-10 h-1 cursor-row-resize hover:bg-primary/30 active:bg-primary/50",onMouseDown:j}),(0,r.jsx)(e8,{repoId:l,databaseId:c,insights:t})]})]})})}let e9={critical:"bg-red-500/20 text-red-400 border-red-500/30",high:"bg-orange-500/20 text-orange-400 border-orange-500/30",medium:"bg-yellow-500/20 text-yellow-400 border-yellow-500/30",low:"bg-blue-500/20 text-blue-400 border-blue-500/30",info:"bg-gray-500/20 text-gray-400 border-gray-500/30"},e7={deterministic:"bg-emerald-500/20 text-emerald-400 border-emerald-500/30",llm:"bg-violet-500/20 text-violet-400 border-violet-500/30"},te={service:"bg-sky-500/20 text-sky-400 border-sky-500/30",module:"bg-teal-500/20 text-teal-400 border-teal-500/30",database:"bg-amber-500/20 text-amber-400 border-amber-500/30"},tt={service:"Service",module:"Module",database:"Database"};function ta(){let[e,t]=(0,s.useState)([]),[a,l]=(0,s.useState)(!0),[o,d]=(0,s.useState)("all");(0,s.useEffect)(()=>{(0,eM.Q4)().then(t).catch(()=>t([])).finally(()=>l(!1))},[]);let i={critical:0,high:1,medium:2,low:3,info:4},c={service:0,module:1,database:2},u={deterministic:0,llm:1},m=("all"===o?e:e.filter(e=>e.category===o)).slice().sort((e,t)=>{var a,r,s,l,n,o;return(null!=(a=i[e.severity])?a:5)-(null!=(r=i[t.severity])?r:5)||(null!=(s=c[e.category])?s:9)-(null!=(l=c[t.category])?l:9)||(null!=(n=u[e.type])?n:9)-(null!=(o=u[t.type])?o:9)}),x=[{value:"all",label:"All",icon:(0,r.jsx)(j.A,{className:"h-3.5 w-3.5"})},{value:"service",label:"Service",icon:(0,r.jsx)(ek.A,{className:"h-3.5 w-3.5"})},{value:"module",label:"Module",icon:(0,r.jsx)(J.A,{className:"h-3.5 w-3.5"})},{value:"database",label:"Database",icon:(0,r.jsx)(Y.A,{className:"h-3.5 w-3.5"})}];return a?(0,r.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,r.jsx)(n.A,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):(0,r.jsxs)("div",{className:"h-full overflow-y-auto p-3",children:[(0,r.jsx)("div",{className:"mb-3 flex gap-1.5 overflow-x-auto scrollbar-thin",children:x.map(e=>(0,r.jsxs)("button",{onClick:()=>d(e.value),className:"flex shrink-0 items-center gap-1.5 rounded-md px-2.5 py-1.5 text-xs font-medium transition-colors ".concat(o===e.value?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground"),children:[e.icon,e.label]},e.value))}),0===m.length?(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[(0,r.jsx)(j.A,{className:"mb-3 h-8 w-8 text-muted-foreground"}),(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:"No rules found"})]}):(0,r.jsx)("div",{className:"space-y-2",children:m.map(e=>(0,r.jsxs)("div",{className:"rounded-lg border border-border bg-card p-3",children:[(0,r.jsxs)("div",{className:"mb-1.5 flex items-start justify-between gap-2",children:[(0,r.jsx)("h4",{className:"text-sm font-medium text-foreground",children:e.name}),(0,r.jsx)("div",{className:"flex shrink-0 gap-1.5",children:(0,r.jsx)("span",{className:"rounded border px-1.5 py-0.5 text-[10px] font-medium uppercase ".concat(e9[e.severity]||""),children:e.severity})})]}),(0,r.jsx)("p",{className:"text-xs leading-relaxed text-muted-foreground",children:e.description}),(0,r.jsxs)("div",{className:"mt-2 flex items-center gap-1.5",children:[(0,r.jsx)("span",{className:"rounded border px-1.5 py-0.5 text-[10px] font-medium ".concat(te[e.category]||""),children:tt[e.category]||e.category}),(0,r.jsx)("span",{className:"rounded border px-1.5 py-0.5 text-[10px] font-medium ".concat(e7[e.type]||""),children:"deterministic"===e.type?"Deterministic":"LLM"})]})]},e.key))})]})}var tr=a(25042);function ts(e){let{repoId:t,selectedPath:a,onSelectPath:l}=e,[o,d]=(0,s.useState)([]),[i,c]=(0,s.useState)(!0);(0,s.useEffect)(()=>{c(!0),eM.oc(t).then(e=>d(e.files)).catch(()=>{}).finally(()=>c(!1))},[t]);let u=(0,s.useMemo)(()=>(function(e){let t={name:"",path:"",isFile:!1,children:[]};for(let a of e){if(!a)continue;let e=a.split("/"),r=t;for(let t=0;t<e.length;t++){let a=e[t],s=t===e.length-1,l=e.slice(0,t+1).join("/"),n=r.children.find(e=>e.name===a);n||(n={name:a,path:l,isFile:s,children:[]},r.children.push(n)),r=n}}return function e(t){for(let a of(t.children.sort((e,t)=>!e.isFile&&t.isFile?-1:e.isFile&&!t.isFile?1:e.name.localeCompare(t.name)),t.children))e(a)}(t),function e(t){for(let a=0;a<t.children.length;a++){let r=t.children[a];for(;!r.isFile&&1===r.children.length&&!r.children[0].isFile;){let e=r.children[0];r={name:"".concat(r.name,"/").concat(e.name),path:e.path,isFile:e.isFile,children:e.children},t.children[a]=r}e(r)}}(t),t})(o),[o]);return i?(0,r.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,r.jsx)(n.A,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):0===u.children.length?(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-center px-4",children:[(0,r.jsx)(tr.A,{className:"mb-3 h-8 w-8 text-muted-foreground"}),(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:"No files found in repository."})]}):(0,r.jsxs)("div",{className:"flex h-full flex-col overflow-hidden",children:[a&&(0,r.jsxs)("div",{className:"flex items-center gap-2 border-b border-border px-3 py-1.5 text-xs text-muted-foreground",children:[(0,r.jsxs)("span",{className:"truncate flex-1",children:["Filter: ",(0,r.jsx)("span",{className:"font-medium text-foreground",children:a})]}),(0,r.jsx)("button",{onClick:()=>l(null),className:"shrink-0 rounded p-0.5 hover:bg-muted",children:(0,r.jsx)(eU.A,{className:"h-3 w-3"})})]}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto py-1",children:u.children.map(e=>(0,r.jsx)(tl,{node:e,depth:0,selectedPath:a,onSelectPath:l},e.path))})]})}function tl(e){let{node:t,depth:a,selectedPath:l,onSelectPath:n}=e,[o,d]=(0,s.useState)(a<1),i=l===t.path,c=!!l&&l.startsWith(t.path+"/"),u=(0,s.useCallback)(()=>{t.isFile?n(i?null:t.path):(i?n(null):n(t.path),d(!0))},[t.path,t.isFile,i,n]),m=(0,s.useCallback)(e=>{e.stopPropagation(),d(e=>!e)},[]);return(0,r.jsxs)("div",{children:[(0,r.jsxs)("button",{onClick:u,className:"flex w-full items-center gap-1.5 px-2 py-1 text-[13px] transition-colors ".concat(i?"bg-accent text-accent-foreground":c?"bg-accent/50 text-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground"),style:{paddingLeft:"".concat(8+12*a,"px")},children:[t.isFile?(0,r.jsx)("span",{className:"w-4"}):(0,r.jsx)("span",{onClick:m,className:"shrink-0 flex items-center justify-center w-4 h-4",children:o?(0,r.jsx)(W.A,{className:"h-3 w-3"}):(0,r.jsx)(B.A,{className:"h-3 w-3"})}),(0,r.jsx)("span",{className:"truncate",children:t.name})]}),!t.isFile&&o&&(0,r.jsx)("div",{children:t.children.map(e=>(0,r.jsx)(tl,{node:e,depth:a+1,selectedPath:l,onSelectPath:n},e.path))})]})}var tn=a(97367),to=a(91160),td=a(60726),ti=a(43418),tc=a(8713);function tu(e){let{message:t}=e;if("system"===t.role)return(0,r.jsxs)("div",{className:"flex items-center justify-center gap-1.5 py-2",children:[(0,r.jsx)(ti.A,{className:"h-3 w-3 text-muted-foreground"}),(0,r.jsx)("span",{className:"text-[11px] text-muted-foreground",children:t.content})]});let a="user"===t.role;return a||t.content?a?(0,r.jsx)("div",{className:"flex justify-end",children:(0,r.jsx)("div",{className:"max-w-[85%] rounded-2xl bg-primary px-3 py-2 text-sm text-primary-foreground",children:(0,r.jsx)("p",{className:"whitespace-pre-wrap break-words leading-relaxed",children:t.content})})}):(0,r.jsx)("div",{className:"text-sm text-foreground",children:(0,r.jsx)("div",{className:"prose prose-sm dark:prose-invert max-w-none break-words leading-relaxed [&_p]:my-1 [&_ul]:my-1 [&_ol]:my-1 [&_li]:my-0 [&_h1]:text-base [&_h2]:text-sm [&_h3]:text-sm [&_pre]:text-xs [&_code]:text-xs",children:(0,r.jsx)(tc.oz,{children:t.content})})}):null}var tm=a(74611);function tx(e){let{onSend:t,disabled:a}=e,[l,n]=(0,s.useState)(""),o=(0,s.useRef)(null),d=()=>{l.trim()&&!a&&(t(l.trim()),n(""),o.current&&(o.current.style.height="auto"))};return(0,r.jsx)("div",{className:"border-t border-border p-3",children:(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)("textarea",{ref:o,value:l,onChange:e=>n(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),d())},onInput:()=>{let e=o.current;e&&(e.style.height="auto",e.style.height="".concat(Math.min(e.scrollHeight,150),"px"))},placeholder:"Ask about architecture...",rows:2,disabled:a,className:"w-full resize-none rounded-lg border border-border bg-muted px-3 py-2.5 pr-10 text-sm text-foreground placeholder:text-muted-foreground focus:border-primary focus:outline-none disabled:opacity-50",style:{maxHeight:150}}),(0,r.jsx)("button",{onClick:d,disabled:a||!l.trim(),"aria-label":"Send message",className:"absolute bottom-2.5 right-2.5 flex h-6 w-6 items-center justify-center rounded-full bg-primary text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-30 disabled:cursor-not-allowed",children:(0,r.jsx)(tm.A,{className:"h-3.5 w-3.5"})})]})})}function th(e){let{repoId:t,explainRequest:a,onExplainHandled:l}=e,{messages:o,isStreaming:d,isLoadingHistory:i,conversationList:c,sendMessage:u,explainNode:m,newConversation:x,fetchConversations:h,loadConversation:p}=function(e){let[t,a]=(0,s.useState)([]),[r,l]=(0,s.useState)(!1),[n,o]=(0,s.useState)([]),[d,i]=(0,s.useState)(!1),c=(0,s.useRef)(null),u=(0,s.useRef)(void 0),m=(0,s.useRef)(0),x=()=>(m.current+=1,"msg-".concat(m.current)),h=(0,s.useCallback)(t=>{if(!t.trim()||r)return;let s={id:x(),role:"user",content:t,timestamp:new Date},n=x(),o={id:n,role:"assistant",content:"",timestamp:new Date};a(e=>[...e,s,o]),l(!0),c.current=(0,eM.Vl)(e,t,e=>{a(t=>t.map(t=>t.id===n?{...t,content:t.content+e}:t))},e=>{e&&(u.current=e),l(!1)},e=>{a(t=>t.map(t=>t.id===n?{...t,content:"Error: ".concat(e.message)}:t)),l(!1)},{conversationId:u.current})},[e,r]),p=(0,s.useCallback)((e,t,a)=>{h('Explain the "'.concat(t,'" ').concat("methodNode"===a?"function":"moduleNode"===a?"module":"layerNode"===a?"layer":"service"," — what does it do, how does it fit into the architecture, and are there any concerns?"))},[h]),f=(0,s.useCallback)(()=>{c.current&&c.current.abort(),a([]),l(!1),u.current=void 0},[]),g=(0,s.useCallback)(async()=>{try{let t=await (0,eM.lS)(e);o(t)}catch(e){}},[e]),b=(0,s.useCallback)(async t=>{if(!r){i(!0);try{let r=await (0,eM.kP)(e,t);u.current=t,a(r.messages.map(e=>({id:e.id,role:e.role,content:e.content,timestamp:new Date(e.createdAt)})))}catch(e){}finally{i(!1)}}},[e,r]);return{messages:t,isStreaming:r,isLoadingHistory:d,conversationList:n,sendMessage:h,explainNode:p,newConversation:f,fetchConversations:g,loadConversation:b}}(t),f=(0,s.useRef)(null),g=(0,s.useRef)(null),[b,y]=(0,s.useState)(!1),v=o[o.length-1];return((0,s.useEffect)(()=>{g.current&&(g.current.scrollTop=g.current.scrollHeight)},[null==v?void 0:v.content,o.length]),(0,s.useEffect)(()=>{a&&a.nodeId!==f.current&&(f.current=a.nodeId,m(a.nodeId,a.nodeName,a.nodeType),null==l||l())},[a,m,l]),b)?(0,r.jsxs)("div",{className:"flex h-full flex-col overflow-hidden",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 border-b border-border px-3 py-2",children:[(0,r.jsx)("button",{onClick:()=>y(!1),className:"flex items-center justify-center rounded-md p-1 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground","aria-label":"Back to chat",children:(0,r.jsx)(tn.A,{className:"h-4 w-4"})}),(0,r.jsx)("span",{className:"text-sm font-medium text-foreground",children:"Conversations"})]}),(0,r.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto",children:0===c.length?(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[(0,r.jsx)(to.A,{className:"mb-3 h-8 w-8 text-muted-foreground"}),(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:"No conversations yet"})]}):(0,r.jsx)("div",{className:"divide-y divide-border",children:c.map(e=>(0,r.jsxs)("button",{onClick:()=>{p(e.id),y(!1)},className:"w-full px-3 py-2.5 text-left transition-colors hover:bg-accent",children:[(0,r.jsx)("p",{className:"truncate text-sm text-foreground",children:e.preview}),(0,r.jsx)("p",{className:"mt-0.5 text-[10px] text-muted-foreground",children:new Date(e.updatedAt).toLocaleDateString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})})]},e.id))})})]}):(0,r.jsxs)("div",{className:"flex h-full flex-col overflow-hidden",children:[(0,r.jsxs)("div",{className:"flex items-center justify-end gap-1 border-b border-border px-2 py-1.5",children:[(0,r.jsx)("button",{onClick:()=>{x(),y(!1)},className:"flex items-center justify-center rounded-md p-1 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground","aria-label":"New conversation",title:"New conversation",children:(0,r.jsx)(td.A,{className:"h-4 w-4"})}),(0,r.jsx)("button",{onClick:()=>{h(),y(!0)},className:"flex items-center justify-center rounded-md p-1 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground","aria-label":"Conversation history",title:"Conversation history",children:(0,r.jsx)(to.A,{className:"h-4 w-4"})})]}),(0,r.jsx)("div",{ref:g,className:"min-h-0 flex-1 overflow-y-auto",children:(0,r.jsxs)("div",{className:"space-y-3 p-3",children:[i?(0,r.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,r.jsx)(n.A,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):0===o.length?(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[(0,r.jsx)(E.A,{className:"mb-3 h-8 w-8 text-muted-foreground"}),(0,r.jsx)("p",{className:"text-sm font-medium text-foreground",children:"Architecture Chat"}),(0,r.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"Ask questions about your codebase architecture"})]}):o.map(e=>(0,r.jsx)(tu,{message:e},e.id)),d&&(()=>{let e=[...o].reverse().find(e=>"assistant"===e.role),t=!!(null==e?void 0:e.content);return(0,r.jsx)("div",{className:"flex items-center gap-2 py-1 text-xs text-muted-foreground",children:t?(0,r.jsxs)("span",{className:"inline-flex gap-0.5",children:[(0,r.jsx)("span",{className:"h-1 w-1 animate-bounce rounded-full bg-muted-foreground [animation-delay:0ms]"}),(0,r.jsx)("span",{className:"h-1 w-1 animate-bounce rounded-full bg-muted-foreground [animation-delay:150ms]"}),(0,r.jsx)("span",{className:"h-1 w-1 animate-bounce rounded-full bg-muted-foreground [animation-delay:300ms]"})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.A,{className:"h-3 w-3 animate-spin"}),"Thinking..."]})})})()]})}),(0,r.jsx)(tx,{onSend:e=>{u(e)},disabled:d})]})}var tp=a(6540),tf=a(98682),tg=a(72054);let tb={api:"Routes & Controllers",service:"Business Logic",data:"Database & ORM",external:"HTTP Clients"};function ty(e){let{depthLevel:t,serviceTypes:a,frameworks:l,layerTypes:n,hasDatabases:o,onFilterChange:d}=e,[i,c]=(0,s.useState)(!1),[u,m]=(0,s.useState)({excludedTypes:new Set,excludedFrameworks:new Set,excludedLayers:new Set,searchQuery:"",showDatabases:!0}),x=e=>{m(e),d(e)},h=(e,t)=>{let a=new Set(e);return a.has(t)?a.delete(t):a.add(t),a},p=u.excludedTypes.size>0||u.excludedFrameworks.size>0||u.excludedLayers.size>0||u.searchQuery.length>0||!u.showDatabases,f=u.excludedTypes.size+u.excludedFrameworks.size+u.excludedLayers.size+ +!!u.searchQuery+ +!u.showDatabases,g="services"!==t&&n.length>0;return(0,r.jsxs)("div",{className:"absolute left-4 top-3 z-10",children:[(0,r.jsxs)("button",{onClick:()=>c(!i),className:"flex items-center gap-1.5 rounded-md border border-border bg-card px-3 py-1.5 text-xs font-medium shadow-sm text-muted-foreground hover:text-foreground transition-colors",children:[(0,r.jsx)(tp.A,{className:"h-3.5 w-3.5"}),"Filters",p&&(0,r.jsx)("span",{className:"ml-1 flex h-4 w-4 items-center justify-center rounded-full bg-primary text-[10px] text-primary-foreground",children:f})]}),i&&(0,r.jsxs)("div",{className:"mt-1.5 w-56 rounded-md border border-border bg-card p-2.5 shadow-lg max-h-[calc(100vh-120px)] overflow-y-auto",children:[(0,r.jsxs)("div",{className:"relative mb-2",children:[(0,r.jsx)(tf.A,{className:"absolute left-2 top-1/2 h-3 w-3 -translate-y-1/2 text-muted-foreground"}),(0,r.jsx)(tg.p,{type:"text",value:u.searchQuery,onChange:e=>x({...u,searchQuery:e.target.value}),placeholder:"services"===t?"Search services...":"methods"===t?"Search functions...":"modules"===t?"Search modules...":"Search...",className:"h-7 pl-7 text-[11px]"})]}),(a.length>0||o)&&(0,r.jsxs)("div",{className:"mb-2",children:[(0,r.jsx)("h4",{className:"mb-1 text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:"Type"}),(0,r.jsxs)("div",{className:"space-y-0.5",children:[a.map(e=>(0,r.jsxs)("label",{className:"flex cursor-pointer items-center gap-1.5 rounded px-1 py-0.5 text-[11px] text-foreground hover:bg-muted/50",children:[(0,r.jsx)("input",{type:"checkbox",checked:!u.excludedTypes.has(e),onChange:()=>x({...u,excludedTypes:h(u.excludedTypes,e)}),className:"rounded border-border accent-primary h-3 w-3"}),e]},e)),o&&(0,r.jsxs)("label",{className:"flex cursor-pointer items-center gap-1.5 rounded px-1 py-0.5 text-[11px] text-foreground hover:bg-muted/50",children:[(0,r.jsx)("input",{type:"checkbox",checked:u.showDatabases,onChange:()=>x({...u,showDatabases:!u.showDatabases}),className:"rounded border-border accent-primary h-3 w-3"}),"database"]})]})]}),l.length>0&&(0,r.jsxs)("div",{className:"mb-2",children:[(0,r.jsx)("h4",{className:"mb-1 text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:"Framework"}),(0,r.jsx)("div",{className:"space-y-0.5",children:l.map(e=>(0,r.jsxs)("label",{className:"flex cursor-pointer items-center gap-1.5 rounded px-1 py-0.5 text-[11px] text-foreground hover:bg-muted/50",children:[(0,r.jsx)("input",{type:"checkbox",checked:!u.excludedFrameworks.has(e),onChange:()=>x({...u,excludedFrameworks:h(u.excludedFrameworks,e)}),className:"rounded border-border accent-primary h-3 w-3"}),e]},e))})]}),g&&(0,r.jsxs)("div",{children:[(0,r.jsx)("h4",{className:"mb-1 text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:"Layer"}),(0,r.jsx)("div",{className:"space-y-0.5",children:n.map(e=>(0,r.jsxs)("label",{className:"flex cursor-pointer items-center gap-1.5 rounded px-1 py-0.5 text-[11px] text-foreground hover:bg-muted/50",children:[(0,r.jsx)("input",{type:"checkbox",checked:!u.excludedLayers.has(e),onChange:()=>x({...u,excludedLayers:h(u.excludedLayers,e)}),className:"rounded border-border accent-primary h-3 w-3"}),tb[e]||e]},e))})]})]})]})}var tv=a(41010);let tj=(0,a(2011).T)()||window.location.origin,tN=null;function tw(){return tN||(tN=(0,tv.io)(tj,{autoConnect:!1,reconnection:!0,reconnectionAttempts:10,reconnectionDelay:1e3,reconnectionDelayMax:5e3,transports:["websocket","polling"]})),tN}function tk(e){let t=tw();t.connected&&t.emit("joinRepo",e)}var tC=a(25500),tS=a(4274),tA=a(81393),tM=a(19663),tT=a(23714);function tI(e){let{className:t,children:a,value:s,...l}=e;return(0,r.jsxs)(tS.w,{value:s,"data-slot":"progress",className:(0,f.cn)("flex flex-wrap gap-3",t),...l,children:[a,(0,r.jsx)(tE,{children:(0,r.jsx)(tz,{})})]})}function tE(e){let{className:t,...a}=e;return(0,r.jsx)(tA.X,{className:(0,f.cn)("relative flex h-1 w-full items-center overflow-x-hidden rounded-full bg-muted",t),"data-slot":"progress-track",...a})}function tz(e){let{className:t,...a}=e;return(0,r.jsx)(tM.Z,{"data-slot":"progress-indicator",className:(0,f.cn)("h-full bg-primary transition-all",t),...a})}function tL(e){let{className:t,...a}=e;return(0,r.jsx)(tT.u,{className:(0,f.cn)("text-sm font-medium",t),"data-slot":"progress-label",...a})}function tF(){var e,t,a,u,m;let x=(0,l.useParams)(),h=(0,l.useSearchParams)(),p=(0,l.useRouter)(),f=Array.isArray(x.slug)?x.slug[0]:"",[g,b]=(0,s.useState)(null),[v,j]=(0,s.useState)(null),N={services:"services",modules:"modules",methods:"functions"},w=(null==h?void 0:h.get("mode"))||"",[C,S]=(0,s.useState)({services:"services",modules:"modules",functions:"methods"}[w]||"services"),A=(0,s.useCallback)(e=>{S(e);let t=new URL(window.location.href);"services"===e?t.searchParams.delete("mode"):t.searchParams.set("mode",N[e]),p.replace(t.pathname+t.search,{scroll:!1})},[p]),[M,T]=(0,s.useState)([]),[I,E]=(0,s.useState)([]),[z,L]=(0,s.useState)(!1),[F,D]=(0,s.useState)(null),[P,R]=(0,s.useState)(!1),[X,H]=(0,s.useState)("violations"),[B,W]=(0,s.useState)(null),[_,V]=(0,s.useState)(!1),[G,K]=(0,s.useState)(null),O=null==g?void 0:g.defaultBranch,{nodes:Q,edges:Y,savedCollapsedIds:$,isLoading:q,error:Z,refetch:J}=function(e,t){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"services",[r,l]=(0,s.useState)([]),[n,o]=(0,s.useState)([]),[d,i]=(0,s.useState)(void 0),[c,u]=(0,s.useState)(!0),[m,x]=(0,s.useState)(null),h=(0,s.useCallback)(async()=>{if(e){u(!0),x(null);try{let r=await eM.XT(e,{branch:t,level:a});if("modules"===a||"methods"===a){let e=r.nodes.map(e=>{var t,a,r,s;return"databaseNode"===e.type?{id:e.id,type:"database",position:e.position,data:{label:e.data.label,databaseType:e.data.databaseType||e.data.serviceType,tableCount:null!=(a=null!=(t=e.data.tableCount)?t:e.data.fileCount)?a:0,connectedServices:e.data.connectedServices||[],framework:e.data.framework}}:"methodNode"===e.type?{id:e.id,type:"method",position:e.position,parentId:e.parentId,extent:e.extent,style:e.style,data:{...e.data,filePath:e.data.rootPath||""}}:"moduleNode"===e.type?{id:e.id,type:"module",position:e.position,parentId:e.parentId,extent:e.extent,style:e.style,data:{label:e.data.label,moduleKind:e.data.moduleKind||e.data.serviceType||"standalone",methodCount:null!=(s=null!=(r=e.data.methodCount)?r:e.data.fileCount)?s:0,propertyCount:e.data.propertyCount,importCount:e.data.importCount,exportCount:e.data.exportCount,superClass:e.data.superClass,layerColor:e.data.layerColor||"#6b7280",isDead:e.data.isDead||!1,isContainer:e.data.isContainer||!1,violations:e.data.violations,filePath:e.data.rootPath||""}}:"layerNode"===e.type?{id:e.id,type:"layer",position:e.position,parentId:e.parentId,extent:e.extent,style:e.style,data:{label:e.data.label,layer:e.data.label,fileCount:e.data.fileCount||0,layerColor:e.data.layerColor||"#6b7280",fileNames:e.data.fileNames||[],filePaths:e.data.filePaths||[],isContainer:e.data.isContainer||!1,violations:e.data.violations||[]}}:{id:e.id,type:"serviceGroup",position:e.position,style:e.style,data:{label:e.data.label,description:e.data.description,serviceType:e.data.serviceType||"unknown",framework:e.data.framework,fileCount:e.data.fileCount||0,layers:e.data.layers||[],rootPath:e.data.rootPath||"",violations:e.data.violations||[]}}}),t=r.edges.map(e=>({id:e.id,source:e.source,target:e.target,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle,type:"database"===e.data.dependencyType?"database":"intraLayer",data:{label:"",dependencyCount:e.data.dependencyCount||0,hasHttpCalls:"http"===e.data.dependencyType,isViolation:e.data.isViolation||!1,violationReason:e.data.violationReason}}));l(e),o(t),i(r.collapsedIds)}else{let e=r.nodes.map(e=>{var t,a,r;return"databaseNode"===e.type?{id:e.id,type:"database",position:e.position,data:{label:e.data.label,databaseType:e.data.databaseType||e.data.serviceType,tableCount:null!=(a=null!=(t=e.data.tableCount)?t:e.data.fileCount)?a:0,connectedServices:e.data.connectedServices||[],framework:e.data.framework}}:{id:e.id,type:"service",position:e.position,data:{label:e.data.label,description:e.data.description,serviceInfo:{type:e.data.serviceType||"unknown",framework:e.data.framework||null,fileCount:e.data.fileCount||0,layers:(e.data.layers||[]).map(e=>({layer:e,confidence:1,evidence:[]})),rootPath:null!=(r=e.data.rootPath)?r:""},insightCount:0,hasHighSeverity:!1}}}),t=r.edges.map(e=>({id:e.id,source:e.source,target:e.target,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle,type:"database"===e.data.dependencyType?"database":"dependency",data:{label:"http"===e.data.dependencyType?"".concat(e.data.dependencyCount||0," HTTP call").concat(1!==(e.data.dependencyCount||0)?"s":""):"database"===e.data.dependencyType?"":"".concat(e.data.dependencyCount||0," import").concat(1!==(e.data.dependencyCount||0)?"s":""),dependencyCount:e.data.dependencyCount||0,hasHttpCalls:"http"===e.data.dependencyType}}));l(e),o(t),i(r.collapsedIds)}}catch(e){x(e instanceof Error?e.message:"Failed to fetch graph")}finally{u(!1)}}},[e,t,a]);return(0,s.useEffect)(()=>{h()},[h]),{nodes:r,edges:n,savedCollapsedIds:d,isLoading:c,error:m,refetch:h,setNodes:l,setEdges:o}}(f,O,C),{isConnected:U,analysisProgress:ee,onEvent:et}=function(e){let[t,a]=(0,s.useState)(!1),[r,l]=(0,s.useState)(null),n=(0,s.useRef)(new Map);return(0,s.useEffect)(()=>{let t=function(){let e=tw();return e.connected||e.connect(),e}();function r(){a(!0),e&&tk(e)}function s(){a(!1)}function o(e){e.percent>=100?l(null):l(e)}function d(e){var t;l(null),null==(t=n.current.get("analysis:complete"))||t.forEach(t=>t(e))}return t.on("connect",r),t.on("disconnect",s),t.on("analysis:progress",o),t.on("analysis:complete",d),t.on("files:changed",e=>{var t;null==(t=n.current.get("files:changed"))||t.forEach(t=>t(e))}),t.on("violations:ready",e=>{var t;l(null),null==(t=n.current.get("violations:ready"))||t.forEach(t=>t(e))}),t.connected&&e&&tk(e),()=>{e&&function(e){let t=tw();t.connected&&t.emit("leaveRepo",e)}(e),t.off("connect",r),t.off("disconnect",s),t.off("analysis:progress",o),t.off("analysis:complete",d),(null==tN?void 0:tN.connected)&&tN.disconnect()}},[e]),{isConnected:t,analysisProgress:r,onEvent:(0,s.useCallback)((e,t)=>{let a=n.current.get(e)||[];return a.push(t),n.current.set(e,a),()=>{let a=n.current.get(e)||[];n.current.set(e,a.filter(e=>e!==t))}},[])}}(f),{insights:ea,isLoading:er,refetch:es}=function(e,t){let[a,r]=(0,s.useState)([]),[l,n]=(0,s.useState)(!0),[o,d]=(0,s.useState)(null),i=(0,s.useCallback)(async()=>{if(e){n(!0),d(null);try{let t=await eM.BZ(e);r(t)}catch(e){d(e instanceof Error?e.message:"Failed to fetch insights")}finally{n(!1)}}},[e]);return(0,s.useEffect)(()=>{i()},[i]),{insights:(0,s.useMemo)(()=>{let e={critical:0,high:1,medium:2,low:3,info:4},r={service:0,module:1,function:2,database:3},s=[...a].sort((t,a)=>{var s,l,n,o;let d=(null!=(s=e[t.severity])?s:5)-(null!=(l=e[a.severity])?l:5);if(0!==d)return d;let i=(null!=(n=r[t.type])?n:9)-(null!=(o=r[a.type])?o:9);return 0!==i?i:new Date(a.createdAt).getTime()-new Date(t.createdAt).getTime()});return t?s.filter(e=>e.targetServiceId===t||e.targetDatabaseId===t||e.targetModuleId===t||e.targetMethodId===t):s},[a,t]),allInsights:a,isLoading:l,error:o,refetch:i}}(f,null!=v?v:void 0),{diffResult:el,isChecking:en,error:eo,run:ed,load:ei}=function(e){let[t,a]=(0,s.useState)(null),[r,l]=(0,s.useState)(!1),[n,o]=(0,s.useState)(null),d=(0,s.useCallback)(async()=>{l(!0),o(null);try{let t=await eM.xJ(e);a(t)}catch(e){e instanceof eM.hD&&409===e.status?o("Switch to Normal mode and run an analysis first"):o(e instanceof Error?e.message:"Diff check failed"),a(null)}finally{l(!1)}},[e]);return{diffResult:t,isChecking:r,error:n,run:d,load:(0,s.useCallback)(async()=>{o(null);try{let t=await eM.aI(e);a(t)}catch(e){o(e instanceof Error?e.message:"Failed to load diff check"),a(null)}},[e]),clear:(0,s.useCallback)(()=>{a(null),o(null)},[])}}(f);(0,s.useEffect)(()=>{f&&eM.L8(f).then(b).catch(()=>{})},[f]),(0,s.useEffect)(()=>{T(Q),E(Y)},[Q,Y]),(0,s.useEffect)(()=>{!ee||z||_||L(!0)},[ee,z,_]),(0,s.useEffect)(()=>et("analysis:complete",()=>{L(!1),J()}),[et,J]),(0,s.useEffect)(()=>et("violations:ready",()=>{L(!1),es()}),[et,es]);let ec=async()=>{if(_)ed();else try{L(!0),await eM.LY(f)}catch(e){L(!1)}},[eu,em]=(0,s.useState)(null),ex=(0,s.useCallback)(e=>{if(j(e),e){let t=Q.find(t=>t.id===e);if(t&&"database"===t.type){em(e),H("violations");return}}em(null)},[Q]),eh=(0,s.useCallback)(e=>{var t;let a=Q.find(t=>t.id===e),r=(null==a||null==(t=a.data)?void 0:t.label)||e;j(e),R(!0),D({nodeId:e,nodeName:r,nodeType:null==a?void 0:a.type})},[Q]),ep=(0,s.useCallback)(e=>{let t=new Set;if("services"===C)for(let a of Q){let r=a.data,s=r.serviceInfo;s&&e.excludedTypes.size>0&&e.excludedTypes.has(s.type)&&t.add(a.id),(null==s?void 0:s.framework)&&e.excludedFrameworks.size>0&&e.excludedFrameworks.has(s.framework)&&t.add(a.id),e.searchQuery&&((r.label||"").toLowerCase().includes(e.searchQuery.toLowerCase())||t.add(a.id)),e.showDatabases||"database"!==a.type||t.add(a.id)}else{let a=new Map;for(let e of Q){let t=e.parentId;t&&a.set(e.id,t)}if(!e.showDatabases)for(let e of Q)"database"===e.type&&t.add(e.id);for(let a of Q){if("serviceGroup"!==a.type)continue;let r=a.data;e.excludedTypes.size>0&&e.excludedTypes.has(r.serviceType)&&t.add(a.id),r.framework&&e.excludedFrameworks.size>0&&e.excludedFrameworks.has(r.framework)&&t.add(a.id)}if(e.excludedLayers.size>0)for(let a of Q){if("layer"!==a.type)continue;let r=a.data;e.excludedLayers.has(r.label)&&t.add(a.id)}let r=!0;for(;r;)for(let e of(r=!1,Q)){if(t.has(e.id))continue;let s=a.get(e.id);s&&t.has(s)&&(t.add(e.id),r=!0)}if(e.searchQuery){let r=e.searchQuery.toLowerCase(),s=new Set;for(let e of Q)if(!t.has(e.id)&&(e.data.label||"").toLowerCase().includes(r)){s.add(e.id);let t=a.get(e.id);for(;t;)s.add(t),t=a.get(t)}let l=!0;for(;l;)for(let e of(l=!1,Q)){if(s.has(e.id))continue;let t=a.get(e.id);t&&s.has(t)&&(s.add(e.id),l=!0)}for(let e of Q)"database"!==e.type&&(s.has(e.id)||t.add(e.id))}for(let e of Q)!("serviceGroup"!==e.type||t.has(e.id))&&(Q.some(r=>a.get(r.id)===e.id&&!t.has(r.id))||t.add(e.id))}let a=Q.filter(e=>!t.has(e.id)),r=new Set(a.map(e=>e.id)),s=Y.filter(e=>r.has(e.source)&&r.has(e.target));T(a),E(s)},[Q,Y,C]),ef=(0,s.useCallback)(()=>{V(!0),ei()},[ei]),eb=(0,s.useCallback)(()=>{V(!1)},[]),ey=(0,s.useMemo)(()=>{if(!_||!el)return M;let e=new Set(el.affectedNodeIds.services),t=new Set(el.affectedNodeIds.layers),a=new Set(el.affectedNodeIds.modules),r=new Set(el.affectedNodeIds.methods),s=new Map,l=new Map,n=new Map,o=new Map,d=new Map,i=new Map;for(let e of el.newInsights){if(e.targetServiceName&&s.set(e.targetServiceName,(s.get(e.targetServiceName)||0)+1),e.targetModuleName&&e.targetServiceName){let t="".concat(e.targetServiceName,"::").concat(e.targetModuleName);n.set(t,(n.get(t)||0)+1)}if(e.targetMethodName&&e.targetModuleName&&e.targetServiceName){let t="".concat(e.targetServiceName,"::").concat(e.targetModuleName,"::").concat(e.targetMethodName);o.set(t,(o.get(t)||0)+1)}}for(let e of el.resolvedInsights||[]){if(e.targetServiceName&&l.set(e.targetServiceName,(l.get(e.targetServiceName)||0)+1),e.targetModuleName&&e.targetServiceName){let t="".concat(e.targetServiceName,"::").concat(e.targetModuleName);d.set(t,(d.get(t)||0)+1)}if(e.targetMethodName&&e.targetModuleName&&e.targetServiceName){let t="".concat(e.targetServiceName,"::").concat(e.targetModuleName,"::").concat(e.targetMethodName);i.set(t,(i.get(t)||0)+1)}}let c=e=>{let t=e;for(;;){let e=t.parentId;if(!e)return"";let a=M.find(t=>t.id===e);if(!a)return"";if("serviceGroup"===a.type)return a.data.label;t=a}};return M.map(u=>{let m=u.data,x=m.label;if("service"===u.type||"serviceGroup"===u.type){let t=e.has(x);return{...u,data:{...m,diffBadge:t?{newCount:s.get(x)||0,resolvedCount:l.get(x)||0}:void 0},style:t?u.style:{...u.style,opacity:.4}}}if("layer"===u.type){let e=u.parentId,a=e?M.find(t=>t.id===e):void 0,r=a?a.data.label:"",s="".concat(r,"::").concat(x),l=t.has(s);return{...u,data:{...m,diffBadge:l?{newCount:0,resolvedCount:0}:void 0},style:l?u.style:{...u.style,opacity:.4}}}if("module"===u.type){let e=c(u),t="".concat(e,"::").concat(x),r=a.has(t);return{...u,data:{...m,diffBadge:r?{newCount:n.get(t)||0,resolvedCount:d.get(t)||0}:void 0},style:r?u.style:{...u.style,opacity:.4}}}if("method"===u.type){let e=c(u),t=u.parentId,a=t?M.find(e=>e.id===t):void 0,s=a?a.data.label:"",l="".concat(e,"::").concat(s,"::").concat(x),n=r.has(l);return{...u,data:{...m,diffBadge:n?{newCount:o.get(l)||0,resolvedCount:i.get(l)||0}:void 0},style:n?u.style:{...u.style,opacity:.4}}}return{...u,style:{...u.style,opacity:.4}}})},[M,_,el]),ev=(0,s.useCallback)((e,t)=>{if(!e||!t)return!1;if(e.includes(t))return!0;let a=e.split("/");for(let e=a.length-1;e>=1;e--){let r=a.slice(e).join("/");if(t.startsWith(r+"/")||t===r)return!0}return!1},[]),ej=(0,s.useMemo)(()=>{let e=_?ey:M;if(!G)return e;let t=new Map;for(let a of e){let e=a.parentId;e&&t.set(a.id,e)}let a=new Set;for(let r of e){let e=r.data,s=!1;if("module"===r.type||"method"===r.type)ev(e.filePath||e.rootPath||"",G)&&(s=!0);else if("layer"===r.type){let t=e.filePaths;(null==t?void 0:t.some(e=>ev(e,G)))&&(s=!0)}else if("serviceGroup"===r.type)ev(e.rootPath||"",G)&&(s=!0);else if("service"===r.type){let t=e.serviceInfo;ev((null==t?void 0:t.rootPath)||"",G)&&(s=!0)}if(s){a.add(r.id);let e=t.get(r.id);for(;e;)a.add(e),e=t.get(e)}}let r=!0;for(;r;)for(let s of(r=!1,e)){if(a.has(s.id))continue;let e=t.get(s.id);if(!e||!a.has(e))continue;let l=s.data;if("module"===s.type||"method"===s.type)ev(l.filePath||l.rootPath||"",G)&&(a.add(s.id),r=!0);else if("layer"===s.type){let e=l.filePaths;(null==e?void 0:e.some(e=>ev(e,G)))&&(a.add(s.id),r=!0)}}return e.map(e=>a.has(e.id)?e:{...e,style:{...e.style,opacity:.15}})},[M,ey,_,G,ev]),eN=(0,s.useMemo)(()=>{if(!G)return null;let e=new Set;for(let a of ej){var t;(null==(t=a.style)?void 0:t.opacity)!==.15&&e.add(a.id)}return e},[ej,G]),ew=(0,s.useMemo)(()=>{let e=new Map;for(let t of Q){let a=t.data,r=a.filePath||a.rootPath;if(!r&&"service"===t.type){let e=a.serviceInfo;r=(null==e?void 0:e.rootPath)||""}r&&e.set(t.id,r)}return e},[Q]);f||(0,l.redirect)("/");let ek=(0,s.useCallback)((e,t)=>{var a;let r="service"===t?["service","serviceGroup"]:"module"===t?["module"]:"method"===t?["method"]:void 0,s=Q.find(t=>t.data.label===e&&(!r||!!r.includes(t.type||"")));return null!=(a=null==s?void 0:s.id)?a:null},[Q]),eC=v&&null!=(a=null==(t=Q.find(e=>e.id===v))||null==(e=t.data)?void 0:e.label)?a:null,eS=Q.some(e=>"database"===e.type),eA=new Set,eT=new Set,eI=new Set;for(let e of Q){let t=e.data;if("service"===e.type){let e=t.serviceInfo;(null==e?void 0:e.type)&&eA.add(e.type),(null==e?void 0:e.framework)&&eT.add(e.framework)}"serviceGroup"===e.type&&(t.serviceType&&eA.add(t.serviceType),t.framework&&eT.add(t.framework)),"layer"===e.type&&eI.add(t.label)}let eE=[...eA],ez=[...eT],eL=[...eI],eD=(0,s.useCallback)((e,t)=>{t&&t!==C?(A(t),setTimeout(()=>W({nodeId:e,key:Date.now()}),500)):W({nodeId:e,key:Date.now()})},[C]);return(0,r.jsxs)("div",{className:"flex h-screen flex-col",children:[(0,r.jsx)(c.Y,{repoName:null==g?void 0:g.name,currentBranch:O,onAnalyze:ec,isAnalyzing:z,showBack:!0,backHref:"/",isChatOpen:P,onToggleChat:()=>R(e=>!e),isDiffMode:_,onEnterDiffMode:ef,onExitDiffMode:eb}),(0,r.jsxs)("div",{className:"flex flex-1 overflow-hidden",children:[(0,r.jsxs)(k,{activeTab:X,onTabChange:H,children:["violations"===X&&(0,r.jsx)(e6,{insights:ea,isLoading:er,repoId:f,selectedService:v,selectedServiceName:eC,selectedDatabaseId:eu,isDiffMode:_,diffResult:el,onLocateNode:eD,resolveNodeIdByName:ek,selectedPath:G,nodeFilePathMap:ew}),"rules"===X&&(0,r.jsx)(ta,{}),"files"===X&&(0,r.jsx)(ts,{repoId:f,selectedPath:G,onSelectPath:e=>{var t;if(K(e),!e)return void ex(null);let a=null;for(let t of Q){if("service"!==t.type&&"serviceGroup"!==t.type)continue;let r=t.data,s="";if("service"===t.type){let e=r.serviceInfo;s=(null==e?void 0:e.rootPath)||""}else s=r.rootPath||"";if(!s)continue;let l=s.split("/");for(let r=l.length-1;r>=0;r--){let s=l.slice(r).join("/");if(e.startsWith(s)||e.startsWith(s+"/")){let e=l.length-r;(!a||e>a.depth)&&(a={id:t.id,depth:e});break}}}ex(null!=(t=null==a?void 0:a.id)?t:null)}})]}),(0,r.jsxs)("div",{className:"relative flex-1",children:[ee&&(0,r.jsxs)("div",{className:"absolute bottom-4 left-1/2 z-20 w-72 -translate-x-1/2 rounded-lg border border-border bg-card p-3 shadow-lg",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,r.jsx)(n.A,{className:"h-3.5 w-3.5 shrink-0 animate-spin text-primary"}),(0,r.jsx)(tI,{value:ee.percent,className:"flex-1 gap-1",children:(0,r.jsx)("div",{className:"flex w-full items-center justify-between",children:(0,r.jsx)(tL,{className:"text-[11px] font-medium capitalize",children:ee.step})})})]}),ee.detail&&(0,r.jsx)("p",{className:"mt-1.5 pl-6 text-[10px] text-muted-foreground",children:ee.detail})]}),(0,r.jsx)("div",{className:"absolute right-3 top-2 z-20 flex items-center gap-1.5 rounded-full bg-card px-2 py-1 text-[10px] shadow-sm border border-border",children:U?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(o.A,{className:"h-3 w-3 text-emerald-500"}),(0,r.jsx)("span",{className:"text-emerald-500",children:"Live"})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(d.A,{className:"h-3 w-3 text-muted-foreground"}),(0,r.jsx)("span",{className:"text-muted-foreground",children:"Offline"})]})}),q?(0,r.jsx)("div",{className:"flex h-full items-center justify-center",children:(0,r.jsxs)("div",{className:"flex flex-col items-center gap-3",children:[(0,r.jsx)(n.A,{className:"h-10 w-10 animate-spin text-primary"}),(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:"Loading graph..."})]})}):Z?(0,r.jsx)("div",{className:"flex h-full items-center justify-center",children:(0,r.jsxs)("div",{className:"flex flex-col items-center gap-3 text-center",children:[(0,r.jsx)(i.A,{className:"h-10 w-10 text-destructive"}),(0,r.jsxs)(tC.Fc,{variant:"destructive",className:"max-w-sm",children:[(0,r.jsx)(tC.XL,{children:"Failed to load graph"}),(0,r.jsx)(tC.TN,{children:Z})]}),(0,r.jsx)(eg.$,{onClick:()=>J(),className:"mt-2",children:"Retry"})]})}):0===M.length&&0===Q.length?(0,r.jsx)("div",{className:"flex h-full items-center justify-center",children:(0,r.jsxs)("div",{className:"flex flex-col items-center gap-3 text-center",children:[(0,r.jsx)(i.A,{className:"h-10 w-10 text-muted-foreground"}),(0,r.jsxs)(tC.Fc,{className:"max-w-sm",children:[(0,r.jsx)(tC.XL,{children:"No graph data"}),(0,r.jsx)(tC.TN,{children:"Run an analysis to generate the architecture graph"})]}),(0,r.jsxs)(eg.$,{onClick:ec,disabled:z,className:"mt-2",children:[z&&(0,r.jsx)(n.A,{className:"h-4 w-4 animate-spin"}),z?"Analyzing...":"Analyze Repository"]}),_&&eo&&(0,r.jsxs)(tC.Fc,{className:"mt-3 max-w-sm border-amber-500/30 text-amber-500",children:[(0,r.jsx)(i.A,{className:"h-4 w-4"}),(0,r.jsx)(tC.TN,{className:"text-amber-500/90",children:eo})]})]})}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ty,{depthLevel:C,serviceTypes:eE,frameworks:ez,layerTypes:eL,hasDatabases:eS,onFilterChange:ep}),(0,r.jsx)(eF,{initialNodes:ej,initialEdges:I,onNodeSelect:ex,onExplainNode:eh,selectedNodeId:v,repoId:f,branch:O,onRefetch:J,depthLevel:C,onDepthChange:A,focusNodeId:null!=(u=null==B?void 0:B.nodeId)?u:null,focusKey:null!=(m=null==B?void 0:B.key)?m:0,isDiffMode:_,diffResult:el,isDiffChecking:en,hasProgressBar:!!ee,onEnterDiffMode:ef,onExitDiffMode:eb,highlightedNodeIds:eN,savedCollapsedIds:$})]})]}),(0,r.jsx)(y,{isOpen:P,children:(0,r.jsx)(th,{repoId:f,selectedService:v,explainRequest:F,onExplainHandled:()=>D(null)})})]})]})}},89766:(e,t,a)=>{Promise.resolve().then(a.bind(a,40191))}},e=>{e.O(0,[206,763,381,552,572,429,597,358],()=>e(e.s=89766)),_N_E=e.O()}]);
|