routeweb 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +42 -5
- package/dist/public/assets/{SearchModal-B0C7wJfG.js → SearchModal-FE7UTYzy.js} +1 -1
- package/dist/public/assets/{TesterDrawer-7pr3VKRs.js → TesterDrawer--T5ETDwa.js} +1 -1
- package/dist/public/assets/index-MvsnPaMs.js +36 -0
- package/dist/public/index.html +1 -1
- package/package.json +2 -2
- package/dist/public/assets/index-Co71Z6SJ.js +0 -36
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SearchModal-FE7UTYzy.js","assets/react-D71YmLB6.js","assets/vendor-DBc_8COV.js","assets/graph-Dp3lBNo7.js","assets/TesterDrawer--T5ETDwa.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var gn=Object.defineProperty;var xn=(n,t,r)=>t in n?gn(n,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[t]=r;var ue=(n,t,r)=>xn(n,typeof t!="symbol"?t+"":t,r);import{a as X,j as L,b as bn}from"./react-D71YmLB6.js";import{f as Ie,P as Fe,p as wn,S as vn,w as En,T as $n,_ as jn,U as Sn,R as An,r as Pn,C as _n}from"./graph-Dp3lBNo7.js";import{_ as nt,l as Nn,P as kn,M as Mn,g as Tn,L as Cn,S as ut,C as In,F as Fn,h as Rn,j as zn,k as On,m as Dn,E as Ln,n as Zn,N as on,G as qn,o as Gn,q as Wn,r as Hn,K as Bn,W as Un,w as Vn,R as Kn,x as Jn,y as Yn}from"./vendor-DBc_8COV.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const p of document.querySelectorAll('link[rel="modulepreload"]'))s(p);new MutationObserver(p=>{for(const f of p)if(f.type==="childList")for(const E of f.addedNodes)E.tagName==="LINK"&&E.rel==="modulepreload"&&s(E)}).observe(document,{childList:!0,subtree:!0});function r(p){const f={};return p.integrity&&(f.integrity=p.integrity),p.referrerPolicy&&(f.referrerPolicy=p.referrerPolicy),p.crossOrigin==="use-credentials"?f.credentials="include":p.crossOrigin==="anonymous"?f.credentials="omit":f.credentials="same-origin",f}function s(p){if(p.ep)return;p.ep=!0;const f=r(p);fetch(p.href,f)}})();const Xn="modulepreload",Qn=function(n){return"/"+n},Nt={},an=function(t,r,s){let p=Promise.resolve();if(r&&r.length>0){let E=function(j){return Promise.all(j.map(P=>Promise.resolve(P).then(A=>({status:"fulfilled",value:A}),A=>({status:"rejected",reason:A}))))};document.getElementsByTagName("link");const x=document.querySelector("meta[property=csp-nonce]"),b=(x==null?void 0:x.nonce)||(x==null?void 0:x.getAttribute("nonce"));p=E(r.map(j=>{if(j=Qn(j),j in Nt)return;Nt[j]=!0;const P=j.endsWith(".css"),A=P?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${j}"]${A}`))return;const w=document.createElement("link");if(w.rel=P?"stylesheet":Xn,P||(w.as="script"),w.crossOrigin="",w.href=j,b&&w.setAttribute("nonce",b),document.head.appendChild(w),P)return new Promise((k,D)=>{w.addEventListener("load",k),w.addEventListener("error",()=>D(new Error(`Unable to preload CSS for ${j}`)))})}))}function f(E){const x=new Event("vite:preloadError",{cancelable:!0});if(x.payload=E,window.dispatchEvent(x),!x.defaultPrevented)throw E}return p.then(E=>{for(const x of E||[])x.status==="rejected"&&f(x.reason);return t().catch(f)})};function ln(n){return n.replace(/\\/g,"/").replace(/\/+/g,"/")}function oe(n){const r=ln(n).split("/"),s=[];for(const p of r)!p||p==="."||(p===".."?s.length>0&&s[s.length-1]!==".."&&s.pop():s.push(p));return s.join("/")}function Re(n){const t=ln(n),r=t.lastIndexOf("/");return r<=0?"":t.slice(0,r)}function le(...n){return oe(n.filter(Boolean).join("/"))}function ne(n,t){const r=n==="/"?"":n.replace(/\/+$/,""),s=t==="/"?"":t.replace(/^\/+/,"");if(!r&&!s)return"/";if(!r)return"/"+s;if(!s)return r.startsWith("/")?r:"/"+r;const p=`${r}/${s}`.replace(/\/+/g,"/");return p.startsWith("/")?p:"/"+p}function fe(n){const t=[],r=/:([A-Za-z0-9_]+)/g;let s;for(;(s=r.exec(n))!==null;)t.includes(s[1])||t.push(s[1]);return t}function me(n){const t=n.split("/").filter(Boolean);return t.length===0?"/":t[0].toLowerCase()==="api"&&t.length>=2&&/^v\d+$/i.test(t[1])&&t.length>=3?`/api/${t[1]}/${t[2]}`:t[0].toLowerCase()==="api"&&t.length>=2?`/api/${t[1]}`:`/${t[0]}`}var kt=[".ts",".tsx",".js",".jsx",".mjs",".cjs"];function es(n){let t="",r=!1,s=!1,p=0;for(;p<n.length;){const f=n[p],E=n[p+1];if(r){t+=f,s?s=!1:f==="\\"?s=!0:f==='"'&&(r=!1),p++;continue}if(f==='"'){r=!0,t+=f,p++;continue}if(f==="/"&&E==="/"){for(;p<n.length&&n[p]!==`
|
|
3
|
+
`;)p++;continue}if(f==="/"&&E==="*"){for(p+=2;p<n.length&&!(n[p]==="*"&&n[p+1]==="/");)p++;p+=2;continue}t+=f,p++}return t.replace(/,\s*([}\]])/g,"$1")}function ct(n){if(typeof n=="string")return[n];if(Array.isArray(n))return n.flatMap(ct);if(n&&typeof n=="object"){const t=n,r=["import","node","default","require"],s=[];for(const p of r)p in t&&s.push(...ct(t[p]));for(const[p,f]of Object.entries(t))r.includes(p)||s.push(...ct(f));return s}return[]}function et(n){const t=new Map;for(const r of n){const s=oe(r.path);if(s==="tsconfig.json"||s.endsWith("/tsconfig.json"))try{const p=JSON.parse(es(r.content));if(p.compilerOptions){const f=Re(s),E=t.get(f);t.set(f,{baseDir:f,baseUrl:p.compilerOptions.baseUrl,paths:p.compilerOptions.paths,packageImports:E==null?void 0:E.packageImports})}}catch{}else if(s==="package.json"||s.endsWith("/package.json"))try{const p=JSON.parse(r.content);if(p.imports&&typeof p.imports=="object"){const f=Re(s),E={};for(const[x,b]of Object.entries(p.imports)){const j=ct(b);j.length>0&&(E[x]=j)}if(Object.keys(E).length>0){const x=t.get(f);t.set(f,{baseDir:f,baseUrl:x==null?void 0:x.baseUrl,paths:x==null?void 0:x.paths,packageImports:E})}}}catch{}}return t}function ts(n,t){let r=Re(oe(n));for(;;){const s=t.get(r);if(s)return s;if(!r)break;r=Re(r)}return t.get("")}function st(n,t){const r=oe(n);if(t.has(r))return r;const s=r.match(/\.(m|c)?jsx?$/);if(s){const p=r.slice(0,-s[0].length);for(const f of[".ts",".tsx",".mts",".cts"])if(t.has(p+f))return p+f}for(const p of kt)if(t.has(r+p))return r+p;for(const p of kt){const f=le(r,`index${p}`);if(t.has(f))return f}return null}function Ce(n,t,r,s){if(!t)return null;if(t.startsWith(".")){const b=Re(n),j=le(b,t);return st(j,r)}const p=s instanceof Map?ts(n,s):s;if(!p)return null;const f=(b,j)=>{if(!b)return null;for(const[P,A]of Object.entries(b))if(P.includes("*")){const[w,k]=P.split("*");if(t.startsWith(w)&&t.endsWith(k)){const D=t.slice(w.length,t.length-k.length);for(const _ of A){const q=_.replace("*",D),B=j?le(j,q):oe(q),V=st(B,r);if(V)return V}}}else if(t===P)for(const w of A){const k=j?le(j,w):oe(w),D=st(k,r);if(D)return D}return null};if(t.startsWith("#")&&p.packageImports){const b=f(p.packageImports,p.baseDir);if(b)return b}const E=p.baseUrl?le(p.baseDir,p.baseUrl):p.baseDir,x=f(p.paths,E);if(x)return x;if(p.baseUrl){const b=le(E,t),j=st(b,r);if(j)return j}return null}function ns(n){var A;const t=n.nodes.filter(w=>w.type==="route"),r=((A=n.metadata.unresolved)==null?void 0:A.length)??n.metadata.unresolvedMounts.length;if(t.length===0){const w=`# ${n.metadata.repoName} (${n.metadata.framework})
|
|
4
|
+
No routes detected across ${n.metadata.scannedFiles} files.`;return r>0?`${w}
|
|
5
|
+
|
|
6
|
+
⚠ ${r} route-like calls could not be fully resolved (run with --debug for details)`:w}const s=[],p=n.metadata.detectedPort?` | port: ${n.metadata.detectedPort}`:"";s.push(`# ${n.metadata.repoName} (${n.metadata.framework} | ${t.length} routes | ${n.metadata.scannedFiles} files${p})`);const f=new Map;for(const w of t)for(const k of w.middlewares??[])f.set(k,(f.get(k)??0)+1);const E=Math.max(2,Math.ceil(t.length*.8)),x=new Set(Array.from(f.entries()).filter(([,w])=>w>=E).map(([w])=>w));x.size>0&&s.push(`# Global middleware: [${Array.from(x).join(", ")}]`);const b=[...t].sort((w,k)=>{const D=(w.fullPath??"").localeCompare(k.fullPath??"");return D!==0?D:(w.method??"").localeCompare(k.method??"")}),j=b.map(w=>`${(w.method??"GET").padEnd(6)} ${w.fullPath??"/"}`),P=Math.min(48,Math.max(...j.map(w=>w.length)));for(let w=0;w<b.length;w++){const k=b[w],D=j[w].padEnd(P),_=(k.middlewares??[]).filter($=>!x.has($)),q=_.length>0?`[${_.join(", ")}]`:"[]",B=`${k.controller??"handler"} (${k.controllerFile??k.file}:${k.controllerLine??k.line})`,V=[];k.pathParams&&k.pathParams.length>0&&V.push(`params: {${k.pathParams.join(", ")}}`),k.queryParams&&k.queryParams.length>0&&V.push(`query: {${k.queryParams.join(", ")}}`),k.bodyFields&&k.bodyFields.length>0&&V.push(`body: {${k.bodyFields.join(", ")}}`),k.partial&&V.push("partial: prefix may be missing");const T=V.length>0?` | ${V.join(" | ")}`:"";s.push(`${D} -> ${q} -> ${B}${T}`)}return r>0&&(s.push(""),s.push(`⚠ ${r} route-like calls could not be fully resolved (run with --debug for details)`)),s.join(`
|
|
7
|
+
`)}var ss=["auth","authenticate","isauthenticated","requireauth","verifyjwt","jwt","protect","guard","authguard","permission","preauthorize","secured","rolesallowed","login_required","depends","bearer"];typeof nt=="function"?nt:nt.default??nt;function rs(n){try{return Nn.parse(n,{sourceType:"unambiguous",errorRecovery:!0,plugins:["typescript","jsx","decorators-legacy","classProperties","classPrivateProperties","classPrivateMethods","dynamicImport","optionalChaining","nullishCoalescingOperator","topLevelAwait"]})}catch{return null}}function ge(n){return n?n.type==="Identifier"?n.name:n.type==="StringLiteral"?n.value:null:null}function We(n,t,r){var A,w,k,D,_,q,B,V,T,$,c,i,g,m,e,a,u,o,l,h;const s=rs(n.content);if(!s)return null;const p=new Map,f=new Map,E=[],x=new Map,b=new Set,j=(y,d,v)=>{d==="express"&&(v==="default"||v==="*")&&b.add(y),p.set(y,{localName:y,sourceSpecifier:d,resolvedFile:Ce(n.path,d,t,r),importedName:v})};for(const y of s.program.body)if(y.type==="ImportDeclaration"){const d=y.source.value;for(const v of y.specifiers)if(v.type==="ImportDefaultSpecifier")j(v.local.name,d,"default");else if(v.type==="ImportNamespaceSpecifier")j(v.local.name,d,"*");else if(v.type==="ImportSpecifier"){const S=ge(v.imported)??v.local.name;j(v.local.name,d,S)}}else if(y.type==="ExportNamedDeclaration"){if(y.source){const d=Ce(n.path,y.source.value,t,r);for(const v of y.specifiers)if(v.type==="ExportSpecifier"){const S=ge(v.exported)??"",I=ge(v.local)??S;E.push({resolvedFile:d,exportedName:S,importedName:I})}}else if(y.declaration){const d=y.declaration;if(d.type==="FunctionDeclaration"&&d.id)x.set(d.id.name,d),f.set(d.id.name,{name:d.id.name,node:d,line:((A=d.loc)==null?void 0:A.start.line)??1});else if(d.type==="ClassDeclaration"&&d.id)x.set(d.id.name,d),f.set(d.id.name,{name:d.id.name,node:d,line:((w=d.loc)==null?void 0:w.start.line)??1});else if(d.type==="VariableDeclaration"){for(const v of d.declarations)if(v.id.type==="Identifier"&&v.init)x.set(v.id.name,v.init),f.set(v.id.name,{name:v.id.name,node:v.init,line:((k=v.loc)==null?void 0:k.start.line)??1});else if(v.id.type==="ObjectPattern"&&v.init)for(const S of v.id.properties)S.type==="ObjectProperty"&&S.value.type==="Identifier"&&f.set(S.value.name,{name:S.value.name,node:v.init,line:((D=S.loc)==null?void 0:D.start.line)??((_=v.loc)==null?void 0:_.start.line)??1})}}else for(const d of y.specifiers)if(d.type==="ExportSpecifier"){const v=d.local.name,S=ge(d.exported)??v,I=x.get(v);I?f.set(S,{name:S,node:I,line:((q=I.loc)==null?void 0:q.start.line)??((B=d.loc)==null?void 0:B.start.line)??1}):f.set(S,{name:S,node:d.local,line:((V=d.loc)==null?void 0:V.start.line)??1})}}else if(y.type==="ExportAllDeclaration"){const d=Ce(n.path,y.source.value,t,r);E.push({resolvedFile:d,exportedName:"*",importedName:"*"})}else if(y.type==="ExportDefaultDeclaration"){const d=y.declaration;if(d.type==="Identifier"){const v=x.get(d.name)??d;f.set("default",{name:"default",localName:d.name,node:v,line:((T=v.loc)==null?void 0:T.start.line)??(($=y.loc)==null?void 0:$.start.line)??1})}else f.set("default",{name:"default",node:d,line:((c=d.loc)==null?void 0:c.start.line)??((i=y.loc)==null?void 0:i.start.line)??1})}else if(y.type==="FunctionDeclaration"&&y.id)x.set(y.id.name,y);else if(y.type==="ClassDeclaration"&&y.id)x.set(y.id.name,y);else if(y.type==="VariableDeclaration")for(const d of y.declarations){if(!d.init)continue;const v=ze(d.init);if(v){if(d.id.type==="Identifier")j(d.id.name,v,"default");else if(d.id.type==="ObjectPattern"){for(const S of d.id.properties)if(S.type==="ObjectProperty"){const I=ge(S.key),O=S.value.type==="Identifier"?S.value.name:I;I&&O&&j(O,v,I)}}}else d.id.type==="Identifier"&&x.set(d.id.name,d.init)}else if(y.type==="ExpressionStatement"&&y.expression.type==="AssignmentExpression"){const{left:d,right:v}=y.expression;if(d.type==="MemberExpression"){const S=d.object.type==="Identifier"?d.object.name:null,I=ge(d.property);if(S==="module"&&I==="exports"){const O=v.type==="Identifier"?v.name:void 0,z=v.type==="Identifier"?x.get(v.name)??v:v;if(f.set("default",{name:"default",localName:O,node:z,line:((g=z.loc)==null?void 0:g.start.line)??((m=y.loc)==null?void 0:m.start.line)??1}),z.type==="ObjectExpression"){for(const G of z.properties)if(G.type==="ObjectProperty"){const W=ge(G.key);if(W){const H=G.value.type==="Identifier"?x.get(G.value.name)??G.value:G.value;f.set(W,{name:W,node:H,line:((e=H.loc)==null?void 0:e.start.line)??((a=G.loc)==null?void 0:a.start.line)??1})}}}}else if(S==="exports"&&I){const O=v.type==="Identifier"?x.get(v.name)??v:v;f.set(I,{name:I,node:O,line:((u=O.loc)==null?void 0:u.start.line)??((o=y.loc)==null?void 0:o.start.line)??1})}else if(d.object.type==="MemberExpression"&&d.object.object.type==="Identifier"&&d.object.object.name==="module"&&ge(d.object.property)==="exports"&&I){const O=v.type==="Identifier"?x.get(v.name)??v:v;f.set(I,{name:I,node:O,line:((l=O.loc)==null?void 0:l.start.line)??((h=y.loc)==null?void 0:h.start.line)??1})}}}const P=y=>{if(!(!y||typeof y!="object")){if(y.type==="VariableDeclarator"&&y.init){const d=ze(y.init);if(d){if(y.id.type==="Identifier"&&!p.has(y.id.name))j(y.id.name,d,"default");else if(y.id.type==="ObjectPattern"){for(const v of y.id.properties)if(v.type==="ObjectProperty"){const S=ge(v.key),I=v.value.type==="Identifier"?v.value.name:S;S&&I&&!p.has(I)&&j(I,d,S)}}}}for(const d of Object.keys(y)){if(d==="loc"||d==="start"||d==="end"||d==="extra")continue;const v=y[d];if(Array.isArray(v))for(const S of v)S&&typeof S=="object"&&"type"in S&&P(S);else v&&typeof v=="object"&&"type"in v&&P(v)}}};return P(s.program),{path:n.path,ast:s,imports:p,exports:f,reExports:E,locals:x,expressImports:b}}function ze(n){var t;return n.type==="CallExpression"&&n.callee.type==="Identifier"&&n.callee.name==="require"&&((t=n.arguments[0])==null?void 0:t.type)==="StringLiteral"?n.arguments[0].value:n.type==="MemberExpression"?ze(n.object):null}function cn(n,t=0){if(t>3||n.type==="FunctionDeclaration"||n.type==="FunctionExpression"||n.type==="ArrowFunctionExpression"||n.type==="ObjectMethod"||n.type==="ClassMethod")return n;if(n.type==="CallExpression"){for(const r of n.arguments)if(r.type==="FunctionExpression"||r.type==="ArrowFunctionExpression")return r;for(const r of n.arguments)if(r.type!=="SpreadElement"){const s=cn(r,t+1);if(s!==r)return s}}return n}function _t(n){const t=new Set,r=new Set,s=new Set,p=cn(n);if(p.type!=="FunctionDeclaration"&&p.type!=="FunctionExpression"&&p.type!=="ArrowFunctionExpression"&&p.type!=="ObjectMethod"&&p.type!=="ClassMethod")return{pathParams:[],queryParams:[],bodyFields:[]};let f="req";const E=p.params[0];(E==null?void 0:E.type)==="Identifier"&&(f=E.name);const x=(A,w)=>{w&&!w.startsWith("_")&&A.add(w)},b=A=>{if(A.type==="LogicalExpression")return b(A.left);if(A.type==="MemberExpression"&&A.object.type==="Identifier"&&A.object.name===f){const w=ge(A.property);if(w==="params"||w==="query"||w==="body")return w}return null},j=A=>A==="params"?t:A==="query"?r:s,P=A=>{if(!(!A||typeof A!="object")){if(A.type==="MemberExpression"){const w=b(A.object);if(w){const k=ge(A.property);x(j(w),k)}}if(A.type==="VariableDeclarator"&&A.init&&A.id.type==="ObjectPattern"){const w=b(A.init);if(w){const k=j(w);for(const D of A.id.properties)D.type==="ObjectProperty"&&x(k,ge(D.key))}}for(const w of Object.keys(A)){if(w==="loc"||w==="start"||w==="end"||w==="extra")continue;const k=A[w];if(Array.isArray(k))for(const D of k)D&&typeof D=="object"&&"type"in D&&P(D);else k&&typeof k=="object"&&"type"in k&&P(k)}}};return P(p.body),{pathParams:Array.from(t),queryParams:Array.from(r),bodyFields:Array.from(s)}}var _e=new Set(["get","post","put","patch","delete","options","head","all"]),dt=/\.(ts|tsx|js|jsx|mjs|cjs)$/i,pn=/(\.test\.|\.spec\.|__tests__|__mocks__)/i;function de(n){let t=n;for(;t.type==="TSAsExpression"||t.type==="TSSatisfiesExpression"||t.type==="TSTypeAssertion"||t.type==="ParenthesizedExpression";)t=t.expression;return t}function ae(n){return n?n.type==="Identifier"?n.name:n.type==="StringLiteral"?n.value:null:null}function Ge(n){if(n.type==="Identifier")return n.name;if(n.type==="MemberExpression"){const t=Ge(n.object),r=ae(n.property)??"";return t?`${t}.${r}`:r}return n.type==="CallExpression"?Ge(n.callee):"anonymous"}function os(n,t){for(const r of n){const s=oe(r.path);if(s===".env"||s===".env.example"){const p=r.content.match(/^\s*PORT\s*=\s*(\d+)/m);if(p)return Number(p[1])}}for(const r of t)r.ast.program.body.map(s=>s).length;for(const r of n){if(!dt.test(r.path))continue;const s=r.content.match(/\.listen\(\s*(\d{2,5})\b/);if(s)return Number(s[1]);const p=r.content.match(/\b(?:PORT|port)\b\s*=\s*(?:process\.env\.PORT\s*\|\|\s*)?(\d{2,5})\b/);if(p)return Number(p[1])}}function as(n){const{fileSet:t,tsConfig:r,parsedMap:s}=n,p=(x,b,j=0)=>{var P,A,w,k,D,_,q,B,V,T;if(j>8)return null;if(b.type==="Identifier"){const $=x.imports.get(b.name);if($&&$.resolvedFile){const i=s.get($.resolvedFile);if(!i)return null;if($.importedName==="*")return{file:i,node:i.ast.program,name:b.name,line:1};const g=i.exports.get($.importedName);if(g)return g.node.type==="Identifier"&&g.node.name!==b.name?p(i,g.node,j+1)??{file:i,node:g.node,name:$.importedName,line:g.line}:{file:i,node:g.node,name:$.importedName==="default"?b.name:$.importedName,localName:g.localName,line:g.line};for(const m of i.reExports)if(m.resolvedFile&&(m.exportedName==="*"||m.exportedName===$.importedName)){const e=s.get(m.resolvedFile);if(e){const a=m.exportedName==="*"?$.importedName:m.importedName,u=e.exports.get(a);if(u)return u.node.type==="Identifier"&&u.node.name!==a?p(e,u.node,j+1)??{file:e,node:u.node,name:a,localName:u.localName,line:u.line}:{file:e,node:u.node,name:a,localName:u.localName,line:u.line}}}return $.importedName==="default"&&i.exports.size>0?{file:i,node:i.ast.program,name:b.name,line:1}:null}const c=x.locals.get(b.name);return c?{file:x,node:c,name:b.name,line:((P=c.loc)==null?void 0:P.start.line)??1}:null}if(b.type==="MemberExpression"){const $=ae(b.property);if(!$)return null;if(b.object.type==="ThisExpression")for(const a of x.locals.values()){const u=de(a);if(u.type==="ClassDeclaration"||u.type==="ClassExpression")for(const o of u.body.body){if((o.type==="ClassMethod"||o.type==="ClassProperty")&&ae(o.key)===$){const l=o.type==="ClassProperty"&&o.value?o.value:o;return{file:x,node:l,name:`${((A=u.id)==null?void 0:A.name)??"this"}.${$}`,line:((w=o.loc)==null?void 0:w.start.line)??1}}if(o.type==="ClassMethod"){for(const l of o.body.body)if(l.type==="ExpressionStatement"&&l.expression.type==="AssignmentExpression"&&l.expression.left.type==="MemberExpression"&&l.expression.left.object.type==="ThisExpression"&&ae(l.expression.left.property)===$){const h=l.expression.right,y=h.type==="NewExpression"?p(x,h.callee,j+1):null;return y||{file:x,node:h,name:`${((k=u.id)==null?void 0:k.name)??"this"}.${$}`,line:((D=l.loc)==null?void 0:D.start.line)??1}}}}}const c=ze(b.object);if(c){const a=Ce(x.path,c,t,r);if(a){const u=s.get(a),o=u==null?void 0:u.exports.get($);if(u&&o)return{file:u,node:o.node,name:$,line:o.line}}}const i=p(x,b.object,j+1);if(!i)return null;let g=i,m=de(g.node);if(m.type==="NewExpression"){const a=p(g.file,m.callee,j+1);a&&(g=a,m=de(a.node))}if(m.type==="ClassDeclaration"||m.type==="ClassExpression"){if($==="router")return{file:g.file,node:m,name:g.name,line:((_=m.loc)==null?void 0:_.start.line)??1};let a={file:g.file,node:m,name:g.name},u=0;for(;a&&u<5;){for(const o of a.node.body.body)if((o.type==="ClassMethod"||o.type==="ClassProperty")&&ae(o.key)===$){const l=o.type==="ClassProperty"&&o.value?o.value:o;return{file:a.file,node:l,name:`${a.name}.${$}`,line:((q=o.loc)==null?void 0:q.start.line)??1}}if(a.node.superClass){const o=p(a.file,a.node.superClass,j+1+u),l=o?de(o.node):null;if(o&&l&&(l.type==="ClassDeclaration"||l.type==="ClassExpression")){a={file:o.file,node:l,name:o.name},u++;continue}}a=null}}if(m.type==="Program"){const a=i.file.exports.get($);if(a)return{file:i.file,node:a.node,name:`${i.name}.${$}`,line:a.line}}if(m.type==="ObjectExpression")for(const a of m.properties){if(a.type==="ObjectProperty"&&ae(a.key)===$){if(a.value.type==="Identifier"||a.value.type==="MemberExpression"){const o=p(i.file,a.value,j+1);if(o)return o}const u=a.value.type==="Identifier"?i.file.locals.get(a.value.name)??a.value:a.value;return{file:i.file,node:u,name:`${i.name}.${$}`,line:((B=u.loc)==null?void 0:B.start.line)??((V=a.loc)==null?void 0:V.start.line)??1}}if(a.type==="ObjectMethod"&&ae(a.key)===$)return{file:i.file,node:a,name:`${i.name}.${$}`,line:((T=a.loc)==null?void 0:T.start.line)??1}}const e=i.file.exports.get($);if(e){if(e.node.type==="Identifier"){const a=p(i.file,e.node,j+1);if(a)return a}return{file:i.file,node:e.node,name:`${i.name}.${$}`,localName:e.localName,line:e.line}}}if(b.type==="NewExpression")return p(x,b.callee,j+1);if(b.type==="CallExpression"){if(b.callee.type==="MemberExpression"&&b.callee.object.type==="Identifier"&&b.callee.object.name==="Object"&&ae(b.callee.property)==="assign"&&b.arguments[0]&&b.arguments[0].type!=="SpreadElement")return p(x,b.arguments[0],j+1);if(b.callee.type==="MemberExpression"&&ae(b.callee.property)==="bind")return p(x,b.callee.object,j+1);let $=ze(b);if(!$&&b.callee.type==="Identifier"&&b.callee.name==="require"&&b.arguments[0]){const i=b.arguments[0],g=f(x,i);if(g)$=g;else if(i.type==="CallExpression"&&i.callee.type==="MemberExpression"&&ae(i.callee.property)==="join"){const m=[];for(const e of i.arguments)if(e.type==="Identifier"&&e.name==="__dirname")m.push(".");else{const a=f(x,e);a!==null&&m.push(a)}m.length>0&&($=m.join("/"))}}if($){const i=Ce(x.path,$,t,r);if(i){const g=s.get(i);if(g){const m=g.exports.get("default");if(m)return m.node.type==="CallExpression"&&m.node.callee.type==="MemberExpression"&&m.node.callee.object.type==="Identifier"&&m.node.callee.object.name==="Object"&&ae(m.node.callee.property)==="assign"&&m.node.arguments[0]?p(g,m.node.arguments[0],j+1)??{file:g,node:m.node,name:$,localName:m.localName,line:m.line}:{file:g,node:m.node,name:$,localName:m.localName,line:m.line}}}}const c=p(x,b.callee,j+1);if(c&&(c.node.type==="FunctionDeclaration"||c.node.type==="FunctionExpression"||c.node.type==="ArrowFunctionExpression"))return c}return null},f=(x,b,j=0)=>{if(!b||j>8)return null;const P=de(b);if(P.type==="StringLiteral")return P.value;if(P.type==="NumericLiteral")return String(P.value);if(P.type==="RegExpLiteral")return`/${P.pattern}/`;if(P.type==="TemplateLiteral"){let A="";for(let w=0;w<P.quasis.length;w++)if(A+=P.quasis[w].value.cooked??P.quasis[w].value.raw,w<P.expressions.length){const k=f(x,P.expressions[w],j+1);if(k===null)return null;A+=k}return A}if(P.type==="BinaryExpression"&&P.operator==="+"){const A=f(x,P.left,j+1),w=f(x,P.right,j+1);return A!==null&&w!==null?A+w:null}if(P.type==="Identifier"||P.type==="MemberExpression"){const A=p(x,P);if(A)return f(A.file,A.node,j+1)}return null};return{resolveSymbol:p,resolveStringExpr:f,resolveStringOrArrayValues:(x,b)=>{if(!b)return null;const j=de(b),P=f(x,j);if(P!==null)return[P];if(j.type==="ArrayExpression"){const A=[];for(const w of j.elements)if(w&&w.type!=="SpreadElement"){const k=f(x,w);k!==null&&A.push(k)}return A.length>0?A:null}return null}}}function is(n,t){const{fileSet:r}=n,{resolveSymbol:s,resolveStringExpr:p,resolveStringOrArrayValues:f}=t,E=(P,A)=>{var k;let w=A;for(;w.type==="CallExpression"&&w.callee.type==="MemberExpression";){const D=ae(w.callee.property);if(D==="Router"&&w.callee.object.type==="Identifier"&&P.expressImports.has(w.callee.object.name))return!0;if(D==="use"||D==="route"||_e.has(D??"")){w=w.callee.object;continue}break}if(w.type==="CallExpression"){const D=w.callee;if(D.type==="Identifier"&&D.name==="Router"&&((k=P.imports.get("Router"))==null?void 0:k.sourceSpecifier)==="express"||D.type==="MemberExpression"&&D.object.type==="Identifier"&&P.expressImports.has(D.object.name)&&ae(D.property)==="Router")return!0}return!1},x=new Map,b=P=>{const A=x.get(P.path);if(A)return A;const w=new Set,k=new Set,D=(V,T)=>{if(!T)return;const $=de(T);if($.type==="CallExpression"){const c=$.callee;c.type==="Identifier"&&P.expressImports.has(c.name)?w.add(V):E(P,$)&&k.add(V)}};for(const[V,T]of P.locals.entries())D(V,T);const _=V=>{if(!(!V||typeof V!="object")){if(V.type==="VariableDeclarator"&&V.id.type==="Identifier"&&V.init)D(V.id.name,V.init);else if(V.type==="AssignmentExpression"&&V.left.type==="MemberExpression"&&V.left.object.type==="ThisExpression"){const T=ae(V.left.property);T&&D(`this.${T}`,V.right)}else if(V.type==="ClassProperty"&&V.value){const T=ae(V.key);T&&D(`this.${T}`,V.value)}for(const T of Object.keys(V)){if(T==="loc"||T==="start"||T==="end"||T==="extra")continue;const $=V[T];if(Array.isArray($))for(const c of $)c&&typeof c=="object"&&"type"in c&&_(c);else $&&typeof $=="object"&&"type"in $&&_($)}}};_(P.ast.program);const q=P.exports.get("default");q&&E(P,q.node)&&k.add("__default_router__");const B={apps:w,routers:k};return x.set(P.path,B),B},j=(P,A,w,k)=>{const D=[],_=c=>{var i;if(!k)return c;if(c.type==="Identifier"&&((i=k.identMap)!=null&&i.has(c.name)))return k.identMap.get(c.name);if(k.computedPropMap&&c.type==="MemberExpression"&&c.computed&&c.property.type==="Identifier"&&k.computedPropMap.has(c.property.name))return k.computedPropMap.get(c.property.name);if(c.type==="BinaryExpression"&&c.operator==="+"){const g=_(c.left),m=_(c.right);if(g!==c.left||m!==c.right)return{...c,left:g,right:m}}if(c.type==="CallExpression"&&c.callee.type==="Identifier"&&c.callee.name==="require"&&c.arguments[0]){const g=_(c.arguments[0]);if(g!==c.arguments[0])return{...c,arguments:[g,...c.arguments.slice(1)]}}if(k.paramName&&k.props&&c.type==="MemberExpression"&&c.object.type==="Identifier"&&c.object.name===k.paramName){const g=ae(c.property);if(g&&k.props.has(g))return k.props.get(g)}return c},q=(c,i,g)=>{var a,u;if(!i)return!1;const m=de(c);if(m.type==="CallExpression"&&m.callee.type==="MemberExpression"&&m.callee.object.type==="Identifier"&&m.callee.object.name==="Object"&&ae(m.callee.property)==="entries"&&m.arguments[0]&&i.type==="ArrayPattern"&&((a=i.elements[0])==null?void 0:a.type)==="Identifier"&&((u=i.elements[1])==null?void 0:u.type)==="Identifier"){const o=i.elements[0].name,l=i.elements[1].name,h=de(m.arguments[0]),y=h.type==="ObjectExpression"?h:(()=>{const d=s(P,h);return d?de(d.node):null})();if((y==null?void 0:y.type)==="ObjectExpression"){for(const d of y.properties)if(d.type==="ObjectProperty"){const v=ae(d.key);if(v){const S=new Map([[o,{type:"StringLiteral",value:v}],[l,d.value]]);D.push(...j(P,g,w,{identMap:S}))}}return!0}}if(m.type==="CallExpression"&&m.callee.type==="MemberExpression"&&m.callee.object.type==="Identifier"&&m.callee.object.name==="Object"&&ae(m.callee.property)==="keys"&&m.arguments[0]&&i.type==="Identifier"){const o=i.name,l=de(m.arguments[0]),h=l.type==="ObjectExpression"?l:(()=>{const y=s(P,l);return y?de(y.node):null})();if((h==null?void 0:h.type)==="ObjectExpression"){for(const y of h.properties)if(y.type==="ObjectProperty"){const d=ae(y.key);if(d){const v=new Map([[o,{type:"StringLiteral",value:d}]]),S=new Map([[o,y.value]]);D.push(...j(P,g,w,{identMap:v,computedPropMap:S}))}}return!0}}if(m.type==="CallExpression"&&(m.callee.type==="MemberExpression"&&ae(m.callee.property)==="readdirSync"||m.callee.type==="Identifier"&&m.callee.name==="readdirSync")&&m.arguments[0]&&i.type==="Identifier"){const o=m.arguments[0];let l=null;if(o.type==="CallExpression"&&o.callee.type==="MemberExpression"&&ae(o.callee.property)==="join"){const h=[];for(const y of o.arguments){if(y.type==="Identifier"&&y.name==="__dirname")continue;const d=p(P,y);d!==null&&h.push(d)}h.length>0&&(l=h.join("/"))}else o.type==="BinaryExpression"&&o.operator==="+"&&o.left.type==="Identifier"&&o.left.name==="__dirname"?l=p(P,o.right):l=p(P,o);if(l!==null){const h=oe(le(Re(P.path),l)),y=h?`${h}/`:"",d=Array.from(r).filter(v=>v!==P.path&&v.startsWith(y)&&!v.slice(y.length).includes("/")&&dt.test(v)&&!pn.test(v));for(const v of d){const S=v.slice(y.length),I=new Map([[i.name,{type:"StringLiteral",value:S}]]);D.push(...j(P,g,w,{identMap:I}))}return!0}}const e=m.type==="ArrayExpression"?m:(()=>{const o=s(P,m);return o?de(o.node):null})();if((e==null?void 0:e.type)==="ArrayExpression"&&i.type==="Identifier"){for(const o of e.elements)if((o==null?void 0:o.type)==="ObjectExpression"){const l=new Map;for(const h of o.properties)if(h.type==="ObjectProperty"){const y=ae(h.key);y&&l.set(y,h.value)}D.push(...j(P,g,w,{paramName:i.name,props:l}))}return!0}return!1},B=c=>{if(c.type==="ThisExpression"&&w.has("this"))return"this";if(c.type==="Identifier"&&w.has(c.name))return c.name;if(c.type==="MemberExpression"&&c.object.type==="ThisExpression"){const i=ae(c.property);if(i&&w.has(`this.${i}`))return`this.${i}`}return null},V=c=>{var m;const i=[];let g=c;for(;g.type==="CallExpression"&&g.callee.type==="MemberExpression";){const e=ae(g.callee.property);if(!e)return null;if(e==="route"){const a=B(g.callee.object);if(a){const u=p(P,_(g.arguments[0]));return{routerName:a,pathArg:u??void 0,dynamicPath:u===null,chain:i.reverse()}}return null}if(_e.has(e))i.push({methodName:e,args:g.arguments.map(_),line:((m=g.loc)==null?void 0:m.start.line)??1}),g=g.callee.object;else return null}return null},T=c=>{var a,u,o,l,h,y,d,v,S,I,O;const i=c.type==="AwaitExpression"?c.argument:c;if(i.type!=="CallExpression")return;if(i.callee.type==="MemberExpression"&&ae(i.callee.property)==="forEach"&&i.arguments[0]&&(i.arguments[0].type==="ArrowFunctionExpression"||i.arguments[0].type==="FunctionExpression")){const z=i.arguments[0],G=z.body.type==="BlockStatement"?z.body.body:[{type:"ExpressionStatement",expression:z.body}];if(q(i.callee.object,z.params[0],G))return}if(i.callee.type==="MemberExpression"&&ae(i.callee.property)==="route"&&B(i.callee.object)&&((a=i.arguments[0])==null?void 0:a.type)==="ObjectExpression"){const z=i.arguments[0];let G=null,W,H,N;for(const C of z.properties){if(C.type!=="ObjectProperty")continue;const R=ae(C.key);R==="method"?G=p(P,C.value):R==="path"?W=C.value:R==="handler"?H=C.value:R==="middleware"&&(N=C.value)}if(G&&_e.has(G.toLowerCase())&&H){const C=f(P,W),R=[];if(N&&R.push(N),R.push(H),C)for(const M of C)D.push({kind:"method",objectName:"this",methodName:G.toLowerCase(),pathArg:M,dynamicPath:!1,args:R,line:((u=i.loc)==null?void 0:u.start.line)??1});return}}if(i.callee.type==="MemberExpression"&&ae(i.callee.property)==="route"&&((o=i.arguments[0])==null?void 0:o.type)==="ObjectExpression"){const z=B(i.callee.object);if(z){const G=i.arguments[0];let W=null,H,N,C;for(const R of G.properties)if(R.type==="ObjectProperty"){const M=ae(R.key);M==="method"?W=((l=p(P,R.value))==null?void 0:l.toLowerCase())??null:M==="path"?H=R.value:M==="handler"?N=R.value:M==="middleware"&&(C=R.value)}if(W&&_e.has(W)&&N){const R=p(P,H),M=[];C&&M.push(C),M.push(N),D.push({kind:"method",objectName:z,methodName:W,pathArg:R??void 0,dynamicPath:R===null,args:M,line:((h=i.loc)==null?void 0:h.start.line)??1});return}}}if(i.callee.type==="MemberExpression"&&ae(i.callee.property)==="route"&&((y=i.arguments[0])==null?void 0:y.type)==="ObjectExpression"){const z=B(i.callee.object);if(z){const G=i.arguments[0];let W=null,H,N,C;for(const R of G.properties)if(R.type==="ObjectProperty"){const M=ae(R.key);M==="method"?W=((d=p(P,R.value))==null?void 0:d.toLowerCase())??null:M==="path"?H=R.value:M==="handler"?N=R.value:M==="middleware"&&(C=R.value)}if(W&&_e.has(W)&&N){const R=p(P,H),M=[];C&&M.push(C),M.push(N),D.push({kind:"method",objectName:z,methodName:W,pathArg:R??void 0,dynamicPath:R===null,args:M,line:((v=i.loc)==null?void 0:v.start.line)??1});return}}}const g=V(i);if(g&&g.chain.length>0){D.push({kind:"route-chain",objectName:g.routerName,methodName:"route",pathArg:g.pathArg,dynamicPath:g.dynamicPath,args:[],line:((S=i.loc)==null?void 0:S.start.line)??1,chainCalls:g.chain});return}if((z=>{var N;const G=[];let W=z;for(;W.type==="CallExpression"&&W.callee.type==="MemberExpression";){const C=ae(W.callee.property);if(!C||C!=="use"&&!_e.has(C))break;G.push({methodName:C,args:W.arguments.map(_),line:((N=W.loc)==null?void 0:N.start.line)??1}),W=W.callee.object}if(G.length===0)return!1;let H=B(W);if(!H){if(w.has("__default_router__")&&E(P,W)&&!(W.type==="CallExpression"&&W.callee.type==="MemberExpression"&&G.length===0))H="__default_router__";else if(W.type==="CallExpression"&&E(P,W)){for(const C of w)if(P.locals.get(C)===z){H=C;break}}}if(!H)return!1;for(const C of G.reverse())if(C.methodName==="use"){const R=C.args[0],M=f(P,R);if(M)for(const F of M)D.push({kind:"use",objectName:H,methodName:"use",pathArg:F,args:C.args.slice(1),line:C.line});else D.push({kind:"use",objectName:H,methodName:"use",pathArg:void 0,args:C.args,line:C.line})}else if(_e.has(C.methodName)){const R=C.args[0],M=f(P,R);if(M)for(const F of M)D.push({kind:"method",objectName:H,methodName:C.methodName,pathArg:F,dynamicPath:!1,args:C.args.slice(1),line:C.line});else D.push({kind:"method",objectName:H,methodName:C.methodName,pathArg:void 0,dynamicPath:!0,args:C.args.slice(1),line:C.line})}return!0})(i))return;for(let z=0;z<i.arguments.length;z++){const G=i.arguments[z];if(G.type==="Identifier"&&w.has(G.name)){D.push({kind:"delegate",objectName:G.name,methodName:"delegate",args:[],line:((I=i.loc)==null?void 0:I.start.line)??1,delegateCallee:i.callee,delegateArgIndex:z});return}if(G.type==="ObjectExpression"){for(const W of G.properties)if(W.type==="ObjectProperty"&&W.value.type==="Identifier"&&w.has(W.value.name)){const H=ae(W.key);if(H){D.push({kind:"delegate",objectName:W.value.name,methodName:"delegate",args:[],line:((O=i.loc)==null?void 0:O.start.line)??1,delegateCallee:i.callee,delegateArgIndex:z,delegatePropKey:H});return}}}}let e=i;for(;e.type==="CallExpression";){for(const z of e.arguments)(z.type==="ArrowFunctionExpression"||z.type==="FunctionExpression")&&z.body.type==="BlockStatement"&&$(z.body);if(e.callee.type==="MemberExpression")e=e.callee.object;else break}},$=c=>{var i,g,m;if(c){if(c.type==="ExpressionStatement")c.expression.type==="AssignmentExpression"&&(c.expression.right.type==="ArrowFunctionExpression"||c.expression.right.type==="FunctionExpression")&&c.expression.right.body.type==="BlockStatement"?$(c.expression.right.body):T(c.expression);else if(c.type==="BlockStatement")for(const e of c.body)$(e);else if(c.type==="IfStatement")$(c.consequent),$(c.alternate);else if(c.type==="TryStatement")$(c.block),c.handler&&$(c.handler.body),$(c.finalizer);else if(c.type==="ForOfStatement"){let e;c.left.type==="VariableDeclaration"?e=(i=c.left.declarations[0])==null?void 0:i.id:(c.left.type==="Identifier"||c.left.type==="ArrayPattern")&&(e=c.left);const a=c.body.type==="BlockStatement"?c.body.body:[c.body];q(c.right,e,a)||$(c.body)}else if(c.type==="ForStatement"||c.type==="ForInStatement"||c.type==="WhileStatement")$(c.body);else if(c.type==="FunctionDeclaration"&&c.body)(c.params.some(a=>a.type==="Identifier"&&w.has(a.name))||w.size>0)&&$(c.body);else if(c.type==="ClassDeclaration")for(const e of c.body.body)e.type==="ClassMethod"&&$(e.body);else if(c.type==="ExportNamedDeclaration"&&c.declaration)$(c.declaration);else if(c.type==="ReturnStatement"&&c.argument)T(c.argument);else if(c.type==="ExportDefaultDeclaration")w.has("__default_router__")&&c.declaration.type==="CallExpression"?T(c.declaration):c.declaration.type==="ClassDeclaration"?$(c.declaration):(c.declaration.type==="FunctionDeclaration"||c.declaration.type==="FunctionExpression"||c.declaration.type==="ArrowFunctionExpression")&&((g=c.declaration.body)==null?void 0:g.type)==="BlockStatement"&&$(c.declaration.body);else if(c.type==="VariableDeclaration")for(const e of c.declarations)e.id.type==="Identifier"&&w.has(e.id.name)&&((m=e.init)==null?void 0:m.type)==="CallExpression"&&E(P,e.init)&&T(e.init),e.init&&(e.init.type==="ArrowFunctionExpression"||e.init.type==="FunctionExpression")&&e.init.body.type==="BlockStatement"&&(e.init.params.some(u=>u.type==="Identifier"&&w.has(u.name))||w.size>0)&&$(e.init.body)}};for(const c of A)$(c);return D};return{isExpressRouterCreation:E,getRouterVarsInFile:b,collectCallsInBlock:j}}function ls(n,t,r){const{nodes:s,addNode:p,addEdge:f}=n,{resolveSymbol:E}=t,{isExpressRouterCreation:x,getRouterVarsInFile:b}=r,j=w=>{const k=[];for(const D of w)if(D.type==="ArrayExpression")for(const _ of D.elements)_&&_.type!=="SpreadElement"&&k.push(...j([_]));else D.type!=="SpreadElement"&&k.push(D);return k};return{flattenArgNodes:j,isRouterSymbol:w=>{if(!w)return null;const{apps:k,routers:D}=b(w.file),_=w.localName??w.name;if(D.has(_)||k.has(_))return _;if(w.node.type==="ClassMethod"&&w.node.kind==="get")return"this";if(x(w.file,w.node))return D.has("__default_router__")?"__default_router__":_;if(w.node.type==="ClassDeclaration"||w.node.type==="ClassExpression"){let q=w.node,B=w.file;for(let V=0;V<4&&q;V++){const{routers:T,apps:$}=b(B);if(T.has("this.app")||T.has("this.router")||$.has("this.app"))return"this";if(q.superClass){const c=E(B,q.superClass,1),i=c?de(c.node):null;if(c&&i&&(i.type==="ClassDeclaration"||i.type==="ClassExpression")){q=i,B=c.file;continue}}break}}if(w.node.type==="FunctionDeclaration"||w.node.type==="FunctionExpression"||w.node.type==="ArrowFunctionExpression"){if(w.node.body.type==="BlockStatement"){for(const q of w.node.body.body)if(q.type==="ReturnStatement"&&q.argument){if(q.argument.type==="Identifier"&&D.has(q.argument.name))return q.argument.name;if(x(w.file,q.argument))return"__default_router__"}}else if(x(w.file,w.node.body))return"__default_router__"}return null},registerRoute:(w,k,D,_,q,B,V)=>{var W,H,N;const T=j(_);if(T.length===0)return;const $=T[T.length-1],c=T.slice(0,-1),i=[...V];for(const C of c){const R=Ge(C);i.includes(R)||i.push(R);const M=`mw:${R}`;p({id:M,type:"middleware",label:R,file:q.path,line:((W=C.loc)==null?void 0:W.start.line)??B})}let g="inlineHandler",m=q.path,e=((H=$.loc)==null?void 0:H.start.line)??B,a=$;if($.type!=="ArrowFunctionExpression"&&$.type!=="FunctionExpression"){let C=$;C.type==="CallExpression"&&/^(?:.*asyncHandler|catchAsync)$/i.test(Ge(C.callee))&&C.arguments[0]&&C.arguments[0].type!=="SpreadElement"&&(C=C.arguments[0]),g=Ge(C);const R=E(q,C);R&&(a=R.node,m=R.file.path,e=R.line)}const u=_t(a),o=(C,R)=>{if(!C)return;const M=de(C);if(M.type==="ObjectExpression"){for(const F of M.properties)if(F.type==="ObjectProperty"){const Z=ae(F.key);Z&&R.add(Z)}}else M.type==="CallExpression"&&M.callee.type==="MemberExpression"&&ae(M.callee.property)==="object"&&M.arguments[0]&&o(M.arguments[0],R)},l=new Set(u.bodyFields),h=new Set(u.queryParams),y=new Set(u.pathParams);for(const C of c)if(C.type==="CallExpression"&&((N=C.arguments[0])==null?void 0:N.type)==="ObjectExpression"){for(const R of C.arguments[0].properties)if(R.type==="ObjectProperty"){const M=ae(R.key);M==="body"?o(R.value,l):M==="query"?o(R.value,h):M==="params"&&o(R.value,y)}}const d=Array.from(new Set([...fe(D),...y])),v=Array.from(h),S=Array.from(l),I=me(D),O=`route:${k}:${D}`,z=s.get(O);z?(z.middlewares=Array.from(new Set([...z.middlewares??[],...i])),z.pathParams=Array.from(new Set([...z.pathParams??[],...d])),z.queryParams=Array.from(new Set([...z.queryParams??[],...v])),z.bodyFields=Array.from(new Set([...z.bodyFields??[],...S])),g!=="inlineHandler"&&(z.controller=g,z.controllerFile=m,z.controllerLine=e)):p({id:O,type:"route",label:`${k} ${D}`,file:q.path,line:B,method:k,fullPath:D,pathParams:d,queryParams:v,bodyFields:S,group:I,middlewares:i,controller:g,controllerFile:m,controllerLine:e}),f({id:`edge:${w}->${O}`,source:w,target:O,type:"handles"});for(const C of i){const R=`mw:${C}`;s.has(R)||p({id:R,type:"middleware",label:C,file:q.path,line:B}),f({id:`edge:${O}->${R}`,source:O,target:R,type:"uses"})}const G=`ctrl:${m}:${g}:${e}`;p({id:G,type:"controller",label:g,file:m,line:e}),f({id:`edge:${O}->${G}`,source:O,target:G,type:"calls"})}}}var cs=class{constructor(){ue(this,"name","express")}detect(n){const t=n.find(r=>oe(r.path)==="package.json");return t&&/"express"\s*:/.test(t.content)?!0:n.some(r=>dt.test(r.path)&&/from\s+['"]express['"]|require\(['"]express['"]\)/.test(r.content))}scan(n,t){const r=performance.now(),s=n.map(d=>({path:oe(d.path),content:d.content})),p=s.filter(d=>dt.test(d.path)&&!pn.test(d.path)),f=new Set(s.map(d=>d.path)),E=et(s),x=new Map;for(const d of p){const v=We(d,f,E);v&&x.set(d.path,v)}const b=Array.from(x.values()),j=os(s,b),P=new Map,A=new Map,w=[],k=d=>{P.has(d.id)||P.set(d.id,d)},D=d=>{A.has(d.id)||A.set(d.id,d)},_={fileSet:f,tsConfig:E,parsedMap:x,nodes:P,addNode:k,addEdge:D},q=as(_),B=is(_,q),V=ls(_,q,B),{resolveSymbol:T}=q,{getRouterVarsInFile:$,collectCallsInBlock:c}=B,{flattenArgNodes:i,isRouterSymbol:g,registerRoute:m}=V,e=new Set,a=(d,v,S,I,O,z)=>{const G=`${d.path}:${Array.from(v).join(",")}:${O}`;if(e.has(G))return;e.add(G);const W=c(d,S,v),H=[...z];for(const N of W)if(N.kind==="use"){const C=N.pathArg?ne(O,N.pathArg):O,R=i(N.args),M=[...H];for(const F of R){const Z=T(d,F),U=g(Z);if(Z&&U){const J=`router:${Z.file.path}:${C||"/"}`;k({id:J,type:"router",label:C||Z.name,file:Z.file.path,line:Z.line}),D({id:`edge:${I}->${J}`,source:I,target:J,type:"mounts",label:N.pathArg??"/"});let K=Z.file,Q=Z.file.ast.program.body;if(F.type==="MemberExpression"&&F.object.type==="NewExpression"){const re=T(d,F.object.callee);re&&(re.node.type==="ClassDeclaration"||re.node.type==="ClassExpression")&&(K=re.file,Q=re.file.ast.program.body)}const te=new Set([U]);Z.node.type==="ClassDeclaration"||Z.node.type==="ClassExpression"?(Q=[Z.node],te.add("this"),te.add("this.app"),te.add("this.router")):(Z.node.type==="FunctionDeclaration"||Z.node.type==="FunctionExpression"||Z.node.type==="ArrowFunctionExpression")&&(Z.node.body.type==="BlockStatement"?Q=Z.node.body.body:Q=[{type:"ExpressionStatement",expression:Z.node.body}]),a(K,te,Q,J,C,M)}else if(F.type==="CallExpression"&&F.callee.type==="MemberExpression"&&ae(F.callee.property)==="readdirSync")w.push(`${d.path}:${N.line} (dynamic fs.readdirSync mount)`);else{const J=Ge(F);J&&J!=="anonymous"&&!J.startsWith("express.")&&!M.includes(J)&&(M.push(J),N.pathArg||H.push(J))}}}else if(N.kind==="delegate"&&N.delegateCallee&&N.delegateArgIndex!==void 0){const C=T(d,N.delegateCallee);if(C&&(C.node.type==="FunctionDeclaration"||C.node.type==="FunctionExpression"||C.node.type==="ArrowFunctionExpression")&&C.node.body.type==="BlockStatement"){const R=C.node.params[N.delegateArgIndex];let M=null;if(!N.delegatePropKey&&(R==null?void 0:R.type)==="Identifier")M=R.name;else if(N.delegatePropKey&&(R==null?void 0:R.type)==="ObjectPattern"){for(const F of R.properties)if(F.type==="ObjectProperty"&&ae(F.key)===N.delegatePropKey&&F.value.type==="Identifier"){M=F.value.name;break}}M&&a(C.file,new Set([M]),C.node.body.body,I,O,H)}}else if(N.kind==="method"){if(N.dynamicPath||N.pathArg===void 0){w.push(`${d.path}:${N.line} (dynamic route path)`);continue}const C=ne(O,N.pathArg),R=N.methodName.toUpperCase();m(I,R,C,N.args,d,N.line,H)}else if(N.kind==="route-chain"&&N.chainCalls){if(N.dynamicPath||N.pathArg===void 0){w.push(`${d.path}:${N.line} (dynamic .route() path)`);continue}const C=ne(O,N.pathArg);for(const R of N.chainCalls){const M=R.methodName.toUpperCase();m(I,M,C,R.args,d,R.line,H)}}},u=[];for(const d of b){const{apps:v}=$(d);v.size>0&&u.push({pf:d,apps:v})}const o=new Set;if(u.length>1)for(const{pf:d}of u)for(const v of d.imports.values())v.resolvedFile&&o.add(v.resolvedFile);const l=u.filter(d=>!o.has(d.pf.path)),h=l.length>0?l:u;if(h.length>0)for(const{pf:d,apps:v}of h){const S=`entry:${d.path}`;k({id:S,type:"entry",label:d.path,file:d.path,line:1}),a(d,v,d.ast.program.body,S,"",[])}else for(const d of b){const{routers:v}=$(d);if(v.size>0){const S=`router:${d.path}:/`;k({id:S,type:"router",label:d.path,file:d.path,line:1}),a(d,v,d.ast.program.body,S,"",[])}}const y=Math.round((performance.now()-r)*100)/100;return{version:"1.0",metadata:{repoName:(t==null?void 0:t.repoName)??"express-app",framework:"express",detectedPort:j,scannedFiles:p.length,scanDurationMs:y,unresolvedMounts:w},nodes:Array.from(P.values()),edges:Array.from(A.values())}}},ht=new Set(["get","post","put","patch","delete","options","head","all"]),Mt=/\.(ts|tsx|js|jsx|mjs|cjs)$/i,Tt=/(\.test\.|\.spec\.|__tests__|__mocks__)/i;function we(n){let t=n;for(;t.type==="TSAsExpression"||t.type==="TSSatisfiesExpression"||t.type==="TSTypeAssertion"||t.type==="ParenthesizedExpression";)t=t.expression;return t}function ye(n){return n?n.type==="Identifier"?n.name:n.type==="StringLiteral"?n.value:null:null}function Je(n){if(n.type==="Identifier")return n.name;if(n.type==="MemberExpression"){const t=Je(n.object),r=ye(n.property)??"";return t?`${t}.${r}`:r}return n.type==="CallExpression"?Je(n.callee):"anonymous"}function ps(n){var E;const t=new Set,r=new Set,s=new Set;if(n.type!=="FunctionDeclaration"&&n.type!=="FunctionExpression"&&n.type!=="ArrowFunctionExpression"&&n.type!=="ObjectMethod"&&n.type!=="ClassMethod")return{pathParams:[],queryParams:[],bodyFields:[]};const p=((E=n.params[0])==null?void 0:E.type)==="Identifier"?n.params[0].name:"c",f=x=>{var b;if(!(!x||typeof x!="object")){if(x.type==="CallExpression"&&x.callee.type==="MemberExpression"&&x.callee.object.type==="MemberExpression"&&x.callee.object.object.type==="Identifier"&&x.callee.object.object.name===p&&ye(x.callee.object.property)==="req"){const j=ye(x.callee.property),P=x.arguments[0],A=(P==null?void 0:P.type)==="StringLiteral"?P.value:null;j==="param"&&A?t.add(A):(j==="query"||j==="queries")&&A&&r.add(A)}if(x.type==="VariableDeclarator"&&x.init&&x.id.type==="ObjectPattern"){const j=x.init.type==="AwaitExpression"?x.init.argument:x.init;if(j.type==="CallExpression"&&j.callee.type==="MemberExpression"&&j.callee.object.type==="MemberExpression"&&j.callee.object.object.type==="Identifier"&&j.callee.object.object.name===p&&ye(j.callee.object.property)==="req"){const P=ye(j.callee.property);let A=null;if(P==="json"||P==="parseBody")A=s;else if(P==="query"||P==="queries")A=r;else if(P==="param")A=t;else if(P==="valid"&&((b=j.arguments[0])==null?void 0:b.type)==="StringLiteral"){const w=j.arguments[0].value;w==="json"||w==="form"?A=s:w==="query"?A=r:w==="param"&&(A=t)}if(A){for(const w of x.id.properties)if(w.type==="ObjectProperty"){const k=ye(w.key);k&&A.add(k)}}}}for(const j of Object.keys(x)){if(j==="loc"||j==="start"||j==="end"||j==="extra")continue;const P=x[j];if(Array.isArray(P))for(const A of P)A&&typeof A=="object"&&"type"in A&&f(A);else P&&typeof P=="object"&&"type"in P&&f(P)}}};return f(n.body),{pathParams:Array.from(t),queryParams:Array.from(r),bodyFields:Array.from(s)}}var us=class{constructor(){ue(this,"name","hono")}detect(n){const t=n.find(r=>oe(r.path)==="package.json");return t&&/"(?:hono|@hono\/[^"]+)"\s*:/.test(t.content)?!0:n.some(r=>Mt.test(r.path)&&!Tt.test(r.path)&&/from\s+['"](?:hono(?:\/[^'"]*)?|@hono\/[^'"]+)['"]|require\(\s*['"](?:hono(?:\/[^'"]*)?|@hono\/[^'"]+)['"]\s*\)/.test(r.content))}scan(n,t){const r=performance.now(),s=n.map(e=>({path:oe(e.path),content:e.content})),p=s.filter(e=>Mt.test(e.path)&&!Tt.test(e.path)),f=new Set(s.map(e=>e.path)),E=et(s),x=new Map;for(const e of p){const a=We(e,f,E);a&&x.set(e.path,a)}const b=Array.from(x.values()),j=new Map,P=new Map,A=[],w=e=>{j.has(e.id)||j.set(e.id,e)},k=e=>{P.has(e.id)||P.set(e.id,e)},D=(e,a,u=0)=>{var l,h;if(u>8)return null;const o=we(a);if(o.type==="Identifier"){const y=e.imports.get(o.name);if(y!=null&&y.resolvedFile){const v=x.get(y.resolvedFile);if(!v)return null;if(y.importedName==="*")return{file:v,node:v.ast.program,name:o.name,line:1};const S=v.exports.get(y.importedName);if(S)return S.node.type==="Identifier"&&S.node.name!==o.name?D(v,S.node,u+1)??{file:v,node:S.node,name:y.importedName,localName:S.localName,line:S.line}:{file:v,node:S.node,name:y.importedName==="default"?o.name:y.importedName,localName:S.localName,line:S.line};for(const I of v.reExports)if(I.resolvedFile&&(I.exportedName==="*"||I.exportedName===y.importedName)){const O=x.get(I.resolvedFile),z=I.exportedName==="*"?y.importedName:I.importedName,G=O==null?void 0:O.exports.get(z);if(O&&G)return{file:O,node:G.node,name:z,localName:G.localName,line:G.line}}}const d=e.locals.get(o.name);if(d)return{file:e,node:d,name:o.name,line:((l=d.loc)==null?void 0:l.start.line)??1}}if(o.type==="MemberExpression"){const y=ye(o.property);if(!y)return null;const d=D(e,o.object,u+1);if(!d)return null;const v=we(d.node);if(v.type==="Program"){const S=d.file.exports.get(y);if(S)return{file:d.file,node:S.node,name:`${d.name}.${y}`,line:S.line}}if(v.type==="ObjectExpression"){for(const S of v.properties)if(S.type==="ObjectProperty"&&ye(S.key)===y)return{file:d.file,node:S.value,name:`${d.name}.${y}`,line:((h=S.loc)==null?void 0:h.start.line)??1}}}if(o.type==="CallExpression"){const y=D(e,o.callee,u+1);if(y&&(y.node.type==="FunctionDeclaration"||y.node.type==="FunctionExpression"||y.node.type==="ArrowFunctionExpression"))return y}return null},_=(e,a,u=0)=>{if(!a||u>8)return null;const o=we(a);if(o.type==="StringLiteral")return o.value;if(o.type==="TemplateLiteral"){let l="";for(let h=0;h<o.quasis.length;h++)if(l+=o.quasis[h].value.cooked??o.quasis[h].value.raw,h<o.expressions.length){const y=_(e,o.expressions[h],u+1);if(y===null)return null;l+=y}return l}if(o.type==="BinaryExpression"&&o.operator==="+"){const l=_(e,o.left,u+1),h=_(e,o.right,u+1);return l!==null&&h!==null?l+h:null}if(o.type==="Identifier"||o.type==="MemberExpression"){const l=D(e,o);if(l)return _(l.file,l.node,u+1)}return null},q=(e,a,u=0)=>{if(u>4)return{isHono:!1};let o=we(a),l;for(;o.type==="CallExpression"&&o.callee.type==="MemberExpression";){const h=ye(o.callee.property);if(h==="basePath"){l=_(e,o.arguments[0])??l,o=we(o.callee.object);continue}if(h==="route"||h==="use"||h==="on"||h==="openapi"||ht.has(h??"")){o=we(o.callee.object);continue}break}if(o.type==="NewExpression"&&o.callee.type==="Identifier"){const h=e.imports.get(o.callee.name);if(h&&(h.sourceSpecifier==="hono"||h.sourceSpecifier.startsWith("hono/")||h.sourceSpecifier==="@hono/zod-openapi"))return{isHono:!0,basePath:l};if(o.callee.name==="Hono"||o.callee.name==="OpenAPIHono")return{isHono:!0,basePath:l}}if(o.type==="CallExpression"&&o.callee.type==="MemberExpression"&&ye(o.callee.property)==="createApp")return{isHono:!0,basePath:l};if(o.type==="CallExpression"){const h=D(e,o.callee);if(h&&(h.node.type==="FunctionDeclaration"||h.node.type==="FunctionExpression"||h.node.type==="ArrowFunctionExpression")){if(h.node.body.type==="BlockStatement"){for(const y of h.node.body.body)if(y.type==="ReturnStatement"&&y.argument){if(q(h.file,y.argument,u+1).isHono)return{isHono:!0,basePath:l};if(y.argument.type==="Identifier"){const d=h.file.locals.get(y.argument.name);if(d&&q(h.file,d,u+1).isHono)return{isHono:!0,basePath:l}}}}else if(q(h.file,h.node.body,u+1).isHono)return{isHono:!0,basePath:l}}}return{isHono:!1}},B=e=>{const a=new Map,u=l=>{if(!(!l||typeof l!="object")){if(l.type==="VariableDeclarator"&&l.id.type==="Identifier"&&l.init){const h=q(e,l.init);h.isHono&&a.set(l.id.name,h.basePath)}for(const h of Object.keys(l)){if(h==="loc"||h==="start"||h==="end"||h==="extra")continue;const y=l[h];if(Array.isArray(y))for(const d of y)d&&typeof d=="object"&&"type"in d&&u(d);else y&&typeof y=="object"&&"type"in y&&u(y)}}};u(e.ast.program);const o=e.exports.get("default");if(o){const l=q(e,o.node);l.isHono&&a.set("__default_hono__",l.basePath)}return a},V=(e,a,u,o,l,h,y)=>{var M;if(o.length===0)return;const d=o[o.length-1],v=o.slice(0,-1),S=[...y];for(const F of v){const Z=Je(F);Z&&Z!=="anonymous"&&!S.includes(Z)&&S.push(Z)}let I="inlineHandler",O=l.path,z=((M=d.loc)==null?void 0:M.start.line)??h,G=d;if(d.type!=="ArrowFunctionExpression"&&d.type!=="FunctionExpression"){I=Je(d);const F=D(l,d);F&&(G=F.node,O=F.file.path,z=F.line)}const W=ps(G),H=Array.from(new Set([...fe(u),...W.pathParams])),N=me(u),C=`route:${a}:${u}`;w({id:C,type:"route",label:`${a} ${u}`,file:l.path,line:h,method:a,fullPath:u,pathParams:H,queryParams:W.queryParams,bodyFields:W.bodyFields,group:N,middlewares:S,controller:I,controllerFile:O,controllerLine:z}),k({id:`edge:${e}->${C}`,source:e,target:C,type:"handles"});for(const F of S){const Z=`mw:${F}`;w({id:Z,type:"middleware",label:F,file:l.path,line:h}),k({id:`edge:${C}->${Z}`,source:C,target:Z,type:"uses"})}const R=`ctrl:${O}:${I}:${z}`;w({id:R,type:"controller",label:I,file:O,line:z}),k({id:`edge:${C}->${R}`,source:C,target:R,type:"calls"})},T=new Set,$=(e,a,u,o,l,h)=>{const y=`${e.path}:${Array.from(a).join(",")}:${l}`;if(T.has(y))return;T.add(y);const d=[...h],v=(I,O)=>{var C,R,M;const z=F=>O&&F.type==="Identifier"&&O.has(F.name)?O.get(F.name):F;if(I.callee.type==="MemberExpression"&&ye(I.callee.property)==="forEach"&&I.arguments[0]&&(I.arguments[0].type==="ArrowFunctionExpression"||I.arguments[0].type==="FunctionExpression")){const F=I.arguments[0],Z=F.params[0],U=we(I.callee.object),J=U.type==="ArrayExpression"?{node:U}:D(e,U),K=J?we(J.node):null;if((K==null?void 0:K.type)==="ArrayExpression"&&(Z==null?void 0:Z.type)==="Identifier"){const Q=F.body.type==="BlockStatement"?F.body.body:[{type:"ExpressionStatement",expression:F.body}];for(const te of K.elements)if(te&&te.type!=="SpreadElement"){const re=new Map([[Z.name,te]]);for(const ie of Q)ie.type==="ExpressionStatement"&&ie.expression.type==="CallExpression"&&v(ie.expression,re)}return}}const G=[];let W=I;for(;W.type==="CallExpression"&&W.callee.type==="MemberExpression";){const F=ye(W.callee.property);if(!F||F!=="route"&&F!=="use"&&F!=="on"&&F!=="openapi"&&F!=="basePath"&&!ht.has(F))break;G.push({methodName:F,args:W.arguments.map(z),line:((C=W.loc)==null?void 0:C.start.line)??1}),W=we(W.callee.object)}if(G.length===0)return;let H=!1;if(W.type==="Identifier"&&a.has(W.name))H=!0;else if(a.has("__default_hono__")&&q(e,W).isHono)H=!0;else for(const F of a)if(e.locals.get(F)===I){H=!0;break}if(!H)return;let N=l;for(const F of G.reverse())if(F.methodName==="basePath"){const Z=_(e,F.args[0]);Z&&(N=ne(N,Z))}else if(F.methodName==="use"){const U=_(e,F.args[0])!==null?F.args.slice(1):F.args;for(const J of U){const K=Je(J);K&&K!=="anonymous"&&!d.includes(K)&&d.push(K)}}else if(F.methodName==="route"){const Z=_(e,F.args[0]),U=F.args[1];if(Z!==null&&U){const J=ne(N,Z),K=D(e,U);if(K){const Q=B(K.file),te=K.localName??K.name,re=Q.has(te)?te:Q.has("__default_hono__")?"__default_hono__":null;if(re){const ie=Q.get(re),Y=ie?ne(J,ie):J,se=`router:${K.file.path}:${Y||"/"}`;w({id:se,type:"router",label:Y||K.name,file:K.file.path,line:K.line}),k({id:`edge:${o}->${se}`,source:o,target:se,type:"mounts",label:Z});const ee=(K.node.type==="FunctionDeclaration"||K.node.type==="FunctionExpression"||K.node.type==="ArrowFunctionExpression")&&K.node.body.type==="BlockStatement"?K.node.body.body:K.file.ast.program.body;$(K.file,new Set([re]),ee,se,Y,d)}else A.push(`${e.path}:${F.line} (unresolved Hono .route() target)`)}else A.push(`${e.path}:${F.line} (unresolved Hono .route() target)`)}else A.push(`${e.path}:${F.line} (dynamic Hono .route() mount)`)}else if(F.methodName==="on"){const Z=F.args[0],U=[];if((Z==null?void 0:Z.type)==="StringLiteral")U.push(Z.value.toUpperCase());else if((Z==null?void 0:Z.type)==="ArrayExpression")for(const K of Z.elements)(K==null?void 0:K.type)==="StringLiteral"&&U.push(K.value.toUpperCase());const J=_(e,F.args[1]);if(J!==null&&U.length>0){const K=ne(N,J);for(const Q of U)V(o,Q,K,F.args.slice(2),e,F.line,d)}}else if(F.methodName==="openapi"){const Z=F.args[0]?D(e,F.args[0]):null;if(Z&&Z.node.type==="CallExpression"&&((R=Z.node.arguments[0])==null?void 0:R.type)==="ObjectExpression"){let U=null,J=null;for(const K of Z.node.arguments[0].properties)if(K.type==="ObjectProperty"){const Q=ye(K.key);Q==="method"&&(U=((M=_(Z.file,K.value))==null?void 0:M.toUpperCase())??null),Q==="path"&&(J=_(Z.file,K.value))}if(U&&J!==null){const K=ne(N,J.replace(/\{([^}]+)\}/g,":$1"));V(o,U,K,F.args.slice(1),e,F.line,d)}}}else if(ht.has(F.methodName)){const Z=_(e,F.args[0]);if(Z!==null){const U=ne(N,Z);V(o,F.methodName.toUpperCase(),U,F.args.slice(1),e,F.line,d)}else A.push(`${e.path}:${F.line} (dynamic Hono route path)`)}},S=I=>{var O,z;if(I)if(I.type==="ExpressionStatement"){const G=I.expression.type==="AwaitExpression"?I.expression.argument:I.expression;G.type==="CallExpression"&&v(G)}else if(I.type==="BlockStatement")for(const G of I.body)S(G);else if(I.type==="IfStatement")S(I.consequent),S(I.alternate);else if(I.type==="VariableDeclaration")for(const G of I.declarations)((O=G.init)==null?void 0:O.type)==="CallExpression"&&v(G.init);else I.type==="ExportDefaultDeclaration"?I.declaration.type==="CallExpression"?v(I.declaration):(I.declaration.type==="FunctionDeclaration"||I.declaration.type==="FunctionExpression"||I.declaration.type==="ArrowFunctionExpression")&&((z=I.declaration.body)==null?void 0:z.type)==="BlockStatement"&&S(I.declaration.body):I.type==="FunctionDeclaration"&&I.body&&S(I.body)};for(const I of u)S(I)},c=[];for(const e of b){const a=B(e);a.size>0&&c.push({pf:e,apps:a})}const i=new Set;if(c.length>1)for(const{pf:e}of c)for(const a of e.imports.values())a.resolvedFile&&i.add(a.resolvedFile);const g=c.filter(e=>!i.has(e.pf.path)),m=g.length>0?g:c;for(const{pf:e,apps:a}of m){const u=`entry:${e.path}`;w({id:u,type:"entry",label:e.path,file:e.path,line:1});for(const[o,l]of a.entries())$(e,new Set([o]),e.ast.program.body,u,l??"",[])}return{version:"1.0",metadata:{repoName:(t==null?void 0:t.repoName)??"hono-app",framework:"hono",scannedFiles:p.length,scanDurationMs:Math.round((performance.now()-r)*100)/100,unresolvedMounts:A},nodes:Array.from(j.values()),edges:Array.from(P.values())}}},ds=new Set(["get","post","put","patch","delete","options","head","all"]),Ct=/\.(ts|tsx|js|jsx|mjs|cjs)$/i,It=/(\.test\.|\.spec\.|__tests__|__mocks__)/i;function De(n){let t=n;for(;t.type==="TSAsExpression"||t.type==="TSSatisfiesExpression"||t.type==="TSTypeAssertion"||t.type==="ParenthesizedExpression";)t=t.expression;return t}function he(n){return n?n.type==="Identifier"?n.name:n.type==="StringLiteral"?n.value:null:null}function Le(n){if(n.type==="Identifier")return n.name;if(n.type==="MemberExpression"){const t=Le(n.object),r=he(n.property)??"";return t?`${t}.${r}`:r}return n.type==="CallExpression"?Le(n.callee):"anonymous"}function yt(n,t){if(!n)return;const r=De(n);if(r.type==="ObjectExpression"){for(const s of r.properties)if(s.type==="ObjectProperty"&&he(s.key)==="properties"){const p=De(s.value);if(p.type==="ObjectExpression"){for(const f of p.properties)if(f.type==="ObjectProperty"){const E=he(f.key);E&&t.add(E)}}}}}var fs=class{constructor(){ue(this,"name","fastify")}detect(n){const t=n.find(r=>oe(r.path)==="package.json");return t&&/"fastify"\s*:/.test(t.content)?!0:n.some(r=>Ct.test(r.path)&&!It.test(r.path)&&/from\s+['"]fastify['"]|require\(\s*['"]fastify['"]\s*\)/.test(r.content))}scan(n,t){const r=performance.now(),s=n.map($=>({path:oe($.path),content:$.content})),p=s.filter($=>Ct.test($.path)&&!It.test($.path)),f=new Set(s.map($=>$.path)),E=et(s),x=new Map;for(const $ of p){const c=We($,f,E);c&&x.set($.path,c)}const b=Array.from(x.values()),j=new Map,P=new Map,A=[],w=$=>{j.has($.id)||j.set($.id,$)},k=$=>{P.has($.id)||P.set($.id,$)},D=($,c,i=0)=>{var m,e,a;if(i>8)return null;const g=De(c);if(g.type==="Identifier"){const u=$.imports.get(g.name);if(u!=null&&u.resolvedFile){const l=x.get(u.resolvedFile);if(!l)return null;if(u.importedName==="*")return{file:l,node:l.ast.program,name:g.name,line:1};const h=l.exports.get(u.importedName);if(h)return h.node.type==="Identifier"&&h.node.name!==g.name?D(l,h.node,i+1)??{file:l,node:h.node,name:u.importedName,localName:h.localName,line:h.line}:{file:l,node:h.node,name:u.importedName==="default"?g.name:u.importedName,localName:h.localName,line:h.line}}const o=$.locals.get(g.name);if(o)return{file:$,node:o,name:g.name,line:((m=o.loc)==null?void 0:m.start.line)??1}}if(g.type==="MemberExpression"){const u=he(g.property);if(!u)return null;const o=D($,g.object,i+1);if(!o)return null;const l=De(o.node);if(l.type==="Program"){const h=o.file.exports.get(u);if(h)return{file:o.file,node:h.node,name:`${o.name}.${u}`,line:h.line}}if(l.type==="ObjectExpression"){for(const h of l.properties)if(h.type==="ObjectProperty"&&he(h.key)===u)return{file:o.file,node:h.value,name:`${o.name}.${u}`,line:((e=h.loc)==null?void 0:e.start.line)??1}}}if(g.type==="CallExpression"){const u=ze(g);if(u){const o=Ce($.path,u,f,E),l=o?x.get(o):void 0,h=l==null?void 0:l.exports.get("default");if(l&&h)return{file:l,node:h.node,name:u,localName:h.localName,line:h.line}}if(g.arguments[0]&&g.arguments[0].type!=="SpreadElement"){const o=g.arguments[0];if(o.type==="FunctionExpression"||o.type==="ArrowFunctionExpression")return{file:$,node:o,name:Le(g.callee),line:((a=o.loc)==null?void 0:a.start.line)??1}}}return null},_=($,c,i=0)=>{if(!c||i>8)return null;const g=De(c);if(g.type==="StringLiteral")return g.value;if(g.type==="TemplateLiteral"){let m="";for(let e=0;e<g.quasis.length;e++)if(m+=g.quasis[e].value.cooked??g.quasis[e].value.raw,e<g.expressions.length){const a=_($,g.expressions[e],i+1);if(a===null)return null;m+=a}return m}if(g.type==="BinaryExpression"&&g.operator==="+"){const m=_($,g.left,i+1),e=_($,g.right,i+1);return m!==null&&e!==null?m+e:null}if(g.type==="Identifier"||g.type==="MemberExpression"){const m=D($,g);if(m)return _(m.file,m.node,i+1)}return null},q=$=>{const c=new Set,i=new Set;for(const[m,e]of $.imports.entries())e.sourceSpecifier==="fastify"&&(e.importedName==="default"||e.importedName==="*")&&i.add(m);const g=m=>{if(!(!m||typeof m!="object")){if(m.type==="VariableDeclarator"&&m.id.type==="Identifier"&&m.init){const e=De(m.init);e.type==="CallExpression"&&e.callee.type==="Identifier"&&i.has(e.callee.name)&&c.add(m.id.name)}for(const e of Object.keys(m)){if(e==="loc"||e==="start"||e==="end"||e==="extra")continue;const a=m[e];if(Array.isArray(a))for(const u of a)u&&typeof u=="object"&&"type"in u&&g(u);else a&&typeof a=="object"&&"type"in a&&g(a)}}};return g($.ast.program),c},B=($,c,i,g,m,e,a,u)=>{var R;const o=[...u],l=new Set,h=new Set,y=new Set;if(m){for(const M of m.properties)if(M.type==="ObjectProperty"){const F=he(M.key);if(F==="preHandler"||F==="onRequest")if(M.value.type==="ArrayExpression")for(const Z of M.value.elements)Z&&Z.type!=="SpreadElement"&&o.push(Le(Z));else o.push(Le(M.value));else if(F==="schema"&&M.value.type==="ObjectExpression"){for(const Z of M.value.properties)if(Z.type==="ObjectProperty"){const U=he(Z.key);U==="body"?yt(Z.value,l):U==="querystring"||U==="query"?yt(Z.value,h):U==="params"&&yt(Z.value,y)}}}}let d="inlineHandler",v=e.path,S=((R=g.loc)==null?void 0:R.start.line)??a,I=g;if(g.type!=="ArrowFunctionExpression"&&g.type!=="FunctionExpression"&&g.type!=="ObjectMethod"){d=Le(g);const M=D(e,g);M&&(I=M.node,v=M.file.path,S=M.line)}const O=_t(I),z=Array.from(new Set([...fe(i),...O.pathParams,...y])),G=Array.from(new Set([...O.queryParams,...h])),W=Array.from(new Set([...O.bodyFields,...l])),H=me(i),N=`route:${c}:${i}`;w({id:N,type:"route",label:`${c} ${i}`,file:e.path,line:a,method:c,fullPath:i,pathParams:z,queryParams:G,bodyFields:W,group:H,middlewares:o,controller:d,controllerFile:v,controllerLine:S}),k({id:`edge:${$}->${N}`,source:$,target:N,type:"handles"});for(const M of o){const F=`mw:${M}`;w({id:F,type:"middleware",label:M,file:e.path,line:a}),k({id:`edge:${N}->${F}`,source:N,target:F,type:"uses"})}const C=`ctrl:${v}:${d}:${S}`;w({id:C,type:"controller",label:d,file:v,line:S}),k({id:`edge:${N}->${C}`,source:N,target:C,type:"calls"})},V=new Set,T=($,c,i,g,m,e)=>{const a=`${$.path}:${Array.from(c).join(",")}:${m}`;if(V.has(a))return;V.add(a);const u=l=>{var d,v,S,I,O,z,G;if(l.callee.type!=="MemberExpression"||l.callee.object.type!=="Identifier"||!c.has(l.callee.object.name))return;const h=he(l.callee.property),y=((d=l.loc)==null?void 0:d.start.line)??1;if(h){if(h==="register"){const W=l.arguments[0],H=((v=l.arguments[1])==null?void 0:v.type)==="ObjectExpression"?l.arguments[1]:null;let N="",C;if(H){for(const M of H.properties)if(M.type==="ObjectProperty"){const F=he(M.key);if(F==="prefix"&&(N=_($,M.value)??""),F==="dir"&&(C=M.value),F==="options"&&M.value.type==="ObjectExpression")for(const Z of M.value.properties)Z.type==="ObjectProperty"&&he(Z.key)==="prefix"&&(N=_($,Z.value)??N)}}const R=N?ne(m,N):m;if(C){let M=null;if(C.type==="CallExpression"&&(C.callee.type==="MemberExpression"&&he(C.callee.property)==="join"||C.callee.type==="Identifier"&&C.callee.name==="join")){const F=[];for(const Z of C.arguments){if(Z.type==="Identifier"&&Z.name==="__dirname")continue;const U=_($,Z);U!==null&&F.push(U)}F.length>0&&(M=F.join("/"))}else M=_($,C);if(M){const F=oe(le(Re($.path),M)),Z=F?`${F}/`:"";for(const U of b)if(U.path.startsWith(Z)){const J=U.exports.get("default");let K=J==null?void 0:J.node;if((K==null?void 0:K.type)==="CallExpression"&&K.arguments[0]&&K.arguments[0].type!=="SpreadElement"&&(K=K.arguments[0]),K&&(K.type==="FunctionDeclaration"||K.type==="FunctionExpression"||K.type==="ArrowFunctionExpression")&&K.body.type==="BlockStatement"){const Q=((S=K.params[0])==null?void 0:S.type)==="Identifier"?K.params[0].name:"fastify",te=`router:${U.path}:${R||"/"}`;w({id:te,type:"router",label:R||U.path,file:U.path,line:(J==null?void 0:J.line)??1}),k({id:`edge:${g}->${te}`,source:g,target:te,type:"mounts"}),T(U,new Set([Q]),K.body.body,te,R,e)}}return}}if(W){const M=D($,W);if(M&&(M.node.type==="FunctionDeclaration"||M.node.type==="FunctionExpression"||M.node.type==="ArrowFunctionExpression")&&M.node.body.type==="BlockStatement"){const F=((I=M.node.params[0])==null?void 0:I.type)==="Identifier"?M.node.params[0].name:"fastify",Z=`router:${M.file.path}:${R||"/"}`;w({id:Z,type:"router",label:R||M.name,file:M.file.path,line:M.line}),k({id:`edge:${g}->${Z}`,source:g,target:Z,type:"mounts",label:N||"/"}),T(M.file,new Set([F]),M.node.body.body,Z,R,e)}else A.push(`${$.path}:${((O=l.loc)==null?void 0:O.start.line)??1} (unresolved Fastify plugin)`)}return}if(h==="route"&&((z=l.arguments[0])==null?void 0:z.type)==="ObjectExpression"){const W=l.arguments[0];let H=[],N=null,C;for(const R of W.properties)if(R.type==="ObjectProperty"){const M=he(R.key);if(M==="method")if(R.value.type==="ArrayExpression")for(const F of R.value.elements){const Z=_($,F);Z&&H.push(Z.toUpperCase())}else{const F=_($,R.value);F&&H.push(F.toUpperCase())}else M==="url"||M==="path"?N=_($,R.value):M==="handler"&&(C=R.value)}else R.type==="ObjectMethod"&&he(R.key)==="handler"&&(C=R);if(N!==null&&C&&H.length>0){const R=ne(m,N);for(const M of H)B(g,M,R,C,W,$,y,e)}return}if(ds.has(h)){const W=_($,l.arguments[0]);if(W===null){A.push(`${$.path}:${y} (dynamic Fastify route path)`);return}const H=ne(m,W),N=((G=l.arguments[1])==null?void 0:G.type)==="ObjectExpression"?l.arguments[1]:null,C=N?l.arguments[2]:l.arguments[1];C&&B(g,h.toUpperCase(),H,C,N,$,y,e)}}},o=l=>{if(l){if(l.type==="ExpressionStatement"){const h=l.expression.type==="AwaitExpression"?l.expression.argument:l.expression;h.type==="CallExpression"&&u(h)}else if(l.type==="BlockStatement")for(const h of l.body)o(h);else if(l.type==="IfStatement")o(l.consequent),o(l.alternate);else if(l.type==="FunctionDeclaration"&&l.body)o(l.body);else if(l.type==="VariableDeclaration")for(const h of l.declarations)h.init&&(h.init.type==="ArrowFunctionExpression"||h.init.type==="FunctionExpression")&&h.init.body.type==="BlockStatement"&&o(h.init.body)}};for(const l of i)o(l)};for(const $ of b){const c=q($);if(c.size>0){const i=`entry:${$.path}`;w({id:i,type:"entry",label:$.path,file:$.path,line:1}),T($,c,$.ast.program.body,i,"",[])}}return{version:"1.0",metadata:{repoName:(t==null?void 0:t.repoName)??"fastify-app",framework:"fastify",scannedFiles:p.length,scanDurationMs:Math.round((performance.now()-r)*100)/100,unresolvedMounts:A},nodes:Array.from(j.values()),edges:Array.from(P.values())}}},Ft={Get:"GET",Post:"POST",Put:"PUT",Patch:"PATCH",Delete:"DELETE",Options:"OPTIONS",Head:"HEAD",All:"ALL"},gt=/\.(ts|tsx|js|jsx|mjs|cjs)$/i,Rt=/(\.test\.|\.spec\.|__tests__|__mocks__)/i;function Ye(n){return n?n.type==="Identifier"?n.name:n.type==="StringLiteral"?n.value:null:null}function pt(n){return n?n.type==="StringLiteral"?n.value:n.type==="TemplateLiteral"&&n.expressions.length===0?n.quasis.map(t=>t.value.cooked??t.value.raw).join(""):null:null}function ft(n){if(n.type==="Identifier")return n.name;if(n.type==="MemberExpression"){const t=ft(n.object),r=Ye(n.property)??"";return t?`${t}.${r}`:r}return n.type==="CallExpression"?ft(n.callee):"anonymous"}function zt(n){if(n.expression.type!=="CallExpression")return[""];const t=n.expression.arguments[0];if(!t)return[""];const r=pt(t);if(r!==null)return[r];if(t.type==="ArrayExpression"){const s=[];for(const p of t.elements)if(p&&p.type!=="SpreadElement"){const f=pt(p);f!==null&&s.push(f)}return s.length>0?s:[""]}if(t.type==="ObjectExpression"){for(const s of t.properties)if(s.type==="ObjectProperty"&&Ye(s.key)==="path"){const p=pt(s.value);if(p!==null)return[p]}}return[""]}function xt(n){return n.expression.type==="CallExpression"&&n.expression.callee.type==="Identifier"?n.expression.callee.name:n.expression.type==="Identifier"?n.expression.name:null}var ms=class{constructor(){ue(this,"name","nestjs")}detect(n){const t=n.find(r=>oe(r.path)==="package.json");return t&&/"@nestjs\/(?:common|core)"\s*:/.test(t.content)?!0:n.some(r=>gt.test(r.path)&&!Rt.test(r.path)&&/from\s+['"]@nestjs\/common['"]/.test(r.content))}scan(n,t){var V,T,$,c,i,g,m;const r=performance.now(),s=n.map(e=>({path:oe(e.path),content:e.content})),p=s.filter(e=>gt.test(e.path)&&!Rt.test(e.path)),f=new Set(s.map(e=>e.path)),E=et(s),x=new Map;for(const e of p){const a=We(e,f,E);a&&x.set(e.path,a)}const b=Array.from(x.values()),j=new Map,P=new Map,A=e=>{j.has(e.id)||j.set(e.id,e)},w=e=>{P.has(e.id)||P.set(e.id,e)},k=new Map;for(const e of b)for(const a of e.ast.program.body){const u=a.type==="ExportNamedDeclaration"&&a.declaration?a.declaration:a;if(u.type==="ClassDeclaration"&&u.id){const o=[];for(const l of u.body.body)if(l.type==="ClassProperty"){const h=Ye(l.key);h&&o.push(h)}o.length>0&&k.set(u.id.name,o)}else if(u.type==="TSInterfaceDeclaration"){const o=[];for(const l of u.body.body)if(l.type==="TSPropertySignature"){const h=Ye(l.key);h&&o.push(h)}o.length>0&&k.set(u.id.name,o)}}let D="",_="main.ts",q;for(const e of s){if(!gt.test(e.path))continue;const a=e.content.match(/\.setGlobalPrefix\(\s*['"`]([^'"`]+)['"`]/);a&&(D=a[1],_=e.path);const u=e.content.match(/\.listen\(\s*(\d{2,5})\b/);u&&!q&&(q=Number(u[1]))}const B=`entry:${_}`;A({id:B,type:"entry",label:_,file:_,line:1});for(const e of b)for(const a of e.ast.program.body){const u=a.type==="ExportNamedDeclaration"&&a.declaration||a.type==="ExportDefaultDeclaration"&&a.declaration.type==="ClassDeclaration"?a.declaration:a;if(u.type!=="ClassDeclaration"||!((V=u.decorators)!=null&&V.length))continue;let o=null;const l=[];for(const y of u.decorators){const d=xt(y);if(d==="Controller")o=zt(y);else if((d==="UseGuards"||d==="UseInterceptors"||d==="UsePipes")&&y.expression.type==="CallExpression")for(const v of y.expression.arguments)v.type!=="SpreadElement"&&l.push(ft(v))}if(!o)continue;const h=((T=u.id)==null?void 0:T.name)??"Controller";for(const y of o){const d=ne(D,y),v=`router:${e.path}:${h}:${d||"/"}`;A({id:v,type:"router",label:d||h,file:e.path,line:(($=u.loc)==null?void 0:$.start.line)??1}),w({id:`edge:${B}->${v}`,source:B,target:v,type:"mounts",label:d||"/"});for(const S of u.body.body){if(S.type!=="ClassMethod"||!((c=S.decorators)!=null&&c.length))continue;const I=[],O=[...l];for(const R of S.decorators){const M=xt(R);if(M&&M in Ft)I.push({method:Ft[M],paths:zt(R)});else if((M==="UseGuards"||M==="UseInterceptors"||M==="UsePipes")&&R.expression.type==="CallExpression")for(const F of R.expression.arguments)F.type!=="SpreadElement"&&O.push(ft(F))}if(I.length===0)continue;const z=new Set,G=new Set,W=new Set;for(const R of S.params)if(!(R.type!=="Identifier"||!((i=R.decorators)!=null&&i.length)))for(const M of R.decorators){const F=xt(M),Z=M.expression.type==="CallExpression"?pt(M.expression.arguments[0]):null;if(F==="Param"&&Z)z.add(Z);else if(F==="Query"&&Z)G.add(Z);else if(F==="Body"){if(Z)W.add(Z);else if(((g=R.typeAnnotation)==null?void 0:g.type)==="TSTypeAnnotation"&&R.typeAnnotation.typeAnnotation.type==="TSTypeReference"&&R.typeAnnotation.typeAnnotation.typeName.type==="Identifier"){const U=R.typeAnnotation.typeAnnotation.typeName.name;for(const J of k.get(U)??[])W.add(J)}}}const H=Ye(S.key)??"handler",N=`${h}.${H}`,C=((m=S.loc)==null?void 0:m.start.line)??1;for(const R of I)for(const M of R.paths){const F=ne(d,M),Z=Array.from(new Set([...fe(F),...z])),U=`route:${R.method}:${F}`;A({id:U,type:"route",label:`${R.method} ${F}`,file:e.path,line:C,method:R.method,fullPath:F,pathParams:Z,queryParams:Array.from(G),bodyFields:Array.from(W),group:me(F),middlewares:O,controller:N,controllerFile:e.path,controllerLine:C}),w({id:`edge:${v}->${U}`,source:v,target:U,type:"handles"});for(const K of O){const Q=`mw:${K}`;A({id:Q,type:"middleware",label:K,file:e.path,line:C}),w({id:`edge:${U}->${Q}`,source:U,target:Q,type:"uses"})}const J=`ctrl:${e.path}:${N}:${C}`;A({id:J,type:"controller",label:N,file:e.path,line:C}),w({id:`edge:${U}->${J}`,source:U,target:J,type:"calls"})}}}}return{version:"1.0",metadata:{repoName:(t==null?void 0:t.repoName)??"nestjs-app",framework:"nestjs",detectedPort:q,scannedFiles:p.length,scanDurationMs:Math.round((performance.now()-r)*100)/100,unresolvedMounts:[]},nodes:Array.from(j.values()),edges:Array.from(P.values())}}},Ot=new Set(["get","post","put","patch","delete","del","options","head","all"]),Dt=/\.(ts|tsx|js|jsx|mjs|cjs)$/i,Lt=/(\.test\.|\.spec\.|__tests__|__mocks__)/i;function He(n){let t=n;for(;t.type==="TSAsExpression"||t.type==="TSSatisfiesExpression"||t.type==="TSTypeAssertion"||t.type==="ParenthesizedExpression";)t=t.expression;return t}function be(n){return n?n.type==="Identifier"?n.name:n.type==="StringLiteral"?n.value:null:null}function Xe(n){if(n.type==="Identifier")return n.name;if(n.type==="MemberExpression"){const t=Xe(n.object),r=be(n.property)??"";return t?`${t}.${r}`:r}return n.type==="CallExpression"?Xe(n.callee):"anonymous"}function hs(n){var x;const t=new Set,r=new Set,s=new Set;if(n.type!=="FunctionDeclaration"&&n.type!=="FunctionExpression"&&n.type!=="ArrowFunctionExpression"&&n.type!=="ObjectMethod"&&n.type!=="ClassMethod")return{pathParams:[],queryParams:[],bodyFields:[]};const p=((x=n.params[0])==null?void 0:x.type)==="Identifier"?n.params[0].name:"ctx",f=b=>{if(b.type==="LogicalExpression")return f(b.left);if(b.type==="MemberExpression"&&b.object.type==="Identifier"&&b.object.name===p){const j=be(b.property);if(j==="params")return t;if(j==="query")return r}if(b.type==="MemberExpression"&&b.object.type==="MemberExpression"&&b.object.object.type==="Identifier"&&b.object.object.name===p&&be(b.object.property)==="request"){const j=be(b.property);if(j==="body")return s;if(j==="query")return r}return null},E=b=>{if(!(!b||typeof b!="object")){if(b.type==="MemberExpression"){const j=f(b.object),P=be(b.property);j&&P&&j.add(P)}if(b.type==="VariableDeclarator"&&b.init&&b.id.type==="ObjectPattern"){const j=f(b.init);if(j){for(const P of b.id.properties)if(P.type==="ObjectProperty"){const A=be(P.key);A&&j.add(A)}}}for(const j of Object.keys(b)){if(j==="loc"||j==="start"||j==="end"||j==="extra")continue;const P=b[j];if(Array.isArray(P))for(const A of P)A&&typeof A=="object"&&"type"in A&&E(A);else P&&typeof P=="object"&&"type"in P&&E(P)}}};return E(n.body),{pathParams:Array.from(t),queryParams:Array.from(r),bodyFields:Array.from(s)}}var ys=class{constructor(){ue(this,"name","koa")}detect(n){const t=n.find(r=>oe(r.path)==="package.json");return t&&/"(?:koa|@koa\/router|koa-router)"\s*:/.test(t.content)?!0:n.some(r=>Dt.test(r.path)&&!Lt.test(r.path)&&/(?:from\s+['"](?:koa|@koa\/router|koa-router)['"]|require\(\s*['"](?:koa|@koa\/router|koa-router)['"]\s*\))/.test(r.content))}scan(n,t){const r=performance.now(),s=n.map(c=>({path:oe(c.path),content:c.content})),p=s.filter(c=>Dt.test(c.path)&&!Lt.test(c.path)),f=new Set(s.map(c=>c.path)),E=et(s),x=new Map;for(const c of p){const i=We(c,f,E);i&&x.set(c.path,i)}const b=Array.from(x.values()),j=new Map,P=new Map,A=[],w=c=>{j.has(c.id)||j.set(c.id,c)},k=c=>{P.has(c.id)||P.set(c.id,c)},D=(c,i,g=0)=>{var e;if(g>8)return null;const m=He(i);if(m.type==="Identifier"){const a=c.imports.get(m.name);if(a!=null&&a.resolvedFile){const o=x.get(a.resolvedFile);if(!o)return null;if(a.importedName==="*")return{file:o,node:o.ast.program,name:m.name,line:1};const l=o.exports.get(a.importedName);if(l)return{file:o,node:l.node,name:a.importedName==="default"?m.name:a.importedName,localName:l.localName,line:l.line}}const u=c.locals.get(m.name);if(u)return{file:c,node:u,name:m.name,line:((e=u.loc)==null?void 0:e.start.line)??1}}if(m.type==="MemberExpression"){const a=be(m.property);if(!a)return null;const u=D(c,m.object,g+1);if(!u)return null;if(He(u.node).type==="Program"){const l=u.file.exports.get(a);if(l)return{file:u.file,node:l.node,name:`${u.name}.${a}`,line:l.line}}}if(m.type==="CallExpression"){if(m.callee.type==="MemberExpression"&&be(m.callee.property)==="routes")return D(c,m.callee.object,g+1);const a=ze(m);if(a){const u=Ce(c.path,a,f,E),o=u?x.get(u):void 0,l=o==null?void 0:o.exports.get("default");if(o&&l)return{file:o,node:l.node,name:a,localName:l.localName,line:l.line}}}return null},_=(c,i,g=0)=>{if(!i||g>8)return null;const m=He(i);if(m.type==="StringLiteral")return m.value;if(m.type==="TemplateLiteral"){let e="";for(let a=0;a<m.quasis.length;a++)if(e+=m.quasis[a].value.cooked??m.quasis[a].value.raw,a<m.expressions.length){const u=_(c,m.expressions[a],g+1);if(u===null)return null;e+=u}return e}if(m.type==="BinaryExpression"&&m.operator==="+"){const e=_(c,m.left,g+1),a=_(c,m.right,g+1);return e!==null&&a!==null?e+a:null}if(m.type==="Identifier"||m.type==="MemberExpression"){const e=D(c,m);if(e)return _(e.file,e.node,g+1)}return null},q=c=>{const i=new Set,g=new Map,m=new Set,e=new Set;for(const[u,o]of c.imports.entries())o.sourceSpecifier==="koa"&&m.add(u),(o.sourceSpecifier==="@koa/router"||o.sourceSpecifier==="koa-router")&&e.add(u);const a=u=>{if(!(!u||typeof u!="object")){if(u.type==="VariableDeclarator"&&u.id.type==="Identifier"&&u.init){const o=He(u.init);if(o.type==="NewExpression"&&o.callee.type==="Identifier"){if(m.has(o.callee.name))i.add(u.id.name);else if(e.has(o.callee.name)){let l="";const h=o.arguments[0];if((h==null?void 0:h.type)==="ObjectExpression")for(const y of h.properties)y.type==="ObjectProperty"&&be(y.key)==="prefix"&&(l=_(c,y.value)??"");g.set(u.id.name,l)}}}for(const o of Object.keys(u)){if(o==="loc"||o==="start"||o==="end"||o==="extra")continue;const l=u[o];if(Array.isArray(l))for(const h of l)h&&typeof h=="object"&&"type"in h&&a(h);else l&&typeof l=="object"&&"type"in l&&a(l)}}};return a(c.ast.program),{apps:i,routers:g}},B=(c,i,g,m,e,a,u)=>{var W;if(m.length===0)return;const o=m[m.length-1],l=m.slice(0,-1),h=[...u];for(const H of l){const N=Xe(H);N&&N!=="anonymous"&&!h.includes(N)&&h.push(N)}let y="inlineHandler",d=e.path,v=((W=o.loc)==null?void 0:W.start.line)??a,S=o;if(o.type!=="ArrowFunctionExpression"&&o.type!=="FunctionExpression"){y=Xe(o);const H=D(e,o);H&&(S=H.node,d=H.file.path,v=H.line)}const I=hs(S),O=Array.from(new Set([...fe(g),...I.pathParams])),z=`route:${i}:${g}`;w({id:z,type:"route",label:`${i} ${g}`,file:e.path,line:a,method:i,fullPath:g,pathParams:O,queryParams:I.queryParams,bodyFields:I.bodyFields,group:me(g),middlewares:h,controller:y,controllerFile:d,controllerLine:v}),k({id:`edge:${c}->${z}`,source:c,target:z,type:"handles"});for(const H of h){const N=`mw:${H}`;w({id:N,type:"middleware",label:H,file:e.path,line:a}),k({id:`edge:${z}->${N}`,source:z,target:N,type:"uses"})}const G=`ctrl:${d}:${y}:${v}`;w({id:G,type:"controller",label:y,file:d,line:v}),k({id:`edge:${z}->${G}`,source:z,target:G,type:"calls"})},V=new Set,T=(c,i,g,m,e,a)=>{const u=`${c.path}:${Array.from(i).join(",")}:${e}`;if(V.has(u))return;V.add(u);let o=e;const l=[...a],h=d=>{var I;const v=[];let S=d;for(;S.type==="CallExpression"&&S.callee.type==="MemberExpression";){const O=be(S.callee.property);if(!O||O!=="use"&&O!=="prefix"&&!Ot.has(O))break;v.push({methodName:O,args:S.arguments,line:((I=S.loc)==null?void 0:I.start.line)??1}),S=He(S.callee.object)}if(v.length!==0&&!(S.type!=="Identifier"||!i.has(S.name))){for(const O of v.reverse())if(O.methodName==="prefix"){const z=_(c,O.args[0]);z!==null&&(o=ne(o,z))}else if(O.methodName==="use"){const z=_(c,O.args[0]),G=z?ne(o,z):o,W=z?O.args.slice(1):O.args;for(const H of W){if(H.type==="CallExpression"&&H.callee.type==="MemberExpression"&&be(H.callee.property)==="allowedMethods")continue;const N=D(c,H);if(N){const{routers:R}=q(N.file),M=N.localName??N.name;if(R.has(M)){const F=R.get(M)??"",Z=F?ne(G,F):G,U=`router:${N.file.path}:${Z||"/"}`;w({id:U,type:"router",label:Z||N.name,file:N.file.path,line:N.line}),k({id:`edge:${m}->${U}`,source:m,target:U,type:"mounts"}),T(N.file,new Set([M]),N.file.ast.program.body,U,Z,l);continue}}const C=Xe(H);C&&C!=="anonymous"&&!l.includes(C)&&l.push(C)}}else if(Ot.has(O.methodName)){const z=O.methodName==="del"?"DELETE":O.methodName.toUpperCase();let G=0;const W=_(c,O.args[0]),H=_(c,O.args[1]);W!==null&&!W.startsWith("/")&&H!==null&&H.startsWith("/")&&(G=1);const N=_(c,O.args[G]);if(N===null){A.push(`${c.path}:${O.line} (dynamic Koa route path)`);continue}const C=ne(o,N);B(m,z,C,O.args.slice(G+1),c,O.line,l)}}},y=d=>{if(d)if(d.type==="ExpressionStatement"){const v=d.expression.type==="AwaitExpression"?d.expression.argument:d.expression;if(v.type==="CallExpression"){h(v);let S=v;for(;S.type==="CallExpression";){for(const I of S.arguments)(I.type==="ArrowFunctionExpression"||I.type==="FunctionExpression")&&I.body.type==="BlockStatement"&&y(I.body);if(S.callee.type==="MemberExpression")S=S.callee.object;else break}}}else if(d.type==="BlockStatement")for(const v of d.body)y(v);else d.type==="IfStatement"?(y(d.consequent),y(d.alternate)):d.type==="FunctionDeclaration"&&d.body&&y(d.body)};for(const d of g)y(d)},$=[];for(const c of b){const{apps:i}=q(c);i.size>0&&$.push({pf:c,apps:i})}if($.length>0)for(const{pf:c,apps:i}of $){const g=`entry:${c.path}`;w({id:g,type:"entry",label:c.path,file:c.path,line:1}),T(c,i,c.ast.program.body,g,"",[])}else for(const c of b){const{routers:i}=q(c);for(const[g,m]of i.entries()){const e=`router:${c.path}:${m||"/"}`;w({id:e,type:"router",label:m||c.path,file:c.path,line:1}),T(c,new Set([g]),c.ast.program.body,e,m,[])}}return{version:"1.0",metadata:{repoName:(t==null?void 0:t.repoName)??"koa-app",framework:"koa",scannedFiles:p.length,scanDurationMs:Math.round((performance.now()-r)*100)/100,unresolvedMounts:A},nodes:Array.from(j.values()),edges:Array.from(P.values())}}},Zt=/(?:^|.*\/)(?:src\/)?app\/(?:(.*)\/)?route\.(ts|tsx|js|jsx|mjs|cjs)$/i,qt=/(?:^|.*\/)(?:src\/)?pages\/api\/(.+)\.(ts|tsx|js|jsx|mjs|cjs)$/i,gs=/(?:^|\/)next\.config\.(js|mjs|ts|cjs)$/i,$t=new Set(["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"]);function Ze(n){return n?n.type==="Identifier"?n.name:n.type==="StringLiteral"?n.value:null:null}function Gt(n){const t=[];for(const r of n){if(!r||r.startsWith("(")&&r.endsWith(")")||r.startsWith("@"))continue;const s=r.match(/^\[{1,2}\.\.\.([^\]]+)\]{1,2}$/);if(s){t.push(`*${s[1]}`);continue}const p=r.match(/^\[([^\]]+)\]$/);if(p){t.push(`:${p[1]}`);continue}t.push(r)}return"/"+t.join("/")}function xs(n){const t=new Set,r=new Set,s=p=>{var f;if(!(!p||typeof p!="object")){if(p.type==="CallExpression"&&p.callee.type==="MemberExpression"&&Ze(p.callee.property)==="get"&&((f=p.arguments[0])==null?void 0:f.type)==="StringLiteral"){const E=p.callee.object;(E.type==="Identifier"&&E.name==="searchParams"||E.type==="MemberExpression"&&Ze(E.property)==="searchParams")&&t.add(p.arguments[0].value)}if(p.type==="VariableDeclarator"&&p.init&&p.id.type==="ObjectPattern"){const E=p.init.type==="AwaitExpression"?p.init.argument:p.init;if(E.type==="CallExpression"&&E.callee.type==="MemberExpression"&&Ze(E.callee.property)==="json"){for(const x of p.id.properties)if(x.type==="ObjectProperty"){const b=Ze(x.key);b&&r.add(b)}}}for(const E of Object.keys(p)){if(E==="loc"||E==="start"||E==="end"||E==="extra")continue;const x=p[E];if(Array.isArray(x))for(const b of x)b&&typeof b=="object"&&"type"in b&&s(b);else x&&typeof x=="object"&&"type"in x&&s(x)}}};return s(n),{queryParams:Array.from(t),bodyFields:Array.from(r)}}function bs(n){const t=new Set,r=s=>{var p;if(!(!s||typeof s!="object")){if(s.type==="BinaryExpression"&&(s.operator==="==="||s.operator==="=="||s.operator==="!=="||s.operator==="!=")){const f=(E,x)=>{if(E.type==="MemberExpression"&&Ze(E.property)==="method"&&x.type==="StringLiteral"){const b=x.value.toUpperCase();$t.has(b)&&t.add(b)}};f(s.left,s.right),f(s.right,s.left)}else if(s.type==="SwitchStatement"&&s.discriminant.type==="MemberExpression"&&Ze(s.discriminant.property)==="method"){for(const f of s.cases)if(((p=f.test)==null?void 0:p.type)==="StringLiteral"){const E=f.test.value.toUpperCase();$t.has(E)&&t.add(E)}}for(const f of Object.keys(s)){if(f==="loc"||f==="start"||f==="end"||f==="extra")continue;const E=s[f];if(Array.isArray(E))for(const x of E)x&&typeof x=="object"&&"type"in x&&r(x);else E&&typeof E=="object"&&"type"in E&&r(E)}}};return r(n.ast.program),t.size>0?Array.from(t):["ALL"]}var ws=class{constructor(){ue(this,"name","nextjs")}detect(n){return n.some(r=>(oe(r.path)==="package.json"||oe(r.path).endsWith("/package.json"))&&/"next"\s*:/.test(r.content))?n.some(r=>{const s=oe(r.path);return Zt.test(s)||qt.test(s)}):!1}scan(n,t){const r=performance.now(),s=n.map(_=>({path:oe(_.path),content:_.content})),p=new Set(s.map(_=>_.path));let f="";for(const _ of s)if(gs.test(_.path)){const q=_.content.match(/\bbasePath\s*:\s*['"`]([^'"`]+)['"`]/);if(q){f=q[1];break}}const E=new Map,x=new Map,b=_=>{E.has(_.id)||E.set(_.id,_)},j=_=>{x.has(_.id)||x.set(_.id,_)},P="entry:nextjs-app-router",A="entry:nextjs-pages-router";let w=!1,k=!1,D=0;for(const _ of s){const q=_.path.match(Zt),B=q?null:_.path.match(qt);if(!q&&!B)continue;const V=We(_,p);if(V){if(D++,q){w||(w=!0,b({id:P,type:"entry",label:"app/ (App Router)",file:_.path,line:1}));const T=q[1]?q[1].split("/"):[],$=Gt(T),c=f?ne(f,$):$,i=me(c);for(const[g,m]of V.exports.entries()){const e=g.toUpperCase();if(!$t.has(e))continue;const a=e,u=xs(m.node),o=fe(c),l=`route:${a}:${c}`;b({id:l,type:"route",label:`${a} ${c}`,file:_.path,line:m.line,method:a,fullPath:c,pathParams:o,queryParams:u.queryParams,bodyFields:u.bodyFields,group:i,middlewares:[],controller:g,controllerFile:_.path,controllerLine:m.line}),j({id:`edge:${P}->${l}`,source:P,target:l,type:"handles"})}}else if(B){k||(k=!0,b({id:A,type:"entry",label:"pages/api/ (Pages Router)",file:_.path,line:1}));const T=B[1].split("/");T[T.length-1]==="index"&&T.pop();const $=ne("/api",Gt(T)),c=f?ne(f,$):$,i=me(c),g=V.exports.get("default"),m=g?_t(g.node):{pathParams:[],queryParams:[],bodyFields:[]},e=bs(V),a=Array.from(new Set([...fe(c),...m.pathParams]));for(const u of e){const o=`route:${u}:${c}`;b({id:o,type:"route",label:`${u} ${c}`,file:_.path,line:(g==null?void 0:g.line)??1,method:u,fullPath:c,pathParams:a,queryParams:m.queryParams,bodyFields:m.bodyFields,group:i,middlewares:[],controller:(g==null?void 0:g.localName)??"handler",controllerFile:_.path,controllerLine:(g==null?void 0:g.line)??1}),j({id:`edge:${A}->${o}`,source:A,target:o,type:"handles"})}}}}return{version:"1.0",metadata:{repoName:(t==null?void 0:t.repoName)??"nextjs-app",framework:"nextjs",scannedFiles:D,scanDurationMs:Math.round((performance.now()-r)*100)/100,unresolvedMounts:[]},nodes:Array.from(E.values()),edges:Array.from(x.values())}}},Wt=/(?:^|\/)(?:tests?|__tests__)\/|test_[^/]+\.py$|_test\.py$/i,vs=new Set(["get","post","put","patch","delete","options","head"]);function bt(n,t,r){let s=n.includes("/")?n.slice(0,n.lastIndexOf("/")):"",p=t.modulePath;if(p.startsWith(".")){let x=0;for(;p[x]===".";)x++;for(let b=1;b<x;b++)s=s.includes("/")?s.slice(0,s.lastIndexOf("/")):"";p=p.slice(x)}else s="";const f=p?p.replace(/\./g,"/"):"",E=[];if(s&&f)E.push(le(s,`${f}.py`),le(s,`${f}/__init__.py`));else if(f){E.push(`${f}.py`,`${f}/__init__.py`);for(const x of r)(x.endsWith(`/${f}.py`)||x.endsWith(`/${f}/__init__.py`))&&E.push(x)}else s&&E.push(le(s,"__init__.py"));for(const x of E){const b=oe(x);if(r.has(b))return b}return null}function rt(n){const t=[],r=/Depends\(\s*([A-Za-z_][A-Za-z0-9_.]*)/g;let s;for(;(s=r.exec(n))!==null;)t.includes(s[1])||t.push(s[1]);return t}function ot(n,t){let r=0,s=null,p=!1;for(let f=t;f<n.length;f++){const E=n[f];if(s){p?p=!1:E==="\\"?p=!0:E===s&&(s=null);continue}if(E==='"'||E==="'"){s=E;continue}if(E==="(")r++;else if(E===")"&&(r--,r===0))return{content:n.slice(t+1,f),endIdx:f}}return{content:n.slice(t+1),endIdx:n.length-1}}function Ht(n,t){let r=1;for(let s=0;s<t&&s<n.length;s++)n[s]===`
|
|
8
|
+
`&&r++;return r}var Es=class{constructor(){ue(this,"name","fastapi")}detect(n){return n.some(r=>{const s=oe(r.path);return(s==="requirements.txt"||s==="pyproject.toml"||s==="Pipfile")&&/\bfastapi\b/i.test(r.content)})?!0:n.some(r=>r.path.endsWith(".py")&&!Wt.test(r.path)&&/(?:from\s+fastapi\b|import\s+fastapi\b)/.test(r.content))}scan(n,t){var V;const r=performance.now(),s=n.map(T=>({path:oe(T.path),content:T.content})).filter(T=>T.path.endsWith(".py")&&!Wt.test(T.path)),p=new Set(s.map(T=>T.path)),f=new Map,E=new Map;for(const T of s){const $=/^[ \t]*([A-Za-z_][A-Za-z0-9_]*)(?:\s*:\s*str)?\s*=\s*['"]([^'"]*)['"]/gm;let c;for(;(c=$.exec(T.content))!==null;)c[2].startsWith("/")&&E.set(c[1],c[2]);const i=/^class\s+([A-Za-z_][A-Za-z0-9_]*)\s*\([^)]*(?:BaseModel|SQLModel|Schema)[^)]*\)\s*:/gm;let g;for(;(g=i.exec(T.content))!==null;){const m=g[1],e=T.content.slice(g.index+g[0].length),a=[];for(const u of e.split(`
|
|
9
|
+
`)){if(u.trim()===""||u.trim().startsWith("#"))continue;if(!/^\s+/.test(u))break;const o=u.match(/^\s+([a-z_][a-zA-Z0-9_]*)\s*:/);o&&o[1]!=="model_config"&&a.push(o[1])}a.length>0&&f.set(m,a)}}const x=new Map;for(const T of s){const $=new Map,c=new Map,i=[],g=[],m=T.content,e=/^\s*from\s+(\.{0,3}[A-Za-z0-9_.]*)\s+import\s+([^\n#]+)/gm;let a;for(;(a=e.exec(m))!==null;){const S=a[1],I=a[2].replace(/[()]/g,"").split(",");for(const O of I){const z=O.trim();if(!z)continue;const G=z.match(/^([A-Za-z0-9_*]+)\s+as\s+([A-Za-z0-9_]+)$/);G?$.set(G[2],{modulePath:S,importedName:G[1]}):/^[A-Za-z0-9_]+$/.test(z)&&$.set(z,{modulePath:S,importedName:z})}}const u=S=>{const I=S.match(/^['"]([^'"]*)['"]$/);if(I)return I[1].replace(/\{([^:}]+)(?::[^}]+)?\}/g,":$1");const O=S.match(/^f['"]([^'"]*)['"]$/);if(O)return O[1].replace(/\{([A-Za-z_][A-Za-z0-9_.]*)\}/g,(H,N)=>{const C=E.get(N.split(".").pop());return C!==void 0?C:H}).replace(/\{([^:}]+)(?::[^}]+)?\}/g,":$1");const z=S.split(".").pop();return(E.get(z)??"").replace(/\{([^:}]+)(?::[^}]+)?\}/g,":$1")},o=/^[ \t]*([A-Za-z_][A-Za-z0-9_]*)\s*(?::[^=\n]+)?=\s*(FastAPI|APIRouter[A-Za-z0-9_]*)\s*\(/gm;let l;for(;(l=o.exec(m))!==null;){const S=l[1],I=l[2],{content:O}=ot(m,l.index+l[0].length-1),z=O.match(/prefix\s*=\s*(f?['"][^'"]*['"]|[A-Za-z_][A-Za-z0-9_.]*)/);c.set(S,{varName:S,prefix:z?u(z[1]):"",dependencies:rt(O),isApp:I==="FastAPI"})}const h=/\b([A-Za-z_][A-Za-z0-9_]*)\.include_router\s*\(/g;let y;for(;(y=h.exec(m))!==null;){const S=y[1],{content:I}=ot(m,y.index+y[0].length-1),O=((V=I.split(",")[0])==null?void 0:V.trim().split(/\s+/)[0])??"",z=I.match(/prefix\s*=\s*(f?['"][^'"]*['"]|[A-Za-z_][A-Za-z0-9_.]*)/),G=z?u(z[1]):"";O&&i.push({parentVar:S,targetExpr:O,prefix:G,dependencies:rt(I),line:Ht(m,y.index)})}const d=/@([A-Za-z_][A-Za-z0-9_]*)\.(get|post|put|patch|delete|options|head|api_route)\s*\(/g;let v;for(;(v=d.exec(m))!==null;){const S=v[1],I=v[2].toLowerCase(),{content:O,endIdx:z}=ot(m,v.index+v[0].length-1),G=O.match(/^\s*['"]([^'"]*)['"]/);if(!G)continue;const W=G[1].replace(/\{([^:}]+)(?::[^}]+)?\}/g,":$1"),H=[];if(I==="api_route"){const U=O.match(/methods\s*=\s*\[([^\]]+)\]/);if(U)for(const J of U[1].split(",")){const K=J.replace(/['"\s]/g,"").toUpperCase();K&&H.push(K)}H.length===0&&H.push("GET")}else vs.has(I)&&H.push(I.toUpperCase());const C=m.slice(z+1).match(/(?:async\s+)?def\s+([A-Za-z_][A-Za-z0-9_]*)\s*\(/),R=C?C[1]:"handler",M=rt(O),F=[],Z=[];if(C&&C.index!==void 0){const U=z+1+C.index+C[0].length-1,J=ot(m,U).content;for(const Q of rt(J))M.includes(Q)||M.push(Q);const K=new Set(fe(W));for(const Q of J.split(",")){const te=Q.trim();if(!te||te.startsWith("*"))continue;const re=te.match(/^([A-Za-z_][A-Za-z0-9_]*)(?:\s*:\s*([^=]+))?(?:\s*=\s*(.+))?$/);if(!re)continue;const ie=re[1],Y=(re[2]??"").trim(),se=(re[3]??"").trim();if(!(ie==="self"||ie==="cls"||se.includes("Depends("))&&!/^(?:Request|Response|BackgroundTasks|WebSocket|Session|AsyncSession)$/.test(Y))if(se.includes("Body("))Z.push(ie);else if(f.has(Y))for(const ee of f.get(Y))Z.includes(ee)||Z.push(ee);else!K.has(ie)&&(se.includes("Query(")||/^(?:str|int|float|bool|Optional\[)/.test(Y))&&F.push(ie)}}g.push({targetVar:S,methods:H,path:W,handlerName:R,line:Ht(m,v.index),middlewares:M,queryParams:F,bodyFields:Z})}for(const S of g)c.has(S.targetVar)||c.set(S.targetVar,{varName:S.targetVar,prefix:"",dependencies:[],isApp:!1});x.set(T.path,{path:T.path,imports:$,routers:c,includes:i,routes:g})}const b=new Map,j=new Map,P=[],A=T=>{b.has(T.id)||b.set(T.id,T)},w=T=>{j.has(T.id)||j.set(T.id,T)},k=(T,$)=>{if(T.routers.has($))return{file:T,varName:$};const c=$.split("."),i=T.imports.get(c[0]);if(i){let g=null;if(c.length>1&&i.importedName!=="*"){const e=i.modulePath?`${i.modulePath}.${i.importedName}`:i.importedName;g=bt(T.path,{modulePath:e},p)}if(g||(g=bt(T.path,i,p)),!g&&i.importedName!=="*"){const e=i.modulePath?`${i.modulePath}.${i.importedName}`:i.importedName;g=bt(T.path,{modulePath:e},p)}const m=g?x.get(g):void 0;if(m){const e=c.length>1?c[1]:i.importedName;if(m.routers.has(e))return{file:m,varName:e};if(m.routers.size===1){const a=Array.from(m.routers.keys())[0];return{file:m,varName:a}}}}return null},D=new Set,_=new Set,q=(T,$,c,i,g,m=!1)=>{const e=`${T.path}:${$}:${i}`;if(D.has(e))return;D.add(e),_.add(`${T.path}:${$}`);const a=T.routers.get($),u=a!=null&&a.prefix?ne(i,a.prefix):i,o=Array.from(new Set([...g,...(a==null?void 0:a.dependencies)??[]]));for(const l of T.routes){if(l.targetVar!==$)continue;const h=ne(u,l.path),y=fe(h),d=Array.from(new Set([...o,...l.middlewares])),v=me(h);for(const S of l.methods){const I=`route:${S}:${h}`;A({id:I,type:"route",label:`${S} ${h}`,file:T.path,line:l.line,method:S,fullPath:h,pathParams:y,queryParams:l.queryParams,bodyFields:l.bodyFields,group:v,middlewares:d,controller:l.handlerName,controllerFile:T.path,controllerLine:l.line,...m?{partial:!0}:{}}),w({id:`edge:${c}->${I}`,source:c,target:I,type:"handles"});for(const z of d){const G=`mw:${z}`;A({id:G,type:"middleware",label:z,file:T.path,line:l.line}),w({id:`edge:${I}->${G}`,source:I,target:G,type:"uses"})}const O=`ctrl:${T.path}:${l.handlerName}:${l.line}`;A({id:O,type:"controller",label:l.handlerName,file:T.path,line:l.line}),w({id:`edge:${I}->${O}`,source:I,target:O,type:"calls"})}}for(const l of T.includes){if(l.parentVar!==$)continue;const h=k(T,l.targetExpr);if(!h){P.push(`${T.path}:${l.line} -> ${l.targetExpr}`);continue}const y=l.prefix?ne(u,l.prefix):u,d=`router:${h.file.path}:${y||"/"}`;A({id:d,type:"router",label:y||h.varName,file:h.file.path,line:1}),w({id:`edge:${c}->${d}`,source:c,target:d,type:"mounts"}),q(h.file,h.varName,d,y,Array.from(new Set([...o,...l.dependencies])))}},B=[];for(const T of x.values())for(const $ of T.routers.values())$.isApp&&B.push({pf:T,varName:$.varName});if(B.length>0)for(const{pf:T,varName:$}of B){const c=`entry:${T.path}`;A({id:c,type:"entry",label:T.path,file:T.path,line:1}),q(T,$,c,"",[])}for(const T of x.values())for(const $ of T.routers.values())if(!$.isApp&&!_.has(`${T.path}:${$.varName}`)){const c=`router:${T.path}:${$.prefix||"/"}`;A({id:c,type:"router",label:$.prefix||T.path,file:T.path,line:1}),q(T,$.varName,c,"",[],B.length>0)}return{version:"1.0",metadata:{repoName:(t==null?void 0:t.repoName)??"fastapi-app",framework:"fastapi",scannedFiles:s.length,scanDurationMs:Math.round((performance.now()-r)*100)/100,unresolvedMounts:P},nodes:Array.from(b.values()),edges:Array.from(j.values())}}},Bt=/(?:^|\/)(?:tests?|__tests__)\/|test_[^/]+\.py$|_test\.py$/i,$s=new Set(["get","post","put","patch","delete","options","head"]);function Ut(n,t,r){let s=n.includes("/")?n.slice(0,n.lastIndexOf("/")):"",p=t.modulePath;if(p.startsWith(".")){let x=0;for(;p[x]===".";)x++;for(let b=1;b<x;b++)s=s.includes("/")?s.slice(0,s.lastIndexOf("/")):"";p=p.slice(x)}else s="";const f=p?p.replace(/\./g,"/"):"",E=[];if(s&&f)E.push(le(s,`${f}.py`),le(s,`${f}/__init__.py`));else if(f){E.push(`${f}.py`,`${f}/__init__.py`);for(const x of r)(x.endsWith(`/${f}.py`)||x.endsWith(`/${f}/__init__.py`))&&E.push(x)}else s&&E.push(le(s,"__init__.py"));for(const x of E){const b=oe(x);if(r.has(b))return b}return null}function Vt(n,t){let r=1;for(let s=0;s<t&&s<n.length;s++)n[s]===`
|
|
10
|
+
`&&r++;return r}var js=class{constructor(){ue(this,"name","flask")}detect(n){return n.some(r=>{const s=oe(r.path);return(s==="requirements.txt"||s==="pyproject.toml"||s==="Pipfile")&&/\bflask\b/i.test(r.content)})?!0:n.some(r=>r.path.endsWith(".py")&&!Bt.test(r.path)&&/(?:from\s+flask\b|import\s+flask\b)/.test(r.content))}scan(n,t){var D;const r=performance.now(),s=n.map(_=>({path:oe(_.path),content:_.content})).filter(_=>_.path.endsWith(".py")&&!Bt.test(_.path)),p=new Set(s.map(_=>_.path)),f=new Map;for(const _ of s){const q=new Map,B=new Map,V=[],T=[],$=_.content,c=/^\s*from\s+(\.{0,3}[A-Za-z0-9_.]*)\s+import\s+([^\n#]+)/gm;let i;for(;(i=c.exec($))!==null;){const l=i[1];for(const h of i[2].replace(/[()]/g,"").split(",")){const y=h.trim();if(!y)continue;const d=y.match(/^([A-Za-z0-9_*]+)\s+as\s+([A-Za-z0-9_]+)$/);d?q.set(d[2],{modulePath:l,importedName:d[1]}):/^[A-Za-z0-9_]+$/.test(y)&&q.set(y,{modulePath:l,importedName:y})}}const g=/^[ \t]*([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(Flask|Blueprint)\s*\(([^)]*)\)/gm;let m;for(;(m=g.exec($))!==null;){const l=m[3].match(/url_prefix\s*=\s*['"]([^'"]*)['"]/);B.set(m[1],{varName:m[1],urlPrefix:l?l[1]:"",isApp:m[2]==="Flask"})}const e=/\b([A-Za-z_][A-Za-z0-9_]*)\.register_blueprint\s*\(([^)]*)\)/g;let a;for(;(a=e.exec($))!==null;){const l=((D=a[2].split(",")[0])==null?void 0:D.trim())??"",h=a[2].match(/url_prefix\s*=\s*['"]([^'"]*)['"]/);l&&V.push({parentVar:a[1],bpExpr:l,urlPrefix:h?h[1]:"",line:Vt($,a.index)})}const u=/@([A-Za-z_][A-Za-z0-9_]*)\.(route|get|post|put|patch|delete|options|head)\s*\(([^)]*)\)/g;let o;for(;(o=u.exec($))!==null;){const l=o[1],h=o[2].toLowerCase(),y=o[3],d=y.match(/^\s*['"]([^'"]*)['"]/);if(!d)continue;const v=d[1].replace(/<(?:[^:>]+:)?([^>]+)>/g,":$1"),S=[];if(h==="route"){const z=y.match(/methods\s*=\s*\[([^\]]+)\]/);if(z)for(const G of z[1].split(",")){const W=G.replace(/['"\s]/g,"").toUpperCase();W&&S.push(W)}S.length===0&&S.push("GET")}else $s.has(h)&&S.push(h.toUpperCase());const O=$.slice(o.index+o[0].length).match(/(?:async\s+)?def\s+([A-Za-z_][A-Za-z0-9_]*)\s*\(/);T.push({targetVar:l,methods:S,path:v,handlerName:O?O[1]:"handler",line:Vt($,o.index)})}f.set(_.path,{path:_.path,imports:q,routers:B,registers:V,routes:T})}const E=new Map,x=new Map,b=_=>{E.has(_.id)||E.set(_.id,_)},j=_=>{x.has(_.id)||x.set(_.id,_)},P=new Set,A=new Set,w=(_,q,B,V)=>{const T=`${_.path}:${q}:${V}`;if(P.has(T))return;P.add(T),A.add(`${_.path}:${q}`);const $=_.routers.get(q),c=$!=null&&$.urlPrefix?ne(V,$.urlPrefix):V;for(const i of _.routes){if(i.targetVar!==q)continue;const g=ne(c,i.path),m=fe(g),e=me(g);for(const a of i.methods){const u=`route:${a}:${g}`;b({id:u,type:"route",label:`${a} ${g}`,file:_.path,line:i.line,method:a,fullPath:g,pathParams:m,queryParams:[],bodyFields:[],group:e,middlewares:[],controller:i.handlerName,controllerFile:_.path,controllerLine:i.line}),j({id:`edge:${B}->${u}`,source:B,target:u,type:"handles"});const o=`ctrl:${_.path}:${i.handlerName}:${i.line}`;b({id:o,type:"controller",label:i.handlerName,file:_.path,line:i.line}),j({id:`edge:${u}->${o}`,source:u,target:o,type:"calls"})}}for(const i of _.registers){if(i.parentVar!==q)continue;let g,m=i.bpExpr;if(_.routers.has(i.bpExpr))g=_;else{const u=_.imports.get(i.bpExpr);if(u){let o=Ut(_.path,u,p);if(!o&&u.importedName!=="*"){const l=u.modulePath?`${u.modulePath}.${u.importedName}`:u.importedName;o=Ut(_.path,{modulePath:l},p)}o&&(g=f.get(o),m=u.importedName)}}if(!g||!g.routers.has(m))continue;const e=i.urlPrefix?ne(c,i.urlPrefix):c,a=`router:${g.path}:${e||"/"}`;b({id:a,type:"router",label:e||m,file:g.path,line:1}),j({id:`edge:${B}->${a}`,source:B,target:a,type:"mounts"}),w(g,m,a,e)}},k=[];for(const _ of f.values())for(const q of _.routers.values())q.isApp&&k.push({pf:_,varName:q.varName});if(k.length>0)for(const{pf:_,varName:q}of k){const B=`entry:${_.path}`;b({id:B,type:"entry",label:_.path,file:_.path,line:1}),w(_,q,B,"")}for(const _ of f.values())for(const q of _.routers.values())if(!q.isApp&&!A.has(`${_.path}:${q.varName}`)){const B=`router:${_.path}:${q.urlPrefix||"/"}`;b({id:B,type:"router",label:q.urlPrefix||_.path,file:_.path,line:1}),w(_,q.varName,B,"")}return{version:"1.0",metadata:{repoName:(t==null?void 0:t.repoName)??"flask-app",framework:"flask",scannedFiles:s.length,scanDurationMs:Math.round((performance.now()-r)*100)/100,unresolvedMounts:[]},nodes:Array.from(E.values()),edges:Array.from(x.values())}}},Kt=/(?:^|\/)(?:tests?|__tests__)\/|test_[^/]+\.py$|_test\.py$/i,un=new Set(["get","post","put","patch","delete","options","head"]);function qe(n,t){let r=1;for(let s=0;s<t&&s<n.length;s++)n[s]===`
|
|
11
|
+
`&&r++;return r}function Ss(n){return n.replace(/#[^\n]*/g,t=>" ".repeat(t.length))}function jt(n,t,r,s){if(n[t]!==r)return null;let p=0,f=null;for(let E=t;E<n.length;E++){const x=n[E];if(f){if(x==="\\"){E++;continue}x===f&&(f=null);continue}if(x==='"'||x==="'"){f=x;continue}if(x===r)p++;else if(x===s&&(p--,p===0))return{text:n.slice(t+1,E),endIdx:E}}return null}function Qe(n){const t=[];let r=0,s=0,p=0,f=null,E=0;for(let b=0;b<n.length;b++){const j=n[b];if(f){if(j==="\\"){b++;continue}j===f&&(f=null);continue}if(j==='"'||j==="'"){f=j;continue}if(j==="(")r++;else if(j===")")r--;else if(j==="[")s++;else if(j==="]")s--;else if(j==="{")p++;else if(j==="}")p--;else if(j===","&&r===0&&s===0&&p===0){const P=n.slice(E,b).trim();P&&t.push(P),E=b+1}}const x=n.slice(E).trim();return x&&t.push(x),t}function $e(n){const t=n.trim().match(/^[rfbuRFBU]{0,2}(['"])([\s\S]*)\1$/);return t?t[2]:null}function As(n,t){let r=n.trim();return t?(r=r.replace(/^\^/,"").replace(/\$$/,""),r=r.replace(/\/\?$/,""),r=r.replace(/\(\?P<([A-Za-z_][A-Za-z0-9_]*)>[^)]*\)/g,":$1"),r=r.replace(/\\([./\-_])/g,"$1")):r=r.replace(/<(?:[A-Za-z_][A-Za-z0-9_]*:)?([A-Za-z_][A-Za-z0-9_]*)>/g,":$1"),r?r.startsWith("/")?r:`/${r}`:"/"}function Be(n,t,r){let s=n.includes("/")?n.slice(0,n.lastIndexOf("/")):"",p=t.modulePath;if(p.startsWith(".")){let b=0;for(;p[b]===".";)b++;for(let j=1;j<b;j++)s=s.includes("/")?s.slice(0,s.lastIndexOf("/")):"";p=p.slice(b)}else s="";const f=p?p.replace(/\./g,"/"):"",E=t.importedName&&t.importedName!=="*"?t.importedName:"",x=[];if(s&&f)E&&x.push(le(s,`${f}/${E}.py`),le(s,`${f}/${E}/__init__.py`)),x.push(le(s,`${f}.py`),le(s,`${f}/__init__.py`));else if(f){if(E){x.push(`${f}/${E}.py`,`${f}/${E}/__init__.py`);for(const b of r)(b.endsWith(`/${f}/${E}.py`)||b.endsWith(`/${f}/${E}/__init__.py`))&&x.push(b)}x.push(`${f}.py`,`${f}/__init__.py`);for(const b of r)(b.endsWith(`/${f}.py`)||b.endsWith(`/${f}/__init__.py`))&&x.push(b)}else s&&(E&&x.push(le(s,`${E}.py`),le(s,`${E}/__init__.py`)),x.push(le(s,"__init__.py")));for(const b of x){const j=oe(b);if(r.has(j))return j}return null}function at(n,t){const r=n.replace(/\./g,"/"),s=[`${r}.py`,`${r}/__init__.py`];for(const p of s){const f=oe(p);if(t.has(f))return f}for(const p of t)if(p.endsWith(`/${r}.py`)||p.endsWith(`/${r}/__init__.py`))return p;return null}function Ps(n){const t=new Map,r=/^[ \t]*from\s+([.\w]+)\s+import\s+\(([^)]+)\)|^[ \t]*from\s+([.\w]+)\s+import\s+([^\n#]+)/gm;let s;for(;(s=r.exec(n))!==null;){const f=s[1]||s[3],E=(s[2]||s[4]||"").split(",");for(const x of E){const b=x.trim();if(!b||b==="*")continue;const j=b.match(/^([A-Za-z_][A-Za-z0-9_]*)\s+as\s+([A-Za-z_][A-Za-z0-9_]*)$/);if(j)t.set(j[2],{modulePath:f,importedName:j[1]});else{const P=b.split(/\s+/)[0];/^[A-Za-z_][A-Za-z0-9_]*$/.test(P)&&t.set(P,{modulePath:f,importedName:P})}}}const p=/^[ \t]*import\s+([^\n#]+)/gm;for(;(s=p.exec(n))!==null;)for(const f of s[1].split(",")){const E=f.trim(),x=E.match(/^([.\w]+)\s+as\s+([A-Za-z_][A-Za-z0-9_]*)$/);if(x)t.set(x[2],{modulePath:x[1],importedName:"*"});else if(/^[.\w]+$/.test(E)){const b=E.split(".")[0];t.set(b,{modulePath:E,importedName:"*"})}}return t}function St(n,t,r){const s=[],p=/\b(path|re_path|url)\s*\(/g;let f;for(;(f=p.exec(n))!==null;){const b=f[1],j=b==="re_path"||b==="url",P=f.index+f[0].length-1,A=jt(n,P,"(",")");if(!A)continue;const w=Qe(A.text);if(w.length<2){p.lastIndex=A.endIdx+1;continue}let k=$e(w[0]);if(k===null&&w[0].includes("route=")){const T=w[0].match(/route\s*=\s*([rfbuRFBU]{0,2}['"][^'"]*['"])/);T&&(k=$e(T[1]))}if(k===null){p.lastIndex=A.endIdx+1;continue}const D=As(k,j);let _=w[1].replace(/^view\s*=\s*/,"").trim(),q;for(const T of w.slice(2)){const $=T.match(/^name\s*=\s*(['"])([^'"]+)\1$/);$&&(q=$[2])}const B=qe(r,t+f.index),V=_.match(/^include\s*\(([\s\S]*)\)$/);if(V){const T=V[1].trim(),c=Qe(T)[0]??"";if(c.startsWith("[")){const i=c.slice(1,-1);s.push({kind:"inline",pattern:D,targetExpr:_,name:q,line:B,inlineEntries:St(i,t+f.index,r)})}else if($e(c)===null&&/\.urls\b/.test(c))s.push({kind:"router_urls",pattern:D,targetExpr:c,name:q,line:B});else{const i=c.match(/^\(\s*([^,]+)\s*,/),g=i?i[1].trim():c;$e(g)===null&&/\.urls\b/.test(g)?s.push({kind:"router_urls",pattern:D,targetExpr:g,name:q,line:B}):s.push({kind:"include",pattern:D,targetExpr:g,name:q,line:B})}}else s.push({kind:"view",pattern:D,targetExpr:_,name:q,line:B});p.lastIndex=A.endIdx+1}const E=/([A-Za-z_][A-Za-z0-9_]*)\.urls\b/g;let x;for(;(x=E.exec(n))!==null;){const b=n.slice(Math.max(0,x.index-20),x.index);/include\s*\(\s*$/.test(b)||s.push({kind:"router_urls",pattern:"/",targetExpr:`${x[1]}.urls`,line:qe(r,t+x.index)})}return s}function it(n){const t=[],r=/['"]([A-Za-z]+)['"]/g;let s;for(;(s=r.exec(n))!==null;){const p=s[1].toLowerCase();un.has(p)&&t.push(p.toUpperCase())}return t}function _s(n){const t=n.split(".").pop()??n;return t==="ListCreateAPIView"?["GET","POST"]:t==="RetrieveUpdateDestroyAPIView"?["GET","PUT","PATCH","DELETE"]:t==="RetrieveUpdateAPIView"?["GET","PUT","PATCH"]:t==="RetrieveDestroyAPIView"?["GET","DELETE"]:t==="ListAPIView"||t==="RetrieveAPIView"||t==="TemplateView"||t==="ListView"||t==="DetailView"||t==="RedirectView"?["GET"]:t==="CreateAPIView"?["POST"]:t==="UpdateAPIView"?["PUT","PATCH"]:t==="DestroyAPIView"?["DELETE"]:[]}function Ns(n){const t=Ss(n.content),r=Ps(t),s=[],p=/\burlpatterns\s*(?:\+?=)\s*/g;let f;for(;(f=p.exec(t))!==null;){const a=f.index+f[0].length;if(t[a]==="["){const u=jt(t,a,"[","]");u&&s.push(...St(u.text,a+1,t))}else{const u=t.indexOf(`
|
|
12
|
+
`,a),l=t.slice(a,u===-1?t.length:u).match(/^([A-Za-z_][A-Za-z0-9_]*)\.urls\b/);l&&s.push({kind:"router_urls",pattern:"/",targetExpr:`${l[1]}.urls`,line:qe(t,f.index)})}}s.length===0&&(/(?:^|\/)urls\.py$/.test(n.path)||/\b(?:path|re_path)\s*\(/.test(t))&&/\b(?:from\s+django|include|path|re_path)\b/.test(t)&&s.push(...St(t,0,t));const E=new Set,x=/^([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(?:[\w.]+\.)?(?:DefaultRouter|SimpleRouter)\s*\(/gm;let b;for(;(b=x.exec(t))!==null;)E.add(b[1]);const j=[],P=/\b([A-Za-z_][A-Za-z0-9_]*)\.register\s*\(/g;let A;for(;(A=P.exec(t))!==null;){const a=A.index+A[0].length-1,u=jt(t,a,"(",")");if(!u)continue;const o=Qe(u.text);if(o.length<2)continue;const l=$e(o[0].replace(/^prefix\s*=\s*/,""));if(l===null)continue;const h=o[1].replace(/^viewset\s*=\s*/,"").trim();let y;for(const d of o.slice(2)){const v=d.match(/^basename\s*=\s*(['"])([^'"]+)\1$/);v&&(y=v[2])}j.push({routerVar:A[1],prefix:l.startsWith("/")?l:`/${l}`,viewSetExpr:h,basename:y,line:qe(t,A.index)})}const w=new Map,k=t.split(`
|
|
13
|
+
`),D=/^class\s+([A-Za-z_][A-Za-z0-9_]*)\s*(?:\(([^)]*)\))?\s*:/;let _=null,q=[];for(let a=0;a<k.length;a++){const u=k[a],o=u.trim();if(!o)continue;const l=u.length-u.trimStart().length;if(l===0){if(o.startsWith("@")){q.push(o);continue}const h=o.match(D);if(h){const y=h[2]?h[2].split(",").map(d=>d.trim()).filter(Boolean):[];_={name:h[1],bases:y,httpMethods:[],actions:[],viewSetActions:new Set,permissionClasses:[],line:a+1},w.set(h[1],_),q=[];continue}!o.startsWith("def ")&&!o.startsWith("async def ")&&(_=null,q=[])}if(l===0){const h=o.match(/^(?:async\s+)?def\s+([A-Za-z_][A-Za-z0-9_]*)\s*\(/);if(h){_=null;const y=[],d=q.slice();q=[];for(const v of d)if(v.startsWith("@api_view")){const S=it(v);y.push(...S.length>0?S:["GET"])}if(y.length===0){let v=a+1;for(;v<k.length;){const G=k[v];if(G.trim()&&G.length-G.trimStart().length===0)break;v++}const S=k.slice(a+1,v).join(`
|
|
14
|
+
`),I=new Set,O=/request\.method\s*(?:==|in)\s*(?:\[([^\]]+)\]|['"]([A-Za-z]+)['"])/g;let z;for(;(z=O.exec(S))!==null;){const G=it(z[1]||`'${z[2]}'`);for(const W of G)I.add(W)}I.size>0?y.push(...I):y.push("GET")}At.set(h[1],{name:h[1],methods:Array.from(new Set(y)),decorators:d.map(v=>v.replace(/^@/,"").split("(")[0]),line:a+1});continue}}if(_&&l>0){if(o.startsWith("@")){q.push(o);continue}const h=o.match(/^(?:async\s+)?def\s+([A-Za-z_][A-Za-z0-9_]*)\s*\(/);if(h){const y=h[1],d=q.slice();q=[],un.has(y)&&_.httpMethods.push(y.toUpperCase()),["list","create","retrieve","update","partial_update","destroy"].includes(y)&&_.viewSetActions.add(y);for(const v of d)if(v.startsWith("@action")){const S=v.match(/detail\s*=\s*(True|False)/),I=S?S[1]==="True":!1,O=v.match(/methods\s*=\s*\[([^\]]+)\]/),z=O?it(O[1]):["GET"],G=v.match(/url_path\s*=\s*['"]([^'"]+)['"]/),W=G?G[1]:y;_.actions.push({name:y,detail:I,methods:z.length>0?z:["GET"],urlPath:W,line:a+1})}}else{q=[];const y=o.match(/^serializer_class\s*=\s*([A-Za-z_][A-Za-z0-9_]*)/);y&&(_.serializerClass=y[1]);const d=o.match(/^permission_classes\s*=\s*\[([^\]]+)\]/);d&&(_.permissionClasses=d[1].split(",").map(v=>v.trim()).filter(Boolean))}}}const B=new Set,V=new Set,T=/^([A-Za-z_][A-Za-z0-9_]*)\s*=\s*NinjaAPI\s*\(/gm;let $;for(;($=T.exec(t))!==null;)B.add($[1]);const c=/^([A-Za-z_][A-Za-z0-9_]*)\s*=\s*Router\s*\(/gm;for(;($=c.exec(t))!==null;)V.add($[1]);const i=[],g=/@([A-Za-z_][A-Za-z0-9_]*)\.(get|post|put|patch|delete|api_operation)\s*\(([^)]*)\)[\s\S]*?(?:async\s+)?def\s+([A-Za-z_][A-Za-z0-9_]*)\s*\(/g;for(;($=g.exec(t))!==null;){const a=$[1];if(!B.has(a)&&!V.has(a))continue;const u=Qe($[3]),o=u[0]?$e(u[0])??"/":"/",l=$[2]==="api_operation"?it(u[0]||""):[$[2].toUpperCase()];i.push({targetVar:a,methods:l.length>0?l:["GET"],path:o.startsWith("/")?o:`/${o}`,handlerName:$[4],line:qe(t,$.index)})}const m=[],e=/\b([A-Za-z_][A-Za-z0-9_]*)\.add_router\s*\(([^)]+)\)/g;for(;($=e.exec(t))!==null;){const a=Qe($[2]);if(a.length<2)continue;const u=$e(a[0])??"/";m.push({parentVar:$[1],prefix:u.startsWith("/")?u:`/${u}`,childExpr:a[1].trim(),line:qe(t,$.index)})}return{path:n.path,imports:r,urlEntries:s,routerVars:E,routerRegs:j,classes:w,funcs:At,ninjaApis:B,ninjaRouters:V,ninjaRoutes:i,ninjaMounts:m}}var At;function ks(n){return At=new Map,Ns(n)}var Ms=class{constructor(){ue(this,"name","django")}detect(n){return n.some(s=>oe(s.path).endsWith("manage.py")&&/django|DJANGO_SETTINGS_MODULE/.test(s.content))||n.some(s=>{const p=oe(s.path);return(p==="requirements.txt"||p==="pyproject.toml"||p==="Pipfile")&&/\b(?:django|djangorestframework|django-ninja)\b/i.test(s.content)})?!0:n.some(s=>s.path.endsWith(".py")&&!Kt.test(s.path)&&/(?:from\s+django\.|import\s+django\b|from\s+rest_framework\b|from\s+ninja\b)/.test(s.content))}scan(n,t){const r=performance.now(),s=n.map(e=>({path:oe(e.path),content:e.content})).filter(e=>e.path.endsWith(".py")&&!Kt.test(e.path)),p=new Set(s.map(e=>e.path)),f=new Map;for(const e of s)f.set(e.path,ks(e));const E=[],x=[],b=new Set,j=new Set,P=[],A=e=>{b.has(e.id)||(b.add(e.id),E.push(e))},w=e=>{j.has(e.id)||(j.add(e.id),x.push(e))};let k=null;for(const e of s){const a=e.content.match(/ROOT_URLCONF\s*=\s*['"]([.\w]+)['"]/);if(a&&(k=at(a[1],p),k))break}const D=new Set;for(const e of f.values())for(const a of e.urlEntries)if(a.kind==="include"){const u=$e(a.targetExpr),o=u?at(u,p):(()=>{const l=e.imports.get(a.targetExpr.split(".")[0]);return l?Be(e.path,l,p):null})();o&&D.add(o)}const _=[];if(k)_.push(k);else{for(const e of f.values())(e.urlEntries.length>0||e.ninjaApis.size>0)&&!D.has(e.path)&&_.push(e.path);if(_.length===0){const e=s.find(a=>/(?:^|\/)urls\.py$/.test(a.path));e&&_.push(e.path)}}const q=new Set,B=new Set,V=(e,a)=>{let u=a.trim(),o=!1;const l=u.match(/^([.\w]+)\.as_view\s*\(/);l&&(u=l[1],o=!0);const h=u.split("."),y=f.get(e);if(!y)return{file:e,symbol:u,isAsView:o};if(h.length===1){const v=y.imports.get(h[0]);if(v){const S=Be(e,v,p);if(S)return{file:S,symbol:v.importedName==="*"?h[0]:v.importedName,isAsView:o}}return{file:e,symbol:h[0],isAsView:o}}const d=y.imports.get(h[0]);if(d){const v=Be(e,d,p);if(v)return{file:v,symbol:h[h.length-1],isAsView:o};if(d.importedName==="*"){const S=`${d.modulePath}.${h.slice(1,-1).join(".")}`.replace(/\.$/,""),I=at(S,p);if(I)return{file:I,symbol:h[h.length-1],isAsView:o}}}return{file:e,symbol:h[h.length-1],isAsView:o}},T=(e,a,u,o,l,h,y)=>{var S,I;const d=u||"/",v=`route:${a}:${d}`;A({id:v,type:"route",label:`${a} ${d}`,file:o,line:l,method:a,fullPath:d,pathParams:fe(d),group:me(d),middlewares:(S=y==null?void 0:y.middlewares)!=null&&S.length?y.middlewares:void 0,bodyFields:(I=y==null?void 0:y.bodyFields)!=null&&I.length?y.bodyFields:void 0,controller:(y==null?void 0:y.controller)??h,controllerFile:(y==null?void 0:y.controllerFile)??o,controllerLine:(y==null?void 0:y.controllerLine)??l}),w({id:`edge:${e}->${v}`,source:e,target:v,type:"handles"})},$=(e,a,u,o)=>{var N;const l=C=>C.endsWith("/")?C:`${C}/`,h=l(ne(a,u.prefix)),y=l(ne(h,":id")),d=V(o,u.viewSetExpr),v=f.get(d.file),S=v==null?void 0:v.classes.get(d.symbol),I=(N=S==null?void 0:S.permissionClasses)!=null&&N.length?S.permissionClasses:void 0,O=S!=null&&S.serializerClass?[S.serializerClass]:void 0,z=S?d.file:o,G=S?S.line:u.line,W=(S==null?void 0:S.bases.some(C=>/ReadOnlyModelViewSet/.test(C)))??!1,H=(S==null?void 0:S.bases.some(C=>/ModelViewSet/.test(C)))??!1;if(S&&S.viewSetActions.size>0&&!H?(S.viewSetActions.has("list")&&T(e,"GET",h,z,G,`${d.symbol}.list`,{middlewares:I,bodyFields:O}),S.viewSetActions.has("create")&&T(e,"POST",h,z,G,`${d.symbol}.create`,{middlewares:I,bodyFields:O}),S.viewSetActions.has("retrieve")&&T(e,"GET",y,z,G,`${d.symbol}.retrieve`,{middlewares:I,bodyFields:O}),S.viewSetActions.has("update")&&T(e,"PUT",y,z,G,`${d.symbol}.update`,{middlewares:I,bodyFields:O}),S.viewSetActions.has("partial_update")&&T(e,"PATCH",y,z,G,`${d.symbol}.partial_update`,{middlewares:I,bodyFields:O}),S.viewSetActions.has("destroy")&&T(e,"DELETE",y,z,G,`${d.symbol}.destroy`,{middlewares:I,bodyFields:O})):W?(T(e,"GET",h,z,G,`${d.symbol}.list`,{middlewares:I,bodyFields:O}),T(e,"GET",y,z,G,`${d.symbol}.retrieve`,{middlewares:I,bodyFields:O})):(T(e,"GET",h,z,G,`${d.symbol}.list`,{middlewares:I,bodyFields:O}),T(e,"POST",h,z,G,`${d.symbol}.create`,{middlewares:I,bodyFields:O}),T(e,"GET",y,z,G,`${d.symbol}.retrieve`,{middlewares:I,bodyFields:O}),T(e,"PUT",y,z,G,`${d.symbol}.update`,{middlewares:I,bodyFields:O}),T(e,"PATCH",y,z,G,`${d.symbol}.partial_update`,{middlewares:I,bodyFields:O}),T(e,"DELETE",y,z,G,`${d.symbol}.destroy`,{middlewares:I,bodyFields:O})),S)for(const C of S.actions){const R=C.detail?y:h,M=l(ne(R,C.urlPath));for(const F of C.methods)T(e,F,M,z,C.line,`${d.symbol}.${C.name}`,{middlewares:I,bodyFields:O})}},c=(e,a,u,o)=>{const l=o.replace(/\.urls$/,"").trim(),h=f.get(u);if(!h)return;let y=u,d=h.routerRegs.filter(v=>v.routerVar===l);if(d.length===0){const v=l.split("."),S=h.imports.get(v[0]);if(S){const I=Be(u,S,p);if(I&&f.has(I)){y=I;const O=f.get(I),z=S.importedName==="*"?v[v.length-1]:S.importedName;d=O.routerRegs.filter(G=>G.routerVar===z)}}}B.add(`${y}:${l}`);for(const v of d)$(e,a,v,y)},i=(e,a,u,o)=>{for(const l of o){const h=ne(a,l.pattern);if(l.kind==="inline"&&l.inlineEntries){const y=`router:${u}:${h}:${l.line}`;A({id:y,type:"router",label:l.pattern,file:u,line:l.line}),w({id:`edge:${e}->${y}`,source:e,target:y,type:"mounts",label:l.pattern}),i(y,h,u,l.inlineEntries)}else if(l.kind==="include"){const y=$e(l.targetExpr);let d=null;if(y)d=at(y,p);else{const v=f.get(u),S=v==null?void 0:v.imports.get(l.targetExpr.split(".")[0]);S&&(d=Be(u,S,p))}if(d&&f.has(d)){const v=`router:${d}:${h}`;if(A({id:v,type:"router",label:l.pattern,file:d,line:l.line}),w({id:`edge:${e}->${v}`,source:e,target:v,type:"mounts",label:l.pattern}),!q.has(`${d}@${h}`)){q.add(`${d}@${h}`);const S=f.get(d);i(v,h,d,S.urlEntries)}}else P.push(`${u}:${l.line} -> ${l.targetExpr}`)}else if(l.kind==="router_urls")c(e,h,u,l.targetExpr);else if(l.kind==="view"){if(l.targetExpr.endsWith(".urls")){const I=l.targetExpr.replace(/\.urls$/,"").trim(),O=V(u,I),z=f.get(O.file);if(z!=null&&z.ninjaApis.has(O.symbol)){g(e,h,O.file,O.symbol);continue}c(e,h,u,l.targetExpr);continue}const y=V(u,l.targetExpr),d=f.get(y.file),v=d==null?void 0:d.classes.get(y.symbol),S=d==null?void 0:d.funcs.get(y.symbol);if(v){const I=v.bases.flatMap(_s),O=Array.from(new Set([...v.httpMethods,...I])),z=O.length>0?O:["GET"],G=v.permissionClasses.length?v.permissionClasses:void 0,W=v.serializerClass?[v.serializerClass]:void 0;for(const H of z)T(e,H,h,y.file,v.line,y.symbol,{middlewares:G,bodyFields:W})}else if(S){const I=S.decorators.filter(O=>O!=="api_view");for(const O of S.methods)T(e,O,h,y.file,S.line,y.symbol,{middlewares:I})}else T(e,"GET",h,u,l.line,l.targetExpr)}}},g=(e,a,u,o)=>{const l=f.get(u);if(l){for(const h of l.ninjaRoutes){if(h.targetVar!==o)continue;const y=ne(a,h.path);for(const d of h.methods)T(e,d,y,u,h.line,h.handlerName)}for(const h of l.ninjaMounts){if(h.parentVar!==o)continue;const y=ne(a,h.prefix),d=V(u,h.childExpr);g(e,y,d.file,d.symbol)}}};for(const e of _){const a=`entry:${e}`;A({id:a,type:"entry",label:e,file:e,line:1}),q.add(`${e}@/`);const u=f.get(e);i(a,"/",e,u.urlEntries);for(const o of u.ninjaApis)g(a,"/",e,o)}for(const e of f.values()){if(!Array.from(q).some(u=>u.startsWith(`${e.path}@`))&&e.urlEntries.length>0){const u=`entry:${e.path}`;A({id:u,type:"entry",label:e.path,file:e.path,line:1}),q.add(`${e.path}@/`),i(u,"/",e.path,e.urlEntries)}for(const u of e.routerRegs)if(!B.has(`${e.path}:${u.routerVar}`)){const o=`entry:${e.path}`;A({id:o,type:"entry",label:e.path,file:e.path,line:1}),$(o,"/",u,e.path)}}const m=Number((performance.now()-r).toFixed(2));return{version:"1.0",metadata:{repoName:(t==null?void 0:t.repoName)??"unknown",framework:"django",scannedFiles:n.length,scanDurationMs:m,unresolvedMounts:P},nodes:E,edges:x}}},Jt=/(?:^|\/)(?:tests?|__tests__|vendor)\/|_test\.go$/i,Ts={GET:"GET",Get:"GET",POST:"POST",Post:"POST",PUT:"PUT",Put:"PUT",PATCH:"PATCH",Patch:"PATCH",DELETE:"DELETE",Delete:"DELETE",OPTIONS:"OPTIONS",Options:"OPTIONS",HEAD:"HEAD",Head:"HEAD",Any:"ALL",All:"ALL"};function Oe(n,t){let r=1;for(let s=0;s<t&&s<n.length;s++)n[s]===`
|
|
15
|
+
`&&r++;return r}function Cs(n){let t="",r=null;for(let s=0;s<n.length;s++){const p=n[s];if(r){if(t+=p,r!=="`"&&p==="\\"&&s+1<n.length){t+=n[++s];continue}p===r&&(r=null);continue}if(p==='"'||p==="'"||p==="`"){r=p,t+=p;continue}if(p==="/"&&n[s+1]==="/"){for(;s<n.length&&n[s]!==`
|
|
16
|
+
`;)t+=" ",s++;s<n.length&&(t+=`
|
|
17
|
+
`);continue}if(p==="/"&&n[s+1]==="*"){for(t+=" ",s+=2;s<n.length&&!(n[s]==="*"&&n[s+1]==="/");)t+=n[s]===`
|
|
18
|
+
`?`
|
|
19
|
+
`:" ",s++;s<n.length&&(t+=" ",s++);continue}t+=p}return t}function Ne(n,t,r,s){if(n[t]!==r)return null;let p=0,f=null;for(let E=t;E<n.length;E++){const x=n[E];if(f){if(f!=="`"&&x==="\\"){E++;continue}x===f&&(f=null);continue}if(x==='"'||x==="'"||x==="`"){f=x;continue}if(x===r)p++;else if(x===s&&(p--,p===0))return{text:n.slice(t+1,E),endIdx:E}}return null}function ke(n){const t=[];let r=0,s=0,p=0,f=null,E=0;for(let b=0;b<n.length;b++){const j=n[b];if(f){if(f!=="`"&&j==="\\"){b++;continue}j===f&&(f=null);continue}if(j==='"'||j==="'"||j==="`"){f=j;continue}if(j==="(")r++;else if(j===")")r--;else if(j==="[")s++;else if(j==="]")s--;else if(j==="{")p++;else if(j==="}")p--;else if(j===","&&r===0&&s===0&&p===0){const P=n.slice(E,b).trim();P&&t.push(P),E=b+1}}const x=n.slice(E).trim();return x&&t.push(x),t}function je(n){const t=n.trim(),r=t.match(/^"([^"\\]*(?:\\.[^"\\]*)*)"$/)||t.match(/^`([^`]*)`$/);return r?r[1]:null}function Ae(n){let t=n.trim();return t=t.replace(/\{([A-Za-z_][A-Za-z0-9_]*)(?::[^}]*|\.\.\.)?\}/g,":$1"),t?t.startsWith("/")?t:`/${t}`:"/"}function Is(n){const t=n.trim(),r=t.match(/^(GET|POST|PUT|PATCH|DELETE|OPTIONS|HEAD)\s+(.+)$/i);return r?{method:r[1].toUpperCase(),path:Ae(r[2])}:{method:"GET",path:Ae(t)}}function ve(n){const t=n.trim();return t.match(/^func\s*\(/)?"anonymous":t.replace(/\([^)]*\)$/,"").trim()||"handler"}function Fs(n){const t=n.map(r=>r.content).join(`
|
|
20
|
+
`);return/github\.com\/gin-gonic\/gin/.test(t)?"gin":/github\.com\/labstack\/echo/.test(t)?"echo":/github\.com\/gofiber\/fiber/.test(t)?"fiber":/github\.com\/go-chi\/chi/.test(t)?"chi":/github\.com\/gorilla\/mux/.test(t)?"gorilla-mux":"go-http"}var Rs=class{constructor(){ue(this,"name","go")}detect(n){return n.some(r=>oe(r.path).endsWith("go.mod")&&/(?:github\.com\/(?:gin-gonic\/gin|labstack\/echo|gofiber\/fiber|go-chi\/chi|gorilla\/mux)|golang\.org)/i.test(r.content))?!0:n.some(r=>r.path.endsWith(".go")&&!Jt.test(r.path)&&/(?:github\.com\/(?:gin-gonic\/gin|labstack\/echo|gofiber\/fiber|go-chi\/chi|gorilla\/mux)|http\.(?:HandleFunc|NewServeMux|Handle)\s*\()/.test(r.content))}scan(n,t){const r=performance.now(),s=n.map(i=>({path:oe(i.path),content:i.content})).filter(i=>i.path.endsWith(".go")&&!Jt.test(i.path)),p=Fs(n),f=[],E=[],x=new Set,b=new Set,j=i=>{x.has(i.id)||(x.add(i.id),f.push(i))},P=i=>{b.has(i.id)||(b.add(i.id),E.push(i))},A=new Map,w=/(?:\*?gin\.(?:Engine|RouterGroup|IRouter|IRoutes)|\*?echo\.(?:Echo|Group)|fiber\.Router|\*?fiber\.App|chi\.Router|\*?mux\.Router|\*?http\.ServeMux)/,k=new Map,D=new Map;for(const i of s){const g=Cs(i.content);k.set(i.path,g);const m=g.match(/^\s*package\s+([A-Za-z_][A-Za-z0-9_]*)/m),e=m?m[1]:"main";D.set(i.path,e);const a=/\bfunc\s*(?:\([^)]+\)\s*)?([A-Za-z_][A-Za-z0-9_]*)\s*\(([^)]*)\)/g;let u;for(;(u=a.exec(g))!==null;){const o=u[1],l=u[2],h=u.index+u[0].length;let y=g.indexOf("{",h);if(y===-1)continue;const d=Ne(g,y,"{","}");if(!d)continue;const v=[];for(const O of ke(l))if(w.test(O)){const z=O.replace(w,"").trim().split(/\s*,\s*/);for(const G of z)/^[A-Za-z_][A-Za-z0-9_]*$/.test(G)&&v.push(G)}const S={name:o,pkg:e,file:i.path,line:Oe(g,u.index),routerParams:v,body:d.text,bodyStartIdx:y+1},I=A.get(o)??[];I.push(S),A.set(o,I),a.lastIndex=d.endIdx+1}}const _=(i,g,m,e,a,u,o)=>{const l=m||"/",h=`route:${g}:${l}`;j({id:h,type:"route",label:`${g} ${l}`,file:e,line:a,method:g,fullPath:l,pathParams:fe(l),group:me(l),middlewares:o!=null&&o.length?o:void 0,controller:u,controllerFile:e,controllerLine:a}),P({id:`edge:${i}->${h}`,source:i,target:h,type:"handles"})},q=new Set,B=(i,g,m,e,a,u)=>{const o=new Map(a),l=/\b([A-Za-z_][A-Za-z0-9_]*)\s*:?=\s*(?:gin\.(?:Default|New)|echo\.New|fiber\.New|chi\.New(?:Router)?|mux\.NewRouter|http\.NewServeMux)\s*\(/g;let h;for(;(h=l.exec(i))!==null;){const R=h[1];o.has(R)||o.set(R,{varName:R,prefix:"/",middlewares:[],nodeId:u})}const y=/\b([A-Za-z_][A-Za-z0-9_]*)\s*:?=\s*([A-Za-z_][A-Za-z0-9_]*)\.(?:Group|PathPrefix)\s*\(/g;let d;for(;(d=y.exec(i))!==null;){const R=d[1],M=d[2],F=d.index+d[0].length-1,Z=Ne(i,F,"(",")");if(!Z)continue;const U=ke(Z.text),J=U[0]?je(U[0]):null;if(J===null)continue;const K=o.get(M)??{prefix:"/",middlewares:[],nodeId:u},Q=ne(K.prefix,Ae(J)),te=[...K.middlewares,...U.slice(1).map(ve)],re=`router:${e}:${Q}:${Oe(m,g+d.index)}`;j({id:re,type:"router",label:J,file:e,line:Oe(m,g+d.index)}),P({id:`edge:${K.nodeId}->${re}`,source:K.nodeId,target:re,type:"mounts",label:J}),o.set(R,{varName:R,prefix:Q,middlewares:te,nodeId:re})}const v=/\b([A-Za-z_][A-Za-z0-9_]*)\.Use\s*\(/g;let S;for(;(S=v.exec(i))!==null;){const R=o.get(S[1]);if(!R)continue;const M=S.index+S[0].length-1,F=Ne(i,M,"(",")");if(F)for(const Z of ke(F.text))R.middlewares.push(ve(Z))}const I=/\b([A-Za-z_][A-Za-z0-9_]*)\.(Route|Group)\s*\(/g,O=[];let z;for(;(z=I.exec(i))!==null;){const R=z[1],M=z[2],F=z.index+z[0].length-1,Z=Ne(i,F,"(",")");if(!Z)continue;const U=ke(Z.text),J=M==="Route"?U[1]:U[0];if(!J||!/^func\s*\(/.test(J.trim()))continue;const K=o.get(R)??{prefix:"/",middlewares:[],nodeId:u},Q=M==="Route"&&U[0]?je(U[0])??"/":"/",te=ne(K.prefix,Ae(Q)),re=J.match(/^func\s*\(\s*([A-Za-z_][A-Za-z0-9_]*)/),ie=re?re[1]:R,Y=J.indexOf("{"),se=Y!==-1?Ne(J,Y,"{","}"):null;if(se){const ee=`router:${e}:${te}:${Oe(m,g+z.index)}`;j({id:ee,type:"router",label:Q,file:e,line:Oe(m,g+z.index)}),P({id:`edge:${K.nodeId}->${ee}`,source:K.nodeId,target:ee,type:"mounts",label:Q});const ce=new Map(o);ce.set(ie,{varName:ie,prefix:te,middlewares:[...K.middlewares],nodeId:ee}),O.push([F,Z.endIdx]),B(se.text,g+z.index,m,e,ce,u)}I.lastIndex=Z.endIdx+1}const G=R=>O.some(([M,F])=>R>=M&&R<=F),W=/\b([A-Za-z_][A-Za-z0-9_]*)\.(GET|Get|POST|Post|PUT|Put|PATCH|Patch|DELETE|Delete|OPTIONS|Options|HEAD|Head|Any|All|HandleFunc|Handle|Add|Method)\s*\(/g;let H;for(;(H=W.exec(i))!==null;){if(G(H.index))continue;const R=H[1],M=H[2],F=H.index+H[0].length-1,Z=Ne(i,F,"(",")");if(!Z)continue;const U=ke(Z.text),J=Oe(m,g+H.index),K=o.get(R)??{prefix:"/",middlewares:[],nodeId:u};if(M==="Add"||M==="Method"||M==="Handle"&&U.length>=3&&je(U[1])!==null){const Q=U[0]?je(U[0]):null,te=U[1]?je(U[1]):null;if(Q&&te!==null){const re=Q.toUpperCase()||"GET",ie=ne(K.prefix,Ae(te)),Y=U[2]?ve(U[2]):"handler",se=[...K.middlewares,...U.slice(3).map(ve)];_(K.nodeId,re,ie,e,J,Y,se)}}else if(M==="HandleFunc"||M==="Handle"){const Q=U[0]?je(U[0]):null;if(Q!==null){const re=i.slice(Z.endIdx+1,Z.endIdx+80).match(/^\s*\.Methods\s*\(([^)]+)\)/);if(re){const ie=ne(K.prefix,Ae(Q)),Y=U[1]?ve(U[1]):"handler",se=re[1].match(/"([A-Za-z]+)"/g)??[];for(const ee of se){const ce=ee.replace(/"/g,"").toUpperCase();_(K.nodeId,ce,ie,e,J,Y,K.middlewares)}}else{const ie=Is(Q),Y=ne(K.prefix,ie.path),se=U[1]?ve(U[1]):"handler";_(K.nodeId,ie.method,Y,e,J,se,K.middlewares)}}}else{const Q=Ts[M]??"GET",te=U[0]?je(U[0]):null;if(te!==null){const re=ne(K.prefix,Ae(te)),ie=U.length>=2?ve(U[U.length-1]):"handler",Y=U.length>2?[...K.middlewares,...U.slice(1,-1).map(ve)]:K.middlewares;_(K.nodeId,Q,re,e,J,ie,Y)}}W.lastIndex=Z.endIdx+1}const N=/\b(?:([A-Za-z_][A-Za-z0-9_]*)\.)?([A-Za-z_][A-Za-z0-9_]*)\s*\(/g;let C;for(;(C=N.exec(i))!==null;){if(G(C.index))continue;const R=C[2],M=A.get(R);if(!M||M.length===0)continue;const F=C.index+C[0].length-1,Z=Ne(i,F,"(",")");if(!Z)continue;const U=ke(Z.text);for(let J=0;J<U.length;J++){const K=U[J].trim();let Q=o.get(K);if(!Q){const te=K.match(/^([A-Za-z_][A-Za-z0-9_]*)\.(?:Group|PathPrefix)\s*\(([\s\S]*)\)$/);if(te){const re=o.get(te[1]),ie=ke(te[2]),Y=ie[0]?je(ie[0]):null;re&&Y!==null&&(Q={varName:K,prefix:ne(re.prefix,Ae(Y)),middlewares:[...re.middlewares,...ie.slice(1).map(ve)],nodeId:re.nodeId})}}if(Q)for(const te of M){if(te.routerParams.length===0)continue;const re=te.routerParams[0],ie=`${te.file}:${te.name}@${Q.prefix}`;if(q.has(ie))continue;q.add(ie);const Y=k.get(te.file)??te.body,se=new Map;se.set(re,{varName:re,prefix:Q.prefix,middlewares:[...Q.middlewares],nodeId:Q.nodeId}),B(te.body,te.bodyStartIdx,Y,te.file,se,u)}}}},V=s.filter(i=>/\bfunc\s+main\s*\(/.test(k.get(i.path)??"")),T=[...V,...s.filter(i=>!V.includes(i))];for(const i of T){const g=k.get(i.path);if(/\b(?:gin\.(?:Default|New)|echo\.New|fiber\.New|chi\.New(?:Router)?|mux\.NewRouter|http\.(?:NewServeMux|HandleFunc|Handle))\b/.test(g)){const e=`entry:${i.path}`;j({id:e,type:"entry",label:i.path,file:i.path,line:1});const a=new Map;a.set("http",{varName:"http",prefix:"/",middlewares:[],nodeId:e}),B(g,0,g,i.path,a,e)}}for(const i of A.values())for(const g of i){if(g.routerParams.length===0||Array.from(q).some(o=>o.startsWith(`${g.file}:${g.name}@`)))continue;const e=`entry:${g.file}`;j({id:e,type:"entry",label:g.file,file:g.file,line:1});const a=k.get(g.file)??g.body,u=new Map;u.set(g.routerParams[0],{varName:g.routerParams[0],prefix:"/",middlewares:[],nodeId:e}),q.add(`${g.file}:${g.name}@/`),B(g.body,g.bodyStartIdx,a,g.file,u,e)}const $=new Set(f.filter(i=>i.type==="entry").map(i=>i.file));for(const i of s){if($.has(i.path)||Array.from(q).some(e=>e.startsWith(`${i.path}:`)))continue;const m=k.get(i.path);if(/\.(?:GET|Get|POST|Post|PUT|Put|PATCH|Patch|DELETE|Delete|Any|All|HandleFunc)\s*\(\s*["`][^"`]*\//.test(m)){const e=`entry:${i.path}`;j({id:e,type:"entry",label:i.path,file:i.path,line:1}),B(m,0,m,i.path,new Map,e)}}const c=Number((performance.now()-r).toFixed(2));return{version:"1.0",metadata:{repoName:(t==null?void 0:t.repoName)??"unknown",framework:p,scannedFiles:n.length,scanDurationMs:c,unresolvedMounts:[]},nodes:f,edges:E}}},Yt=/(?:^|\/)(?:tests?|benches|examples|target)\/|_test\.rs$/i,Xt=new Set(["get","post","put","patch","delete","head","options"]);function Se(n,t){let r=1;for(let s=0;s<t&&s<n.length;s++)n[s]===`
|
|
21
|
+
`&&r++;return r}function zs(n){let t="",r=!1,s=0;for(let p=0;p<n.length;p++){const f=n[p];if(s>0){f==="/"&&n[p+1]==="*"?(s++,t+=" ",p++):f==="*"&&n[p+1]==="/"?(s--,t+=" ",p++):t+=f===`
|
|
22
|
+
`?`
|
|
23
|
+
`:" ";continue}if(r){if(t+=f,f==="\\"&&p+1<n.length){t+=n[++p];continue}f==='"'&&(r=!1);continue}if(f==='"'){r=!0,t+=f;continue}if(f==="/"&&n[p+1]==="/"){for(;p<n.length&&n[p]!==`
|
|
24
|
+
`;)t+=" ",p++;p<n.length&&(t+=`
|
|
25
|
+
`);continue}if(f==="/"&&n[p+1]==="*"){s=1,t+=" ",p++;continue}t+=f}return t}function Ee(n,t,r,s){if(n[t]!==r)return null;let p=0,f=!1;for(let E=t;E<n.length;E++){const x=n[E];if(f){if(x==="\\"){E++;continue}x==='"'&&(f=!1);continue}if(x==='"'){f=!0;continue}if(x===r)p++;else if(x===s&&(p--,p===0))return{text:n.slice(t+1,E),endIdx:E}}return null}function Ue(n){const t=[];let r=0,s=0,p=0,f=!1,E=0;for(let b=0;b<n.length;b++){const j=n[b];if(f){if(j==="\\"){b++;continue}j==='"'&&(f=!1);continue}if(j==='"'){f=!0;continue}if(j==="(")r++;else if(j===")")r--;else if(j==="[")s++;else if(j==="]")s--;else if(j==="{")p++;else if(j==="}")p--;else if(j===","&&r===0&&s===0&&p===0){const P=n.slice(E,b).trim();P&&t.push(P),E=b+1}}const x=n.slice(E).trim();return x&&t.push(x),t}function Ve(n){const t=n.trim(),r=t.match(/^"([^"\\]*(?:\\.[^"\\]*)*)"$/)||t.match(/^r#*"([\s\S]*?)"#*$/);return r?r[1]:null}function Ke(n){let t=n.trim();return t=t.replace(/\{\*?([A-Za-z_][A-Za-z0-9_]*)(?::[^}]*)?\}/g,":$1"),t=t.replace(/<([A-Za-z_][A-Za-z0-9_]*)(?:\.\.)?>/g,":$1"),t?t.startsWith("/")?t:`/${t}`:"/"}function Os(n){const t=n.map(r=>r.content).join(`
|
|
26
|
+
`);return/\baxum\b/.test(t)?"axum":/\bactix[-_]web\b/.test(t)?"actix-web":/\brocket\b/.test(t)?"rocket":"rust"}var Ds=class{constructor(){ue(this,"name","rust")}detect(n){return n.some(r=>oe(r.path).endsWith("Cargo.toml")&&/\b(?:axum|actix-web|rocket)\b/i.test(r.content))?!0:n.some(r=>r.path.endsWith(".rs")&&!Yt.test(r.path)&&/(?:use\s+(?:axum|actix_web|rocket)|Router::new\s*\(|App::new\s*\(|rocket::build\s*\()/.test(r.content))}scan(n,t){const r=performance.now(),s=n.map(c=>({path:oe(c.path),content:c.content})).filter(c=>c.path.endsWith(".rs")&&!Yt.test(c.path)),p=Os(n),f=[],E=[],x=new Set,b=new Set,j=c=>{x.has(c.id)||(x.add(c.id),f.push(c))},P=c=>{b.has(c.id)||(b.add(c.id),E.push(c))},A=(c,i,g,m,e,a,u)=>{const o=g||"/",l=`route:${i}:${o}`;j({id:l,type:"route",label:`${i} ${o}`,file:m,line:e,method:i,fullPath:o,pathParams:fe(o),group:me(o),middlewares:void 0,controller:a,controllerFile:m,controllerLine:e}),P({id:`edge:${c}->${l}`,source:c,target:l,type:"handles"})},w=new Map,k=new Map,D=new Map;for(const c of s){const i=zs(c.content);w.set(c.path,i);const g=/((?:#\[(?:(?:actix_web|rocket)::)?(?:get|post|put|patch|delete|head|options|route)\s*\([^)]*\)\]\s*)+)(?:pub(?:\([^)]*\))?\s+)?(?:async\s+)?fn\s+([A-Za-z_][A-Za-z0-9_]*)\s*\(/g;let m;for(;(m=g.exec(i))!==null;){const u=m[1],o=m[2],l=[],h=/#\[(?:(?:actix_web|rocket)::)?(get|post|put|patch|delete|head|options|route)\s*\(([^)]*)\)\]/g;let y;for(;(y=h.exec(u))!==null;){const d=y[1].toLowerCase(),v=Ue(y[2]),S=v[0]?Ve(v[0]):null;if(S===null)continue;const I=Ke(S),O=Se(i,m.index);if(d==="route"){const z=y[2].match(/method\s*=\s*"([A-Za-z]+)"/g)??[];if(z.length>0)for(const G of z){const W=G.match(/"([A-Za-z]+)"/)[1].toUpperCase();l.push({method:W,path:I,handler:o,line:O})}else l.push({method:"GET",path:I,handler:o,line:O})}else Xt.has(d)&&l.push({method:d.toUpperCase(),path:I,handler:o,line:O})}if(l.length>0){const d=k.get(o)??[];d.push({name:o,file:c.path,line:Se(i,m.index),routes:l}),k.set(o,d)}}const e=/\b(?:pub(?:\([^)]*\))?\s+)?(?:async\s+)?fn\s+([A-Za-z_][A-Za-z0-9_]*)\s*(?:<[^>]*>)?\s*\(([^)]*)\)(?:\s*->\s*([^{]+))?\s*\{/g;let a;for(;(a=e.exec(i))!==null;){const u=a[1],o=a[2],l=a[3]??"",h=a.index+a[0].length-1,y=Ee(i,h,"{","}");if(!y)continue;const d={name:u,file:c.path,line:Se(i,a.index),isServiceConfig:/ServiceConfig/.test(o),returnsRouter:/\bRouter\b/.test(l),body:y.text,bodyOffset:h+1},v=D.get(u)??[];v.push(d),D.set(u,v),e.lastIndex=y.endIdx+1}}const _=new Set,q=new Set,B=c=>{const i=[],g=/\b(?:(?:axum::)?routing::)?(get|post|put|patch|delete|options|head|any)\s*\(/g;let m;for(;(m=g.exec(c))!==null;){const e=m.index+m[0].length-1,a=Ee(c,e,"(",")");if(!a)continue;const u=m[1].toLowerCase(),o=u==="any"?"ALL":u.toUpperCase(),l=a.text.trim().replace(/\s+/g," ");i.push({method:o,handler:l||"handler"}),g.lastIndex=a.endIdx+1}return i},V=c=>{const i=[],g=/\bweb::(get|post|put|patch|delete|head|to|route)\s*\(/g;let m;for(;(m=g.exec(c))!==null;){const e=m[1].toLowerCase(),u=c.slice(m.index).match(/\.to\s*\(([^)]+)\)/),o=u?u[1].trim():"handler";if(Xt.has(e))i.push({method:e.toUpperCase(),handler:o});else if(e==="to"){const l=m.index+m[0].length-1,h=Ee(c,l,"(",")");i.push({method:"GET",handler:h?h.text.trim():"handler"})}}return i},T=(c,i,g,m,e,a)=>{const u=/\.route\s*\(/g;let o;for(;(o=u.exec(c))!==null;){const W=o.index+o[0].length-1,H=Ee(c,W,"(",")");if(!H)continue;const N=Ue(H.text),C=N[0]?Ve(N[0]):null;if(C!==null&&N[1]){const R=ne(e,Ke(C)),M=Se(g,i+o.index),F=B(N[1]);if(F.length>0)for(const Z of F)A(a,Z.method,R,m,M,Z.handler);else{const Z=V(N[1]);for(const U of Z)A(a,U.method,R,m,M,U.handler)}}u.lastIndex=H.endIdx+1}const l=/\.nest(?:_service)?\s*\(/g;let h;for(;(h=l.exec(c))!==null;){const W=h.index+h[0].length-1,H=Ee(c,W,"(",")");if(!H)continue;const N=Ue(H.text),C=N[0]?Ve(N[0]):null;if(C!==null&&N[1]){const R=ne(e,Ke(C)),M=N[1].trim(),F=M.match(/([A-Za-z_][A-Za-z0-9_]*)\s*\(/),Z=F?F[1]:M,U=D.get(Z);if(U&&U.length>0){const J=`router:${m}:${R}:${Se(g,i+h.index)}`;j({id:J,type:"router",label:C,file:m,line:Se(g,i+h.index)}),P({id:`edge:${a}->${J}`,source:a,target:J,type:"mounts",label:C});for(const K of U){const Q=`${K.file}:${K.name}@${R}`;if(q.has(Q))continue;q.add(Q);const te=w.get(K.file)??K.body;T(K.body,K.bodyOffset,te,K.file,R,J)}}}l.lastIndex=H.endIdx+1}const y=/\bweb::scope\s*\(/g;let d;for(;(d=y.exec(c))!==null;){const W=d.index+d[0].length-1,H=Ee(c,W,"(",")");if(!H)continue;const N=Ue(H.text),C=N[0]?Ve(N[0]):null;if(C!==null){const R=ne(e,Ke(C)),M=`router:${m}:${R}:${Se(g,i+d.index)}`;j({id:M,type:"router",label:C,file:m,line:Se(g,i+d.index)}),P({id:`edge:${a}->${M}`,source:a,target:M,type:"mounts",label:C});const F=c.slice(H.endIdx+1),Z=F.search(/;|\n\s*\)/),U=Z===-1?F:F.slice(0,Z);T(U,i+H.endIdx+1,g,m,R,M)}}const v=/\.service\s*\(/g;let S;for(;(S=v.exec(c))!==null;){const W=S.index+S[0].length-1,H=Ee(c,W,"(",")");if(!H)continue;const N=H.text.trim();if(!N.startsWith("web::")){const C=N.split("::").pop()??N,R=k.get(C);if(R)for(const M of R){_.add(`${M.file}:${M.name}`);for(const F of M.routes)A(a,F.method,ne(e,F.path),M.file,F.line,M.name)}}v.lastIndex=H.endIdx+1}const I=/\.configure\s*\(/g;let O;for(;(O=I.exec(c))!==null;){const W=O.index+O[0].length-1,H=Ee(c,W,"(",")");if(!H)continue;const N=H.text.trim().split("::").pop()??H.text.trim(),C=D.get(N);if(C)for(const R of C){const M=`${R.file}:${R.name}@${e}`;if(q.has(M))continue;q.add(M);const F=w.get(R.file)??R.body;T(R.body,R.bodyOffset,F,R.file,e,a)}I.lastIndex=H.endIdx+1}const z=/\.mount\s*\(/g;let G;for(;(G=z.exec(c))!==null;){const W=G.index+G[0].length-1,H=Ee(c,W,"(",")");if(!H)continue;const N=Ue(H.text),C=N[0]?Ve(N[0]):null;if(C!==null&&N[1]){const R=ne(e,Ke(C)),M=N[1].match(/routes!\s*\[([\s\S]*?)\]/);if(M){const F=M[1].split(",").map(Z=>Z.trim().split("::").pop()).filter(Boolean);for(const Z of F){const U=k.get(Z);if(U)for(const J of U){_.add(`${J.file}:${J.name}`);for(const K of J.routes)A(a,K.method,ne(R,K.path),J.file,K.line,J.name)}}}}z.lastIndex=H.endIdx+1}};for(const c of s){const i=w.get(c.path);if(/\b(?:Router::new|App::new|rocket::build)\s*\(/.test(i)||/\bfn\s+main\s*\(/.test(i)){const g=`entry:${c.path}`;j({id:g,type:"entry",label:c.path,file:c.path,line:1}),T(i,0,i,c.path,"/",g)}}for(const c of D.values())for(const i of c){if(!i.returnsRouter&&!i.isServiceConfig||Array.from(q).some(a=>a.startsWith(`${i.file}:${i.name}@`)))continue;const m=`entry:${i.file}`;j({id:m,type:"entry",label:i.file,file:i.file,line:1}),q.add(`${i.file}:${i.name}@/`);const e=w.get(i.file)??i.body;T(i.body,i.bodyOffset,e,i.file,"/",m)}for(const c of k.values())for(const i of c){if(_.has(`${i.file}:${i.name}`))continue;const g=`entry:${i.file}`;j({id:g,type:"entry",label:i.file,file:i.file,line:1});for(const m of i.routes)A(g,m.method,m.path,i.file,m.line,i.name)}const $=Number((performance.now()-r).toFixed(2));return{version:"1.0",metadata:{repoName:(t==null?void 0:t.repoName)??"unknown",framework:p,scannedFiles:n.length,scanDurationMs:$,unresolvedMounts:[]},nodes:f,edges:E}}},Qt=/(?:^|\/)(?:src\/test|tests?|__tests__|target|build)\/|Test\.(?:java|kt)$/i,Ls={GetMapping:"GET",PostMapping:"POST",PutMapping:"PUT",PatchMapping:"PATCH",DeleteMapping:"DELETE"};function Zs(n,t){let r=1;for(let s=0;s<t&&s<n.length;s++)n[s]===`
|
|
27
|
+
`&&r++;return r}function qs(n){let t="",r=!1;for(let s=0;s<n.length;s++){const p=n[s];if(r){if(t+=p,p==="\\"&&s+1<n.length){t+=n[++s];continue}p==='"'&&(r=!1);continue}if(p==='"'){r=!0,t+=p;continue}if(p==="/"&&n[s+1]==="/"){for(;s<n.length&&n[s]!==`
|
|
28
|
+
`;)t+=" ",s++;s<n.length&&(t+=`
|
|
29
|
+
`);continue}if(p==="/"&&n[s+1]==="*"){for(t+=" ",s+=2;s<n.length&&!(n[s]==="*"&&n[s+1]==="/");)t+=n[s]===`
|
|
30
|
+
`?`
|
|
31
|
+
`:" ",s++;s<n.length&&(t+=" ",s++);continue}t+=p}return t}function wt(n){const t=n.trim().replace(/\{([A-Za-z_][A-Za-z0-9_]*)(?::[^}]*)?\}/g,":$1");return t?t.startsWith("/")?t:`/${t}`:"/"}function en(n){const t=[],r=n.trim();if(!r)return[""];const s=r.match(/(?:value|path)\s*=\s*(\{[^}]*\}|\[[^\]]*\]|"[^"]*")/),p=s?s[1]:r;if(!s&&r.includes("=")&&!/^\s*(?:"|\{|\[)/.test(r))return[""];const f=/"([^"]*)"/g;let E;for(;(E=f.exec(p))!==null;)t.push(E[1]);return t.length>0?t:[""]}function Gs(n){const t=[],r=n.match(/method\s*=\s*(\{[^}]*\}|(?:RequestMethod\.)?(?:GET|POST|PUT|PATCH|DELETE|OPTIONS|HEAD))/);if(!r)return["GET"];const s=/\b(?:RequestMethod\.)?(GET|POST|PUT|PATCH|DELETE|OPTIONS|HEAD)\b/g;let p;for(;(p=s.exec(r[1]))!==null;)t.push(p[1]);return t.length>0?t:["GET"]}var Ws=class{constructor(){ue(this,"name","springboot")}detect(n){return n.some(r=>{const s=oe(r.path);return(s.endsWith("pom.xml")||s.endsWith("build.gradle")||s.endsWith("build.gradle.kts"))&&/spring-boot-starter-web|org\.springframework\.boot/i.test(r.content)})?!0:n.some(r=>(r.path.endsWith(".java")||r.path.endsWith(".kt"))&&!Qt.test(r.path)&&/@(?:RestController|Controller|RequestMapping|GetMapping|PostMapping)\b/.test(r.content))}scan(n,t){const r=performance.now(),s=n.map(A=>({path:oe(A.path),content:A.content})).filter(A=>(A.path.endsWith(".java")||A.path.endsWith(".kt"))&&!Qt.test(A.path)),p=[],f=[],E=new Set,x=new Set,b=A=>{E.has(A.id)||(E.add(A.id),p.push(A))},j=A=>{x.has(A.id)||(x.add(A.id),f.push(A))};for(const A of s){const w=qs(A.content);let k=A.path.split("/").pop().replace(/\.(?:java|kt)$/,""),D=["/"],_=[];const q=[],B=w.split(`
|
|
32
|
+
`);let V=[],T=!1;for(let i=0;i<B.length;i++){const g=B[i].trim();if(!g)continue;if(g.startsWith("@")){let e=g,a=(e.match(/\(/g)||[]).length,u=(e.match(/\)/g)||[]).length;for(;a>u&&i+1<B.length;){i++;const o=B[i].trim();e+=" "+o,a+=(o.match(/\(/g)||[]).length,u+=(o.match(/\)/g)||[]).length}V.push(e);continue}const m=T?null:g.match(/^(?:(?:public|open|internal|abstract|final|sealed)\s+)*(?:class|interface)\s+([A-Za-z_][A-Za-z0-9_]*)/);if(m){T=!0,k=m[1];const e=V.join(`
|
|
33
|
+
`);V=[];const a=e.match(/@RequestMapping\s*(?:\(([^)]*)\))?/);a&&a[1]&&(D=en(a[1]).map(wt));const u=e.match(/@(?:PreAuthorize|Secured|RolesAllowed)\s*\([^)]*\)/g);u&&(_=u.map(o=>o.replace(/^@/,"").split("(")[0]));continue}if(V.length>0){const e=V.join(`
|
|
34
|
+
`);if(/@(?:GetMapping|PostMapping|PutMapping|PatchMapping|DeleteMapping|RequestMapping)\b/.test(e)){let a=g,u=(a.match(/\(/g)||[]).length,o=(a.match(/\)/g)||[]).length;for(;u>o&&i+1<B.length;){i++;const h=B[i].trim();a+=" "+h,u+=(h.match(/\(/g)||[]).length,o+=(h.match(/\)/g)||[]).length}const l=a.match(/([A-Za-z_][A-Za-z0-9_]*)\s*\(([\s\S]*)\)/);if(l){const h=l[1],y=l[2]??"",d=/@(GetMapping|PostMapping|PutMapping|PatchMapping|DeleteMapping|RequestMapping)\s*(?:\(([^)]*)\))?/g;let v;const S=[];for(;(v=d.exec(e))!==null;){const M=v[1],F=v[2]??"",Z=en(F);M==="RequestMapping"?S.push({methods:Gs(F),subPaths:Z}):S.push({methods:[Ls[M]],subPaths:Z})}const I=[..._],O=e.match(/@(?:PreAuthorize|Secured|RolesAllowed)\s*\([^)]*\)/g);if(O)for(const M of O)I.push(M.replace(/^@/,"").split("(")[0]);const z=[],G=/@RequestParam(?:\s*\(\s*(?:value\s*=\s*|name\s*=\s*)?"([^"]+)"|\s*\([^)]*\))?\s+(?:[A-Za-z_<>[\]?]+\s+)?([A-Za-z_][A-Za-z0-9_]*)/g;let W;for(;(W=G.exec(y))!==null;)z.push(W[1]||W[2]);const H=[],N=/@RequestBody(?:\s+([A-Za-z_][A-Za-z0-9_<>?]*))?/g;let C;for(;(C=N.exec(y))!==null;)C[1]&&H.push(C[1]);const R=i+1;for(const M of S)for(const F of D)for(const Z of M.subPaths){const U=ne(F,wt(Z));for(const J of M.methods)q.push({method:J,fullPath:U,handler:`${k}.${h}`,line:R,middlewares:I.length?I:void 0,queryParams:z.length?z:void 0,bodyFields:H.length?H:void 0})}}}V=[]}}const $=/\b(GET|POST|PUT|PATCH|DELETE|OPTIONS|HEAD)\s*\(\s*"([^"]+)"/g;let c;for(;(c=$.exec(w))!==null;){const i=c[1],g=wt(c[2]);q.push({method:i,fullPath:g,handler:`${k}.router`,line:Zs(w,c.index)})}if(q.length>0){const i=`entry:${A.path}`;b({id:i,type:"entry",label:A.path,file:A.path,line:1});for(const g of q){const m=`route:${g.method}:${g.fullPath}`;b({id:m,type:"route",label:`${g.method} ${g.fullPath}`,file:A.path,line:g.line,method:g.method,fullPath:g.fullPath,pathParams:fe(g.fullPath),group:me(g.fullPath),middlewares:g.middlewares,queryParams:g.queryParams,bodyFields:g.bodyFields,controller:g.handler,controllerFile:A.path,controllerLine:g.line}),j({id:`edge:${i}->${m}`,source:i,target:m,type:"handles"})}}}const P=Number((performance.now()-r).toFixed(2));return{version:"1.0",metadata:{repoName:(t==null?void 0:t.repoName)??"unknown",framework:"springboot",scannedFiles:n.length,scanDurationMs:P,unresolvedMounts:[]},nodes:p,edges:f}}},tn=/(?:^|\/)(?:spec|test|tests)\/|_(?:spec|test)\.rb$/i,Hs=[{action:"index",method:"GET",item:!1},{action:"create",method:"POST",item:!1},{action:"show",method:"GET",item:!0},{action:"update",method:"PATCH",item:!0},{action:"update",method:"PUT",item:!0},{action:"destroy",method:"DELETE",item:!0}],Bs=[{action:"show",method:"GET"},{action:"create",method:"POST"},{action:"update",method:"PATCH"},{action:"update",method:"PUT"},{action:"destroy",method:"DELETE"}];function lt(n){const t=[],r=/:([A-Za-z_][A-Za-z0-9_]*)|['"]([A-Za-z_][A-Za-z0-9_]*)['"]/g;let s;for(;(s=r.exec(n))!==null;)t.push(s[1]||s[2]);return t}function Us(n){return n.endsWith("ies")?`${n.slice(0,-3)}y`:n.endsWith("ses")||n.endsWith("xes")||n.endsWith("ches")||n.endsWith("shes")?n.slice(0,-2):n.endsWith("s")&&!n.endsWith("ss")?n.slice(0,-1):n}function Vs(n){let t=null;for(let r=0;r<n.length;r++){const s=n[r];if(t){if(s==="\\"){r++;continue}s===t&&(t=null);continue}if(s==="'"||s==='"'){t=s;continue}if(s==="#")return n.slice(0,r)}return n}function nn(n){const t=n.trim().replace(/\(\.:format\)/g,"");return t?t.startsWith("/")?t:`/${t}`:"/"}var Ks=class{constructor(){ue(this,"name","rails")}detect(n){return n.some(r=>oe(r.path).endsWith("config/routes.rb"))||n.some(r=>oe(r.path)==="Gemfile"&&/\b(?:rails|sinatra|grape)\b/i.test(r.content))?!0:n.some(r=>r.path.endsWith(".rb")&&!tn.test(r.path)&&/Rails\.application\.routes\.draw/.test(r.content))}scan(n,t){const r=performance.now(),s=n.map(k=>({path:oe(k.path),content:k.content})).filter(k=>k.path.endsWith(".rb")&&!tn.test(k.path)),p=[],f=[],E=new Set,x=new Set,b=k=>{E.has(k.id)||(E.add(k.id),p.push(k))},j=k=>{x.has(k.id)||(x.add(k.id),f.push(k))},P=(k,D,_,q,B,V)=>{const T=_||"/",$=`route:${D}:${T}`;b({id:$,type:"route",label:`${D} ${T}`,file:q,line:B,method:D,fullPath:T,pathParams:fe(T),group:me(T),controller:V,controllerFile:q,controllerLine:B}),j({id:`edge:${k}->${$}`,source:k,target:$,type:"handles"})},A=s.filter(k=>k.path.endsWith("routes.rb")||/Rails\.application\.routes\.draw/.test(k.content));for(const k of A){const D=`entry:${k.path}`;b({id:D,type:"entry",label:k.path,file:k.path,line:1});const _=[{prefix:"/",kind:"root"}],q=k.content.split(`
|
|
35
|
+
`);for(let B=0;B<q.length;B++){const V=B+1,T=Vs(q[B]).trim();if(!T)continue;const $=_[_.length-1],c=/\bdo(?:\s*\|[^|]*\|)?\s*$/.test(T);if(T==="end"){_.length>1&&_.pop();continue}const i=T.match(/^namespace\s+:([A-Za-z_][A-Za-z0-9_]*)/);if(i&&c){_.push({prefix:ne($.prefix,`/${i[1]}`),kind:"namespace"});continue}const g=T.match(/^scope\s+(?:path:\s*)?['"]([^'"]+)['"]/);if(g&&c){_.push({prefix:ne($.prefix,nn(g[1])),kind:"scope"});continue}if(/^scope\b/.test(T)&&c){_.push({prefix:$.prefix,kind:"scope"});continue}if(/^member\b/.test(T)&&c){_.push({prefix:ne($.prefix,":id"),kind:"member"});continue}if(/^collection\b/.test(T)&&c){_.push({prefix:$.prefix,kind:"collection"});continue}const m=T.match(/^(resources?)\s+((?::[A-Za-z_][A-Za-z0-9_]*\s*,?\s*)+)(.*)$/);if(m){const u=m[1]==="resource",o=lt(m[2]),l=m[3]??"",h=l.match(/path:\s*['"]([^'"]+)['"]/),y=l.match(/only:\s*(?:\[([^\]]+)\]|(:[A-Za-z_]+))/),d=l.match(/except:\s*(?:\[([^\]]+)\]|(:[A-Za-z_]+))/),v=y?new Set(lt(y[1]||y[2])):null,S=d?new Set(lt(d[1]||d[2])):null;let I=$.prefix;$.kind==="resources"&&$.paramName&&(I=ne($.prefix,`:${$.paramName}`));for(const O of o){const z=h?h[1]:O,G=ne(I,`/${z}`);if(u)for(const W of Bs)v&&!v.has(W.action)||S&&S.has(W.action)||P(D,W.method,G,k.path,V,`${O}#${W.action}`);else for(const W of Hs){if(v&&!v.has(W.action)||S&&S.has(W.action))continue;const H=W.item?ne(G,":id"):G;P(D,W.method,H,k.path,V,`${O}#${W.action}`)}c&&o.length===1&&_.push({prefix:G,kind:u?"resource":"resources",resourceName:O,paramName:`${Us(O)}_id`})}continue}const e=T.match(/^root\s+(?:to:\s*)?['"]([^'"]+)['"]/);if(e){P(D,"GET",$.prefix,k.path,V,e[1]);continue}const a=T.match(/^(get|post|put|patch|delete|options|head|match)\s+['":]([^'",\s]+)['"]?(.*)$/);if(a){const u=a[1].toLowerCase(),o=a[2],l=a[3]??"",h=l.match(/(?:to:|=>)\s*['"]([^'"]+)['"]/),y=h?h[1]:o;let d=$.prefix;$.kind==="resources"&&$.paramName&&!T.includes("on:")?d=ne($.prefix,`:${$.paramName}`):$.kind==="resources"&&l.includes("on: :member")&&$.paramName&&(d=ne($.prefix,":id"));const v=ne(d,nn(o));if(u==="match"){const S=l.match(/via:\s*(?:\[([^\]]+)\]|(:[A-Za-z_]+))/),I=S?lt(S[1]||S[2]):["get"];for(const O of I){const z=O==="all"?"ALL":O.toUpperCase();P(D,z,v,k.path,V,y)}}else P(D,u.toUpperCase(),v,k.path,V,y);continue}c&&_.push({prefix:$.prefix,kind:"scope"})}}const w=Number((performance.now()-r).toFixed(2));return{version:"1.0",metadata:{repoName:(t==null?void 0:t.repoName)??"unknown",framework:"rails",scannedFiles:n.length,scanDurationMs:w,unresolvedMounts:[]},nodes:p,edges:f}}},dn=/(?:^|\/)(?:tests?|__tests__|spec|target|vendor|node_modules)\/|\.(?:test|spec)\./i;function Me(n,t){let r=1;for(let s=0;s<t&&s<n.length;s++)n[s]===`
|
|
36
|
+
`&&r++;return r}function Pt(n,t){const r=new Set(t.nodes.map(E=>E.id)),s=new Set(t.edges.map(E=>E.id)),p=E=>{const x=`entry:${E}`;return r.has(x)||(r.add(x),t.nodes.push({id:x,type:"entry",label:E,file:E,line:1})),x},f=(E,x,b,j,P,A)=>{const w=p(E),k=`route:${b}:${j}`;r.has(k)||(r.add(k),t.nodes.push({id:k,type:"route",label:`${b} ${j}`,file:E,line:x,method:"ALL",fullPath:j,group:P,controller:A,controllerFile:E,controllerLine:x}));const D=`edge:${w}->${k}`;s.has(D)||(s.add(D),t.edges.push({id:D,source:w,target:k,type:"handles"}))};for(const E of n){const x=oe(E.path);if(dn.test(x))continue;const b=E.content;if(x.endsWith(".proto")){const j=/\bservice\s+([A-Za-z_][A-Za-z0-9_]*)\s*\{([^}]*)\}/g;let P;for(;(P=j.exec(b))!==null;){const A=P[1],w=P[2],k=/\brpc\s+([A-Za-z_][A-Za-z0-9_]*)\s*\(/g;let D;for(;(D=k.exec(w))!==null;)f(x,Me(b,P.index+D.index),"GRPC",`/${A}/${D[1]}`,"grpc",`${A}.${D[1]}`)}continue}if(x.endsWith(".graphql")||x.endsWith(".gql")){const j=/\btype\s+(Query|Mutation|Subscription)\s*\{([^}]*)\}/g;let P;for(;(P=j.exec(b))!==null;){const A=P[1].toUpperCase(),w=P[2],k=/^\s*([A-Za-z_][A-Za-z0-9_]*)\s*(?:\([^)]*\))?\s*:/gm;let D;for(;(D=k.exec(w))!==null;)f(x,Me(b,P.index+D.index),`GQL:${A}`,`/${D[1]}`,"graphql",`${P[1]}.${D[1]}`)}continue}if(/\.(?:ts|tsx|js|jsx)$/.test(x)){if(/@nestjs\/graphql|type-graphql/.test(b)){const A=/@(Query|Mutation|Subscription)\s*\([^)]*\)[\s\S]{0,120}?\b([A-Za-z_][A-Za-z0-9_]*)\s*\(/g;let w;for(;(w=A.exec(b))!==null;)f(x,Me(b,w.index),`GQL:${w[1].toUpperCase()}`,`/${w[2]}`,"graphql",w[2])}if(/\b(?:initTRPC|publicProcedure|protectedProcedure|trpc)\b/.test(b)){const A=/([A-Za-z_][A-Za-z0-9_]*)\s*:\s*[A-Za-z_][A-Za-z0-9_.]*[Pp]rocedure[\s\S]{0,200}?\.(query|mutation|subscription)\s*\(/g;let w;for(;(w=A.exec(b))!==null;)f(x,Me(b,w.index),`TRPC:${w[2].toUpperCase()}`,`/${w[1]}`,"trpc",w[1])}const j=/\b(?:io|socket|wss)\.(?:on|of)\s*\(\s*['"]([^'"]+)['"]/g;let P;for(;(P=j.exec(b))!==null;){const A=P[1];A==="connection"||A==="disconnect"||A==="error"||f(x,Me(b,P.index),"WS",`/${A.replace(/^\/+/,"")}`,"websocket",A)}}if(x.endsWith(".py")){const j=/@[A-Za-z_][A-Za-z0-9_]*\.websocket\s*\(\s*['"]([^'"]+)['"]/g;let P;for(;(P=j.exec(b))!==null;){const A=P[1].startsWith("/")?P[1]:`/${P[1]}`;f(x,Me(b,P.index),"WS",A,"websocket","websocket")}}if(x.endsWith(".java")||x.endsWith(".kt")){const j=/@MessageMapping\s*\(\s*"([^"]+)"\s*\)/g;let P;for(;(P=j.exec(b))!==null;){const A=P[1].startsWith("/")?P[1]:`/${P[1]}`;f(x,Me(b,P.index),"WS",A,"websocket","MessageMapping")}}}}var Js=class{constructor(){ue(this,"name","protocols")}detect(n){return n.some(t=>!dn.test(t.path)&&(t.path.endsWith(".proto")||t.path.endsWith(".graphql")||t.path.endsWith(".gql")||/\binitTRPC\b/.test(t.content)))}scan(n,t){const r=performance.now(),s={version:"1.0",metadata:{repoName:(t==null?void 0:t.repoName)??"unknown",framework:"protocols",scannedFiles:n.length,scanDurationMs:0,unresolvedMounts:[]},nodes:[],edges:[]};return Pt(n,s),s.metadata.scanDurationMs=Number((performance.now()-r).toFixed(2)),s}},vt=[new Es,new js,new Ms,new Rs,new Ds,new Ws,new Ks,new ms,new us,new fs,new ys,new ws,new Js,new cs];function fn(n,t){const r=vt.filter(f=>f.detect(n)),s=r.length>0?r:[vt[vt.length-1]];let p;if(s.length===1)p=s[0].scan(n,t),s[0].name!=="protocols"&&Pt(n,p);else{const f=s.map(w=>w.scan(n,t)),E=f.filter(w=>w.nodes.some(k=>k.type==="route")),x=E.length>0?E:[f[0]],b=new Map(x.flatMap(w=>w.nodes.map(k=>[k.id,k]))),j=new Map(x.flatMap(w=>w.edges.map(k=>[k.id,k]))),P=Array.from(new Set(x.flatMap(w=>w.metadata.unresolvedMounts))),A=Array.from(new Set(x.map(w=>w.metadata.framework)));p={version:x[0].version,nodes:Array.from(b.values()),edges:Array.from(j.values()),metadata:{...x[0].metadata,framework:A.join(" + "),scannedFiles:Math.max(...x.map(w=>w.metadata.scannedFiles)),scanDurationMs:x.reduce((w,k)=>w+k.metadata.scanDurationMs,0),unresolvedMounts:P}},s.some(w=>w.name==="protocols")||Pt(n,p)}return p.metadata.unresolved||(p.metadata.unresolved=p.metadata.unresolvedMounts.map(f=>{const E=f.match(/^([^:]+):(\d+)\s*->\s*(.+)$/);if(E)return{file:E[1],line:Number(E[2]),reason:`Unresolved mount: ${E[3]}`};const x=f.match(/^([^:]+):(\d+)\s*\(([^)]+)\)(.*)$/);if(x)return{file:x[1],line:Number(x[2]),reason:`${x[3]}${x[4]}`.trim()};const b=f.match(/^([^:]+):(\d+)\s*(.*)$/);return b?{file:b[1],line:Number(b[2]),reason:b[3]||"Unresolved route/mount"}:{file:"",line:1,reason:f}})),p}const Ys={entry:{width:220,height:76},router:{width:210,height:68},route:{width:310,height:92},middleware:{width:170,height:48},controller:{width:220,height:62}};function Xs(n){return Ys[n]??{width:220,height:70}}function Qs(n,t){const r=new Set([n]),s=new Set,p=new Map,f=new Map;for(const b of t){let j=p.get(b.target);j||(j=[],p.set(b.target,j)),j.push(b);let P=f.get(b.source);P||(P=[],f.set(b.source,P)),P.push(b)}const E=[n];for(;E.length>0;){const b=E.pop();for(const j of p.get(b)??[])s.add(j.id),r.has(j.source)||(r.add(j.source),E.push(j.source))}const x=[n];for(;x.length>0;){const b=x.pop();for(const j of f.get(b)??[])s.add(j.id),r.has(j.target)||(r.add(j.target),x.push(j.target))}return{nodeIds:r,edgeIds:s}}const sn={GET:{bg:"rgba(16,185,129,0.18)",text:"#34d399",border:"rgba(16,185,129,0.45)"},POST:{bg:"rgba(56,189,248,0.18)",text:"#38bdf8",border:"rgba(56,189,248,0.45)"},PUT:{bg:"rgba(245,158,11,0.18)",text:"#fbbf24",border:"rgba(245,158,11,0.45)"},PATCH:{bg:"rgba(249,115,22,0.18)",text:"#fb923c",border:"rgba(249,115,22,0.45)"},DELETE:{bg:"rgba(244,63,94,0.18)",text:"#fb7185",border:"rgba(244,63,94,0.45)"},OPTIONS:{bg:"rgba(161,161,170,0.18)",text:"#a1a1aa",border:"rgba(161,161,170,0.4)"},HEAD:{bg:"rgba(161,161,170,0.18)",text:"#a1a1aa",border:"rgba(161,161,170,0.4)"},ALL:{bg:"rgba(168,85,247,0.18)",text:"#c084fc",border:"rgba(168,85,247,0.45)"}};function Et(n,t,r,s,p,f){n.beginPath(),n.roundRect(t,r,s,p,f)}function Te(n,t,r){if(n.measureText(t).width<=r)return t;let s=0,p=t.length;for(;s<p;){const f=s+p+1>>1;n.measureText(t.slice(0,f)+"…").width<=r?s=f:p=f-1}return t.slice(0,s)+"…"}const er=X.forwardRef(({nodes:n,edges:t,selectedRouteId:r,onSelectRoute:s},p)=>{const f=X.useRef(null),E=X.useRef({x:80,y:80,scale:.75}),x=X.useRef(null),b=X.useRef({active:!1,moved:!1,startX:0,startY:0,origX:0,origY:0}),j=X.useRef(null),[P,A]=X.useState(!1),w=X.useMemo(()=>{const m=n.map(o=>{const l=Xs(o.type??"route");return{node:o,data:o.data,x:o.position.x,y:o.position.y,w:l.width,h:l.height}}),e=new Map(m.map(o=>[o.node.id,o])),a=new Map,u=new Map;for(const o of t){let l=a.get(o.target);l||(l=[],a.set(o.target,l)),l.push(o);let h=u.get(o.source);h||(h=[],u.set(o.source,h)),h.push(o)}return{boxes:m,boxById:e,byTarget:a,bySource:u}},[n,t]),k=X.useCallback(m=>{if(!m)return null;const e=new Set([m]),a=new Set,u=[m];for(;u.length>0;){const l=u.pop();for(const h of w.byTarget.get(l)??[])a.add(h.id),e.has(h.source)||(e.add(h.source),u.push(h.source))}const o=[m];for(;o.length>0;){const l=o.pop();for(const h of w.bySource.get(l)??[])a.add(h.id),e.has(h.target)||(e.add(h.target),o.push(h.target))}return{nodeIds:e,edgeIds:a}},[w]),D=X.useCallback(()=>{const m=f.current;if(!m)return;const e=m.getContext("2d");if(!e)return;const a=window.devicePixelRatio||1,u=m.clientWidth,o=m.clientHeight;(m.width!==Math.floor(u*a)||m.height!==Math.floor(o*a))&&(m.width=Math.floor(u*a),m.height=Math.floor(o*a));const{x:l,y:h,scale:y}=E.current;if(e.setTransform(a,0,0,a,0,0),e.fillStyle="#09090b",e.fillRect(0,0,u,o),y>.32){const N=24*y,C=(l%N+N)%N,R=(h%N+N)%N;e.fillStyle="#18181f";for(let M=C;M<u;M+=N)for(let F=R;F<o;F+=N)e.fillRect(M,F,1.3,1.3)}e.save(),e.translate(l,h),e.scale(y,y);const d=-l/y-100,v=-h/y-100,S=(u-l)/y+100,I=(o-h)/y+100,O=x.current??r,z=k(O),G=1/Math.max(y,.06),W=(N,C)=>{const R=w.boxById.get(N.source),M=w.boxById.get(N.target);if(!R||!M)return;const F=R.x+R.w/2,Z=R.y+R.h/2,U=M.x+M.w/2,J=M.y+M.h/2;if(!(Math.max(F,U)<d||Math.min(F,U)>S||Math.max(Z,J)<v||Math.min(Z,J)>I)){if(e.beginPath(),y<.32){const K=F,Q=Z,te=U,re=J;e.moveTo(K,Q),e.lineTo(te,re)}else{const K=M.x>=R.x+R.w-20,Q=K?R.x+R.w:F,te=K?M.x:U,re=Math.max(44,Math.abs(te-Q)*.45);e.moveTo(Q,Z),e.bezierCurveTo(Q+(K?re:0),Z,te-(K?re:0),J,te,J)}C?(e.strokeStyle="#10b981",e.lineWidth=y<.32?2.2*G:2.2):(e.strokeStyle=z?"rgba(113,113,122,0.1)":"rgba(113,113,122,0.32)",e.lineWidth=y<.32?.9*G:1.3),e.stroke()}};for(const N of t)(!z||!z.edgeIds.has(N.id))&&W(N,!1);if(z)for(const N of t)z.edgeIds.has(N.id)&&W(N,!0);const H=y>=.32;for(const N of w.boxes){if(N.x+N.w<d||N.x>S||N.y+N.h<v||N.y>I)continue;const C=z?z.nodeIds.has(N.node.id):!1,R=z?!C:!1,M=r===N.node.id,F=N.data.type;if(e.globalAlpha=R?.16:1,!H){Et(e,N.x,N.y,N.w,N.h,10),e.fillStyle=C?"rgba(16,185,129,0.22)":"#141419",e.fill(),e.strokeStyle=M?"#38bdf8":C?"#10b981":F==="entry"?"rgba(16,185,129,0.65)":F==="router"?"rgba(56,189,248,0.45)":"rgba(255,255,255,0.28)",e.lineWidth=(C||M?2.4:1.1)*G,e.stroke(),e.globalAlpha=1;continue}if(C&&H&&(e.shadowBlur=16,e.shadowColor="rgba(16, 185, 129, 0.35)"),Et(e,N.x,N.y,N.w,N.h,11),e.fillStyle=F==="middleware"?"#19132b":F==="controller"?"#0b2027":"#101014",e.fill(),e.shadowBlur=0,M?(e.strokeStyle="#38bdf8",e.lineWidth=2):C?(e.strokeStyle="#10b981",e.lineWidth=2):(e.strokeStyle=F==="entry"?"rgba(16,185,129,0.55)":F==="router"?"rgba(56,189,248,0.42)":F==="middleware"?"rgba(167,139,250,0.42)":F==="controller"?"rgba(34,211,238,0.38)":"rgba(255,255,255,0.16)",e.lineWidth=1.1),e.stroke(),e.fillStyle=C?"#10b981":"#52525b",F!=="entry"&&(e.beginPath(),e.arc(N.x,N.y+N.h/2,3.2,0,Math.PI*2),e.fill()),(F==="entry"||F==="router"||F==="route")&&(e.beginPath(),e.arc(N.x+N.w,N.y+N.h/2,3.2,0,Math.PI*2),e.fill()),e.textBaseline="middle",F==="route"){const Z=(N.data.method??"GET").toUpperCase(),U=sn[Z]??sn.GET;Et(e,N.x+12,N.y+12,50,18,4),e.fillStyle=U.bg,e.fill(),e.strokeStyle=U.border,e.lineWidth=1,e.stroke(),e.font="bold 10px ui-monospace, SFMono-Regular, Menlo, monospace",e.fillStyle=U.text,e.fillText(Z,N.x+18,N.y+21),e.font="10px ui-monospace, SFMono-Regular, Menlo, monospace",e.fillStyle="#71717a",e.fillText(Te(e,N.data.controller??"handler",N.w-86),N.x+70,N.y+21),e.font="500 12px ui-monospace, SFMono-Regular, Menlo, monospace",e.fillStyle="#f4f4f5",e.fillText(Te(e,N.data.fullPath??N.data.label,N.w-24),N.x+12,N.y+49);const J=N.data.middlewares??[];J.length>0&&(e.font="10px ui-monospace, SFMono-Regular, Menlo, monospace",e.fillStyle="#c4b5fd",e.fillText(Te(e,J.slice(0,2).join(" · ")+(J.length>2?` +${J.length-2}`:""),N.w-24),N.x+12,N.y+72))}else F==="entry"?(e.font="bold 10px ui-sans-serif, system-ui, sans-serif",e.fillStyle="#34d399",e.fillText("ENTRY",N.x+14,N.y+22),e.font="500 12px ui-monospace, SFMono-Regular, Menlo, monospace",e.fillStyle="#f4f4f5",e.fillText(Te(e,N.data.label,N.w-28),N.x+14,N.y+46)):F==="router"?(e.font="bold 10px ui-sans-serif, system-ui, sans-serif",e.fillStyle="#38bdf8",e.fillText("ROUTER",N.x+12,N.y+20),e.font="600 12px ui-monospace, SFMono-Regular, Menlo, monospace",e.fillStyle="#f4f4f5",e.fillText(Te(e,N.data.label,N.w-24),N.x+12,N.y+40),e.font="10px ui-monospace, SFMono-Regular, Menlo, monospace",e.fillStyle="#71717a",e.fillText(Te(e,N.data.file,N.w-24),N.x+12,N.y+56)):(e.font="11px ui-monospace, SFMono-Regular, Menlo, monospace",e.fillStyle=F==="middleware"?"#c4b5fd":"#67e8f9",e.fillText(Te(e,N.data.label,N.w-24),N.x+12,N.y+N.h/2));e.globalAlpha=1}e.restore()},[t,k,w,r]),_=X.useCallback(()=>{j.current===null&&(j.current=requestAnimationFrame(()=>{j.current=null,D()}))},[D]),q=X.useCallback(()=>{const m=f.current;if(!m||w.boxes.length===0)return;let e=1/0,a=1/0,u=-1/0,o=-1/0;for(const S of w.boxes)S.x<e&&(e=S.x),S.y<a&&(a=S.y),S.x+S.w>u&&(u=S.x+S.w),S.y+S.h>o&&(o=S.y+S.h);const l=m.clientWidth||window.innerWidth,h=m.clientHeight||window.innerHeight,y=Math.max(1,u-e),d=Math.max(1,o-a),v=Math.max(.08,Math.min(1.1,Math.min(l*.8/y,h*.8/d)));E.current={scale:v,x:l/2-(e+u)/2*v,y:h/2-(a+o)/2*v},_()},[w.boxes,_]),B=X.useCallback((m,e,a=.95)=>{const u=f.current,o=(u==null?void 0:u.clientWidth)||window.innerWidth,l=(u==null?void 0:u.clientHeight)||window.innerHeight;E.current={scale:a,x:o/2-m*a,y:l/2-e*a},_()},[_]);X.useImperativeHandle(p,()=>({fitView:q,centerOn:B}),[q,B]),X.useEffect(()=>{if(w.boxes.some(a=>a.x<-100||a.y<-100)||w.boxes.length<=100){q();return}const e=w.boxes.find(a=>a.data.type==="entry")??w.boxes[0];e?B(e.x+420,e.y+e.h/2,.58):q()},[w.boxes,B,q]),X.useEffect(()=>{_()},[r,_]),X.useEffect(()=>{const m=()=>_();return window.addEventListener("resize",m),()=>window.removeEventListener("resize",m)},[_]);const V=(m,e)=>{const a=f.current;if(!a)return null;const u=a.getBoundingClientRect(),{x:o,y:l,scale:h}=E.current,y=(m-u.left-o)/h,d=(e-u.top-l)/h;for(let v=w.boxes.length-1;v>=0;v--){const S=w.boxes[v];if(y>=S.x&&y<=S.x+S.w&&d>=S.y&&d<=S.y+S.h)return S}return null},T=m=>{b.current={active:!0,moved:!1,startX:m.clientX,startY:m.clientY,origX:E.current.x,origY:E.current.y}},$=m=>{if(b.current.active){const u=m.clientX-b.current.startX,o=m.clientY-b.current.startY;(Math.abs(u)>3||Math.abs(o)>3)&&(b.current.moved=!0),E.current.x=b.current.origX+u,E.current.y=b.current.origY+o,_();return}const e=V(m.clientX,m.clientY),a=e?e.node.id:null;A((e==null?void 0:e.data.type)==="route"),a!==x.current&&(x.current=a,_())},c=m=>{const e=b.current.moved;if(b.current.active=!1,!e){const a=V(m.clientX,m.clientY);(a==null?void 0:a.data.type)==="route"?s(a.data):s(null)}},i=m=>{m.preventDefault();const e=f.current;if(!e)return;const a=e.getBoundingClientRect(),u=m.clientX-a.left,o=m.clientY-a.top,l=E.current,h=m.deltaY<0?1.12:.89,y=Math.max(.05,Math.min(2.5,l.scale*h));E.current={scale:y,x:u-(u-l.x)*y/l.scale,y:o-(o-l.y)*y/l.scale},_()},g=m=>{const e=f.current;if(!e)return;const a=e.clientWidth,u=e.clientHeight,o=E.current,l=Math.max(.05,Math.min(2.5,o.scale*m));E.current={scale:l,x:a/2-(a/2-o.x)*l/o.scale,y:u/2-(u/2-o.y)*l/o.scale},_()};return L.jsxs("div",{className:"relative h-full w-full",children:[L.jsx("canvas",{ref:f,onPointerDown:T,onPointerMove:$,onPointerUp:c,onPointerLeave:()=>{b.current.active=!1,x.current!==null&&(x.current=null,_())},onWheel:i,className:`h-full w-full touch-none ${P?"cursor-pointer":"cursor-grab active:cursor-grabbing"}`}),L.jsxs("div",{className:"fixed bottom-4 left-4 z-20 flex flex-col overflow-hidden rounded-xl border border-white/10 bg-zinc-950/90 shadow-xl",children:[L.jsx("button",{onClick:()=>g(1.25),title:"Zoom in",className:"p-2 text-zinc-300 hover:bg-white/10",children:L.jsx(kn,{className:"h-4 w-4"})}),L.jsx("button",{onClick:()=>g(.8),title:"Zoom out",className:"border-t border-white/10 p-2 text-zinc-300 hover:bg-white/10",children:L.jsx(Mn,{className:"h-4 w-4"})}),L.jsx("button",{onClick:q,title:"Fit view",className:"border-t border-white/10 p-2 text-zinc-300 hover:bg-white/10",children:L.jsx(Tn,{className:"h-4 w-4"})})]})]})}),rn={GET:{bg:"bg-emerald-500/15",text:"text-emerald-400",border:"border-emerald-500/35",glow:"shadow-[0_0_12px_rgba(16,185,129,0.28)]",dot:"#10b981"},POST:{bg:"bg-sky-500/15",text:"text-sky-400",border:"border-sky-500/35",glow:"shadow-[0_0_12px_rgba(56,189,248,0.28)]",dot:"#38bdf8"},PUT:{bg:"bg-amber-500/15",text:"text-amber-400",border:"border-amber-500/35",glow:"shadow-[0_0_12px_rgba(245,158,11,0.28)]",dot:"#f59e0b"},PATCH:{bg:"bg-amber-500/15",text:"text-amber-400",border:"border-amber-500/35",glow:"shadow-[0_0_12px_rgba(245,158,11,0.28)]",dot:"#f59e0b"},DELETE:{bg:"bg-rose-500/15",text:"text-rose-400",border:"border-rose-500/35",glow:"shadow-[0_0_12px_rgba(244,63,94,0.28)]",dot:"#f43f5e"},OPTIONS:{bg:"bg-zinc-500/15",text:"text-zinc-300",border:"border-zinc-500/35",glow:"",dot:"#71717a"},HEAD:{bg:"bg-zinc-500/15",text:"text-zinc-300",border:"border-zinc-500/35",glow:"",dot:"#71717a"},ALL:{bg:"bg-violet-500/15",text:"text-violet-300",border:"border-violet-500/35",glow:"",dot:"#a78bfa"}};function tr(n){return rn[(n??"GET").toUpperCase()]??rn.GET}function tt(n){return n._dimmed?"opacity-20 scale-[0.98]":"opacity-100"}const nr=X.memo(({data:n})=>{const t=n;return L.jsxs("div",{className:`w-[220px] rounded-xl border bg-zinc-950/95 px-3.5 py-2.5 transition-colors duration-150 ${t._highlighted?"border-emerald-400/70 shadow-[0_0_24px_rgba(16,185,129,0.3)]":"border-white/15 shadow-md shadow-black/50"} ${tt(t)}`,children:[L.jsxs("div",{className:"flex items-center gap-2",children:[L.jsx("span",{className:"h-2.5 w-2.5 rounded-full bg-emerald-400 shadow-[0_0_8px_#10b981]"}),L.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-emerald-400",children:"Entry"})]}),L.jsx("div",{className:"mt-1 truncate font-mono text-xs font-medium text-zinc-100",title:t.label,children:t.label}),L.jsx(Ie,{type:"source",position:Fe.Right,className:"!h-2 !w-2 !border-zinc-700 !bg-emerald-400"})]})}),sr=X.memo(({data:n})=>{const t=n;return L.jsxs("div",{className:`w-[210px] rounded-xl border bg-zinc-950/95 px-3 py-2.5 transition-colors duration-150 ${t._highlighted?"border-sky-400/70 shadow-[0_0_22px_rgba(56,189,248,0.28)]":"border-white/12 shadow-md shadow-black/40 hover:border-white/25"} ${tt(t)}`,children:[L.jsx(Ie,{type:"target",position:Fe.Left,className:"!h-2 !w-2 !border-zinc-700 !bg-zinc-400"}),L.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wider text-sky-400/90",children:[L.jsx(Cn,{className:"h-3 w-3"}),L.jsx("span",{children:"Router"})]}),L.jsx("div",{className:"mt-1 truncate font-mono text-xs font-semibold text-zinc-100",title:t.label,children:t.label}),L.jsx("div",{className:"mt-0.5 truncate font-mono text-[10px] text-zinc-500",title:t.file,children:t.file}),L.jsx(Ie,{type:"source",position:Fe.Right,className:"!h-2 !w-2 !border-zinc-700 !bg-sky-400"})]})}),rr=X.memo(({data:n})=>{const t=n,r=tr(t.method),s=t.middlewares??[],p=s.slice(0,2),f=s.length-p.length;return L.jsxs("div",{className:`group w-[310px] rounded-xl border bg-zinc-950/95 px-3.5 py-2.5 transition-colors duration-150 cursor-pointer ${t._selected?"border-sky-400 ring-1 ring-sky-400/40 shadow-[0_0_28px_rgba(56,189,248,0.3)]":t._highlighted?"border-emerald-400/75 shadow-[0_0_22px_rgba(16,185,129,0.28)]":"border-white/10 shadow-md shadow-black/50 hover:border-white/25"} ${tt(t)}`,children:[L.jsx(Ie,{type:"target",position:Fe.Left,className:"!h-2 !w-2 !border-zinc-700 !bg-zinc-400"}),L.jsxs("div",{className:"flex items-center justify-between gap-2",children:[L.jsxs("div",{className:"flex items-center gap-1.5",children:[L.jsx("span",{className:`inline-flex items-center rounded-md border px-1.5 py-0.5 font-mono text-[10px] font-bold tracking-wide ${r.bg} ${r.text} ${r.border} ${r.glow}`,children:t.method??"GET"}),!!t.partial&&L.jsx("span",{className:"inline-flex items-center rounded border border-amber-500/40 bg-amber-500/10 px-1 py-0.5 font-mono text-[9px] text-amber-300",title:"Prefix may be missing (unmounted fallback)",children:"partial"})]}),L.jsx("span",{className:"truncate font-mono text-[10px] text-zinc-500",children:t.controller??"handler"})]}),L.jsx("div",{className:"mt-1.5 truncate font-mono text-xs font-medium text-zinc-100",title:t.fullPath??t.label,children:t.fullPath??t.label}),L.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-1",children:[p.map(E=>L.jsxs("span",{className:"inline-flex items-center gap-1 rounded bg-violet-500/15 border border-violet-500/25 px-1.5 py-0.5 font-mono text-[9px] text-violet-300",children:[L.jsx(ut,{className:"h-2.5 w-2.5"}),E]},E)),f>0&&L.jsxs("span",{className:"rounded bg-violet-500/10 px-1.5 py-0.5 font-mono text-[9px] text-violet-400",children:["+",f]}),t.bodyFields&&t.bodyFields.length>0&&L.jsx("span",{className:"rounded bg-zinc-800/90 px-1.5 py-0.5 font-mono text-[9px] text-zinc-400",children:`{${t.bodyFields.slice(0,2).join(", ")}${t.bodyFields.length>2?"…":""}}`}),t.queryParams&&t.queryParams.length>0&&L.jsxs("span",{className:"rounded bg-zinc-800/90 px-1.5 py-0.5 font-mono text-[9px] text-zinc-400",children:["?",t.queryParams[0]]})]}),L.jsx(Ie,{type:"source",position:Fe.Right,className:"!h-2 !w-2 !border-zinc-700 !bg-zinc-400"})]})}),or=X.memo(({data:n})=>{const t=n;return L.jsxs("div",{className:`w-[170px] rounded-lg border bg-violet-950/70 px-3 py-2 transition-colors duration-150 ${t._highlighted?"border-violet-400/70 shadow-[0_0_18px_rgba(167,139,250,0.3)]":"border-violet-500/30"} ${tt(t)}`,children:[L.jsx(Ie,{type:"target",position:Fe.Left,className:"!h-1.5 !w-1.5 !border-violet-400 !bg-violet-400"}),L.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] font-medium text-violet-300",children:[L.jsx(ut,{className:"h-3 w-3 shrink-0"}),L.jsx("span",{className:"truncate font-mono",children:t.label})]})]})}),ar=X.memo(({data:n})=>{const t=n;return L.jsxs("div",{className:`w-[220px] rounded-lg border bg-cyan-950/60 px-3 py-2 transition-colors duration-150 ${t._highlighted?"border-cyan-400/70 shadow-[0_0_18px_rgba(34,211,238,0.28)]":"border-cyan-500/25"} ${tt(t)}`,children:[L.jsx(Ie,{type:"target",position:Fe.Left,className:"!h-1.5 !w-1.5 !border-cyan-400 !bg-cyan-400"}),L.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] font-medium text-cyan-300",children:[L.jsx(In,{className:"h-3 w-3 shrink-0"}),L.jsx("span",{className:"truncate font-mono",children:t.label})]}),L.jsxs("div",{className:"mt-0.5 flex items-center gap-1 truncate font-mono text-[9px] text-zinc-500",children:[L.jsx(Fn,{className:"h-2.5 w-2.5 shrink-0"}),L.jsxs("span",{className:"truncate",children:[t.file,":",t.line]})]})]})}),ir={entry:nr,router:sr,route:rr,middleware:or,controller:ar,model:Rn};function lr({groups:n,hiddenGroups:t,onToggleGroup:r,onShowAll:s,onIsolateGroup:p,collapsed:f,onToggleCollapse:E}){return f?L.jsxs("button",{onClick:E,title:"Expand Route Groups",className:"pointer-events-auto flex items-center gap-1.5 rounded-xl border border-white/10 bg-zinc-950/85 px-2.5 py-2 text-xs text-zinc-300 shadow-xl backdrop-blur-md hover:border-white/25",children:[L.jsx(zn,{className:"h-4 w-4"}),L.jsxs("span",{className:"font-medium",children:["Groups (",n.length,")"]})]}):L.jsxs("aside",{className:"pointer-events-auto flex max-h-[calc(100vh-110px)] w-60 flex-col rounded-2xl border border-white/10 bg-zinc-950/85 shadow-2xl shadow-black/60 backdrop-blur-md",children:[L.jsxs("div",{className:"flex items-center justify-between border-b border-white/10 px-3 py-2.5",children:[L.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-semibold text-zinc-200",children:[L.jsx(On,{className:"h-3.5 w-3.5 text-sky-400"}),L.jsx("span",{children:"Route Groups"})]}),L.jsxs("div",{className:"flex items-center gap-1",children:[t.size>0&&L.jsx("button",{onClick:s,className:"rounded px-1.5 py-0.5 text-[10px] text-sky-400 hover:bg-sky-500/10",children:"Show all"}),L.jsx("button",{onClick:E,className:"rounded p-0.5 text-zinc-400 hover:bg-white/10 hover:text-zinc-200",children:L.jsx(Dn,{className:"h-4 w-4"})})]})]}),L.jsx("div",{className:"flex-1 space-y-0.5 overflow-y-auto p-2",children:n.map(x=>{const b=t.has(x.name);return L.jsxs("div",{className:`group flex items-center justify-between rounded-lg px-2 py-1.5 text-xs transition ${b?"opacity-45":"hover:bg-white/5"}`,children:[L.jsx("button",{onClick:()=>p(x.name),title:"Click to isolate group",className:"flex min-w-0 flex-1 items-center gap-2 text-left",children:L.jsx("span",{className:"truncate font-mono text-[11px] text-zinc-200",children:x.name})}),L.jsxs("div",{className:"flex items-center gap-1.5",children:[L.jsx("span",{className:"rounded bg-white/5 px-1.5 py-0.5 font-mono text-[10px] text-zinc-400",children:x.count}),L.jsx("button",{onClick:()=>r(x.name),title:b?"Show group":"Hide group",className:"rounded p-0.5 text-zinc-500 hover:bg-white/10 hover:text-zinc-200",children:b?L.jsx(Ln,{className:"h-3.5 w-3.5"}):L.jsx(Zn,{className:"h-3.5 w-3.5"})})]})]},x.name)})})]})}const cr=/\.(js|jsx|ts|tsx|mjs|cjs|py|go|rs|java|kt|rb|proto|graphql|gql)$/i,pr=/^(package\.json|tsconfig\.json|requirements\.txt|pyproject\.toml|go\.mod|Cargo\.toml|pom\.xml|Gemfile)$/i,ur=/(?:^|\/)(?:node_modules|dist|build|target|vendor|\.git|tests?|__tests__|spec)(?:\/|$)/i;function dr(n){const t=n.trim().replace(/\.git$/,""),r=t.match(/^https?:\/\/github\.com\/([A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+)/);if(r)return r[1];const s=t.match(/^([A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+)$/);return s?s[1]:null}async function mn(n){const t=dr(n);if(!t)throw new Error("Enter a valid GitHub URL or owner/repo slug (e.g. fastapi/fastapi).");const r=await fetch(`https://api.github.com/repos/${t}/git/trees/HEAD?recursive=1`);if(r.status===403||r.status===429)throw new Error("GitHub API rate limit reached (60 req/hr unauthenticated). Try again later or use `npx routeweb`.");if(r.status===404)throw new Error(`Repository "${t}" not found or is private.`);if(!r.ok)throw new Error(`GitHub API error (${r.status}).`);const p=((await r.json()).tree??[]).filter(b=>{if(b.type!=="blob"||(b.size??0)>25e4||ur.test(b.path))return!1;const j=b.path.split("/").pop()??"";return cr.test(j)||pr.test(j)}).slice(0,120),f=[],E=15;for(let b=0;b<p.length;b+=E){const j=p.slice(b,b+E),P=await Promise.all(j.map(async A=>{try{const w=await fetch(`https://raw.githubusercontent.com/${t}/HEAD/${A.path}`);return w.ok?{path:A.path,content:await w.text()}:null}catch{return null}}));for(const A of P)A&&f.push(A)}const x=fn(f,{repoName:t});return{slug:t,graph:x}}const fr=new Set(["node_modules",".git","dist","build","coverage"]),mr=/\.(js|jsx|ts|tsx|mjs|cjs)$/i,hr=/^(package\.json|tsconfig\.json|\.env(\.example)?)$/i;function yr({onLoadDemo:n,onLoadScanned:t}){const r=X.useRef(null),[s,p]=X.useState(!1),[f,E]=X.useState(""),[x,b]=X.useState(null),j=async()=>{if(f.trim()){p(!0),b(null);try{const{slug:A,graph:w}=await mn(f);window.location.hash=`#gh/${A}`,t(w)}catch(A){b(A instanceof Error?A.message:String(A))}finally{p(!1)}}},P=async A=>{if(!(!A||A.length===0)){p(!0);try{const w=[];let k="local-project";for(const _ of Array.from(A)){const q=_.webkitRelativePath||_.name,B=q.split("/");if(B.length>1&&(k=B[0]),B.some(c=>fr.has(c)))continue;const V=B.length>1?B.slice(1).join("/"):q,T=B[B.length-1];if(!mr.test(T)&&!hr.test(T))continue;const $=await _.text();w.push({path:V,content:$})}const D=fn(w,{repoName:k});t(D)}finally{p(!1)}}};return L.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-[#09090b]/90 p-4 backdrop-blur-md",children:L.jsxs("div",{className:"w-full max-w-lg rounded-3xl border border-white/15 bg-zinc-950/90 p-8 shadow-2xl shadow-black",children:[L.jsxs("div",{className:"flex items-center gap-3",children:[L.jsx("div",{className:"flex h-11 w-11 items-center justify-center rounded-2xl border border-white/15 bg-gradient-to-br from-emerald-500/20 to-sky-500/20",children:L.jsx(on,{className:"h-6 w-6 text-sky-400"})}),L.jsxs("div",{children:[L.jsx("h1",{className:"text-lg font-bold tracking-tight text-zinc-100",children:"routeweb"}),L.jsx("p",{className:"text-xs text-zinc-400",children:"Zero-config Express AST mapper & interactive spider-web visualizer"})]})]}),L.jsxs("p",{className:"mt-5 text-sm leading-relaxed text-zinc-300",children:["Running in ",L.jsx("span",{className:"font-mono text-sky-400",children:"Static Web Mode"}),". Paste any public GitHub repository, drop a local folder to parse client-side, or explore the demo."]}),L.jsxs("div",{className:"mt-4 flex gap-2",children:[L.jsx("input",{type:"text",value:f,onChange:A=>E(A.target.value),onKeyDown:A=>A.key==="Enter"&&void j(),placeholder:"owner/repo or https://github.com/owner/repo",className:"flex-1 rounded-xl border border-white/15 bg-black/50 px-3 py-2 font-mono text-xs text-zinc-100 placeholder-zinc-500 focus:border-emerald-500/60 focus:outline-none"}),L.jsxs("button",{onClick:()=>void j(),disabled:s||!f.trim(),className:"flex items-center gap-1.5 rounded-xl border border-emerald-500/40 bg-emerald-500/15 px-3.5 py-2 text-xs font-semibold text-emerald-300 transition hover:bg-emerald-500/25 disabled:opacity-50",children:[L.jsx(qn,{className:"h-3.5 w-3.5"}),L.jsx("span",{children:s?"Scanning…":"Scan GitHub"})]})]}),x&&L.jsx("p",{className:"mt-2 rounded-lg border border-rose-500/30 bg-rose-500/10 px-3 py-2 text-xs text-rose-300",children:x}),L.jsxs("div",{className:"mt-6 grid grid-cols-1 gap-3 sm:grid-cols-2",children:[L.jsxs("button",{onClick:n,className:"flex items-center justify-center gap-2 rounded-xl border border-sky-500/40 bg-sky-500/15 px-4 py-3 text-sm font-semibold text-sky-300 transition hover:bg-sky-500/25",children:[L.jsx(Gn,{className:"h-4 w-4"}),L.jsx("span",{children:"Load Demo Graph"})]}),L.jsxs("button",{onClick:()=>{var A;return(A=r.current)==null?void 0:A.click()},disabled:s,className:"flex items-center justify-center gap-2 rounded-xl border border-white/15 bg-white/5 px-4 py-3 text-sm font-semibold text-zinc-100 transition hover:bg-white/10 disabled:opacity-50",children:[L.jsx(Wn,{className:"h-4 w-4 text-emerald-400"}),L.jsx("span",{children:s?"Scanning AST…":"Open Local Folder"})]}),L.jsx("input",{ref:r,type:"file",className:"hidden",webkitdirectory:"",multiple:!0,onChange:A=>void P(A.target.files)})]}),L.jsxs("div",{className:"mt-6 rounded-xl border border-white/10 bg-zinc-900/70 px-3.5 py-2.5 font-mono text-[11px] text-zinc-400",children:["$ npx routeweb . ",L.jsx("span",{className:"text-zinc-600",children:"# or --format md for AI agents"})]})]})})}const gr=["ALL","GET","POST","PUT","PATCH","DELETE"];function xr({repoName:n,routeCount:t,fileCount:r,methodFilter:s,onMethodFilterChange:p,entries:f=[],entryFilter:E="ALL",onEntryFilterChange:x,targetBaseUrl:b,onTargetBaseUrlChange:j,globalAuth:P,onGlobalAuthChange:A,layoutMode:w,onLayoutModeChange:k,middlewareMode:D,onMiddlewareModeChange:_,onOpenSearch:q,onRescan:B,onCopyMarkdown:V,isStaticMode:T,securityOnly:$=!1,onSecurityOnlyChange:c}){const[i,g]=X.useState(!1),[m,e]=X.useState(!1),[a,u]=X.useState(!1),o=()=>{V(),e(!0),setTimeout(()=>e(!1),1600)},l=async()=>{if(!(!B||a)){u(!0);try{await B()}finally{u(!1)}}};return L.jsxs("header",{className:"pointer-events-auto relative z-30 flex flex-wrap items-center justify-between gap-2 rounded-2xl border border-white/10 bg-zinc-950/85 px-3 py-2 shadow-2xl shadow-black/60 backdrop-blur-md",children:[L.jsxs("div",{className:"flex items-center gap-2.5",children:[L.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-lg bg-gradient-to-br from-emerald-500/20 to-sky-500/20 border border-white/10",children:L.jsx(on,{className:"h-4 w-4 text-sky-400"})}),L.jsx("div",{children:L.jsxs("div",{className:"flex items-center gap-2",children:[L.jsx("span",{className:"text-xs font-semibold tracking-tight text-zinc-100",children:n}),L.jsxs("span",{className:"rounded-full bg-white/5 border border-white/10 px-2 py-0.5 font-mono text-[10px] text-zinc-400",children:[t," routes · ",r," files"]}),f.length>1&&x&&L.jsxs("select",{value:E,onChange:h=>x(h.target.value),title:"Filter by Express entry point",className:"max-w-[175px] truncate rounded-lg border border-emerald-500/30 bg-emerald-500/10 px-2 py-0.5 font-mono text-[10px] text-emerald-300 outline-none hover:border-emerald-400/50",children:[L.jsxs("option",{value:"ALL",className:"bg-zinc-950 text-zinc-200",children:["All entries (",f.length,")"]}),f.map(h=>L.jsx("option",{value:h.id,className:"bg-zinc-950 text-zinc-200",children:h.label},h.id))]})]})})]}),L.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[L.jsxs("button",{onClick:q,className:"flex items-center gap-2 rounded-lg border border-white/10 bg-white/5 px-2.5 py-1 text-xs text-zinc-400 transition hover:border-white/20 hover:text-zinc-200",children:[L.jsx(Hn,{className:"h-3.5 w-3.5"}),L.jsx("span",{className:"hidden sm:inline",children:"Search"}),L.jsx("kbd",{className:"rounded bg-zinc-900 px-1 py-0.5 font-mono text-[10px] text-zinc-500",children:"⌘K"})]}),L.jsx("div",{className:"flex items-center rounded-lg border border-white/10 bg-zinc-900/70 p-0.5",children:gr.map(h=>L.jsx("button",{onClick:()=>p(h),className:`rounded-md px-2 py-0.5 font-mono text-[10px] font-semibold transition ${s===h?"bg-white/15 text-zinc-100 shadow-sm":"text-zinc-500 hover:text-zinc-300"}`,children:h},h))}),c&&L.jsxs("button",{onClick:()=>c(!$),title:"Heuristic: show only POST/PUT/PATCH/DELETE routes without detected auth middleware",className:`flex items-center gap-1 rounded-lg border px-2 py-1 font-mono text-[10px] font-semibold transition ${$?"border-amber-500/50 bg-amber-500/15 text-amber-300":"border-white/10 bg-white/5 text-zinc-400 hover:border-white/20 hover:text-zinc-200"}`,children:[L.jsx(ut,{className:"h-3 w-3"}),L.jsx("span",{children:"Unprotected"})]})]}),L.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[L.jsx("input",{type:"text",value:b,onChange:h=>j(h.target.value),placeholder:"http://localhost:3000",title:"Target Base URL",className:"w-40 rounded-lg border border-white/10 bg-zinc-900/80 px-2.5 py-1 font-mono text-[11px] text-zinc-200 outline-none focus:border-sky-500/60"}),L.jsxs("div",{className:"relative",children:[L.jsxs("button",{onClick:()=>g(h=>!h),className:`flex items-center gap-1.5 rounded-lg border px-2.5 py-1 text-xs transition ${P?"border-emerald-500/40 bg-emerald-500/15 text-emerald-300":"border-white/10 bg-white/5 text-zinc-300 hover:border-white/20"}`,children:[L.jsx(Bn,{className:"h-3.5 w-3.5"}),L.jsx("span",{className:"hidden md:inline",children:P?"Auth Set":"Auth"})]}),i&&L.jsxs("div",{className:"absolute right-0 top-full mt-2 w-72 rounded-xl border border-white/15 bg-zinc-950/95 p-3 shadow-2xl backdrop-blur-md",children:[L.jsx("div",{className:"text-xs font-semibold text-zinc-200",children:"Global Authorization Header"}),L.jsx("p",{className:"mt-0.5 text-[11px] text-zinc-500",children:"Paste a JWT token (auto-prefixed with Bearer) or full header like Basic ..."}),L.jsx("input",{type:"text",value:P,onChange:h=>A(h.target.value),placeholder:"Paste token or Bearer <token>",className:"mt-2 w-full rounded-lg border border-white/10 bg-zinc-900 px-2.5 py-1.5 font-mono text-[11px] text-zinc-100 outline-none focus:border-sky-500/60"}),L.jsxs("div",{className:"mt-2 flex justify-end gap-1.5",children:[P&&L.jsx("button",{onClick:()=>A(""),className:"rounded-md px-2 py-1 text-[11px] text-rose-400 hover:bg-rose-500/10",children:"Clear"}),L.jsx("button",{onClick:()=>g(!1),className:"rounded-md bg-white/10 px-2.5 py-1 text-[11px] font-medium text-zinc-100 hover:bg-white/15",children:"Done"})]})]})]}),L.jsxs("div",{className:"flex items-center rounded-lg border border-white/10 bg-zinc-900/70 p-0.5",children:[L.jsxs("button",{onClick:()=>k("flow"),title:"Left-to-Right Flow",className:`flex items-center gap-1 rounded-md px-2 py-0.5 text-[11px] transition ${w==="flow"?"bg-white/15 text-zinc-100":"text-zinc-500 hover:text-zinc-300"}`,children:[L.jsx(Un,{className:"h-3 w-3"}),L.jsx("span",{className:"hidden lg:inline",children:"Flow"})]}),L.jsxs("button",{onClick:()=>k("radial"),title:"Clustered Spider Web",className:`flex items-center gap-1 rounded-md px-2 py-0.5 text-[11px] transition ${w==="radial"?"bg-white/15 text-zinc-100":"text-zinc-500 hover:text-zinc-300"}`,children:[L.jsx(Vn,{className:"h-3 w-3"}),L.jsx("span",{className:"hidden lg:inline",children:"Web"})]})]}),L.jsxs("button",{onClick:()=>_(D==="badges"?"nodes":"badges"),title:"Toggle Middleware & Controller Nodes",className:`flex items-center gap-1 rounded-lg border px-2 py-1 text-[11px] transition ${D==="nodes"?"border-violet-500/40 bg-violet-500/15 text-violet-300":"border-white/10 bg-white/5 text-zinc-400 hover:text-zinc-200"}`,children:[L.jsx(ut,{className:"h-3.5 w-3.5"}),L.jsx("span",{className:"hidden xl:inline",children:D==="nodes"?"Nodes":"Badges"})]}),!T&&B&&L.jsx("button",{onClick:l,disabled:a,title:"Rescan repository",className:"flex items-center gap-1 rounded-lg border border-white/10 bg-white/5 px-2.5 py-1 text-xs text-zinc-300 transition hover:border-white/20 hover:text-zinc-100 disabled:opacity-50",children:L.jsx(Kn,{className:`h-3.5 w-3.5 ${a?"animate-spin":""}`})}),L.jsxs("button",{onClick:o,title:"Copy Markdown API Map for AI Agents",className:"flex items-center gap-1.5 rounded-lg border border-sky-500/30 bg-sky-500/15 px-2.5 py-1 text-xs font-medium text-sky-300 transition hover:bg-sky-500/25",children:[m?L.jsx(Jn,{className:"h-3.5 w-3.5"}):L.jsx(Yn,{className:"h-3.5 w-3.5"}),L.jsx("span",{className:"hidden sm:inline",children:m?"Copied!":"Copy MD"})]})]})]})}const br={version:"1.0",metadata:{repoName:"sample-express (demo)",framework:"express",detectedPort:3001,scannedFiles:10,scanDurationMs:14.2,unresolvedMounts:[]},nodes:[{id:"entry:src/index.js",type:"entry",label:"src/index.js",file:"src/index.js",line:1},{id:"router:src/routes/v1/index.js:/api/v1",type:"router",label:"/api/v1",file:"src/routes/v1/index.js",line:1},{id:"router:src/routes/v1/auth.js:/api/v1/auth",type:"router",label:"/api/v1/auth",file:"src/routes/v1/auth.js",line:1},{id:"router:src/routes/v1/users.js:/api/v1/users",type:"router",label:"/api/v1/users",file:"src/routes/v1/users.js",line:1},{id:"router:src/routes/v1/tasks.js:/api/v1/tasks",type:"router",label:"/api/v1/tasks",file:"src/routes/v1/tasks.js",line:1},{id:"route:GET:/health",type:"route",label:"GET /health",file:"src/index.js",line:7,method:"GET",fullPath:"/health",pathParams:[],queryParams:[],bodyFields:[],group:"/health",middlewares:[],controller:"inlineHandler",controllerFile:"src/index.js",controllerLine:7},{id:"route:POST:/api/v1/auth/login",type:"route",label:"POST /api/v1/auth/login",file:"src/routes/v1/auth.js",line:7,method:"POST",fullPath:"/api/v1/auth/login",pathParams:[],queryParams:[],bodyFields:["email","password"],group:"/api/v1/auth",middlewares:["validateBody"],controller:"authController.login",controllerFile:"src/controllers/auth.js",controllerLine:3},{id:"route:POST:/api/v1/auth/register",type:"route",label:"POST /api/v1/auth/register",file:"src/routes/v1/auth.js",line:8,method:"POST",fullPath:"/api/v1/auth/register",pathParams:[],queryParams:[],bodyFields:["name","email","password"],group:"/api/v1/auth",middlewares:["validateBody"],controller:"authController.register",controllerFile:"src/controllers/auth.js",controllerLine:15},{id:"route:GET:/api/v1/users",type:"route",label:"GET /api/v1/users",file:"src/routes/v1/users.js",line:7,method:"GET",fullPath:"/api/v1/users",pathParams:[],queryParams:["role","limit"],bodyFields:[],group:"/api/v1/users",middlewares:["verifyJWT"],controller:"userController.listUsers",controllerFile:"src/controllers/users.js",controllerLine:3},{id:"route:GET:/api/v1/users/:id",type:"route",label:"GET /api/v1/users/:id",file:"src/routes/v1/users.js",line:8,method:"GET",fullPath:"/api/v1/users/:id",pathParams:["id"],queryParams:[],bodyFields:[],group:"/api/v1/users",middlewares:["verifyJWT"],controller:"userController.getUser",controllerFile:"src/controllers/users.js",controllerLine:15},{id:"route:GET:/api/v1/tasks",type:"route",label:"GET /api/v1/tasks",file:"src/routes/v1/tasks.js",line:7,method:"GET",fullPath:"/api/v1/tasks",pathParams:[],queryParams:["status","priority"],bodyFields:[],group:"/api/v1/tasks",middlewares:["verifyJWT"],controller:"taskController.listTasks",controllerFile:"src/controllers/tasks.js",controllerLine:3},{id:"route:POST:/api/v1/tasks",type:"route",label:"POST /api/v1/tasks",file:"src/routes/v1/tasks.js",line:9,method:"POST",fullPath:"/api/v1/tasks",pathParams:[],queryParams:[],bodyFields:["title","priority","assigneeId"],group:"/api/v1/tasks",middlewares:["verifyJWT","validateBody"],controller:"taskController.createTask",controllerFile:"src/controllers/tasks.js",controllerLine:11},{id:"mw:verifyJWT",type:"middleware",label:"verifyJWT",file:"src/middleware/auth.js",line:1},{id:"mw:validateBody",type:"middleware",label:"validateBody",file:"src/middleware/auth.js",line:15}],edges:[{id:"e1",source:"entry:src/index.js",target:"route:GET:/health",type:"handles"},{id:"e2",source:"entry:src/index.js",target:"router:src/routes/v1/index.js:/api/v1",type:"mounts"},{id:"e3",source:"router:src/routes/v1/index.js:/api/v1",target:"router:src/routes/v1/auth.js:/api/v1/auth",type:"mounts"},{id:"e4",source:"router:src/routes/v1/index.js:/api/v1",target:"router:src/routes/v1/users.js:/api/v1/users",type:"mounts"},{id:"e5",source:"router:src/routes/v1/index.js:/api/v1",target:"router:src/routes/v1/tasks.js:/api/v1/tasks",type:"mounts"},{id:"e6",source:"router:src/routes/v1/auth.js:/api/v1/auth",target:"route:POST:/api/v1/auth/login",type:"handles"},{id:"e7",source:"router:src/routes/v1/auth.js:/api/v1/auth",target:"route:POST:/api/v1/auth/register",type:"handles"},{id:"e8",source:"router:src/routes/v1/users.js:/api/v1/users",target:"route:GET:/api/v1/users",type:"handles"},{id:"e9",source:"router:src/routes/v1/users.js:/api/v1/users",target:"route:GET:/api/v1/users/:id",type:"handles"},{id:"e10",source:"router:src/routes/v1/tasks.js:/api/v1/tasks",target:"route:GET:/api/v1/tasks",type:"handles"},{id:"e11",source:"router:src/routes/v1/tasks.js:/api/v1/tasks",target:"route:POST:/api/v1/tasks",type:"handles"},{id:"e12",source:"route:GET:/api/v1/users",target:"mw:verifyJWT",type:"uses"},{id:"e13",source:"route:GET:/api/v1/users/:id",target:"mw:verifyJWT",type:"uses"},{id:"e14",source:"route:GET:/api/v1/tasks",target:"mw:verifyJWT",type:"uses"},{id:"e15",source:"route:POST:/api/v1/tasks",target:"mw:verifyJWT",type:"uses"},{id:"e16",source:"route:POST:/api/v1/auth/login",target:"mw:validateBody",type:"uses"},{id:"e17",source:"route:POST:/api/v1/auth/register",target:"mw:validateBody",type:"uses"},{id:"e18",source:"route:POST:/api/v1/tasks",target:"mw:validateBody",type:"uses"}]},wr=X.lazy(()=>an(()=>import("./SearchModal-FE7UTYzy.js"),__vite__mapDeps([0,1,2,3])).then(n=>({default:n.SearchModal}))),vr=X.lazy(()=>an(()=>import("./TesterDrawer--T5ETDwa.js"),__vite__mapDeps([4,1,2,3])).then(n=>({default:n.TesterDrawer}))),Er=80;function $r(){const{fitView:n,setCenter:t}=vn(),r=X.useRef(null),s=X.useRef(null),p=X.useRef(0),[f,E]=X.useState(null),[x,b]=X.useState(!1),[j,P]=X.useState(!1),[A,w]=X.useState("http://localhost:3000"),[k,D]=X.useState(""),[_,q]=X.useState("ALL"),[B,V]=X.useState(!1),[T,$]=X.useState("ALL"),[c,i]=X.useState(new Set),[g,m]=X.useState("flow"),[e,a]=X.useState("badges"),[u,o]=X.useState(!1),[l,h]=X.useState(!1),[y,d]=X.useState(null),[v,S]=X.useState(null),[I,O,z]=En([]),[G,W,H]=$n([]);X.useEffect(()=>{let Y=!1;async function se(){try{const ee=await fetch("/api/graph"),ce=ee.headers.get("content-type")??"";if(!ee.ok||!ce.includes("application/json"))throw new Error("Static mode");const pe=await ee.json();if(Y)return;E(pe),i(new Set),b(!1),P(!1),pe.metadata.detectedPort&&w(`http://localhost:${pe.metadata.detectedPort}`);try{const Pe=await fetch("/api/config");if(Pe.ok){const xe=await Pe.json();xe.targetBaseUrl&&!Y&&w(xe.targetBaseUrl)}}catch{}}catch{if(!Y){b(!0);const ee=window.location.hash;if(ee.startsWith("#gh/")){const ce=ee.slice(4);try{const pe=await mn(ce);if(!Y){E(pe.graph),P(!1);return}}catch{}}P(!0)}}}return se(),()=>{Y=!0}},[]),X.useEffect(()=>{const Y=se=>{(se.metaKey||se.ctrlKey)&&se.key.toLowerCase()==="k"&&(se.preventDefault(),h(ee=>!ee))};return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[]);const N=X.useMemo(()=>f?f.nodes.filter(Y=>Y.type==="entry").map(Y=>({id:Y.id,label:Y.label})):[],[f]),C=X.useMemo(()=>f?f.nodes.filter(Y=>Y.type==="route"):[],[f]),R=X.useMemo(()=>{const Y=new Map;for(const se of C){const ee=se.group??"/";Y.set(ee,(Y.get(ee)??0)+1)}return Array.from(Y.entries()).sort((se,ee)=>se[0].localeCompare(ee[0])).map(([se,ee])=>({name:se,count:ee}))},[C]),[M,F]=X.useState({nodes:[],edges:[]});X.useEffect(()=>{const Y=new Worker(new URL("/assets/layout.worker-BZLKpmFA.js",import.meta.url),{type:"module"});return s.current=Y,Y.onmessage=se=>{se.data.id===p.current&&F({nodes:se.data.nodes,edges:se.data.edges})},()=>{Y.terminate(),s.current=null}},[]),X.useEffect(()=>{var ee;if(!f){F({nodes:[],edges:[]});return}let Y=f;if(B){const ce=new Set(["POST","PUT","PATCH","DELETE"]),pe=new Set,Pe=f.nodes.filter(xe=>{if(xe.type!=="route")return pe.add(xe.id),!0;const hn=(xe.method??"GET").toUpperCase();return ce.has(hn)?(xe.middlewares??[]).map(mt=>mt.toLowerCase()).some(mt=>ss.some(yn=>mt.includes(yn)))?!1:(pe.add(xe.id),!0):!1});Y={...f,nodes:Pe,edges:f.edges.filter(xe=>pe.has(xe.source)&&pe.has(xe.target))}}const se=++p.current;(ee=s.current)==null||ee.postMessage({id:se,graph:Y,layoutMode:g,middlewareMode:e,methodFilter:_,entryFilter:T,hiddenGroups:Array.from(c),searchQuery:""})},[f,B,g,e,_,T,c]);const Z=M.nodes.length>Er,U=v??(y==null?void 0:y.id)??null;X.useEffect(()=>{if(Z)return;if(M.nodes.length===0){O([]),W([]);return}if(!U){O(M.nodes.map(ee=>({...ee,data:{...ee.data,_dimmed:!1,_highlighted:!1,_selected:(y==null?void 0:y.id)===ee.id}}))),W(M.edges);return}const{nodeIds:Y,edgeIds:se}=Qs(U,M.edges);O(M.nodes.map(ee=>({...ee,data:{...ee.data,_dimmed:!Y.has(ee.id),_highlighted:Y.has(ee.id),_selected:(y==null?void 0:y.id)===ee.id}}))),W(M.edges.map(ee=>{const ce=se.has(ee.id);return{...ee,animated:ce,style:{...ee.style,stroke:ce?"#10b981":"rgba(113,113,122,0.12)",strokeWidth:ce?2.2:1}}}))},[Z,M,U,y,O,W]),X.useEffect(()=>{if(!Z&&M.nodes.length>0){const Y=setTimeout(()=>{n({padding:.16,duration:350})},50);return()=>clearTimeout(Y)}},[Z,f,g,e,n,M.nodes.length]);const J=X.useCallback((Y,se)=>{const ee=se.data;ee.type==="route"&&d(ee)},[]),K=X.useCallback(Y=>{var ce;const se=Y.group??"/";c.has(se)&&i(pe=>{const Pe=new Set(pe);return Pe.delete(se),Pe}),d(Y);const ee=M.nodes.find(pe=>pe.id===Y.id);ee&&(Z?(ce=r.current)==null||ce.centerOn(ee.position.x+150,ee.position.y+45,1):t(ee.position.x+150,ee.position.y+45,{zoom:1.05,duration:400}))},[M.nodes,c,t,Z]),Q=async()=>{const Y=await fetch("/api/rescan",{method:"POST"});if(Y.ok){const se=await Y.json();E(se)}},te=()=>{f&&navigator.clipboard.writeText(ns(f))},re=Y=>{i(se=>{const ee=new Set(se);return ee.has(Y)?ee.delete(Y):ee.add(Y),ee})},ie=Y=>{i(se=>{const ee=R.map(pe=>pe.name).filter(pe=>pe!==Y);return se.size===ee.length&&!se.has(Y)?new Set:new Set(ee)})};return L.jsxs("div",{className:"relative h-screen w-screen overflow-hidden bg-[#09090b]",children:[Z?L.jsx(er,{ref:r,nodes:M.nodes,edges:M.edges,selectedRouteId:(y==null?void 0:y.id)??null,onSelectRoute:d}):L.jsxs(jn,{nodes:I,edges:G,onNodesChange:z,onEdgesChange:H,onNodeClick:J,onNodeMouseEnter:(Y,se)=>S(se.id),onNodeMouseLeave:()=>S(null),onPaneClick:()=>d(null),nodeTypes:ir,onlyRenderVisibleElements:!0,minZoom:.1,maxZoom:2,proOptions:{hideAttribution:!0},children:[L.jsx(Sn,{variant:An.Dots,gap:22,size:1.2,color:"#1c1c22"}),L.jsx(Pn,{position:"bottom-left"}),L.jsx(_n,{position:"bottom-right",nodeColor:Y=>Y.type==="entry"?"#10b981":Y.type==="router"?"#38bdf8":Y.type==="middleware"?"#a78bfa":Y.type==="controller"?"#22d3ee":"#52525b",maskColor:"rgba(9, 9, 11, 0.72)"})]}),f&&L.jsx("div",{className:"pointer-events-none fixed inset-x-3 top-3 z-30",children:L.jsx(xr,{repoName:f.metadata.repoName,routeCount:C.length,fileCount:f.metadata.scannedFiles,methodFilter:_,onMethodFilterChange:q,entries:N,entryFilter:T,onEntryFilterChange:$,targetBaseUrl:A,onTargetBaseUrlChange:w,globalAuth:k,onGlobalAuthChange:D,layoutMode:g,onLayoutModeChange:m,middlewareMode:e,onMiddlewareModeChange:a,onOpenSearch:()=>h(!0),onRescan:x?void 0:Q,onCopyMarkdown:te,isStaticMode:x,securityOnly:B,onSecurityOnlyChange:V})}),f&&R.length>0&&L.jsx("div",{className:"pointer-events-none fixed left-3 top-18 z-20",children:L.jsx(lr,{groups:R,hiddenGroups:c,onToggleGroup:re,onShowAll:()=>i(new Set),onIsolateGroup:ie,collapsed:u,onToggleCollapse:()=>o(Y=>!Y)})}),L.jsx(X.Suspense,{fallback:null,children:y&&L.jsx(vr,{route:y,targetBaseUrl:A,globalAuth:k,isStaticMode:x,onClose:()=>d(null)})}),L.jsx(X.Suspense,{fallback:null,children:l&&L.jsx(wr,{open:l,routes:C,onClose:()=>h(!1),onSelectRoute:K})}),j&&L.jsx(yr,{onLoadDemo:()=>{E(br),w("http://localhost:3001"),P(!1)},onLoadScanned:Y=>{E(Y),i(new Set),Y.metadata.detectedPort&&w(`http://localhost:${Y.metadata.detectedPort}`),P(!1)}})]})}function jr(){return L.jsx(wn,{children:L.jsx($r,{})})}bn.createRoot(document.getElementById("root")).render(L.jsx(X.StrictMode,{children:L.jsx(jr,{})}));export{tr as g};
|
package/dist/public/index.html
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap"
|
|
17
17
|
rel="stylesheet"
|
|
18
18
|
/>
|
|
19
|
-
<script type="module" crossorigin src="/assets/index-
|
|
19
|
+
<script type="module" crossorigin src="/assets/index-MvsnPaMs.js"></script>
|
|
20
20
|
<link rel="modulepreload" crossorigin href="/assets/react-D71YmLB6.js">
|
|
21
21
|
<link rel="modulepreload" crossorigin href="/assets/vendor-DBc_8COV.js">
|
|
22
22
|
<link rel="modulepreload" crossorigin href="/assets/graph-Dp3lBNo7.js">
|