routeweb 0.1.0 → 0.1.2

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.
@@ -0,0 +1,36 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SearchModal-ZELlGejR.js","assets/react-D71YmLB6.js","assets/vendor-DBc_8COV.js","assets/graph-Dp3lBNo7.js","assets/TesterDrawer-CUl488Qp.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 rn,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 $ of f.addedNodes)$.tagName==="LINK"&&$.rel==="modulepreload"&&s($)}).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},_t={},on=function(t,r,s){let p=Promise.resolve();if(r&&r.length>0){let $=function(S){return Promise.all(S.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=$(r.map(S=>{if(S=Qn(S),S in _t)return;_t[S]=!0;const P=S.endsWith(".css"),A=P?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${S}"]${A}`))return;const w=document.createElement("link");if(w.rel=P?"stylesheet":Xn,P||(w.as="script"),w.crossOrigin="",w.href=S,b&&w.setAttribute("nonce",b),document.head.appendChild(w),P)return new Promise((M,D)=>{w.addEventListener("load",M),w.addEventListener("error",()=>D(new Error(`Unable to preload CSS for ${S}`)))})}))}function f($){const x=new Event("vite:preloadError",{cancelable:!0});if(x.payload=$,window.dispatchEvent(x),!x.defaultPrevented)throw $}return p.then($=>{for(const x of $||[])x.status==="rejected"&&f(x.reason);return t().catch(f)})};function an(n){return n.replace(/\\/g,"/").replace(/\/+/g,"/")}function oe(n){const r=an(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=an(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 Nt=[".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],$=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==="/"&&$==="/"){for(;p<n.length&&n[p]!==`
3
+ `;)p++;continue}if(f==="/"&&$==="*"){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),$=t.get(f);t.set(f,{baseDir:f,baseUrl:p.compilerOptions.baseUrl,paths:p.compilerOptions.paths,packageImports:$==null?void 0:$.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),$={};for(const[x,b]of Object.entries(p.imports)){const S=ct(b);S.length>0&&($[x]=S)}if(Object.keys($).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:$})}}}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 Nt)if(t.has(r+p))return r+p;for(const p of Nt){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),S=le(b,t);return st(S,r)}const p=s instanceof Map?ts(n,s):s;if(!p)return null;const f=(b,S)=>{if(!b)return null;for(const[P,A]of Object.entries(b))if(P.includes("*")){const[w,M]=P.split("*");if(t.startsWith(w)&&t.endsWith(M)){const D=t.slice(w.length,t.length-M.length);for(const _ of A){const q=_.replace("*",D),B=S?le(S,q):oe(q),V=st(B,r);if(V)return V}}}else if(t===P)for(const w of A){const M=S?le(S,w):oe(w),D=st(M,r);if(D)return D}return null};if(t.startsWith("#")&&p.packageImports){const b=f(p.packageImports,p.baseDir);if(b)return b}const $=p.baseUrl?le(p.baseDir,p.baseUrl):p.baseDir,x=f(p.paths,$);if(x)return x;if(p.baseUrl){const b=le($,t),S=st(b,r);if(S)return S}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 M of w.middlewares??[])f.set(M,(f.get(M)??0)+1);const $=Math.max(2,Math.ceil(t.length*.8)),x=new Set(Array.from(f.entries()).filter(([,w])=>w>=$).map(([w])=>w));x.size>0&&s.push(`# Global middleware: [${Array.from(x).join(", ")}]`);const b=[...t].sort((w,M)=>{const D=(w.fullPath??"").localeCompare(M.fullPath??"");return D!==0?D:(w.method??"").localeCompare(M.method??"")}),S=b.map(w=>`${(w.method??"GET").padEnd(6)} ${w.fullPath??"/"}`),P=Math.min(48,Math.max(...S.map(w=>w.length)));for(let w=0;w<b.length;w++){const M=b[w],D=S[w].padEnd(P),_=(M.middlewares??[]).filter(E=>!x.has(E)),q=_.length>0?`[${_.join(", ")}]`:"[]",B=`${M.controller??"handler"} (${M.controllerFile??M.file}:${M.controllerLine??M.line})`,V=[];M.pathParams&&M.pathParams.length>0&&V.push(`params: {${M.pathParams.join(", ")}}`),M.queryParams&&M.queryParams.length>0&&V.push(`query: {${M.queryParams.join(", ")}}`),M.bodyFields&&M.bodyFields.length>0&&V.push(`body: {${M.bodyFields.join(", ")}}`),M.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,M,D,_,q,B,V,T,E,c,a,g,m,e,i,u,o,l,h;const s=rs(n.content);if(!s)return null;const p=new Map,f=new Map,$=[],x=new Map,b=new Set,S=(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")S(v.local.name,d,"default");else if(v.type==="ImportNamespaceSpecifier")S(v.local.name,d,"*");else if(v.type==="ImportSpecifier"){const j=ge(v.imported)??v.local.name;S(v.local.name,d,j)}}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 j=ge(v.exported)??"",I=ge(v.local)??j;$.push({resolvedFile:d,exportedName:j,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:((M=v.loc)==null?void 0:M.start.line)??1});else if(v.id.type==="ObjectPattern"&&v.init)for(const j of v.id.properties)j.type==="ObjectProperty"&&j.value.type==="Identifier"&&f.set(j.value.name,{name:j.value.name,node:v.init,line:((D=j.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,j=ge(d.exported)??v,I=x.get(v);I?f.set(j,{name:j,node:I,line:((q=I.loc)==null?void 0:q.start.line)??((B=d.loc)==null?void 0:B.start.line)??1}):f.set(j,{name:j,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);$.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)??((E=y.loc)==null?void 0:E.start.line)??1})}else f.set("default",{name:"default",node:d,line:((c=d.loc)==null?void 0:c.start.line)??((a=y.loc)==null?void 0:a.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")S(d.id.name,v,"default");else if(d.id.type==="ObjectPattern"){for(const j of d.id.properties)if(j.type==="ObjectProperty"){const I=ge(j.key),O=j.value.type==="Identifier"?j.value.name:I;I&&O&&S(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 j=d.object.type==="Identifier"?d.object.name:null,I=ge(d.property);if(j==="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)??((i=G.loc)==null?void 0:i.start.line)??1})}}}}else if(j==="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))S(y.id.name,d,"default");else if(y.id.type==="ObjectPattern"){for(const v of y.id.properties)if(v.type==="ObjectProperty"){const j=ge(v.key),I=v.value.type==="Identifier"?v.value.name:j;j&&I&&!p.has(I)&&S(I,d,j)}}}}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 j of v)j&&typeof j=="object"&&"type"in j&&P(j);else v&&typeof v=="object"&&"type"in v&&P(v)}}};return P(s.program),{path:n.path,ast:s,imports:p,exports:f,reExports:$,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 ln(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=ln(r,t+1);if(s!==r)return s}}return n}function Pt(n){const t=new Set,r=new Set,s=new Set,p=ln(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 $=p.params[0];($==null?void 0:$.type)==="Identifier"&&(f=$.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},S=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 M=ge(A.property);x(S(w),M)}}if(A.type==="VariableDeclarator"&&A.init&&A.id.type==="ObjectPattern"){const w=b(A.init);if(w){const M=S(w);for(const D of A.id.properties)D.type==="ObjectProperty"&&x(M,ge(D.key))}}for(const w of Object.keys(A)){if(w==="loc"||w==="start"||w==="end"||w==="extra")continue;const M=A[w];if(Array.isArray(M))for(const D of M)D&&typeof D=="object"&&"type"in D&&P(D);else M&&typeof M=="object"&&"type"in M&&P(M)}}};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,cn=/(\.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 ie(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=ie(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 is(n){const{fileSet:t,tsConfig:r,parsedMap:s}=n,p=(x,b,S=0)=>{var P,A,w,M,D,_,q,B,V,T;if(S>8)return null;if(b.type==="Identifier"){const E=x.imports.get(b.name);if(E&&E.resolvedFile){const a=s.get(E.resolvedFile);if(!a)return null;if(E.importedName==="*")return{file:a,node:a.ast.program,name:b.name,line:1};const g=a.exports.get(E.importedName);if(g)return g.node.type==="Identifier"&&g.node.name!==b.name?p(a,g.node,S+1)??{file:a,node:g.node,name:E.importedName,line:g.line}:{file:a,node:g.node,name:E.importedName==="default"?b.name:E.importedName,localName:g.localName,line:g.line};for(const m of a.reExports)if(m.resolvedFile&&(m.exportedName==="*"||m.exportedName===E.importedName)){const e=s.get(m.resolvedFile);if(e){const i=m.exportedName==="*"?E.importedName:m.importedName,u=e.exports.get(i);if(u)return u.node.type==="Identifier"&&u.node.name!==i?p(e,u.node,S+1)??{file:e,node:u.node,name:i,localName:u.localName,line:u.line}:{file:e,node:u.node,name:i,localName:u.localName,line:u.line}}}return E.importedName==="default"&&a.exports.size>0?{file:a,node:a.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 E=ie(b.property);if(!E)return null;if(b.object.type==="ThisExpression")for(const i of x.locals.values()){const u=de(i);if(u.type==="ClassDeclaration"||u.type==="ClassExpression")for(const o of u.body.body){if((o.type==="ClassMethod"||o.type==="ClassProperty")&&ie(o.key)===E){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"}.${E}`,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"&&ie(l.expression.left.property)===E){const h=l.expression.right,y=h.type==="NewExpression"?p(x,h.callee,S+1):null;return y||{file:x,node:h,name:`${((M=u.id)==null?void 0:M.name)??"this"}.${E}`,line:((D=l.loc)==null?void 0:D.start.line)??1}}}}}const c=ze(b.object);if(c){const i=Ce(x.path,c,t,r);if(i){const u=s.get(i),o=u==null?void 0:u.exports.get(E);if(u&&o)return{file:u,node:o.node,name:E,line:o.line}}}const a=p(x,b.object,S+1);if(!a)return null;let g=a,m=de(g.node);if(m.type==="NewExpression"){const i=p(g.file,m.callee,S+1);i&&(g=i,m=de(i.node))}if(m.type==="ClassDeclaration"||m.type==="ClassExpression"){if(E==="router")return{file:g.file,node:m,name:g.name,line:((_=m.loc)==null?void 0:_.start.line)??1};let i={file:g.file,node:m,name:g.name},u=0;for(;i&&u<5;){for(const o of i.node.body.body)if((o.type==="ClassMethod"||o.type==="ClassProperty")&&ie(o.key)===E){const l=o.type==="ClassProperty"&&o.value?o.value:o;return{file:i.file,node:l,name:`${i.name}.${E}`,line:((q=o.loc)==null?void 0:q.start.line)??1}}if(i.node.superClass){const o=p(i.file,i.node.superClass,S+1+u),l=o?de(o.node):null;if(o&&l&&(l.type==="ClassDeclaration"||l.type==="ClassExpression")){i={file:o.file,node:l,name:o.name},u++;continue}}i=null}}if(m.type==="Program"){const i=a.file.exports.get(E);if(i)return{file:a.file,node:i.node,name:`${a.name}.${E}`,line:i.line}}if(m.type==="ObjectExpression")for(const i of m.properties){if(i.type==="ObjectProperty"&&ie(i.key)===E){if(i.value.type==="Identifier"||i.value.type==="MemberExpression"){const o=p(a.file,i.value,S+1);if(o)return o}const u=i.value.type==="Identifier"?a.file.locals.get(i.value.name)??i.value:i.value;return{file:a.file,node:u,name:`${a.name}.${E}`,line:((B=u.loc)==null?void 0:B.start.line)??((V=i.loc)==null?void 0:V.start.line)??1}}if(i.type==="ObjectMethod"&&ie(i.key)===E)return{file:a.file,node:i,name:`${a.name}.${E}`,line:((T=i.loc)==null?void 0:T.start.line)??1}}const e=a.file.exports.get(E);if(e){if(e.node.type==="Identifier"){const i=p(a.file,e.node,S+1);if(i)return i}return{file:a.file,node:e.node,name:`${a.name}.${E}`,localName:e.localName,line:e.line}}}if(b.type==="NewExpression")return p(x,b.callee,S+1);if(b.type==="CallExpression"){if(b.callee.type==="MemberExpression"&&b.callee.object.type==="Identifier"&&b.callee.object.name==="Object"&&ie(b.callee.property)==="assign"&&b.arguments[0]&&b.arguments[0].type!=="SpreadElement")return p(x,b.arguments[0],S+1);if(b.callee.type==="MemberExpression"&&ie(b.callee.property)==="bind")return p(x,b.callee.object,S+1);let E=ze(b);if(!E&&b.callee.type==="Identifier"&&b.callee.name==="require"&&b.arguments[0]){const a=b.arguments[0],g=f(x,a);if(g)E=g;else if(a.type==="CallExpression"&&a.callee.type==="MemberExpression"&&ie(a.callee.property)==="join"){const m=[];for(const e of a.arguments)if(e.type==="Identifier"&&e.name==="__dirname")m.push(".");else{const i=f(x,e);i!==null&&m.push(i)}m.length>0&&(E=m.join("/"))}}if(E){const a=Ce(x.path,E,t,r);if(a){const g=s.get(a);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"&&ie(m.node.callee.property)==="assign"&&m.node.arguments[0]?p(g,m.node.arguments[0],S+1)??{file:g,node:m.node,name:E,localName:m.localName,line:m.line}:{file:g,node:m.node,name:E,localName:m.localName,line:m.line}}}}const c=p(x,b.callee,S+1);if(c&&(c.node.type==="FunctionDeclaration"||c.node.type==="FunctionExpression"||c.node.type==="ArrowFunctionExpression"))return c}return null},f=(x,b,S=0)=>{if(!b||S>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 M=f(x,P.expressions[w],S+1);if(M===null)return null;A+=M}return A}if(P.type==="BinaryExpression"&&P.operator==="+"){const A=f(x,P.left,S+1),w=f(x,P.right,S+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,S+1)}return null};return{resolveSymbol:p,resolveStringExpr:f,resolveStringOrArrayValues:(x,b)=>{if(!b)return null;const S=de(b),P=f(x,S);if(P!==null)return[P];if(S.type==="ArrayExpression"){const A=[];for(const w of S.elements)if(w&&w.type!=="SpreadElement"){const M=f(x,w);M!==null&&A.push(M)}return A.length>0?A:null}return null}}}function as(n,t){const{fileSet:r}=n,{resolveSymbol:s,resolveStringExpr:p,resolveStringOrArrayValues:f}=t,$=(P,A)=>{var M;let w=A;for(;w.type==="CallExpression"&&w.callee.type==="MemberExpression";){const D=ie(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"&&((M=P.imports.get("Router"))==null?void 0:M.sourceSpecifier)==="express"||D.type==="MemberExpression"&&D.object.type==="Identifier"&&P.expressImports.has(D.object.name)&&ie(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,M=new Set,D=(V,T)=>{if(!T)return;const E=de(T);if(E.type==="CallExpression"){const c=E.callee;c.type==="Identifier"&&P.expressImports.has(c.name)?w.add(V):$(P,E)&&M.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=ie(V.left.property);T&&D(`this.${T}`,V.right)}else if(V.type==="ClassProperty"&&V.value){const T=ie(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 E=V[T];if(Array.isArray(E))for(const c of E)c&&typeof c=="object"&&"type"in c&&_(c);else E&&typeof E=="object"&&"type"in E&&_(E)}}};_(P.ast.program);const q=P.exports.get("default");q&&$(P,q.node)&&M.add("__default_router__");const B={apps:w,routers:M};return x.set(P.path,B),B},S=(P,A,w,M)=>{const D=[],_=c=>{var a;if(!M)return c;if(c.type==="Identifier"&&((a=M.identMap)!=null&&a.has(c.name)))return M.identMap.get(c.name);if(M.computedPropMap&&c.type==="MemberExpression"&&c.computed&&c.property.type==="Identifier"&&M.computedPropMap.has(c.property.name))return M.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(M.paramName&&M.props&&c.type==="MemberExpression"&&c.object.type==="Identifier"&&c.object.name===M.paramName){const g=ie(c.property);if(g&&M.props.has(g))return M.props.get(g)}return c},q=(c,a,g)=>{var i,u;if(!a)return!1;const m=de(c);if(m.type==="CallExpression"&&m.callee.type==="MemberExpression"&&m.callee.object.type==="Identifier"&&m.callee.object.name==="Object"&&ie(m.callee.property)==="entries"&&m.arguments[0]&&a.type==="ArrayPattern"&&((i=a.elements[0])==null?void 0:i.type)==="Identifier"&&((u=a.elements[1])==null?void 0:u.type)==="Identifier"){const o=a.elements[0].name,l=a.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=ie(d.key);if(v){const j=new Map([[o,{type:"StringLiteral",value:v}],[l,d.value]]);D.push(...S(P,g,w,{identMap:j}))}}return!0}}if(m.type==="CallExpression"&&m.callee.type==="MemberExpression"&&m.callee.object.type==="Identifier"&&m.callee.object.name==="Object"&&ie(m.callee.property)==="keys"&&m.arguments[0]&&a.type==="Identifier"){const o=a.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=ie(y.key);if(d){const v=new Map([[o,{type:"StringLiteral",value:d}]]),j=new Map([[o,y.value]]);D.push(...S(P,g,w,{identMap:v,computedPropMap:j}))}}return!0}}if(m.type==="CallExpression"&&(m.callee.type==="MemberExpression"&&ie(m.callee.property)==="readdirSync"||m.callee.type==="Identifier"&&m.callee.name==="readdirSync")&&m.arguments[0]&&a.type==="Identifier"){const o=m.arguments[0];let l=null;if(o.type==="CallExpression"&&o.callee.type==="MemberExpression"&&ie(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)&&!cn.test(v));for(const v of d){const j=v.slice(y.length),I=new Map([[a.name,{type:"StringLiteral",value:j}]]);D.push(...S(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"&&a.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=ie(h.key);y&&l.set(y,h.value)}D.push(...S(P,g,w,{paramName:a.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 a=ie(c.property);if(a&&w.has(`this.${a}`))return`this.${a}`}return null},V=c=>{var m;const a=[];let g=c;for(;g.type==="CallExpression"&&g.callee.type==="MemberExpression";){const e=ie(g.callee.property);if(!e)return null;if(e==="route"){const i=B(g.callee.object);if(i){const u=p(P,_(g.arguments[0]));return{routerName:i,pathArg:u??void 0,dynamicPath:u===null,chain:a.reverse()}}return null}if(_e.has(e))a.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 i,u,o,l,h,y,d,v,j,I,O;const a=c.type==="AwaitExpression"?c.argument:c;if(a.type!=="CallExpression")return;if(a.callee.type==="MemberExpression"&&ie(a.callee.property)==="forEach"&&a.arguments[0]&&(a.arguments[0].type==="ArrowFunctionExpression"||a.arguments[0].type==="FunctionExpression")){const z=a.arguments[0],G=z.body.type==="BlockStatement"?z.body.body:[{type:"ExpressionStatement",expression:z.body}];if(q(a.callee.object,z.params[0],G))return}if(a.callee.type==="MemberExpression"&&ie(a.callee.property)==="route"&&B(a.callee.object)&&((i=a.arguments[0])==null?void 0:i.type)==="ObjectExpression"){const z=a.arguments[0];let G=null,W,H,N;for(const C of z.properties){if(C.type!=="ObjectProperty")continue;const R=ie(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 k of C)D.push({kind:"method",objectName:"this",methodName:G.toLowerCase(),pathArg:k,dynamicPath:!1,args:R,line:((u=a.loc)==null?void 0:u.start.line)??1});return}}if(a.callee.type==="MemberExpression"&&ie(a.callee.property)==="route"&&((o=a.arguments[0])==null?void 0:o.type)==="ObjectExpression"){const z=B(a.callee.object);if(z){const G=a.arguments[0];let W=null,H,N,C;for(const R of G.properties)if(R.type==="ObjectProperty"){const k=ie(R.key);k==="method"?W=((l=p(P,R.value))==null?void 0:l.toLowerCase())??null:k==="path"?H=R.value:k==="handler"?N=R.value:k==="middleware"&&(C=R.value)}if(W&&_e.has(W)&&N){const R=p(P,H),k=[];C&&k.push(C),k.push(N),D.push({kind:"method",objectName:z,methodName:W,pathArg:R??void 0,dynamicPath:R===null,args:k,line:((h=a.loc)==null?void 0:h.start.line)??1});return}}}if(a.callee.type==="MemberExpression"&&ie(a.callee.property)==="route"&&((y=a.arguments[0])==null?void 0:y.type)==="ObjectExpression"){const z=B(a.callee.object);if(z){const G=a.arguments[0];let W=null,H,N,C;for(const R of G.properties)if(R.type==="ObjectProperty"){const k=ie(R.key);k==="method"?W=((d=p(P,R.value))==null?void 0:d.toLowerCase())??null:k==="path"?H=R.value:k==="handler"?N=R.value:k==="middleware"&&(C=R.value)}if(W&&_e.has(W)&&N){const R=p(P,H),k=[];C&&k.push(C),k.push(N),D.push({kind:"method",objectName:z,methodName:W,pathArg:R??void 0,dynamicPath:R===null,args:k,line:((v=a.loc)==null?void 0:v.start.line)??1});return}}}const g=V(a);if(g&&g.chain.length>0){D.push({kind:"route-chain",objectName:g.routerName,methodName:"route",pathArg:g.pathArg,dynamicPath:g.dynamicPath,args:[],line:((j=a.loc)==null?void 0:j.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=ie(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__")&&$(P,W)&&!(W.type==="CallExpression"&&W.callee.type==="MemberExpression"&&G.length===0))H="__default_router__";else if(W.type==="CallExpression"&&$(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],k=f(P,R);if(k)for(const F of k)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],k=f(P,R);if(k)for(const F of k)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})(a))return;for(let z=0;z<a.arguments.length;z++){const G=a.arguments[z];if(G.type==="Identifier"&&w.has(G.name)){D.push({kind:"delegate",objectName:G.name,methodName:"delegate",args:[],line:((I=a.loc)==null?void 0:I.start.line)??1,delegateCallee:a.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=ie(W.key);if(H){D.push({kind:"delegate",objectName:W.value.name,methodName:"delegate",args:[],line:((O=a.loc)==null?void 0:O.start.line)??1,delegateCallee:a.callee,delegateArgIndex:z,delegatePropKey:H});return}}}}let e=a;for(;e.type==="CallExpression";){for(const z of e.arguments)(z.type==="ArrowFunctionExpression"||z.type==="FunctionExpression")&&z.body.type==="BlockStatement"&&E(z.body);if(e.callee.type==="MemberExpression")e=e.callee.object;else break}},E=c=>{var a,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"?E(c.expression.right.body):T(c.expression);else if(c.type==="BlockStatement")for(const e of c.body)E(e);else if(c.type==="IfStatement")E(c.consequent),E(c.alternate);else if(c.type==="TryStatement")E(c.block),c.handler&&E(c.handler.body),E(c.finalizer);else if(c.type==="ForOfStatement"){let e;c.left.type==="VariableDeclaration"?e=(a=c.left.declarations[0])==null?void 0:a.id:(c.left.type==="Identifier"||c.left.type==="ArrayPattern")&&(e=c.left);const i=c.body.type==="BlockStatement"?c.body.body:[c.body];q(c.right,e,i)||E(c.body)}else if(c.type==="ForStatement"||c.type==="ForInStatement"||c.type==="WhileStatement")E(c.body);else if(c.type==="FunctionDeclaration"&&c.body)(c.params.some(i=>i.type==="Identifier"&&w.has(i.name))||w.size>0)&&E(c.body);else if(c.type==="ClassDeclaration")for(const e of c.body.body)e.type==="ClassMethod"&&E(e.body);else if(c.type==="ExportNamedDeclaration"&&c.declaration)E(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"?E(c.declaration):(c.declaration.type==="FunctionDeclaration"||c.declaration.type==="FunctionExpression"||c.declaration.type==="ArrowFunctionExpression")&&((g=c.declaration.body)==null?void 0:g.type)==="BlockStatement"&&E(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"&&$(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(e.init.body)}};for(const c of A)E(c);return D};return{isExpressRouterCreation:$,getRouterVarsInFile:b,collectCallsInBlock:S}}function ls(n,t,r){const{nodes:s,addNode:p,addEdge:f}=n,{resolveSymbol:$}=t,{isExpressRouterCreation:x,getRouterVarsInFile:b}=r,S=w=>{const M=[];for(const D of w)if(D.type==="ArrayExpression")for(const _ of D.elements)_&&_.type!=="SpreadElement"&&M.push(...S([_]));else D.type!=="SpreadElement"&&M.push(D);return M};return{flattenArgNodes:S,isRouterSymbol:w=>{if(!w)return null;const{apps:M,routers:D}=b(w.file),_=w.localName??w.name;if(D.has(_)||M.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:E}=b(B);if(T.has("this.app")||T.has("this.router")||E.has("this.app"))return"this";if(q.superClass){const c=$(B,q.superClass,1),a=c?de(c.node):null;if(c&&a&&(a.type==="ClassDeclaration"||a.type==="ClassExpression")){q=a,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,M,D,_,q,B,V)=>{var W,H,N;const T=S(_);if(T.length===0)return;const E=T[T.length-1],c=T.slice(0,-1),a=[...V];for(const C of c){const R=Ge(C);a.includes(R)||a.push(R);const k=`mw:${R}`;p({id:k,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=E.loc)==null?void 0:H.start.line)??B,i=E;if(E.type!=="ArrowFunctionExpression"&&E.type!=="FunctionExpression"){let C=E;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=$(q,C);R&&(i=R.node,m=R.file.path,e=R.line)}const u=Pt(i),o=(C,R)=>{if(!C)return;const k=de(C);if(k.type==="ObjectExpression"){for(const F of k.properties)if(F.type==="ObjectProperty"){const Z=ie(F.key);Z&&R.add(Z)}}else k.type==="CallExpression"&&k.callee.type==="MemberExpression"&&ie(k.callee.property)==="object"&&k.arguments[0]&&o(k.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 k=ie(R.key);k==="body"?o(R.value,l):k==="query"?o(R.value,h):k==="params"&&o(R.value,y)}}const d=Array.from(new Set([...fe(D),...y])),v=Array.from(h),j=Array.from(l),I=me(D),O=`route:${M}:${D}`,z=s.get(O);z?(z.middlewares=Array.from(new Set([...z.middlewares??[],...a])),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??[],...j])),g!=="inlineHandler"&&(z.controller=g,z.controllerFile=m,z.controllerLine=e)):p({id:O,type:"route",label:`${M} ${D}`,file:q.path,line:B,method:M,fullPath:D,pathParams:d,queryParams:v,bodyFields:j,group:I,middlewares:a,controller:g,controllerFile:m,controllerLine:e}),f({id:`edge:${w}->${O}`,source:w,target:O,type:"handles"});for(const C of a){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)&&!cn.test(d.path)),f=new Set(s.map(d=>d.path)),$=et(s),x=new Map;for(const d of p){const v=We(d,f,$);v&&x.set(d.path,v)}const b=Array.from(x.values()),S=os(s,b),P=new Map,A=new Map,w=[],M=d=>{P.has(d.id)||P.set(d.id,d)},D=d=>{A.has(d.id)||A.set(d.id,d)},_={fileSet:f,tsConfig:$,parsedMap:x,nodes:P,addNode:M,addEdge:D},q=is(_),B=as(_,q),V=ls(_,q,B),{resolveSymbol:T}=q,{getRouterVarsInFile:E,collectCallsInBlock:c}=B,{flattenArgNodes:a,isRouterSymbol:g,registerRoute:m}=V,e=new Set,i=(d,v,j,I,O,z)=>{const G=`${d.path}:${Array.from(v).join(",")}:${O}`;if(e.has(G))return;e.add(G);const W=c(d,j,v),H=[...z];for(const N of W)if(N.kind==="use"){const C=N.pathArg?ne(O,N.pathArg):O,R=a(N.args),k=[...H];for(const F of R){const Z=T(d,F),U=g(Z);if(Z&&U){const J=`router:${Z.file.path}:${C||"/"}`;M({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}]),i(K,te,Q,J,C,k)}else if(F.type==="CallExpression"&&F.callee.type==="MemberExpression"&&ie(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.")&&!k.includes(J)&&(k.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 k=null;if(!N.delegatePropKey&&(R==null?void 0:R.type)==="Identifier")k=R.name;else if(N.delegatePropKey&&(R==null?void 0:R.type)==="ObjectPattern"){for(const F of R.properties)if(F.type==="ObjectProperty"&&ie(F.key)===N.delegatePropKey&&F.value.type==="Identifier"){k=F.value.name;break}}k&&i(C.file,new Set([k]),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 k=R.methodName.toUpperCase();m(I,k,C,R.args,d,R.line,H)}}},u=[];for(const d of b){const{apps:v}=E(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 j=`entry:${d.path}`;M({id:j,type:"entry",label:d.path,file:d.path,line:1}),i(d,v,d.ast.program.body,j,"",[])}else for(const d of b){const{routers:v}=E(d);if(v.size>0){const j=`router:${d.path}:/`;M({id:j,type:"router",label:d.path,file:d.path,line:1}),i(d,v,d.ast.program.body,j,"",[])}}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:S,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"]),kt=/\.(ts|tsx|js|jsx|mjs|cjs)$/i,Mt=/(\.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 $;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=(($=n.params[0])==null?void 0:$.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 S=ye(x.callee.property),P=x.arguments[0],A=(P==null?void 0:P.type)==="StringLiteral"?P.value:null;S==="param"&&A?t.add(A):(S==="query"||S==="queries")&&A&&r.add(A)}if(x.type==="VariableDeclarator"&&x.init&&x.id.type==="ObjectPattern"){const S=x.init.type==="AwaitExpression"?x.init.argument:x.init;if(S.type==="CallExpression"&&S.callee.type==="MemberExpression"&&S.callee.object.type==="MemberExpression"&&S.callee.object.object.type==="Identifier"&&S.callee.object.object.name===p&&ye(S.callee.object.property)==="req"){const P=ye(S.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=S.arguments[0])==null?void 0:b.type)==="StringLiteral"){const w=S.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 M=ye(w.key);M&&A.add(M)}}}}for(const S of Object.keys(x)){if(S==="loc"||S==="start"||S==="end"||S==="extra")continue;const P=x[S];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=>kt.test(r.path)&&!Mt.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=>kt.test(e.path)&&!Mt.test(e.path)),f=new Set(s.map(e=>e.path)),$=et(s),x=new Map;for(const e of p){const i=We(e,f,$);i&&x.set(e.path,i)}const b=Array.from(x.values()),S=new Map,P=new Map,A=[],w=e=>{S.has(e.id)||S.set(e.id,e)},M=e=>{P.has(e.id)||P.set(e.id,e)},D=(e,i,u=0)=>{var l,h;if(u>8)return null;const o=we(i);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 j=v.exports.get(y.importedName);if(j)return j.node.type==="Identifier"&&j.node.name!==o.name?D(v,j.node,u+1)??{file:v,node:j.node,name:y.importedName,localName:j.localName,line:j.line}:{file:v,node:j.node,name:y.importedName==="default"?o.name:y.importedName,localName:j.localName,line:j.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 j=d.file.exports.get(y);if(j)return{file:d.file,node:j.node,name:`${d.name}.${y}`,line:j.line}}if(v.type==="ObjectExpression"){for(const j of v.properties)if(j.type==="ObjectProperty"&&ye(j.key)===y)return{file:d.file,node:j.value,name:`${d.name}.${y}`,line:((h=j.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,i,u=0)=>{if(!i||u>8)return null;const o=we(i);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,i,u=0)=>{if(u>4)return{isHono:!1};let o=we(i),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 i=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&&i.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&&i.set("__default_hono__",l.basePath)}return i},V=(e,i,u,o,l,h,y)=>{var k;if(o.length===0)return;const d=o[o.length-1],v=o.slice(0,-1),j=[...y];for(const F of v){const Z=Je(F);Z&&Z!=="anonymous"&&!j.includes(Z)&&j.push(Z)}let I="inlineHandler",O=l.path,z=((k=d.loc)==null?void 0:k.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:${i}:${u}`;w({id:C,type:"route",label:`${i} ${u}`,file:l.path,line:h,method:i,fullPath:u,pathParams:H,queryParams:W.queryParams,bodyFields:W.bodyFields,group:N,middlewares:j,controller:I,controllerFile:O,controllerLine:z}),M({id:`edge:${e}->${C}`,source:e,target:C,type:"handles"});for(const F of j){const Z=`mw:${F}`;w({id:Z,type:"middleware",label:F,file:l.path,line:h}),M({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}),M({id:`edge:${C}->${R}`,source:C,target:R,type:"calls"})},T=new Set,E=(e,i,u,o,l,h)=>{const y=`${e.path}:${Array.from(i).join(",")}:${l}`;if(T.has(y))return;T.add(y);const d=[...h],v=(I,O)=>{var C,R,k;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 ae of Q)ae.type==="ExpressionStatement"&&ae.expression.type==="CallExpression"&&v(ae.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"&&i.has(W.name))H=!0;else if(i.has("__default_hono__")&&q(e,W).isHono)H=!0;else for(const F of i)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 ae=Q.get(re),Y=ae?ne(J,ae):J,se=`router:${K.file.path}:${Y||"/"}`;w({id:se,type:"router",label:Y||K.name,file:K.file.path,line:K.line}),M({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;E(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=((k=_(Z.file,K.value))==null?void 0:k.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)`)}},j=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)j(G);else if(I.type==="IfStatement")j(I.consequent),j(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"&&j(I.declaration.body):I.type==="FunctionDeclaration"&&I.body&&j(I.body)};for(const I of u)j(I)},c=[];for(const e of b){const i=B(e);i.size>0&&c.push({pf:e,apps:i})}const a=new Set;if(c.length>1)for(const{pf:e}of c)for(const i of e.imports.values())i.resolvedFile&&a.add(i.resolvedFile);const g=c.filter(e=>!a.has(e.pf.path)),m=g.length>0?g:c;for(const{pf:e,apps:i}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 i.entries())E(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(S.values()),edges:Array.from(P.values())}}},ds=new Set(["get","post","put","patch","delete","options","head","all"]),Tt=/\.(ts|tsx|js|jsx|mjs|cjs)$/i,Ct=/(\.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 $=he(f.key);$&&t.add($)}}}}}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=>Tt.test(r.path)&&!Ct.test(r.path)&&/from\s+['"]fastify['"]|require\(\s*['"]fastify['"]\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=>Tt.test(E.path)&&!Ct.test(E.path)),f=new Set(s.map(E=>E.path)),$=et(s),x=new Map;for(const E of p){const c=We(E,f,$);c&&x.set(E.path,c)}const b=Array.from(x.values()),S=new Map,P=new Map,A=[],w=E=>{S.has(E.id)||S.set(E.id,E)},M=E=>{P.has(E.id)||P.set(E.id,E)},D=(E,c,a=0)=>{var m,e,i;if(a>8)return null;const g=De(c);if(g.type==="Identifier"){const u=E.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,a+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=E.locals.get(g.name);if(o)return{file:E,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(E,g.object,a+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(E.path,u,f,$),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:E,node:o,name:Le(g.callee),line:((i=o.loc)==null?void 0:i.start.line)??1}}}return null},_=(E,c,a=0)=>{if(!c||a>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 i=_(E,g.expressions[e],a+1);if(i===null)return null;m+=i}return m}if(g.type==="BinaryExpression"&&g.operator==="+"){const m=_(E,g.left,a+1),e=_(E,g.right,a+1);return m!==null&&e!==null?m+e:null}if(g.type==="Identifier"||g.type==="MemberExpression"){const m=D(E,g);if(m)return _(m.file,m.node,a+1)}return null},q=E=>{const c=new Set,a=new Set;for(const[m,e]of E.imports.entries())e.sourceSpecifier==="fastify"&&(e.importedName==="default"||e.importedName==="*")&&a.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"&&a.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 i=m[e];if(Array.isArray(i))for(const u of i)u&&typeof u=="object"&&"type"in u&&g(u);else i&&typeof i=="object"&&"type"in i&&g(i)}}};return g(E.ast.program),c},B=(E,c,a,g,m,e,i,u)=>{var R;const o=[...u],l=new Set,h=new Set,y=new Set;if(m){for(const k of m.properties)if(k.type==="ObjectProperty"){const F=he(k.key);if(F==="preHandler"||F==="onRequest")if(k.value.type==="ArrayExpression")for(const Z of k.value.elements)Z&&Z.type!=="SpreadElement"&&o.push(Le(Z));else o.push(Le(k.value));else if(F==="schema"&&k.value.type==="ObjectExpression"){for(const Z of k.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,j=((R=g.loc)==null?void 0:R.start.line)??i,I=g;if(g.type!=="ArrowFunctionExpression"&&g.type!=="FunctionExpression"&&g.type!=="ObjectMethod"){d=Le(g);const k=D(e,g);k&&(I=k.node,v=k.file.path,j=k.line)}const O=Pt(I),z=Array.from(new Set([...fe(a),...O.pathParams,...y])),G=Array.from(new Set([...O.queryParams,...h])),W=Array.from(new Set([...O.bodyFields,...l])),H=me(a),N=`route:${c}:${a}`;w({id:N,type:"route",label:`${c} ${a}`,file:e.path,line:i,method:c,fullPath:a,pathParams:z,queryParams:G,bodyFields:W,group:H,middlewares:o,controller:d,controllerFile:v,controllerLine:j}),M({id:`edge:${E}->${N}`,source:E,target:N,type:"handles"});for(const k of o){const F=`mw:${k}`;w({id:F,type:"middleware",label:k,file:e.path,line:i}),M({id:`edge:${N}->${F}`,source:N,target:F,type:"uses"})}const C=`ctrl:${v}:${d}:${j}`;w({id:C,type:"controller",label:d,file:v,line:j}),M({id:`edge:${N}->${C}`,source:N,target:C,type:"calls"})},V=new Set,T=(E,c,a,g,m,e)=>{const i=`${E.path}:${Array.from(c).join(",")}:${m}`;if(V.has(i))return;V.add(i);const u=l=>{var d,v,j,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 k of H.properties)if(k.type==="ObjectProperty"){const F=he(k.key);if(F==="prefix"&&(N=_(E,k.value)??""),F==="dir"&&(C=k.value),F==="options"&&k.value.type==="ObjectExpression")for(const Z of k.value.properties)Z.type==="ObjectProperty"&&he(Z.key)==="prefix"&&(N=_(E,Z.value)??N)}}const R=N?ne(m,N):m;if(C){let k=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=_(E,Z);U!==null&&F.push(U)}F.length>0&&(k=F.join("/"))}else k=_(E,C);if(k){const F=oe(le(Re(E.path),k)),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=((j=K.params[0])==null?void 0:j.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}),M({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 k=D(E,W);if(k&&(k.node.type==="FunctionDeclaration"||k.node.type==="FunctionExpression"||k.node.type==="ArrowFunctionExpression")&&k.node.body.type==="BlockStatement"){const F=((I=k.node.params[0])==null?void 0:I.type)==="Identifier"?k.node.params[0].name:"fastify",Z=`router:${k.file.path}:${R||"/"}`;w({id:Z,type:"router",label:R||k.name,file:k.file.path,line:k.line}),M({id:`edge:${g}->${Z}`,source:g,target:Z,type:"mounts",label:N||"/"}),T(k.file,new Set([F]),k.node.body.body,Z,R,e)}else A.push(`${E.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 k=he(R.key);if(k==="method")if(R.value.type==="ArrayExpression")for(const F of R.value.elements){const Z=_(E,F);Z&&H.push(Z.toUpperCase())}else{const F=_(E,R.value);F&&H.push(F.toUpperCase())}else k==="url"||k==="path"?N=_(E,R.value):k==="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 k of H)B(g,k,R,C,W,E,y,e)}return}if(ds.has(h)){const W=_(E,l.arguments[0]);if(W===null){A.push(`${E.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,E,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 a)o(l)};for(const E of b){const c=q(E);if(c.size>0){const a=`entry:${E.path}`;w({id:a,type:"entry",label:E.path,file:E.path,line:1}),T(E,c,E.ast.program.body,a,"",[])}}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(S.values()),edges:Array.from(P.values())}}},It={Get:"GET",Post:"POST",Put:"PUT",Patch:"PATCH",Delete:"DELETE",Options:"OPTIONS",Head:"HEAD",All:"ALL"},gt=/\.(ts|tsx|js|jsx|mjs|cjs)$/i,Ft=/(\.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 Rt(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)&&!Ft.test(r.path)&&/from\s+['"]@nestjs\/common['"]/.test(r.content))}scan(n,t){var V,T,E,c,a,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)&&!Ft.test(e.path)),f=new Set(s.map(e=>e.path)),$=et(s),x=new Map;for(const e of p){const i=We(e,f,$);i&&x.set(e.path,i)}const b=Array.from(x.values()),S=new Map,P=new Map,A=e=>{S.has(e.id)||S.set(e.id,e)},w=e=>{P.has(e.id)||P.set(e.id,e)},M=new Map;for(const e of b)for(const i of e.ast.program.body){const u=i.type==="ExportNamedDeclaration"&&i.declaration?i.declaration:i;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&&M.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&&M.set(u.id.name,o)}}let D="",_="main.ts",q;for(const e of s){if(!gt.test(e.path))continue;const i=e.content.match(/\.setGlobalPrefix\(\s*['"`]([^'"`]+)['"`]/);i&&(D=i[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 i of e.ast.program.body){const u=i.type==="ExportNamedDeclaration"&&i.declaration||i.type==="ExportDefaultDeclaration"&&i.declaration.type==="ClassDeclaration"?i.declaration:i;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=Rt(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:((E=u.loc)==null?void 0:E.start.line)??1}),w({id:`edge:${B}->${v}`,source:B,target:v,type:"mounts",label:d||"/"});for(const j of u.body.body){if(j.type!=="ClassMethod"||!((c=j.decorators)!=null&&c.length))continue;const I=[],O=[...l];for(const R of j.decorators){const k=xt(R);if(k&&k in It)I.push({method:It[k],paths:Rt(R)});else if((k==="UseGuards"||k==="UseInterceptors"||k==="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 j.params)if(!(R.type!=="Identifier"||!((a=R.decorators)!=null&&a.length)))for(const k of R.decorators){const F=xt(k),Z=k.expression.type==="CallExpression"?pt(k.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 M.get(U)??[])W.add(J)}}}const H=Ye(j.key)??"handler",N=`${h}.${H}`,C=((m=j.loc)==null?void 0:m.start.line)??1;for(const R of I)for(const k of R.paths){const F=ne(d,k),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(S.values()),edges:Array.from(P.values())}}},zt=new Set(["get","post","put","patch","delete","del","options","head","all"]),Ot=/\.(ts|tsx|js|jsx|mjs|cjs)$/i,Dt=/(\.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 S=be(b.property);if(S==="params")return t;if(S==="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 S=be(b.property);if(S==="body")return s;if(S==="query")return r}return null},$=b=>{if(!(!b||typeof b!="object")){if(b.type==="MemberExpression"){const S=f(b.object),P=be(b.property);S&&P&&S.add(P)}if(b.type==="VariableDeclarator"&&b.init&&b.id.type==="ObjectPattern"){const S=f(b.init);if(S){for(const P of b.id.properties)if(P.type==="ObjectProperty"){const A=be(P.key);A&&S.add(A)}}}for(const S of Object.keys(b)){if(S==="loc"||S==="start"||S==="end"||S==="extra")continue;const P=b[S];if(Array.isArray(P))for(const A of P)A&&typeof A=="object"&&"type"in A&&$(A);else P&&typeof P=="object"&&"type"in P&&$(P)}}};return $(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=>Ot.test(r.path)&&!Dt.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=>Ot.test(c.path)&&!Dt.test(c.path)),f=new Set(s.map(c=>c.path)),$=et(s),x=new Map;for(const c of p){const a=We(c,f,$);a&&x.set(c.path,a)}const b=Array.from(x.values()),S=new Map,P=new Map,A=[],w=c=>{S.has(c.id)||S.set(c.id,c)},M=c=>{P.has(c.id)||P.set(c.id,c)},D=(c,a,g=0)=>{var e;if(g>8)return null;const m=He(a);if(m.type==="Identifier"){const i=c.imports.get(m.name);if(i!=null&&i.resolvedFile){const o=x.get(i.resolvedFile);if(!o)return null;if(i.importedName==="*")return{file:o,node:o.ast.program,name:m.name,line:1};const l=o.exports.get(i.importedName);if(l)return{file:o,node:l.node,name:i.importedName==="default"?m.name:i.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 i=be(m.property);if(!i)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(i);if(l)return{file:u.file,node:l.node,name:`${u.name}.${i}`,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 i=ze(m);if(i){const u=Ce(c.path,i,f,$),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:i,localName:l.localName,line:l.line}}}return null},_=(c,a,g=0)=>{if(!a||g>8)return null;const m=He(a);if(m.type==="StringLiteral")return m.value;if(m.type==="TemplateLiteral"){let e="";for(let i=0;i<m.quasis.length;i++)if(e+=m.quasis[i].value.cooked??m.quasis[i].value.raw,i<m.expressions.length){const u=_(c,m.expressions[i],g+1);if(u===null)return null;e+=u}return e}if(m.type==="BinaryExpression"&&m.operator==="+"){const e=_(c,m.left,g+1),i=_(c,m.right,g+1);return e!==null&&i!==null?e+i: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 a=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 i=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))a.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&&i(h);else l&&typeof l=="object"&&"type"in l&&i(l)}}};return i(c.ast.program),{apps:a,routers:g}},B=(c,a,g,m,e,i,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)??i,j=o;if(o.type!=="ArrowFunctionExpression"&&o.type!=="FunctionExpression"){y=Xe(o);const H=D(e,o);H&&(j=H.node,d=H.file.path,v=H.line)}const I=hs(j),O=Array.from(new Set([...fe(g),...I.pathParams])),z=`route:${a}:${g}`;w({id:z,type:"route",label:`${a} ${g}`,file:e.path,line:i,method:a,fullPath:g,pathParams:O,queryParams:I.queryParams,bodyFields:I.bodyFields,group:me(g),middlewares:h,controller:y,controllerFile:d,controllerLine:v}),M({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:i}),M({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}),M({id:`edge:${z}->${G}`,source:z,target:G,type:"calls"})},V=new Set,T=(c,a,g,m,e,i)=>{const u=`${c.path}:${Array.from(a).join(",")}:${e}`;if(V.has(u))return;V.add(u);let o=e;const l=[...i],h=d=>{var I;const v=[];let j=d;for(;j.type==="CallExpression"&&j.callee.type==="MemberExpression";){const O=be(j.callee.property);if(!O||O!=="use"&&O!=="prefix"&&!zt.has(O))break;v.push({methodName:O,args:j.arguments,line:((I=j.loc)==null?void 0:I.start.line)??1}),j=He(j.callee.object)}if(v.length!==0&&!(j.type!=="Identifier"||!a.has(j.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),k=N.localName??N.name;if(R.has(k)){const F=R.get(k)??"",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}),M({id:`edge:${m}->${U}`,source:m,target:U,type:"mounts"}),T(N.file,new Set([k]),N.file.ast.program.body,U,Z,l);continue}}const C=Xe(H);C&&C!=="anonymous"&&!l.includes(C)&&l.push(C)}}else if(zt.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 j=v;for(;j.type==="CallExpression";){for(const I of j.arguments)(I.type==="ArrowFunctionExpression"||I.type==="FunctionExpression")&&I.body.type==="BlockStatement"&&y(I.body);if(j.callee.type==="MemberExpression")j=j.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)},E=[];for(const c of b){const{apps:a}=q(c);a.size>0&&E.push({pf:c,apps:a})}if(E.length>0)for(const{pf:c,apps:a}of E){const g=`entry:${c.path}`;w({id:g,type:"entry",label:c.path,file:c.path,line:1}),T(c,a,c.ast.program.body,g,"",[])}else for(const c of b){const{routers:a}=q(c);for(const[g,m]of a.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(S.values()),edges:Array.from(P.values())}}},Lt=/(?:^|.*\/)(?:src\/)?app\/(?:(.*)\/)?route\.(ts|tsx|js|jsx|mjs|cjs)$/i,Zt=/(?:^|.*\/)(?: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 qt(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 $=p.callee.object;($.type==="Identifier"&&$.name==="searchParams"||$.type==="MemberExpression"&&Ze($.property)==="searchParams")&&t.add(p.arguments[0].value)}if(p.type==="VariableDeclarator"&&p.init&&p.id.type==="ObjectPattern"){const $=p.init.type==="AwaitExpression"?p.init.argument:p.init;if($.type==="CallExpression"&&$.callee.type==="MemberExpression"&&Ze($.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 $ of Object.keys(p)){if($==="loc"||$==="start"||$==="end"||$==="extra")continue;const x=p[$];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=($,x)=>{if($.type==="MemberExpression"&&Ze($.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 $=f.test.value.toUpperCase();$t.has($)&&t.add($)}}for(const f of Object.keys(s)){if(f==="loc"||f==="start"||f==="end"||f==="extra")continue;const $=s[f];if(Array.isArray($))for(const x of $)x&&typeof x=="object"&&"type"in x&&r(x);else $&&typeof $=="object"&&"type"in $&&r($)}}};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 Lt.test(s)||Zt.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 $=new Map,x=new Map,b=_=>{$.has(_.id)||$.set(_.id,_)},S=_=>{x.has(_.id)||x.set(_.id,_)},P="entry:nextjs-app-router",A="entry:nextjs-pages-router";let w=!1,M=!1,D=0;for(const _ of s){const q=_.path.match(Lt),B=q?null:_.path.match(Zt);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("/"):[],E=qt(T),c=f?ne(f,E):E,a=me(c);for(const[g,m]of V.exports.entries()){const e=g.toUpperCase();if(!$t.has(e))continue;const i=e,u=xs(m.node),o=fe(c),l=`route:${i}:${c}`;b({id:l,type:"route",label:`${i} ${c}`,file:_.path,line:m.line,method:i,fullPath:c,pathParams:o,queryParams:u.queryParams,bodyFields:u.bodyFields,group:a,middlewares:[],controller:g,controllerFile:_.path,controllerLine:m.line}),S({id:`edge:${P}->${l}`,source:P,target:l,type:"handles"})}}else if(B){M||(M=!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 E=ne("/api",qt(T)),c=f?ne(f,E):E,a=me(c),g=V.exports.get("default"),m=g?Pt(g.node):{pathParams:[],queryParams:[],bodyFields:[]},e=bs(V),i=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:i,queryParams:m.queryParams,bodyFields:m.bodyFields,group:a,middlewares:[],controller:(g==null?void 0:g.localName)??"handler",controllerFile:_.path,controllerLine:(g==null?void 0:g.line)??1}),S({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($.values()),edges:Array.from(x.values())}}},Gt=/(?:^|\/)(?: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,"/"):"",$=[];if(s&&f)$.push(le(s,`${f}.py`),le(s,`${f}/__init__.py`));else if(f){$.push(`${f}.py`,`${f}/__init__.py`);for(const x of r)(x.endsWith(`/${f}.py`)||x.endsWith(`/${f}/__init__.py`))&&$.push(x)}else s&&$.push(le(s,"__init__.py"));for(const x of $){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 $=n[f];if(s){p?p=!1:$==="\\"?p=!0:$===s&&(s=null);continue}if($==='"'||$==="'"){s=$;continue}if($==="(")r++;else if($===")"&&(r--,r===0))return{content:n.slice(t+1,f),endIdx:f}}return{content:n.slice(t+1),endIdx:n.length-1}}function Wt(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")&&!Gt.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")&&!Gt.test(T.path)),p=new Set(s.map(T=>T.path)),f=new Map,$=new Map;for(const T of s){const E=/^[ \t]*([A-Za-z_][A-Za-z0-9_]*)(?:\s*:\s*str)?\s*=\s*['"]([^'"]*)['"]/gm;let c;for(;(c=E.exec(T.content))!==null;)c[2].startsWith("/")&&$.set(c[1],c[2]);const a=/^class\s+([A-Za-z_][A-Za-z0-9_]*)\s*\([^)]*(?:BaseModel|SQLModel|Schema)[^)]*\)\s*:/gm;let g;for(;(g=a.exec(T.content))!==null;){const m=g[1],e=T.content.slice(g.index+g[0].length),i=[];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"&&i.push(o[1])}i.length>0&&f.set(m,i)}}const x=new Map;for(const T of s){const E=new Map,c=new Map,a=[],g=[],m=T.content,e=/^\s*from\s+(\.{0,3}[A-Za-z0-9_.]*)\s+import\s+([^\n#]+)/gm;let i;for(;(i=e.exec(m))!==null;){const j=i[1],I=i[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?E.set(G[2],{modulePath:j,importedName:G[1]}):/^[A-Za-z0-9_]+$/.test(z)&&E.set(z,{modulePath:j,importedName:z})}}const u=j=>{const I=j.match(/^['"]([^'"]*)['"]$/);if(I)return I[1].replace(/\{([^:}]+)(?::[^}]+)?\}/g,":$1");const O=j.match(/^f['"]([^'"]*)['"]$/);if(O)return O[1].replace(/\{([A-Za-z_][A-Za-z0-9_.]*)\}/g,(H,N)=>{const C=$.get(N.split(".").pop());return C!==void 0?C:H}).replace(/\{([^:}]+)(?::[^}]+)?\}/g,":$1");const z=j.split(".").pop();return($.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 j=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(j,{varName:j,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 j=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&&a.push({parentVar:j,targetExpr:O,prefix:G,dependencies:rt(I),line:Wt(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 j=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",k=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))k.includes(Q)||k.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 ae=re[1],Y=(re[2]??"").trim(),se=(re[3]??"").trim();if(!(ae==="self"||ae==="cls"||se.includes("Depends("))&&!/^(?:Request|Response|BackgroundTasks|WebSocket|Session|AsyncSession)$/.test(Y))if(se.includes("Body("))Z.push(ae);else if(f.has(Y))for(const ee of f.get(Y))Z.includes(ee)||Z.push(ee);else!K.has(ae)&&(se.includes("Query(")||/^(?:str|int|float|bool|Optional\[)/.test(Y))&&F.push(ae)}}g.push({targetVar:j,methods:H,path:W,handlerName:R,line:Wt(m,v.index),middlewares:k,queryParams:F,bodyFields:Z})}for(const j of g)c.has(j.targetVar)||c.set(j.targetVar,{varName:j.targetVar,prefix:"",dependencies:[],isApp:!1});x.set(T.path,{path:T.path,imports:E,routers:c,includes:a,routes:g})}const b=new Map,S=new Map,P=[],A=T=>{b.has(T.id)||b.set(T.id,T)},w=T=>{S.has(T.id)||S.set(T.id,T)},M=(T,E)=>{if(T.routers.has(E))return{file:T,varName:E};const c=E.split("."),a=T.imports.get(c[0]);if(a){let g=null;if(c.length>1&&a.importedName!=="*"){const e=a.modulePath?`${a.modulePath}.${a.importedName}`:a.importedName;g=bt(T.path,{modulePath:e},p)}if(g||(g=bt(T.path,a,p)),!g&&a.importedName!=="*"){const e=a.modulePath?`${a.modulePath}.${a.importedName}`:a.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]:a.importedName;if(m.routers.has(e))return{file:m,varName:e};if(m.routers.size===1){const i=Array.from(m.routers.keys())[0];return{file:m,varName:i}}}}return null},D=new Set,_=new Set,q=(T,E,c,a,g,m=!1)=>{const e=`${T.path}:${E}:${a}`;if(D.has(e))return;D.add(e),_.add(`${T.path}:${E}`);const i=T.routers.get(E),u=i!=null&&i.prefix?ne(a,i.prefix):a,o=Array.from(new Set([...g,...(i==null?void 0:i.dependencies)??[]]));for(const l of T.routes){if(l.targetVar!==E)continue;const h=ne(u,l.path),y=fe(h),d=Array.from(new Set([...o,...l.middlewares])),v=me(h);for(const j of l.methods){const I=`route:${j}:${h}`;A({id:I,type:"route",label:`${j} ${h}`,file:T.path,line:l.line,method:j,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!==E)continue;const h=M(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 E of T.routers.values())E.isApp&&B.push({pf:T,varName:E.varName});if(B.length>0)for(const{pf:T,varName:E}of B){const c=`entry:${T.path}`;A({id:c,type:"entry",label:T.path,file:T.path,line:1}),q(T,E,c,"",[])}for(const T of x.values())for(const E of T.routers.values())if(!E.isApp&&!_.has(`${T.path}:${E.varName}`)){const c=`router:${T.path}:${E.prefix||"/"}`;A({id:c,type:"router",label:E.prefix||T.path,file:T.path,line:1}),q(T,E.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(S.values())}}},Ht=/(?:^|\/)(?:tests?|__tests__)\/|test_[^/]+\.py$|_test\.py$/i,$s=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,"/"):"",$=[];if(s&&f)$.push(le(s,`${f}.py`),le(s,`${f}/__init__.py`));else if(f){$.push(`${f}.py`,`${f}/__init__.py`);for(const x of r)(x.endsWith(`/${f}.py`)||x.endsWith(`/${f}/__init__.py`))&&$.push(x)}else s&&$.push(le(s,"__init__.py"));for(const x of $){const b=oe(x);if(r.has(b))return b}return null}function Ut(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")&&!Ht.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")&&!Ht.test(_.path)),p=new Set(s.map(_=>_.path)),f=new Map;for(const _ of s){const q=new Map,B=new Map,V=[],T=[],E=_.content,c=/^\s*from\s+(\.{0,3}[A-Za-z0-9_.]*)\s+import\s+([^\n#]+)/gm;let a;for(;(a=c.exec(E))!==null;){const l=a[1];for(const h of a[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(E))!==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 i;for(;(i=e.exec(E))!==null;){const l=((D=i[2].split(",")[0])==null?void 0:D.trim())??"",h=i[2].match(/url_prefix\s*=\s*['"]([^'"]*)['"]/);l&&V.push({parentVar:i[1],bpExpr:l,urlPrefix:h?h[1]:"",line:Ut(E,i.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(E))!==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"),j=[];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&&j.push(W)}j.length===0&&j.push("GET")}else $s.has(h)&&j.push(h.toUpperCase());const O=E.slice(o.index+o[0].length).match(/(?:async\s+)?def\s+([A-Za-z_][A-Za-z0-9_]*)\s*\(/);T.push({targetVar:l,methods:j,path:v,handlerName:O?O[1]:"handler",line:Ut(E,o.index)})}f.set(_.path,{path:_.path,imports:q,routers:B,registers:V,routes:T})}const $=new Map,x=new Map,b=_=>{$.has(_.id)||$.set(_.id,_)},S=_=>{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 E=_.routers.get(q),c=E!=null&&E.urlPrefix?ne(V,E.urlPrefix):V;for(const a of _.routes){if(a.targetVar!==q)continue;const g=ne(c,a.path),m=fe(g),e=me(g);for(const i of a.methods){const u=`route:${i}:${g}`;b({id:u,type:"route",label:`${i} ${g}`,file:_.path,line:a.line,method:i,fullPath:g,pathParams:m,queryParams:[],bodyFields:[],group:e,middlewares:[],controller:a.handlerName,controllerFile:_.path,controllerLine:a.line}),S({id:`edge:${B}->${u}`,source:B,target:u,type:"handles"});const o=`ctrl:${_.path}:${a.handlerName}:${a.line}`;b({id:o,type:"controller",label:a.handlerName,file:_.path,line:a.line}),S({id:`edge:${u}->${o}`,source:u,target:o,type:"calls"})}}for(const a of _.registers){if(a.parentVar!==q)continue;let g,m=a.bpExpr;if(_.routers.has(a.bpExpr))g=_;else{const u=_.imports.get(a.bpExpr);if(u){let o=Bt(_.path,u,p);if(!o&&u.importedName!=="*"){const l=u.modulePath?`${u.modulePath}.${u.importedName}`:u.importedName;o=Bt(_.path,{modulePath:l},p)}o&&(g=f.get(o),m=u.importedName)}}if(!g||!g.routers.has(m))continue;const e=a.urlPrefix?ne(c,a.urlPrefix):c,i=`router:${g.path}:${e||"/"}`;b({id:i,type:"router",label:e||m,file:g.path,line:1}),S({id:`edge:${B}->${i}`,source:B,target:i,type:"mounts"}),w(g,m,i,e)}},M=[];for(const _ of f.values())for(const q of _.routers.values())q.isApp&&M.push({pf:_,varName:q.varName});if(M.length>0)for(const{pf:_,varName:q}of M){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($.values()),edges:Array.from(x.values())}}},Vt=/(?:^|\/)(?:tests?|__tests__)\/|test_[^/]+\.py$|_test\.py$/i,pn=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 $=t;$<n.length;$++){const x=n[$];if(f){if(x==="\\"){$++;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,$),endIdx:$}}return null}function Qe(n){const t=[];let r=0,s=0,p=0,f=null,$=0;for(let b=0;b<n.length;b++){const S=n[b];if(f){if(S==="\\"){b++;continue}S===f&&(f=null);continue}if(S==='"'||S==="'"){f=S;continue}if(S==="(")r++;else if(S===")")r--;else if(S==="[")s++;else if(S==="]")s--;else if(S==="{")p++;else if(S==="}")p--;else if(S===","&&r===0&&s===0&&p===0){const P=n.slice($,b).trim();P&&t.push(P),$=b+1}}const x=n.slice($).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 S=1;S<b;S++)s=s.includes("/")?s.slice(0,s.lastIndexOf("/")):"";p=p.slice(b)}else s="";const f=p?p.replace(/\./g,"/"):"",$=t.importedName&&t.importedName!=="*"?t.importedName:"",x=[];if(s&&f)$&&x.push(le(s,`${f}/${$}.py`),le(s,`${f}/${$}/__init__.py`)),x.push(le(s,`${f}.py`),le(s,`${f}/__init__.py`));else if(f){if($){x.push(`${f}/${$}.py`,`${f}/${$}/__init__.py`);for(const b of r)(b.endsWith(`/${f}/${$}.py`)||b.endsWith(`/${f}/${$}/__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&&($&&x.push(le(s,`${$}.py`),le(s,`${$}/__init__.py`)),x.push(le(s,"__init__.py")));for(const b of x){const S=oe(b);if(r.has(S))return S}return null}function it(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],$=(s[2]||s[4]||"").split(",");for(const x of $){const b=x.trim();if(!b||b==="*")continue;const S=b.match(/^([A-Za-z_][A-Za-z0-9_]*)\s+as\s+([A-Za-z_][A-Za-z0-9_]*)$/);if(S)t.set(S[2],{modulePath:f,importedName:S[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 $=f.trim(),x=$.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($)){const b=$.split(".")[0];t.set(b,{modulePath:$,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],S=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 M=$e(w[0]);if(M===null&&w[0].includes("route=")){const T=w[0].match(/route\s*=\s*([rfbuRFBU]{0,2}['"][^'"]*['"])/);T&&(M=$e(T[1]))}if(M===null){p.lastIndex=A.endIdx+1;continue}const D=As(M,S);let _=w[1].replace(/^view\s*=\s*/,"").trim(),q;for(const T of w.slice(2)){const E=T.match(/^name\s*=\s*(['"])([^'"]+)\1$/);E&&(q=E[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 a=c.slice(1,-1);s.push({kind:"inline",pattern:D,targetExpr:_,name:q,line:B,inlineEntries:St(a,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 a=c.match(/^\(\s*([^,]+)\s*,/),g=a?a[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 $=/([A-Za-z_][A-Za-z0-9_]*)\.urls\b/g;let x;for(;(x=$.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 at(n){const t=[],r=/['"]([A-Za-z]+)['"]/g;let s;for(;(s=r.exec(n))!==null;){const p=s[1].toLowerCase();pn.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 i=f.index+f[0].length;if(t[i]==="["){const u=jt(t,i,"[","]");u&&s.push(...St(u.text,i+1,t))}else{const u=t.indexOf(`
12
+ `,i),l=t.slice(i,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 $=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;)$.add(b[1]);const S=[],P=/\b([A-Za-z_][A-Za-z0-9_]*)\.register\s*\(/g;let A;for(;(A=P.exec(t))!==null;){const i=A.index+A[0].length-1,u=jt(t,i,"(",")");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])}S.push({routerVar:A[1],prefix:l.startsWith("/")?l:`/${l}`,viewSetExpr:h,basename:y,line:qe(t,A.index)})}const w=new Map,M=t.split(`
13
+ `),D=/^class\s+([A-Za-z_][A-Za-z0-9_]*)\s*(?:\(([^)]*)\))?\s*:/;let _=null,q=[];for(let i=0;i<M.length;i++){const u=M[i],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:i+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 j=at(v);y.push(...j.length>0?j:["GET"])}if(y.length===0){let v=i+1;for(;v<M.length;){const G=M[v];if(G.trim()&&G.length-G.trimStart().length===0)break;v++}const j=M.slice(i+1,v).join(`
14
+ `),I=new Set,O=/request\.method\s*(?:==|in)\s*(?:\[([^\]]+)\]|['"]([A-Za-z]+)['"])/g;let z;for(;(z=O.exec(j))!==null;){const G=at(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:i+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=[],pn.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 j=v.match(/detail\s*=\s*(True|False)/),I=j?j[1]==="True":!1,O=v.match(/methods\s*=\s*\[([^\]]+)\]/),z=O?at(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:i+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 E;for(;(E=T.exec(t))!==null;)B.add(E[1]);const c=/^([A-Za-z_][A-Za-z0-9_]*)\s*=\s*Router\s*\(/gm;for(;(E=c.exec(t))!==null;)V.add(E[1]);const a=[],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(;(E=g.exec(t))!==null;){const i=E[1];if(!B.has(i)&&!V.has(i))continue;const u=Qe(E[3]),o=u[0]?$e(u[0])??"/":"/",l=E[2]==="api_operation"?at(u[0]||""):[E[2].toUpperCase()];a.push({targetVar:i,methods:l.length>0?l:["GET"],path:o.startsWith("/")?o:`/${o}`,handlerName:E[4],line:qe(t,E.index)})}const m=[],e=/\b([A-Za-z_][A-Za-z0-9_]*)\.add_router\s*\(([^)]+)\)/g;for(;(E=e.exec(t))!==null;){const i=Qe(E[2]);if(i.length<2)continue;const u=$e(i[0])??"/";m.push({parentVar:E[1],prefix:u.startsWith("/")?u:`/${u}`,childExpr:i[1].trim(),line:qe(t,E.index)})}return{path:n.path,imports:r,urlEntries:s,routerVars:$,routerRegs:S,classes:w,funcs:At,ninjaApis:B,ninjaRouters:V,ninjaRoutes:a,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")&&!Vt.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")&&!Vt.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 $=[],x=[],b=new Set,S=new Set,P=[],A=e=>{b.has(e.id)||(b.add(e.id),$.push(e))},w=e=>{S.has(e.id)||(S.add(e.id),x.push(e))};let M=null;for(const e of s){const i=e.content.match(/ROOT_URLCONF\s*=\s*['"]([.\w]+)['"]/);if(i&&(M=it(i[1],p),M))break}const D=new Set;for(const e of f.values())for(const i of e.urlEntries)if(i.kind==="include"){const u=$e(i.targetExpr),o=u?it(u,p):(()=>{const l=e.imports.get(i.targetExpr.split(".")[0]);return l?Be(e.path,l,p):null})();o&&D.add(o)}const _=[];if(M)_.push(M);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(i=>/(?:^|\/)urls\.py$/.test(i.path));e&&_.push(e.path)}}const q=new Set,B=new Set,V=(e,i)=>{let u=i.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 j=Be(e,v,p);if(j)return{file:j,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 j=`${d.modulePath}.${h.slice(1,-1).join(".")}`.replace(/\.$/,""),I=it(j,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,i,u,o,l,h,y)=>{var j,I;const d=u||"/",v=`route:${i}:${d}`;A({id:v,type:"route",label:`${i} ${d}`,file:o,line:l,method:i,fullPath:d,pathParams:fe(d),group:me(d),middlewares:(j=y==null?void 0:y.middlewares)!=null&&j.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=(e,i,u,o)=>{var N;const l=C=>C.endsWith("/")?C:`${C}/`,h=l(ne(i,u.prefix)),y=l(ne(h,":id")),d=V(o,u.viewSetExpr),v=f.get(d.file),j=v==null?void 0:v.classes.get(d.symbol),I=(N=j==null?void 0:j.permissionClasses)!=null&&N.length?j.permissionClasses:void 0,O=j!=null&&j.serializerClass?[j.serializerClass]:void 0,z=j?d.file:o,G=j?j.line:u.line,W=(j==null?void 0:j.bases.some(C=>/ReadOnlyModelViewSet/.test(C)))??!1,H=(j==null?void 0:j.bases.some(C=>/ModelViewSet/.test(C)))??!1;if(j&&j.viewSetActions.size>0&&!H?(j.viewSetActions.has("list")&&T(e,"GET",h,z,G,`${d.symbol}.list`,{middlewares:I,bodyFields:O}),j.viewSetActions.has("create")&&T(e,"POST",h,z,G,`${d.symbol}.create`,{middlewares:I,bodyFields:O}),j.viewSetActions.has("retrieve")&&T(e,"GET",y,z,G,`${d.symbol}.retrieve`,{middlewares:I,bodyFields:O}),j.viewSetActions.has("update")&&T(e,"PUT",y,z,G,`${d.symbol}.update`,{middlewares:I,bodyFields:O}),j.viewSetActions.has("partial_update")&&T(e,"PATCH",y,z,G,`${d.symbol}.partial_update`,{middlewares:I,bodyFields:O}),j.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})),j)for(const C of j.actions){const R=C.detail?y:h,k=l(ne(R,C.urlPath));for(const F of C.methods)T(e,F,k,z,C.line,`${d.symbol}.${C.name}`,{middlewares:I,bodyFields:O})}},c=(e,i,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("."),j=h.imports.get(v[0]);if(j){const I=Be(u,j,p);if(I&&f.has(I)){y=I;const O=f.get(I),z=j.importedName==="*"?v[v.length-1]:j.importedName;d=O.routerRegs.filter(G=>G.routerVar===z)}}}B.add(`${y}:${l}`);for(const v of d)E(e,i,v,y)},a=(e,i,u,o)=>{for(const l of o){const h=ne(i,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}),a(y,h,u,l.inlineEntries)}else if(l.kind==="include"){const y=$e(l.targetExpr);let d=null;if(y)d=it(y,p);else{const v=f.get(u),j=v==null?void 0:v.imports.get(l.targetExpr.split(".")[0]);j&&(d=Be(u,j,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 j=f.get(d);a(v,h,d,j.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),j=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(j){const I=j.decorators.filter(O=>O!=="api_view");for(const O of j.methods)T(e,O,h,y.file,j.line,y.symbol,{middlewares:I})}else T(e,"GET",h,u,l.line,l.targetExpr)}}},g=(e,i,u,o)=>{const l=f.get(u);if(l){for(const h of l.ninjaRoutes){if(h.targetVar!==o)continue;const y=ne(i,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(i,h.prefix),d=V(u,h.childExpr);g(e,y,d.file,d.symbol)}}};for(const e of _){const i=`entry:${e}`;A({id:i,type:"entry",label:e,file:e,line:1}),q.add(`${e}@/`);const u=f.get(e);a(i,"/",e,u.urlEntries);for(const o of u.ninjaApis)g(i,"/",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}@/`),a(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}),E(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:$,edges:x}}},Kt=/(?:^|\/)(?: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 $=t;$<n.length;$++){const x=n[$];if(f){if(f!=="`"&&x==="\\"){$++;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,$),endIdx:$}}return null}function ke(n){const t=[];let r=0,s=0,p=0,f=null,$=0;for(let b=0;b<n.length;b++){const S=n[b];if(f){if(f!=="`"&&S==="\\"){b++;continue}S===f&&(f=null);continue}if(S==='"'||S==="'"||S==="`"){f=S;continue}if(S==="(")r++;else if(S===")")r--;else if(S==="[")s++;else if(S==="]")s--;else if(S==="{")p++;else if(S==="}")p--;else if(S===","&&r===0&&s===0&&p===0){const P=n.slice($,b).trim();P&&t.push(P),$=b+1}}const x=n.slice($).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")&&!Kt.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(a=>({path:oe(a.path),content:a.content})).filter(a=>a.path.endsWith(".go")&&!Kt.test(a.path)),p=Fs(n),f=[],$=[],x=new Set,b=new Set,S=a=>{x.has(a.id)||(x.add(a.id),f.push(a))},P=a=>{b.has(a.id)||(b.add(a.id),$.push(a))},A=new Map,w=/(?:\*?gin\.(?:Engine|RouterGroup|IRouter|IRoutes)|\*?echo\.(?:Echo|Group)|fiber\.Router|\*?fiber\.App|chi\.Router|\*?mux\.Router|\*?http\.ServeMux)/,M=new Map,D=new Map;for(const a of s){const g=Cs(a.content);M.set(a.path,g);const m=g.match(/^\s*package\s+([A-Za-z_][A-Za-z0-9_]*)/m),e=m?m[1]:"main";D.set(a.path,e);const i=/\bfunc\s*(?:\([^)]+\)\s*)?([A-Za-z_][A-Za-z0-9_]*)\s*\(([^)]*)\)/g;let u;for(;(u=i.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 j={name:o,pkg:e,file:a.path,line:Oe(g,u.index),routerParams:v,body:d.text,bodyStartIdx:y+1},I=A.get(o)??[];I.push(j),A.set(o,I),i.lastIndex=d.endIdx+1}}const _=(a,g,m,e,i,u,o)=>{const l=m||"/",h=`route:${g}:${l}`;S({id:h,type:"route",label:`${g} ${l}`,file:e,line:i,method:g,fullPath:l,pathParams:fe(l),group:me(l),middlewares:o!=null&&o.length?o:void 0,controller:u,controllerFile:e,controllerLine:i}),P({id:`edge:${a}->${h}`,source:a,target:h,type:"handles"})},q=new Set,B=(a,g,m,e,i,u)=>{const o=new Map(i),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(a))!==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(a))!==null;){const R=d[1],k=d[2],F=d.index+d[0].length-1,Z=Ne(a,F,"(",")");if(!Z)continue;const U=ke(Z.text),J=U[0]?je(U[0]):null;if(J===null)continue;const K=o.get(k)??{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)}`;S({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 j;for(;(j=v.exec(a))!==null;){const R=o.get(j[1]);if(!R)continue;const k=j.index+j[0].length-1,F=Ne(a,k,"(",")");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(a))!==null;){const R=z[1],k=z[2],F=z.index+z[0].length-1,Z=Ne(a,F,"(",")");if(!Z)continue;const U=ke(Z.text),J=k==="Route"?U[1]:U[0];if(!J||!/^func\s*\(/.test(J.trim()))continue;const K=o.get(R)??{prefix:"/",middlewares:[],nodeId:u},Q=k==="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_]*)/),ae=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)}`;S({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(ae,{varName:ae,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(([k,F])=>R>=k&&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(a))!==null;){if(G(H.index))continue;const R=H[1],k=H[2],F=H.index+H[0].length-1,Z=Ne(a,F,"(",")");if(!Z)continue;const U=ke(Z.text),J=Oe(m,g+H.index),K=o.get(R)??{prefix:"/",middlewares:[],nodeId:u};if(k==="Add"||k==="Method"||k==="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",ae=ne(K.prefix,Ae(te)),Y=U[2]?ve(U[2]):"handler",se=[...K.middlewares,...U.slice(3).map(ve)];_(K.nodeId,re,ae,e,J,Y,se)}}else if(k==="HandleFunc"||k==="Handle"){const Q=U[0]?je(U[0]):null;if(Q!==null){const re=a.slice(Z.endIdx+1,Z.endIdx+80).match(/^\s*\.Methods\s*\(([^)]+)\)/);if(re){const ae=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,ae,e,J,Y,K.middlewares)}}else{const ae=Is(Q),Y=ne(K.prefix,ae.path),se=U[1]?ve(U[1]):"handler";_(K.nodeId,ae.method,Y,e,J,se,K.middlewares)}}}else{const Q=Ts[k]??"GET",te=U[0]?je(U[0]):null;if(te!==null){const re=ne(K.prefix,Ae(te)),ae=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,ae,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(a))!==null;){if(G(C.index))continue;const R=C[2],k=A.get(R);if(!k||k.length===0)continue;const F=C.index+C[0].length-1,Z=Ne(a,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]),ae=ke(te[2]),Y=ae[0]?je(ae[0]):null;re&&Y!==null&&(Q={varName:K,prefix:ne(re.prefix,Ae(Y)),middlewares:[...re.middlewares,...ae.slice(1).map(ve)],nodeId:re.nodeId})}}if(Q)for(const te of k){if(te.routerParams.length===0)continue;const re=te.routerParams[0],ae=`${te.file}:${te.name}@${Q.prefix}`;if(q.has(ae))continue;q.add(ae);const Y=M.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(a=>/\bfunc\s+main\s*\(/.test(M.get(a.path)??"")),T=[...V,...s.filter(a=>!V.includes(a))];for(const a of T){const g=M.get(a.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:${a.path}`;S({id:e,type:"entry",label:a.path,file:a.path,line:1});const i=new Map;i.set("http",{varName:"http",prefix:"/",middlewares:[],nodeId:e}),B(g,0,g,a.path,i,e)}}for(const a of A.values())for(const g of a){if(g.routerParams.length===0||Array.from(q).some(o=>o.startsWith(`${g.file}:${g.name}@`)))continue;const e=`entry:${g.file}`;S({id:e,type:"entry",label:g.file,file:g.file,line:1});const i=M.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,i,g.file,u,e)}const E=new Set(f.filter(a=>a.type==="entry").map(a=>a.file));for(const a of s){if(E.has(a.path)||Array.from(q).some(e=>e.startsWith(`${a.path}:`)))continue;const m=M.get(a.path);if(/\.(?:GET|Get|POST|Post|PUT|Put|PATCH|Patch|DELETE|Delete|Any|All|HandleFunc)\s*\(\s*["`][^"`]*\//.test(m)){const e=`entry:${a.path}`;S({id:e,type:"entry",label:a.path,file:a.path,line:1}),B(m,0,m,a.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:$}}},Jt=/(?:^|\/)(?:tests?|benches|examples|target)\/|_test\.rs$/i,Yt=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 $=t;$<n.length;$++){const x=n[$];if(f){if(x==="\\"){$++;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,$),endIdx:$}}return null}function Ue(n){const t=[];let r=0,s=0,p=0,f=!1,$=0;for(let b=0;b<n.length;b++){const S=n[b];if(f){if(S==="\\"){b++;continue}S==='"'&&(f=!1);continue}if(S==='"'){f=!0;continue}if(S==="(")r++;else if(S===")")r--;else if(S==="[")s++;else if(S==="]")s--;else if(S==="{")p++;else if(S==="}")p--;else if(S===","&&r===0&&s===0&&p===0){const P=n.slice($,b).trim();P&&t.push(P),$=b+1}}const x=n.slice($).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")&&!Jt.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")&&!Jt.test(c.path)),p=Os(n),f=[],$=[],x=new Set,b=new Set,S=c=>{x.has(c.id)||(x.add(c.id),f.push(c))},P=c=>{b.has(c.id)||(b.add(c.id),$.push(c))},A=(c,a,g,m,e,i,u)=>{const o=g||"/",l=`route:${a}:${o}`;S({id:l,type:"route",label:`${a} ${o}`,file:m,line:e,method:a,fullPath:o,pathParams:fe(o),group:me(o),middlewares:void 0,controller:i,controllerFile:m,controllerLine:e}),P({id:`edge:${c}->${l}`,source:c,target:l,type:"handles"})},w=new Map,M=new Map,D=new Map;for(const c of s){const a=zs(c.content);w.set(c.path,a);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(a))!==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]),j=v[0]?Ve(v[0]):null;if(j===null)continue;const I=Ke(j),O=Se(a,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 Yt.has(d)&&l.push({method:d.toUpperCase(),path:I,handler:o,line:O})}if(l.length>0){const d=M.get(o)??[];d.push({name:o,file:c.path,line:Se(a,m.index),routes:l}),M.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 i;for(;(i=e.exec(a))!==null;){const u=i[1],o=i[2],l=i[3]??"",h=i.index+i[0].length-1,y=Ee(a,h,"{","}");if(!y)continue;const d={name:u,file:c.path,line:Se(a,i.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 a=[],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,i=Ee(c,e,"(",")");if(!i)continue;const u=m[1].toLowerCase(),o=u==="any"?"ALL":u.toUpperCase(),l=i.text.trim().replace(/\s+/g," ");a.push({method:o,handler:l||"handler"}),g.lastIndex=i.endIdx+1}return a},V=c=>{const a=[],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(Yt.has(e))a.push({method:e.toUpperCase(),handler:o});else if(e==="to"){const l=m.index+m[0].length-1,h=Ee(c,l,"(",")");a.push({method:"GET",handler:h?h.text.trim():"handler"})}}return a},T=(c,a,g,m,e,i)=>{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)),k=Se(g,a+o.index),F=B(N[1]);if(F.length>0)for(const Z of F)A(i,Z.method,R,m,k,Z.handler);else{const Z=V(N[1]);for(const U of Z)A(i,U.method,R,m,k,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)),k=N[1].trim(),F=k.match(/([A-Za-z_][A-Za-z0-9_]*)\s*\(/),Z=F?F[1]:k,U=D.get(Z);if(U&&U.length>0){const J=`router:${m}:${R}:${Se(g,a+h.index)}`;S({id:J,type:"router",label:C,file:m,line:Se(g,a+h.index)}),P({id:`edge:${i}->${J}`,source:i,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)),k=`router:${m}:${R}:${Se(g,a+d.index)}`;S({id:k,type:"router",label:C,file:m,line:Se(g,a+d.index)}),P({id:`edge:${i}->${k}`,source:i,target:k,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,a+H.endIdx+1,g,m,R,k)}}const v=/\.service\s*\(/g;let j;for(;(j=v.exec(c))!==null;){const W=j.index+j[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=M.get(C);if(R)for(const k of R){_.add(`${k.file}:${k.name}`);for(const F of k.routes)A(i,F.method,ne(e,F.path),k.file,F.line,k.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 k=`${R.file}:${R.name}@${e}`;if(q.has(k))continue;q.add(k);const F=w.get(R.file)??R.body;T(R.body,R.bodyOffset,F,R.file,e,i)}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)),k=N[1].match(/routes!\s*\[([\s\S]*?)\]/);if(k){const F=k[1].split(",").map(Z=>Z.trim().split("::").pop()).filter(Boolean);for(const Z of F){const U=M.get(Z);if(U)for(const J of U){_.add(`${J.file}:${J.name}`);for(const K of J.routes)A(i,K.method,ne(R,K.path),J.file,K.line,J.name)}}}}z.lastIndex=H.endIdx+1}};for(const c of s){const a=w.get(c.path);if(/\b(?:Router::new|App::new|rocket::build)\s*\(/.test(a)||/\bfn\s+main\s*\(/.test(a)){const g=`entry:${c.path}`;S({id:g,type:"entry",label:c.path,file:c.path,line:1}),T(a,0,a,c.path,"/",g)}}for(const c of D.values())for(const a of c){if(!a.returnsRouter&&!a.isServiceConfig||Array.from(q).some(i=>i.startsWith(`${a.file}:${a.name}@`)))continue;const m=`entry:${a.file}`;S({id:m,type:"entry",label:a.file,file:a.file,line:1}),q.add(`${a.file}:${a.name}@/`);const e=w.get(a.file)??a.body;T(a.body,a.bodyOffset,e,a.file,"/",m)}for(const c of M.values())for(const a of c){if(_.has(`${a.file}:${a.name}`))continue;const g=`entry:${a.file}`;S({id:g,type:"entry",label:a.file,file:a.file,line:1});for(const m of a.routes)A(g,m.method,m.path,a.file,m.line,a.name)}const E=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:E,unresolvedMounts:[]},nodes:f,edges:$}}},Xt=/(?:^|\/)(?: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 Qt(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 $;for(;($=f.exec(p))!==null;)t.push($[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"))&&!Xt.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"))&&!Xt.test(A.path)),p=[],f=[],$=new Set,x=new Set,b=A=>{$.has(A.id)||($.add(A.id),p.push(A))},S=A=>{x.has(A.id)||(x.add(A.id),f.push(A))};for(const A of s){const w=qs(A.content);let M=A.path.split("/").pop().replace(/\.(?:java|kt)$/,""),D=["/"],_=[];const q=[],B=w.split(`
32
+ `);let V=[],T=!1;for(let a=0;a<B.length;a++){const g=B[a].trim();if(!g)continue;if(g.startsWith("@")){let e=g,i=(e.match(/\(/g)||[]).length,u=(e.match(/\)/g)||[]).length;for(;i>u&&a+1<B.length;){a++;const o=B[a].trim();e+=" "+o,i+=(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,M=m[1];const e=V.join(`
33
+ `);V=[];const i=e.match(/@RequestMapping\s*(?:\(([^)]*)\))?/);i&&i[1]&&(D=Qt(i[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 i=g,u=(i.match(/\(/g)||[]).length,o=(i.match(/\)/g)||[]).length;for(;u>o&&a+1<B.length;){a++;const h=B[a].trim();i+=" "+h,u+=(h.match(/\(/g)||[]).length,o+=(h.match(/\)/g)||[]).length}const l=i.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 j=[];for(;(v=d.exec(e))!==null;){const k=v[1],F=v[2]??"",Z=Qt(F);k==="RequestMapping"?j.push({methods:Gs(F),subPaths:Z}):j.push({methods:[Ls[k]],subPaths:Z})}const I=[..._],O=e.match(/@(?:PreAuthorize|Secured|RolesAllowed)\s*\([^)]*\)/g);if(O)for(const k of O)I.push(k.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=a+1;for(const k of j)for(const F of D)for(const Z of k.subPaths){const U=ne(F,wt(Z));for(const J of k.methods)q.push({method:J,fullPath:U,handler:`${M}.${h}`,line:R,middlewares:I.length?I:void 0,queryParams:z.length?z:void 0,bodyFields:H.length?H:void 0})}}}V=[]}}const E=/\b(GET|POST|PUT|PATCH|DELETE|OPTIONS|HEAD)\s*\(\s*"([^"]+)"/g;let c;for(;(c=E.exec(w))!==null;){const a=c[1],g=wt(c[2]);q.push({method:a,fullPath:g,handler:`${M}.router`,line:Zs(w,c.index)})}if(q.length>0){const a=`entry:${A.path}`;b({id:a,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}),S({id:`edge:${a}->${m}`,source:a,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}}},en=/(?:^|\/)(?: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 tn(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")&&!en.test(r.path)&&/Rails\.application\.routes\.draw/.test(r.content))}scan(n,t){const r=performance.now(),s=n.map(M=>({path:oe(M.path),content:M.content})).filter(M=>M.path.endsWith(".rb")&&!en.test(M.path)),p=[],f=[],$=new Set,x=new Set,b=M=>{$.has(M.id)||($.add(M.id),p.push(M))},S=M=>{x.has(M.id)||(x.add(M.id),f.push(M))},P=(M,D,_,q,B,V)=>{const T=_||"/",E=`route:${D}:${T}`;b({id:E,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}),S({id:`edge:${M}->${E}`,source:M,target:E,type:"handles"})},A=s.filter(M=>M.path.endsWith("routes.rb")||/Rails\.application\.routes\.draw/.test(M.content));for(const M of A){const D=`entry:${M.path}`;b({id:D,type:"entry",label:M.path,file:M.path,line:1});const _=[{prefix:"/",kind:"root"}],q=M.content.split(`
35
+ `);for(let B=0;B<q.length;B++){const V=B+1,T=Vs(q[B]).trim();if(!T)continue;const E=_[_.length-1],c=/\bdo(?:\s*\|[^|]*\|)?\s*$/.test(T);if(T==="end"){_.length>1&&_.pop();continue}const a=T.match(/^namespace\s+:([A-Za-z_][A-Za-z0-9_]*)/);if(a&&c){_.push({prefix:ne(E.prefix,`/${a[1]}`),kind:"namespace"});continue}const g=T.match(/^scope\s+(?:path:\s*)?['"]([^'"]+)['"]/);if(g&&c){_.push({prefix:ne(E.prefix,tn(g[1])),kind:"scope"});continue}if(/^scope\b/.test(T)&&c){_.push({prefix:E.prefix,kind:"scope"});continue}if(/^member\b/.test(T)&&c){_.push({prefix:ne(E.prefix,":id"),kind:"member"});continue}if(/^collection\b/.test(T)&&c){_.push({prefix:E.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,j=d?new Set(lt(d[1]||d[2])):null;let I=E.prefix;E.kind==="resources"&&E.paramName&&(I=ne(E.prefix,`:${E.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)||j&&j.has(W.action)||P(D,W.method,G,M.path,V,`${O}#${W.action}`);else for(const W of Hs){if(v&&!v.has(W.action)||j&&j.has(W.action))continue;const H=W.item?ne(G,":id"):G;P(D,W.method,H,M.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",E.prefix,M.path,V,e[1]);continue}const i=T.match(/^(get|post|put|patch|delete|options|head|match)\s+['":]([^'",\s]+)['"]?(.*)$/);if(i){const u=i[1].toLowerCase(),o=i[2],l=i[3]??"",h=l.match(/(?:to:|=>)\s*['"]([^'"]+)['"]/),y=h?h[1]:o;let d=E.prefix;E.kind==="resources"&&E.paramName&&!T.includes("on:")?d=ne(E.prefix,`:${E.paramName}`):E.kind==="resources"&&l.includes("on: :member")&&E.paramName&&(d=ne(E.prefix,":id"));const v=ne(d,tn(o));if(u==="match"){const j=l.match(/via:\s*(?:\[([^\]]+)\]|(:[A-Za-z_]+))/),I=j?lt(j[1]||j[2]):["get"];for(const O of I){const z=O==="all"?"ALL":O.toUpperCase();P(D,z,v,M.path,V,y)}}else P(D,u.toUpperCase(),v,M.path,V,y);continue}c&&_.push({prefix:E.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}}},un=/(?:^|\/)(?: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 dn(n,t){const r=new Set(t.nodes.map($=>$.id)),s=new Set(t.edges.map($=>$.id)),p=$=>{const x=`entry:${$}`;return r.has(x)||(r.add(x),t.nodes.push({id:x,type:"entry",label:$,file:$,line:1})),x},f=($,x,b,S,P,A)=>{const w=p($),M=`route:${b}:${S}`;r.has(M)||(r.add(M),t.nodes.push({id:M,type:"route",label:`${b} ${S}`,file:$,line:x,method:"ALL",fullPath:S,group:P,controller:A,controllerFile:$,controllerLine:x}));const D=`edge:${w}->${M}`;s.has(D)||(s.add(D),t.edges.push({id:D,source:w,target:M,type:"handles"}))};for(const $ of n){const x=oe($.path);if(un.test(x))continue;const b=$.content;if(x.endsWith(".proto")){const S=/\bservice\s+([A-Za-z_][A-Za-z0-9_]*)\s*\{([^}]*)\}/g;let P;for(;(P=S.exec(b))!==null;){const A=P[1],w=P[2],M=/\brpc\s+([A-Za-z_][A-Za-z0-9_]*)\s*\(/g;let D;for(;(D=M.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 S=/\btype\s+(Query|Mutation|Subscription)\s*\{([^}]*)\}/g;let P;for(;(P=S.exec(b))!==null;){const A=P[1].toUpperCase(),w=P[2],M=/^\s*([A-Za-z_][A-Za-z0-9_]*)\s*(?:\([^)]*\))?\s*:/gm;let D;for(;(D=M.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 S=/\b(?:io|socket|wss)\.(?:on|of)\s*\(\s*['"]([^'"]+)['"]/g;let P;for(;(P=S.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 S=/@[A-Za-z_][A-Za-z0-9_]*\.websocket\s*\(\s*['"]([^'"]+)['"]/g;let P;for(;(P=S.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 S=/@MessageMapping\s*\(\s*"([^"]+)"\s*\)/g;let P;for(;(P=S.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=>!un.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 dn(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.find(p=>p.detect(n))??vt[vt.length-1],s=r.scan(n,t);return r.name!=="protocols"&&dn(n,s),s.metadata.unresolved||(s.metadata.unresolved=s.metadata.unresolvedMounts.map(p=>{const f=p.match(/^([^:]+):(\d+)\s*->\s*(.+)$/);if(f)return{file:f[1],line:Number(f[2]),reason:`Unresolved mount: ${f[3]}`};const $=p.match(/^([^:]+):(\d+)\s*\(([^)]+)\)(.*)$/);if($)return{file:$[1],line:Number($[2]),reason:`${$[3]}${$[4]}`.trim()};const x=p.match(/^([^:]+):(\d+)\s*(.*)$/);return x?{file:x[1],line:Number(x[2]),reason:x[3]||"Unresolved route/mount"}:{file:"",line:1,reason:p}})),s}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 S=p.get(b.target);S||(S=[],p.set(b.target,S)),S.push(b);let P=f.get(b.source);P||(P=[],f.set(b.source,P)),P.push(b)}const $=[n];for(;$.length>0;){const b=$.pop();for(const S of p.get(b)??[])s.add(S.id),r.has(S.source)||(r.add(S.source),$.push(S.source))}const x=[n];for(;x.length>0;){const b=x.pop();for(const S of f.get(b)??[])s.add(S.id),r.has(S.target)||(r.add(S.target),x.push(S.target))}return{nodeIds:r,edgeIds:s}}const nn={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),$=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}),S=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])),i=new Map,u=new Map;for(const o of t){let l=i.get(o.target);l||(l=[],i.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:i,bySource:u}},[n,t]),M=X.useCallback(m=>{if(!m)return null;const e=new Set([m]),i=new Set,u=[m];for(;u.length>0;){const l=u.pop();for(const h of w.byTarget.get(l)??[])i.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)??[])i.add(h.id),e.has(h.target)||(e.add(h.target),o.push(h.target))}return{nodeIds:e,edgeIds:i}},[w]),D=X.useCallback(()=>{const m=f.current;if(!m)return;const e=m.getContext("2d");if(!e)return;const i=window.devicePixelRatio||1,u=m.clientWidth,o=m.clientHeight;(m.width!==Math.floor(u*i)||m.height!==Math.floor(o*i))&&(m.width=Math.floor(u*i),m.height=Math.floor(o*i));const{x:l,y:h,scale:y}=$.current;if(e.setTransform(i,0,0,i,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 k=C;k<u;k+=N)for(let F=R;F<o;F+=N)e.fillRect(k,F,1.3,1.3)}e.save(),e.translate(l,h),e.scale(y,y);const d=-l/y-100,v=-h/y-100,j=(u-l)/y+100,I=(o-h)/y+100,O=x.current??r,z=M(O),G=1/Math.max(y,.06),W=(N,C)=>{const R=w.boxById.get(N.source),k=w.boxById.get(N.target);if(!R||!k)return;const F=R.x+R.w/2,Z=R.y+R.h/2,U=k.x+k.w/2,J=k.y+k.h/2;if(!(Math.max(F,U)<d||Math.min(F,U)>j||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=k.x>=R.x+R.w-20,Q=K?R.x+R.w:F,te=K?k.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>j||N.y+N.h<v||N.y>I)continue;const C=z?z.nodeIds.has(N.node.id):!1,R=z?!C:!1,k=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=k?"#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||k?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,k?(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=nn[Z]??nn.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,M,w,r]),_=X.useCallback(()=>{S.current===null&&(S.current=requestAnimationFrame(()=>{S.current=null,D()}))},[D]),q=X.useCallback(()=>{const m=f.current;if(!m||w.boxes.length===0)return;let e=1/0,i=1/0,u=-1/0,o=-1/0;for(const j of w.boxes)j.x<e&&(e=j.x),j.y<i&&(i=j.y),j.x+j.w>u&&(u=j.x+j.w),j.y+j.h>o&&(o=j.y+j.h);const l=m.clientWidth||window.innerWidth,h=m.clientHeight||window.innerHeight,y=Math.max(1,u-e),d=Math.max(1,o-i),v=Math.max(.08,Math.min(1.1,Math.min(l*.8/y,h*.8/d)));$.current={scale:v,x:l/2-(e+u)/2*v,y:h/2-(i+o)/2*v},_()},[w.boxes,_]),B=X.useCallback((m,e,i=.95)=>{const u=f.current,o=(u==null?void 0:u.clientWidth)||window.innerWidth,l=(u==null?void 0:u.clientHeight)||window.innerHeight;$.current={scale:i,x:o/2-m*i,y:l/2-e*i},_()},[_]);X.useImperativeHandle(p,()=>({fitView:q,centerOn:B}),[q,B]),X.useEffect(()=>{if(w.boxes.some(i=>i.x<-100||i.y<-100)||w.boxes.length<=100){q();return}const e=w.boxes.find(i=>i.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 i=f.current;if(!i)return null;const u=i.getBoundingClientRect(),{x:o,y:l,scale:h}=$.current,y=(m-u.left-o)/h,d=(e-u.top-l)/h;for(let v=w.boxes.length-1;v>=0;v--){const j=w.boxes[v];if(y>=j.x&&y<=j.x+j.w&&d>=j.y&&d<=j.y+j.h)return j}return null},T=m=>{b.current={active:!0,moved:!1,startX:m.clientX,startY:m.clientY,origX:$.current.x,origY:$.current.y}},E=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),$.current.x=b.current.origX+u,$.current.y=b.current.origY+o,_();return}const e=V(m.clientX,m.clientY),i=e?e.node.id:null;A((e==null?void 0:e.data.type)==="route"),i!==x.current&&(x.current=i,_())},c=m=>{const e=b.current.moved;if(b.current.active=!1,!e){const i=V(m.clientX,m.clientY);(i==null?void 0:i.data.type)==="route"?s(i.data):s(null)}},a=m=>{m.preventDefault();const e=f.current;if(!e)return;const i=e.getBoundingClientRect(),u=m.clientX-i.left,o=m.clientY-i.top,l=$.current,h=m.deltaY<0?1.12:.89,y=Math.max(.05,Math.min(2.5,l.scale*h));$.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 i=e.clientWidth,u=e.clientHeight,o=$.current,l=Math.max(.05,Math.min(2.5,o.scale*m));$.current={scale:l,x:i/2-(i/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:E,onPointerUp:c,onPointerLeave:()=>{b.current.active=!1,x.current!==null&&(x.current=null,_())},onWheel:a,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"})})]})]})}),sn={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 sn[(n??"GET").toUpperCase()]??sn.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($=>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"}),$]},$)),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})]})]})}),ir=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]})]})]})}),ar={entry:nr,router:sr,route:rr,middleware:or,controller:ir,model:Rn};function lr({groups:n,hiddenGroups:t,onToggleGroup:r,onShowAll:s,onIsolateGroup:p,collapsed:f,onToggleCollapse:$}){return f?L.jsxs("button",{onClick:$,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:$,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 S=b.path.split("/").pop()??"";return cr.test(S)||pr.test(S)}).slice(0,120),f=[],$=15;for(let b=0;b<p.length;b+=$){const S=p.slice(b,b+$),P=await Promise.all(S.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,$]=X.useState(""),[x,b]=X.useState(null),S=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 M="local-project";for(const _ of Array.from(A)){const q=_.webkitRelativePath||_.name,B=q.split("/");if(B.length>1&&(M=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 E=await _.text();w.push({path:V,content:E})}const D=fn(w,{repoName:M});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(rn,{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=>$(A.target.value),onKeyDown:A=>A.key==="Enter"&&void S(),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 S(),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:$="ALL",onEntryFilterChange:x,targetBaseUrl:b,onTargetBaseUrlChange:S,globalAuth:P,onGlobalAuthChange:A,layoutMode:w,onLayoutModeChange:M,middlewareMode:D,onMiddlewareModeChange:_,onOpenSearch:q,onRescan:B,onCopyMarkdown:V,isStaticMode:T,securityOnly:E=!1,onSecurityOnlyChange:c}){const[a,g]=X.useState(!1),[m,e]=X.useState(!1),[i,u]=X.useState(!1),o=()=>{V(),e(!0),setTimeout(()=>e(!1),1600)},l=async()=>{if(!(!B||i)){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(rn,{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:$,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(!E),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 ${E?"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=>S(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"})]}),a&&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:()=>M("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:()=>M("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:i,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 ${i?"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(()=>on(()=>import("./SearchModal-ZELlGejR.js"),__vite__mapDeps([0,1,2,3])).then(n=>({default:n.SearchModal}))),vr=X.lazy(()=>on(()=>import("./TesterDrawer-CUl488Qp.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,$]=X.useState(null),[x,b]=X.useState(!1),[S,P]=X.useState(!1),[A,w]=X.useState("http://localhost:3000"),[M,D]=X.useState(""),[_,q]=X.useState("ALL"),[B,V]=X.useState(!1),[T,E]=X.useState("ALL"),[c,a]=X.useState(new Set),[g,m]=X.useState("flow"),[e,i]=X.useState("badges"),[u,o]=X.useState(!1),[l,h]=X.useState(!1),[y,d]=X.useState(null),[v,j]=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;$(pe),a(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){$(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]),[k,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=k.nodes.length>Er,U=v??(y==null?void 0:y.id)??null;X.useEffect(()=>{if(Z)return;if(k.nodes.length===0){O([]),W([]);return}if(!U){O(k.nodes.map(ee=>({...ee,data:{...ee.data,_dimmed:!1,_highlighted:!1,_selected:(y==null?void 0:y.id)===ee.id}}))),W(k.edges);return}const{nodeIds:Y,edgeIds:se}=Qs(U,k.edges);O(k.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(k.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,k,U,y,O,W]),X.useEffect(()=>{if(!Z&&k.nodes.length>0){const Y=setTimeout(()=>{n({padding:.16,duration:350})},50);return()=>clearTimeout(Y)}},[Z,f,g,e,n,k.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)&&a(pe=>{const Pe=new Set(pe);return Pe.delete(se),Pe}),d(Y);const ee=k.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}))},[k.nodes,c,t,Z]),Q=async()=>{const Y=await fetch("/api/rescan",{method:"POST"});if(Y.ok){const se=await Y.json();$(se)}},te=()=>{f&&navigator.clipboard.writeText(ns(f))},re=Y=>{a(se=>{const ee=new Set(se);return ee.has(Y)?ee.delete(Y):ee.add(Y),ee})},ae=Y=>{a(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:k.nodes,edges:k.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)=>j(se.id),onNodeMouseLeave:()=>j(null),onPaneClick:()=>d(null),nodeTypes:ar,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:E,targetBaseUrl:A,onTargetBaseUrlChange:w,globalAuth:M,onGlobalAuthChange:D,layoutMode:g,onLayoutModeChange:m,middlewareMode:e,onMiddlewareModeChange:i,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:()=>a(new Set),onIsolateGroup:ae,collapsed:u,onToggleCollapse:()=>o(Y=>!Y)})}),L.jsx(X.Suspense,{fallback:null,children:y&&L.jsx(vr,{route:y,targetBaseUrl:A,globalAuth:M,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})}),S&&L.jsx(yr,{onLoadDemo:()=>{$(br),w("http://localhost:3001"),P(!1)},onLoadScanned:Y=>{$(Y),a(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};
@@ -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-Co71Z6SJ.js"></script>
19
+ <script type="module" crossorigin src="/assets/index-CHRlXsqI.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">