@omfalos/mokosh 0.1.10 → 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/cli.js +28 -28
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +30 -30
- package/dist/cli.mjs.map +1 -1
- package/dist/index.js +15 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -15
- package/dist/index.mjs.map +1 -1
- package/dist/mcp.js +17 -17
- package/dist/mcp.js.map +1 -1
- package/dist/mcp.mjs +17 -17
- package/dist/mcp.mjs.map +1 -1
- package/dist/parse-worker.js +1 -1
- package/dist/parse-worker.js.map +1 -1
- package/dist/parse-worker.mjs +1 -1
- package/dist/parse-worker.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
`)}};function Vt(e){return Ct.serialize(e)}var Xt=m(require("fs")),Ve=m(require("path"));function Yt(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 Xe(e,t){if(typeof e=="string")return Yt(e,t);if(e&&typeof e=="object"){let r=e;for(let s of["import","require","default"]){let n=Xe(r[s],t);if(n)return n}}return null}function fn(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 mn(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 Ye(e,t){return Zt(e,t)[0]??null}function Zt(e,t){let r=[],s=Ve.default.join(t,"package.json");if(Xt.default.existsSync(s))try{let n=JSON.parse(Xt.default.readFileSync(s,"utf8"));if(n.exports&&typeof n.exports=="object"&&!Array.isArray(n.exports))for(let i of Object.values(n.exports)){let o=Xe(i,e);o&&!r.includes(o)&&r.push(o)}else if(typeof n.exports=="string"){let i=Yt(n.exports,e);i&&r.push(i)}if(r.length===0)for(let i of[n.main,n.module].filter(Boolean)){let o=Yt(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 un(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 gn(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 dn(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:fn(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 hn(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 Ze(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=un(e,t),s=gn(e,r,t),n=mn(e,t),i=dn(n,s,e,t),{internalFiles:o,unreachableFromEntry:a,testFiles:c}=hn(e,r,t);return{entryPoints:t,publicExports:i,internalFiles:o,unreachableFromEntry:a,testFiles:c}}function qe(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}}var L=m(require("fs")),tr=m(require("path"));function Et(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 er(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:Et(e)}}function rr(e,t){return e.impact.get(t)??[]}function sr(e,t){return e.graphHash===Et(t)}function nr(e,t){let r=tr.default.dirname(t);L.default.existsSync(r)||L.default.mkdirSync(r,{recursive:!0});let s={graphHash:e.graphHash,impact:[...e.impact.entries()]};L.default.writeFileSync(t,JSON.stringify(s))}function ir(e){if(!L.default.existsSync(e))return null;try{let t=L.default.readFileSync(e,"utf-8"),r=JSON.parse(t);return{graphHash:r.graphHash,impact:new Map(r.impact)}}catch{return null}}var et=m(require("path"));function yn(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 xn(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=et.default.extname(n),c=et.default.basename(n,a),p=c==="index"?et.default.basename(et.default.dirname(n)):c;s.set(n,{path:n,outDegree:i,tag:`feature:${p}`})}return s}function G(e,t){let r=t?.minOutDegree??5;return xn(e,yn(e),r)}var Sn=(e,t)=>e.outDegree-t.outDegree;function bn(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 vn(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 kn(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 Cn(e,t,r){let s=[];for(let n of e.keys())!t.has(n)&&!r.has(n)&&s.push(n);return s}function Ft(e,t){let r=t?.detectFn??G,s=t?.hubComparator??Sn,n=r(e.nodes,t),i=bn(e,n),o=vn(e.nodes,n,i,s);return{features:kn(n,o),unassigned:Cn(e.nodes,n,o)}}var qt=new Set(["typescript","javascript","python","go"]),rt=new Set(["typescript","javascript","python"]),st=new Set(["typescript","javascript"]);function or(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:qt.has(r),importSymbolsTracked:rt.has(r),callEdgesTracked:st.has(r)})).sort((r,s)=>s.fileCount-r.fileCount)}var nt=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 T=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 nt(this.nodes).findUnusedFiles(t)}findCycles(){return new nt(this.nodes).findCycles()}};var I=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 ar(e,t){let r=e.nodes.get(t);if(r)return{category:r.category,exports:r.exports.map(s=>s.name)}}function cr(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 pr(e,t,r={}){let{testsOnly:s=!1,changedSymbols:n}=r,i=n?new I(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 lr(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 fr(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 mr(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 ur(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 gr(e){return[...e.nodes.values()].some(t=>t.coveragePct!==void 0)}function dr(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")||it(t)==="cli"?"cli":h(t,"util")||h(t,"utils")||h(t,"helper")||h(t,"helpers")?"util":h(t,"model")||h(t,"models")||it(t)==="model"?"model":h(t,"parser")||h(t,"parsers")||it(t)==="parser"?"parser":it(t)==="builder"?"builder":it(t)==="resolver"?"resolver":"other"}function h(e,t){return e.includes(`/${t}/`)||e.includes(`/${t}.`)}function it(e){let t=e.slice(e.lastIndexOf("/")+1);return t.slice(0,t.lastIndexOf("."))||t}function hr(e,t){let r=Ft(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:dr(i),...i.description?{description:i.description}:{},exports:i.exports.map(a=>a.name),...o?{featureHub:o}:{}})}return n}function yr(e,t){let r=[];for(let s of e.nodes.values())if(s.exports.some(n=>n.name===t))if(st.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(rt.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 En(e){return e?e.startsWith("interface ")?"interface":e.startsWith("class ")?"class":e.startsWith("enum ")?"enum":"type":"type"}function Fn(e,t){if(t==="type-only")return!0;let r=e.signature??"";return r.startsWith("interface ")||r.startsWith("class ")||r.startsWith("enum ")}function xr(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(!Fn(n,s.category))continue;let i=`${s.path}::${n.name}`;t.set(i,{name:n.name,file:s.path,kind:En(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 Sr(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())}}var Dr=m(require("path"));var Tt=m(require("fs")),re=m(require("path"));var O=m(require("fs")),C=m(require("path"));var te=m(require("fs")),wn=m(require("path"));function br(e){try{return te.default.statSync(e,{throwIfNoEntry:!1})?.isDirectory()===!0}catch{return!1}}function Pt(e){try{return te.default.statSync(e,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}function ee(e,t){let r=C.default.join(t,"package.json");if(!O.default.existsSync(r))return null;let s={};try{s=JSON.parse(O.default.readFileSync(r,"utf-8"))}catch{return null}let n=s.name;return n?{name:n,root:t,relativeRoot:C.default.relative(e,t),entryPoints:Pn(t,s)}:null}function Pn(e,t){let r=[];if(t.exports){let n=t.exports;if(typeof n=="string")r.push(C.default.join(e,n));else if(typeof n=="object"&&n!==null){let i=n["."];if(typeof i=="string")r.push(C.default.join(e,i));else if(typeof i=="object"&&i!==null){let o=i.import??i.require??i.default;typeof o=="string"&&r.push(C.default.join(e,o))}}}t.main&&r.push(C.default.join(e,t.main));for(let n of["src/index.ts","src/index.tsx","index.ts","index.tsx","index.js"])r.push(C.default.join(e,n));let s=r.filter(Pt);return s.length>0?s.slice(0,1):r.slice(0,1)}function j(e,t){let r=[],s=new Set;for(let n of t){let i=n.replace(/\/$/,"").replace(/^\.\//,"");Tn(e,i,s,r)}return r}function Tn(e,t,r,s){if(!t.includes("*")){In(e,t,r,s);return}let n=t.split("/");n.includes("**")?Mn(e,n,r,s):Nn(e,n,r,s)}function In(e,t,r,s){let n=C.default.join(e,t);if(r.has(n)||!br(n))return;r.add(n);let i=ee(e,n);i&&s.push(i)}function Mn(e,t,r,s){let n=C.default.join(e,t[0]==="**"?"":t[0]??"");vr(e,n,r,s)}function Nn(e,t,r,s){let n=t.findIndex(a=>a.includes("*")),i=C.default.join(e,...t.slice(0,n)),o;try{o=O.default.readdirSync(i,{withFileTypes:!0})}catch{return}for(let a of o){if(!a.isDirectory())continue;let c=C.default.join(i,a.name);if(r.has(c))continue;r.add(c);let p=ee(e,c);p&&s.push(p)}}function vr(e,t,r,s){let n;try{n=O.default.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.default.join(t,i.name);if(O.default.existsSync(C.default.join(o,"package.json"))&&!r.has(o)){r.add(o);let a=ee(e,o);a&&s.push(a)}else vr(e,o,r,s)}}var kr={type:"npm",detect(e){let t=re.default.join(e,"package.json");if(!Tt.default.existsSync(t))return null;let r;try{r=JSON.parse(Tt.default.readFileSync(t,"utf-8")).workspaces}catch{return null}if(!r||Tt.default.existsSync(re.default.join(e,"yarn.lock")))return null;let s=Array.isArray(r)?r:r.packages??[];return s.length===0?null:j(e,s)}};var N=m(require("fs")),S=m(require("path"));var Cr={type:"nx",detect(e){return N.default.existsSync(S.default.join(e,"nx.json"))?Er(e,e,new Set,0).map(r=>Rn(e,r,S.default.join(r,"project.json"))).filter(r=>r!==null):null}};function Er(e,t,r,s){if(s>4)return[];let n;try{n=N.default.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.default.join(t,a);N.default.existsSync(S.default.join(c,"project.json"))&&!r.has(c)?(r.add(c),i.push(c)):i.push(...Er(e,c,r,s+1))}return i}function Rn(e,t,r){let s={};try{s=JSON.parse(N.default.readFileSync(r,"utf-8"))}catch{return null}let n=s.name,i,o,a=S.default.join(t,"package.json");if(N.default.existsSync(a))try{let c=JSON.parse(N.default.readFileSync(a,"utf-8"));n=c.name??n,i=c.main,o=c.exports}catch{}return n?{name:n,root:t,relativeRoot:S.default.relative(e,t),entryPoints:An(t,s,i,o)}:null}function An(e,t,r,s){let n=[],i=t.targets?.build?.options?.main??t.targets?.build?.options?.entryFile;if(i){let a=S.default.resolve(e,"../..");n.push(S.default.resolve(a,i)),n.push(S.default.resolve(e,i))}if(s){let a=s;if(typeof a=="string")n.push(S.default.join(e,a));else if(typeof a=="object"&&a!==null){let c=a["."];typeof c=="string"&&n.push(S.default.join(e,c))}}if(r&&n.push(S.default.join(e,r)),t.sourceRoot){let a=S.default.resolve(e,"../.."),c=S.default.resolve(a,t.sourceRoot);n.push(S.default.join(c,"index.ts"),S.default.join(c,"index.tsx"))}for(let a of["src/index.ts","src/index.tsx","index.ts","index.tsx"])n.push(S.default.join(e,a));let o=n.filter(Pt);return o.length>0?o.slice(0,1):n.slice(0,1)}var se=m(require("fs")),Fr=m(require("path")),wr=require("js-yaml");var Pr={type:"pnpm",detect(e){let t=Fr.default.join(e,"pnpm-workspace.yaml");if(!se.default.existsSync(t))return null;let r=[];try{r=(0,wr.load)(se.default.readFileSync(t,"utf-8"))?.packages??[]}catch{return null}return j(e,r)}};var Tr=m(require("fs")),Ir=m(require("path")),Mr={type:"turborepo",detect(e){return Tr.default.existsSync(Ir.default.join(e,"turbo.json"))?[]:null}};var It=m(require("fs")),ne=m(require("path"));var Nr={type:"yarn",detect(e){if(!It.default.existsSync(ne.default.join(e,"yarn.lock")))return null;let t=ne.default.join(e,"package.json");if(!It.default.existsSync(t))return null;let r;try{r=JSON.parse(It.default.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:j(e,s)}};var Rr=[];function w(e){Rr.push(e)}function Ar(){return Rr}w(Mr);w(Cr);w(Pr);w(Nr);w(kr);function Mt(e,t=Ar()){let r=Dr.default.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 _=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 T(i);r.packages.set(s.name,{graph:o,pkg:{...s,root:""}})}return r}};var Lr=new Map;function R(e,t){Lr.set(e,t)}function Gr(e){return Lr.get(e)}function Or(e,t){return t.startsWith("!")?e!==t.slice(1):e===t}function Dn(e,t){return t.startsWith("!")?!e.includes(t.slice(1)):e.includes(t)}var Ln=(e,t)=>!t.category||Or(e.category,t.category),Gn=(e,t)=>!t.type||Or(e.type,t.type),On=(e,t)=>t.lastAuthor?t.lastAuthor.startsWith("!")?e.lastAuthor!==t.lastAuthor.slice(1):e.lastAuthor!==void 0&&e.lastAuthor===t.lastAuthor:!0,jn=(e,t)=>!t.path||Dn(e.path,t.path),_n=(e,t)=>t.isExternal===void 0?!0:e.imports.some(s=>s.isExternal)===t.isExternal,Wn=(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)))},$n=(e,t)=>!t.allTags?.length||t.allTags.every(r=>e.tags.some(s=>s.name===r)),zn=(e,t)=>!t.importsFile||e.imports.some(r=>r.toPath?.includes(t.importsFile)),Bn=(e,t,r)=>t.importedBy===void 0?!0:(r?.get(e.path)??[]).some(n=>n.includes(t.importedBy)),Un=(e,t)=>t.minImports===void 0||e.imports.length>=t.minImports,Kn=(e,t)=>t.maxImports===void 0||e.imports.length<=t.maxImports,Jn=(e,t)=>t.minSize===void 0||e.size>=t.minSize,Hn=(e,t)=>t.maxSize===void 0||e.size<=t.maxSize,Qn=(e,t)=>t.hasDocstring===void 0||!!e.description===t.hasDocstring,Vn=(e,t)=>t.isDocumented===void 0||!!e.documentedBy?.length===t.isDocumented,Xn=(e,t)=>t.isStale===void 0||!!e.staleFor?.length===t.isStale,Yn=(e,t)=>t.minCoverage===void 0||(e.coveragePct??101)>=t.minCoverage,Zn=(e,t)=>t.maxCoverage===void 0||(e.coveragePct??0)<=t.maxCoverage,qn=(e,t)=>t.minExportUsage===void 0||(e.avgExportUsage??-1)>=t.minExportUsage,ti=(e,t)=>t.maxExportUsage===void 0||(e.avgExportUsage??0)<=t.maxExportUsage,ei=(e,t)=>t.minComplexity===void 0||(e.complexity??-1/0)>=t.minComplexity,ri=(e,t)=>t.maxComplexity===void 0||(e.complexity??0)<=t.maxComplexity,si=(e,t)=>t.minCognitiveComplexity===void 0||(e.cognitiveComplexity??-1/0)>=t.minCognitiveComplexity,ni=(e,t)=>t.maxCognitiveComplexity===void 0||(e.cognitiveComplexity??0)<=t.maxCognitiveComplexity,ii=(e,t)=>t.minCommits===void 0||(e.commitCount90d??-1/0)>=t.minCommits,oi=(e,t)=>t.maxCommits===void 0||(e.commitCount90d??0)<=t.maxCommits,ai=(e,t,r)=>!t.any?.length||t.any.some(s=>ot(e,s,r)),ci=[Ln,Gn,On,jn,_n,Wn,$n,zn,Bn,Un,Kn,Jn,Hn,Qn,Vn,Xn,Yn,Zn,qn,ti,ei,ri,si,ni,ii,oi,ai];function ot(e,t,r){return ci.every(s=>s(e,t,r))}function ie(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=>ot(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 jr(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 pi(e){let t=[];for(let r of e.split("|")){let s=r.trim();if(!s)continue;let n={};jr(n,s),Object.keys(n).length>0&&t.push(n)}return t}function oe(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=pi(i);o.length>0&&(t.any=[...t.any??[],...o]);continue}jr(t,s)}return t}var Se=m(require("fs/promises")),Qr=m(require("path"));var jt=m(require("path")),at=m(require("typescript"));var ae=m(require("path")),ce=m(require("typescript"));var b=m(require("typescript")),_r=new Set(["describe","test","it"]);function W(e){let t=[];for(let r of e.statements){if(!b.default.isExpressionStatement(r))continue;let s=r.expression;if(!b.default.isCallExpression(s))continue;let n=s.expression;b.default.isIdentifier(n)&&_r.has(n.text)&&t.push(s),b.default.isPropertyAccessExpression(n)&&b.default.isIdentifier(n.expression)&&_r.has(n.expression.text)&&t.push(s)}return t}function $(e,t,r){for(let s of e.arguments){if(!b.default.isObjectLiteralExpression(s))continue;let n=s.properties.find(i=>b.default.isPropertyAssignment(i)&&b.default.isIdentifier(i.name)&&i.name.text===t);if(!(!n||!b.default.isArrayLiteralExpression(n.initializer)))return n.initializer.elements.filter(b.default.isStringLiteral).map(i=>i.text)}return null}function z(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(!b.default.isObjectLiteralExpression(o))continue;let a=o.properties.find(p=>b.default.isPropertyAssignment(p)&&b.default.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 B(e,t,r){let s=e.arguments;for(let n=1;n<s.length;n++){let i=s[n];if(!b.default.isObjectLiteralExpression(i))continue;let o=i.properties.findIndex(c=>b.default.isPropertyAssignment(c)&&b.default.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 U(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 K(e){return`[${e.map(t=>JSON.stringify(t)).join(", ")}]`}var F=new Set([".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"]);function li(e){return K(e.map(t=>`@${t}`))}function fi(e){return e.map(t=>t.startsWith("@")?t.slice(1):t)}var Nt=class{name="cypress";canHandle(t){return F.has(ae.default.extname(t).toLowerCase())}apply(t,r,s){let n=ce.default.createSourceFile(ae.default.basename(t),r,ce.default.ScriptTarget.Latest,!0),i=W(n);if(i.length===0)return r;let o=$(i[0],"tags",n),a=[...s].sort();if(o!==null&&JSON.stringify(fi(o).sort())===JSON.stringify(a))return r;let c=i.flatMap(p=>{let g=s.length===0?B(p,"tags",n):z(p,"tags",li(a),n);return g?[g]:[]});return c.length>0?U(r,c):r}};var Wr=m(require("path")),pe=/# <mokosh-tags>[\s\S]*?# <\/mokosh-tags>\n*/,le=/^@([a-zA-Z0-9_-]+)/gm;function mi(e){return["# <mokosh-tags>",...e.map(t=>`@${t}`),"# </mokosh-tags>"].join(`
|
|
1
|
+
"use strict";var sn=Object.create;var St=Object.defineProperty;var nn=Object.getOwnPropertyDescriptor;var on=Object.getOwnPropertyNames;var an=Object.getPrototypeOf,cn=Object.prototype.hasOwnProperty;var pn=(e,t)=>{for(var r in t)St(e,r,{get:t[r],enumerable:!0})},je=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of on(t))!cn.call(e,n)&&n!==r&&St(e,n,{get:()=>t[n],enumerable:!(s=nn(t,n))||s.enumerable});return e};var m=(e,t,r)=>(r=e!=null?sn(an(e)):{},je(t||!e||!e.__esModule?St(r,"default",{value:e,enumerable:!0}):r,e)),ln=e=>je(St({},"__esModule",{value:!0}),e);var Sa={};pn(Sa,{CALL_EDGE_TYPES:()=>nt,DEFAULT_EXTENSIONS:()=>Ct,DEFAULT_IGNORE_DIRS:()=>Et,EXPORT_TRACKING_TYPES:()=>te,Graph:()=>P,IMPORT_SYMBOL_TYPES:()=>st,MermaidExporter:()=>kt,SymbolTraversalContext:()=>N,WorkspaceGraph:()=>z,applyConfig:()=>Je,applyTags:()=>Xr,buildApiSurface:()=>qe,buildChangeImpactCache:()=>rr,buildFeatureGraph:()=>Ft,buildResponsibilityGraph:()=>yr,buildTypeGraph:()=>Sr,computeGraphHash:()=>wt,configToGraphOptions:()=>He,createImportMap:()=>ha,createWorkspaceGraph:()=>ya,detectAllEntryPoints:()=>qt,detectEntryPoint:()=>Ze,detectFeatures:()=>j,detectMonorepo:()=>Mt,filterGraph:()=>oe,findComplexFunctions:()=>mr,findSymbol:()=>xr,getAffected:()=>lr,getAllProjectFiles:()=>xa,getCallers:()=>fr,getDependencies:()=>pr,getDependents:()=>Tt,getLanguageCoverage:()=>ar,getNodeMeta:()=>cr,hasCoverageData:()=>dr,isChangeImpactCacheValid:()=>nr,loadChangeImpactCache:()=>or,loadCoverageMap:()=>Qe,loadMokoshConfig:()=>vt,parseQuery:()=>ae,proposeAffectedTests:()=>en,proposeTags:()=>tn,queryCallGraph:()=>tr,queryChangeImpact:()=>sr,queryTypeGraph:()=>br,registerConfigMatcher:()=>Z,registerMonorepoDetector:()=>F,registerParser:()=>A,registerTestLibrary:()=>et,registerTestPattern:()=>q,saveChangeImpactCache:()=>ir,slimSerialize:()=>ur,summarizeWorkspacePackages:()=>gr,toMermaid:()=>Xt});module.exports=ln(Sa);var bt=m(require("fs")),Vt=m(require("path"));var fn=[".config.","biome.json","tsconfig.json","package.json",".prettierrc",".eslintrc"],_e=[];function Z(e){_e.push(e)}function We(e){return[...fn,..._e].some(t=>typeof t=="string"?e.includes(t):t instanceof RegExp?t.test(e):t(e))}var mn=[".test.",".spec.","-test.","-spec."],ze=[];function q(e){ze.push(e)}function tt(){return[...mn,...ze]}var un=["jest","vitest","playwright","cypress","@testing-library/"],$e=[];function et(e){$e.push(e)}function Kt(){return[...un,...$e]}var Be=.8;function Jt(e){Be=e}function Ht(){return Be}var gn=["mokosh.config.js","mokosh.config.cjs","mokosh.config.json"];function vt(e,{allowJs:t=!0,isExplicitPath:r=!1}={}){if(r){let s=Vt.default.resolve(e);return bt.default.existsSync(s)?s.endsWith(".json")?Ue(s):t?Ke(s):{}:{}}for(let s of gn){let n=Vt.default.resolve(e,s);if(bt.default.existsSync(n)){if(s.endsWith(".json"))return Ue(n);if(t)return Ke(n)}}return{}}function Ue(e){return JSON.parse(bt.default.readFileSync(e,"utf-8"))}function Ke(e){let t=require(e);return t&&typeof t=="object"&&"default"in t&&(t=t.default),typeof t=="function"?t({}):t}function Je(e){for(let t of e.configMatchers??[])Z(t);for(let t of e.testPatterns??[])q(t);for(let t of e.testLibraries??[])et(t);e.barrelThreshold!==void 0&&Jt(e.barrelThreshold)}function He(e){return{gitStats:e?.gitStats??!1,parallelParsing:e?.parallelParsing,pathAliases:e?.pathAliases}}var Et=["node_modules",".git","dist","build",".next",".cache","mokosh-cache","coverage"],Ct=[".ts",".tsx",".js",".jsx",".mjs",".cjs",".css",".scss",".sass",".less",".styl",".coffee",".ls",".lua",".py",".go",".feature",".md",".mdx"];var Ve=m(require("fs")),Qt=m(require("path"));function Qe(e,t){let r=Qt.default.resolve(e,t);try{let s=Ve.default.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=Qt.default.relative(e,o);i.set(p,c)}return i}catch{return new Map}}var kt={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 Xt(e){return kt.serialize(e)}var Yt=m(require("fs")),Xe=m(require("path"));function Zt(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 Ye(e,t){if(typeof e=="string")return Zt(e,t);if(e&&typeof e=="object"){let r=e;for(let s of["import","require","default"]){let n=Ye(r[s],t);if(n)return n}}return null}function dn(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 hn(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 Ze(e,t){return qt(e,t)[0]??null}function qt(e,t){let r=[],s=Xe.default.join(t,"package.json");if(Yt.default.existsSync(s))try{let n=JSON.parse(Yt.default.readFileSync(s,"utf8"));if(n.exports&&typeof n.exports=="object"&&!Array.isArray(n.exports))for(let i of Object.values(n.exports)){let o=Ye(i,e);o&&!r.includes(o)&&r.push(o)}else if(typeof n.exports=="string"){let i=Zt(n.exports,e);i&&r.push(i)}if(r.length===0)for(let i of[n.main,n.module].filter(Boolean)){let o=Zt(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 yn(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 xn(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 Sn(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:dn(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 bn(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 qe(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=yn(e,t),s=xn(e,r,t),n=hn(e,t),i=Sn(n,s,e,t),{internalFiles:o,unreachableFromEntry:a,testFiles:c}=bn(e,r,t);return{entryPoints:t,publicExports:i,internalFiles:o,unreachableFromEntry:a,testFiles:c}}function tr(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}}var O=m(require("fs")),er=m(require("path"));function wt(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 rr(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:wt(e)}}function sr(e,t){return e.impact.get(t)??[]}function nr(e,t){return e.graphHash===wt(t)}function ir(e,t){let r=er.default.dirname(t);O.default.existsSync(r)||O.default.mkdirSync(r,{recursive:!0});let s={graphHash:e.graphHash,impact:[...e.impact.entries()]};O.default.writeFileSync(t,JSON.stringify(s))}function or(e){if(!O.default.existsSync(e))return null;try{let t=O.default.readFileSync(e,"utf-8"),r=JSON.parse(t);return{graphHash:r.graphHash,impact:new Map(r.impact)}}catch{return null}}var rt=m(require("path"));function vn(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 En(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=rt.default.extname(n),c=rt.default.basename(n,a),p=c==="index"?rt.default.basename(rt.default.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 En(e,vn(e),r)}var Cn=(e,t)=>e.outDegree-t.outDegree;function kn(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 wn(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 Fn(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 Tn(e,t,r){let s=[];for(let n of e.keys())!t.has(n)&&!r.has(n)&&s.push(n);return s}function Ft(e,t){let r=t?.detectFn??j,s=t?.hubComparator??Cn,n=r(e.nodes,t),i=kn(e,n),o=wn(e.nodes,n,i,s);return{features:Fn(n,o),unassigned:Tn(e.nodes,n,o)}}var te=new Set(["typescript","javascript","python","go","scss","less","lua","coffeescript"]),st=new Set(["typescript","javascript","python"]),nt=new Set(["typescript","javascript"]);function ar(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:te.has(r),importSymbolsTracked:st.has(r),callEdgesTracked:nt.has(r)})).sort((r,s)=>s.fileCount-r.fileCount)}var it=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 P=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 it(this.nodes).findUnusedFiles(t)}findCycles(){return new it(this.nodes).findCycles()}};var N=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 cr(e,t){let r=e.nodes.get(t);if(r)return{category:r.category,exports:r.exports.map(s=>s.name)}}function pr(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 Tt(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 lr(e,t,r={}){let{testsOnly:s=!1,changedSymbols:n}=r,i=n?new N(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 fr(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 mr(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 ur(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 gr(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 dr(e){return[...e.nodes.values()].some(t=>t.coveragePct!==void 0)}function hr(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")||ot(t)==="cli"?"cli":h(t,"util")||h(t,"utils")||h(t,"helper")||h(t,"helpers")?"util":h(t,"model")||h(t,"models")||ot(t)==="model"?"model":h(t,"parser")||h(t,"parsers")||ot(t)==="parser"?"parser":ot(t)==="builder"?"builder":ot(t)==="resolver"?"resolver":"other"}function h(e,t){return e.includes(`/${t}/`)||e.includes(`/${t}.`)}function ot(e){let t=e.slice(e.lastIndexOf("/")+1);return t.slice(0,t.lastIndexOf("."))||t}function yr(e,t){let r=Ft(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:hr(i),...i.description?{description:i.description}:{},exports:i.exports.map(a=>a.name),...o?{featureHub:o}:{}})}return n}function xr(e,t){let r=[];for(let s of e.nodes.values())if(s.exports.some(n=>n.name===t))if(nt.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(st.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=Tt(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 Pn(e){return e?e.startsWith("interface ")?"interface":e.startsWith("class ")?"class":e.startsWith("enum ")?"enum":"type":"type"}function Nn(e,t){if(t==="type-only")return!0;let r=e.signature??"";return r.startsWith("interface ")||r.startsWith("class ")||r.startsWith("enum ")}function Sr(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(!Nn(n,s.category))continue;let i=`${s.path}::${n.name}`;t.set(i,{name:n.name,file:s.path,kind:Pn(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 br(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())}}var Lr=m(require("path"));var Nt=m(require("fs")),se=m(require("path"));var _=m(require("fs")),C=m(require("path"));var ee=m(require("fs")),In=m(require("path"));function vr(e){try{return ee.default.statSync(e,{throwIfNoEntry:!1})?.isDirectory()===!0}catch{return!1}}function Pt(e){try{return ee.default.statSync(e,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}function re(e,t){let r=C.default.join(t,"package.json");if(!_.default.existsSync(r))return null;let s={};try{s=JSON.parse(_.default.readFileSync(r,"utf-8"))}catch{return null}let n=s.name;return n?{name:n,root:t,relativeRoot:C.default.relative(e,t),entryPoints:Mn(t,s)}:null}function Mn(e,t){let r=[];if(t.exports){let n=t.exports;if(typeof n=="string")r.push(C.default.join(e,n));else if(typeof n=="object"&&n!==null){let i=n["."];if(typeof i=="string")r.push(C.default.join(e,i));else if(typeof i=="object"&&i!==null){let o=i.import??i.require??i.default;typeof o=="string"&&r.push(C.default.join(e,o))}}}t.main&&r.push(C.default.join(e,t.main));for(let n of["src/index.ts","src/index.tsx","index.ts","index.tsx","index.js"])r.push(C.default.join(e,n));let s=r.filter(Pt);return s.length>0?s.slice(0,1):r.slice(0,1)}function W(e,t){let r=[],s=new Set;for(let n of t){let i=n.replace(/\/$/,"").replace(/^\.\//,"");Rn(e,i,s,r)}return r}function Rn(e,t,r,s){if(!t.includes("*")){An(e,t,r,s);return}let n=t.split("/");n.includes("**")?Dn(e,n,r,s):Ln(e,n,r,s)}function An(e,t,r,s){let n=C.default.join(e,t);if(r.has(n)||!vr(n))return;r.add(n);let i=re(e,n);i&&s.push(i)}function Dn(e,t,r,s){let n=C.default.join(e,t[0]==="**"?"":t[0]??"");Er(e,n,r,s)}function Ln(e,t,r,s){let n=t.findIndex(a=>a.includes("*")),i=C.default.join(e,...t.slice(0,n)),o;try{o=_.default.readdirSync(i,{withFileTypes:!0})}catch{return}for(let a of o){if(!a.isDirectory())continue;let c=C.default.join(i,a.name);if(r.has(c))continue;r.add(c);let p=re(e,c);p&&s.push(p)}}function Er(e,t,r,s){let n;try{n=_.default.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.default.join(t,i.name);if(_.default.existsSync(C.default.join(o,"package.json"))&&!r.has(o)){r.add(o);let a=re(e,o);a&&s.push(a)}else Er(e,o,r,s)}}var Cr={type:"npm",detect(e){let t=se.default.join(e,"package.json");if(!Nt.default.existsSync(t))return null;let r;try{r=JSON.parse(Nt.default.readFileSync(t,"utf-8")).workspaces}catch{return null}if(!r||Nt.default.existsSync(se.default.join(e,"yarn.lock")))return null;let s=Array.isArray(r)?r:r.packages??[];return s.length===0?null:W(e,s)}};var R=m(require("fs")),S=m(require("path"));var kr={type:"nx",detect(e){return R.default.existsSync(S.default.join(e,"nx.json"))?wr(e,e,new Set,0).map(r=>Gn(e,r,S.default.join(r,"project.json"))).filter(r=>r!==null):null}};function wr(e,t,r,s){if(s>4)return[];let n;try{n=R.default.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.default.join(t,a);R.default.existsSync(S.default.join(c,"project.json"))&&!r.has(c)?(r.add(c),i.push(c)):i.push(...wr(e,c,r,s+1))}return i}function Gn(e,t,r){let s={};try{s=JSON.parse(R.default.readFileSync(r,"utf-8"))}catch{return null}let n=s.name,i,o,a=S.default.join(t,"package.json");if(R.default.existsSync(a))try{let c=JSON.parse(R.default.readFileSync(a,"utf-8"));n=c.name??n,i=c.main,o=c.exports}catch{}return n?{name:n,root:t,relativeRoot:S.default.relative(e,t),entryPoints:On(t,s,i,o)}:null}function On(e,t,r,s){let n=[],i=t.targets?.build?.options?.main??t.targets?.build?.options?.entryFile;if(i){let a=S.default.resolve(e,"../..");n.push(S.default.resolve(a,i)),n.push(S.default.resolve(e,i))}if(s){let a=s;if(typeof a=="string")n.push(S.default.join(e,a));else if(typeof a=="object"&&a!==null){let c=a["."];typeof c=="string"&&n.push(S.default.join(e,c))}}if(r&&n.push(S.default.join(e,r)),t.sourceRoot){let a=S.default.resolve(e,"../.."),c=S.default.resolve(a,t.sourceRoot);n.push(S.default.join(c,"index.ts"),S.default.join(c,"index.tsx"))}for(let a of["src/index.ts","src/index.tsx","index.ts","index.tsx"])n.push(S.default.join(e,a));let o=n.filter(Pt);return o.length>0?o.slice(0,1):n.slice(0,1)}var ne=m(require("fs")),Fr=m(require("path")),Tr=require("js-yaml");var Pr={type:"pnpm",detect(e){let t=Fr.default.join(e,"pnpm-workspace.yaml");if(!ne.default.existsSync(t))return null;let r=[];try{r=(0,Tr.load)(ne.default.readFileSync(t,"utf-8"))?.packages??[]}catch{return null}return W(e,r)}};var Nr=m(require("fs")),Ir=m(require("path")),Mr={type:"turborepo",detect(e){return Nr.default.existsSync(Ir.default.join(e,"turbo.json"))?[]:null}};var It=m(require("fs")),ie=m(require("path"));var Rr={type:"yarn",detect(e){if(!It.default.existsSync(ie.default.join(e,"yarn.lock")))return null;let t=ie.default.join(e,"package.json");if(!It.default.existsSync(t))return null;let r;try{r=JSON.parse(It.default.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:W(e,s)}};var Ar=[];function F(e){Ar.push(e)}function Dr(){return Ar}F(Mr);F(kr);F(Pr);F(Rr);F(Cr);function Mt(e,t=Dr()){let r=Lr.default.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 z=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 P(i);r.packages.set(s.name,{graph:o,pkg:{...s,root:""}})}return r}};var Gr=new Map;function A(e,t){Gr.set(e,t)}function Or(e){return Gr.get(e)}function jr(e,t){return t.startsWith("!")?e!==t.slice(1):e===t}function jn(e,t){return t.startsWith("!")?!e.includes(t.slice(1)):e.includes(t)}var _n=(e,t)=>!t.category||jr(e.category,t.category),Wn=(e,t)=>!t.type||jr(e.type,t.type),zn=(e,t)=>t.lastAuthor?t.lastAuthor.startsWith("!")?e.lastAuthor!==t.lastAuthor.slice(1):e.lastAuthor!==void 0&&e.lastAuthor===t.lastAuthor:!0,$n=(e,t)=>!t.path||jn(e.path,t.path),Bn=(e,t)=>t.isExternal===void 0?!0:e.imports.some(s=>s.isExternal)===t.isExternal,Un=(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)))},Kn=(e,t)=>!t.allTags?.length||t.allTags.every(r=>e.tags.some(s=>s.name===r)),Jn=(e,t)=>!t.importsFile||e.imports.some(r=>r.toPath?.includes(t.importsFile)),Hn=(e,t,r)=>t.importedBy===void 0?!0:(r?.get(e.path)??[]).some(n=>n.includes(t.importedBy)),Vn=(e,t)=>t.minImports===void 0||e.imports.length>=t.minImports,Qn=(e,t)=>t.maxImports===void 0||e.imports.length<=t.maxImports,Xn=(e,t)=>t.minSize===void 0||e.size>=t.minSize,Yn=(e,t)=>t.maxSize===void 0||e.size<=t.maxSize,Zn=(e,t)=>t.hasDocstring===void 0||!!e.description===t.hasDocstring,qn=(e,t)=>t.isDocumented===void 0||!!e.documentedBy?.length===t.isDocumented,ti=(e,t)=>t.isStale===void 0||!!e.staleFor?.length===t.isStale,ei=(e,t)=>t.minCoverage===void 0||(e.coveragePct??101)>=t.minCoverage,ri=(e,t)=>t.maxCoverage===void 0||(e.coveragePct??0)<=t.maxCoverage,si=(e,t)=>t.minExportUsage===void 0||(e.avgExportUsage??-1)>=t.minExportUsage,ni=(e,t)=>t.maxExportUsage===void 0||(e.avgExportUsage??0)<=t.maxExportUsage,ii=(e,t)=>t.minComplexity===void 0||(e.complexity??-1/0)>=t.minComplexity,oi=(e,t)=>t.maxComplexity===void 0||(e.complexity??0)<=t.maxComplexity,ai=(e,t)=>t.minCognitiveComplexity===void 0||(e.cognitiveComplexity??-1/0)>=t.minCognitiveComplexity,ci=(e,t)=>t.maxCognitiveComplexity===void 0||(e.cognitiveComplexity??0)<=t.maxCognitiveComplexity,pi=(e,t)=>t.minCommits===void 0||(e.commitCount90d??-1/0)>=t.minCommits,li=(e,t)=>t.maxCommits===void 0||(e.commitCount90d??0)<=t.maxCommits,fi=(e,t,r)=>!t.any?.length||t.any.some(s=>at(e,s,r)),mi=[_n,Wn,zn,$n,Bn,Un,Kn,Jn,Hn,Vn,Qn,Xn,Yn,Zn,qn,ti,ei,ri,si,ni,ii,oi,ai,ci,pi,li,fi];function at(e,t,r){return mi.every(s=>s(e,t,r))}function oe(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=>at(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 _r(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 ui(e){let t=[];for(let r of e.split("|")){let s=r.trim();if(!s)continue;let n={};_r(n,s),Object.keys(n).length>0&&t.push(n)}return t}function ae(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=ui(i);o.length>0&&(t.any=[...t.any??[],...o]);continue}_r(t,s)}return t}var be=m(require("fs/promises")),Qr=m(require("path"));var _t=m(require("path")),ct=m(require("typescript"));var ce=m(require("path")),pe=m(require("typescript"));var b=m(require("typescript")),Wr=new Set(["describe","test","it"]);function $(e){let t=[];for(let r of e.statements){if(!b.default.isExpressionStatement(r))continue;let s=r.expression;if(!b.default.isCallExpression(s))continue;let n=s.expression;b.default.isIdentifier(n)&&Wr.has(n.text)&&t.push(s),b.default.isPropertyAccessExpression(n)&&b.default.isIdentifier(n.expression)&&Wr.has(n.expression.text)&&t.push(s)}return t}function B(e,t,r){for(let s of e.arguments){if(!b.default.isObjectLiteralExpression(s))continue;let n=s.properties.find(i=>b.default.isPropertyAssignment(i)&&b.default.isIdentifier(i.name)&&i.name.text===t);if(!(!n||!b.default.isArrayLiteralExpression(n.initializer)))return n.initializer.elements.filter(b.default.isStringLiteral).map(i=>i.text)}return null}function U(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(!b.default.isObjectLiteralExpression(o))continue;let a=o.properties.find(p=>b.default.isPropertyAssignment(p)&&b.default.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 K(e,t,r){let s=e.arguments;for(let n=1;n<s.length;n++){let i=s[n];if(!b.default.isObjectLiteralExpression(i))continue;let o=i.properties.findIndex(c=>b.default.isPropertyAssignment(c)&&b.default.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 J(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 H(e){return`[${e.map(t=>JSON.stringify(t)).join(", ")}]`}var w=new Set([".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"]);function gi(e){return H(e.map(t=>`@${t}`))}function di(e){return e.map(t=>t.startsWith("@")?t.slice(1):t)}var Rt=class{name="cypress";canHandle(t){return w.has(ce.default.extname(t).toLowerCase())}apply(t,r,s){let n=pe.default.createSourceFile(ce.default.basename(t),r,pe.default.ScriptTarget.Latest,!0),i=$(n);if(i.length===0)return r;let o=B(i[0],"tags",n),a=[...s].sort();if(o!==null&&JSON.stringify(di(o).sort())===JSON.stringify(a))return r;let c=i.flatMap(p=>{let g=s.length===0?K(p,"tags",n):U(p,"tags",gi(a),n);return g?[g]:[]});return c.length>0?J(r,c):r}};var zr=m(require("path")),le=/# <mokosh-tags>[\s\S]*?# <\/mokosh-tags>\n*/,fe=/^@([a-zA-Z0-9_-]+)/gm;function hi(e){return["# <mokosh-tags>",...e.map(t=>`@${t}`),"# </mokosh-tags>"].join(`
|
|
3
3
|
`)+`
|
|
4
4
|
|
|
5
|
-
`}function
|
|
6
|
-
`}function
|
|
7
|
-
`+r.slice(c)}};var
|
|
5
|
+
`}function yi(e){let t=new Set;fe.lastIndex=0;let r=fe.exec(e);for(;r!==null;)r[1]&&t.add(r[1]),r=fe.exec(e);return t}var At=class{name="gherkin";canHandle(t){return zr.default.extname(t).toLowerCase()===".feature"}apply(t,r,s){let n=r.replace(le,""),i=yi(n),o=s.filter(c=>!i.has(c)),a=o.length>0?hi(o):"";return le.test(r)?r.replace(le,a):a?r.replace(/^(Feature:)/m,`${a}$1`):r}};function $r(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)}var Br=m(require("path")),me=/^\/\/go:build mokosh_[^\n]+\n/m,xi=/^package\s+\S+/m;function Si(e){return`//go:build ${e.map(r=>`mokosh_${r}`).join(" || ")}
|
|
6
|
+
`}function bi(e){let t=me.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 Dt=class{name="go";canHandle(t){return Br.default.basename(t).endsWith("_test.go")}apply(t,r,s){let n=bi(r),i=[...s].sort();if(n!==null&&JSON.stringify([...n].sort())===JSON.stringify(i))return r;if(s.length===0)return r.replace(me,"");let o=Si(i);if(n!==null)return r.replace(me,o);let a=xi.exec(r);if(!a)return r;let c=a.index;return r.slice(0,c)+o+`
|
|
7
|
+
`+r.slice(c)}};var Ur=m(require("path"));var vi=/^\/\*\*\n(?: \* @group .+\n)+ \*\/\n+/,ue=/^ \* @group (.+)$/gm;function Ei(e){return["/**",...e.map(t=>` * @group ${t}`)," */"].join(`
|
|
8
8
|
`)+`
|
|
9
9
|
|
|
10
|
-
`}function
|
|
10
|
+
`}function Ci(e){let t=[];ue.lastIndex=0;let r=ue.exec(e);for(;r!==null;)r[1]&&t.push(r[1]),r=ue.exec(e);return t}var Lt=class{name="jest";canHandle(t){return w.has(Ur.default.extname(t).toLowerCase())}apply(t,r,s){let n=vi.exec(r),i=n?Ci(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:Ei(o)+a}};var ge=m(require("path")),de=m(require("typescript"));function ki(e){return H(e.map(t=>`@${t}`))}function wi(e){return e.map(t=>t.startsWith("@")?t.slice(1):t)}var Gt=class{name="playwright";canHandle(t){return w.has(ge.default.extname(t).toLowerCase())}apply(t,r,s){let n=de.default.createSourceFile(ge.default.basename(t),r,de.default.ScriptTarget.Latest,!0),i=$(n);if(i.length===0)return r;let o=B(i[0],"tag",n),a=[...s].sort();if(o!==null&&JSON.stringify(wi(o).sort())===JSON.stringify(a))return r;let c=i.flatMap(p=>{let g=s.length===0?K(p,"tag",n):U(p,"tag",ki(a),n);return g?[g]:[]});return c.length>0?J(r,c):r}};var Kr=m(require("path")),he=/^pytestmark\s*=\s*.+$/m,Fi=/^import pytest\s*$/m;function Ti(e){let t=e.map(r=>`pytest.mark.${r}`).join(", ");return e.length===1?`pytestmark = pytest.mark.${e[0]}`:`pytestmark = [${t}]`}function Pi(e){let t=he.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 Ot=class{name="pytest";canHandle(t){return Kr.default.extname(t).toLowerCase()===".py"}apply(t,r,s){let n=Pi(r),i=[...s].sort();if(n!==null&&JSON.stringify([...n].sort())===JSON.stringify(i))return r;if(s.length===0)return r.replace(he,"").replace(/\n{3,}/g,`
|
|
11
11
|
|
|
12
|
-
`);let o=
|
|
12
|
+
`);let o=Ti(i);if(n!==null)return r.replace(he,o);let a=Fi.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
|
|
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}var
|
|
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
|
|
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=Ai(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 Oi(e){let t=ct.default.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 ji(e){let t=ct.default.readFileSync(e,"utf-8");if(t.includes("__metadata:")){let r=Li(t);if(r!==null)return r}return Gi(t)}function _i(e){let t=ct.default.readFileSync(e,"utf-8"),r={dependencies:{}};try{let s=(0,ve.load)(t);if(s.packages)for(let[n,i]of Object.entries(s.packages)){let{name:o,version:a}=Di(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 rs(e){let t=[["package-lock.json",Oi],["yarn.lock",ji],["pnpm-lock.yaml",_i]];for(let[r,s]of t){let n=ts.default.join(e,r);if(ct.default.existsSync(n))return s(n)}return null}var ke=m(require("path"));function M(e){switch(ke.default.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=ke.default.extname(e).toLowerCase();return[".css",".scss",".sass",".less",".styl"].includes(t)}var ss=m(require("coffeescript"));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=t.source?.value;return r?{fromPath:e,toPath:"",rawSpecifier:r,isStyle:E(r),type:"static"}:null}function Bi(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 Ui(e,t,r){let s=t.constructor?.name;if(s==="ImportDeclaration"){let n=zi(e,t);n&&r.push(n)}else if(s==="Call"){let n=Bi(e,t);n&&r.push(n)}}function Ce(e,t,r){if(!(!t||typeof t!="object")){Ui(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)Ce(e,i,r);else Ce(e,n,r)}}}function ns(e,t){let r=Wi(t),s=$i(e,r),n=[];try{Ce(e,ss.default.nodes(t),n)}catch{}return{imports:n,exports:[],tags:Array.from(r).map(i=>({name:i,kind:"comment-marker"})),category:s}}var J=require("@cucumber/gherkin"),is=require("@cucumber/messages");var Ki=is.IdGenerator.uuid();function Ee(e,t){let r=new Set;try{let s=new J.AstBuilder(Ki),n=new J.GherkinClassicTokenMatcher,o=new J.Parser(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"}}R("gherkin",Ee);var as=m(require("path")),cs=require("@lezer/go"),Ji=/\/\/\s*@tag\s+([a-zA-Z0-9_-]+)/,Hi=/^\/\/go:build\s+(.+)$/,Qi=/^\/\/\s*\+build\s+(.+)$/;function ps(e,t){let r=[],s=new Map,n=new Set,i=new Set,a=cs.parser.parse(t).cursor();do switch(a.name){case"LineComment":{let u=t.slice(a.from,a.to),y=u.match(Ji);y?.[1]&&n.add(y[1]);let k=u.match(Hi);k&&os(k[1],i);let X=u.match(Qi);X&&os(X[1],i);break}case"ImportSpec":{let u=a.node.getChild("String");if(u){let k=t.slice(u.from,u.to).slice(1,-1);r.push({fromPath:e,toPath:"",rawSpecifier:k,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=as.default.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 os(e,t){for(let r of e.split(/[\s,&|!()]+/)){let s=r.trim();s&&s!=="ignore"&&t.add(s)}}var ls=m(require("livescript"));function H(e){return e.startsWith("'")||e.startsWith('"')?e.slice(1,-1):e}function Vi(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 Xi(e,t){let r=e.toLowerCase();return r.includes(".test.")||r.includes(".spec.")||t.has("test")?"test":"logic"}var Yi=new Set(["first_line","first_column","last_line","last_column","line","column"]);function Zi(e,t){let r=e.constructor?.name||e.type;if(r==="Import"){let s=e.right?.value;if(typeof s=="string"){let n=H(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=H(n);return{fromPath:t,toPath:"",rawSpecifier:i,isStyle:E(i),type:"require"}}}}return null}function Fe(e,t){if(!e||typeof e!="object")return[];let r=[],s=Zi(e,t);s&&r.push(s);for(let n in e){if(Yi.has(n))continue;let i=e[n];if(!(!i||typeof i!="object"))if(Array.isArray(i))for(let o of i)r.push(...Fe(o,t));else r.push(...Fe(i,t))}return r}function fs(e,t){let r=Vi(t),s=Xi(e,r),n=[];try{n=Fe(ls.default.ast(t),e)}catch{}return{imports:n,exports:[],tags:Array.from(r).map(i=>({name:i,kind:"comment-marker"})),category:s}}var ms=m(require("luaparse"));function qi(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 to(e,t){let r=e.toLowerCase();return r.includes(".test.")||r.includes(".spec.")||t.has("test")?"test":"logic"}function eo(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=H(o.raw))}else if(n.type==="StringCallExpression"){let o=n.argument;o?.type==="StringLiteral"&&(i=H(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 us(e,t){let r=qi(t),s=to(e,r),n=[];try{let i=ms.default.parse(t);n=eo(i,e)}catch{}return{imports:n,exports:[],tags:Array.from(r).map(i=>({name:i,kind:"comment-marker"})),category:s}}var ro=["http://","https://","mailto:","//"],so="ts|tsx|js|jsx|mjs|cjs|py|go|lua|css|scss|less|styl|coffee|ls|feature|md|mdx|json",no=new RegExp(`(?:\\.{1,2}/)?[\\w.-]+(?:/[\\w.-]+)*\\.(?:${so})\\b`,"g"),gs;async function io(){return gs??=(async()=>{let{unified:e}=await import("unified"),t=(await import("remark-parse")).default;return e().use(t)})(),gs}function oo(e){let t=e.trim();return t.length===0||t.startsWith("#")||ro.some(r=>t.startsWith(r))}function ao(e,t){let r=e.match(no);return r?r.map(s=>({fromPath:t,toPath:"",rawSpecifier:s,isStyle:!1,type:"static"})):[]}function ds(e,t,r){if(e.type==="link"&&typeof e.url=="string"&&!oo(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(...ao(e.value,t)),Array.isArray(e.children))for(let s of e.children)ds(s,t,r)}async function hs(e,t){let s=(await io()).parse(t),n=[];ds(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"}}var ys=m(require("path")),xs=require("@lezer/python"),co=new Set(["pytest","unittest","nose","hypothesis"]);function Ss(e,t){let r=[],s=[],n=new Set,i=ys.default.basename(e).toLowerCase(),a=xs.parser.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 po(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=uo(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 po(e,t,r){let s=e.firstChild;return s?s.name==="from"?lo(e,t,r):fo(e,t,r):[]}function lo(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=mo(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[pt(r,i,o,!0)];let p=a===1?"./":"../".repeat(a-1);return c?[pt(r,p+c.replace(/\./g,"/"),o,!1)]:o[0]==="*"?[pt(r,p.slice(0,-1),["*"],!1)]:o.map(g=>pt(r,p+g,[g],!1))}function fo(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(pt(r,i,["*"],!0))}n=n.nextSibling}return s}function mo(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 pt(e,t,r,s){return{fromPath:e,toPath:"",rawSpecifier:t,isStyle:!1,isExternal:s,type:"static",symbols:r.length>0?r:void 0}}function uo(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=>co.has(s.rawSpecifier))?"test":"logic"}var Te=m(require("path")),l=m(require("typescript"));var d=m(require("typescript"));function go(e){let t=1;function r(s){switch(s.kind){case d.default.SyntaxKind.IfStatement:case d.default.SyntaxKind.ConditionalExpression:case d.default.SyntaxKind.ForStatement:case d.default.SyntaxKind.ForInStatement:case d.default.SyntaxKind.ForOfStatement:case d.default.SyntaxKind.WhileStatement:case d.default.SyntaxKind.DoStatement:case d.default.SyntaxKind.CatchClause:case d.default.SyntaxKind.CaseClause:t++;break;case d.default.SyntaxKind.BinaryExpression:{let n=s.operatorToken.kind;(n===d.default.SyntaxKind.AmpersandAmpersandToken||n===d.default.SyntaxKind.BarBarToken||n===d.default.SyntaxKind.QuestionQuestionToken)&&t++;break}}d.default.forEachChild(s,r)}return r(e),t}function ho(e){let t=0;function r(s,n,i){if(d.default.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.default.isIfStatement(s.elseStatement)?r(s.elseStatement,n,!0):(t+=1,r(s.elseStatement,n+1,!1)));return}if(d.default.isForStatement(s)||d.default.isForInStatement(s)||d.default.isForOfStatement(s)||d.default.isWhileStatement(s)||d.default.isDoStatement(s)||d.default.isSwitchStatement(s)){t+=1+n,d.default.forEachChild(s,a=>r(a,n+1,!1));return}if(d.default.isCatchClause(s)){t+=1+n,d.default.forEachChild(s,a=>r(a,n,!1));return}if(d.default.isConditionalExpression(s)&&(t+=1),d.default.isBinaryExpression(s)){let a=s.operatorToken.kind;(a===d.default.SyntaxKind.AmpersandAmpersandToken||a===d.default.SyntaxKind.BarBarToken||a===d.default.SyntaxKind.QuestionQuestionToken)&&(t+=1)}if(n>0&&(d.default.isFunctionDeclaration(s)||d.default.isFunctionExpression(s)||d.default.isArrowFunction(s))){t+=1+n,d.default.forEachChild(s,a=>r(a,n+1,!1));return}d.default.forEachChild(s,a=>r(a,n,!1))}return r(e,0,!1),t}function we(e){return{complexity:go(e),cognitiveComplexity:ho(e)}}var x=m(require("typescript")),Pe=new Set(["test","describe","it"]);function bs(e,t){yo(e,t),So(e,t),bo(e,t),vo(e,t)}function yo(e,t){if((x.default.isFunctionDeclaration(e)||x.default.isVariableDeclaration(e))&&e.name&&x.default.isIdentifier(e.name)&&xo(e)){let r;if(x.default.isFunctionDeclaration(e))r="function";else{let s=e.initializer;r=s&&(x.default.isArrowFunction(s)||x.default.isFunctionExpression(s))?"function":"variable"}t.tags.add({name:e.name.text,kind:r})}}function xo(e){if(x.default.isFunctionDeclaration(e))return x.default.isSourceFile(e.parent);let t=e.parent?.parent;return!!t&&x.default.isSourceFile(t.parent)}function So(e,t){if(!x.default.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 bo(e,t){if(!x.default.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 vo(e,t){if(x.default.isCallExpression(e)&&ko(e.expression))for(let r of e.arguments)x.default.isObjectLiteralExpression(r)&&Co(r,t)}function ko(e){return x.default.isIdentifier(e)?Pe.has(e.text):!!(x.default.isPropertyAccessExpression(e)&&(Pe.has(e.name.text)||x.default.isIdentifier(e.expression)&&Pe.has(e.expression.text)))}function Co(e,t){for(let r of e.properties){if(!x.default.isPropertyAssignment(r)||!x.default.isIdentifier(r.name)||r.name.text!=="tags"&&r.name.text!=="tag")continue;let{initializer:s}=r,n=x.default.isArrayLiteralExpression(s)?s.elements.filter(x.default.isStringLiteral):r.name.text==="tag"&&x.default.isStringLiteral(s)?[s]:[];for(let i of n)t.tags.add({name:i.text.replace(/^@/,""),kind:"comment-marker"})}}function Ie(e,t,r){let s=[],n=new Map,i=new Set,o=l.default.createSourceFile(e,t,l.default.ScriptTarget.Latest,!0,r==="typescript"?l.default.ScriptKind.TSX:l.default.ScriptKind.JSX),a={filePath:e,imports:s,exports:n,tags:i,rawCallEdges:[],sourceFile:o,hasUI:!1,hasTypesOnly:!0,totalStatements:0,exportStatements:0},c=Ge=>{Po(Ge,a),l.default.forEachChild(Ge,c)};c(o);let p=jo(e,a);(p==="test"||p==="barrel")&&i.add({name:p,kind:"comment-marker"}),p!=="test"&&_o(a,o);let g=o.statements[0],u=g?ks(g):void 0,{complexity:y,cognitiveComplexity:k}=we(o),X=Eo(o);return{imports:s,exports:Array.from(n.values()),tags:Array.from(i),category:p,rawCallEdges:a.rawCallEdges??[],complexity:y,cognitiveComplexity:k,...X.length>0?{functions:X}:{},...u!==void 0?{description:u}:{}}}function Eo(e){let t=[],r=(n,i)=>{let{complexity:o,cognitiveComplexity:a}=we(i),c=e.getLineAndCharacterOfPosition(i.getStart(e)).line+1;t.push({name:n,line:c,complexity:o,cognitiveComplexity:a})},s=(n,i)=>{if(l.default.isFunctionDeclaration(n)&&n.name&&n.body?r(n.name.text,n):l.default.isVariableDeclaration(n)&&l.default.isIdentifier(n.name)&&n.initializer&&(l.default.isArrowFunction(n.initializer)||l.default.isFunctionExpression(n.initializer))?r(n.name.text,n.initializer):i&&l.default.isMethodDeclaration(n)&&l.default.isIdentifier(n.name)&&n.body?r(`${i}.${n.name.text}`,n):i&&l.default.isConstructorDeclaration(n)&&n.body?r(`${i}.constructor`,n):i&&l.default.isGetAccessorDeclaration(n)&&l.default.isIdentifier(n.name)&&n.body?r(`${i}.get ${n.name.text}`,n):i&&l.default.isSetAccessorDeclaration(n)&&l.default.isIdentifier(n.name)&&n.body&&r(`${i}.set ${n.name.text}`,n),l.default.isClassDeclaration(n)&&n.name){let o=n.name.text;l.default.forEachChild(n,a=>s(a,o));return}l.default.forEachChild(n,o=>s(o,i))};return s(e,void 0),t}function vs(e,t,r,s){let n={name:e},i=ks(r);i!==void 0&&(n.doc=i);let o=Fo(t);o!==void 0&&(n.flags=o);let a=wo(t,s);return a!==void 0&&(n.signature=a),n}function ks(e){let t=l.default.getJSDocCommentsAndTags(e);for(let r of t)if(l.default.isJSDoc(r)&&r.comment)return l.default.getTextOfJSDocComment(r.comment)||void 0}function Fo(e){let t=new Set(["deprecated","internal","public","alpha","beta"]),r=l.default.getJSDocTags(e).map(s=>s.tagName.text).filter(s=>t.has(s));return r.length>0?r:void 0}function wo(e,t){let r=l.default.createPrinter({removeComments:!0}),s=n=>r.printNode(l.default.EmitHint.Unspecified,n,t);if(l.default.isFunctionDeclaration(e)||l.default.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.default.isVariableDeclaration(e)){if(e.type)return s(e.type);if(e.initializer&&(l.default.isArrowFunction(e.initializer)||l.default.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.default.isClassDeclaration(e)&&e.name)return`class ${e.name.text}`;if(l.default.isInterfaceDeclaration(e))return`interface ${e.name.text}`;if(l.default.isTypeAliasDeclaration(e))return s(e.type);if(l.default.isEnumDeclaration(e))return`enum ${e.name.text}`}function Po(e,t){To(e,t),Io(e,t),No(e,t),Ro(e,t),Oo(e,t),bs(e,t)}function To(e,t){if(!l.default.isSourceFile(e))return;let r=e.statements.filter(s=>!l.default.isEmptyStatement(s));t.totalStatements=r.length,t.exportStatements=r.filter(s=>l.default.isExportDeclaration(s)||l.default.isExportAssignment(s)||Me(s)).length}function Io(e,t){if(l.default.isJsxElement(e)||l.default.isJsxSelfClosingElement(e)||l.default.isJsxFragment(e)){t.hasUI=!0,t.hasTypesOnly=!1;return}if(l.default.isFunctionDeclaration(e)||l.default.isMethodDeclaration(e)||l.default.isArrowFunction(e)||l.default.isClassDeclaration(e)||l.default.isVariableStatement(e)||l.default.isEnumDeclaration(e)){t.hasTypesOnly=!1;return}l.default.isExportDeclaration(e)&&!Mo(e)&&(t.hasTypesOnly=!1)}function Mo(e){return e.isTypeOnly?!0:!e.exportClause||!l.default.isNamedExports(e.exportClause)?!1:e.exportClause.elements.every(t=>t.isTypeOnly)}function No(e,t){if(!l.default.isImportDeclaration(e)||!e.moduleSpecifier||!l.default.isStringLiteral(e.moduleSpecifier))return;let r=[];if(e.importClause&&(e.importClause.name&&r.push("default"),e.importClause.namedBindings))if(l.default.isNamedImports(e.importClause.namedBindings))for(let n of e.importClause.namedBindings.elements)r.push(n.name.text);else l.default.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 Ro(e,t){l.default.isExportDeclaration(e)?Ao(e,t):l.default.isExportAssignment(e)?t.exports.set("default",{name:"default"}):Me(e)&&Go(e,t)}function Ao(e,t){if(e.moduleSpecifier&&l.default.isStringLiteral(e.moduleSpecifier))Do(e,e.moduleSpecifier.text,t);else if(e.exportClause&&l.default.isNamedExports(e.exportClause))for(let r of e.exportClause.elements){let s=r.name.text;t.exports.set(s,{name:s})}}function Do(e,t,r){let s=Lo(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 Lo(e){return e.exportClause?l.default.isNamedExports(e.exportClause)?e.exportClause.elements.map(t=>t.name.text):[]:["*"]}function Go(e,t){if((l.default.isFunctionDeclaration(e)||l.default.isClassDeclaration(e)||l.default.isInterfaceDeclaration(e)||l.default.isTypeAliasDeclaration(e)||l.default.isEnumDeclaration(e))&&e.name){let s=e.name.text;t.exports.set(s,vs(s,e,e,t.sourceFile));return}if(l.default.isVariableStatement(e)){for(let s of e.declarationList.declarations)if(l.default.isIdentifier(s.name)){let n=s.name.text;t.exports.set(n,vs(n,s,e,t.sourceFile))}}}function Oo(e,t){if(!l.default.isCallExpression(e))return;let r=e.arguments[0];!r||!l.default.isStringLiteral(r)||(e.expression.kind===l.default.SyntaxKind.ImportKeyword?t.imports.push({fromPath:t.filePath,toPath:"",rawSpecifier:r.text,isStyle:E(r.text),type:"dynamic"}):l.default.isIdentifier(e.expression)&&e.expression.text==="require"&&t.imports.push({fromPath:t.filePath,toPath:"",rawSpecifier:r.text,isStyle:E(r.text),type:"require"}))}function jo(e,t){let r=Te.default.basename(e).toLowerCase(),s=Te.default.extname(e).toLowerCase();return q().some(i=>r.includes(i))?"test":_e(r)?"config":t.imports.some(i=>Ut().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>Jt()?"barrel":"logic"}function Me(e){return l.default.canHaveModifiers(e)&&l.default.getModifiers(e)?.some(t=>t.kind===l.default.SyntaxKind.ExportKeyword)===!0}function _o(e,t){let r=e.rawCallEdges??[];e.rawCallEdges=r;let s=new Map;for(let n of t.statements){if(!l.default.isImportDeclaration(n)||!l.default.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.default.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=$o(n);if(i){let o=zo(n);o&&Wt(o,i,s,r);continue}l.default.isClassDeclaration(n)&&n.name&&Wo(n,s,r)}}function Wo(e,t,r){let s=e.name.text;for(let n of e.members)l.default.isMethodDeclaration(n)&&n.body&&l.default.isIdentifier(n.name)?Wt(n.body,`${s}.${n.name.text}`,t,r):l.default.isConstructorDeclaration(n)&&n.body&&Wt(n.body,`${s}.constructor`,t,r)}function $o(e){if(Me(e)){if(l.default.isFunctionDeclaration(e)&&e.name)return e.name.text;if(l.default.isVariableStatement(e)){for(let t of e.declarationList.declarations)if(l.default.isIdentifier(t.name)&&t.initializer&&(l.default.isArrowFunction(t.initializer)||l.default.isFunctionExpression(t.initializer)))return t.name.text}}}function zo(e){if(l.default.isFunctionDeclaration(e))return e.body;if(l.default.isVariableStatement(e)){for(let t of e.declarationList.declarations)if(t.initializer&&(l.default.isArrowFunction(t.initializer)||l.default.isFunctionExpression(t.initializer)))return t.initializer}}function Wt(e,t,r,s){if(l.default.isCallExpression(e)&&l.default.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.default.forEachChild(e,n=>Wt(n,t,r,s))}function $t(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"}var Ne=m(require("postcss")),Bo=m(require("postcss-less")),Uo=Bo,Es=new Set(["reference","inline"]);function Cs(e){return e.startsWith("~")||e.startsWith("http://")||e.startsWith("https://")||e.startsWith("//")||e.startsWith("data:")}function Ko(e){let t=e.trim();return t.length>0&&!t.startsWith("http://")&&!t.startsWith("https://")&&!t.startsWith("//")&&!t.startsWith("data:")&&!t.startsWith("#")}function Jo(e,t){let r=e.match(/^\(([^)]+)\)\s+['"]([^'"]+)['"]/);if(r){let i=r[1]?.trim()??"",o=r[2]??"";if(!o)return null;let a=Es.has(i)?"side-effect":"static";return{fromPath:t,toPath:"",rawSpecifier:o,isStyle:!0,type:a,...Cs(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",...Cs(n)?{isExternal:!0}:{}}:null}function Ho(e,t){let r=[],s=/url\(['"]?([^'")]+)['"]?\)/g,n=s.exec(e);for(;n!==null;){let i=n[1]?.trim()??"";Ko(i)&&r.push({fromPath:t,toPath:"",rawSpecifier:i,isStyle:!0,type:"static"}),n=s.exec(e)}return r}function Fs(e,t){let r=[];return e.walk(s=>{if(s.type==="atrule"&&s.name==="import"){let n=Jo(s.params,t);n&&r.push(n)}s.type==="decl"&&r.push(...Ho(s.value,t))}),r}function Qo(e){return e.replace(/(?<!:)\/\/.*/g,"")}function Vo(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=Es.has(i)?"side-effect":"static";r.push({fromPath:t,toPath:"",rawSpecifier:o,isStyle:!0,type:a})}n=s.exec(e)}return r}function ws(e,t){let r=Ne.default.parse(Qo(e));return{imports:Fs(r,t),root:r}}function Ps(e,t){try{let r=Uo.parse(e);return{imports:Fs(r,t),root:r}}catch{return{imports:Vo(e,t),root:Ne.default.parse("")}}}var Ts=require("postcss-scss");function Xo(e){return!!(e.startsWith("sass:")||e.startsWith("~")||e.startsWith("http://")||e.startsWith("https://")||e.startsWith("//")||!e.startsWith(".")&&!e.startsWith("/")&&!e.startsWith("_"))}function Yo(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 Is(e,t){let r=(0,Ts.parse)(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}=Yo(o);if(!a)return;let p={fromPath:t,toPath:"",rawSpecifier:a,isStyle:!0,type:i==="forward"?"re-export":"static",...Xo(a)?{isExternal:!0}:{}};c&&(p.symbols=[c]),s.push(p)}),{imports:s,root:r}}function Ms(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 Ns(e,t){if(t.length===0)return"ui";try{let r=require("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 lt(e,t){let r=M(e);if(r==="stylus"){let i=Ms(t,e);return{imports:i,exports:[],tags:[],category:Ns(t,i)}}if(r==="scss"){let{imports:i,root:o}=Is(t,e);return{imports:i,exports:[],tags:[],category:$t(o,i)}}if(r==="less"){let{imports:i,root:o}=Ps(t,e);return{imports:i,exports:[],tags:[],category:$t(o,i)}}let{imports:s,root:n}=ws(t,e);return{imports:s,exports:[],tags:[],category:$t(n,s)}}for(let[e,t]of[["javascript",(r,s)=>Ie(r,s,"javascript")],["typescript",(r,s)=>Ie(r,s,"typescript")],["css",lt],["scss",lt],["less",lt],["stylus",lt],["coffeescript",ns],["livescript",fs],["lua",us],["python",Ss],["go",ps],["gherkin",Ee],["markdown",hs]])R(e,t);async function Rs(e,t){let r=M(e),s=Gr(r);return s?s(e,t):{imports:[],exports:[],tags:[],category:"other"}}var Re=m(require("path"));function Ds(e,t){for(let r of e.values()){let s=t.get(r.path);s!==void 0&&(r.coveragePct=s)}}function Ls(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 Gs(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 Os(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 As(e){return Math.round(e*1e4)/1e4}function js(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=As(Math.min(1,i)),r.push(s.exportUsageRatio)}r.length>0&&(t.avgExportUsage=As(r.reduce((s,n)=>s+n,0)/r.length),t.maxExportUsage=Math.max(...r))}}function Ae(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=Re.default.basename(r,Re.default.extname(r)).replace(/\.(test|spec)$/,"");Ae(e.tags,s,"import")}function qo(e,t){if(!(!t.symbols||t.symbols.includes("*")))for(let r of t.symbols)Ae(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"&&Ae(e.tags,n.name,"comment-marker")}function _s(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))}var ht=m(require("fs")),P=m(require("path"));var De=m(require("fs")),A=m(require("path")),ft=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 $s(a);if(r!==i&&!r.startsWith(`${i}/`))return null;let c=r.slice(i.length).replace(/^\//,"");return c?$s(A.default.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=De.default.readFileSync(A.default.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 A.default.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("=>")){
|
|
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}var ye=m(require("path")),xe=m(require("typescript"));var Ii=/\/\/ <mokosh-tags>[\s\S]*?\/\/ <\/mokosh-tags>\n*/,jt=class{name="vitest";canHandle(t){return w.has(ye.default.extname(t).toLowerCase())}apply(t,r,s){let n=r.replace(Ii,""),i=xe.default.createSourceFile(ye.default.basename(t),n,xe.default.ScriptTarget.Latest,!0),o=$(i);if(o.length===0)return n;let a=B(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?K(g,"tags",i):U(g,"tags",H(c),i);return u?[u]:[]});return p.length>0?J(n,p):n}};var Jr={vitest:()=>new jt,playwright:()=>new Gt,cypress:()=>new Rt,jest:()=>new Lt},Mi={"@playwright/test":"playwright",cypress:"cypress","@jest/globals":"jest",vitest:"vitest"};function Ri(e){let t=ct.default.createSourceFile("detect.ts",e,ct.default.ScriptTarget.Latest,!0);for(let r of t.statements){if(!ct.default.isImportDeclaration(r)||!ct.default.isStringLiteral(r.moduleSpecifier))continue;let s=Mi[r.moduleSpecifier.text];if(s)return s}return null}var Se=class{constructor(t,r,s){this.rootDir=t;this.defaultFramework=r;this.frameworkOverrides=s}rootDir;defaultFramework;frameworkOverrides;name="auto";canHandle(t){return w.has(_t.default.extname(t).toLowerCase())}apply(t,r,s){let n=Ri(r)??this.matchOverride(t)??this.defaultFramework;return(Jr[n]??Jr.vitest)().apply(t,r,s)}matchOverride(t){let r=_t.default.relative(this.rootDir,t).split(_t.default.sep).join("/");for(let[s,n]of this.frameworkOverrides)if($r(s,r))return n;return null}};function Hr(e="vitest",t={},r=process.cwd()){return[new At,new Ot,new Dt,new Se(r,e,Object.entries(t))]}function Vr(e,t){return t.find(r=>r.canHandle(e))??null}var Ai=/^[a-zA-Z][a-zA-Z0-9_-]{1,}$/,Di=new Set(["import"]),Li=new Set(["common","fixture","fixtures","helper","helpers","index","main","mock","mocks","setup","shared","spec","test","tests","types","util","utils"]);async function Gi(e,t,r,s){let n;try{n=await be.default.readFile(e,"utf8")}catch(a){return{path:e,status:"error",error:String(a)}}let i=Vr(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 be.default.writeFile(e,o,"utf8"),{path:e,status:"updated"})}async function Xr(e,t,r){let s=vt(t),n=s.tagApplier?.framework??"vitest",i=s.tagApplier?.frameworkOverrides??{},o=Hr(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 E of c.tags)Di.has(E.kind)&&Ai.test(E.name)&&(Li.has(E.name.toLowerCase())||p.has(E.name)||(p.add(E.name),g.push(E.name)));g.sort();let u=Qr.default.resolve(t,c.path),y=await Gi(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 Wt=class{isTestNode(t){return t.category==="test"||t.tags.some(r=>r.name==="test")}};var Q=m(require("fs")),v=m(require("path")),Ys=m(require("piscina"));var ve=require("child_process");var Yr="%x00%H%x09%ae%x09%at",Zr=256*1024*1024;function qr(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 ts(e){let t=new Map;try{let r=(0,ve.execFileSync)("git",["-C",e,"log","--since=90 days ago","--name-status","-M",`--format=${Yr}`],{encoding:"utf-8",stdio:["ignore","pipe","ignore"],maxBuffer:Zr});qr(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=(0,ve.execFileSync)("git",["-C",e,"log","--name-status","-M",`--format=${Yr}`],{encoding:"utf-8",stdio:["ignore","pipe","ignore"],maxBuffer:Zr});qr(r,(s,n,i)=>{t.has(s)||t.set(s,{commitCount90d:0,lastAuthor:void 0,lastCommitAt:i||void 0})})}catch{}return t}var pt=m(require("fs")),es=m(require("path")),Ee=require("js-yaml");function rs(e){let t=e.lastIndexOf("@");return t>0?e.substring(0,t):e}function Oi(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)),rs(r)}).filter(Boolean)}function ji(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 _i(e){try{let t=(0,Ee.load)(e),r={dependencies:{}};for(let[s,n]of Object.entries(t))if(!(s==="__metadata"||!n?.version))for(let i of s.split(", ")){let o=rs(i);o&&(r.dependencies[o]={version:n.version,...n.dependencies!==void 0&&{dependencies:n.dependencies}})}return r}catch{return null}}function Wi(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=Oi(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 zi(e){let t=pt.default.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 $i(e){let t=pt.default.readFileSync(e,"utf-8");if(t.includes("__metadata:")){let r=_i(t);if(r!==null)return r}return Wi(t)}function Bi(e){let t=pt.default.readFileSync(e,"utf-8"),r={dependencies:{}};try{let s=(0,Ee.load)(t);if(s.packages)for(let[n,i]of Object.entries(s.packages)){let{name:o,version:a}=ji(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 ss(e){let t=[["package-lock.json",zi],["yarn.lock",$i],["pnpm-lock.yaml",Bi]];for(let[r,s]of t){let n=es.default.join(e,r);if(pt.default.existsSync(n))return s(n)}return null}var Ce=m(require("path"));function I(e){switch(Ce.default.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=Ce.default.extname(e).toLowerCase();return[".css",".scss",".sass",".less",".styl"].includes(t)}var is=m(require("coffeescript"));function M(e){return e.startsWith("'")||e.startsWith('"')?e.slice(1,-1):e}function os(e){if(e){if(typeof e.originalValue=="string")return e.originalValue;if(typeof e.value=="string")return M(e.value)}}function D(e){if(e){if(typeof e.value=="string")return e.value;if(typeof e.base?.value=="string")return e.base.value}}function Ui(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 Ji(e,t){let r=os(t.source);return r?{fromPath:e,toPath:"",rawSpecifier:r,isStyle:k(r),type:"static"}:null}function Hi(e,t){let r=t.variable?.base?.value==="require",s=os(t.args?.[0]?.base);return!r||!s?null:{fromPath:e,toPath:"",rawSpecifier:s,isStyle:k(s),type:"require"}}function ns(e,t){if(t)return[{name:t}];let r=e.value;if(r?.constructor?.name==="Class"){let n=D(r.variable);return n?[{name:n}]:[]}if(r?.base?.constructor?.name==="Obj"&&Array.isArray(r.base.properties))return r.base.properties.map(n=>D(n.variable)??D(n)).filter(n=>!!n).map(n=>({name:n}));let s=D(r);return s?[{name:s}]:[]}function Vi(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=D(e.variable)??D(e.variable?.base);return t?[{name:t}]:[]}function Qi(e,t,r,s){let n=t.constructor?.name;if(n==="ImportDeclaration"){let i=Ji(e,t);i&&r.push(i)}else if(n==="Call"){let i=Hi(e,t);i&&r.push(i)}else if(n==="Assign"){let i=D(t.variable?.base),o=t.variable?.properties?.[0]?.name?.value;i==="module"&&o==="exports"?s.push(...ns(t,void 0)):i==="exports"&&typeof o=="string"&&s.push(...ns(t,o))}else n==="ExportNamedDeclaration"&&t.clause?s.push(...Vi(t.clause)):n==="ExportDefaultDeclaration"&&s.push({name:"default"})}function ke(e,t,r,s){if(!(!t||typeof t!="object")){Qi(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)ke(e,o,r,s);else ke(e,i,r,s)}}}function as(e,t){let r=Ui(t),s=Ki(e,r),n=[],i=[];try{ke(e,is.default.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}}var V=require("@cucumber/gherkin"),cs=require("@cucumber/messages");var Xi=cs.IdGenerator.uuid();function we(e,t){let r=new Set;try{let s=new V.AstBuilder(Xi),n=new V.GherkinClassicTokenMatcher,o=new V.Parser(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"}}A("gherkin",we);var ls=m(require("path")),fs=require("@lezer/go"),Yi=/\/\/\s*@tag\s+([a-zA-Z0-9_-]+)/,Zi=/^\/\/go:build\s+(.+)$/,qi=/^\/\/\s*\+build\s+(.+)$/;function ms(e,t){let r=[],s=new Map,n=new Set,i=new Set,a=fs.parser.parse(t).cursor();do switch(a.name){case"LineComment":{let u=t.slice(a.from,a.to),y=u.match(Yi);y?.[1]&&n.add(y[1]);let E=u.match(Zi);E&&ps(E[1],i);let Y=u.match(qi);Y&&ps(Y[1],i);break}case"ImportSpec":{let u=a.node.getChild("String");if(u){let E=t.slice(u.from,u.to).slice(1,-1);r.push({fromPath:e,toPath:"",rawSpecifier:E,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=ls.default.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 ps(e,t){for(let r of e.split(/[\s,&|!()]+/)){let s=r.trim();s&&s!=="ignore"&&t.add(s)}}var us=m(require("livescript"));function to(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 eo(e,t){let r=e.toLowerCase();return r.includes(".test.")||r.includes(".spec.")||t.has("test")?"test":"logic"}var ro=new Set(["first_line","first_column","last_line","last_column","line","column"]);function so(e,t){let r=e.constructor?.name||e.type;if(r==="Import"){let s=e.right?.value;if(typeof s=="string"){let n=M(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=M(n);return{fromPath:t,toPath:"",rawSpecifier:i,isStyle:k(i),type:"require"}}}}return null}function Fe(e,t){if(!e||typeof e!="object")return[];let r=[],s=so(e,t);s&&r.push(s);for(let n in e){if(ro.has(n))continue;let i=e[n];if(!(!i||typeof i!="object"))if(Array.isArray(i))for(let o of i)r.push(...Fe(o,t));else r.push(...Fe(i,t))}return r}function gs(e,t){let r=to(t),s=eo(e,r),n=[];try{n=Fe(us.default.ast(t),e)}catch{}return{imports:n,exports:[],tags:Array.from(r).map(i=>({name:i,kind:"comment-marker"})),category:s}}var ds=m(require("luaparse"));function no(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 io(e,t){let r=e.toLowerCase();return r.includes(".test.")||r.includes(".spec.")||t.has("test")?"test":"logic"}function oo(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=M(o.raw))}else if(n.type==="StringCallExpression"){let o=n.argument;o?.type==="StringLiteral"&&(i=M(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 ao(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 co(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 po(e){let t=e.body,r=ao(t),s=co(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 hs(e,t){let r=no(t),s=io(e,r),n=[],i=[];try{let o=ds.default.parse(t);n=oo(o,e),i=po(o)}catch{}return{imports:n,exports:i,tags:Array.from(r).map(o=>({name:o,kind:"comment-marker"})),category:s}}var lo=["http://","https://","mailto:","//"],fo="ts|tsx|js|jsx|mjs|cjs|py|go|lua|css|scss|less|styl|coffee|ls|feature|md|mdx|json",mo=new RegExp(`(?:\\.{1,2}/)?[\\w.-]+(?:/[\\w.-]+)*\\.(?:${fo})\\b`,"g"),ys;async function uo(){return ys??=(async()=>{let{unified:e}=await import("unified"),t=(await import("remark-parse")).default;return e().use(t)})(),ys}function go(e){let t=e.trim();return t.length===0||t.startsWith("#")||lo.some(r=>t.startsWith(r))}function ho(e,t){let r=e.match(mo);return r?r.map(s=>({fromPath:t,toPath:"",rawSpecifier:s,isStyle:!1,type:"static"})):[]}function xs(e,t,r){if(e.type==="link"&&typeof e.url=="string"&&!go(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(...ho(e.value,t)),Array.isArray(e.children))for(let s of e.children)xs(s,t,r)}async function Ss(e,t){let s=(await uo()).parse(t),n=[];xs(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"}}var bs=m(require("path")),vs=require("@lezer/python"),yo=new Set(["pytest","unittest","nose","hypothesis"]);function Es(e,t){let r=[],s=[],n=new Set,i=bs.default.basename(e).toLowerCase(),a=vs.parser.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 xo(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=Eo(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 xo(e,t,r){let s=e.firstChild;return s?s.name==="from"?So(e,t,r):bo(e,t,r):[]}function So(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=vo(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[lt(r,i,o,!0)];let p=a===1?"./":"../".repeat(a-1);return c?[lt(r,p+c.replace(/\./g,"/"),o,!1)]:o[0]==="*"?[lt(r,p.slice(0,-1),["*"],!1)]:o.map(g=>lt(r,p+g,[g],!1))}function bo(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(lt(r,i,["*"],!0))}n=n.nextSibling}return s}function vo(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 lt(e,t,r,s){return{fromPath:e,toPath:"",rawSpecifier:t,isStyle:!1,isExternal:s,type:"static",symbols:r.length>0?r:void 0}}function Eo(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=>yo.has(s.rawSpecifier))?"test":"logic"}var Ne=m(require("path")),l=m(require("typescript"));var d=m(require("typescript"));function Co(e){let t=1;function r(s){switch(s.kind){case d.default.SyntaxKind.IfStatement:case d.default.SyntaxKind.ConditionalExpression:case d.default.SyntaxKind.ForStatement:case d.default.SyntaxKind.ForInStatement:case d.default.SyntaxKind.ForOfStatement:case d.default.SyntaxKind.WhileStatement:case d.default.SyntaxKind.DoStatement:case d.default.SyntaxKind.CatchClause:case d.default.SyntaxKind.CaseClause:t++;break;case d.default.SyntaxKind.BinaryExpression:{let n=s.operatorToken.kind;(n===d.default.SyntaxKind.AmpersandAmpersandToken||n===d.default.SyntaxKind.BarBarToken||n===d.default.SyntaxKind.QuestionQuestionToken)&&t++;break}}d.default.forEachChild(s,r)}return r(e),t}function ko(e){let t=0;function r(s,n,i){if(d.default.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.default.isIfStatement(s.elseStatement)?r(s.elseStatement,n,!0):(t+=1,r(s.elseStatement,n+1,!1)));return}if(d.default.isForStatement(s)||d.default.isForInStatement(s)||d.default.isForOfStatement(s)||d.default.isWhileStatement(s)||d.default.isDoStatement(s)||d.default.isSwitchStatement(s)){t+=1+n,d.default.forEachChild(s,a=>r(a,n+1,!1));return}if(d.default.isCatchClause(s)){t+=1+n,d.default.forEachChild(s,a=>r(a,n,!1));return}if(d.default.isConditionalExpression(s)&&(t+=1),d.default.isBinaryExpression(s)){let a=s.operatorToken.kind;(a===d.default.SyntaxKind.AmpersandAmpersandToken||a===d.default.SyntaxKind.BarBarToken||a===d.default.SyntaxKind.QuestionQuestionToken)&&(t+=1)}if(n>0&&(d.default.isFunctionDeclaration(s)||d.default.isFunctionExpression(s)||d.default.isArrowFunction(s))){t+=1+n,d.default.forEachChild(s,a=>r(a,n+1,!1));return}d.default.forEachChild(s,a=>r(a,n,!1))}return r(e,0,!1),t}function Te(e){return{complexity:Co(e),cognitiveComplexity:ko(e)}}var x=m(require("typescript")),Pe=new Set(["test","describe","it"]);function Cs(e,t){wo(e,t),To(e,t),Po(e,t),No(e,t)}function wo(e,t){if((x.default.isFunctionDeclaration(e)||x.default.isVariableDeclaration(e))&&e.name&&x.default.isIdentifier(e.name)&&Fo(e)){let r;if(x.default.isFunctionDeclaration(e))r="function";else{let s=e.initializer;r=s&&(x.default.isArrowFunction(s)||x.default.isFunctionExpression(s))?"function":"variable"}t.tags.add({name:e.name.text,kind:r})}}function Fo(e){if(x.default.isFunctionDeclaration(e))return x.default.isSourceFile(e.parent);let t=e.parent?.parent;return!!t&&x.default.isSourceFile(t.parent)}function To(e,t){if(!x.default.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 Po(e,t){if(!x.default.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 No(e,t){if(x.default.isCallExpression(e)&&Io(e.expression))for(let r of e.arguments)x.default.isObjectLiteralExpression(r)&&Mo(r,t)}function Io(e){return x.default.isIdentifier(e)?Pe.has(e.text):!!(x.default.isPropertyAccessExpression(e)&&(Pe.has(e.name.text)||x.default.isIdentifier(e.expression)&&Pe.has(e.expression.text)))}function Mo(e,t){for(let r of e.properties){if(!x.default.isPropertyAssignment(r)||!x.default.isIdentifier(r.name)||r.name.text!=="tags"&&r.name.text!=="tag")continue;let{initializer:s}=r,n=x.default.isArrayLiteralExpression(s)?s.elements.filter(x.default.isStringLiteral):r.name.text==="tag"&&x.default.isStringLiteral(s)?[s]:[];for(let i of n)t.tags.add({name:i.text.replace(/^@/,""),kind:"comment-marker"})}}function Ie(e,t,r){let s=[],n=new Map,i=new Set,o=l.default.createSourceFile(e,t,l.default.ScriptTarget.Latest,!0,r==="typescript"?l.default.ScriptKind.TSX:l.default.ScriptKind.JSX),a={filePath:e,imports:s,exports:n,tags:i,rawCallEdges:[],sourceFile:o,hasUI:!1,hasTypesOnly:!0,totalStatements:0,exportStatements:0},c=Oe=>{Lo(Oe,a),l.default.forEachChild(Oe,c)};c(o);let p=Jo(e,a);(p==="test"||p==="barrel")&&i.add({name:p,kind:"comment-marker"}),p!=="test"&&Ho(a,o);let g=o.statements[0],u=g?ws(g):void 0,{complexity:y,cognitiveComplexity:E}=Te(o),Y=Ro(o);return{imports:s,exports:Array.from(n.values()),tags:Array.from(i),category:p,rawCallEdges:a.rawCallEdges??[],complexity:y,cognitiveComplexity:E,...Y.length>0?{functions:Y}:{},...u!==void 0?{description:u}:{}}}function Ro(e){let t=[],r=(n,i)=>{let{complexity:o,cognitiveComplexity:a}=Te(i),c=e.getLineAndCharacterOfPosition(i.getStart(e)).line+1;t.push({name:n,line:c,complexity:o,cognitiveComplexity:a})},s=(n,i)=>{if(l.default.isFunctionDeclaration(n)&&n.name&&n.body?r(n.name.text,n):l.default.isVariableDeclaration(n)&&l.default.isIdentifier(n.name)&&n.initializer&&(l.default.isArrowFunction(n.initializer)||l.default.isFunctionExpression(n.initializer))?r(n.name.text,n.initializer):i&&l.default.isMethodDeclaration(n)&&l.default.isIdentifier(n.name)&&n.body?r(`${i}.${n.name.text}`,n):i&&l.default.isConstructorDeclaration(n)&&n.body?r(`${i}.constructor`,n):i&&l.default.isGetAccessorDeclaration(n)&&l.default.isIdentifier(n.name)&&n.body?r(`${i}.get ${n.name.text}`,n):i&&l.default.isSetAccessorDeclaration(n)&&l.default.isIdentifier(n.name)&&n.body&&r(`${i}.set ${n.name.text}`,n),l.default.isClassDeclaration(n)&&n.name){let o=n.name.text;l.default.forEachChild(n,a=>s(a,o));return}l.default.forEachChild(n,o=>s(o,i))};return s(e,void 0),t}function ks(e,t,r,s){let n={name:e},i=ws(r);i!==void 0&&(n.doc=i);let o=Ao(t);o!==void 0&&(n.flags=o);let a=Do(t,s);return a!==void 0&&(n.signature=a),n}function ws(e){let t=l.default.getJSDocCommentsAndTags(e);for(let r of t)if(l.default.isJSDoc(r)&&r.comment)return l.default.getTextOfJSDocComment(r.comment)||void 0}function Ao(e){let t=new Set(["deprecated","internal","public","alpha","beta"]),r=l.default.getJSDocTags(e).map(s=>s.tagName.text).filter(s=>t.has(s));return r.length>0?r:void 0}function Do(e,t){let r=l.default.createPrinter({removeComments:!0}),s=n=>r.printNode(l.default.EmitHint.Unspecified,n,t);if(l.default.isFunctionDeclaration(e)||l.default.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.default.isVariableDeclaration(e)){if(e.type)return s(e.type);if(e.initializer&&(l.default.isArrowFunction(e.initializer)||l.default.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.default.isClassDeclaration(e)&&e.name)return`class ${e.name.text}`;if(l.default.isInterfaceDeclaration(e))return`interface ${e.name.text}`;if(l.default.isTypeAliasDeclaration(e))return s(e.type);if(l.default.isEnumDeclaration(e))return`enum ${e.name.text}`}function Lo(e,t){Go(e,t),Oo(e,t),_o(e,t),Wo(e,t),Ko(e,t),Cs(e,t)}function Go(e,t){if(!l.default.isSourceFile(e))return;let r=e.statements.filter(s=>!l.default.isEmptyStatement(s));t.totalStatements=r.length,t.exportStatements=r.filter(s=>l.default.isExportDeclaration(s)||l.default.isExportAssignment(s)||Me(s)).length}function Oo(e,t){if(l.default.isJsxElement(e)||l.default.isJsxSelfClosingElement(e)||l.default.isJsxFragment(e)){t.hasUI=!0,t.hasTypesOnly=!1;return}if(l.default.isFunctionDeclaration(e)||l.default.isMethodDeclaration(e)||l.default.isArrowFunction(e)||l.default.isClassDeclaration(e)||l.default.isVariableStatement(e)||l.default.isEnumDeclaration(e)){t.hasTypesOnly=!1;return}l.default.isExportDeclaration(e)&&!jo(e)&&(t.hasTypesOnly=!1)}function jo(e){return e.isTypeOnly?!0:!e.exportClause||!l.default.isNamedExports(e.exportClause)?!1:e.exportClause.elements.every(t=>t.isTypeOnly)}function _o(e,t){if(!l.default.isImportDeclaration(e)||!e.moduleSpecifier||!l.default.isStringLiteral(e.moduleSpecifier))return;let r=[];if(e.importClause&&(e.importClause.name&&r.push("default"),e.importClause.namedBindings))if(l.default.isNamedImports(e.importClause.namedBindings))for(let n of e.importClause.namedBindings.elements)r.push(n.name.text);else l.default.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 Wo(e,t){l.default.isExportDeclaration(e)?zo(e,t):l.default.isExportAssignment(e)?t.exports.set("default",{name:"default"}):Me(e)&&Uo(e,t)}function zo(e,t){if(e.moduleSpecifier&&l.default.isStringLiteral(e.moduleSpecifier))$o(e,e.moduleSpecifier.text,t);else if(e.exportClause&&l.default.isNamedExports(e.exportClause))for(let r of e.exportClause.elements){let s=r.name.text;t.exports.set(s,{name:s})}}function $o(e,t,r){let s=Bo(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 Bo(e){return e.exportClause?l.default.isNamedExports(e.exportClause)?e.exportClause.elements.map(t=>t.name.text):[]:["*"]}function Uo(e,t){if((l.default.isFunctionDeclaration(e)||l.default.isClassDeclaration(e)||l.default.isInterfaceDeclaration(e)||l.default.isTypeAliasDeclaration(e)||l.default.isEnumDeclaration(e))&&e.name){let s=e.name.text;t.exports.set(s,ks(s,e,e,t.sourceFile));return}if(l.default.isVariableStatement(e)){for(let s of e.declarationList.declarations)if(l.default.isIdentifier(s.name)){let n=s.name.text;t.exports.set(n,ks(n,s,e,t.sourceFile))}}}function Ko(e,t){if(!l.default.isCallExpression(e))return;let r=e.arguments[0];!r||!l.default.isStringLiteral(r)||(e.expression.kind===l.default.SyntaxKind.ImportKeyword?t.imports.push({fromPath:t.filePath,toPath:"",rawSpecifier:r.text,isStyle:k(r.text),type:"dynamic"}):l.default.isIdentifier(e.expression)&&e.expression.text==="require"&&t.imports.push({fromPath:t.filePath,toPath:"",rawSpecifier:r.text,isStyle:k(r.text),type:"require"}))}function Jo(e,t){let r=Ne.default.basename(e).toLowerCase(),s=Ne.default.extname(e).toLowerCase();return tt().some(i=>r.includes(i))?"test":We(r)?"config":t.imports.some(i=>Kt().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>Ht()?"barrel":"logic"}function Me(e){return l.default.canHaveModifiers(e)&&l.default.getModifiers(e)?.some(t=>t.kind===l.default.SyntaxKind.ExportKeyword)===!0}function Ho(e,t){let r=e.rawCallEdges??[];e.rawCallEdges=r;let s=new Map;for(let n of t.statements){if(!l.default.isImportDeclaration(n)||!l.default.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.default.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=Qo(n);if(i){let o=Xo(n);o&&zt(o,i,s,r);continue}l.default.isClassDeclaration(n)&&n.name&&Vo(n,s,r)}}function Vo(e,t,r){let s=e.name.text;for(let n of e.members)l.default.isMethodDeclaration(n)&&n.body&&l.default.isIdentifier(n.name)?zt(n.body,`${s}.${n.name.text}`,t,r):l.default.isConstructorDeclaration(n)&&n.body&&zt(n.body,`${s}.constructor`,t,r)}function Qo(e){if(Me(e)){if(l.default.isFunctionDeclaration(e)&&e.name)return e.name.text;if(l.default.isVariableStatement(e)){for(let t of e.declarationList.declarations)if(l.default.isIdentifier(t.name)&&t.initializer&&(l.default.isArrowFunction(t.initializer)||l.default.isFunctionExpression(t.initializer)))return t.name.text}}}function Xo(e){if(l.default.isFunctionDeclaration(e))return e.body;if(l.default.isVariableStatement(e)){for(let t of e.declarationList.declarations)if(t.initializer&&(l.default.isArrowFunction(t.initializer)||l.default.isFunctionExpression(t.initializer)))return t.initializer}}function zt(e,t,r,s){if(l.default.isCallExpression(e)&&l.default.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.default.forEachChild(e,n=>zt(n,t,r,s))}function $t(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"}var Re=m(require("postcss")),Yo=m(require("postcss-less")),Zo=Yo,Ts=new Set(["reference","inline"]);function Fs(e){return e.startsWith("~")||e.startsWith("http://")||e.startsWith("https://")||e.startsWith("//")||e.startsWith("data:")}function qo(e){let t=e.trim();return t.length>0&&!t.startsWith("http://")&&!t.startsWith("https://")&&!t.startsWith("//")&&!t.startsWith("data:")&&!t.startsWith("#")}function ta(e,t){let r=e.match(/^\(([^)]+)\)\s+['"]([^'"]+)['"]/);if(r){let i=r[1]?.trim()??"",o=r[2]??"";if(!o)return null;let a=Ts.has(i)?"side-effect":"static";return{fromPath:t,toPath:"",rawSpecifier:o,isStyle:!0,type:a,...Fs(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",...Fs(n)?{isExternal:!0}:{}}:null}function ea(e,t){let r=[],s=/url\(['"]?([^'")]+)['"]?\)/g,n=s.exec(e);for(;n!==null;){let i=n[1]?.trim()??"";qo(i)&&r.push({fromPath:t,toPath:"",rawSpecifier:i,isStyle:!0,type:"static"}),n=s.exec(e)}return r}function Ps(e,t){let r=[];return e.walk(s=>{if(s.type==="atrule"&&s.name==="import"){let n=ta(s.params,t);n&&r.push(n)}s.type==="decl"&&r.push(...ea(s.value,t))}),r}function ra(e){return e.replace(/(?<!:)\/\/.*/g,"")}function sa(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=Ts.has(i)?"side-effect":"static";r.push({fromPath:t,toPath:"",rawSpecifier:o,isStyle:!0,type:a})}n=s.exec(e)}return r}function Ns(e,t){let r=Re.default.parse(ra(e));return{imports:Ps(r,t),root:r}}function na(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 Is(e,t){try{let r=Zo.parse(e),{exports:s,tags:n}=na(r);return{imports:Ps(r,t),root:r,exports:s,tags:n}}catch{return{imports:sa(e,t),root:Re.default.parse(""),exports:[],tags:[]}}}var Rs=require("postcss-scss");function Ms(e){return e.startsWith("_")||e.startsWith("-")}function ia(e){return!!(e.startsWith("sass:")||e.startsWith("~")||e.startsWith("http://")||e.startsWith("https://")||e.startsWith("//")||!e.startsWith(".")&&!e.startsWith("/")&&!e.startsWith("_"))}function oa(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 aa(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||Ms(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||Ms(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 As(e,t){let r=(0,Rs.parse)(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}=oa(c);if(!p)return;let u={fromPath:t,toPath:"",rawSpecifier:p,isStyle:!0,type:a==="forward"?"re-export":"static",...ia(p)?{isExternal:!0}:{}};g&&(u.symbols=[g]),s.push(u)});let{exports:n,tags:i}=aa(r);return{imports:s,root:r,exports:n,tags:i}}function Ds(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 Ls(e,t){if(t.length===0)return"ui";try{let r=require("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 ft(e,t){let r=I(e);if(r==="stylus"){let i=Ds(t,e);return{imports:i,exports:[],tags:[],category:Ls(t,i)}}if(r==="scss"){let{imports:i,root:o,exports:a,tags:c}=As(t,e);return{imports:i,exports:a,tags:c,category:$t(o,i)}}if(r==="less"){let{imports:i,root:o,exports:a,tags:c}=Is(t,e);return{imports:i,exports:a,tags:c,category:$t(o,i)}}let{imports:s,root:n}=Ns(t,e);return{imports:s,exports:[],tags:[],category:$t(n,s)}}for(let[e,t]of[["javascript",(r,s)=>Ie(r,s,"javascript")],["typescript",(r,s)=>Ie(r,s,"typescript")],["css",ft],["scss",ft],["less",ft],["stylus",ft],["coffeescript",as],["livescript",gs],["lua",hs],["python",Es],["go",ms],["gherkin",we],["markdown",Ss]])A(e,t);async function Gs(e,t){let r=I(e),s=Or(r);return s?s(e,t):{imports:[],exports:[],tags:[],category:"other"}}var Ae=m(require("path"));function js(e,t){for(let r of e.values()){let s=t.get(r.path);s!==void 0&&(r.coveragePct=s)}}function _s(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 Ws(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 zs(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 Os(e){return Math.round(e*1e4)/1e4}function $s(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=Os(Math.min(1,i)),r.push(s.exportUsageRatio)}r.length>0&&(t.avgExportUsage=Os(r.reduce((s,n)=>s+n,0)/r.length),t.maxExportUsage=Math.max(...r))}}function De(e,t,r){t&&(e.some(s=>s.name===t&&s.kind===r)||e.push({name:t,kind:r}))}function ca(e,t){let r=t.toPath,s=Ae.default.basename(r,Ae.default.extname(r)).replace(/\.(test|spec)$/,"");De(e.tags,s,"import")}function pa(e,t){if(!(!t.symbols||t.symbols.includes("*")))for(let r of t.symbols)De(e.tags,r,"import")}function la(e,t,r){let s=r.get(t.toPath);if(!(!s||s.category==="test"))for(let n of s.tags)n.kind==="comment-marker"&&De(e.tags,n.name,"comment-marker")}function Bs(e){for(let t of e.values())if(t.category==="test")for(let r of t.imports)!r.toPath||r.isExternal||(ca(t,r),pa(t,r),la(t,r,e))}var yt=m(require("fs")),T=m(require("path"));var Le=m(require("fs")),L=m(require("path")),mt=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 Ks(a);if(r!==i&&!r.startsWith(`${i}/`))return null;let c=r.slice(i.length).replace(/^\//,"");return c?Ks(L.default.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=Le.default.readFileSync(L.default.join(t,"go.mod"),"utf-8"),i=fa(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 L.default.join(i,o)}}}};function fa(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("=>")){Us(a,t,n);continue}!i&&/^replace\s+/.test(a)&&a.includes("=>")&&Us(a.replace(/^replace\s+/,""),t,n)}return{mod:s,replaces:n}}function Us(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=L.default.isAbsolute(n)?n:L.default.resolve(t,n);r.set(i,o)}function Ks(e){let t;try{t=Le.default.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:L.default.join(e,s.name),isExternal:!1})).sort((s,n)=>s.path.localeCompare(n.path));return r.length>0?r:null}var Js=m(require("fs")),Bt=m(require("path")),ut=class{extensions=[".lua"];resolve(t,r,s,n){let i=r.replace(/\./g,Bt.default.sep),o=[s,Bt.default.join(s,"lib")];for(let a of o){if(!Js.default.existsSync(a))continue;let c=n(Bt.default.join(a,"_dummy.lua"),i);if(c)return[c]}return null}};var Hs=m(require("path")),gt=class{extensions=[".md",".mdx"];resolve(t,r,s,n){let i=n(Hs.default.join(s,"_dummy"),`./${r}`);return i?[i]:null}};var Qs=m(require("fs")),Ut=m(require("path")),dt=class{extensions=[".py"];resolve(t,r,s,n){let i=r.replace(/\./g,Ut.default.sep),o=Ut.default.join(s,`${i}.py`);if(Vs(o))return[{path:o,isExternal:!1}];let a=Ut.default.join(s,i,"__init__.py");return Vs(a)?[{path:a,isExternal:!1}]:null}};function Vs(e){try{return Qs.default.statSync(e,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}var Ge=m(require("path")),ma=["~","http://","https://","//","data:","sass:"],ht=class{extensions=[".css",".scss",".sass",".less",".styl"];resolve(t,r,s,n){if(ma.some(g=>r.startsWith(g)))return null;let i=n(t,r);if(i)return[i];let o=Ge.default.dirname(r),a=Ge.default.basename(r),c=o==="."?`_${a}`:`${o}/_${a}`,p=n(t,c);return p?[p]:null}};var G=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 dt,new ut,new mt,new ht,new gt]}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.default.dirname(t),n=r.startsWith("/")?r:T.default.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.default.join(t,`index${r}`);if(this.isFile(i))return{path:i,isExternal:s};if(r===".py"){let o=T.default.join(t,"__init__.py");if(this.isFile(o))return{path:o,isExternal:s}}return null}isFile(t){try{return yt.default.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.default.join(r,"tsconfig.json");if(yt.default.existsSync(s))try{let i=JSON.parse(yt.default.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.default.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.default.join(s,a);try{if(yt.default.statSync(c,{throwIfNoEntry:!1})?.isFile())return{...i,path:c}}catch{}}return{...i,path:s}}let o=this.resolveLocalPath(T.default.join(s,"_dummy"),n.slice(1));return o?{...i,path:o.path}:null}return null}};var ua=["tests","test","__tests__","specs","spec"],Xs=new Set(["node_modules",".git","dist","build",".next",".cache","mokosh-cache","coverage"]),ga=20;function da(e,t){if(e.length===0)return t;let r=e.map(o=>v.default.dirname(o).split(v.default.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(v.default.sep)||v.default.sep,i=v.default.relative(t,n);return i.startsWith("..")||v.default.isAbsolute(i)?t:n}var xt=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 G(t),this.lockFile=ss(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=>v.default.isAbsolute(s)?s:v.default.resolve(this.rootDir,s));await this.initPool(),this.enableGitStats&&(this.gitStatsMap=ts(this.rootDir));try{for(let s of r)this.enqueue(s);return await this.drain(),await this.processTestFiles(da(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
|
-
`),
|
|
23
|
+
`),Bs(this.graph.nodes),Ws(this.graph.nodes),$s(this.graph.nodes),zs(this.graph.nodes),this.coverageMap.size>0&&js(this.graph.nodes,this.coverageMap),new P(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??ga;if(!(r>0&&!this.hasAtLeastFiles(this.rootDir,r)))try{let s=v.default.join(__dirname,"parse-worker.js");this.pool=new Ys.default({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=Q.default.readdirSync(i,{withFileTypes:!0})}catch{continue}for(let a of o)if(a.isDirectory())
|
|
25
|
+
`),this.pool=null}}hasAtLeastFiles(t,r){let s=0,n=[t];for(;n.length>0;){let i=n.pop(),o;try{o=Q.default.readdirSync(i,{withFileTypes:!0})}catch{continue}for(let a of o)if(a.isDirectory())Xs.has(a.name)||n.push(v.default.join(i,a.name));else if(a.isFile()&&(s++,s>=r))return!0}return s>=r}async processTestFiles(t){let r=tt(),s=i=>r.some(o=>i.name.includes(o));this.walkProject(t,s);let n=t;for(;n!==this.rootDir;){let i=v.default.dirname(n);if(i===n)break;for(let o of ua){let a=v.default.join(i,o);try{Q.default.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=Q.default.readdirSync(t,{withFileTypes:!0})}catch{return}for(let n of s){let i=v.default.join(t,n.name);n.isDirectory()?Xs.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=Q.default.statSync(t,{throwIfNoEntry:!1});if(!r?.isFile())return;let s=v.default.relative(this.rootDir,t),n=await this.getNode(t,s,r);n.imports=await this.resolveImports(t,n.imports),_s(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=Q.default.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}):
|
|
27
|
+
`),null}}parseContent(t,r){return this.pool?this.pool.run({filePath:t,content:r}):Gs(t,r)}makeStubNode(t,r,s){return{path:r,type:I(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:v.default.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:E}=n;return{path:r,type:I(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}:{},...E!==void 0?{functions:E}:{}}}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:v.default.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 Zs(e,t){return{identifier:t?.identifier??new Wt,featureMap:t?.featureDetection===!1?new Map:j(e.nodes,t?.featureDetection??void 0)}}function qs(e,t,r,s,n){for(let i of t){let o=e.nodes.get(i);if(!o)continue;let a=new N(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 tn(e,t,r){let{identifier:s,featureMap:n}=Zs(e,r),i=new Set;for(let o of t){let a=n.get(o);a&&i.add(a.tag)}return qs(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 en(e,t,r){let{identifier:s,featureMap:n}=Zs(e,r),i=new Set;return qs(e,t,n,()=>{},o=>{s.isTestNode(o)&&i.add(o.path)}),Array.from(i)}var rn=m(require("fs")),X=m(require("path"));async function ha(e,t,r=null,s={}){let n=s.silent?void 0:a=>{process.stderr.write(`Processed ${a} files...\r`)},i=X.default.resolve(e);return await new xt(i,r,s.pathAliases?new G(i,{pathAliases:s.pathAliases}):void 0,n,s.gitStats??!1,s.coverageMap??new Map,s.parallelParsing??!0).build(t)}async function ya(e,t={}){let r=X.default.resolve(e),s=Mt(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 z(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 xt(r,null,new G(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 xa(e,t={}){let r=[],s=new Set([...t.ignoreDirs??Et,...t.additionalIgnoreDirs??[]]),n=new Set([...t.extensions??Ct,...t.additionalExtensions??[]]);function i(o){try{let a=rn.default.readdirSync(o,{withFileTypes:!0});for(let c of a){let p=X.default.join(o,c.name);c.isDirectory()?s.has(c.name)||i(p):c.isFile()&&n.has(X.default.extname(c.name).toLowerCase())&&r.push(X.default.relative(e,p))}}catch{}}return i(e),r}0&&(module.exports={CALL_EDGE_TYPES,DEFAULT_EXTENSIONS,DEFAULT_IGNORE_DIRS,EXPORT_TRACKING_TYPES,Graph,IMPORT_SYMBOL_TYPES,MermaidExporter,SymbolTraversalContext,WorkspaceGraph,applyConfig,applyTags,buildApiSurface,buildChangeImpactCache,buildFeatureGraph,buildResponsibilityGraph,buildTypeGraph,computeGraphHash,configToGraphOptions,createImportMap,createWorkspaceGraph,detectAllEntryPoints,detectEntryPoint,detectFeatures,detectMonorepo,filterGraph,findComplexFunctions,findSymbol,getAffected,getAllProjectFiles,getCallers,getDependencies,getDependents,getLanguageCoverage,getNodeMeta,hasCoverageData,isChangeImpactCacheValid,loadChangeImpactCache,loadCoverageMap,loadMokoshConfig,parseQuery,proposeAffectedTests,proposeTags,queryCallGraph,queryChangeImpact,queryTypeGraph,registerConfigMatcher,registerMonorepoDetector,registerParser,registerTestLibrary,registerTestPattern,saveChangeImpactCache,slimSerialize,summarizeWorkspacePackages,toMermaid});
|
|
28
28
|
//# sourceMappingURL=index.js.map
|