@omfalos/mokosh 0.1.11 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,28 +1,28 @@
1
- var Tt=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});import Xr from"path";import{fileURLToPath as Yr}from"url";var Zr=()=>Yr(import.meta.url),qr=()=>Xr.dirname(Zr()),m=qr();import Rt from"fs";import ge from"path";var ts=[".config.","biome.json","tsconfig.json","package.json",".prettierrc",".eslintrc"],pe=[];function ct(e){pe.push(e)}function le(e){return[...ts,...pe].some(t=>typeof t=="string"?e.includes(t):t instanceof RegExp?t.test(e):t(e))}var es=[".test.",".spec.","-test.","-spec."],me=[];function pt(e){me.push(e)}function U(){return[...es,...me]}var rs=["jest","vitest","playwright","cypress","@testing-library/"],fe=[];function lt(e){fe.push(e)}function It(){return[...rs,...fe]}var ue=.8;function Mt(e){ue=e}function Nt(){return ue}var ss=["mokosh.config.js","mokosh.config.cjs","mokosh.config.json"];function At(e,{allowJs:t=!0,isExplicitPath:r=!1}={}){if(r){let s=ge.resolve(e);return Rt.existsSync(s)?s.endsWith(".json")?de(s):t?he(s):{}:{}}for(let s of ss){let n=ge.resolve(e,s);if(Rt.existsSync(n)){if(s.endsWith(".json"))return de(n);if(t)return he(n)}}return{}}function de(e){return JSON.parse(Rt.readFileSync(e,"utf-8"))}function he(e){let t=Tt(e);return t&&typeof t=="object"&&"default"in t&&(t=t.default),typeof t=="function"?t({}):t}function ns(e){for(let t of e.configMatchers??[])ct(t);for(let t of e.testPatterns??[])pt(t);for(let t of e.testLibraries??[])lt(t);e.barrelThreshold!==void 0&&Mt(e.barrelThreshold)}function is(e){return{gitStats:e?.gitStats??!1,parallelParsing:e?.parallelParsing,pathAliases:e?.pathAliases}}var Dt=["node_modules",".git","dist","build",".next",".cache","mokosh-cache","coverage"],Lt=[".ts",".tsx",".js",".jsx",".mjs",".cjs",".css",".scss",".sass",".less",".styl",".coffee",".ls",".lua",".py",".go",".feature",".md",".mdx"];import os from"fs";import ye from"path";function as(e,t){let r=ye.resolve(e,t);try{let s=os.readFileSync(r,"utf-8"),n=JSON.parse(s),i=new Map;for(let[o,a]of Object.entries(n)){if(o==="total")continue;let c=a?.lines?.pct;if(typeof c!="number")continue;let p=ye.relative(e,o);i.set(p,c)}return i}catch{return new Map}}var Gt={serialize(e){let t=["graph TD"],r=new Set;for(let s of e.nodes.values()){let n=`"${s.path}"`;for(let i of s.imports){if(!i.toPath)continue;let o=`"${i.toPath}"`,a=`${s.path} -> ${i.toPath}`;if(!r.has(a)){let c=i.isStyle?"-- styles -->":"-->";t.push(` ${n} ${c} ${o}`),r.add(a)}}}return t.join(`
2
- `)}};function xe(e){return Gt.serialize(e)}import Se from"fs";import cs from"path";function Ot(e,t){let r=e.replace(/^\.\//,"");if(t.nodes.has(r))return r;let s=r.replace(/^dist\//,"src/").replace(/\.(js|mjs|cjs)$/,".ts");return t.nodes.has(s)?s:null}function be(e,t){if(typeof e=="string")return Ot(e,t);if(e&&typeof e=="object"){let r=e;for(let s of["import","require","default"]){let n=be(r[s],t);if(n)return n}}return null}function ps(e){if(!e)return"unknown";let t=e.trimStart();return t.startsWith("interface ")?"interface":t.startsWith("class ")?"class":t.startsWith("enum ")?"enum":t.startsWith("type ")?"type":t.startsWith("namespace ")?"namespace":t.startsWith("const ")||t.startsWith("let ")||t.startsWith("var ")||t.startsWith("readonly ")?"const":t.startsWith("(")||t.startsWith("async ")||t.startsWith("function ")||t.includes("=>")?"function":"unknown"}function ls(e,t){let r=new Set,s=new Set,n=[...t];for(;n.length;){let i=n.shift();if(s.has(i))continue;s.add(i);let o=e.nodes.get(i);if(o){for(let a of o.exports)r.add(a.name);for(let a of o.imports){if(a.type!=="re-export"||a.isExternal||!a.toPath)continue;if(!a.symbols?.length||a.symbols.includes("*")){let p=e.nodes.get(a.toPath);if(p)for(let g of p.exports)r.add(g.name);n.push(a.toPath)}else for(let p of a.symbols)r.add(p)}}}return r}function ms(e,t){return ve(e,t)[0]??null}function ve(e,t){let r=[],s=cs.join(t,"package.json");if(Se.existsSync(s))try{let n=JSON.parse(Se.readFileSync(s,"utf8"));if(n.exports&&typeof n.exports=="object"&&!Array.isArray(n.exports))for(let i of Object.values(n.exports)){let o=be(i,e);o&&!r.includes(o)&&r.push(o)}else if(typeof n.exports=="string"){let i=Ot(n.exports,e);i&&r.push(i)}if(r.length===0)for(let i of[n.main,n.module].filter(Boolean)){let o=Ot(i,e);o&&!r.includes(o)&&r.push(o)}}catch{}if(r.length===0){for(let n of["src/index.ts","src/index.js","index.ts","index.js"])if(e.nodes.has(n)){r.push(n);break}}return r}function fs(e,t){let r=new Set(t);for(let s of t)e.traverse(s,n=>(r.add(n.path),!0),{direction:"outgoing"});return r}function us(e,t,r){let s=new Map;for(let n of t){if(r.includes(n))continue;let i=e.nodes.get(n);if(!i)continue;let o=i.category==="barrel";for(let a of i.exports){let c=s.get(a.name),p=!!(a.signature||a.doc);(!c||p&&!o)&&s.set(a.name,{file:n,symbol:a})}}return s}function gs(e,t,r,s){let n=[];for(let i of e){let o=t.get(i),a=s.flatMap(u=>r.nodes.get(u)?.exports??[]).find(u=>u.name===i),c=o?.symbol??a,p=o?.file??s.find(u=>r.nodes.get(u)?.exports.some(y=>y.name===i))??s[0],g={name:i,definedIn:p,kind:ps(c?.signature)};c?.doc&&(g.doc=c.doc),c?.signature&&(g.signature=c.signature),n.push(g)}return n.sort((i,o)=>i.name.localeCompare(o.name)),n}function ds(e,t,r){let s=c=>e.nodes.get(c)?.category==="test",n=[...t].filter(c=>!r.includes(c)&&!s(c)),i=[...e.nodes.keys()].filter(c=>!t.has(c)),o=i.filter(c=>!s(c)),a=i.filter(c=>s(c));return{internalFiles:n,unreachableFromEntry:o,testFiles:a}}function hs(e,t){if(t.length===0)throw new Error("buildApiSurface requires at least one entry point");for(let p of t)if(!e.nodes.has(p))throw new Error(`Entry point not found in graph: ${p}`);let r=fs(e,t),s=us(e,r,t),n=ls(e,t),i=gs(n,s,e,t),{internalFiles:o,unreachableFromEntry:a,testFiles:c}=ds(e,r,t);return{entryPoints:t,publicExports:i,internalFiles:o,unreachableFromEntry:a,testFiles:c}}function ys(e,t){let r=null,s=[];for(let i of e.nodes.values()){i.exports.some(o=>o.name===t)&&(r=i.path);for(let o of i.callEdges??[])o.to===t&&s.push({file:i.path,callerFunction:o.from})}let n=[];if(r){let i=e.nodes.get(r);for(let o of i?.callEdges??[])o.from===t&&n.push({file:o.toFile,calleeFunction:o.to})}return{functionName:t,definedIn:r,callers:s,callees:n}}import K from"fs";import xs from"path";function jt(e){let t=[...e.nodes.entries()].sort(([s],[n])=>s.localeCompare(n)).map(([s,n])=>`${s}:${n.mtime}:${n.size}`).join("|"),r=2166136261;for(let s=0;s<t.length;s++)r^=t.charCodeAt(s),r=Math.imul(r,16777619)>>>0;return r.toString(16).padStart(8,"0")}function Ss(e){let t=new Map;for(let r of e.nodes.keys()){let s=[];e.traverse(r,n=>(n.path!==r&&s.push(n.path),!0),{direction:"incoming"}),t.set(r,s)}return{impact:t,graphHash:jt(e)}}function bs(e,t){return e.impact.get(t)??[]}function vs(e,t){return e.graphHash===jt(t)}function ks(e,t){let r=xs.dirname(t);K.existsSync(r)||K.mkdirSync(r,{recursive:!0});let s={graphHash:e.graphHash,impact:[...e.impact.entries()]};K.writeFileSync(t,JSON.stringify(s))}function Cs(e){if(!K.existsSync(e))return null;try{let t=K.readFileSync(e,"utf-8"),r=JSON.parse(t);return{graphHash:r.graphHash,impact:new Map(r.impact)}}catch{return null}}import mt from"path";function Es(e){let t=new Map;for(let[r,s]of e){let n=s.imports.filter(i=>i.toPath&&!i.isExternal).length;n>0&&t.set(r,n)}return t}function Fs(e,t,r){let s=new Map;for(let[n,i]of t){if(i<r)continue;let o=e.get(n);if(!o||o.category==="test"||o.category==="barrel")continue;let a=mt.extname(n),c=mt.basename(n,a),p=c==="index"?mt.basename(mt.dirname(n)):c;s.set(n,{path:n,outDegree:i,tag:`feature:${p}`})}return s}function J(e,t){let r=t?.minOutDegree??5;return Fs(e,Es(e),r)}var ws=(e,t)=>e.outDegree-t.outDegree;function Ps(e,t){let r=new Map;for(let s of t.values()){let n=new Set;e.traverse(s.path,i=>(i.path!==s.path&&n.add(i.path),!0),{direction:"outgoing"}),r.set(s.path,n)}return r}function Ts(e,t,r,s){let n=new Map;for(let[i]of e){if(t.has(i))continue;let o=null;for(let a of t.values())r.get(a.path)?.has(i)&&(!o||s(a,o)<0)&&(o=a);o&&n.set(i,o.path)}return n}function Is(e,t){let r=new Map;for(let s of e.values()){let n=s.tag.replace("feature:",""),i=[];for(let[o,a]of t)a===s.path&&i.push(o);r.set(n,{hub:s.path,outDegree:s.outDegree,files:i})}return r}function Ms(e,t,r){let s=[];for(let n of e.keys())!t.has(n)&&!r.has(n)&&s.push(n);return s}function _t(e,t){let r=t?.detectFn??J,s=t?.hubComparator??ws,n=r(e.nodes,t),i=Ps(e,n),o=Ts(e.nodes,n,i,s);return{features:Is(n,o),unassigned:Ms(e.nodes,n,o)}}var ke=new Set(["typescript","javascript","python","go"]),ft=new Set(["typescript","javascript","python"]),ut=new Set(["typescript","javascript"]);function Ns(e){let t=new Map;for(let r of e.nodes.values())t.set(r.type,(t.get(r.type)??0)+1);return[...t.entries()].map(([r,s])=>({type:r,fileCount:s,exportsTracked:ke.has(r),importSymbolsTracked:ft.has(r),callEdgesTracked:ut.has(r)})).sort((r,s)=>s.fileCount-r.fileCount)}var H=class{constructor(t){this.nodes=t}nodes;findUnusedFiles(t){let r=new Set(this.nodes.keys());return t.filter(s=>!r.has(s))}findHighExportUsage(t){let r=[];for(let s of this.nodes.values()){if(s.maxExportUsage===void 0||s.maxExportUsage<t)continue;let n=s.imports.reduce((i,o)=>(o.exportUsageRatio??0)>(i?.exportUsageRatio??0)?o:i,null);r.push({path:s.path,maxExportUsage:s.maxExportUsage,tightestDep:n?.toPath??""})}return r.sort((s,n)=>n.maxExportUsage-s.maxExportUsage)}findCycles(){let t=[],r=new Set,s=new Set,n=[],i=o=>{r.add(o),s.add(o),n.push(o);let a=this.nodes.get(o);if(a){for(let c of a.imports)if(!(!c.toPath||c.isExternal))if(s.has(c.toPath)){let p=n.indexOf(c.toPath);t.push([...n.slice(p),c.toPath])}else r.has(c.toPath)||i(c.toPath)}s.delete(o),n.pop()};for(let o of this.nodes.keys())r.has(o)||i(o);return t}};var I=class e{constructor(t){this.nodes=t}nodes;_incomingEdgesCache=null;_callIncomingCache=null;serialize(){return{nodes:Array.from(this.nodes.values())}}static deserialize(t){let r=new Map;for(let s of t.nodes)r.set(s.path,s);return new e(r)}getIncomingEdgesMap(){if(this._incomingEdgesCache)return this._incomingEdgesCache;let t=new Map;for(let r of this.nodes.values())for(let s of r.imports)if(s.toPath){let n=t.get(s.toPath)||[];n.push(r.path),t.set(s.toPath,n)}return this._incomingEdgesCache=t,t}dfs(t,r,s,n){let i=new Set,o=s.maxDepth??1/0,a=(c,p,g)=>{if(p>o||i.has(c))return;let u=this.nodes.get(c);if(u&&(i.add(c),r(u,p,g)!==!1))for(let y of n(c))a(y,p+1,c)};a(t,0,null)}traverse(t,r,s={}){let n=s.direction??"outgoing",i=n==="incoming"?this.getIncomingEdgesMap():null;this.dfs(t,r,s,o=>n==="outgoing"?this.nodes.get(o)?.imports.map(a=>a.toPath).filter(Boolean)??[]:i?.get(o)??[])}getCallIncomingCache(){if(this._callIncomingCache)return this._callIncomingCache;let t=new Map;for(let r of this.nodes.values())for(let s of r.callEdges??[]){let n=t.get(s.toFile)??[];n.push(r.path),t.set(s.toFile,n)}return this._callIncomingCache=t,t}traverseCalls(t,r,s={}){let n=s.direction??"outgoing",i=n==="incoming"?this.getCallIncomingCache():null;this.dfs(t,r,s,o=>n==="outgoing"?this.nodes.get(o)?.callEdges?.map(a=>a.toFile)??[]:i?.get(o)??[])}getCallers(t){let r=[];return this.traverseCalls(t,s=>(s.path!==t&&r.push(s.path),!0),{direction:"incoming",maxDepth:1}),r}getCallEdgesFor(t){return this.nodes.get(t)?.callEdges??[]}getNeighbors(t){let r=this.nodes.get(t);return r?r.imports.map(s=>this.nodes.get(s.toPath)).filter(s=>s!==void 0):[]}findUnusedFiles(t){return new H(this.nodes).findUnusedFiles(t)}findCycles(){return new H(this.nodes).findCycles()}};var M=class{affectedSymbols=new Map;constructor(t,r){this.affectedSymbols.set(t,new Set(["default",...r]))}updateAffectedSymbols(t,r){let s=this.affectedSymbols.get(r)||new Set,n=t.imports.find(c=>c.toPath===r);if(!n)return!1;let i=n.symbols||["*"],o=new Set;for(let c of i)(c==="*"||s.has("*")||s.has(c))&&o.add("*");if(o.size===0)return!1;let a=this.affectedSymbols.get(t.path)||new Set;for(let c of o)a.add(c);return this.affectedSymbols.set(t.path,a),!0}};function Rs(e,t){let r=e.nodes.get(t);if(r)return{category:r.category,exports:r.exports.map(s=>s.name)}}function As(e,t,r=1){let s=[];return e.traverse(t,(n,i,o)=>{if(n.path===t)return!0;let a=o?e.nodes.get(o)?.imports.find(c=>c.toPath===n.path):void 0;return s.push({path:n.path,...a?.symbols?{symbols:a.symbols}:{}}),!0},{direction:"outgoing",maxDepth:r}),s}function Wt(e,t){let r=[];return e.traverse(t,s=>{if(s.path===t)return!0;let n=s.imports.find(i=>i.toPath===t);return r.push({path:s.path,...n?.symbols?{symbols:n.symbols}:{}}),!0},{direction:"incoming",maxDepth:1}),r}function Ds(e,t,r={}){let{testsOnly:s=!1,changedSymbols:n}=r,i=n?new M(t,n):null,o=[];return e.traverse(t,(a,c,p)=>{if(a.path===t)return!0;if(i&&p&&!i.updateAffectedSymbols(a,p))return!1;let g=a.category==="test"||a.tags.some(u=>u.name==="test");return(!s||g)&&o.push(a.path),!0},{direction:"incoming"}),o}function Ls(e,t,r={}){let{depth:s=1,withEdgeDetail:n=!1}=r,i=[];return e.traverseCalls(t,o=>{if(o.path===t)return!0;let a={file:o.path};return n&&(a.edges=(o.callEdges??[]).filter(c=>c.toFile===t).map(c=>({from:c.from,to:c.to}))),i.push(a),!0},{direction:"incoming",maxDepth:s}),i}function Gs(e,t={}){let{metric:r="cognitiveComplexity",threshold:s=10,limit:n=20}=t;return[...e.nodes.values()].flatMap(i=>(i.functions??[]).filter(o=>o[r]>=s).map(o=>({file:i.path,name:o.name,line:o.line,complexity:o.complexity,cognitiveComplexity:o.cognitiveComplexity}))).sort((i,o)=>o[r]-i[r]).slice(0,n)}function Os(e){return{nodes:e.nodes.map(r=>({path:r.path,type:r.type,category:r.category,exports:r.exports.map(s=>s.name),tags:r.tags.filter(s=>s.kind==="comment-marker"||s.kind==="import").map(s=>s.name),importsFiles:r.imports.filter(s=>!s.isExternal&&s.toPath).map(s=>s.toPath),...r.description!==void 0&&{description:r.description},...r.testedBy!==void 0&&{testedBy:r.testedBy},...r.coveragePct!==void 0&&{coveragePct:r.coveragePct},...r.avgExportUsage!==void 0&&{avgExportUsage:r.avgExportUsage},...r.maxExportUsage!==void 0&&{maxExportUsage:r.maxExportUsage}})),cycles:e.cycles}}function js(e){let t=e.getPackageDependencies(),r=Array.from(e.packages.values()).map(({graph:s,pkg:n})=>({name:n.name,relativeRoot:n.relativeRoot,nodeCount:s.nodes.size,dependsOn:t.get(n.name)??[]}));return{monorepoType:e.type,packageCount:r.length,packages:r}}function _s(e){return[...e.nodes.values()].some(t=>t.coveragePct!==void 0)}function Ce(e){if(e.category==="test")return"test";if(e.category==="config")return"config";if(e.category==="type-only")return"types";let t=e.path;return h(t,"component")||h(t,"components")?"component":h(t,"controller")||h(t,"controllers")?"controller":h(t,"middleware")?"middleware":h(t,"router")||h(t,"routes")||h(t,"route")?"router":h(t,"store")||h(t,"stores")?"store":h(t,"service")||h(t,"services")?"service":h(t,"handler")||h(t,"handlers")?"handler":h(t,"adapter")||h(t,"adapters")?"adapter":h(t,"plugin")||h(t,"plugins")?"plugin":h(t,"api")?"api":h(t,"cli")||h(t,"commands")||Q(t)==="cli"?"cli":h(t,"util")||h(t,"utils")||h(t,"helper")||h(t,"helpers")?"util":h(t,"model")||h(t,"models")||Q(t)==="model"?"model":h(t,"parser")||h(t,"parsers")||Q(t)==="parser"?"parser":Q(t)==="builder"?"builder":Q(t)==="resolver"?"resolver":"other"}function h(e,t){return e.includes(`/${t}/`)||e.includes(`/${t}.`)}function Q(e){let t=e.slice(e.lastIndexOf("/")+1);return t.slice(0,t.lastIndexOf("."))||t}function Ws(e,t){let r=_t(e,t),s=new Map;for(let[i,o]of r.features){for(let a of o.files)s.set(a,i);s.set(o.hub,i)}let n=new Map;for(let i of e.nodes.values()){let o=s.get(i.path);n.set(i.path,{path:i.path,role:Ce(i),...i.description?{description:i.description}:{},exports:i.exports.map(a=>a.name),...o?{featureHub:o}:{}})}return n}function $s(e,t){let r=[];for(let s of e.nodes.values())if(s.exports.some(n=>n.name===t))if(ut.has(s.type)){let n=[];for(let i of e.nodes.values())for(let o of i.callEdges??[])o.to===t&&n.push({file:i.path,callerFunction:o.from});r.push({path:s.path,category:s.category,precision:"call",callers:n})}else if(ft.has(s.type)){let n=[];for(let i of e.nodes.values())for(let o of i.imports)o.toPath===s.path&&o.symbols?.includes(t)&&n.push({file:i.path,symbols:o.symbols});r.push({path:s.path,category:s.category,precision:"import-symbol",importers:n})}else{let n=Wt(e,s.path).map(i=>({file:i.path,...i.symbols?{symbols:i.symbols}:{}}));r.push({path:s.path,category:s.category,precision:"file-level",importers:n})}return r}function zs(e){return e?e.startsWith("interface ")?"interface":e.startsWith("class ")?"class":e.startsWith("enum ")?"enum":"type":"type"}function Bs(e,t){if(t==="type-only")return!0;let r=e.signature??"";return r.startsWith("interface ")||r.startsWith("class ")||r.startsWith("enum ")}function Us(e){let t=new Map;for(let s of e.nodes.values())if(!(s.type!=="typescript"&&s.type!=="javascript"))for(let n of s.exports){if(!Bs(n,s.category))continue;let i=`${s.path}::${n.name}`;t.set(i,{name:n.name,file:s.path,kind:zs(n.signature),...n.doc?{doc:n.doc}:{}})}let r=[];for(let s of e.nodes.values())if(!(s.type!=="typescript"&&s.type!=="javascript")){for(let n of s.imports)if(!(!n.toPath||n.isExternal||!n.symbols?.length))for(let i of n.symbols)t.has(`${n.toPath}::${i}`)&&r.push({fromFile:s.path,toType:i,toFile:n.toPath})}return{types:t,edges:r}}function Ks(e,t){let r=null;for(let i of e.types.values())if(i.name===t){r=i;break}if(!r)return{type:null,usedByFiles:[],uses:[]};let s=new Set,n=new Map;for(let i of e.edges)if(i.toType===t&&i.toFile===r.file&&s.add(i.fromFile),i.fromFile===r.file){let o=e.types.get(`${i.toFile}::${i.toType}`);o&&n.set(`${o.file}::${o.name}`,o)}return{type:r,usedByFiles:Array.from(s),uses:Array.from(n.values())}}import sn from"path";import zt from"fs";import Pe from"path";import V from"fs";import C from"path";import Ee from"fs";import gc from"path";function Fe(e){try{return Ee.statSync(e,{throwIfNoEntry:!1})?.isDirectory()===!0}catch{return!1}}function gt(e){try{return Ee.statSync(e,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}function $t(e,t){let r=C.join(t,"package.json");if(!V.existsSync(r))return null;let s={};try{s=JSON.parse(V.readFileSync(r,"utf-8"))}catch{return null}let n=s.name;return n?{name:n,root:t,relativeRoot:C.relative(e,t),entryPoints:Js(t,s)}:null}function Js(e,t){let r=[];if(t.exports){let n=t.exports;if(typeof n=="string")r.push(C.join(e,n));else if(typeof n=="object"&&n!==null){let i=n["."];if(typeof i=="string")r.push(C.join(e,i));else if(typeof i=="object"&&i!==null){let o=i.import??i.require??i.default;typeof o=="string"&&r.push(C.join(e,o))}}}t.main&&r.push(C.join(e,t.main));for(let n of["src/index.ts","src/index.tsx","index.ts","index.tsx","index.js"])r.push(C.join(e,n));let s=r.filter(gt);return s.length>0?s.slice(0,1):r.slice(0,1)}function R(e,t){let r=[],s=new Set;for(let n of t){let i=n.replace(/\/$/,"").replace(/^\.\//,"");Hs(e,i,s,r)}return r}function Hs(e,t,r,s){if(!t.includes("*")){Qs(e,t,r,s);return}let n=t.split("/");n.includes("**")?Vs(e,n,r,s):Xs(e,n,r,s)}function Qs(e,t,r,s){let n=C.join(e,t);if(r.has(n)||!Fe(n))return;r.add(n);let i=$t(e,n);i&&s.push(i)}function Vs(e,t,r,s){let n=C.join(e,t[0]==="**"?"":t[0]??"");we(e,n,r,s)}function Xs(e,t,r,s){let n=t.findIndex(a=>a.includes("*")),i=C.join(e,...t.slice(0,n)),o;try{o=V.readdirSync(i,{withFileTypes:!0})}catch{return}for(let a of o){if(!a.isDirectory())continue;let c=C.join(i,a.name);if(r.has(c))continue;r.add(c);let p=$t(e,c);p&&s.push(p)}}function we(e,t,r,s){let n;try{n=V.readdirSync(t,{withFileTypes:!0})}catch{return}for(let i of n){if(!i.isDirectory()||i.name==="node_modules"||i.name.startsWith("."))continue;let o=C.join(t,i.name);if(V.existsSync(C.join(o,"package.json"))&&!r.has(o)){r.add(o);let a=$t(e,o);a&&s.push(a)}else we(e,o,r,s)}}var Te={type:"npm",detect(e){let t=Pe.join(e,"package.json");if(!zt.existsSync(t))return null;let r;try{r=JSON.parse(zt.readFileSync(t,"utf-8")).workspaces}catch{return null}if(!r||zt.existsSync(Pe.join(e,"yarn.lock")))return null;let s=Array.isArray(r)?r:r.packages??[];return s.length===0?null:R(e,s)}};import A from"fs";import S from"path";var Ie={type:"nx",detect(e){return A.existsSync(S.join(e,"nx.json"))?Me(e,e,new Set,0).map(r=>Ys(e,r,S.join(r,"project.json"))).filter(r=>r!==null):null}};function Me(e,t,r,s){if(s>4)return[];let n;try{n=A.readdirSync(t,{withFileTypes:!0})}catch{return[]}let i=[];for(let o of n){if(!o.isDirectory())continue;let a=o.name;if(a.startsWith(".")||a==="node_modules"||a==="dist"||a===".nx")continue;let c=S.join(t,a);A.existsSync(S.join(c,"project.json"))&&!r.has(c)?(r.add(c),i.push(c)):i.push(...Me(e,c,r,s+1))}return i}function Ys(e,t,r){let s={};try{s=JSON.parse(A.readFileSync(r,"utf-8"))}catch{return null}let n=s.name,i,o,a=S.join(t,"package.json");if(A.existsSync(a))try{let c=JSON.parse(A.readFileSync(a,"utf-8"));n=c.name??n,i=c.main,o=c.exports}catch{}return n?{name:n,root:t,relativeRoot:S.relative(e,t),entryPoints:Zs(t,s,i,o)}:null}function Zs(e,t,r,s){let n=[],i=t.targets?.build?.options?.main??t.targets?.build?.options?.entryFile;if(i){let a=S.resolve(e,"../..");n.push(S.resolve(a,i)),n.push(S.resolve(e,i))}if(s){let a=s;if(typeof a=="string")n.push(S.join(e,a));else if(typeof a=="object"&&a!==null){let c=a["."];typeof c=="string"&&n.push(S.join(e,c))}}if(r&&n.push(S.join(e,r)),t.sourceRoot){let a=S.resolve(e,"../.."),c=S.resolve(a,t.sourceRoot);n.push(S.join(c,"index.ts"),S.join(c,"index.tsx"))}for(let a of["src/index.ts","src/index.tsx","index.ts","index.tsx"])n.push(S.join(e,a));let o=n.filter(gt);return o.length>0?o.slice(0,1):n.slice(0,1)}import Ne from"fs";import qs from"path";import{load as tn}from"js-yaml";var Re={type:"pnpm",detect(e){let t=qs.join(e,"pnpm-workspace.yaml");if(!Ne.existsSync(t))return null;let r=[];try{r=tn(Ne.readFileSync(t,"utf-8"))?.packages??[]}catch{return null}return R(e,r)}};import en from"fs";import rn from"path";var Ae={type:"turborepo",detect(e){return en.existsSync(rn.join(e,"turbo.json"))?[]:null}};import Bt from"fs";import De from"path";var Le={type:"yarn",detect(e){if(!Bt.existsSync(De.join(e,"yarn.lock")))return null;let t=De.join(e,"package.json");if(!Bt.existsSync(t))return null;let r;try{r=JSON.parse(Bt.readFileSync(t,"utf-8")).workspaces}catch{return null}if(!r)return null;let s=Array.isArray(r)?r:r.packages??[];return s.length===0?null:R(e,s)}};var Ge=[];function w(e){Ge.push(e)}function Oe(){return Ge}w(Ae);w(Ie);w(Re);w(Le);w(Te);function Ut(e,t=Oe()){let r=sn.resolve(e),s=new Map,n=[];for(let o of t){let a=o.detect(r);if(a!==null){n.push(o.type);for(let c of a)s.has(c.name)||s.set(c.name,c)}}if(n.length===0)return{root:r,type:"none",types:[],packages:[],packageMap:new Map};let i=Array.from(s.values());return{root:r,type:n[0],types:n,packages:i,packageMap:new Map(i.map(o=>[o.name,o]))}}var X=class e{constructor(t,r){this.monorepoRoot=t;this.type=r}monorepoRoot;type;packages=new Map;addPackage(t,r){this.packages.set(t.name,{graph:r,pkg:t})}getPackageForFile(t){for(let{pkg:r}of this.packages.values())if(t===r.relativeRoot||t.startsWith(`${r.relativeRoot}/`))return r}getPackageDependencies(){let t=new Map;for(let{graph:r,pkg:s}of this.packages.values()){let n=new Set;for(let i of r.nodes.values())for(let o of i.imports)o.isWorkspace&&o.workspacePackage&&n.add(o.workspacePackage);t.set(s.name,[...n])}return t}getAffectedAcrossPackages(t){let r=this.getPackageForFile(t);if(!r)return[];let s=this.packages.get(r.name);if(!s)return[];let n=[];s.graph.traverse(t,i=>(i.path!==t&&n.push({file:i.path,package:r.name}),!0),{direction:"incoming"});for(let{graph:i,pkg:o}of this.packages.values())if(o.name!==r.name)for(let a of i.nodes.values())a.imports.some(p=>p.isWorkspace&&p.workspacePackage===r.name)&&n.push({file:a.path,package:o.name});return n}serialize(){return{monorepoRoot:this.monorepoRoot,type:this.type,packages:Array.from(this.packages.values()).map(({graph:t,pkg:r})=>({pkg:{name:r.name,relativeRoot:r.relativeRoot,entryPoints:r.entryPoints},nodes:Array.from(t.nodes.values())}))}}static deserialize(t){let r=new e(t.monorepoRoot,t.type);for(let{pkg:s,nodes:n}of t.packages){let i=new Map(n.map(a=>[a.path,a])),o=new I(i);r.packages.set(s.name,{graph:o,pkg:{...s,root:""}})}return r}};var je=new Map;function D(e,t){je.set(e,t)}function _e(e){return je.get(e)}function We(e,t){return t.startsWith("!")?e!==t.slice(1):e===t}function nn(e,t){return t.startsWith("!")?!e.includes(t.slice(1)):e.includes(t)}var on=(e,t)=>!t.category||We(e.category,t.category),an=(e,t)=>!t.type||We(e.type,t.type),cn=(e,t)=>t.lastAuthor?t.lastAuthor.startsWith("!")?e.lastAuthor!==t.lastAuthor.slice(1):e.lastAuthor!==void 0&&e.lastAuthor===t.lastAuthor:!0,pn=(e,t)=>!t.path||nn(e.path,t.path),ln=(e,t)=>t.isExternal===void 0?!0:e.imports.some(s=>s.isExternal)===t.isExternal,mn=(e,t)=>{if(!t.tags||t.tags.length===0)return!0;let r=t.tags.filter(n=>!n.startsWith("!")),s=t.tags.filter(n=>n.startsWith("!")).map(n=>n.slice(1));return!(r.length>0&&!r.some(n=>e.tags.some(i=>i.name===n))||s.some(n=>e.tags.some(i=>i.name===n)))},fn=(e,t)=>!t.allTags?.length||t.allTags.every(r=>e.tags.some(s=>s.name===r)),un=(e,t)=>!t.importsFile||e.imports.some(r=>r.toPath?.includes(t.importsFile)),gn=(e,t,r)=>t.importedBy===void 0?!0:(r?.get(e.path)??[]).some(n=>n.includes(t.importedBy)),dn=(e,t)=>t.minImports===void 0||e.imports.length>=t.minImports,hn=(e,t)=>t.maxImports===void 0||e.imports.length<=t.maxImports,yn=(e,t)=>t.minSize===void 0||e.size>=t.minSize,xn=(e,t)=>t.maxSize===void 0||e.size<=t.maxSize,Sn=(e,t)=>t.hasDocstring===void 0||!!e.description===t.hasDocstring,bn=(e,t)=>t.isDocumented===void 0||!!e.documentedBy?.length===t.isDocumented,vn=(e,t)=>t.isStale===void 0||!!e.staleFor?.length===t.isStale,kn=(e,t)=>t.minCoverage===void 0||(e.coveragePct??101)>=t.minCoverage,Cn=(e,t)=>t.maxCoverage===void 0||(e.coveragePct??0)<=t.maxCoverage,En=(e,t)=>t.minExportUsage===void 0||(e.avgExportUsage??-1)>=t.minExportUsage,Fn=(e,t)=>t.maxExportUsage===void 0||(e.avgExportUsage??0)<=t.maxExportUsage,wn=(e,t)=>t.minComplexity===void 0||(e.complexity??-1/0)>=t.minComplexity,Pn=(e,t)=>t.maxComplexity===void 0||(e.complexity??0)<=t.maxComplexity,Tn=(e,t)=>t.minCognitiveComplexity===void 0||(e.cognitiveComplexity??-1/0)>=t.minCognitiveComplexity,In=(e,t)=>t.maxCognitiveComplexity===void 0||(e.cognitiveComplexity??0)<=t.maxCognitiveComplexity,Mn=(e,t)=>t.minCommits===void 0||(e.commitCount90d??-1/0)>=t.minCommits,Nn=(e,t)=>t.maxCommits===void 0||(e.commitCount90d??0)<=t.maxCommits,Rn=(e,t,r)=>!t.any?.length||t.any.some(s=>Y(e,s,r)),An=[on,an,cn,pn,ln,mn,fn,un,gn,dn,hn,yn,xn,Sn,bn,vn,kn,Cn,En,Fn,wn,Pn,Tn,In,Mn,Nn,Rn];function Y(e,t,r){return An.every(s=>s(e,t,r))}function $e(e,t){let r=new Map;if(t.importedBy!==void 0){for(let o of e.nodes)for(let a of o.imports)if(a.toPath){let c=r.get(a.toPath)??[];c.push(o.path),r.set(a.toPath,c)}}let s=e.nodes.filter(o=>Y(o,t,r)),n=new Set(s.map(o=>o.path)),i=s.map(o=>({...o,imports:o.imports.filter(a=>!a.toPath||n.has(a.toPath))}));if(t.sort){let o=t.sortDir==="asc"?-1:1;i.sort((a,c)=>{let p=0;return t.sort==="size"?p=c.size-a.size:t.sort==="imports"?p=c.imports.length-a.imports.length:t.sort==="commitCount90d"?p=(c.commitCount90d??0)-(a.commitCount90d??0):t.sort==="exportUsage"?p=(c.avgExportUsage??0)-(a.avgExportUsage??0):t.sort==="complexity"?p=(c.complexity??0)-(a.complexity??0):t.sort==="cognitiveComplexity"&&(p=(c.cognitiveComplexity??0)-(a.cognitiveComplexity??0)),p*o})}return t.limit!==void 0&&i.splice(t.limit),{nodes:i,cycles:e.cycles?.filter(o=>o.every(a=>n.has(a)))??void 0}}function ze(e,t){let r=t.indexOf(":");if(r===-1)return;let s=t.slice(0,r).trim().toLowerCase(),n=t.slice(r+1).trim();if(!(!s||!n))switch(s){case"category":e.category=n;break;case"type":e.type=n;break;case"tag":case"tags":n.includes("+")?e.allTags=[...e.allTags??[],...n.split("+")]:e.tags=[...e.tags??[],n];break;case"path":e.path=n;break;case"external":e.isExternal=n.toLowerCase()==="true";break;case"importsfile":e.importsFile=n;break;case"importedby":e.importedBy=n;break;case"minimports":e.minImports=parseInt(n,10);break;case"maximports":e.maxImports=parseInt(n,10);break;case"minsize":e.minSize=parseInt(n,10);break;case"maxsize":e.maxSize=parseInt(n,10);break;case"sort":e.sort=n;break;case"sortdir":e.sortDir=n.toLowerCase()==="asc"?"asc":"desc";break;case"limit":e.limit=parseInt(n,10);break;case"hasdocstring":e.hasDocstring=n.toLowerCase()!=="false";break;case"mincoverage":e.minCoverage=parseInt(n,10);break;case"maxcoverage":e.maxCoverage=parseInt(n,10);break;case"minexportusage":e.minExportUsage=parseFloat(n);break;case"maxexportusage":e.maxExportUsage=parseFloat(n);break;case"mincomplexity":e.minComplexity=parseInt(n,10);break;case"maxcomplexity":e.maxComplexity=parseInt(n,10);break;case"mincognitivecomplexity":e.minCognitiveComplexity=parseInt(n,10);break;case"maxcognitivecomplexity":e.maxCognitiveComplexity=parseInt(n,10);break;case"mincommits":e.minCommits=parseInt(n,10);break;case"maxcommits":e.maxCommits=parseInt(n,10);break;case"isdocumented":e.isDocumented=n.toLowerCase()!=="false";break;case"isstale":e.isStale=n.toLowerCase()!=="false";break;case"lastauthor":e.lastAuthor=n;break}}function Dn(e){let t=[];for(let r of e.split("|")){let s=r.trim();if(!s)continue;let n={};ze(n,s),Object.keys(n).length>0&&t.push(n)}return t}function Be(e){let t={},r=e.split(",");for(let s of r){let n=s.trim();if(n.toLowerCase().startsWith("any(")&&n.endsWith(")")){let i=n.slice(4,-1),o=Dn(i);o.length>0&&(t.any=[...t.any??[],...o]);continue}ze(t,s)}return t}import er from"fs/promises";import ni from"path";import Xt from"path";import kt from"typescript";import Ke from"path";import Je from"typescript";import v from"typescript";var Ue=new Set(["describe","test","it"]);function L(e){let t=[];for(let r of e.statements){if(!v.isExpressionStatement(r))continue;let s=r.expression;if(!v.isCallExpression(s))continue;let n=s.expression;v.isIdentifier(n)&&Ue.has(n.text)&&t.push(s),v.isPropertyAccessExpression(n)&&v.isIdentifier(n.expression)&&Ue.has(n.expression.text)&&t.push(s)}return t}function G(e,t,r){for(let s of e.arguments){if(!v.isObjectLiteralExpression(s))continue;let n=s.properties.find(i=>v.isPropertyAssignment(i)&&v.isIdentifier(i.name)&&i.name.text===t);if(!(!n||!v.isArrayLiteralExpression(n.initializer)))return n.initializer.elements.filter(v.isStringLiteral).map(i=>i.text)}return null}function O(e,t,r,s){if(e.arguments.length===0)return null;for(let i=1;i<e.arguments.length;i++){let o=e.arguments[i];if(!v.isObjectLiteralExpression(o))continue;let a=o.properties.find(p=>v.isPropertyAssignment(p)&&v.isIdentifier(p.name)&&p.name.text===t);if(a)return{start:a.initializer.getStart(s),end:a.initializer.getEnd(),text:r};let c=o.getEnd()-1;return{start:c,end:c,text:`${o.properties.length>0?", ":""}${t}: ${r}`}}let n=e.arguments[e.arguments.length-1];return{start:n.getStart(s),end:n.getStart(s),text:`{ ${t}: ${r} }, `}}function j(e,t,r){let s=e.arguments;for(let n=1;n<s.length;n++){let i=s[n];if(!v.isObjectLiteralExpression(i))continue;let o=i.properties.findIndex(c=>v.isPropertyAssignment(c)&&v.isIdentifier(c.name)&&c.name.text===t);if(o<0)continue;if(i.properties.length===1)return{start:s[n-1].getEnd(),end:i.getEnd(),text:""};let a=i.properties[o];return o===i.properties.length-1?{start:i.properties[o-1].getEnd(),end:a.getEnd(),text:""}:{start:a.getStart(r),end:i.properties[o+1].getStart(r),text:""}}return null}function _(e,t){let r=[...t].sort((n,i)=>i.start-n.start),s=e;for(let n of r)s=s.slice(0,n.start)+n.text+s.slice(n.end);return s}function W(e){return`[${e.map(t=>JSON.stringify(t)).join(", ")}]`}var F=new Set([".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"]);function Ln(e){return W(e.map(t=>`@${t}`))}function Gn(e){return e.map(t=>t.startsWith("@")?t.slice(1):t)}var dt=class{name="cypress";canHandle(t){return F.has(Ke.extname(t).toLowerCase())}apply(t,r,s){let n=Je.createSourceFile(Ke.basename(t),r,Je.ScriptTarget.Latest,!0),i=L(n);if(i.length===0)return r;let o=G(i[0],"tags",n),a=[...s].sort();if(o!==null&&JSON.stringify(Gn(o).sort())===JSON.stringify(a))return r;let c=i.flatMap(p=>{let g=s.length===0?j(p,"tags",n):O(p,"tags",Ln(a),n);return g?[g]:[]});return c.length>0?_(r,c):r}};import On from"path";var Kt=/# <mokosh-tags>[\s\S]*?# <\/mokosh-tags>\n*/,Jt=/^@([a-zA-Z0-9_-]+)/gm;function jn(e){return["# <mokosh-tags>",...e.map(t=>`@${t}`),"# </mokosh-tags>"].join(`
1
+ var Nt=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});import ts from"path";import{fileURLToPath as es}from"url";var rs=()=>es(import.meta.url),ss=()=>ts.dirname(rs()),f=ss();import At from"fs";import de from"path";var ns=[".config.","biome.json","tsconfig.json","package.json",".prettierrc",".eslintrc"],le=[];function pt(e){le.push(e)}function fe(e){return[...ns,...le].some(t=>typeof t=="string"?e.includes(t):t instanceof RegExp?t.test(e):t(e))}var is=[".test.",".spec.","-test.","-spec."],me=[];function lt(e){me.push(e)}function K(){return[...is,...me]}var os=["jest","vitest","playwright","cypress","@testing-library/"],ue=[];function ft(e){ue.push(e)}function It(){return[...os,...ue]}var ge=.8;function Mt(e){ge=e}function Rt(){return ge}var as=["mokosh.config.js","mokosh.config.cjs","mokosh.config.json"];function Dt(e,{allowJs:t=!0,isExplicitPath:r=!1}={}){if(r){let s=de.resolve(e);return At.existsSync(s)?s.endsWith(".json")?he(s):t?ye(s):{}:{}}for(let s of as){let n=de.resolve(e,s);if(At.existsSync(n)){if(s.endsWith(".json"))return he(n);if(t)return ye(n)}}return{}}function he(e){return JSON.parse(At.readFileSync(e,"utf-8"))}function ye(e){let t=Nt(e);return t&&typeof t=="object"&&"default"in t&&(t=t.default),typeof t=="function"?t({}):t}function cs(e){for(let t of e.configMatchers??[])pt(t);for(let t of e.testPatterns??[])lt(t);for(let t of e.testLibraries??[])ft(t);e.barrelThreshold!==void 0&&Mt(e.barrelThreshold)}function ps(e){return{gitStats:e?.gitStats??!1,parallelParsing:e?.parallelParsing,pathAliases:e?.pathAliases}}var Lt=["node_modules",".git","dist","build",".next",".cache","mokosh-cache","coverage"],Gt=[".ts",".tsx",".js",".jsx",".mjs",".cjs",".css",".scss",".sass",".less",".styl",".coffee",".ls",".lua",".py",".go",".feature",".md",".mdx"];import ls from"fs";import xe from"path";function fs(e,t){let r=xe.resolve(e,t);try{let s=ls.readFileSync(r,"utf-8"),n=JSON.parse(s),i=new Map;for(let[o,a]of Object.entries(n)){if(o==="total")continue;let c=a?.lines?.pct;if(typeof c!="number")continue;let p=xe.relative(e,o);i.set(p,c)}return i}catch{return new Map}}var Ot={serialize(e){let t=["graph TD"],r=new Set;for(let s of e.nodes.values()){let n=`"${s.path}"`;for(let i of s.imports){if(!i.toPath)continue;let o=`"${i.toPath}"`,a=`${s.path} -> ${i.toPath}`;if(!r.has(a)){let c=i.isStyle?"-- styles -->":"-->";t.push(` ${n} ${c} ${o}`),r.add(a)}}}return t.join(`
2
+ `)}};function Se(e){return Ot.serialize(e)}import be from"fs";import ms from"path";function jt(e,t){let r=e.replace(/^\.\//,"");if(t.nodes.has(r))return r;let s=r.replace(/^dist\//,"src/").replace(/\.(js|mjs|cjs)$/,".ts");return t.nodes.has(s)?s:null}function ve(e,t){if(typeof e=="string")return jt(e,t);if(e&&typeof e=="object"){let r=e;for(let s of["import","require","default"]){let n=ve(r[s],t);if(n)return n}}return null}function us(e){if(!e)return"unknown";let t=e.trimStart();return t.startsWith("interface ")?"interface":t.startsWith("class ")?"class":t.startsWith("enum ")?"enum":t.startsWith("type ")?"type":t.startsWith("namespace ")?"namespace":t.startsWith("const ")||t.startsWith("let ")||t.startsWith("var ")||t.startsWith("readonly ")?"const":t.startsWith("(")||t.startsWith("async ")||t.startsWith("function ")||t.includes("=>")?"function":"unknown"}function gs(e,t){let r=new Set,s=new Set,n=[...t];for(;n.length;){let i=n.shift();if(s.has(i))continue;s.add(i);let o=e.nodes.get(i);if(o){for(let a of o.exports)r.add(a.name);for(let a of o.imports){if(a.type!=="re-export"||a.isExternal||!a.toPath)continue;if(!a.symbols?.length||a.symbols.includes("*")){let p=e.nodes.get(a.toPath);if(p)for(let g of p.exports)r.add(g.name);n.push(a.toPath)}else for(let p of a.symbols)r.add(p)}}}return r}function ds(e,t){return Ee(e,t)[0]??null}function Ee(e,t){let r=[],s=ms.join(t,"package.json");if(be.existsSync(s))try{let n=JSON.parse(be.readFileSync(s,"utf8"));if(n.exports&&typeof n.exports=="object"&&!Array.isArray(n.exports))for(let i of Object.values(n.exports)){let o=ve(i,e);o&&!r.includes(o)&&r.push(o)}else if(typeof n.exports=="string"){let i=jt(n.exports,e);i&&r.push(i)}if(r.length===0)for(let i of[n.main,n.module].filter(Boolean)){let o=jt(i,e);o&&!r.includes(o)&&r.push(o)}}catch{}if(r.length===0){for(let n of["src/index.ts","src/index.js","index.ts","index.js"])if(e.nodes.has(n)){r.push(n);break}}return r}function hs(e,t){let r=new Set(t);for(let s of t)e.traverse(s,n=>(r.add(n.path),!0),{direction:"outgoing"});return r}function ys(e,t,r){let s=new Map;for(let n of t){if(r.includes(n))continue;let i=e.nodes.get(n);if(!i)continue;let o=i.category==="barrel";for(let a of i.exports){let c=s.get(a.name),p=!!(a.signature||a.doc);(!c||p&&!o)&&s.set(a.name,{file:n,symbol:a})}}return s}function xs(e,t,r,s){let n=[];for(let i of e){let o=t.get(i),a=s.flatMap(u=>r.nodes.get(u)?.exports??[]).find(u=>u.name===i),c=o?.symbol??a,p=o?.file??s.find(u=>r.nodes.get(u)?.exports.some(y=>y.name===i))??s[0],g={name:i,definedIn:p,kind:us(c?.signature)};c?.doc&&(g.doc=c.doc),c?.signature&&(g.signature=c.signature),n.push(g)}return n.sort((i,o)=>i.name.localeCompare(o.name)),n}function Ss(e,t,r){let s=c=>e.nodes.get(c)?.category==="test",n=[...t].filter(c=>!r.includes(c)&&!s(c)),i=[...e.nodes.keys()].filter(c=>!t.has(c)),o=i.filter(c=>!s(c)),a=i.filter(c=>s(c));return{internalFiles:n,unreachableFromEntry:o,testFiles:a}}function bs(e,t){if(t.length===0)throw new Error("buildApiSurface requires at least one entry point");for(let p of t)if(!e.nodes.has(p))throw new Error(`Entry point not found in graph: ${p}`);let r=hs(e,t),s=ys(e,r,t),n=gs(e,t),i=xs(n,s,e,t),{internalFiles:o,unreachableFromEntry:a,testFiles:c}=Ss(e,r,t);return{entryPoints:t,publicExports:i,internalFiles:o,unreachableFromEntry:a,testFiles:c}}function vs(e,t){let r=null,s=[];for(let i of e.nodes.values()){i.exports.some(o=>o.name===t)&&(r=i.path);for(let o of i.callEdges??[])o.to===t&&s.push({file:i.path,callerFunction:o.from})}let n=[];if(r){let i=e.nodes.get(r);for(let o of i?.callEdges??[])o.from===t&&n.push({file:o.toFile,calleeFunction:o.to})}return{functionName:t,definedIn:r,callers:s,callees:n}}import J from"fs";import Es from"path";function _t(e){let t=[...e.nodes.entries()].sort(([s],[n])=>s.localeCompare(n)).map(([s,n])=>`${s}:${n.mtime}:${n.size}`).join("|"),r=2166136261;for(let s=0;s<t.length;s++)r^=t.charCodeAt(s),r=Math.imul(r,16777619)>>>0;return r.toString(16).padStart(8,"0")}function Cs(e){let t=new Map;for(let r of e.nodes.keys()){let s=[];e.traverse(r,n=>(n.path!==r&&s.push(n.path),!0),{direction:"incoming"}),t.set(r,s)}return{impact:t,graphHash:_t(e)}}function ks(e,t){return e.impact.get(t)??[]}function ws(e,t){return e.graphHash===_t(t)}function Fs(e,t){let r=Es.dirname(t);J.existsSync(r)||J.mkdirSync(r,{recursive:!0});let s={graphHash:e.graphHash,impact:[...e.impact.entries()]};J.writeFileSync(t,JSON.stringify(s))}function Ts(e){if(!J.existsSync(e))return null;try{let t=J.readFileSync(e,"utf-8"),r=JSON.parse(t);return{graphHash:r.graphHash,impact:new Map(r.impact)}}catch{return null}}import mt from"path";function Ps(e){let t=new Map;for(let[r,s]of e){let n=s.imports.filter(i=>i.toPath&&!i.isExternal).length;n>0&&t.set(r,n)}return t}function Ns(e,t,r){let s=new Map;for(let[n,i]of t){if(i<r)continue;let o=e.get(n);if(!o||o.category==="test"||o.category==="barrel")continue;let a=mt.extname(n),c=mt.basename(n,a),p=c==="index"?mt.basename(mt.dirname(n)):c;s.set(n,{path:n,outDegree:i,tag:`feature:${p}`})}return s}function H(e,t){let r=t?.minOutDegree??5;return Ns(e,Ps(e),r)}var Is=(e,t)=>e.outDegree-t.outDegree;function Ms(e,t){let r=new Map;for(let s of t.values()){let n=new Set;e.traverse(s.path,i=>(i.path!==s.path&&n.add(i.path),!0),{direction:"outgoing"}),r.set(s.path,n)}return r}function Rs(e,t,r,s){let n=new Map;for(let[i]of e){if(t.has(i))continue;let o=null;for(let a of t.values())r.get(a.path)?.has(i)&&(!o||s(a,o)<0)&&(o=a);o&&n.set(i,o.path)}return n}function As(e,t){let r=new Map;for(let s of e.values()){let n=s.tag.replace("feature:",""),i=[];for(let[o,a]of t)a===s.path&&i.push(o);r.set(n,{hub:s.path,outDegree:s.outDegree,files:i})}return r}function Ds(e,t,r){let s=[];for(let n of e.keys())!t.has(n)&&!r.has(n)&&s.push(n);return s}function Wt(e,t){let r=t?.detectFn??H,s=t?.hubComparator??Is,n=r(e.nodes,t),i=Ms(e,n),o=Rs(e.nodes,n,i,s);return{features:As(n,o),unassigned:Ds(e.nodes,n,o)}}var Ce=new Set(["typescript","javascript","python","go","scss","less","lua","coffeescript"]),ut=new Set(["typescript","javascript","python"]),gt=new Set(["typescript","javascript"]);function Ls(e){let t=new Map;for(let r of e.nodes.values())t.set(r.type,(t.get(r.type)??0)+1);return[...t.entries()].map(([r,s])=>({type:r,fileCount:s,exportsTracked:Ce.has(r),importSymbolsTracked:ut.has(r),callEdgesTracked:gt.has(r)})).sort((r,s)=>s.fileCount-r.fileCount)}var V=class{constructor(t){this.nodes=t}nodes;findUnusedFiles(t){let r=new Set(this.nodes.keys());return t.filter(s=>!r.has(s))}findHighExportUsage(t){let r=[];for(let s of this.nodes.values()){if(s.maxExportUsage===void 0||s.maxExportUsage<t)continue;let n=s.imports.reduce((i,o)=>(o.exportUsageRatio??0)>(i?.exportUsageRatio??0)?o:i,null);r.push({path:s.path,maxExportUsage:s.maxExportUsage,tightestDep:n?.toPath??""})}return r.sort((s,n)=>n.maxExportUsage-s.maxExportUsage)}findCycles(){let t=[],r=new Set,s=new Set,n=[],i=o=>{r.add(o),s.add(o),n.push(o);let a=this.nodes.get(o);if(a){for(let c of a.imports)if(!(!c.toPath||c.isExternal))if(s.has(c.toPath)){let p=n.indexOf(c.toPath);t.push([...n.slice(p),c.toPath])}else r.has(c.toPath)||i(c.toPath)}s.delete(o),n.pop()};for(let o of this.nodes.keys())r.has(o)||i(o);return t}};var I=class e{constructor(t){this.nodes=t}nodes;_incomingEdgesCache=null;_callIncomingCache=null;serialize(){return{nodes:Array.from(this.nodes.values())}}static deserialize(t){let r=new Map;for(let s of t.nodes)r.set(s.path,s);return new e(r)}getIncomingEdgesMap(){if(this._incomingEdgesCache)return this._incomingEdgesCache;let t=new Map;for(let r of this.nodes.values())for(let s of r.imports)if(s.toPath){let n=t.get(s.toPath)||[];n.push(r.path),t.set(s.toPath,n)}return this._incomingEdgesCache=t,t}dfs(t,r,s,n){let i=new Set,o=s.maxDepth??1/0,a=(c,p,g)=>{if(p>o||i.has(c))return;let u=this.nodes.get(c);if(u&&(i.add(c),r(u,p,g)!==!1))for(let y of n(c))a(y,p+1,c)};a(t,0,null)}traverse(t,r,s={}){let n=s.direction??"outgoing",i=n==="incoming"?this.getIncomingEdgesMap():null;this.dfs(t,r,s,o=>n==="outgoing"?this.nodes.get(o)?.imports.map(a=>a.toPath).filter(Boolean)??[]:i?.get(o)??[])}getCallIncomingCache(){if(this._callIncomingCache)return this._callIncomingCache;let t=new Map;for(let r of this.nodes.values())for(let s of r.callEdges??[]){let n=t.get(s.toFile)??[];n.push(r.path),t.set(s.toFile,n)}return this._callIncomingCache=t,t}traverseCalls(t,r,s={}){let n=s.direction??"outgoing",i=n==="incoming"?this.getCallIncomingCache():null;this.dfs(t,r,s,o=>n==="outgoing"?this.nodes.get(o)?.callEdges?.map(a=>a.toFile)??[]:i?.get(o)??[])}getCallers(t){let r=[];return this.traverseCalls(t,s=>(s.path!==t&&r.push(s.path),!0),{direction:"incoming",maxDepth:1}),r}getCallEdgesFor(t){return this.nodes.get(t)?.callEdges??[]}getNeighbors(t){let r=this.nodes.get(t);return r?r.imports.map(s=>this.nodes.get(s.toPath)).filter(s=>s!==void 0):[]}findUnusedFiles(t){return new V(this.nodes).findUnusedFiles(t)}findCycles(){return new V(this.nodes).findCycles()}};var M=class{affectedSymbols=new Map;constructor(t,r){this.affectedSymbols.set(t,new Set(["default",...r]))}updateAffectedSymbols(t,r){let s=this.affectedSymbols.get(r)||new Set,n=t.imports.find(c=>c.toPath===r);if(!n)return!1;let i=n.symbols||["*"],o=new Set;for(let c of i)(c==="*"||s.has("*")||s.has(c))&&o.add("*");if(o.size===0)return!1;let a=this.affectedSymbols.get(t.path)||new Set;for(let c of o)a.add(c);return this.affectedSymbols.set(t.path,a),!0}};function Gs(e,t){let r=e.nodes.get(t);if(r)return{category:r.category,exports:r.exports.map(s=>s.name)}}function Os(e,t,r=1){let s=[];return e.traverse(t,(n,i,o)=>{if(n.path===t)return!0;let a=o?e.nodes.get(o)?.imports.find(c=>c.toPath===n.path):void 0;return s.push({path:n.path,...a?.symbols?{symbols:a.symbols}:{}}),!0},{direction:"outgoing",maxDepth:r}),s}function zt(e,t){let r=[];return e.traverse(t,s=>{if(s.path===t)return!0;let n=s.imports.find(i=>i.toPath===t);return r.push({path:s.path,...n?.symbols?{symbols:n.symbols}:{}}),!0},{direction:"incoming",maxDepth:1}),r}function js(e,t,r={}){let{testsOnly:s=!1,changedSymbols:n}=r,i=n?new M(t,n):null,o=[];return e.traverse(t,(a,c,p)=>{if(a.path===t)return!0;if(i&&p&&!i.updateAffectedSymbols(a,p))return!1;let g=a.category==="test"||a.tags.some(u=>u.name==="test");return(!s||g)&&o.push(a.path),!0},{direction:"incoming"}),o}function _s(e,t,r={}){let{depth:s=1,withEdgeDetail:n=!1}=r,i=[];return e.traverseCalls(t,o=>{if(o.path===t)return!0;let a={file:o.path};return n&&(a.edges=(o.callEdges??[]).filter(c=>c.toFile===t).map(c=>({from:c.from,to:c.to}))),i.push(a),!0},{direction:"incoming",maxDepth:s}),i}function Ws(e,t={}){let{metric:r="cognitiveComplexity",threshold:s=10,limit:n=20}=t;return[...e.nodes.values()].flatMap(i=>(i.functions??[]).filter(o=>o[r]>=s).map(o=>({file:i.path,name:o.name,line:o.line,complexity:o.complexity,cognitiveComplexity:o.cognitiveComplexity}))).sort((i,o)=>o[r]-i[r]).slice(0,n)}function zs(e){return{nodes:e.nodes.map(r=>({path:r.path,type:r.type,category:r.category,exports:r.exports.map(s=>s.name),tags:r.tags.filter(s=>s.kind==="comment-marker"||s.kind==="import").map(s=>s.name),importsFiles:r.imports.filter(s=>!s.isExternal&&s.toPath).map(s=>s.toPath),...r.description!==void 0&&{description:r.description},...r.testedBy!==void 0&&{testedBy:r.testedBy},...r.coveragePct!==void 0&&{coveragePct:r.coveragePct},...r.avgExportUsage!==void 0&&{avgExportUsage:r.avgExportUsage},...r.maxExportUsage!==void 0&&{maxExportUsage:r.maxExportUsage}})),cycles:e.cycles}}function $s(e){let t=e.getPackageDependencies(),r=Array.from(e.packages.values()).map(({graph:s,pkg:n})=>({name:n.name,relativeRoot:n.relativeRoot,nodeCount:s.nodes.size,dependsOn:t.get(n.name)??[]}));return{monorepoType:e.type,packageCount:r.length,packages:r}}function Bs(e){return[...e.nodes.values()].some(t=>t.coveragePct!==void 0)}function ke(e){if(e.category==="test")return"test";if(e.category==="config")return"config";if(e.category==="type-only")return"types";let t=e.path;return h(t,"component")||h(t,"components")?"component":h(t,"controller")||h(t,"controllers")?"controller":h(t,"middleware")?"middleware":h(t,"router")||h(t,"routes")||h(t,"route")?"router":h(t,"store")||h(t,"stores")?"store":h(t,"service")||h(t,"services")?"service":h(t,"handler")||h(t,"handlers")?"handler":h(t,"adapter")||h(t,"adapters")?"adapter":h(t,"plugin")||h(t,"plugins")?"plugin":h(t,"api")?"api":h(t,"cli")||h(t,"commands")||Q(t)==="cli"?"cli":h(t,"util")||h(t,"utils")||h(t,"helper")||h(t,"helpers")?"util":h(t,"model")||h(t,"models")||Q(t)==="model"?"model":h(t,"parser")||h(t,"parsers")||Q(t)==="parser"?"parser":Q(t)==="builder"?"builder":Q(t)==="resolver"?"resolver":"other"}function h(e,t){return e.includes(`/${t}/`)||e.includes(`/${t}.`)}function Q(e){let t=e.slice(e.lastIndexOf("/")+1);return t.slice(0,t.lastIndexOf("."))||t}function Us(e,t){let r=Wt(e,t),s=new Map;for(let[i,o]of r.features){for(let a of o.files)s.set(a,i);s.set(o.hub,i)}let n=new Map;for(let i of e.nodes.values()){let o=s.get(i.path);n.set(i.path,{path:i.path,role:ke(i),...i.description?{description:i.description}:{},exports:i.exports.map(a=>a.name),...o?{featureHub:o}:{}})}return n}function Ks(e,t){let r=[];for(let s of e.nodes.values())if(s.exports.some(n=>n.name===t))if(gt.has(s.type)){let n=[];for(let i of e.nodes.values())for(let o of i.callEdges??[])o.to===t&&n.push({file:i.path,callerFunction:o.from});r.push({path:s.path,category:s.category,precision:"call",callers:n})}else if(ut.has(s.type)){let n=[];for(let i of e.nodes.values())for(let o of i.imports)o.toPath===s.path&&o.symbols?.includes(t)&&n.push({file:i.path,symbols:o.symbols});r.push({path:s.path,category:s.category,precision:"import-symbol",importers:n})}else{let n=zt(e,s.path).map(i=>({file:i.path,...i.symbols?{symbols:i.symbols}:{}}));r.push({path:s.path,category:s.category,precision:"file-level",importers:n})}return r}function Js(e){return e?e.startsWith("interface ")?"interface":e.startsWith("class ")?"class":e.startsWith("enum ")?"enum":"type":"type"}function Hs(e,t){if(t==="type-only")return!0;let r=e.signature??"";return r.startsWith("interface ")||r.startsWith("class ")||r.startsWith("enum ")}function Vs(e){let t=new Map;for(let s of e.nodes.values())if(!(s.type!=="typescript"&&s.type!=="javascript"))for(let n of s.exports){if(!Hs(n,s.category))continue;let i=`${s.path}::${n.name}`;t.set(i,{name:n.name,file:s.path,kind:Js(n.signature),...n.doc?{doc:n.doc}:{}})}let r=[];for(let s of e.nodes.values())if(!(s.type!=="typescript"&&s.type!=="javascript")){for(let n of s.imports)if(!(!n.toPath||n.isExternal||!n.symbols?.length))for(let i of n.symbols)t.has(`${n.toPath}::${i}`)&&r.push({fromFile:s.path,toType:i,toFile:n.toPath})}return{types:t,edges:r}}function Qs(e,t){let r=null;for(let i of e.types.values())if(i.name===t){r=i;break}if(!r)return{type:null,usedByFiles:[],uses:[]};let s=new Set,n=new Map;for(let i of e.edges)if(i.toType===t&&i.toFile===r.file&&s.add(i.fromFile),i.fromFile===r.file){let o=e.types.get(`${i.toFile}::${i.toType}`);o&&n.set(`${o.file}::${o.name}`,o)}return{type:r,usedByFiles:Array.from(s),uses:Array.from(n.values())}}import cn from"path";import Bt from"fs";import Pe from"path";import X from"fs";import C from"path";import we from"fs";import kc from"path";function Fe(e){try{return we.statSync(e,{throwIfNoEntry:!1})?.isDirectory()===!0}catch{return!1}}function dt(e){try{return we.statSync(e,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}function $t(e,t){let r=C.join(t,"package.json");if(!X.existsSync(r))return null;let s={};try{s=JSON.parse(X.readFileSync(r,"utf-8"))}catch{return null}let n=s.name;return n?{name:n,root:t,relativeRoot:C.relative(e,t),entryPoints:Xs(t,s)}:null}function Xs(e,t){let r=[];if(t.exports){let n=t.exports;if(typeof n=="string")r.push(C.join(e,n));else if(typeof n=="object"&&n!==null){let i=n["."];if(typeof i=="string")r.push(C.join(e,i));else if(typeof i=="object"&&i!==null){let o=i.import??i.require??i.default;typeof o=="string"&&r.push(C.join(e,o))}}}t.main&&r.push(C.join(e,t.main));for(let n of["src/index.ts","src/index.tsx","index.ts","index.tsx","index.js"])r.push(C.join(e,n));let s=r.filter(dt);return s.length>0?s.slice(0,1):r.slice(0,1)}function D(e,t){let r=[],s=new Set;for(let n of t){let i=n.replace(/\/$/,"").replace(/^\.\//,"");Ys(e,i,s,r)}return r}function Ys(e,t,r,s){if(!t.includes("*")){Zs(e,t,r,s);return}let n=t.split("/");n.includes("**")?qs(e,n,r,s):tn(e,n,r,s)}function Zs(e,t,r,s){let n=C.join(e,t);if(r.has(n)||!Fe(n))return;r.add(n);let i=$t(e,n);i&&s.push(i)}function qs(e,t,r,s){let n=C.join(e,t[0]==="**"?"":t[0]??"");Te(e,n,r,s)}function tn(e,t,r,s){let n=t.findIndex(a=>a.includes("*")),i=C.join(e,...t.slice(0,n)),o;try{o=X.readdirSync(i,{withFileTypes:!0})}catch{return}for(let a of o){if(!a.isDirectory())continue;let c=C.join(i,a.name);if(r.has(c))continue;r.add(c);let p=$t(e,c);p&&s.push(p)}}function Te(e,t,r,s){let n;try{n=X.readdirSync(t,{withFileTypes:!0})}catch{return}for(let i of n){if(!i.isDirectory()||i.name==="node_modules"||i.name.startsWith("."))continue;let o=C.join(t,i.name);if(X.existsSync(C.join(o,"package.json"))&&!r.has(o)){r.add(o);let a=$t(e,o);a&&s.push(a)}else Te(e,o,r,s)}}var Ne={type:"npm",detect(e){let t=Pe.join(e,"package.json");if(!Bt.existsSync(t))return null;let r;try{r=JSON.parse(Bt.readFileSync(t,"utf-8")).workspaces}catch{return null}if(!r||Bt.existsSync(Pe.join(e,"yarn.lock")))return null;let s=Array.isArray(r)?r:r.packages??[];return s.length===0?null:D(e,s)}};import L from"fs";import S from"path";var Ie={type:"nx",detect(e){return L.existsSync(S.join(e,"nx.json"))?Me(e,e,new Set,0).map(r=>en(e,r,S.join(r,"project.json"))).filter(r=>r!==null):null}};function Me(e,t,r,s){if(s>4)return[];let n;try{n=L.readdirSync(t,{withFileTypes:!0})}catch{return[]}let i=[];for(let o of n){if(!o.isDirectory())continue;let a=o.name;if(a.startsWith(".")||a==="node_modules"||a==="dist"||a===".nx")continue;let c=S.join(t,a);L.existsSync(S.join(c,"project.json"))&&!r.has(c)?(r.add(c),i.push(c)):i.push(...Me(e,c,r,s+1))}return i}function en(e,t,r){let s={};try{s=JSON.parse(L.readFileSync(r,"utf-8"))}catch{return null}let n=s.name,i,o,a=S.join(t,"package.json");if(L.existsSync(a))try{let c=JSON.parse(L.readFileSync(a,"utf-8"));n=c.name??n,i=c.main,o=c.exports}catch{}return n?{name:n,root:t,relativeRoot:S.relative(e,t),entryPoints:rn(t,s,i,o)}:null}function rn(e,t,r,s){let n=[],i=t.targets?.build?.options?.main??t.targets?.build?.options?.entryFile;if(i){let a=S.resolve(e,"../..");n.push(S.resolve(a,i)),n.push(S.resolve(e,i))}if(s){let a=s;if(typeof a=="string")n.push(S.join(e,a));else if(typeof a=="object"&&a!==null){let c=a["."];typeof c=="string"&&n.push(S.join(e,c))}}if(r&&n.push(S.join(e,r)),t.sourceRoot){let a=S.resolve(e,"../.."),c=S.resolve(a,t.sourceRoot);n.push(S.join(c,"index.ts"),S.join(c,"index.tsx"))}for(let a of["src/index.ts","src/index.tsx","index.ts","index.tsx"])n.push(S.join(e,a));let o=n.filter(dt);return o.length>0?o.slice(0,1):n.slice(0,1)}import Re from"fs";import sn from"path";import{load as nn}from"js-yaml";var Ae={type:"pnpm",detect(e){let t=sn.join(e,"pnpm-workspace.yaml");if(!Re.existsSync(t))return null;let r=[];try{r=nn(Re.readFileSync(t,"utf-8"))?.packages??[]}catch{return null}return D(e,r)}};import on from"fs";import an from"path";var De={type:"turborepo",detect(e){return on.existsSync(an.join(e,"turbo.json"))?[]:null}};import Ut from"fs";import Le from"path";var Ge={type:"yarn",detect(e){if(!Ut.existsSync(Le.join(e,"yarn.lock")))return null;let t=Le.join(e,"package.json");if(!Ut.existsSync(t))return null;let r;try{r=JSON.parse(Ut.readFileSync(t,"utf-8")).workspaces}catch{return null}if(!r)return null;let s=Array.isArray(r)?r:r.packages??[];return s.length===0?null:D(e,s)}};var Oe=[];function F(e){Oe.push(e)}function je(){return Oe}F(De);F(Ie);F(Ae);F(Ge);F(Ne);function Kt(e,t=je()){let r=cn.resolve(e),s=new Map,n=[];for(let o of t){let a=o.detect(r);if(a!==null){n.push(o.type);for(let c of a)s.has(c.name)||s.set(c.name,c)}}if(n.length===0)return{root:r,type:"none",types:[],packages:[],packageMap:new Map};let i=Array.from(s.values());return{root:r,type:n[0],types:n,packages:i,packageMap:new Map(i.map(o=>[o.name,o]))}}var Y=class e{constructor(t,r){this.monorepoRoot=t;this.type=r}monorepoRoot;type;packages=new Map;addPackage(t,r){this.packages.set(t.name,{graph:r,pkg:t})}getPackageForFile(t){for(let{pkg:r}of this.packages.values())if(t===r.relativeRoot||t.startsWith(`${r.relativeRoot}/`))return r}getPackageDependencies(){let t=new Map;for(let{graph:r,pkg:s}of this.packages.values()){let n=new Set;for(let i of r.nodes.values())for(let o of i.imports)o.isWorkspace&&o.workspacePackage&&n.add(o.workspacePackage);t.set(s.name,[...n])}return t}getAffectedAcrossPackages(t){let r=this.getPackageForFile(t);if(!r)return[];let s=this.packages.get(r.name);if(!s)return[];let n=[];s.graph.traverse(t,i=>(i.path!==t&&n.push({file:i.path,package:r.name}),!0),{direction:"incoming"});for(let{graph:i,pkg:o}of this.packages.values())if(o.name!==r.name)for(let a of i.nodes.values())a.imports.some(p=>p.isWorkspace&&p.workspacePackage===r.name)&&n.push({file:a.path,package:o.name});return n}serialize(){return{monorepoRoot:this.monorepoRoot,type:this.type,packages:Array.from(this.packages.values()).map(({graph:t,pkg:r})=>({pkg:{name:r.name,relativeRoot:r.relativeRoot,entryPoints:r.entryPoints},nodes:Array.from(t.nodes.values())}))}}static deserialize(t){let r=new e(t.monorepoRoot,t.type);for(let{pkg:s,nodes:n}of t.packages){let i=new Map(n.map(a=>[a.path,a])),o=new I(i);r.packages.set(s.name,{graph:o,pkg:{...s,root:""}})}return r}};var _e=new Map;function G(e,t){_e.set(e,t)}function We(e){return _e.get(e)}function ze(e,t){return t.startsWith("!")?e!==t.slice(1):e===t}function pn(e,t){return t.startsWith("!")?!e.includes(t.slice(1)):e.includes(t)}var ln=(e,t)=>!t.category||ze(e.category,t.category),fn=(e,t)=>!t.type||ze(e.type,t.type),mn=(e,t)=>t.lastAuthor?t.lastAuthor.startsWith("!")?e.lastAuthor!==t.lastAuthor.slice(1):e.lastAuthor!==void 0&&e.lastAuthor===t.lastAuthor:!0,un=(e,t)=>!t.path||pn(e.path,t.path),gn=(e,t)=>t.isExternal===void 0?!0:e.imports.some(s=>s.isExternal)===t.isExternal,dn=(e,t)=>{if(!t.tags||t.tags.length===0)return!0;let r=t.tags.filter(n=>!n.startsWith("!")),s=t.tags.filter(n=>n.startsWith("!")).map(n=>n.slice(1));return!(r.length>0&&!r.some(n=>e.tags.some(i=>i.name===n))||s.some(n=>e.tags.some(i=>i.name===n)))},hn=(e,t)=>!t.allTags?.length||t.allTags.every(r=>e.tags.some(s=>s.name===r)),yn=(e,t)=>!t.importsFile||e.imports.some(r=>r.toPath?.includes(t.importsFile)),xn=(e,t,r)=>t.importedBy===void 0?!0:(r?.get(e.path)??[]).some(n=>n.includes(t.importedBy)),Sn=(e,t)=>t.minImports===void 0||e.imports.length>=t.minImports,bn=(e,t)=>t.maxImports===void 0||e.imports.length<=t.maxImports,vn=(e,t)=>t.minSize===void 0||e.size>=t.minSize,En=(e,t)=>t.maxSize===void 0||e.size<=t.maxSize,Cn=(e,t)=>t.hasDocstring===void 0||!!e.description===t.hasDocstring,kn=(e,t)=>t.isDocumented===void 0||!!e.documentedBy?.length===t.isDocumented,wn=(e,t)=>t.isStale===void 0||!!e.staleFor?.length===t.isStale,Fn=(e,t)=>t.minCoverage===void 0||(e.coveragePct??101)>=t.minCoverage,Tn=(e,t)=>t.maxCoverage===void 0||(e.coveragePct??0)<=t.maxCoverage,Pn=(e,t)=>t.minExportUsage===void 0||(e.avgExportUsage??-1)>=t.minExportUsage,Nn=(e,t)=>t.maxExportUsage===void 0||(e.avgExportUsage??0)<=t.maxExportUsage,In=(e,t)=>t.minComplexity===void 0||(e.complexity??-1/0)>=t.minComplexity,Mn=(e,t)=>t.maxComplexity===void 0||(e.complexity??0)<=t.maxComplexity,Rn=(e,t)=>t.minCognitiveComplexity===void 0||(e.cognitiveComplexity??-1/0)>=t.minCognitiveComplexity,An=(e,t)=>t.maxCognitiveComplexity===void 0||(e.cognitiveComplexity??0)<=t.maxCognitiveComplexity,Dn=(e,t)=>t.minCommits===void 0||(e.commitCount90d??-1/0)>=t.minCommits,Ln=(e,t)=>t.maxCommits===void 0||(e.commitCount90d??0)<=t.maxCommits,Gn=(e,t,r)=>!t.any?.length||t.any.some(s=>Z(e,s,r)),On=[ln,fn,mn,un,gn,dn,hn,yn,xn,Sn,bn,vn,En,Cn,kn,wn,Fn,Tn,Pn,Nn,In,Mn,Rn,An,Dn,Ln,Gn];function Z(e,t,r){return On.every(s=>s(e,t,r))}function $e(e,t){let r=new Map;if(t.importedBy!==void 0){for(let o of e.nodes)for(let a of o.imports)if(a.toPath){let c=r.get(a.toPath)??[];c.push(o.path),r.set(a.toPath,c)}}let s=e.nodes.filter(o=>Z(o,t,r)),n=new Set(s.map(o=>o.path)),i=s.map(o=>({...o,imports:o.imports.filter(a=>!a.toPath||n.has(a.toPath))}));if(t.sort){let o=t.sortDir==="asc"?-1:1;i.sort((a,c)=>{let p=0;return t.sort==="size"?p=c.size-a.size:t.sort==="imports"?p=c.imports.length-a.imports.length:t.sort==="commitCount90d"?p=(c.commitCount90d??0)-(a.commitCount90d??0):t.sort==="exportUsage"?p=(c.avgExportUsage??0)-(a.avgExportUsage??0):t.sort==="complexity"?p=(c.complexity??0)-(a.complexity??0):t.sort==="cognitiveComplexity"&&(p=(c.cognitiveComplexity??0)-(a.cognitiveComplexity??0)),p*o})}return t.limit!==void 0&&i.splice(t.limit),{nodes:i,cycles:e.cycles?.filter(o=>o.every(a=>n.has(a)))??void 0}}function Be(e,t){let r=t.indexOf(":");if(r===-1)return;let s=t.slice(0,r).trim().toLowerCase(),n=t.slice(r+1).trim();if(!(!s||!n))switch(s){case"category":e.category=n;break;case"type":e.type=n;break;case"tag":case"tags":n.includes("+")?e.allTags=[...e.allTags??[],...n.split("+")]:e.tags=[...e.tags??[],n];break;case"path":e.path=n;break;case"external":e.isExternal=n.toLowerCase()==="true";break;case"importsfile":e.importsFile=n;break;case"importedby":e.importedBy=n;break;case"minimports":e.minImports=parseInt(n,10);break;case"maximports":e.maxImports=parseInt(n,10);break;case"minsize":e.minSize=parseInt(n,10);break;case"maxsize":e.maxSize=parseInt(n,10);break;case"sort":e.sort=n;break;case"sortdir":e.sortDir=n.toLowerCase()==="asc"?"asc":"desc";break;case"limit":e.limit=parseInt(n,10);break;case"hasdocstring":e.hasDocstring=n.toLowerCase()!=="false";break;case"mincoverage":e.minCoverage=parseInt(n,10);break;case"maxcoverage":e.maxCoverage=parseInt(n,10);break;case"minexportusage":e.minExportUsage=parseFloat(n);break;case"maxexportusage":e.maxExportUsage=parseFloat(n);break;case"mincomplexity":e.minComplexity=parseInt(n,10);break;case"maxcomplexity":e.maxComplexity=parseInt(n,10);break;case"mincognitivecomplexity":e.minCognitiveComplexity=parseInt(n,10);break;case"maxcognitivecomplexity":e.maxCognitiveComplexity=parseInt(n,10);break;case"mincommits":e.minCommits=parseInt(n,10);break;case"maxcommits":e.maxCommits=parseInt(n,10);break;case"isdocumented":e.isDocumented=n.toLowerCase()!=="false";break;case"isstale":e.isStale=n.toLowerCase()!=="false";break;case"lastauthor":e.lastAuthor=n;break}}function jn(e){let t=[];for(let r of e.split("|")){let s=r.trim();if(!s)continue;let n={};Be(n,s),Object.keys(n).length>0&&t.push(n)}return t}function Ue(e){let t={},r=e.split(",");for(let s of r){let n=s.trim();if(n.toLowerCase().startsWith("any(")&&n.endsWith(")")){let i=n.slice(4,-1),o=jn(i);o.length>0&&(t.any=[...t.any??[],...o]);continue}Be(t,s)}return t}import rr from"fs/promises";import ci from"path";import Yt from"path";import Ct from"typescript";import Je from"path";import He from"typescript";import v from"typescript";var Ke=new Set(["describe","test","it"]);function O(e){let t=[];for(let r of e.statements){if(!v.isExpressionStatement(r))continue;let s=r.expression;if(!v.isCallExpression(s))continue;let n=s.expression;v.isIdentifier(n)&&Ke.has(n.text)&&t.push(s),v.isPropertyAccessExpression(n)&&v.isIdentifier(n.expression)&&Ke.has(n.expression.text)&&t.push(s)}return t}function j(e,t,r){for(let s of e.arguments){if(!v.isObjectLiteralExpression(s))continue;let n=s.properties.find(i=>v.isPropertyAssignment(i)&&v.isIdentifier(i.name)&&i.name.text===t);if(!(!n||!v.isArrayLiteralExpression(n.initializer)))return n.initializer.elements.filter(v.isStringLiteral).map(i=>i.text)}return null}function _(e,t,r,s){if(e.arguments.length===0)return null;for(let i=1;i<e.arguments.length;i++){let o=e.arguments[i];if(!v.isObjectLiteralExpression(o))continue;let a=o.properties.find(p=>v.isPropertyAssignment(p)&&v.isIdentifier(p.name)&&p.name.text===t);if(a)return{start:a.initializer.getStart(s),end:a.initializer.getEnd(),text:r};let c=o.getEnd()-1;return{start:c,end:c,text:`${o.properties.length>0?", ":""}${t}: ${r}`}}let n=e.arguments[e.arguments.length-1];return{start:n.getStart(s),end:n.getStart(s),text:`{ ${t}: ${r} }, `}}function W(e,t,r){let s=e.arguments;for(let n=1;n<s.length;n++){let i=s[n];if(!v.isObjectLiteralExpression(i))continue;let o=i.properties.findIndex(c=>v.isPropertyAssignment(c)&&v.isIdentifier(c.name)&&c.name.text===t);if(o<0)continue;if(i.properties.length===1)return{start:s[n-1].getEnd(),end:i.getEnd(),text:""};let a=i.properties[o];return o===i.properties.length-1?{start:i.properties[o-1].getEnd(),end:a.getEnd(),text:""}:{start:a.getStart(r),end:i.properties[o+1].getStart(r),text:""}}return null}function z(e,t){let r=[...t].sort((n,i)=>i.start-n.start),s=e;for(let n of r)s=s.slice(0,n.start)+n.text+s.slice(n.end);return s}function $(e){return`[${e.map(t=>JSON.stringify(t)).join(", ")}]`}var w=new Set([".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"]);function _n(e){return $(e.map(t=>`@${t}`))}function Wn(e){return e.map(t=>t.startsWith("@")?t.slice(1):t)}var ht=class{name="cypress";canHandle(t){return w.has(Je.extname(t).toLowerCase())}apply(t,r,s){let n=He.createSourceFile(Je.basename(t),r,He.ScriptTarget.Latest,!0),i=O(n);if(i.length===0)return r;let o=j(i[0],"tags",n),a=[...s].sort();if(o!==null&&JSON.stringify(Wn(o).sort())===JSON.stringify(a))return r;let c=i.flatMap(p=>{let g=s.length===0?W(p,"tags",n):_(p,"tags",_n(a),n);return g?[g]:[]});return c.length>0?z(r,c):r}};import zn from"path";var Jt=/# <mokosh-tags>[\s\S]*?# <\/mokosh-tags>\n*/,Ht=/^@([a-zA-Z0-9_-]+)/gm;function $n(e){return["# <mokosh-tags>",...e.map(t=>`@${t}`),"# </mokosh-tags>"].join(`
3
3
  `)+`
4
4
 
5
- `}function _n(e){let t=new Set;Jt.lastIndex=0;let r=Jt.exec(e);for(;r!==null;)r[1]&&t.add(r[1]),r=Jt.exec(e);return t}var ht=class{name="gherkin";canHandle(t){return On.extname(t).toLowerCase()===".feature"}apply(t,r,s){let n=r.replace(Kt,""),i=_n(n),o=s.filter(c=>!i.has(c)),a=o.length>0?jn(o):"";return Kt.test(r)?r.replace(Kt,a):a?r.replace(/^(Feature:)/m,`${a}$1`):r}};function He(e,t){let r=e.replace(/\\/g,"/"),s=t.replace(/\\/g,"/"),n="";for(let i=0;i<r.length;i++){let o=r[i];o==="*"?r[i+1]==="*"?(n+=".*",i++):n+="[^/]*":o==="?"?n+="[^/]":o!==void 0&&(n+=o.replace(/[.+^${}()|[\]\\]/g,"\\$&"))}return new RegExp(`^${n}$`).test(s)}import Wn from"path";var Ht=/^\/\/go:build mokosh_[^\n]+\n/m,$n=/^package\s+\S+/m;function zn(e){return`//go:build ${e.map(r=>`mokosh_${r}`).join(" || ")}
6
- `}function Bn(e){let t=Ht.exec(e);if(!t)return null;let r=t[0],s=/mokosh_([a-zA-Z0-9_-]+)/g,n=[],i=s.exec(r);for(;i!==null;)i[1]&&n.push(i[1]),i=s.exec(r);return n}var yt=class{name="go";canHandle(t){return Wn.basename(t).endsWith("_test.go")}apply(t,r,s){let n=Bn(r),i=[...s].sort();if(n!==null&&JSON.stringify([...n].sort())===JSON.stringify(i))return r;if(s.length===0)return r.replace(Ht,"");let o=zn(i);if(n!==null)return r.replace(Ht,o);let a=$n.exec(r);if(!a)return r;let c=a.index;return r.slice(0,c)+o+`
7
- `+r.slice(c)}};import Un from"path";var Kn=/^\/\*\*\n(?: \* @group .+\n)+ \*\/\n+/,Qt=/^ \* @group (.+)$/gm;function Jn(e){return["/**",...e.map(t=>` * @group ${t}`)," */"].join(`
5
+ `}function Bn(e){let t=new Set;Ht.lastIndex=0;let r=Ht.exec(e);for(;r!==null;)r[1]&&t.add(r[1]),r=Ht.exec(e);return t}var yt=class{name="gherkin";canHandle(t){return zn.extname(t).toLowerCase()===".feature"}apply(t,r,s){let n=r.replace(Jt,""),i=Bn(n),o=s.filter(c=>!i.has(c)),a=o.length>0?$n(o):"";return Jt.test(r)?r.replace(Jt,a):a?r.replace(/^(Feature:)/m,`${a}$1`):r}};function Ve(e,t){let r=e.replace(/\\/g,"/"),s=t.replace(/\\/g,"/"),n="";for(let i=0;i<r.length;i++){let o=r[i];o==="*"?r[i+1]==="*"?(n+=".*",i++):n+="[^/]*":o==="?"?n+="[^/]":o!==void 0&&(n+=o.replace(/[.+^${}()|[\]\\]/g,"\\$&"))}return new RegExp(`^${n}$`).test(s)}import Un from"path";var Vt=/^\/\/go:build mokosh_[^\n]+\n/m,Kn=/^package\s+\S+/m;function Jn(e){return`//go:build ${e.map(r=>`mokosh_${r}`).join(" || ")}
6
+ `}function Hn(e){let t=Vt.exec(e);if(!t)return null;let r=t[0],s=/mokosh_([a-zA-Z0-9_-]+)/g,n=[],i=s.exec(r);for(;i!==null;)i[1]&&n.push(i[1]),i=s.exec(r);return n}var xt=class{name="go";canHandle(t){return Un.basename(t).endsWith("_test.go")}apply(t,r,s){let n=Hn(r),i=[...s].sort();if(n!==null&&JSON.stringify([...n].sort())===JSON.stringify(i))return r;if(s.length===0)return r.replace(Vt,"");let o=Jn(i);if(n!==null)return r.replace(Vt,o);let a=Kn.exec(r);if(!a)return r;let c=a.index;return r.slice(0,c)+o+`
7
+ `+r.slice(c)}};import Vn from"path";var Qn=/^\/\*\*\n(?: \* @group .+\n)+ \*\/\n+/,Qt=/^ \* @group (.+)$/gm;function Xn(e){return["/**",...e.map(t=>` * @group ${t}`)," */"].join(`
8
8
  `)+`
9
9
 
10
- `}function Hn(e){let t=[];Qt.lastIndex=0;let r=Qt.exec(e);for(;r!==null;)r[1]&&t.push(r[1]),r=Qt.exec(e);return t}var xt=class{name="jest";canHandle(t){return F.has(Un.extname(t).toLowerCase())}apply(t,r,s){let n=Kn.exec(r),i=n?Hn(n[0]):null,o=[...s].sort();if(i!==null&&JSON.stringify([...i].sort())===JSON.stringify(o))return r;let a=n?r.slice(n[0].length):r;return s.length===0?a:Jn(o)+a}};import Qe from"path";import Ve from"typescript";function Qn(e){return W(e.map(t=>`@${t}`))}function Vn(e){return e.map(t=>t.startsWith("@")?t.slice(1):t)}var St=class{name="playwright";canHandle(t){return F.has(Qe.extname(t).toLowerCase())}apply(t,r,s){let n=Ve.createSourceFile(Qe.basename(t),r,Ve.ScriptTarget.Latest,!0),i=L(n);if(i.length===0)return r;let o=G(i[0],"tag",n),a=[...s].sort();if(o!==null&&JSON.stringify(Vn(o).sort())===JSON.stringify(a))return r;let c=i.flatMap(p=>{let g=s.length===0?j(p,"tag",n):O(p,"tag",Qn(a),n);return g?[g]:[]});return c.length>0?_(r,c):r}};import Xn from"path";var Vt=/^pytestmark\s*=\s*.+$/m,Yn=/^import pytest\s*$/m;function Zn(e){let t=e.map(r=>`pytest.mark.${r}`).join(", ");return e.length===1?`pytestmark = pytest.mark.${e[0]}`:`pytestmark = [${t}]`}function qn(e){let t=Vt.exec(e);if(!t)return null;let r=t[0],s=[],n=/pytest\.mark\.([a-zA-Z0-9_-]+)/g,i=n.exec(r);for(;i!==null;)i[1]&&s.push(i[1]),i=n.exec(r);return s}var bt=class{name="pytest";canHandle(t){return Xn.extname(t).toLowerCase()===".py"}apply(t,r,s){let n=qn(r),i=[...s].sort();if(n!==null&&JSON.stringify([...n].sort())===JSON.stringify(i))return r;if(s.length===0)return r.replace(Vt,"").replace(/\n{3,}/g,`
10
+ `}function Yn(e){let t=[];Qt.lastIndex=0;let r=Qt.exec(e);for(;r!==null;)r[1]&&t.push(r[1]),r=Qt.exec(e);return t}var St=class{name="jest";canHandle(t){return w.has(Vn.extname(t).toLowerCase())}apply(t,r,s){let n=Qn.exec(r),i=n?Yn(n[0]):null,o=[...s].sort();if(i!==null&&JSON.stringify([...i].sort())===JSON.stringify(o))return r;let a=n?r.slice(n[0].length):r;return s.length===0?a:Xn(o)+a}};import Qe from"path";import Xe from"typescript";function Zn(e){return $(e.map(t=>`@${t}`))}function qn(e){return e.map(t=>t.startsWith("@")?t.slice(1):t)}var bt=class{name="playwright";canHandle(t){return w.has(Qe.extname(t).toLowerCase())}apply(t,r,s){let n=Xe.createSourceFile(Qe.basename(t),r,Xe.ScriptTarget.Latest,!0),i=O(n);if(i.length===0)return r;let o=j(i[0],"tag",n),a=[...s].sort();if(o!==null&&JSON.stringify(qn(o).sort())===JSON.stringify(a))return r;let c=i.flatMap(p=>{let g=s.length===0?W(p,"tag",n):_(p,"tag",Zn(a),n);return g?[g]:[]});return c.length>0?z(r,c):r}};import ti from"path";var Xt=/^pytestmark\s*=\s*.+$/m,ei=/^import pytest\s*$/m;function ri(e){let t=e.map(r=>`pytest.mark.${r}`).join(", ");return e.length===1?`pytestmark = pytest.mark.${e[0]}`:`pytestmark = [${t}]`}function si(e){let t=Xt.exec(e);if(!t)return null;let r=t[0],s=[],n=/pytest\.mark\.([a-zA-Z0-9_-]+)/g,i=n.exec(r);for(;i!==null;)i[1]&&s.push(i[1]),i=n.exec(r);return s}var vt=class{name="pytest";canHandle(t){return ti.extname(t).toLowerCase()===".py"}apply(t,r,s){let n=si(r),i=[...s].sort();if(n!==null&&JSON.stringify([...n].sort())===JSON.stringify(i))return r;if(s.length===0)return r.replace(Xt,"").replace(/\n{3,}/g,`
11
11
 
12
- `);let o=Zn(i);if(n!==null)return r.replace(Vt,o);let a=Yn.test(r),c=ti(r),p=r.slice(0,c),g=r.slice(c),u=a?"":`import pytest
12
+ `);let o=ri(i);if(n!==null)return r.replace(Xt,o);let a=ei.test(r),c=ni(r),p=r.slice(0,c),g=r.slice(c),u=a?"":`import pytest
13
13
  `,y=p.endsWith(`
14
14
 
15
15
  `)?"":`
16
16
  `;return p+y+u+o+`
17
- `+g}};function ti(e){let t=e.split(`
18
- `),r=-1;for(let n=0;n<t.length;n++){let i=t[n].trimStart();(i.startsWith("import ")||i.startsWith("from "))&&(r=n)}if(r<0)return 0;let s=0;for(let n=0;n<=r;n++)s+=t[n].length+1;return s}import Xe from"path";import Ye from"typescript";var ei=/\/\/ <mokosh-tags>[\s\S]*?\/\/ <\/mokosh-tags>\n*/,vt=class{name="vitest";canHandle(t){return F.has(Xe.extname(t).toLowerCase())}apply(t,r,s){let n=r.replace(ei,""),i=Ye.createSourceFile(Xe.basename(t),n,Ye.ScriptTarget.Latest,!0),o=L(i);if(o.length===0)return n;let a=G(o[0],"tags",i),c=[...s].sort();if(a!==null&&JSON.stringify([...a].sort())===JSON.stringify(c))return n;let p=o.flatMap(g=>{let u=s.length===0?j(g,"tags",i):O(g,"tags",W(c),i);return u?[u]:[]});return p.length>0?_(n,p):n}};var Ze={vitest:()=>new vt,playwright:()=>new St,cypress:()=>new dt,jest:()=>new xt},ri={"@playwright/test":"playwright",cypress:"cypress","@jest/globals":"jest",vitest:"vitest"};function si(e){let t=kt.createSourceFile("detect.ts",e,kt.ScriptTarget.Latest,!0);for(let r of t.statements){if(!kt.isImportDeclaration(r)||!kt.isStringLiteral(r.moduleSpecifier))continue;let s=ri[r.moduleSpecifier.text];if(s)return s}return null}var Yt=class{constructor(t,r,s){this.rootDir=t;this.defaultFramework=r;this.frameworkOverrides=s}rootDir;defaultFramework;frameworkOverrides;name="auto";canHandle(t){return F.has(Xt.extname(t).toLowerCase())}apply(t,r,s){let n=si(r)??this.matchOverride(t)??this.defaultFramework;return(Ze[n]??Ze.vitest)().apply(t,r,s)}matchOverride(t){let r=Xt.relative(this.rootDir,t).split(Xt.sep).join("/");for(let[s,n]of this.frameworkOverrides)if(He(s,r))return n;return null}};function qe(e="vitest",t={},r=process.cwd()){return[new ht,new bt,new yt,new Yt(r,e,Object.entries(t))]}function tr(e,t){return t.find(r=>r.canHandle(e))??null}var ii=/^[a-zA-Z][a-zA-Z0-9_-]{1,}$/,oi=new Set(["import"]),ai=new Set(["common","fixture","fixtures","helper","helpers","index","main","mock","mocks","setup","shared","spec","test","tests","types","util","utils"]);async function ci(e,t,r,s){let n;try{n=await er.readFile(e,"utf8")}catch(a){return{path:e,status:"error",error:String(a)}}let i=tr(e,s);if(!i)return{path:e,status:"unchanged"};let o=i.apply(e,n,t);return o===n?{path:e,status:"unchanged"}:(r||await er.writeFile(e,o,"utf8"),{path:e,status:"updated"})}async function pi(e,t,r){let s=At(t),n=s.tagApplier?.framework??"vitest",i=s.tagApplier?.frameworkOverrides??{},o=qe(n,i,t),a={updated:0,unchanged:0,errors:0,files:[]};for(let c of e.nodes.values()){if(c.category!=="test")continue;let p=new Set,g=[];for(let b of c.tags)oi.has(b.kind)&&ii.test(b.name)&&(ai.has(b.name.toLowerCase())||p.has(b.name)||(p.add(b.name),g.push(b.name)));g.sort();let u=ni.resolve(t,c.path),y=await ci(u,g,r.dryRun,o);y.path=c.path,a.files.push(y),y.status==="updated"?a.updated++:y.status==="unchanged"?a.unchanged++:a.errors++}return a}var Ct=class{isTestNode(t){return t.category==="test"||t.tags.some(r=>r.name==="test")}};import it from"fs";import k from"path";import Xo from"piscina";import{execFileSync as rr}from"child_process";var sr="%x00%H%x09%ae%x09%at",nr=256*1024*1024;function ir(e,t){let r="",s=0;for(let n of e.split(`
19
- `)){if(n.startsWith("\0")){let[,c,p]=n.slice(1).split(" ");r=c??"",s=p?Number(p)*1e3:0;continue}if(n==="")continue;let i=n.split(" "),o=i[0];if(!o)continue;let a=o.startsWith("R")||o.startsWith("C")?i[2]:i[1];a&&t(a,r,s)}}function or(e){let t=new Map;try{let r=rr("git",["-C",e,"log","--since=90 days ago","--name-status","-M",`--format=${sr}`],{encoding:"utf-8",stdio:["ignore","pipe","ignore"],maxBuffer:nr});ir(r,(s,n,i)=>{let o=t.get(s);if(o){o.commitCount90d+=1;return}t.set(s,{commitCount90d:1,lastAuthor:n||void 0,lastCommitAt:i||void 0})})}catch{return t}try{let r=rr("git",["-C",e,"log","--name-status","-M",`--format=${sr}`],{encoding:"utf-8",stdio:["ignore","pipe","ignore"],maxBuffer:nr});ir(r,(s,n,i)=>{t.has(s)||t.set(s,{commitCount90d:0,lastAuthor:void 0,lastCommitAt:i||void 0})})}catch{}return t}import Et from"fs";import li from"path";import{load as ar}from"js-yaml";function cr(e){let t=e.lastIndexOf("@");return t>0?e.substring(0,t):e}function mi(e){return e.replace(/:$/,"").split(",").map(t=>{let r=t.trim();return r.startsWith('"')&&(r=r.slice(1)),r.endsWith('"')&&(r=r.slice(0,-1)),cr(r)}).filter(Boolean)}function fi(e,t){let r=e.startsWith("/")?e.slice(1):e,s=r.lastIndexOf("@");return s>0?{name:r.substring(0,s),version:t||r.substring(s+1)}:{name:r,version:t}}function ui(e){try{let t=ar(e),r={dependencies:{}};for(let[s,n]of Object.entries(t))if(!(s==="__metadata"||!n?.version))for(let i of s.split(", ")){let o=cr(i);o&&(r.dependencies[o]={version:n.version,...n.dependencies!==void 0&&{dependencies:n.dependencies}})}return r}catch{return null}}function gi(e){let t={dependencies:{}};for(let r of e.split(/\n\n+/)){let s=r.split(`
20
- `).filter(c=>c.trim().length>0&&!c.trim().startsWith("#"));if(s.length<2)continue;let n=s[0];if(!n||n.startsWith(" "))continue;let i=mi(n);if(i.length===0)continue;let a=s.find(c=>c.trim().startsWith('version "'))?.match(/version "(.*?)"/)?.[1]??"";for(let c of i)t.dependencies[c]={version:a}}return t}function di(e){let t=Et.readFileSync(e,"utf-8"),r=JSON.parse(t),s={dependencies:{}};if(r.packages)for(let[n,i]of Object.entries(r.packages)){if(!n.startsWith("node_modules/"))continue;let o=n.replace("node_modules/","");o.includes("node_modules/")||(s.dependencies[o]={version:i.version,...i.dependencies!==void 0&&{dependencies:i.dependencies}})}else if(r.dependencies)for(let[n,i]of Object.entries(r.dependencies))s.dependencies[n]={version:i.version,...i.dependencies!==void 0&&{dependencies:i.dependencies}};return s}function hi(e){let t=Et.readFileSync(e,"utf-8");if(t.includes("__metadata:")){let r=ui(t);if(r!==null)return r}return gi(t)}function yi(e){let t=Et.readFileSync(e,"utf-8"),r={dependencies:{}};try{let s=ar(t);if(s.packages)for(let[n,i]of Object.entries(s.packages)){let{name:o,version:a}=fi(n,i.version);o&&(r.dependencies[o]={version:a,...i.dependencies!==void 0&&{dependencies:i.dependencies}})}if(s.dependencies)for(let[n,i]of Object.entries(s.dependencies)){if(r.dependencies[n])continue;let o=typeof i=="string"?i:i.version;r.dependencies[n]={version:o||""}}}catch{}return r}function pr(e){let t=[["package-lock.json",di],["yarn.lock",hi],["pnpm-lock.yaml",yi]];for(let[r,s]of t){let n=li.join(e,r);if(Et.existsSync(n))return s(n)}return null}import lr from"path";function P(e){switch(lr.extname(e).toLowerCase()){case".js":case".jsx":case".mjs":case".cjs":return"javascript";case".ts":case".tsx":return"typescript";case".css":return"css";case".scss":case".sass":return"scss";case".less":return"less";case".styl":return"stylus";case".coffee":return"coffeescript";case".ls":return"livescript";case".lua":return"lua";case".py":return"python";case".go":return"go";case".java":case".cpp":case".cc":case".cxx":case".c":return"unknown";case".feature":return"gherkin";case".md":case".mdx":return"markdown";default:return"unknown"}}function E(e){let t=lr.extname(e).toLowerCase();return[".css",".scss",".sass",".less",".styl"].includes(t)}import xi from"coffeescript";function Si(e){let t=new Set,r=/@tag\s+([a-zA-Z0-9_-]+)/g,s=r.exec(e);for(;s!==null;)s[1]&&t.add(s[1]),s=r.exec(e);return t}function bi(e,t){let r=e.toLowerCase();return r.includes(".test.")||r.includes(".spec.")||t.has("test")?"test":"logic"}function vi(e,t){let r=t.source?.value;return r?{fromPath:e,toPath:"",rawSpecifier:r,isStyle:E(r),type:"static"}:null}function ki(e,t){let r=t.variable?.base?.value==="require",s=t.args?.[0]?.base?.value;return!r||!s?null:{fromPath:e,toPath:"",rawSpecifier:s,isStyle:E(s),type:"require"}}function Ci(e,t,r){let s=t.constructor?.name;if(s==="ImportDeclaration"){let n=vi(e,t);n&&r.push(n)}else if(s==="Call"){let n=ki(e,t);n&&r.push(n)}}function Zt(e,t,r){if(!(!t||typeof t!="object")){Ci(e,t,r);for(let s in t){if(s==="locationData")continue;let n=t[s];if(!(!n||typeof n!="object"))if(Array.isArray(n))for(let i of n)Zt(e,i,r);else Zt(e,n,r)}}}function mr(e,t){let r=Si(t),s=bi(e,r),n=[];try{Zt(e,xi.nodes(t),n)}catch{}return{imports:n,exports:[],tags:Array.from(r).map(i=>({name:i,kind:"comment-marker"})),category:s}}import{AstBuilder as Ei,GherkinClassicTokenMatcher as Fi,Parser as wi}from"@cucumber/gherkin";import{IdGenerator as Pi}from"@cucumber/messages";var Ti=Pi.uuid();function qt(e,t){let r=new Set;try{let s=new Ei(Ti),n=new Fi,o=new wi(s,n).parse(t);o.feature&&(o.feature.tags.forEach(a=>{r.add(a.name.startsWith("@")?a.name.slice(1):a.name)}),o.feature.children.forEach(a=>{a.scenario&&(a.scenario.tags.forEach(c=>{r.add(c.name.startsWith("@")?c.name.slice(1):c.name)}),a.scenario.examples.forEach(c=>{c.tags.forEach(p=>{r.add(p.name.startsWith("@")?p.name.slice(1):p.name)})})),a.rule&&a.rule.children.forEach(c=>{c.scenario&&c.scenario.tags.forEach(p=>{r.add(p.name.startsWith("@")?p.name.slice(1):p.name)})})}))}catch(s){console.warn(`[GherkinParser] Failed to parse ${e}:`,s)}return{imports:[],exports:[],tags:Array.from(r).map(s=>({name:s,kind:"comment-marker"})),category:"test"}}D("gherkin",qt);import Ii from"path";import{parser as Mi}from"@lezer/go";var Ni=/\/\/\s*@tag\s+([a-zA-Z0-9_-]+)/,Ri=/^\/\/go:build\s+(.+)$/,Ai=/^\/\/\s*\+build\s+(.+)$/;function ur(e,t){let r=[],s=new Map,n=new Set,i=new Set,a=Mi.parse(t).cursor();do switch(a.name){case"LineComment":{let u=t.slice(a.from,a.to),y=u.match(Ni);y?.[1]&&n.add(y[1]);let b=u.match(Ri);b&&fr(b[1],i);let B=u.match(Ai);B&&fr(B[1],i);break}case"ImportSpec":{let u=a.node.getChild("String");if(u){let b=t.slice(u.from,u.to).slice(1,-1);r.push({fromPath:e,toPath:"",rawSpecifier:b,isExternal:!0,isStyle:!1,type:"static"})}break}case"FunctionDecl":case"TypeDecl":case"VarDecl":case"ConstDecl":{let u=a.node.getChild("DefName")??a.node.getChild("TypeSpec")?.getChild("DefName")??a.node.getChild("VarSpec")?.getChild("DefName")??a.node.getChild("ConstSpec")?.getChild("DefName");if(u){let y=t.slice(u.from,u.to);y!=="_"&&/^[A-Z]/.test(y)&&!s.has(y)&&s.set(y,{name:y})}break}}while(a.next());let c=r.some(u=>u.rawSpecifier==="testing"),p=Ii.basename(e).endsWith("_test.go")||n.has("test")||c?"test":"logic",g=new Set([...n,...i]);return{imports:r,exports:Array.from(s.values()),tags:Array.from(g).map(u=>({name:u,kind:"comment-marker"})),category:p}}function fr(e,t){for(let r of e.split(/[\s,&|!()]+/)){let s=r.trim();s&&s!=="ignore"&&t.add(s)}}import Di from"livescript";function $(e){return e.startsWith("'")||e.startsWith('"')?e.slice(1,-1):e}function Li(e){let t=new Set,r=/@tag\s+([a-zA-Z0-9_-]+)/g,s=r.exec(e);for(;s!==null;)s[1]&&t.add(s[1]),s=r.exec(e);return t}function Gi(e,t){let r=e.toLowerCase();return r.includes(".test.")||r.includes(".spec.")||t.has("test")?"test":"logic"}var Oi=new Set(["first_line","first_column","last_line","last_column","line","column"]);function ji(e,t){let r=e.constructor?.name||e.type;if(r==="Import"){let s=e.right?.value;if(typeof s=="string"){let n=$(s);return{fromPath:t,toPath:"",rawSpecifier:n,isStyle:E(n),type:"static"}}}if(r==="Chain"&&e.head?.value==="require"){let s=e.tails?.[0];if(s?.constructor?.name==="Call"||s?.type==="Call"){let n=s.args?.[0]?.value;if(typeof n=="string"){let i=$(n);return{fromPath:t,toPath:"",rawSpecifier:i,isStyle:E(i),type:"require"}}}}return null}function te(e,t){if(!e||typeof e!="object")return[];let r=[],s=ji(e,t);s&&r.push(s);for(let n in e){if(Oi.has(n))continue;let i=e[n];if(!(!i||typeof i!="object"))if(Array.isArray(i))for(let o of i)r.push(...te(o,t));else r.push(...te(i,t))}return r}function gr(e,t){let r=Li(t),s=Gi(e,r),n=[];try{n=te(Di.ast(t),e)}catch{}return{imports:n,exports:[],tags:Array.from(r).map(i=>({name:i,kind:"comment-marker"})),category:s}}import _i from"luaparse";function Wi(e){let t=new Set,r=/@tag\s+([a-zA-Z0-9_-]+)/g,s=r.exec(e);for(;s!==null;)s[1]&&t.add(s[1]),s=r.exec(e);return t}function $i(e,t){let r=e.toLowerCase();return r.includes(".test.")||r.includes(".spec.")||t.has("test")?"test":"logic"}function zi(e,t){let r=[];function s(n){if(!(!n||typeof n!="object")){if((n.type==="CallExpression"||n.type==="StringCallExpression")&&n.base?.type==="Identifier"&&n.base?.name==="require"){let i;if(n.type==="CallExpression"){let o=n.arguments?.[0];o?.type==="StringLiteral"&&(i=$(o.raw))}else if(n.type==="StringCallExpression"){let o=n.argument;o?.type==="StringLiteral"&&(i=$(o.raw))}i&&r.push({fromPath:t,toPath:"",rawSpecifier:i,isStyle:E(i),type:"require"})}for(let i in n){if(i==="loc")continue;let o=n[i];if(o&&typeof o=="object")if(Array.isArray(o))for(let a of o)s(a);else s(o)}}}return s(e),r}function dr(e,t){let r=Wi(t),s=$i(e,r),n=[];try{let i=_i.parse(t);n=zi(i,e)}catch{}return{imports:n,exports:[],tags:Array.from(r).map(i=>({name:i,kind:"comment-marker"})),category:s}}var Bi=["http://","https://","mailto:","//"],Ui="ts|tsx|js|jsx|mjs|cjs|py|go|lua|css|scss|less|styl|coffee|ls|feature|md|mdx|json",Ki=new RegExp(`(?:\\.{1,2}/)?[\\w.-]+(?:/[\\w.-]+)*\\.(?:${Ui})\\b`,"g"),hr;async function Ji(){return hr??=(async()=>{let{unified:e}=await import("unified"),t=(await import("remark-parse")).default;return e().use(t)})(),hr}function Hi(e){let t=e.trim();return t.length===0||t.startsWith("#")||Bi.some(r=>t.startsWith(r))}function Qi(e,t){let r=e.match(Ki);return r?r.map(s=>({fromPath:t,toPath:"",rawSpecifier:s,isStyle:!1,type:"static"})):[]}function yr(e,t,r){if(e.type==="link"&&typeof e.url=="string"&&!Hi(e.url)&&r.push({fromPath:t,toPath:"",rawSpecifier:e.url,isStyle:!1,type:"static"}),(e.type==="code"||e.type==="inlineCode")&&typeof e.value=="string"&&r.push(...Qi(e.value,t)),Array.isArray(e.children))for(let s of e.children)yr(s,t,r)}async function xr(e,t){let s=(await Ji()).parse(t),n=[];yr(s,e,n);let i=new Set;return{imports:n.filter(a=>i.has(a.rawSpecifier)?!1:(i.add(a.rawSpecifier),!0)),exports:[],tags:[],category:"other"}}import Vi from"path";import{parser as Xi}from"@lezer/python";var Yi=new Set(["pytest","unittest","nose","hypothesis"]);function Sr(e,t){let r=[],s=[],n=new Set,i=Vi.basename(e).toLowerCase(),a=Xi.parse(t).cursor();do switch(a.name){case"Comment":{let p=t.slice(a.from,a.to).match(/#\s*@tag\s+([a-zA-Z0-9_-]+)/);p?.[1]&&n.add(p[1]);break}case"ImportStatement":{for(let p of Zi(a.node,t,e))r.push(p);break}case"FunctionDefinition":case"ClassDefinition":{let p=a.node.parent;if(p?.name==="Script"||p?.name==="DecoratedStatement"&&p.parent?.name==="Script"){let u=a.node.getChild("VariableName");u&&s.push({name:t.slice(u.from,u.to)})}break}case"AssignStatement":{if(a.node.parent?.name==="Script"){let p=a.node.firstChild;p?.name==="VariableName"&&s.push({name:t.slice(p.from,p.to)})}break}}while(a.next());let c=ro(i,r,n);return c==="test"&&n.add("test"),{imports:r,exports:s,tags:Array.from(n).map(p=>({name:p,kind:"comment-marker"})),category:c}}function Zi(e,t,r){let s=e.firstChild;return s?s.name==="from"?qi(e,t,r):to(e,t,r):[]}function qi(e,t,r){let s=e.firstChild;if(!s)return[];let n=s.nextSibling;for(;n&&n.name!=="import";)n=n.nextSibling;if(!n)return[];let i=t.slice(s.to,n.from).trim(),o=eo(n.nextSibling,t);if(!o.length)return[];let a=0;for(;a<i.length&&i[a]===".";)a++;let c=i.slice(a);if(a===0)return[Z(r,i,o,!0)];let p=a===1?"./":"../".repeat(a-1);return c?[Z(r,p+c.replace(/\./g,"/"),o,!1)]:o[0]==="*"?[Z(r,p.slice(0,-1),["*"],!1)]:o.map(g=>Z(r,p+g,[g],!1))}function to(e,t,r){let s=[],n=e.firstChild?.nextSibling??null;for(;n;){if(n.name==="VariableName"){let i=t.slice(n.from,n.to);for(;n.nextSibling?.name==="."&&n.nextSibling.nextSibling?.name==="VariableName";)n=n.nextSibling.nextSibling,i+=`.${t.slice(n.from,n.to)}`;n.nextSibling?.name==="as"&&(n=n.nextSibling.nextSibling??n.nextSibling),s.push(Z(r,i,["*"],!0))}n=n.nextSibling}return s}function eo(e,t){let r=[],s=e;for(;s;)s.name==="*"?r.push("*"):s.name==="VariableName"&&(r.push(t.slice(s.from,s.to)),s.nextSibling?.name==="as"&&(s=s.nextSibling.nextSibling??s.nextSibling)),s=s.nextSibling;return r}function Z(e,t,r,s){return{fromPath:e,toPath:"",rawSpecifier:t,isStyle:!1,isExternal:s,type:"static",symbols:r.length>0?r:void 0}}function ro(e,t,r){return e.startsWith("test_")||e.endsWith("_test.py")?"test":e==="conftest.py"||e==="setup.py"?"config":r.has("test")||t.some(s=>Yi.has(s.rawSpecifier))?"test":"logic"}import vr from"path";import l from"typescript";import d from"typescript";function so(e){let t=1;function r(s){switch(s.kind){case d.SyntaxKind.IfStatement:case d.SyntaxKind.ConditionalExpression:case d.SyntaxKind.ForStatement:case d.SyntaxKind.ForInStatement:case d.SyntaxKind.ForOfStatement:case d.SyntaxKind.WhileStatement:case d.SyntaxKind.DoStatement:case d.SyntaxKind.CatchClause:case d.SyntaxKind.CaseClause:t++;break;case d.SyntaxKind.BinaryExpression:{let n=s.operatorToken.kind;(n===d.SyntaxKind.AmpersandAmpersandToken||n===d.SyntaxKind.BarBarToken||n===d.SyntaxKind.QuestionQuestionToken)&&t++;break}}d.forEachChild(s,r)}return r(e),t}function no(e){let t=0;function r(s,n,i){if(d.isIfStatement(s)){t+=i?1:1+n;let a=i?n:n+1;r(s.expression,a,!1),r(s.thenStatement,a,!1),s.elseStatement&&(d.isIfStatement(s.elseStatement)?r(s.elseStatement,n,!0):(t+=1,r(s.elseStatement,n+1,!1)));return}if(d.isForStatement(s)||d.isForInStatement(s)||d.isForOfStatement(s)||d.isWhileStatement(s)||d.isDoStatement(s)||d.isSwitchStatement(s)){t+=1+n,d.forEachChild(s,a=>r(a,n+1,!1));return}if(d.isCatchClause(s)){t+=1+n,d.forEachChild(s,a=>r(a,n,!1));return}if(d.isConditionalExpression(s)&&(t+=1),d.isBinaryExpression(s)){let a=s.operatorToken.kind;(a===d.SyntaxKind.AmpersandAmpersandToken||a===d.SyntaxKind.BarBarToken||a===d.SyntaxKind.QuestionQuestionToken)&&(t+=1)}if(n>0&&(d.isFunctionDeclaration(s)||d.isFunctionExpression(s)||d.isArrowFunction(s))){t+=1+n,d.forEachChild(s,a=>r(a,n+1,!1));return}d.forEachChild(s,a=>r(a,n,!1))}return r(e,0,!1),t}function ee(e){return{complexity:so(e),cognitiveComplexity:no(e)}}import x from"typescript";var re=new Set(["test","describe","it"]);function br(e,t){io(e,t),ao(e,t),co(e,t),po(e,t)}function io(e,t){if((x.isFunctionDeclaration(e)||x.isVariableDeclaration(e))&&e.name&&x.isIdentifier(e.name)&&oo(e)){let r;if(x.isFunctionDeclaration(e))r="function";else{let s=e.initializer;r=s&&(x.isArrowFunction(s)||x.isFunctionExpression(s))?"function":"variable"}t.tags.add({name:e.name.text,kind:r})}}function oo(e){if(x.isFunctionDeclaration(e))return x.isSourceFile(e.parent);let t=e.parent?.parent;return!!t&&x.isSourceFile(t.parent)}function ao(e,t){if(!x.isStringLiteral(e))return;let r=e.text.match(/@[\w-]+/g);if(r)for(let s of r)t.tags.add({name:s.substring(1),kind:"comment-marker"})}function co(e,t){if(!x.isSourceFile(e))return;let r=/@tag\s+([a-zA-Z0-9_-]+)/g,s=e.getFullText(),n=r.exec(s);for(;n!==null;)n[1]&&t.tags.add({name:n[1],kind:"comment-marker"}),n=r.exec(s)}function po(e,t){if(x.isCallExpression(e)&&lo(e.expression))for(let r of e.arguments)x.isObjectLiteralExpression(r)&&mo(r,t)}function lo(e){return x.isIdentifier(e)?re.has(e.text):!!(x.isPropertyAccessExpression(e)&&(re.has(e.name.text)||x.isIdentifier(e.expression)&&re.has(e.expression.text)))}function mo(e,t){for(let r of e.properties){if(!x.isPropertyAssignment(r)||!x.isIdentifier(r.name)||r.name.text!=="tags"&&r.name.text!=="tag")continue;let{initializer:s}=r,n=x.isArrayLiteralExpression(s)?s.elements.filter(x.isStringLiteral):r.name.text==="tag"&&x.isStringLiteral(s)?[s]:[];for(let i of n)t.tags.add({name:i.text.replace(/^@/,""),kind:"comment-marker"})}}function se(e,t,r){let s=[],n=new Map,i=new Set,o=l.createSourceFile(e,t,l.ScriptTarget.Latest,!0,r==="typescript"?l.ScriptKind.TSX:l.ScriptKind.JSX),a={filePath:e,imports:s,exports:n,tags:i,rawCallEdges:[],sourceFile:o,hasUI:!1,hasTypesOnly:!0,totalStatements:0,exportStatements:0},c=ce=>{ho(ce,a),l.forEachChild(ce,c)};c(o);let p=Po(e,a);(p==="test"||p==="barrel")&&i.add({name:p,kind:"comment-marker"}),p!=="test"&&To(a,o);let g=o.statements[0],u=g?Cr(g):void 0,{complexity:y,cognitiveComplexity:b}=ee(o),B=fo(o);return{imports:s,exports:Array.from(n.values()),tags:Array.from(i),category:p,rawCallEdges:a.rawCallEdges??[],complexity:y,cognitiveComplexity:b,...B.length>0?{functions:B}:{},...u!==void 0?{description:u}:{}}}function fo(e){let t=[],r=(n,i)=>{let{complexity:o,cognitiveComplexity:a}=ee(i),c=e.getLineAndCharacterOfPosition(i.getStart(e)).line+1;t.push({name:n,line:c,complexity:o,cognitiveComplexity:a})},s=(n,i)=>{if(l.isFunctionDeclaration(n)&&n.name&&n.body?r(n.name.text,n):l.isVariableDeclaration(n)&&l.isIdentifier(n.name)&&n.initializer&&(l.isArrowFunction(n.initializer)||l.isFunctionExpression(n.initializer))?r(n.name.text,n.initializer):i&&l.isMethodDeclaration(n)&&l.isIdentifier(n.name)&&n.body?r(`${i}.${n.name.text}`,n):i&&l.isConstructorDeclaration(n)&&n.body?r(`${i}.constructor`,n):i&&l.isGetAccessorDeclaration(n)&&l.isIdentifier(n.name)&&n.body?r(`${i}.get ${n.name.text}`,n):i&&l.isSetAccessorDeclaration(n)&&l.isIdentifier(n.name)&&n.body&&r(`${i}.set ${n.name.text}`,n),l.isClassDeclaration(n)&&n.name){let o=n.name.text;l.forEachChild(n,a=>s(a,o));return}l.forEachChild(n,o=>s(o,i))};return s(e,void 0),t}function kr(e,t,r,s){let n={name:e},i=Cr(r);i!==void 0&&(n.doc=i);let o=uo(t);o!==void 0&&(n.flags=o);let a=go(t,s);return a!==void 0&&(n.signature=a),n}function Cr(e){let t=l.getJSDocCommentsAndTags(e);for(let r of t)if(l.isJSDoc(r)&&r.comment)return l.getTextOfJSDocComment(r.comment)||void 0}function uo(e){let t=new Set(["deprecated","internal","public","alpha","beta"]),r=l.getJSDocTags(e).map(s=>s.tagName.text).filter(s=>t.has(s));return r.length>0?r:void 0}function go(e,t){let r=l.createPrinter({removeComments:!0}),s=n=>r.printNode(l.EmitHint.Unspecified,n,t);if(l.isFunctionDeclaration(e)||l.isMethodDeclaration(e)){let n=e.parameters.map(s).join(", "),i=e.type?s(e.type):"void";return`${e.typeParameters?`<${e.typeParameters.map(a=>a.name.text).join(", ")}>`:""}(${n}) => ${i}`}if(l.isVariableDeclaration(e)){if(e.type)return s(e.type);if(e.initializer&&(l.isArrowFunction(e.initializer)||l.isFunctionExpression(e.initializer))){let n=e.initializer,i=n.parameters.map(s).join(", "),o=n.type?s(n.type):"unknown";return`(${i}) => ${o}`}return}if(l.isClassDeclaration(e)&&e.name)return`class ${e.name.text}`;if(l.isInterfaceDeclaration(e))return`interface ${e.name.text}`;if(l.isTypeAliasDeclaration(e))return s(e.type);if(l.isEnumDeclaration(e))return`enum ${e.name.text}`}function ho(e,t){yo(e,t),xo(e,t),bo(e,t),vo(e,t),wo(e,t),br(e,t)}function yo(e,t){if(!l.isSourceFile(e))return;let r=e.statements.filter(s=>!l.isEmptyStatement(s));t.totalStatements=r.length,t.exportStatements=r.filter(s=>l.isExportDeclaration(s)||l.isExportAssignment(s)||ne(s)).length}function xo(e,t){if(l.isJsxElement(e)||l.isJsxSelfClosingElement(e)||l.isJsxFragment(e)){t.hasUI=!0,t.hasTypesOnly=!1;return}if(l.isFunctionDeclaration(e)||l.isMethodDeclaration(e)||l.isArrowFunction(e)||l.isClassDeclaration(e)||l.isVariableStatement(e)||l.isEnumDeclaration(e)){t.hasTypesOnly=!1;return}l.isExportDeclaration(e)&&!So(e)&&(t.hasTypesOnly=!1)}function So(e){return e.isTypeOnly?!0:!e.exportClause||!l.isNamedExports(e.exportClause)?!1:e.exportClause.elements.every(t=>t.isTypeOnly)}function bo(e,t){if(!l.isImportDeclaration(e)||!e.moduleSpecifier||!l.isStringLiteral(e.moduleSpecifier))return;let r=[];if(e.importClause&&(e.importClause.name&&r.push("default"),e.importClause.namedBindings))if(l.isNamedImports(e.importClause.namedBindings))for(let n of e.importClause.namedBindings.elements)r.push(n.name.text);else l.isNamespaceImport(e.importClause.namedBindings)&&r.push("*");let s=r.length>0?"static":"side-effect";t.imports.push({fromPath:t.filePath,toPath:"",rawSpecifier:e.moduleSpecifier.text,isStyle:E(e.moduleSpecifier.text),type:s,symbols:r.length>0?r:void 0})}function vo(e,t){l.isExportDeclaration(e)?ko(e,t):l.isExportAssignment(e)?t.exports.set("default",{name:"default"}):ne(e)&&Fo(e,t)}function ko(e,t){if(e.moduleSpecifier&&l.isStringLiteral(e.moduleSpecifier))Co(e,e.moduleSpecifier.text,t);else if(e.exportClause&&l.isNamedExports(e.exportClause))for(let r of e.exportClause.elements){let s=r.name.text;t.exports.set(s,{name:s})}}function Co(e,t,r){let s=Eo(e),n={fromPath:r.filePath,toPath:"",rawSpecifier:t,isStyle:E(t),type:"re-export"};s.length>0&&(n.symbols=s),r.imports.push(n)}function Eo(e){return e.exportClause?l.isNamedExports(e.exportClause)?e.exportClause.elements.map(t=>t.name.text):[]:["*"]}function Fo(e,t){if((l.isFunctionDeclaration(e)||l.isClassDeclaration(e)||l.isInterfaceDeclaration(e)||l.isTypeAliasDeclaration(e)||l.isEnumDeclaration(e))&&e.name){let s=e.name.text;t.exports.set(s,kr(s,e,e,t.sourceFile));return}if(l.isVariableStatement(e)){for(let s of e.declarationList.declarations)if(l.isIdentifier(s.name)){let n=s.name.text;t.exports.set(n,kr(n,s,e,t.sourceFile))}}}function wo(e,t){if(!l.isCallExpression(e))return;let r=e.arguments[0];!r||!l.isStringLiteral(r)||(e.expression.kind===l.SyntaxKind.ImportKeyword?t.imports.push({fromPath:t.filePath,toPath:"",rawSpecifier:r.text,isStyle:E(r.text),type:"dynamic"}):l.isIdentifier(e.expression)&&e.expression.text==="require"&&t.imports.push({fromPath:t.filePath,toPath:"",rawSpecifier:r.text,isStyle:E(r.text),type:"require"}))}function Po(e,t){let r=vr.basename(e).toLowerCase(),s=vr.extname(e).toLowerCase();return U().some(i=>r.includes(i))?"test":le(r)?"config":t.imports.some(i=>It().some(o=>i.rawSpecifier.includes(o)))?"test":s===".tsx"||s===".jsx"||t.hasUI?"ui":t.hasTypesOnly&&t.totalStatements>0?"type-only":t.totalStatements>0&&t.exportStatements/t.totalStatements>Nt()?"barrel":"logic"}function ne(e){return l.canHaveModifiers(e)&&l.getModifiers(e)?.some(t=>t.kind===l.SyntaxKind.ExportKeyword)===!0}function To(e,t){let r=e.rawCallEdges??[];e.rawCallEdges=r;let s=new Map;for(let n of t.statements){if(!l.isImportDeclaration(n)||!l.isStringLiteral(n.moduleSpecifier))continue;let i=n.moduleSpecifier.text,o=n.importClause;if(o&&(o.name&&s.set(o.name.text,i),o.namedBindings&&l.isNamedImports(o.namedBindings)))for(let a of o.namedBindings.elements)s.set(a.name.text,i)}if(s.size!==0)for(let n of t.statements){let i=Mo(n);if(i){let o=No(n);o&&Ft(o,i,s,r);continue}l.isClassDeclaration(n)&&n.name&&Io(n,s,r)}}function Io(e,t,r){let s=e.name.text;for(let n of e.members)l.isMethodDeclaration(n)&&n.body&&l.isIdentifier(n.name)?Ft(n.body,`${s}.${n.name.text}`,t,r):l.isConstructorDeclaration(n)&&n.body&&Ft(n.body,`${s}.constructor`,t,r)}function Mo(e){if(ne(e)){if(l.isFunctionDeclaration(e)&&e.name)return e.name.text;if(l.isVariableStatement(e)){for(let t of e.declarationList.declarations)if(l.isIdentifier(t.name)&&t.initializer&&(l.isArrowFunction(t.initializer)||l.isFunctionExpression(t.initializer)))return t.name.text}}}function No(e){if(l.isFunctionDeclaration(e))return e.body;if(l.isVariableStatement(e)){for(let t of e.declarationList.declarations)if(t.initializer&&(l.isArrowFunction(t.initializer)||l.isFunctionExpression(t.initializer)))return t.initializer}}function Ft(e,t,r,s){if(l.isCallExpression(e)&&l.isIdentifier(e.expression)){let n=e.expression.text,i=r.get(n);i&&!s.some(o=>o.from===t&&o.to===n&&o.toSpecifier===i)&&s.push({from:t,to:n,toSpecifier:i})}l.forEachChild(e,n=>Ft(n,t,r,s))}function wt(e,t){if(t.length===0)return"ui";let r=!1;return e.walk(s=>{if(s.type==="rule")return r=!0,!1}),r?"ui":"barrel"}import Fr from"postcss";import*as Ro from"postcss-less";var Ao=Ro,wr=new Set(["reference","inline"]);function Er(e){return e.startsWith("~")||e.startsWith("http://")||e.startsWith("https://")||e.startsWith("//")||e.startsWith("data:")}function Do(e){let t=e.trim();return t.length>0&&!t.startsWith("http://")&&!t.startsWith("https://")&&!t.startsWith("//")&&!t.startsWith("data:")&&!t.startsWith("#")}function Lo(e,t){let r=e.match(/^\(([^)]+)\)\s+['"]([^'"]+)['"]/);if(r){let i=r[1]?.trim()??"",o=r[2]??"";if(!o)return null;let a=wr.has(i)?"side-effect":"static";return{fromPath:t,toPath:"",rawSpecifier:o,isStyle:!0,type:a,...Er(o)?{isExternal:!0}:{}}}let s=e.match(/^url\(['"]?([^'")]+)['"]?\)/),n=s?s[1]?.trim()??"":e.match(/^['"]([^'"]+)['"]/)?.[1]??"";return n?{fromPath:t,toPath:"",rawSpecifier:n,isStyle:!0,type:"static",...Er(n)?{isExternal:!0}:{}}:null}function Go(e,t){let r=[],s=/url\(['"]?([^'")]+)['"]?\)/g,n=s.exec(e);for(;n!==null;){let i=n[1]?.trim()??"";Do(i)&&r.push({fromPath:t,toPath:"",rawSpecifier:i,isStyle:!0,type:"static"}),n=s.exec(e)}return r}function Pr(e,t){let r=[];return e.walk(s=>{if(s.type==="atrule"&&s.name==="import"){let n=Lo(s.params,t);n&&r.push(n)}s.type==="decl"&&r.push(...Go(s.value,t))}),r}function Oo(e){return e.replace(/(?<!:)\/\/.*/g,"")}function jo(e,t){let r=[],s=/@import\s+(?:\(([^)]+)\)\s+)?['"]([^'"]+)['"]/g,n=s.exec(e);for(;n!==null;){let i=n[1]?.trim()??"",o=n[2]??"";if(o){let a=wr.has(i)?"side-effect":"static";r.push({fromPath:t,toPath:"",rawSpecifier:o,isStyle:!0,type:a})}n=s.exec(e)}return r}function Tr(e,t){let r=Fr.parse(Oo(e));return{imports:Pr(r,t),root:r}}function Ir(e,t){try{let r=Ao.parse(e);return{imports:Pr(r,t),root:r}}catch{return{imports:jo(e,t),root:Fr.parse("")}}}import{parse as _o}from"postcss-scss";function Wo(e){return!!(e.startsWith("sass:")||e.startsWith("~")||e.startsWith("http://")||e.startsWith("https://")||e.startsWith("//")||!e.startsWith(".")&&!e.startsWith("/")&&!e.startsWith("_"))}function $o(e){let t=e.match(/^['"]([^'"]+)['"]/);if(!t?.[1])return{specifier:""};let r=t[1],n=e.match(/\bas\s+(\S+)/)?.[1];return n!==void 0?{specifier:r,alias:n}:{specifier:r}}function Mr(e,t){let r=_o(e),s=[];return r.walk(n=>{if(n.type!=="atrule")return;let{name:i,params:o}=n;if(i!=="import"&&i!=="use"&&i!=="forward")return;let{specifier:a,alias:c}=$o(o);if(!a)return;let p={fromPath:t,toPath:"",rawSpecifier:a,isStyle:!0,type:i==="forward"?"re-export":"static",...Wo(a)?{isExternal:!0}:{}};c&&(p.symbols=[c]),s.push(p)}),{imports:s,root:r}}function Nr(e,t){let r=[],s=/@require\s+['"]([^'"]+)['"]/g,n=s.exec(e);for(;n!==null;){let o=n[1];o&&r.push({fromPath:t,toPath:"",rawSpecifier:o,isStyle:!0,type:"require"}),n=s.exec(e)}let i=/(?<!@)(?:import|require)\s*\(?\s*['"]([^'"]+)['"]/g;for(n=i.exec(e);n!==null;){let o=n[1];o&&r.push({fromPath:t,toPath:"",rawSpecifier:o,isStyle:!0,type:"static"}),n=i.exec(e)}return r}function Rr(e,t){if(t.length===0)return"ui";try{let r=Tt("stylus");return new r.Parser(e).parse().nodes.some(i=>i.constructor.name!=="Import")?"ui":"barrel"}catch{return e.replace(/^\s*@?(?:require|import)\b.*/gm,"").trim().length>0?"ui":"barrel"}}function q(e,t){let r=P(e);if(r==="stylus"){let i=Nr(t,e);return{imports:i,exports:[],tags:[],category:Rr(t,i)}}if(r==="scss"){let{imports:i,root:o}=Mr(t,e);return{imports:i,exports:[],tags:[],category:wt(o,i)}}if(r==="less"){let{imports:i,root:o}=Ir(t,e);return{imports:i,exports:[],tags:[],category:wt(o,i)}}let{imports:s,root:n}=Tr(t,e);return{imports:s,exports:[],tags:[],category:wt(n,s)}}for(let[e,t]of[["javascript",(r,s)=>se(r,s,"javascript")],["typescript",(r,s)=>se(r,s,"typescript")],["css",q],["scss",q],["less",q],["stylus",q],["coffeescript",mr],["livescript",gr],["lua",dr],["python",Sr],["go",ur],["gherkin",qt],["markdown",xr]])D(e,t);async function Ar(e,t){let r=P(e),s=_e(r);return s?s(e,t):{imports:[],exports:[],tags:[],category:"other"}}import Dr from"path";function Gr(e,t){for(let r of e.values()){let s=t.get(r.path);s!==void 0&&(r.coveragePct=s)}}function Or(e,t){for(let r of e)if(r.isExternal){let s=r.rawSpecifier.startsWith("@")?r.rawSpecifier.split("/").slice(0,2).join("/"):r.rawSpecifier.split("/")[0];s&&!t.some(n=>n.name===s)&&t.push({name:s,kind:"library"})}}function jr(e){for(let t of e.values())if(t.category==="test")for(let r of t.imports){if(r.isExternal||!r.toPath)continue;let s=e.get(r.toPath);s&&(s.category!=="logic"&&s.category!=="barrel"||(s.testedBy??=[],s.testedBy.includes(t.path)||s.testedBy.push(t.path)))}}function _r(e){for(let t of e.values())if(t.type==="markdown")for(let r of t.imports){if(r.isExternal||!r.toPath)continue;let s=e.get(r.toPath);!s||s===t||(s.documentedBy??=[],s.documentedBy.includes(t.path)||s.documentedBy.push(t.path),s.category==="logic"&&(s.lastCommitAt??0)>(t.lastCommitAt??0)&&(t.staleFor??=[],t.staleFor.includes(s.path)||t.staleFor.push(s.path)))}}function Lr(e){return Math.round(e*1e4)/1e4}function Wr(e){for(let t of e.values()){let r=[];for(let s of t.imports){if(s.isExternal||!s.toPath)continue;let n=e.get(s.toPath);if(!n||n.exports.length===0)continue;let i;if(s.symbols===void 0){if(s.type==="side-effect")continue;i=1}else s.symbols.includes("*")?i=1:i=s.symbols.length/n.exports.length;s.exportUsageRatio=Lr(Math.min(1,i)),r.push(s.exportUsageRatio)}r.length>0&&(t.avgExportUsage=Lr(r.reduce((s,n)=>s+n,0)/r.length),t.maxExportUsage=Math.max(...r))}}function ie(e,t,r){t&&(e.some(s=>s.name===t&&s.kind===r)||e.push({name:t,kind:r}))}function zo(e,t){let r=t.toPath,s=Dr.basename(r,Dr.extname(r)).replace(/\.(test|spec)$/,"");ie(e.tags,s,"import")}function Bo(e,t){if(!(!t.symbols||t.symbols.includes("*")))for(let r of t.symbols)ie(e.tags,r,"import")}function Uo(e,t,r){let s=r.get(t.toPath);if(!(!s||s.category==="test"))for(let n of s.tags)n.kind==="comment-marker"&&ie(e.tags,n.name,"comment-marker")}function $r(e){for(let t of e.values())if(t.category==="test")for(let r of t.imports)!r.toPath||r.isExternal||(zo(t,r),Bo(t,r),Uo(t,r,e))}import Pt from"fs";import T from"path";import Ur from"fs";import z from"path";var tt=class{extensions=[".go"];goModCache=new Map;resolve(t,r,s,n){let{mod:i,replaces:o}=this.readGoMod(s);if(!i)return null;let a=this.applyReplace(r,o,s);if(a!==void 0)return Br(a);if(r!==i&&!r.startsWith(`${i}/`))return null;let c=r.slice(i.length).replace(/^\//,"");return c?Br(z.join(s,c)):null}readGoMod(t){let r=this.goModCache.get(t);if(r!==void 0)return r;let s={mod:null,replaces:new Map};try{let n=Ur.readFileSync(z.join(t,"go.mod"),"utf-8"),i=Ko(n,t);return this.goModCache.set(t,i),i}catch{return this.goModCache.set(t,s),s}}applyReplace(t,r,s){for(let[n,i]of r){if(t===n)return i;if(t.startsWith(`${n}/`)){let o=t.slice(n.length+1);return z.join(i,o)}}}};function Ko(e,t){let r=e.split(`
21
- `),s=null,n=new Map,i=!1;for(let o of r){let a=o.trim();if(a.startsWith("module ")){s=a.slice(7).trim();continue}if(/^replace\s*\(/.test(a)){i=!0;continue}if(i&&a===")"){i=!1;continue}if(i&&a.includes("=>")){zr(a,t,n);continue}!i&&/^replace\s+/.test(a)&&a.includes("=>")&&zr(a.replace(/^replace\s+/,""),t,n)}return{mod:s,replaces:n}}function zr(e,t,r){let[s,n]=e.split("=>").map(a=>a.trim());if(!s||!n)return;let i=s.split(/\s+/)[0];if(!n.startsWith(".")&&!n.startsWith("/"))return;let o=z.isAbsolute(n)?n:z.resolve(t,n);r.set(i,o)}function Br(e){let t;try{t=Ur.readdirSync(e,{withFileTypes:!0})}catch{return null}let r=t.filter(s=>s.isFile()&&s.name.endsWith(".go")&&!s.name.endsWith("_test.go")).map(s=>({path:z.join(e,s.name),isExternal:!1})).sort((s,n)=>s.path.localeCompare(n.path));return r.length>0?r:null}import Jo from"fs";import oe from"path";var et=class{extensions=[".lua"];resolve(t,r,s,n){let i=r.replace(/\./g,oe.sep),o=[s,oe.join(s,"lib")];for(let a of o){if(!Jo.existsSync(a))continue;let c=n(oe.join(a,"_dummy.lua"),i);if(c)return[c]}return null}};import Ho from"path";var rt=class{extensions=[".md",".mdx"];resolve(t,r,s,n){let i=n(Ho.join(s,"_dummy"),`./${r}`);return i?[i]:null}};import Qo from"fs";import ae from"path";var st=class{extensions=[".py"];resolve(t,r,s,n){let i=r.replace(/\./g,ae.sep),o=ae.join(s,`${i}.py`);if(Kr(o))return[{path:o,isExternal:!1}];let a=ae.join(s,i,"__init__.py");return Kr(a)?[{path:a,isExternal:!1}]:null}};function Kr(e){try{return Qo.statSync(e,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}import Jr from"path";var Vo=["~","http://","https://","//","data:","sass:"],nt=class{extensions=[".css",".scss",".sass",".less",".styl"];resolve(t,r,s,n){if(Vo.some(g=>r.startsWith(g)))return null;let i=n(t,r);if(i)return[i];let o=Jr.dirname(r),a=Jr.basename(r),c=o==="."?`_${a}`:`${o}/_${a}`,p=n(t,c);return p?[p]:null}};var N=class{constructor(t,r={}){this.rootDir=t;this.workspaceMap=r.workspaceMap??new Map,this.tsconfigSearchPaths=r.tsconfigSearchPaths??[t],this.pathAliases=r.pathAliases,this.langResolvers=r.langResolvers??[new st,new et,new tt,new nt,new rt]}rootDir;workspaceMap;tsconfigSearchPaths;pathAliases;langResolvers;resolveAll(t,r){let s=this.resolvePathAlias(r);if(s)return[s];if(r.startsWith(".")||r.startsWith("/")){let o=this.resolveLocalPath(t,r);return o?[o]:[]}let n=(o,a)=>this.resolveLocalPath(o,a);for(let o of this.langResolvers)if(o.extensions.some(a=>t.endsWith(a))){let a=o.resolve(t,r,this.rootDir,n);if(a)return a}let i=this.resolveWorkspaceImport(r);return i?[i]:[{path:r,isExternal:!0}]}resolve(t,r){let s=this.resolvePathAlias(r);if(s)return s;if(r.startsWith(".")||r.startsWith("/"))return this.resolveLocalPath(t,r);let n=(o,a)=>this.resolveLocalPath(o,a);for(let o of this.langResolvers)if(o.extensions.some(a=>t.endsWith(a))){let a=o.resolve(t,r,this.rootDir,n);if(a)return a[0]??null}let i=this.resolveWorkspaceImport(r);return i||{path:r,isExternal:!0}}resolveLocalPath(t,r){let s=T.dirname(t),n=r.startsWith("/")?r:T.resolve(s,r),i=!n.startsWith(this.rootDir),o=["",".ts",".tsx",".js",".jsx",".mjs",".cjs",".css",".scss",".sass",".less",".styl",".coffee",".ls",".lua",".py",".feature",".md",".mdx"],a=n.match(/\.(js|mjs|cjs)$/);if(a){let c=n.slice(0,-a[0].length);for(let p of[".ts",".tsx"]){let g=this.tryExtensions(c,p,i);if(g)return g}}for(let c of o){let p=this.tryExtensions(n,c,i);if(p)return p}return i?{path:n,isExternal:!0}:null}tryExtensions(t,r,s){let n=t+r;if(this.isFile(n))return{path:n,isExternal:s};let i=T.join(t,`index${r}`);if(this.isFile(i))return{path:i,isExternal:s};if(r===".py"){let o=T.join(t,"__init__.py");if(this.isFile(o))return{path:o,isExternal:s}}return null}isFile(t){try{return Pt.statSync(t,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}resolvePathAlias(t){if(this.pathAliases)for(let r in this.pathAliases){let s=this.matchAliasPattern(r,t),n=this.pathAliases[r];if(s&&n){let i=this.tryAliasSubstitutions(n,s[1]||"");if(i)return i}}for(let r of this.tsconfigSearchPaths){let s=T.join(r,"tsconfig.json");if(Pt.existsSync(s))try{let i=JSON.parse(Pt.readFileSync(s,"utf-8")).compilerOptions?.paths;if(!i)continue;for(let o in i){let a=this.matchAliasPattern(o,t);if(a){let c=this.tryAliasSubstitutions(i[o],a[1]||"",r);if(c)return c}}}catch{}}return null}aliasRegexCache=new Map;matchAliasPattern(t,r){let s=this.aliasRegexCache.get(t);if(!s){let n=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace("\\*","(.*)");s=new RegExp(`^${n}$`),this.aliasRegexCache.set(t,s)}return r.match(s)}tryAliasSubstitutions(t,r,s=this.rootDir){let n=["",".ts",".tsx",".js",".jsx",".coffee",".ls",".lua",".feature"];for(let i of t){let o=i.replace("*",r),a=T.resolve(s,o);for(let c of n){let p=this.tryExtensions(a,c,!1);if(p)return p}}return null}resolveWorkspaceImport(t){if(this.workspaceMap.size===0)return null;for(let[r,s]of this.workspaceMap){if(t!==r&&!t.startsWith(`${r}/`))continue;let n=t.slice(r.length),i={path:"",isExternal:!1,isWorkspace:!0,workspacePackage:r};if(!n){for(let a of["src/index.ts","src/index.tsx","index.ts","index.tsx","index.js"]){let c=T.join(s,a);try{if(Pt.statSync(c,{throwIfNoEntry:!1})?.isFile())return{...i,path:c}}catch{}}return{...i,path:s}}let o=this.resolveLocalPath(T.join(s,"_dummy"),n.slice(1));return o?{...i,path:o.path}:null}return null}};var Yo=["tests","test","__tests__","specs","spec"],Hr=new Set(["node_modules",".git","dist","build",".next",".cache","mokosh-cache","coverage"]),Zo=20;function qo(e,t){if(e.length===0)return t;let r=e.map(o=>k.dirname(o).split(k.sep)),s=r[0];for(let o of r.slice(1)){let a=0;for(;a<s.length&&a<o.length&&s[a]===o[a];)a++;s=s.slice(0,a)}let n=s.join(k.sep)||k.sep,i=k.relative(t,n);return i.startsWith("..")||k.isAbsolute(i)?t:n}var ot=class{constructor(t,r=null,s,n,i=!1,o=new Map,a=!0){this.rootDir=t;this.enableGitStats=i;this.coverageMap=o;this.parallelParsing=a;this.previousGraph=r,this.resolver=s||new N(t),this.lockFile=pr(t),n&&(this.progressCallback=n)}rootDir;enableGitStats;coverageMap;parallelParsing;graph={nodes:new Map};visited=new Set;queue=[];previousGraph=null;resolver;lockFile=null;progressCallback;pool=null;gitStatsMap=null;async build(t){let r=t.map(s=>k.isAbsolute(s)?s:k.resolve(this.rootDir,s));await this.initPool(),this.enableGitStats&&(this.gitStatsMap=or(this.rootDir));try{for(let s of r)this.enqueue(s);return await this.drain(),await this.processTestFiles(qo(r,this.rootDir)),await this.processDocFiles(),this.progressCallback&&this.visited.size>=100&&process.stderr.write(`
17
+ `+g}};function ni(e){let t=e.split(`
18
+ `),r=-1;for(let n=0;n<t.length;n++){let i=t[n].trimStart();(i.startsWith("import ")||i.startsWith("from "))&&(r=n)}if(r<0)return 0;let s=0;for(let n=0;n<=r;n++)s+=t[n].length+1;return s}import Ye from"path";import Ze from"typescript";var ii=/\/\/ <mokosh-tags>[\s\S]*?\/\/ <\/mokosh-tags>\n*/,Et=class{name="vitest";canHandle(t){return w.has(Ye.extname(t).toLowerCase())}apply(t,r,s){let n=r.replace(ii,""),i=Ze.createSourceFile(Ye.basename(t),n,Ze.ScriptTarget.Latest,!0),o=O(i);if(o.length===0)return n;let a=j(o[0],"tags",i),c=[...s].sort();if(a!==null&&JSON.stringify([...a].sort())===JSON.stringify(c))return n;let p=o.flatMap(g=>{let u=s.length===0?W(g,"tags",i):_(g,"tags",$(c),i);return u?[u]:[]});return p.length>0?z(n,p):n}};var qe={vitest:()=>new Et,playwright:()=>new bt,cypress:()=>new ht,jest:()=>new St},oi={"@playwright/test":"playwright",cypress:"cypress","@jest/globals":"jest",vitest:"vitest"};function ai(e){let t=Ct.createSourceFile("detect.ts",e,Ct.ScriptTarget.Latest,!0);for(let r of t.statements){if(!Ct.isImportDeclaration(r)||!Ct.isStringLiteral(r.moduleSpecifier))continue;let s=oi[r.moduleSpecifier.text];if(s)return s}return null}var Zt=class{constructor(t,r,s){this.rootDir=t;this.defaultFramework=r;this.frameworkOverrides=s}rootDir;defaultFramework;frameworkOverrides;name="auto";canHandle(t){return w.has(Yt.extname(t).toLowerCase())}apply(t,r,s){let n=ai(r)??this.matchOverride(t)??this.defaultFramework;return(qe[n]??qe.vitest)().apply(t,r,s)}matchOverride(t){let r=Yt.relative(this.rootDir,t).split(Yt.sep).join("/");for(let[s,n]of this.frameworkOverrides)if(Ve(s,r))return n;return null}};function tr(e="vitest",t={},r=process.cwd()){return[new yt,new vt,new xt,new Zt(r,e,Object.entries(t))]}function er(e,t){return t.find(r=>r.canHandle(e))??null}var pi=/^[a-zA-Z][a-zA-Z0-9_-]{1,}$/,li=new Set(["import"]),fi=new Set(["common","fixture","fixtures","helper","helpers","index","main","mock","mocks","setup","shared","spec","test","tests","types","util","utils"]);async function mi(e,t,r,s){let n;try{n=await rr.readFile(e,"utf8")}catch(a){return{path:e,status:"error",error:String(a)}}let i=er(e,s);if(!i)return{path:e,status:"unchanged"};let o=i.apply(e,n,t);return o===n?{path:e,status:"unchanged"}:(r||await rr.writeFile(e,o,"utf8"),{path:e,status:"updated"})}async function ui(e,t,r){let s=Dt(t),n=s.tagApplier?.framework??"vitest",i=s.tagApplier?.frameworkOverrides??{},o=tr(n,i,t),a={updated:0,unchanged:0,errors:0,files:[]};for(let c of e.nodes.values()){if(c.category!=="test")continue;let p=new Set,g=[];for(let b of c.tags)li.has(b.kind)&&pi.test(b.name)&&(fi.has(b.name.toLowerCase())||p.has(b.name)||(p.add(b.name),g.push(b.name)));g.sort();let u=ci.resolve(t,c.path),y=await mi(u,g,r.dryRun,o);y.path=c.path,a.files.push(y),y.status==="updated"?a.updated++:y.status==="unchanged"?a.unchanged++:a.errors++}return a}var kt=class{isTestNode(t){return t.category==="test"||t.tags.some(r=>r.name==="test")}};import ot from"fs";import E from"path";import oa from"piscina";import{execFileSync as sr}from"child_process";var nr="%x00%H%x09%ae%x09%at",ir=256*1024*1024;function or(e,t){let r="",s=0;for(let n of e.split(`
19
+ `)){if(n.startsWith("\0")){let[,c,p]=n.slice(1).split(" ");r=c??"",s=p?Number(p)*1e3:0;continue}if(n==="")continue;let i=n.split(" "),o=i[0];if(!o)continue;let a=o.startsWith("R")||o.startsWith("C")?i[2]:i[1];a&&t(a,r,s)}}function ar(e){let t=new Map;try{let r=sr("git",["-C",e,"log","--since=90 days ago","--name-status","-M",`--format=${nr}`],{encoding:"utf-8",stdio:["ignore","pipe","ignore"],maxBuffer:ir});or(r,(s,n,i)=>{let o=t.get(s);if(o){o.commitCount90d+=1;return}t.set(s,{commitCount90d:1,lastAuthor:n||void 0,lastCommitAt:i||void 0})})}catch{return t}try{let r=sr("git",["-C",e,"log","--name-status","-M",`--format=${nr}`],{encoding:"utf-8",stdio:["ignore","pipe","ignore"],maxBuffer:ir});or(r,(s,n,i)=>{t.has(s)||t.set(s,{commitCount90d:0,lastAuthor:void 0,lastCommitAt:i||void 0})})}catch{}return t}import wt from"fs";import gi from"path";import{load as cr}from"js-yaml";function pr(e){let t=e.lastIndexOf("@");return t>0?e.substring(0,t):e}function di(e){return e.replace(/:$/,"").split(",").map(t=>{let r=t.trim();return r.startsWith('"')&&(r=r.slice(1)),r.endsWith('"')&&(r=r.slice(0,-1)),pr(r)}).filter(Boolean)}function hi(e,t){let r=e.startsWith("/")?e.slice(1):e,s=r.lastIndexOf("@");return s>0?{name:r.substring(0,s),version:t||r.substring(s+1)}:{name:r,version:t}}function yi(e){try{let t=cr(e),r={dependencies:{}};for(let[s,n]of Object.entries(t))if(!(s==="__metadata"||!n?.version))for(let i of s.split(", ")){let o=pr(i);o&&(r.dependencies[o]={version:n.version,...n.dependencies!==void 0&&{dependencies:n.dependencies}})}return r}catch{return null}}function xi(e){let t={dependencies:{}};for(let r of e.split(/\n\n+/)){let s=r.split(`
20
+ `).filter(c=>c.trim().length>0&&!c.trim().startsWith("#"));if(s.length<2)continue;let n=s[0];if(!n||n.startsWith(" "))continue;let i=di(n);if(i.length===0)continue;let a=s.find(c=>c.trim().startsWith('version "'))?.match(/version "(.*?)"/)?.[1]??"";for(let c of i)t.dependencies[c]={version:a}}return t}function Si(e){let t=wt.readFileSync(e,"utf-8"),r=JSON.parse(t),s={dependencies:{}};if(r.packages)for(let[n,i]of Object.entries(r.packages)){if(!n.startsWith("node_modules/"))continue;let o=n.replace("node_modules/","");o.includes("node_modules/")||(s.dependencies[o]={version:i.version,...i.dependencies!==void 0&&{dependencies:i.dependencies}})}else if(r.dependencies)for(let[n,i]of Object.entries(r.dependencies))s.dependencies[n]={version:i.version,...i.dependencies!==void 0&&{dependencies:i.dependencies}};return s}function bi(e){let t=wt.readFileSync(e,"utf-8");if(t.includes("__metadata:")){let r=yi(t);if(r!==null)return r}return xi(t)}function vi(e){let t=wt.readFileSync(e,"utf-8"),r={dependencies:{}};try{let s=cr(t);if(s.packages)for(let[n,i]of Object.entries(s.packages)){let{name:o,version:a}=hi(n,i.version);o&&(r.dependencies[o]={version:a,...i.dependencies!==void 0&&{dependencies:i.dependencies}})}if(s.dependencies)for(let[n,i]of Object.entries(s.dependencies)){if(r.dependencies[n])continue;let o=typeof i=="string"?i:i.version;r.dependencies[n]={version:o||""}}}catch{}return r}function lr(e){let t=[["package-lock.json",Si],["yarn.lock",bi],["pnpm-lock.yaml",vi]];for(let[r,s]of t){let n=gi.join(e,r);if(wt.existsSync(n))return s(n)}return null}import fr from"path";function T(e){switch(fr.extname(e).toLowerCase()){case".js":case".jsx":case".mjs":case".cjs":return"javascript";case".ts":case".tsx":return"typescript";case".css":return"css";case".scss":case".sass":return"scss";case".less":return"less";case".styl":return"stylus";case".coffee":return"coffeescript";case".ls":return"livescript";case".lua":return"lua";case".py":return"python";case".go":return"go";case".java":case".cpp":case".cc":case".cxx":case".c":return"unknown";case".feature":return"gherkin";case".md":case".mdx":return"markdown";default:return"unknown"}}function k(e){let t=fr.extname(e).toLowerCase();return[".css",".scss",".sass",".less",".styl"].includes(t)}import Ei from"coffeescript";function P(e){return e.startsWith("'")||e.startsWith('"')?e.slice(1,-1):e}function ur(e){if(e){if(typeof e.originalValue=="string")return e.originalValue;if(typeof e.value=="string")return P(e.value)}}function R(e){if(e){if(typeof e.value=="string")return e.value;if(typeof e.base?.value=="string")return e.base.value}}function Ci(e){let t=new Set,r=/@tag\s+([a-zA-Z0-9_-]+)/g,s=r.exec(e);for(;s!==null;)s[1]&&t.add(s[1]),s=r.exec(e);return t}function ki(e,t){let r=e.toLowerCase();return r.includes(".test.")||r.includes(".spec.")||t.has("test")?"test":"logic"}function wi(e,t){let r=ur(t.source);return r?{fromPath:e,toPath:"",rawSpecifier:r,isStyle:k(r),type:"static"}:null}function Fi(e,t){let r=t.variable?.base?.value==="require",s=ur(t.args?.[0]?.base);return!r||!s?null:{fromPath:e,toPath:"",rawSpecifier:s,isStyle:k(s),type:"require"}}function mr(e,t){if(t)return[{name:t}];let r=e.value;if(r?.constructor?.name==="Class"){let n=R(r.variable);return n?[{name:n}]:[]}if(r?.base?.constructor?.name==="Obj"&&Array.isArray(r.base.properties))return r.base.properties.map(n=>R(n.variable)??R(n)).filter(n=>!!n).map(n=>({name:n}));let s=R(r);return s?[{name:s}]:[]}function Ti(e){if(Array.isArray(e.specifiers))return e.specifiers.map(r=>r.identifier??r.original?.value).filter(r=>!!r).map(r=>({name:r}));let t=R(e.variable)??R(e.variable?.base);return t?[{name:t}]:[]}function Pi(e,t,r,s){let n=t.constructor?.name;if(n==="ImportDeclaration"){let i=wi(e,t);i&&r.push(i)}else if(n==="Call"){let i=Fi(e,t);i&&r.push(i)}else if(n==="Assign"){let i=R(t.variable?.base),o=t.variable?.properties?.[0]?.name?.value;i==="module"&&o==="exports"?s.push(...mr(t,void 0)):i==="exports"&&typeof o=="string"&&s.push(...mr(t,o))}else n==="ExportNamedDeclaration"&&t.clause?s.push(...Ti(t.clause)):n==="ExportDefaultDeclaration"&&s.push({name:"default"})}function qt(e,t,r,s){if(!(!t||typeof t!="object")){Pi(e,t,r,s);for(let n in t){if(n==="locationData")continue;let i=t[n];if(!(!i||typeof i!="object"))if(Array.isArray(i))for(let o of i)qt(e,o,r,s);else qt(e,i,r,s)}}}function gr(e,t){let r=Ci(t),s=ki(e,r),n=[],i=[];try{qt(e,Ei.nodes(t),n,i)}catch{}let o=new Set,a=i.filter(c=>o.has(c.name)?!1:(o.add(c.name),!0));return{imports:n,exports:a,tags:Array.from(r).map(c=>({name:c,kind:"comment-marker"})),category:s}}import{AstBuilder as Ni,GherkinClassicTokenMatcher as Ii,Parser as Mi}from"@cucumber/gherkin";import{IdGenerator as Ri}from"@cucumber/messages";var Ai=Ri.uuid();function te(e,t){let r=new Set;try{let s=new Ni(Ai),n=new Ii,o=new Mi(s,n).parse(t);o.feature&&(o.feature.tags.forEach(a=>{r.add(a.name.startsWith("@")?a.name.slice(1):a.name)}),o.feature.children.forEach(a=>{a.scenario&&(a.scenario.tags.forEach(c=>{r.add(c.name.startsWith("@")?c.name.slice(1):c.name)}),a.scenario.examples.forEach(c=>{c.tags.forEach(p=>{r.add(p.name.startsWith("@")?p.name.slice(1):p.name)})})),a.rule&&a.rule.children.forEach(c=>{c.scenario&&c.scenario.tags.forEach(p=>{r.add(p.name.startsWith("@")?p.name.slice(1):p.name)})})}))}catch(s){console.warn(`[GherkinParser] Failed to parse ${e}:`,s)}return{imports:[],exports:[],tags:Array.from(r).map(s=>({name:s,kind:"comment-marker"})),category:"test"}}G("gherkin",te);import Di from"path";import{parser as Li}from"@lezer/go";var Gi=/\/\/\s*@tag\s+([a-zA-Z0-9_-]+)/,Oi=/^\/\/go:build\s+(.+)$/,ji=/^\/\/\s*\+build\s+(.+)$/;function hr(e,t){let r=[],s=new Map,n=new Set,i=new Set,a=Li.parse(t).cursor();do switch(a.name){case"LineComment":{let u=t.slice(a.from,a.to),y=u.match(Gi);y?.[1]&&n.add(y[1]);let b=u.match(Oi);b&&dr(b[1],i);let U=u.match(ji);U&&dr(U[1],i);break}case"ImportSpec":{let u=a.node.getChild("String");if(u){let b=t.slice(u.from,u.to).slice(1,-1);r.push({fromPath:e,toPath:"",rawSpecifier:b,isExternal:!0,isStyle:!1,type:"static"})}break}case"FunctionDecl":case"TypeDecl":case"VarDecl":case"ConstDecl":{let u=a.node.getChild("DefName")??a.node.getChild("TypeSpec")?.getChild("DefName")??a.node.getChild("VarSpec")?.getChild("DefName")??a.node.getChild("ConstSpec")?.getChild("DefName");if(u){let y=t.slice(u.from,u.to);y!=="_"&&/^[A-Z]/.test(y)&&!s.has(y)&&s.set(y,{name:y})}break}}while(a.next());let c=r.some(u=>u.rawSpecifier==="testing"),p=Di.basename(e).endsWith("_test.go")||n.has("test")||c?"test":"logic",g=new Set([...n,...i]);return{imports:r,exports:Array.from(s.values()),tags:Array.from(g).map(u=>({name:u,kind:"comment-marker"})),category:p}}function dr(e,t){for(let r of e.split(/[\s,&|!()]+/)){let s=r.trim();s&&s!=="ignore"&&t.add(s)}}import _i from"livescript";function Wi(e){let t=new Set,r=/@tag\s+([a-zA-Z0-9_-]+)/g,s=r.exec(e);for(;s!==null;)s[1]&&t.add(s[1]),s=r.exec(e);return t}function zi(e,t){let r=e.toLowerCase();return r.includes(".test.")||r.includes(".spec.")||t.has("test")?"test":"logic"}var $i=new Set(["first_line","first_column","last_line","last_column","line","column"]);function Bi(e,t){let r=e.constructor?.name||e.type;if(r==="Import"){let s=e.right?.value;if(typeof s=="string"){let n=P(s);return{fromPath:t,toPath:"",rawSpecifier:n,isStyle:k(n),type:"static"}}}if(r==="Chain"&&e.head?.value==="require"){let s=e.tails?.[0];if(s?.constructor?.name==="Call"||s?.type==="Call"){let n=s.args?.[0]?.value;if(typeof n=="string"){let i=P(n);return{fromPath:t,toPath:"",rawSpecifier:i,isStyle:k(i),type:"require"}}}}return null}function ee(e,t){if(!e||typeof e!="object")return[];let r=[],s=Bi(e,t);s&&r.push(s);for(let n in e){if($i.has(n))continue;let i=e[n];if(!(!i||typeof i!="object"))if(Array.isArray(i))for(let o of i)r.push(...ee(o,t));else r.push(...ee(i,t))}return r}function yr(e,t){let r=Wi(t),s=zi(e,r),n=[];try{n=ee(_i.ast(t),e)}catch{}return{imports:n,exports:[],tags:Array.from(r).map(i=>({name:i,kind:"comment-marker"})),category:s}}import Ui from"luaparse";function Ki(e){let t=new Set,r=/@tag\s+([a-zA-Z0-9_-]+)/g,s=r.exec(e);for(;s!==null;)s[1]&&t.add(s[1]),s=r.exec(e);return t}function Ji(e,t){let r=e.toLowerCase();return r.includes(".test.")||r.includes(".spec.")||t.has("test")?"test":"logic"}function Hi(e,t){let r=[];function s(n){if(!(!n||typeof n!="object")){if((n.type==="CallExpression"||n.type==="StringCallExpression")&&n.base?.type==="Identifier"&&n.base?.name==="require"){let i;if(n.type==="CallExpression"){let o=n.arguments?.[0];o?.type==="StringLiteral"&&(i=P(o.raw))}else if(n.type==="StringCallExpression"){let o=n.argument;o?.type==="StringLiteral"&&(i=P(o.raw))}i&&r.push({fromPath:t,toPath:"",rawSpecifier:i,isStyle:k(i),type:"require"})}for(let i in n){if(i==="loc")continue;let o=n[i];if(o&&typeof o=="object")if(Array.isArray(o))for(let a of o)s(a);else s(o)}}}return s(e),r}function Vi(e){let t=new Set;for(let r of e)r.type==="LocalStatement"&&r.variables.forEach((s,n)=>{r.init[n]?.type==="TableConstructorExpression"&&t.add(s.name)});return t}function Qi(e){let t=e[e.length-1];if(t?.type!=="ReturnStatement")return[];let r=t.arguments[0];if(r?.type!=="TableConstructorExpression")return[];let s=[];for(let n of r.fields)n.type==="TableKeyString"&&s.push({name:n.key.name});return s}function Xi(e){let t=e.body,r=Vi(t),s=Qi(t);for(let i of t)if(i.type==="FunctionDeclaration")i.identifier?.type==="MemberExpression"?i.identifier.base.type==="Identifier"&&r.has(i.identifier.base.name)&&s.push({name:i.identifier.identifier.name}):i.identifier?.type==="Identifier"&&!i.isLocal&&s.push({name:i.identifier.name});else if(i.type==="AssignmentStatement")for(let o of i.variables)o.type==="MemberExpression"&&o.base.type==="Identifier"&&r.has(o.base.name)&&s.push({name:o.identifier.name});let n=new Set;return s.filter(i=>n.has(i.name)?!1:(n.add(i.name),!0))}function xr(e,t){let r=Ki(t),s=Ji(e,r),n=[],i=[];try{let o=Ui.parse(t);n=Hi(o,e),i=Xi(o)}catch{}return{imports:n,exports:i,tags:Array.from(r).map(o=>({name:o,kind:"comment-marker"})),category:s}}var Yi=["http://","https://","mailto:","//"],Zi="ts|tsx|js|jsx|mjs|cjs|py|go|lua|css|scss|less|styl|coffee|ls|feature|md|mdx|json",qi=new RegExp(`(?:\\.{1,2}/)?[\\w.-]+(?:/[\\w.-]+)*\\.(?:${Zi})\\b`,"g"),Sr;async function to(){return Sr??=(async()=>{let{unified:e}=await import("unified"),t=(await import("remark-parse")).default;return e().use(t)})(),Sr}function eo(e){let t=e.trim();return t.length===0||t.startsWith("#")||Yi.some(r=>t.startsWith(r))}function ro(e,t){let r=e.match(qi);return r?r.map(s=>({fromPath:t,toPath:"",rawSpecifier:s,isStyle:!1,type:"static"})):[]}function br(e,t,r){if(e.type==="link"&&typeof e.url=="string"&&!eo(e.url)&&r.push({fromPath:t,toPath:"",rawSpecifier:e.url,isStyle:!1,type:"static"}),(e.type==="code"||e.type==="inlineCode")&&typeof e.value=="string"&&r.push(...ro(e.value,t)),Array.isArray(e.children))for(let s of e.children)br(s,t,r)}async function vr(e,t){let s=(await to()).parse(t),n=[];br(s,e,n);let i=new Set;return{imports:n.filter(a=>i.has(a.rawSpecifier)?!1:(i.add(a.rawSpecifier),!0)),exports:[],tags:[],category:"other"}}import so from"path";import{parser as no}from"@lezer/python";var io=new Set(["pytest","unittest","nose","hypothesis"]);function Er(e,t){let r=[],s=[],n=new Set,i=so.basename(e).toLowerCase(),a=no.parse(t).cursor();do switch(a.name){case"Comment":{let p=t.slice(a.from,a.to).match(/#\s*@tag\s+([a-zA-Z0-9_-]+)/);p?.[1]&&n.add(p[1]);break}case"ImportStatement":{for(let p of oo(a.node,t,e))r.push(p);break}case"FunctionDefinition":case"ClassDefinition":{let p=a.node.parent;if(p?.name==="Script"||p?.name==="DecoratedStatement"&&p.parent?.name==="Script"){let u=a.node.getChild("VariableName");u&&s.push({name:t.slice(u.from,u.to)})}break}case"AssignStatement":{if(a.node.parent?.name==="Script"){let p=a.node.firstChild;p?.name==="VariableName"&&s.push({name:t.slice(p.from,p.to)})}break}}while(a.next());let c=lo(i,r,n);return c==="test"&&n.add("test"),{imports:r,exports:s,tags:Array.from(n).map(p=>({name:p,kind:"comment-marker"})),category:c}}function oo(e,t,r){let s=e.firstChild;return s?s.name==="from"?ao(e,t,r):co(e,t,r):[]}function ao(e,t,r){let s=e.firstChild;if(!s)return[];let n=s.nextSibling;for(;n&&n.name!=="import";)n=n.nextSibling;if(!n)return[];let i=t.slice(s.to,n.from).trim(),o=po(n.nextSibling,t);if(!o.length)return[];let a=0;for(;a<i.length&&i[a]===".";)a++;let c=i.slice(a);if(a===0)return[q(r,i,o,!0)];let p=a===1?"./":"../".repeat(a-1);return c?[q(r,p+c.replace(/\./g,"/"),o,!1)]:o[0]==="*"?[q(r,p.slice(0,-1),["*"],!1)]:o.map(g=>q(r,p+g,[g],!1))}function co(e,t,r){let s=[],n=e.firstChild?.nextSibling??null;for(;n;){if(n.name==="VariableName"){let i=t.slice(n.from,n.to);for(;n.nextSibling?.name==="."&&n.nextSibling.nextSibling?.name==="VariableName";)n=n.nextSibling.nextSibling,i+=`.${t.slice(n.from,n.to)}`;n.nextSibling?.name==="as"&&(n=n.nextSibling.nextSibling??n.nextSibling),s.push(q(r,i,["*"],!0))}n=n.nextSibling}return s}function po(e,t){let r=[],s=e;for(;s;)s.name==="*"?r.push("*"):s.name==="VariableName"&&(r.push(t.slice(s.from,s.to)),s.nextSibling?.name==="as"&&(s=s.nextSibling.nextSibling??s.nextSibling)),s=s.nextSibling;return r}function q(e,t,r,s){return{fromPath:e,toPath:"",rawSpecifier:t,isStyle:!1,isExternal:s,type:"static",symbols:r.length>0?r:void 0}}function lo(e,t,r){return e.startsWith("test_")||e.endsWith("_test.py")?"test":e==="conftest.py"||e==="setup.py"?"config":r.has("test")||t.some(s=>io.has(s.rawSpecifier))?"test":"logic"}import kr from"path";import l from"typescript";import d from"typescript";function fo(e){let t=1;function r(s){switch(s.kind){case d.SyntaxKind.IfStatement:case d.SyntaxKind.ConditionalExpression:case d.SyntaxKind.ForStatement:case d.SyntaxKind.ForInStatement:case d.SyntaxKind.ForOfStatement:case d.SyntaxKind.WhileStatement:case d.SyntaxKind.DoStatement:case d.SyntaxKind.CatchClause:case d.SyntaxKind.CaseClause:t++;break;case d.SyntaxKind.BinaryExpression:{let n=s.operatorToken.kind;(n===d.SyntaxKind.AmpersandAmpersandToken||n===d.SyntaxKind.BarBarToken||n===d.SyntaxKind.QuestionQuestionToken)&&t++;break}}d.forEachChild(s,r)}return r(e),t}function mo(e){let t=0;function r(s,n,i){if(d.isIfStatement(s)){t+=i?1:1+n;let a=i?n:n+1;r(s.expression,a,!1),r(s.thenStatement,a,!1),s.elseStatement&&(d.isIfStatement(s.elseStatement)?r(s.elseStatement,n,!0):(t+=1,r(s.elseStatement,n+1,!1)));return}if(d.isForStatement(s)||d.isForInStatement(s)||d.isForOfStatement(s)||d.isWhileStatement(s)||d.isDoStatement(s)||d.isSwitchStatement(s)){t+=1+n,d.forEachChild(s,a=>r(a,n+1,!1));return}if(d.isCatchClause(s)){t+=1+n,d.forEachChild(s,a=>r(a,n,!1));return}if(d.isConditionalExpression(s)&&(t+=1),d.isBinaryExpression(s)){let a=s.operatorToken.kind;(a===d.SyntaxKind.AmpersandAmpersandToken||a===d.SyntaxKind.BarBarToken||a===d.SyntaxKind.QuestionQuestionToken)&&(t+=1)}if(n>0&&(d.isFunctionDeclaration(s)||d.isFunctionExpression(s)||d.isArrowFunction(s))){t+=1+n,d.forEachChild(s,a=>r(a,n+1,!1));return}d.forEachChild(s,a=>r(a,n,!1))}return r(e,0,!1),t}function re(e){return{complexity:fo(e),cognitiveComplexity:mo(e)}}import x from"typescript";var se=new Set(["test","describe","it"]);function Cr(e,t){uo(e,t),ho(e,t),yo(e,t),xo(e,t)}function uo(e,t){if((x.isFunctionDeclaration(e)||x.isVariableDeclaration(e))&&e.name&&x.isIdentifier(e.name)&&go(e)){let r;if(x.isFunctionDeclaration(e))r="function";else{let s=e.initializer;r=s&&(x.isArrowFunction(s)||x.isFunctionExpression(s))?"function":"variable"}t.tags.add({name:e.name.text,kind:r})}}function go(e){if(x.isFunctionDeclaration(e))return x.isSourceFile(e.parent);let t=e.parent?.parent;return!!t&&x.isSourceFile(t.parent)}function ho(e,t){if(!x.isStringLiteral(e))return;let r=e.text.match(/@[\w-]+/g);if(r)for(let s of r)t.tags.add({name:s.substring(1),kind:"comment-marker"})}function yo(e,t){if(!x.isSourceFile(e))return;let r=/@tag\s+([a-zA-Z0-9_-]+)/g,s=e.getFullText(),n=r.exec(s);for(;n!==null;)n[1]&&t.tags.add({name:n[1],kind:"comment-marker"}),n=r.exec(s)}function xo(e,t){if(x.isCallExpression(e)&&So(e.expression))for(let r of e.arguments)x.isObjectLiteralExpression(r)&&bo(r,t)}function So(e){return x.isIdentifier(e)?se.has(e.text):!!(x.isPropertyAccessExpression(e)&&(se.has(e.name.text)||x.isIdentifier(e.expression)&&se.has(e.expression.text)))}function bo(e,t){for(let r of e.properties){if(!x.isPropertyAssignment(r)||!x.isIdentifier(r.name)||r.name.text!=="tags"&&r.name.text!=="tag")continue;let{initializer:s}=r,n=x.isArrayLiteralExpression(s)?s.elements.filter(x.isStringLiteral):r.name.text==="tag"&&x.isStringLiteral(s)?[s]:[];for(let i of n)t.tags.add({name:i.text.replace(/^@/,""),kind:"comment-marker"})}}function ne(e,t,r){let s=[],n=new Map,i=new Set,o=l.createSourceFile(e,t,l.ScriptTarget.Latest,!0,r==="typescript"?l.ScriptKind.TSX:l.ScriptKind.JSX),a={filePath:e,imports:s,exports:n,tags:i,rawCallEdges:[],sourceFile:o,hasUI:!1,hasTypesOnly:!0,totalStatements:0,exportStatements:0},c=pe=>{ko(pe,a),l.forEachChild(pe,c)};c(o);let p=Lo(e,a);(p==="test"||p==="barrel")&&i.add({name:p,kind:"comment-marker"}),p!=="test"&&Go(a,o);let g=o.statements[0],u=g?Fr(g):void 0,{complexity:y,cognitiveComplexity:b}=re(o),U=vo(o);return{imports:s,exports:Array.from(n.values()),tags:Array.from(i),category:p,rawCallEdges:a.rawCallEdges??[],complexity:y,cognitiveComplexity:b,...U.length>0?{functions:U}:{},...u!==void 0?{description:u}:{}}}function vo(e){let t=[],r=(n,i)=>{let{complexity:o,cognitiveComplexity:a}=re(i),c=e.getLineAndCharacterOfPosition(i.getStart(e)).line+1;t.push({name:n,line:c,complexity:o,cognitiveComplexity:a})},s=(n,i)=>{if(l.isFunctionDeclaration(n)&&n.name&&n.body?r(n.name.text,n):l.isVariableDeclaration(n)&&l.isIdentifier(n.name)&&n.initializer&&(l.isArrowFunction(n.initializer)||l.isFunctionExpression(n.initializer))?r(n.name.text,n.initializer):i&&l.isMethodDeclaration(n)&&l.isIdentifier(n.name)&&n.body?r(`${i}.${n.name.text}`,n):i&&l.isConstructorDeclaration(n)&&n.body?r(`${i}.constructor`,n):i&&l.isGetAccessorDeclaration(n)&&l.isIdentifier(n.name)&&n.body?r(`${i}.get ${n.name.text}`,n):i&&l.isSetAccessorDeclaration(n)&&l.isIdentifier(n.name)&&n.body&&r(`${i}.set ${n.name.text}`,n),l.isClassDeclaration(n)&&n.name){let o=n.name.text;l.forEachChild(n,a=>s(a,o));return}l.forEachChild(n,o=>s(o,i))};return s(e,void 0),t}function wr(e,t,r,s){let n={name:e},i=Fr(r);i!==void 0&&(n.doc=i);let o=Eo(t);o!==void 0&&(n.flags=o);let a=Co(t,s);return a!==void 0&&(n.signature=a),n}function Fr(e){let t=l.getJSDocCommentsAndTags(e);for(let r of t)if(l.isJSDoc(r)&&r.comment)return l.getTextOfJSDocComment(r.comment)||void 0}function Eo(e){let t=new Set(["deprecated","internal","public","alpha","beta"]),r=l.getJSDocTags(e).map(s=>s.tagName.text).filter(s=>t.has(s));return r.length>0?r:void 0}function Co(e,t){let r=l.createPrinter({removeComments:!0}),s=n=>r.printNode(l.EmitHint.Unspecified,n,t);if(l.isFunctionDeclaration(e)||l.isMethodDeclaration(e)){let n=e.parameters.map(s).join(", "),i=e.type?s(e.type):"void";return`${e.typeParameters?`<${e.typeParameters.map(a=>a.name.text).join(", ")}>`:""}(${n}) => ${i}`}if(l.isVariableDeclaration(e)){if(e.type)return s(e.type);if(e.initializer&&(l.isArrowFunction(e.initializer)||l.isFunctionExpression(e.initializer))){let n=e.initializer,i=n.parameters.map(s).join(", "),o=n.type?s(n.type):"unknown";return`(${i}) => ${o}`}return}if(l.isClassDeclaration(e)&&e.name)return`class ${e.name.text}`;if(l.isInterfaceDeclaration(e))return`interface ${e.name.text}`;if(l.isTypeAliasDeclaration(e))return s(e.type);if(l.isEnumDeclaration(e))return`enum ${e.name.text}`}function ko(e,t){wo(e,t),Fo(e,t),Po(e,t),No(e,t),Do(e,t),Cr(e,t)}function wo(e,t){if(!l.isSourceFile(e))return;let r=e.statements.filter(s=>!l.isEmptyStatement(s));t.totalStatements=r.length,t.exportStatements=r.filter(s=>l.isExportDeclaration(s)||l.isExportAssignment(s)||ie(s)).length}function Fo(e,t){if(l.isJsxElement(e)||l.isJsxSelfClosingElement(e)||l.isJsxFragment(e)){t.hasUI=!0,t.hasTypesOnly=!1;return}if(l.isFunctionDeclaration(e)||l.isMethodDeclaration(e)||l.isArrowFunction(e)||l.isClassDeclaration(e)||l.isVariableStatement(e)||l.isEnumDeclaration(e)){t.hasTypesOnly=!1;return}l.isExportDeclaration(e)&&!To(e)&&(t.hasTypesOnly=!1)}function To(e){return e.isTypeOnly?!0:!e.exportClause||!l.isNamedExports(e.exportClause)?!1:e.exportClause.elements.every(t=>t.isTypeOnly)}function Po(e,t){if(!l.isImportDeclaration(e)||!e.moduleSpecifier||!l.isStringLiteral(e.moduleSpecifier))return;let r=[];if(e.importClause&&(e.importClause.name&&r.push("default"),e.importClause.namedBindings))if(l.isNamedImports(e.importClause.namedBindings))for(let n of e.importClause.namedBindings.elements)r.push(n.name.text);else l.isNamespaceImport(e.importClause.namedBindings)&&r.push("*");let s=r.length>0?"static":"side-effect";t.imports.push({fromPath:t.filePath,toPath:"",rawSpecifier:e.moduleSpecifier.text,isStyle:k(e.moduleSpecifier.text),type:s,symbols:r.length>0?r:void 0})}function No(e,t){l.isExportDeclaration(e)?Io(e,t):l.isExportAssignment(e)?t.exports.set("default",{name:"default"}):ie(e)&&Ao(e,t)}function Io(e,t){if(e.moduleSpecifier&&l.isStringLiteral(e.moduleSpecifier))Mo(e,e.moduleSpecifier.text,t);else if(e.exportClause&&l.isNamedExports(e.exportClause))for(let r of e.exportClause.elements){let s=r.name.text;t.exports.set(s,{name:s})}}function Mo(e,t,r){let s=Ro(e),n={fromPath:r.filePath,toPath:"",rawSpecifier:t,isStyle:k(t),type:"re-export"};s.length>0&&(n.symbols=s),r.imports.push(n)}function Ro(e){return e.exportClause?l.isNamedExports(e.exportClause)?e.exportClause.elements.map(t=>t.name.text):[]:["*"]}function Ao(e,t){if((l.isFunctionDeclaration(e)||l.isClassDeclaration(e)||l.isInterfaceDeclaration(e)||l.isTypeAliasDeclaration(e)||l.isEnumDeclaration(e))&&e.name){let s=e.name.text;t.exports.set(s,wr(s,e,e,t.sourceFile));return}if(l.isVariableStatement(e)){for(let s of e.declarationList.declarations)if(l.isIdentifier(s.name)){let n=s.name.text;t.exports.set(n,wr(n,s,e,t.sourceFile))}}}function Do(e,t){if(!l.isCallExpression(e))return;let r=e.arguments[0];!r||!l.isStringLiteral(r)||(e.expression.kind===l.SyntaxKind.ImportKeyword?t.imports.push({fromPath:t.filePath,toPath:"",rawSpecifier:r.text,isStyle:k(r.text),type:"dynamic"}):l.isIdentifier(e.expression)&&e.expression.text==="require"&&t.imports.push({fromPath:t.filePath,toPath:"",rawSpecifier:r.text,isStyle:k(r.text),type:"require"}))}function Lo(e,t){let r=kr.basename(e).toLowerCase(),s=kr.extname(e).toLowerCase();return K().some(i=>r.includes(i))?"test":fe(r)?"config":t.imports.some(i=>It().some(o=>i.rawSpecifier.includes(o)))?"test":s===".tsx"||s===".jsx"||t.hasUI?"ui":t.hasTypesOnly&&t.totalStatements>0?"type-only":t.totalStatements>0&&t.exportStatements/t.totalStatements>Rt()?"barrel":"logic"}function ie(e){return l.canHaveModifiers(e)&&l.getModifiers(e)?.some(t=>t.kind===l.SyntaxKind.ExportKeyword)===!0}function Go(e,t){let r=e.rawCallEdges??[];e.rawCallEdges=r;let s=new Map;for(let n of t.statements){if(!l.isImportDeclaration(n)||!l.isStringLiteral(n.moduleSpecifier))continue;let i=n.moduleSpecifier.text,o=n.importClause;if(o&&(o.name&&s.set(o.name.text,i),o.namedBindings&&l.isNamedImports(o.namedBindings)))for(let a of o.namedBindings.elements)s.set(a.name.text,i)}if(s.size!==0)for(let n of t.statements){let i=jo(n);if(i){let o=_o(n);o&&Ft(o,i,s,r);continue}l.isClassDeclaration(n)&&n.name&&Oo(n,s,r)}}function Oo(e,t,r){let s=e.name.text;for(let n of e.members)l.isMethodDeclaration(n)&&n.body&&l.isIdentifier(n.name)?Ft(n.body,`${s}.${n.name.text}`,t,r):l.isConstructorDeclaration(n)&&n.body&&Ft(n.body,`${s}.constructor`,t,r)}function jo(e){if(ie(e)){if(l.isFunctionDeclaration(e)&&e.name)return e.name.text;if(l.isVariableStatement(e)){for(let t of e.declarationList.declarations)if(l.isIdentifier(t.name)&&t.initializer&&(l.isArrowFunction(t.initializer)||l.isFunctionExpression(t.initializer)))return t.name.text}}}function _o(e){if(l.isFunctionDeclaration(e))return e.body;if(l.isVariableStatement(e)){for(let t of e.declarationList.declarations)if(t.initializer&&(l.isArrowFunction(t.initializer)||l.isFunctionExpression(t.initializer)))return t.initializer}}function Ft(e,t,r,s){if(l.isCallExpression(e)&&l.isIdentifier(e.expression)){let n=e.expression.text,i=r.get(n);i&&!s.some(o=>o.from===t&&o.to===n&&o.toSpecifier===i)&&s.push({from:t,to:n,toSpecifier:i})}l.forEachChild(e,n=>Ft(n,t,r,s))}function Tt(e,t){if(t.length===0)return"ui";let r=!1;return e.walk(s=>{if(s.type==="rule")return r=!0,!1}),r?"ui":"barrel"}import Pr from"postcss";import*as Wo from"postcss-less";var zo=Wo,Nr=new Set(["reference","inline"]);function Tr(e){return e.startsWith("~")||e.startsWith("http://")||e.startsWith("https://")||e.startsWith("//")||e.startsWith("data:")}function $o(e){let t=e.trim();return t.length>0&&!t.startsWith("http://")&&!t.startsWith("https://")&&!t.startsWith("//")&&!t.startsWith("data:")&&!t.startsWith("#")}function Bo(e,t){let r=e.match(/^\(([^)]+)\)\s+['"]([^'"]+)['"]/);if(r){let i=r[1]?.trim()??"",o=r[2]??"";if(!o)return null;let a=Nr.has(i)?"side-effect":"static";return{fromPath:t,toPath:"",rawSpecifier:o,isStyle:!0,type:a,...Tr(o)?{isExternal:!0}:{}}}let s=e.match(/^url\(['"]?([^'")]+)['"]?\)/),n=s?s[1]?.trim()??"":e.match(/^['"]([^'"]+)['"]/)?.[1]??"";return n?{fromPath:t,toPath:"",rawSpecifier:n,isStyle:!0,type:"static",...Tr(n)?{isExternal:!0}:{}}:null}function Uo(e,t){let r=[],s=/url\(['"]?([^'")]+)['"]?\)/g,n=s.exec(e);for(;n!==null;){let i=n[1]?.trim()??"";$o(i)&&r.push({fromPath:t,toPath:"",rawSpecifier:i,isStyle:!0,type:"static"}),n=s.exec(e)}return r}function Ir(e,t){let r=[];return e.walk(s=>{if(s.type==="atrule"&&s.name==="import"){let n=Bo(s.params,t);n&&r.push(n)}s.type==="decl"&&r.push(...Uo(s.value,t))}),r}function Ko(e){return e.replace(/(?<!:)\/\/.*/g,"")}function Jo(e,t){let r=[],s=/@import\s+(?:\(([^)]+)\)\s+)?['"]([^'"]+)['"]/g,n=s.exec(e);for(;n!==null;){let i=n[1]?.trim()??"",o=n[2]??"";if(o){let a=Nr.has(i)?"side-effect":"static";r.push({fromPath:t,toPath:"",rawSpecifier:o,isStyle:!0,type:a})}n=s.exec(e)}return r}function Mr(e,t){let r=Pr.parse(Ko(e));return{imports:Ir(r,t),root:r}}function Ho(e){let t=[],r=[];for(let s of e.nodes??[]){if(s.type!=="atrule")continue;let{value:n}=s;if(n===void 0)continue;let i=s.name;i&&(t.push({name:i}),r.push({name:i,kind:"variable"}))}return{exports:t,tags:r}}function Rr(e,t){try{let r=zo.parse(e),{exports:s,tags:n}=Ho(r);return{imports:Ir(r,t),root:r,exports:s,tags:n}}catch{return{imports:Jo(e,t),root:Pr.parse(""),exports:[],tags:[]}}}import{parse as Vo}from"postcss-scss";function Ar(e){return e.startsWith("_")||e.startsWith("-")}function Qo(e){return!!(e.startsWith("sass:")||e.startsWith("~")||e.startsWith("http://")||e.startsWith("https://")||e.startsWith("//")||!e.startsWith(".")&&!e.startsWith("/")&&!e.startsWith("_"))}function Xo(e){let t=e.match(/^['"]([^'"]+)['"]/);if(!t?.[1])return{specifier:""};let r=t[1],n=e.match(/\bas\s+(\S+)/)?.[1];return n!==void 0?{specifier:r,alias:n}:{specifier:r}}function Yo(e){let t=[],r=[];for(let s of e.nodes??[]){if(s.type==="decl"&&s.prop.startsWith("$")){let n=s.prop.slice(1);if(!n||Ar(n))continue;t.push({name:n}),r.push({name:n,kind:"variable"});continue}if(s.type==="atrule"&&(s.name==="mixin"||s.name==="function")){let i=s.params.match(/^([\w-]+)/)?.[1];if(!i||Ar(i))continue;let o=s.params.trim();t.push(o.includes("(")?{name:i,signature:o}:{name:i}),r.push({name:i,kind:"function"})}}return{exports:t,tags:r}}function Dr(e,t){let r=Vo(e),s=[];r.walk(o=>{if(o.type!=="atrule")return;let{name:a,params:c}=o;if(a!=="import"&&a!=="use"&&a!=="forward")return;let{specifier:p,alias:g}=Xo(c);if(!p)return;let u={fromPath:t,toPath:"",rawSpecifier:p,isStyle:!0,type:a==="forward"?"re-export":"static",...Qo(p)?{isExternal:!0}:{}};g&&(u.symbols=[g]),s.push(u)});let{exports:n,tags:i}=Yo(r);return{imports:s,root:r,exports:n,tags:i}}function Lr(e,t){let r=[],s=/@require\s+['"]([^'"]+)['"]/g,n=s.exec(e);for(;n!==null;){let o=n[1];o&&r.push({fromPath:t,toPath:"",rawSpecifier:o,isStyle:!0,type:"require"}),n=s.exec(e)}let i=/(?<!@)(?:import|require)\s*\(?\s*['"]([^'"]+)['"]/g;for(n=i.exec(e);n!==null;){let o=n[1];o&&r.push({fromPath:t,toPath:"",rawSpecifier:o,isStyle:!0,type:"static"}),n=i.exec(e)}return r}function Gr(e,t){if(t.length===0)return"ui";try{let r=Nt("stylus");return new r.Parser(e).parse().nodes.some(i=>i.constructor.name!=="Import")?"ui":"barrel"}catch{return e.replace(/^\s*@?(?:require|import)\b.*/gm,"").trim().length>0?"ui":"barrel"}}function tt(e,t){let r=T(e);if(r==="stylus"){let i=Lr(t,e);return{imports:i,exports:[],tags:[],category:Gr(t,i)}}if(r==="scss"){let{imports:i,root:o,exports:a,tags:c}=Dr(t,e);return{imports:i,exports:a,tags:c,category:Tt(o,i)}}if(r==="less"){let{imports:i,root:o,exports:a,tags:c}=Rr(t,e);return{imports:i,exports:a,tags:c,category:Tt(o,i)}}let{imports:s,root:n}=Mr(t,e);return{imports:s,exports:[],tags:[],category:Tt(n,s)}}for(let[e,t]of[["javascript",(r,s)=>ne(r,s,"javascript")],["typescript",(r,s)=>ne(r,s,"typescript")],["css",tt],["scss",tt],["less",tt],["stylus",tt],["coffeescript",gr],["livescript",yr],["lua",xr],["python",Er],["go",hr],["gherkin",te],["markdown",vr]])G(e,t);async function Or(e,t){let r=T(e),s=We(r);return s?s(e,t):{imports:[],exports:[],tags:[],category:"other"}}import jr from"path";function Wr(e,t){for(let r of e.values()){let s=t.get(r.path);s!==void 0&&(r.coveragePct=s)}}function zr(e,t){for(let r of e)if(r.isExternal){let s=r.rawSpecifier.startsWith("@")?r.rawSpecifier.split("/").slice(0,2).join("/"):r.rawSpecifier.split("/")[0];s&&!t.some(n=>n.name===s)&&t.push({name:s,kind:"library"})}}function $r(e){for(let t of e.values())if(t.category==="test")for(let r of t.imports){if(r.isExternal||!r.toPath)continue;let s=e.get(r.toPath);s&&(s.category!=="logic"&&s.category!=="barrel"||(s.testedBy??=[],s.testedBy.includes(t.path)||s.testedBy.push(t.path)))}}function Br(e){for(let t of e.values())if(t.type==="markdown")for(let r of t.imports){if(r.isExternal||!r.toPath)continue;let s=e.get(r.toPath);!s||s===t||(s.documentedBy??=[],s.documentedBy.includes(t.path)||s.documentedBy.push(t.path),s.category==="logic"&&(s.lastCommitAt??0)>(t.lastCommitAt??0)&&(t.staleFor??=[],t.staleFor.includes(s.path)||t.staleFor.push(s.path)))}}function _r(e){return Math.round(e*1e4)/1e4}function Ur(e){for(let t of e.values()){let r=[];for(let s of t.imports){if(s.isExternal||!s.toPath)continue;let n=e.get(s.toPath);if(!n||n.exports.length===0)continue;let i;if(s.symbols===void 0){if(s.type==="side-effect")continue;i=1}else s.symbols.includes("*")?i=1:i=s.symbols.length/n.exports.length;s.exportUsageRatio=_r(Math.min(1,i)),r.push(s.exportUsageRatio)}r.length>0&&(t.avgExportUsage=_r(r.reduce((s,n)=>s+n,0)/r.length),t.maxExportUsage=Math.max(...r))}}function oe(e,t,r){t&&(e.some(s=>s.name===t&&s.kind===r)||e.push({name:t,kind:r}))}function Zo(e,t){let r=t.toPath,s=jr.basename(r,jr.extname(r)).replace(/\.(test|spec)$/,"");oe(e.tags,s,"import")}function qo(e,t){if(!(!t.symbols||t.symbols.includes("*")))for(let r of t.symbols)oe(e.tags,r,"import")}function ta(e,t,r){let s=r.get(t.toPath);if(!(!s||s.category==="test"))for(let n of s.tags)n.kind==="comment-marker"&&oe(e.tags,n.name,"comment-marker")}function Kr(e){for(let t of e.values())if(t.category==="test")for(let r of t.imports)!r.toPath||r.isExternal||(Zo(t,r),qo(t,r),ta(t,r,e))}import Pt from"fs";import N from"path";import Vr from"fs";import B from"path";var et=class{extensions=[".go"];goModCache=new Map;resolve(t,r,s,n){let{mod:i,replaces:o}=this.readGoMod(s);if(!i)return null;let a=this.applyReplace(r,o,s);if(a!==void 0)return Hr(a);if(r!==i&&!r.startsWith(`${i}/`))return null;let c=r.slice(i.length).replace(/^\//,"");return c?Hr(B.join(s,c)):null}readGoMod(t){let r=this.goModCache.get(t);if(r!==void 0)return r;let s={mod:null,replaces:new Map};try{let n=Vr.readFileSync(B.join(t,"go.mod"),"utf-8"),i=ea(n,t);return this.goModCache.set(t,i),i}catch{return this.goModCache.set(t,s),s}}applyReplace(t,r,s){for(let[n,i]of r){if(t===n)return i;if(t.startsWith(`${n}/`)){let o=t.slice(n.length+1);return B.join(i,o)}}}};function ea(e,t){let r=e.split(`
21
+ `),s=null,n=new Map,i=!1;for(let o of r){let a=o.trim();if(a.startsWith("module ")){s=a.slice(7).trim();continue}if(/^replace\s*\(/.test(a)){i=!0;continue}if(i&&a===")"){i=!1;continue}if(i&&a.includes("=>")){Jr(a,t,n);continue}!i&&/^replace\s+/.test(a)&&a.includes("=>")&&Jr(a.replace(/^replace\s+/,""),t,n)}return{mod:s,replaces:n}}function Jr(e,t,r){let[s,n]=e.split("=>").map(a=>a.trim());if(!s||!n)return;let i=s.split(/\s+/)[0];if(!n.startsWith(".")&&!n.startsWith("/"))return;let o=B.isAbsolute(n)?n:B.resolve(t,n);r.set(i,o)}function Hr(e){let t;try{t=Vr.readdirSync(e,{withFileTypes:!0})}catch{return null}let r=t.filter(s=>s.isFile()&&s.name.endsWith(".go")&&!s.name.endsWith("_test.go")).map(s=>({path:B.join(e,s.name),isExternal:!1})).sort((s,n)=>s.path.localeCompare(n.path));return r.length>0?r:null}import ra from"fs";import ae from"path";var rt=class{extensions=[".lua"];resolve(t,r,s,n){let i=r.replace(/\./g,ae.sep),o=[s,ae.join(s,"lib")];for(let a of o){if(!ra.existsSync(a))continue;let c=n(ae.join(a,"_dummy.lua"),i);if(c)return[c]}return null}};import sa from"path";var st=class{extensions=[".md",".mdx"];resolve(t,r,s,n){let i=n(sa.join(s,"_dummy"),`./${r}`);return i?[i]:null}};import na from"fs";import ce from"path";var nt=class{extensions=[".py"];resolve(t,r,s,n){let i=r.replace(/\./g,ce.sep),o=ce.join(s,`${i}.py`);if(Qr(o))return[{path:o,isExternal:!1}];let a=ce.join(s,i,"__init__.py");return Qr(a)?[{path:a,isExternal:!1}]:null}};function Qr(e){try{return na.statSync(e,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}import Xr from"path";var ia=["~","http://","https://","//","data:","sass:"],it=class{extensions=[".css",".scss",".sass",".less",".styl"];resolve(t,r,s,n){if(ia.some(g=>r.startsWith(g)))return null;let i=n(t,r);if(i)return[i];let o=Xr.dirname(r),a=Xr.basename(r),c=o==="."?`_${a}`:`${o}/_${a}`,p=n(t,c);return p?[p]:null}};var A=class{constructor(t,r={}){this.rootDir=t;this.workspaceMap=r.workspaceMap??new Map,this.tsconfigSearchPaths=r.tsconfigSearchPaths??[t],this.pathAliases=r.pathAliases,this.langResolvers=r.langResolvers??[new nt,new rt,new et,new it,new st]}rootDir;workspaceMap;tsconfigSearchPaths;pathAliases;langResolvers;resolveAll(t,r){let s=this.resolvePathAlias(r);if(s)return[s];if(r.startsWith(".")||r.startsWith("/")){let o=this.resolveLocalPath(t,r);return o?[o]:[]}let n=(o,a)=>this.resolveLocalPath(o,a);for(let o of this.langResolvers)if(o.extensions.some(a=>t.endsWith(a))){let a=o.resolve(t,r,this.rootDir,n);if(a)return a}let i=this.resolveWorkspaceImport(r);return i?[i]:[{path:r,isExternal:!0}]}resolve(t,r){let s=this.resolvePathAlias(r);if(s)return s;if(r.startsWith(".")||r.startsWith("/"))return this.resolveLocalPath(t,r);let n=(o,a)=>this.resolveLocalPath(o,a);for(let o of this.langResolvers)if(o.extensions.some(a=>t.endsWith(a))){let a=o.resolve(t,r,this.rootDir,n);if(a)return a[0]??null}let i=this.resolveWorkspaceImport(r);return i||{path:r,isExternal:!0}}resolveLocalPath(t,r){let s=N.dirname(t),n=r.startsWith("/")?r:N.resolve(s,r),i=!n.startsWith(this.rootDir),o=["",".ts",".tsx",".js",".jsx",".mjs",".cjs",".css",".scss",".sass",".less",".styl",".coffee",".ls",".lua",".py",".feature",".md",".mdx"],a=n.match(/\.(js|mjs|cjs)$/);if(a){let c=n.slice(0,-a[0].length);for(let p of[".ts",".tsx"]){let g=this.tryExtensions(c,p,i);if(g)return g}}for(let c of o){let p=this.tryExtensions(n,c,i);if(p)return p}return i?{path:n,isExternal:!0}:null}tryExtensions(t,r,s){let n=t+r;if(this.isFile(n))return{path:n,isExternal:s};let i=N.join(t,`index${r}`);if(this.isFile(i))return{path:i,isExternal:s};if(r===".py"){let o=N.join(t,"__init__.py");if(this.isFile(o))return{path:o,isExternal:s}}return null}isFile(t){try{return Pt.statSync(t,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}resolvePathAlias(t){if(this.pathAliases)for(let r in this.pathAliases){let s=this.matchAliasPattern(r,t),n=this.pathAliases[r];if(s&&n){let i=this.tryAliasSubstitutions(n,s[1]||"");if(i)return i}}for(let r of this.tsconfigSearchPaths){let s=N.join(r,"tsconfig.json");if(Pt.existsSync(s))try{let i=JSON.parse(Pt.readFileSync(s,"utf-8")).compilerOptions?.paths;if(!i)continue;for(let o in i){let a=this.matchAliasPattern(o,t);if(a){let c=this.tryAliasSubstitutions(i[o],a[1]||"",r);if(c)return c}}}catch{}}return null}aliasRegexCache=new Map;matchAliasPattern(t,r){let s=this.aliasRegexCache.get(t);if(!s){let n=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace("\\*","(.*)");s=new RegExp(`^${n}$`),this.aliasRegexCache.set(t,s)}return r.match(s)}tryAliasSubstitutions(t,r,s=this.rootDir){let n=["",".ts",".tsx",".js",".jsx",".coffee",".ls",".lua",".feature"];for(let i of t){let o=i.replace("*",r),a=N.resolve(s,o);for(let c of n){let p=this.tryExtensions(a,c,!1);if(p)return p}}return null}resolveWorkspaceImport(t){if(this.workspaceMap.size===0)return null;for(let[r,s]of this.workspaceMap){if(t!==r&&!t.startsWith(`${r}/`))continue;let n=t.slice(r.length),i={path:"",isExternal:!1,isWorkspace:!0,workspacePackage:r};if(!n){for(let a of["src/index.ts","src/index.tsx","index.ts","index.tsx","index.js"]){let c=N.join(s,a);try{if(Pt.statSync(c,{throwIfNoEntry:!1})?.isFile())return{...i,path:c}}catch{}}return{...i,path:s}}let o=this.resolveLocalPath(N.join(s,"_dummy"),n.slice(1));return o?{...i,path:o.path}:null}return null}};var aa=["tests","test","__tests__","specs","spec"],Yr=new Set(["node_modules",".git","dist","build",".next",".cache","mokosh-cache","coverage"]),ca=20;function pa(e,t){if(e.length===0)return t;let r=e.map(o=>E.dirname(o).split(E.sep)),s=r[0];for(let o of r.slice(1)){let a=0;for(;a<s.length&&a<o.length&&s[a]===o[a];)a++;s=s.slice(0,a)}let n=s.join(E.sep)||E.sep,i=E.relative(t,n);return i.startsWith("..")||E.isAbsolute(i)?t:n}var at=class{constructor(t,r=null,s,n,i=!1,o=new Map,a=!0){this.rootDir=t;this.enableGitStats=i;this.coverageMap=o;this.parallelParsing=a;this.previousGraph=r,this.resolver=s||new A(t),this.lockFile=lr(t),n&&(this.progressCallback=n)}rootDir;enableGitStats;coverageMap;parallelParsing;graph={nodes:new Map};visited=new Set;queue=[];previousGraph=null;resolver;lockFile=null;progressCallback;pool=null;gitStatsMap=null;async build(t){let r=t.map(s=>E.isAbsolute(s)?s:E.resolve(this.rootDir,s));await this.initPool(),this.enableGitStats&&(this.gitStatsMap=ar(this.rootDir));try{for(let s of r)this.enqueue(s);return await this.drain(),await this.processTestFiles(pa(r,this.rootDir)),await this.processDocFiles(),this.progressCallback&&this.visited.size>=100&&process.stderr.write(`
22
22
  Done. Total processed: ${this.visited.size} nodes.
23
- `),$r(this.graph.nodes),jr(this.graph.nodes),Wr(this.graph.nodes),_r(this.graph.nodes),this.coverageMap.size>0&&Gr(this.graph.nodes,this.coverageMap),new I(this.graph.nodes)}finally{this.pool&&(await this.pool.destroy(),this.pool=null)}}async initPool(){if(this.parallelParsing===!1)return;let t=typeof this.parallelParsing=="object"?this.parallelParsing:{},r=t.minFiles??Zo;if(!(r>0&&!this.hasAtLeastFiles(this.rootDir,r)))try{let s=k.join(m,"parse-worker.js");this.pool=new Xo({filename:s,...t.maxThreads!==void 0?{maxThreads:t.maxThreads}:{}})}catch(s){process.stderr.write(`
23
+ `),Kr(this.graph.nodes),$r(this.graph.nodes),Ur(this.graph.nodes),Br(this.graph.nodes),this.coverageMap.size>0&&Wr(this.graph.nodes,this.coverageMap),new I(this.graph.nodes)}finally{this.pool&&(await this.pool.destroy(),this.pool=null)}}async initPool(){if(this.parallelParsing===!1)return;let t=typeof this.parallelParsing=="object"?this.parallelParsing:{},r=t.minFiles??ca;if(!(r>0&&!this.hasAtLeastFiles(this.rootDir,r)))try{let s=E.join(f,"parse-worker.js");this.pool=new oa({filename:s,...t.maxThreads!==void 0?{maxThreads:t.maxThreads}:{}})}catch(s){process.stderr.write(`
24
24
  Warning: failed to start parse worker pool, falling back to synchronous parsing: ${s}
25
- `),this.pool=null}}hasAtLeastFiles(t,r){let s=0,n=[t];for(;n.length>0;){let i=n.pop(),o;try{o=it.readdirSync(i,{withFileTypes:!0})}catch{continue}for(let a of o)if(a.isDirectory())Hr.has(a.name)||n.push(k.join(i,a.name));else if(a.isFile()&&(s++,s>=r))return!0}return s>=r}async processTestFiles(t){let r=U(),s=i=>r.some(o=>i.name.includes(o));this.walkProject(t,s);let n=t;for(;n!==this.rootDir;){let i=k.dirname(n);if(i===n)break;for(let o of Yo){let a=k.join(i,o);try{it.statSync(a).isDirectory()&&this.walkProject(a,s)}catch{}}n=i}await this.drain()}async processDocFiles(){this.walkProject(this.rootDir,t=>t.name.endsWith(".md")||t.name.endsWith(".mdx")),await this.drain()}walkProject(t,r){let s;try{s=it.readdirSync(t,{withFileTypes:!0})}catch{return}for(let n of s){let i=k.join(t,n.name);n.isDirectory()?Hr.has(n.name)||this.walkProject(i,r):n.isFile()&&r(n)&&this.enqueue(i)}}enqueue(t){this.visited.has(t)||(this.visited.add(t),this.showProgress(),this.queue.push(t))}async drain(){for(;this.queue.length>0;){let t=this.queue;this.queue=[],await Promise.all(t.map(r=>this.finishFile(r)))}}async finishFile(t){let r=it.statSync(t,{throwIfNoEntry:!1});if(!r?.isFile())return;let s=k.relative(this.rootDir,t),n=await this.getNode(t,s,r);n.imports=await this.resolveImports(t,n.imports),Or(n.imports,n.tags),this.graph.nodes.set(n.path,n)}async getNode(t,r,s){let n=this.previousGraph?.nodes.get(r);if(n&&n.mtime===s.mtimeMs&&n.size===s.size)return{...n};let i=await this.tryParse(t,r);if(!i)return this.makeStubNode(t,r,s);let o=this.resolveCallEdges(t,i.rawCallEdges),a=this.buildNode(t,r,s,i,o);return this.attachGitStats(a,r),a}async tryParse(t,r){let s=it.readFileSync(t,"utf-8");try{return await this.parseContent(t,s)}catch(n){return process.stderr.write(`
25
+ `),this.pool=null}}hasAtLeastFiles(t,r){let s=0,n=[t];for(;n.length>0;){let i=n.pop(),o;try{o=ot.readdirSync(i,{withFileTypes:!0})}catch{continue}for(let a of o)if(a.isDirectory())Yr.has(a.name)||n.push(E.join(i,a.name));else if(a.isFile()&&(s++,s>=r))return!0}return s>=r}async processTestFiles(t){let r=K(),s=i=>r.some(o=>i.name.includes(o));this.walkProject(t,s);let n=t;for(;n!==this.rootDir;){let i=E.dirname(n);if(i===n)break;for(let o of aa){let a=E.join(i,o);try{ot.statSync(a).isDirectory()&&this.walkProject(a,s)}catch{}}n=i}await this.drain()}async processDocFiles(){this.walkProject(this.rootDir,t=>t.name.endsWith(".md")||t.name.endsWith(".mdx")),await this.drain()}walkProject(t,r){let s;try{s=ot.readdirSync(t,{withFileTypes:!0})}catch{return}for(let n of s){let i=E.join(t,n.name);n.isDirectory()?Yr.has(n.name)||this.walkProject(i,r):n.isFile()&&r(n)&&this.enqueue(i)}}enqueue(t){this.visited.has(t)||(this.visited.add(t),this.showProgress(),this.queue.push(t))}async drain(){for(;this.queue.length>0;){let t=this.queue;this.queue=[],await Promise.all(t.map(r=>this.finishFile(r)))}}async finishFile(t){let r=ot.statSync(t,{throwIfNoEntry:!1});if(!r?.isFile())return;let s=E.relative(this.rootDir,t),n=await this.getNode(t,s,r);n.imports=await this.resolveImports(t,n.imports),zr(n.imports,n.tags),this.graph.nodes.set(n.path,n)}async getNode(t,r,s){let n=this.previousGraph?.nodes.get(r);if(n&&n.mtime===s.mtimeMs&&n.size===s.size)return{...n};let i=await this.tryParse(t,r);if(!i)return this.makeStubNode(t,r,s);let o=this.resolveCallEdges(t,i.rawCallEdges),a=this.buildNode(t,r,s,i,o);return this.attachGitStats(a,r),a}async tryParse(t,r){let s=ot.readFileSync(t,"utf-8");try{return await this.parseContent(t,s)}catch(n){return process.stderr.write(`
26
26
  Warning: failed to parse ${r}: ${n}
27
- `),null}}parseContent(t,r){return this.pool?this.pool.run({filePath:t,content:r}):Ar(t,r)}makeStubNode(t,r,s){return{path:r,type:P(t),category:"other",imports:[],exports:[],tags:[],mtime:s.mtimeMs,size:s.size}}resolveCallEdges(t,r){let s=[];for(let n of r??[])try{let i=this.resolver.resolve(t,n.toSpecifier);i&&!i.isExternal&&s.push({from:n.from,to:n.to,toFile:k.relative(this.rootDir,i.path)})}catch{}return s}buildNode(t,r,s,n,i){let{imports:o,exports:a,tags:c,category:p,description:g,complexity:u,cognitiveComplexity:y,functions:b}=n;return{path:r,type:P(t),category:p,imports:o,exports:a,tags:c,mtime:s.mtimeMs,size:s.size,...g!==void 0?{description:g}:{},...i.length>0?{callEdges:i}:{},...u!==void 0?{complexity:u}:{},...y!==void 0?{cognitiveComplexity:y}:{},...b!==void 0?{functions:b}:{}}}attachGitStats(t,r){let s=this.gitStatsMap?.get(r);s&&(t.commitCount90d=s.commitCount90d,s.lastAuthor!==void 0&&(t.lastAuthor=s.lastAuthor),s.lastCommitAt!==void 0&&(t.lastCommitAt=s.lastCommitAt))}async resolveImports(t,r){let s=[];for(let n of r){let i=this.resolver.resolveAll(t,n.rawSpecifier);if(i.length!==0)for(let o of i){let a={...n,toPath:o.isExternal?o.path:k.relative(this.rootDir,o.path),isExternal:o.isExternal};o.isWorkspace&&(a.isWorkspace=!0,a.workspacePackage=o.workspacePackage),o.isExternal?this.attachLockfileVersion(a):this.enqueue(o.path),s.push(a)}}return s}attachLockfileVersion(t){if(!this.lockFile)return;let r=t.rawSpecifier.startsWith("@")?t.rawSpecifier.split("/").slice(0,2).join("/"):t.rawSpecifier.split("/")[0],s=r?this.lockFile.dependencies[r]:void 0;s&&(t.version=s.version)}showProgress(){this.progressCallback&&this.visited.size%100===0&&this.progressCallback(this.visited.size)}};function Qr(e,t){return{identifier:t?.identifier??new Ct,featureMap:t?.featureDetection===!1?new Map:J(e.nodes,t?.featureDetection??void 0)}}function Vr(e,t,r,s,n){for(let i of t){let o=e.nodes.get(i);if(!o)continue;let a=new M(i,["*",...o.exports.map(c=>c.name)]);e.traverse(i,(c,p,g)=>{if(!g)return!0;if(!a.updateAffectedSymbols(c,g))return!1;if(p>0){let u=r.get(c.path);if(u)return s(u),!1}return n(c),!0},{direction:"incoming"})}}function ta(e,t,r){let{identifier:s,featureMap:n}=Qr(e,r),i=new Set;for(let o of t){let a=n.get(o);a&&i.add(a.tag)}return Vr(e,t,n,o=>i.add(o.tag),o=>{if(s.isTestNode(o))for(let a of o.tags)i.add(a.name)}),Array.from(i)}function ea(e,t,r){let{identifier:s,featureMap:n}=Qr(e,r),i=new Set;return Vr(e,t,n,()=>{},o=>{s.isTestNode(o)&&i.add(o.path)}),Array.from(i)}import ra from"fs";import at from"path";async function Tu(e,t,r=null,s={}){let n=s.silent?void 0:a=>{process.stderr.write(`Processed ${a} files...\r`)},i=at.resolve(e);return await new ot(i,r,s.pathAliases?new N(i,{pathAliases:s.pathAliases}):void 0,n,s.gitStats??!1,s.coverageMap??new Map,s.parallelParsing??!0).build(t)}async function Iu(e,t={}){let r=at.resolve(e),s=Ut(r),n=t.packages?s.packages.filter(a=>t.packages?.includes(a.name)||t.packages?.includes(a.relativeRoot)):s.packages,i=new Map(s.packages.map(a=>[a.name,a.root])),o=new X(r,s.type);for(let a of n){let c=t.silent?void 0:u=>{process.stderr.write(`[${a.name}] Processed ${u} files...\r`)},g=await new ot(r,null,new N(r,{workspaceMap:i,tsconfigSearchPaths:[a.root,r],pathAliases:t.pathAliases}),c,t.gitStats??!1,new Map,t.parallelParsing??!0).build(a.entryPoints);o.addPackage(a,g)}return o}function Mu(e,t={}){let r=[],s=new Set([...t.ignoreDirs??Dt,...t.additionalIgnoreDirs??[]]),n=new Set([...t.extensions??Lt,...t.additionalExtensions??[]]);function i(o){try{let a=ra.readdirSync(o,{withFileTypes:!0});for(let c of a){let p=at.join(o,c.name);c.isDirectory()?s.has(c.name)||i(p):c.isFile()&&n.has(at.extname(c.name).toLowerCase())&&r.push(at.relative(e,p))}}catch{}}return i(e),r}export{ut as CALL_EDGE_TYPES,Lt as DEFAULT_EXTENSIONS,Dt as DEFAULT_IGNORE_DIRS,ke as EXPORT_TRACKING_TYPES,I as Graph,ft as IMPORT_SYMBOL_TYPES,Gt as MermaidExporter,M as SymbolTraversalContext,X as WorkspaceGraph,ns as applyConfig,pi as applyTags,hs as buildApiSurface,Ss as buildChangeImpactCache,_t as buildFeatureGraph,Ws as buildResponsibilityGraph,Us as buildTypeGraph,jt as computeGraphHash,is as configToGraphOptions,Tu as createImportMap,Iu as createWorkspaceGraph,ve as detectAllEntryPoints,ms as detectEntryPoint,J as detectFeatures,Ut as detectMonorepo,$e as filterGraph,Gs as findComplexFunctions,$s as findSymbol,Ds as getAffected,Mu as getAllProjectFiles,Ls as getCallers,As as getDependencies,Wt as getDependents,Ns as getLanguageCoverage,Rs as getNodeMeta,_s as hasCoverageData,vs as isChangeImpactCacheValid,Cs as loadChangeImpactCache,as as loadCoverageMap,At as loadMokoshConfig,Be as parseQuery,ea as proposeAffectedTests,ta as proposeTags,ys as queryCallGraph,bs as queryChangeImpact,Ks as queryTypeGraph,ct as registerConfigMatcher,w as registerMonorepoDetector,D as registerParser,lt as registerTestLibrary,pt as registerTestPattern,ks as saveChangeImpactCache,Os as slimSerialize,js as summarizeWorkspacePackages,xe as toMermaid};
27
+ `),null}}parseContent(t,r){return this.pool?this.pool.run({filePath:t,content:r}):Or(t,r)}makeStubNode(t,r,s){return{path:r,type:T(t),category:"other",imports:[],exports:[],tags:[],mtime:s.mtimeMs,size:s.size}}resolveCallEdges(t,r){let s=[];for(let n of r??[])try{let i=this.resolver.resolve(t,n.toSpecifier);i&&!i.isExternal&&s.push({from:n.from,to:n.to,toFile:E.relative(this.rootDir,i.path)})}catch{}return s}buildNode(t,r,s,n,i){let{imports:o,exports:a,tags:c,category:p,description:g,complexity:u,cognitiveComplexity:y,functions:b}=n;return{path:r,type:T(t),category:p,imports:o,exports:a,tags:c,mtime:s.mtimeMs,size:s.size,...g!==void 0?{description:g}:{},...i.length>0?{callEdges:i}:{},...u!==void 0?{complexity:u}:{},...y!==void 0?{cognitiveComplexity:y}:{},...b!==void 0?{functions:b}:{}}}attachGitStats(t,r){let s=this.gitStatsMap?.get(r);s&&(t.commitCount90d=s.commitCount90d,s.lastAuthor!==void 0&&(t.lastAuthor=s.lastAuthor),s.lastCommitAt!==void 0&&(t.lastCommitAt=s.lastCommitAt))}async resolveImports(t,r){let s=[];for(let n of r){let i=this.resolver.resolveAll(t,n.rawSpecifier);if(i.length!==0)for(let o of i){let a={...n,toPath:o.isExternal?o.path:E.relative(this.rootDir,o.path),isExternal:o.isExternal};o.isWorkspace&&(a.isWorkspace=!0,a.workspacePackage=o.workspacePackage),o.isExternal?this.attachLockfileVersion(a):this.enqueue(o.path),s.push(a)}}return s}attachLockfileVersion(t){if(!this.lockFile)return;let r=t.rawSpecifier.startsWith("@")?t.rawSpecifier.split("/").slice(0,2).join("/"):t.rawSpecifier.split("/")[0],s=r?this.lockFile.dependencies[r]:void 0;s&&(t.version=s.version)}showProgress(){this.progressCallback&&this.visited.size%100===0&&this.progressCallback(this.visited.size)}};function Zr(e,t){return{identifier:t?.identifier??new kt,featureMap:t?.featureDetection===!1?new Map:H(e.nodes,t?.featureDetection??void 0)}}function qr(e,t,r,s,n){for(let i of t){let o=e.nodes.get(i);if(!o)continue;let a=new M(i,["*",...o.exports.map(c=>c.name)]);e.traverse(i,(c,p,g)=>{if(!g)return!0;if(!a.updateAffectedSymbols(c,g))return!1;if(p>0){let u=r.get(c.path);if(u)return s(u),!1}return n(c),!0},{direction:"incoming"})}}function la(e,t,r){let{identifier:s,featureMap:n}=Zr(e,r),i=new Set;for(let o of t){let a=n.get(o);a&&i.add(a.tag)}return qr(e,t,n,o=>i.add(o.tag),o=>{if(s.isTestNode(o))for(let a of o.tags)i.add(a.name)}),Array.from(i)}function fa(e,t,r){let{identifier:s,featureMap:n}=Zr(e,r),i=new Set;return qr(e,t,n,()=>{},o=>{s.isTestNode(o)&&i.add(o.path)}),Array.from(i)}import ma from"fs";import ct from"path";async function _u(e,t,r=null,s={}){let n=s.silent?void 0:a=>{process.stderr.write(`Processed ${a} files...\r`)},i=ct.resolve(e);return await new at(i,r,s.pathAliases?new A(i,{pathAliases:s.pathAliases}):void 0,n,s.gitStats??!1,s.coverageMap??new Map,s.parallelParsing??!0).build(t)}async function Wu(e,t={}){let r=ct.resolve(e),s=Kt(r),n=t.packages?s.packages.filter(a=>t.packages?.includes(a.name)||t.packages?.includes(a.relativeRoot)):s.packages,i=new Map(s.packages.map(a=>[a.name,a.root])),o=new Y(r,s.type);for(let a of n){let c=t.silent?void 0:u=>{process.stderr.write(`[${a.name}] Processed ${u} files...\r`)},g=await new at(r,null,new A(r,{workspaceMap:i,tsconfigSearchPaths:[a.root,r],pathAliases:t.pathAliases}),c,t.gitStats??!1,new Map,t.parallelParsing??!0).build(a.entryPoints);o.addPackage(a,g)}return o}function zu(e,t={}){let r=[],s=new Set([...t.ignoreDirs??Lt,...t.additionalIgnoreDirs??[]]),n=new Set([...t.extensions??Gt,...t.additionalExtensions??[]]);function i(o){try{let a=ma.readdirSync(o,{withFileTypes:!0});for(let c of a){let p=ct.join(o,c.name);c.isDirectory()?s.has(c.name)||i(p):c.isFile()&&n.has(ct.extname(c.name).toLowerCase())&&r.push(ct.relative(e,p))}}catch{}}return i(e),r}export{gt as CALL_EDGE_TYPES,Gt as DEFAULT_EXTENSIONS,Lt as DEFAULT_IGNORE_DIRS,Ce as EXPORT_TRACKING_TYPES,I as Graph,ut as IMPORT_SYMBOL_TYPES,Ot as MermaidExporter,M as SymbolTraversalContext,Y as WorkspaceGraph,cs as applyConfig,ui as applyTags,bs as buildApiSurface,Cs as buildChangeImpactCache,Wt as buildFeatureGraph,Us as buildResponsibilityGraph,Vs as buildTypeGraph,_t as computeGraphHash,ps as configToGraphOptions,_u as createImportMap,Wu as createWorkspaceGraph,Ee as detectAllEntryPoints,ds as detectEntryPoint,H as detectFeatures,Kt as detectMonorepo,$e as filterGraph,Ws as findComplexFunctions,Ks as findSymbol,js as getAffected,zu as getAllProjectFiles,_s as getCallers,Os as getDependencies,zt as getDependents,Ls as getLanguageCoverage,Gs as getNodeMeta,Bs as hasCoverageData,ws as isChangeImpactCacheValid,Ts as loadChangeImpactCache,fs as loadCoverageMap,Dt as loadMokoshConfig,Ue as parseQuery,fa as proposeAffectedTests,la as proposeTags,vs as queryCallGraph,ks as queryChangeImpact,Qs as queryTypeGraph,pt as registerConfigMatcher,F as registerMonorepoDetector,G as registerParser,ft as registerTestLibrary,lt as registerTestPattern,Fs as saveChangeImpactCache,zs as slimSerialize,$s as summarizeWorkspacePackages,Se as toMermaid};
28
28
  //# sourceMappingURL=index.mjs.map