@omfalos/mokosh 0.4.2 → 0.4.4

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.mjs CHANGED
@@ -1,51 +1,51 @@
1
1
  #!/usr/bin/env node
2
- var Nt=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var m=(t,e)=>()=>(t&&(e=t(t=0)),e);var Pa=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);import Ia from"path";import{fileURLToPath as Da}from"url";var Ma,Aa,u,l=m(()=>{"use strict";Ma=()=>Da(import.meta.url),Aa=()=>Ia.dirname(Ma()),u=Aa()});function ze(t){wn.push(t)}function En(t){return[...La,...wn].some(e=>typeof e=="string"?t.includes(e):e instanceof RegExp?e.test(t):e(t))}function $e(t){Tn.push(t)}function ge(){return[...Ra,...Tn]}function Ue(t){Fn.push(t)}function Pt(){return[...Oa,...Fn]}function It(t){Nn=t}function Dt(){return Nn}var La,wn,Ra,Tn,Oa,Fn,Nn,re=m(()=>{"use strict";l();La=[".config.","biome.json","tsconfig.json","package.json",".prettierrc",".eslintrc"],wn=[];Ra=[".test.",".spec.","-test.","-spec."],Tn=[];Oa=["jest","vitest","playwright","cypress","@testing-library/"],Fn=[];Nn=.8});import Mt from"fs";import Pn from"path";function ne(t,{allowJs:e=!0,isExplicitPath:r=!1}={}){if(r){let n=Pn.resolve(t);return Mt.existsSync(n)?n.endsWith(".json")?In(n):e?Dn(n):{}:{}}for(let n of Ga){let o=Pn.resolve(t,n);if(Mt.existsSync(o)){if(n.endsWith(".json"))return In(o);if(e)return Dn(o)}}return{}}function In(t){return JSON.parse(Mt.readFileSync(t,"utf-8"))}function Dn(t){let e=Nt(t);return e&&typeof e=="object"&&"default"in e&&(e=e.default),typeof e=="function"?e({}):e}function At(t){for(let e of t.configMatchers??[])ze(e);for(let e of t.testPatterns??[])$e(e);for(let e of t.testLibraries??[])Ue(e);t.barrelThreshold!==void 0&&It(t.barrelThreshold)}function N(t){return{gitStats:t?.gitStats??!1,parallelParsing:t?.parallelParsing,pathAliases:t?.pathAliases}}var Ga,Lt=m(()=>{"use strict";l();re();Ga=["mokosh.config.js","mokosh.config.cjs","mokosh.config.json"]});var oe,de,se,J,Rt,he=m(()=>{"use strict";l();oe="mokosh-cache",de="duplication-tokens.json",se="graph.json",J=["node_modules",".git","dist","build",".next",".cache","mokosh-cache","coverage"],Rt=[".ts",".tsx",".js",".jsx",".mjs",".cjs",".css",".scss",".sass",".less",".styl",".coffee",".ls",".lua",".py",".go",".feature",".md",".mdx"]});import Eu from"fs";import Fu from"path";var Mn=m(()=>{"use strict";l()});var Be,An=m(()=>{"use strict";l();Be={serialize(t){let e=["graph TD"],r=new Set;for(let n of t.nodes.values()){let o=`"${n.path}"`;for(let s of n.imports){if(!s.toPath)continue;let i=`"${s.toPath}"`,a=`${n.path} -> ${s.toPath}`;if(!r.has(a)){let c=s.isStyle?"-- styles -->":"-->";e.push(` ${o} ${c} ${i}`),r.add(a)}}}return e.join(`
3
- `)}}});var Ln=m(()=>{"use strict";l();An()});import Rn from"fs";import ja from"path";function Ot(t,e){let r=t.replace(/^\.\//,"");if(e.nodes.has(r))return r;let n=r.replace(/^dist\//,"src/").replace(/\.(js|mjs|cjs)$/,".ts");return e.nodes.has(n)?n:null}function On(t,e){if(typeof t=="string")return Ot(t,e);if(t&&typeof t=="object"){let r=t;for(let n of["import","require","default"]){let o=On(r[n],e);if(o)return o}}return null}function Wa(t){if(!t)return"unknown";let e=t.trimStart();return e.startsWith("interface ")?"interface":e.startsWith("class ")?"class":e.startsWith("enum ")?"enum":e.startsWith("type ")?"type":e.startsWith("namespace ")?"namespace":e.startsWith("const ")||e.startsWith("let ")||e.startsWith("var ")||e.startsWith("readonly ")?"const":e.startsWith("(")||e.startsWith("async ")||e.startsWith("function ")||e.includes("=>")?"function":"unknown"}function za(t,e){let r=new Set,n=new Set,o=[...e];for(;o.length;){let s=o.shift();if(n.has(s))continue;n.add(s);let i=t.nodes.get(s);if(i){for(let a of i.exports)r.add(a.name);for(let a of i.imports){if(a.type!=="re-export"||a.isExternal||!a.toPath)continue;if(!a.symbols?.length||a.symbols.includes("*")){let p=t.nodes.get(a.toPath);if(p)for(let f of p.exports)r.add(f.name);o.push(a.toPath)}else for(let p of a.symbols)r.add(p)}}}return r}function Gt(t,e){let r=[],n=ja.join(e,"package.json");if(Rn.existsSync(n))try{let o=JSON.parse(Rn.readFileSync(n,"utf8"));if(o.exports&&typeof o.exports=="object"&&!Array.isArray(o.exports))for(let s of Object.values(o.exports)){let i=On(s,t);i&&!r.includes(i)&&r.push(i)}else if(typeof o.exports=="string"){let s=Ot(o.exports,t);s&&r.push(s)}if(r.length===0)for(let s of[o.main,o.module].filter(Boolean)){let i=Ot(s,t);i&&!r.includes(i)&&r.push(i)}}catch{}if(r.length===0){for(let o of["src/index.ts","src/index.js","index.ts","index.js"])if(t.nodes.has(o)){r.push(o);break}}return r}function $a(t,e){let r=new Set(e);for(let n of e)t.traverse(n,o=>(r.add(o.path),!0),{direction:"outgoing"});return r}function Ua(t,e,r){let n=new Map;for(let o of e){if(r.includes(o))continue;let s=t.nodes.get(o);if(!s)continue;let i=s.category==="barrel";for(let a of s.exports){let c=n.get(a.name),p=!!(a.signature||a.doc);(!c||p&&!i)&&n.set(a.name,{file:o,symbol:a})}}return n}function Ba(t,e,r,n){let o=[];for(let s of t){let i=e.get(s),a=n.flatMap(d=>r.nodes.get(d)?.exports??[]).find(d=>d.name===s),c=i?.symbol??a,p=i?.file??n.find(d=>r.nodes.get(d)?.exports.some(y=>y.name===s))??n[0],f={name:s,definedIn:p,kind:Wa(c?.signature)};c?.doc&&(f.doc=c.doc),c?.signature&&(f.signature=c.signature),o.push(f)}return o.sort((s,i)=>s.name.localeCompare(i.name)),o}function Ja(t,e,r){let n=c=>t.nodes.get(c)?.category==="test",o=[...e].filter(c=>!r.includes(c)&&!n(c)),s=[...t.nodes.keys()].filter(c=>!e.has(c)),i=s.filter(c=>!n(c)),a=s.filter(c=>n(c));return{internalFiles:o,unreachableFromEntry:i,testFiles:a}}function _t(t,e){if(e.length===0)throw new Error("buildApiSurface requires at least one entry point");for(let p of e)if(!t.nodes.has(p))throw new Error(`Entry point not found in graph: ${p}`);let r=$a(t,e),n=Ua(t,r,e),o=za(t,e),s=Ba(o,n,t,e),{internalFiles:i,unreachableFromEntry:a,testFiles:c}=Ja(t,r,e);return{entryPoints:e,publicExports:s,internalFiles:i,unreachableFromEntry:a,testFiles:c}}var jt=m(()=>{"use strict";l()});function Wt(t,e){let r=null,n=[];for(let s of t.nodes.values()){s.exports.some(i=>i.name===e)&&(r=s.path);for(let i of s.callEdges??[])i.to===e&&n.push({file:s.path,callerFunction:i.from})}let o=[];if(r){let s=t.nodes.get(r);for(let i of s?.callEdges??[])i.from===e&&o.push({file:i.toFile,calleeFunction:i.to})}return{functionName:e,definedIn:r,callers:n,callees:o}}var zt=m(()=>{"use strict";l()});import $u from"fs";import Bu from"path";function Gn(t){let e=[...t.nodes.entries()].sort(([n],[o])=>n.localeCompare(o)).map(([n,o])=>`${n}:${o.mtime}:${o.size}`).join("|"),r=2166136261;for(let n=0;n<e.length;n++)r^=e.charCodeAt(n),r=Math.imul(r,16777619)>>>0;return r.toString(16).padStart(8,"0")}function $t(t){let e=new Map;for(let r of t.nodes.keys()){let n=[];t.traverse(r,o=>(o.path!==r&&n.push(o.path),!0),{direction:"incoming"}),e.set(r,n)}return{impact:e,graphHash:Gn(t)}}function Ut(t,e){return t.impact.get(e)??[]}var Bt=m(()=>{"use strict";l()});import Je from"fs";import Ka from"path";import{load as _n}from"js-yaml";function jn(t){let e=t.lastIndexOf("@");return e>0?t.substring(0,e):t}function Ha(t){return t.replace(/:$/,"").split(",").map(e=>{let r=e.trim();return r.startsWith('"')&&(r=r.slice(1)),r.endsWith('"')&&(r=r.slice(0,-1)),jn(r)}).filter(Boolean)}function Va(t,e){let r=t.startsWith("/")?t.slice(1):t,n=r.lastIndexOf("@");return n>0?{name:r.substring(0,n),version:e||r.substring(n+1)}:{name:r,version:e}}function Qa(t){try{let e=_n(t),r={dependencies:{}};for(let[n,o]of Object.entries(e))if(!(n==="__metadata"||!o?.version))for(let s of n.split(", ")){let i=jn(s);i&&(r.dependencies[i]={version:o.version,...o.dependencies!==void 0&&{dependencies:o.dependencies}})}return r}catch{return null}}function Ya(t){let e={dependencies:{}};for(let r of t.split(/\n\n+/)){let n=r.split(`
4
- `).filter(c=>c.trim().length>0&&!c.trim().startsWith("#"));if(n.length<2)continue;let o=n[0];if(!o||o.startsWith(" "))continue;let s=Ha(o);if(s.length===0)continue;let a=n.find(c=>c.trim().startsWith('version "'))?.match(/version "(.*?)"/)?.[1]??"";for(let c of s)e.dependencies[c]={version:a}}return e}function Xa(t){let e=Je.readFileSync(t,"utf-8"),r=JSON.parse(e),n={dependencies:{}};if(r.packages)for(let[o,s]of Object.entries(r.packages)){if(!o.startsWith("node_modules/"))continue;let i=o.replace("node_modules/","");i.includes("node_modules/")||(n.dependencies[i]={version:s.version,...s.dependencies!==void 0&&{dependencies:s.dependencies}})}else if(r.dependencies)for(let[o,s]of Object.entries(r.dependencies))n.dependencies[o]={version:s.version,...s.dependencies!==void 0&&{dependencies:s.dependencies}};return n}function qa(t){let e=Je.readFileSync(t,"utf-8");if(e.includes("__metadata:")){let r=Qa(e);if(r!==null)return r}return Ya(e)}function Za(t){let e=Je.readFileSync(t,"utf-8"),r={dependencies:{}};try{let n=_n(e);if(n.packages)for(let[o,s]of Object.entries(n.packages)){let{name:i,version:a}=Va(o,s.version);i&&(r.dependencies[i]={version:a,...s.dependencies!==void 0&&{dependencies:s.dependencies}})}if(n.dependencies)for(let[o,s]of Object.entries(n.dependencies)){if(r.dependencies[o])continue;let i=typeof s=="string"?s:s.version;r.dependencies[o]={version:i||""}}}catch{}return r}function Wn(t){let e={"package-lock.json":Xa,"yarn.lock":qa,"pnpm-lock.yaml":Za},r=Jt.map(n=>[n,e[n]]);for(let[n,o]of r){let s=Ka.join(t,n);if(Je.existsSync(s))return o(s)}return null}var Jt,Kt=m(()=>{"use strict";l();Jt=["package-lock.json","yarn.lock","pnpm-lock.yaml"]});function zn(t){return ec.has(t)?"style":"code"}var ec,$n=m(()=>{"use strict";l();ec=new Set(["css","scss","less","stylus"])});import Bn from"postcss";import*as tc from"postcss-less";function Un(t){return t.startsWith("~")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("//")||t.startsWith("data:")}function nc(t){let e=t.trim();return e.length>0&&!e.startsWith("http://")&&!e.startsWith("https://")&&!e.startsWith("//")&&!e.startsWith("data:")&&!e.startsWith("#")}function oc(t,e){let r=t.match(/^\(([^)]+)\)\s+['"]([^'"]+)['"]/);if(r){let s=r[1]?.trim()??"",i=r[2]??"";if(!i)return null;let a=Jn.has(s)?"side-effect":"static";return{fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:a,...Un(i)?{isExternal:!0}:{}}}let n=t.match(/^url\(['"]?([^'")]+)['"]?\)/),o=n?n[1]?.trim()??"":t.match(/^['"]([^'"]+)['"]/)?.[1]??"";return o?{fromPath:e,toPath:"",rawSpecifier:o,isStyle:!0,type:"static",...Un(o)?{isExternal:!0}:{}}:null}function sc(t,e){let r=[],n=/url\(['"]?([^'")]+)['"]?\)/g,o=n.exec(t);for(;o!==null;){let s=o[1]?.trim()??"";nc(s)&&r.push({fromPath:e,toPath:"",rawSpecifier:s,isStyle:!0,type:"static"}),o=n.exec(t)}return r}function Kn(t,e){let r=[];return t.walk(n=>{if(n.type==="atrule"&&n.name==="import"){let o=oc(n.params,e);o&&r.push(o)}n.type==="decl"&&r.push(...sc(n.value,e))}),r}function ic(t){return t.replace(/(?<!:)\/\/.*/g,"")}function ac(t,e){let r=[],n=/@import\s+(?:\(([^)]+)\)\s+)?['"]([^'"]+)['"]/g,o=n.exec(t);for(;o!==null;){let s=o[1]?.trim()??"",i=o[2]??"";if(i){let a=Jn.has(s)?"side-effect":"static";r.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:a})}o=n.exec(t)}return r}function Ke(t,e){let r=Bn.parse(ic(t));return{imports:Kn(r,e),root:r}}function cc(t){let e=[],r=[];for(let n of t.nodes??[]){if(n.type!=="atrule")continue;let{value:o}=n;if(o===void 0)continue;let s=n.name;s&&(e.push({name:s}),r.push({name:s,kind:"variable"}))}return{exports:e,tags:r}}function He(t,e){try{let r=rc.parse(t),{exports:n,tags:o}=cc(r);return{imports:Kn(r,e),root:r,exports:n,tags:o}}catch{return{imports:ac(t,e),root:Bn.parse(""),exports:[],tags:[]}}}var rc,Jn,Ht=m(()=>{"use strict";l();rc=tc,Jn=new Set(["reference","inline"])});import{parse as lc}from"postcss-scss";function Hn(t){return t.startsWith("_")||t.startsWith("-")}function pc(t){return!!(t.startsWith("sass:")||t.startsWith("~")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("//")||!t.startsWith(".")&&!t.startsWith("/")&&!t.startsWith("_"))}function fc(t){let e=t.match(/^['"]([^'"]+)['"]/);if(!e?.[1])return{specifier:""};let r=e[1],o=t.match(/\bas\s+(\S+)/)?.[1];return o!==void 0?{specifier:r,alias:o}:{specifier:r}}function uc(t){let e=[],r=[];for(let n of t.nodes??[]){if(n.type==="decl"&&n.prop.startsWith("$")){let o=n.prop.slice(1);if(!o||Hn(o))continue;e.push({name:o}),r.push({name:o,kind:"variable"});continue}if(n.type==="atrule"&&(n.name==="mixin"||n.name==="function")){let s=n.params.match(/^([\w-]+)/)?.[1];if(!s||Hn(s))continue;let i=n.params.trim();e.push(i.includes("(")?{name:s,signature:i}:{name:s}),r.push({name:s,kind:"function"})}}return{exports:e,tags:r}}function Ve(t,e){let r=lc(t),n=[];r.walk(i=>{if(i.type!=="atrule")return;let{name:a,params:c}=i;if(a!=="import"&&a!=="use"&&a!=="forward")return;let{specifier:p,alias:f}=fc(c);if(!p)return;let d={fromPath:e,toPath:"",rawSpecifier:p,isStyle:!0,type:a==="forward"?"re-export":"static",...pc(p)?{isExternal:!0}:{}};f&&(d.symbols=[f]),n.push(d)});let{exports:o,tags:s}=uc(r);return{imports:n,root:r,exports:o,tags:s}}var Vt=m(()=>{"use strict";l()});function mc(t){return t.trim().replace(/\s+/g," ")}function gc(t){try{return t.fileType==="scss"?Ve(t.source,t.file).root:t.fileType==="less"?He(t.source,t.file).root:t.fileType==="css"?Ke(t.source,t.file).root:void 0}catch{return}}function dc(t){let e=gc(t);if(!e)return[];let r=[];return e.walkRules(n=>{let o=n.nodes?.filter(f=>f.type==="decl")??[];if(o.length===0)return;let s=o[0],i=o[o.length-1],a=n.source?.start?.line??s?.source?.start?.line,c=i?.source?.end?.line??i?.source?.start?.line??a;if(a===void 0||c===void 0)return;let p=o.map(f=>`${f.prop.trim().toLowerCase()}:${mc(f.value)}`).join(";");r.push({file:t.file,startLine:a,endLine:c,lines:c-a+1,signature:p,declCount:o.length})}),r}function Vn(t,e,r=2){let n=new Map;for(let s of t)for(let i of dc(s)){if(i.declCount<r||i.lines<e)continue;let a=n.get(i.signature);a?a.push(i):n.set(i.signature,[i])}let o=[];for(let s of n.values())for(let i=0;i<s.length;i++)for(let a=i+1;a<s.length;a++){let c=s[i],p=s[a];if(c.file===p.file&&c.startLine===p.startLine&&c.endLine===p.endLine)continue;let f={file:c.file,startLine:c.startLine,endLine:c.endLine},d={file:p.file,startLine:p.startLine,endLine:p.endLine};o.push({occurrences:[f,d],lines:Math.min(c.lines,p.lines),tokens:c.declCount,family:"style"})}return o.sort((s,i)=>i.lines-s.lines)}var Qn=m(()=>{"use strict";l();Ht();Vt()});function Yn(t){let e=t.length,r=[],n=[{lcpLength:0,low:0}];for(let o=1;o<e;o++){let s=o-1;for(;t[o]<n[n.length-1].lcpLength;){let i=n.pop();r.push({lcpLength:i.lcpLength,low:i.low,high:o-1}),s=i.low}t[o]>n[n.length-1].lcpLength&&n.push({lcpLength:t[o],low:s})}for(;n.length>1;){let o=n.pop();r.push({lcpLength:o.lcpLength,low:o.low,high:e-1})}return r}var Xn=m(()=>{"use strict";l()});function qn(t,e,r){let n=0;for(let o=e;o<e+r;o++)hc.has(t[o].text)&&n++;return n/r}var hc,Zn=m(()=>{"use strict";l();hc=new Set(["{","}",":",",","[","]"])});function eo(t){let e=t.length;if(e===0)return[];let r=Array.from({length:e},(s,i)=>i),n=new Array(e);{let s=[...new Set(t)].sort(),i=new Map(s.map((a,c)=>[a,c]));for(let a=0;a<e;a++)n[a]=i.get(t[a])}let o=new Array(e).fill(0);for(let s=1;s<e;s*=2){let i=a=>a+s<e?n[a+s]:-1;r.sort((a,c)=>{let p=n[a]-n[c];return p!==0?p:i(a)-i(c)}),o[r[0]]=0;for(let a=1;a<e;a++){let c=r[a-1],p=r[a],f=n[c]===n[p],d=i(c)===i(p);o[p]=o[c]+(f&&d?0:1)}if([n,o]=[o,n],n[r[e-1]]===e-1)break}return r}function to(t,e){let r=t.length,n=new Array(r).fill(0);if(r===0)return n;let o=new Array(r);for(let i=0;i<r;i++)o[e[i]]=i;let s=0;for(let i=0;i<r;i++){let a=o[i];if(a>0){let c=e[a-1];for(;i+s<r&&c+s<r&&t[i+s]===t[c+s];)s++;n[a]=s,s>0&&s--}else s=0}return n}var ro=m(()=>{"use strict";l()});function no(t,e,r,n=.5){let o=[],s=[],i=new Map;for(let{file:d,tokens:y}of t)if(y.length!==0){i.set(d,y);for(let x=0;x<y.length;x++)o.push(y[x].text),s.push({file:d,localIndex:x});o.push(` ${d}`),s.push({file:d,localIndex:-1})}if(o.length===0)return[];let a=eo(o),c=to(o,a),p=Yn(c),f=[];for(let d of p){let y=yc(d,a,s,i,e,r,n);y&&f.push(y)}return f.sort((d,y)=>y.lines-d.lines)}function yc(t,e,r,n,o,s,i){if(t.lcpLength<o)return;let a=[];for(let x=t.low;x<=t.high;x++){let v=r[e[x]];v.localIndex!==-1&&a.push(v)}if(a.length<2||!xc(a,n))return;let c=bc(a,t.lcpLength);if(c.length<2)return;let p=c[0],f=n.get(p.file);if(qn(f,p.localIndex,t.lcpLength)>i)return;let d=c.map(({file:x,localIndex:v})=>{let C=n.get(x);return{file:x,startLine:C[v].line,endLine:C[v+t.lcpLength-1].line}}),y=Math.min(...d.map(x=>x.endLine-x.startLine+1));if(!(y<s))return{occurrences:d,lines:y,tokens:t.lcpLength}}function xc(t,e){let r=null;for(let{file:n,localIndex:o}of t){if(o===0)return!0;let i=e.get(n)[o-1].text;if(r===null)r=i;else if(r!==i)return!0}return!1}function bc(t,e){let r=new Map;for(let{file:o,localIndex:s}of t){let i=r.get(o);i?i.push(s):r.set(o,[s])}let n=[];for(let[o,s]of r){s.sort((a,c)=>a-c);let i=Number.NEGATIVE_INFINITY;for(let a of s)a>=i&&(n.push({file:o,localIndex:a}),i=a+e)}return n}var oo=m(()=>{"use strict";l();Xn();Zn();ro()});function so(t,e,r){let n=t.slice(e,r).replace(/[^\n]/g," ");return t.slice(0,e)+n+t.slice(r)}function Cc(t,e){if(!e)return t;let r=t;for(let[n,o]of e.block??[]){let s=0;for(;;){let i=r.indexOf(n,s);if(i===-1)break;let a=r.indexOf(o,i+n.length),c=a===-1?r.length:a+o.length;r=so(r,i,c),s=c}}for(let n of e.line??[]){let o=0;for(;;){let s=r.indexOf(n,o);if(s===-1)break;let i=r.indexOf(`
5
- `,s),a=i===-1?r.length:i;r=so(r,s,a),o=a}}return r}function ao(t,e,r=!0){let n=Cc(t,Sc[e]),o=[],s=1,i=0;Qt.lastIndex=0;let a=Qt.exec(n);for(;a!==null;){for(let f=i;f<a.index;f++)n[f]===`
6
- `&&s++;i=a.index;let c=a[0],p=c;vc.test(c)&&!Ec.has(c)?p="ID":r&&(io.test(c)||wc.test(c))&&(p=io.test(c)?"NUM":"STR"),o.push({text:p,line:s});for(let f=i;f<a.index+c.length;f++)n[f]===`
7
- `&&s++;i=a.index+c.length,a=Qt.exec(n)}return o}var Sc,kc,Qt,vc,io,wc,Ec,co=m(()=>{"use strict";l();Sc={typescript:{line:["//"],block:[["/*","*/"]]},javascript:{line:["//"],block:[["/*","*/"]]},go:{line:["//"],block:[["/*","*/"]]},css:{block:[["/*","*/"]]},scss:{line:["//"],block:[["/*","*/"]]},less:{line:["//"],block:[["/*","*/"]]},stylus:{line:["//"],block:[["/*","*/"]]},python:{line:["#"]},gherkin:{line:["#"]},coffeescript:{line:["#"],block:[["###","###"]]},livescript:{line:["#"],block:[["###","###"]]},lua:{line:["--"],block:[["--[[","]]"]]},markdown:{block:[["<!--","-->"]]}};kc=["===","!==","...","=>","==","!=","<=",">=","&&","||","::","->","..","+=","-=","*=","/="],Qt=new RegExp(`${kc.map(t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|")}|[A-Za-z_$][A-Za-z0-9_$]*|\\d+(?:\\.\\d+)?|"(?:\\\\.|[^"\\\\])*"|'(?:\\\\.|[^'\\\\])*'|\`(?:\\\\.|[^\`\\\\])*\`|\\S`,"g"),vc=/^[A-Za-z_$][A-Za-z0-9_$]*$/,io=/^\d+(?:\.\d+)?$/,wc=/^(".*"|'.*'|`.*`)$/s,Ec=new Set(["if","else","elif","for","while","do","switch","case","default","break","continue","return","function","def","class","struct","interface","const","let","var","local","import","export","from","package","try","catch","except","finally","throw","raise","new","this","self","end","then","yield","async","await","nil","null","None","true","false","True","False","and","or","not","in","of","is"])});import ye from"fs";import Tc from"path";function Fc(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.mtime=="number"&&typeof e.size=="number"&&typeof e.ignoreLiterals=="boolean"&&Array.isArray(e.tokens)}function Qe(t){try{if(!ye.existsSync(t))return new Map;let e=ye.readFileSync(t,"utf-8"),r=JSON.parse(e);if(!Array.isArray(r))return new Map;let n=r.filter(o=>Array.isArray(o)&&o.length===2&&typeof o[0]=="string"&&Fc(o[1]));return new Map(n)}catch{return new Map}}function Ye(t,e){let r=Tc.dirname(e);ye.existsSync(r)||ye.mkdirSync(r,{recursive:!0}),ye.writeFileSync(e,JSON.stringify([...t.entries()]))}var lo=m(()=>{"use strict";l()});import{readFile as po}from"fs/promises";import xe from"path";import Nc from"piscina";function Dc(t){return Jt.includes(xe.basename(t))}function Mc(t,e){if(e.length===0)return!1;let r=new Set(e);return t.split(xe.sep).some(n=>r.has(n))}async function Yt(t,e,r={}){let{minLines:n=6,windowSize:o=15,ignoreLiterals:s=!0,maxPunctuationRatio:i=.5,limit:a=50,ignoreDirs:c=J,parallelTokenizing:p=!0,tokenCache:f}=r,d=[...t.nodes.values()].filter(x=>!Dc(x.path)&&!Mc(x.path,c)),y=Ac(p,d.length);try{let x=[],v=new Map;if(await Promise.all(d.map(async b=>{if(Ic.has(b.type)){let te;try{te=await po(xe.join(e,b.path),"utf8")}catch{return}x.push({file:b.path,source:te,fileType:b.type});return}let E=f?.get(b.path),G=E&&E.mtime===b.mtime&&E.size===b.size&&E.ignoreLiterals===s,O;if(G)O=E.tokens;else{let te;try{te=await po(xe.join(e,b.path),"utf8")}catch{return}O=y?await y.run({source:te,fileType:b.type,ignoreLiterals:s}):ao(te,b.type,s),f?.set(b.path,{mtime:b.mtime,size:b.size,ignoreLiterals:s,tokens:O})}let B=zn(b.type),kn={file:b.path,tokens:O},vn=v.get(B);vn?vn.push(kn):v.set(B,[kn])})),f){let b=new Set(d.map(E=>E.path));for(let E of f.keys())b.has(E)||f.delete(E)}let C=Vn(x,n);for(let[b,E]of v)for(let G of no(E,o,n,i))C.push({...G,family:b});return{groups:C.sort((b,E)=>E.lines-b.lines).slice(0,a)}}finally{y&&await y.destroy()}}function Ac(t,e){if(t===!1)return null;let r=typeof t=="object"?t:{},n=r.minFiles??Pc;if(e<n)return null;r.maxThreads!==void 0&&r.maxThreads<1&&process.stderr.write(`
2
+ var At=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var m=(t,e)=>()=>(t&&(e=t(t=0)),e);var Ba=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);import Ua from"path";import{fileURLToPath as Ha}from"url";var Ja,Ka,u,l=m(()=>{"use strict";Ja=()=>Ha(import.meta.url),Ka=()=>Ua.dirname(Ja()),u=Ka()});function He(t){Rt.push(t)}function Rn(t){return[...Va,...Rt].some(e=>typeof e=="string"?t.includes(e):e instanceof RegExp?e.test(t):e(t))}function Je(t){Lt.push(t)}function ye(){return[...Qa,...Lt]}function Ke(t){Ot.push(t)}function Gt(){return[...Ya,...Ot]}function jt(t){_t=t}function Wt(){return _t}function Ve(){Rt.length=0,Lt.length=0,Ot.length=0,_t=Ln}var Va,Rt,Qa,Lt,Ya,Ot,Ln,_t,se=m(()=>{"use strict";l();Va=[".config.","biome.json","tsconfig.json","package.json",".prettierrc",".eslintrc"],Rt=[];Qa=[".test.",".spec.","-test.","-spec."],Lt=[];Ya=["jest","vitest","playwright","cypress","@testing-library/"],Ot=[];Ln=.8,_t=Ln});import zt from"fs";import On from"path";function ie(t,{allowJs:e=!0,isExplicitPath:r=!1}={}){if(r){let n=On.resolve(t);return zt.existsSync(n)?n.endsWith(".json")?Gn(n):e?_n(n):{}:{}}for(let n of Xa){let o=On.resolve(t,n);if(zt.existsSync(o)){if(n.endsWith(".json"))return Gn(o);if(e)return _n(o)}}return{}}function Gn(t){return JSON.parse(zt.readFileSync(t,"utf-8"))}function _n(t){let e=At(t);return e&&typeof e=="object"&&"default"in e&&(e=e.default),typeof e=="function"?e({}):e}function $t(t){Ve();for(let e of t.configMatchers??[])He(e);for(let e of t.testPatterns??[])Je(e);for(let e of t.testLibraries??[])Ke(e);t.barrelThreshold!==void 0&&jt(t.barrelThreshold)}function N(t){return{gitStats:t?.gitStats??!1,parallelParsing:t?.parallelParsing,pathAliases:t?.pathAliases}}var Xa,Bt=m(()=>{"use strict";l();se();Xa=["mokosh.config.js","mokosh.config.cjs","mokosh.config.json"]});var ae,xe,ce,K,Ut,be=m(()=>{"use strict";l();ae="mokosh-cache",xe="duplication-tokens.json",ce="graph.json",K=["node_modules",".git","dist","build",".next",".cache","mokosh-cache","coverage"],Ut=[".ts",".tsx",".js",".jsx",".mjs",".cjs",".css",".scss",".sass",".less",".styl",".coffee",".ls",".lua",".py",".go",".feature",".md",".mdx"]});import Xu from"fs";import Zu from"path";var jn=m(()=>{"use strict";l()});var Qe,Wn=m(()=>{"use strict";l();Qe={serialize(t){let e=["graph TD"],r=new Set;for(let n of t.nodes.values()){let o=`"${n.path}"`;for(let s of n.imports){if(!s.toPath)continue;let i=`"${s.toPath}"`,a=`${n.path} -> ${s.toPath}`;if(!r.has(a)){let c=s.isStyle?"-- styles -->":"-->";e.push(` ${o} ${c} ${i}`),r.add(a)}}}return e.join(`
3
+ `)}}});var zn=m(()=>{"use strict";l();Wn()});import $n from"fs";import Za from"path";function Ht(t,e){let r=t.replace(/^\.\//,"");if(e.nodes.has(r))return r;let n=r.replace(/^dist\//,"src/").replace(/\.(js|mjs|cjs)$/,".ts");return e.nodes.has(n)?n:null}function Bn(t,e){if(typeof t=="string")return Ht(t,e);if(t&&typeof t=="object"){let r=t;for(let n of["import","require","default"]){let o=Bn(r[n],e);if(o)return o}}return null}function ec(t){if(!t)return"unknown";let e=t.trimStart();return e.startsWith("interface ")?"interface":e.startsWith("class ")?"class":e.startsWith("enum ")?"enum":e.startsWith("type ")?"type":e.startsWith("namespace ")?"namespace":e.startsWith("const ")||e.startsWith("let ")||e.startsWith("var ")||e.startsWith("readonly ")?"const":e.startsWith("(")||e.startsWith("async ")||e.startsWith("function ")||e.includes("=>")?"function":"unknown"}function tc(t,e){let r=new Set,n=new Set,o=[...e];for(;o.length;){let s=o.shift();if(n.has(s))continue;n.add(s);let i=t.nodes.get(s);if(i){for(let a of i.exports)r.add(a.name);for(let a of i.imports){if(a.type!=="re-export"||a.isExternal||!a.toPath)continue;if(!a.symbols?.length||a.symbols.includes("*")){let p=t.nodes.get(a.toPath);if(p)for(let f of p.exports)r.add(f.name);o.push(a.toPath)}else for(let p of a.symbols)r.add(p)}}}return r}function Jt(t,e){let r=[],n=Za.join(e,"package.json");if($n.existsSync(n))try{let o=JSON.parse($n.readFileSync(n,"utf8"));if(o.exports&&typeof o.exports=="object"&&!Array.isArray(o.exports))for(let s of Object.values(o.exports)){let i=Bn(s,t);i&&!r.includes(i)&&r.push(i)}else if(typeof o.exports=="string"){let s=Ht(o.exports,t);s&&r.push(s)}if(r.length===0)for(let s of[o.main,o.module].filter(Boolean)){let i=Ht(s,t);i&&!r.includes(i)&&r.push(i)}}catch{}if(r.length===0){for(let o of["src/index.ts","src/index.js","index.ts","index.js"])if(t.nodes.has(o)){r.push(o);break}}return r}function rc(t,e){let r=new Set(e);for(let n of e)t.traverse(n,o=>(r.add(o.path),!0),{direction:"outgoing"});return r}function nc(t,e,r){let n=new Map;for(let o of e){if(r.includes(o))continue;let s=t.nodes.get(o);if(!s)continue;let i=s.category==="barrel";for(let a of s.exports){let c=n.get(a.name),p=!!(a.signature||a.doc);(!c||p&&!i)&&n.set(a.name,{file:o,symbol:a})}}return n}function oc(t,e,r,n){let o=[];for(let s of t){let i=e.get(s),a=n.flatMap(g=>r.nodes.get(g)?.exports??[]).find(g=>g.name===s),c=i?.symbol??a,p=i?.file??n.find(g=>r.nodes.get(g)?.exports.some(y=>y.name===s))??n[0],f={name:s,definedIn:p,kind:ec(c?.signature)};c?.doc&&(f.doc=c.doc),c?.signature&&(f.signature=c.signature),o.push(f)}return o.sort((s,i)=>s.name.localeCompare(i.name)),o}function sc(t,e,r){let n=c=>t.nodes.get(c)?.category==="test",o=[...e].filter(c=>!r.includes(c)&&!n(c)),s=[...t.nodes.keys()].filter(c=>!e.has(c)),i=s.filter(c=>!n(c)),a=s.filter(c=>n(c));return{internalFiles:o,unreachableFromEntry:i,testFiles:a}}function Kt(t,e){if(e.length===0)throw new Error("buildApiSurface requires at least one entry point");for(let p of e)if(!t.nodes.has(p))throw new Error(`Entry point not found in graph: ${p}`);let r=rc(t,e),n=nc(t,r,e),o=tc(t,e),s=oc(o,n,t,e),{internalFiles:i,unreachableFromEntry:a,testFiles:c}=sc(t,r,e);return{entryPoints:e,publicExports:s,internalFiles:i,unreachableFromEntry:a,testFiles:c}}var Vt=m(()=>{"use strict";l()});function Qt(t,e){let r=null,n=[];for(let s of t.nodes.values()){s.exports.some(i=>i.name===e)&&(r=s.path);for(let i of s.callEdges??[])i.to===e&&n.push({file:s.path,callerFunction:i.from})}let o=[];if(r){let s=t.nodes.get(r);for(let i of s?.callEdges??[])i.from===e&&o.push({file:i.toFile,calleeFunction:i.to})}return{functionName:e,definedIn:r,callers:n,callees:o}}var Yt=m(()=>{"use strict";l()});import dm from"fs";import hm from"path";function Un(t){let e=[...t.nodes.entries()].sort(([n],[o])=>n.localeCompare(o)).map(([n,o])=>`${n}:${o.mtime}:${o.size}`).join("|"),r=2166136261;for(let n=0;n<e.length;n++)r^=e.charCodeAt(n),r=Math.imul(r,16777619)>>>0;return r.toString(16).padStart(8,"0")}function Xt(t){let e=new Map;for(let r of t.nodes.keys()){let n=[];t.traverse(r,o=>(o.path!==r&&n.push(o.path),!0),{direction:"incoming"}),e.set(r,n)}return{impact:e,graphHash:Un(t)}}function qt(t,e){return t.impact.get(e)??[]}var Zt=m(()=>{"use strict";l()});import Ye from"fs";import ic from"path";import{load as Hn}from"js-yaml";function Jn(t){let e=t.lastIndexOf("@");return e>0?t.substring(0,e):t}function ac(t){return t.replace(/:$/,"").split(",").map(e=>{let r=e.trim();return r.startsWith('"')&&(r=r.slice(1)),r.endsWith('"')&&(r=r.slice(0,-1)),Jn(r)}).filter(Boolean)}function cc(t,e){let r=t.startsWith("/")?t.slice(1):t,n=r.lastIndexOf("@");return n>0?{name:r.substring(0,n),version:e||r.substring(n+1)}:{name:r,version:e}}function lc(t){try{let e=Hn(t),r={dependencies:{}};for(let[n,o]of Object.entries(e))if(!(n==="__metadata"||!o?.version))for(let s of n.split(", ")){let i=Jn(s);i&&(r.dependencies[i]={version:o.version,...o.dependencies!==void 0&&{dependencies:o.dependencies}})}return r}catch{return null}}function pc(t){let e={dependencies:{}};for(let r of t.split(/\n\n+/)){let n=r.split(`
4
+ `).filter(c=>c.trim().length>0&&!c.trim().startsWith("#"));if(n.length<2)continue;let o=n[0];if(!o||o.startsWith(" "))continue;let s=ac(o);if(s.length===0)continue;let a=n.find(c=>c.trim().startsWith('version "'))?.match(/version "(.*?)"/)?.[1]??"";for(let c of s)e.dependencies[c]={version:a}}return e}function fc(t){let e=Ye.readFileSync(t,"utf-8"),r=JSON.parse(e),n={dependencies:{}};if(r.packages)for(let[o,s]of Object.entries(r.packages)){if(!o.startsWith("node_modules/"))continue;let i=o.replace("node_modules/","");i.includes("node_modules/")||(n.dependencies[i]={version:s.version,...s.dependencies!==void 0&&{dependencies:s.dependencies}})}else if(r.dependencies)for(let[o,s]of Object.entries(r.dependencies))n.dependencies[o]={version:s.version,...s.dependencies!==void 0&&{dependencies:s.dependencies}};return n}function uc(t){let e=Ye.readFileSync(t,"utf-8");if(e.includes("__metadata:")){let r=lc(e);if(r!==null)return r}return pc(e)}function mc(t){let e=Ye.readFileSync(t,"utf-8"),r={dependencies:{}};try{let n=Hn(e);if(n.packages)for(let[o,s]of Object.entries(n.packages)){let{name:i,version:a}=cc(o,s.version);i&&(r.dependencies[i]={version:a,...s.dependencies!==void 0&&{dependencies:s.dependencies}})}if(n.dependencies)for(let[o,s]of Object.entries(n.dependencies)){if(r.dependencies[o])continue;let i=typeof s=="string"?s:s.version;r.dependencies[o]={version:i||""}}}catch{}return r}function Kn(t){let e={"package-lock.json":fc,"yarn.lock":uc,"pnpm-lock.yaml":mc},r=er.map(n=>[n,e[n]]);for(let[n,o]of r){let s=ic.join(t,n);if(Ye.existsSync(s))return o(s)}return null}var er,tr=m(()=>{"use strict";l();er=["package-lock.json","yarn.lock","pnpm-lock.yaml"]});function Vn(t){return dc.has(t)?"style":"code"}var dc,Qn=m(()=>{"use strict";l();dc=new Set(["css","scss","less","stylus"])});import Xn from"postcss";import*as gc from"postcss-less";function Yn(t){return t.startsWith("~")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("//")||t.startsWith("data:")}function yc(t){let e=t.trim();return e.length>0&&!e.startsWith("http://")&&!e.startsWith("https://")&&!e.startsWith("//")&&!e.startsWith("data:")&&!e.startsWith("#")}function xc(t,e){let r=t.match(/^\(([^)]+)\)\s+['"]([^'"]+)['"]/);if(r){let s=r[1]?.trim()??"",i=r[2]??"";if(!i)return null;let a=qn.has(s)?"side-effect":"static";return{fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:a,...Yn(i)?{isExternal:!0}:{}}}let n=t.match(/^url\(['"]?([^'")]+)['"]?\)/),o=n?n[1]?.trim()??"":t.match(/^['"]([^'"]+)['"]/)?.[1]??"";return o?{fromPath:e,toPath:"",rawSpecifier:o,isStyle:!0,type:"static",...Yn(o)?{isExternal:!0}:{}}:null}function bc(t,e){let r=[],n=/url\(['"]?([^'")]+)['"]?\)/g,o=n.exec(t);for(;o!==null;){let s=o[1]?.trim()??"";yc(s)&&r.push({fromPath:e,toPath:"",rawSpecifier:s,isStyle:!0,type:"static"}),o=n.exec(t)}return r}function Zn(t,e){let r=[];return t.walk(n=>{if(n.type==="atrule"&&n.name==="import"){let o=xc(n.params,e);o&&r.push(o)}n.type==="decl"&&r.push(...bc(n.value,e))}),r}function Sc(t){return t.replace(/(?<!:)\/\/.*/g,"")}function Cc(t,e){let r=[],n=/@import\s+(?:\(([^)]+)\)\s+)?['"]([^'"]+)['"]/g,o=n.exec(t);for(;o!==null;){let s=o[1]?.trim()??"",i=o[2]??"";if(i){let a=qn.has(s)?"side-effect":"static";r.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:a})}o=n.exec(t)}return r}function Xe(t,e){let r=Xn.parse(Sc(t));return{imports:Zn(r,e),root:r}}function kc(t){let e=[],r=[];for(let n of t.nodes??[]){if(n.type!=="atrule")continue;let{value:o}=n;if(o===void 0)continue;let s=n.name;s&&(e.push({name:s}),r.push({name:s,kind:"variable"}))}return{exports:e,tags:r}}function qe(t,e){try{let r=hc.parse(t),{exports:n,tags:o}=kc(r);return{imports:Zn(r,e),root:r,exports:n,tags:o}}catch{return{imports:Cc(t,e),root:Xn.parse(""),exports:[],tags:[]}}}var hc,qn,rr=m(()=>{"use strict";l();hc=gc,qn=new Set(["reference","inline"])});import{parse as vc}from"postcss-scss";function eo(t){return t.startsWith("_")||t.startsWith("-")}function wc(t){return!!(t.startsWith("sass:")||t.startsWith("~")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("//")||!t.startsWith(".")&&!t.startsWith("/")&&!t.startsWith("_"))}function Tc(t){let e=t.match(/^['"]([^'"]+)['"]/);if(!e?.[1])return{specifier:""};let r=e[1],o=t.match(/\bas\s+(\S+)/)?.[1];return o!==void 0?{specifier:r,alias:o}:{specifier:r}}function Ec(t){let e=[],r=[];for(let n of t.nodes??[]){if(n.type==="decl"&&n.prop.startsWith("$")){let o=n.prop.slice(1);if(!o||eo(o))continue;e.push({name:o}),r.push({name:o,kind:"variable"});continue}if(n.type==="atrule"&&(n.name==="mixin"||n.name==="function")){let s=n.params.match(/^([\w-]+)/)?.[1];if(!s||eo(s))continue;let i=n.params.trim();e.push(i.includes("(")?{name:s,signature:i}:{name:s}),r.push({name:s,kind:"function"})}}return{exports:e,tags:r}}function Ze(t,e){let r=vc(t),n=[];r.walk(i=>{if(i.type!=="atrule")return;let{name:a,params:c}=i;if(a!=="import"&&a!=="use"&&a!=="forward")return;let{specifier:p,alias:f}=Tc(c);if(!p)return;let g={fromPath:e,toPath:"",rawSpecifier:p,isStyle:!0,type:a==="forward"?"re-export":"static",...wc(p)?{isExternal:!0}:{}};f&&(g.symbols=[f]),n.push(g)});let{exports:o,tags:s}=Ec(r);return{imports:n,root:r,exports:o,tags:s}}var nr=m(()=>{"use strict";l()});function Fc(t){return t.trim().replace(/\s+/g," ")}function Nc(t){try{return t.fileType==="scss"?Ze(t.source,t.file).root:t.fileType==="less"?qe(t.source,t.file).root:t.fileType==="css"?Xe(t.source,t.file).root:void 0}catch{return}}function Pc(t){let e=Nc(t);if(!e)return[];let r=[];return e.walkRules(n=>{let o=n.nodes?.filter(f=>f.type==="decl")??[];if(o.length===0)return;let s=o[0],i=o[o.length-1],a=n.source?.start?.line??s?.source?.start?.line,c=i?.source?.end?.line??i?.source?.start?.line??a;if(a===void 0||c===void 0)return;let p=o.map(f=>`${f.prop.trim().toLowerCase()}:${Fc(f.value)}`).join(";");r.push({file:t.file,startLine:a,endLine:c,lines:c-a+1,signature:p,declCount:o.length})}),r}function to(t,e,r=2){let n=new Map;for(let s of t)for(let i of Pc(s)){if(i.declCount<r||i.lines<e)continue;let a=n.get(i.signature);a?a.push(i):n.set(i.signature,[i])}let o=[];for(let s of n.values())for(let i=0;i<s.length;i++)for(let a=i+1;a<s.length;a++){let c=s[i],p=s[a];if(c.file===p.file&&c.startLine===p.startLine&&c.endLine===p.endLine)continue;let f={file:c.file,startLine:c.startLine,endLine:c.endLine},g={file:p.file,startLine:p.startLine,endLine:p.endLine};o.push({occurrences:[f,g],lines:Math.min(c.lines,p.lines),tokens:c.declCount,family:"style"})}return o.sort((s,i)=>i.lines-s.lines)}var ro=m(()=>{"use strict";l();rr();nr()});function no(t){let e=t.length,r=[],n=[{lcpLength:0,low:0}];for(let o=1;o<e;o++){let s=o-1;for(;t[o]<n[n.length-1].lcpLength;){let i=n.pop();r.push({lcpLength:i.lcpLength,low:i.low,high:o-1}),s=i.low}t[o]>n[n.length-1].lcpLength&&n.push({lcpLength:t[o],low:s})}for(;n.length>1;){let o=n.pop();r.push({lcpLength:o.lcpLength,low:o.low,high:e-1})}return r}var oo=m(()=>{"use strict";l()});function so(t,e,r){let n=0;for(let o=e;o<e+r;o++)Ic.has(t[o].text)&&n++;return n/r}var Ic,io=m(()=>{"use strict";l();Ic=new Set(["{","}",":",",","[","]"])});function ao(t){let e=t.length;if(e===0)return[];let r=Array.from({length:e},(s,i)=>i),n=new Array(e);{let s=[...new Set(t)].sort(),i=new Map(s.map((a,c)=>[a,c]));for(let a=0;a<e;a++)n[a]=i.get(t[a])}let o=new Array(e).fill(0);for(let s=1;s<e;s*=2){let i=a=>a+s<e?n[a+s]:-1;r.sort((a,c)=>{let p=n[a]-n[c];return p!==0?p:i(a)-i(c)}),o[r[0]]=0;for(let a=1;a<e;a++){let c=r[a-1],p=r[a],f=n[c]===n[p],g=i(c)===i(p);o[p]=o[c]+(f&&g?0:1)}if([n,o]=[o,n],n[r[e-1]]===e-1)break}return r}function co(t,e){let r=t.length,n=new Array(r).fill(0);if(r===0)return n;let o=new Array(r);for(let i=0;i<r;i++)o[e[i]]=i;let s=0;for(let i=0;i<r;i++){let a=o[i];if(a>0){let c=e[a-1];for(;i+s<r&&c+s<r&&t[i+s]===t[c+s];)s++;n[a]=s,s>0&&s--}else s=0}return n}var lo=m(()=>{"use strict";l()});function po(t,e,r,n=.5){let o=[],s=[],i=new Map;for(let{file:g,tokens:y}of t)if(y.length!==0){i.set(g,y);for(let x=0;x<y.length;x++)o.push(y[x].text),s.push({file:g,localIndex:x});o.push(` ${g}`),s.push({file:g,localIndex:-1})}if(o.length===0)return[];let a=ao(o),c=co(o,a),p=no(c),f=[];for(let g of p){let y=Dc(g,a,s,i,e,r,n);y&&f.push(y)}return f.sort((g,y)=>y.lines-g.lines)}function Dc(t,e,r,n,o,s,i){if(t.lcpLength<o)return;let a=[];for(let x=t.low;x<=t.high;x++){let w=r[e[x]];w.localIndex!==-1&&a.push(w)}if(a.length<2||!Mc(a,n))return;let c=Ac(a,t.lcpLength);if(c.length<2)return;let p=c[0],f=n.get(p.file);if(so(f,p.localIndex,t.lcpLength)>i)return;let g=c.map(({file:x,localIndex:w})=>{let E=n.get(x);return{file:x,startLine:E[w].line,endLine:E[w+t.lcpLength-1].line}}),y=Math.min(...g.map(x=>x.endLine-x.startLine+1));if(!(y<s))return{occurrences:g,lines:y,tokens:t.lcpLength}}function Mc(t,e){let r=null;for(let{file:n,localIndex:o}of t){if(o===0)return!0;let i=e.get(n)[o-1].text;if(r===null)r=i;else if(r!==i)return!0}return!1}function Ac(t,e){let r=new Map;for(let{file:o,localIndex:s}of t){let i=r.get(o);i?i.push(s):r.set(o,[s])}let n=[];for(let[o,s]of r){s.sort((a,c)=>a-c);let i=Number.NEGATIVE_INFINITY;for(let a of s)a>=i&&(n.push({file:o,localIndex:a}),i=a+e)}return n}var fo=m(()=>{"use strict";l();oo();io();lo()});function uo(t,e,r){let n=t.slice(e,r).replace(/[^\n]/g," ");return t.slice(0,e)+n+t.slice(r)}function Lc(t,e){if(!e)return t;let r=t;for(let[n,o]of e.block??[]){let s=0;for(;;){let i=r.indexOf(n,s);if(i===-1)break;let a=r.indexOf(o,i+n.length),c=a===-1?r.length:a+o.length;r=uo(r,i,c),s=c}}for(let n of e.line??[]){let o=0;for(;;){let s=r.indexOf(n,o);if(s===-1)break;let i=r.indexOf(`
5
+ `,s),a=i===-1?r.length:i;r=uo(r,s,a),o=a}}return r}function go(t,e,r=!0){let n=Lc(t,Rc[e]),o=[],s=1,i=0;or.lastIndex=0;let a=or.exec(n);for(;a!==null;){for(let f=i;f<a.index;f++)n[f]===`
6
+ `&&s++;i=a.index;let c=a[0],p=c;Gc.test(c)&&!jc.has(c)?p="ID":r&&(mo.test(c)||_c.test(c))&&(p=mo.test(c)?"NUM":"STR"),o.push({text:p,line:s});for(let f=i;f<a.index+c.length;f++)n[f]===`
7
+ `&&s++;i=a.index+c.length,a=or.exec(n)}return o}var Rc,Oc,or,Gc,mo,_c,jc,ho=m(()=>{"use strict";l();Rc={typescript:{line:["//"],block:[["/*","*/"]]},javascript:{line:["//"],block:[["/*","*/"]]},go:{line:["//"],block:[["/*","*/"]]},css:{block:[["/*","*/"]]},scss:{line:["//"],block:[["/*","*/"]]},less:{line:["//"],block:[["/*","*/"]]},stylus:{line:["//"],block:[["/*","*/"]]},python:{line:["#"]},gherkin:{line:["#"]},coffeescript:{line:["#"],block:[["###","###"]]},livescript:{line:["#"],block:[["###","###"]]},lua:{line:["--"],block:[["--[[","]]"]]},markdown:{block:[["<!--","-->"]]}};Oc=["===","!==","...","=>","==","!=","<=",">=","&&","||","::","->","..","+=","-=","*=","/="],or=new RegExp(`${Oc.map(t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|")}|[A-Za-z_$][A-Za-z0-9_$]*|\\d+(?:\\.\\d+)?|"(?:\\\\.|[^"\\\\])*"|'(?:\\\\.|[^'\\\\])*'|\`(?:\\\\.|[^\`\\\\])*\`|\\S`,"g"),Gc=/^[A-Za-z_$][A-Za-z0-9_$]*$/,mo=/^\d+(?:\.\d+)?$/,_c=/^(".*"|'.*'|`.*`)$/s,jc=new Set(["if","else","elif","for","while","do","switch","case","default","break","continue","return","function","def","class","struct","interface","const","let","var","local","import","export","from","package","try","catch","except","finally","throw","raise","new","this","self","end","then","yield","async","await","nil","null","None","true","false","True","False","and","or","not","in","of","is"])});import Se from"fs";import Wc from"path";function zc(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.mtime=="number"&&typeof e.size=="number"&&typeof e.ignoreLiterals=="boolean"&&Array.isArray(e.tokens)}function et(t){try{if(!Se.existsSync(t))return new Map;let e=Se.readFileSync(t,"utf-8"),r=JSON.parse(e);if(!Array.isArray(r))return new Map;let n=r.filter(o=>Array.isArray(o)&&o.length===2&&typeof o[0]=="string"&&zc(o[1]));return new Map(n)}catch{return new Map}}function tt(t,e){let r=Wc.dirname(e);Se.existsSync(r)||Se.mkdirSync(r,{recursive:!0}),Se.writeFileSync(e,JSON.stringify([...t.entries()]))}var yo=m(()=>{"use strict";l()});import{readFile as xo}from"fs/promises";import Ce from"path";import $c from"piscina";function Hc(t){return er.includes(Ce.basename(t))}function Jc(t,e){if(e.length===0)return!1;let r=new Set(e);return t.split(Ce.sep).some(n=>r.has(n))}async function sr(t,e,r={}){let{minLines:n=6,windowSize:o=15,ignoreLiterals:s=!0,maxPunctuationRatio:i=.5,limit:a=50,ignoreDirs:c=K,parallelTokenizing:p=!0,tokenCache:f}=r,g=[...t.nodes.values()].filter(x=>!Hc(x.path)&&!Jc(x.path,c)),y=Kc(p,g.length);try{let x=[],w=new Map;if(await Promise.all(g.map(async b=>{if(Uc.has(b.type)){let oe;try{oe=await xo(Ce.join(e,b.path),"utf8")}catch{return}x.push({file:b.path,source:oe,fileType:b.type});return}let v=f?.get(b.path),G=v&&v.mtime===b.mtime&&v.size===b.size&&v.ignoreLiterals===s,O;if(G)O=v.tokens;else{let oe;try{oe=await xo(Ce.join(e,b.path),"utf8")}catch{return}O=y?await y.run({source:oe,fileType:b.type,ignoreLiterals:s}):go(oe,b.type,s),f?.set(b.path,{mtime:b.mtime,size:b.size,ignoreLiterals:s,tokens:O})}let J=Vn(b.type),Mn={file:b.path,tokens:O},An=w.get(J);An?An.push(Mn):w.set(J,[Mn])})),f){let b=new Set(g.map(v=>v.path));for(let v of f.keys())b.has(v)||f.delete(v)}let E=to(x,n);for(let[b,v]of w)for(let G of po(v,o,n,i))E.push({...G,family:b});return{groups:E.sort((b,v)=>v.lines-b.lines).slice(0,a)}}finally{y&&await y.destroy()}}function Kc(t,e){if(t===!1)return null;let r=typeof t=="object"?t:{},n=r.minFiles??Bc;if(e<n)return null;r.maxThreads!==void 0&&r.maxThreads<1&&process.stderr.write(`
8
8
  Warning: parallelTokenizing.maxThreads (${r.maxThreads}) must be at least 1; using 1.
9
- `);try{return new Nc({filename:xe.join(u,"duplication-worker.js"),...r.maxThreads!==void 0?{maxThreads:Math.max(1,r.maxThreads)}:{}})}catch(o){return process.stderr.write(`
9
+ `);try{return new $c({filename:Ce.join(u,"duplication-worker.js"),...r.maxThreads!==void 0?{maxThreads:Math.max(1,r.maxThreads)}:{}})}catch(o){return process.stderr.write(`
10
10
  Warning: failed to start duplicate-detection worker pool, falling back to synchronous tokenizing: ${o}
11
- `),null}}var Pc,Ic,Xt=m(()=>{"use strict";l();he();Kt();$n();Qn();oo();co();lo();Pc=20,Ic=new Set(["css","scss","less"])});import Xe from"path";function Lc(t){let e=new Map;for(let[r,n]of t){let o=n.imports.filter(s=>s.toPath&&!s.isExternal).length;o>0&&e.set(r,o)}return e}function Rc(t,e,r){let n=new Map;for(let[o,s]of e){if(s<r)continue;let i=t.get(o);if(!i||i.category==="test"||i.category==="barrel")continue;let a=Xe.extname(o),c=Xe.basename(o,a),p=c==="index"?Xe.basename(Xe.dirname(o)):c;n.set(o,{path:o,outDegree:s,tag:`feature:${p}`})}return n}function K(t,e){let r=e?.minOutDegree??5;return Rc(t,Lc(t),r)}var qe=m(()=>{"use strict";l()});function Gc(t,e){let r=new Map;for(let n of e.values()){let o=new Set;t.traverse(n.path,s=>(s.path!==n.path&&o.add(s.path),!0),{direction:"outgoing"}),r.set(n.path,o)}return r}function _c(t,e,r,n){let o=new Map;for(let[s]of t){if(e.has(s))continue;let i=null;for(let a of e.values())r.get(a.path)?.has(s)&&(!i||n(a,i)<0)&&(i=a);i&&o.set(s,i.path)}return o}function jc(t,e){let r=new Map;for(let n of t.values()){let o=n.tag.replace("feature:",""),s=[];for(let[i,a]of e)a===n.path&&s.push(i);r.set(o,{hub:n.path,outDegree:n.outDegree,files:s})}return r}function Wc(t,e,r){let n=[];for(let o of t.keys())!e.has(o)&&!r.has(o)&&n.push(o);return n}function be(t,e){let r=e?.detectFn??K,n=e?.hubComparator??Oc,o=r(t.nodes,e),s=Gc(t,o),i=_c(t.nodes,o,s,n);return{features:jc(o,i),unassigned:Wc(t.nodes,o,i)}}var Oc,Ze=m(()=>{"use strict";l();qe();Oc=(t,e)=>t.outDegree-e.outDegree});function qt(t){let e=new Map;for(let r of t.nodes.values())e.set(r.type,(e.get(r.type)??0)+1);return[...e.entries()].map(([r,n])=>({type:r,fileCount:n,exportsTracked:fo.has(r),importSymbolsTracked:uo.has(r),callEdgesTracked:et.has(r)})).sort((r,n)=>n.fileCount-r.fileCount)}var fo,uo,et,Zt=m(()=>{"use strict";l();fo=new Set(["typescript","javascript","python","go","scss","less","lua","coffeescript"]),uo=new Set(["typescript","javascript","python"]),et=new Set(["typescript","javascript","go","python"])});var Se,mo=m(()=>{"use strict";l();Se=class{constructor(e){this.nodes=e}nodes;findUnusedFiles(e){let r=new Set(this.nodes.keys());return e.filter(n=>!r.has(n))}findHighExportUsage(e){let r=[];for(let n of this.nodes.values()){if(n.maxExportUsage===void 0||n.maxExportUsage<e)continue;let o=n.imports.reduce((s,i)=>(i.exportUsageRatio??0)>(s?.exportUsageRatio??0)?i:s,null);r.push({path:n.path,maxExportUsage:n.maxExportUsage,tightestDep:o?.toPath??""})}return r.sort((n,o)=>o.maxExportUsage-n.maxExportUsage)}findCycles(){let e=[],r=new Set,n=new Set,o=[],s=i=>{r.add(i),n.add(i),o.push(i);let a=this.nodes.get(i);if(a){for(let c of a.imports)if(!(!c.toPath||c.isExternal))if(n.has(c.toPath)){let p=o.indexOf(c.toPath);e.push([...o.slice(p),c.toPath])}else r.has(c.toPath)||s(c.toPath)}n.delete(i),o.pop()};for(let i of this.nodes.keys())r.has(i)||s(i);return e}}});var D,Ce=m(()=>{"use strict";l();mo();D=class t{constructor(e){this.nodes=e}nodes;_incomingEdgesCache=null;_callIncomingCache=null;serialize(){return{nodes:Array.from(this.nodes.values())}}static deserialize(e){let r=new Map;for(let n of e.nodes)r.set(n.path,n);return new t(r)}getIncomingEdgesMap(){if(this._incomingEdgesCache)return this._incomingEdgesCache;let e=new Map;for(let r of this.nodes.values())for(let n of r.imports)if(n.toPath){let o=e.get(n.toPath)||[];o.push(r.path),e.set(n.toPath,o)}return this._incomingEdgesCache=e,e}dfs(e,r,n,o){let s=new Set,i=n.maxDepth??1/0,a=(c,p,f)=>{if(p>i||s.has(c))return;let d=this.nodes.get(c);if(d&&(s.add(c),r(d,p,f)!==!1))for(let y of o(c))a(y,p+1,c)};a(e,0,null)}traverse(e,r,n={}){let o=n.direction??"outgoing",s=o==="incoming"?this.getIncomingEdgesMap():null;this.dfs(e,r,n,i=>o==="outgoing"?this.nodes.get(i)?.imports.map(a=>a.toPath).filter(Boolean)??[]:s?.get(i)??[])}getCallIncomingCache(){if(this._callIncomingCache)return this._callIncomingCache;let e=new Map;for(let r of this.nodes.values())for(let n of r.callEdges??[]){let o=e.get(n.toFile)??[];o.push(r.path),e.set(n.toFile,o)}return this._callIncomingCache=e,e}traverseCalls(e,r,n={}){let o=n.direction??"outgoing",s=o==="incoming"?this.getCallIncomingCache():null;this.dfs(e,r,n,i=>o==="outgoing"?this.nodes.get(i)?.callEdges?.map(a=>a.toFile)??[]:s?.get(i)??[])}getCallers(e){let r=[];return this.traverseCalls(e,n=>(n.path!==e&&r.push(n.path),!0),{direction:"incoming",maxDepth:1}),r}getCallEdgesFor(e){return this.nodes.get(e)?.callEdges??[]}getNeighbors(e){let r=this.nodes.get(e);return r?r.imports.map(n=>this.nodes.get(n.toPath)).filter(n=>n!==void 0):[]}findUnusedFiles(e){return new Se(this.nodes).findUnusedFiles(e)}findCycles(){return new Se(this.nodes).findCycles()}}});var H,tt=m(()=>{"use strict";l();H=class{affectedSymbols=new Map;constructor(e,r){this.affectedSymbols.set(e,new Set(["default",...r]))}updateAffectedSymbols(e,r){let n=this.affectedSymbols.get(r)||new Set,o=e.imports.find(c=>c.toPath===r);if(!o)return!1;let s=o.symbols||["*"],i=new Set;for(let c of s)(c==="*"||n.has("*")||n.has(c))&&i.add("*");if(i.size===0)return!1;let a=this.affectedSymbols.get(e.path)||new Set;for(let c of i)a.add(c);return this.affectedSymbols.set(e.path,a),!0}}});function V(t,e){let r=t.nodes.get(e);if(r)return{category:r.category,exports:r.exports.map(n=>n.name)}}function er(t,e,r=1){let n=[];return t.traverse(e,(o,s,i)=>{if(o.path===e)return!0;let a=i?t.nodes.get(i)?.imports.find(c=>c.toPath===o.path):void 0;return n.push({path:o.path,...a?.symbols?{symbols:a.symbols}:{}}),!0},{direction:"outgoing",maxDepth:r}),n}function ke(t,e){let r=[];return t.traverse(e,n=>{if(n.path===e)return!0;let o=n.imports.find(s=>s.toPath===e);return r.push({path:n.path,...o?.symbols?{symbols:o.symbols}:{}}),!0},{direction:"incoming",maxDepth:1}),r}function tr(t,e,r={}){let{testsOnly:n=!1,changedSymbols:o}=r,s=o?new H(e,o):null,i=[];return t.traverse(e,(a,c,p)=>{if(a.path===e)return!0;if(s&&p&&!s.updateAffectedSymbols(a,p))return!1;let f=a.category==="test"||a.tags.some(d=>d.name==="test");return(!n||f)&&i.push(a.path),!0},{direction:"incoming"}),i}function rr(t,e,r={}){let{depth:n=1,withEdgeDetail:o=!1}=r,s=[];return t.traverseCalls(e,i=>{if(i.path===e)return!0;let a={file:i.path};return o&&(a.edges=(i.callEdges??[]).filter(c=>c.toFile===e).map(c=>({from:c.from,to:c.to}))),s.push(a),!0},{direction:"incoming",maxDepth:n}),s}function nr(t,e={}){let{metric:r="cognitiveComplexity",threshold:n=10,limit:o=20}=e;return[...t.nodes.values()].flatMap(s=>(s.functions??[]).filter(i=>i[r]>=n).map(i=>({file:s.path,name:i.name,line:i.line,complexity:i.complexity,cognitiveComplexity:i.cognitiveComplexity}))).sort((s,i)=>i[r]-s[r]).slice(0,o)}function or(t){return{nodes:t.nodes.map(r=>({path:r.path,type:r.type,category:r.category,exports:r.exports.map(n=>n.name),tags:r.tags.filter(n=>n.kind==="comment-marker"||n.kind==="import").map(n=>n.name),importsFiles:r.imports.filter(n=>!n.isExternal&&n.toPath).map(n=>n.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:t.cycles}}function sr(t){let e=t.getPackageDependencies(),r=Array.from(t.packages.values()).map(({graph:n,pkg:o})=>({name:o.name,relativeRoot:o.relativeRoot,nodeCount:n.nodes.size,dependsOn:e.get(o.name)??[]}));return{monorepoType:t.type,packageCount:r.length,packages:r}}function ir(t){return[...t.nodes.values()].some(e=>e.coveragePct!==void 0)}var ar=m(()=>{"use strict";l();tt()});function go(t){if(t.category==="test")return"test";if(t.category==="config")return"config";if(t.category==="type-only")return"types";let e=t.path;return k(e,"component")||k(e,"components")?"component":k(e,"controller")||k(e,"controllers")?"controller":k(e,"middleware")?"middleware":k(e,"router")||k(e,"routes")||k(e,"route")?"router":k(e,"store")||k(e,"stores")?"store":k(e,"service")||k(e,"services")?"service":k(e,"handler")||k(e,"handlers")?"handler":k(e,"adapter")||k(e,"adapters")?"adapter":k(e,"plugin")||k(e,"plugins")?"plugin":k(e,"api")?"api":k(e,"cli")||k(e,"commands")||ve(e)==="cli"?"cli":k(e,"util")||k(e,"utils")||k(e,"helper")||k(e,"helpers")?"util":k(e,"model")||k(e,"models")||ve(e)==="model"?"model":k(e,"parser")||k(e,"parsers")||ve(e)==="parser"?"parser":ve(e)==="builder"?"builder":ve(e)==="resolver"?"resolver":"other"}function k(t,e){return t.includes(`/${e}/`)||t.includes(`/${e}.`)}function ve(t){let e=t.slice(t.lastIndexOf("/")+1);return e.slice(0,e.lastIndexOf("."))||e}var ho=m(()=>{"use strict";l()});function cr(t,e){let r=be(t,e),n=new Map;for(let[s,i]of r.features){for(let a of i.files)n.set(a,s);n.set(i.hub,s)}let o=new Map;for(let s of t.nodes.values()){let i=n.get(s.path);o.set(s.path,{path:s.path,role:go(s),...s.description?{description:s.description}:{},exports:s.exports.map(a=>a.name),...i?{featureHub:i}:{}})}return o}var lr=m(()=>{"use strict";l();Ze();ho()});function pr(t,e){let r=[];for(let n of t.nodes.values())if(n.exports.some(o=>o.name===e))if(et.has(n.type)){let o=[];for(let s of t.nodes.values())for(let i of s.callEdges??[])i.to===e&&o.push({file:s.path,callerFunction:i.from});r.push({path:n.path,category:n.category,precision:"call",callers:o})}else{let o=ke(t,n.path).map(s=>({file:s.path,...s.symbols?{symbols:s.symbols}:{}}));r.push({path:n.path,category:n.category,precision:"file-level",importers:o})}return r}var yo=m(()=>{"use strict";l();Zt();ar()});function zc(t){return t?t.startsWith("interface ")?"interface":t.startsWith("class ")?"class":t.startsWith("enum ")?"enum":"type":"type"}function $c(t,e){if(e==="type-only")return!0;let r=t.signature??"";return r.startsWith("interface ")||r.startsWith("class ")||r.startsWith("enum ")}function fr(t){let e=new Map;for(let n of t.nodes.values())if(!(n.type!=="typescript"&&n.type!=="javascript"))for(let o of n.exports){if(!$c(o,n.category))continue;let s=`${n.path}::${o.name}`;e.set(s,{name:o.name,file:n.path,kind:zc(o.signature),...o.doc?{doc:o.doc}:{}})}let r=[];for(let n of t.nodes.values())if(!(n.type!=="typescript"&&n.type!=="javascript")){for(let o of n.imports)if(!(!o.toPath||o.isExternal||!o.symbols?.length))for(let s of o.symbols)e.has(`${o.toPath}::${s}`)&&r.push({fromFile:n.path,toType:s,toFile:o.toPath})}return{types:e,edges:r}}function ur(t,e){let r=null;for(let s of t.types.values())if(s.name===e){r=s;break}if(!r)return{type:null,usedByFiles:[],uses:[]};let n=new Set,o=new Map;for(let s of t.edges)if(s.toType===e&&s.toFile===r.file&&n.add(s.fromFile),s.fromFile===r.file){let i=t.types.get(`${s.toFile}::${s.toType}`);i&&o.set(`${i.file}::${i.name}`,i)}return{type:r,usedByFiles:Array.from(n),uses:Array.from(o.values())}}var mr=m(()=>{"use strict";l()});import xo from"fs";import yg from"path";function bo(t){try{return xo.statSync(t,{throwIfNoEntry:!1})?.isDirectory()===!0}catch{return!1}}function rt(t){try{return xo.statSync(t,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}var nt=m(()=>{"use strict";l()});import we from"fs";import M from"path";function gr(t,e){let r=M.join(e,"package.json");if(!we.existsSync(r))return null;let n={};try{n=JSON.parse(we.readFileSync(r,"utf-8"))}catch{return null}let o=n.name;return o?{name:o,root:e,relativeRoot:M.relative(t,e),entryPoints:Uc(e,n)}:null}function Uc(t,e){let r=[];if(e.exports){let o=e.exports;if(typeof o=="string")r.push(M.join(t,o));else if(typeof o=="object"&&o!==null){let s=o["."];if(typeof s=="string")r.push(M.join(t,s));else if(typeof s=="object"&&s!==null){let i=s.import??s.require??s.default;typeof i=="string"&&r.push(M.join(t,i))}}}e.main&&r.push(M.join(t,e.main));for(let o of["src/index.ts","src/index.tsx","index.ts","index.tsx","index.js"])r.push(M.join(t,o));let n=r.filter(rt);return n.length>0?n.slice(0,1):r.slice(0,1)}function ie(t,e){let r=[],n=new Set;for(let o of e){let s=o.replace(/\/$/,"").replace(/^\.\//,"");Bc(t,s,n,r)}return r}function Bc(t,e,r,n){if(!e.includes("*")){Jc(t,e,r,n);return}let o=e.split("/");o.includes("**")?Kc(t,o,r,n):Hc(t,o,r,n)}function Jc(t,e,r,n){let o=M.join(t,e);if(r.has(o)||!bo(o))return;r.add(o);let s=gr(t,o);s&&n.push(s)}function Kc(t,e,r,n){let o=M.join(t,e[0]==="**"?"":e[0]??"");So(t,o,r,n)}function Hc(t,e,r,n){let o=e.findIndex(a=>a.includes("*")),s=M.join(t,...e.slice(0,o)),i;try{i=we.readdirSync(s,{withFileTypes:!0})}catch{return}for(let a of i){if(!a.isDirectory())continue;let c=M.join(s,a.name);if(r.has(c))continue;r.add(c);let p=gr(t,c);p&&n.push(p)}}function So(t,e,r,n){let o;try{o=we.readdirSync(e,{withFileTypes:!0})}catch{return}for(let s of o){if(!s.isDirectory()||s.name==="node_modules"||s.name.startsWith("."))continue;let i=M.join(e,s.name);if(we.existsSync(M.join(i,"package.json"))&&!r.has(i)){r.add(i);let a=gr(t,i);a&&n.push(a)}else So(t,i,r,n)}}var ot=m(()=>{"use strict";l();nt();nt()});import dr from"fs";import Co from"path";var ko,vo=m(()=>{"use strict";l();ot();ko={type:"npm",detect(t){let e=Co.join(t,"package.json");if(!dr.existsSync(e))return null;let r;try{r=JSON.parse(dr.readFileSync(e,"utf-8")).workspaces}catch{return null}if(!r||dr.existsSync(Co.join(t,"yarn.lock")))return null;let n=Array.isArray(r)?r:r.packages??[];return n.length===0?null:ie(t,n)}}});import ae from"fs";import P from"path";function Eo(t,e,r,n){if(n>4)return[];let o;try{o=ae.readdirSync(e,{withFileTypes:!0})}catch{return[]}let s=[];for(let i of o){if(!i.isDirectory())continue;let a=i.name;if(a.startsWith(".")||a==="node_modules"||a==="dist"||a===".nx")continue;let c=P.join(e,a);ae.existsSync(P.join(c,"project.json"))&&!r.has(c)?(r.add(c),s.push(c)):s.push(...Eo(t,c,r,n+1))}return s}function Vc(t,e,r){let n={};try{n=JSON.parse(ae.readFileSync(r,"utf-8"))}catch{return null}let o=n.name,s,i,a=P.join(e,"package.json");if(ae.existsSync(a))try{let c=JSON.parse(ae.readFileSync(a,"utf-8"));o=c.name??o,s=c.main,i=c.exports}catch{}return o?{name:o,root:e,relativeRoot:P.relative(t,e),entryPoints:Qc(e,n,s,i)}:null}function Qc(t,e,r,n){let o=[],s=e.targets?.build?.options?.main??e.targets?.build?.options?.entryFile;if(s){let a=P.resolve(t,"../..");o.push(P.resolve(a,s)),o.push(P.resolve(t,s))}if(n){let a=n;if(typeof a=="string")o.push(P.join(t,a));else if(typeof a=="object"&&a!==null){let c=a["."];typeof c=="string"&&o.push(P.join(t,c))}}if(r&&o.push(P.join(t,r)),e.sourceRoot){let a=P.resolve(t,"../.."),c=P.resolve(a,e.sourceRoot);o.push(P.join(c,"index.ts"),P.join(c,"index.tsx"))}for(let a of["src/index.ts","src/index.tsx","index.ts","index.tsx"])o.push(P.join(t,a));let i=o.filter(rt);return i.length>0?i.slice(0,1):o.slice(0,1)}var wo,To=m(()=>{"use strict";l();nt();wo={type:"nx",detect(t){return ae.existsSync(P.join(t,"nx.json"))?Eo(t,t,new Set,0).map(r=>Vc(t,r,P.join(r,"project.json"))).filter(r=>r!==null):null}}});import Fo from"fs";import Yc from"path";import{load as Xc}from"js-yaml";var No,Po=m(()=>{"use strict";l();ot();No={type:"pnpm",detect(t){let e=Yc.join(t,"pnpm-workspace.yaml");if(!Fo.existsSync(e))return null;let r=[];try{r=Xc(Fo.readFileSync(e,"utf-8"))?.packages??[]}catch{return null}return ie(t,r)}}});import qc from"fs";import Zc from"path";var Io,Do=m(()=>{"use strict";l();Io={type:"turborepo",detect(t){return qc.existsSync(Zc.join(t,"turbo.json"))?[]:null}}});import hr from"fs";import Mo from"path";var Ao,Lo=m(()=>{"use strict";l();ot();Ao={type:"yarn",detect(t){if(!hr.existsSync(Mo.join(t,"yarn.lock")))return null;let e=Mo.join(t,"package.json");if(!hr.existsSync(e))return null;let r;try{r=JSON.parse(hr.readFileSync(e,"utf-8")).workspaces}catch{return null}if(!r)return null;let n=Array.isArray(r)?r:r.packages??[];return n.length===0?null:ie(t,n)}}});function W(t){Ro.push(t)}function Oo(){return Ro}var Ro,st=m(()=>{"use strict";l();Ro=[]});import el from"path";function yr(t,e=Oo()){let r=el.resolve(t),n=new Map,o=[];for(let i of e){let a=i.detect(r);if(a!==null){o.push(i.type);for(let c of a)n.has(c.name)||n.set(c.name,c)}}if(o.length===0)return{root:r,type:"none",types:[],packages:[],packageMap:new Map};let s=Array.from(n.values());return{root:r,type:o[0],types:o,packages:s,packageMap:new Map(s.map(i=>[i.name,i]))}}var xr=m(()=>{"use strict";l();vo();To();Po();Do();Lo();st();st();W(Io);W(wo);W(No);W(Ao);W(ko)});var Ee,br=m(()=>{"use strict";l();Ce();Ee=class t{constructor(e,r){this.monorepoRoot=e;this.type=r}monorepoRoot;type;packages=new Map;addPackage(e,r){this.packages.set(e.name,{graph:r,pkg:e})}getPackageForFile(e){for(let{pkg:r}of this.packages.values())if(e===r.relativeRoot||e.startsWith(`${r.relativeRoot}/`))return r}getPackageDependencies(){let e=new Map;for(let{graph:r,pkg:n}of this.packages.values()){let o=new Set;for(let s of r.nodes.values())for(let i of s.imports)i.isWorkspace&&i.workspacePackage&&o.add(i.workspacePackage);e.set(n.name,[...o])}return e}getAffectedAcrossPackages(e){let r=this.getPackageForFile(e);if(!r)return[];let n=this.packages.get(r.name);if(!n)return[];let o=[];n.graph.traverse(e,s=>(s.path!==e&&o.push({file:s.path,package:r.name}),!0),{direction:"incoming"});for(let{graph:s,pkg:i}of this.packages.values())if(i.name!==r.name)for(let a of s.nodes.values())a.imports.some(p=>p.isWorkspace&&p.workspacePackage===r.name)&&o.push({file:a.path,package:i.name});return o}serialize(){return{monorepoRoot:this.monorepoRoot,type:this.type,packages:Array.from(this.packages.values()).map(({graph:e,pkg:r})=>({pkg:{name:r.name,relativeRoot:r.relativeRoot,entryPoints:r.entryPoints},nodes:Array.from(e.nodes.values())}))}}static deserialize(e){let r=new t(e.monorepoRoot,e.type);for(let{pkg:n,nodes:o}of e.packages){let s=new Map(o.map(a=>[a.path,a])),i=new D(s);r.packages.set(n.name,{graph:i,pkg:{...n,root:""}})}return r}}});function ce(t,e){Go.set(t,e)}function _o(t){return Go.get(t)}var Go,Te=m(()=>{"use strict";l();Go=new Map});function jo(t,e){return e.startsWith("!")?t!==e.slice(1):t===e}function tl(t,e){return e.startsWith("!")?!t.includes(e.slice(1)):t.includes(e)}function Fe(t,e,r){return Pl.every(n=>n(t,e,r))}var rl,nl,ol,sl,il,al,cl,ll,pl,fl,ul,ml,gl,dl,hl,yl,xl,bl,Sl,Cl,kl,vl,wl,El,Tl,Fl,Nl,Pl,Sr=m(()=>{"use strict";l();rl=(t,e)=>!e.category||jo(t.category,e.category),nl=(t,e)=>!e.type||jo(t.type,e.type),ol=(t,e)=>e.lastAuthor?e.lastAuthor.startsWith("!")?t.lastAuthor!==e.lastAuthor.slice(1):t.lastAuthor!==void 0&&t.lastAuthor===e.lastAuthor:!0,sl=(t,e)=>!e.path||tl(t.path,e.path),il=(t,e)=>e.isExternal===void 0?!0:t.imports.some(n=>n.isExternal)===e.isExternal,al=(t,e)=>{if(!e.tags||e.tags.length===0)return!0;let r=e.tags.filter(o=>!o.startsWith("!")),n=e.tags.filter(o=>o.startsWith("!")).map(o=>o.slice(1));return!(r.length>0&&!r.some(o=>t.tags.some(s=>s.name===o))||n.some(o=>t.tags.some(s=>s.name===o)))},cl=(t,e)=>!e.allTags?.length||e.allTags.every(r=>t.tags.some(n=>n.name===r)),ll=(t,e)=>!e.importsFile||t.imports.some(r=>r.toPath?.includes(e.importsFile)),pl=(t,e,r)=>e.importedBy===void 0?!0:(r?.get(t.path)??[]).some(o=>o.includes(e.importedBy)),fl=(t,e)=>e.minImports===void 0||t.imports.length>=e.minImports,ul=(t,e)=>e.maxImports===void 0||t.imports.length<=e.maxImports,ml=(t,e)=>e.minSize===void 0||t.size>=e.minSize,gl=(t,e)=>e.maxSize===void 0||t.size<=e.maxSize,dl=(t,e)=>e.hasDocstring===void 0||!!t.description===e.hasDocstring,hl=(t,e)=>e.isDocumented===void 0||!!t.documentedBy?.length===e.isDocumented,yl=(t,e)=>e.isStale===void 0||!!t.staleFor?.length===e.isStale,xl=(t,e)=>e.minCoverage===void 0||(t.coveragePct??101)>=e.minCoverage,bl=(t,e)=>e.maxCoverage===void 0||(t.coveragePct??0)<=e.maxCoverage,Sl=(t,e)=>e.minExportUsage===void 0||(t.avgExportUsage??-1)>=e.minExportUsage,Cl=(t,e)=>e.maxExportUsage===void 0||(t.avgExportUsage??0)<=e.maxExportUsage,kl=(t,e)=>e.minComplexity===void 0||(t.complexity??-1/0)>=e.minComplexity,vl=(t,e)=>e.maxComplexity===void 0||(t.complexity??0)<=e.maxComplexity,wl=(t,e)=>e.minCognitiveComplexity===void 0||(t.cognitiveComplexity??-1/0)>=e.minCognitiveComplexity,El=(t,e)=>e.maxCognitiveComplexity===void 0||(t.cognitiveComplexity??0)<=e.maxCognitiveComplexity,Tl=(t,e)=>e.minCommits===void 0||(t.commitCount90d??-1/0)>=e.minCommits,Fl=(t,e)=>e.maxCommits===void 0||(t.commitCount90d??0)<=e.maxCommits,Nl=(t,e,r)=>!e.any?.length||e.any.some(n=>Fe(t,n,r)),Pl=[rl,nl,ol,sl,il,al,cl,ll,pl,fl,ul,ml,gl,dl,hl,yl,xl,bl,Sl,Cl,kl,vl,wl,El,Tl,Fl,Nl]});function it(t,e){let r=new Map;if(e.importedBy!==void 0){for(let i of t.nodes)for(let a of i.imports)if(a.toPath){let c=r.get(a.toPath)??[];c.push(i.path),r.set(a.toPath,c)}}let n=t.nodes.filter(i=>Fe(i,e,r)),o=new Set(n.map(i=>i.path)),s=n.map(i=>({...i,imports:i.imports.filter(a=>!a.toPath||o.has(a.toPath))}));if(e.sort){let i=e.sortDir==="asc"?-1:1;s.sort((a,c)=>{let p=0;return e.sort==="size"?p=c.size-a.size:e.sort==="imports"?p=c.imports.length-a.imports.length:e.sort==="commitCount90d"?p=(c.commitCount90d??0)-(a.commitCount90d??0):e.sort==="exportUsage"?p=(c.avgExportUsage??0)-(a.avgExportUsage??0):e.sort==="complexity"?p=(c.complexity??0)-(a.complexity??0):e.sort==="cognitiveComplexity"&&(p=(c.cognitiveComplexity??0)-(a.cognitiveComplexity??0)),p*i})}return e.limit!==void 0&&s.splice(e.limit),{nodes:s,cycles:t.cycles?.filter(i=>i.every(a=>o.has(a)))??void 0}}var Wo=m(()=>{"use strict";l();Sr();Sr()});function zo(t,e){let r=e.indexOf(":");if(r===-1)return;let n=e.slice(0,r).trim().toLowerCase(),o=e.slice(r+1).trim();if(!(!n||!o))switch(n){case"category":t.category=o;break;case"type":t.type=o;break;case"tag":case"tags":o.includes("+")?t.allTags=[...t.allTags??[],...o.split("+")]:t.tags=[...t.tags??[],o];break;case"path":t.path=o;break;case"external":t.isExternal=o.toLowerCase()==="true";break;case"importsfile":t.importsFile=o;break;case"importedby":t.importedBy=o;break;case"minimports":t.minImports=parseInt(o,10);break;case"maximports":t.maxImports=parseInt(o,10);break;case"minsize":t.minSize=parseInt(o,10);break;case"maxsize":t.maxSize=parseInt(o,10);break;case"sort":t.sort=o;break;case"sortdir":t.sortDir=o.toLowerCase()==="asc"?"asc":"desc";break;case"limit":t.limit=parseInt(o,10);break;case"hasdocstring":t.hasDocstring=o.toLowerCase()!=="false";break;case"mincoverage":t.minCoverage=parseInt(o,10);break;case"maxcoverage":t.maxCoverage=parseInt(o,10);break;case"minexportusage":t.minExportUsage=parseFloat(o);break;case"maxexportusage":t.maxExportUsage=parseFloat(o);break;case"mincomplexity":t.minComplexity=parseInt(o,10);break;case"maxcomplexity":t.maxComplexity=parseInt(o,10);break;case"mincognitivecomplexity":t.minCognitiveComplexity=parseInt(o,10);break;case"maxcognitivecomplexity":t.maxCognitiveComplexity=parseInt(o,10);break;case"mincommits":t.minCommits=parseInt(o,10);break;case"maxcommits":t.maxCommits=parseInt(o,10);break;case"isdocumented":t.isDocumented=o.toLowerCase()!=="false";break;case"isstale":t.isStale=o.toLowerCase()!=="false";break;case"lastauthor":t.lastAuthor=o;break}}function Il(t){let e=[];for(let r of t.split("|")){let n=r.trim();if(!n)continue;let o={};zo(o,n),Object.keys(o).length>0&&e.push(o)}return e}function at(t){let e={},r=t.split(",");for(let n of r){let o=n.trim();if(o.toLowerCase().startsWith("any(")&&o.endsWith(")")){let s=o.slice(4,-1),i=Il(s);i.length>0&&(e.any=[...e.any??[],...i]);continue}zo(e,n)}return e}var $o=m(()=>{"use strict";l()});var Uo=m(()=>{"use strict";l();Wo();$o()});import Dl from"path";import F from"typescript";function Q(t,e){let r=t[e];if(r===void 0)throw new Error(`Index ${e} out of bounds (length ${t.length})`);return r}function Cr(t){let e=[];for(let r of t.statements){if(!F.isExpressionStatement(r))continue;let n=r.expression;if(!F.isCallExpression(n))continue;let o=n.expression;F.isIdentifier(o)&&Bo.has(o.text)&&e.push(n),F.isPropertyAccessExpression(o)&&F.isIdentifier(o.expression)&&Bo.has(o.expression.text)&&e.push(n)}return e}function kr(t,e,r){for(let n of t.arguments){if(!F.isObjectLiteralExpression(n))continue;let o=n.properties.find(s=>F.isPropertyAssignment(s)&&F.isIdentifier(s.name)&&s.name.text===e);if(!(!o||!F.isArrayLiteralExpression(o.initializer)))return o.initializer.elements.filter(F.isStringLiteral).map(s=>s.text)}return null}function vr(t,e,r,n){if(t.arguments.length===0)return null;for(let s=1;s<t.arguments.length;s++){let i=Q(t.arguments,s);if(!F.isObjectLiteralExpression(i))continue;let a=i.properties.find(p=>F.isPropertyAssignment(p)&&F.isIdentifier(p.name)&&p.name.text===e);if(a)return{start:a.initializer.getStart(n),end:a.initializer.getEnd(),text:r};let c=i.getEnd()-1;return{start:c,end:c,text:`${i.properties.length>0?", ":""}${e}: ${r}`}}let o=Q(t.arguments,t.arguments.length-1);return{start:o.getStart(n),end:o.getStart(n),text:`{ ${e}: ${r} }, `}}function wr(t,e,r){let n=t.arguments;for(let o=1;o<n.length;o++){let s=Q(n,o);if(!F.isObjectLiteralExpression(s))continue;let i=s.properties.findIndex(c=>F.isPropertyAssignment(c)&&F.isIdentifier(c.name)&&c.name.text===e);if(i<0)continue;if(s.properties.length===1)return{start:Q(n,o-1).getEnd(),end:s.getEnd(),text:""};let a=Q(s.properties,i);return i===s.properties.length-1?{start:Q(s.properties,i-1).getEnd(),end:a.getEnd(),text:""}:{start:a.getStart(r),end:Q(s.properties,i+1).getStart(r),text:""}}return null}function Er(t,e){let r=[...e].sort((o,s)=>s.start-o.start),n=t;for(let o of r)n=n.slice(0,o.start)+o.text+n.slice(o.end);return n}function Tr(t){return`[${t.map(e=>JSON.stringify(e)).join(", ")}]`}function Ml(t){return t.map(e=>e.startsWith("@")?e.slice(1):e)}function ct(t,e,r,n){let o=F.createSourceFile(Dl.basename(t),e,F.ScriptTarget.Latest,!0),s=Cr(o),[i]=s;if(!i)return e;let a=kr(i,n,o),c=[...r].sort();if(a!==null&&JSON.stringify(Ml(a).sort())===JSON.stringify(c))return e;let p=Tr(c.map(d=>`@${d}`)),f=s.flatMap(d=>{let y=r.length===0?wr(d,n,o):vr(d,n,p,o);return y?[y]:[]});return f.length>0?Er(e,f):e}var Bo,_,le=m(()=>{"use strict";l();Bo=new Set(["describe","test","it"]);_=new Set([".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"])});import Al from"path";var lt,Jo=m(()=>{"use strict";l();le();lt=class{name="cypress";canHandle(e){return _.has(Al.extname(e).toLowerCase())}apply(e,r,n){return ct(e,r,n,"tags")}}});import Ll from"path";function Rl(t){return`${["# <mokosh-tags>",...t.map(e=>`@${e}`),"# </mokosh-tags>"].join(`
11
+ `),null}}var Bc,Uc,ir=m(()=>{"use strict";l();be();tr();Qn();ro();fo();ho();yo();Bc=20,Uc=new Set(["css","scss","less"])});import rt from"path";function Vc(t){let e=new Map;for(let[r,n]of t){let o=n.imports.filter(s=>s.toPath&&!s.isExternal).length;o>0&&e.set(r,o)}return e}function Qc(t,e,r){let n=new Map;for(let[o,s]of e){if(s<r)continue;let i=t.get(o);if(!i||i.category==="test"||i.category==="barrel")continue;let a=rt.extname(o),c=rt.basename(o,a),p=c==="index"?rt.basename(rt.dirname(o)):c;n.set(o,{path:o,outDegree:s,tag:`feature:${p}`})}return n}function V(t,e){let r=e?.minOutDegree??5;return Qc(t,Vc(t),r)}var nt=m(()=>{"use strict";l()});function Xc(t,e){let r=new Map;for(let n of e.values()){let o=new Set;t.traverse(n.path,s=>(s.path!==n.path&&o.add(s.path),!0),{direction:"outgoing"}),r.set(n.path,o)}return r}function qc(t,e,r,n){let o=new Map;for(let[s]of t){if(e.has(s))continue;let i=null;for(let a of e.values())r.get(a.path)?.has(s)&&(!i||n(a,i)<0)&&(i=a);i&&o.set(s,i.path)}return o}function Zc(t,e){let r=new Map;for(let n of t.values()){let o=n.tag.replace("feature:",""),s=[];for(let[i,a]of e)a===n.path&&s.push(i);r.set(o,{hub:n.path,outDegree:n.outDegree,files:s})}return r}function el(t,e,r){let n=[];for(let o of t.keys())!e.has(o)&&!r.has(o)&&n.push(o);return n}function ke(t,e){let r=e?.detectFn??V,n=e?.hubComparator??Yc,o=r(t.nodes,e),s=Xc(t,o),i=qc(t.nodes,o,s,n);return{features:Zc(o,i),unassigned:el(t.nodes,o,i)}}var Yc,ot=m(()=>{"use strict";l();nt();Yc=(t,e)=>t.outDegree-e.outDegree});function ar(t){let e=new Map;for(let r of t.nodes.values())e.set(r.type,(e.get(r.type)??0)+1);return[...e.entries()].map(([r,n])=>({type:r,fileCount:n,exportsTracked:bo.has(r),importSymbolsTracked:So.has(r),callEdgesTracked:st.has(r)})).sort((r,n)=>n.fileCount-r.fileCount)}var bo,So,st,cr=m(()=>{"use strict";l();bo=new Set(["typescript","javascript","python","go","scss","less","lua","coffeescript"]),So=new Set(["typescript","javascript","python"]),st=new Set(["typescript","javascript","go","python"])});var ve,Co=m(()=>{"use strict";l();ve=class{constructor(e){this.nodes=e}nodes;findUnusedFiles(e){let r=new Set(this.nodes.keys());return e.filter(n=>!r.has(n))}findHighExportUsage(e){let r=[];for(let n of this.nodes.values()){if(n.maxExportUsage===void 0||n.maxExportUsage<e)continue;let o=n.imports.reduce((s,i)=>(i.exportUsageRatio??0)>(s?.exportUsageRatio??0)?i:s,null);r.push({path:n.path,maxExportUsage:n.maxExportUsage,tightestDep:o?.toPath??""})}return r.sort((n,o)=>o.maxExportUsage-n.maxExportUsage)}findCycles(){let e=[],r=new Set,n=new Set,o=[],s=i=>{r.add(i),n.add(i),o.push(i);let a=this.nodes.get(i);if(a){for(let c of a.imports)if(!(!c.toPath||c.isExternal))if(n.has(c.toPath)){let p=o.indexOf(c.toPath);e.push([...o.slice(p),c.toPath])}else r.has(c.toPath)||s(c.toPath)}n.delete(i),o.pop()};for(let i of this.nodes.keys())r.has(i)||s(i);return e}}});var D,we=m(()=>{"use strict";l();Co();D=class t{constructor(e){this.nodes=e}nodes;_incomingEdgesCache=null;_callIncomingCache=null;serialize(){return{nodes:Array.from(this.nodes.values())}}static deserialize(e){let r=new Map;for(let n of e.nodes)r.set(n.path,n);return new t(r)}getIncomingEdgesMap(){if(this._incomingEdgesCache)return this._incomingEdgesCache;let e=new Map;for(let r of this.nodes.values())for(let n of r.imports)if(n.toPath){let o=e.get(n.toPath)||[];o.push(r.path),e.set(n.toPath,o)}return this._incomingEdgesCache=e,e}dfs(e,r,n,o){let s=new Set,i=n.maxDepth??1/0,a=(c,p,f)=>{if(p>i||s.has(c))return;let g=this.nodes.get(c);if(g&&(s.add(c),r(g,p,f)!==!1))for(let y of o(c))a(y,p+1,c)};a(e,0,null)}traverse(e,r,n={}){let o=n.direction??"outgoing",s=o==="incoming"?this.getIncomingEdgesMap():null;this.dfs(e,r,n,i=>o==="outgoing"?this.nodes.get(i)?.imports.map(a=>a.toPath).filter(Boolean)??[]:s?.get(i)??[])}getCallIncomingCache(){if(this._callIncomingCache)return this._callIncomingCache;let e=new Map;for(let r of this.nodes.values())for(let n of r.callEdges??[]){let o=e.get(n.toFile)??[];o.push(r.path),e.set(n.toFile,o)}return this._callIncomingCache=e,e}traverseCalls(e,r,n={}){let o=n.direction??"outgoing",s=o==="incoming"?this.getCallIncomingCache():null;this.dfs(e,r,n,i=>o==="outgoing"?this.nodes.get(i)?.callEdges?.map(a=>a.toFile)??[]:s?.get(i)??[])}getCallers(e){let r=[];return this.traverseCalls(e,n=>(n.path!==e&&r.push(n.path),!0),{direction:"incoming",maxDepth:1}),r}getCallEdgesFor(e){return this.nodes.get(e)?.callEdges??[]}getNeighbors(e){let r=this.nodes.get(e);return r?r.imports.map(n=>this.nodes.get(n.toPath)).filter(n=>n!==void 0):[]}findUnusedFiles(e){return new ve(this.nodes).findUnusedFiles(e)}findCycles(){return new ve(this.nodes).findCycles()}}});var Q,it=m(()=>{"use strict";l();Q=class{affectedSymbols=new Map;constructor(e,r){this.affectedSymbols.set(e,new Set(["default",...r]))}updateAffectedSymbols(e,r){let n=this.affectedSymbols.get(r)||new Set,o=e.imports.find(c=>c.toPath===r);if(!o)return!1;let s=o.symbols||["*"],i=new Set;for(let c of s)(c==="*"||n.has("*")||n.has(c))&&i.add("*");if(i.size===0)return!1;let a=this.affectedSymbols.get(e.path)||new Set;for(let c of i)a.add(c);return this.affectedSymbols.set(e.path,a),!0}}});function Y(t,e){let r=t.nodes.get(e);if(r)return{category:r.category,exports:r.exports.map(n=>n.name)}}function lr(t,e,r=1){let n=[];return t.traverse(e,(o,s,i)=>{if(o.path===e)return!0;let a=i?t.nodes.get(i)?.imports.find(c=>c.toPath===o.path):void 0;return n.push({path:o.path,...a?.symbols?{symbols:a.symbols}:{}}),!0},{direction:"outgoing",maxDepth:r}),n}function Te(t,e){let r=[];return t.traverse(e,n=>{if(n.path===e)return!0;let o=n.imports.find(s=>s.toPath===e);return r.push({path:n.path,...o?.symbols?{symbols:o.symbols}:{}}),!0},{direction:"incoming",maxDepth:1}),r}function pr(t,e,r={}){let{testsOnly:n=!1,changedSymbols:o}=r,s=o?new Q(e,o):null,i=[];return t.traverse(e,(a,c,p)=>{if(a.path===e)return!0;if(s&&p&&!s.updateAffectedSymbols(a,p))return!1;let f=a.category==="test"||a.tags.some(g=>g.name==="test");return(!n||f)&&i.push(a.path),!0},{direction:"incoming"}),i}function fr(t,e,r={}){let{depth:n=1,withEdgeDetail:o=!1}=r,s=[];return t.traverseCalls(e,i=>{if(i.path===e)return!0;let a={file:i.path};return o&&(a.edges=(i.callEdges??[]).filter(c=>c.toFile===e).map(c=>({from:c.from,to:c.to}))),s.push(a),!0},{direction:"incoming",maxDepth:n}),s}function ur(t,e={}){let{metric:r="cognitiveComplexity",threshold:n=10,limit:o=20}=e;return[...t.nodes.values()].flatMap(s=>(s.functions??[]).filter(i=>i[r]>=n).map(i=>({file:s.path,name:i.name,line:i.line,complexity:i.complexity,cognitiveComplexity:i.cognitiveComplexity}))).sort((s,i)=>i[r]-s[r]).slice(0,o)}function mr(t){return{nodes:t.nodes.map(r=>({path:r.path,type:r.type,category:r.category,exports:r.exports.map(n=>n.name),tags:r.tags.filter(n=>n.kind==="comment-marker"||n.kind==="import").map(n=>n.name),importsFiles:r.imports.filter(n=>!n.isExternal&&n.toPath).map(n=>n.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:t.cycles}}function dr(t){let e=t.getPackageDependencies(),r=Array.from(t.packages.values()).map(({graph:n,pkg:o})=>({name:o.name,relativeRoot:o.relativeRoot,nodeCount:n.nodes.size,dependsOn:e.get(o.name)??[]}));return{monorepoType:t.type,packageCount:r.length,packages:r}}function Ee(t){return[...t.nodes.values()].some(e=>e.coveragePct!==void 0)}function ko(t){return[...t.nodes.values()].some(e=>e.commitCount90d!==void 0)}function gr(t,e={}){let{metric:r="cognitiveComplexity",minComplexity:n=10,maxCoveragePct:o=50,minChurn:s=0,limit:i=20}=e,a=ko(t),c=[...t.nodes.values()].filter(p=>p.coveragePct!==void 0&&p.coveragePct<=o&&(!a||(p.commitCount90d??0)>=s)).flatMap(p=>(p.functions??[]).filter(f=>f[r]>=n).map(f=>({file:p.path,name:f.name,line:f.line,complexity:f.complexity,cognitiveComplexity:f.cognitiveComplexity,coveragePct:p.coveragePct,...p.commitCount90d!==void 0&&{commitCount90d:p.commitCount90d}}))).sort((p,f)=>f[r]-p[r]).slice(0,i);return{hotspots:c,count:c.length,churnDataAvailable:a}}var hr=m(()=>{"use strict";l();it()});function vo(t){if(t.category==="test")return"test";if(t.category==="config")return"config";if(t.category==="type-only")return"types";let e=t.path;return C(e,"component")||C(e,"components")?"component":C(e,"controller")||C(e,"controllers")?"controller":C(e,"middleware")?"middleware":C(e,"router")||C(e,"routes")||C(e,"route")?"router":C(e,"store")||C(e,"stores")?"store":C(e,"service")||C(e,"services")?"service":C(e,"handler")||C(e,"handlers")?"handler":C(e,"adapter")||C(e,"adapters")?"adapter":C(e,"plugin")||C(e,"plugins")?"plugin":C(e,"api")?"api":C(e,"cli")||C(e,"commands")||Fe(e)==="cli"?"cli":C(e,"util")||C(e,"utils")||C(e,"helper")||C(e,"helpers")?"util":C(e,"model")||C(e,"models")||Fe(e)==="model"?"model":C(e,"parser")||C(e,"parsers")||Fe(e)==="parser"?"parser":Fe(e)==="builder"?"builder":Fe(e)==="resolver"?"resolver":"other"}function C(t,e){return t.includes(`/${e}/`)||t.includes(`/${e}.`)}function Fe(t){let e=t.slice(t.lastIndexOf("/")+1);return e.slice(0,e.lastIndexOf("."))||e}var wo=m(()=>{"use strict";l()});function yr(t,e){let r=ke(t,e),n=new Map;for(let[s,i]of r.features){for(let a of i.files)n.set(a,s);n.set(i.hub,s)}let o=new Map;for(let s of t.nodes.values()){let i=n.get(s.path);o.set(s.path,{path:s.path,role:vo(s),...s.description?{description:s.description}:{},exports:s.exports.map(a=>a.name),...i?{featureHub:i}:{}})}return o}var xr=m(()=>{"use strict";l();ot();wo()});function br(t,e){let r=[];for(let n of t.nodes.values())if(n.exports.some(o=>o.name===e))if(st.has(n.type)){let o=[];for(let s of t.nodes.values())for(let i of s.callEdges??[])i.to===e&&o.push({file:s.path,callerFunction:i.from});r.push({path:n.path,category:n.category,precision:"call",callers:o})}else{let o=Te(t,n.path).map(s=>({file:s.path,...s.symbols?{symbols:s.symbols}:{}}));r.push({path:n.path,category:n.category,precision:"file-level",importers:o})}return r}var To=m(()=>{"use strict";l();cr();hr()});function tl(t){return t?t.startsWith("interface ")?"interface":t.startsWith("class ")?"class":t.startsWith("enum ")?"enum":"type":"type"}function rl(t,e){if(e==="type-only")return!0;let r=t.signature??"";return r.startsWith("interface ")||r.startsWith("class ")||r.startsWith("enum ")}function Sr(t){let e=new Map;for(let n of t.nodes.values())if(!(n.type!=="typescript"&&n.type!=="javascript"))for(let o of n.exports){if(!rl(o,n.category))continue;let s=`${n.path}::${o.name}`;e.set(s,{name:o.name,file:n.path,kind:tl(o.signature),...o.doc?{doc:o.doc}:{}})}let r=[];for(let n of t.nodes.values())if(!(n.type!=="typescript"&&n.type!=="javascript")){for(let o of n.imports)if(!(!o.toPath||o.isExternal||!o.symbols?.length))for(let s of o.symbols)e.has(`${o.toPath}::${s}`)&&r.push({fromFile:n.path,toType:s,toFile:o.toPath})}return{types:e,edges:r}}function Cr(t,e){let r=null;for(let s of t.types.values())if(s.name===e){r=s;break}if(!r)return{type:null,usedByFiles:[],uses:[]};let n=new Set,o=new Map;for(let s of t.edges)if(s.toType===e&&s.toFile===r.file&&n.add(s.fromFile),s.fromFile===r.file){let i=t.types.get(`${s.toFile}::${s.toType}`);i&&o.set(`${i.file}::${i.name}`,i)}return{type:r,usedByFiles:Array.from(n),uses:Array.from(o.values())}}var kr=m(()=>{"use strict";l()});import Eo from"fs";import Bd from"path";function Fo(t){try{return Eo.statSync(t,{throwIfNoEntry:!1})?.isDirectory()===!0}catch{return!1}}function at(t){try{return Eo.statSync(t,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}var ct=m(()=>{"use strict";l()});import Ne from"fs";import M from"path";function vr(t,e){let r=M.join(e,"package.json");if(!Ne.existsSync(r))return null;let n={};try{n=JSON.parse(Ne.readFileSync(r,"utf-8"))}catch{return null}let o=n.name;return o?{name:o,root:e,relativeRoot:M.relative(t,e),entryPoints:nl(e,n)}:null}function nl(t,e){let r=[];if(e.exports){let o=e.exports;if(typeof o=="string")r.push(M.join(t,o));else if(typeof o=="object"&&o!==null){let s=o["."];if(typeof s=="string")r.push(M.join(t,s));else if(typeof s=="object"&&s!==null){let i=s.import??s.require??s.default;typeof i=="string"&&r.push(M.join(t,i))}}}e.main&&r.push(M.join(t,e.main));for(let o of["src/index.ts","src/index.tsx","index.ts","index.tsx","index.js"])r.push(M.join(t,o));let n=r.filter(at);return n.length>0?n.slice(0,1):r.slice(0,1)}function le(t,e){let r=[],n=new Set;for(let o of e){let s=o.replace(/\/$/,"").replace(/^\.\//,"");ol(t,s,n,r)}return r}function ol(t,e,r,n){if(!e.includes("*")){sl(t,e,r,n);return}let o=e.split("/");o.includes("**")?il(t,o,r,n):al(t,o,r,n)}function sl(t,e,r,n){let o=M.join(t,e);if(r.has(o)||!Fo(o))return;r.add(o);let s=vr(t,o);s&&n.push(s)}function il(t,e,r,n){let o=M.join(t,e[0]==="**"?"":e[0]??"");No(t,o,r,n)}function al(t,e,r,n){let o=e.findIndex(a=>a.includes("*")),s=M.join(t,...e.slice(0,o)),i;try{i=Ne.readdirSync(s,{withFileTypes:!0})}catch{return}for(let a of i){if(!a.isDirectory())continue;let c=M.join(s,a.name);if(r.has(c))continue;r.add(c);let p=vr(t,c);p&&n.push(p)}}function No(t,e,r,n){let o;try{o=Ne.readdirSync(e,{withFileTypes:!0})}catch{return}for(let s of o){if(!s.isDirectory()||s.name==="node_modules"||s.name.startsWith("."))continue;let i=M.join(e,s.name);if(Ne.existsSync(M.join(i,"package.json"))&&!r.has(i)){r.add(i);let a=vr(t,i);a&&n.push(a)}else No(t,i,r,n)}}var lt=m(()=>{"use strict";l();ct();ct()});import wr from"fs";import Po from"path";var Io,Do=m(()=>{"use strict";l();lt();Io={type:"npm",detect(t){let e=Po.join(t,"package.json");if(!wr.existsSync(e))return null;let r;try{r=JSON.parse(wr.readFileSync(e,"utf-8")).workspaces}catch{return null}if(!r||wr.existsSync(Po.join(t,"yarn.lock")))return null;let n=Array.isArray(r)?r:r.packages??[];return n.length===0?null:le(t,n)}}});import pe from"fs";import P from"path";function Ao(t,e,r,n){if(n>4)return[];let o;try{o=pe.readdirSync(e,{withFileTypes:!0})}catch{return[]}let s=[];for(let i of o){if(!i.isDirectory())continue;let a=i.name;if(a.startsWith(".")||a==="node_modules"||a==="dist"||a===".nx")continue;let c=P.join(e,a);pe.existsSync(P.join(c,"project.json"))&&!r.has(c)?(r.add(c),s.push(c)):s.push(...Ao(t,c,r,n+1))}return s}function cl(t,e,r){let n={};try{n=JSON.parse(pe.readFileSync(r,"utf-8"))}catch{return null}let o=n.name,s,i,a=P.join(e,"package.json");if(pe.existsSync(a))try{let c=JSON.parse(pe.readFileSync(a,"utf-8"));o=c.name??o,s=c.main,i=c.exports}catch{}return o?{name:o,root:e,relativeRoot:P.relative(t,e),entryPoints:ll(e,n,s,i)}:null}function ll(t,e,r,n){let o=[],s=e.targets?.build?.options?.main??e.targets?.build?.options?.entryFile;if(s){let a=P.resolve(t,"../..");o.push(P.resolve(a,s)),o.push(P.resolve(t,s))}if(n){let a=n;if(typeof a=="string")o.push(P.join(t,a));else if(typeof a=="object"&&a!==null){let c=a["."];typeof c=="string"&&o.push(P.join(t,c))}}if(r&&o.push(P.join(t,r)),e.sourceRoot){let a=P.resolve(t,"../.."),c=P.resolve(a,e.sourceRoot);o.push(P.join(c,"index.ts"),P.join(c,"index.tsx"))}for(let a of["src/index.ts","src/index.tsx","index.ts","index.tsx"])o.push(P.join(t,a));let i=o.filter(at);return i.length>0?i.slice(0,1):o.slice(0,1)}var Mo,Ro=m(()=>{"use strict";l();ct();Mo={type:"nx",detect(t){return pe.existsSync(P.join(t,"nx.json"))?Ao(t,t,new Set,0).map(r=>cl(t,r,P.join(r,"project.json"))).filter(r=>r!==null):null}}});import Lo from"fs";import pl from"path";import{load as fl}from"js-yaml";var Oo,Go=m(()=>{"use strict";l();lt();Oo={type:"pnpm",detect(t){let e=pl.join(t,"pnpm-workspace.yaml");if(!Lo.existsSync(e))return null;let r=[];try{r=fl(Lo.readFileSync(e,"utf-8"))?.packages??[]}catch{return null}return le(t,r)}}});import ul from"fs";import ml from"path";var _o,jo=m(()=>{"use strict";l();_o={type:"turborepo",detect(t){return ul.existsSync(ml.join(t,"turbo.json"))?[]:null}}});import Tr from"fs";import Wo from"path";var zo,$o=m(()=>{"use strict";l();lt();zo={type:"yarn",detect(t){if(!Tr.existsSync(Wo.join(t,"yarn.lock")))return null;let e=Wo.join(t,"package.json");if(!Tr.existsSync(e))return null;let r;try{r=JSON.parse(Tr.readFileSync(e,"utf-8")).workspaces}catch{return null}if(!r)return null;let n=Array.isArray(r)?r:r.packages??[];return n.length===0?null:le(t,n)}}});function z(t){Bo.push(t)}function Uo(){return Bo}var Bo,pt=m(()=>{"use strict";l();Bo=[]});import dl from"path";function Er(t,e=Uo()){let r=dl.resolve(t),n=new Map,o=[];for(let i of e){let a=i.detect(r);if(a!==null){o.push(i.type);for(let c of a)n.has(c.name)||n.set(c.name,c)}}if(o.length===0)return{root:r,type:"none",types:[],packages:[],packageMap:new Map};let s=Array.from(n.values());return{root:r,type:o[0],types:o,packages:s,packageMap:new Map(s.map(i=>[i.name,i]))}}var Fr=m(()=>{"use strict";l();Do();Ro();Go();jo();$o();pt();pt();z(_o);z(Mo);z(Oo);z(zo);z(Io)});var Pe,Nr=m(()=>{"use strict";l();we();Pe=class t{constructor(e,r){this.monorepoRoot=e;this.type=r}monorepoRoot;type;packages=new Map;addPackage(e,r){this.packages.set(e.name,{graph:r,pkg:e})}getPackageForFile(e){for(let{pkg:r}of this.packages.values())if(e===r.relativeRoot||e.startsWith(`${r.relativeRoot}/`))return r}getPackageDependencies(){let e=new Map;for(let{graph:r,pkg:n}of this.packages.values()){let o=new Set;for(let s of r.nodes.values())for(let i of s.imports)i.isWorkspace&&i.workspacePackage&&o.add(i.workspacePackage);e.set(n.name,[...o])}return e}getAffectedAcrossPackages(e){let r=this.getPackageForFile(e);if(!r)return[];let n=this.packages.get(r.name);if(!n)return[];let o=[];n.graph.traverse(e,s=>(s.path!==e&&o.push({file:s.path,package:r.name}),!0),{direction:"incoming"});for(let{graph:s,pkg:i}of this.packages.values())if(i.name!==r.name)for(let a of s.nodes.values())a.imports.some(p=>p.isWorkspace&&p.workspacePackage===r.name)&&o.push({file:a.path,package:i.name});return o}serialize(){return{monorepoRoot:this.monorepoRoot,type:this.type,packages:Array.from(this.packages.values()).map(({graph:e,pkg:r})=>({pkg:{name:r.name,relativeRoot:r.relativeRoot,entryPoints:r.entryPoints},nodes:Array.from(e.nodes.values())}))}}static deserialize(e){let r=new t(e.monorepoRoot,e.type);for(let{pkg:n,nodes:o}of e.packages){let s=new Map(o.map(a=>[a.path,a])),i=new D(s);r.packages.set(n.name,{graph:i,pkg:{...n,root:""}})}return r}}});function fe(t,e){Ho.set(t,e)}function Jo(t){return Ho.get(t)}var Ho,Ie=m(()=>{"use strict";l();Ho=new Map});function Ko(t,e){return e.startsWith("!")?t!==e.slice(1):t===e}function gl(t,e){return e.startsWith("!")?!t.includes(e.slice(1)):t.includes(e)}function De(t,e,r){return Bl.every(n=>n(t,e,r))}var hl,yl,xl,bl,Sl,Cl,kl,vl,wl,Tl,El,Fl,Nl,Pl,Il,Dl,Ml,Al,Rl,Ll,Ol,Gl,_l,jl,Wl,zl,$l,Bl,Pr=m(()=>{"use strict";l();hl=(t,e)=>!e.category||Ko(t.category,e.category),yl=(t,e)=>!e.type||Ko(t.type,e.type),xl=(t,e)=>e.lastAuthor?e.lastAuthor.startsWith("!")?t.lastAuthor!==e.lastAuthor.slice(1):t.lastAuthor!==void 0&&t.lastAuthor===e.lastAuthor:!0,bl=(t,e)=>!e.path||gl(t.path,e.path),Sl=(t,e)=>e.isExternal===void 0?!0:t.imports.some(n=>n.isExternal)===e.isExternal,Cl=(t,e)=>{if(!e.tags||e.tags.length===0)return!0;let r=e.tags.filter(o=>!o.startsWith("!")),n=e.tags.filter(o=>o.startsWith("!")).map(o=>o.slice(1));return!(r.length>0&&!r.some(o=>t.tags.some(s=>s.name===o))||n.some(o=>t.tags.some(s=>s.name===o)))},kl=(t,e)=>!e.allTags?.length||e.allTags.every(r=>t.tags.some(n=>n.name===r)),vl=(t,e)=>!e.importsFile||t.imports.some(r=>r.toPath?.includes(e.importsFile)),wl=(t,e,r)=>e.importedBy===void 0?!0:(r?.get(t.path)??[]).some(o=>o.includes(e.importedBy)),Tl=(t,e)=>e.minImports===void 0||t.imports.length>=e.minImports,El=(t,e)=>e.maxImports===void 0||t.imports.length<=e.maxImports,Fl=(t,e)=>e.minSize===void 0||t.size>=e.minSize,Nl=(t,e)=>e.maxSize===void 0||t.size<=e.maxSize,Pl=(t,e)=>e.hasDocstring===void 0||!!t.description===e.hasDocstring,Il=(t,e)=>e.isDocumented===void 0||!!t.documentedBy?.length===e.isDocumented,Dl=(t,e)=>e.isStale===void 0||!!t.staleFor?.length===e.isStale,Ml=(t,e)=>e.minCoverage===void 0||(t.coveragePct??101)>=e.minCoverage,Al=(t,e)=>e.maxCoverage===void 0||(t.coveragePct??0)<=e.maxCoverage,Rl=(t,e)=>e.minExportUsage===void 0||(t.avgExportUsage??-1)>=e.minExportUsage,Ll=(t,e)=>e.maxExportUsage===void 0||(t.avgExportUsage??0)<=e.maxExportUsage,Ol=(t,e)=>e.minComplexity===void 0||(t.complexity??-1/0)>=e.minComplexity,Gl=(t,e)=>e.maxComplexity===void 0||(t.complexity??0)<=e.maxComplexity,_l=(t,e)=>e.minCognitiveComplexity===void 0||(t.cognitiveComplexity??-1/0)>=e.minCognitiveComplexity,jl=(t,e)=>e.maxCognitiveComplexity===void 0||(t.cognitiveComplexity??0)<=e.maxCognitiveComplexity,Wl=(t,e)=>e.minCommits===void 0||(t.commitCount90d??-1/0)>=e.minCommits,zl=(t,e)=>e.maxCommits===void 0||(t.commitCount90d??0)<=e.maxCommits,$l=(t,e,r)=>!e.any?.length||e.any.some(n=>De(t,n,r)),Bl=[hl,yl,xl,bl,Sl,Cl,kl,vl,wl,Tl,El,Fl,Nl,Pl,Il,Dl,Ml,Al,Rl,Ll,Ol,Gl,_l,jl,Wl,zl,$l]});function ft(t,e){let r=new Map;if(e.importedBy!==void 0){for(let i of t.nodes)for(let a of i.imports)if(a.toPath){let c=r.get(a.toPath)??[];c.push(i.path),r.set(a.toPath,c)}}let n=t.nodes.filter(i=>De(i,e,r)),o=new Set(n.map(i=>i.path)),s=n.map(i=>({...i,imports:i.imports.filter(a=>!a.toPath||o.has(a.toPath))}));if(e.sort){let i=e.sortDir==="asc"?-1:1;s.sort((a,c)=>{let p=0;return e.sort==="size"?p=c.size-a.size:e.sort==="imports"?p=c.imports.length-a.imports.length:e.sort==="commitCount90d"?p=(c.commitCount90d??0)-(a.commitCount90d??0):e.sort==="exportUsage"?p=(c.avgExportUsage??0)-(a.avgExportUsage??0):e.sort==="complexity"?p=(c.complexity??0)-(a.complexity??0):e.sort==="cognitiveComplexity"&&(p=(c.cognitiveComplexity??0)-(a.cognitiveComplexity??0)),p*i})}return e.limit!==void 0&&s.splice(e.limit),{nodes:s,cycles:t.cycles?.filter(i=>i.every(a=>o.has(a)))??void 0}}var Vo=m(()=>{"use strict";l();Pr();Pr()});function Qo(t,e){let r=e.indexOf(":");if(r===-1)return;let n=e.slice(0,r).trim().toLowerCase(),o=e.slice(r+1).trim();if(!(!n||!o))switch(n){case"category":t.category=o;break;case"type":t.type=o;break;case"tag":case"tags":o.includes("+")?t.allTags=[...t.allTags??[],...o.split("+")]:t.tags=[...t.tags??[],o];break;case"path":t.path=o;break;case"external":t.isExternal=o.toLowerCase()==="true";break;case"importsfile":t.importsFile=o;break;case"importedby":t.importedBy=o;break;case"minimports":t.minImports=parseInt(o,10);break;case"maximports":t.maxImports=parseInt(o,10);break;case"minsize":t.minSize=parseInt(o,10);break;case"maxsize":t.maxSize=parseInt(o,10);break;case"sort":t.sort=o;break;case"sortdir":t.sortDir=o.toLowerCase()==="asc"?"asc":"desc";break;case"limit":t.limit=parseInt(o,10);break;case"hasdocstring":t.hasDocstring=o.toLowerCase()!=="false";break;case"mincoverage":t.minCoverage=parseInt(o,10);break;case"maxcoverage":t.maxCoverage=parseInt(o,10);break;case"minexportusage":t.minExportUsage=parseFloat(o);break;case"maxexportusage":t.maxExportUsage=parseFloat(o);break;case"mincomplexity":t.minComplexity=parseInt(o,10);break;case"maxcomplexity":t.maxComplexity=parseInt(o,10);break;case"mincognitivecomplexity":t.minCognitiveComplexity=parseInt(o,10);break;case"maxcognitivecomplexity":t.maxCognitiveComplexity=parseInt(o,10);break;case"mincommits":t.minCommits=parseInt(o,10);break;case"maxcommits":t.maxCommits=parseInt(o,10);break;case"isdocumented":t.isDocumented=o.toLowerCase()!=="false";break;case"isstale":t.isStale=o.toLowerCase()!=="false";break;case"lastauthor":t.lastAuthor=o;break}}function Ul(t){let e=[];for(let r of t.split("|")){let n=r.trim();if(!n)continue;let o={};Qo(o,n),Object.keys(o).length>0&&e.push(o)}return e}function ut(t){let e={},r=t.split(",");for(let n of r){let o=n.trim();if(o.toLowerCase().startsWith("any(")&&o.endsWith(")")){let s=o.slice(4,-1),i=Ul(s);i.length>0&&(e.any=[...e.any??[],...i]);continue}Qo(e,n)}return e}var Yo=m(()=>{"use strict";l()});var Xo=m(()=>{"use strict";l();Vo();Yo()});import Hl from"path";import F from"typescript";function X(t,e){let r=t[e];if(r===void 0)throw new Error(`Index ${e} out of bounds (length ${t.length})`);return r}function Ir(t){let e=[];for(let r of t.statements){if(!F.isExpressionStatement(r))continue;let n=r.expression;if(!F.isCallExpression(n))continue;let o=n.expression;F.isIdentifier(o)&&qo.has(o.text)&&e.push(n),F.isPropertyAccessExpression(o)&&F.isIdentifier(o.expression)&&qo.has(o.expression.text)&&e.push(n)}return e}function Dr(t,e,r){for(let n of t.arguments){if(!F.isObjectLiteralExpression(n))continue;let o=n.properties.find(s=>F.isPropertyAssignment(s)&&F.isIdentifier(s.name)&&s.name.text===e);if(!(!o||!F.isArrayLiteralExpression(o.initializer)))return o.initializer.elements.filter(F.isStringLiteral).map(s=>s.text)}return null}function Mr(t,e,r,n){if(t.arguments.length===0)return null;for(let s=1;s<t.arguments.length;s++){let i=X(t.arguments,s);if(!F.isObjectLiteralExpression(i))continue;let a=i.properties.find(p=>F.isPropertyAssignment(p)&&F.isIdentifier(p.name)&&p.name.text===e);if(a)return{start:a.initializer.getStart(n),end:a.initializer.getEnd(),text:r};let c=i.getEnd()-1;return{start:c,end:c,text:`${i.properties.length>0?", ":""}${e}: ${r}`}}let o=X(t.arguments,t.arguments.length-1);return{start:o.getStart(n),end:o.getStart(n),text:`{ ${e}: ${r} }, `}}function Ar(t,e,r){let n=t.arguments;for(let o=1;o<n.length;o++){let s=X(n,o);if(!F.isObjectLiteralExpression(s))continue;let i=s.properties.findIndex(c=>F.isPropertyAssignment(c)&&F.isIdentifier(c.name)&&c.name.text===e);if(i<0)continue;if(s.properties.length===1)return{start:X(n,o-1).getEnd(),end:s.getEnd(),text:""};let a=X(s.properties,i);return i===s.properties.length-1?{start:X(s.properties,i-1).getEnd(),end:a.getEnd(),text:""}:{start:a.getStart(r),end:X(s.properties,i+1).getStart(r),text:""}}return null}function Rr(t,e){let r=[...e].sort((o,s)=>s.start-o.start),n=t;for(let o of r)n=n.slice(0,o.start)+o.text+n.slice(o.end);return n}function Lr(t){return`[${t.map(e=>JSON.stringify(e)).join(", ")}]`}function Jl(t){return t.map(e=>e.startsWith("@")?e.slice(1):e)}function mt(t,e,r,n){let o=F.createSourceFile(Hl.basename(t),e,F.ScriptTarget.Latest,!0),s=Ir(o),[i]=s;if(!i)return e;let a=Dr(i,n,o),c=[...r].sort();if(a!==null&&JSON.stringify(Jl(a).sort())===JSON.stringify(c))return e;let p=Lr(c.map(g=>`@${g}`)),f=s.flatMap(g=>{let y=r.length===0?Ar(g,n,o):Mr(g,n,p,o);return y?[y]:[]});return f.length>0?Rr(e,f):e}var qo,_,ue=m(()=>{"use strict";l();qo=new Set(["describe","test","it"]);_=new Set([".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"])});import Kl from"path";var dt,Zo=m(()=>{"use strict";l();ue();dt=class{name="cypress";canHandle(e){return _.has(Kl.extname(e).toLowerCase())}apply(e,r,n){return mt(e,r,n,"tags")}}});import Vl from"path";function Ql(t){return`${["# <mokosh-tags>",...t.map(e=>`@${e}`),"# </mokosh-tags>"].join(`
12
12
  `)}
13
13
 
14
- `}function Ol(t){let e=new Set;Nr.lastIndex=0;let r=Nr.exec(t);for(;r!==null;)r[1]&&e.add(r[1]),r=Nr.exec(t);return e}var Fr,Nr,pt,Ko=m(()=>{"use strict";l();Fr=/# <mokosh-tags>[\s\S]*?# <\/mokosh-tags>\n*/,Nr=/^@([a-zA-Z0-9_-]+)/gm;pt=class{name="gherkin";canHandle(e){return Ll.extname(e).toLowerCase()===".feature"}apply(e,r,n){let o=r.replace(Fr,""),s=Ol(o),i=n.filter(c=>!s.has(c)),a=i.length>0?Rl(i):"";return Fr.test(r)?r.replace(Fr,a):a?r.replace(/^(Feature:)/m,`${a}$1`):r}}});function Ho(t,e){let r=t.replace(/\\/g,"/"),n=e.replace(/\\/g,"/"),o="";for(let s=0;s<r.length;s++){let i=r[s];i==="*"?r[s+1]==="*"?(o+=".*",s++):o+="[^/]*":i==="?"?o+="[^/]":i!==void 0&&(o+=i.replace(/[.+^${}()|[\]\\]/g,"\\$&"))}return new RegExp(`^${o}$`).test(n)}var Vo=m(()=>{"use strict";l()});import Gl from"path";function jl(t){return`//go:build ${t.map(r=>`mokosh_${r}`).join(" || ")}
15
- `}function Wl(t){let e=Pr.exec(t);if(!e)return null;let r=e[0]??"",n=/mokosh_([a-zA-Z0-9_-]+)/g,o=[],s=n.exec(r);for(;s!==null;)s[1]&&o.push(s[1]),s=n.exec(r);return o}var Pr,_l,ft,Qo=m(()=>{"use strict";l();Pr=/^\/\/go:build mokosh_[^\n]+\n/m,_l=/^package\s+\S+/m;ft=class{name="go";canHandle(e){return Gl.basename(e).endsWith("_test.go")}apply(e,r,n){let o=Wl(r),s=[...n].sort();if(o!==null&&JSON.stringify([...o].sort())===JSON.stringify(s))return r;if(n.length===0)return r.replace(Pr,"");let i=jl(s);if(o!==null)return r.replace(Pr,i);let a=_l.exec(r);if(!a)return r;let c=a.index;return`${r.slice(0,c)+i}
16
- ${r.slice(c)}`}}});import zl from"path";function Ul(t){return`${["/**",...t.map(e=>` * @group ${e}`)," */"].join(`
14
+ `}function Yl(t){let e=new Set;Gr.lastIndex=0;let r=Gr.exec(t);for(;r!==null;)r[1]&&e.add(r[1]),r=Gr.exec(t);return e}var Or,Gr,gt,es=m(()=>{"use strict";l();Or=/# <mokosh-tags>[\s\S]*?# <\/mokosh-tags>\n*/,Gr=/^@([a-zA-Z0-9_-]+)/gm;gt=class{name="gherkin";canHandle(e){return Vl.extname(e).toLowerCase()===".feature"}apply(e,r,n){let o=r.replace(Or,""),s=Yl(o),i=n.filter(c=>!s.has(c)),a=i.length>0?Ql(i):"";return Or.test(r)?r.replace(Or,a):a?r.replace(/^(Feature:)/m,`${a}$1`):r}}});function ts(t,e){let r=t.replace(/\\/g,"/"),n=e.replace(/\\/g,"/"),o="";for(let s=0;s<r.length;s++){let i=r[s];i==="*"?r[s+1]==="*"?(o+=".*",s++):o+="[^/]*":i==="?"?o+="[^/]":i!==void 0&&(o+=i.replace(/[.+^${}()|[\]\\]/g,"\\$&"))}return new RegExp(`^${o}$`).test(n)}var rs=m(()=>{"use strict";l()});import Xl from"path";function Zl(t){return`//go:build ${t.map(r=>`mokosh_${r}`).join(" || ")}
15
+ `}function ep(t){let e=_r.exec(t);if(!e)return null;let r=e[0]??"",n=/mokosh_([a-zA-Z0-9_-]+)/g,o=[],s=n.exec(r);for(;s!==null;)s[1]&&o.push(s[1]),s=n.exec(r);return o}var _r,ql,ht,ns=m(()=>{"use strict";l();_r=/^\/\/go:build mokosh_[^\n]+\n/m,ql=/^package\s+\S+/m;ht=class{name="go";canHandle(e){return Xl.basename(e).endsWith("_test.go")}apply(e,r,n){let o=ep(r),s=[...n].sort();if(o!==null&&JSON.stringify([...o].sort())===JSON.stringify(s))return r;if(n.length===0)return r.replace(_r,"");let i=Zl(s);if(o!==null)return r.replace(_r,i);let a=ql.exec(r);if(!a)return r;let c=a.index;return`${r.slice(0,c)+i}
16
+ ${r.slice(c)}`}}});import tp from"path";function np(t){return`${["/**",...t.map(e=>` * @group ${e}`)," */"].join(`
17
17
  `)}
18
18
 
19
- `}function Bl(t){let e=[];Ir.lastIndex=0;let r=Ir.exec(t);for(;r!==null;)r[1]&&e.push(r[1]),r=Ir.exec(t);return e}var $l,Ir,ut,Yo=m(()=>{"use strict";l();le();$l=/^\/\*\*\n(?: \* @group .+\n)+ \*\/\n+/,Ir=/^ \* @group (.+)$/gm;ut=class{name="jest";canHandle(e){return _.has(zl.extname(e).toLowerCase())}apply(e,r,n){let o=$l.exec(r),s=o?Bl(o[0]):null,i=[...n].sort();if(s!==null&&JSON.stringify([...s].sort())===JSON.stringify(i))return r;let a=o?r.slice(o[0].length):r;return n.length===0?a:Ul(i)+a}}});import Jl from"path";var mt,Xo=m(()=>{"use strict";l();le();mt=class{name="playwright";canHandle(e){return _.has(Jl.extname(e).toLowerCase())}apply(e,r,n){return ct(e,r,n,"tag")}}});import Kl from"path";function Vl(t){let e=t.map(r=>`pytest.mark.${r}`).join(", ");return t.length===1?`pytestmark = pytest.mark.${t[0]}`:`pytestmark = [${e}]`}function Ql(t){let e=Dr.exec(t);if(!e)return null;let r=e[0],n=[],o=/pytest\.mark\.([a-zA-Z0-9_-]+)/g,s=o.exec(r);for(;s!==null;)s[1]&&n.push(s[1]),s=o.exec(r);return n}function Yl(t){let e=t.split(`
20
- `),r=-1;return e.forEach((o,s)=>{(o.trimStart().startsWith("import ")||o.trimStart().startsWith("from "))&&(r=s)}),r<0?0:e.slice(0,r+1).reduce((o,s)=>o+s.length+1,0)}var Dr,Hl,gt,qo=m(()=>{"use strict";l();Dr=/^pytestmark\s*=\s*.+$/m,Hl=/^import pytest\s*$/m;gt=class{name="pytest";canHandle(e){return Kl.extname(e).toLowerCase()===".py"}apply(e,r,n){let o=Ql(r),s=[...n].sort();if(o!==null&&JSON.stringify([...o].sort())===JSON.stringify(s))return r;if(n.length===0)return r.replace(Dr,"").replace(/\n{3,}/g,`
19
+ `}function op(t){let e=[];jr.lastIndex=0;let r=jr.exec(t);for(;r!==null;)r[1]&&e.push(r[1]),r=jr.exec(t);return e}var rp,jr,yt,os=m(()=>{"use strict";l();ue();rp=/^\/\*\*\n(?: \* @group .+\n)+ \*\/\n+/,jr=/^ \* @group (.+)$/gm;yt=class{name="jest";canHandle(e){return _.has(tp.extname(e).toLowerCase())}apply(e,r,n){let o=rp.exec(r),s=o?op(o[0]):null,i=[...n].sort();if(s!==null&&JSON.stringify([...s].sort())===JSON.stringify(i))return r;let a=o?r.slice(o[0].length):r;return n.length===0?a:np(i)+a}}});import sp from"path";var xt,ss=m(()=>{"use strict";l();ue();xt=class{name="playwright";canHandle(e){return _.has(sp.extname(e).toLowerCase())}apply(e,r,n){return mt(e,r,n,"tag")}}});import ip from"path";function cp(t){let e=t.map(r=>`pytest.mark.${r}`).join(", ");return t.length===1?`pytestmark = pytest.mark.${t[0]}`:`pytestmark = [${e}]`}function lp(t){let e=Wr.exec(t);if(!e)return null;let r=e[0],n=[],o=/pytest\.mark\.([a-zA-Z0-9_-]+)/g,s=o.exec(r);for(;s!==null;)s[1]&&n.push(s[1]),s=o.exec(r);return n}function pp(t){let e=t.split(`
20
+ `),r=-1;return e.forEach((o,s)=>{(o.trimStart().startsWith("import ")||o.trimStart().startsWith("from "))&&(r=s)}),r<0?0:e.slice(0,r+1).reduce((o,s)=>o+s.length+1,0)}var Wr,ap,bt,is=m(()=>{"use strict";l();Wr=/^pytestmark\s*=\s*.+$/m,ap=/^import pytest\s*$/m;bt=class{name="pytest";canHandle(e){return ip.extname(e).toLowerCase()===".py"}apply(e,r,n){let o=lp(r),s=[...n].sort();if(o!==null&&JSON.stringify([...o].sort())===JSON.stringify(s))return r;if(n.length===0)return r.replace(Wr,"").replace(/\n{3,}/g,`
21
21
 
22
- `);let i=Vl(s);if(o!==null)return r.replace(Dr,i);let a=Hl.test(r),c=Yl(r),p=r.slice(0,c),f=r.slice(c),d=a?"":`import pytest
22
+ `);let i=cp(s);if(o!==null)return r.replace(Wr,i);let a=ap.test(r),c=pp(r),p=r.slice(0,c),f=r.slice(c),g=a?"":`import pytest
23
23
  `,y=p.endsWith(`
24
24
 
25
25
  `)?"":`
26
- `;return`${p+y+d+i}
27
- ${f}`}}});import Zo from"path";import es from"typescript";var Xl,dt,ts=m(()=>{"use strict";l();le();Xl=/\/\/ <mokosh-tags>[\s\S]*?\/\/ <\/mokosh-tags>\n*/,dt=class{name="vitest";canHandle(e){return _.has(Zo.extname(e).toLowerCase())}apply(e,r,n){let o=r.replace(Xl,""),s=es.createSourceFile(Zo.basename(e),o,es.ScriptTarget.Latest,!0),i=Cr(s),[a]=i;if(!a)return o;let c=kr(a,"tags",s),p=[...n].sort();if(c!==null&&JSON.stringify([...c].sort())===JSON.stringify(p))return o;let f=i.flatMap(d=>{let y=n.length===0?wr(d,"tags",s):vr(d,"tags",Tr(p),s);return y?[y]:[]});return f.length>0?Er(o,f):o}}});import Mr from"path";import ht from"typescript";function Zl(t){let e=ht.createSourceFile("detect.ts",t,ht.ScriptTarget.Latest,!0);for(let r of e.statements){if(!ht.isImportDeclaration(r)||!ht.isStringLiteral(r.moduleSpecifier))continue;let n=ql[r.moduleSpecifier.text];if(n)return n}return null}function ns(t="vitest",e={},r=process.cwd()){return[new pt,new gt,new ft,new Ar(r,t,Object.entries(e))]}function os(t,e){return e.find(r=>r.canHandle(t))??null}var rs,ql,Ar,ss=m(()=>{"use strict";l();Jo();Ko();Vo();Qo();Yo();Xo();qo();le();ts();rs={vitest:()=>new dt,playwright:()=>new mt,cypress:()=>new lt,jest:()=>new ut},ql={"@playwright/test":"playwright",cypress:"cypress","@jest/globals":"jest",vitest:"vitest"};Ar=class{constructor(e,r,n){this.rootDir=e;this.defaultFramework=r;this.frameworkOverrides=n}rootDir;defaultFramework;frameworkOverrides;name="auto";canHandle(e){return _.has(Mr.extname(e).toLowerCase())}apply(e,r,n){let o=Zl(r)??this.matchOverride(e)??this.defaultFramework;return(rs[o]??rs.vitest)().apply(e,r,n)}matchOverride(e){let r=Mr.relative(this.rootDir,e).split(Mr.sep).join("/");for(let[n,o]of this.frameworkOverrides)if(Ho(n,r))return o;return null}}});import is from"fs/promises";import ep from"path";async function op(t,e,r,n){let o;try{o=await is.readFile(t,"utf8")}catch(a){return{path:t,status:"error",error:String(a)}}let s=os(t,n);if(!s)return{path:t,status:"unchanged"};let i=s.apply(t,o,e);return i===o?{path:t,status:"unchanged"}:(r||await is.writeFile(t,i,"utf8"),{path:t,status:"updated"})}async function Lr(t,e,r){let n=ne(e),o=n.tagApplier?.framework??"vitest",s=n.tagApplier?.frameworkOverrides??{},i=ns(o,s,e),a={updated:0,unchanged:0,errors:0,files:[]};for(let c of t.nodes.values()){if(c.category!=="test")continue;let p=new Set,f=[];for(let x of c.tags)rp.has(x.kind)&&tp.test(x.name)&&(np.has(x.name.toLowerCase())||p.has(x.name)||(p.add(x.name),f.push(x.name)));f.sort();let d=ep.resolve(e,c.path),y=await op(d,f,r.dryRun,i);y.path=c.path,a.files.push(y),y.status==="updated"?a.updated++:y.status==="unchanged"?a.unchanged++:a.errors++}return a}var tp,rp,np,as=m(()=>{"use strict";l();Lt();ss();tp=/^[a-zA-Z][a-zA-Z0-9_-]{1,}$/,rp=new Set(["import"]),np=new Set(["common","fixture","fixtures","helper","helpers","index","main","mock","mocks","setup","shared","spec","test","tests","types","util","utils"])});var yt,Rr=m(()=>{"use strict";l();yt=class{isTestNode(e){return e.category==="test"||e.tags.some(r=>r.name==="test")}}});import{execFileSync as Or}from"child_process";function ps(t,e){let r="",n=0;for(let o of t.split(`
28
- `)){if(o.startsWith("\0")){let[,c,p]=o.slice(1).split(" ");r=c??"",n=p?Number(p)*1e3:0;continue}if(o==="")continue;let s=o.split(" "),i=s[0];if(!i)continue;let a=i.startsWith("R")||i.startsWith("C")?s[2]:s[1];a&&e(a,r,n)}}function fs(t){let e=new Map;try{let r=Or("git",["-C",t,"log","--since=90 days ago","--name-status","-M",`--format=${cs}`],{encoding:"utf-8",stdio:["ignore","pipe","ignore"],maxBuffer:ls});ps(r,(n,o,s)=>{let i=e.get(n);if(i){i.commitCount90d+=1;return}e.set(n,{commitCount90d:1,lastAuthor:o||void 0,lastCommitAt:s||void 0})})}catch{return e}try{let r=Or("git",["-C",t,"log","--name-status","-M",`--format=${cs}`],{encoding:"utf-8",stdio:["ignore","pipe","ignore"],maxBuffer:ls});ps(r,(n,o,s)=>{e.has(n)||e.set(n,{commitCount90d:0,lastAuthor:void 0,lastCommitAt:s||void 0})})}catch{}return e}var xt,cs,ls,Gr=m(()=>{"use strict";l();xt=class{getChangedFiles(){try{let r=[["diff","--name-only"],["diff","--cached","--name-only"],["ls-files","--others","--exclude-standard"]].flatMap(n=>{try{return Or("git",n,{encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).split(`
29
- `).map(s=>s.trim()).filter(s=>s!=="")}catch{return[]}});return Array.from(new Set(r))}catch(e){return console.error("Error getting git diff:",e),[]}}},cs="%x00%H%x09%ae%x09%at",ls=256*1024*1024});import us from"path";function z(t){switch(us.extname(t).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 A(t){let e=us.extname(t).toLowerCase();return[".css",".scss",".sass",".less",".styl"].includes(e)}var $=m(()=>{"use strict";l()});function U(t){return t.startsWith("'")||t.startsWith('"')?t.slice(1,-1):t}function pe(t){let e=new Set,r=/@tag\s+([a-zA-Z0-9_-]+)/g,n=r.exec(t);for(;n!==null;)n[1]&&e.add(n[1]),n=r.exec(t);return e}function fe(t,e){let r=t.toLowerCase();return r.includes(".test.")||r.includes(".spec.")||e.has("test")?"test":"logic"}var bt=m(()=>{"use strict";l()});import sp from"coffeescript";function gs(t){if(t){if(typeof t.originalValue=="string")return t.originalValue;if(typeof t.value=="string")return U(t.value)}}function Y(t){if(t){if(typeof t.value=="string")return t.value;if(typeof t.base?.value=="string")return t.base.value}}function ip(t,e){let r=gs(e.source);return r?{fromPath:t,toPath:"",rawSpecifier:r,isStyle:A(r),type:"static"}:null}function ap(t,e){let r=e.variable?.base?.value==="require",n=gs(e.args?.[0]?.base);return!r||!n?null:{fromPath:t,toPath:"",rawSpecifier:n,isStyle:A(n),type:"require"}}function ms(t,e){if(e)return[{name:e}];let r=t.value;if(r?.constructor?.name==="Class"){let o=Y(r.variable);return o?[{name:o}]:[]}if(r?.base?.constructor?.name==="Obj"&&Array.isArray(r.base.properties))return r.base.properties.map(o=>Y(o.variable)??Y(o)).filter(o=>!!o).map(o=>({name:o}));let n=Y(r);return n?[{name:n}]:[]}function cp(t){if(Array.isArray(t.specifiers))return t.specifiers.map(r=>r.identifier??r.original?.value).filter(r=>!!r).map(r=>({name:r}));let e=Y(t.variable)??Y(t.variable?.base);return e?[{name:e}]:[]}function lp(t,e,r,n){let o=e.constructor?.name;if(o==="ImportDeclaration"){let s=ip(t,e);s&&r.push(s)}else if(o==="Call"){let s=ap(t,e);s&&r.push(s)}else if(o==="Assign"){let s=Y(e.variable?.base),i=e.variable?.properties?.[0]?.name?.value;s==="module"&&i==="exports"?n.push(...ms(e,void 0)):s==="exports"&&typeof i=="string"&&n.push(...ms(e,i))}else o==="ExportNamedDeclaration"&&e.clause?n.push(...cp(e.clause)):o==="ExportDefaultDeclaration"&&n.push({name:"default"})}function _r(t,e,r,n){if(!(!e||typeof e!="object")){lp(t,e,r,n);for(let o in e){if(o==="locationData")continue;let s=e[o];if(!(!s||typeof s!="object"))if(Array.isArray(s))for(let i of s)_r(t,i,r,n);else _r(t,s,r,n)}}}function ds(t,e){let r=pe(e),n=fe(t,r),o=[],s=[];try{_r(t,sp.nodes(e),o,s)}catch{}let i=new Set,a=s.filter(c=>i.has(c.name)?!1:(i.add(c.name),!0));return{imports:o,exports:a,tags:Array.from(r).map(c=>({name:c,kind:"comment-marker"})),category:n}}var hs=m(()=>{"use strict";l();$();bt()});import{AstBuilder as pp,GherkinClassicTokenMatcher as fp,Parser as up}from"@cucumber/gherkin";import{IdGenerator as mp}from"@cucumber/messages";function jr(t,e){let r=new Set;try{let n=new pp(gp),o=new fp,i=new up(n,o).parse(e);i.feature&&(i.feature.tags.forEach(a=>{r.add(a.name.startsWith("@")?a.name.slice(1):a.name)}),i.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(n){console.warn(`[GherkinParser] Failed to parse ${t}:`,n)}return{imports:[],exports:[],tags:Array.from(r).map(n=>({name:n,kind:"comment-marker"})),category:"test"}}var gp,ys=m(()=>{"use strict";l();Te();gp=mp.uuid();ce("gherkin",jr)});function X(t){let e=[],r=t.firstChild;for(;r;)e.push(r),r=r.nextSibling;return e}function Ne(t,e){let r=1;for(let n=0;n<e&&n<t.length;n++)t[n]===`
30
- `&&r++;return r}var Wr=m(()=>{"use strict";l()});function dp(t,e){let r=1;function n(o){switch(o.type.name){case"IfStatement":case"ForStatement":r++;break;case"Case":{o.firstChild?.type.name==="case"&&r++;break}case"LogicOp":{let i=e.slice(o.from,o.to);(i==="&&"||i==="||")&&r++;break}}let s=o.firstChild;for(;s;)n(s),s=s.nextSibling}return n(t),r}function hp(t,e){let r=0;function n(o,s,i){let a=o.type.name;if(a==="IfStatement"){r+=i?1:1+s;let f=X(o),d=i?s:s+1,y=f[1];y&&y.type.name!=="Block"&&n(y,d,!1);let x=f.find(C=>C.type.name==="Block");x&&n(x,d,!1);let v=f.findIndex(C=>C.type.name==="else");if(v>=0){let C=f[v+1];C?.type.name==="IfStatement"?n(C,s,!0):C&&(r+=1,n(C,s+1,!1))}return}if(a==="ForStatement"||a==="SwitchStatement"||a==="SelectStatement"){r+=1+s;let f=o.firstChild;for(;f;)n(f,s+1,!1),f=f.nextSibling;return}if(a==="LogicOp"){let f=e.slice(o.from,o.to);(f==="&&"||f==="||")&&(r+=1)}if(s>0&&a==="FunctionLiteral"){r+=1+s;let f=o.firstChild;for(;f;)n(f,s+1,!1),f=f.nextSibling;return}let p=o.firstChild;for(;p;)n(p,s,!1),p=p.nextSibling}return n(t,0,!1),r}function St(t,e){return{complexity:dp(t,e),cognitiveComplexity:hp(t,e)}}function zr(t,e){let n=t.getChild("Parameters")?.getChild("Parameter"),o=n?.getChild("TypeName")??n?.getChild("PointerType")?.getChild("TypeName");return o?e.slice(o.from,o.to):void 0}function xs(t,e){let r=[],n=t.cursor();do if(n.name==="FunctionDecl"){let o=n.node.getChild("DefName");if(o){let s=e.slice(o.from,o.to),{complexity:i,cognitiveComplexity:a}=St(n.node,e);r.push({name:s,line:Ne(e,n.from),complexity:i,cognitiveComplexity:a})}}else if(n.name==="MethodDecl"){let o=n.node.getChild("FieldName");if(o){let s=e.slice(o.from,o.to),i=zr(n.node,e),a=i?`${i}.${s}`:s,{complexity:c,cognitiveComplexity:p}=St(n.node,e);r.push({name:a,line:Ne(e,n.from),complexity:c,cognitiveComplexity:p})}}while(n.next());return r}var bs=m(()=>{"use strict";l();Wr()});import yp from"path";import{parser as xp}from"@lezer/go";function Cs(t,e){let r=[],n=new Map,o=new Set,s=new Set,i=new Map,a=xp.parse(e),c=a.cursor();do switch(c.name){case"LineComment":{let b=e.slice(c.from,c.to),E=b.match(bp);E?.[1]&&o.add(E[1]);let G=b.match(Sp);G&&Ss(G[1],s);let O=b.match(Cp);O&&Ss(O[1],s);break}case"ImportSpec":{let b=c.node.getChild("String");if(b){let G=e.slice(b.from,b.to).slice(1,-1);r.push({fromPath:t,toPath:"",rawSpecifier:G,isExternal:!0,isStyle:!1,type:"static"});let O=c.node.getChild("DefName"),B=O?e.slice(O.from,O.to):G.split("/").pop();B&&B!=="_"&&B!=="."&&i.set(B,G)}break}case"FunctionDecl":case"MethodDecl":case"TypeDecl":case"VarDecl":case"ConstDecl":{let b=c.node.getChild("DefName")??c.node.getChild("FieldName")??c.node.getChild("TypeSpec")?.getChild("DefName")??c.node.getChild("VarSpec")?.getChild("DefName")??c.node.getChild("ConstSpec")?.getChild("DefName");if(b){let E=e.slice(b.from,b.to);E!=="_"&&/^[A-Z]/.test(E)&&!n.has(E)&&n.set(E,{name:E})}break}}while(c.next());let p=r.some(b=>b.rawSpecifier==="testing"),f=yp.basename(t).endsWith("_test.go")||o.has("test")||p?"test":"logic",d=new Set([...o,...s]),{complexity:y,cognitiveComplexity:x}=St(a.topNode,e),v=xs(a,e),C=f==="test"?[]:kp(a,e,i);return{imports:r,exports:Array.from(n.values()),tags:Array.from(d).map(b=>({name:b,kind:"comment-marker"})),category:f,rawCallEdges:C,complexity:y,cognitiveComplexity:x,...v.length>0?{functions:v}:{}}}function kp(t,e,r){let n=[];function o(i,a){if(i.type.name==="CallExpr"){let p=i.firstChild;if(p?.type.name==="SelectorExpr"){let f=p.firstChild,d=p.getChild("FieldName");if(f?.type.name==="VariableName"&&d){let y=e.slice(f.from,f.to),x=r.get(y);if(x){let v=e.slice(d.from,d.to);n.push({from:a,to:v,toSpecifier:x})}}}}let c=i.firstChild;for(;c;)o(c,a),c=c.nextSibling}let s=t.cursor();do if(s.name==="FunctionDecl"){let i=s.node.getChild("DefName"),a=s.node.getChild("Block");if(i&&a){let c=e.slice(i.from,i.to);/^[A-Z]/.test(c)&&o(a,c)}}else if(s.name==="MethodDecl"){let i=s.node.getChild("FieldName"),a=s.node.getChild("Block");if(i&&a){let c=e.slice(i.from,i.to),p=zr(s.node,e);o(a,p?`${p}.${c}`:c)}}while(s.next());return n}function Ss(t,e){for(let r of t.split(/[\s,&|!()]+/)){let n=r.trim();n&&n!=="ignore"&&e.add(n)}}var bp,Sp,Cp,ks=m(()=>{"use strict";l();bs();bp=/\/\/\s*@tag\s+([a-zA-Z0-9_-]+)/,Sp=/^\/\/go:build\s+(.+)$/,Cp=/^\/\/\s*\+build\s+(.+)$/});import vp from"livescript";function q(t){if(t){if(typeof t.value=="string")return t.value;if(typeof t.base?.value=="string")return t.base.value}}function wp(t){if(!t)return[];if(t.constructor?.name==="Class"){let r=q(t.title);return r?[{name:r}]:[]}if(t.constructor?.name==="Obj"&&Array.isArray(t.items))return t.items.map(r=>q(r.key)??q(r.val)).filter(r=>!!r).map(r=>({name:r}));let e=q(t);return e?[{name:e}]:[]}function Ep(t){let e=t.constructor?.name||t.type;if(e==="Assign"&&t.left?.constructor?.name==="Chain"){let r=t.left,n=q(r.head),s=r.tails?.[0]?.key?.name;if(n==="module"&&s==="exports")return wp(t.right);if(n==="exports"&&typeof s=="string")return[{name:s}];if(r.head?.verb==="out"&&typeof s=="string")return[{name:s}]}if(e==="Import"&&t.left?.verb==="out"){let r=t.right;if(r?.constructor?.name==="Obj"&&Array.isArray(r.items))return r.items.map(n=>q(n.val)??q(n.key)).filter(n=>!!n).map(n=>({name:n}))}return[]}function Fp(t,e){let r=t.constructor?.name||t.type;if(r==="Import"){let n=t.right?.value;if(typeof n=="string"){let o=U(n);return{fromPath:e,toPath:"",rawSpecifier:o,isStyle:A(o),type:"static"}}}if(r==="Chain"&&t.head?.value==="require"){let n=t.tails?.[0];if(n?.constructor?.name==="Call"||n?.type==="Call"){let o=n.args?.[0]?.value;if(typeof o=="string"){let s=U(o);return{fromPath:e,toPath:"",rawSpecifier:s,isStyle:A(s),type:"require"}}}}return null}function $r(t,e,r){if(!t||typeof t!="object")return[];let n=[],o=Fp(t,e);o&&n.push(o),r.push(...Ep(t));for(let s in t){if(Tp.has(s))continue;let i=t[s];if(!(!i||typeof i!="object"))if(Array.isArray(i))for(let a of i)n.push(...$r(a,e,r));else n.push(...$r(i,e,r))}return n}function vs(t,e){let r=pe(e),n=fe(t,r),o=[],s=[];try{o=$r(vp.ast(e),t,s)}catch{}let i=new Set,a=s.filter(c=>i.has(c.name)?!1:(i.add(c.name),!0));return{imports:o,exports:a,tags:Array.from(r).map(c=>({name:c,kind:"comment-marker"})),category:n}}var Tp,ws=m(()=>{"use strict";l();$();bt();Tp=new Set(["first_line","first_column","last_line","last_column","line","column"])});import Np from"luaparse";function Pp(t,e){let r=[];function n(o){if(!(!o||typeof o!="object")){if((o.type==="CallExpression"||o.type==="StringCallExpression")&&o.base?.type==="Identifier"&&o.base?.name==="require"){let s;if(o.type==="CallExpression"){let i=o.arguments?.[0];i?.type==="StringLiteral"&&(s=U(i.raw))}else if(o.type==="StringCallExpression"){let i=o.argument;i?.type==="StringLiteral"&&(s=U(i.raw))}s&&r.push({fromPath:e,toPath:"",rawSpecifier:s,isStyle:A(s),type:"require"})}for(let s in o){if(s==="loc")continue;let i=o[s];if(i&&typeof i=="object")if(Array.isArray(i))for(let a of i)n(a);else n(i)}}}return n(t),r}function Ip(t){let e=new Set;for(let r of t)r.type==="LocalStatement"&&r.variables.forEach((n,o)=>{r.init[o]?.type==="TableConstructorExpression"&&e.add(n.name)});return e}function Dp(t){let e=t[t.length-1];if(e?.type!=="ReturnStatement")return[];let r=e.arguments[0];if(r?.type!=="TableConstructorExpression")return[];let n=[];for(let o of r.fields)o.type==="TableKeyString"&&n.push({name:o.key.name});return n}function Mp(t){let e=t.body,r=Ip(e),n=Dp(e);for(let s of e)if(s.type==="FunctionDeclaration")s.identifier?.type==="MemberExpression"?s.identifier.base.type==="Identifier"&&r.has(s.identifier.base.name)&&n.push({name:s.identifier.identifier.name}):s.identifier?.type==="Identifier"&&!s.isLocal&&n.push({name:s.identifier.name});else if(s.type==="AssignmentStatement")for(let i of s.variables)i.type==="MemberExpression"&&i.base.type==="Identifier"&&r.has(i.base.name)&&n.push({name:i.identifier.name});let o=new Set;return n.filter(s=>o.has(s.name)?!1:(o.add(s.name),!0))}function Es(t,e){let r=pe(e),n=fe(t,r),o=[],s=[];try{let i=Np.parse(e);o=Pp(i,t),s=Mp(i)}catch{}return{imports:o,exports:s,tags:Array.from(r).map(i=>({name:i,kind:"comment-marker"})),category:n}}var Ts=m(()=>{"use strict";l();$();bt()});async function Op(){return Fs??=(async()=>{let{unified:t}=await import("unified"),e=(await import("remark-parse")).default;return t().use(e)})(),Fs}function Gp(t){let e=t.trim();return e.length===0||e.startsWith("#")||Ap.some(r=>e.startsWith(r))}function _p(t,e){let r=t.match(Rp);return r?r.map(n=>({fromPath:e,toPath:"",rawSpecifier:n,isStyle:!1,type:"static"})):[]}function Ns(t,e,r){if(t.type==="link"&&typeof t.url=="string"&&!Gp(t.url)&&r.push({fromPath:e,toPath:"",rawSpecifier:t.url,isStyle:!1,type:"static"}),(t.type==="code"||t.type==="inlineCode")&&typeof t.value=="string"&&r.push(..._p(t.value,e)),Array.isArray(t.children))for(let n of t.children)Ns(n,e,r)}async function Ps(t,e){let n=(await Op()).parse(e),o=[];Ns(n,t,o);let s=new Set;return{imports:o.filter(a=>s.has(a.rawSpecifier)?!1:(s.add(a.rawSpecifier),!0)),exports:[],tags:[],category:"other"}}var Ap,Lp,Rp,Fs,Is=m(()=>{"use strict";l();Ap=["http://","https://","mailto:","//"],Lp="ts|tsx|js|jsx|mjs|cjs|py|go|lua|css|scss|less|styl|coffee|ls|feature|md|mdx|json",Rp=new RegExp(`(?:\\.{1,2}/)?[\\w.-]+(?:/[\\w.-]+)*\\.(?:${Lp})\\b`,"g")});function jp(t){let e=1;function r(n){switch(n.type.name){case"IfStatement":{e+=X(n).filter(s=>s.type.name==="if"||s.type.name==="elif").length;break}case"TryStatement":{e+=X(n).filter(s=>s.type.name==="except").length;break}case"ForStatement":case"WhileStatement":case"ConditionalExpression":e++;break;case"and":case"or":e++;break}let o=n.firstChild;for(;o;)r(o),o=o.nextSibling}return r(t),e}function Wp(t){let e=0;function r(n,o){let s=n.type.name;if(s==="IfStatement"){let c=X(n),p=0,f=0;for(;f<c.length;){let d=c[f];if(d?.type.name==="if"||d?.type.name==="elif"){let y=p>0;e+=y?1:1+o;let x=y?o:o+1,v=c[f+1],C=c[f+2];v&&r(v,x),C&&r(C,x),p++,f+=3}else if(d?.type.name==="else"){e+=1;let y=c[f+1];y&&r(y,o+1),f+=2}else f++}return}if(s==="TryStatement"){let c=X(n),p=0;for(;p<c.length;){let f=c[p];if(f?.type.name==="except"){for(e+=1+o,p++;p<c.length&&c[p]?.type.name!=="Body";)r(c[p],o),p++;p<c.length&&(r(c[p],o),p++)}else f?.type.name==="Body"&&r(f,o),p++}return}if(s==="ForStatement"||s==="WhileStatement"){e+=1+o;let c=n.firstChild;for(;c;)r(c,o+1),c=c.nextSibling;return}if((s==="ConditionalExpression"||s==="and"||s==="or")&&(e+=1),o>0&&(s==="FunctionDefinition"||s==="LambdaExpression")){e+=1+o;let c=n.firstChild;for(;c;)r(c,o+1),c=c.nextSibling;return}let a=n.firstChild;for(;a;)r(a,o),a=a.nextSibling}return r(t,0),e}function Ur(t){return{complexity:jp(t),cognitiveComplexity:Wp(t)}}function Ds(t,e){let r=[];function n(i,a){let{complexity:c,cognitiveComplexity:p}=Ur(i);r.push({name:a,line:Ne(e,i.from),complexity:c,cognitiveComplexity:p})}function o(i){let a=i.firstChild;for(;a;)s(a),a=a.nextSibling}function s(i){if(i.type.name==="ClassDefinition"){let a=i.getChild("VariableName"),c=a?e.slice(a.from,a.to):void 0,p=i.getChild("Body");if(p){let f=p.firstChild;for(;f;){if(f.type.name==="FunctionDefinition"){let d=f.getChild("VariableName"),y=d?e.slice(d.from,d.to):void 0;y&&n(f,c?`${c}.${y}`:y),o(f)}else s(f);f=f.nextSibling}}return}if(i.type.name==="FunctionDefinition"){let a=i.getChild("VariableName");a&&n(i,e.slice(a.from,a.to)),o(i);return}o(i)}return s(t.topNode),r}var Ms=m(()=>{"use strict";l();Wr()});import zp from"path";import{parser as $p}from"@lezer/python";function As(t,e){let r=[],n=[],o=new Set,s=zp.basename(t).toLowerCase(),i=$p.parse(e),a=i.cursor();do switch(a.name){case"Comment":{let x=e.slice(a.from,a.to).match(/#\s*@tag\s+([a-zA-Z0-9_-]+)/);x?.[1]&&o.add(x[1]);break}case"ImportStatement":{for(let x of Bp(a.node,e,t))r.push(x);break}case"FunctionDefinition":case"ClassDefinition":{let x=a.node.parent;if(x?.name==="Script"||x?.name==="DecoratedStatement"&&x.parent?.name==="Script"){let C=a.node.getChild("VariableName");C&&n.push({name:e.slice(C.from,C.to)})}break}case"AssignStatement":{if(a.node.parent?.name==="Script"){let x=a.node.firstChild;x?.name==="VariableName"&&n.push({name:e.slice(x.from,x.to)})}break}}while(a.next());let c=Yp(s,r,o);c==="test"&&o.add("test");let{complexity:p,cognitiveComplexity:f}=Ur(i.topNode),d=Ds(i,e),y=c==="test"?[]:Qp(i,e);return{imports:r,exports:n,tags:Array.from(o).map(x=>({name:x,kind:"comment-marker"})),category:c,rawCallEdges:y,complexity:p,cognitiveComplexity:f,...d.length>0?{functions:d}:{}}}function Bp(t,e,r){let n=t.firstChild;return n?n.name==="from"?Jp(t,e,r):Kp(t,e,r):[]}function Jp(t,e,r){let n=t.firstChild;if(!n)return[];let o=n.nextSibling;for(;o&&o.name!=="import";)o=o.nextSibling;if(!o)return[];let s=e.slice(n.to,o.from).trim(),i=Hp(o.nextSibling,e);if(!i.length)return[];let a=0;for(;a<s.length&&s[a]===".";)a++;let c=s.slice(a);if(a===0)return[Pe(r,s,i,!0)];let p=a===1?"./":"../".repeat(a-1);return c?[Pe(r,p+c.replace(/\./g,"/"),i,!1)]:i[0]==="*"?[Pe(r,p.slice(0,-1),["*"],!1)]:i.map(f=>Pe(r,p+f,[f],!1))}function Kp(t,e,r){let n=[],o=t.firstChild?.nextSibling??null;for(;o;){if(o.name==="VariableName"){let s=e.slice(o.from,o.to);for(;o.nextSibling?.name==="."&&o.nextSibling.nextSibling?.name==="VariableName";)o=o.nextSibling.nextSibling,s+=`.${e.slice(o.from,o.to)}`;o.nextSibling?.name==="as"&&(o=o.nextSibling.nextSibling??o.nextSibling),n.push(Pe(r,s,["*"],!0))}o=o.nextSibling}return n}function Hp(t,e){let r=[],n=t;for(;n;)n.name==="*"?r.push("*"):n.name==="VariableName"&&(r.push(e.slice(n.from,n.to)),n.nextSibling?.name==="as"&&(n=n.nextSibling.nextSibling??n.nextSibling)),n=n.nextSibling;return r}function Vp(t,e){let r=new Map,n=t.cursor();do{if(n.name!=="ImportStatement")continue;let s=n.node.firstChild;if(s?.type.name!=="from")continue;let i=s.nextSibling;for(;i&&i.type.name!=="import";)i=i.nextSibling;if(!i)continue;let a=e.slice(s.to,i.from).trim(),c=0;for(;c<a.length&&a[c]===".";)c++;let p=a.slice(c),f=c<=1?"./":"../".repeat(c-1),d=i.nextSibling;for(;d;){if(d.type.name==="VariableName"){let y=e.slice(d.from,d.to),x=y;if(d.nextSibling?.type.name==="as"){let C=d.nextSibling.nextSibling;C?.type.name==="VariableName"&&(x=e.slice(C.from,C.to),d=C)}let v=c===0?a:p?f+p.replace(/\./g,"/"):f+y;r.set(x,v)}d=d.nextSibling}}while(n.next());return r}function Qp(t,e){let r=Vp(t,e),n=[];function o(a,c){if(a.type.name==="CallExpression"&&a.firstChild?.type.name==="VariableName"){let f=a.firstChild,d=e.slice(f.from,f.to),y=r.get(d);y&&n.push({from:c,to:d,toSpecifier:y})}let p=a.firstChild;for(;p;)o(p,c),p=p.nextSibling}function s(a){let c=a.firstChild;for(;c;)i(c),c=c.nextSibling}function i(a){if(a.type.name==="ClassDefinition"){let c=a.getChild("VariableName"),p=c?e.slice(c.from,c.to):void 0,f=a.getChild("Body");if(f){let d=f.firstChild;for(;d;){if(d.type.name==="FunctionDefinition"){let y=d.getChild("VariableName"),x=y?e.slice(y.from,y.to):void 0;x&&o(d,p?`${p}.${x}`:x)}else i(d);d=d.nextSibling}}return}if(a.type.name==="FunctionDefinition"){let c=a.getChild("VariableName");c&&o(a,e.slice(c.from,c.to));return}s(a)}return i(t.topNode),n}function Pe(t,e,r,n){return{fromPath:t,toPath:"",rawSpecifier:e,isStyle:!1,isExternal:n,type:"static",symbols:r.length>0?r:void 0}}function Yp(t,e,r){return t.startsWith("test_")||t.endsWith("_test.py")?"test":t==="conftest.py"||t==="setup.py"?"config":r.has("test")||e.some(n=>Up.has(n.rawSpecifier))?"test":"logic"}var Up,Ls=m(()=>{"use strict";l();Ms();Up=new Set(["pytest","unittest","nose","hypothesis"])});import S from"typescript";function Xp(t){let e=1;function r(n){switch(n.kind){case S.SyntaxKind.IfStatement:case S.SyntaxKind.ConditionalExpression:case S.SyntaxKind.ForStatement:case S.SyntaxKind.ForInStatement:case S.SyntaxKind.ForOfStatement:case S.SyntaxKind.WhileStatement:case S.SyntaxKind.DoStatement:case S.SyntaxKind.CatchClause:case S.SyntaxKind.CaseClause:e++;break;case S.SyntaxKind.BinaryExpression:{let o=n.operatorToken.kind;(o===S.SyntaxKind.AmpersandAmpersandToken||o===S.SyntaxKind.BarBarToken||o===S.SyntaxKind.QuestionQuestionToken)&&e++;break}}S.forEachChild(n,r)}return r(t),e}function qp(t){let e=0;function r(n,o,s){if(S.isIfStatement(n)){e+=s?1:1+o;let a=s?o:o+1;r(n.expression,a,!1),r(n.thenStatement,a,!1),n.elseStatement&&(S.isIfStatement(n.elseStatement)?r(n.elseStatement,o,!0):(e+=1,r(n.elseStatement,o+1,!1)));return}if(S.isForStatement(n)||S.isForInStatement(n)||S.isForOfStatement(n)||S.isWhileStatement(n)||S.isDoStatement(n)||S.isSwitchStatement(n)){e+=1+o,S.forEachChild(n,a=>r(a,o+1,!1));return}if(S.isCatchClause(n)){e+=1+o,S.forEachChild(n,a=>r(a,o,!1));return}if(S.isConditionalExpression(n)&&(e+=1),S.isBinaryExpression(n)){let a=n.operatorToken.kind;(a===S.SyntaxKind.AmpersandAmpersandToken||a===S.SyntaxKind.BarBarToken||a===S.SyntaxKind.QuestionQuestionToken)&&(e+=1)}if(o>0&&(S.isFunctionDeclaration(n)||S.isFunctionExpression(n)||S.isArrowFunction(n))){e+=1+o,S.forEachChild(n,a=>r(a,o+1,!1));return}S.forEachChild(n,a=>r(a,o,!1))}return r(t,0,!1),e}function Br(t){return{complexity:Xp(t),cognitiveComplexity:qp(t)}}var Rs=m(()=>{"use strict";l()});import T from"typescript";function Os(t,e){Zp(t,e),tf(t,e),rf(t,e),nf(t,e)}function Zp(t,e){if((T.isFunctionDeclaration(t)||T.isVariableDeclaration(t))&&t.name&&T.isIdentifier(t.name)&&ef(t)){let r;if(T.isFunctionDeclaration(t))r="function";else{let n=t.initializer;r=n&&(T.isArrowFunction(n)||T.isFunctionExpression(n))?"function":"variable"}e.tags.add({name:t.name.text,kind:r})}}function ef(t){if(T.isFunctionDeclaration(t))return T.isSourceFile(t.parent);let e=t.parent?.parent;return!!e&&T.isSourceFile(e.parent)}function tf(t,e){if(!T.isStringLiteral(t))return;let r=t.text.match(/@[\w-]+/g);if(r)for(let n of r)e.tags.add({name:n.substring(1),kind:"comment-marker"})}function rf(t,e){if(!T.isSourceFile(t))return;let r=/@tag\s+([a-zA-Z0-9_-]+)/g,n=t.getFullText(),o=r.exec(n);for(;o!==null;)o[1]&&e.tags.add({name:o[1],kind:"comment-marker"}),o=r.exec(n)}function nf(t,e){if(T.isCallExpression(t)&&of(t.expression))for(let r of t.arguments)T.isObjectLiteralExpression(r)&&sf(r,e)}function of(t){return T.isIdentifier(t)?Jr.has(t.text):!!(T.isPropertyAccessExpression(t)&&(Jr.has(t.name.text)||T.isIdentifier(t.expression)&&Jr.has(t.expression.text)))}function sf(t,e){for(let r of t.properties){if(!T.isPropertyAssignment(r)||!T.isIdentifier(r.name)||r.name.text!=="tags"&&r.name.text!=="tag")continue;let{initializer:n}=r,o=T.isArrayLiteralExpression(n)?n.elements.filter(T.isStringLiteral):r.name.text==="tag"&&T.isStringLiteral(n)?[n]:[];for(let s of o)e.tags.add({name:s.text.replace(/^@/,""),kind:"comment-marker"})}}var Jr,Gs=m(()=>{"use strict";l();Jr=new Set(["test","describe","it"])});import _s from"path";import h from"typescript";function Kr(t,e,r){let n=[],o=new Map,s=new Set,i=h.createSourceFile(t,e,h.ScriptTarget.Latest,!0,r==="typescript"?h.ScriptKind.TSX:h.ScriptKind.JSX),a={filePath:t,imports:n,exports:o,tags:s,rawCallEdges:[],sourceFile:i,hasUI:!1,hasTypesOnly:!0,totalStatements:0,exportStatements:0},c=C=>{pf(C,a),h.forEachChild(C,c)};c(i);let p=Cf(t,a);(p==="test"||p==="barrel")&&s.add({name:p,kind:"comment-marker"}),p!=="test"&&kf(a,i);let f=i.statements[0],d=f?Ws(f):void 0,{complexity:y,cognitiveComplexity:x}=Br(i),v=af(i);return{imports:n,exports:Array.from(o.values()),tags:Array.from(s),category:p,rawCallEdges:a.rawCallEdges??[],complexity:y,cognitiveComplexity:x,...v.length>0?{functions:v}:{},...d!==void 0?{description:d}:{}}}function af(t){let e=[],r=(o,s)=>{let{complexity:i,cognitiveComplexity:a}=Br(s),c=t.getLineAndCharacterOfPosition(s.getStart(t)).line+1;e.push({name:o,line:c,complexity:i,cognitiveComplexity:a})},n=(o,s)=>{if(h.isFunctionDeclaration(o)&&o.name&&o.body?r(o.name.text,o):h.isVariableDeclaration(o)&&h.isIdentifier(o.name)&&o.initializer&&(h.isArrowFunction(o.initializer)||h.isFunctionExpression(o.initializer))?r(o.name.text,o.initializer):s&&h.isMethodDeclaration(o)&&h.isIdentifier(o.name)&&o.body?r(`${s}.${o.name.text}`,o):s&&h.isConstructorDeclaration(o)&&o.body?r(`${s}.constructor`,o):s&&h.isGetAccessorDeclaration(o)&&h.isIdentifier(o.name)&&o.body?r(`${s}.get ${o.name.text}`,o):s&&h.isSetAccessorDeclaration(o)&&h.isIdentifier(o.name)&&o.body&&r(`${s}.set ${o.name.text}`,o),h.isClassDeclaration(o)&&o.name){let i=o.name.text;h.forEachChild(o,a=>n(a,i));return}h.forEachChild(o,i=>n(i,s))};return n(t,void 0),e}function js(t,e,r,n){let o={name:t},s=Ws(r);s!==void 0&&(o.doc=s);let i=cf(e);i!==void 0&&(o.flags=i);let a=lf(e,n);return a!==void 0&&(o.signature=a),o}function Ws(t){let e=h.getJSDocCommentsAndTags(t);for(let r of e)if(h.isJSDoc(r)&&r.comment)return h.getTextOfJSDocComment(r.comment)||void 0}function cf(t){let e=new Set(["deprecated","internal","public","alpha","beta"]),r=h.getJSDocTags(t).map(n=>n.tagName.text).filter(n=>e.has(n));return r.length>0?r:void 0}function lf(t,e){let r=h.createPrinter({removeComments:!0}),n=o=>r.printNode(h.EmitHint.Unspecified,o,e);if(h.isFunctionDeclaration(t)||h.isMethodDeclaration(t)){let o=t.parameters.map(n).join(", "),s=t.type?n(t.type):"void";return`${t.typeParameters?`<${t.typeParameters.map(a=>a.name.text).join(", ")}>`:""}(${o}) => ${s}`}if(h.isVariableDeclaration(t)){if(t.type)return n(t.type);if(t.initializer&&(h.isArrowFunction(t.initializer)||h.isFunctionExpression(t.initializer))){let o=t.initializer,s=o.parameters.map(n).join(", "),i=o.type?n(o.type):"unknown";return`(${s}) => ${i}`}return}if(h.isClassDeclaration(t)&&t.name)return`class ${t.name.text}`;if(h.isInterfaceDeclaration(t))return`interface ${t.name.text}`;if(h.isTypeAliasDeclaration(t))return n(t.type);if(h.isEnumDeclaration(t))return`enum ${t.name.text}`}function pf(t,e){ff(t,e),uf(t,e),gf(t,e),df(t,e),Sf(t,e),Os(t,e)}function ff(t,e){if(!h.isSourceFile(t))return;let r=t.statements.filter(n=>!h.isEmptyStatement(n));e.totalStatements=r.length,e.exportStatements=r.filter(n=>h.isExportDeclaration(n)||h.isExportAssignment(n)||Hr(n)).length}function uf(t,e){if(h.isJsxElement(t)||h.isJsxSelfClosingElement(t)||h.isJsxFragment(t)){e.hasUI=!0,e.hasTypesOnly=!1;return}if(h.isFunctionDeclaration(t)||h.isMethodDeclaration(t)||h.isArrowFunction(t)||h.isClassDeclaration(t)||h.isVariableStatement(t)||h.isEnumDeclaration(t)){e.hasTypesOnly=!1;return}h.isExportDeclaration(t)&&!mf(t)&&(e.hasTypesOnly=!1)}function mf(t){return t.isTypeOnly?!0:!t.exportClause||!h.isNamedExports(t.exportClause)?!1:t.exportClause.elements.every(e=>e.isTypeOnly)}function gf(t,e){if(!h.isImportDeclaration(t)||!t.moduleSpecifier||!h.isStringLiteral(t.moduleSpecifier))return;let r=[];if(t.importClause&&(t.importClause.name&&r.push("default"),t.importClause.namedBindings))if(h.isNamedImports(t.importClause.namedBindings))for(let o of t.importClause.namedBindings.elements)r.push(o.name.text);else h.isNamespaceImport(t.importClause.namedBindings)&&r.push("*");let n=r.length>0?"static":"side-effect";e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:t.moduleSpecifier.text,isStyle:A(t.moduleSpecifier.text),type:n,symbols:r.length>0?r:void 0})}function df(t,e){h.isExportDeclaration(t)?hf(t,e):h.isExportAssignment(t)?e.exports.set("default",{name:"default"}):Hr(t)&&bf(t,e)}function hf(t,e){if(t.moduleSpecifier&&h.isStringLiteral(t.moduleSpecifier))yf(t,t.moduleSpecifier.text,e);else if(t.exportClause&&h.isNamedExports(t.exportClause))for(let r of t.exportClause.elements){let n=r.name.text;e.exports.set(n,{name:n})}}function yf(t,e,r){let n=xf(t),o={fromPath:r.filePath,toPath:"",rawSpecifier:e,isStyle:A(e),type:"re-export"};n.length>0&&(o.symbols=n),r.imports.push(o)}function xf(t){return t.exportClause?h.isNamedExports(t.exportClause)?t.exportClause.elements.map(e=>e.name.text):[]:["*"]}function bf(t,e){if((h.isFunctionDeclaration(t)||h.isClassDeclaration(t)||h.isInterfaceDeclaration(t)||h.isTypeAliasDeclaration(t)||h.isEnumDeclaration(t))&&t.name){let n=t.name.text;e.exports.set(n,js(n,t,t,e.sourceFile));return}if(h.isVariableStatement(t)){for(let n of t.declarationList.declarations)if(h.isIdentifier(n.name)){let o=n.name.text;e.exports.set(o,js(o,n,t,e.sourceFile))}}}function Sf(t,e){if(!h.isCallExpression(t))return;let r=t.arguments[0];!r||!h.isStringLiteral(r)||(t.expression.kind===h.SyntaxKind.ImportKeyword?e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:r.text,isStyle:A(r.text),type:"dynamic"}):h.isIdentifier(t.expression)&&t.expression.text==="require"&&e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:r.text,isStyle:A(r.text),type:"require"}))}function Cf(t,e){let r=_s.basename(t).toLowerCase(),n=_s.extname(t).toLowerCase();return ge().some(s=>r.includes(s))?"test":En(r)?"config":e.imports.some(s=>Pt().some(i=>s.rawSpecifier.includes(i)))?"test":n===".tsx"||n===".jsx"||e.hasUI?"ui":e.hasTypesOnly&&e.totalStatements>0?"type-only":e.totalStatements>0&&e.exportStatements/e.totalStatements>Dt()?"barrel":"logic"}function Hr(t){return h.canHaveModifiers(t)&&h.getModifiers(t)?.some(e=>e.kind===h.SyntaxKind.ExportKeyword)===!0}function kf(t,e){let r=t.rawCallEdges??[];t.rawCallEdges=r;let n=new Map;for(let o of e.statements){if(!h.isImportDeclaration(o)||!h.isStringLiteral(o.moduleSpecifier))continue;let s=o.moduleSpecifier.text,i=o.importClause;if(i&&(i.name&&n.set(i.name.text,s),i.namedBindings&&h.isNamedImports(i.namedBindings)))for(let a of i.namedBindings.elements)n.set(a.name.text,s)}if(n.size!==0)for(let o of e.statements){let s=wf(o);if(s){let i=Ef(o);i&&Ct(i,s,n,r);continue}h.isClassDeclaration(o)&&o.name&&vf(o,o.name.text,n,r)}}function vf(t,e,r,n){for(let o of t.members)h.isMethodDeclaration(o)&&o.body&&h.isIdentifier(o.name)?Ct(o.body,`${e}.${o.name.text}`,r,n):h.isConstructorDeclaration(o)&&o.body&&Ct(o.body,`${e}.constructor`,r,n)}function wf(t){if(Hr(t)){if(h.isFunctionDeclaration(t)&&t.name)return t.name.text;if(h.isVariableStatement(t)){for(let e of t.declarationList.declarations)if(h.isIdentifier(e.name)&&e.initializer&&(h.isArrowFunction(e.initializer)||h.isFunctionExpression(e.initializer)))return e.name.text}}}function Ef(t){if(h.isFunctionDeclaration(t))return t.body;if(h.isVariableStatement(t)){for(let e of t.declarationList.declarations)if(e.initializer&&(h.isArrowFunction(e.initializer)||h.isFunctionExpression(e.initializer)))return e.initializer}}function Ct(t,e,r,n){if(h.isCallExpression(t)&&h.isIdentifier(t.expression)){let o=t.expression.text,s=r.get(o);s&&!n.some(i=>i.from===e&&i.to===o&&i.toSpecifier===s)&&n.push({from:e,to:o,toSpecifier:s})}h.forEachChild(t,o=>Ct(o,e,r,n))}var zs=m(()=>{"use strict";l();re();Rs();$();Gs()});function kt(t,e){if(e.length===0)return"ui";let r=!1;return t.walk(n=>{if(n.type==="rule")return r=!0,!1}),r?"ui":"barrel"}var $s=m(()=>{"use strict";l()});function Us(t,e){let r=[],n=/@require\s+['"]([^'"]+)['"]/g,o=n.exec(t);for(;o!==null;){let i=o[1];i&&r.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:"require"}),o=n.exec(t)}let s=/(?<!@)(?:import|require)\s*\(?\s*['"]([^'"]+)['"]/g;for(o=s.exec(t);o!==null;){let i=o[1];i&&r.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:"static"}),o=s.exec(t)}return r}function Bs(t,e){if(e.length===0)return"ui";try{let r=Nt("stylus");return new r.Parser(t).parse().nodes.some(s=>s.constructor.name!=="Import")?"ui":"barrel"}catch{return t.replace(/^\s*@?(?:require|import)\b.*/gm,"").trim().length>0?"ui":"barrel"}}var Js=m(()=>{"use strict";l()});function Ie(t,e){let r=z(t);if(r==="stylus"){let s=Us(e,t);return{imports:s,exports:[],tags:[],category:Bs(e,s)}}if(r==="scss"){let{imports:s,root:i,exports:a,tags:c}=Ve(e,t);return{imports:s,exports:a,tags:c,category:kt(i,s)}}if(r==="less"){let{imports:s,root:i,exports:a,tags:c}=He(e,t);return{imports:s,exports:a,tags:c,category:kt(i,s)}}let{imports:n,root:o}=Ke(e,t);return{imports:n,exports:[],tags:[],category:kt(o,n)}}var Ks=m(()=>{"use strict";l();$();$s();Ht();Vt();Js()});async function Hs(t,e){let r=z(t),n=_o(r);return n?n(t,e):{imports:[],exports:[],tags:[],category:"other"}}var Vs=m(()=>{"use strict";l();$();hs();ys();ks();ws();Ts();Is();Ls();zs();Te();Ks();re();$();Te();for(let[t,e]of[["javascript",(r,n)=>Kr(r,n,"javascript")],["typescript",(r,n)=>Kr(r,n,"typescript")],["css",Ie],["scss",Ie],["less",Ie],["stylus",Ie],["coffeescript",ds],["livescript",vs],["lua",Es],["python",As],["go",Cs],["gherkin",jr],["markdown",Ps]])ce(t,e)});import Qs from"path";function Tf(t,e){let r=e.get(t.path);r!==void 0&&(t.coveragePct=r)}function Xs(t,e){for(let r of t)if(r.isExternal){let n=r.rawSpecifier.startsWith("@")?r.rawSpecifier.split("/").slice(0,2).join("/"):r.rawSpecifier.split("/")[0];n&&!e.some(o=>o.name===n)&&e.push({name:n,kind:"library"})}}function Ff(t,e,r){if(e.isExternal||!e.toPath)return;let n=r.get(e.toPath);n&&(n.category!=="logic"&&n.category!=="barrel"||(n.testedBy??=[],n.testedBy.includes(t.path)||n.testedBy.push(t.path)))}function Nf(t,e){if(t.type==="markdown")for(let r of t.imports){if(r.isExternal||!r.toPath)continue;let n=e.get(r.toPath);!n||n===t||(n.documentedBy??=[],n.documentedBy.includes(t.path)||n.documentedBy.push(t.path),n.category==="logic"&&(n.lastCommitAt??0)>(t.lastCommitAt??0)&&(t.staleFor??=[],t.staleFor.includes(n.path)||t.staleFor.push(n.path)))}}function Ys(t){return Math.round(t*1e4)/1e4}function Pf(t,e){let r=[];for(let n of t.imports){if(n.isExternal||!n.toPath)continue;let o=e.get(n.toPath);if(!o||o.exports.length===0)continue;let s;if(n.symbols===void 0){if(n.type==="side-effect")continue;s=1}else n.symbols.includes("*")?s=1:s=n.symbols.length/o.exports.length;n.exportUsageRatio=Ys(Math.min(1,s)),r.push(n.exportUsageRatio)}r.length>0&&(t.avgExportUsage=Ys(r.reduce((n,o)=>n+o,0)/r.length),t.maxExportUsage=Math.max(...r))}function Vr(t,e,r){e&&(t.some(n=>n.name===e&&n.kind===r)||t.push({name:e,kind:r}))}function If(t,e){let r=e.toPath,n=Qs.basename(r,Qs.extname(r)).replace(/\.(test|spec)$/,"");Vr(t.tags,n,"import")}function Df(t,e){if(!(!e.symbols||e.symbols.includes("*")))for(let r of e.symbols)Vr(t.tags,r,"import")}function Mf(t,e,r){let n=r.get(e.toPath);if(!(!n||n.category==="test"))for(let o of n.tags)o.kind==="comment-marker"&&Vr(t.tags,o.name,"comment-marker")}function Af(t,e,r){!e.toPath||e.isExternal||(If(t,e),Df(t,e),Mf(t,e,r))}function qs(t,e){for(let r of t.values())delete r.testedBy,delete r.documentedBy,delete r.staleFor,r.category==="test"&&(r.tags=r.tags.filter(n=>n.kind!=="import"));for(let r of t.values()){if(Pf(r,t),e.size>0&&Tf(r,e),r.category==="test")for(let n of r.imports)Ff(r,n,t),Af(r,n,t);Nf(r,t)}}var Zs=m(()=>{"use strict";l()});import ri from"fs";import ue from"path";function Lf(t,e){let r=t.split(`
31
- `),n=null,o=new Map,s=!1;for(let i of r){let a=i.trim();if(a.startsWith("module ")){n=a.slice(7).trim();continue}if(/^replace\s*\(/.test(a)){s=!0;continue}if(s&&a===")"){s=!1;continue}if(s&&a.includes("=>")){ei(a,e,o);continue}!s&&/^replace\s+/.test(a)&&a.includes("=>")&&ei(a.replace(/^replace\s+/,""),e,o)}return{mod:n,replaces:o}}function ei(t,e,r){let[n,o]=t.split("=>").map(a=>a.trim());if(!n||!o)return;let s=n.split(/\s+/)[0];if(!o.startsWith(".")&&!o.startsWith("/"))return;let i=ue.isAbsolute(o)?o:ue.resolve(e,o);r.set(s,i)}function ti(t){let e;try{e=ri.readdirSync(t,{withFileTypes:!0})}catch{return null}let r=e.filter(n=>n.isFile()&&n.name.endsWith(".go")&&!n.name.endsWith("_test.go")).map(n=>({path:ue.join(t,n.name),isExternal:!1})).sort((n,o)=>n.path.localeCompare(o.path));return r.length>0?r:null}var De,ni=m(()=>{"use strict";l();De=class{extensions=[".go"];goModCache=new Map;resolve(e,r,n,o){let{mod:s,replaces:i}=this.readGoMod(n);if(!s)return null;let a=this.applyReplace(r,i,n);if(a!==void 0)return ti(a);if(r!==s&&!r.startsWith(`${s}/`))return null;let c=r.slice(s.length).replace(/^\//,"");return c?ti(ue.join(n,c)):null}readGoMod(e){let r=this.goModCache.get(e);if(r!==void 0)return r;let n={mod:null,replaces:new Map};try{let o=ri.readFileSync(ue.join(e,"go.mod"),"utf-8"),s=Lf(o,e);return this.goModCache.set(e,s),s}catch{return this.goModCache.set(e,n),n}}applyReplace(e,r,n){for(let[o,s]of r){if(e===o)return s;if(e.startsWith(`${o}/`)){let i=e.slice(o.length+1);return ue.join(s,i)}}}}});import Rf from"fs";import Qr from"path";var Me,oi=m(()=>{"use strict";l();Me=class{extensions=[".lua"];resolve(e,r,n,o){let s=r.replace(/\./g,Qr.sep),i=[n,Qr.join(n,"lib")];for(let a of i){if(!Rf.existsSync(a))continue;let c=o(Qr.join(a,"_dummy.lua"),s);if(c)return[c]}return null}}});import Of from"path";var Ae,si=m(()=>{"use strict";l();Ae=class{extensions=[".md",".mdx"];resolve(e,r,n,o){let s=o(Of.join(n,"_dummy"),`./${r}`);return s?[s]:null}}});import Gf from"fs";import Yr from"path";function ii(t){try{return Gf.statSync(t,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}var Le,ai=m(()=>{"use strict";l();Le=class{extensions=[".py"];resolve(e,r,n,o){let s=r.replace(/\./g,Yr.sep),i=Yr.join(n,`${s}.py`);if(ii(i))return[{path:i,isExternal:!1}];let a=Yr.join(n,s,"__init__.py");return ii(a)?[{path:a,isExternal:!1}]:null}}});import ci from"path";var _f,Re,li=m(()=>{"use strict";l();_f=["~","http://","https://","//","data:","sass:"],Re=class{extensions=[".css",".scss",".sass",".less",".styl"];resolve(e,r,n,o){if(_f.some(f=>r.startsWith(f)))return null;let s=o(e,r);if(s)return[s];let i=ci.dirname(r),a=ci.basename(r),c=i==="."?`_${a}`:`${i}/_${a}`,p=o(e,c);return p?[p]:null}}});var pi=m(()=>{"use strict";l();ni();oi();si();ai();li()});import vt from"fs";import j from"path";var Z,Xr=m(()=>{"use strict";l();pi();Z=class{constructor(e,r={}){this.rootDir=e;this.workspaceMap=r.workspaceMap??new Map,this.tsconfigSearchPaths=r.tsconfigSearchPaths??[e],this.pathAliases=r.pathAliases,this.langResolvers=r.langResolvers??[new Le,new Me,new De,new Re,new Ae]}rootDir;workspaceMap;tsconfigSearchPaths;pathAliases;langResolvers;resolutionCache=new Map;langBucketFor(e){for(let r=0;r<this.langResolvers.length;r++)if(this.langResolvers[r]?.extensions.some(n=>e.endsWith(n)))return String(r);return"none"}cacheKey(e,r){return`${j.dirname(e)}\0${this.langBucketFor(e)}\0${r}`}resolveAll(e,r){let n=this.cacheKey(e,r),o=this.resolutionCache.get(n);if(o!==void 0)return o??[];let s=this.resolveAllUncached(e,r);return this.resolutionCache.set(n,s.length>0?s:null),s}resolveAllUncached(e,r){let n=this.resolvePathAlias(r);if(n)return[n];if(r.startsWith(".")||r.startsWith("/")){let i=this.resolveLocalPath(e,r);return i?[i]:[]}let o=(i,a)=>this.resolveLocalPath(i,a);for(let i of this.langResolvers)if(i.extensions.some(a=>e.endsWith(a))){let a=i.resolve(e,r,this.rootDir,o);if(a)return a}let s=this.resolveWorkspaceImport(r);return s?[s]:[{path:r,isExternal:!0}]}resolve(e,r){return this.resolveAll(e,r)[0]??null}resolveLocalPath(e,r){let n=j.dirname(e),o=r.startsWith("/")?r:j.resolve(n,r),s=!o.startsWith(this.rootDir),i=["",".ts",".tsx",".js",".jsx",".mjs",".cjs",".css",".scss",".sass",".less",".styl",".coffee",".ls",".lua",".py",".feature",".md",".mdx"],a=o.match(/\.(js|mjs|cjs)$/);if(a){let c=o.slice(0,-a[0].length);for(let p of[".ts",".tsx"]){let f=this.tryExtensions(c,p,s);if(f)return f}}for(let c of i){let p=this.tryExtensions(o,c,s);if(p)return p}return s?{path:o,isExternal:!0}:null}tryExtensions(e,r,n){let o=e+r;if(this.isFile(o))return{path:o,isExternal:n};let s=j.join(e,`index${r}`);if(this.isFile(s))return{path:s,isExternal:n};if(r===".py"){let i=j.join(e,"__init__.py");if(this.isFile(i))return{path:i,isExternal:n}}return null}isFile(e){try{return vt.statSync(e,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}resolvePathAlias(e){if(this.pathAliases)for(let r in this.pathAliases){let n=this.matchAliasPattern(r,e),o=this.pathAliases[r];if(n&&o){let s=this.tryAliasSubstitutions(o,n[1]||"");if(s)return s}}for(let r of this.tsconfigSearchPaths){let n=j.join(r,"tsconfig.json");if(vt.existsSync(n))try{let s=JSON.parse(vt.readFileSync(n,"utf-8")).compilerOptions?.paths;if(!s)continue;for(let i in s){let a=this.matchAliasPattern(i,e);if(a){let c=this.tryAliasSubstitutions(s[i],a[1]||"",r);if(c)return c}}}catch{}}return null}aliasRegexCache=new Map;matchAliasPattern(e,r){let n=this.aliasRegexCache.get(e);if(!n){let o=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace("\\*","(.*)");n=new RegExp(`^${o}$`),this.aliasRegexCache.set(e,n)}return r.match(n)}tryAliasSubstitutions(e,r,n=this.rootDir){let o=["",".ts",".tsx",".js",".jsx",".coffee",".ls",".lua",".feature"];for(let s of e){let i=s.replace("*",r),a=j.resolve(n,i);for(let c of o){let p=this.tryExtensions(a,c,!1);if(p)return p}}return null}resolveWorkspaceImport(e){if(this.workspaceMap.size===0)return null;for(let[r,n]of this.workspaceMap){if(e!==r&&!e.startsWith(`${r}/`))continue;let o=e.slice(r.length),s={path:"",isExternal:!1,isWorkspace:!0,workspacePackage:r};if(!o){for(let a of["src/index.ts","src/index.tsx","index.ts","index.tsx","index.js"]){let c=j.join(n,a);try{if(vt.statSync(c,{throwIfNoEntry:!1})?.isFile())return{...s,path:c}}catch{}}return{...s,path:n}}let i=this.resolveLocalPath(j.join(n,"_dummy"),o.slice(1));return i?{...s,path:i.path}:null}return null}}});import Oe from"fs";import I from"path";import jf from"piscina";function $f(t,e){if(t.length===0)return e;let r=t.map(i=>I.dirname(i).split(I.sep)),n=r[0]??[];for(let i of r.slice(1)){let a=0;for(;a<n.length&&a<i.length&&n[a]===i[a];)a++;n=n.slice(0,a)}let o=n.join(I.sep)||I.sep,s=I.relative(e,o);return s.startsWith("..")||I.isAbsolute(s)?e:o}var Wf,fi,zf,Ge,ui=m(()=>{"use strict";l();Gr();re();Kt();Vs();Zs();Ce();Xr();Wf=["tests","test","__tests__","specs","spec"],fi=new Set(["node_modules",".git","dist","build",".next",".cache","mokosh-cache","coverage"]),zf=600;Ge=class{constructor(e,r=null,n,o,s=!1,i=new Map,a=!0){this.rootDir=e;this.enableGitStats=s;this.coverageMap=i;this.parallelParsing=a;this.previousGraph=r,this.resolver=n||new Z(e),this.lockFile=Wn(e),o&&(this.progressCallback=o)}rootDir;enableGitStats;coverageMap;parallelParsing;graph={nodes:new Map};visited=new Set;queue=[];previousGraph=null;resolver;lockFile=null;progressCallback;pool=null;gitStatsMap=null;async build(e){let r=e.map(n=>I.isAbsolute(n)?n:I.resolve(this.rootDir,n));await this.initPool(),this.enableGitStats&&(this.gitStatsMap=fs(this.rootDir));try{for(let n of r)this.enqueue(n);return await this.drain(),await this.processTestFiles($f(r,this.rootDir)),await this.processDocFiles(),this.progressCallback&&this.visited.size>=100&&process.stderr.write(`
26
+ `;return`${p+y+g+i}
27
+ ${f}`}}});import as from"path";import cs from"typescript";var fp,St,ls=m(()=>{"use strict";l();ue();fp=/\/\/ <mokosh-tags>[\s\S]*?\/\/ <\/mokosh-tags>\n*/,St=class{name="vitest";canHandle(e){return _.has(as.extname(e).toLowerCase())}apply(e,r,n){let o=r.replace(fp,""),s=cs.createSourceFile(as.basename(e),o,cs.ScriptTarget.Latest,!0),i=Ir(s),[a]=i;if(!a)return o;let c=Dr(a,"tags",s),p=[...n].sort();if(c!==null&&JSON.stringify([...c].sort())===JSON.stringify(p))return o;let f=i.flatMap(g=>{let y=n.length===0?Ar(g,"tags",s):Mr(g,"tags",Lr(p),s);return y?[y]:[]});return f.length>0?Rr(o,f):o}}});import zr from"path";import Ct from"typescript";function mp(t){let e=Ct.createSourceFile("detect.ts",t,Ct.ScriptTarget.Latest,!0);for(let r of e.statements){if(!Ct.isImportDeclaration(r)||!Ct.isStringLiteral(r.moduleSpecifier))continue;let n=up[r.moduleSpecifier.text];if(n)return n}return null}function fs(t="vitest",e={},r=process.cwd()){return[new gt,new bt,new ht,new $r(r,t,Object.entries(e))]}function us(t,e){return e.find(r=>r.canHandle(t))??null}var ps,up,$r,ms=m(()=>{"use strict";l();Zo();es();rs();ns();os();ss();is();ue();ls();ps={vitest:()=>new St,playwright:()=>new xt,cypress:()=>new dt,jest:()=>new yt},up={"@playwright/test":"playwright",cypress:"cypress","@jest/globals":"jest",vitest:"vitest"};$r=class{constructor(e,r,n){this.rootDir=e;this.defaultFramework=r;this.frameworkOverrides=n}rootDir;defaultFramework;frameworkOverrides;name="auto";canHandle(e){return _.has(zr.extname(e).toLowerCase())}apply(e,r,n){let o=mp(r)??this.matchOverride(e)??this.defaultFramework;return(ps[o]??ps.vitest)().apply(e,r,n)}matchOverride(e){let r=zr.relative(this.rootDir,e).split(zr.sep).join("/");for(let[n,o]of this.frameworkOverrides)if(ts(n,r))return o;return null}}});import ds from"fs/promises";import dp from"path";async function xp(t,e,r,n){let o;try{o=await ds.readFile(t,"utf8")}catch(a){return{path:t,status:"error",error:String(a)}}let s=us(t,n);if(!s)return{path:t,status:"unchanged"};let i=s.apply(t,o,e);return i===o?{path:t,status:"unchanged"}:(r||await ds.writeFile(t,i,"utf8"),{path:t,status:"updated"})}async function Br(t,e,r){let n=ie(e),o=n.tagApplier?.framework??"vitest",s=n.tagApplier?.frameworkOverrides??{},i=fs(o,s,e),a={updated:0,unchanged:0,errors:0,files:[]};for(let c of t.nodes.values()){if(c.category!=="test")continue;let p=new Set,f=[];for(let x of c.tags)hp.has(x.kind)&&gp.test(x.name)&&(yp.has(x.name.toLowerCase())||p.has(x.name)||(p.add(x.name),f.push(x.name)));f.sort();let g=dp.resolve(e,c.path),y=await xp(g,f,r.dryRun,i);y.path=c.path,a.files.push(y),y.status==="updated"?a.updated++:y.status==="unchanged"?a.unchanged++:a.errors++}return a}var gp,hp,yp,gs=m(()=>{"use strict";l();Bt();ms();gp=/^[a-zA-Z][a-zA-Z0-9_-]{1,}$/,hp=new Set(["import"]),yp=new Set(["common","fixture","fixtures","helper","helpers","index","main","mock","mocks","setup","shared","spec","test","tests","types","util","utils"])});var kt,Ur=m(()=>{"use strict";l();kt=class{isTestNode(e){return e.category==="test"||e.tags.some(r=>r.name==="test")}}});import{execFileSync as Hr}from"child_process";function xs(t,e){let r="",n=0;for(let o of t.split(`
28
+ `)){if(o.startsWith("\0")){let[,c,p]=o.slice(1).split(" ");r=c??"",n=p?Number(p)*1e3:0;continue}if(o==="")continue;let s=o.split(" "),i=s[0];if(!i)continue;let a=i.startsWith("R")||i.startsWith("C")?s[2]:s[1];a&&e(a,r,n)}}function bs(t){let e=new Map;try{let r=Hr("git",["-C",t,"log","--since=90 days ago","--name-status","-M",`--format=${hs}`],{encoding:"utf-8",stdio:["ignore","pipe","ignore"],maxBuffer:ys});xs(r,(n,o,s)=>{let i=e.get(n);if(i){i.commitCount90d+=1;return}e.set(n,{commitCount90d:1,lastAuthor:o||void 0,lastCommitAt:s||void 0})})}catch{return e}try{let r=Hr("git",["-C",t,"log","--name-status","-M",`--format=${hs}`],{encoding:"utf-8",stdio:["ignore","pipe","ignore"],maxBuffer:ys});xs(r,(n,o,s)=>{e.has(n)||e.set(n,{commitCount90d:0,lastAuthor:void 0,lastCommitAt:s||void 0})})}catch{}return e}var vt,hs,ys,Jr=m(()=>{"use strict";l();vt=class{getChangedFiles(e,r){try{let o=[["diff","--name-only"],["diff","--cached","--name-only"],["ls-files","--others","--exclude-standard"],...r?[["diff","--name-only","--end-of-options",`${r}...HEAD`]]:[]].flatMap(s=>{try{return Hr("git",s,{cwd:e,encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).split(`
29
+ `).map(a=>a.trim()).filter(a=>a!=="")}catch{return[]}});return Array.from(new Set(o))}catch(n){return console.error("Error getting git diff:",n),[]}}},hs="%x00%H%x09%ae%x09%at",ys=256*1024*1024});import Ss from"path";function $(t){switch(Ss.extname(t).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 A(t){let e=Ss.extname(t).toLowerCase();return[".css",".scss",".sass",".less",".styl"].includes(e)}var B=m(()=>{"use strict";l()});function U(t){return t.startsWith("'")||t.startsWith('"')?t.slice(1,-1):t}function me(t){let e=new Set,r=/@tag\s+([a-zA-Z0-9_-]+)/g,n=r.exec(t);for(;n!==null;)n[1]&&e.add(n[1]),n=r.exec(t);return e}function de(t,e){let r=t.toLowerCase();return r.includes(".test.")||r.includes(".spec.")||e.has("test")?"test":"logic"}var wt=m(()=>{"use strict";l()});import bp from"coffeescript";function ks(t){if(t){if(typeof t.originalValue=="string")return t.originalValue;if(typeof t.value=="string")return U(t.value)}}function q(t){if(t){if(typeof t.value=="string")return t.value;if(typeof t.base?.value=="string")return t.base.value}}function Sp(t,e){let r=ks(e.source);return r?{fromPath:t,toPath:"",rawSpecifier:r,isStyle:A(r),type:"static"}:null}function Cp(t,e){let r=e.variable?.base?.value==="require",n=ks(e.args?.[0]?.base);return!r||!n?null:{fromPath:t,toPath:"",rawSpecifier:n,isStyle:A(n),type:"require"}}function Cs(t,e){if(e)return[{name:e}];let r=t.value;if(r?.constructor?.name==="Class"){let o=q(r.variable);return o?[{name:o}]:[]}if(r?.base?.constructor?.name==="Obj"&&Array.isArray(r.base.properties))return r.base.properties.map(o=>q(o.variable)??q(o)).filter(o=>!!o).map(o=>({name:o}));let n=q(r);return n?[{name:n}]:[]}function kp(t){if(Array.isArray(t.specifiers))return t.specifiers.map(r=>r.identifier??r.original?.value).filter(r=>!!r).map(r=>({name:r}));let e=q(t.variable)??q(t.variable?.base);return e?[{name:e}]:[]}function vp(t,e,r,n){let o=e.constructor?.name;if(o==="ImportDeclaration"){let s=Sp(t,e);s&&r.push(s)}else if(o==="Call"){let s=Cp(t,e);s&&r.push(s)}else if(o==="Assign"){let s=q(e.variable?.base),i=e.variable?.properties?.[0]?.name?.value;s==="module"&&i==="exports"?n.push(...Cs(e,void 0)):s==="exports"&&typeof i=="string"&&n.push(...Cs(e,i))}else o==="ExportNamedDeclaration"&&e.clause?n.push(...kp(e.clause)):o==="ExportDefaultDeclaration"&&n.push({name:"default"})}function Kr(t,e,r,n){if(!(!e||typeof e!="object")){vp(t,e,r,n);for(let o in e){if(o==="locationData")continue;let s=e[o];if(!(!s||typeof s!="object"))if(Array.isArray(s))for(let i of s)Kr(t,i,r,n);else Kr(t,s,r,n)}}}function vs(t,e){let r=me(e),n=de(t,r),o=[],s=[];try{Kr(t,bp.nodes(e),o,s)}catch{}let i=new Set,a=s.filter(c=>i.has(c.name)?!1:(i.add(c.name),!0));return{imports:o,exports:a,tags:Array.from(r).map(c=>({name:c,kind:"comment-marker"})),category:n}}var ws=m(()=>{"use strict";l();B();wt()});import{AstBuilder as wp,GherkinClassicTokenMatcher as Tp,Parser as Ep}from"@cucumber/gherkin";import{IdGenerator as Fp}from"@cucumber/messages";function Vr(t,e){let r=new Set;try{let n=new wp(Np),o=new Tp,i=new Ep(n,o).parse(e);i.feature&&(i.feature.tags.forEach(a=>{r.add(a.name.startsWith("@")?a.name.slice(1):a.name)}),i.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(n){console.warn(`[GherkinParser] Failed to parse ${t}:`,n)}return{imports:[],exports:[],tags:Array.from(r).map(n=>({name:n,kind:"comment-marker"})),category:"test"}}var Np,Ts=m(()=>{"use strict";l();Ie();Np=Fp.uuid();fe("gherkin",Vr)});function Z(t){let e=[],r=t.firstChild;for(;r;)e.push(r),r=r.nextSibling;return e}function Me(t,e){let r=1;for(let n=0;n<e&&n<t.length;n++)t[n]===`
30
+ `&&r++;return r}var Qr=m(()=>{"use strict";l()});function Pp(t,e){let r=1;function n(o){switch(o.type.name){case"IfStatement":case"ForStatement":r++;break;case"Case":{o.firstChild?.type.name==="case"&&r++;break}case"LogicOp":{let i=e.slice(o.from,o.to);(i==="&&"||i==="||")&&r++;break}}let s=o.firstChild;for(;s;)n(s),s=s.nextSibling}return n(t),r}function Fs(t,e,r,n){let o=r?1:1+e,s=Z(t),i=r?e:e+1,a=s[1];a&&a.type.name!=="Block"&&(o+=ge(a,i,!1,n));let c=s.find(f=>f.type.name==="Block");c&&(o+=ge(c,i,!1,n));let p=s.findIndex(f=>f.type.name==="else");if(p>=0){let f=s[p+1];f?.type.name==="IfStatement"?o+=Fs(f,e,!0,n):f&&(o+=1+ge(f,e+1,!1,n))}return o}function Es(t,e,r){let n=1+e,o=t.firstChild;for(;o;)n+=ge(o,e+1,!1,r),o=o.nextSibling;return n}function Ip(t,e,r){let n=0,o=t.firstChild;for(;o;)n+=ge(o,e,!1,r),o=o.nextSibling;return n}function Dp(t,e){let r=e.slice(t.from,t.to);return r==="&&"||r==="||"}function ge(t,e,r,n){let o=t.type.name;if(o==="IfStatement")return Fs(t,e,r,n);if(o==="ForStatement"||o==="SwitchStatement"||o==="SelectStatement")return Es(t,e,n);let s=o==="LogicOp"&&Dp(t,n)?1:0;return e>0&&o==="FunctionLiteral"?s+Es(t,e,n):s+Ip(t,e,n)}function Mp(t,e){return ge(t,0,!1,e)}function Tt(t,e){return{complexity:Pp(t,e),cognitiveComplexity:Mp(t,e)}}function Yr(t,e){let n=t.getChild("Parameters")?.getChild("Parameter"),o=n?.getChild("TypeName")??n?.getChild("PointerType")?.getChild("TypeName");return o?e.slice(o.from,o.to):void 0}function Ns(t,e){let r=[],n=t.cursor();do if(n.name==="FunctionDecl"){let o=n.node.getChild("DefName");if(o){let s=e.slice(o.from,o.to),{complexity:i,cognitiveComplexity:a}=Tt(n.node,e);r.push({name:s,line:Me(e,n.from),complexity:i,cognitiveComplexity:a})}}else if(n.name==="MethodDecl"){let o=n.node.getChild("FieldName");if(o){let s=e.slice(o.from,o.to),i=Yr(n.node,e),a=i?`${i}.${s}`:s,{complexity:c,cognitiveComplexity:p}=Tt(n.node,e);r.push({name:a,line:Me(e,n.from),complexity:c,cognitiveComplexity:p})}}while(n.next());return r}var Ps=m(()=>{"use strict";l();Qr()});import Ap from"path";import{parser as Rp}from"@lezer/go";function Ds(t,e){let r=[],n=new Map,o=new Set,s=new Set,i=new Map,a=Rp.parse(e),c=a.cursor();do switch(c.name){case"LineComment":{let b=e.slice(c.from,c.to),v=b.match(Lp);v?.[1]&&o.add(v[1]);let G=b.match(Op);G&&Is(G[1],s);let O=b.match(Gp);O&&Is(O[1],s);break}case"ImportSpec":{let b=c.node.getChild("String");if(b){let G=e.slice(b.from,b.to).slice(1,-1);r.push({fromPath:t,toPath:"",rawSpecifier:G,isExternal:!0,isStyle:!1,type:"static"});let O=c.node.getChild("DefName"),J=O?e.slice(O.from,O.to):G.split("/").pop();J&&J!=="_"&&J!=="."&&i.set(J,G)}break}case"FunctionDecl":case"MethodDecl":case"TypeDecl":case"VarDecl":case"ConstDecl":{let b=c.node.getChild("DefName")??c.node.getChild("FieldName")??c.node.getChild("TypeSpec")?.getChild("DefName")??c.node.getChild("VarSpec")?.getChild("DefName")??c.node.getChild("ConstSpec")?.getChild("DefName");if(b){let v=e.slice(b.from,b.to);v!=="_"&&/^[A-Z]/.test(v)&&!n.has(v)&&n.set(v,{name:v})}break}}while(c.next());let p=r.some(b=>b.rawSpecifier==="testing"),f=Ap.basename(t).endsWith("_test.go")||o.has("test")||p?"test":"logic",g=new Set([...o,...s]),{complexity:y,cognitiveComplexity:x}=Tt(a.topNode,e),w=Ns(a,e),E=f==="test"?[]:_p(a,e,i);return{imports:r,exports:Array.from(n.values()),tags:Array.from(g).map(b=>({name:b,kind:"comment-marker"})),category:f,rawCallEdges:E,complexity:y,cognitiveComplexity:x,...w.length>0?{functions:w}:{}}}function _p(t,e,r){let n=[];function o(i,a){if(i.type.name==="CallExpr"){let p=i.firstChild;if(p?.type.name==="SelectorExpr"){let f=p.firstChild,g=p.getChild("FieldName");if(f?.type.name==="VariableName"&&g){let y=e.slice(f.from,f.to),x=r.get(y);if(x){let w=e.slice(g.from,g.to);n.push({from:a,to:w,toSpecifier:x})}}}}let c=i.firstChild;for(;c;)o(c,a),c=c.nextSibling}let s=t.cursor();do if(s.name==="FunctionDecl"){let i=s.node.getChild("DefName"),a=s.node.getChild("Block");if(i&&a){let c=e.slice(i.from,i.to);/^[A-Z]/.test(c)&&o(a,c)}}else if(s.name==="MethodDecl"){let i=s.node.getChild("FieldName"),a=s.node.getChild("Block");if(i&&a){let c=e.slice(i.from,i.to),p=Yr(s.node,e);o(a,p?`${p}.${c}`:c)}}while(s.next());return n}function Is(t,e){for(let r of t.split(/[\s,&|!()]+/)){let n=r.trim();n&&n!=="ignore"&&e.add(n)}}var Lp,Op,Gp,Ms=m(()=>{"use strict";l();Ps();Lp=/\/\/\s*@tag\s+([a-zA-Z0-9_-]+)/,Op=/^\/\/go:build\s+(.+)$/,Gp=/^\/\/\s*\+build\s+(.+)$/});import jp from"livescript";function ee(t){if(t){if(typeof t.value=="string")return t.value;if(typeof t.base?.value=="string")return t.base.value}}function Wp(t){if(!t)return[];if(t.constructor?.name==="Class"){let r=ee(t.title);return r?[{name:r}]:[]}if(t.constructor?.name==="Obj"&&Array.isArray(t.items))return t.items.map(r=>ee(r.key)??ee(r.val)).filter(r=>!!r).map(r=>({name:r}));let e=ee(t);return e?[{name:e}]:[]}function zp(t){let e=t.constructor?.name||t.type;if(e==="Assign"&&t.left?.constructor?.name==="Chain"){let r=t.left,n=ee(r.head),s=r.tails?.[0]?.key?.name;if(n==="module"&&s==="exports")return Wp(t.right);if(n==="exports"&&typeof s=="string")return[{name:s}];if(r.head?.verb==="out"&&typeof s=="string")return[{name:s}]}if(e==="Import"&&t.left?.verb==="out"){let r=t.right;if(r?.constructor?.name==="Obj"&&Array.isArray(r.items))return r.items.map(n=>ee(n.val)??ee(n.key)).filter(n=>!!n).map(n=>({name:n}))}return[]}function Bp(t,e){let r=t.constructor?.name||t.type;if(r==="Import"){let n=t.right?.value;if(typeof n=="string"){let o=U(n);return{fromPath:e,toPath:"",rawSpecifier:o,isStyle:A(o),type:"static"}}}if(r==="Chain"&&t.head?.value==="require"){let n=t.tails?.[0];if(n?.constructor?.name==="Call"||n?.type==="Call"){let o=n.args?.[0]?.value;if(typeof o=="string"){let s=U(o);return{fromPath:e,toPath:"",rawSpecifier:s,isStyle:A(s),type:"require"}}}}return null}function Xr(t,e,r){if(!t||typeof t!="object")return[];let n=[],o=Bp(t,e);o&&n.push(o),r.push(...zp(t));for(let s in t){if($p.has(s))continue;let i=t[s];if(!(!i||typeof i!="object"))if(Array.isArray(i))for(let a of i)n.push(...Xr(a,e,r));else n.push(...Xr(i,e,r))}return n}function As(t,e){let r=me(e),n=de(t,r),o=[],s=[];try{o=Xr(jp.ast(e),t,s)}catch{}let i=new Set,a=s.filter(c=>i.has(c.name)?!1:(i.add(c.name),!0));return{imports:o,exports:a,tags:Array.from(r).map(c=>({name:c,kind:"comment-marker"})),category:n}}var $p,Rs=m(()=>{"use strict";l();B();wt();$p=new Set(["first_line","first_column","last_line","last_column","line","column"])});import Up from"luaparse";function Hp(t,e){let r=[];function n(o){if(!(!o||typeof o!="object")){if((o.type==="CallExpression"||o.type==="StringCallExpression")&&o.base?.type==="Identifier"&&o.base?.name==="require"){let s;if(o.type==="CallExpression"){let i=o.arguments?.[0];i?.type==="StringLiteral"&&(s=U(i.raw))}else if(o.type==="StringCallExpression"){let i=o.argument;i?.type==="StringLiteral"&&(s=U(i.raw))}s&&r.push({fromPath:e,toPath:"",rawSpecifier:s,isStyle:A(s),type:"require"})}for(let s in o){if(s==="loc")continue;let i=o[s];if(i&&typeof i=="object")if(Array.isArray(i))for(let a of i)n(a);else n(i)}}}return n(t),r}function Jp(t){let e=new Set;for(let r of t)r.type==="LocalStatement"&&r.variables.forEach((n,o)=>{r.init[o]?.type==="TableConstructorExpression"&&e.add(n.name)});return e}function Kp(t){let e=t[t.length-1];if(e?.type!=="ReturnStatement")return[];let r=e.arguments[0];if(r?.type!=="TableConstructorExpression")return[];let n=[];for(let o of r.fields)o.type==="TableKeyString"&&n.push({name:o.key.name});return n}function Vp(t){let e=t.body,r=Jp(e),n=Kp(e);for(let s of e)if(s.type==="FunctionDeclaration")s.identifier?.type==="MemberExpression"?s.identifier.base.type==="Identifier"&&r.has(s.identifier.base.name)&&n.push({name:s.identifier.identifier.name}):s.identifier?.type==="Identifier"&&!s.isLocal&&n.push({name:s.identifier.name});else if(s.type==="AssignmentStatement")for(let i of s.variables)i.type==="MemberExpression"&&i.base.type==="Identifier"&&r.has(i.base.name)&&n.push({name:i.identifier.name});let o=new Set;return n.filter(s=>o.has(s.name)?!1:(o.add(s.name),!0))}function Ls(t,e){let r=me(e),n=de(t,r),o=[],s=[];try{let i=Up.parse(e);o=Hp(i,t),s=Vp(i)}catch{}return{imports:o,exports:s,tags:Array.from(r).map(i=>({name:i,kind:"comment-marker"})),category:n}}var Os=m(()=>{"use strict";l();B();wt()});async function qp(){return Gs??=(async()=>{let{unified:t}=await import("unified"),e=(await import("remark-parse")).default;return t().use(e)})(),Gs}function Zp(t){let e=t.trim();return e.length===0||e.startsWith("#")||Qp.some(r=>e.startsWith(r))}function ef(t,e){let r=t.match(Xp);return r?r.map(n=>({fromPath:e,toPath:"",rawSpecifier:n,isStyle:!1,type:"static"})):[]}function _s(t,e,r){if(t.type==="link"&&typeof t.url=="string"&&!Zp(t.url)&&r.push({fromPath:e,toPath:"",rawSpecifier:t.url,isStyle:!1,type:"static"}),(t.type==="code"||t.type==="inlineCode")&&typeof t.value=="string"&&r.push(...ef(t.value,e)),Array.isArray(t.children))for(let n of t.children)_s(n,e,r)}async function js(t,e){let n=(await qp()).parse(e),o=[];_s(n,t,o);let s=new Set;return{imports:o.filter(a=>s.has(a.rawSpecifier)?!1:(s.add(a.rawSpecifier),!0)),exports:[],tags:[],category:"other"}}var Qp,Yp,Xp,Gs,Ws=m(()=>{"use strict";l();Qp=["http://","https://","mailto:","//"],Yp="ts|tsx|js|jsx|mjs|cjs|py|go|lua|css|scss|less|styl|coffee|ls|feature|md|mdx|json",Xp=new RegExp(`(?:\\.{1,2}/)?[\\w.-]+(?:/[\\w.-]+)*\\.(?:${Yp})\\b`,"g")});function tf(t){let e=1;function r(n){switch(n.type.name){case"IfStatement":{e+=Z(n).filter(s=>s.type.name==="if"||s.type.name==="elif").length;break}case"TryStatement":{e+=Z(n).filter(s=>s.type.name==="except").length;break}case"ForStatement":case"WhileStatement":case"ConditionalExpression":e++;break;case"and":case"or":e++;break}let o=n.firstChild;for(;o;)r(o),o=o.nextSibling}return r(t),e}function rf(t,e){let r=0,n=Z(t),o=0,s=0;for(;s<n.length;){let i=n[s];if(i?.type.name==="if"||i?.type.name==="elif"){let a=o>0;r+=a?1:1+e;let c=a?e:e+1,p=n[s+1],f=n[s+2];p&&(r+=j(p,c)),f&&(r+=j(f,c)),o++,s+=3}else if(i?.type.name==="else"){r+=1;let a=n[s+1];a&&(r+=j(a,e+1)),s+=2}else s++}return r}function nf(t,e){let r=0,n=Z(t),o=0;for(;o<n.length;){let s=n[o];if(s?.type.name==="except"){for(r+=1+e,o++;o<n.length&&n[o]?.type.name!=="Body";)r+=j(n[o],e),o++;o<n.length&&(r+=j(n[o],e),o++)}else s?.type.name==="Body"&&(r+=j(s,e)),o++}return r}function zs(t,e){let r=1+e,n=t.firstChild;for(;n;)r+=j(n,e+1),n=n.nextSibling;return r}function of(t,e){let r=0,n=t.firstChild;for(;n;)r+=j(n,e),n=n.nextSibling;return r}function j(t,e){let r=t.type.name;if(r==="IfStatement")return rf(t,e);if(r==="TryStatement")return nf(t,e);if(r==="ForStatement"||r==="WhileStatement")return zs(t,e);let n=r==="ConditionalExpression"||r==="and"||r==="or"?1:0;return e>0&&(r==="FunctionDefinition"||r==="LambdaExpression")?n+zs(t,e):n+of(t,e)}function sf(t){return j(t,0)}function qr(t){return{complexity:tf(t),cognitiveComplexity:sf(t)}}function $s(t,e){let r=[];function n(i,a){let{complexity:c,cognitiveComplexity:p}=qr(i);r.push({name:a,line:Me(e,i.from),complexity:c,cognitiveComplexity:p})}function o(i){let a=i.firstChild;for(;a;)s(a),a=a.nextSibling}function s(i){if(i.type.name==="ClassDefinition"){let a=i.getChild("VariableName"),c=a?e.slice(a.from,a.to):void 0,p=i.getChild("Body");if(p){let f=p.firstChild;for(;f;){if(f.type.name==="FunctionDefinition"){let g=f.getChild("VariableName"),y=g?e.slice(g.from,g.to):void 0;y&&n(f,c?`${c}.${y}`:y),o(f)}else s(f);f=f.nextSibling}}return}if(i.type.name==="FunctionDefinition"){let a=i.getChild("VariableName");a&&n(i,e.slice(a.from,a.to)),o(i);return}o(i)}return s(t.topNode),r}var Bs=m(()=>{"use strict";l();Qr()});import af from"path";import{parser as cf}from"@lezer/python";function Us(t,e){let r=[],n=[],o=new Set,s=af.basename(t).toLowerCase(),i=cf.parse(e),a=i.cursor();do switch(a.name){case"Comment":{let x=e.slice(a.from,a.to).match(/#\s*@tag\s+([a-zA-Z0-9_-]+)/);x?.[1]&&o.add(x[1]);break}case"ImportStatement":{for(let x of pf(a.node,e,t))r.push(x);break}case"FunctionDefinition":case"ClassDefinition":{let x=a.node.parent;if(x?.name==="Script"||x?.name==="DecoratedStatement"&&x.parent?.name==="Script"){let E=a.node.getChild("VariableName");E&&n.push({name:e.slice(E.from,E.to)})}break}case"AssignStatement":{if(a.node.parent?.name==="Script"){let x=a.node.firstChild;x?.name==="VariableName"&&n.push({name:e.slice(x.from,x.to)})}break}}while(a.next());let c=hf(s,r,o);c==="test"&&o.add("test");let{complexity:p,cognitiveComplexity:f}=qr(i.topNode),g=$s(i,e),y=c==="test"?[]:gf(i,e);return{imports:r,exports:n,tags:Array.from(o).map(x=>({name:x,kind:"comment-marker"})),category:c,rawCallEdges:y,complexity:p,cognitiveComplexity:f,...g.length>0?{functions:g}:{}}}function pf(t,e,r){let n=t.firstChild;return n?n.name==="from"?ff(t,e,r):uf(t,e,r):[]}function ff(t,e,r){let n=t.firstChild;if(!n)return[];let o=n.nextSibling;for(;o&&o.name!=="import";)o=o.nextSibling;if(!o)return[];let s=e.slice(n.to,o.from).trim(),i=mf(o.nextSibling,e);if(!i.length)return[];let a=0;for(;a<s.length&&s[a]===".";)a++;let c=s.slice(a);if(a===0)return[Ae(r,s,i,!0)];let p=a===1?"./":"../".repeat(a-1);return c?[Ae(r,p+c.replace(/\./g,"/"),i,!1)]:i[0]==="*"?[Ae(r,p.slice(0,-1),["*"],!1)]:i.map(f=>Ae(r,p+f,[f],!1))}function uf(t,e,r){let n=[],o=t.firstChild?.nextSibling??null;for(;o;){if(o.name==="VariableName"){let s=e.slice(o.from,o.to);for(;o.nextSibling?.name==="."&&o.nextSibling.nextSibling?.name==="VariableName";)o=o.nextSibling.nextSibling,s+=`.${e.slice(o.from,o.to)}`;o.nextSibling?.name==="as"&&(o=o.nextSibling.nextSibling??o.nextSibling),n.push(Ae(r,s,["*"],!0))}o=o.nextSibling}return n}function mf(t,e){let r=[],n=t;for(;n;)n.name==="*"?r.push("*"):n.name==="VariableName"&&(r.push(e.slice(n.from,n.to)),n.nextSibling?.name==="as"&&(n=n.nextSibling.nextSibling??n.nextSibling)),n=n.nextSibling;return r}function df(t,e){let r=new Map,n=t.cursor();do{if(n.name!=="ImportStatement")continue;let s=n.node.firstChild;if(s?.type.name!=="from")continue;let i=s.nextSibling;for(;i&&i.type.name!=="import";)i=i.nextSibling;if(!i)continue;let a=e.slice(s.to,i.from).trim(),c=0;for(;c<a.length&&a[c]===".";)c++;let p=a.slice(c),f=c<=1?"./":"../".repeat(c-1),g=i.nextSibling;for(;g;){if(g.type.name==="VariableName"){let y=e.slice(g.from,g.to),x=y;if(g.nextSibling?.type.name==="as"){let E=g.nextSibling.nextSibling;E?.type.name==="VariableName"&&(x=e.slice(E.from,E.to),g=E)}let w=c===0?a:p?f+p.replace(/\./g,"/"):f+y;r.set(x,w)}g=g.nextSibling}}while(n.next());return r}function gf(t,e){let r=df(t,e),n=[];function o(a,c){if(a.type.name==="CallExpression"&&a.firstChild?.type.name==="VariableName"){let f=a.firstChild,g=e.slice(f.from,f.to),y=r.get(g);y&&n.push({from:c,to:g,toSpecifier:y})}let p=a.firstChild;for(;p;)o(p,c),p=p.nextSibling}function s(a){let c=a.firstChild;for(;c;)i(c),c=c.nextSibling}function i(a){if(a.type.name==="ClassDefinition"){let c=a.getChild("VariableName"),p=c?e.slice(c.from,c.to):void 0,f=a.getChild("Body");if(f){let g=f.firstChild;for(;g;){if(g.type.name==="FunctionDefinition"){let y=g.getChild("VariableName"),x=y?e.slice(y.from,y.to):void 0;x&&o(g,p?`${p}.${x}`:x)}else i(g);g=g.nextSibling}}return}if(a.type.name==="FunctionDefinition"){let c=a.getChild("VariableName");c&&o(a,e.slice(c.from,c.to));return}s(a)}return i(t.topNode),n}function Ae(t,e,r,n){return{fromPath:t,toPath:"",rawSpecifier:e,isStyle:!1,isExternal:n,type:"static",symbols:r.length>0?r:void 0}}function hf(t,e,r){return t.startsWith("test_")||t.endsWith("_test.py")?"test":t==="conftest.py"||t==="setup.py"?"config":r.has("test")||e.some(n=>lf.has(n.rawSpecifier))?"test":"logic"}var lf,Hs=m(()=>{"use strict";l();Bs();lf=new Set(["pytest","unittest","nose","hypothesis"])});import S from"typescript";function yf(t){let e=1;function r(n){switch(n.kind){case S.SyntaxKind.IfStatement:case S.SyntaxKind.ConditionalExpression:case S.SyntaxKind.ForStatement:case S.SyntaxKind.ForInStatement:case S.SyntaxKind.ForOfStatement:case S.SyntaxKind.WhileStatement:case S.SyntaxKind.DoStatement:case S.SyntaxKind.CatchClause:case S.SyntaxKind.CaseClause:e++;break;case S.SyntaxKind.BinaryExpression:{let o=n.operatorToken.kind;(o===S.SyntaxKind.AmpersandAmpersandToken||o===S.SyntaxKind.BarBarToken||o===S.SyntaxKind.QuestionQuestionToken)&&e++;break}}S.forEachChild(n,r)}return r(t),e}function Ks(t,e,r){let n=r?1:1+e,o=r?e:e+1;return n+=te(t.expression,o,!1),n+=te(t.thenStatement,o,!1),t.elseStatement&&(S.isIfStatement(t.elseStatement)?n+=Ks(t.elseStatement,e,!0):n+=1+te(t.elseStatement,e+1,!1)),n}function Js(t,e){let r=1+e;return S.forEachChild(t,n=>{r+=te(n,e+1,!1)}),r}function xf(t,e){let r=1+e;return S.forEachChild(t,n=>{r+=te(n,e,!1)}),r}function bf(t,e){let r=0;return S.forEachChild(t,n=>{r+=te(n,e,!1)}),r}function Sf(t){let e=t.operatorToken.kind;return e===S.SyntaxKind.AmpersandAmpersandToken||e===S.SyntaxKind.BarBarToken||e===S.SyntaxKind.QuestionQuestionToken}function te(t,e,r){if(S.isIfStatement(t))return Ks(t,e,r);if(S.isForStatement(t)||S.isForInStatement(t)||S.isForOfStatement(t)||S.isWhileStatement(t)||S.isDoStatement(t)||S.isSwitchStatement(t))return Js(t,e);if(S.isCatchClause(t))return xf(t,e);let n=0;return S.isConditionalExpression(t)&&(n+=1),S.isBinaryExpression(t)&&Sf(t)&&(n+=1),e>0&&(S.isFunctionDeclaration(t)||S.isFunctionExpression(t)||S.isArrowFunction(t))?n+Js(t,e):n+bf(t,e)}function Cf(t){return te(t,0,!1)}function Zr(t){return{complexity:yf(t),cognitiveComplexity:Cf(t)}}var Vs=m(()=>{"use strict";l()});import T from"typescript";function Qs(t,e){kf(t,e),wf(t,e),Tf(t,e),Ef(t,e)}function kf(t,e){if((T.isFunctionDeclaration(t)||T.isVariableDeclaration(t))&&t.name&&T.isIdentifier(t.name)&&vf(t)){let r;if(T.isFunctionDeclaration(t))r="function";else{let n=t.initializer;r=n&&(T.isArrowFunction(n)||T.isFunctionExpression(n))?"function":"variable"}e.tags.add({name:t.name.text,kind:r})}}function vf(t){if(T.isFunctionDeclaration(t))return T.isSourceFile(t.parent);let e=t.parent?.parent;return!!e&&T.isSourceFile(e.parent)}function wf(t,e){if(!T.isStringLiteral(t))return;let r=t.text.match(/@[\w-]+/g);if(r)for(let n of r)e.tags.add({name:n.substring(1),kind:"comment-marker"})}function Tf(t,e){if(!T.isSourceFile(t))return;let r=/@tag\s+([a-zA-Z0-9_-]+)/g,n=t.getFullText(),o=r.exec(n);for(;o!==null;)o[1]&&e.tags.add({name:o[1],kind:"comment-marker"}),o=r.exec(n)}function Ef(t,e){if(T.isCallExpression(t)&&Ff(t.expression))for(let r of t.arguments)T.isObjectLiteralExpression(r)&&Nf(r,e)}function Ff(t){return T.isIdentifier(t)?en.has(t.text):!!(T.isPropertyAccessExpression(t)&&(en.has(t.name.text)||T.isIdentifier(t.expression)&&en.has(t.expression.text)))}function Nf(t,e){for(let r of t.properties){if(!T.isPropertyAssignment(r)||!T.isIdentifier(r.name)||r.name.text!=="tags"&&r.name.text!=="tag")continue;let{initializer:n}=r,o=T.isArrayLiteralExpression(n)?n.elements.filter(T.isStringLiteral):r.name.text==="tag"&&T.isStringLiteral(n)?[n]:[];for(let s of o)e.tags.add({name:s.text.replace(/^@/,""),kind:"comment-marker"})}}var en,Ys=m(()=>{"use strict";l();en=new Set(["test","describe","it"])});import Xs from"path";import h from"typescript";function tn(t,e,r){let n=[],o=new Map,s=new Set,i=h.createSourceFile(t,e,h.ScriptTarget.Latest,!0,r==="typescript"?h.ScriptKind.TSX:h.ScriptKind.JSX),a={filePath:t,imports:n,exports:o,tags:s,rawCallEdges:[],sourceFile:i,hasUI:!1,hasTypesOnly:!0,totalStatements:0,exportStatements:0},c=E=>{Mf(E,a),h.forEachChild(E,c)};c(i);let p=Bf(t,a);(p==="test"||p==="barrel")&&s.add({name:p,kind:"comment-marker"}),p!=="test"&&Uf(a,i);let f=i.statements[0],g=f?Zs(f):void 0,{complexity:y,cognitiveComplexity:x}=Zr(i),w=Pf(i);return{imports:n,exports:Array.from(o.values()),tags:Array.from(s),category:p,rawCallEdges:a.rawCallEdges??[],complexity:y,cognitiveComplexity:x,...w.length>0?{functions:w}:{},...g!==void 0?{description:g}:{}}}function Pf(t){let e=[],r=(o,s)=>{let{complexity:i,cognitiveComplexity:a}=Zr(s),c=t.getLineAndCharacterOfPosition(s.getStart(t)).line+1;e.push({name:o,line:c,complexity:i,cognitiveComplexity:a})},n=(o,s)=>{if(h.isFunctionDeclaration(o)&&o.name&&o.body?r(o.name.text,o):h.isVariableDeclaration(o)&&h.isIdentifier(o.name)&&o.initializer&&(h.isArrowFunction(o.initializer)||h.isFunctionExpression(o.initializer))?r(o.name.text,o.initializer):s&&h.isMethodDeclaration(o)&&h.isIdentifier(o.name)&&o.body?r(`${s}.${o.name.text}`,o):s&&h.isConstructorDeclaration(o)&&o.body?r(`${s}.constructor`,o):s&&h.isGetAccessorDeclaration(o)&&h.isIdentifier(o.name)&&o.body?r(`${s}.get ${o.name.text}`,o):s&&h.isSetAccessorDeclaration(o)&&h.isIdentifier(o.name)&&o.body&&r(`${s}.set ${o.name.text}`,o),h.isClassDeclaration(o)&&o.name){let i=o.name.text;h.forEachChild(o,a=>n(a,i));return}h.forEachChild(o,i=>n(i,s))};return n(t,void 0),e}function qs(t,e,r,n){let o={name:t},s=Zs(r);s!==void 0&&(o.doc=s);let i=If(e);i!==void 0&&(o.flags=i);let a=Df(e,n);return a!==void 0&&(o.signature=a),o}function Zs(t){let e=h.getJSDocCommentsAndTags(t);for(let r of e)if(h.isJSDoc(r)&&r.comment)return h.getTextOfJSDocComment(r.comment)||void 0}function If(t){let e=new Set(["deprecated","internal","public","alpha","beta"]),r=h.getJSDocTags(t).map(n=>n.tagName.text).filter(n=>e.has(n));return r.length>0?r:void 0}function Df(t,e){let r=h.createPrinter({removeComments:!0}),n=o=>r.printNode(h.EmitHint.Unspecified,o,e);if(h.isFunctionDeclaration(t)||h.isMethodDeclaration(t)){let o=t.parameters.map(n).join(", "),s=t.type?n(t.type):"void";return`${t.typeParameters?`<${t.typeParameters.map(a=>a.name.text).join(", ")}>`:""}(${o}) => ${s}`}if(h.isVariableDeclaration(t)){if(t.type)return n(t.type);if(t.initializer&&(h.isArrowFunction(t.initializer)||h.isFunctionExpression(t.initializer))){let o=t.initializer,s=o.parameters.map(n).join(", "),i=o.type?n(o.type):"unknown";return`(${s}) => ${i}`}return}if(h.isClassDeclaration(t)&&t.name)return`class ${t.name.text}`;if(h.isInterfaceDeclaration(t))return`interface ${t.name.text}`;if(h.isTypeAliasDeclaration(t))return n(t.type);if(h.isEnumDeclaration(t))return`enum ${t.name.text}`}function Mf(t,e){Af(t,e),Rf(t,e),Of(t,e),Gf(t,e),$f(t,e),Qs(t,e)}function Af(t,e){if(!h.isSourceFile(t))return;let r=t.statements.filter(n=>!h.isEmptyStatement(n));e.totalStatements=r.length,e.exportStatements=r.filter(n=>h.isExportDeclaration(n)||h.isExportAssignment(n)||rn(n)).length}function Rf(t,e){if(h.isJsxElement(t)||h.isJsxSelfClosingElement(t)||h.isJsxFragment(t)){e.hasUI=!0,e.hasTypesOnly=!1;return}if(h.isFunctionDeclaration(t)||h.isMethodDeclaration(t)||h.isArrowFunction(t)||h.isClassDeclaration(t)||h.isVariableStatement(t)||h.isEnumDeclaration(t)){e.hasTypesOnly=!1;return}h.isExportDeclaration(t)&&!Lf(t)&&(e.hasTypesOnly=!1)}function Lf(t){return t.isTypeOnly?!0:!t.exportClause||!h.isNamedExports(t.exportClause)?!1:t.exportClause.elements.every(e=>e.isTypeOnly)}function Of(t,e){if(!h.isImportDeclaration(t)||!t.moduleSpecifier||!h.isStringLiteral(t.moduleSpecifier))return;let r=[];if(t.importClause&&(t.importClause.name&&r.push("default"),t.importClause.namedBindings))if(h.isNamedImports(t.importClause.namedBindings))for(let o of t.importClause.namedBindings.elements)r.push(o.name.text);else h.isNamespaceImport(t.importClause.namedBindings)&&r.push("*");let n=r.length>0?"static":"side-effect";e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:t.moduleSpecifier.text,isStyle:A(t.moduleSpecifier.text),type:n,symbols:r.length>0?r:void 0})}function Gf(t,e){h.isExportDeclaration(t)?_f(t,e):h.isExportAssignment(t)?e.exports.set("default",{name:"default"}):rn(t)&&zf(t,e)}function _f(t,e){if(t.moduleSpecifier&&h.isStringLiteral(t.moduleSpecifier))jf(t,t.moduleSpecifier.text,e);else if(t.exportClause&&h.isNamedExports(t.exportClause))for(let r of t.exportClause.elements){let n=r.name.text;e.exports.set(n,{name:n})}}function jf(t,e,r){let n=Wf(t),o={fromPath:r.filePath,toPath:"",rawSpecifier:e,isStyle:A(e),type:"re-export"};n.length>0&&(o.symbols=n),r.imports.push(o)}function Wf(t){return t.exportClause?h.isNamedExports(t.exportClause)?t.exportClause.elements.map(e=>e.name.text):[]:["*"]}function zf(t,e){if((h.isFunctionDeclaration(t)||h.isClassDeclaration(t)||h.isInterfaceDeclaration(t)||h.isTypeAliasDeclaration(t)||h.isEnumDeclaration(t))&&t.name){let n=t.name.text;e.exports.set(n,qs(n,t,t,e.sourceFile));return}if(h.isVariableStatement(t)){for(let n of t.declarationList.declarations)if(h.isIdentifier(n.name)){let o=n.name.text;e.exports.set(o,qs(o,n,t,e.sourceFile))}}}function $f(t,e){if(!h.isCallExpression(t))return;let r=t.arguments[0];!r||!h.isStringLiteral(r)||(t.expression.kind===h.SyntaxKind.ImportKeyword?e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:r.text,isStyle:A(r.text),type:"dynamic"}):h.isIdentifier(t.expression)&&t.expression.text==="require"&&e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:r.text,isStyle:A(r.text),type:"require"}))}function Bf(t,e){let r=Xs.basename(t).toLowerCase(),n=Xs.extname(t).toLowerCase();return ye().some(s=>r.includes(s))?"test":Rn(r)?"config":e.imports.some(s=>Gt().some(i=>s.rawSpecifier.includes(i)))?"test":n===".tsx"||n===".jsx"||e.hasUI?"ui":e.hasTypesOnly&&e.totalStatements>0?"type-only":e.totalStatements>0&&e.exportStatements/e.totalStatements>Wt()?"barrel":"logic"}function rn(t){return h.canHaveModifiers(t)&&h.getModifiers(t)?.some(e=>e.kind===h.SyntaxKind.ExportKeyword)===!0}function Uf(t,e){let r=t.rawCallEdges??[];t.rawCallEdges=r;let n=new Map;for(let o of e.statements){if(!h.isImportDeclaration(o)||!h.isStringLiteral(o.moduleSpecifier))continue;let s=o.moduleSpecifier.text,i=o.importClause;if(i&&(i.name&&n.set(i.name.text,s),i.namedBindings&&h.isNamedImports(i.namedBindings)))for(let a of i.namedBindings.elements)n.set(a.name.text,s)}if(n.size!==0)for(let o of e.statements){let s=Jf(o);if(s){let i=Kf(o);i&&Et(i,s,n,r);continue}h.isClassDeclaration(o)&&o.name&&Hf(o,o.name.text,n,r)}}function Hf(t,e,r,n){for(let o of t.members)h.isMethodDeclaration(o)&&o.body&&h.isIdentifier(o.name)?Et(o.body,`${e}.${o.name.text}`,r,n):h.isConstructorDeclaration(o)&&o.body&&Et(o.body,`${e}.constructor`,r,n)}function Jf(t){if(rn(t)){if(h.isFunctionDeclaration(t)&&t.name)return t.name.text;if(h.isVariableStatement(t)){for(let e of t.declarationList.declarations)if(h.isIdentifier(e.name)&&e.initializer&&(h.isArrowFunction(e.initializer)||h.isFunctionExpression(e.initializer)))return e.name.text}}}function Kf(t){if(h.isFunctionDeclaration(t))return t.body;if(h.isVariableStatement(t)){for(let e of t.declarationList.declarations)if(e.initializer&&(h.isArrowFunction(e.initializer)||h.isFunctionExpression(e.initializer)))return e.initializer}}function Et(t,e,r,n){if(h.isCallExpression(t)&&h.isIdentifier(t.expression)){let o=t.expression.text,s=r.get(o);s&&!n.some(i=>i.from===e&&i.to===o&&i.toSpecifier===s)&&n.push({from:e,to:o,toSpecifier:s})}h.forEachChild(t,o=>Et(o,e,r,n))}var ei=m(()=>{"use strict";l();se();Vs();B();Ys()});function Ft(t,e){if(e.length===0)return"ui";let r=!1;return t.walk(n=>{if(n.type==="rule")return r=!0,!1}),r?"ui":"barrel"}var ti=m(()=>{"use strict";l()});function ri(t,e){let r=[],n=/@require\s+['"]([^'"]+)['"]/g,o=n.exec(t);for(;o!==null;){let i=o[1];i&&r.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:"require"}),o=n.exec(t)}let s=/(?<!@)(?:import|require)\s*\(?\s*['"]([^'"]+)['"]/g;for(o=s.exec(t);o!==null;){let i=o[1];i&&r.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:"static"}),o=s.exec(t)}return r}function ni(t,e){if(e.length===0)return"ui";try{let r=At("stylus");return new r.Parser(t).parse().nodes.some(s=>s.constructor.name!=="Import")?"ui":"barrel"}catch{return t.replace(/^\s*@?(?:require|import)\b.*/gm,"").trim().length>0?"ui":"barrel"}}var oi=m(()=>{"use strict";l()});function Re(t,e){let r=$(t);if(r==="stylus"){let s=ri(e,t);return{imports:s,exports:[],tags:[],category:ni(e,s)}}if(r==="scss"){let{imports:s,root:i,exports:a,tags:c}=Ze(e,t);return{imports:s,exports:a,tags:c,category:Ft(i,s)}}if(r==="less"){let{imports:s,root:i,exports:a,tags:c}=qe(e,t);return{imports:s,exports:a,tags:c,category:Ft(i,s)}}let{imports:n,root:o}=Xe(e,t);return{imports:n,exports:[],tags:[],category:Ft(o,n)}}var si=m(()=>{"use strict";l();B();ti();rr();nr();oi()});async function ii(t,e){let r=$(t),n=Jo(r);return n?n(t,e):{imports:[],exports:[],tags:[],category:"other"}}var ai=m(()=>{"use strict";l();B();ws();Ts();Ms();Rs();Os();Ws();Hs();ei();Ie();si();se();B();Ie();for(let[t,e]of[["javascript",(r,n)=>tn(r,n,"javascript")],["typescript",(r,n)=>tn(r,n,"typescript")],["css",Re],["scss",Re],["less",Re],["stylus",Re],["coffeescript",vs],["livescript",As],["lua",Ls],["python",Us],["go",Ds],["gherkin",Vr],["markdown",js]])fe(t,e)});import ci from"path";function Vf(t,e){let r=e.get(t.path);r!==void 0&&(t.coveragePct=r)}function pi(t,e){for(let r of t)if(r.isExternal){let n=r.rawSpecifier.startsWith("@")?r.rawSpecifier.split("/").slice(0,2).join("/"):r.rawSpecifier.split("/")[0];n&&!e.some(o=>o.name===n)&&e.push({name:n,kind:"library"})}}function Qf(t,e,r){if(e.isExternal||!e.toPath)return;let n=r.get(e.toPath);n&&(n.category!=="logic"&&n.category!=="barrel"||(n.testedBy??=[],n.testedBy.includes(t.path)||n.testedBy.push(t.path)))}function Yf(t,e){if(t.type==="markdown")for(let r of t.imports){if(r.isExternal||!r.toPath)continue;let n=e.get(r.toPath);!n||n===t||(n.documentedBy??=[],n.documentedBy.includes(t.path)||n.documentedBy.push(t.path),n.category==="logic"&&(n.lastCommitAt??0)>(t.lastCommitAt??0)&&(t.staleFor??=[],t.staleFor.includes(n.path)||t.staleFor.push(n.path)))}}function li(t){return Math.round(t*1e4)/1e4}function Xf(t,e){let r=[];for(let n of t.imports){if(n.isExternal||!n.toPath)continue;let o=e.get(n.toPath);if(!o||o.exports.length===0)continue;let s;if(n.symbols===void 0){if(n.type==="side-effect")continue;s=1}else n.symbols.includes("*")?s=1:s=n.symbols.length/o.exports.length;n.exportUsageRatio=li(Math.min(1,s)),r.push(n.exportUsageRatio)}r.length>0&&(t.avgExportUsage=li(r.reduce((n,o)=>n+o,0)/r.length),t.maxExportUsage=Math.max(...r))}function nn(t,e,r){e&&(t.some(n=>n.name===e&&n.kind===r)||t.push({name:e,kind:r}))}function qf(t,e){let r=e.toPath,n=ci.basename(r,ci.extname(r)).replace(/\.(test|spec)$/,"");nn(t.tags,n,"import")}function Zf(t,e){if(!(!e.symbols||e.symbols.includes("*")))for(let r of e.symbols)nn(t.tags,r,"import")}function eu(t,e,r){let n=r.get(e.toPath);if(!(!n||n.category==="test"))for(let o of n.tags)o.kind==="comment-marker"&&nn(t.tags,o.name,"comment-marker")}function tu(t,e,r){!e.toPath||e.isExternal||(qf(t,e),Zf(t,e),eu(t,e,r))}function fi(t,e){for(let r of t.values())delete r.testedBy,delete r.documentedBy,delete r.staleFor,r.category==="test"&&(r.tags=r.tags.filter(n=>n.kind!=="import"));for(let r of t.values()){if(Xf(r,t),e.size>0&&Vf(r,e),r.category==="test")for(let n of r.imports)Qf(r,n,t),tu(r,n,t);Yf(r,t)}}var ui=m(()=>{"use strict";l()});import gi from"fs";import he from"path";function ru(t,e){let r=t.split(`
31
+ `),n=null,o=new Map,s=!1;for(let i of r){let a=i.trim();if(a.startsWith("module ")){n=a.slice(7).trim();continue}if(/^replace\s*\(/.test(a)){s=!0;continue}if(s&&a===")"){s=!1;continue}if(s&&a.includes("=>")){mi(a,e,o);continue}!s&&/^replace\s+/.test(a)&&a.includes("=>")&&mi(a.replace(/^replace\s+/,""),e,o)}return{mod:n,replaces:o}}function mi(t,e,r){let[n,o]=t.split("=>").map(a=>a.trim());if(!n||!o)return;let s=n.split(/\s+/)[0];if(!o.startsWith(".")&&!o.startsWith("/"))return;let i=he.isAbsolute(o)?o:he.resolve(e,o);r.set(s,i)}function di(t){let e;try{e=gi.readdirSync(t,{withFileTypes:!0})}catch{return null}let r=e.filter(n=>n.isFile()&&n.name.endsWith(".go")&&!n.name.endsWith("_test.go")).map(n=>({path:he.join(t,n.name),isExternal:!1})).sort((n,o)=>n.path.localeCompare(o.path));return r.length>0?r:null}var Le,hi=m(()=>{"use strict";l();Le=class{extensions=[".go"];goModCache=new Map;resolve(e,r,n,o){let{mod:s,replaces:i}=this.readGoMod(n);if(!s)return null;let a=this.applyReplace(r,i,n);if(a!==void 0)return di(a);if(r!==s&&!r.startsWith(`${s}/`))return null;let c=r.slice(s.length).replace(/^\//,"");return c?di(he.join(n,c)):null}readGoMod(e){let r=this.goModCache.get(e);if(r!==void 0)return r;let n={mod:null,replaces:new Map};try{let o=gi.readFileSync(he.join(e,"go.mod"),"utf-8"),s=ru(o,e);return this.goModCache.set(e,s),s}catch{return this.goModCache.set(e,n),n}}applyReplace(e,r,n){for(let[o,s]of r){if(e===o)return s;if(e.startsWith(`${o}/`)){let i=e.slice(o.length+1);return he.join(s,i)}}}}});import nu from"fs";import on from"path";var Oe,yi=m(()=>{"use strict";l();Oe=class{extensions=[".lua"];resolve(e,r,n,o){let s=r.replace(/\./g,on.sep),i=[n,on.join(n,"lib")];for(let a of i){if(!nu.existsSync(a))continue;let c=o(on.join(a,"_dummy.lua"),s);if(c)return[c]}return null}}});import ou from"path";var Ge,xi=m(()=>{"use strict";l();Ge=class{extensions=[".md",".mdx"];resolve(e,r,n,o){let s=o(ou.join(n,"_dummy"),`./${r}`);return s?[s]:null}}});import su from"fs";import sn from"path";function bi(t){try{return su.statSync(t,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}var _e,Si=m(()=>{"use strict";l();_e=class{extensions=[".py"];resolve(e,r,n,o){let s=r.replace(/\./g,sn.sep),i=sn.join(n,`${s}.py`);if(bi(i))return[{path:i,isExternal:!1}];let a=sn.join(n,s,"__init__.py");return bi(a)?[{path:a,isExternal:!1}]:null}}});import Ci from"path";var iu,je,ki=m(()=>{"use strict";l();iu=["~","http://","https://","//","data:","sass:"],je=class{extensions=[".css",".scss",".sass",".less",".styl"];resolve(e,r,n,o){if(iu.some(f=>r.startsWith(f)))return null;let s=o(e,r);if(s)return[s];let i=Ci.dirname(r),a=Ci.basename(r),c=i==="."?`_${a}`:`${i}/_${a}`,p=o(e,c);return p?[p]:null}}});var vi=m(()=>{"use strict";l();hi();yi();xi();Si();ki()});import Nt from"fs";import W from"path";var re,an=m(()=>{"use strict";l();vi();re=class{constructor(e,r={}){this.rootDir=e;this.workspaceMap=r.workspaceMap??new Map,this.tsconfigSearchPaths=r.tsconfigSearchPaths??[e],this.pathAliases=r.pathAliases,this.langResolvers=r.langResolvers??[new _e,new Oe,new Le,new je,new Ge]}rootDir;workspaceMap;tsconfigSearchPaths;pathAliases;langResolvers;resolutionCache=new Map;langBucketFor(e){for(let r=0;r<this.langResolvers.length;r++)if(this.langResolvers[r]?.extensions.some(n=>e.endsWith(n)))return String(r);return"none"}cacheKey(e,r){return`${W.dirname(e)}\0${this.langBucketFor(e)}\0${r}`}resolveAll(e,r){let n=this.cacheKey(e,r),o=this.resolutionCache.get(n);if(o!==void 0)return o??[];let s=this.resolveAllUncached(e,r);return this.resolutionCache.set(n,s.length>0?s:null),s}resolveAllUncached(e,r){let n=this.resolvePathAlias(r);if(n)return[n];if(r.startsWith(".")||r.startsWith("/")){let i=this.resolveLocalPath(e,r);return i?[i]:[]}let o=(i,a)=>this.resolveLocalPath(i,a);for(let i of this.langResolvers)if(i.extensions.some(a=>e.endsWith(a))){let a=i.resolve(e,r,this.rootDir,o);if(a)return a}let s=this.resolveWorkspaceImport(r);return s?[s]:[{path:r,isExternal:!0}]}resolve(e,r){return this.resolveAll(e,r)[0]??null}resolveLocalPath(e,r){let n=W.dirname(e),o=r.startsWith("/")?r:W.resolve(n,r),s=!o.startsWith(this.rootDir),i=["",".ts",".tsx",".js",".jsx",".mjs",".cjs",".css",".scss",".sass",".less",".styl",".coffee",".ls",".lua",".py",".feature",".md",".mdx"],a=o.match(/\.(js|mjs|cjs)$/);if(a){let c=o.slice(0,-a[0].length);for(let p of[".ts",".tsx"]){let f=this.tryExtensions(c,p,s);if(f)return f}}for(let c of i){let p=this.tryExtensions(o,c,s);if(p)return p}return s?{path:o,isExternal:!0}:null}tryExtensions(e,r,n){let o=e+r;if(this.isFile(o))return{path:o,isExternal:n};let s=W.join(e,`index${r}`);if(this.isFile(s))return{path:s,isExternal:n};if(r===".py"){let i=W.join(e,"__init__.py");if(this.isFile(i))return{path:i,isExternal:n}}return null}isFile(e){try{return Nt.statSync(e,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}resolvePathAlias(e){if(this.pathAliases)for(let r in this.pathAliases){let n=this.matchAliasPattern(r,e),o=this.pathAliases[r];if(n&&o){let s=this.tryAliasSubstitutions(o,n[1]||"");if(s)return s}}for(let r of this.tsconfigSearchPaths){let n=W.join(r,"tsconfig.json");if(Nt.existsSync(n))try{let s=JSON.parse(Nt.readFileSync(n,"utf-8")).compilerOptions?.paths;if(!s)continue;for(let i in s){let a=this.matchAliasPattern(i,e);if(a){let c=this.tryAliasSubstitutions(s[i],a[1]||"",r);if(c)return c}}}catch{}}return null}aliasRegexCache=new Map;matchAliasPattern(e,r){let n=this.aliasRegexCache.get(e);if(!n){let o=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace("\\*","(.*)");n=new RegExp(`^${o}$`),this.aliasRegexCache.set(e,n)}return r.match(n)}tryAliasSubstitutions(e,r,n=this.rootDir){let o=["",".ts",".tsx",".js",".jsx",".coffee",".ls",".lua",".feature"];for(let s of e){let i=s.replace("*",r),a=W.resolve(n,i);for(let c of o){let p=this.tryExtensions(a,c,!1);if(p)return p}}return null}resolveWorkspaceImport(e){if(this.workspaceMap.size===0)return null;for(let[r,n]of this.workspaceMap){if(e!==r&&!e.startsWith(`${r}/`))continue;let o=e.slice(r.length),s={path:"",isExternal:!1,isWorkspace:!0,workspacePackage:r};if(!o){for(let a of["src/index.ts","src/index.tsx","index.ts","index.tsx","index.js"]){let c=W.join(n,a);try{if(Nt.statSync(c,{throwIfNoEntry:!1})?.isFile())return{...s,path:c}}catch{}}return{...s,path:n}}let i=this.resolveLocalPath(W.join(n,"_dummy"),o.slice(1));return i?{...s,path:i.path}:null}return null}}});import We from"fs";import I from"path";import au from"piscina";function pu(t,e){if(t.length===0)return e;let r=t.map(i=>I.dirname(i).split(I.sep)),n=r[0]??[];for(let i of r.slice(1)){let a=0;for(;a<n.length&&a<i.length&&n[a]===i[a];)a++;n=n.slice(0,a)}let o=n.join(I.sep)||I.sep,s=I.relative(e,o);return s.startsWith("..")||I.isAbsolute(s)?e:o}var cu,wi,lu,ze,Ti=m(()=>{"use strict";l();Jr();se();tr();ai();ui();we();an();cu=["tests","test","__tests__","specs","spec"],wi=new Set(["node_modules",".git","dist","build",".next",".cache","mokosh-cache","coverage"]),lu=600;ze=class{constructor(e,r=null,n,o,s=!1,i=new Map,a=!0){this.rootDir=e;this.enableGitStats=s;this.coverageMap=i;this.parallelParsing=a;this.previousGraph=r,this.resolver=n||new re(e),this.lockFile=Kn(e),o&&(this.progressCallback=o)}rootDir;enableGitStats;coverageMap;parallelParsing;graph={nodes:new Map};visited=new Set;queue=[];previousGraph=null;resolver;lockFile=null;progressCallback;pool=null;gitStatsMap=null;async build(e){let r=e.map(n=>I.isAbsolute(n)?n:I.resolve(this.rootDir,n));await this.initPool(),this.enableGitStats&&(this.gitStatsMap=bs(this.rootDir));try{for(let n of r)this.enqueue(n);return await this.drain(),await this.processTestFiles(pu(r,this.rootDir)),await this.processDocFiles(),this.progressCallback&&this.visited.size>=100&&process.stderr.write(`
32
32
  Done. Total processed: ${this.visited.size} nodes.
33
- `),qs(this.graph.nodes,this.coverageMap),new D(this.graph.nodes)}finally{this.pool&&(await this.pool.destroy(),this.pool=null)}}async initPool(){if(this.parallelParsing===!1)return;let e=typeof this.parallelParsing=="object"?this.parallelParsing:{},r=e.minFiles??zf;if(!(r>0&&!this.hasAtLeastFiles(this.rootDir,r))){e.maxThreads!==void 0&&e.maxThreads<1&&process.stderr.write(`
33
+ `),fi(this.graph.nodes,this.coverageMap),new D(this.graph.nodes)}finally{this.pool&&(await this.pool.destroy(),this.pool=null)}}async initPool(){if(this.parallelParsing===!1)return;let e=typeof this.parallelParsing=="object"?this.parallelParsing:{},r=e.minFiles??lu;if(!(r>0&&!this.hasAtLeastFiles(this.rootDir,r))){e.maxThreads!==void 0&&e.maxThreads<1&&process.stderr.write(`
34
34
  Warning: parallelParsing.maxThreads (${e.maxThreads}) must be at least 1; using 1.
35
- `);try{let n=I.join(u,"parse-worker.js");this.pool=new jf({filename:n,...e.maxThreads!==void 0?{maxThreads:Math.max(1,e.maxThreads)}:{}})}catch(n){process.stderr.write(`
35
+ `);try{let n=I.join(u,"parse-worker.js");this.pool=new au({filename:n,...e.maxThreads!==void 0?{maxThreads:Math.max(1,e.maxThreads)}:{}})}catch(n){process.stderr.write(`
36
36
  Warning: failed to start parse worker pool, falling back to synchronous parsing: ${n}
37
- `),this.pool=null}}}hasAtLeastFiles(e,r){let n=0,o=[e];for(;o.length>0;){let s=o.pop();if(s===void 0)continue;let i;try{i=Oe.readdirSync(s,{withFileTypes:!0})}catch{continue}for(let a of i)if(a.isDirectory())fi.has(a.name)||o.push(I.join(s,a.name));else if(a.isFile()&&(n++,n>=r))return!0}return n>=r}async processTestFiles(e){let r=ge(),n=s=>r.some(i=>s.name.includes(i));this.walkProject(e,n);let o=e;for(;o!==this.rootDir;){let s=I.dirname(o);if(s===o)break;for(let i of Wf){let a=I.join(s,i);try{Oe.statSync(a).isDirectory()&&this.walkProject(a,n)}catch{}}o=s}await this.drain()}async processDocFiles(){this.walkProject(this.rootDir,e=>e.name.endsWith(".md")||e.name.endsWith(".mdx")),await this.drain()}walkProject(e,r){let n;try{n=Oe.readdirSync(e,{withFileTypes:!0})}catch{return}for(let o of n){let s=I.join(e,o.name);o.isDirectory()?fi.has(o.name)||this.walkProject(s,r):o.isFile()&&r(o)&&this.enqueue(s)}}enqueue(e){this.visited.has(e)||(this.visited.add(e),this.showProgress(),this.queue.push(e))}async drain(){for(;this.queue.length>0;){let e=this.queue;this.queue=[],await Promise.all(e.map(r=>this.finishFile(r)))}}async finishFile(e){let r=Oe.statSync(e,{throwIfNoEntry:!1});if(!r?.isFile())return;let n=I.relative(this.rootDir,e),o=await this.getNode(e,n,r);o.imports=await this.resolveImports(e,o.imports),Xs(o.imports,o.tags),this.graph.nodes.set(o.path,o)}async getNode(e,r,n){let o=this.previousGraph?.nodes.get(r);if(o&&o.mtime===n.mtimeMs&&o.size===n.size)return{...o};let s=await this.tryParse(e,r);if(!s)return this.makeStubNode(e,r,n);let i=this.resolveCallEdges(e,s.rawCallEdges),a=this.buildNode(e,r,n,s,i);return this.attachGitStats(a,r),a}async tryParse(e,r){let n=Oe.readFileSync(e,"utf-8");try{return await this.parseContent(e,n)}catch(o){return process.stderr.write(`
37
+ `),this.pool=null}}}hasAtLeastFiles(e,r){let n=0,o=[e];for(;o.length>0;){let s=o.pop();if(s===void 0)continue;let i;try{i=We.readdirSync(s,{withFileTypes:!0})}catch{continue}for(let a of i)if(a.isDirectory())wi.has(a.name)||o.push(I.join(s,a.name));else if(a.isFile()&&(n++,n>=r))return!0}return n>=r}async processTestFiles(e){let r=ye(),n=s=>r.some(i=>s.name.includes(i));this.walkProject(e,n);let o=e;for(;o!==this.rootDir;){let s=I.dirname(o);if(s===o)break;for(let i of cu){let a=I.join(s,i);try{We.statSync(a).isDirectory()&&this.walkProject(a,n)}catch{}}o=s}await this.drain()}async processDocFiles(){this.walkProject(this.rootDir,e=>e.name.endsWith(".md")||e.name.endsWith(".mdx")),await this.drain()}walkProject(e,r){let n;try{n=We.readdirSync(e,{withFileTypes:!0})}catch{return}for(let o of n){let s=I.join(e,o.name);o.isDirectory()?wi.has(o.name)||this.walkProject(s,r):o.isFile()&&r(o)&&this.enqueue(s)}}enqueue(e){this.visited.has(e)||(this.visited.add(e),this.showProgress(),this.queue.push(e))}async drain(){for(;this.queue.length>0;){let e=this.queue;this.queue=[],await Promise.all(e.map(r=>this.finishFile(r)))}}async finishFile(e){let r=We.statSync(e,{throwIfNoEntry:!1});if(!r?.isFile())return;let n=I.relative(this.rootDir,e),o=await this.getNode(e,n,r);o.imports=await this.resolveImports(e,o.imports),pi(o.imports,o.tags),this.graph.nodes.set(o.path,o)}async getNode(e,r,n){let o=this.previousGraph?.nodes.get(r);if(o&&o.mtime===n.mtimeMs&&o.size===n.size)return{...o};let s=await this.tryParse(e,r);if(!s)return this.makeStubNode(e,r,n);let i=this.resolveCallEdges(e,s.rawCallEdges),a=this.buildNode(e,r,n,s,i);return this.attachGitStats(a,r),a}async tryParse(e,r){let n=We.readFileSync(e,"utf-8");try{return await this.parseContent(e,n)}catch(o){return process.stderr.write(`
38
38
  Warning: failed to parse ${r}: ${o}
39
- `),null}}parseContent(e,r){return this.pool?this.pool.run({filePath:e,content:r}):Hs(e,r)}makeStubNode(e,r,n){return{path:r,type:z(e),category:"other",imports:[],exports:[],tags:[],mtime:n.mtimeMs,size:n.size}}resolveCallEdges(e,r){let n=[];for(let o of r??[])try{let s=this.resolver.resolve(e,o.toSpecifier);s&&!s.isExternal&&n.push({from:o.from,to:o.to,toFile:I.relative(this.rootDir,s.path)})}catch{}return n}buildNode(e,r,n,o,s){let{imports:i,exports:a,tags:c,category:p,description:f,complexity:d,cognitiveComplexity:y,functions:x}=o;return{path:r,type:z(e),category:p,imports:i,exports:a,tags:c,mtime:n.mtimeMs,size:n.size,...f!==void 0?{description:f}:{},...s.length>0?{callEdges:s}:{},...d!==void 0?{complexity:d}:{},...y!==void 0?{cognitiveComplexity:y}:{},...x!==void 0?{functions:x}:{}}}attachGitStats(e,r){let n=this.gitStatsMap?.get(r);n&&(e.commitCount90d=n.commitCount90d,n.lastAuthor!==void 0&&(e.lastAuthor=n.lastAuthor),n.lastCommitAt!==void 0&&(e.lastCommitAt=n.lastCommitAt))}async resolveImports(e,r){let n=[];for(let o of r){let s=this.resolver.resolveAll(e,o.rawSpecifier);if(s.length!==0)for(let i of s){let a={...o,toPath:i.isExternal?i.path:I.relative(this.rootDir,i.path),isExternal:i.isExternal};i.isWorkspace&&(a.isWorkspace=!0,a.workspacePackage=i.workspacePackage),i.isExternal?this.attachLockfileVersion(a):this.enqueue(i.path),n.push(a)}}return n}attachLockfileVersion(e){if(!this.lockFile)return;let r=e.rawSpecifier.startsWith("@")?e.rawSpecifier.split("/").slice(0,2).join("/"):e.rawSpecifier.split("/")[0],n=r?this.lockFile.dependencies[r]:void 0;n&&(e.version=n.version)}showProgress(){this.progressCallback&&this.visited.size%100===0&&this.progressCallback(this.visited.size)}}});var mi=m(()=>{"use strict";l();jt();ui();zt();Bt();Xt();qe();Ze();Ce();Xr();lr();tt();mr();xr();br()});var qr=m(()=>{"use strict";l();mi()});function gi(t,e){return{identifier:e?.identifier??new yt,featureMap:e?.featureDetection===!1?new Map:K(t.nodes,e?.featureDetection??void 0)}}function di(t,e,r,n,o){for(let s of e){let i=t.nodes.get(s);if(!i)continue;let a=new H(s,["*",...i.exports.map(c=>c.name)]);t.traverse(s,(c,p,f)=>{if(!f)return!0;if(!a.updateAffectedSymbols(c,f))return!1;if(p>0){let d=r.get(c.path);if(d)return n(d),!1}return o(c),!0},{direction:"incoming"})}}function Zr(t,e,r){let{identifier:n,featureMap:o}=gi(t,r),s=new Set;for(let i of e){let a=o.get(i);a&&s.add(a.tag)}return di(t,e,o,i=>s.add(i.tag),i=>{if(n.isTestNode(i))for(let a of i.tags)s.add(a.name)}),Array.from(s)}function en(t,e,r){let{identifier:n,featureMap:o}=gi(t,r),s=new Set;return di(t,e,o,()=>{},i=>{n.isTestNode(i)&&s.add(i.path)}),Array.from(s)}var hi=m(()=>{"use strict";l();qr();Rr()});var yi=m(()=>{"use strict";l();as();Rr();hi()});import Uf from"fs";import _e from"path";async function L(t,e,r=null,n={}){let o=n.silent?void 0:a=>{process.stderr.write(`Processed ${a} files...\r`)},s=_e.resolve(t);return await new Ge(s,r,n.pathAliases?new Z(s,{pathAliases:n.pathAliases}):void 0,o,n.gitStats??!1,n.coverageMap??new Map,n.parallelParsing??!0).build(e)}async function xi(t,e={}){let r=_e.resolve(t),n=yr(r),o=e.packages?n.packages.filter(a=>e.packages?.includes(a.name)||e.packages?.includes(a.relativeRoot)):n.packages,s=new Map(n.packages.map(a=>[a.name,a.root])),i=new Ee(r,n.type);for(let a of o){let c=e.silent?void 0:d=>{process.stderr.write(`[${a.name}] Processed ${d} files...\r`)},f=await new Ge(r,null,new Z(r,{workspaceMap:s,tsconfigSearchPaths:[a.root,r],pathAliases:e.pathAliases}),c,e.gitStats??!1,new Map,e.parallelParsing??!0).build(a.entryPoints);i.addPackage(a,f)}return i}function R(t,e={}){let r=[],n=new Set([...e.ignoreDirs??J,...e.additionalIgnoreDirs??[]]),o=new Set([...e.extensions??Rt,...e.additionalExtensions??[]]);function s(i){try{let a=Uf.readdirSync(i,{withFileTypes:!0});for(let c of a){let p=_e.join(i,c.name);c.isDirectory()?n.has(c.name)||s(p):c.isFile()&&o.has(_e.extname(c.name).toLowerCase())&&r.push(_e.relative(t,p))}}catch{}}return s(t),r}var w=m(()=>{"use strict";l();Lt();he();Mn();Ln();jt();zt();Bt();Xt();qe();Ze();Zt();Ce();ar();lr();yo();tt();mr();xr();st();br();re();Te();Uo();yi();he();qr()});var tn=m(()=>{"use strict";l();he()});import je from"path";import{parseArgs as Bf}from"util";function Jf(t){for(let e=0;e<t.length;e++)if(t[e]==="--root"&&t[e+1])return je.resolve(t[e+1]);return process.cwd()}function me(t){return t?parseInt(t,10):void 0}function bi(t){return t?t.split(",").map(e=>e.trim()):void 0}function Hf(t){let e=[];for(let r=0;r<t.length;r++){let n=t[r];if(n!==void 0)if(!n.startsWith("--"))e.push(n);else if(Kf.has(n)){let o=t[r+1];o!==void 0&&!o.startsWith("--")&&(e.push(n,o),r++)}else n.slice(2)in rn&&e.push(n)}return e}function Si(t){let e=Jf(t),r=je.join(je.resolve(e,oe),se),{values:n,positionals:o}=Bf({args:Hf(t),allowPositionals:!0,options:rn}),s=n.cache,i=n.config,a=n.metric;return{rootDir:e,cachePath:s?je.resolve(e,s):r,configPath:i?je.resolve(e,i):void 0,query:n.query,file:n.file,typeFilter:n.type,functionName:n.function,filterPaths:bi(n.paths),featureThreshold:me(n["feature-threshold"]),minOutDegree:me(n["min-out-degree"]),mermaid:n.mermaid??!1,proposeTags:n["propose-tags"]??!1,plain:n.plain??!1,affectedTests:n["affected-tests"]??!1,detectFeatures:n["detect-features"]??!1,findUnused:n["find-unused"]??!1,excludeTests:n["exclude-tests"]??!1,checkCycles:n["check-cycles"]??!1,checkDocDrift:n["check-doc-drift"]??!1,findUncovered:n["find-uncovered"]??!1,listTags:n["list-tags"]??!1,callers:n.callers??!1,silent:n.silent??!1,queryHelp:n["query-help"]??!1,help:t.length===0||(n.help??!1),typeGraph:n["type-graph"]??!1,moduleResponsibility:n["module-responsibility"]??!1,featureGraph:n["feature-graph"]??!1,callGraph:n["call-graph"]??!1,findSymbol:n["find-symbol"]??!1,apiSurface:n["api-surface"]??!1,applyTags:n["apply-tags"]??!1,dryRun:n["dry-run"]??!1,initSkill:n["init-skill"]??!1,initConfig:n["init-config"]??!1,force:n.force??!1,dependencies:n.dependencies??!1,dependents:n.dependents??!1,affected:n.affected??!1,testsOnly:n["tests-only"]??!1,changedSymbols:bi(n["changed-symbols"]),cached:n.cached??!1,depth:me(n.depth),withMeta:n["with-meta"]??!1,withEdgeDetail:n["with-edge-detail"]??!1,findComplexFunctions:n["find-complex-functions"]??!1,metric:a==="complexity"||a==="cognitiveComplexity"?a:void 0,complexityThreshold:me(n["complexity-threshold"]),limit:me(n.limit),findDuplicates:n["find-duplicates"]??!1,minDuplicateLines:me(n["min-duplicate-lines"]),workspacePackages:n["workspace-packages"]??!1,workspaceAffected:n["workspace-affected"]??!1,clearCache:n["clear-cache"]??!1,slim:n.slim??!1,watch:n.watch??!1,entryPoints:o}}var rn,Kf,Ci=m(()=>{"use strict";l();tn();rn={root:{type:"string"},cache:{type:"string"},config:{type:"string"},query:{type:"string"},file:{type:"string"},type:{type:"string"},paths:{type:"string"},function:{type:"string"},"feature-threshold":{type:"string"},"min-out-degree":{type:"string"},mermaid:{type:"boolean"},"propose-tags":{type:"boolean"},plain:{type:"boolean"},"affected-tests":{type:"boolean"},"detect-features":{type:"boolean"},"find-unused":{type:"boolean"},"exclude-tests":{type:"boolean"},"check-cycles":{type:"boolean"},"check-doc-drift":{type:"boolean"},"find-uncovered":{type:"boolean"},"list-tags":{type:"boolean"},callers:{type:"boolean"},silent:{type:"boolean"},"query-help":{type:"boolean"},help:{type:"boolean"},"type-graph":{type:"boolean"},"module-responsibility":{type:"boolean"},"feature-graph":{type:"boolean"},"call-graph":{type:"boolean"},"find-symbol":{type:"boolean"},"api-surface":{type:"boolean"},"apply-tags":{type:"boolean"},"dry-run":{type:"boolean"},"init-skill":{type:"boolean"},"init-config":{type:"boolean"},force:{type:"boolean"},dependencies:{type:"boolean"},dependents:{type:"boolean"},affected:{type:"boolean"},"tests-only":{type:"boolean"},"changed-symbols":{type:"string"},cached:{type:"boolean"},depth:{type:"string"},"with-meta":{type:"boolean"},"with-edge-detail":{type:"boolean"},"find-complex-functions":{type:"boolean"},metric:{type:"string"},"complexity-threshold":{type:"string"},limit:{type:"string"},"find-duplicates":{type:"boolean"},"min-duplicate-lines":{type:"string"},"workspace-packages":{type:"boolean"},"workspace-affected":{type:"boolean"},"clear-cache":{type:"boolean"},slim:{type:"boolean"},watch:{type:"boolean"}},Kf=new Set(Object.entries(rn).filter(([,t])=>t.type==="string").map(([t])=>`--${t}`))});async function nn(t){let{graph:e,file:r,testsOnly:n,changedSymbols:o,cached:s,withMeta:i}=t;r||(console.error("Error: --affected requires --file <path>"),process.exit(1));let a=f=>i?f.map(d=>({path:d,...V(e,d)})):f;if(s){let f=$t(e),d=Ut(f,r),y=n?d.filter(v=>e.nodes.get(v)?.category==="test"):d,x=a(y);console.log(JSON.stringify({file:r,affected:x,count:x.length},null,2));return}let c=tr(e,r,{testsOnly:n,changedSymbols:o}),p=a(c);console.log(JSON.stringify({file:r,affected:p,count:p.length},null,2))}var ki=m(()=>{"use strict";l();w()});import on from"path";function ee(t){return t.filter(e=>{let r=on.basename(e).toLowerCase();return Vf.some(n=>r.includes(n))})}function wt(t){return new xt().getChangedFiles().map(e=>on.relative(t,on.resolve(t,e)))}var Vf,Et=m(()=>{"use strict";l();Gr();Vf=[".test.",".spec.","-test.","-spec."]});async function vi(t){let{graph:e}=t,{rootDir:r,scanOptions:n,featureThreshold:o,rawConfig:s}=t,i=wt(r);if(![...e.nodes.values()].some(p=>ee([p.path]).length>0)){let p=R(r,n);e=await L(r,ee(p),e,N(s))}let c=en(e,i,{...o!==void 0&&{featureDetection:{minOutDegree:o}}});console.log(c.join(`
40
- `))}var wi=m(()=>{"use strict";l();w();Et()});async function Ei(t){let{graph:e,rootDir:r,entryPoints:n}=t,o=n.length?n:Gt(e,r);o.length===0&&(console.error("Error: No entry points found. Pass entry points as positional args or ensure package.json has a main/exports field."),process.exit(1));let s=_t(e,o);console.log(JSON.stringify(s,null,2))}var Ti=m(()=>{"use strict";l();w()});async function Fi(t){let{graph:e}=t,{rootDir:r,scanOptions:n,dryRun:o,plain:s,rawConfig:i}=t;if(s||console.log(o?"Dry run: computing tag changes...":"Applying tags to test files..."),e.nodes.size===0){let c=R(r,n);e=await L(r,ee(c),e,N(i))}let a=await Lr(e,r,{dryRun:o});console.log(JSON.stringify(a,null,2))}var Ni=m(()=>{"use strict";l();w();Et()});async function Pi(t){let{graph:e,functionName:r}=t;r||(console.error("Error: --call-graph requires --function <name>"),process.exit(1));let n=Wt(e,r);console.log(JSON.stringify(n,null,2))}var Ii=m(()=>{"use strict";l();w()});async function sn(t){let{graph:e,file:r,plain:n,depth:o,withEdgeDetail:s}=t;r||(console.error("Error: --callers requires --file <path>"),process.exit(1));let i=rr(e,r,{depth:o??1,withEdgeDetail:s});console.log(n?i.map(a=>a.file).join(`
41
- `):JSON.stringify({file:r,callers:i,count:i.length},null,2))}var Di=m(()=>{"use strict";l();w()});async function an(t){let{graph:e}=t,r=e.findCycles();if(r.length>0){process.stderr.write(`Found ${r.length} cycle(s):
39
+ `),null}}parseContent(e,r){return this.pool?this.pool.run({filePath:e,content:r}):ii(e,r)}makeStubNode(e,r,n){return{path:r,type:$(e),category:"other",imports:[],exports:[],tags:[],mtime:n.mtimeMs,size:n.size}}resolveCallEdges(e,r){let n=[];for(let o of r??[])try{let s=this.resolver.resolve(e,o.toSpecifier);s&&!s.isExternal&&n.push({from:o.from,to:o.to,toFile:I.relative(this.rootDir,s.path)})}catch{}return n}buildNode(e,r,n,o,s){let{imports:i,exports:a,tags:c,category:p,description:f,complexity:g,cognitiveComplexity:y,functions:x}=o;return{path:r,type:$(e),category:p,imports:i,exports:a,tags:c,mtime:n.mtimeMs,size:n.size,...f!==void 0?{description:f}:{},...s.length>0?{callEdges:s}:{},...g!==void 0?{complexity:g}:{},...y!==void 0?{cognitiveComplexity:y}:{},...x!==void 0?{functions:x}:{}}}attachGitStats(e,r){let n=this.gitStatsMap?.get(r);n&&(e.commitCount90d=n.commitCount90d,n.lastAuthor!==void 0&&(e.lastAuthor=n.lastAuthor),n.lastCommitAt!==void 0&&(e.lastCommitAt=n.lastCommitAt))}async resolveImports(e,r){let n=[];for(let o of r){let s=this.resolver.resolveAll(e,o.rawSpecifier);if(s.length!==0)for(let i of s){let a={...o,toPath:i.isExternal?i.path:I.relative(this.rootDir,i.path),isExternal:i.isExternal};i.isWorkspace&&(a.isWorkspace=!0,a.workspacePackage=i.workspacePackage),i.isExternal?this.attachLockfileVersion(a):this.enqueue(i.path),n.push(a)}}return n}attachLockfileVersion(e){if(!this.lockFile)return;let r=e.rawSpecifier.startsWith("@")?e.rawSpecifier.split("/").slice(0,2).join("/"):e.rawSpecifier.split("/")[0],n=r?this.lockFile.dependencies[r]:void 0;n&&(e.version=n.version)}showProgress(){this.progressCallback&&this.visited.size%100===0&&this.progressCallback(this.visited.size)}}});var Ei=m(()=>{"use strict";l();Vt();Ti();Yt();Zt();ir();nt();ot();we();an();xr();it();kr();Fr();Nr()});var cn=m(()=>{"use strict";l();Ei()});function Fi(t,e){return{identifier:e?.identifier??new kt,featureMap:e?.featureDetection===!1?new Map:V(t.nodes,e?.featureDetection??void 0)}}function Ni(t,e,r,n,o){for(let s of e){let i=t.nodes.get(s);if(!i)continue;let a=new Q(s,["*",...i.exports.map(c=>c.name)]);t.traverse(s,(c,p,f)=>{if(!f)return!0;if(!a.updateAffectedSymbols(c,f))return!1;if(p>0){let g=r.get(c.path);if(g)return n(g),!1}return o(c),!0},{direction:"incoming"})}}function ln(t,e,r){let{identifier:n,featureMap:o}=Fi(t,r),s=new Set;for(let i of e){let a=o.get(i);a&&s.add(a.tag)}return Ni(t,e,o,i=>s.add(i.tag),i=>{if(n.isTestNode(i))for(let a of i.tags)s.add(a.name)}),Array.from(s)}function pn(t,e,r){let{identifier:n,featureMap:o}=Fi(t,r),s=new Set;return Ni(t,e,o,()=>{},i=>{n.isTestNode(i)&&s.add(i.path)}),Array.from(s)}var Pi=m(()=>{"use strict";l();cn();Ur()});var Ii=m(()=>{"use strict";l();gs();Ur();Pi()});import fu from"fs";import $e from"path";async function R(t,e,r=null,n={}){let o=n.silent?void 0:a=>{process.stderr.write(`Processed ${a} files...\r`)},s=$e.resolve(t);return await new ze(s,r,n.pathAliases?new re(s,{pathAliases:n.pathAliases}):void 0,o,n.gitStats??!1,n.coverageMap??new Map,n.parallelParsing??!0).build(e)}async function Di(t,e={}){let r=$e.resolve(t),n=Er(r),o=e.packages?n.packages.filter(a=>e.packages?.includes(a.name)||e.packages?.includes(a.relativeRoot)):n.packages,s=new Map(n.packages.map(a=>[a.name,a.root])),i=new Pe(r,n.type);for(let a of o){let c=e.silent?void 0:g=>{process.stderr.write(`[${a.name}] Processed ${g} files...\r`)},f=await new ze(r,null,new re(r,{workspaceMap:s,tsconfigSearchPaths:[a.root,r],pathAliases:e.pathAliases}),c,e.gitStats??!1,new Map,e.parallelParsing??!0).build(a.entryPoints);i.addPackage(a,f)}return i}function L(t,e={}){let r=[],n=new Set([...e.ignoreDirs??K,...e.additionalIgnoreDirs??[]]),o=new Set([...e.extensions??Ut,...e.additionalExtensions??[]]);function s(i){try{let a=fu.readdirSync(i,{withFileTypes:!0});for(let c of a){let p=$e.join(i,c.name);c.isDirectory()?n.has(c.name)||s(p):c.isFile()&&o.has($e.extname(c.name).toLowerCase())&&r.push($e.relative(t,p))}}catch{}}return s(t),r}var k=m(()=>{"use strict";l();Bt();be();jn();zn();Vt();Yt();Zt();ir();nt();ot();cr();we();hr();xr();To();it();kr();Fr();pt();Nr();se();Ie();Xo();Ii();be();cn()});var fn=m(()=>{"use strict";l();be()});import Be from"path";import{parseArgs as uu}from"util";function mu(t){for(let e=0;e<t.length;e++)if(t[e]==="--root"&&t[e+1])return Be.resolve(t[e+1]);return process.cwd()}function H(t){return t?parseInt(t,10):void 0}function Mi(t){return t?t.split(",").map(e=>e.trim()):void 0}function gu(t){let e=[];for(let r=0;r<t.length;r++){let n=t[r];if(n!==void 0)if(!n.startsWith("--"))e.push(n);else if(du.has(n)){let o=t[r+1];o!==void 0&&!o.startsWith("--")&&(e.push(n,o),r++)}else n.slice(2)in un&&e.push(n)}return e}function hu(t){return{mermaid:t.mermaid??!1,proposeTags:t["propose-tags"]??!1,plain:t.plain??!1,affectedTests:t["affected-tests"]??!1,detectFeatures:t["detect-features"]??!1,findUnused:t["find-unused"]??!1,excludeTests:t["exclude-tests"]??!1,checkCycles:t["check-cycles"]??!1,checkDocDrift:t["check-doc-drift"]??!1,findUncovered:t["find-uncovered"]??!1}}function yu(t){return{listTags:t["list-tags"]??!1,callers:t.callers??!1,silent:t.silent??!1,queryHelp:t["query-help"]??!1,typeGraph:t["type-graph"]??!1,moduleResponsibility:t["module-responsibility"]??!1,featureGraph:t["feature-graph"]??!1,callGraph:t["call-graph"]??!1,findSymbol:t["find-symbol"]??!1,apiSurface:t["api-surface"]??!1}}function xu(t){return{applyTags:t["apply-tags"]??!1,dryRun:t["dry-run"]??!1,initSkill:t["init-skill"]??!1,initConfig:t["init-config"]??!1,force:t.force??!1,dependencies:t.dependencies??!1,dependents:t.dependents??!1,affected:t.affected??!1,testsOnly:t["tests-only"]??!1,cached:t.cached??!1}}function bu(t){return{withMeta:t["with-meta"]??!1,withEdgeDetail:t["with-edge-detail"]??!1,findComplexFunctions:t["find-complex-functions"]??!1,findDuplicates:t["find-duplicates"]??!1,findRiskHotspots:t["find-risk-hotspots"]??!1,workspacePackages:t["workspace-packages"]??!1,workspaceAffected:t["workspace-affected"]??!1,clearCache:t["clear-cache"]??!1,slim:t.slim??!1,watch:t.watch??!1}}function Ai(t){let e=mu(t),r=Be.join(Be.resolve(e,ae),ce),{values:n,positionals:o}=uu({args:gu(t),allowPositionals:!0,options:un}),s=n.cache,i=n.config,a=n.metric,c=n;return{rootDir:e,cachePath:s?Be.resolve(e,s):r,configPath:i?Be.resolve(e,i):void 0,query:n.query,file:n.file,typeFilter:n.type,functionName:n.function,filterPaths:Mi(n.paths),featureThreshold:H(n["feature-threshold"]),minOutDegree:H(n["min-out-degree"]),...hu(c),...yu(c),help:t.length===0||(n.help??!1),...xu(c),changedSymbols:Mi(n["changed-symbols"]),depth:H(n.depth),...bu(c),metric:a==="complexity"||a==="cognitiveComplexity"?a:void 0,complexityThreshold:H(n["complexity-threshold"]),limit:H(n.limit),minDuplicateLines:H(n["min-duplicate-lines"]),maxCoveragePct:H(n["max-coverage-pct"]),minChurn:H(n["min-churn"]),base:n.base,entryPoints:o}}var un,du,Ri=m(()=>{"use strict";l();fn();un={root:{type:"string"},cache:{type:"string"},config:{type:"string"},query:{type:"string"},file:{type:"string"},type:{type:"string"},paths:{type:"string"},function:{type:"string"},"feature-threshold":{type:"string"},"min-out-degree":{type:"string"},mermaid:{type:"boolean"},"propose-tags":{type:"boolean"},plain:{type:"boolean"},"affected-tests":{type:"boolean"},"detect-features":{type:"boolean"},"find-unused":{type:"boolean"},"exclude-tests":{type:"boolean"},"check-cycles":{type:"boolean"},"check-doc-drift":{type:"boolean"},"find-uncovered":{type:"boolean"},"list-tags":{type:"boolean"},callers:{type:"boolean"},silent:{type:"boolean"},"query-help":{type:"boolean"},help:{type:"boolean"},"type-graph":{type:"boolean"},"module-responsibility":{type:"boolean"},"feature-graph":{type:"boolean"},"call-graph":{type:"boolean"},"find-symbol":{type:"boolean"},"api-surface":{type:"boolean"},"apply-tags":{type:"boolean"},"dry-run":{type:"boolean"},"init-skill":{type:"boolean"},"init-config":{type:"boolean"},force:{type:"boolean"},dependencies:{type:"boolean"},dependents:{type:"boolean"},affected:{type:"boolean"},"tests-only":{type:"boolean"},"changed-symbols":{type:"string"},cached:{type:"boolean"},depth:{type:"string"},"with-meta":{type:"boolean"},"with-edge-detail":{type:"boolean"},"find-complex-functions":{type:"boolean"},metric:{type:"string"},"complexity-threshold":{type:"string"},limit:{type:"string"},"find-duplicates":{type:"boolean"},"min-duplicate-lines":{type:"string"},"find-risk-hotspots":{type:"boolean"},"max-coverage-pct":{type:"string"},"min-churn":{type:"string"},"workspace-packages":{type:"boolean"},"workspace-affected":{type:"boolean"},"clear-cache":{type:"boolean"},slim:{type:"boolean"},watch:{type:"boolean"},base:{type:"string"}},du=new Set(Object.entries(un).filter(([,t])=>t.type==="string").map(([t])=>`--${t}`))});async function mn(t){let{graph:e,file:r,testsOnly:n,changedSymbols:o,cached:s,withMeta:i}=t;r||(console.error("Error: --affected requires --file <path>"),process.exit(1));let a=f=>i?f.map(g=>({path:g,...Y(e,g)})):f;if(s){let f=Xt(e),g=qt(f,r),y=n?g.filter(w=>e.nodes.get(w)?.category==="test"):g,x=a(y);console.log(JSON.stringify({file:r,affected:x,count:x.length},null,2));return}let c=pr(e,r,{testsOnly:n,changedSymbols:o}),p=a(c);console.log(JSON.stringify({file:r,affected:p,count:p.length},null,2))}var Li=m(()=>{"use strict";l();k()});import dn from"path";function ne(t){return t.filter(e=>{let r=dn.basename(e).toLowerCase();return Su.some(n=>r.includes(n))})}function Pt(t,e){return new vt().getChangedFiles(t,e).map(r=>dn.relative(t,dn.resolve(t,r)))}var Su,It=m(()=>{"use strict";l();Jr();Su=[".test.",".spec.","-test.","-spec."]});async function Oi(t){let{graph:e}=t,{rootDir:r,scanOptions:n,featureThreshold:o,rawConfig:s,base:i}=t,a=Pt(r,i);if(![...e.nodes.values()].some(f=>ne([f.path]).length>0)){let f=L(r,n);e=await R(r,ne(f),e,N(s))}let p=pn(e,a,{...o!==void 0&&{featureDetection:{minOutDegree:o}}});console.log(p.join(`
40
+ `))}var Gi=m(()=>{"use strict";l();k();It()});async function _i(t){let{graph:e,rootDir:r,entryPoints:n}=t,o=n.length?n:Jt(e,r);o.length===0&&(console.error("Error: No entry points found. Pass entry points as positional args or ensure package.json has a main/exports field."),process.exit(1));let s=Kt(e,o);console.log(JSON.stringify(s,null,2))}var ji=m(()=>{"use strict";l();k()});async function Wi(t){let{graph:e}=t,{rootDir:r,scanOptions:n,dryRun:o,plain:s,rawConfig:i}=t;if(s||console.log(o?"Dry run: computing tag changes...":"Applying tags to test files..."),e.nodes.size===0){let c=L(r,n);e=await R(r,ne(c),e,N(i))}let a=await Br(e,r,{dryRun:o});console.log(JSON.stringify(a,null,2))}var zi=m(()=>{"use strict";l();k();It()});async function $i(t){let{graph:e,functionName:r}=t;r||(console.error("Error: --call-graph requires --function <name>"),process.exit(1));let n=Qt(e,r);console.log(JSON.stringify(n,null,2))}var Bi=m(()=>{"use strict";l();k()});async function gn(t){let{graph:e,file:r,plain:n,depth:o,withEdgeDetail:s}=t;r||(console.error("Error: --callers requires --file <path>"),process.exit(1));let i=fr(e,r,{depth:o??1,withEdgeDetail:s});console.log(n?i.map(a=>a.file).join(`
41
+ `):JSON.stringify({file:r,callers:i,count:i.length},null,2))}var Ui=m(()=>{"use strict";l();k()});async function hn(t){let{graph:e}=t,r=e.findCycles();if(r.length>0){process.stderr.write(`Found ${r.length} cycle(s):
42
42
  `);for(let n of r)process.stderr.write(` ${n.join(" \u2192 ")}
43
- `);process.exit(1)}console.log("No cycles detected.")}var Mi=m(()=>{"use strict";l()});async function cn(t){let{graph:e}=t,r=[...e.nodes.values()].filter(n=>n.type==="markdown"&&n.staleFor&&n.staleFor.length>0).map(n=>({doc:n.path,staleFor:n.staleFor}));if(r.length>0){process.stderr.write(`Found ${r.length} doc(s) that may be out of date:
43
+ `);process.exit(1)}console.log("No cycles detected.")}var Hi=m(()=>{"use strict";l()});async function yn(t){let{graph:e}=t,r=[...e.nodes.values()].filter(n=>n.type==="markdown"&&n.staleFor&&n.staleFor.length>0).map(n=>({doc:n.path,staleFor:n.staleFor}));if(r.length>0){process.stderr.write(`Found ${r.length} doc(s) that may be out of date:
44
44
  `);for(let{doc:n,staleFor:o}of r)process.stderr.write(` ${n} \u2014 references changed more recently: ${o.join(", ")}
45
- `);process.exit(1)}console.log("No doc drift detected.")}var Ai=m(()=>{"use strict";l()});import Li from"fs";import Ri from"path";function Oi(t){let e=Ri.join(Ri.dirname(t),de),r=!1;for(let n of[t,e])Li.existsSync(n)&&(Li.unlinkSync(n),console.log(`Cache cleared: ${n}`),r=!0);r||console.log(`No cache file present at ${t}`)}var Gi=m(()=>{"use strict";l();w()});async function ln(t){let{graph:e,file:r,depth:n,withMeta:o}=t;r||(console.error("Error: --dependencies requires --file <path>"),process.exit(1));let s=er(e,r,n??1),i=o?s.map(a=>({...a,...V(e,a.path)})):s;console.log(JSON.stringify({file:r,dependencies:i},null,2))}var _i=m(()=>{"use strict";l();w()});async function pn(t){let{graph:e,file:r,withMeta:n}=t;r||(console.error("Error: --dependents requires --file <path>"),process.exit(1));let o=ke(e,r),s=n?o.map(i=>({...i,...V(e,i.path)})):o;console.log(JSON.stringify({file:r,dependents:s},null,2))}var ji=m(()=>{"use strict";l();w()});async function Wi(t){let{graph:e}=t,{rootDir:r,scanOptions:n,featureThreshold:o,rawConfig:s}=t;if(e.nodes.size===0){let c=R(r,n);e=await L(r,c,e,N(s))}let i=K(e.nodes,o!==void 0?{minOutDegree:o}:void 0),a=Array.from(i.values()).sort((c,p)=>p.outDegree-c.outDegree);console.log(JSON.stringify({features:a},null,2))}var zi=m(()=>{"use strict";l();w()});async function $i(t){let{graph:e}=t,{rootDir:r,scanOptions:n,minOutDegree:o,rawConfig:s}=t;if(e.nodes.size===0){let c=R(r,n);e=await L(r,c,e,N(s))}let i=be(e,o!==void 0?{minOutDegree:o}:void 0),a=Object.fromEntries(i.features);console.log(JSON.stringify({features:a,unassigned:i.unassigned},null,2))}var Ui=m(()=>{"use strict";l();w()});async function fn(t){let{graph:e,metric:r,complexityThreshold:n,limit:o}=t,s=n??10,i=nr(e,{metric:r,threshold:s,limit:o});console.log(JSON.stringify({metric:r??"cognitiveComplexity",threshold:s,functions:i,count:i.length},null,2))}var Bi=m(()=>{"use strict";l();w()});import Ji from"path";async function un(t){let{graph:e,rootDir:r,scanOptions:n,minDuplicateLines:o,limit:s,cachePath:i}=t,a=o??6,c=[...n.ignoreDirs??J,...n.additionalIgnoreDirs??[]],p=Ji.join(Ji.dirname(i),de),f=Qe(p),{groups:d}=await Yt(e,r,{minLines:a,limit:s,ignoreDirs:c,tokenCache:f});Ye(f,p),console.log(JSON.stringify({minLines:a,groups:d,count:d.length},null,2))}var Ki=m(()=>{"use strict";l();w()});async function Hi(t){let{graph:e,functionName:r,plain:n}=t;r||(console.error("Error: --find-symbol requires --function <name>"),process.exit(1));let o=pr(e,r);console.log(n?o.map(s=>s.path).join(`
46
- `):JSON.stringify({name:r,matches:o,count:o.length},null,2))}var Vi=m(()=>{"use strict";l();w()});async function mn(t){let{graph:e,featureThreshold:r,rawConfig:n,plain:o}=t,s=r??n.coverageThreshold??80;if(!ir(e)){console.log(JSON.stringify({error:"No coverage data available. Set coverageReportPath in mokosh.config and rebuild the graph."},null,2));return}let i=[...e.nodes.values()].filter(a=>a.category!=="test"&&a.category!=="config").filter(a=>a.coveragePct!==void 0&&a.coveragePct<s).map(a=>({file:a.path,coveragePct:a.coveragePct}));console.log(o?i.map(a=>a.file).join(`
47
- `):JSON.stringify({threshold:s,uncovered:i,count:i.length},null,2))}var Qi=m(()=>{"use strict";l();w()});import Qf from"path";function Xf(t){let e=Qf.basename(t).toLowerCase();return Yf.some(r=>e.includes(r))}async function Yi(t){let{graph:e,rootDir:r,scanOptions:n,excludeTests:o}=t,s=R(r,n),i=e.findUnusedFiles(s);o&&(i=i.filter(a=>!Xf(a))),console.log(JSON.stringify({unusedFiles:i},null,2))}var Yf,Xi=m(()=>{"use strict";l();w();Yf=[".test.",".spec.","-test.","-spec.",".stories."]});async function gn(t){let{graph:e,queryStr:r,mermaidOutput:n,slim:o}=t,s=e.serialize();if(r){let c=at(r);s=it(s,c)}if(n){let c=D.deserialize(s);console.log(Be.serialize(c));return}let i=e.findCycles();i.length>0&&(s.cycles=i);let a=qt(e);console.log(JSON.stringify(o?{...or(s),languageCoverage:a}:{...s,languageCoverage:a},null,2))}var qi=m(()=>{"use strict";l();w()});import qf from"fs";import dn from"path";function Tt(t,e,r){let n=t;for(let o=0;o<6;o++){let s=dn.join(n,"templates",...e);if(qf.existsSync(dn.join(s,r)))return s;let i=dn.dirname(n);if(i===n)break;n=i}throw new Error(`Could not locate mokosh templates/${e.join("/")}`)}var hn=m(()=>{"use strict";l()});import Zi from"fs";import ea from"path";function ta(t,e=process.cwd()){let r=Tt(u,["config"],"mokosh.config.js"),n=ea.join(r,"mokosh.config.js"),o=ea.join(e,"mokosh.config.js");if(Zi.existsSync(o)&&!t){console.log("skipped mokosh.config.js (already exists, use --force to overwrite)");return}Zi.copyFileSync(n,o),console.log("wrote mokosh.config.js")}var ra=m(()=>{"use strict";l();hn()});import yn from"fs";import Ft from"path";function na(t,e=process.cwd()){let r=Tt(u,["skill"],"SKILL.md");for(let n of Zf){let o=Ft.join(r,n.templateFile),s=Ft.join(e,...n.destPath),i=Ft.join(...n.destPath);if(yn.existsSync(s)&&!t){console.log(`skipped ${i} (already exists, use --force to overwrite)`);continue}yn.mkdirSync(Ft.dirname(s),{recursive:!0}),yn.copyFileSync(o,s),console.log(`wrote ${i}`)}}var Zf,oa=m(()=>{"use strict";l();hn();Zf=[{templateFile:"SKILL.md",destPath:[".claude","skills","mokosh","SKILL.md"]},{templateFile:"mokosh.md",destPath:[".claude","commands","mokosh.md"]}]});async function xn(t){let{graph:e,plain:r}=t,n=new Map;for(let s of e.nodes.values())for(let i of s.tags)n.set(i.name,(n.get(i.name)??0)+1);let o=[...n.entries()].map(([s,i])=>({name:s,count:i})).sort((s,i)=>i.count-s.count);console.log(r?o.map(s=>s.name).join(`
48
- `):JSON.stringify({tags:o,count:o.length},null,2))}var sa=m(()=>{"use strict";l()});async function ia(t){let{graph:e,filterPaths:r,minOutDegree:n}=t,o=cr(e,n!==void 0?{minOutDegree:n}:void 0);if(r?.length){let s=r.map(i=>o.get(i)).filter(Boolean);console.log(JSON.stringify({count:s.length,modules:s},null,2))}else{let s=Array.from(o.values());console.log(JSON.stringify({count:s.length,modules:s},null,2))}}var aa=m(()=>{"use strict";l();w()});async function ca(t){let{graph:e}=t,{rootDir:r,scanOptions:n,featureThreshold:o,plain:s,rawConfig:i}=t;s||console.log("Proposing test tags based on git diff...");let a=wt(r);if(e.nodes.size===0){let p=R(r,n);e=await L(r,ee(p),e,N(i))}let c=Zr(e,a,{...o!==void 0&&{featureDetection:{minOutDegree:o}}});console.log(s?c.join(" "):JSON.stringify({proposedTags:c},null,2))}var la=m(()=>{"use strict";l();w();Et()});async function pa(t){let{graph:e,typeFilter:r}=t,n=fr(e);if(r){let o=ur(n,r);console.log(JSON.stringify(o,null,2))}else{let o=Array.from(n.types.values());console.log(JSON.stringify({count:o.length,types:o},null,2))}}var fa=m(()=>{"use strict";l();w()});function ua(t,e){let r=t.getAffectedAcrossPackages(e);console.log(JSON.stringify({file:e,affected:r,count:r.length},null,2))}var ma=m(()=>{"use strict";l()});function ga(t){console.log(JSON.stringify(sr(t),null,2))}var da=m(()=>{"use strict";l();w()});import bn from"path";function eu(t,e,r,n){return t!==e?t:r?bn.resolve(n,r):e}function ha(t){let{rootDir:e,entryPoints:r,cachePath:n,configPath:o}=t,s=o?ne(o,{isExplicitPath:!0}):ne(e),i=bn.join(bn.resolve(e,oe),se),a=r.length>0?r:s.entryPoints??[],c=eu(n,i,s.cachePath,e),p={...s.ignoreDirs!==void 0&&{additionalIgnoreDirs:s.ignoreDirs},...s.extensions!==void 0&&{additionalExtensions:s.extensions}};return{rootDir:e,resolvedEntryPoints:a,resolvedCachePath:c,scanOptions:p,rawConfig:s}}var ya=m(()=>{"use strict";l();w();tn()});import We from"fs";import tu from"path";function xa(t){if(!We.existsSync(t))return null;let e=We.readFileSync(t,"utf-8");return D.deserialize(JSON.parse(e))}function Sn(t,e){let r=tu.dirname(e);We.existsSync(r)||We.mkdirSync(r,{recursive:!0}),We.writeFileSync(e,JSON.stringify(t.serialize(),null,2))}async function Cn(t,e,r,n={silent:!1,...N(void 0)}){return L(t,e,r,n)}var ba=m(()=>{"use strict";l();w()});var Sa,Ca,ka=m(()=>{"use strict";l();Sa=`
45
+ `);process.exit(1)}console.log("No doc drift detected.")}var Ji=m(()=>{"use strict";l()});import Ki from"fs";import Vi from"path";function Qi(t){let e=Vi.join(Vi.dirname(t),xe),r=!1;for(let n of[t,e])Ki.existsSync(n)&&(Ki.unlinkSync(n),console.log(`Cache cleared: ${n}`),r=!0);r||console.log(`No cache file present at ${t}`)}var Yi=m(()=>{"use strict";l();k()});async function xn(t){let{graph:e,file:r,depth:n,withMeta:o}=t;r||(console.error("Error: --dependencies requires --file <path>"),process.exit(1));let s=lr(e,r,n??1),i=o?s.map(a=>({...a,...Y(e,a.path)})):s;console.log(JSON.stringify({file:r,dependencies:i},null,2))}var Xi=m(()=>{"use strict";l();k()});async function bn(t){let{graph:e,file:r,withMeta:n}=t;r||(console.error("Error: --dependents requires --file <path>"),process.exit(1));let o=Te(e,r),s=n?o.map(i=>({...i,...Y(e,i.path)})):o;console.log(JSON.stringify({file:r,dependents:s},null,2))}var qi=m(()=>{"use strict";l();k()});async function Zi(t){let{graph:e}=t,{rootDir:r,scanOptions:n,featureThreshold:o,rawConfig:s}=t;if(e.nodes.size===0){let c=L(r,n);e=await R(r,c,e,N(s))}let i=V(e.nodes,o!==void 0?{minOutDegree:o}:void 0),a=Array.from(i.values()).sort((c,p)=>p.outDegree-c.outDegree);console.log(JSON.stringify({features:a},null,2))}var ea=m(()=>{"use strict";l();k()});async function ta(t){let{graph:e}=t,{rootDir:r,scanOptions:n,minOutDegree:o,rawConfig:s}=t;if(e.nodes.size===0){let c=L(r,n);e=await R(r,c,e,N(s))}let i=ke(e,o!==void 0?{minOutDegree:o}:void 0),a=Object.fromEntries(i.features);console.log(JSON.stringify({features:a,unassigned:i.unassigned},null,2))}var ra=m(()=>{"use strict";l();k()});async function Sn(t){let{graph:e,metric:r,complexityThreshold:n,limit:o}=t,s=n??10,i=ur(e,{metric:r,threshold:s,limit:o});console.log(JSON.stringify({metric:r??"cognitiveComplexity",threshold:s,functions:i,count:i.length},null,2))}var na=m(()=>{"use strict";l();k()});import oa from"path";async function Cn(t){let{graph:e,rootDir:r,scanOptions:n,minDuplicateLines:o,limit:s,cachePath:i}=t,a=o??6,c=[...n.ignoreDirs??K,...n.additionalIgnoreDirs??[]],p=oa.join(oa.dirname(i),xe),f=et(p),{groups:g}=await sr(e,r,{minLines:a,limit:s,ignoreDirs:c,tokenCache:f});tt(f,p),console.log(JSON.stringify({minLines:a,groups:g,count:g.length},null,2))}var sa=m(()=>{"use strict";l();k()});async function kn(t){let{graph:e,metric:r,complexityThreshold:n,maxCoveragePct:o,minChurn:s,limit:i}=t;if(!Ee(e)){console.log(JSON.stringify({error:"No coverage data available. Set coverageReportPath in mokosh.config and rebuild the graph."},null,2));return}let a=n??10,c=o??50,p=s??0,{hotspots:f,count:g,churnDataAvailable:y}=gr(e,{metric:r,minComplexity:a,maxCoveragePct:c,minChurn:p,limit:i});console.log(JSON.stringify({metric:r??"cognitiveComplexity",minComplexity:a,maxCoveragePct:c,minChurn:p,churnDataAvailable:y,hotspots:f,count:g},null,2))}var ia=m(()=>{"use strict";l();k()});async function aa(t){let{graph:e,functionName:r,plain:n}=t;r||(console.error("Error: --find-symbol requires --function <name>"),process.exit(1));let o=br(e,r);console.log(n?o.map(s=>s.path).join(`
46
+ `):JSON.stringify({name:r,matches:o,count:o.length},null,2))}var ca=m(()=>{"use strict";l();k()});async function vn(t){let{graph:e,featureThreshold:r,rawConfig:n,plain:o}=t,s=r??n.coverageThreshold??80;if(!Ee(e)){console.log(JSON.stringify({error:"No coverage data available. Set coverageReportPath in mokosh.config and rebuild the graph."},null,2));return}let i=[...e.nodes.values()].filter(a=>a.category!=="test"&&a.category!=="config").filter(a=>a.coveragePct!==void 0&&a.coveragePct<s).map(a=>({file:a.path,coveragePct:a.coveragePct}));console.log(o?i.map(a=>a.file).join(`
47
+ `):JSON.stringify({threshold:s,uncovered:i,count:i.length},null,2))}var la=m(()=>{"use strict";l();k()});import Cu from"path";function vu(t){let e=Cu.basename(t).toLowerCase();return ku.some(r=>e.includes(r))}async function pa(t){let{graph:e,rootDir:r,scanOptions:n,excludeTests:o}=t,s=L(r,n),i=e.findUnusedFiles(s);o&&(i=i.filter(a=>!vu(a))),console.log(JSON.stringify({unusedFiles:i},null,2))}var ku,fa=m(()=>{"use strict";l();k();ku=[".test.",".spec.","-test.","-spec.",".stories."]});async function wn(t){let{graph:e,queryStr:r,mermaidOutput:n,slim:o}=t,s=e.serialize();if(r){let c=ut(r);s=ft(s,c)}if(n){let c=D.deserialize(s);console.log(Qe.serialize(c));return}let i=e.findCycles();i.length>0&&(s.cycles=i);let a=ar(e);console.log(JSON.stringify(o?{...mr(s),languageCoverage:a}:{...s,languageCoverage:a},null,2))}var ua=m(()=>{"use strict";l();k()});import wu from"fs";import Tn from"path";function Dt(t,e,r){let n=t;for(let o=0;o<6;o++){let s=Tn.join(n,"templates",...e);if(wu.existsSync(Tn.join(s,r)))return s;let i=Tn.dirname(n);if(i===n)break;n=i}throw new Error(`Could not locate mokosh templates/${e.join("/")}`)}var En=m(()=>{"use strict";l()});import ma from"fs";import da from"path";function ga(t,e=process.cwd()){let r=Dt(u,["config"],"mokosh.config.js"),n=da.join(r,"mokosh.config.js"),o=da.join(e,"mokosh.config.js");if(ma.existsSync(o)&&!t){console.log("skipped mokosh.config.js (already exists, use --force to overwrite)");return}ma.copyFileSync(n,o),console.log("wrote mokosh.config.js")}var ha=m(()=>{"use strict";l();En()});import Fn from"fs";import Mt from"path";function ya(t,e=process.cwd()){let r=Dt(u,["skill"],"SKILL.md");for(let n of Tu){let o=Mt.join(r,n.templateFile),s=Mt.join(e,...n.destPath),i=Mt.join(...n.destPath);if(Fn.existsSync(s)&&!t){console.log(`skipped ${i} (already exists, use --force to overwrite)`);continue}Fn.mkdirSync(Mt.dirname(s),{recursive:!0}),Fn.copyFileSync(o,s),console.log(`wrote ${i}`)}}var Tu,xa=m(()=>{"use strict";l();En();Tu=[{templateFile:"SKILL.md",destPath:[".claude","skills","mokosh","SKILL.md"]},{templateFile:"mokosh.md",destPath:[".claude","commands","mokosh.md"]}]});async function Nn(t){let{graph:e,plain:r}=t,n=new Map;for(let s of e.nodes.values())for(let i of s.tags)n.set(i.name,(n.get(i.name)??0)+1);let o=[...n.entries()].map(([s,i])=>({name:s,count:i})).sort((s,i)=>i.count-s.count);console.log(r?o.map(s=>s.name).join(`
48
+ `):JSON.stringify({tags:o,count:o.length},null,2))}var ba=m(()=>{"use strict";l()});async function Sa(t){let{graph:e,filterPaths:r,minOutDegree:n}=t,o=yr(e,n!==void 0?{minOutDegree:n}:void 0);if(r?.length){let s=r.map(i=>o.get(i)).filter(Boolean);console.log(JSON.stringify({count:s.length,modules:s},null,2))}else{let s=Array.from(o.values());console.log(JSON.stringify({count:s.length,modules:s},null,2))}}var Ca=m(()=>{"use strict";l();k()});async function ka(t){let{graph:e}=t,{rootDir:r,scanOptions:n,featureThreshold:o,plain:s,rawConfig:i,base:a}=t;s||console.log("Proposing test tags based on git diff...");let c=Pt(r,a);if(e.nodes.size===0){let f=L(r,n);e=await R(r,ne(f),e,N(i))}let p=ln(e,c,{...o!==void 0&&{featureDetection:{minOutDegree:o}}});console.log(s?p.join(" "):JSON.stringify({proposedTags:p},null,2))}var va=m(()=>{"use strict";l();k();It()});async function wa(t){let{graph:e,typeFilter:r}=t,n=Sr(e);if(r){let o=Cr(n,r);console.log(JSON.stringify(o,null,2))}else{let o=Array.from(n.types.values());console.log(JSON.stringify({count:o.length,types:o},null,2))}}var Ta=m(()=>{"use strict";l();k()});function Ea(t,e){let r=t.getAffectedAcrossPackages(e);console.log(JSON.stringify({file:e,affected:r,count:r.length},null,2))}var Fa=m(()=>{"use strict";l()});function Na(t){console.log(JSON.stringify(dr(t),null,2))}var Pa=m(()=>{"use strict";l();k()});import Pn from"path";function Eu(t,e,r,n){return t!==e?t:r?Pn.resolve(n,r):e}function Ia(t){let{rootDir:e,entryPoints:r,cachePath:n,configPath:o}=t,s=o?ie(o,{isExplicitPath:!0}):ie(e),i=Pn.join(Pn.resolve(e,ae),ce),a=r.length>0?r:s.entryPoints??[],c=Eu(n,i,s.cachePath,e),p={...s.ignoreDirs!==void 0&&{additionalIgnoreDirs:s.ignoreDirs},...s.extensions!==void 0&&{additionalExtensions:s.extensions}};return{rootDir:e,resolvedEntryPoints:a,resolvedCachePath:c,scanOptions:p,rawConfig:s}}var Da=m(()=>{"use strict";l();k();fn()});import Ue from"fs";import Fu from"path";function Ma(t){if(!Ue.existsSync(t))return null;let e=Ue.readFileSync(t,"utf-8");return D.deserialize(JSON.parse(e))}function In(t,e){let r=Fu.dirname(e);Ue.existsSync(r)||Ue.mkdirSync(r,{recursive:!0}),Ue.writeFileSync(e,JSON.stringify(t.serialize(),null,2))}async function Dn(t,e,r,n={silent:!1,...N(void 0)}){return R(t,e,r,n)}var Aa=m(()=>{"use strict";l();k()});var Ra,La,Oa=m(()=>{"use strict";l();Ra=`
49
49
  Usage: mokosh [options] <entry-point1> <entry-point2> ...
50
50
 
51
51
  Options:
@@ -55,6 +55,9 @@ Options:
55
55
  --propose-tags Propose test tags based on git diff
56
56
  --plain Output tags as plain text instead of JSON (use with --propose-tags)
57
57
  --affected-tests List test files affected by git diff
58
+ --base <ref> Diff against this ref (e.g. origin/main) instead of only local
59
+ working-tree/staged/untracked changes (use with --propose-tags/
60
+ --affected-tests); needed in CI, where the tree is already clean
58
61
  --apply-tags Write @tag annotations into test files from graph tags
59
62
  --dry-run Preview tag changes without writing to disk (use with --apply-tags)
60
63
  --detect-features Output files with high out-degree (orchestrators/aggregators)
@@ -112,6 +115,11 @@ MCP parity (mirrors the MCP server's tools for use when MCP is unavailable):
112
115
  always excluded
113
116
  --min-duplicate-lines <N> Minimum duplicated block size in lines to report (default: 6,
114
117
  use with --find-duplicates)
118
+ --find-risk-hotspots List functions that are complex, undertested, and (if gitStats is
119
+ enabled) frequently changed \u2014 requires coverageReportPath in config
120
+ --max-coverage-pct <N> Max file coverage % to include (default: 50, use with --find-risk-hotspots)
121
+ --min-churn <N> Min 90-day commit count to include (default: 0, ignored if gitStats
122
+ is off; use with --find-risk-hotspots)
115
123
  --workspace-packages List monorepo packages and their cross-package dependencies
116
124
  --workspace-affected Cross-package blast-radius for --file in a monorepo
117
125
  --find-symbol Find every file that exports --function <name> by exact name, with
@@ -119,8 +127,8 @@ MCP parity (mirrors the MCP server's tools for use when MCP is unavailable):
119
127
  precision for TS/JS, named-import for Python, file-level otherwise)
120
128
  --watch Re-run on file changes. Supported with the default output, --query,
121
129
  --callers, --dependencies, --dependents, --affected, --find-uncovered,
122
- --find-complex-functions, --find-duplicates, --check-cycles,
123
- --check-doc-drift, and
130
+ --find-complex-functions, --find-duplicates, --find-risk-hotspots,
131
+ --check-cycles, --check-doc-drift, and
124
132
  --list-tags only.
125
133
 
126
134
  Notes:
@@ -132,7 +140,7 @@ Notes:
132
140
  server only loads JSON config (allowJs: false) for security. This is intentional.
133
141
  --workspace-packages/--workspace-affected require explicit opt-in (unlike MCP's analyze tool,
134
142
  which auto-detects a monorepo when entryPoints is empty); other commands remain single-package.
135
- `,Ca=`
143
+ `,La=`
136
144
  Query filter reference (--query "key:value,key:value,...")
137
145
  All keys are case-insensitive. Multiple keys are AND'd together.
138
146
 
@@ -255,5 +263,5 @@ COMMON PATTERNS
255
263
 
256
264
  Large TypeScript logic files:
257
265
  --query "type:typescript,category:logic,sort:size,limit:5"
258
- `});var va,wa=m(()=>{"use strict";l();va=/(?:^|[/\\])(?:node_modules|\.git|dist|build|coverage)(?:[/\\]|$)/});import ru from"fs";function Ea(t,e,r){let n=null,o=!1,s=!1,i=async()=>{if(o){s=!0;return}o=!0;try{await r()}finally{o=!1,s&&(s=!1,i())}};i();let a=null;try{a=ru.watch(t,{recursive:!0},(c,p)=>{!p||va.test(p)||(n&&clearTimeout(n),n=setTimeout(()=>{i()},e))})}catch(c){console.error(`Warning: unable to watch ${t}: ${c.message}`)}process.on("SIGINT",()=>{n&&clearTimeout(n),a?.close(),process.exit(0)})}var Ta=m(()=>{"use strict";l();wa()});function ou(t){t.help&&(console.log(Sa),process.exit(0)),t.queryHelp&&(console.log(Ca),process.exit(0)),t.initSkill&&(na(t.force),process.exit(0)),t.initConfig&&(ta(t.force),process.exit(0)),t.clearCache&&(Oi(t.cachePath),process.exit(0))}async function su(t,e,r){if(!t.workspacePackages&&!t.workspaceAffected)return!1;t.watch&&(console.error("Error: --watch is not supported with --workspace-packages/--workspace-affected"),process.exit(1));let n=await xi(r,N(e.rawConfig));return t.workspacePackages?ga(n):(t.file||(console.error("Error: --workspace-affected requires --file <path>"),process.exit(1)),ua(n,t.file)),!0}function iu(t){return t.proposeTags||t.affectedTests||t.applyTags||t.callers||t.dependencies||t.dependents||t.affected||t.findUncovered||t.listTags||t.findComplexFunctions||t.findDuplicates||t.typeGraph||t.moduleResponsibility||t.callGraph||t.findSymbol||t.apiSurface}function au(t){let r=[{name:"--propose-tags",flag:t.proposeTags,handler:ca},{name:"--apply-tags",flag:t.applyTags,handler:Fi},{name:"--affected-tests",flag:t.affectedTests,handler:vi},{name:"--detect-features",flag:t.detectFeatures,handler:Wi},{name:"--find-unused",flag:t.findUnused,handler:Yi},{name:"--check-cycles",flag:t.checkCycles,handler:an},{name:"--check-doc-drift",flag:t.checkDocDrift,handler:cn},{name:"--find-uncovered",flag:t.findUncovered,handler:mn},{name:"--list-tags",flag:t.listTags,handler:xn},{name:"--callers",flag:t.callers,handler:sn},{name:"--dependencies",flag:t.dependencies,handler:ln},{name:"--dependents",flag:t.dependents,handler:pn},{name:"--affected",flag:t.affected,handler:nn},{name:"--find-complex-functions",flag:t.findComplexFunctions,handler:fn},{name:"--find-duplicates",flag:t.findDuplicates,handler:un},{name:"--type-graph",flag:t.typeGraph,handler:pa},{name:"--module-responsibility",flag:t.moduleResponsibility,handler:ia},{name:"--feature-graph",flag:t.featureGraph,handler:$i},{name:"--call-graph",flag:t.callGraph,handler:Pi},{name:"--find-symbol",flag:t.findSymbol,handler:Hi},{name:"--api-surface",flag:t.apiSurface,handler:Ei}].filter(n=>n.flag);return r.length>1&&(console.error(`Error: conflicting flags: ${r.map(n=>n.name).join(", ")} (pass only one command flag)`),process.exit(1)),r[0]?.handler??gn}async function cu(t,e,r,n,o,s,i){nu.has(t)||(console.error("Error: --watch is only supported with the default output, --query, --callers, --dependencies, --dependents, --affected, --find-uncovered, --find-complex-functions, --find-duplicates, --check-cycles, --check-doc-drift, and --list-tags"),process.exit(1)),Ea(r,300,async()=>{let a=await Cn(r,n,e.graph,{silent:s,...N(i)});Sn(a,o),console.log(`--- rebuilt at ${new Date().toISOString()} ---`),await t({...e,graph:a})})}async function Fa(){let t=process.argv.slice(2),e=Si(t);ou(e);let r=ha(e);At(r.rawConfig);let{rootDir:n,resolvedEntryPoints:o,resolvedCachePath:s,scanOptions:i}=r;if(await su(e,r,n))return;let a=iu(e),c=xa(s)??new D(new Map);(o.length>0||!a)&&(o.length===0&&!a&&!e.findUnused&&!e.detectFeatures&&!e.checkCycles&&!e.checkDocDrift&&(console.error("Error: No entry points provided"),process.exit(1)),c=await Cn(n,o,c,{silent:e.silent,...N(r.rawConfig)}),Sn(c,s));let p={graph:c,rootDir:n,cachePath:s,entryPoints:o.map(d=>d.replace(`${n}/`,"")),scanOptions:i,rawConfig:r.rawConfig,featureThreshold:e.featureThreshold,queryStr:e.query,mermaidOutput:e.mermaid,plain:e.plain,excludeTests:e.excludeTests,file:e.file,typeFilter:e.typeFilter,filterPaths:e.filterPaths,minOutDegree:e.minOutDegree,functionName:e.functionName,dryRun:e.dryRun,depth:e.depth,cached:e.cached,changedSymbols:e.changedSymbols,withMeta:e.withMeta,withEdgeDetail:e.withEdgeDetail,metric:e.metric,complexityThreshold:e.complexityThreshold,limit:e.limit,slim:e.slim,testsOnly:e.testsOnly,minDuplicateLines:e.minDuplicateLines},f=au(e);if(e.watch){await cu(f,p,n,o,s,e.silent,r.rawConfig);return}await f(p)}var nu,Na=m(()=>{"use strict";l();w();Ci();ki();wi();Ti();Ni();Ii();Di();Mi();Ai();Gi();_i();ji();zi();Ui();Bi();Ki();Vi();Qi();Xi();qi();ra();oa();sa();aa();la();fa();ma();da();ya();ba();ka();Ta();nu=new Set([gn,sn,ln,pn,nn,mn,fn,un,an,cn,xn])});var lu=Pa(()=>{l();Na();Fa().catch(t=>{console.error(t),process.exit(1)})});export default lu();
266
+ `});var Ga,_a=m(()=>{"use strict";l();Ga=/(?:^|[/\\])(?:node_modules|\.git|dist|build|coverage)(?:[/\\]|$)/});import Nu from"fs";function ja(t,e,r){let n=null,o=!1,s=!1,i=async()=>{if(o){s=!0;return}o=!0;try{await r()}finally{o=!1,s&&(s=!1,i())}};i();let a=null;try{a=Nu.watch(t,{recursive:!0},(c,p)=>{!p||Ga.test(p)||(n&&clearTimeout(n),n=setTimeout(()=>{i()},e))})}catch(c){console.error(`Warning: unable to watch ${t}: ${c.message}`)}process.on("SIGINT",()=>{n&&clearTimeout(n),a?.close(),process.exit(0)})}var Wa=m(()=>{"use strict";l();_a()});function Iu(t){t.help&&(console.log(Ra),process.exit(0)),t.queryHelp&&(console.log(La),process.exit(0)),t.initSkill&&(ya(t.force),process.exit(0)),t.initConfig&&(ga(t.force),process.exit(0)),t.clearCache&&(Qi(t.cachePath),process.exit(0))}async function Du(t,e,r){if(!t.workspacePackages&&!t.workspaceAffected)return!1;t.watch&&(console.error("Error: --watch is not supported with --workspace-packages/--workspace-affected"),process.exit(1));let n=await Di(r,N(e.rawConfig));return t.workspacePackages?Na(n):(t.file||(console.error("Error: --workspace-affected requires --file <path>"),process.exit(1)),Ea(n,t.file)),!0}function Mu(t){return t.proposeTags||t.affectedTests||t.applyTags||t.callers||t.dependencies||t.dependents||t.affected||t.findUncovered||t.listTags||t.findComplexFunctions||t.findDuplicates||t.findRiskHotspots||t.typeGraph||t.moduleResponsibility||t.callGraph||t.findSymbol||t.apiSurface}function Au(t){let r=[{name:"--propose-tags",flag:t.proposeTags,handler:ka},{name:"--apply-tags",flag:t.applyTags,handler:Wi},{name:"--affected-tests",flag:t.affectedTests,handler:Oi},{name:"--detect-features",flag:t.detectFeatures,handler:Zi},{name:"--find-unused",flag:t.findUnused,handler:pa},{name:"--check-cycles",flag:t.checkCycles,handler:hn},{name:"--check-doc-drift",flag:t.checkDocDrift,handler:yn},{name:"--find-uncovered",flag:t.findUncovered,handler:vn},{name:"--list-tags",flag:t.listTags,handler:Nn},{name:"--callers",flag:t.callers,handler:gn},{name:"--dependencies",flag:t.dependencies,handler:xn},{name:"--dependents",flag:t.dependents,handler:bn},{name:"--affected",flag:t.affected,handler:mn},{name:"--find-complex-functions",flag:t.findComplexFunctions,handler:Sn},{name:"--find-duplicates",flag:t.findDuplicates,handler:Cn},{name:"--find-risk-hotspots",flag:t.findRiskHotspots,handler:kn},{name:"--type-graph",flag:t.typeGraph,handler:wa},{name:"--module-responsibility",flag:t.moduleResponsibility,handler:Sa},{name:"--feature-graph",flag:t.featureGraph,handler:ta},{name:"--call-graph",flag:t.callGraph,handler:$i},{name:"--find-symbol",flag:t.findSymbol,handler:aa},{name:"--api-surface",flag:t.apiSurface,handler:_i}].filter(n=>n.flag);return r.length>1&&(console.error(`Error: conflicting flags: ${r.map(n=>n.name).join(", ")} (pass only one command flag)`),process.exit(1)),r[0]?.handler??wn}async function Ru(t,e,r,n,o,s,i){Pu.has(t)||(console.error("Error: --watch is only supported with the default output, --query, --callers, --dependencies, --dependents, --affected, --find-uncovered, --find-complex-functions, --find-duplicates, --find-risk-hotspots, --check-cycles, --check-doc-drift, and --list-tags"),process.exit(1)),ja(r,300,async()=>{let a=await Dn(r,n,e.graph,{silent:s,...N(i)});In(a,o),console.log(`--- rebuilt at ${new Date().toISOString()} ---`),await t({...e,graph:a})})}async function za(){let t=process.argv.slice(2),e=Ai(t);Iu(e);let r=Ia(e);$t(r.rawConfig);let{rootDir:n,resolvedEntryPoints:o,resolvedCachePath:s,scanOptions:i}=r;if(await Du(e,r,n))return;let a=Mu(e),c=Ma(s)??new D(new Map);(o.length>0||!a)&&(o.length===0&&!a&&!e.findUnused&&!e.detectFeatures&&!e.checkCycles&&!e.checkDocDrift&&(console.error("Error: No entry points provided"),process.exit(1)),c=await Dn(n,o,c,{silent:e.silent,...N(r.rawConfig)}),In(c,s));let p={graph:c,rootDir:n,cachePath:s,entryPoints:o.map(g=>g.replace(`${n}/`,"")),scanOptions:i,rawConfig:r.rawConfig,featureThreshold:e.featureThreshold,queryStr:e.query,mermaidOutput:e.mermaid,plain:e.plain,excludeTests:e.excludeTests,file:e.file,typeFilter:e.typeFilter,filterPaths:e.filterPaths,minOutDegree:e.minOutDegree,functionName:e.functionName,dryRun:e.dryRun,depth:e.depth,cached:e.cached,changedSymbols:e.changedSymbols,withMeta:e.withMeta,withEdgeDetail:e.withEdgeDetail,metric:e.metric,complexityThreshold:e.complexityThreshold,limit:e.limit,slim:e.slim,testsOnly:e.testsOnly,minDuplicateLines:e.minDuplicateLines,maxCoveragePct:e.maxCoveragePct,minChurn:e.minChurn,base:e.base},f=Au(e);if(e.watch){await Ru(f,p,n,o,s,e.silent,r.rawConfig);return}await f(p)}var Pu,$a=m(()=>{"use strict";l();k();Ri();Li();Gi();ji();zi();Bi();Ui();Hi();Ji();Yi();Xi();qi();ea();ra();na();sa();ia();ca();la();fa();ua();ha();xa();ba();Ca();va();Ta();Fa();Pa();Da();Aa();Oa();Wa();Pu=new Set([wn,gn,xn,bn,mn,vn,Sn,Cn,kn,hn,yn,Nn])});var Lu=Ba(()=>{l();$a();za().catch(t=>{console.error(t),process.exit(1)})});export default Lu();
259
267
  //# sourceMappingURL=cli.mjs.map