@omfalos/mokosh 0.5.1 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +92 -49
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +93 -50
- package/dist/cli.mjs.map +1 -1
- package/dist/duplication-worker.js +6 -6
- package/dist/duplication-worker.js.map +1 -1
- package/dist/duplication-worker.mjs +6 -6
- package/dist/duplication-worker.mjs.map +1 -1
- package/dist/index.d.mts +988 -40
- package/dist/index.d.ts +988 -40
- package/dist/index.js +47 -39
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +48 -40
- package/dist/index.mjs.map +1 -1
- package/dist/mcp.js +52 -43
- package/dist/mcp.js.map +1 -1
- package/dist/mcp.mjs +52 -43
- package/dist/mcp.mjs.map +1 -1
- package/dist/parse-worker.d.mts +1 -1
- package/dist/parse-worker.d.ts +1 -1
- package/dist/parse-worker.js +6 -6
- package/dist/parse-worker.js.map +1 -1
- package/dist/parse-worker.mjs +6 -6
- package/dist/parse-worker.mjs.map +1 -1
- package/dist/{types-DWARi8gF.d.ts → types-B4jVIqMD.d.ts} +3 -0
- package/dist/{types-Ba-BjVQG.d.mts → types-qfwcXiZS.d.mts} +3 -0
- package/package.json +1 -1
- package/templates/skill/SKILL.md +1 -1
- package/templates/skill/mokosh.md +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -1,65 +1,73 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var
|
|
3
|
-
`)}}});var
|
|
4
|
-
`)){if(o.startsWith("\0")){let[,c,
|
|
5
|
-
`).map(a=>a.trim()).filter(a=>a!=="")}catch{return[]}});return Array.from(new Set(o))}catch(r){return console.error("Error getting git diff:",r),[]}}},
|
|
6
|
-
`).filter(c=>c.trim().length>0&&!c.trim().startsWith("#"));if(r.length<2)continue;let o=r[0];if(!o||o.startsWith(" "))continue;let s=
|
|
7
|
-
`&&n++;return n}var
|
|
8
|
-
`)){let o=r.trim();if(!o||o.startsWith("@")||o.startsWith("*"))continue;let s=o.match(/^package\s+(?:object\s+)?([\w.]+)/);if(s?.[1]){if(n.push(s[1]),!e)break;continue}if(!(e&&/^import\s/.test(o)))break}return n.length>0?n.join("."):null}function
|
|
9
|
-
`),s=[],i=new Set;for(let
|
|
10
|
-
`),s=[],i=new Set;for(let p of o){let f=p.match(cf);if(f?.[1]){s.push(De(t,f[1]));continue}let m=p.match(lf);if(m?.[2]){i.add(m[2]);continue}let h=p.match(pf);if(h?.[1]){i.add(h[1]);continue}let y=p.match(ff);y?.[1]&&i.add(y[1])}let a=$(e,!1);a&&s.push(te(t,a));let c=Array.from(i,p=>({name:p}));return{imports:s,exports:c,tags:Array.from(n).map(p=>({name:p,kind:"comment-marker"})),category:H(t,s.map(p=>p.rawSpecifier),{typeNames:[...i],annotations:Pe(e).annotations})}}var cf,pr,lf,pf,ff,Ys=d(()=>{"use strict";l();Re();cf=/^\s*import\s+([\w.]+(?:\.\*)?)(?:\s+as\s+\w+)?\s*$/,pr="(?:public\\s+|internal\\s+|private\\s+|protected\\s+|open\\s+|abstract\\s+|final\\s+|sealed\\s+|data\\s+|value\\s+|inline\\s+|noinline\\s+|crossinline\\s+|external\\s+|expect\\s+|actual\\s+|suspend\\s+|operator\\s+|infix\\s+|tailrec\\s+|const\\s+|lateinit\\s+)*",lf=new RegExp(`^(?:@[\\w.]+(?:\\([^)]*\\))?\\s+)*${pr}(?:(?:enum|annotation)\\s+)?(class|interface|object|typealias)\\s+([A-Za-z_][A-Za-z0-9_]*)`),pf=new RegExp(`^(?:@[\\w.]+(?:\\([^)]*\\))?\\s+)*${pr}fun\\s+(?:<[^>]*>\\s*)?(?:[A-Za-z_][\\w.]*(?:<[^>]*>)?\\.)?([A-Za-z_][A-Za-z0-9_]*)\\s*[(<]`),ff=new RegExp(`^(?:@[\\w.]+(?:\\([^)]*\\))?\\s+)*${pr}(?:val|var)\\s+(?:<[^>]*>\\s*)?([A-Za-z_][A-Za-z0-9_]*)`)});import mf from"livescript";function ae(t){if(t){if(typeof t.value=="string")return t.value;if(typeof t.base?.value=="string")return t.base.value}}function uf(t){if(!t)return[];if(t.constructor?.name==="Class"){let n=ae(t.title);return n?[{name:n}]:[]}if(t.constructor?.name==="Obj"&&Array.isArray(t.items))return t.items.map(n=>ae(n.key)??ae(n.val)).filter(n=>!!n).map(n=>({name:n}));let e=ae(t);return e?[{name:e}]:[]}function df(t){let e=t.constructor?.name||t.type;if(e==="Assign"&&t.left?.constructor?.name==="Chain"){let n=t.left,r=ae(n.head),s=n.tails?.[0]?.key?.name;if(r==="module"&&s==="exports")return uf(t.right);if(r==="exports"&&typeof s=="string")return[{name:s}];if(n.head?.verb==="out"&&typeof s=="string")return[{name:s}]}if(e==="Import"&&t.left?.verb==="out"){let n=t.right;if(n?.constructor?.name==="Obj"&&Array.isArray(n.items))return n.items.map(r=>ae(r.val)??ae(r.key)).filter(r=>!!r).map(r=>({name:r}))}return[]}function hf(t,e){let n=t.constructor?.name||t.type;if(n==="Import"){let r=t.right?.value;if(typeof r=="string"){let o=Z(r);return{fromPath:e,toPath:"",rawSpecifier:o,isStyle:M(o),type:"static"}}}if(n==="Chain"&&t.head?.value==="require"){let r=t.tails?.[0];if(r?.constructor?.name==="Call"||r?.type==="Call"){let o=r.args?.[0]?.value;if(typeof o=="string"){let s=Z(o);return{fromPath:e,toPath:"",rawSpecifier:s,isStyle:M(s),type:"require"}}}}return null}function fr(t,e,n){if(!t||typeof t!="object")return[];let r=[],o=hf(t,e);o&&r.push(o),n.push(...df(t));for(let s in t){if(gf.has(s))continue;let i=t[s];if(!(!i||typeof i!="object"))if(Array.isArray(i))for(let a of i)r.push(...fr(a,e,n));else r.push(...fr(i,e,n))}return r}function Qs(t,e){let n=we(e),r=Ee(t,n),o=[],s=[];try{o=fr(mf.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(n).map(c=>({name:c,kind:"comment-marker"})),category:r}}var gf,Xs=d(()=>{"use strict";l();X();Ft();gf=new Set(["first_line","first_column","last_line","last_column","line","column"])});import yf from"luaparse";function xf(t,e){let n=[];function r(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=Z(i.raw))}else if(o.type==="StringCallExpression"){let i=o.argument;i?.type==="StringLiteral"&&(s=Z(i.raw))}s&&n.push({fromPath:e,toPath:"",rawSpecifier:s,isStyle:M(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)r(a);else r(i)}}}return r(t),n}function bf(t){let e=new Set;for(let n of t)n.type==="LocalStatement"&&n.variables.forEach((r,o)=>{n.init[o]?.type==="TableConstructorExpression"&&e.add(r.name)});return e}function Sf(t){let e=t[t.length-1];if(e?.type!=="ReturnStatement")return[];let n=e.arguments[0];if(n?.type!=="TableConstructorExpression")return[];let r=[];for(let o of n.fields)o.type==="TableKeyString"&&r.push({name:o.key.name});return r}function Cf(t){let e=t.body,n=bf(e),r=Sf(e);for(let s of e)if(s.type==="FunctionDeclaration")s.identifier?.type==="MemberExpression"?s.identifier.base.type==="Identifier"&&n.has(s.identifier.base.name)&&r.push({name:s.identifier.identifier.name}):s.identifier?.type==="Identifier"&&!s.isLocal&&r.push({name:s.identifier.name});else if(s.type==="AssignmentStatement")for(let i of s.variables)i.type==="MemberExpression"&&i.base.type==="Identifier"&&n.has(i.base.name)&&r.push({name:i.identifier.name});let o=new Set;return r.filter(s=>o.has(s.name)?!1:(o.add(s.name),!0))}function Zs(t,e){let n=we(e),r=Ee(t,n),o=[],s=[];try{let i=yf.parse(e);o=xf(i,t),s=Cf(i)}catch{}return{imports:o,exports:s,tags:Array.from(n).map(i=>({name:i,kind:"comment-marker"})),category:r}}var ei=d(()=>{"use strict";l();X();Ft()});async function Ef(){return ti??=(async()=>{let{unified:t}=await import("unified"),e=(await import("remark-parse")).default;return t().use(e)})(),ti}function Tf(t){let e=t.trim();return e.length===0||e.startsWith("#")||kf.some(n=>e.startsWith(n))}function Ff(t,e){let n=t.match(wf);return n?n.map(r=>({fromPath:e,toPath:"",rawSpecifier:r,isStyle:!1,type:"static",isDocReference:!0})):[]}function ni(t,e,n){if(t.type==="link"&&typeof t.url=="string"&&!Tf(t.url)&&n.push({fromPath:e,toPath:"",rawSpecifier:t.url,isStyle:!1,type:"static",isDocReference:!0}),(t.type==="code"||t.type==="inlineCode")&&typeof t.value=="string"&&n.push(...Ff(t.value,e)),Array.isArray(t.children))for(let r of t.children)ni(r,e,n)}async function ri(t,e){let r=(await Ef()).parse(e),o=[];ni(r,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 kf,vf,wf,ti,oi=d(()=>{"use strict";l();kf=["http://","https://","mailto:","//"],vf="ts|tsx|js|jsx|mjs|cjs|py|go|lua|css|scss|less|styl|coffee|ls|feature|md|mdx|json",wf=new RegExp(`(?:\\.{1,2}/)?[\\w.-]+(?:/[\\w.-]+)*\\.(?:${vf})\\b`,"g")});function Nf(t){let e=1;function n(r){switch(r.type.name){case"IfStatement":{e+=se(r).filter(s=>s.type.name==="if"||s.type.name==="elif").length;break}case"TryStatement":{e+=se(r).filter(s=>s.type.name==="except").length;break}case"ForStatement":case"WhileStatement":case"ConditionalExpression":e++;break;case"and":case"or":e++;break}let o=r.firstChild;for(;o;)n(o),o=o.nextSibling}return n(t),e}function Pf(t,e){let n=0,r=se(t),o=0,s=0;for(;s<r.length;){let i=r[s];if(i?.type.name==="if"||i?.type.name==="elif"){let a=o>0;n+=a?1:1+e;let c=a?e:e+1,p=r[s+1],f=r[s+2];p&&(n+=U(p,c)),f&&(n+=U(f,c)),o++,s+=3}else if(i?.type.name==="else"){n+=1;let a=r[s+1];a&&(n+=U(a,e+1)),s+=2}else s++}return n}function Df(t,e){let n=0,r=se(t),o=0;for(;o<r.length;){let s=r[o];if(s?.type.name==="except"){for(n+=1+e,o++;o<r.length&&r[o]?.type.name!=="Body";)n+=U(r[o],e),o++;o<r.length&&(n+=U(r[o],e),o++)}else s?.type.name==="Body"&&(n+=U(s,e)),o++}return n}function si(t,e){let n=1+e,r=t.firstChild;for(;r;)n+=U(r,e+1),r=r.nextSibling;return n}function Rf(t,e){let n=0,r=t.firstChild;for(;r;)n+=U(r,e),r=r.nextSibling;return n}function U(t,e){let n=t.type.name;switch(n){case"IfStatement":return Pf(t,e);case"TryStatement":return Df(t,e);case"ForStatement":case"WhileStatement":return si(t,e);default:{let r=n==="ConditionalExpression"||n==="and"||n==="or"?1:0;return e>0&&(n==="FunctionDefinition"||n==="LambdaExpression")?r+si(t,e):r+Rf(t,e)}}}function If(t){return U(t,0)}function mr(t){return{complexity:Nf(t),cognitiveComplexity:If(t)}}function ii(t,e){let n=[];function r(i,a){let{complexity:c,cognitiveComplexity:p}=mr(i);n.push({name:a,line:ie(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 m=f.getChild("VariableName"),h=m?e.slice(m.from,m.to):void 0;h&&r(f,c?`${c}.${h}`:h),o(f)}else s(f);f=f.nextSibling}}return}if(i.type.name==="FunctionDefinition"){let a=i.getChild("VariableName");a&&r(i,e.slice(a.from,a.to)),o(i);return}o(i)}return s(t.topNode),n}var ai=d(()=>{"use strict";l();Nt()});import Af from"path";import{parser as Mf}from"@lezer/python";function ci(t,e){let n=[],r=[],o=new Set,s=Af.basename(t).toLowerCase(),i=Mf.parse(e),a=i.cursor();do switch(a.name){case"Comment":{let y=e.slice(a.from,a.to).match(/#\s*@tag\s+([a-zA-Z0-9_-]+)/);y?.[1]&&o.add(y[1]);break}case"ImportStatement":{for(let y of Of(a.node,e,t))n.push(y);break}case"FunctionDefinition":case"ClassDefinition":{let y=a.node.parent;if(y?.name==="Script"||y?.name==="DecoratedStatement"&&y.parent?.name==="Script"){let v=a.node.getChild("VariableName");v&&r.push({name:e.slice(v.from,v.to)})}break}case"AssignStatement":{if(a.node.parent?.name==="Script"){let y=a.node.firstChild;y?.name==="VariableName"&&r.push({name:e.slice(y.from,y.to)})}break}}while(a.next());let c=zf(s,n,o);c==="test"&&o.add("test");let{complexity:p,cognitiveComplexity:f}=mr(i.topNode),m=ii(i,e),h=c==="test"?[]:Wf(i,e);return{imports:n,exports:r,tags:Array.from(o).map(y=>({name:y,kind:"comment-marker"})),category:c,rawCallEdges:h,complexity:p,cognitiveComplexity:f,...m.length>0?{functions:m}:{}}}function Of(t,e,n){let r=t.firstChild;return r?r.name==="from"?_f(t,e,n):Gf(t,e,n):[]}function _f(t,e,n){let r=t.firstChild;if(!r)return[];let o=r.nextSibling;for(;o&&o.name!=="import";)o=o.nextSibling;if(!o)return[];let s=e.slice(r.to,o.from).trim(),i=jf(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[Ve(n,s,i,!0)];let p=a===1?"./":"../".repeat(a-1);return c?[Ve(n,p+c.replace(/\./g,"/"),i,!1)]:i[0]==="*"?[Ve(n,p.slice(0,-1),["*"],!1)]:i.map(f=>Ve(n,p+f,[f],!1))}function Gf(t,e,n){let r=[],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),r.push(Ve(n,s,["*"],!0))}o=o.nextSibling}return r}function jf(t,e){let n=[],r=t;for(;r;)r.name==="*"?n.push("*"):r.name==="VariableName"&&(n.push(e.slice(r.from,r.to)),r.nextSibling?.name==="as"&&(r=r.nextSibling.nextSibling??r.nextSibling)),r=r.nextSibling;return n}function $f(t,e){let n=new Map,r=t.cursor();do{if(r.name!=="ImportStatement")continue;let s=r.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),m=i.nextSibling;for(;m;){if(m.type.name==="VariableName"){let h=e.slice(m.from,m.to),y=h;if(m.nextSibling?.type.name==="as"){let v=m.nextSibling.nextSibling;v?.type.name==="VariableName"&&(y=e.slice(v.from,v.to),m=v)}let b=c===0?a:p?f+p.replace(/\./g,"/"):f+h;n.set(y,b)}m=m.nextSibling}}while(r.next());return n}function Wf(t,e){let n=$f(t,e),r=[];function o(a,c){if(a.type.name==="CallExpression"&&a.firstChild?.type.name==="VariableName"){let f=a.firstChild,m=e.slice(f.from,f.to),h=n.get(m);h&&r.push({from:c,to:m,toSpecifier:h})}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 m=f.firstChild;for(;m;){if(m.type.name==="FunctionDefinition"){let h=m.getChild("VariableName"),y=h?e.slice(h.from,h.to):void 0;y&&o(m,p?`${p}.${y}`:y)}else i(m);m=m.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),r}function Ve(t,e,n,r){return{fromPath:t,toPath:"",rawSpecifier:e,isStyle:!1,isExternal:r,type:"static",symbols:n.length>0?n:void 0}}function zf(t,e,n){return t.startsWith("test_")||t.endsWith("_test.py")?"test":t==="conftest.py"||t==="setup.py"?"config":n.has("test")||e.some(r=>Lf.has(r.rawSpecifier))?"test":"logic"}var Lf,li=d(()=>{"use strict";l();ai();Lf=new Set(["pytest","unittest","nose","hypothesis"])});function Uf(t,e){let n=e.split("=>")[0]?.trim();return n?n==="_"||n==="*"||n==="given"?`${t}.*`:`${t}.${n}`:null}function Jf(t){let e=t.indexOf("{");if(e!==-1){let r=t.indexOf("}",e),o=t.slice(0,e).trim().replace(/\.$/,""),s=t.slice(e+1,r===-1?void 0:r);return o?s.split(",").map(i=>Uf(o,i.trim())).filter(i=>i!=null):[]}let n=[];for(let r of t.split(",")){let o=r.trim().replace(/\s+as\s+\w+$/,"");if(o)if(o.endsWith("._")||o.endsWith(".*")||o.endsWith(".given")){let s=o.replace(/\.(_|\*|given)$/,"");s&&n.push(`${s}.*`)}else n.push(o)}return n}function pi(t,e){let n=Ne(e),o=ee(e).split(`
|
|
11
|
-
`),s=[],i=new Set;for(let p of o){let f=p.match(Bf);if(f?.[1]){for(let h of Jf(f[1]))s.push(De(t,h));continue}let m=p.match(Hf);m?.[2]&&i.add(m[2])}let a=$(e,!0);a&&s.push(te(t,a));let c=Array.from(i,p=>({name:p}));return{imports:s,exports:c,tags:Array.from(n).map(p=>({name:p,kind:"comment-marker"})),category:H(t,s.map(p=>p.rawSpecifier),{typeNames:[...i],annotations:Pe(e).annotations})}}var Bf,Hf,fi=d(()=>{"use strict";l();Re();Bf=/^\s*import\s+(.+?)\s*$/,Hf=/^(?:@\w+\s+)*(?:private\s+|protected\s+|final\s+|sealed\s+|abstract\s+|implicit\s+|case\s+)*(class|trait|object|type|enum)\s+([A-Za-z_$][A-Za-z0-9_$]*)/});import k from"typescript";function Kf(t){let e=1;function n(r){switch(r.kind){case k.SyntaxKind.IfStatement:case k.SyntaxKind.ConditionalExpression:case k.SyntaxKind.ForStatement:case k.SyntaxKind.ForInStatement:case k.SyntaxKind.ForOfStatement:case k.SyntaxKind.WhileStatement:case k.SyntaxKind.DoStatement:case k.SyntaxKind.CatchClause:case k.SyntaxKind.CaseClause:e++;break;case k.SyntaxKind.BinaryExpression:{let o=r.operatorToken.kind;(o===k.SyntaxKind.AmpersandAmpersandToken||o===k.SyntaxKind.BarBarToken||o===k.SyntaxKind.QuestionQuestionToken)&&e++;break}}k.forEachChild(r,n)}return n(t),e}function ui(t,e,n){let r=n?1:1+e,o=n?e:e+1;return r+=ce(t.expression,o,!1),r+=ce(t.thenStatement,o,!1),t.elseStatement&&(k.isIfStatement(t.elseStatement)?r+=ui(t.elseStatement,e,!0):r+=1+ce(t.elseStatement,e+1,!1)),r}function mi(t,e){let n=1+e;return k.forEachChild(t,r=>{n+=ce(r,e+1,!1)}),n}function Vf(t,e){let n=1+e;return k.forEachChild(t,r=>{n+=ce(r,e,!1)}),n}function qf(t,e){let n=0;return k.forEachChild(t,r=>{n+=ce(r,e,!1)}),n}function Yf(t){let e=t.operatorToken.kind;return e===k.SyntaxKind.AmpersandAmpersandToken||e===k.SyntaxKind.BarBarToken||e===k.SyntaxKind.QuestionQuestionToken}function ce(t,e,n){if(k.isIfStatement(t))return ui(t,e,n);if(k.isForStatement(t)||k.isForInStatement(t)||k.isForOfStatement(t)||k.isWhileStatement(t)||k.isDoStatement(t)||k.isSwitchStatement(t))return mi(t,e);if(k.isCatchClause(t))return Vf(t,e);let r=0;return k.isConditionalExpression(t)&&(r+=1),k.isBinaryExpression(t)&&Yf(t)&&(r+=1),e>0&&(k.isFunctionDeclaration(t)||k.isFunctionExpression(t)||k.isArrowFunction(t))?r+mi(t,e):r+qf(t,e)}function Qf(t){return ce(t,0,!1)}function ur(t){return{complexity:Kf(t),cognitiveComplexity:Qf(t)}}var di=d(()=>{"use strict";l()});import T from"typescript";function gi(t,e){Xf(t,e),em(t,e),tm(t,e),nm(t,e)}function Xf(t,e){if((T.isFunctionDeclaration(t)||T.isVariableDeclaration(t))&&t.name&&T.isIdentifier(t.name)&&Zf(t)){let n;if(T.isFunctionDeclaration(t))n="function";else{let r=t.initializer;n=r&&(T.isArrowFunction(r)||T.isFunctionExpression(r))?"function":"variable"}e.tags.add({name:t.name.text,kind:n})}}function Zf(t){if(T.isFunctionDeclaration(t))return T.isSourceFile(t.parent);let e=t.parent?.parent;return!!e&&T.isSourceFile(e.parent)}function em(t,e){if(!T.isStringLiteral(t))return;let n=t.text.match(/@[\w-]+/g);if(n)for(let r of n)e.tags.add({name:r.substring(1),kind:"comment-marker"})}function tm(t,e){if(!T.isSourceFile(t))return;let n=/@tag\s+([a-zA-Z0-9_-]+)/g,r=t.getFullText(),o=n.exec(r);for(;o!==null;)o[1]&&e.tags.add({name:o[1],kind:"comment-marker"}),o=n.exec(r)}function nm(t,e){if(T.isCallExpression(t)&&rm(t.expression))for(let n of t.arguments)T.isObjectLiteralExpression(n)&&om(n,e)}function rm(t){return T.isIdentifier(t)?dr.has(t.text):!!(T.isPropertyAccessExpression(t)&&(dr.has(t.name.text)||T.isIdentifier(t.expression)&&dr.has(t.expression.text)))}function om(t,e){for(let n of t.properties){if(!T.isPropertyAssignment(n)||!T.isIdentifier(n.name)||n.name.text!=="tags"&&n.name.text!=="tag")continue;let{initializer:r}=n,o=T.isArrayLiteralExpression(r)?r.elements.filter(T.isStringLiteral):n.name.text==="tag"&&T.isStringLiteral(r)?[r]:[];for(let s of o)e.tags.add({name:s.text.replace(/^@/,""),kind:"comment-marker"})}}var dr,hi=d(()=>{"use strict";l();dr=new Set(["test","describe","it"])});import yi from"path";import x from"typescript";function gr(t,e,n){let r=[],o=new Map,s=new Set,i=x.createSourceFile(t,e,x.ScriptTarget.Latest,!0,n==="typescript"?x.ScriptKind.TSX:x.ScriptKind.JSX),a={filePath:t,imports:r,exports:o,tags:s,rawCallEdges:[],sourceFile:i,hasUI:!1,hasTypesOnly:!0,totalStatements:0,exportStatements:0},c=v=>{cm(v,a),x.forEachChild(v,c)};c(i);let p=bm(t,a);(p==="test"||p==="barrel")&&s.add({name:p,kind:"comment-marker"}),p!=="test"&&Sm(a,i);let f=i.statements[0],m=f?bi(f):void 0,{complexity:h,cognitiveComplexity:y}=ur(i),b=sm(i);return{imports:r,exports:Array.from(o.values()),tags:Array.from(s),category:p,rawCallEdges:a.rawCallEdges??[],complexity:h,cognitiveComplexity:y,...b.length>0?{functions:b}:{},...m!==void 0?{description:m}:{}}}function sm(t){let e=[],n=(o,s)=>{let{complexity:i,cognitiveComplexity:a}=ur(s),c=t.getLineAndCharacterOfPosition(s.getStart(t)).line+1;e.push({name:o,line:c,complexity:i,cognitiveComplexity:a})},r=(o,s)=>{if(x.isFunctionDeclaration(o)&&o.name&&o.body?n(o.name.text,o):x.isVariableDeclaration(o)&&x.isIdentifier(o.name)&&o.initializer&&(x.isArrowFunction(o.initializer)||x.isFunctionExpression(o.initializer))?n(o.name.text,o.initializer):s&&x.isMethodDeclaration(o)&&x.isIdentifier(o.name)&&o.body?n(`${s}.${o.name.text}`,o):s&&x.isConstructorDeclaration(o)&&o.body?n(`${s}.constructor`,o):s&&x.isGetAccessorDeclaration(o)&&x.isIdentifier(o.name)&&o.body?n(`${s}.get ${o.name.text}`,o):s&&x.isSetAccessorDeclaration(o)&&x.isIdentifier(o.name)&&o.body&&n(`${s}.set ${o.name.text}`,o),x.isClassDeclaration(o)&&o.name){let i=o.name.text;x.forEachChild(o,a=>r(a,i));return}x.forEachChild(o,i=>r(i,s))};return r(t,void 0),e}function xi(t,e,n,r){let o={name:t},s=bi(n);s!==void 0&&(o.doc=s);let i=im(e);i!==void 0&&(o.flags=i);let a=am(e,r);return a!==void 0&&(o.signature=a),o}function bi(t){let e=x.getJSDocCommentsAndTags(t);for(let n of e)if(x.isJSDoc(n)&&n.comment)return x.getTextOfJSDocComment(n.comment)||void 0}function im(t){let e=new Set(["deprecated","internal","public","alpha","beta"]),n=x.getJSDocTags(t).map(r=>r.tagName.text).filter(r=>e.has(r));return n.length>0?n:void 0}function am(t,e){let n=x.createPrinter({removeComments:!0}),r=o=>n.printNode(x.EmitHint.Unspecified,o,e);if(x.isFunctionDeclaration(t)||x.isMethodDeclaration(t)){let o=t.parameters.map(r).join(", "),s=t.type?r(t.type):"void";return`${t.typeParameters?`<${t.typeParameters.map(a=>a.name.text).join(", ")}>`:""}(${o}) => ${s}`}if(x.isVariableDeclaration(t)){if(t.type)return r(t.type);if(t.initializer&&(x.isArrowFunction(t.initializer)||x.isFunctionExpression(t.initializer))){let o=t.initializer,s=o.parameters.map(r).join(", "),i=o.type?r(o.type):"unknown";return`(${s}) => ${i}`}return}if(x.isClassDeclaration(t)&&t.name)return`class ${t.name.text}`;if(x.isInterfaceDeclaration(t))return`interface ${t.name.text}`;if(x.isTypeAliasDeclaration(t))return r(t.type);if(x.isEnumDeclaration(t))return`enum ${t.name.text}`}function cm(t,e){lm(t,e),pm(t,e),mm(t,e),um(t,e),xm(t,e),gi(t,e)}function lm(t,e){if(!x.isSourceFile(t))return;let n=t.statements.filter(r=>!x.isEmptyStatement(r));e.totalStatements=n.length,e.exportStatements=n.filter(r=>x.isExportDeclaration(r)||x.isExportAssignment(r)||hr(r)).length}function pm(t,e){if(x.isJsxElement(t)||x.isJsxSelfClosingElement(t)||x.isJsxFragment(t)){e.hasUI=!0,e.hasTypesOnly=!1;return}if(x.isFunctionDeclaration(t)||x.isMethodDeclaration(t)||x.isArrowFunction(t)||x.isClassDeclaration(t)||x.isVariableStatement(t)||x.isEnumDeclaration(t)){e.hasTypesOnly=!1;return}x.isExportDeclaration(t)&&!fm(t)&&(e.hasTypesOnly=!1)}function fm(t){return t.isTypeOnly?!0:!t.exportClause||!x.isNamedExports(t.exportClause)?!1:t.exportClause.elements.every(e=>e.isTypeOnly)}function mm(t,e){if(!x.isImportDeclaration(t)||!t.moduleSpecifier||!x.isStringLiteral(t.moduleSpecifier))return;let n=[];if(t.importClause&&(t.importClause.name&&n.push("default"),t.importClause.namedBindings))if(x.isNamedImports(t.importClause.namedBindings))for(let o of t.importClause.namedBindings.elements)n.push(o.name.text);else x.isNamespaceImport(t.importClause.namedBindings)&&n.push("*");let r=n.length>0?"static":"side-effect";e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:t.moduleSpecifier.text,isStyle:M(t.moduleSpecifier.text),type:r,symbols:n.length>0?n:void 0})}function um(t,e){x.isExportDeclaration(t)?dm(t,e):x.isExportAssignment(t)?e.exports.set("default",{name:"default"}):hr(t)&&ym(t,e)}function dm(t,e){if(t.moduleSpecifier&&x.isStringLiteral(t.moduleSpecifier))gm(t,t.moduleSpecifier.text,e);else if(t.exportClause&&x.isNamedExports(t.exportClause))for(let n of t.exportClause.elements){let r=n.name.text;e.exports.set(r,{name:r})}}function gm(t,e,n){let r=hm(t),o={fromPath:n.filePath,toPath:"",rawSpecifier:e,isStyle:M(e),type:"re-export"};r.length>0&&(o.symbols=r),n.imports.push(o)}function hm(t){return t.exportClause?x.isNamedExports(t.exportClause)?t.exportClause.elements.map(e=>e.name.text):[]:["*"]}function ym(t,e){if((x.isFunctionDeclaration(t)||x.isClassDeclaration(t)||x.isInterfaceDeclaration(t)||x.isTypeAliasDeclaration(t)||x.isEnumDeclaration(t))&&t.name){let r=t.name.text;e.exports.set(r,xi(r,t,t,e.sourceFile));return}if(x.isVariableStatement(t)){for(let r of t.declarationList.declarations)if(x.isIdentifier(r.name)){let o=r.name.text;e.exports.set(o,xi(o,r,t,e.sourceFile))}}}function xm(t,e){if(!x.isCallExpression(t))return;let n=t.arguments[0];!n||!x.isStringLiteral(n)||(t.expression.kind===x.SyntaxKind.ImportKeyword?e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:n.text,isStyle:M(n.text),type:"dynamic"}):x.isIdentifier(t.expression)&&t.expression.text==="require"&&e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:n.text,isStyle:M(n.text),type:"require"}))}function bm(t,e){let n=yi.basename(t).toLowerCase(),r=yi.extname(t).toLowerCase();return ze().some(s=>n.includes(s))?"test":Zo(n)?"config":e.imports.some(s=>Tn().some(i=>s.rawSpecifier.includes(i)))?"test":r===".tsx"||r===".jsx"||e.hasUI?"ui":e.hasTypesOnly&&e.totalStatements>0?"type-only":e.totalStatements>0&&e.exportStatements/e.totalStatements>Pn()?"barrel":"logic"}function hr(t){return x.canHaveModifiers(t)&&x.getModifiers(t)?.some(e=>e.kind===x.SyntaxKind.ExportKeyword)===!0}function Sm(t,e){let n=t.rawCallEdges??[];t.rawCallEdges=n;let r=new Map;for(let o of e.statements){if(!x.isImportDeclaration(o)||!x.isStringLiteral(o.moduleSpecifier))continue;let s=o.moduleSpecifier.text,i=o.importClause;if(i&&(i.name&&r.set(i.name.text,s),i.namedBindings&&x.isNamedImports(i.namedBindings)))for(let a of i.namedBindings.elements)r.set(a.name.text,s)}if(r.size!==0)for(let o of e.statements){let s=km(o);if(s){let i=vm(o);i&&Dt(i,s,r,n);continue}x.isClassDeclaration(o)&&o.name&&Cm(o,o.name.text,r,n)}}function Cm(t,e,n,r){for(let o of t.members)x.isMethodDeclaration(o)&&o.body&&x.isIdentifier(o.name)?Dt(o.body,`${e}.${o.name.text}`,n,r):x.isConstructorDeclaration(o)&&o.body&&Dt(o.body,`${e}.constructor`,n,r)}function km(t){if(hr(t)){if(x.isFunctionDeclaration(t)&&t.name)return t.name.text;if(x.isVariableStatement(t)){for(let e of t.declarationList.declarations)if(x.isIdentifier(e.name)&&e.initializer&&(x.isArrowFunction(e.initializer)||x.isFunctionExpression(e.initializer)))return e.name.text}}}function vm(t){if(x.isFunctionDeclaration(t))return t.body;if(x.isVariableStatement(t)){for(let e of t.declarationList.declarations)if(e.initializer&&(x.isArrowFunction(e.initializer)||x.isFunctionExpression(e.initializer)))return e.initializer}}function Dt(t,e,n,r){if(x.isCallExpression(t)&&x.isIdentifier(t.expression)){let o=t.expression.text,s=n.get(o);s&&!r.some(i=>i.from===e&&i.to===o&&i.toSpecifier===s)&&r.push({from:e,to:o,toSpecifier:s})}x.forEachChild(t,o=>Dt(o,e,n,r))}var Si=d(()=>{"use strict";l();be();di();X();hi()});function Rt(t,e){if(e.length===0)return"ui";let n=!1;return t.walk(r=>{if(r.type==="rule")return n=!0,!1}),n?"ui":"barrel"}var Ci=d(()=>{"use strict";l()});import vi from"postcss";import*as wm from"postcss-less";function ki(t){return t.startsWith("~")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("//")||t.startsWith("data:")}function Tm(t){let e=t.trim();return e.length>0&&!e.startsWith("http://")&&!e.startsWith("https://")&&!e.startsWith("//")&&!e.startsWith("data:")&&!e.startsWith("#")}function Fm(t,e){let n=t.match(/^\(([^)]+)\)\s+['"]([^'"]+)['"]/);if(n){let s=n[1]?.trim()??"",i=n[2]??"";if(!i)return null;let a=wi.has(s)?"side-effect":"static";return{fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:a,...ki(i)?{isExternal:!0}:{}}}let r=t.match(/^url\(['"]?([^'")]+)['"]?\)/),o=r?r[1]?.trim()??"":t.match(/^['"]([^'"]+)['"]/)?.[1]??"";return o?{fromPath:e,toPath:"",rawSpecifier:o,isStyle:!0,type:"static",...ki(o)?{isExternal:!0}:{}}:null}function Nm(t,e){let n=[],r=/url\(['"]?([^'")]+)['"]?\)/g,o=r.exec(t);for(;o!==null;){let s=o[1]?.trim()??"";Tm(s)&&n.push({fromPath:e,toPath:"",rawSpecifier:s,isStyle:!0,type:"static"}),o=r.exec(t)}return n}function Ei(t,e){let n=[];return t.walk(r=>{if(r.type==="atrule"&&r.name==="import"){let o=Fm(r.params,e);o&&n.push(o)}r.type==="decl"&&n.push(...Nm(r.value,e))}),n}function Pm(t){return t.replace(/(?<!:)\/\/.*/g,"")}function Dm(t,e){let n=[],r=/@import\s+(?:\(([^)]+)\)\s+)?['"]([^'"]+)['"]/g,o=r.exec(t);for(;o!==null;){let s=o[1]?.trim()??"",i=o[2]??"";if(i){let a=wi.has(s)?"side-effect":"static";n.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:a})}o=r.exec(t)}return n}function It(t,e){let n=vi.parse(Pm(t));return{imports:Ei(n,e),root:n}}function Rm(t){let e=[],n=[];for(let r of t.nodes??[]){if(r.type!=="atrule")continue;let{value:o}=r;if(o===void 0)continue;let s=r.name;s&&(e.push({name:s}),n.push({name:s,kind:"variable"}))}return{exports:e,tags:n}}function At(t,e){try{let n=Em.parse(t),{exports:r,tags:o}=Rm(n);return{imports:Ei(n,e),root:n,exports:r,tags:o}}catch{return{imports:Dm(t,e),root:vi.parse(""),exports:[],tags:[]}}}var Em,wi,yr=d(()=>{"use strict";l();Em=wm,wi=new Set(["reference","inline"])});import{parse as Im}from"postcss-scss";function Ti(t){return t.startsWith("_")||t.startsWith("-")}function Am(t){return!!(t.startsWith("sass:")||t.startsWith("~")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("//")||!t.startsWith(".")&&!t.startsWith("/")&&!t.startsWith("_"))}function Mm(t){let e=t.match(/^['"]([^'"]+)['"]/);if(!e?.[1])return{specifier:""};let n=e[1],o=t.match(/\bas\s+(\S+)/)?.[1];return o!==void 0?{specifier:n,alias:o}:{specifier:n}}function Lm(t){let e=[],n=[];for(let r of t.nodes??[]){if(r.type==="decl"&&r.prop.startsWith("$")){let o=r.prop.slice(1);if(!o||Ti(o))continue;e.push({name:o}),n.push({name:o,kind:"variable"});continue}if(r.type==="atrule"&&(r.name==="mixin"||r.name==="function")){let s=r.params.match(/^([\w-]+)/)?.[1];if(!s||Ti(s))continue;let i=r.params.trim();e.push(i.includes("(")?{name:s,signature:i}:{name:s}),n.push({name:s,kind:"function"})}}return{exports:e,tags:n}}function Mt(t,e){let n=Im(t),r=[];n.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}=Mm(c);if(!p)return;let m={fromPath:e,toPath:"",rawSpecifier:p,isStyle:!0,type:a==="forward"?"re-export":"static",...Am(p)?{isExternal:!0}:{}};f&&(m.symbols=[f]),r.push(m)});let{exports:o,tags:s}=Lm(n);return{imports:r,root:n,exports:o,tags:s}}var xr=d(()=>{"use strict";l()});function Fi(t,e){let n=[],r=/@require\s+['"]([^'"]+)['"]/g,o=r.exec(t);for(;o!==null;){let i=o[1];i&&n.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:"require"}),o=r.exec(t)}let s=/(?<!@)(?:import|require)\s*\(?\s*['"]([^'"]+)['"]/g;for(o=s.exec(t);o!==null;){let i=o[1];i&&n.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:"static"}),o=s.exec(t)}return n}function Ni(t,e){if(e.length===0)return"ui";try{let n=kn("stylus");return new n.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 Pi=d(()=>{"use strict";l()});function qe(t,e){let n=B(t);if(n==="stylus"){let s=Fi(e,t);return{imports:s,exports:[],tags:[],category:Ni(e,s)}}if(n==="scss"){let{imports:s,root:i,exports:a,tags:c}=Mt(e,t);return{imports:s,exports:a,tags:c,category:Rt(i,s)}}if(n==="less"){let{imports:s,root:i,exports:a,tags:c}=At(e,t);return{imports:s,exports:a,tags:c,category:Rt(i,s)}}let{imports:r,root:o}=It(e,t);return{imports:r,exports:[],tags:[],category:Rt(o,r)}}var Di=d(()=>{"use strict";l();X();Ci();yr();xr();Pi()});async function Ri(t,e){let n=B(t),r=Is(n);return r?r(t,e):{imports:[],exports:[],tags:[],category:"other"}}var Ii=d(()=>{"use strict";l();X();Ds();As();$s();zs();Vs();Ys();Xs();ei();oi();li();fi();Si();Ke();Di();be();X();Ke();for(let[t,e]of[["javascript",(n,r)=>gr(n,r,"javascript")],["typescript",(n,r)=>gr(n,r,"typescript")],["css",qe],["scss",qe],["less",qe],["stylus",qe],["coffeescript",Ps],["livescript",Qs],["lua",Zs],["python",ci],["go",js],["java",Ks],["kotlin",qs],["scala",pi],["groovy",Ws],["gherkin",rr],["markdown",ri]])Te(t,e)});import Ai from"path";function Om(t,e){let n=e.get(t.path);n!==void 0&&(t.coveragePct=n)}function Li(t,e){for(let n of t)if(n.isExternal){let r=n.rawSpecifier.startsWith("@")?n.rawSpecifier.split("/").slice(0,2).join("/"):n.rawSpecifier.split("/")[0];r&&!e.some(o=>o.name===r)&&e.push({name:r,kind:"library"})}}function _m(t,e,n){if(e.isExternal||!e.toPath)return;let r=n.get(e.toPath);r&&(r.category!=="logic"&&r.category!=="barrel"||(r.testedBy??=[],r.testedBy.includes(t.path)||r.testedBy.push(t.path)))}function Gm(t,e){if(t.type==="markdown")for(let n of t.imports){if(n.isExternal||!n.toPath)continue;let r=e.get(n.toPath);!r||r===t||(r.documentedBy??=[],r.documentedBy.includes(t.path)||r.documentedBy.push(t.path),r.category==="logic"&&(r.lastCommitAt??0)>(t.lastCommitAt??0)&&(t.staleFor??=[],t.staleFor.includes(r.path)||t.staleFor.push(r.path)))}}function Mi(t){return Math.round(t*1e4)/1e4}function jm(t,e){let n=[];for(let r of t.imports){if(r.isExternal||!r.toPath)continue;let o=e.get(r.toPath);if(!o||o.exports.length===0)continue;let s;if(r.symbols===void 0){if(r.type==="side-effect")continue;s=1}else r.symbols.includes("*")?s=1:s=r.symbols.length/o.exports.length;r.exportUsageRatio=Mi(Math.min(1,s)),n.push(r.exportUsageRatio)}n.length>0&&(t.avgExportUsage=Mi(n.reduce((r,o)=>r+o,0)/n.length),t.maxExportUsage=Math.max(...n))}function br(t,e,n){e&&(t.some(r=>r.name===e&&r.kind===n)||t.push({name:e,kind:n}))}function $m(t,e){let n=e.toPath,r=Ai.basename(n,Ai.extname(n)).replace(/\.(test|spec)$/,"");br(t.tags,r,"import")}function Wm(t,e){if(!(!e.symbols||e.symbols.includes("*")))for(let n of e.symbols)br(t.tags,n,"import")}function zm(t,e,n){let r=n.get(e.toPath);if(!(!r||r.category==="test"))for(let o of r.tags)o.kind==="comment-marker"&&br(t.tags,o.name,"comment-marker")}function Bm(t,e,n){!e.toPath||e.isExternal||($m(t,e),Wm(t,e),zm(t,e,n))}function Oi(t,e){for(let n of t.values())delete n.testedBy,delete n.documentedBy,delete n.staleFor,n.category==="test"&&(n.tags=n.tags.filter(r=>r.kind!=="import"));for(let n of t.values()){if(jm(n,t),e.size>0&&Om(n,e),n.category==="test")for(let r of n.imports)_m(n,r,t),Bm(n,r,t);Gm(n,t)}}var _i=d(()=>{"use strict";l()});function Sr(t){let e=new Map;for(let n of t.nodes.values())e.set(n.type,(e.get(n.type)??0)+1);return[...e.entries()].map(([n,r])=>({type:n,fileCount:r,exportsTracked:ji.has(n),importSymbolsTracked:$i.has(n),callEdgesTracked:Lt.has(n)})).sort((n,r)=>r.fileCount-n.fileCount)}var Gi,ji,$i,Lt,Ot=d(()=>{"use strict";l();Gi=new Set(["java","kotlin","scala","groovy"]),ji=new Set(["typescript","javascript","python","go","java","kotlin","scala","groovy","scss","less","lua","coffeescript"]),$i=new Set(["typescript","javascript","python"]),Lt=new Set(["typescript","javascript","go","python","java"])});import Bi from"fs";import Ae from"path";function Hm(t,e){let n=t.split(`
|
|
12
|
-
`),r=null,o=new Map,s=!1;for(let i of n){let a=i.trim();if(a.startsWith("module ")){r=a.slice(7).trim();continue}if(/^replace\s*\(/.test(a)){s=!0;continue}if(s&&a===")"){s=!1;continue}if(s&&a.includes("=>")){Wi(a,e,o);continue}!s&&/^replace\s+/.test(a)&&a.includes("=>")&&Wi(a.replace(/^replace\s+/,""),e,o)}return{mod:r,replaces:o}}function Wi(t,e,n){let[r,o]=t.split("=>").map(a=>a.trim());if(!r||!o)return;let s=r.split(/\s+/)[0];if(!o.startsWith(".")&&!o.startsWith("/"))return;let i=Ae.isAbsolute(o)?o:Ae.resolve(e,o);n.set(s,i)}function zi(t){let e;try{e=Bi.readdirSync(t,{withFileTypes:!0})}catch{return null}let n=e.filter(r=>r.isFile()&&r.name.endsWith(".go")&&!r.name.endsWith("_test.go")).map(r=>({path:Ae.join(t,r.name),isExternal:!1})).sort((r,o)=>r.path.localeCompare(o.path));return n.length>0?n:null}var Ye,Cr=d(()=>{"use strict";l();Ye=class{extensions=[".go"];goModCache=new Map;resolve(e,n,r,o){let{mod:s,replaces:i}=this.readGoMod(r);if(!s)return null;let a=this.applyReplace(n,i,r);if(a!==void 0)return zi(a);if(n!==s&&!n.startsWith(`${s}/`))return null;let c=n.slice(s.length).replace(/^\//,"");return c?zi(Ae.join(r,c)):null}readGoMod(e){let n=this.goModCache.get(e);if(n!==void 0)return n;let r={mod:null,replaces:new Map};try{let o=Bi.readFileSync(Ae.join(e,"go.mod"),"utf-8"),s=Hm(o,e);return this.goModCache.set(e,s),s}catch{return this.goModCache.set(e,r),r}}applyReplace(e,n,r){for(let[o,s]of n){if(e===o)return s;if(e.startsWith(`${o}/`)){let i=e.slice(o.length+1);return Ae.join(s,i)}}}}});import _t from"fs";import Gt from"path";function Ji(t){let e=t.replace(/\\/g,"/"),n=e.match(/^(.*)\/src\/([^/]+)(?:\/|$)/);if(!n?.[1]||!n[2]){let s=e.lastIndexOf("/");return{module:s===-1?e:e.slice(0,s),rootSegment:"",sourceRoot:"unknown"}}let r=n[2],o=r==="main"?"main":Km.has(r)?r:"unknown";return{module:n[1],rootSegment:r,sourceRoot:o}}function Vm(t,e=[]){let n=new Map,r=(process.env.MOKOSH_IGNORE_DIRS??"").split(",").map(a=>a.trim()).filter(Boolean),o=new Set([...A,...r,...e]),s=(a,c)=>{let{module:p,rootSegment:f,sourceRoot:m}=Ji(c),h=n.get(a);if(!h){n.set(a,[{module:p,rootSegment:f,sourceRoot:m,files:[c]}]);return}let y=h.find(b=>b.module===p&&b.rootSegment===f);y?y.files.push(c):h.push({module:p,rootSegment:f,sourceRoot:m,files:[c]})},i=(a,c)=>{if(c>Jm)return;let p;try{p=_t.readdirSync(a,{withFileTypes:!0})}catch{return}for(let f of p){let m=Gt.join(a,f.name);if(f.isDirectory()){!f.name.startsWith(".")&&!o.has(f.name)&&i(m,c+1);continue}if(!f.isFile())continue;let h=Gt.extname(f.name);if(!Um.has(h))continue;let y=Ym(m,h===".scala"||h===".sc");y&&s(y,m)}};i(t,0);for(let a of n.values())for(let c of a)c.files.sort();return n}function qm(t,e){let n=t.get(e);if(!(!n||n.length===0))return n.length===1?n[0]?.files:n.flatMap(r=>r.files).sort()}function Ym(t,e){let n;try{let r=_t.openSync(t,"r");try{let o=Buffer.alloc(Hi),s=_t.readSync(r,o,0,Hi,0);n=o.toString("utf8",0,s)}finally{_t.closeSync(r)}}catch{return null}return $(n,e)}function kr(t){return!t||t.length===0?null:t.map(e=>({path:e,isExternal:!1}))}function Ui(t){return Gt.basename(t,Gt.extname(t))}var Um,Jm,Hi,Km,le,vr=d(()=>{"use strict";l();j();Re();Um=new Set([".java",".kt",".kts",".scala",".sc",".groovy"]),Jm=12,Hi=4096,Km=new Set(sr);le=class{constructor(e=[]){this.extraIgnoreDirs=e}extraIgnoreDirs;extensions=[".java",".kt",".kts",".scala",".sc",".groovy",".gradle"];indexCache=new Map;resolve(e,n,r,o){let s=this.getIndex(r);if(s.size===0)return null;let i=n.endsWith(".*"),a=(i?n.slice(0,-2):n).split(".").filter(Boolean);if(a.length===0)return null;if(i){let c=s.get(a.join("."));if(!c)return null;let p=Ji(e),f=c.filter(y=>y.module===p.module&&y.rootSegment===p.rootSegment),m=p.sourceRoot!=="main"&&p.sourceRoot!=="unknown",h=f.flatMap(y=>m?y.files:y.files.filter(b=>!ir(Ui(b))));return kr(h)}for(let c=a.length-1;c>=1;c--){let p=qm(s,a.slice(0,c).join("."));if(!p)continue;let f=a[c],m=p.filter(h=>Ui(h)===f);if(m.length>0)return kr(m);if(c===a.length-1)return kr(p)}return null}getIndex(e){let n=this.indexCache.get(e);if(n)return n;let r=Vm(e,this.extraIgnoreDirs);return this.indexCache.set(e,r),r}}});import Qm from"fs";import wr from"path";var Qe,Er=d(()=>{"use strict";l();Qe=class{extensions=[".lua"];resolve(e,n,r,o){let s=n.replace(/\./g,wr.sep),i=[r,wr.join(r,"lib")];for(let a of i){if(!Qm.existsSync(a))continue;let c=o(wr.join(a,"_dummy.lua"),s);if(c)return[c]}return null}}});import Xm from"path";var Zm,Xe,Tr=d(()=>{"use strict";l();j();Zm=new Set(A),Xe=class{extensions=[".md",".mdx"];resolve(e,n,r,o){let s=n.replace(/^\.\//,"").split("/")[0];if(s&&Zm.has(s))return null;let i=o(Xm.join(r,"_dummy"),`./${n}`);return i?[i]:null}}});import eu from"fs";import Fr from"path";function Ki(t){try{return eu.statSync(t,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}var Ze,Nr=d(()=>{"use strict";l();Ze=class{extensions=[".py"];resolve(e,n,r,o){let s=n.replace(/\./g,Fr.sep),i=Fr.join(r,`${s}.py`);if(Ki(i))return[{path:i,isExternal:!1}];let a=Fr.join(r,s,"__init__.py");return Ki(a)?[{path:a,isExternal:!1}]:null}}});import Vi from"path";var tu,et,Pr=d(()=>{"use strict";l();tu=["~","http://","https://","//","data:","sass:"],et=class{extensions=[".css",".scss",".sass",".less",".styl"];resolve(e,n,r,o){if(tu.some(f=>n.startsWith(f)))return null;let s=o(e,n);if(s)return[s];let i=Vi.dirname(n),a=Vi.basename(n),c=i==="."?`_${a}`:`${i}/_${a}`,p=o(e,c);return p?[p]:null}}});function jt(t={}){return[new Ze,new Qe,new Ye,t.jvm??new le,new et,new Xe]}var Dr=d(()=>{"use strict";l();Cr();vr();Er();Tr();Nr();Pr();Cr();vr();Er();Tr();Nr();Pr()});import $t from"fs";import J from"path";var K,Wt=d(()=>{"use strict";l();Dr();K=class{constructor(e,n={}){this.rootDir=e;this.workspaceMap=n.workspaceMap??new Map,this.tsconfigSearchPaths=n.tsconfigSearchPaths??[e],this.pathAliases=n.pathAliases,this.langResolvers=n.langResolvers??jt()}rootDir;workspaceMap;tsconfigSearchPaths;pathAliases;langResolvers;resolutionCache=new Map;langBucketFor(e){for(let n=0;n<this.langResolvers.length;n++)if(this.langResolvers[n]?.extensions.some(r=>e.endsWith(r)))return String(n);return"none"}cacheKey(e,n){return`${J.dirname(e)}\0${this.langBucketFor(e)}\0${n}`}resolveAll(e,n){let r=this.cacheKey(e,n),o=this.resolutionCache.get(r);if(o!==void 0)return o??[];let s=this.resolveAllUncached(e,n);return this.resolutionCache.set(r,s.length>0?s:null),s}resolveAllUncached(e,n){let r=this.resolvePathAlias(n);if(r)return[r];if(n.startsWith(".")||n.startsWith("/")){let i=this.resolveLocalPath(e,n);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,n,this.rootDir,o);if(a)return a}let s=this.resolveWorkspaceImport(n);return s?[s]:[{path:n,isExternal:!0}]}resolve(e,n){return this.resolveAll(e,n)[0]??null}resolveLocalPath(e,n){let r=J.dirname(e),o=n.startsWith("/")?n:J.resolve(r,n),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,n,r){let o=e+n;if(this.isFile(o))return{path:o,isExternal:r};let s=J.join(e,`index${n}`);if(this.isFile(s))return{path:s,isExternal:r};if(n===".py"){let i=J.join(e,"__init__.py");if(this.isFile(i))return{path:i,isExternal:r}}return null}isFile(e){try{return $t.statSync(e,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}resolvePathAlias(e){if(this.pathAliases)for(let n in this.pathAliases){let r=this.matchAliasPattern(n,e),o=this.pathAliases[n];if(r&&o){let s=this.tryAliasSubstitutions(o,r[1]||"");if(s)return s}}for(let n of this.tsconfigSearchPaths){let r=J.join(n,"tsconfig.json");if($t.existsSync(r))try{let s=JSON.parse($t.readFileSync(r,"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]||"",n);if(c)return c}}}catch{}}return null}aliasRegexCache=new Map;matchAliasPattern(e,n){let r=this.aliasRegexCache.get(e);if(!r){let o=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace("\\*","(.*)");r=new RegExp(`^${o}$`),this.aliasRegexCache.set(e,r)}return n.match(r)}tryAliasSubstitutions(e,n,r=this.rootDir){let o=["",".ts",".tsx",".js",".jsx",".coffee",".ls",".lua",".feature"];for(let s of e){let i=s.replace("*",n),a=J.resolve(r,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[n,r]of this.workspaceMap){if(e!==n&&!e.startsWith(`${n}/`))continue;let o=e.slice(n.length),s={path:"",isExternal:!1,isWorkspace:!0,workspacePackage:n};if(!o){for(let a of["src/index.ts","src/index.tsx","index.ts","index.tsx","index.js"]){let c=J.join(r,a);try{if($t.statSync(c,{throwIfNoEntry:!1})?.isFile())return{...s,path:c}}catch{}}return{...s,path:r}}let i=this.resolveLocalPath(J.join(r,"_dummy"),o.slice(1));return i?{...s,path:i.path}:null}return null}}});import tt from"fs";import R from"path";import nu from"piscina";function iu(){return(process.env.MOKOSH_IGNORE_DIRS??"").split(",").map(t=>t.trim()).filter(Boolean)}function au(t,e){if(t.length===0)return e;let n=t.map(i=>R.dirname(i).split(R.sep)),r=n[0]??[];for(let i of n.slice(1)){let a=0;for(;a<r.length&&a<i.length&&r[a]===i[a];)a++;r=r.slice(0,a)}let o=r.join(R.sep)||R.sep,s=R.relative(e,o);return s.startsWith("..")||R.isAbsolute(s)?e:o}var ru,ou,su,pe,Rr=d(()=>{"use strict";l();Hn();be();tr();Ii();_i();Ot();ve();Wt();ru=["tests","test","__tests__","specs","spec"],ou=["node_modules",".git","dist","build",".next",".cache","mokosh-cache","coverage",".pytest_cache","__pycache__"],su=600;pe=class{constructor(e,n=null,r,o,s=!1,i=new Map,a=!0,c=[],p=null){this.rootDir=e;this.enableGitStats=s;this.coverageMap=i;this.parallelParsing=a;this.docFiles=p;this.previousGraph=n,this.walkIgnoreDirs=new Set([...ou,...c,...iu()]),this.resolver=r||new K(e),this.lockFile=Es(e),o&&(this.progressCallback=o)}rootDir;enableGitStats;coverageMap;parallelParsing;docFiles;graph={nodes:new Map};visited=new Set;queue=[];previousGraph=null;resolver;lockFile=null;progressCallback;pool=null;gitStatsMap=null;walkIgnoreDirs;async build(e){let n=e.map(r=>R.isAbsolute(r)?r:R.resolve(this.rootDir,r));await this.initPool(),this.enableGitStats&&(this.gitStatsMap=xs(this.rootDir));try{for(let r of n)this.enqueue(r);return await this.drain(),await this.processTestFiles(au(n,this.rootDir)),await this.processDocFiles(),this.progressCallback&&this.visited.size>=100&&process.stderr.write(`
|
|
2
|
+
var ur=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,n)=>(typeof require<"u"?require:e)[n]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var d=(t,e)=>()=>(t&&(e=t(t=0)),e);var Fu=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);import Du from"path";import{fileURLToPath as Nu}from"url";var Pu,Ru,m,p=d(()=>{"use strict";Pu=()=>Nu(import.meta.url),Ru=()=>Du.dirname(Pu()),m=Ru()});function $t(t){fr.push(t)}function ii(t){return[...Au,...fr].some(e=>typeof e=="string"?t.includes(e):e instanceof RegExp?e.test(t):e(t))}function Wt(t){mr.push(t)}function ut(){return[...Lu,...mr]}function zt(t){dr.push(t)}function gr(){return[...Iu,...dr]}function yr(t){hr=t}function xr(){return hr}function Bt(){fr.length=0,mr.length=0,dr.length=0,hr=ai}var Au,fr,Lu,mr,Iu,dr,ai,hr,_e=d(()=>{"use strict";p();Au=[".config.","biome.json","tsconfig.json","package.json",".prettierrc",".eslintrc"],fr=[];Lu=[".test.",".spec.","-test.","-spec."],mr=[];Iu=["jest","vitest","playwright","cypress","@testing-library/"],dr=[];ai=.8,hr=ai});function Sr(t){let e=new Set(Ht);for(let n of t?.blocklist??[])e.add(n.toLowerCase());for(let n of t?.allowlist??[])e.delete(n.toLowerCase());br=e}function kr(){br=new Set(Ht)}function Kt(t){if(!li.test(t))return!1;let e=t.toLowerCase();return!ci.has(e)&&!br.has(e)}function ye(t){return Ut.includes(t.kind)&&Kt(t.name)}function Cr(t){let e=new Set,n=[];for(let r of t)!ye(r)||e.has(r.name)||(e.add(r.name),n.push(r.name));return n}var Ut,ci,li,Ht,br,xe=d(()=>{"use strict";p();Ut=["comment-marker","import"],ci=new Set(["test","barrel"]),li=/^[a-zA-Z][a-zA-Z0-9_-]{1,}$/,Ht=new Set(["index","main","common","shared","types","type","constants","const","config","util","utils","helper","helpers","mock","mocks","fixture","fixtures","setup","spec","test","tests","args","props","options","opts","context","ctx","handler","handlers","callback","cb","fn","impl","run","get","set","use","name","value","data","item","result","node","org","linux","darwin","windows","freebsd","openbsd","netbsd","dragonfly","solaris","android","ios","js","wasm","wasip1","plan9","aix","illumos","amd64","arm","arm64","ppc64","ppc64le","mips","mips64","riscv64","s390x","loong64","cgo","gc","gccgo","unix"]),br=new Set(Ht)});import vr from"fs";import pi from"path";function Oe(t,{allowJs:e=!0,isExplicitPath:n=!1}={}){if(n){let r=pi.resolve(t);return vr.existsSync(r)?r.endsWith(".json")?ui(r):e?fi(r):{}:{}}for(let r of Mu){let o=pi.resolve(t,r);if(vr.existsSync(o)){if(r.endsWith(".json"))return ui(o);if(e)return fi(o)}}return{}}function ui(t){return JSON.parse(vr.readFileSync(t,"utf-8"))}function fi(t){let e=ur(t);return e&&typeof e=="object"&&"default"in e&&(e=e.default),typeof e=="function"?e({}):e}function wr(t){Bt(),kr(),Sr(t.tags);for(let e of t.configMatchers??[])$t(e);for(let e of t.testPatterns??[])Wt(e);for(let e of t.testLibraries??[])zt(e);t.barrelThreshold!==void 0&&yr(t.barrelThreshold)}function F(t){return{gitStats:t?.gitStats??!1,parallelParsing:t?.parallelParsing,pathAliases:t?.pathAliases,additionalIgnoreDirs:t?.ignoreDirs}}var Mu,Er=d(()=>{"use strict";p();_e();xe();Mu=["mokosh.config.js","mokosh.config.cjs","mokosh.config.json"]});var ue,be,Tr,Ge,ft,$,Fr,Y=d(()=>{"use strict";p();ue="mokosh-cache",be="duplication-tokens.json",Tr="duplication-result.json",Ge="graph.json",ft="branch-graphs",$=["node_modules",".git","dist","build",".next",".cache","mokosh-cache","coverage",".pytest_cache","__pycache__",".gradle","target"],Fr=[".ts",".tsx",".js",".jsx",".mjs",".cjs",".css",".scss",".sass",".less",".styl",".coffee",".ls",".lua",".py",".go",".java",".kt",".kts",".scala",".sc",".groovy",".gradle",".feature",".md",".mdx"]});import Zx from"fs";import eb from"path";var mi=d(()=>{"use strict";p()});var Jt,di=d(()=>{"use strict";p();Jt={serialize(t){let e=["graph TD"],n=new Set;for(let r of t.nodes.values()){let o=`"${r.path}"`;for(let s of r.imports){if(!s.toPath)continue;let i=`"${s.toPath}"`,a=`${r.path} -> ${s.toPath}`;if(!n.has(a)){let c=s.isStyle?"-- styles -->":"-->";e.push(` ${o} ${c} ${i}`),n.add(a)}}}return e.join(`
|
|
3
|
+
`)}}});var gi=d(()=>{"use strict";p();di()});function Ou(t,e){return t.length!==e.length?t.length<e.length:t.join("\0")<e.join("\0")}var je,Vt=d(()=>{"use strict";p();je=class{constructor(e){this.nodes=e}nodes;findUnusedFiles(e){let n=new Set(this.nodes.keys());return e.filter(r=>!n.has(r))}findHighExportUsage(e){let n=[];for(let r of this.nodes.values()){if(r.maxExportUsage===void 0||r.maxExportUsage<e)continue;let o=r.imports.reduce((s,i)=>(i.exportUsageRatio??0)>(s?.exportUsageRatio??0)?i:s,null);n.push({path:r.path,maxExportUsage:r.maxExportUsage,tightestDep:o?.toPath??""})}return n.sort((r,o)=>o.maxExportUsage-r.maxExportUsage)}traversableTargets(e,n){let r=this.nodes.get(e);if(!r)return[];let o=new Set;for(let s of r.imports)!s.toPath||s.isExternal||s.isSamePackage&&!n.has("samePackage")||s.isDocReference&&!n.has("docReference")||o.add(s.toPath);return[...o]}findCycles(e={}){let n=new Set(e.includeKinds??[]),r=[],o=new Set,s=new Set,i=[],a=c=>{o.add(c),s.add(c),i.push(c);for(let l of this.traversableTargets(c,n))if(s.has(l)){let u=i.indexOf(l);r.push([...i.slice(u),l])}else o.has(l)||a(l);s.delete(c),i.pop()};for(let c of this.nodes.keys())o.has(c)||a(c);return e.expandComponents?r:this.collapseByComponent(r,n)}collapseByComponent(e,n){if(e.length<=1)return e;let r=this.componentIds(n),o=new Map,s=new Map;for(let[i,a]of e.entries()){let c=r.get(a[0]);if(c===void 0)continue;s.has(c)||s.set(c,i);let l=o.get(c);(l===void 0||Ou(a,l))&&o.set(c,a)}return[...o.entries()].sort(([i],[a])=>s.get(i)-s.get(a)).map(([,i])=>i)}componentIds(e){let n=new Map,r=new Map,o=new Set,s=[],i=new Map,a=0,c=0;for(let l of this.nodes.keys()){if(n.has(l))continue;let u=[{node:l,targets:this.traversableTargets(l,e),next:0}];for(n.set(l,a),r.set(l,a),a++,s.push(l),o.add(l);u.length>0;){let f=u[u.length-1];if(f.next<f.targets.length){let h=f.targets[f.next++];n.has(h)?o.has(h)&&r.set(f.node,Math.min(r.get(f.node),n.get(h))):(n.set(h,a),r.set(h,a),a++,s.push(h),o.add(h),u.push({node:h,targets:this.traversableTargets(h,e),next:0}))}else{if(r.get(f.node)===n.get(f.node)){let y=[],b;do b=s.pop(),o.delete(b),y.push(b);while(b!==f.node);if(y.length>1){for(let v of y)i.set(v,c);c++}}u.pop();let h=u[u.length-1];h&&r.set(h.node,Math.min(r.get(h.node),r.get(f.node)))}}}return i}}});import hi from"fs";import Gu from"path";function Qt(t,e){let n=t.replace(/^\.\//,"");if(e.nodes.has(n))return n;let r=n.replace(/^dist\//,"src/").replace(/\.(js|mjs|cjs)$/,".ts");return e.nodes.has(r)?r:null}function yi(t,e){if(typeof t=="string")return Qt(t,e);if(t&&typeof t=="object"){let n=t;for(let r of["import","require","default"]){let o=yi(n[r],e);if(o)return o}}return null}function ju(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 $u(t,e){let n=new Set,r=new Set,o=[...e];for(;o.length;){let s=o.shift();if(r.has(s))continue;r.add(s);let i=t.nodes.get(s);if(i){for(let a of i.exports)n.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 l=t.nodes.get(a.toPath);if(l)for(let u of l.exports)n.add(u.name);o.push(a.toPath)}else for(let l of a.symbols)n.add(l)}}}return n}function Dr(t,e){let n=[],r=Gu.join(e,"package.json");if(hi.existsSync(r))try{let o=JSON.parse(hi.readFileSync(r,"utf8"));if(o.exports&&typeof o.exports=="object"&&!Array.isArray(o.exports))for(let i of Object.values(o.exports)){let a=yi(i,t);a&&!n.includes(a)&&n.push(a)}else if(typeof o.exports=="string"){let i=Qt(o.exports,t);i&&n.push(i)}let s=typeof o.bin=="string"?[o.bin]:o.bin&&typeof o.bin=="object"&&!Array.isArray(o.bin)?Object.values(o.bin).filter(i=>typeof i=="string"):[];for(let i of s){let a=Qt(i,t);a&&!n.includes(a)&&n.push(a)}if(n.length===0)for(let i of[o.main,o.module].filter(Boolean)){let a=Qt(i,t);a&&!n.includes(a)&&n.push(a)}}catch{}if(n.length===0){for(let o of["src/index.ts","src/index.js","index.ts","index.js"])if(t.nodes.has(o)){n.push(o);break}}return n.length===0?Bu(t):n}function zu(t){return t.endsWith("_test.go")||/(^|\/)(test|tests|__tests__|testdata)\//.test(t)||/[._-](test|spec)\.[^/]+$/.test(t)}function Bu(t){let e=[...t.nodes.values()],n=i=>e.filter(a=>i(a.type)&&a.category!=="test"&&!zu(a.path)),r=n(i=>i==="python");if(r.length>0){let i=r.filter(a=>a.path.replace(/^.*\//,"")==="__init__.py");if(i.length>0){let a=Math.min(...i.map(c=>c.path.split("/").length));return i.filter(c=>c.path.split("/").length===a).map(c=>c.path).sort()}return r.map(a=>a.path).sort()}let o=n(i=>i==="go");if(o.length>0)return o.map(i=>i.path).sort();let s=n(i=>Wu.has(i));return s.length>0?s.map(i=>i.path).sort():[]}function Uu(t,e){let n=new Set(e);for(let r of e)t.traverse(r,o=>(n.add(o.path),!0),{direction:"outgoing"});return n}function Hu(t,e,n){let r=new Map;for(let o of e){if(n.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=r.get(a.name),l=!!(a.signature||a.doc);(!c||l&&!i)&&r.set(a.name,{file:o,symbol:a})}}return r}function Ku(t,e,n,r){let o=[];for(let s of t){let i=e.get(s),a=r.flatMap(f=>n.nodes.get(f)?.exports??[]).find(f=>f.name===s),c=i?.symbol??a,l=i?.file??r.find(f=>n.nodes.get(f)?.exports.some(h=>h.name===s))??r[0],u={name:s,definedIn:l,kind:ju(c?.signature)};c?.doc&&(u.doc=c.doc),c?.signature&&(u.signature=c.signature),o.push(u)}return o.sort((s,i)=>s.name.localeCompare(i.name)),o}function Ju(t,e,n){let r=c=>t.nodes.get(c)?.category==="test",o=[...e].filter(c=>!n.includes(c)&&!r(c)),s=[...t.nodes.keys()].filter(c=>!e.has(c)),i=s.filter(c=>!r(c)),a=s.filter(c=>r(c));return{internalFiles:o,unreachableFromEntry:i,testFiles:a}}function Nr(t,e){if(e.length===0)throw new Error("buildApiSurface requires at least one entry point");for(let l of e)if(!t.nodes.has(l))throw new Error(`Entry point not found in graph: ${l}`);let n=Uu(t,e),r=Hu(t,n,e),o=$u(t,e),s=Ku(o,r,t,e),{internalFiles:i,unreachableFromEntry:a,testFiles:c}=Ju(t,n,e);return{entryPoints:e,publicExports:s,internalFiles:i,unreachableFromEntry:a,testFiles:c}}var Wu,Pr=d(()=>{"use strict";p();Wu=new Set(["java","kotlin","scala","groovy"])});function Rr(t,e){let n=null,r=[];for(let s of t.nodes.values()){s.exports.some(i=>i.name===e)&&(n=s.path);for(let i of s.callEdges??[])i.to===e&&r.push({file:s.path,callerFunction:i.from})}let o=[];if(n){let s=t.nodes.get(n);for(let i of s?.callEdges??[])i.from===e&&o.push({file:i.toFile,calleeFunction:i.to})}return{functionName:e,definedIn:n,callers:r,callees:o}}var Ar=d(()=>{"use strict";p()});import yb from"fs";import bb from"path";function xi(t){let e=[...t.nodes.entries()].sort(([r],[o])=>r.localeCompare(o)).map(([r,o])=>`${r}:${o.mtime}:${o.size}`).join("|"),n=2166136261;for(let r=0;r<e.length;r++)n^=e.charCodeAt(r),n=Math.imul(n,16777619)>>>0;return n.toString(16).padStart(8,"0")}function Lr(t){let e=new Map;for(let n of t.nodes.keys()){let r=[];t.traverse(n,o=>(o.path!==n&&r.push(o.path),!0),{direction:"incoming"}),e.set(n,r)}return{impact:e,graphHash:xi(t)}}function Ir(t,e){return t.impact.get(e)??[]}var Mr=d(()=>{"use strict";p()});var _,$e=d(()=>{"use strict";p();Vt();_=class t{constructor(e){this.nodes=e}nodes;_incomingEdgesCache=null;_callIncomingCache=null;serialize(){return{nodes:Array.from(this.nodes.values())}}static deserialize(e){let n=new Map;for(let r of e.nodes)n.set(r.path,r);return new t(n)}getIncomingEdgesMap(){if(this._incomingEdgesCache)return this._incomingEdgesCache;let e=new Map;for(let n of this.nodes.values())for(let r of n.imports)if(r.toPath){let o=e.get(r.toPath)||[];o.push(n.path),e.set(r.toPath,o)}return this._incomingEdgesCache=e,e}dfs(e,n,r,o){let s=new Set,i=r.maxDepth??1/0,a=[{path:e,depth:0,parent:null}];for(;a.length>0;){let c=a.pop(),{path:l,depth:u,parent:f}=c;if(u>i||s.has(l))continue;let h=this.nodes.get(l);if(!h||(s.add(l),n(h,u,f)===!1))continue;let y=o(l);for(let b=y.length-1;b>=0;b--)a.push({path:y[b],depth:u+1,parent:l})}}traverse(e,n,r={}){let o=r.direction??"outgoing",s=o==="incoming"?this.getIncomingEdgesMap():null;this.dfs(e,n,r,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 n of this.nodes.values())for(let r of n.callEdges??[]){let o=e.get(r.toFile)??[];o.push(n.path),e.set(r.toFile,o)}return this._callIncomingCache=e,e}traverseCalls(e,n,r={}){let o=r.direction??"outgoing",s=o==="incoming"?this.getCallIncomingCache():null;this.dfs(e,n,r,i=>o==="outgoing"?this.nodes.get(i)?.callEdges?.map(a=>a.toFile)??[]:s?.get(i)??[])}getCallers(e){let n=[];return this.traverseCalls(e,r=>(r.path!==e&&n.push(r.path),!0),{direction:"incoming",maxDepth:1}),n}getCallEdgesFor(e){return this.nodes.get(e)?.callEdges??[]}getNeighbors(e){let n=this.nodes.get(e);return n?n.imports.map(r=>this.nodes.get(r.toPath)).filter(r=>r!==void 0):[]}findUnusedFiles(e){return new je(this.nodes).findUnusedFiles(e)}findCycles(e){return new je(this.nodes).findCycles(e)}}});import mt from"fs";import bi from"path";function Yt(t){return bi.join(t,ue,ft)}function Si(t,e){return bi.join(Yt(t),`${e}.json`)}function ki(t,e){let n=Si(t,e);if(!mt.existsSync(n))return null;try{let r=mt.readFileSync(n,"utf-8");return _.deserialize(JSON.parse(r))}catch{return null}}function Ci(t,e,n){let r=Yt(t);mt.existsSync(r)||mt.mkdirSync(r,{recursive:!0}),mt.writeFileSync(Si(t,e),JSON.stringify(n.serialize()))}var vi=d(()=>{"use strict";p();Y();$e()});import{execFileSync as _r}from"child_process";function Ti(t,e){let n="",r=0;for(let o of t.split(`
|
|
4
|
+
`)){if(o.startsWith("\0")){let[,c,l]=o.slice(1).split(" ");n=c??"",r=l?Number(l)*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,n,r)}}function Fi(t){let e=new Map;try{let n=_r("git",["-C",t,"log","--since=90 days ago","--name-status","-M",`--format=${wi}`],{encoding:"utf-8",stdio:["ignore","pipe","ignore"],maxBuffer:Ei});Ti(n,(r,o,s)=>{let i=e.get(r);if(i){i.commitCount90d+=1;return}e.set(r,{commitCount90d:1,lastAuthor:o||void 0,lastCommitAt:s||void 0})})}catch{return e}try{let n=_r("git",["-C",t,"log","--name-status","-M",`--format=${wi}`],{encoding:"utf-8",stdio:["ignore","pipe","ignore"],maxBuffer:Ei});Ti(n,(r,o,s)=>{e.has(r)||e.set(r,{commitCount90d:0,lastAuthor:void 0,lastCommitAt:s||void 0})})}catch{}return e}var Xt,wi,Ei,Or=d(()=>{"use strict";p();Xt=class{getChangedFiles(e,n){try{let o=[["diff","--name-only"],["diff","--cached","--name-only"],["ls-files","--others","--exclude-standard"],...n?[["diff","--name-only","--end-of-options",`${n}...HEAD`]]:[]].flatMap(s=>{try{return _r("git",s,{cwd:e,encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).split(`
|
|
5
|
+
`).map(a=>a.trim()).filter(a=>a!=="")}catch{return[]}});return Array.from(new Set(o))}catch(r){return console.error("Error getting git diff:",r),[]}}},wi="%x00%H%x09%ae%x09%at",Ei=256*1024*1024});var dt,Gr=d(()=>{"use strict";p();dt=["package-lock.json","yarn.lock","pnpm-lock.yaml"]});import Zt from"fs";import Vu from"path";import{load as Di}from"js-yaml";function Ni(t){let e=t.lastIndexOf("@");return e>0?t.substring(0,e):t}function Qu(t){return t.replace(/:$/,"").split(",").map(e=>{let n=e.trim();return n.startsWith('"')&&(n=n.slice(1)),n.endsWith('"')&&(n=n.slice(0,-1)),Ni(n)}).filter(Boolean)}function Yu(t,e){let n=t.startsWith("/")?t.slice(1):t,r=n.lastIndexOf("@");return r>0?{name:n.substring(0,r),version:e||n.substring(r+1)}:{name:n,version:e}}function Xu(t){try{let e=Di(t),n={dependencies:{}};for(let[r,o]of Object.entries(e))if(!(r==="__metadata"||!o?.version))for(let s of r.split(", ")){let i=Ni(s);i&&(n.dependencies[i]={version:o.version,...o.dependencies!==void 0&&{dependencies:o.dependencies}})}return n}catch{return null}}function Zu(t){let e={dependencies:{}};for(let n of t.split(/\n\n+/)){let r=n.split(`
|
|
6
|
+
`).filter(c=>c.trim().length>0&&!c.trim().startsWith("#"));if(r.length<2)continue;let o=r[0];if(!o||o.startsWith(" "))continue;let s=Qu(o);if(s.length===0)continue;let a=r.find(c=>c.trim().startsWith('version "'))?.match(/version "(.*?)"/)?.[1]??"";for(let c of s)e.dependencies[c]={version:a}}return e}function Pi(t){let e=Zt.readFileSync(t,"utf-8"),n=JSON.parse(e),r={dependencies:{}};if(n.packages)for(let[o,s]of Object.entries(n.packages)){if(!o.startsWith("node_modules/"))continue;let i=o.replace("node_modules/","");i.includes("node_modules/")||(r.dependencies[i]={version:s.version,...s.dependencies!==void 0&&{dependencies:s.dependencies}})}else if(n.dependencies)for(let[o,s]of Object.entries(n.dependencies))r.dependencies[o]={version:s.version,...s.dependencies!==void 0&&{dependencies:s.dependencies}};return r}function Ri(t){let e=Zt.readFileSync(t,"utf-8");if(e.includes("__metadata:")){let n=Xu(e);if(n!==null)return n}return Zu(e)}function Ai(t){let e=Zt.readFileSync(t,"utf-8"),n={dependencies:{}};try{let r=Di(e);if(r.packages)for(let[o,s]of Object.entries(r.packages)){let{name:i,version:a}=Yu(o,s.version);i&&(n.dependencies[i]={version:a,...s.dependencies!==void 0&&{dependencies:s.dependencies}})}if(r.dependencies)for(let[o,s]of Object.entries(r.dependencies)){if(n.dependencies[o])continue;let i=typeof s=="string"?s:s.version;n.dependencies[o]={version:i||""}}}catch{}return n}function jr(t){for(let e of dt){let n=Vu.join(t,e);if(Zt.existsSync(n))return qu[e](n)}return null}var qu,$r=d(()=>{"use strict";p();Gr();qu={"package-lock.json":Pi,"yarn.lock":Ri,"pnpm-lock.yaml":Ai}});function Li(t){let e=t.trim();return e.length>=2&&(e[0]==='"'||e[0]==="'")&&e[e.length-1]===e[0]?e.slice(1,-1):e}function ef(t){let e=t.trim();if(e.startsWith('"')||e.startsWith("'")){let a=Li(e).split(":");return a.length>=3&&a[0]&&a[2]?{group:a[0],version:a[2]}:null}if(!e.startsWith("{"))return null;let n=e.match(/module\s*=\s*["']([^"']+)["']/),r=e.match(/group\s*=\s*["']([^"']+)["']/),o=n?n[1].split(":")[0]:r?.[1];if(!o)return null;let s=e.match(/version\.ref\s*=\s*["']([^"']+)["']/)??e.match(/version\s*=\s*\{\s*ref\s*=\s*["']([^"']+)["']/),i=e.match(/version\s*=\s*["']([^"']+)["']/);return{group:o,...i?.[1]!==void 0&&{version:i[1]},...s?.[1]!==void 0&&{versionRef:s[1]}}}function Wr(t){let e=t.split(/\r?\n/).map(s=>s.replace(/#.*$/,"").trim()),n={},r="";for(let s of e){let i=s.match(/^\[([\w.-]+)\]$/);if(i){r=i[1];continue}if(r!=="versions"||!s)continue;let a=s.indexOf("=");if(a===-1)continue;let c=s.slice(0,a).trim(),l=Li(s.slice(a+1));c&&l&&(n[c]=l)}let o={};r="";for(let s of e){let i=s.match(/^\[([\w.-]+)\]$/);if(i){r=i[1];continue}if(r!=="libraries"||!s)continue;let a=s.indexOf("=");if(a===-1)continue;let c=ef(s.slice(a+1));if(!c)continue;let l=c.versionRef?n[c.versionRef]:c.version;l&&(o[c.group]=l)}return o}function zr(t){let e={};for(let n of t.split(/\r?\n/)){let r=n.trim();if(!r||r.startsWith("#")||r.startsWith("empty="))continue;let s=r.split("=")[0].split(":");s.length>=3&&s[0]&&s[2]&&(e[s[0]]=s[2])}return e}function Br(t){let e={},n=/["']([\w.-]+):([\w.-]+):([\w.\-+]+)["']/g;for(let o=n.exec(t);o;o=n.exec(t)){let[,s,,i]=o;s&&i&&/\d/.test(i)&&(e[s]=i)}let r=/group:\s*["']([\w.-]+)["'][^\n)]*?version:\s*["']([\w.\-+]+)["']/g;for(let o=r.exec(t);o;o=r.exec(t))o[1]&&o[2]&&/\d/.test(o[2])&&(e[o[1]]=o[2]);return e}var Ur=d(()=>{"use strict";p()});function qt(t){let e={},n=/["']([\w.-]+)["']\s*%%?\s*["']([\w.-]+)["']\s*%\s*["']([\w.\-+]+)["']/g;for(let r=n.exec(t);r;r=n.exec(t)){let[,o,,s]=r;o&&s&&(e[o]=s)}return e}var Hr=d(()=>{"use strict";p()});import tn from"fs";import en from"path";function gt(t){try{return tn.existsSync(t)?tn.readFileSync(t,"utf-8"):null}catch{return null}}function Kr(t){let e={},n=u=>{for(let[f,h]of Object.entries(u))!e[f]&&h&&(e[f]=h)},r=gt(en.join(t,"gradle","libs.versions.toml"));r&&n(Wr(r));let o=[],s=[],i=[],a=(u,f)=>{let h;try{h=tn.readdirSync(u,{withFileTypes:!0})}catch{return}for(let y of h){let b=en.join(u,y.name);if(y.isDirectory()){f<nf&&!y.name.startsWith(".")&&!tf.has(y.name)&&a(b,f+1);continue}y.isFile()&&(y.name==="gradle.lockfile"?o.push(b):y.name==="build.gradle"||y.name==="build.gradle.kts"?s.push(b):y.name==="build.sbt"&&i.push(b))}};a(t,0);for(let u of o){let f=gt(u);f&&n(zr(f))}for(let u of s){let f=gt(u);f&&n(Br(f))}for(let u of i){let f=gt(u);f&&n(qt(f))}try{let u=en.join(t,"project");for(let f of tn.readdirSync(u,{withFileTypes:!0}))if(f.isFile()&&f.name.endsWith(".scala")){let h=gt(en.join(u,f.name));h&&n(qt(h))}}catch{}let c=Object.keys(e);if(c.length===0)return null;let l={};for(let u of c)l[u]={version:e[u]};return l}var tf,nf,Jr=d(()=>{"use strict";p();Ur();Hr();tf=new Set(["node_modules","build",".gradle","target",".git","dist"]),nf=2});function Ii(t){let e=jr(t),n=Kr(t);return n?{...e??{dependencies:{}},jvmDependencies:n}:e}var Vr=d(()=>{"use strict";p();$r();Jr();Ur();$r();Jr();Hr();Gr()});import Mi from"path";function K(t){switch(Mi.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":return"java";case".kt":case".kts":return"kotlin";case".scala":case".sc":return"scala";case".groovy":case".gradle":return"groovy";case".cpp":case".cc":case".cxx":case".c":return"unknown";case".feature":return"gherkin";case".md":case".mdx":return"markdown";default:return"unknown"}}function W(t){let e=Mi.extname(t).toLowerCase();return[".css",".scss",".sass",".less",".styl"].includes(e)}var ne=d(()=>{"use strict";p()});function fe(t){return t.startsWith("'")||t.startsWith('"')?t.slice(1,-1):t}function We(t){let e=new Set,n=/@tag\s+([a-zA-Z0-9_-]+)/g,r=n.exec(t);for(;r!==null;)r[1]&&e.add(r[1]),r=n.exec(t);return e}function ze(t,e){let n=t.toLowerCase();return n.includes(".test.")||n.includes(".spec.")||e.has("test")?"test":"logic"}var nn=d(()=>{"use strict";p()});import rf from"coffeescript";function Oi(t){if(t){if(typeof t.originalValue=="string")return t.originalValue;if(typeof t.value=="string")return fe(t.value)}}function Se(t){if(t){if(typeof t.value=="string")return t.value;if(typeof t.base?.value=="string")return t.base.value}}function of(t,e){let n=Oi(e.source);return n?{fromPath:t,toPath:"",rawSpecifier:n,isStyle:W(n),type:"static"}:null}function sf(t,e){let n=e.variable?.base?.value==="require",r=Oi(e.args?.[0]?.base);return!n||!r?null:{fromPath:t,toPath:"",rawSpecifier:r,isStyle:W(r),type:"require"}}function _i(t,e){if(e)return[{name:e}];let n=t.value;if(n?.constructor?.name==="Class"){let o=Se(n.variable);return o?[{name:o}]:[]}if(n?.base?.constructor?.name==="Obj"&&Array.isArray(n.base.properties))return n.base.properties.map(o=>Se(o.variable)??Se(o)).filter(o=>!!o).map(o=>({name:o}));let r=Se(n);return r?[{name:r}]:[]}function af(t){if(Array.isArray(t.specifiers))return t.specifiers.map(n=>n.identifier??n.original?.value).filter(n=>!!n).map(n=>({name:n}));let e=Se(t.variable)??Se(t.variable?.base);return e?[{name:e}]:[]}function cf(t,e,n,r){let o=e.constructor?.name;if(o==="ImportDeclaration"){let s=of(t,e);s&&n.push(s)}else if(o==="Call"){let s=sf(t,e);s&&n.push(s)}else if(o==="Assign"){let s=Se(e.variable?.base),i=e.variable?.properties?.[0]?.name?.value;s==="module"&&i==="exports"?r.push(..._i(e,void 0)):s==="exports"&&typeof i=="string"&&r.push(..._i(e,i))}else o==="ExportNamedDeclaration"&&e.clause?r.push(...af(e.clause)):o==="ExportDefaultDeclaration"&&r.push({name:"default"})}function Qr(t,e,n,r){if(!(!e||typeof e!="object")){cf(t,e,n,r);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)Qr(t,i,n,r);else Qr(t,s,n,r)}}}function Gi(t,e){let n=We(e),r=ze(t,n),o=[],s=[];try{Qr(t,rf.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(n).map(c=>({name:c,kind:"comment-marker"})),category:r}}var ji=d(()=>{"use strict";p();ne();nn()});function Be(t,e){$i.set(t,e)}function Wi(t){return $i.get(t)}var $i,ht=d(()=>{"use strict";p();$i=new Map});import{AstBuilder as lf,GherkinClassicTokenMatcher as pf,Parser as uf}from"@cucumber/gherkin";import{IdGenerator as ff}from"@cucumber/messages";function Yr(t,e){let n=new Set,r=o=>{for(let s of o)n.add(s.name.startsWith("@")?s.name.slice(1):s.name)};try{let o=new lf(mf),s=new pf,a=new uf(o,s).parse(e);if(a.feature){r(a.feature.tags);for(let c of a.feature.children){if(c.scenario){r(c.scenario.tags);for(let l of c.scenario.examples)r(l.tags)}if(c.rule)for(let l of c.rule.children)l.scenario&&r(l.scenario.tags)}}}catch(o){console.warn(`[GherkinParser] Failed to parse ${t}:`,o)}return{imports:[],exports:[],tags:Array.from(n).map(o=>({name:o,kind:"comment-marker"})),category:"test"}}var mf,zi=d(()=>{"use strict";p();ht();mf=ff.uuid();Be("gherkin",Yr)});function ke(t){let e=[],n=t.firstChild;for(;n;)e.push(n),n=n.nextSibling;return e}function Ce(t,e){let n=1;for(let r=0;r<e&&r<t.length;r++)t[r]===`
|
|
7
|
+
`&&n++;return n}var rn=d(()=>{"use strict";p()});function df(t,e){let n=1;function r(o){switch(o.type.name){case"IfStatement":case"ForStatement":n++;break;case"Case":{o.firstChild?.type.name==="case"&&n++;break}case"LogicOp":{let i=e.slice(o.from,o.to);(i==="&&"||i==="||")&&n++;break}}let s=o.firstChild;for(;s;)r(s),s=s.nextSibling}return r(t),n}function Ui(t,e,n,r){let o=n?1:1+e,s=ke(t),i=n?e:e+1,a=s[1];a&&a.type.name!=="Block"&&(o+=Ue(a,i,!1,r));let c=s.find(u=>u.type.name==="Block");c&&(o+=Ue(c,i,!1,r));let l=s.findIndex(u=>u.type.name==="else");if(l>=0){let u=s[l+1];u?.type.name==="IfStatement"?o+=Ui(u,e,!0,r):u&&(o+=1+Ue(u,e+1,!1,r))}return o}function Bi(t,e,n){let r=1+e,o=t.firstChild;for(;o;)r+=Ue(o,e+1,!1,n),o=o.nextSibling;return r}function gf(t,e,n){let r=0,o=t.firstChild;for(;o;)r+=Ue(o,e,!1,n),o=o.nextSibling;return r}function hf(t,e){let n=e.slice(t.from,t.to);return n==="&&"||n==="||"}function Ue(t,e,n,r){let o=t.type.name;if(o==="IfStatement")return Ui(t,e,n,r);if(o==="ForStatement"||o==="SwitchStatement"||o==="SelectStatement")return Bi(t,e,r);let s=o==="LogicOp"&&hf(t,r)?1:0;return e>0&&o==="FunctionLiteral"?s+Bi(t,e,r):s+gf(t,e,r)}function yf(t,e){return Ue(t,0,!1,e)}function on(t,e){return{complexity:df(t,e),cognitiveComplexity:yf(t,e)}}function Xr(t,e){let r=t.getChild("Parameters")?.getChild("Parameter"),o=r?.getChild("TypeName")??r?.getChild("PointerType")?.getChild("TypeName");return o?e.slice(o.from,o.to):void 0}function Hi(t,e){let n=[],r=t.cursor();do if(r.name==="FunctionDecl"){let o=r.node.getChild("DefName");if(o){let s=e.slice(o.from,o.to),{complexity:i,cognitiveComplexity:a}=on(r.node,e);n.push({name:s,line:Ce(e,r.from),complexity:i,cognitiveComplexity:a})}}else if(r.name==="MethodDecl"){let o=r.node.getChild("FieldName");if(o){let s=e.slice(o.from,o.to),i=Xr(r.node,e),a=i?`${i}.${s}`:s,{complexity:c,cognitiveComplexity:l}=on(r.node,e);n.push({name:a,line:Ce(e,r.from),complexity:c,cognitiveComplexity:l})}}while(r.next());return n}var Ki=d(()=>{"use strict";p();rn()});import xf from"path";import{parser as bf}from"@lezer/go";function Vi(t,e){let n=[],r=new Map,o=new Set,s=new Set,i=new Map,a=bf.parse(e),c=a.cursor();do switch(c.name){case"LineComment":{let k=e.slice(c.from,c.to),E=k.match(Sf);E?.[1]&&o.add(E[1]);let A=k.match(kf);A&&Ji(A[1],s);let G=k.match(Cf);G&&Ji(G[1],s);break}case"ImportSpec":{let k=c.node.getChild("String");if(k){let A=e.slice(k.from,k.to).slice(1,-1);n.push({fromPath:t,toPath:"",rawSpecifier:A,isExternal:!0,isStyle:!1,type:"static"});let G=c.node.getChild("DefName"),N=G?e.slice(G.from,G.to):A.split("/").pop();N&&N!=="_"&&N!=="."&&i.set(N,A)}break}case"FunctionDecl":case"MethodDecl":case"TypeDecl":case"VarDecl":case"ConstDecl":{let k=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(k){let E=e.slice(k.from,k.to);E!=="_"&&/^[A-Z]/.test(E)&&!r.has(E)&&r.set(E,{name:E})}break}}while(c.next());let l=n.some(k=>k.rawSpecifier==="testing"),u=xf.basename(t).endsWith("_test.go")||o.has("test")||l?"test":"logic",f=new Set([...o,...s]),{complexity:h,cognitiveComplexity:y}=on(a.topNode,e),b=Hi(a,e),v=u==="test"?[]:vf(a,e,i);return{imports:n,exports:Array.from(r.values()),tags:Array.from(f).map(k=>({name:k,kind:"comment-marker"})),category:u,rawCallEdges:v,complexity:h,cognitiveComplexity:y,...b.length>0?{functions:b}:{}}}function vf(t,e,n){let r=[];function o(i,a){if(i.type.name==="CallExpr"){let l=i.firstChild;if(l?.type.name==="SelectorExpr"){let u=l.firstChild,f=l.getChild("FieldName");if(u?.type.name==="VariableName"&&f){let h=e.slice(u.from,u.to),y=n.get(h);if(y){let b=e.slice(f.from,f.to);r.push({from:a,to:b,toSpecifier:y})}}}}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),l=Xr(s.node,e);o(a,l?`${l}.${c}`:c)}}while(s.next());return r}function Ji(t,e){for(let n of t.split(/[\s,&|!()]+/)){let r=n.trim();r&&r!=="ignore"&&e.add(r)}}var Sf,kf,Cf,Qi=d(()=>{"use strict";p();Ki();Sf=/\/\/\s*@tag\s+([a-zA-Z0-9_-]+)/,kf=/^\/\/go:build\s+(.+)$/,Cf=/^\/\/\s*\+build\s+(.+)$/});function qr(t){let e=t.replace(/\.\w+$/,"");return Ff.test(e)}function He(t){let e=new Set;for(let n of t.matchAll(wf))n[1]&&e.add(n[1]);return e}function me(t){let e=t.replace(/\/\*[\s\S]*?\*\//g,n=>n.replace(/[^\n]/g," "));return e=e.replace(/\/\/[^\n]*/g,n=>" ".repeat(n.length)),e}function Ke(t){let e=me(t),n=new Set;for(let o of e.matchAll(/@([A-Z]\w*)/g))o[1]&&n.add(o[1]);let r=new Set;for(let o of e.matchAll(/\b(?:class|object|interface|trait|enum)\s+([A-Za-z_]\w*)/g))o[1]&&r.add(o[1]);return{annotations:[...n],typeNames:[...r]}}function sn(t){let e=t.split(".").pop();return e&&e!=="*"?e:void 0}function Je(t,e,n=e){let r=sn(n);return{fromPath:t,toPath:"",rawSpecifier:e,isExternal:!0,isStyle:!1,type:"static",symbols:r?[r]:void 0}}function de(t,e){return{fromPath:t,toPath:"",rawSpecifier:`${e}.*`,isExternal:!0,isStyle:!1,type:"side-effect",isSamePackage:!0}}function X(t,e){let n=[];for(let r of me(t).split(`
|
|
8
|
+
`)){let o=r.trim();if(!o||o.startsWith("@")||o.startsWith("*"))continue;let s=o.match(/^package\s+(?:object\s+)?([\w.]+)/);if(s?.[1]){if(n.push(s[1]),!e)break;continue}if(!(e&&/^import\s/.test(o)))break}return n.length>0?n.join("."):null}function re(t,e,n={}){let r=t.replace(/\\/g,"/"),o=r.split("/").pop()??"";if(o.endsWith(".gradle")||o==="build.gradle.kts"||o==="settings.gradle.kts")return"config";if(Tf.test(r)||e.some(i=>Ef.some(a=>i===a||i.startsWith(`${a}.`))))return"test";let s=n.annotations??[];return s.some(i=>Df.has(i))?"config":s.some(i=>Nf.has(i))||(n.typeNames??[]).some(i=>Rf.some(a=>i.endsWith(a)))?"ui":s.some(i=>Pf.has(i))?"logic":qr(o)?"test":"logic"}var wf,Ef,Zr,Tf,Ff,Df,Nf,Pf,Rf,Ve=d(()=>{"use strict";p();wf=/\/\/\s*@tag\s+([a-zA-Z0-9_-]+)/g,Ef=["org.junit","androidx.test","org.robolectric","org.mockito","org.scalatest","munit","spock.lang","io.kotest","org.spekframework","org.testng","org.assertj","com.google.truth","org.hamcrest","io.mockk","com.nhaarman.mockitokotlin2"],Zr=["test","androidTest","integrationTest","it"],Tf=new RegExp(`/src/(${Zr.join("|")})/`),Ff=/(?:Test|Tests|Spec|IT|ITCase)$/;Df=new Set(["Configuration","SpringBootApplication","EnableAutoConfiguration"]),Nf=new Set(["Composable","Preview"]),Pf=new Set(["RestController","Controller","Service","Repository","Component","Entity","MappedSuperclass","Embeddable"]),Rf=["Activity","Fragment","ViewModel","Screen","Composable"]});function If(t,e){return t?e.endsWith(".*")?e.slice(0,-2)||null:e.split(".").slice(0,-1).join(".")||null:e||null}function Yi(t,e){let n=He(e),o=me(e).split(`
|
|
9
|
+
`),s=[],i=new Set;for(let l of o){let u=l.match(Af);if(u?.[2]){let h=If(!!u[1],u[2]);h&&s.push(Je(t,h,u[2]));continue}let f=l.match(Lf);f?.[2]&&i.add(f[2])}let a=X(e,!1);a&&s.push(de(t,a));let c=Array.from(i,l=>({name:l}));return{imports:s,exports:c,tags:Array.from(n).map(l=>({name:l,kind:"comment-marker"})),category:re(t,s.map(l=>l.rawSpecifier),{typeNames:[...i],annotations:Ke(e).annotations})}}var Af,Lf,Xi=d(()=>{"use strict";p();Ve();Af=/^\s*import\s+(static\s+)?([\w.]+(?:\.\*)?)(?:\s+as\s+\w+)?\s*$/,Lf=/^(?:@\w+\s+)*(?:public\s+|private\s+|protected\s+|final\s+|abstract\s+|static\s+)*(class|interface|trait|enum|def)\s+([A-Za-z_][A-Za-z0-9_]*)/});function _f(t,e){let n=1;function r(o){let s=o.type.name;if(s==="IfStatement"||s==="CatchClause"||s==="TernaryExpression")n++;else if(Zi.has(s))n++;else if(s==="SwitchLabel")o.firstChild?.type.name==="case"&&n++;else if(s==="LogicOp"){let a=e.slice(o.from,o.to);(a==="&&"||a==="||")&&n++}let i=o.firstChild;for(;i;)r(i),i=i.nextSibling}return r(t),n}function qi(t,e,n,r){let o=n?1:1+e,s=[];for(let u=t.firstChild;u;u=u.nextSibling)s.push(u);let i=n?e:e+1,a=s[1];a&&a.type.name!=="Block"&&(o+=Qe(a,i,!1,r));let c=s.find(u=>u.type.name==="Block");c&&(o+=Qe(c,i,!1,r));let l=s.findIndex(u=>u.type.name==="else");if(l>=0){let u=s[l+1];u?.type.name==="IfStatement"?o+=qi(u,e,!0,r):u&&(o+=1+Qe(u,e+1,!1,r))}return o}function eo(t,e,n){let r=1+e,o=t.firstChild;for(;o;)r+=Qe(o,e+1,!1,n),o=o.nextSibling;return r}function Of(t,e,n){let r=0,o=t.firstChild;for(;o;)r+=Qe(o,e,!1,n),o=o.nextSibling;return r}function Gf(t,e){let n=e.slice(t.from,t.to);return n==="&&"||n==="||"}function Qe(t,e,n,r){let o=t.type.name;if(o==="IfStatement")return qi(t,e,n,r);if(Zi.has(o)||o==="SwitchStatement"||o==="CatchClause"||o==="TernaryExpression")return eo(t,e,r);let s=o==="LogicOp"&&Gf(t,r)?1:0;return e>0&&o==="LambdaExpression"?s+eo(t,e,r):s+Of(t,e,r)}function jf(t,e){return Qe(t,0,!1,e)}function to(t,e){return{complexity:_f(t,e),cognitiveComplexity:jf(t,e)}}function no(t,e){for(let n=t.parent;n;n=n.parent)if(Mf.has(n.type.name)){let r=n.getChild("Definition");if(r)return e.slice(r.from,r.to)}}function ea(t,e){let n=[],r=t.cursor();do if(r.name==="MethodDeclaration"||r.name==="ConstructorDeclaration"){let o=r.node.getChild("Definition");if(o){let s=e.slice(o.from,o.to),i=no(r.node,e),a=i&&r.name==="MethodDeclaration"?`${i}.${s}`:s,{complexity:c,cognitiveComplexity:l}=to(r.node,e);n.push({name:a,line:Ce(e,r.from),complexity:c,cognitiveComplexity:l})}}while(r.next());return n}var Zi,Mf,ta=d(()=>{"use strict";p();rn();Zi=new Set(["ForStatement","EnhancedForStatement","WhileStatement","DoStatement"]),Mf=new Set(["ClassDeclaration","InterfaceDeclaration","EnumDeclaration","RecordDeclaration","AnnotationTypeDeclaration"])});import{parser as $f}from"@lezer/java";function zf(t,e){let n=t.getChild("ScopedIdentifier");if(!n)return null;let r=t.getChild("static")!=null,o=t.getChild("Asterisk")!=null,s=e.slice(n.from,n.to);if(r){if(o)return s?{specifier:s,wildcard:!1}:null;let i=s.split(".").slice(0,-1).join(".");return i?{specifier:i,wildcard:!1,symbol:sn(s)}:null}return o?{specifier:`${s}.*`,wildcard:!0}:{specifier:s,wildcard:!1,symbol:sn(s)}}function Bf(t){let e=new Map;for(let n of t){if(n.type==="side-effect")continue;let r=n.rawSpecifier;if(r.endsWith(".*"))continue;let o=r.split(".").pop();o&&e.set(o,r)}return e}function Uf(t,e){let n=t;if(n.name==="GenericType"&&(n=n.firstChild),!n)return null;if(n.name==="TypeName")return e.slice(n.from,n.to);if(n.name==="ScopedTypeName"){let r=null;for(let o=n.firstChild;o;o=o.nextSibling)o.name==="TypeName"&&(r=o);return r?e.slice(r.from,r.to):null}return null}function Hf(t,e,n){let r=[];function o(i,a){let c=i.type.name;if(c==="MethodInvocation"){let u=i.firstChild;if(u?.type.name==="Identifier"){let f=n.get(e.slice(u.from,u.to)),h=i.getChild("MethodName");f&&h&&r.push({from:a,to:e.slice(h.from,h.to),toSpecifier:f})}}else if(c==="ObjectCreationExpression"){let u=i.getChild("TypeName")??i.getChild("GenericType")??i.getChild("ScopedTypeName"),f=u&&Uf(u,e);if(f){let h=n.get(f);h&&r.push({from:a,to:"new",toSpecifier:h})}}let l=i.firstChild;for(;l;)o(l,a),l=l.nextSibling}let s=t.cursor();do if(s.name==="MethodDeclaration"||s.name==="ConstructorDeclaration"){let i=s.node.getChild("Definition"),a=s.node.getChild("Block")??s.node.getChild("ConstructorBody");if(i&&a){let c=e.slice(i.from,i.to),l=no(s.node,e),u=l&&s.name==="MethodDeclaration"?`${l}.${c}`:c;o(a,u)}}while(s.next());return r}function na(t,e){let n=[],r=new Map,o=new Set,s=new Set,i;try{i=$f.parse(e)}catch{return{imports:[],exports:[],tags:[],category:re(t,[])}}let a=i.cursor();do switch(a.name){case"LineComment":{let b=e.slice(a.from,a.to).match(Wf);b?.[1]&&o.add(b[1]);break}case"MarkerAnnotation":case"Annotation":{let b=a.node.getChild("Identifier");b&&s.add(e.slice(b.from,b.to));break}case"ImportDeclaration":{let b=zf(a.node,e);b&&n.push({fromPath:t,toPath:"",rawSpecifier:b.specifier,isExternal:!0,isStyle:!1,type:"static",symbols:b.symbol?[b.symbol]:void 0});break}case"ClassDeclaration":case"InterfaceDeclaration":case"EnumDeclaration":case"AnnotationTypeDeclaration":{if(a.node.parent?.name==="Program"){let b=a.node.getChild("Definition");if(b){let v=e.slice(b.from,b.to);r.has(v)||r.set(v,{name:v})}}break}}while(a.next());let c=X(e,!1);c&&n.push(de(t,c));let l=re(t,n.map(b=>b.rawSpecifier),{typeNames:[...r.keys()],annotations:[...s]}),{complexity:u,cognitiveComplexity:f}=to(i.topNode,e),h=ea(i,e),y=l==="test"?[]:Hf(i,e,Bf(n));return{imports:n,exports:Array.from(r.values()),tags:Array.from(o).map(b=>({name:b,kind:"comment-marker"})),category:l,rawCallEdges:y,complexity:u,cognitiveComplexity:f,...h.length>0?{functions:h}:{}}}var Wf,ra=d(()=>{"use strict";p();ta();Ve();Wf=/\/\/\s*@tag\s+([a-zA-Z0-9_-]+)/});function oa(t,e){let n=He(e),o=me(e).split(`
|
|
10
|
+
`),s=[],i=new Set;for(let l of o){let u=l.match(Kf);if(u?.[1]){s.push(Je(t,u[1]));continue}let f=l.match(Jf);if(f?.[2]){i.add(f[2]);continue}let h=l.match(Vf);if(h?.[1]){i.add(h[1]);continue}let y=l.match(Qf);y?.[1]&&i.add(y[1])}let a=X(e,!1);a&&s.push(de(t,a));let c=Array.from(i,l=>({name:l}));return{imports:s,exports:c,tags:Array.from(n).map(l=>({name:l,kind:"comment-marker"})),category:re(t,s.map(l=>l.rawSpecifier),{typeNames:[...i],annotations:Ke(e).annotations})}}var Kf,ro,Jf,Vf,Qf,sa=d(()=>{"use strict";p();Ve();Kf=/^\s*import\s+([\w.]+(?:\.\*)?)(?:\s+as\s+\w+)?\s*$/,ro="(?:public\\s+|internal\\s+|private\\s+|protected\\s+|open\\s+|abstract\\s+|final\\s+|sealed\\s+|data\\s+|value\\s+|inline\\s+|noinline\\s+|crossinline\\s+|external\\s+|expect\\s+|actual\\s+|suspend\\s+|operator\\s+|infix\\s+|tailrec\\s+|const\\s+|lateinit\\s+)*",Jf=new RegExp(`^(?:@[\\w.]+(?:\\([^)]*\\))?\\s+)*${ro}(?:(?:enum|annotation)\\s+)?(class|interface|object|typealias)\\s+([A-Za-z_][A-Za-z0-9_]*)`),Vf=new RegExp(`^(?:@[\\w.]+(?:\\([^)]*\\))?\\s+)*${ro}fun\\s+(?:<[^>]*>\\s*)?(?:[A-Za-z_][\\w.]*(?:<[^>]*>)?\\.)?([A-Za-z_][A-Za-z0-9_]*)\\s*[(<]`),Qf=new RegExp(`^(?:@[\\w.]+(?:\\([^)]*\\))?\\s+)*${ro}(?:val|var)\\s+(?:<[^>]*>\\s*)?([A-Za-z_][A-Za-z0-9_]*)`)});import Yf from"livescript";function ve(t){if(t){if(typeof t.value=="string")return t.value;if(typeof t.base?.value=="string")return t.base.value}}function Xf(t){if(!t)return[];if(t.constructor?.name==="Class"){let n=ve(t.title);return n?[{name:n}]:[]}if(t.constructor?.name==="Obj"&&Array.isArray(t.items))return t.items.map(n=>ve(n.key)??ve(n.val)).filter(n=>!!n).map(n=>({name:n}));let e=ve(t);return e?[{name:e}]:[]}function Zf(t){let e=t.constructor?.name||t.type;if(e==="Assign"&&t.left?.constructor?.name==="Chain"){let n=t.left,r=ve(n.head),s=n.tails?.[0]?.key?.name;if(r==="module"&&s==="exports")return Xf(t.right);if(r==="exports"&&typeof s=="string")return[{name:s}];if(n.head?.verb==="out"&&typeof s=="string")return[{name:s}]}if(e==="Import"&&t.left?.verb==="out"){let n=t.right;if(n?.constructor?.name==="Obj"&&Array.isArray(n.items))return n.items.map(r=>ve(r.val)??ve(r.key)).filter(r=>!!r).map(r=>({name:r}))}return[]}function em(t,e){let n=t.constructor?.name||t.type;if(n==="Import"){let r=t.right?.value;if(typeof r=="string"){let o=fe(r);return{fromPath:e,toPath:"",rawSpecifier:o,isStyle:W(o),type:"static"}}}if(n==="Chain"&&t.head?.value==="require"){let r=t.tails?.[0];if(r?.constructor?.name==="Call"||r?.type==="Call"){let o=r.args?.[0]?.value;if(typeof o=="string"){let s=fe(o);return{fromPath:e,toPath:"",rawSpecifier:s,isStyle:W(s),type:"require"}}}}return null}function oo(t,e,n){if(!t||typeof t!="object")return[];let r=[],o=em(t,e);o&&r.push(o),n.push(...Zf(t));for(let s in t){if(qf.has(s))continue;let i=t[s];if(!(!i||typeof i!="object"))if(Array.isArray(i))for(let a of i)r.push(...oo(a,e,n));else r.push(...oo(i,e,n))}return r}function ia(t,e){let n=We(e),r=ze(t,n),o=[],s=[];try{o=oo(Yf.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(n).map(c=>({name:c,kind:"comment-marker"})),category:r}}var qf,aa=d(()=>{"use strict";p();ne();nn();qf=new Set(["first_line","first_column","last_line","last_column","line","column"])});import tm from"luaparse";function nm(t,e){let n=[];function r(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=fe(i.raw))}else if(o.type==="StringCallExpression"){let i=o.argument;i?.type==="StringLiteral"&&(s=fe(i.raw))}s&&n.push({fromPath:e,toPath:"",rawSpecifier:s,isStyle:W(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)r(a);else r(i)}}}return r(t),n}function rm(t){let e=new Set;for(let n of t)n.type==="LocalStatement"&&n.variables.forEach((r,o)=>{n.init[o]?.type==="TableConstructorExpression"&&e.add(r.name)});return e}function om(t){let e=t[t.length-1];if(e?.type!=="ReturnStatement")return[];let n=e.arguments[0];if(n?.type!=="TableConstructorExpression")return[];let r=[];for(let o of n.fields)o.type==="TableKeyString"&&r.push({name:o.key.name});return r}function sm(t){let e=t.body,n=rm(e),r=om(e);for(let s of e)if(s.type==="FunctionDeclaration")s.identifier?.type==="MemberExpression"?s.identifier.base.type==="Identifier"&&n.has(s.identifier.base.name)&&r.push({name:s.identifier.identifier.name}):s.identifier?.type==="Identifier"&&!s.isLocal&&r.push({name:s.identifier.name});else if(s.type==="AssignmentStatement")for(let i of s.variables)i.type==="MemberExpression"&&i.base.type==="Identifier"&&n.has(i.base.name)&&r.push({name:i.identifier.name});let o=new Set;return r.filter(s=>o.has(s.name)?!1:(o.add(s.name),!0))}function ca(t,e){let n=We(e),r=ze(t,n),o=[],s=[];try{let i=tm.parse(e);o=nm(i,t),s=sm(i)}catch{}return{imports:o,exports:s,tags:Array.from(n).map(i=>({name:i,kind:"comment-marker"})),category:r}}var la=d(()=>{"use strict";p();ne();nn()});async function lm(){return pa??=(async()=>{let{unified:t}=await import("unified"),e=(await import("remark-parse")).default;return t().use(e)})(),pa}function pm(t){let e=t.trim();return e.length===0||e.startsWith("#")||im.some(n=>e.startsWith(n))}function um(t,e){let n=t.match(cm);return n?n.map(r=>({fromPath:e,toPath:"",rawSpecifier:r,isStyle:!1,type:"static",isDocReference:!0})):[]}function ua(t,e,n){if(t.type==="link"&&typeof t.url=="string"&&!pm(t.url)&&n.push({fromPath:e,toPath:"",rawSpecifier:t.url,isStyle:!1,type:"static",isDocReference:!0}),(t.type==="code"||t.type==="inlineCode")&&typeof t.value=="string"&&n.push(...um(t.value,e)),Array.isArray(t.children))for(let r of t.children)ua(r,e,n)}async function fa(t,e){let r=(await lm()).parse(e),o=[];ua(r,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 im,am,cm,pa,ma=d(()=>{"use strict";p();im=["http://","https://","mailto:","//"],am="ts|tsx|js|jsx|mjs|cjs|py|go|lua|css|scss|less|styl|coffee|ls|feature|md|mdx|json",cm=new RegExp(`(?:\\.{1,2}/)?[\\w.-]+(?:/[\\w.-]+)*\\.(?:${am})\\b`,"g")});function fm(t){let e=1;function n(r){switch(r.type.name){case"IfStatement":{e+=ke(r).filter(s=>s.type.name==="if"||s.type.name==="elif").length;break}case"TryStatement":{e+=ke(r).filter(s=>s.type.name==="except").length;break}case"ForStatement":case"WhileStatement":case"ConditionalExpression":e++;break;case"and":case"or":e++;break}let o=r.firstChild;for(;o;)n(o),o=o.nextSibling}return n(t),e}function mm(t,e){let n=0,r=ke(t),o=0,s=0;for(;s<r.length;){let i=r[s];if(i?.type.name==="if"||i?.type.name==="elif"){let a=o>0;n+=a?1:1+e;let c=a?e:e+1,l=r[s+1],u=r[s+2];l&&(n+=oe(l,c)),u&&(n+=oe(u,c)),o++,s+=3}else if(i?.type.name==="else"){n+=1;let a=r[s+1];a&&(n+=oe(a,e+1)),s+=2}else s++}return n}function dm(t,e){let n=0,r=ke(t),o=0;for(;o<r.length;){let s=r[o];if(s?.type.name==="except"){for(n+=1+e,o++;o<r.length&&r[o]?.type.name!=="Body";)n+=oe(r[o],e),o++;o<r.length&&(n+=oe(r[o],e),o++)}else s?.type.name==="Body"&&(n+=oe(s,e)),o++}return n}function da(t,e){let n=1+e,r=t.firstChild;for(;r;)n+=oe(r,e+1),r=r.nextSibling;return n}function gm(t,e){let n=0,r=t.firstChild;for(;r;)n+=oe(r,e),r=r.nextSibling;return n}function oe(t,e){let n=t.type.name;switch(n){case"IfStatement":return mm(t,e);case"TryStatement":return dm(t,e);case"ForStatement":case"WhileStatement":return da(t,e);default:{let r=n==="ConditionalExpression"||n==="and"||n==="or"?1:0;return e>0&&(n==="FunctionDefinition"||n==="LambdaExpression")?r+da(t,e):r+gm(t,e)}}}function hm(t){return oe(t,0)}function so(t){return{complexity:fm(t),cognitiveComplexity:hm(t)}}function ga(t,e){let n=[];function r(i,a){let{complexity:c,cognitiveComplexity:l}=so(i);n.push({name:a,line:Ce(e,i.from),complexity:c,cognitiveComplexity:l})}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,l=i.getChild("Body");if(l){let u=l.firstChild;for(;u;){if(u.type.name==="FunctionDefinition"){let f=u.getChild("VariableName"),h=f?e.slice(f.from,f.to):void 0;h&&r(u,c?`${c}.${h}`:h),o(u)}else s(u);u=u.nextSibling}}return}if(i.type.name==="FunctionDefinition"){let a=i.getChild("VariableName");a&&r(i,e.slice(a.from,a.to)),o(i);return}o(i)}return s(t.topNode),n}var ha=d(()=>{"use strict";p();rn()});import ym from"path";import{parser as xm}from"@lezer/python";function ya(t,e){let n=[],r=[],o=new Set,s=ym.basename(t).toLowerCase(),i=xm.parse(e),a=i.cursor();do switch(a.name){case"Comment":{let y=e.slice(a.from,a.to).match(/#\s*@tag\s+([a-zA-Z0-9_-]+)/);y?.[1]&&o.add(y[1]);break}case"ImportStatement":{for(let y of Sm(a.node,e,t))n.push(y);break}case"FunctionDefinition":case"ClassDefinition":{let y=a.node.parent;if(y?.name==="Script"||y?.name==="DecoratedStatement"&&y.parent?.name==="Script"){let v=a.node.getChild("VariableName");v&&r.push({name:e.slice(v.from,v.to)})}break}case"AssignStatement":{if(a.node.parent?.name==="Script"){let y=a.node.firstChild;y?.name==="VariableName"&&r.push({name:e.slice(y.from,y.to)})}break}}while(a.next());let c=Tm(s,n,o);c==="test"&&o.add("test");let{complexity:l,cognitiveComplexity:u}=so(i.topNode),f=ga(i,e),h=c==="test"?[]:Em(i,e);return{imports:n,exports:r,tags:Array.from(o).map(y=>({name:y,kind:"comment-marker"})),category:c,rawCallEdges:h,complexity:l,cognitiveComplexity:u,...f.length>0?{functions:f}:{}}}function Sm(t,e,n){let r=t.firstChild;return r?r.name==="from"?km(t,e,n):Cm(t,e,n):[]}function km(t,e,n){let r=t.firstChild;if(!r)return[];let o=r.nextSibling;for(;o&&o.name!=="import";)o=o.nextSibling;if(!o)return[];let s=e.slice(r.to,o.from).trim(),i=vm(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[yt(n,s,i,!0)];let l=a===1?"./":"../".repeat(a-1);return c?[yt(n,l+c.replace(/\./g,"/"),i,!1)]:i[0]==="*"?[yt(n,l.slice(0,-1),["*"],!1)]:i.map(u=>yt(n,l+u,[u],!1))}function Cm(t,e,n){let r=[],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),r.push(yt(n,s,["*"],!0))}o=o.nextSibling}return r}function vm(t,e){let n=[],r=t;for(;r;)r.name==="*"?n.push("*"):r.name==="VariableName"&&(n.push(e.slice(r.from,r.to)),r.nextSibling?.name==="as"&&(r=r.nextSibling.nextSibling??r.nextSibling)),r=r.nextSibling;return n}function wm(t,e){let n=new Map,r=t.cursor();do{if(r.name!=="ImportStatement")continue;let s=r.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 l=a.slice(c),u=c<=1?"./":"../".repeat(c-1),f=i.nextSibling;for(;f;){if(f.type.name==="VariableName"){let h=e.slice(f.from,f.to),y=h;if(f.nextSibling?.type.name==="as"){let v=f.nextSibling.nextSibling;v?.type.name==="VariableName"&&(y=e.slice(v.from,v.to),f=v)}let b=c===0?a:l?u+l.replace(/\./g,"/"):u+h;n.set(y,b)}f=f.nextSibling}}while(r.next());return n}function Em(t,e){let n=wm(t,e),r=[];function o(a,c){if(a.type.name==="CallExpression"&&a.firstChild?.type.name==="VariableName"){let u=a.firstChild,f=e.slice(u.from,u.to),h=n.get(f);h&&r.push({from:c,to:f,toSpecifier:h})}let l=a.firstChild;for(;l;)o(l,c),l=l.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"),l=c?e.slice(c.from,c.to):void 0,u=a.getChild("Body");if(u){let f=u.firstChild;for(;f;){if(f.type.name==="FunctionDefinition"){let h=f.getChild("VariableName"),y=h?e.slice(h.from,h.to):void 0;y&&o(f,l?`${l}.${y}`:y)}else i(f);f=f.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),r}function yt(t,e,n,r){return{fromPath:t,toPath:"",rawSpecifier:e,isStyle:!1,isExternal:r,type:"static",symbols:n.length>0?n:void 0}}function Tm(t,e,n){return t.startsWith("test_")||t.endsWith("_test.py")?"test":t==="conftest.py"||t==="setup.py"?"config":n.has("test")||e.some(r=>bm.has(r.rawSpecifier))?"test":"logic"}var bm,xa=d(()=>{"use strict";p();ha();bm=new Set(["pytest","unittest","nose","hypothesis"])});function Nm(t,e){let n=e.split("=>")[0]?.trim();return n?n==="_"||n==="*"||n==="given"?`${t}.*`:`${t}.${n}`:null}function Pm(t){let e=t.indexOf("{");if(e!==-1){let r=t.indexOf("}",e),o=t.slice(0,e).trim().replace(/\.$/,""),s=t.slice(e+1,r===-1?void 0:r);return o?s.split(",").map(i=>Nm(o,i.trim())).filter(i=>i!=null):[]}let n=[];for(let r of t.split(",")){let o=r.trim().replace(/\s+as\s+\w+$/,"");if(o)if(o.endsWith("._")||o.endsWith(".*")||o.endsWith(".given")){let s=o.replace(/\.(_|\*|given)$/,"");s&&n.push(`${s}.*`)}else n.push(o)}return n}function ba(t,e){let n=He(e),o=me(e).split(`
|
|
11
|
+
`),s=[],i=new Set;for(let l of o){let u=l.match(Fm);if(u?.[1]){for(let h of Pm(u[1]))s.push(Je(t,h));continue}let f=l.match(Dm);f?.[2]&&i.add(f[2])}let a=X(e,!0);a&&s.push(de(t,a));let c=Array.from(i,l=>({name:l}));return{imports:s,exports:c,tags:Array.from(n).map(l=>({name:l,kind:"comment-marker"})),category:re(t,s.map(l=>l.rawSpecifier),{typeNames:[...i],annotations:Ke(e).annotations})}}var Fm,Dm,Sa=d(()=>{"use strict";p();Ve();Fm=/^\s*import\s+(.+?)\s*$/,Dm=/^(?:@\w+\s+)*(?:private\s+|protected\s+|final\s+|sealed\s+|abstract\s+|implicit\s+|case\s+)*(class|trait|object|type|enum)\s+([A-Za-z_$][A-Za-z0-9_$]*)/});import C from"typescript";function Rm(t){let e=1;function n(r){switch(r.kind){case C.SyntaxKind.IfStatement:case C.SyntaxKind.ConditionalExpression:case C.SyntaxKind.ForStatement:case C.SyntaxKind.ForInStatement:case C.SyntaxKind.ForOfStatement:case C.SyntaxKind.WhileStatement:case C.SyntaxKind.DoStatement:case C.SyntaxKind.CatchClause:case C.SyntaxKind.CaseClause:e++;break;case C.SyntaxKind.BinaryExpression:{let o=r.operatorToken.kind;(o===C.SyntaxKind.AmpersandAmpersandToken||o===C.SyntaxKind.BarBarToken||o===C.SyntaxKind.QuestionQuestionToken)&&e++;break}}C.forEachChild(r,n)}return n(t),e}function Ca(t,e,n){let r=n?1:1+e,o=n?e:e+1;return r+=we(t.expression,o,!1),r+=we(t.thenStatement,o,!1),t.elseStatement&&(C.isIfStatement(t.elseStatement)?r+=Ca(t.elseStatement,e,!0):r+=1+we(t.elseStatement,e+1,!1)),r}function ka(t,e){let n=1+e;return C.forEachChild(t,r=>{n+=we(r,e+1,!1)}),n}function Am(t,e){let n=1+e;return C.forEachChild(t,r=>{n+=we(r,e,!1)}),n}function Lm(t,e){let n=0;return C.forEachChild(t,r=>{n+=we(r,e,!1)}),n}function Im(t){let e=t.operatorToken.kind;return e===C.SyntaxKind.AmpersandAmpersandToken||e===C.SyntaxKind.BarBarToken||e===C.SyntaxKind.QuestionQuestionToken}function we(t,e,n){if(C.isIfStatement(t))return Ca(t,e,n);if(C.isForStatement(t)||C.isForInStatement(t)||C.isForOfStatement(t)||C.isWhileStatement(t)||C.isDoStatement(t)||C.isSwitchStatement(t))return ka(t,e);if(C.isCatchClause(t))return Am(t,e);let r=0;return C.isConditionalExpression(t)&&(r+=1),C.isBinaryExpression(t)&&Im(t)&&(r+=1),e>0&&(C.isFunctionDeclaration(t)||C.isFunctionExpression(t)||C.isArrowFunction(t))?r+ka(t,e):r+Lm(t,e)}function Mm(t){return we(t,0,!1)}function io(t){return{complexity:Rm(t),cognitiveComplexity:Mm(t)}}var va=d(()=>{"use strict";p()});import T from"typescript";function wa(t,e){_m(t,e),Gm(t,e),jm(t,e)}function _m(t,e){if((T.isFunctionDeclaration(t)||T.isVariableDeclaration(t))&&t.name&&T.isIdentifier(t.name)&&Om(t)){let n;if(T.isFunctionDeclaration(t))n="function";else{let r=t.initializer;n=r&&(T.isArrowFunction(r)||T.isFunctionExpression(r))?"function":"variable"}e.tags.add({name:t.name.text,kind:n})}}function Om(t){if(T.isFunctionDeclaration(t))return T.isSourceFile(t.parent);let e=t.parent?.parent;return!!e&&T.isSourceFile(e.parent)}function Gm(t,e){if(!T.isSourceFile(t))return;let n=/@tag\s+([a-zA-Z0-9_-]+)/g,r=t.getFullText(),o=n.exec(r);for(;o!==null;)o[1]&&e.tags.add({name:o[1],kind:"comment-marker"}),o=n.exec(r)}function jm(t,e){if(!T.isCallExpression(t)||!$m(t.expression))return;let[n]=t.arguments;if(n&&T.isStringLiteral(n))for(let r of n.text.match(/@[\w-]+/g)??[])e.tags.add({name:r.substring(1),kind:"comment-marker"});for(let r of t.arguments)T.isObjectLiteralExpression(r)&&Wm(r,e)}function $m(t){return T.isIdentifier(t)?ao.has(t.text):!!(T.isPropertyAccessExpression(t)&&(ao.has(t.name.text)||T.isIdentifier(t.expression)&&ao.has(t.expression.text)))}function Wm(t,e){for(let n of t.properties){if(!T.isPropertyAssignment(n)||!T.isIdentifier(n.name)||n.name.text!=="tags"&&n.name.text!=="tag")continue;let{initializer:r}=n,o=T.isArrayLiteralExpression(r)?r.elements.filter(T.isStringLiteral):n.name.text==="tag"&&T.isStringLiteral(r)?[r]:[];for(let s of o)e.tags.add({name:s.text.replace(/^@/,""),kind:"comment-marker"})}}var ao,Ea=d(()=>{"use strict";p();ao=new Set(["test","describe","it"])});import Ta from"path";import x from"typescript";function co(t,e,n){let r=[],o=new Map,s=new Set,i=x.createSourceFile(t,e,x.ScriptTarget.Latest,!0,n==="typescript"?x.ScriptKind.TSX:x.ScriptKind.JSX),a={filePath:t,imports:r,exports:o,tags:s,rawCallEdges:[],sourceFile:i,hasUI:!1,hasTypesOnly:!0,totalStatements:0,exportStatements:0},c=v=>{Hm(v,a),x.forEachChild(v,c)};c(i);let l=nd(t,a);(l==="test"||l==="barrel")&&s.add({name:l,kind:"comment-marker"}),l!=="test"&&rd(a,i);let u=i.statements[0],f=u?Da(u):void 0,{complexity:h,cognitiveComplexity:y}=io(i),b=zm(i);return{imports:r,exports:Array.from(o.values()),tags:Array.from(s),category:l,rawCallEdges:a.rawCallEdges??[],complexity:h,cognitiveComplexity:y,...b.length>0?{functions:b}:{},...f!==void 0?{description:f}:{}}}function zm(t){let e=[],n=(o,s)=>{let{complexity:i,cognitiveComplexity:a}=io(s),c=t.getLineAndCharacterOfPosition(s.getStart(t)).line+1;e.push({name:o,line:c,complexity:i,cognitiveComplexity:a})},r=(o,s)=>{if(x.isFunctionDeclaration(o)&&o.name&&o.body?n(o.name.text,o):x.isVariableDeclaration(o)&&x.isIdentifier(o.name)&&o.initializer&&(x.isArrowFunction(o.initializer)||x.isFunctionExpression(o.initializer))?n(o.name.text,o.initializer):s&&x.isMethodDeclaration(o)&&x.isIdentifier(o.name)&&o.body?n(`${s}.${o.name.text}`,o):s&&x.isConstructorDeclaration(o)&&o.body?n(`${s}.constructor`,o):s&&x.isGetAccessorDeclaration(o)&&x.isIdentifier(o.name)&&o.body?n(`${s}.get ${o.name.text}`,o):s&&x.isSetAccessorDeclaration(o)&&x.isIdentifier(o.name)&&o.body&&n(`${s}.set ${o.name.text}`,o),x.isClassDeclaration(o)&&o.name){let i=o.name.text;x.forEachChild(o,a=>r(a,i));return}x.forEachChild(o,i=>r(i,s))};return r(t,void 0),e}function Fa(t,e,n,r){let o={name:t},s=Da(n);s!==void 0&&(o.doc=s);let i=Bm(e);i!==void 0&&(o.flags=i);let a=Um(e,r);return a!==void 0&&(o.signature=a),o}function Da(t){let e=x.getJSDocCommentsAndTags(t);for(let n of e)if(x.isJSDoc(n)&&n.comment)return x.getTextOfJSDocComment(n.comment)||void 0}function Bm(t){let e=new Set(["deprecated","internal","public","alpha","beta"]),n=x.getJSDocTags(t).map(r=>r.tagName.text).filter(r=>e.has(r));return n.length>0?n:void 0}function Um(t,e){let n=x.createPrinter({removeComments:!0}),r=o=>n.printNode(x.EmitHint.Unspecified,o,e);if(x.isFunctionDeclaration(t)||x.isMethodDeclaration(t)){let o=t.parameters.map(r).join(", "),s=t.type?r(t.type):"void";return`${t.typeParameters?`<${t.typeParameters.map(a=>a.name.text).join(", ")}>`:""}(${o}) => ${s}`}if(x.isVariableDeclaration(t)){if(t.type)return r(t.type);if(t.initializer&&(x.isArrowFunction(t.initializer)||x.isFunctionExpression(t.initializer))){let o=t.initializer,s=o.parameters.map(r).join(", "),i=o.type?r(o.type):"unknown";return`(${s}) => ${i}`}return}if(x.isClassDeclaration(t)&&t.name)return`class ${t.name.text}`;if(x.isInterfaceDeclaration(t))return`interface ${t.name.text}`;if(x.isTypeAliasDeclaration(t))return r(t.type);if(x.isEnumDeclaration(t))return`enum ${t.name.text}`}function Hm(t,e){Km(t,e),Jm(t,e),Qm(t,e),Ym(t,e),td(t,e),wa(t,e)}function Km(t,e){if(!x.isSourceFile(t))return;let n=t.statements.filter(r=>!x.isEmptyStatement(r));e.totalStatements=n.length,e.exportStatements=n.filter(r=>x.isExportDeclaration(r)||x.isExportAssignment(r)||lo(r)).length}function Jm(t,e){if(x.isJsxElement(t)||x.isJsxSelfClosingElement(t)||x.isJsxFragment(t)){e.hasUI=!0,e.hasTypesOnly=!1;return}if(x.isFunctionDeclaration(t)||x.isMethodDeclaration(t)||x.isArrowFunction(t)||x.isClassDeclaration(t)||x.isVariableStatement(t)||x.isEnumDeclaration(t)){e.hasTypesOnly=!1;return}x.isExportDeclaration(t)&&!Vm(t)&&(e.hasTypesOnly=!1)}function Vm(t){return t.isTypeOnly?!0:!t.exportClause||!x.isNamedExports(t.exportClause)?!1:t.exportClause.elements.every(e=>e.isTypeOnly)}function Qm(t,e){if(!x.isImportDeclaration(t)||!t.moduleSpecifier||!x.isStringLiteral(t.moduleSpecifier))return;let n=[];if(t.importClause&&(t.importClause.name&&n.push("default"),t.importClause.namedBindings))if(x.isNamedImports(t.importClause.namedBindings))for(let o of t.importClause.namedBindings.elements)n.push(o.name.text);else x.isNamespaceImport(t.importClause.namedBindings)&&n.push("*");let r=n.length>0?"static":"side-effect";e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:t.moduleSpecifier.text,isStyle:W(t.moduleSpecifier.text),type:r,symbols:n.length>0?n:void 0})}function Ym(t,e){x.isExportDeclaration(t)?Xm(t,e):x.isExportAssignment(t)?e.exports.set("default",{name:"default"}):lo(t)&&ed(t,e)}function Xm(t,e){if(t.moduleSpecifier&&x.isStringLiteral(t.moduleSpecifier))Zm(t,t.moduleSpecifier.text,e);else if(t.exportClause&&x.isNamedExports(t.exportClause))for(let n of t.exportClause.elements){let r=n.name.text;e.exports.set(r,{name:r})}}function Zm(t,e,n){let r=qm(t),o={fromPath:n.filePath,toPath:"",rawSpecifier:e,isStyle:W(e),type:"re-export"};r.length>0&&(o.symbols=r),n.imports.push(o)}function qm(t){return t.exportClause?x.isNamedExports(t.exportClause)?t.exportClause.elements.map(e=>e.name.text):[]:["*"]}function ed(t,e){if((x.isFunctionDeclaration(t)||x.isClassDeclaration(t)||x.isInterfaceDeclaration(t)||x.isTypeAliasDeclaration(t)||x.isEnumDeclaration(t))&&t.name){let r=t.name.text;e.exports.set(r,Fa(r,t,t,e.sourceFile));return}if(x.isVariableStatement(t)){for(let r of t.declarationList.declarations)if(x.isIdentifier(r.name)){let o=r.name.text;e.exports.set(o,Fa(o,r,t,e.sourceFile))}}}function td(t,e){if(!x.isCallExpression(t))return;let n=t.arguments[0];!n||!x.isStringLiteral(n)||(t.expression.kind===x.SyntaxKind.ImportKeyword?e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:n.text,isStyle:W(n.text),type:"dynamic"}):x.isIdentifier(t.expression)&&t.expression.text==="require"&&e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:n.text,isStyle:W(n.text),type:"require"}))}function nd(t,e){let n=Ta.basename(t).toLowerCase(),r=Ta.extname(t).toLowerCase();return ut().some(s=>n.includes(s))?"test":ii(n)?"config":e.imports.some(s=>gr().some(i=>s.rawSpecifier.includes(i)))?"test":r===".tsx"||r===".jsx"||e.hasUI?"ui":e.hasTypesOnly&&e.totalStatements>0?"type-only":e.totalStatements>0&&e.exportStatements/e.totalStatements>xr()?"barrel":"logic"}function lo(t){return x.canHaveModifiers(t)&&x.getModifiers(t)?.some(e=>e.kind===x.SyntaxKind.ExportKeyword)===!0}function rd(t,e){let n=t.rawCallEdges??[];t.rawCallEdges=n;let r=new Map;for(let o of e.statements){if(!x.isImportDeclaration(o)||!x.isStringLiteral(o.moduleSpecifier))continue;let s=o.moduleSpecifier.text,i=o.importClause;if(i&&(i.name&&r.set(i.name.text,s),i.namedBindings&&x.isNamedImports(i.namedBindings)))for(let a of i.namedBindings.elements)r.set(a.name.text,s)}if(r.size!==0)for(let o of e.statements){let s=sd(o);if(s){let i=id(o);i&&an(i,s,r,n);continue}x.isClassDeclaration(o)&&o.name&&od(o,o.name.text,r,n)}}function od(t,e,n,r){for(let o of t.members)x.isMethodDeclaration(o)&&o.body&&x.isIdentifier(o.name)?an(o.body,`${e}.${o.name.text}`,n,r):x.isConstructorDeclaration(o)&&o.body&&an(o.body,`${e}.constructor`,n,r)}function sd(t){if(lo(t)){if(x.isFunctionDeclaration(t)&&t.name)return t.name.text;if(x.isVariableStatement(t)){for(let e of t.declarationList.declarations)if(x.isIdentifier(e.name)&&e.initializer&&(x.isArrowFunction(e.initializer)||x.isFunctionExpression(e.initializer)))return e.name.text}}}function id(t){if(x.isFunctionDeclaration(t))return t.body;if(x.isVariableStatement(t)){for(let e of t.declarationList.declarations)if(e.initializer&&(x.isArrowFunction(e.initializer)||x.isFunctionExpression(e.initializer)))return e.initializer}}function an(t,e,n,r){if(x.isCallExpression(t)&&x.isIdentifier(t.expression)){let o=t.expression.text,s=n.get(o);s&&!r.some(i=>i.from===e&&i.to===o&&i.toSpecifier===s)&&r.push({from:e,to:o,toSpecifier:s})}x.forEachChild(t,o=>an(o,e,n,r))}var Na=d(()=>{"use strict";p();_e();va();ne();Ea()});function cn(t,e){if(e.length===0)return"ui";let n=!1;return t.walk(r=>{if(r.type==="rule")return n=!0,!1}),n?"ui":"barrel"}var Pa=d(()=>{"use strict";p()});import Aa from"postcss";import*as ad from"postcss-less";function Ra(t){return t.startsWith("~")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("//")||t.startsWith("data:")}function ld(t){let e=t.trim();return e.length>0&&!e.startsWith("http://")&&!e.startsWith("https://")&&!e.startsWith("//")&&!e.startsWith("data:")&&!e.startsWith("#")}function pd(t,e){let n=t.match(/^\(([^)]+)\)\s+['"]([^'"]+)['"]/);if(n){let s=n[1]?.trim()??"",i=n[2]??"";if(!i)return null;let a=La.has(s)?"side-effect":"static";return{fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:a,...Ra(i)?{isExternal:!0}:{}}}let r=t.match(/^url\(['"]?([^'")]+)['"]?\)/),o=r?r[1]?.trim()??"":t.match(/^['"]([^'"]+)['"]/)?.[1]??"";return o?{fromPath:e,toPath:"",rawSpecifier:o,isStyle:!0,type:"static",...Ra(o)?{isExternal:!0}:{}}:null}function ud(t,e){let n=[],r=/url\(['"]?([^'")]+)['"]?\)/g,o=r.exec(t);for(;o!==null;){let s=o[1]?.trim()??"";ld(s)&&n.push({fromPath:e,toPath:"",rawSpecifier:s,isStyle:!0,type:"static"}),o=r.exec(t)}return n}function Ia(t,e){let n=[];return t.walk(r=>{if(r.type==="atrule"&&r.name==="import"){let o=pd(r.params,e);o&&n.push(o)}r.type==="decl"&&n.push(...ud(r.value,e))}),n}function fd(t){return t.replace(/(?<!:)\/\/.*/g,"")}function md(t,e){let n=[],r=/@import\s+(?:\(([^)]+)\)\s+)?['"]([^'"]+)['"]/g,o=r.exec(t);for(;o!==null;){let s=o[1]?.trim()??"",i=o[2]??"";if(i){let a=La.has(s)?"side-effect":"static";n.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:a})}o=r.exec(t)}return n}function ln(t,e){let n=Aa.parse(fd(t));return{imports:Ia(n,e),root:n}}function dd(t){let e=[],n=[];for(let r of t.nodes??[]){if(r.type!=="atrule")continue;let{value:o}=r;if(o===void 0)continue;let s=r.name;s&&(e.push({name:s}),n.push({name:s,kind:"variable"}))}return{exports:e,tags:n}}function pn(t,e){try{let n=cd.parse(t),{exports:r,tags:o}=dd(n);return{imports:Ia(n,e),root:n,exports:r,tags:o}}catch{return{imports:md(t,e),root:Aa.parse(""),exports:[],tags:[]}}}var cd,La,po=d(()=>{"use strict";p();cd=ad,La=new Set(["reference","inline"])});import{parse as gd}from"postcss-scss";function Ma(t){return t.startsWith("_")||t.startsWith("-")}function hd(t){return!!(t.startsWith("sass:")||t.startsWith("~")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("//")||!t.startsWith(".")&&!t.startsWith("/")&&!t.startsWith("_"))}function yd(t){let e=t.match(/^['"]([^'"]+)['"]/);if(!e?.[1])return{specifier:""};let n=e[1],o=t.match(/\bas\s+(\S+)/)?.[1];return o!==void 0?{specifier:n,alias:o}:{specifier:n}}function xd(t){let e=[],n=[];for(let r of t.nodes??[]){if(r.type==="decl"&&r.prop.startsWith("$")){let o=r.prop.slice(1);if(!o||Ma(o))continue;e.push({name:o}),n.push({name:o,kind:"variable"});continue}if(r.type==="atrule"&&(r.name==="mixin"||r.name==="function")){let s=r.params.match(/^([\w-]+)/)?.[1];if(!s||Ma(s))continue;let i=r.params.trim();e.push(i.includes("(")?{name:s,signature:i}:{name:s}),n.push({name:s,kind:"function"})}}return{exports:e,tags:n}}function un(t,e){let n=gd(t),r=[];n.walk(i=>{if(i.type!=="atrule")return;let{name:a,params:c}=i;if(a!=="import"&&a!=="use"&&a!=="forward")return;let{specifier:l,alias:u}=yd(c);if(!l)return;let f={fromPath:e,toPath:"",rawSpecifier:l,isStyle:!0,type:a==="forward"?"re-export":"static",...hd(l)?{isExternal:!0}:{}};u&&(f.symbols=[u]),r.push(f)});let{exports:o,tags:s}=xd(n);return{imports:r,root:n,exports:o,tags:s}}var uo=d(()=>{"use strict";p()});function _a(t,e){let n=[],r=/@require\s+['"]([^'"]+)['"]/g,o=r.exec(t);for(;o!==null;){let i=o[1];i&&n.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:"require"}),o=r.exec(t)}let s=/(?<!@)(?:import|require)\s*\(?\s*['"]([^'"]+)['"]/g;for(o=s.exec(t);o!==null;){let i=o[1];i&&n.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:"static"}),o=s.exec(t)}return n}function Oa(t,e){if(e.length===0)return"ui";try{let n=ur("stylus");return new n.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 Ga=d(()=>{"use strict";p()});function xt(t,e){let n=K(t);if(n==="stylus"){let s=_a(e,t);return{imports:s,exports:[],tags:[],category:Oa(e,s)}}if(n==="scss"){let{imports:s,root:i,exports:a,tags:c}=un(e,t);return{imports:s,exports:a,tags:c,category:cn(i,s)}}if(n==="less"){let{imports:s,root:i,exports:a,tags:c}=pn(e,t);return{imports:s,exports:a,tags:c,category:cn(i,s)}}let{imports:r,root:o}=ln(e,t);return{imports:r,exports:[],tags:[],category:cn(o,r)}}var ja=d(()=>{"use strict";p();ne();Pa();po();uo();Ga()});async function $a(t,e){let n=K(t),r=Wi(n);return r?r(t,e):{imports:[],exports:[],tags:[],category:"other"}}var Wa=d(()=>{"use strict";p();ne();ji();zi();Qi();Xi();ra();sa();aa();la();ma();xa();Sa();Na();ht();ja();_e();ne();ht();for(let[t,e]of[["javascript",(n,r)=>co(n,r,"javascript")],["typescript",(n,r)=>co(n,r,"typescript")],["css",xt],["scss",xt],["less",xt],["stylus",xt],["coffeescript",Gi],["livescript",ia],["lua",ca],["python",ya],["go",Vi],["java",na],["kotlin",oa],["scala",ba],["groovy",Yi],["gherkin",Yr],["markdown",fa]])Be(t,e)});import za from"path";function bd(t,e){let n=e.get(t.path);n!==void 0&&(t.coveragePct=n)}function Ua(t,e){for(let n of t)if(n.isExternal){let r=n.rawSpecifier.startsWith("@")?n.rawSpecifier.split("/").slice(0,2).join("/"):n.rawSpecifier.split("/")[0];r&&!e.some(o=>o.name===r)&&e.push({name:r,kind:"library"})}}function Sd(t,e,n){if(e.isExternal||!e.toPath)return;let r=n.get(e.toPath);r&&(r.category!=="logic"&&r.category!=="barrel"||(r.testedBy??=[],r.testedBy.includes(t.path)||r.testedBy.push(t.path)))}function kd(t,e){if(t.type==="markdown")for(let n of t.imports){if(n.isExternal||!n.toPath)continue;let r=e.get(n.toPath);!r||r===t||(r.documentedBy??=[],r.documentedBy.includes(t.path)||r.documentedBy.push(t.path),r.category==="logic"&&(r.lastCommitAt??0)>(t.lastCommitAt??0)&&(t.staleFor??=[],t.staleFor.includes(r.path)||t.staleFor.push(r.path)))}}function Ba(t){return Math.round(t*1e4)/1e4}function Cd(t,e){let n=[];for(let r of t.imports){if(r.isExternal||!r.toPath)continue;let o=e.get(r.toPath);if(!o||o.exports.length===0)continue;let s;if(r.symbols===void 0){if(r.type==="side-effect")continue;s=1}else r.symbols.includes("*")?s=1:s=r.symbols.length/o.exports.length;r.exportUsageRatio=Ba(Math.min(1,s)),n.push(r.exportUsageRatio)}n.length>0&&(t.avgExportUsage=Ba(n.reduce((r,o)=>r+o,0)/n.length),t.maxExportUsage=Math.max(...n))}function Ha(t,e,n){e&&(t.some(r=>r.name===e&&r.kind===n)||t.push({name:e,kind:n}))}function vd(t,e){let n=e.toPath,r=za.basename(n,za.extname(n)).replace(/\.(test|spec)$/,"");Ha(t.tags,r,"import")}function wd(t,e,n){let r=n.get(e.toPath);if(!(!r||r.category==="test"))for(let o of r.tags)o.kind==="comment-marker"&&Ha(t.tags,o.name,"comment-marker")}function Ed(t,e,n){!e.toPath||e.isExternal||(vd(t,e),wd(t,e,n))}function Ka(t,e){for(let n of t.values())delete n.testedBy,delete n.documentedBy,delete n.staleFor,n.category==="test"&&(n.tags=n.tags.filter(r=>r.kind!=="import"));for(let n of t.values()){if(Cd(n,t),e.size>0&&bd(n,e),n.category==="test")for(let r of n.imports)Sd(n,r,t),Ed(n,r,t);kd(n,t)}}var Ja=d(()=>{"use strict";p()});function P(t,e,n,r,o,s,i,a){return{importResolution:t,exportSymbols:e,importSymbols:n,callEdges:r,complexity:o,category:s,duplication:i,testTags:a}}function fo(t){let e=new Map;for(let n of t.nodes.values())e.set(n.type,(e.get(n.type)??0)+1);return[...e.entries()].map(([n,r])=>({type:n,fileCount:r,exportsTracked:Qa.has(n),importSymbolsTracked:Ya.has(n),callEdgesTracked:fn.has(n),fidelity:Xa[n]})).sort((n,r)=>r.fileCount-n.fileCount)}var Va,Qa,Ya,fn,Xa,mn=d(()=>{"use strict";p();Va=new Set(["java","kotlin","scala","groovy"]),Qa=new Set(["typescript","javascript","python","go","java","kotlin","scala","groovy","scss","less","lua","coffeescript"]),Ya=new Set(["typescript","javascript","python","java","kotlin","scala","groovy"]),fn=new Set(["typescript","javascript","go","python","java"]);Xa={typescript:P("full","full","full","full","full","full","partial","full"),javascript:P("full","full","full","full","full","full","partial","full"),python:P("full","partial","partial","full","full","partial","partial","full"),go:P("full","partial","none","full","full","partial","partial","full"),java:P("partial","partial","partial","partial","full","partial","partial","full"),kotlin:P("partial","partial","partial","none","none","partial","partial","full"),scala:P("partial","partial","partial","none","none","partial","partial","full"),groovy:P("partial","partial","partial","none","none","partial","partial","full"),coffeescript:P("partial","partial","none","none","none","partial","partial","none"),livescript:P("partial","none","none","none","none","partial","partial","none"),lua:P("partial","partial","none","none","none","partial","partial","none"),css:P("full","none","none","none","none","full","full","none"),scss:P("full","partial","none","none","none","full","full","none"),less:P("full","partial","none","none","none","full","full","none"),stylus:P("full","none","none","none","none","full","partial","none"),gherkin:P("none","none","none","none","none","full","partial","full"),markdown:P("partial","none","none","none","none","full","partial","none"),unknown:P("none","none","none","none","none","none","none","none")}});import ec from"fs";import Ye from"path";function Td(t,e){let n=t.split(`
|
|
12
|
+
`),r=null,o=new Map,s=!1;for(let i of n){let a=i.trim();if(a.startsWith("module ")){r=a.slice(7).trim();continue}if(/^replace\s*\(/.test(a)){s=!0;continue}if(s&&a===")"){s=!1;continue}if(s&&a.includes("=>")){Za(a,e,o);continue}!s&&/^replace\s+/.test(a)&&a.includes("=>")&&Za(a.replace(/^replace\s+/,""),e,o)}return{mod:r,replaces:o}}function Za(t,e,n){let[r,o]=t.split("=>").map(a=>a.trim());if(!r||!o)return;let s=r.split(/\s+/)[0];if(!o.startsWith(".")&&!o.startsWith("/"))return;let i=Ye.isAbsolute(o)?o:Ye.resolve(e,o);n.set(s,i)}function qa(t){let e;try{e=ec.readdirSync(t,{withFileTypes:!0})}catch{return null}let n=e.filter(r=>r.isFile()&&r.name.endsWith(".go")&&!r.name.endsWith("_test.go")).map(r=>({path:Ye.join(t,r.name),isExternal:!1})).sort((r,o)=>r.path.localeCompare(o.path));return n.length>0?n:null}var bt,mo=d(()=>{"use strict";p();bt=class{extensions=[".go"];goModCache=new Map;resolve(e,n,r,o){let{mod:s,replaces:i}=this.readGoMod(r);if(!s)return null;let a=this.applyReplace(n,i,r);if(a!==void 0)return qa(a);if(n!==s&&!n.startsWith(`${s}/`))return null;let c=n.slice(s.length).replace(/^\//,"");return c?qa(Ye.join(r,c)):null}readGoMod(e){let n=this.goModCache.get(e);if(n!==void 0)return n;let r={mod:null,replaces:new Map};try{let o=ec.readFileSync(Ye.join(e,"go.mod"),"utf-8"),s=Td(o,e);return this.goModCache.set(e,s),s}catch{return this.goModCache.set(e,r),r}}applyReplace(e,n,r){for(let[o,s]of n){if(e===o)return s;if(e.startsWith(`${o}/`)){let i=e.slice(o.length+1);return Ye.join(s,i)}}}}});import dn from"fs";import gn from"path";function rc(t){let e=t.replace(/\\/g,"/"),n=e.match(/^(.*)\/src\/([^/]+)(?:\/|$)/);if(!n?.[1]||!n[2]){let s=e.lastIndexOf("/");return{module:s===-1?e:e.slice(0,s),rootSegment:"",sourceRoot:"unknown"}}let r=n[2],o=r==="main"?"main":Nd.has(r)?r:"unknown";return{module:n[1],rootSegment:r,sourceRoot:o}}function Pd(t,e=[]){let n=new Map,r=(process.env.MOKOSH_IGNORE_DIRS??"").split(",").map(a=>a.trim()).filter(Boolean),o=new Set([...$,...r,...e]),s=(a,c)=>{let{module:l,rootSegment:u,sourceRoot:f}=rc(c),h=n.get(a);if(!h){n.set(a,[{module:l,rootSegment:u,sourceRoot:f,files:[c]}]);return}let y=h.find(b=>b.module===l&&b.rootSegment===u);y?y.files.push(c):h.push({module:l,rootSegment:u,sourceRoot:f,files:[c]})},i=(a,c)=>{if(c>Dd)return;let l;try{l=dn.readdirSync(a,{withFileTypes:!0})}catch{return}for(let u of l){let f=gn.join(a,u.name);if(u.isDirectory()){!u.name.startsWith(".")&&!o.has(u.name)&&i(f,c+1);continue}if(!u.isFile())continue;let h=gn.extname(u.name);if(!Fd.has(h))continue;let y=Ad(f,h===".scala"||h===".sc");y&&s(y,f)}};i(t,0);for(let a of n.values())for(let c of a)c.files.sort();return n}function Rd(t,e){let n=t.get(e);if(!(!n||n.length===0))return n.length===1?n[0]?.files:n.flatMap(r=>r.files).sort()}function Ad(t,e){let n;try{let r=dn.openSync(t,"r");try{let o=Buffer.alloc(tc),s=dn.readSync(r,o,0,tc,0);n=o.toString("utf8",0,s)}finally{dn.closeSync(r)}}catch{return null}return X(n,e)}function go(t){return!t||t.length===0?null:t.map(e=>({path:e,isExternal:!1}))}function nc(t){return gn.basename(t,gn.extname(t))}var Fd,Dd,tc,Nd,Ee,ho=d(()=>{"use strict";p();Y();Ve();Fd=new Set([".java",".kt",".kts",".scala",".sc",".groovy"]),Dd=12,tc=4096,Nd=new Set(Zr);Ee=class{constructor(e=[]){this.extraIgnoreDirs=e}extraIgnoreDirs;extensions=[".java",".kt",".kts",".scala",".sc",".groovy",".gradle"];indexCache=new Map;resolve(e,n,r,o){let s=this.getIndex(r);if(s.size===0)return null;let i=n.endsWith(".*"),a=(i?n.slice(0,-2):n).split(".").filter(Boolean);if(a.length===0)return null;if(i){let c=s.get(a.join("."));if(!c)return null;let l=rc(e),u=c.filter(y=>y.module===l.module&&y.rootSegment===l.rootSegment),f=l.sourceRoot!=="main"&&l.sourceRoot!=="unknown",h=u.flatMap(y=>f?y.files:y.files.filter(b=>!qr(nc(b))));return go(h)}for(let c=a.length-1;c>=1;c--){let l=Rd(s,a.slice(0,c).join("."));if(!l)continue;let u=a[c],f=l.filter(h=>nc(h)===u);if(f.length>0)return go(f);if(c===a.length-1)return go(l)}return null}getIndex(e){let n=this.indexCache.get(e);if(n)return n;let r=Pd(e,this.extraIgnoreDirs);return this.indexCache.set(e,r),r}}});import Ld from"fs";import yo from"path";var St,xo=d(()=>{"use strict";p();St=class{extensions=[".lua"];resolve(e,n,r,o){let s=n.replace(/\./g,yo.sep),i=[r,yo.join(r,"lib")];for(let a of i){if(!Ld.existsSync(a))continue;let c=o(yo.join(a,"_dummy.lua"),s);if(c)return[c]}return null}}});import Id from"path";var Md,kt,bo=d(()=>{"use strict";p();Y();Md=new Set($),kt=class{extensions=[".md",".mdx"];resolve(e,n,r,o){let s=n.replace(/^\.\//,"").split("/")[0];if(s&&Md.has(s))return null;let i=o(Id.join(r,"_dummy"),`./${n}`);return i?[i]:null}}});import _d from"fs";import So from"path";function oc(t){try{return _d.statSync(t,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}var Ct,ko=d(()=>{"use strict";p();Ct=class{extensions=[".py"];resolve(e,n,r,o){let s=n.replace(/\./g,So.sep),i=So.join(r,`${s}.py`);if(oc(i))return[{path:i,isExternal:!1}];let a=So.join(r,s,"__init__.py");return oc(a)?[{path:a,isExternal:!1}]:null}}});import sc from"path";var Od,vt,Co=d(()=>{"use strict";p();Od=["~","http://","https://","//","data:","sass:"],vt=class{extensions=[".css",".scss",".sass",".less",".styl"];resolve(e,n,r,o){if(Od.some(u=>n.startsWith(u)))return null;let s=o(e,n);if(s)return[s];let i=sc.dirname(n),a=sc.basename(n),c=i==="."?`_${a}`:`${i}/_${a}`,l=o(e,c);return l?[l]:null}}});function hn(t={}){return[new Ct,new St,new bt,t.jvm??new Ee,new vt,new kt]}var vo=d(()=>{"use strict";p();mo();ho();xo();bo();ko();Co();mo();ho();xo();bo();ko();Co()});import yn from"fs";import se from"path";function Gd(t,e){let n=t.constructor?.name??"LangResolver";if(ic.has(n))return;ic.add(n);let r=e instanceof Error?e.message:String(e);process.stderr.write(`
|
|
13
|
+
Warning: ${n}.resolve() threw (${r}); affected imports are left unresolved.
|
|
14
|
+
`)}var ic,ie,xn=d(()=>{"use strict";p();vo();ic=new Set;ie=class{constructor(e,n={}){this.rootDir=e;this.workspaceMap=n.workspaceMap??new Map,this.tsconfigSearchPaths=n.tsconfigSearchPaths??[e],this.pathAliases=n.pathAliases,this.langResolvers=n.langResolvers??hn()}rootDir;workspaceMap;tsconfigSearchPaths;pathAliases;langResolvers;resolutionCache=new Map;langBucketFor(e){for(let n=0;n<this.langResolvers.length;n++)if(this.langResolvers[n]?.extensions.some(r=>e.endsWith(r)))return String(n);return"none"}cacheKey(e,n){return`${se.dirname(e)}\0${this.langBucketFor(e)}\0${n}`}resolveAll(e,n){let r=this.cacheKey(e,n),o=this.resolutionCache.get(r);if(o!==void 0)return o??[];let s=this.resolveAllUncached(e,n);return this.resolutionCache.set(r,s.length>0?s:null),s}resolveAllUncached(e,n){let r=this.resolvePathAlias(n);if(r)return[r];if(n.startsWith(".")||n.startsWith("/")){let i=this.resolveLocalPath(e,n);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=null;try{a=i.resolve(e,n,this.rootDir,o)}catch(c){Gd(i,c)}if(a)return a}let s=this.resolveWorkspaceImport(n);return s?[s]:[{path:n,isExternal:!0}]}resolve(e,n){return this.resolveAll(e,n)[0]??null}resolveLocalPath(e,n){let r=se.dirname(e),o=n.startsWith("/")?n:se.resolve(r,n),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 l of[".ts",".tsx"]){let u=this.tryExtensions(c,l,s);if(u)return u}}for(let c of i){let l=this.tryExtensions(o,c,s);if(l)return l}return s?{path:o,isExternal:!0}:null}tryExtensions(e,n,r){let o=e+n;if(this.isFile(o))return{path:o,isExternal:r};let s=se.join(e,`index${n}`);if(this.isFile(s))return{path:s,isExternal:r};if(n===".py"){let i=se.join(e,"__init__.py");if(this.isFile(i))return{path:i,isExternal:r}}return null}isFile(e){try{return yn.statSync(e,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}resolvePathAlias(e){if(this.pathAliases)for(let n in this.pathAliases){let r=this.matchAliasPattern(n,e),o=this.pathAliases[n];if(r&&o){let s=this.tryAliasSubstitutions(o,r[1]||"");if(s)return s}}for(let n of this.tsconfigSearchPaths){let r=se.join(n,"tsconfig.json");if(yn.existsSync(r))try{let s=JSON.parse(yn.readFileSync(r,"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]||"",n);if(c)return c}}}catch{}}return null}aliasRegexCache=new Map;matchAliasPattern(e,n){let r=this.aliasRegexCache.get(e);if(!r){let o=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace("\\*","(.*)");r=new RegExp(`^${o}$`),this.aliasRegexCache.set(e,r)}return n.match(r)}tryAliasSubstitutions(e,n,r=this.rootDir){let o=["",".ts",".tsx",".js",".jsx",".coffee",".ls",".lua",".feature"];for(let s of e){let i=s.replace("*",n),a=se.resolve(r,i);for(let c of o){let l=this.tryExtensions(a,c,!1);if(l)return l}}return null}resolveWorkspaceImport(e){if(this.workspaceMap.size===0)return null;for(let[n,r]of this.workspaceMap){if(e!==n&&!e.startsWith(`${n}/`))continue;let o=e.slice(n.length),s={path:"",isExternal:!1,isWorkspace:!0,workspacePackage:n};if(!o){for(let a of["src/index.ts","src/index.tsx","index.ts","index.tsx","index.js"]){let c=se.join(r,a);try{if(yn.statSync(c,{throwIfNoEntry:!1})?.isFile())return{...s,path:c}}catch{}}return{...s,path:r}}let i=this.resolveLocalPath(se.join(r,"_dummy"),o.slice(1));return i?{...s,path:i.path}:null}return null}}});import wt from"fs";import O from"path";import jd from"piscina";function Bd(){return(process.env.MOKOSH_IGNORE_DIRS??"").split(",").map(t=>t.trim()).filter(Boolean)}function Ud(t,e){if(t.length===0)return e;let n=t.map(i=>O.dirname(i).split(O.sep)),r=n[0]??[];for(let i of n.slice(1)){let a=0;for(;a<r.length&&a<i.length&&r[a]===i[a];)a++;r=r.slice(0,a)}let o=r.join(O.sep)||O.sep,s=O.relative(e,o);return s.startsWith("..")||O.isAbsolute(s)?e:o}var $d,Wd,zd,Te,wo=d(()=>{"use strict";p();Or();_e();Vr();Wa();Ja();mn();$e();xn();$d=["tests","test","__tests__","specs","spec"],Wd=["node_modules",".git","dist","build",".next",".cache","mokosh-cache","coverage",".pytest_cache","__pycache__"],zd=600;Te=class{constructor(e,n=null,r,o,s=!1,i=new Map,a=!0,c=[],l=null){this.rootDir=e;this.enableGitStats=s;this.coverageMap=i;this.parallelParsing=a;this.docFiles=l;this.previousGraph=n,this.walkIgnoreDirs=new Set([...Wd,...c,...Bd()]),this.resolver=r||new ie(e),this.lockFile=Ii(e),o&&(this.progressCallback=o)}rootDir;enableGitStats;coverageMap;parallelParsing;docFiles;graph={nodes:new Map};visited=new Set;queue=[];previousGraph=null;resolver;lockFile=null;progressCallback;pool=null;gitStatsMap=null;walkIgnoreDirs;async build(e){let n=e.map(r=>O.isAbsolute(r)?r:O.resolve(this.rootDir,r));await this.initPool(),this.enableGitStats&&(this.gitStatsMap=Fi(this.rootDir));try{for(let r of n)this.enqueue(r);return await this.drain(),await this.processTestFiles(Ud(n,this.rootDir)),await this.processDocFiles(),this.progressCallback&&this.visited.size>=100&&process.stderr.write(`
|
|
13
15
|
Done. Total processed: ${this.visited.size} nodes.
|
|
14
|
-
`),
|
|
16
|
+
`),Ka(this.graph.nodes,this.coverageMap),new _(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:{},n=e.minFiles??zd;if(!(n>0&&!this.hasAtLeastFiles(this.rootDir,n))){e.maxThreads!==void 0&&e.maxThreads<1&&process.stderr.write(`
|
|
15
17
|
Warning: parallelParsing.maxThreads (${e.maxThreads}) must be at least 1; using 1.
|
|
16
|
-
`);try{let r=
|
|
18
|
+
`);try{let r=O.join(m,"parse-worker.js");this.pool=new jd({filename:r,...e.maxThreads!==void 0?{maxThreads:Math.max(1,e.maxThreads)}:{}})}catch(r){process.stderr.write(`
|
|
17
19
|
Warning: failed to start parse worker pool, falling back to synchronous parsing: ${r}
|
|
18
|
-
`),this.pool=null}}}hasAtLeastFiles(e,n){let r=0,o=[e];for(;o.length>0;){let s=o.pop();if(s===void 0)continue;let i;try{i=
|
|
20
|
+
`),this.pool=null}}}hasAtLeastFiles(e,n){let r=0,o=[e];for(;o.length>0;){let s=o.pop();if(s===void 0)continue;let i;try{i=wt.readdirSync(s,{withFileTypes:!0})}catch{continue}for(let a of i)if(a.isDirectory())this.walkIgnoreDirs.has(a.name)||o.push(O.join(s,a.name));else if(a.isFile()&&(r++,r>=n))return!0}return r>=n}async processTestFiles(e){let n=ut(),r=s=>n.some(i=>s.name.includes(i));this.walkProject(e,r);let o=e;for(;o!==this.rootDir;){let s=O.dirname(o);if(s===o)break;for(let i of $d){let a=O.join(s,i);try{wt.statSync(a).isDirectory()&&this.walkProject(a,r)}catch{}}o=s}await this.drain()}async processDocFiles(){if(this.docFiles!==null){for(let e of this.docFiles)this.enqueue(e);await this.drain();return}this.walkProject(this.rootDir,e=>e.name.endsWith(".md")||e.name.endsWith(".mdx")),await this.drain()}walkProject(e,n){let r;try{r=wt.readdirSync(e,{withFileTypes:!0})}catch{return}for(let o of r){let s=O.join(e,o.name);o.isDirectory()?this.walkIgnoreDirs.has(o.name)||this.walkProject(s,n):o.isFile()&&n(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(n=>this.finishFile(n)))}}async finishFile(e){let n=wt.statSync(e,{throwIfNoEntry:!1});if(!n?.isFile())return;let r=O.relative(this.rootDir,e),o=await this.getNode(e,r,n);o.imports=await this.resolveImports(e,o.imports),Ua(o.imports,o.tags),this.graph.nodes.set(o.path,o)}async getNode(e,n,r){let o=this.previousGraph?.nodes.get(n);if(o&&o.mtime===r.mtimeMs&&o.size===r.size)return{...o};let s=await this.tryParse(e,n);if(!s)return this.makeStubNode(e,n,r);let i=this.resolveCallEdges(e,s.rawCallEdges),a=this.buildNode(e,n,r,s,i);return this.attachGitStats(a,n),a}async tryParse(e,n){let r=wt.readFileSync(e,"utf-8");try{return await this.parseContent(e,r)}catch(o){return process.stderr.write(`
|
|
19
21
|
Warning: failed to parse ${n}: ${o}
|
|
20
|
-
`),null}}parseContent(e,n){return this.pool?this.pool.run({filePath:e,content:n}):Ri(e,n)}makeStubNode(e,n,r){return{path:n,type:B(e),category:"other",imports:[],exports:[],tags:[],mtime:r.mtimeMs,size:r.size}}resolveCallEdges(e,n){let r=[];for(let o of n??[])try{let s=this.resolver.resolve(e,o.toSpecifier);s&&!s.isExternal&&r.push({from:o.from,to:o.to,toFile:R.relative(this.rootDir,s.path)})}catch{}return r}buildNode(e,n,r,o,s){let{imports:i,exports:a,tags:c,category:p,description:f,complexity:m,cognitiveComplexity:h,functions:y}=o;return{path:n,type:B(e),category:p,imports:i,exports:a,tags:c,mtime:r.mtimeMs,size:r.size,...f!==void 0?{description:f}:{},...s.length>0?{callEdges:s}:{},...m!==void 0?{complexity:m}:{},...h!==void 0?{cognitiveComplexity:h}:{},...y!==void 0?{functions:y}:{}}}attachGitStats(e,n){let r=this.gitStatsMap?.get(n);r&&(e.commitCount90d=r.commitCount90d,r.lastAuthor!==void 0&&(e.lastAuthor=r.lastAuthor),r.lastCommitAt!==void 0&&(e.lastCommitAt=r.lastCommitAt))}async resolveImports(e,n){let r=[];for(let o of n){let s=this.resolver.resolveAll(e,o.rawSpecifier);if(!(s.length===0||o.type==="side-effect"&&o.rawSpecifier.endsWith(".*")&&s.every(a=>a.isExternal)))for(let a of s){if(!a.isExternal&&a.path===e)continue;let c={...o,toPath:a.isExternal?a.path:R.relative(this.rootDir,a.path),isExternal:a.isExternal};a.isWorkspace&&(c.isWorkspace=!0,c.workspacePackage=a.workspacePackage),a.isExternal?this.attachLockfileVersion(c):this.enqueue(a.path),r.push(c)}}return r}attachLockfileVersion(e){if(!this.lockFile)return;let n=this.lockFile.jvmDependencies;if(n&&Gi.has(B(e.fromPath))){let s=e.rawSpecifier.replace(/\.\*$/,""),i="";for(let a of Object.keys(n))(s===a||s.startsWith(`${a}.`))&&a.length>i.length&&(i=a);i&&(e.version=n[i]?.version);return}let r=e.rawSpecifier.startsWith("@")?e.rawSpecifier.split("/").slice(0,2).join("/"):e.rawSpecifier.split("/")[0],o=r?this.lockFile.dependencies[r]:void 0;o&&(e.version=o.version)}showProgress(){this.progressCallback&&this.visited.size%100===0&&this.progressCallback(this.visited.size)}}});function qi(t){return cu.has(t)?"style":"code"}var cu,Yi=d(()=>{"use strict";l();cu=new Set(["css","scss","less","stylus"])});import Qi from"path";function uu(t,e){let n=t.split(/[\\/]/),r=/^\*\*\/(.+?)\/\*\*$/.exec(e);return r?n.includes(r[1]):e.startsWith("*.")?Qi.basename(t).endsWith(e.slice(1)):n.includes(e)}function zt(t,e=[]){if(t.split(/[\\/]/).some(o=>lu.has(o)))return!0;let r=Qi.basename(t);return pu.some(o=>r.endsWith(o))?!0:e.some(o=>uu(t,o))}function nt(t){let e=t.slice(0,mu).toLowerCase();return fu.some(n=>e.includes(n))}var lu,pu,fu,mu,Ir=d(()=>{"use strict";l();lu=new Set(["generated","__generated__","__generated","gen","__snapshots__"]),pu=[".pb.go",".pb.ts",".pb.js","_pb2.py","_pb2.pyi","_pb.dart",".g.dart",".generated.ts",".generated.tsx",".generated.js",".generated.jsx","_generated.go",".gen.go",".gen.ts",".snap"],fu=["@generated","do not edit","code generated by","autogenerated","auto-generated","this file was automatically generated","this is a generated file","jest snapshot v1"],mu=500});function du(t){return t.trim().replace(/\s+/g," ")}function gu(t){try{return t.fileType==="scss"?Mt(t.source,t.file).root:t.fileType==="less"?At(t.source,t.file).root:t.fileType==="css"?It(t.source,t.file).root:void 0}catch{return}}function hu(t){let e=gu(t);if(!e)return[];let n=[];return e.walkRules(r=>{let o=r.nodes?.filter(f=>f.type==="decl")??[];if(o.length===0)return;let s=o[0],i=o[o.length-1],a=r.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()}:${du(f.value)}`).join(";");n.push({file:t.file,startLine:a,endLine:c,lines:c-a+1,signature:p,declCount:o.length})}),n}function Xi(t,e,n=2){let r=new Map;for(let s of t)for(let i of hu(s)){if(i.declCount<n||i.lines<e)continue;let a=r.get(i.signature);a?a.push(i):r.set(i.signature,[i])}let o=[];for(let s of r.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},m={file:p.file,startLine:p.startLine,endLine:p.endLine};o.push({occurrences:[f,m],lines:Math.min(c.lines,p.lines),tokens:c.declCount,family:"style"})}return o.sort((s,i)=>i.lines-s.lines)}var Zi=d(()=>{"use strict";l();yr();xr()});function ea(t){let e=t.length,n=[],r=[{lcpLength:0,low:0}];for(let o=1;o<e;o++){let s=o-1;for(;t[o]<r[r.length-1].lcpLength;){let i=r.pop();n.push({lcpLength:i.lcpLength,low:i.low,high:o-1}),s=i.low}t[o]>r[r.length-1].lcpLength&&r.push({lcpLength:t[o],low:s})}for(;r.length>1;){let o=r.pop();n.push({lcpLength:o.lcpLength,low:o.low,high:e-1})}return n}var ta=d(()=>{"use strict";l()});function na(t,e,n){let r=0;for(let o=e;o<e+n;o++)yu.has(t[o].text)&&r++;return r/n}var yu,ra=d(()=>{"use strict";l();yu=new Set(["{","}",":",",","[","]"])});function oa(t){let e=t.length;if(e===0)return[];let n=Array.from({length:e},(s,i)=>i),r=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++)r[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?r[a+s]:-1;n.sort((a,c)=>{let p=r[a]-r[c];return p!==0?p:i(a)-i(c)}),o[n[0]]=0;for(let a=1;a<e;a++){let c=n[a-1],p=n[a],f=r[c]===r[p],m=i(c)===i(p);o[p]=o[c]+(f&&m?0:1)}if([r,o]=[o,r],r[n[e-1]]===e-1)break}return n}function sa(t,e){let n=t.length,r=new Array(n).fill(0);if(n===0)return r;let o=new Array(n);for(let i=0;i<n;i++)o[e[i]]=i;let s=0;for(let i=0;i<n;i++){let a=o[i];if(a>0){let c=e[a-1];for(;i+s<n&&c+s<n&&t[i+s]===t[c+s];)s++;r[a]=s,s>0&&s--}else s=0}return r}var ia=d(()=>{"use strict";l()});function aa(t,e,n,r=.5){let o=[],s=[],i=new Map;for(let{file:m,tokens:h}of t)if(h.length!==0){i.set(m,h);for(let y=0;y<h.length;y++)o.push(h[y].text),s.push({file:m,localIndex:y});o.push(` ${m}`),s.push({file:m,localIndex:-1})}if(o.length===0)return[];let a=oa(o),c=sa(o,a),p=ea(c),f=[];for(let m of p){let h=xu(m,a,s,i,e,n,r);h&&f.push(h)}return f.sort((m,h)=>h.lines-m.lines)}function xu(t,e,n,r,o,s,i){if(t.lcpLength<o)return;let a=[];for(let y=t.low;y<=t.high;y++){let b=n[e[y]];b.localIndex!==-1&&a.push(b)}if(a.length<2||!bu(a,r))return;let c=Su(a,t.lcpLength);if(c.length<2)return;let p=c[0],f=r.get(p.file);if(na(f,p.localIndex,t.lcpLength)>i)return;let m=c.map(({file:y,localIndex:b})=>{let v=r.get(y);return{file:y,startLine:v[b].line,endLine:v[b+t.lcpLength-1].line}}),h=Math.min(...m.map(y=>y.endLine-y.startLine+1));if(!(h<s))return{occurrences:m,lines:h,tokens:t.lcpLength}}function bu(t,e){let n=null;for(let{file:r,localIndex:o}of t){if(o===0)return!0;let i=e.get(r)[o-1].text;if(n===null)n=i;else if(n!==i)return!0}return!1}function Su(t,e){let n=new Map;for(let{file:o,localIndex:s}of t){let i=n.get(o);i?i.push(s):n.set(o,[s])}let r=[];for(let[o,s]of n){s.sort((a,c)=>a-c);let i=Number.NEGATIVE_INFINITY;for(let a of s)a>=i&&(r.push({file:o,localIndex:a}),i=a+e)}return r}var ca=d(()=>{"use strict";l();ta();ra();ia()});function la(t,e,n){let r=t.slice(e,n).replace(/[^\n]/g," ");return t.slice(0,e)+r+t.slice(n)}function ku(t,e){if(!e)return t;let n=t;for(let[r,o]of e.block??[]){let s=0;for(;;){let i=n.indexOf(r,s);if(i===-1)break;let a=n.indexOf(o,i+r.length),c=a===-1?n.length:a+o.length;n=la(n,i,c),s=c}}for(let r of e.line??[]){let o=0;for(;;){let s=n.indexOf(r,o);if(s===-1)break;let i=n.indexOf(`
|
|
21
|
-
`,s),a=i===-1?n.length:i;n=
|
|
22
|
-
`),o=e==="go",s=!1,i=!1;for(let a=0;a<r.length;a++){let c=r[a],
|
|
23
|
-
`)}function
|
|
24
|
-
`&&s++;i=a.index;let c=a[0],
|
|
25
|
-
`&&s++;i=a.index+c.length,a=
|
|
22
|
+
`),null}}parseContent(e,n){return this.pool?this.pool.run({filePath:e,content:n}):$a(e,n)}makeStubNode(e,n,r){return{path:n,type:K(e),category:"other",imports:[],exports:[],tags:[],mtime:r.mtimeMs,size:r.size}}resolveCallEdges(e,n){let r=[];for(let o of n??[])try{let s=this.resolver.resolve(e,o.toSpecifier);s&&!s.isExternal&&r.push({from:o.from,to:o.to,toFile:O.relative(this.rootDir,s.path)})}catch{}return r}buildNode(e,n,r,o,s){let{imports:i,exports:a,tags:c,category:l,description:u,complexity:f,cognitiveComplexity:h,functions:y}=o;return{path:n,type:K(e),category:l,imports:i,exports:a,tags:c,mtime:r.mtimeMs,size:r.size,...u!==void 0?{description:u}:{},...s.length>0?{callEdges:s}:{},...f!==void 0?{complexity:f}:{},...h!==void 0?{cognitiveComplexity:h}:{},...y!==void 0?{functions:y}:{}}}attachGitStats(e,n){let r=this.gitStatsMap?.get(n);r&&(e.commitCount90d=r.commitCount90d,r.lastAuthor!==void 0&&(e.lastAuthor=r.lastAuthor),r.lastCommitAt!==void 0&&(e.lastCommitAt=r.lastCommitAt))}async resolveImports(e,n){let r=[];for(let o of n){let s=this.resolver.resolveAll(e,o.rawSpecifier);if(!(s.length===0||o.type==="side-effect"&&o.rawSpecifier.endsWith(".*")&&s.every(a=>a.isExternal)))for(let a of s){if(!a.isExternal&&a.path===e)continue;let c={...o,toPath:a.isExternal?a.path:O.relative(this.rootDir,a.path),isExternal:a.isExternal};a.isWorkspace&&(c.isWorkspace=!0,c.workspacePackage=a.workspacePackage),a.isExternal?this.attachLockfileVersion(c):this.enqueue(a.path),r.push(c)}}return r}attachLockfileVersion(e){if(!this.lockFile)return;let n=this.lockFile.jvmDependencies;if(n&&Va.has(K(e.fromPath))){let s=e.rawSpecifier.replace(/\.\*$/,""),i="";for(let a of Object.keys(n))(s===a||s.startsWith(`${a}.`))&&a.length>i.length&&(i=a);i&&(e.version=n[i]?.version);return}let r=e.rawSpecifier.startsWith("@")?e.rawSpecifier.split("/").slice(0,2).join("/"):e.rawSpecifier.split("/")[0],o=r?this.lockFile.dependencies[r]:void 0;o&&(e.version=o.version)}showProgress(){this.progressCallback&&this.visited.size%100===0&&this.progressCallback(this.visited.size)}}});function Eo(t,e){return t.startsWith("!")?e!==t.slice(1):e===t}function ac(t){return t.score??t.lines}function bn(t,e){let n=t.occurrences.map(o=>o.file);if(e.path!==void 0){let o=e.path,s=i=>i.includes(o.startsWith("!")?o.slice(1):o);if(o.startsWith("!")?n.some(s):!n.some(s))return!1}if(e.allPaths!==void 0){let o=e.allPaths,s=o.startsWith("!")?o.slice(1):o,i=n.length>0&&n.every(a=>a.includes(s));if(o.startsWith("!")?i:!i)return!1}if(e.family!==void 0&&!Eo(e.family,t.family))return!1;if(e.type!==void 0){let o=e.type.startsWith("!")?e.type.slice(1):e.type,s=n.length>0&&n.every(i=>K(i)===o);if(e.type.startsWith("!")?s:!s)return!1}if(e.kind!==void 0&&!Eo(e.kind,t.kind??"block")||e.defKind!==void 0&&!Eo(e.defKind,t.defKind)||e.minLines!==void 0&&t.lines<e.minLines||e.maxLines!==void 0&&t.lines>e.maxLines)return!1;let r=ac(t);if(e.minScore!==void 0&&r<e.minScore||e.maxScore!==void 0&&r>e.maxScore||e.minOccurrences!==void 0&&t.occurrences.length<e.minOccurrences||e.crossFile!==void 0&&new Set(n).size>=2!==e.crossFile)return!1;if(e.signals!==void 0&&e.signals.length>0){let o=new Set(t.signals??[]),s=e.signals.filter(a=>!a.startsWith("!"));if(e.signals.filter(a=>a.startsWith("!")).map(a=>a.slice(1)).some(a=>o.has(a))||s.length>0&&!s.some(a=>o.has(a)))return!1}return!0}function Sn(t,e){let n=t;if(e.sort){let r=e.sortDir==="asc"?-1:1,o=e.sort==="score"?ac:e.sort==="occurrences"?s=>s.occurrences.length:s=>s.lines;n=[...n].sort((s,i)=>(o(i)-o(s))*r)}return e.limit!==void 0&&(n=n.slice(0,Math.max(0,e.limit))),n}var To=d(()=>{"use strict";p();ne()});function Hd(t,e,n,r,o){let s=t;if(n==="string"){s[e]=o;return}if(n==="bool"){s[e]=o.toLowerCase()==="true";return}let i=Number(o);if(!Number.isFinite(i))throw new Error(`find_duplicates filter: "${r}" expects a number, got "${o}"`);s[e]=i}function Kd(t,e){let n=e.indexOf(":");if(n===-1)throw new Error(`find_duplicates filter: clause "${e}" is not "key:value"`);let r=e.slice(0,n).trim().toLowerCase(),o=e.slice(n+1).trim();if(!r||!o)return;if(!lc.has(r))throw new Error(`find_duplicates filter: unknown key "${r}". Known keys: ${[...lc].sort().join(", ")}`);if(r==="signal"||r==="signals"){t.signals=[...t.signals??[],o];return}if(r==="sort"){if(!cc.has(o))throw new Error(`find_duplicates filter: sort must be one of ${[...cc].join(", ")}, got "${o}"`);t.sort=o;return}if(r==="sortdir"){t.sortDir=o.toLowerCase()==="asc"?"asc":"desc";return}let s=pc[r];s&&Hd(t,s.field,s.kind,r,o)}function Xe(t){let e={};for(let n of t.split(",")){let r=n.trim();r&&Kd(e,r)}return e}var pc,cc,lc,Fo=d(()=>{"use strict";p();pc={path:{field:"path",kind:"string"},allpaths:{field:"allPaths",kind:"string"},family:{field:"family",kind:"string"},type:{field:"type",kind:"string"},kind:{field:"kind",kind:"string"},defkind:{field:"defKind",kind:"string"},minlines:{field:"minLines",kind:"int"},maxlines:{field:"maxLines",kind:"int"},minscore:{field:"minScore",kind:"int"},maxscore:{field:"maxScore",kind:"int"},minoccurrences:{field:"minOccurrences",kind:"int"},crossfile:{field:"crossFile",kind:"bool"},limit:{field:"limit",kind:"int"}},cc=new Set(["lines","score","occurrences"]),lc=new Set([...Object.keys(pc),"signal","signals","sort","sortdir"])});function Jd(t){let e=[...t].sort((r,o)=>r.start-o.start),n=[];for(let r of e){let o=n.at(-1);o&&r.start<=o.end+1?o.end=Math.max(o.end,r.end):n.push({...r})}return n}function Vd(t,e,n){let r=e.flatMap(a=>a.occurrences).filter(a=>a.file===t).map(a=>({start:a.startLine,end:a.endLine})),o=Jd(r).reduce((a,c)=>a+(c.end-c.start+1),0),s=n?.get(t),i=s!==void 0&&s>0?Math.round(o/s*1e3)/10:void 0;return{file:t,coveredLines:o,totalLines:s,coveragePct:i}}function uc(t,e){let n=new Map;for(let o of t){let s=[...new Set(o.occurrences.map(c=>c.file))].sort(),i=s.join("\0"),a=n.get(i);a?a.groups.push(o):n.set(i,{files:s,groups:[o]})}let r=[];for(let{files:o,groups:s}of n.values()){let i=Math.max(...s.map(a=>a.lines));r.push({files:o,groups:[...s].sort((a,c)=>c.lines-a.lines),matchCount:s.length,longestMatch:i,coverage:o.map(a=>Vd(a,s,e))})}return r.sort((o,s)=>s.longestMatch-o.longestMatch||s.matchCount-o.matchCount)}var fc=d(()=>{"use strict";p()});function mc(t){return Qd[t]??"other"}var Qd,dc=d(()=>{"use strict";p();Qd={css:"style",scss:"style",less:"style",stylus:"style",javascript:"js",typescript:"js",coffeescript:"js",livescript:"js",java:"jvm",kotlin:"jvm",scala:"jvm",groovy:"jvm",python:"python",go:"go",lua:"lua",markdown:"markdown",gherkin:"gherkin"}});import gc from"path";function eg(t,e){let n=t.split(/[\\/]/),r=/^\*\*\/(.+?)\/\*\*$/.exec(e);return r?n.includes(r[1]):e.startsWith("*.")?gc.basename(t).endsWith(e.slice(1)):n.includes(e)}function kn(t,e=[]){if(t.split(/[\\/]/).some(o=>Yd.has(o)))return!0;let r=gc.basename(t);return Xd.some(o=>r.endsWith(o))?!0:e.some(o=>eg(t,o))}function Et(t){let e=t.slice(0,qd).toLowerCase();return Zd.some(n=>e.includes(n))}var Yd,Xd,Zd,qd,Do=d(()=>{"use strict";p();Yd=new Set(["generated","__generated__","__generated","gen","__snapshots__"]),Xd=[".pb.go",".pb.ts",".pb.js","_pb2.py","_pb2.pyi","_pb.dart",".g.dart",".generated.ts",".generated.tsx",".generated.js",".generated.jsx","_generated.go",".gen.go",".gen.ts",".snap"],Zd=["@generated","do not edit","code generated by","autogenerated","auto-generated","this file was automatically generated","this is a generated file","jest snapshot v1"],qd=500});import D from"typescript";function hc(t,e,n){let r=t.tagName.getText(e),o=[];for(let s of t.attributes.properties){if(D.isJsxSpreadAttribute(s))return;let i=s.name.getText(e);if(!s.initializer)o.push(i);else if(D.isStringLiteral(s.initializer))o.push(`${i}=${s.initializer.text}`);else if(D.isJsxExpression(s.initializer))if(!s.initializer.expression)o.push(`${i}={}`);else{let a=n.printNode(D.EmitHint.Unspecified,s.initializer.expression,e);o.push(`${i}=${a}`)}else return}return o.sort(),o.length>0?`${r} ${o.join(" ")}`:r}function tg(t,e,n){if(D.isJsxText(t)){let r=t.text.trim().replace(/\s+/g," ");return r.length===0?"":`T:${r}`}if(D.isJsxExpression(t))return t.expression?`E:${n.printNode(D.EmitHint.Unspecified,t.expression,e)}`:"";if(D.isJsxElement(t)||D.isJsxSelfClosingElement(t)||D.isJsxFragment(t))return yc(t,e,n)}function yc(t,e,n){if(D.isJsxSelfClosingElement(t)){let s=hc(t,e,n);return s===void 0?void 0:`<${s}/>`}let r=[];for(let s of t.children){let i=tg(s,e,n);if(i===void 0)return;r.push(i)}if(D.isJsxFragment(t))return`<>${r.join("")}</>`;let o=hc(t.openingElement,e,n);return o===void 0?void 0:`<${o}>${r.join("")}</>`}function ng(t,e){let n=D.createSourceFile(t.file,t.source,D.ScriptTarget.Latest,!0,D.ScriptKind.TSX),r=D.createPrinter({removeComments:!0}),o=[],s=a=>n.getLineAndCharacterOfPosition(a).line+1,i=a=>{if(D.isJsxElement(a)||D.isJsxSelfClosingElement(a)||D.isJsxFragment(a)){let c=yc(a,n,r);c!==void 0&&c.length>=e&&o.push({file:t.file,startLine:s(a.getStart(n)),endLine:s(a.getEnd()),canonicalShape:c})}D.forEachChild(a,i)};return i(n),o}function rg(t){let e=[...t].sort((o,s)=>s[0].canonicalShape.length-o[0].canonicalShape.length),n=new Map,r=[];for(let o of e){let s=o.filter(i=>!n.get(i.file)?.some(c=>c.start<=i.startLine&&i.endLine<=c.end));if(!(s.length<2)){for(let i of s){let a={start:i.startLine,end:i.endLine},c=n.get(i.file);c?c.push(a):n.set(i.file,[a])}r.push(s)}}return r}function xc(t,e=40){let n=new Map;for(let s of t)for(let i of ng(s,e)){let a=n.get(i.canonicalShape);a?a.push(i):n.set(i.canonicalShape,[i])}let r=[...n.values()].filter(s=>s.length>=2),o=[];for(let s of rg(r)){let i=s[0],a=s.map(c=>({file:c.file,startLine:c.startLine,endLine:c.endLine}));o.push({occurrences:a,lines:Math.max(...s.map(c=>c.endLine-c.startLine+1)),tokens:i.canonicalShape.length,kind:"definition",defKind:"jsxElement"})}return o}var bc=d(()=>{"use strict";p()});import L from"typescript";function og(t){let e=t;for(;L.isAsExpression(e)||L.isSatisfiesExpression(e)||L.isParenthesizedExpression(e);)e=e.expression;return e}function sg(t,e,n){if(L.isPropertyAssignment(n)){if(L.isComputedPropertyName(n.name))return;let r=n.name.getText(e),o=t.printNode(L.EmitHint.Unspecified,n.initializer,e);return`${r}:${o}`}if(L.isShorthandPropertyAssignment(n)){let r=n.name.getText(e);return`${r}:${r}`}}function ig(t){let e=t.filter(n=>n!==void 0);if(!(e.length<2||e.length!==t.length))return[...e].sort().join(";")}function ag(t){let e=L.createSourceFile(t.file,t.source,L.ScriptTarget.Latest,!0,L.ScriptKind.TSX),n=L.createPrinter({removeComments:!0}),r=[],o=i=>e.getLineAndCharacterOfPosition(i).line+1,s=i=>{if(L.isVariableDeclaration(i)&&L.isIdentifier(i.name)&&i.initializer&&L.isVariableDeclarationList(i.parent)&&(i.parent.flags&L.NodeFlags.Const)!==0){let a=og(i.initializer);if(L.isObjectLiteralExpression(a)){let c=ig(a.properties.map(l=>sg(n,e,l)));c!==void 0&&r.push({file:t.file,name:i.name.text,startLine:o(i.getStart(e)),endLine:o(i.getEnd()),memberCount:a.properties.length,canonicalShape:c})}}L.forEachChild(i,s)};return s(e),r}function Sc(t,e=3){let n=new Map;for(let o of t)for(let s of ag(o)){if(s.memberCount<e)continue;let i=n.get(s.canonicalShape);i?i.push(s):n.set(s.canonicalShape,[s])}let r=[];for(let o of n.values()){if(o.length<2)continue;let s=o[0],i=o.map(a=>({file:a.file,startLine:a.startLine,endLine:a.endLine,name:a.name}));r.push({occurrences:i,lines:Math.max(...o.map(a=>a.endLine-a.startLine+1)),tokens:s.memberCount,kind:"definition",defKind:"objectLiteral"})}return r}var kc=d(()=>{"use strict";p()});function Cn(t){return t.trim().replace(/\s+/g," ")}function No(t){try{return t.fileType==="scss"?un(t.source,t.file).root:t.fileType==="less"?pn(t.source,t.file).root:t.fileType==="css"?ln(t.source,t.file).root:void 0}catch{return}}function cg(t){let e=No(t);if(!e)return[];let n=[];return e.walkRules(r=>{let o=r.nodes?.filter(u=>u.type==="decl")??[];if(o.length===0)return;let s=o[0],i=o[o.length-1],a=r.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 l=o.map(u=>`${u.prop.trim().toLowerCase()}:${Cn(u.value)}`).join(";");n.push({file:t.file,startLine:a,endLine:c,lines:c-a+1,signature:l,declCount:o.length})}),n}function Cc(t,e,n=2){let r=new Map;for(let s of t)for(let i of cg(s)){if(i.declCount<n||i.lines<e)continue;let a=r.get(i.signature);a?a.push(i):r.set(i.signature,[i])}let o=[];for(let s of r.values())for(let i=0;i<s.length;i++)for(let a=i+1;a<s.length;a++){let c=s[i],l=s[a];if(c.file===l.file&&c.startLine===l.startLine&&c.endLine===l.endLine)continue;let u={file:c.file,startLine:c.startLine,endLine:c.endLine},f={file:l.file,startLine:l.startLine,endLine:l.endLine};o.push({occurrences:[u,f],lines:Math.min(c.lines,l.lines),tokens:c.declCount,family:"style"})}return o.sort((s,i)=>i.lines-s.lines)}var Po=d(()=>{"use strict";p();po();uo()});function lg(t){let e=No(t);if(!e)return[];let n=[];return e.walkDecls(r=>{let o=r.prop.startsWith("--"),s=t.fileType==="scss"&&r.prop.startsWith("$");if(!o&&!s)return;let i=r.source?.start?.line;i!==void 0&&n.push({file:t.file,line:i,name:r.prop,value:Cn(r.value)})}),t.fileType==="less"&&e.walkAtRules(r=>{let{value:o}=r;if(o===void 0)return;let s=r.source?.start?.line;s!==void 0&&n.push({file:t.file,line:s,name:`@${r.name}`,value:Cn(o)})}),n}function vc(t,e=2){let n=t.flatMap(lg),r=new Map,o=new Map;for(let a of n){let c=r.get(a.value);c?c.push(a):r.set(a.value,[a]);let l=o.get(a.name);l?l.push(a):o.set(a.name,[a])}let s=(a,c)=>({file:a.file,startLine:a.line,endLine:a.line,name:a.name,...c?{value:a.value}:{}}),i=[];for(let a of r.values())a.length<e||i.push({occurrences:a.map(c=>s(c,!1)),lines:1,tokens:1,kind:"definition",defKind:"cssVar"});for(let a of o.values())a.length<e||new Set(a.map(l=>l.value)).size<2||i.push({occurrences:a.map(l=>s(l,!0)),lines:1,tokens:1,kind:"definition",defKind:"cssVar",signals:["value-drift"]});return i}var wc=d(()=>{"use strict";p();Po()});function Ec(t){let e=t.length,n=[],r=[{lcpLength:0,low:0}];for(let o=1;o<e;o++){let s=o-1;for(;t[o]<r[r.length-1].lcpLength;){let i=r.pop();n.push({lcpLength:i.lcpLength,low:i.low,high:o-1}),s=i.low}t[o]>r[r.length-1].lcpLength&&r.push({lcpLength:t[o],low:s})}for(;r.length>1;){let o=r.pop();n.push({lcpLength:o.lcpLength,low:o.low,high:e-1})}return n}var Tc=d(()=>{"use strict";p()});function Fc(t,e,n){let r=t.slice(e,n).replace(/[^\n]/g," ");return t.slice(0,e)+r+t.slice(n)}function ug(t,e){if(!e)return t;let n=t;for(let[r,o]of e.block??[]){let s=0;for(;;){let i=n.indexOf(r,s);if(i===-1)break;let a=n.indexOf(o,i+r.length),c=a===-1?n.length:a+o.length;n=Fc(n,i,c),s=c}}for(let r of e.line??[]){let o=0;for(;;){let s=n.indexOf(r,o);if(s===-1)break;let i=n.indexOf(`
|
|
23
|
+
`,s),a=i===-1?n.length:i;n=Fc(n,s,a),o=a}}return n}function mg(t,e){let n=fg[e];if(!n)return t;let r=t.split(`
|
|
24
|
+
`),o=e==="go",s=!1,i=!1;for(let a=0;a<r.length;a++){let c=r[a],l=()=>{r[a]=c.replace(/[^\r]/g," ")};if(s){l(),c.includes(")")&&(s=!1);continue}if(i){l(),(/}\s*from\s/.test(c)||c.includes("}"))&&(i=!1);continue}n.some(u=>u.test(c))&&(l(),o&&/^\s*import\s+\(/.test(c)&&!c.includes(")")?s=!0:(e==="typescript"||e==="javascript")&&/^\s*import\b/.test(c)&&c.includes("{")&&!c.includes("}")&&(i=!0))}return r.join(`
|
|
25
|
+
`)}function Rc(t){return t==="ID"||t==="NUM"||t==="STR"?!1:Pc.has(t)?!0:t.length===1?hg.has(t):yg.has(t)}function Ac(t,e,n=!0){let r=mg(ug(t,pg[e]),e),o=[],s=1,i=0;Ro.lastIndex=0;let a=Ro.exec(r);for(;a!==null;){for(let u=i;u<a.index;u++)r[u]===`
|
|
26
|
+
`&&s++;i=a.index;let c=a[0],l=c;dg.test(c)&&!Pc.has(c)?l="ID":n&&(Dc.test(c)||gg.test(c))&&(l=Dc.test(c)?"NUM":"STR"),o.push({text:l,line:s});for(let u=i;u<a.index+c.length;u++)r[u]===`
|
|
27
|
+
`&&s++;i=a.index+c.length,a=Ro.exec(r)}return o}var pg,fg,Nc,Ro,dg,Dc,gg,Pc,hg,yg,Ao=d(()=>{"use strict";p();pg={typescript:{line:["//"],block:[["/*","*/"]]},javascript:{line:["//"],block:[["/*","*/"]]},go:{line:["//"],block:[["/*","*/"]]},java:{line:["//"],block:[["/*","*/"]]},kotlin:{line:["//"],block:[["/*","*/"]]},scala:{line:["//"],block:[["/*","*/"]]},groovy:{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:[["<!--","-->"]]}};fg={typescript:[/^\s*import[\s{("*]/,/^\s*export\s.*\sfrom\s/],javascript:[/^\s*import[\s{("*]/,/^\s*export\s.*\sfrom\s/],python:[/^\s*import\s+\S/,/^\s*from\s+\S+\s+import[\s(]/],go:[/^\s*import\s+["(]/],java:[/^\s*import\s+/],kotlin:[/^\s*import\s+/],scala:[/^\s*import\s+/],groovy:[/^\s*import\s+/]};Nc=["===","!==","...","=>","==","!=","<=",">=","&&","||","::","->","..","+=","-=","*=","/="],Ro=new RegExp(`${Nc.map(t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|")}|[A-Za-z_$][A-Za-z0-9_$]*|\\d+(?:\\.\\d+)?|"(?:\\\\.|[^"\\\\])*"|'(?:\\\\.|[^'\\\\])*'|\`(?:\\\\.|[^\`\\\\])*\`|\\S`,"g"),dg=/^[A-Za-z_$][A-Za-z0-9_$]*$/,Dc=/^\d+(?:\.\d+)?$/,gg=/^(".*"|'.*'|`.*`)$/s,Pc=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"]),hg=new Set(["+","-","*","%","&","|","!","^","~","?"]),yg=new Set(Nc)});function Lc(t,e,n){let r=0;for(let o=e;o<e+n;o++)xg.has(t[o].text)&&r++;return r/n}function Ic(t,e,n){let r=0;for(let o=e;o<e+n;o++)Rc(t[o].text)&&r++;return r}var xg,Mc=d(()=>{"use strict";p();Ao();xg=new Set(["{","}",":",",","[","]"])});function _c(t){let e=t.length;if(e===0)return[];let n=Array.from({length:e},(s,i)=>i),r=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++)r[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?r[a+s]:-1;n.sort((a,c)=>{let l=r[a]-r[c];return l!==0?l:i(a)-i(c)}),o[n[0]]=0;for(let a=1;a<e;a++){let c=n[a-1],l=n[a],u=r[c]===r[l],f=i(c)===i(l);o[l]=o[c]+(u&&f?0:1)}if([r,o]=[o,r],r[n[e-1]]===e-1)break}return n}function Oc(t,e){let n=t.length,r=new Array(n).fill(0);if(n===0)return r;let o=new Array(n);for(let i=0;i<n;i++)o[e[i]]=i;let s=0;for(let i=0;i<n;i++){let a=o[i];if(a>0){let c=e[a-1];for(;i+s<n&&c+s<n&&t[i+s]===t[c+s];)s++;r[a]=s,s>0&&s--}else s=0}return r}var Gc=d(()=>{"use strict";p()});function jc(t,e,n,r=.5){let o=[],s=[],i=new Map;for(let{file:h,tokens:y}of t)if(y.length!==0){i.set(h,y);for(let b=0;b<y.length;b++)o.push(y[b].text),s.push({file:h,localIndex:b});o.push(` ${h}`),s.push({file:h,localIndex:-1})}if(o.length===0)return[];let a=_c(o),c=Oc(o,a),l=Ec(c),u=[];for(let h of l){let y=bg(h,a,s,i,e,n,r);y&&u.push(y)}return Sg(u,i).sort((h,y)=>y.lines-h.lines)}function bg(t,e,n,r,o,s,i){if(t.lcpLength<o)return;let a=[];for(let h=t.low;h<=t.high;h++){let y=n[e[h]];y.localIndex!==-1&&a.push(y)}if(a.length<2||!kg(a,r))return;let c=Cg(a,t.lcpLength);if(c.length<2)return;let l=c[0],u=r.get(l.file);if(!(Lc(u,l.localIndex,t.lcpLength)>i||Math.min(...c.map(({file:h,localIndex:y})=>{let b=r.get(h),v=b[y].line;return b[y+t.lcpLength-1].line-v+1}))<s))return{occurrences:c,lcpLength:t.lcpLength}}function Sg(t,e){let n=[...t].sort((s,i)=>i.lcpLength-s.lcpLength),r=new Map,o=[];for(let s of n){let i=s.occurrences.filter(({file:f,localIndex:h})=>{let y=h+s.lcpLength;return!r.get(f)?.some(v=>v.start<=h&&y<=v.end)});if(i.length<2)continue;for(let{file:f,localIndex:h}of i){let y={start:h,end:h+s.lcpLength},b=r.get(f);b?b.push(y):r.set(f,[y])}let a=i.map(({file:f,localIndex:h})=>{let y=e.get(f);return{file:f,startLine:y[h].line,endLine:y[h+s.lcpLength-1].line}}),c=Math.min(...a.map(f=>f.endLine-f.startLine+1)),l=i[0],u=Ic(e.get(l.file),l.localIndex,s.lcpLength);o.push({occurrences:a,lines:c,tokens:s.lcpLength,score:u})}return o}function kg(t,e){let n=null;for(let{file:r,localIndex:o}of t){if(o===0)return!0;let i=e.get(r)[o-1].text;if(n===null)n=i;else if(n!==i)return!0}return!1}function Cg(t,e){let n=new Map;for(let{file:o,localIndex:s}of t){let i=n.get(o);i?i.push(s):n.set(o,[s])}let r=[];for(let[o,s]of n){s.sort((a,c)=>a-c);let i=Number.NEGATIVE_INFINITY;for(let a of s)a>=i&&(r.push({file:o,localIndex:a}),i=a+e)}return r}var $c=d(()=>{"use strict";p();Tc();Mc();Gc()});function Wc(t,e,n,r=.6){let o=t.split(`
|
|
28
|
+
`).slice(Math.max(0,e-1),n),s=0,i=0,a=!1;for(let c of o){if(c.trim().length===0)continue;s++;let l=vg.test(c)||wg.test(c);l&&(a=!0),(l||Eg.test(c))&&i++}return a&&s>0&&i/s>=r}var vg,wg,Eg,zc=d(()=>{"use strict";p();vg=/<\/?\s*(?:svg|path|g|circle|ellipse|rect|line|polygon|polyline|defs|use|symbol|mask|clipPath|linearGradient|radialGradient|stop|pattern|filter|fe[A-Z][A-Za-z]*|marker|foreignObject|tspan|textPath)\b/,wg=/\b(?:viewBox|xmlns(?::xlink)?|xlink:href|fill-rule|clip-rule|stroke-width|stroke-linecap|stroke-linejoin|stroke-dasharray|stroke-miterlimit|gradientUnits|gradientTransform|patternUnits|patternTransform|preserveAspectRatio|pathLength|d|points|cx|cy|rx|ry)\s*=/,Eg=/^\s*(?:<\/?[A-Za-z>]|\/?>\s*$|[A-Za-z_$][\w:.$-]*\s*=\s*["'{])/});import Z from"typescript";function Tg(t,e,n){if(!Z.isPropertySignature(n)||!n.type)return;let r=n.name.getText(e),o=n.questionToken?"?":"",s=t.printNode(Z.EmitHint.Unspecified,n.type,e);return`${r}${o}:${s}`}function Fg(t){let e=t.filter(n=>n!==void 0);if(!(e.length<2||e.length!==t.length))return[...e].sort().join(";")}function Dg(t){let e=Z.createSourceFile(t.file,t.source,Z.ScriptTarget.Latest,!0,Z.ScriptKind.TSX),n=Z.createPrinter({removeComments:!0}),r=[],o=i=>e.getLineAndCharacterOfPosition(i).line+1,s=i=>{let a,c,l;if(Z.isInterfaceDeclaration(i)?(a=i.name.text,c="interface",l=i.members):Z.isTypeAliasDeclaration(i)&&Z.isTypeLiteralNode(i.type)&&(a=i.name.text,c="type",l=i.type.members),a&&c&&l){let u=Fg(l.map(f=>Tg(n,e,f)));u!==void 0&&r.push({file:t.file,name:a,defKind:c,startLine:o(i.getStart(e)),endLine:o(i.getEnd()),memberCount:l.length,canonicalShape:u})}Z.forEachChild(i,s)};return s(e),r}function Bc(t,e=2){let n=new Map;for(let o of t)for(let s of Dg(o)){if(s.memberCount<e)continue;let i=n.get(s.canonicalShape);i?i.push(s):n.set(s.canonicalShape,[s])}let r=[];for(let o of n.values()){if(o.length<2)continue;let s=o[0],i=o.map(a=>({file:a.file,startLine:a.startLine,endLine:a.endLine,name:a.name}));r.push({occurrences:i,lines:Math.max(...o.map(a=>a.endLine-a.startLine+1)),tokens:s.memberCount,kind:"definition",defKind:s.defKind})}return r}var Uc=d(()=>{"use strict";p()});import Ng from"crypto";import Tt from"fs";import Pg from"path";function vn(t){let e=[];for(let r of t)e.push(`${r.path}\0${r.mtime}\0${r.size}`);e.sort();let n=Ng.createHash("sha256");for(let r of e)n.update(`${r}
|
|
29
|
+
`);return n.digest("hex")}function wn(t){return JSON.stringify({minLines:t.minLines,ignoreLiterals:t.ignoreLiterals,maxPunctuationRatio:t.maxPunctuationRatio,limit:t.limit,scope:t.scope??null,includeGenerated:t.includeGenerated,includeSameFile:t.includeSameFile,includeSvgMarkup:t.includeSvgMarkup,includeDocs:t.includeDocs,ignoreDirs:[...t.ignoreDirs].sort(),ignoreGlobs:[...t.ignoreGlobs].sort()})}function Rg(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.digest=="string"&&typeof e.paramsKey=="string"&&Array.isArray(e.groups)&&Array.isArray(e.clusters)}function En(t,e,n){try{if(!Tt.existsSync(t))return null;let r=JSON.parse(Tt.readFileSync(t,"utf-8"));return!Rg(r)||r.digest!==e||r.paramsKey!==n?null:{groups:r.groups,clusters:r.clusters}}catch{return null}}function Tn(t,e,n,r,o){try{let s=Pg.dirname(t);Tt.existsSync(s)||Tt.mkdirSync(s,{recursive:!0});let i={digest:e,paramsKey:n,groups:[...r],clusters:[...o]};Tt.writeFileSync(t,JSON.stringify(i))}catch(s){process.stderr.write(`Warning: failed to persist duplication result cache: ${s}
|
|
30
|
+
`)}}var Hc=d(()=>{"use strict";p()});function Lo(t){let e=t.indexOf("/");return e===-1?".":t.slice(0,e)}function Kc(t){let e={};for(let n of t)e[n]=(e[n]??0)+1;return e}function Fn(t){let e={},n=[],r=0;for(let o of t){o.lines>r&&(r=o.lines);for(let s of o.signals??[])n.push(s);for(let s of new Set(o.occurrences.map(i=>Lo(i.file))))e[s]=(e[s]??0)+1}return{matched:t.length,byFamily:Kc(t.map(o=>o.family??"other")),byTopDir:e,bySignal:Kc(n),largestLines:r}}function Dn(t){return t.occurrences.map(e=>`${e.file}:${e.startLine}-${e.endLine}`)}function Nn(t){let e=t.package;return{lines:t.lines,...t.score!==void 0&&{score:t.score},...t.family!==void 0&&{family:t.family},...t.kind!==void 0&&{kind:t.kind},...t.defKind!==void 0&&{defKind:t.defKind},...t.signals!==void 0&&{signals:t.signals},...e!==void 0&&{package:e},occurrences:Dn(t)}}function Pn(t){let e=t.package,n=t.groups[0];return{files:t.files,matchCount:t.matchCount,longestMatch:t.longestMatch,...n!==void 0&&{longestMatchAt:Dn(n)},coverage:t.coverage,...e!==void 0&&{package:e}}}var Jc=d(()=>{"use strict";p()});import Ft from"fs";import Ag from"path";function Lg(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.mtime=="number"&&typeof e.size=="number"&&typeof e.ignoreLiterals=="boolean"&&typeof e.generated=="boolean"&&Array.isArray(e.tokens)}function Ze(t){try{if(!Ft.existsSync(t))return new Map;let e=Ft.readFileSync(t,"utf-8"),n=JSON.parse(e);if(!Array.isArray(n))return new Map;let r=n.filter(o=>Array.isArray(o)&&o.length===2&&typeof o[0]=="string"&&Lg(o[1]));return new Map(r)}catch{return new Map}}function qe(t,e){let n=Ag.dirname(e);Ft.existsSync(n)||Ft.mkdirSync(n,{recursive:!0}),Ft.writeFileSync(e,JSON.stringify([...t.entries()]))}var Vc=d(()=>{"use strict";p()});import{readFile as Io}from"fs/promises";import tt from"path";import Mg from"piscina";function zg(t){return dt.includes(tt.basename(t))}function Bg(t,e){if(e.length===0)return!1;let n=new Set(e);return t.split(tt.sep).some(r=>n.has(r))}function et(t,e,n){let r=[...t.signals??[]];return new Set(t.occurrences.map(o=>o.file)).size===1&&r.push("same-file"),t.occurrences.some(o=>e.has(o.file))&&r.push("generated"),t.occurrences.some(o=>Gg.test(o.file))&&r.push("test"),t.family==="markdown"&&r.push("docs"),t.occurrences.length>0&&t.occurrences.every(o=>{let s=n.get(o.file);return s!==void 0&&Wc(s,o.startLine,o.endLine)})&&r.push("svg-markup"),r.length>0?{...t,signals:r}:t}function Ug(t){return Math.max(0,...t.groups.map(n=>n.tokens))>=Wg?!0:t.groups.length>=jg&&t.files.length<=$g}function Hg(t,e){if(e==="all")return!0;let n=t.groups.some(r=>r.signals?.includes("test"));return e==="tests"?n&&Ug(t):!n}async function nt(t,e,n={}){let{minLines:r=6,windowSize:o=15,ignoreLiterals:s=!0,maxPunctuationRatio:i=.5,limit:a=50,ignoreDirs:c=$,includeGenerated:l=!1,includeSameFile:u=!1,includeSvgMarkup:f=!1,includeDocs:h=!1,scope:y="src",minScore:b=0,ignoreGlobs:v=[],parallelTokenizing:k=!0,tokenCache:E,filter:A}=n,G=A?Xe(A):void 0,N=[...t.nodes.values()].filter(V=>V.type!=="unknown"&&!zg(V.path)&&!Bg(V.path,c)),U=new Set,ct=new Map,te=Kg(k,N.length);try{let V=[],ce=[],Ie=new Map;if(await Promise.all(N.map(async S=>{let M=kn(S.path,v);if(M&&!l)return;if(Og.has(S.type)){let Q;try{Q=await Io(tt.join(e,S.path),"utf8")}catch{return}let si=M||Et(Q);if(si&&!l)return;si&&U.add(S.path),ct.set(S.path,Q.split(`
|
|
31
|
+
`).length),V.push({file:S.path,source:Q,fileType:S.type});return}let le=E?.get(S.path),Tu=le&&le.mtime===S.mtime&&le.size===S.size&&le.ignoreLiterals===s,pt,Me,pe;if(Tu)pt=le.tokens,Me=le.generated;else{let Q;try{Q=await Io(tt.join(e,S.path),"utf8")}catch{return}if(Me=M||Et(Q),Me&&!l)return;pt=te?await te.run({source:Q,fileType:S.type,ignoreLiterals:s}):Ac(Q,S.type,s),E?.set(S.path,{mtime:S.mtime,size:S.size,ignoreLiterals:s,generated:Me,tokens:pt}),pe=Q}if(Me&&!l)return;if(Me&&U.add(S.path),ct.set(S.path,pe!==void 0?pe.split(`
|
|
32
|
+
`).length:pt.at(-1)?.line??0),S.type==="typescript"||S.type==="javascript"){if(pe===void 0)try{pe=await Io(tt.join(e,S.path),"utf8")}catch{pe=void 0}pe!==void 0&&ce.push({file:S.path,source:pe})}let ni=mc(S.type),ri={file:S.path,tokens:pt},oi=Ie.get(ni);oi?oi.push(ri):Ie.set(ni,[ri])})),E){let S=new Set(N.map(M=>M.path));for(let M of E.keys())S.has(M)||E.delete(M)}let j=new Map(ce.map(S=>[S.file,S.source])),H=Cc(V,r).map(S=>et(S,U,j));for(let[S,M]of Ie)for(let le of jc(M,o,r,i))H.push(et({...le,family:S},U,j));for(let S of vc(V))H.push(et({...S,family:"style"},U,j));for(let S of Bc(ce))H.push(et({...S,family:"js"},U,j));for(let S of Sc(ce))H.push(et({...S,family:"js"},U,j));for(let S of xc(ce))H.push(et({...S,family:"js"},U,j));let Gt=H.filter(S=>!(!u&&S.signals?.includes("same-file")||!f&&S.signals?.includes("svg-markup")||!h&&S.signals?.includes("docs")||b>0&&(S.kind??"block")==="block"&&(S.score??S.tokens)<b||G&&!bn(S,G))),lt=uc(Gt,ct).filter(S=>Hg(S,y)),jt=new Set(lt.flatMap(S=>S.groups)),he=S=>S.score??S.lines;return{groups:Gt.filter(S=>jt.has(S)).sort((S,M)=>he(M)-he(S)||M.lines-S.lines).slice(0,a),clusters:lt.sort((S,M)=>Math.max(...M.groups.map(he))-Math.max(...S.groups.map(he))||M.longestMatch-S.longestMatch).slice(0,a)}}finally{te&&await te.destroy()}}function Kg(t,e){if(t===!1)return null;let n=typeof t=="object"?t:{},r=n.minFiles??_g;if(e<r)return null;n.maxThreads!==void 0&&n.maxThreads<1&&process.stderr.write(`
|
|
26
33
|
Warning: parallelTokenizing.maxThreads (${n.maxThreads}) must be at least 1; using 1.
|
|
27
|
-
`);try{return new
|
|
34
|
+
`);try{return new Mg({filename:tt.join(m,"duplication-worker.js"),...n.maxThreads!==void 0?{maxThreads:Math.max(1,n.maxThreads)}:{}})}catch(o){return process.stderr.write(`
|
|
28
35
|
Warning: failed to start duplicate-detection worker pool, falling back to synchronous tokenizing: ${o}
|
|
29
|
-
`),null}}var Iu,Au,Bt=d(()=>{"use strict";l();j();tr();Yi();Ir();Zi();ca();ma();Ir();ua();Iu=20,Au=new Set(["css","scss","less"])});var fe,Ht=d(()=>{"use strict";l();fe=class{affectedSymbols=new Map;constructor(e,n){this.affectedSymbols.set(e,new Set(["default",...n]))}updateAffectedSymbols(e,n){let r=this.affectedSymbols.get(n)||new Set,o=e.imports.find(c=>c.toPath===n);if(!o)return!1;let s=o.symbols||["*"],i=new Set;for(let c of s)(c==="*"||r.has("*")||r.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 me(t,e){let n=t.nodes.get(e);if(n)return{category:n.category,exports:n.exports.map(r=>r.name)}}function Mr(t,e,n=1){let r=[];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 r.push({path:o.path,...a?.symbols?{symbols:a.symbols}:{}}),!0},{direction:"outgoing",maxDepth:n}),r}function st(t,e){let n=[];return t.traverse(e,r=>{if(r.path===e)return!0;let o=r.imports.find(s=>s.toPath===e);return n.push({path:r.path,...o?.symbols?{symbols:o.symbols}:{}}),!0},{direction:"incoming",maxDepth:1}),n}function Lr(t,e,n={}){let{testsOnly:r=!1,changedSymbols:o}=n,s=o?new fe(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(m=>m.name==="test");return(!r||f)&&i.push(a.path),!0},{direction:"incoming"}),i}function Or(t,e,n={}){let{depth:r=1,withEdgeDetail:o=!1}=n,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:r}),s}function _e(t,e={}){let{metric:n="cognitiveComplexity",threshold:r=10,limit:o=20}=e;return[...t.nodes.values()].flatMap(s=>(s.functions??[]).filter(i=>i[n]>=r).map(i=>({file:s.path,name:i.name,line:i.line,complexity:i.complexity,cognitiveComplexity:i.cognitiveComplexity}))).sort((s,i)=>i[n]-s[n]).slice(0,o)}function _r(t){return{nodes:t.nodes.map(n=>({path:n.path,type:n.type,category:n.category,exports:n.exports.map(r=>r.name),tags:n.tags.filter(r=>r.kind==="comment-marker"||r.kind==="import").map(r=>r.name),importsFiles:n.imports.filter(r=>!r.isExternal&&r.toPath).map(r=>r.toPath),...n.description!==void 0&&{description:n.description},...n.testedBy!==void 0&&{testedBy:n.testedBy},...n.coveragePct!==void 0&&{coveragePct:n.coveragePct},...n.avgExportUsage!==void 0&&{avgExportUsage:n.avgExportUsage},...n.maxExportUsage!==void 0&&{maxExportUsage:n.maxExportUsage}})),cycles:t.cycles}}function Gr(t){let e=t.getPackageDependencies(),n=Array.from(t.packages.values()).map(({graph:r,pkg:o})=>({name:o.name,relativeRoot:o.relativeRoot,nodeCount:r.nodes.size,dependsOn:e.get(o.name)??[]}));return{monorepoType:t.type,packageCount:n.length,packages:n}}function ne(t){return[...t.nodes.values()].some(e=>e.coveragePct!==void 0)}function ha(t){return[...t.nodes.values()].some(e=>e.commitCount90d!==void 0)}function Ge(t,e={}){let{metric:n="cognitiveComplexity",minComplexity:r=10,maxCoveragePct:o=50,minChurn:s=0,limit:i=20}=e,a=ha(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[n]>=r).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[n]-p[n]).slice(0,i);return{hotspots:c,count:c.length,churnDataAvailable:a}}var Ut=d(()=>{"use strict";l();Ht()});import{execFileSync as $r}from"child_process";import jr from"fs";import _u from"os";import Gu from"path";function Wr(t,e){try{return $r("git",["rev-parse","--verify",`${e}^{commit}`],{cwd:t,encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).trim()}catch{throw new Error(`Could not resolve git ref "${e}" in ${t}`)}}async function ya(t,e,n){let r=jr.mkdtempSync(Gu.join(_u.tmpdir(),`mokosh-worktree-${e.slice(0,12)}-`));jr.rmdirSync(r);try{return $r("git",["worktree","add","--detach",r,e],{cwd:t,stdio:["ignore","pipe","pipe"]}),await n(r)}finally{try{$r("git",["worktree","remove","--force",r],{cwd:t,stdio:["ignore","pipe","pipe"]})}catch{jr.rmSync(r,{recursive:!0,force:!0})}}}var xa=d(()=>{"use strict";l()});import ju from"path";async function wa(t,e,n,r={}){let o=Wr(t,e),s=ms(t,o);if(s)return{sha:o,graph:s};let i=await ya(t,o,async a=>{let c=r.pathAliases?new K(a,{pathAliases:r.pathAliases}):void 0;return new pe(a,null,c,void 0,r.gitStats??!1,new Map,r.parallelParsing??!0,r.additionalIgnoreDirs??[]).build(n)});return us(t,o,i),{sha:o,graph:i}}function $u(t,e){return`${t.file}:${t.line} ${t.name} (${t[e]})`}function Wu(t,e){return`${t.file}:${t.line} ${t.name} (${t[e]}, cov ${t.coveragePct}%)`}function zu(t,e=4){let n=t.occurrences.slice(0,e).map(s=>`${s.file}:${s.startLine}-${s.endLine}`),r=t.occurrences.length-n.length,o=r>0?`, +${r} more`:"";return`${t.lines}L x${t.occurrences.length}: ${n.join(", ")}${o}`}function Bu(t,e){let{files:n,staleReferences:r,duplication:o,complexity:s,docDrift:i,coverage:a}=t,c=[],p=[n.added.length&&`${n.added.length} added`,n.changed.length&&`${n.changed.length} changed`,n.removed.length&&`${n.removed.length} removed`].filter(Boolean);c.push(p.length?`Files: ${p.join(", ")}`:"No file changes"),r.length>0&&c.push(`\u26A0 ${ue(r.length,"stale reference")} \u2014 removed export still imported`);let f=s.newHotspots[0];return f?c.push(`+${ue(s.newHotspots.length,"complexity hotspot")} (max ${e} ${f[e]} in ${f.file})`):s.resolvedHotspots.length>0&&c.push(`${ue(s.resolvedHotspots.length,"complexity hotspot")} resolved`),o.newGroups.length>0?c.push(`+${ue(o.newGroups.length,"duplication group")}`):o.resolvedGroups.length>0&&c.push(`${ue(o.resolvedGroups.length,"duplication group")} resolved`),i.newlyStale.length>0&&c.push(`${ue(i.newlyStale.length,"doc")} newly stale`),a&&a.newHotspots.length>0&&c.push(`+${ue(a.newHotspots.length,"risk hotspot")}`),c}function Hu(t){let{staleReferences:e,duplication:n,complexity:r,docDrift:o,coverage:s}=t;return e.length>0||(s?.newHotspots.length??0)>0?"attention":r.newHotspots.length>0||n.newGroups.length>0||o.newlyStale.length>0?"review-worthy":"clean"}function zr(t,e={}){let n=e.metric??"cognitiveComplexity",r=e.maxItems??8,o=e.maxPathList??100,{files:s,staleReferences:i,duplication:a,complexity:c,docDrift:p,coverage:f}=t,m=ba(c.head.avgCognitiveComplexity-c.base.avgCognitiveComplexity),h=s.added.length+s.changed.length+s.removed.length,y={base:`${t.base.ref}@${Sa(t.base.sha)}`,head:`${t.head.ref}@${Sa(t.head.sha)}`,verdict:Hu(t),headline:Bu(t,n),files:{added:s.added.length,changed:s.changed.length,removed:s.removed.length,...h<=o?{paths:{added:s.added,changed:s.changed,removed:s.removed}}:{}}};return i.length>0&&(y.staleReferences=i),(c.newHotspots.length>0||c.resolvedHotspots.length>0)&&(y.complexity={avgDelta:m,newHotspots:c.newHotspots.slice(0,r).map(b=>$u(b,n)),newHotspotCount:c.newHotspots.length,resolvedCount:c.resolvedHotspots.length}),(a.newGroups.length>0||a.resolvedGroups.length>0)&&(y.duplication={newGroups:a.newGroups.slice(0,r).map(b=>zu(b)),newGroupCount:a.newGroups.length,resolvedCount:a.resolvedGroups.length,totalGroups:a.head.groups}),(p.newlyStale.length>0||p.resolved.length>0)&&(y.docDrift={newlyStale:p.newlyStale.slice(0,r).map(b=>b.replace("::"," \u2192 ")),newlyStaleCount:p.newlyStale.length,resolvedCount:p.resolved.length}),f&&(f.newHotspots.length>0||f.resolvedHotspots.length>0)&&(y.coverage={avgDelta:ba(f.head.avgCoveragePct-f.base.avgCoveragePct),newHotspots:f.newHotspots.slice(0,r).map(b=>Wu(b,n)),newHotspotCount:f.newHotspots.length,resolvedCount:f.resolvedHotspots.length}),y}function Uu(t,e){let n=[],r=[];for(let[s,i]of e.nodes){let a=t.nodes.get(s);if(!a){n.push(s);continue}let c=JSON.stringify({category:a.category,exports:a.exports.map(f=>f.name).sort(),imports:a.imports.map(f=>f.toPath).sort()}),p=JSON.stringify({category:i.category,exports:i.exports.map(f=>f.name).sort(),imports:i.imports.map(f=>f.toPath).sort()});c!==p&&r.push(s)}let o=[...t.nodes.keys()].filter(s=>!e.nodes.has(s));return{added:n,removed:o,changed:r}}function Ju(t,e){let n=[];for(let[r,o]of t.nodes){let s=e.nodes.get(r);if(!s)continue;let i=new Set(s.exports.map(c=>c.name)),a=o.exports.map(c=>c.name).filter(c=>!i.has(c));if(a.length!==0)for(let c of a){let p=[...e.nodes.values()].filter(f=>f.imports.some(m=>m.toPath===r&&m.symbols?.includes(c))).map(f=>f.path);p.length>0&&n.push({file:r,symbol:c,stillReferencedBy:p})}}return n}function Jt(t){return t.occurrences.map(e=>`${e.file}:${e.startLine}-${e.endLine}`).sort().join("|")}async function Ku(t,e,n,r,o){let s=ju.join(Ct(t),`${r}-${re}`),i=Me(s),[{groups:a},{groups:c}]=await Promise.all([Oe(e,t,{minLines:o,tokenCache:i}),Oe(n,t,{minLines:o})]);Le(i,s);let p=new Set(a.map(Jt)),f=new Set(c.map(Jt));return{base:{groups:a.length},head:{groups:c.length},newGroups:c.filter(m=>!p.has(Jt(m))),resolvedGroups:a.filter(m=>!f.has(Jt(m)))}}function Ca(t){let e=[...t.nodes.values()].map(n=>n.cognitiveComplexity).filter(n=>n!==void 0);return e.length===0?0:e.reduce((n,r)=>n+r,0)/e.length}function Vu(t,e,n,r){let o=_e(t,{metric:n,threshold:r,limit:1/0}),s=_e(e,{metric:n,threshold:r,limit:1/0}),i=p=>`${p.file}:${p.name}`,a=new Set(o.map(i)),c=new Set(s.map(i));return{base:{avgCognitiveComplexity:Ca(t)},head:{avgCognitiveComplexity:Ca(e)},newHotspots:s.filter(p=>!a.has(i(p))),resolvedHotspots:o.filter(p=>!c.has(i(p)))}}function ka(t){let e=new Set;for(let n of t.nodes.values())if(!(n.type!=="markdown"||!n.staleFor))for(let r of n.staleFor)e.add(`${n.path}::${r}`);return e}function qu(t,e){let n=ka(t),r=ka(e);return{base:{staleCount:n.size},head:{staleCount:r.size},newlyStale:[...r].filter(o=>!n.has(o)),resolved:[...n].filter(o=>!r.has(o))}}function va(t){let e=[...t.nodes.values()].map(n=>n.coveragePct).filter(n=>n!==void 0);return e.length===0?0:e.reduce((n,r)=>n+r,0)/e.length}function Yu(t,e,n){if(!ne(t)||!ne(e))return null;let r=Ge(t,{maxCoveragePct:n,limit:1/0}).hotspots,o=Ge(e,{maxCoveragePct:n,limit:1/0}).hotspots,s=c=>`${c.file}:${c.name}`,i=new Set(r.map(s)),a=new Set(o.map(s));return{base:{avgCoveragePct:va(t)},head:{avgCoveragePct:va(e)},newHotspots:o.filter(c=>!i.has(s(c))),resolvedHotspots:r.filter(c=>!a.has(s(c)))}}async function Br(t,e,n,r={}){let{sha:o,graph:s}=await wa(t,e,r.entryPoints??[],r),i=Wr(t,r.headRef??"HEAD"),[a,c]=await Promise.all([Ku(t,s,n,o,r.minDuplicateLines),Promise.resolve(Yu(s,n,r.maxCoveragePct))]);return{base:{ref:e,sha:o},head:{ref:r.headRef??"HEAD",sha:i},files:Uu(s,n),staleReferences:Ju(s,n),duplication:a,complexity:Vu(s,n,r.complexityMetric,r.complexityThreshold),docDrift:qu(s,n),coverage:c}}var ba,Sa,ue,Ea=d(()=>{"use strict";l();j();ds();Rr();Bt();Ut();Wt();xa();ba=t=>Math.round(t*100)/100,Sa=t=>t.length>8?t.slice(0,8):t;ue=(t,e)=>`${t} ${e}${t===1?"":"s"}`});import Kt from"path";function Qu(t){let e=new Map;for(let[n,r]of t){let o=r.imports.filter(s=>s.toPath&&!s.isExternal).length;o>0&&e.set(n,o)}return e}function Xu(t,e,n){let r=new Map;for(let[o,s]of e){if(s<n)continue;let i=t.get(o);if(!i||i.category==="test"||i.category==="barrel")continue;let a=Kt.extname(o),c=Kt.basename(o,a),p=c==="index"?Kt.basename(Kt.dirname(o)):c;r.set(o,{path:o,outDegree:s,tag:`feature:${p}`})}return r}function de(t,e){let n=e?.minOutDegree??5;return Xu(t,Qu(t),n)}var Vt=d(()=>{"use strict";l()});function ed(t,e){let n=new Map;for(let r of e.values()){let o=new Set;t.traverse(r.path,s=>(s.path!==r.path&&o.add(s.path),!0),{direction:"outgoing"}),n.set(r.path,o)}return n}function td(t,e,n,r){let o=new Map;for(let[s]of t){if(e.has(s))continue;let i=null;for(let a of e.values())n.get(a.path)?.has(s)&&(!i||r(a,i)<0)&&(i=a);i&&o.set(s,i.path)}return o}function nd(t,e){let n=new Map;for(let r of t.values()){let o=r.tag.replace("feature:",""),s=[];for(let[i,a]of e)a===r.path&&s.push(i);n.set(o,{hub:r.path,outDegree:r.outDegree,files:s})}return n}function rd(t,e,n){let r=[];for(let o of t.keys())!e.has(o)&&!n.has(o)&&r.push(o);return r}function it(t,e){let n=e?.detectFn??de,r=e?.hubComparator??Zu,o=n(t.nodes,e),s=ed(t,o),i=td(t.nodes,o,s,r);return{features:nd(o,i),unassigned:rd(t.nodes,o,i)}}var Zu,qt=d(()=>{"use strict";l();Vt();Zu=(t,e)=>t.outDegree-e.outDegree});function Ta(t){if(t.category==="test")return"test";if(t.category==="config")return"config";if(t.category==="type-only")return"types";let e=t.path,n=id(e);for(let r of od)if(r.segments?.some(o=>sd(e,o))||r.basenames?.includes(n))return r.role;return"other"}function sd(t,e){return t.includes(`/${e}/`)||t.includes(`/${e}.`)}function id(t){let e=t.slice(t.lastIndexOf("/")+1);return e.slice(0,e.lastIndexOf("."))||e}var od,Fa=d(()=>{"use strict";l();od=[{role:"component",segments:["component","components"]},{role:"controller",segments:["controller","controllers"]},{role:"middleware",segments:["middleware"]},{role:"router",segments:["router","routes","route"]},{role:"store",segments:["store","stores"]},{role:"service",segments:["service","services"]},{role:"handler",segments:["handler","handlers"]},{role:"adapter",segments:["adapter","adapters"]},{role:"plugin",segments:["plugin","plugins"]},{role:"api",segments:["api"]},{role:"cli",segments:["cli","commands"],basenames:["cli"]},{role:"util",segments:["util","utils","helper","helpers"]},{role:"model",segments:["model","models"],basenames:["model"]},{role:"parser",segments:["parser","parsers"],basenames:["parser"]},{role:"builder",basenames:["builder"]},{role:"resolver",basenames:["resolver"]}]});function Hr(t,e){let n=it(t,e),r=new Map;for(let[s,i]of n.features){for(let a of i.files)r.set(a,s);r.set(i.hub,s)}let o=new Map;for(let s of t.nodes.values()){let i=r.get(s.path);o.set(s.path,{path:s.path,role:Ta(s),...s.description?{description:s.description}:{},exports:s.exports.map(a=>a.name),...i?{featureHub:i}:{}})}return o}var Ur=d(()=>{"use strict";l();qt();Fa()});function Jr(t,e){let n=[];for(let r of t.nodes.values())if(r.exports.some(o=>o.name===e))if(Lt.has(r.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});n.push({path:r.path,category:r.category,precision:"call",callers:o})}else{let o=st(t,r.path).map(s=>({file:s.path,...s.symbols?{symbols:s.symbols}:{}}));n.push({path:r.path,category:r.category,precision:"file-level",importers:o})}return n}var Na=d(()=>{"use strict";l();Ot();Ut()});function ad(t){return t?t.startsWith("interface ")?"interface":t.startsWith("class ")?"class":t.startsWith("enum ")?"enum":"type":"type"}function cd(t,e){if(e==="type-only")return!0;let n=t.signature??"";return n.startsWith("interface ")||n.startsWith("class ")||n.startsWith("enum ")}function Kr(t){let e=new Map;for(let r of t.nodes.values())if(!(r.type!=="typescript"&&r.type!=="javascript"))for(let o of r.exports){if(!cd(o,r.category))continue;let s=`${r.path}::${o.name}`;e.set(s,{name:o.name,file:r.path,kind:ad(o.signature),...o.doc?{doc:o.doc}:{}})}let n=[];for(let r of t.nodes.values())if(!(r.type!=="typescript"&&r.type!=="javascript")){for(let o of r.imports)if(!(!o.toPath||o.isExternal||!o.symbols?.length))for(let s of o.symbols)e.has(`${o.toPath}::${s}`)&&n.push({fromFile:r.path,toType:s,toFile:o.toPath})}return{types:e,edges:n}}function Vr(t,e){let n=null;for(let s of t.types.values())if(s.name===e){n=s;break}if(!n)return{type:null,usedByFiles:[],uses:[]};let r=new Set,o=new Map;for(let s of t.edges)if(s.toType===e&&s.toFile===n.file&&r.add(s.fromFile),s.fromFile===n.file){let i=t.types.get(`${s.toFile}::${s.toType}`);i&&o.set(`${i.file}::${i.name}`,i)}return{type:n,usedByFiles:Array.from(r),uses:Array.from(o.values())}}var qr=d(()=>{"use strict";l()});import Pa from"fs";import Gk from"path";function Yt(t){try{return Pa.statSync(t,{throwIfNoEntry:!1})?.isDirectory()===!0}catch{return!1}}function Qt(t){try{return Pa.statSync(t,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}var at=d(()=>{"use strict";l()});import ld from"fs";import Yr from"path";function Da(t,e=[]){let n;try{n=ld.readdirSync(t,{withFileTypes:!0})}catch{return e}for(let r of n){let o=Yr.join(t,r.name);r.isDirectory()?!fd.has(r.name)&&!r.name.startsWith(".")&&Da(o,e):r.isFile()&&pd.has(Yr.extname(r.name).toLowerCase())&&e.push(o)}return e}function Xt(t,e,n){if(!Yt(e))return null;let r=Da(e);return r.length===0?null:{name:n,root:e,relativeRoot:Yr.relative(t,e),entryPoints:r}}var pd,fd,Qr=d(()=>{"use strict";l();j();at();pd=new Set([".java",".kt",".kts",".scala",".sc",".groovy",".gradle"]),fd=new Set(A)});import Ra from"fs";import Ia from"path";function md(t){return t.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/[^\n]*/g,"")}function ud(t){let e=md(t),n=new Set;for(let r of e.matchAll(/['"](:[A-Za-z0-9_\-.:]+)['"]/g)){let o=r[1].replace(/^:/,"").replace(/:$/,"");o&&n.add(o)}return[...n]}var Aa,Ma=d(()=>{"use strict";l();Qr();Aa={type:"gradle",detect(t){let e=["settings.gradle.kts","settings.gradle"].map(s=>Ia.join(t,s)).find(s=>Ra.existsSync(s));if(!e)return null;let n;try{n=Ra.readFileSync(e,"utf-8")}catch{return null}let r=ud(n);if(r.length===0)return null;let o=[];for(let s of r){let i=Ia.join(t,...s.split(":")),a=Xt(t,i,s);a&&o.push(a)}return o.length>0?o:null}}});import ct from"fs";import L from"path";function Xr(t,e){let n=L.join(e,"package.json");if(!ct.existsSync(n))return null;let r={};try{r=JSON.parse(ct.readFileSync(n,"utf-8"))}catch{return null}let o=r.name;return o?{name:o,root:e,relativeRoot:L.relative(t,e),entryPoints:dd(e,r)}:null}function dd(t,e){let n=[];if(e.exports){let o=e.exports;if(typeof o=="string")n.push(L.join(t,o));else if(typeof o=="object"&&o!==null){let s=o["."];if(typeof s=="string")n.push(L.join(t,s));else if(typeof s=="object"&&s!==null){let i=s.import??s.require??s.default;typeof i=="string"&&n.push(L.join(t,i))}}}e.main&&n.push(L.join(t,e.main));for(let o of["src/index.ts","src/index.tsx","index.ts","index.tsx","index.js"])n.push(L.join(t,o));let r=n.filter(Qt);return r.length>0?r.slice(0,1):n.slice(0,1)}function je(t,e){let n=[],r=new Set;for(let o of e){let s=o.replace(/\/$/,"").replace(/^\.\//,"");gd(t,s,r,n)}return n}function gd(t,e,n,r){if(!e.includes("*")){hd(t,e,n,r);return}let o=e.split("/");o.includes("**")?yd(t,o,n,r):xd(t,o,n,r)}function hd(t,e,n,r){let o=L.join(t,e);if(n.has(o)||!Yt(o))return;n.add(o);let s=Xr(t,o);s&&r.push(s)}function yd(t,e,n,r){let o=L.join(t,e[0]==="**"?"":e[0]??"");La(t,o,n,r)}function xd(t,e,n,r){let o=e.findIndex(a=>a.includes("*")),s=L.join(t,...e.slice(0,o)),i;try{i=ct.readdirSync(s,{withFileTypes:!0})}catch{return}for(let a of i){if(!a.isDirectory())continue;let c=L.join(s,a.name);if(n.has(c))continue;n.add(c);let p=Xr(t,c);p&&r.push(p)}}function La(t,e,n,r){let o;try{o=ct.readdirSync(e,{withFileTypes:!0})}catch{return}for(let s of o){if(!s.isDirectory()||s.name==="node_modules"||s.name.startsWith("."))continue;let i=L.join(e,s.name);if(ct.existsSync(L.join(i,"package.json"))&&!n.has(i)){n.add(i);let a=Xr(t,i);a&&r.push(a)}else La(t,i,n,r)}}var Zt=d(()=>{"use strict";l();at();at()});import Zr from"fs";import Oa from"path";var _a,Ga=d(()=>{"use strict";l();Zt();_a={type:"npm",detect(t){let e=Oa.join(t,"package.json");if(!Zr.existsSync(e))return null;let n;try{n=JSON.parse(Zr.readFileSync(e,"utf-8")).workspaces}catch{return null}if(!n||Zr.existsSync(Oa.join(t,"yarn.lock")))return null;let r=Array.isArray(n)?n:n.packages??[];return r.length===0?null:je(t,r)}}});import $e from"fs";import D from"path";function $a(t,e,n,r){if(r>4)return[];let o;try{o=$e.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=D.join(e,a);$e.existsSync(D.join(c,"project.json"))&&!n.has(c)?(n.add(c),s.push(c)):s.push(...$a(t,c,n,r+1))}return s}function bd(t,e,n){let r={};try{r=JSON.parse($e.readFileSync(n,"utf-8"))}catch{return null}let o=r.name,s,i,a=D.join(e,"package.json");if($e.existsSync(a))try{let c=JSON.parse($e.readFileSync(a,"utf-8"));o=c.name??o,s=c.main,i=c.exports}catch{}return o?{name:o,root:e,relativeRoot:D.relative(t,e),entryPoints:Sd(e,r,s,i)}:null}function Sd(t,e,n,r){let o=[],s=e.targets?.build?.options?.main??e.targets?.build?.options?.entryFile;if(s){let a=D.resolve(t,"../..");o.push(D.resolve(a,s)),o.push(D.resolve(t,s))}if(r){let a=r;if(typeof a=="string")o.push(D.join(t,a));else if(typeof a=="object"&&a!==null){let c=a["."];typeof c=="string"&&o.push(D.join(t,c))}}if(n&&o.push(D.join(t,n)),e.sourceRoot){let a=D.resolve(t,"../.."),c=D.resolve(a,e.sourceRoot);o.push(D.join(c,"index.ts"),D.join(c,"index.tsx"))}for(let a of["src/index.ts","src/index.tsx","index.ts","index.tsx"])o.push(D.join(t,a));let i=o.filter(Qt);return i.length>0?i.slice(0,1):o.slice(0,1)}var ja,Wa=d(()=>{"use strict";l();at();ja={type:"nx",detect(t){return $e.existsSync(D.join(t,"nx.json"))?$a(t,t,new Set,0).map(n=>bd(t,n,D.join(n,"project.json"))).filter(n=>n!==null):null}}});import za from"fs";import Cd from"path";import{load as kd}from"js-yaml";var Ba,Ha=d(()=>{"use strict";l();Zt();Ba={type:"pnpm",detect(t){let e=Cd.join(t,"pnpm-workspace.yaml");if(!za.existsSync(e))return null;let n=[];try{n=kd(za.readFileSync(e,"utf-8"))?.packages??[]}catch{return null}return je(t,n)}}});import lt from"fs";import en from"path";function vd(t){return t.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/[^\n]*/g,"")}function wd(t){let e=vd(t),n=new Map;for(let r of e.matchAll(/(?:lazy\s+)?val\s+([A-Za-z0-9_]+)\s*=\s*\(?\s*project\b([^\n]*)/g)){let o=r[1],i=r[2].match(/\bfile\s*\(\s*["']([^"']+)["']\s*\)/),a=i?i[1]:o;if(a==="."||a==="./")continue;let c=a.replace(/^\.\//,"").replace(/\/$/,"");n.has(c)||n.set(c,{name:o,dir:c})}return[...n.values()]}var Ua,Ja=d(()=>{"use strict";l();Qr();Ua={type:"sbt",detect(t){let e=en.join(t,"build.sbt"),n=en.join(t,"project");if(!lt.existsSync(e)||!lt.existsSync(n))return null;let r=[];try{r.push(lt.readFileSync(e,"utf-8"))}catch{return null}try{for(let a of lt.readdirSync(n))a.endsWith(".scala")&&r.push(lt.readFileSync(en.join(n,a),"utf-8"))}catch{}let o=new Set,s=[];for(let a of r)for(let c of wd(a))o.has(c.dir)||(o.add(c.dir),s.push(c));if(s.length===0)return null;let i=[];for(let a of s){let c=en.join(t,...a.dir.split("/")),p=Xt(t,c,a.name);p&&i.push(p)}return i.length>0?i:null}}});import Ed from"fs";import Td from"path";var Ka,Va=d(()=>{"use strict";l();Ka={type:"turborepo",detect(t){return Ed.existsSync(Td.join(t,"turbo.json"))?[]:null}}});import eo from"fs";import qa from"path";var Ya,Qa=d(()=>{"use strict";l();Zt();Ya={type:"yarn",detect(t){if(!eo.existsSync(qa.join(t,"yarn.lock")))return null;let e=qa.join(t,"package.json");if(!eo.existsSync(e))return null;let n;try{n=JSON.parse(eo.readFileSync(e,"utf-8")).workspaces}catch{return null}if(!n)return null;let r=Array.isArray(n)?n:n.packages??[];return r.length===0?null:je(t,r)}}});function W(t){Xa.push(t)}function Za(){return Xa}var Xa,tn=d(()=>{"use strict";l();Xa=[]});import Gv from"fs";import $v from"path";var ec=d(()=>{"use strict";l()});import Nd from"path";function to(t,e=Za()){let n=Nd.resolve(t),r=new Map,o=[];for(let i of e){let a=i.detect(n);if(a!==null){o.push(i.type);for(let c of a)r.has(c.name)||r.set(c.name,c)}}if(o.length===0)return{root:n,type:"none",types:[],packages:[],packageMap:new Map};let s=Array.from(r.values());return{root:n,type:o[0],types:o,packages:s,packageMap:new Map(s.map(i=>[i.name,i]))}}var no=d(()=>{"use strict";l();Ma();Ga();Wa();Ha();Ja();Va();Qa();tn();ec();tn();W(Ka);W(ja);W(Ba);W(Ya);W(_a);W(Aa);W(Ua)});var pt,ro=d(()=>{"use strict";l();ve();pt=class t{constructor(e,n){this.monorepoRoot=e;this.type=n}monorepoRoot;type;packages=new Map;addPackage(e,n){this.packages.set(e.name,{graph:n,pkg:e})}annotateCrossPackageEdges(){for(let{graph:e}of this.packages.values())for(let n of e.nodes.values()){let r=this.getPackageForFile(n.path);if(r)for(let o of n.imports){if(o.isExternal||o.isWorkspace)continue;let s=this.getPackageForFile(o.toPath);s&&s.name!==r.name&&(o.isWorkspace=!0,o.workspacePackage=s.name)}}}getPackageForFile(e){for(let{pkg:n}of this.packages.values())if(e===n.relativeRoot||e.startsWith(`${n.relativeRoot}/`))return n}getPackageDependencies(){let e=new Map;for(let{graph:n,pkg:r}of this.packages.values()){let o=new Set;for(let s of n.nodes.values())for(let i of s.imports)i.isWorkspace&&i.workspacePackage&&o.add(i.workspacePackage);e.set(r.name,[...o])}return e}getAffectedAcrossPackages(e){let n=this.getPackageForFile(e);if(!n)return[];let r=this.packages.get(n.name);if(!r)return[];let o=[];r.graph.traverse(e,s=>(s.path!==e&&o.push({file:s.path,package:n.name}),!0),{direction:"incoming"});for(let{graph:s,pkg:i}of this.packages.values())if(i.name!==n.name)for(let a of s.nodes.values())a.imports.some(p=>p.isWorkspace&&p.workspacePackage===n.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:n})=>({pkg:{name:n.name,relativeRoot:n.relativeRoot,entryPoints:n.entryPoints},nodes:Array.from(e.nodes.values())}))}}static deserialize(e){let n=new t(e.monorepoRoot,e.type);for(let{pkg:r,nodes:o}of e.packages){let s=new Map(o.map(a=>[a.path,a])),i=new I(s);n.packages.set(r.name,{graph:i,pkg:{...r,root:""}})}return n}}});function tc(t,e){return e.startsWith("!")?t!==e.slice(1):t===e}function Pd(t,e){return e.startsWith("!")?!t.includes(e.slice(1)):t.includes(e)}function ft(t,e,n){return rg.every(r=>r(t,e,n))}var Dd,Rd,Id,Ad,Md,Ld,Od,_d,Gd,jd,$d,Wd,zd,Bd,Hd,Ud,Jd,Kd,Vd,qd,Yd,Qd,Xd,Zd,eg,tg,ng,rg,oo=d(()=>{"use strict";l();Dd=(t,e)=>!e.category||tc(t.category,e.category),Rd=(t,e)=>!e.type||tc(t.type,e.type),Id=(t,e)=>e.lastAuthor?e.lastAuthor.startsWith("!")?t.lastAuthor!==e.lastAuthor.slice(1):t.lastAuthor!==void 0&&t.lastAuthor===e.lastAuthor:!0,Ad=(t,e)=>!e.path||Pd(t.path,e.path),Md=(t,e)=>e.isExternal===void 0?!0:t.imports.some(r=>r.isExternal)===e.isExternal,Ld=(t,e)=>{if(!e.tags||e.tags.length===0)return!0;let n=e.tags.filter(o=>!o.startsWith("!")),r=e.tags.filter(o=>o.startsWith("!")).map(o=>o.slice(1));return!(n.length>0&&!n.some(o=>t.tags.some(s=>s.name===o))||r.some(o=>t.tags.some(s=>s.name===o)))},Od=(t,e)=>!e.allTags?.length||e.allTags.every(n=>t.tags.some(r=>r.name===n)),_d=(t,e)=>!e.importsFile||t.imports.some(n=>n.toPath?.includes(e.importsFile)),Gd=(t,e,n)=>e.importedBy===void 0?!0:(n?.get(t.path)??[]).some(o=>o.includes(e.importedBy)),jd=(t,e)=>e.minImports===void 0||t.imports.length>=e.minImports,$d=(t,e)=>e.maxImports===void 0||t.imports.length<=e.maxImports,Wd=(t,e)=>e.minSize===void 0||t.size>=e.minSize,zd=(t,e)=>e.maxSize===void 0||t.size<=e.maxSize,Bd=(t,e)=>e.hasDocstring===void 0||!!t.description===e.hasDocstring,Hd=(t,e)=>e.isDocumented===void 0||!!t.documentedBy?.length===e.isDocumented,Ud=(t,e)=>e.isStale===void 0||!!t.staleFor?.length===e.isStale,Jd=(t,e)=>e.minCoverage===void 0||(t.coveragePct??101)>=e.minCoverage,Kd=(t,e)=>e.maxCoverage===void 0||(t.coveragePct??0)<=e.maxCoverage,Vd=(t,e)=>e.minExportUsage===void 0||(t.avgExportUsage??-1)>=e.minExportUsage,qd=(t,e)=>e.maxExportUsage===void 0||(t.avgExportUsage??0)<=e.maxExportUsage,Yd=(t,e)=>e.minComplexity===void 0||(t.complexity??-1/0)>=e.minComplexity,Qd=(t,e)=>e.maxComplexity===void 0||(t.complexity??0)<=e.maxComplexity,Xd=(t,e)=>e.minCognitiveComplexity===void 0||(t.cognitiveComplexity??-1/0)>=e.minCognitiveComplexity,Zd=(t,e)=>e.maxCognitiveComplexity===void 0||(t.cognitiveComplexity??0)<=e.maxCognitiveComplexity,eg=(t,e)=>e.minCommits===void 0||(t.commitCount90d??-1/0)>=e.minCommits,tg=(t,e)=>e.maxCommits===void 0||(t.commitCount90d??0)<=e.maxCommits,ng=(t,e,n)=>!e.any?.length||e.any.some(r=>ft(t,r,n)),rg=[Dd,Rd,Id,Ad,Md,Ld,Od,_d,Gd,jd,$d,Wd,zd,Bd,Hd,Ud,Jd,Kd,Vd,qd,Yd,Qd,Xd,Zd,eg,tg,ng]});function nn(t,e){let n=new Map;if(e.importedBy!==void 0){for(let i of t.nodes)for(let a of i.imports)if(a.toPath){let c=n.get(a.toPath)??[];c.push(i.path),n.set(a.toPath,c)}}let r=t.nodes.filter(i=>ft(i,e,n)),o=new Set(r.map(i=>i.path)),s=r.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;switch(e.sort){case"size":p=c.size-a.size;break;case"imports":p=c.imports.length-a.imports.length;break;case"commitCount90d":p=(c.commitCount90d??0)-(a.commitCount90d??0);break;case"exportUsage":p=(c.avgExportUsage??0)-(a.avgExportUsage??0);break;case"complexity":p=(c.complexity??0)-(a.complexity??0);break;case"cognitiveComplexity":p=(c.cognitiveComplexity??0)-(a.cognitiveComplexity??0);break}return 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 nc=d(()=>{"use strict";l();oo();oo()});function sg(t,e,n,r){let o=t;switch(n){case"string":o[e]=r;break;case"int":o[e]=parseInt(r,10);break;case"float":o[e]=parseFloat(r);break;case"boolNotFalse":o[e]=r.toLowerCase()!=="false";break;case"boolIsTrue":o[e]=r.toLowerCase()==="true";break}}function oc(t,e){let n=e.indexOf(":");if(n===-1)return;let r=e.slice(0,n).trim().toLowerCase(),o=e.slice(n+1).trim();if(!r||!o)return;if(r==="tag"||r==="tags"){o.includes("+")?t.allTags=[...t.allTags??[],...o.split("+")]:t.tags=[...t.tags??[],o];return}if(r==="sort"){t.sort=o;return}if(r==="sortdir"){t.sortDir=o.toLowerCase()==="asc"?"asc":"desc";return}let s=og[r];s&&sg(t,s.field,s.kind,o)}function ig(t){let e=[];for(let n of t.split("|")){let r=n.trim();if(!r)continue;let o={};oc(o,r),Object.keys(o).length>0&&e.push(o)}return e}function rn(t){let e={},n=t.split(",");for(let r of n){let o=r.trim();if(o.toLowerCase().startsWith(rc)&&o.endsWith(")")){let s=o.slice(rc.length,-1),i=ig(s);i.length>0&&(e.any=[...e.any??[],...i]);continue}oc(e,r)}return e}var og,rc,sc=d(()=>{"use strict";l();og={category:{field:"category",kind:"string"},type:{field:"type",kind:"string"},path:{field:"path",kind:"string"},importsfile:{field:"importsFile",kind:"string"},importedby:{field:"importedBy",kind:"string"},lastauthor:{field:"lastAuthor",kind:"string"},external:{field:"isExternal",kind:"boolIsTrue"},hasdocstring:{field:"hasDocstring",kind:"boolNotFalse"},isdocumented:{field:"isDocumented",kind:"boolNotFalse"},isstale:{field:"isStale",kind:"boolNotFalse"},minimports:{field:"minImports",kind:"int"},maximports:{field:"maxImports",kind:"int"},minsize:{field:"minSize",kind:"int"},maxsize:{field:"maxSize",kind:"int"},limit:{field:"limit",kind:"int"},mincoverage:{field:"minCoverage",kind:"int"},maxcoverage:{field:"maxCoverage",kind:"int"},minexportusage:{field:"minExportUsage",kind:"float"},maxexportusage:{field:"maxExportUsage",kind:"float"},mincomplexity:{field:"minComplexity",kind:"int"},maxcomplexity:{field:"maxComplexity",kind:"int"},mincognitivecomplexity:{field:"minCognitiveComplexity",kind:"int"},maxcognitivecomplexity:{field:"maxCognitiveComplexity",kind:"int"},mincommits:{field:"minCommits",kind:"int"},maxcommits:{field:"maxCommits",kind:"int"}};rc="any("});var ic=d(()=>{"use strict";l();nc();sc()});import ag from"path";import P from"typescript";function ge(t,e){let n=t[e];if(n===void 0)throw new Error(`Index ${e} out of bounds (length ${t.length})`);return n}function so(t){let e=[];for(let n of t.statements){if(!P.isExpressionStatement(n))continue;let r=n.expression;if(!P.isCallExpression(r))continue;let o=r.expression;P.isIdentifier(o)&&ac.has(o.text)&&e.push(r),P.isPropertyAccessExpression(o)&&P.isIdentifier(o.expression)&&ac.has(o.expression.text)&&e.push(r)}return e}function io(t,e,n){for(let r of t.arguments){if(!P.isObjectLiteralExpression(r))continue;let o=r.properties.find(s=>P.isPropertyAssignment(s)&&P.isIdentifier(s.name)&&s.name.text===e);if(!(!o||!P.isArrayLiteralExpression(o.initializer)))return o.initializer.elements.filter(P.isStringLiteral).map(s=>s.text)}return null}function ao(t,e,n,r){if(t.arguments.length===0)return null;for(let s=1;s<t.arguments.length;s++){let i=ge(t.arguments,s);if(!P.isObjectLiteralExpression(i))continue;let a=i.properties.find(p=>P.isPropertyAssignment(p)&&P.isIdentifier(p.name)&&p.name.text===e);if(a)return{start:a.initializer.getStart(r),end:a.initializer.getEnd(),text:n};let c=i.getEnd()-1;return{start:c,end:c,text:`${i.properties.length>0?", ":""}${e}: ${n}`}}let o=ge(t.arguments,t.arguments.length-1);return{start:o.getStart(r),end:o.getStart(r),text:`{ ${e}: ${n} }, `}}function co(t,e,n){let r=t.arguments;for(let o=1;o<r.length;o++){let s=ge(r,o);if(!P.isObjectLiteralExpression(s))continue;let i=s.properties.findIndex(c=>P.isPropertyAssignment(c)&&P.isIdentifier(c.name)&&c.name.text===e);if(i<0)continue;if(s.properties.length===1)return{start:ge(r,o-1).getEnd(),end:s.getEnd(),text:""};let a=ge(s.properties,i);return i===s.properties.length-1?{start:ge(s.properties,i-1).getEnd(),end:a.getEnd(),text:""}:{start:a.getStart(n),end:ge(s.properties,i+1).getStart(n),text:""}}return null}function lo(t,e){let n=[...e].sort((o,s)=>s.start-o.start),r=t;for(let o of n)r=r.slice(0,o.start)+o.text+r.slice(o.end);return r}function po(t){return`[${t.map(e=>JSON.stringify(e)).join(", ")}]`}function cg(t){return t.map(e=>e.startsWith("@")?e.slice(1):e)}function on(t,e,n,r){let o=P.createSourceFile(ag.basename(t),e,P.ScriptTarget.Latest,!0),s=so(o),[i]=s;if(!i)return e;let a=io(i,r,o),c=[...n].sort();if(a!==null&&JSON.stringify(cg(a).sort())===JSON.stringify(c))return e;let p=po(c.map(m=>`@${m}`)),f=s.flatMap(m=>{let h=n.length===0?co(m,r,o):ao(m,r,p,o);return h?[h]:[]});return f.length>0?lo(e,f):e}var ac,z,We=d(()=>{"use strict";l();ac=new Set(["describe","test","it"]);z=new Set([".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"])});import lg from"path";var sn,cc=d(()=>{"use strict";l();We();sn=class{name="cypress";canHandle(e){return z.has(lg.extname(e).toLowerCase())}apply(e,n,r){return on(e,n,r,"tags")}}});import pg from"path";function fg(t){return`${["# <mokosh-tags>",...t.map(e=>`@${e}`),"# </mokosh-tags>"].join(`
|
|
36
|
+
`),null}}var _g,Og,Gg,jg,$g,Wg,Rn=d(()=>{"use strict";p();Y();Vr();To();Fo();fc();dc();Do();bc();kc();Po();wc();$c();zc();Ao();Uc();Do();Hc();Jc();Vc();_g=20,Og=new Set(["css","scss","less"]),Gg=/(?:^|\/)(?:__tests__|__mocks__|__snapshots__|tests?|e2e)\/|\.(?:test|spec)\.[^/]*$|\.snap$/,jg=3,$g=6,Wg=120});var Fe,An=d(()=>{"use strict";p();Fe=class{affectedSymbols=new Map;constructor(e,n){this.affectedSymbols.set(e,new Set(["default",...n]))}updateAffectedSymbols(e,n){let r=this.affectedSymbols.get(n)||new Set,o=e.imports.find(c=>c.toPath===n);if(!o)return!1;let s=o.symbols||["*"],i=new Set;for(let c of s)(c==="*"||r.has("*")||r.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 De(t,e){let n=t.nodes.get(e);if(n)return{category:n.category,exports:n.exports.map(r=>r.name)}}function Mo(t,e,n=1){let r=[];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 r.push({path:o.path,...a?.symbols?{symbols:a.symbols}:{}}),!0},{direction:"outgoing",maxDepth:n}),r}function Dt(t,e){let n=[];return t.traverse(e,r=>{if(r.path===e)return!0;let o=r.imports.find(s=>s.toPath===e);return n.push({path:r.path,...o?.symbols?{symbols:o.symbols}:{}}),!0},{direction:"incoming",maxDepth:1}),n}function _o(t,e,n={}){let{testsOnly:r=!1,changedSymbols:o}=n,s=o?new Fe(e,o):null,i=[];return t.traverse(e,(a,c,l)=>{if(a.path===e)return!0;if(s&&l&&!s.updateAffectedSymbols(a,l))return!1;let u=a.category==="test"||a.tags.some(f=>f.name==="test");return(!r||u)&&i.push(a.path),!0},{direction:"incoming"}),i}function Oo(t,e,n={}){let{depth:r=1,withEdgeDetail:o=!1}=n,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:r}),s}function rt(t,e={}){let{metric:n="cognitiveComplexity",threshold:r=10,limit:o=20}=e;return[...t.nodes.values()].flatMap(s=>(s.functions??[]).filter(i=>i[n]>=r).map(i=>({file:s.path,name:i.name,line:i.line,complexity:i.complexity,cognitiveComplexity:i.cognitiveComplexity}))).sort((s,i)=>i[n]-s[n]).slice(0,o)}function Go(t){return{nodes:t.nodes.map(n=>({path:n.path,type:n.type,category:n.category,exports:n.exports.map(r=>r.name),tags:n.tags.filter(r=>r.kind==="comment-marker"||r.kind==="import").map(r=>r.name),importsFiles:n.imports.filter(r=>!r.isExternal&&r.toPath).map(r=>r.toPath),...n.package!==void 0&&{package:n.package},...n.description!==void 0&&{description:n.description},...n.testedBy!==void 0&&{testedBy:n.testedBy},...n.coveragePct!==void 0&&{coveragePct:n.coveragePct},...n.avgExportUsage!==void 0&&{avgExportUsage:n.avgExportUsage},...n.maxExportUsage!==void 0&&{maxExportUsage:n.maxExportUsage}})),cycles:t.cycles}}function jo(t){let e=t.getPackageDependencies(),n=Array.from(t.packages.values()).map(({graph:r,pkg:o})=>({name:o.name,relativeRoot:o.relativeRoot,nodeCount:r.nodes.size,dependsOn:e.get(o.name)??[]}));return{monorepoType:t.type,packageCount:n.length,packages:n}}function ge(t){return[...t.nodes.values()].some(e=>e.coveragePct!==void 0)}function Qc(t){return[...t.nodes.values()].some(e=>e.commitCount90d!==void 0)}function $o(t){return[...t.nodes.values()].some(e=>e.lastCommitAt!==void 0)}function ot(t,e={}){let{metric:n="cognitiveComplexity",minComplexity:r=10,maxCoveragePct:o=50,minChurn:s=0,limit:i=20}=e,a=Qc(t),c=[...t.nodes.values()].filter(l=>l.coveragePct!==void 0&&l.coveragePct<=o&&(!a||(l.commitCount90d??0)>=s)).flatMap(l=>(l.functions??[]).filter(u=>u[n]>=r).map(u=>({file:l.path,name:u.name,line:u.line,complexity:u.complexity,cognitiveComplexity:u.cognitiveComplexity,coveragePct:l.coveragePct,...l.commitCount90d!==void 0&&{commitCount90d:l.commitCount90d}}))).sort((l,u)=>u[n]-l[n]).slice(0,i);return{hotspots:c,count:c.length,churnDataAvailable:a}}var Ln=d(()=>{"use strict";p();An()});import{execFileSync as zo}from"child_process";import Wo from"fs";import Jg from"os";import Vg from"path";function Bo(t,e){try{return zo("git",["rev-parse","--verify",`${e}^{commit}`],{cwd:t,encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).trim()}catch{throw new Error(`Could not resolve git ref "${e}" in ${t}`)}}async function Yc(t,e,n){let r=Wo.mkdtempSync(Vg.join(Jg.tmpdir(),`mokosh-worktree-${e.slice(0,12)}-`));Wo.rmdirSync(r);try{return zo("git",["worktree","add","--detach",r,e],{cwd:t,stdio:["ignore","pipe","pipe"]}),await n(r)}finally{try{zo("git",["worktree","remove","--force",r],{cwd:t,stdio:["ignore","pipe","pipe"]})}catch{Wo.rmSync(r,{recursive:!0,force:!0})}}}var Xc=d(()=>{"use strict";p()});import Qg from"path";async function rl(t,e,n,r={}){let o=Bo(t,e),s=ki(t,o);if(s)return{sha:o,graph:s};let i=await Yc(t,o,async a=>{if(r.workspaceBuilder)return r.workspaceBuilder(a);let c=r.pathAliases?new ie(a,{pathAliases:r.pathAliases}):void 0;return new Te(a,null,c,void 0,r.gitStats??!1,new Map,r.parallelParsing??!0,r.additionalIgnoreDirs??[]).build(n)});return Ci(t,o,i),{sha:o,graph:i}}function Yg(t,e){return`${t.file}:${t.line} ${t.name} (${t[e]})`}function Xg(t,e){return`${t.file}:${t.line} ${t.name} (${t[e]}, cov ${t.coveragePct}%)`}function Zg(t,e=4){let n=t.occurrences.slice(0,e).map(s=>`${s.file}:${s.startLine}-${s.endLine}`),r=t.occurrences.length-n.length,o=r>0?`, +${r} more`:"";return`${t.lines}L x${t.occurrences.length}: ${n.join(", ")}${o}`}function qg(t,e){let{files:n,staleReferences:r,duplication:o,complexity:s,docDrift:i,coverage:a}=t,c=[],l=[n.added.length&&`${n.added.length} added`,n.changed.length&&`${n.changed.length} changed`,n.removed.length&&`${n.removed.length} removed`].filter(Boolean);c.push(l.length?`Files: ${l.join(", ")}`:"No file changes"),r.length>0&&c.push(`\u26A0 ${Ne(r.length,"stale reference")} \u2014 removed export still imported`);let u=s.newHotspots[0];return u?c.push(`+${Ne(s.newHotspots.length,"complexity hotspot")} (max ${e} ${u[e]} in ${u.file})`):s.resolvedHotspots.length>0&&c.push(`${Ne(s.resolvedHotspots.length,"complexity hotspot")} resolved`),o.newGroups.length>0?c.push(`+${Ne(o.newGroups.length,"duplication group")}`):o.resolvedGroups.length>0&&c.push(`${Ne(o.resolvedGroups.length,"duplication group")} resolved`),i.newlyStale.length>0&&c.push(`${Ne(i.newlyStale.length,"doc")} newly stale`),a&&a.newHotspots.length>0&&c.push(`+${Ne(a.newHotspots.length,"risk hotspot")}`),c}function eh(t){let{staleReferences:e,duplication:n,complexity:r,docDrift:o,coverage:s}=t;return e.length>0||(s?.newHotspots.length??0)>0?"attention":r.newHotspots.length>0||n.newGroups.length>0||o.newlyStale.length>0?"review-worthy":"clean"}function Uo(t,e={}){let n=e.metric??"cognitiveComplexity",r=e.maxItems??8,o=e.maxPathList??100,{files:s,staleReferences:i,duplication:a,complexity:c,docDrift:l,coverage:u}=t,f=Zc(c.head.avgCognitiveComplexity-c.base.avgCognitiveComplexity),h=s.added.length+s.changed.length+s.removed.length,y={base:`${t.base.ref}@${qc(t.base.sha)}`,head:`${t.head.ref}@${qc(t.head.sha)}`,verdict:eh(t),headline:qg(t,n),files:{added:s.added.length,changed:s.changed.length,removed:s.removed.length,...h<=o?{paths:{added:s.added,changed:s.changed,removed:s.removed}}:{}}};return i.length>0&&(y.staleReferences=i),(c.newHotspots.length>0||c.resolvedHotspots.length>0)&&(y.complexity={avgDelta:f,newHotspots:c.newHotspots.slice(0,r).map(b=>Yg(b,n)),newHotspotCount:c.newHotspots.length,resolvedCount:c.resolvedHotspots.length}),(a.newGroups.length>0||a.resolvedGroups.length>0)&&(y.duplication={newGroups:a.newGroups.slice(0,r).map(b=>Zg(b)),newGroupCount:a.newGroups.length,resolvedCount:a.resolvedGroups.length,totalGroups:a.head.groups}),(l.newlyStale.length>0||l.resolved.length>0)&&(y.docDrift={newlyStale:l.newlyStale.slice(0,r).map(b=>b.replace("::"," \u2192 ")),newlyStaleCount:l.newlyStale.length,resolvedCount:l.resolved.length}),u&&(u.newHotspots.length>0||u.resolvedHotspots.length>0)&&(y.coverage={avgDelta:Zc(u.head.avgCoveragePct-u.base.avgCoveragePct),newHotspots:u.newHotspots.slice(0,r).map(b=>Xg(b,n)),newHotspotCount:u.newHotspots.length,resolvedCount:u.resolvedHotspots.length}),y}function th(t,e){let n=[],r=[];for(let[s,i]of e.nodes){let a=t.nodes.get(s);if(!a){n.push(s);continue}let c=JSON.stringify({category:a.category,exports:a.exports.map(u=>u.name).sort(),imports:a.imports.map(u=>u.toPath).sort()}),l=JSON.stringify({category:i.category,exports:i.exports.map(u=>u.name).sort(),imports:i.imports.map(u=>u.toPath).sort()});c!==l&&r.push(s)}let o=[...t.nodes.keys()].filter(s=>!e.nodes.has(s));return{added:n,removed:o,changed:r}}function nh(t,e){let n=[];for(let[r,o]of t.nodes){let s=e.nodes.get(r);if(!s)continue;let i=new Set(s.exports.map(c=>c.name)),a=o.exports.map(c=>c.name).filter(c=>!i.has(c));if(a.length!==0)for(let c of a){let l=[...e.nodes.values()].filter(u=>u.imports.some(f=>f.toPath===r&&f.symbols?.includes(c))).map(u=>u.path);l.length>0&&n.push({file:r,symbol:c,stillReferencedBy:l})}}return n}function In(t){return t.occurrences.map(e=>`${e.file}:${e.startLine}-${e.endLine}`).sort().join("|")}async function rh(t,e,n,r,o){let s=Qg.join(Yt(t),`${r}-${be}`),i=Ze(s),[{groups:a},{groups:c}]=await Promise.all([nt(e,t,{minLines:o,tokenCache:i}),nt(n,t,{minLines:o})]);qe(i,s);let l=new Set(a.map(In)),u=new Set(c.map(In));return{base:{groups:a.length},head:{groups:c.length},newGroups:c.filter(f=>!l.has(In(f))),resolvedGroups:a.filter(f=>!u.has(In(f)))}}function el(t){let e=[...t.nodes.values()].map(n=>n.cognitiveComplexity).filter(n=>n!==void 0);return e.length===0?0:e.reduce((n,r)=>n+r,0)/e.length}function oh(t,e,n,r){let o=rt(t,{metric:n,threshold:r,limit:1/0}),s=rt(e,{metric:n,threshold:r,limit:1/0}),i=l=>`${l.file}:${l.name}`,a=new Set(o.map(i)),c=new Set(s.map(i));return{base:{avgCognitiveComplexity:el(t)},head:{avgCognitiveComplexity:el(e)},newHotspots:s.filter(l=>!a.has(i(l))),resolvedHotspots:o.filter(l=>!c.has(i(l)))}}function tl(t){let e=new Set;for(let n of t.nodes.values())if(!(n.type!=="markdown"||!n.staleFor))for(let r of n.staleFor)e.add(`${n.path}::${r}`);return e}function sh(t,e){let n=tl(t),r=tl(e);return{base:{staleCount:n.size},head:{staleCount:r.size},newlyStale:[...r].filter(o=>!n.has(o)),resolved:[...n].filter(o=>!r.has(o))}}function nl(t){let e=[...t.nodes.values()].map(n=>n.coveragePct).filter(n=>n!==void 0);return e.length===0?0:e.reduce((n,r)=>n+r,0)/e.length}function ih(t,e,n){if(!ge(t)||!ge(e))return null;let r=ot(t,{maxCoveragePct:n,limit:1/0}).hotspots,o=ot(e,{maxCoveragePct:n,limit:1/0}).hotspots,s=c=>`${c.file}:${c.name}`,i=new Set(r.map(s)),a=new Set(o.map(s));return{base:{avgCoveragePct:nl(t)},head:{avgCoveragePct:nl(e)},newHotspots:o.filter(c=>!i.has(s(c))),resolvedHotspots:r.filter(c=>!a.has(s(c)))}}async function Ho(t,e,n,r={}){let{sha:o,graph:s}=await rl(t,e,r.entryPoints??[],r),i=Bo(t,r.headRef??"HEAD"),[a,c]=await Promise.all([rh(t,s,n,o,r.minDuplicateLines),Promise.resolve(ih(s,n,r.maxCoveragePct))]);return{base:{ref:e,sha:o},head:{ref:r.headRef??"HEAD",sha:i},files:th(s,n),staleReferences:nh(s,n),duplication:a,complexity:oh(s,n,r.complexityMetric,r.complexityThreshold),docDrift:sh(s,n),coverage:c}}var Zc,qc,Ne,ol=d(()=>{"use strict";p();Y();vi();wo();Rn();Ln();xn();Xc();Zc=t=>Math.round(t*100)/100,qc=t=>t.length>8?t.slice(0,8):t;Ne=(t,e)=>`${t} ${e}${t===1?"":"s"}`});import Mn from"path";function ah(t){let e=new Map;for(let[n,r]of t){let o=r.imports.filter(s=>s.toPath&&!s.isExternal).length;o>0&&e.set(n,o)}return e}function ch(t,e,n){let r=new Map;for(let[o,s]of e){if(s<n)continue;let i=t.get(o);if(!i||i.category==="test"||i.category==="barrel")continue;let a=Mn.extname(o),c=Mn.basename(o,a),l=c==="index"?Mn.basename(Mn.dirname(o)):c;r.set(o,{path:o,outDegree:s,tag:`feature:${l}`})}return r}function Pe(t,e){let n=e?.minOutDegree??5;return ch(t,ah(t),n)}var _n=d(()=>{"use strict";p()});function ph(t,e){let n=new Map;for(let r of e.values()){let o=new Set;t.traverse(r.path,s=>(s.path!==r.path&&o.add(s.path),!0),{direction:"outgoing"}),n.set(r.path,o)}return n}function uh(t,e,n,r){let o=new Map;for(let[s]of t){if(e.has(s))continue;let i=null;for(let a of e.values())n.get(a.path)?.has(s)&&(!i||r(a,i)<0)&&(i=a);i&&o.set(s,i.path)}return o}function fh(t,e){let n=new Map;for(let r of t.values()){let o=r.tag.replace("feature:",""),s=[];for(let[i,a]of e)a===r.path&&s.push(i);n.set(o,{hub:r.path,outDegree:r.outDegree,files:s})}return n}function mh(t,e,n){let r=[];for(let o of t.keys())!e.has(o)&&!n.has(o)&&r.push(o);return r}function Nt(t,e){let n=e?.detectFn??Pe,r=e?.hubComparator??lh,o=n(t.nodes,e),s=ph(t,o),i=uh(t.nodes,o,s,r);return{features:fh(o,i),unassigned:mh(t.nodes,o,i)}}var lh,On=d(()=>{"use strict";p();_n();lh=(t,e)=>t.outDegree-e.outDegree});function sl(t){if(t.category==="test")return"test";if(t.category==="config")return"config";if(t.category==="type-only")return"types";let e=t.path,n=hh(e);for(let r of dh)if(r.segments?.some(o=>gh(e,o))||r.basenames?.includes(n))return r.role;return"other"}function gh(t,e){return t.includes(`/${e}/`)||t.includes(`/${e}.`)}function hh(t){let e=t.slice(t.lastIndexOf("/")+1);return e.slice(0,e.lastIndexOf("."))||e}var dh,il=d(()=>{"use strict";p();dh=[{role:"component",segments:["component","components"]},{role:"controller",segments:["controller","controllers"]},{role:"middleware",segments:["middleware"]},{role:"router",segments:["router","routes","route"]},{role:"store",segments:["store","stores"]},{role:"service",segments:["service","services"]},{role:"handler",segments:["handler","handlers"]},{role:"adapter",segments:["adapter","adapters"]},{role:"plugin",segments:["plugin","plugins"]},{role:"api",segments:["api"]},{role:"cli",segments:["cli","commands"],basenames:["cli"]},{role:"util",segments:["util","utils","helper","helpers"]},{role:"model",segments:["model","models"],basenames:["model"]},{role:"parser",segments:["parser","parsers"],basenames:["parser"]},{role:"builder",basenames:["builder"]},{role:"resolver",basenames:["resolver"]}]});function Ko(t,e){let n=Nt(t,e),r=new Map;for(let[s,i]of n.features){for(let a of i.files)r.set(a,s);r.set(i.hub,s)}let o=new Map;for(let s of t.nodes.values()){let i=r.get(s.path);o.set(s.path,{path:s.path,role:sl(s),...s.description?{description:s.description}:{},exports:s.exports.map(a=>a.name),...i?{featureHub:i}:{}})}return o}var Jo=d(()=>{"use strict";p();On();il()});function Vo(t,e){let n=[];for(let r of t.nodes.values())if(r.exports.some(o=>o.name===e))if(fn.has(r.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});n.push({path:r.path,category:r.category,precision:"call",callers:o})}else{let o=Dt(t,r.path).map(s=>({file:s.path,...s.symbols?{symbols:s.symbols}:{}}));n.push({path:r.path,category:r.category,precision:"file-level",importers:o})}return n}var al=d(()=>{"use strict";p();mn();Ln()});function Xo(t){let e=new Map;for(let r of t)for(let o of r.nodes.values())for(let s of o.tags){let i=e.get(s.name);i===void 0&&(i={name:s.name,count:0,kinds:[]},e.set(s.name,i)),i.count+=1,i.kinds.includes(s.kind)||i.kinds.push(s.kind)}let n={};for(let r of e.values()){r.kinds.sort((o,s)=>cl.indexOf(o)-cl.indexOf(s));for(let o of r.kinds)n[o]=(n[o]??0)+1}return{entries:e,byKind:n,totalDistinct:e.size}}function Zo(t,e={}){let n=Number.isFinite(e.minCount)?Math.max(1,Math.trunc(e.minCount)):ll,r=Number.isFinite(e.limit)?Math.max(0,Math.trunc(e.limit)):pl,o=Math.min(r,Yo),s=e.prefix?.toLowerCase(),i=y=>e.kind===void 0?y.kinds.some(b=>Qo.includes(b))&&Kt(y.name):e.kind==="all"?!0:y.kinds.includes(e.kind),a=[...t.entries.values()].filter(y=>y.count>=n&&i(y)&&(s===void 0||y.name.toLowerCase().includes(s))).sort((y,b)=>b.count-y.count||y.name.localeCompare(b.name)),c=a.length,l=a.slice(0,o),u=e.kind===void 0?`${Qo.join(" + ")} kinds, noise-filtered`:e.kind==="all"?"all kinds":`${e.kind} kind`,f=c>l.length,h={tags:l.map(y=>({name:y.name,count:y.count,kinds:y.kinds})),count:l.length,matched:c,totalDistinct:t.totalDistinct,byKind:t.byKind,hint:`${c} tag${c===1?"":"s"} match (${u}, count>=${n})${f?`; showing the top ${l.length}`:""}. ${t.totalDistinct} distinct tag names exist across all kinds \u2014 see byKind. Narrow with prefix:"\u2026", a higher minCount, or kind:"comment-marker"|"import"|"function"|"variable"|"library"|"all". This response is always capped at ${Yo} tags.`};return f&&(h.truncated=!0),h}var Qo,ll,pl,Yo,cl,ul=d(()=>{"use strict";p();xe();Qo=Ut,ll=2,pl=50,Yo=250,cl=["function","class","variable","type","import","library","comment-marker"]});function yh(t){return t?t.startsWith("interface ")?"interface":t.startsWith("class ")?"class":t.startsWith("enum ")?"enum":"type":"type"}function xh(t,e){if(e==="type-only")return!0;let n=t.signature??"";return n.startsWith("interface ")||n.startsWith("class ")||n.startsWith("enum ")}function qo(t){let e=new Map;for(let r of t.nodes.values())if(!(r.type!=="typescript"&&r.type!=="javascript"))for(let o of r.exports){if(!xh(o,r.category))continue;let s=`${r.path}::${o.name}`;e.set(s,{name:o.name,file:r.path,kind:yh(o.signature),...o.doc?{doc:o.doc}:{}})}let n=[];for(let r of t.nodes.values())if(!(r.type!=="typescript"&&r.type!=="javascript")){for(let o of r.imports)if(!(!o.toPath||o.isExternal||!o.symbols?.length))for(let s of o.symbols)e.has(`${o.toPath}::${s}`)&&n.push({fromFile:r.path,toType:s,toFile:o.toPath})}return{types:e,edges:n}}function es(t,e){let n=null;for(let s of t.types.values())if(s.name===e){n=s;break}if(!n)return{type:null,usedByFiles:[],uses:[]};let r=new Set,o=new Map;for(let s of t.edges)if(s.toType===e&&s.toFile===n.file&&r.add(s.fromFile),s.fromFile===n.file){let i=t.types.get(`${s.toFile}::${s.toType}`);i&&o.set(`${i.file}::${i.name}`,i)}return{type:n,usedByFiles:Array.from(r),uses:Array.from(o.values())}}var ts=d(()=>{"use strict";p()});import fl from"fs";import jE from"path";function Gn(t){try{return fl.statSync(t,{throwIfNoEntry:!1})?.isDirectory()===!0}catch{return!1}}function jn(t){try{return fl.statSync(t,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}var Pt=d(()=>{"use strict";p()});import bh from"fs";import ns from"path";function ml(t,e=[]){let n;try{n=bh.readdirSync(t,{withFileTypes:!0})}catch{return e}for(let r of n){let o=ns.join(t,r.name);r.isDirectory()?!kh.has(r.name)&&!r.name.startsWith(".")&&ml(o,e):r.isFile()&&Sh.has(ns.extname(r.name).toLowerCase())&&e.push(o)}return e}function $n(t,e,n){if(!Gn(e))return null;let r=ml(e);return r.length===0?null:{name:n,root:e,relativeRoot:ns.relative(t,e),entryPoints:r}}var Sh,kh,rs=d(()=>{"use strict";p();Y();Pt();Sh=new Set([".java",".kt",".kts",".scala",".sc",".groovy",".gradle"]),kh=new Set($)});import dl from"fs";import gl from"path";function Ch(t){return t.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/[^\n]*/g,"")}function vh(t){let e=Ch(t),n=new Set;for(let r of e.matchAll(/['"](:[A-Za-z0-9_\-.:]+)['"]/g)){let o=r[1].replace(/^:/,"").replace(/:$/,"");o&&n.add(o)}return[...n]}var hl,yl=d(()=>{"use strict";p();rs();hl={type:"gradle",detect(t){let e=["settings.gradle.kts","settings.gradle"].map(s=>gl.join(t,s)).find(s=>dl.existsSync(s));if(!e)return null;let n;try{n=dl.readFileSync(e,"utf-8")}catch{return null}let r=vh(n);if(r.length===0)return null;let o=[];for(let s of r){let i=gl.join(t,...s.split(":")),a=$n(t,i,s);a&&o.push(a)}return o.length>0?o:null}}});import Rt from"fs";import ae from"path";function ss(t,e){let n=ae.join(e,"package.json");if(!Rt.existsSync(n))return null;let r={};try{r=JSON.parse(Rt.readFileSync(n,"utf-8"))}catch{return null}let o=r.name;return o?{name:o,root:e,relativeRoot:ae.relative(t,e),entryPoints:Eh(e,r)}:null}function os(t,e){if(typeof t=="string"){wh.test(t)&&!t.endsWith(".d.ts")&&e(t);return}if(t&&typeof t=="object"&&!Array.isArray(t))for(let[n,r]of Object.entries(t))n!=="types"&&os(r,e)}function Eh(t,e){let n=[],r=new Set,o=a=>{let c=ae.join(t,a);r.has(c)||(r.add(c),n.push(c))},s=e.exports;if(typeof s=="string")os(s,o);else if(s&&typeof s=="object"&&!Array.isArray(s))for(let a of Object.values(s))os(a,o);e.main&&o(e.main);for(let a of["src/index.ts","src/index.tsx","index.ts","index.tsx","index.js"])o(a);let i=n.filter(jn);return i.length>0?i:n.slice(0,1)}function st(t,e){let n=[],r=new Set;for(let o of e){let s=o.replace(/\/$/,"").replace(/^\.\//,"");Th(t,s,r,n)}return n}function Th(t,e,n,r){if(!e.includes("*")){Fh(t,e,n,r);return}let o=e.split("/");o.includes("**")?Dh(t,o,n,r):Nh(t,o,n,r)}function Fh(t,e,n,r){let o=ae.join(t,e);if(n.has(o)||!Gn(o))return;n.add(o);let s=ss(t,o);s&&r.push(s)}function Dh(t,e,n,r){let o=ae.join(t,e[0]==="**"?"":e[0]??"");xl(t,o,n,r)}function Nh(t,e,n,r){let o=e.findIndex(a=>a.includes("*")),s=ae.join(t,...e.slice(0,o)),i;try{i=Rt.readdirSync(s,{withFileTypes:!0})}catch{return}for(let a of i){if(!a.isDirectory())continue;let c=ae.join(s,a.name);if(n.has(c))continue;n.add(c);let l=ss(t,c);l&&r.push(l)}}function xl(t,e,n,r){let o;try{o=Rt.readdirSync(e,{withFileTypes:!0})}catch{return}for(let s of o){if(!s.isDirectory()||s.name==="node_modules"||s.name.startsWith("."))continue;let i=ae.join(e,s.name);if(Rt.existsSync(ae.join(i,"package.json"))&&!n.has(i)){n.add(i);let a=ss(t,i);a&&r.push(a)}else xl(t,i,n,r)}}var wh,Wn=d(()=>{"use strict";p();Pt();Pt();wh=/\.[mc]?[jt]sx?$/});import is from"fs";import bl from"path";var Sl,kl=d(()=>{"use strict";p();Wn();Sl={type:"npm",detect(t){let e=bl.join(t,"package.json");if(!is.existsSync(e))return null;let n;try{n=JSON.parse(is.readFileSync(e,"utf-8")).workspaces}catch{return null}if(!n||is.existsSync(bl.join(t,"yarn.lock")))return null;let r=Array.isArray(n)?n:n.packages??[];return r.length===0?null:st(t,r)}}});import it from"fs";import I from"path";function vl(t,e,n,r){if(r>4)return[];let o;try{o=it.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=I.join(e,a);it.existsSync(I.join(c,"project.json"))&&!n.has(c)?(n.add(c),s.push(c)):s.push(...vl(t,c,n,r+1))}return s}function Ph(t,e,n){let r={};try{r=JSON.parse(it.readFileSync(n,"utf-8"))}catch{return null}let o=r.name,s,i,a=I.join(e,"package.json");if(it.existsSync(a))try{let c=JSON.parse(it.readFileSync(a,"utf-8"));o=c.name??o,s=c.main,i=c.exports}catch{}return o?{name:o,root:e,relativeRoot:I.relative(t,e),entryPoints:Rh(e,r,s,i)}:null}function Rh(t,e,n,r){let o=[],s=e.targets?.build?.options?.main??e.targets?.build?.options?.entryFile;if(s){let a=I.resolve(t,"../..");o.push(I.resolve(a,s)),o.push(I.resolve(t,s))}if(r){let a=r;if(typeof a=="string")o.push(I.join(t,a));else if(typeof a=="object"&&a!==null){let c=a["."];typeof c=="string"&&o.push(I.join(t,c))}}if(n&&o.push(I.join(t,n)),e.sourceRoot){let a=I.resolve(t,"../.."),c=I.resolve(a,e.sourceRoot);o.push(I.join(c,"index.ts"),I.join(c,"index.tsx"))}for(let a of["src/index.ts","src/index.tsx","index.ts","index.tsx"])o.push(I.join(t,a));let i=o.filter(jn);return i.length>0?i.slice(0,1):o.slice(0,1)}var Cl,wl=d(()=>{"use strict";p();Pt();Cl={type:"nx",detect(t){return it.existsSync(I.join(t,"nx.json"))?vl(t,t,new Set,0).map(n=>Ph(t,n,I.join(n,"project.json"))).filter(n=>n!==null):null}}});import El from"fs";import Ah from"path";import{load as Lh}from"js-yaml";var Tl,Fl=d(()=>{"use strict";p();Wn();Tl={type:"pnpm",detect(t){let e=Ah.join(t,"pnpm-workspace.yaml");if(!El.existsSync(e))return null;let n=[];try{n=Lh(El.readFileSync(e,"utf-8"))?.packages??[]}catch{return null}return st(t,n)}}});import At from"fs";import zn from"path";function Ih(t){return t.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/[^\n]*/g,"")}function Mh(t){let e=Ih(t),n=new Map;for(let r of e.matchAll(/(?:lazy\s+)?val\s+([A-Za-z0-9_]+)\s*=\s*\(?\s*project\b([^\n]*)/g)){let o=r[1],i=r[2].match(/\bfile\s*\(\s*["']([^"']+)["']\s*\)/),a=i?i[1]:o;if(a==="."||a==="./")continue;let c=a.replace(/^\.\//,"").replace(/\/$/,"");n.has(c)||n.set(c,{name:o,dir:c})}return[...n.values()]}var Dl,Nl=d(()=>{"use strict";p();rs();Dl={type:"sbt",detect(t){let e=zn.join(t,"build.sbt"),n=zn.join(t,"project");if(!At.existsSync(e)||!At.existsSync(n))return null;let r=[];try{r.push(At.readFileSync(e,"utf-8"))}catch{return null}try{for(let a of At.readdirSync(n))a.endsWith(".scala")&&r.push(At.readFileSync(zn.join(n,a),"utf-8"))}catch{}let o=new Set,s=[];for(let a of r)for(let c of Mh(a))o.has(c.dir)||(o.add(c.dir),s.push(c));if(s.length===0)return null;let i=[];for(let a of s){let c=zn.join(t,...a.dir.split("/")),l=$n(t,c,a.name);l&&i.push(l)}return i.length>0?i:null}}});import _h from"fs";import Oh from"path";var Pl,Rl=d(()=>{"use strict";p();Pl={type:"turborepo",detect(t){return _h.existsSync(Oh.join(t,"turbo.json"))?[]:null}}});import as from"fs";import Al from"path";var Ll,Il=d(()=>{"use strict";p();Wn();Ll={type:"yarn",detect(t){if(!as.existsSync(Al.join(t,"yarn.lock")))return null;let e=Al.join(t,"package.json");if(!as.existsSync(e))return null;let n;try{n=JSON.parse(as.readFileSync(e,"utf-8")).workspaces}catch{return null}if(!n)return null;let r=Array.isArray(n)?n:n.packages??[];return r.length===0?null:st(t,r)}}});function q(t){Ml.push(t)}function _l(){return Ml}var Ml,Bn=d(()=>{"use strict";p();Ml=[]});import jT from"fs";import WT from"path";var Ol=d(()=>{"use strict";p()});import jh from"path";function Lt(t,e=_l()){let n=jh.resolve(t),r=new Map,o=[];for(let i of e){let a=i.detect(n);if(a!==null){o.push(i.type);for(let c of a)r.has(c.name)||r.set(c.name,c)}}if(o.length===0)return{root:n,type:"none",types:[],packages:[],packageMap:new Map};let s=Array.from(r.values());return{root:n,type:o[0],types:o,packages:s,packageMap:new Map(s.map(i=>[i.name,i]))}}var cs=d(()=>{"use strict";p();yl();kl();wl();Fl();Nl();Rl();Il();Bn();Ol();Bn();q(Pl);q(Cl);q(Tl);q(Ll);q(Sl);q(hl);q(Dl)});function ls(t,e){return t===e.relativeRoot||t.startsWith(`${e.relativeRoot}/`)}var It,ps=d(()=>{"use strict";p();$e();It=class t{constructor(e,n){this.monorepoRoot=e;this.type=n}monorepoRoot;type;packages=new Map;flattened;addPackage(e,n){this.packages.set(e.name,{graph:n,pkg:e})}annotateCrossPackageEdges(){for(let{graph:e}of this.packages.values())for(let n of e.nodes.values()){let r=this.getPackageForFile(n.path);if(r)for(let o of n.imports){if(o.isExternal||o.isWorkspace)continue;let s=this.getPackageForFile(o.toPath);s&&s.name!==r.name&&(o.isWorkspace=!0,o.workspacePackage=s.name)}}}flatten(){if(this.flattened)return this.flattened;let e=new Map,n=new Map;for(let{graph:r,pkg:o}of this.packages.values())for(let[s,i]of r.nodes)ls(s,o)&&(e.set(s,i),n.set(s,o.name));return this.flattened={graph:new _(e),packageOf:n},this.flattened}getPackageForFile(e){for(let{pkg:n}of this.packages.values())if(e===n.relativeRoot||e.startsWith(`${n.relativeRoot}/`))return n}getPackageDependencies(){let e=new Map;for(let{graph:n,pkg:r}of this.packages.values()){let o=new Set;for(let s of n.nodes.values())for(let i of s.imports)i.isWorkspace&&i.workspacePackage&&o.add(i.workspacePackage);e.set(r.name,[...o])}return e}getAffectedAcrossPackages(e){let{graph:n,packageOf:r}=this.flatten();if(!n.nodes.has(e))return[];let o=[];return n.traverse(e,s=>(s.path!==e&&o.push({file:s.path,package:r.get(s.path)??""}),!0),{direction:"incoming"}),o}summarizeAffectedAcrossPackages(e,n={}){let r=n.maxFilesPerPackage??10,o=this.getAffectedAcrossPackages(e),s=new Map;for(let{file:c,package:l}of o){let u=s.get(l)??[];u.push(c),s.set(l,u)}let i=!1,a=[...s.entries()].map(([c,l])=>{let u=l.slice(0,r),f=l.length-u.length;return f>0&&(i=!0),{package:c,count:l.length,sample:u,more:f}}).sort((c,l)=>l.count-c.count);return{file:e,totalAffected:o.length,packageCount:a.length,byPackage:a,truncated:i}}serialize(){return{monorepoRoot:this.monorepoRoot,type:this.type,packages:Array.from(this.packages.values()).map(({graph:e,pkg:n})=>({pkg:{name:n.name,relativeRoot:n.relativeRoot,entryPoints:n.entryPoints},nodes:Array.from(e.nodes.values())}))}}static deserialize(e){let n=new t(e.monorepoRoot,e.type);for(let{pkg:r,nodes:o}of e.packages){let s=new Map(o.map(a=>[a.path,a])),i=new _(s);n.packages.set(r.name,{graph:i,pkg:{...r,root:""}})}return n}}});function us(t,e){return e.startsWith("!")?t!==e.slice(1):t===e}function $h(t,e){return e.startsWith("!")?!t.includes(e.slice(1)):t.includes(e)}function Mt(t,e,n,r){return gy.every(o=>o(t,e,n,r))}var Wh,zh,Bh,Uh,Hh,Kh,Jh,Vh,Qh,Yh,Xh,Zh,qh,ey,ty,ny,ry,oy,sy,iy,ay,cy,ly,py,uy,fy,my,dy,gy,fs=d(()=>{"use strict";p();xe();Wh=(t,e)=>!e.category||us(t.category,e.category),zh=(t,e)=>!e.type||us(t.type,e.type),Bh=(t,e)=>e.lastAuthor?e.lastAuthor.startsWith("!")?t.lastAuthor!==e.lastAuthor.slice(1):t.lastAuthor!==void 0&&t.lastAuthor===e.lastAuthor:!0,Uh=(t,e)=>!e.path||$h(t.path,e.path),Hh=(t,e,n,r)=>{if(!e.package||!r)return!0;let o=r.get(t.path)??"";return us(o,e.package)},Kh=(t,e)=>e.isExternal===void 0?!0:t.imports.some(r=>r.isExternal)===e.isExternal,Jh=(t,e)=>{if(!e.tags||e.tags.length===0)return!0;let n=new Set(t.tags.filter(ye).map(s=>s.name)),r=e.tags.filter(s=>!s.startsWith("!")),o=e.tags.filter(s=>s.startsWith("!")).map(s=>s.slice(1));return!(r.length>0&&!r.some(s=>n.has(s))||o.some(s=>n.has(s)))},Vh=(t,e)=>{if(!e.allTags?.length)return!0;let n=new Set(t.tags.filter(ye).map(r=>r.name));return e.allTags.every(r=>n.has(r))},Qh=(t,e)=>!e.importsFile||t.imports.some(n=>n.toPath?.includes(e.importsFile)),Yh=(t,e,n)=>e.importedBy===void 0?!0:(n?.get(t.path)??[]).some(o=>o.includes(e.importedBy)),Xh=(t,e)=>e.minImports===void 0||t.imports.length>=e.minImports,Zh=(t,e)=>e.maxImports===void 0||t.imports.length<=e.maxImports,qh=(t,e)=>e.minSize===void 0||t.size>=e.minSize,ey=(t,e)=>e.maxSize===void 0||t.size<=e.maxSize,ty=(t,e)=>e.hasDocstring===void 0||!!t.description===e.hasDocstring,ny=(t,e)=>e.isDocumented===void 0||!!t.documentedBy?.length===e.isDocumented,ry=(t,e)=>e.isStale===void 0||!!t.staleFor?.length===e.isStale,oy=(t,e)=>e.minCoverage===void 0||(t.coveragePct??101)>=e.minCoverage,sy=(t,e)=>e.maxCoverage===void 0||(t.coveragePct??0)<=e.maxCoverage,iy=(t,e)=>e.minExportUsage===void 0||(t.avgExportUsage??-1)>=e.minExportUsage,ay=(t,e)=>e.maxExportUsage===void 0||(t.avgExportUsage??0)<=e.maxExportUsage,cy=(t,e)=>e.minComplexity===void 0||(t.complexity??-1/0)>=e.minComplexity,ly=(t,e)=>e.maxComplexity===void 0||(t.complexity??0)<=e.maxComplexity,py=(t,e)=>e.minCognitiveComplexity===void 0||(t.cognitiveComplexity??-1/0)>=e.minCognitiveComplexity,uy=(t,e)=>e.maxCognitiveComplexity===void 0||(t.cognitiveComplexity??0)<=e.maxCognitiveComplexity,fy=(t,e)=>e.minCommits===void 0||(t.commitCount90d??-1/0)>=e.minCommits,my=(t,e)=>e.maxCommits===void 0||(t.commitCount90d??0)<=e.maxCommits,dy=(t,e,n,r)=>!e.any?.length||e.any.some(o=>Mt(t,o,n,r)),gy=[Wh,zh,Bh,Uh,Hh,Kh,Jh,Vh,Qh,Yh,Xh,Zh,qh,ey,ty,ny,ry,oy,sy,iy,ay,cy,ly,py,uy,fy,my,dy]});function Un(t,e,n={}){let{packageOf:r}=n,o=new Map;if(e.importedBy!==void 0){for(let c of t.nodes)for(let l of c.imports)if(l.toPath){let u=o.get(l.toPath)??[];u.push(c.path),o.set(l.toPath,u)}}let s=t.nodes.filter(c=>Mt(c,e,o,r)),i=new Set(s.map(c=>c.path)),a=s.map(c=>{let l=r?.get(c.path);return{...c,imports:c.imports.filter(u=>!u.toPath||i.has(u.toPath)),...l!==void 0&&{package:l}}});if(e.sort){let c=e.sortDir==="asc"?-1:1;a.sort((l,u)=>{let f=0;switch(e.sort){case"size":f=u.size-l.size;break;case"imports":f=u.imports.length-l.imports.length;break;case"commitCount90d":f=(u.commitCount90d??0)-(l.commitCount90d??0);break;case"exportUsage":f=(u.avgExportUsage??0)-(l.avgExportUsage??0);break;case"complexity":f=(u.complexity??0)-(l.complexity??0);break;case"cognitiveComplexity":f=(u.cognitiveComplexity??0)-(l.cognitiveComplexity??0);break}return f*c})}return e.limit!==void 0&&a.splice(e.limit),{nodes:a,cycles:t.cycles?.filter(c=>c.every(l=>i.has(l)))??void 0}}var Gl=d(()=>{"use strict";p();fs();fs()});function yy(t,e,n,r){let o=t;switch(n){case"string":o[e]=r;break;case"int":o[e]=parseInt(r,10);break;case"float":o[e]=parseFloat(r);break;case"boolNotFalse":o[e]=r.toLowerCase()!=="false";break;case"boolIsTrue":o[e]=r.toLowerCase()==="true";break}}function $l(t,e){let n=e.indexOf(":");if(n===-1)return;let r=e.slice(0,n).trim().toLowerCase(),o=e.slice(n+1).trim();if(!r||!o)return;if(r==="tag"||r==="tags"){o.includes("+")?t.allTags=[...t.allTags??[],...o.split("+")]:t.tags=[...t.tags??[],o];return}if(r==="sort"){t.sort=o;return}if(r==="sortdir"){t.sortDir=o.toLowerCase()==="asc"?"asc":"desc";return}let s=hy[r];s&&yy(t,s.field,s.kind,o)}function xy(t){let e=[];for(let n of t.split("|")){let r=n.trim();if(!r)continue;let o={};$l(o,r),Object.keys(o).length>0&&e.push(o)}return e}function Hn(t){let e={},n=t.split(",");for(let r of n){let o=r.trim();if(o.toLowerCase().startsWith(jl)&&o.endsWith(")")){let s=o.slice(jl.length,-1),i=xy(s);i.length>0&&(e.any=[...e.any??[],...i]);continue}$l(e,r)}return e}var hy,jl,Wl=d(()=>{"use strict";p();hy={category:{field:"category",kind:"string"},type:{field:"type",kind:"string"},path:{field:"path",kind:"string"},package:{field:"package",kind:"string"},importsfile:{field:"importsFile",kind:"string"},importedby:{field:"importedBy",kind:"string"},lastauthor:{field:"lastAuthor",kind:"string"},external:{field:"isExternal",kind:"boolIsTrue"},hasdocstring:{field:"hasDocstring",kind:"boolNotFalse"},isdocumented:{field:"isDocumented",kind:"boolNotFalse"},isstale:{field:"isStale",kind:"boolNotFalse"},minimports:{field:"minImports",kind:"int"},maximports:{field:"maxImports",kind:"int"},minsize:{field:"minSize",kind:"int"},maxsize:{field:"maxSize",kind:"int"},limit:{field:"limit",kind:"int"},mincoverage:{field:"minCoverage",kind:"int"},maxcoverage:{field:"maxCoverage",kind:"int"},minexportusage:{field:"minExportUsage",kind:"float"},maxexportusage:{field:"maxExportUsage",kind:"float"},mincomplexity:{field:"minComplexity",kind:"int"},maxcomplexity:{field:"maxComplexity",kind:"int"},mincognitivecomplexity:{field:"minCognitiveComplexity",kind:"int"},maxcognitivecomplexity:{field:"maxCognitiveComplexity",kind:"int"},mincommits:{field:"minCommits",kind:"int"},maxcommits:{field:"maxCommits",kind:"int"}};jl="any("});var zl=d(()=>{"use strict";p();To();Fo();Gl();Wl()});import Sy from"path";import R from"typescript";function Re(t,e){let n=t[e];if(n===void 0)throw new Error(`Index ${e} out of bounds (length ${t.length})`);return n}function ms(t){let e=[];for(let n of t.statements){if(!R.isExpressionStatement(n))continue;let r=n.expression;if(!R.isCallExpression(r))continue;let o=r.expression;R.isIdentifier(o)&&Bl.has(o.text)&&e.push(r),R.isPropertyAccessExpression(o)&&R.isIdentifier(o.expression)&&Bl.has(o.expression.text)&&e.push(r)}return e}function ds(t,e,n){for(let r of t.arguments){if(!R.isObjectLiteralExpression(r))continue;let o=r.properties.find(s=>R.isPropertyAssignment(s)&&R.isIdentifier(s.name)&&s.name.text===e);if(!(!o||!R.isArrayLiteralExpression(o.initializer)))return o.initializer.elements.filter(R.isStringLiteral).map(s=>s.text)}return null}function gs(t,e,n,r){if(t.arguments.length===0)return null;for(let s=1;s<t.arguments.length;s++){let i=Re(t.arguments,s);if(!R.isObjectLiteralExpression(i))continue;let a=i.properties.find(l=>R.isPropertyAssignment(l)&&R.isIdentifier(l.name)&&l.name.text===e);if(a)return{start:a.initializer.getStart(r),end:a.initializer.getEnd(),text:n};let c=i.getEnd()-1;return{start:c,end:c,text:`${i.properties.length>0?", ":""}${e}: ${n}`}}let o=Re(t.arguments,t.arguments.length-1);return{start:o.getStart(r),end:o.getStart(r),text:`{ ${e}: ${n} }, `}}function hs(t,e,n){let r=t.arguments;for(let o=1;o<r.length;o++){let s=Re(r,o);if(!R.isObjectLiteralExpression(s))continue;let i=s.properties.findIndex(c=>R.isPropertyAssignment(c)&&R.isIdentifier(c.name)&&c.name.text===e);if(i<0)continue;if(s.properties.length===1)return{start:Re(r,o-1).getEnd(),end:s.getEnd(),text:""};let a=Re(s.properties,i);return i===s.properties.length-1?{start:Re(s.properties,i-1).getEnd(),end:a.getEnd(),text:""}:{start:a.getStart(n),end:Re(s.properties,i+1).getStart(n),text:""}}return null}function ys(t,e){let n=[...e].sort((o,s)=>s.start-o.start),r=t;for(let o of n)r=r.slice(0,o.start)+o.text+r.slice(o.end);return r}function xs(t){return`[${t.map(e=>JSON.stringify(e)).join(", ")}]`}function ky(t){return t.map(e=>e.startsWith("@")?e.slice(1):e)}function Kn(t,e,n,r){let o=R.createSourceFile(Sy.basename(t),e,R.ScriptTarget.Latest,!0),s=ms(o),[i]=s;if(!i)return e;let a=ds(i,r,o),c=[...n].sort();if(a!==null&&JSON.stringify(ky(a).sort())===JSON.stringify(c))return e;let l=xs(c.map(f=>`@${f}`)),u=s.flatMap(f=>{let h=n.length===0?hs(f,r,o):gs(f,r,l,o);return h?[h]:[]});return u.length>0?ys(e,u):e}var Bl,ee,at=d(()=>{"use strict";p();Bl=new Set(["describe","test","it"]);ee=new Set([".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"])});import Cy from"path";var Jn,Ul=d(()=>{"use strict";p();at();Jn=class{name="cypress";canHandle(e){return ee.has(Cy.extname(e).toLowerCase())}apply(e,n,r){return Kn(e,n,r,"tags")}}});import vy from"path";function wy(t){return`${["# <mokosh-tags>",...t.map(e=>`@${e}`),"# </mokosh-tags>"].join(`
|
|
30
37
|
`)}
|
|
31
38
|
|
|
32
|
-
`}function
|
|
33
|
-
`}function
|
|
34
|
-
${n.slice(c)}`}}});import
|
|
39
|
+
`}function Ey(t){let e=new Set;Ss.lastIndex=0;let n=Ss.exec(t);for(;n!==null;)n[1]&&e.add(n[1]),n=Ss.exec(t);return e}var bs,Ss,Vn,Hl=d(()=>{"use strict";p();bs=/# <mokosh-tags>[\s\S]*?# <\/mokosh-tags>\n*/,Ss=/^@([a-zA-Z0-9_-]+)/gm;Vn=class{name="gherkin";canHandle(e){return vy.extname(e).toLowerCase()===".feature"}apply(e,n,r){let o=n.replace(bs,""),s=Ey(o),i=r.filter(c=>!s.has(c)),a=i.length>0?wy(i):"";return bs.test(n)?n.replace(bs,a):a?n.replace(/^(Feature:)/m,`${a}$1`):n}}});function Kl(t,e){let n=t.replace(/\\/g,"/"),r=e.replace(/\\/g,"/"),o="";for(let s=0;s<n.length;s++){let i=n[s];i==="*"?n[s+1]==="*"?(o+=".*",s++):o+="[^/]*":i==="?"?o+="[^/]":i!==void 0&&(o+=i.replace(/[.+^${}()|[\]\\]/g,"\\$&"))}return new RegExp(`^${o}$`).test(r)}var Jl=d(()=>{"use strict";p()});import Ty from"path";function Dy(t){return`//go:build ${t.map(n=>`mokosh_${n}`).join(" || ")}
|
|
40
|
+
`}function Ny(t){let e=ks.exec(t);if(!e)return null;let n=e[0]??"",r=/mokosh_([a-zA-Z0-9_-]+)/g,o=[],s=r.exec(n);for(;s!==null;)s[1]&&o.push(s[1]),s=r.exec(n);return o}var ks,Fy,Qn,Vl=d(()=>{"use strict";p();ks=/^\/\/go:build mokosh_[^\n]+\n/m,Fy=/^package\s+\S+/m;Qn=class{name="go";canHandle(e){return Ty.basename(e).endsWith("_test.go")}apply(e,n,r){let o=Ny(n),s=[...r].sort();if(o!==null&&JSON.stringify([...o].sort())===JSON.stringify(s))return n;if(r.length===0)return n.replace(ks,"");let i=Dy(s);if(o!==null)return n.replace(ks,i);let a=Fy.exec(n);if(!a)return n;let c=a.index;return`${n.slice(0,c)+i}
|
|
41
|
+
${n.slice(c)}`}}});import Py from"path";function Ay(t){return`${["/**",...t.map(e=>` * @group ${e}`)," */"].join(`
|
|
35
42
|
`)}
|
|
36
43
|
|
|
37
|
-
`}function
|
|
44
|
+
`}function Ly(t){let e=[];Cs.lastIndex=0;let n=Cs.exec(t);for(;n!==null;)n[1]&&e.push(n[1]),n=Cs.exec(t);return e}var Ry,Cs,Yn,Ql=d(()=>{"use strict";p();at();Ry=/^\/\*\*\n(?: \* @group .+\n)+ \*\/\n+/,Cs=/^ \* @group (.+)$/gm;Yn=class{name="jest";canHandle(e){return ee.has(Py.extname(e).toLowerCase())}apply(e,n,r){let o=Ry.exec(n),s=o?Ly(o[0]):null,i=[...r].sort();if(s!==null&&JSON.stringify([...s].sort())===JSON.stringify(i))return n;let a=o?n.slice(o[0].length):n;return r.length===0?a:Ay(i)+a}}});import Yl from"path";function jy(t){let e=vs.exec(t);if(!e)return null;let n=[],r=/@Tag\("([^"]*)"\)/g,o=r.exec(e[0]);for(;o!==null;)o[1]&&n.push(o[1]),o=r.exec(e[0]);return n}function $y(t){return`${Iy}
|
|
38
45
|
${t.map(e=>`@Tag("${e}")`).join(`
|
|
39
46
|
`)}
|
|
40
|
-
`}function
|
|
41
|
-
`+t.slice(
|
|
42
|
-
`+
|
|
43
|
-
`+t.slice(
|
|
44
|
-
`+t}function
|
|
45
|
-
`),n=-1;return e.forEach((o,s)=>{(o.trimStart().startsWith("import ")||o.trimStart().startsWith("from "))&&(n=s)}),n<0?0:e.slice(0,n+1).reduce((o,s)=>o+s.length+1,0)}var
|
|
47
|
+
`}function Xl(t,e){if(e.importRe.test(t))return t;let n=e.lastImportRe.exec(t);if(n){let o=n.index+n[0].length;return t.slice(0,o)+e.importLine+`
|
|
48
|
+
`+t.slice(o)}let r=e.packageRe.exec(t);if(r){let o=r.index+r[0].length;return t.slice(0,o)+`
|
|
49
|
+
`+e.importLine+`
|
|
50
|
+
`+t.slice(o)}return e.importLine+`
|
|
51
|
+
`+t}function Wy(t,e){return/@Tag\b/.test(t)?t:t.replace(e.importRe,"")}var Iy,vs,My,_y,Oy,Gy,Xn,Zl=d(()=>{"use strict";p();Iy="// mokosh:tags",vs=/^\/\/ mokosh:tags\n(?:[ \t]*@Tag\("[^"]*"\)\n)*/m,My=/\/src\/(test|androidTest|integrationTest|it)\//,_y=/(Test|Tests|Spec|IT)\.(java|groovy|kt)$/,Oy={importLine:"import org.junit.jupiter.api.Tag;",importRe:/^import org\.junit\.jupiter\.api\.Tag;?\n/m,typeDeclRe:/^(?:public\s+|final\s+|abstract\s+|sealed\s+|non-sealed\s+|strictfp\s+)*(?:class|interface|enum|record|@interface)\s+\w+/m,lastImportRe:/^import\s+[^\n]+;\n(?![\s\S]*^import\s)/m,packageRe:/^package\s+[^\n]+;\n/m},Gy={importLine:"import org.junit.jupiter.api.Tag",importRe:/^import org\.junit\.jupiter\.api\.Tag;?\n/m,typeDeclRe:/^(?:public\s+|private\s+|protected\s+|internal\s+|open\s+|abstract\s+|final\s+|sealed\s+|data\s+|inner\s+|value\s+|annotation\s+)*(?:enum\s+)?(?:class|interface|object)\s+\w+/m,lastImportRe:/^import\s+[^\n]+\n(?![\s\S]*^import\s)/m,packageRe:/^package\s+[^\n]+\n/m};Xn=class{name="junit";canHandle(e){let n=e.replace(/\\/g,"/"),r=Yl.extname(n).toLowerCase();return r!==".java"&&r!==".groovy"&&r!==".kt"?!1:My.test(n)||_y.test(n)}apply(e,n,r){let o=Yl.extname(e.replace(/\\/g,"/")).toLowerCase()===".kt"?Gy:Oy,s=jy(n),i=[...r].sort();if(s!==null&&JSON.stringify([...s].sort())===JSON.stringify(i))return n;if(r.length===0)return s===null?n:Wy(n.replace(vs,""),o);let a=$y(i);if(s!==null)return Xl(n.replace(vs,a),o);let c=o.typeDeclRe.exec(n);if(!c)return n;let l=n.slice(0,c.index)+a+n.slice(c.index);return Xl(l,o)}}});import zy from"path";var Zn,ql=d(()=>{"use strict";p();at();Zn=class{name="playwright";canHandle(e){return ee.has(zy.extname(e).toLowerCase())}apply(e,n,r){return Kn(e,n,r,"tag")}}});import By from"path";function Hy(t){let e=t.map(n=>`pytest.mark.${n}`).join(", ");return t.length===1?`pytestmark = pytest.mark.${t[0]}`:`pytestmark = [${e}]`}function Ky(t){let e=ws.exec(t);if(!e)return null;let n=e[0],r=[],o=/pytest\.mark\.([a-zA-Z0-9_-]+)/g,s=o.exec(n);for(;s!==null;)s[1]&&r.push(s[1]),s=o.exec(n);return r}function Jy(t){let e=t.split(`
|
|
52
|
+
`),n=-1;return e.forEach((o,s)=>{(o.trimStart().startsWith("import ")||o.trimStart().startsWith("from "))&&(n=s)}),n<0?0:e.slice(0,n+1).reduce((o,s)=>o+s.length+1,0)}var ws,Uy,qn,ep=d(()=>{"use strict";p();ws=/^pytestmark\s*=\s*.+$/m,Uy=/^import pytest\s*$/m;qn=class{name="pytest";canHandle(e){return By.extname(e).toLowerCase()===".py"}apply(e,n,r){let o=Ky(n),s=[...r].sort();if(o!==null&&JSON.stringify([...o].sort())===JSON.stringify(s))return n;if(r.length===0)return n.replace(ws,"").replace(/\n{3,}/g,`
|
|
46
53
|
|
|
47
|
-
`);let i=
|
|
48
|
-
`,h=
|
|
54
|
+
`);let i=Hy(s);if(o!==null)return n.replace(ws,i);let a=Uy.test(n),c=Jy(n),l=n.slice(0,c),u=n.slice(c),f=a?"":`import pytest
|
|
55
|
+
`,h=l.endsWith(`
|
|
49
56
|
|
|
50
57
|
`)?"":`
|
|
51
|
-
`;return`${
|
|
52
|
-
${
|
|
53
|
-
`;if(o!==null)return n.replace(bo,i);let a=Gg.exec(n);return a?n.slice(0,a.index)+i+n.slice(a.index):n}}});import Sc from"path";import Cc from"typescript";var zg,dn,kc=d(()=>{"use strict";l();We();zg=/\/\/ <mokosh-tags>[\s\S]*?\/\/ <\/mokosh-tags>\n*/,dn=class{name="vitest";canHandle(e){return z.has(Sc.extname(e).toLowerCase())}apply(e,n,r){let o=n.replace(zg,""),s=Cc.createSourceFile(Sc.basename(e),o,Cc.ScriptTarget.Latest,!0),i=so(s),[a]=i;if(!a)return o;let c=io(a,"tags",s),p=[...r].sort();if(c!==null&&JSON.stringify([...c].sort())===JSON.stringify(p))return o;let f=i.flatMap(m=>{let h=r.length===0?co(m,"tags",s):ao(m,"tags",po(p),s);return h?[h]:[]});return f.length>0?lo(o,f):o}}});import So from"path";import gn from"typescript";function Hg(t){let e=gn.createSourceFile("detect.ts",t,gn.ScriptTarget.Latest,!0);for(let n of e.statements){if(!gn.isImportDeclaration(n)||!gn.isStringLiteral(n.moduleSpecifier))continue;let r=Bg[n.moduleSpecifier.text];if(r)return r}return null}function wc(t="vitest",e={},n=process.cwd()){return[new an,new mn,new cn,new pn,new un,new Co(n,t,Object.entries(e))]}function Ec(t,e){return e.find(n=>n.canHandle(t))??null}var vc,Bg,Co,Tc=d(()=>{"use strict";l();cc();lc();fc();mc();uc();hc();yc();xc();bc();We();kc();vc={vitest:()=>new dn,playwright:()=>new fn,cypress:()=>new sn,jest:()=>new ln},Bg={"@playwright/test":"playwright",cypress:"cypress","@jest/globals":"jest",vitest:"vitest"};Co=class{constructor(e,n,r){this.rootDir=e;this.defaultFramework=n;this.frameworkOverrides=r}rootDir;defaultFramework;frameworkOverrides;name="auto";canHandle(e){return z.has(So.extname(e).toLowerCase())}apply(e,n,r){let o=Hg(n)??this.matchOverride(e)??this.defaultFramework;return(vc[o]??vc.vitest)().apply(e,n,r)}matchOverride(e){let n=So.relative(this.rootDir,e).split(So.sep).join("/");for(let[r,o]of this.frameworkOverrides)if(pc(r,n))return o;return null}}});import Fc from"fs/promises";import Ug from"path";async function qg(t,e,n,r){let o;try{o=await Fc.readFile(t,"utf8")}catch(a){return{path:t,status:"error",error:String(a)}}let s=Ec(t,r);if(!s)return{path:t,status:"unchanged"};let i=s.apply(t,o,e);return i===o?{path:t,status:"unchanged"}:(n||await Fc.writeFile(t,i,"utf8"),{path:t,status:"updated"})}async function ko(t,e,n){let r=Se(e),o=r.tagApplier?.framework??"vitest",s=r.tagApplier?.frameworkOverrides??{},i=wc(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 y of c.tags)Kg.has(y.kind)&&Jg.test(y.name)&&(Vg.has(y.name.toLowerCase())||p.has(y.name)||(p.add(y.name),f.push(y.name)));f.sort();let m=Ug.resolve(e,c.path),h=await qg(m,f,n.dryRun,i);h.path=c.path,a.files.push(h),h.status==="updated"?a.updated++:h.status==="unchanged"?a.unchanged++:a.errors++}return a}var Jg,Kg,Vg,Nc=d(()=>{"use strict";l();In();Tc();Jg=/^[a-zA-Z][a-zA-Z0-9_-]{1,}$/,Kg=new Set(["import"]),Vg=new Set(["common","fixture","fixtures","helper","helpers","index","main","mock","mocks","setup","shared","spec","test","tests","types","util","utils"])});var hn,vo=d(()=>{"use strict";l();hn=class{isTestNode(e){return e.category==="test"||e.tags.some(n=>n.name==="test")}}});var Pc=d(()=>{"use strict";l();St();_n();Rr();jn();zn();Bt();Vt();qt();ve();Wt();Ur();Ht();qr();no();ro()});var wo=d(()=>{"use strict";l();Pc()});function Dc(t,e){return{identifier:e?.identifier??new hn,featureMap:e?.featureDetection===!1?new Map:de(t.nodes,e?.featureDetection??void 0)}}function Rc(t,e,n,r,o){for(let s of e){let i=t.nodes.get(s);if(!i)continue;let a=new fe(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 m=n.get(c.path);if(m)return r(m),!1}return o(c),!0},{direction:"incoming"})}}function Eo(t,e,n){let{identifier:r,featureMap:o}=Dc(t,n),s=new Set;for(let i of e){let a=o.get(i);a&&s.add(a.tag)}return Rc(t,e,o,i=>s.add(i.tag),i=>{if(r.isTestNode(i))for(let a of i.tags)s.add(a.name)}),Array.from(s)}function To(t,e,n){let{identifier:r,featureMap:o}=Dc(t,n),s=new Set;return Rc(t,e,o,()=>{},i=>{r.isTestNode(i)&&s.add(i.path)}),Array.from(s)}var Ic=d(()=>{"use strict";l();wo();vo()});var Ac=d(()=>{"use strict";l();Nc();vo();Ic()});import iT from"crypto";import Yg from"fs";import Qg from"os";import he from"path";async function _(t,e,n=null,r={}){let o=r.silent?void 0:a=>{process.stderr.write(`Processed ${a} files...\r`)},s=he.resolve(t);return await new pe(s,n,r.pathAliases?new K(s,{pathAliases:r.pathAliases}):void 0,o,r.gitStats??!1,r.coverageMap??new Map,r.parallelParsing??!0,r.additionalIgnoreDirs??[],r.docFiles??null).build(e)}function Xg(t){let e=Number.parseInt(process.env.MOKOSH_WORKSPACE_CONCURRENCY??"",10),n=Number.isFinite(e)&&e>0?e:Qg.cpus().length||1;return Math.max(1,Math.min(n,Math.max(1,t)))}function Zg(t,e,n){let r=new Map(e.map(s=>[s.name,[]])),o=[...e].sort((s,i)=>i.root.length-s.root.length);for(let s of n){if(!s.endsWith(".md")&&!s.endsWith(".mdx"))continue;let i=he.join(t,s),a=o.find(c=>i===c.root||i.startsWith(`${c.root}${he.sep}`));a&&r.get(a.name)?.push(i)}return r}async function Mc(t,e={}){let n=he.resolve(t),r=e.layout??to(n),o=e.projectFiles??O(n),s=e.additionalIgnoreDirs??[],i=e.packages?r.packages.filter(C=>e.packages?.includes(C.name)||e.packages?.includes(C.relativeRoot)):r.packages,a=new Map(r.packages.map(C=>[C.name,C.root])),c=new pt(n,r.type),p=new le(s),f=Zg(n,i,o),m=Xg(i.length),h=m>1?!1:e.parallelParsing??!0,y=new Array(i.length),b=0,v=async()=>{for(let C=b++;C<i.length;C=b++){let E=i[C],G=e.silent?void 0:F=>{process.stderr.write(`[${E.name}] Processed ${F} files...\r`)},S=new pe(n,e.previousWorkspace?.packages.get(E.name)?.graph??null,new K(n,{workspaceMap:a,tsconfigSearchPaths:[E.root,n],pathAliases:e.pathAliases,langResolvers:jt({jvm:p})}),G,e.gitStats??!1,new Map,h,s,f.get(E.name)??[]);y[C]=await S.build(E.entryPoints)}};return await Promise.all(Array.from({length:m},v)),i.forEach((C,E)=>{c.addPackage(C,y[E])}),c.annotateCrossPackageEdges(),c}function O(t,e={}){let n=[],r=new Set([...e.ignoreDirs??A,...e.additionalIgnoreDirs??[]]),o=new Set([...e.extensions??An,...e.additionalExtensions??[]]);function s(i){try{let a=Yg.readdirSync(i,{withFileTypes:!0});for(let c of a){let p=he.join(i,c.name);c.isDirectory()?r.has(c.name)||s(p):c.isFile()&&o.has(he.extname(c.name).toLowerCase())&&n.push(he.relative(t,p))}}catch{}}return s(t),n}var w=d(()=>{"use strict";l();In();j();os();is();St();_n();jn();zn();Ea();Bt();Vt();qt();Ot();ve();Ut();Ur();Na();Ht();qr();no();tn();ro();be();Ke();ic();Ac();j();wo();Dr()});var Fo=d(()=>{"use strict";l();j()});import mt from"path";import{parseArgs as eh}from"util";function th(t){for(let e=0;e<t.length;e++)if(t[e]==="--root"&&t[e+1])return mt.resolve(t[e+1]);return process.cwd()}function V(t){return t?parseInt(t,10):void 0}function Lc(t){return t?t.split(",").map(e=>e.trim()):void 0}function rh(t){let e=[];for(let n=0;n<t.length;n++){let r=t[n];if(r!==void 0)if(!r.startsWith("--"))e.push(r);else if(nh.has(r)){let o=t[n+1];o!==void 0&&!o.startsWith("--")&&(e.push(r,o),n++)}else r.slice(2)in No&&e.push(r)}return e}function oh(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 sh(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 ih(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 ah(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 Oc(t){let e=th(t),n=mt.join(mt.resolve(e,Q),Ce),{values:r,positionals:o}=eh({args:rh(t),allowPositionals:!0,options:No}),s=r.cache,i=r.config,a=r.metric,c=r;return{rootDir:e,cachePath:s?mt.resolve(e,s):n,configPath:i?mt.resolve(e,i):void 0,query:r.query,file:r.file,typeFilter:r.type,functionName:r.function,filterPaths:Lc(r.paths),featureThreshold:V(r["feature-threshold"]),minOutDegree:V(r["min-out-degree"]),...oh(c),...sh(c),help:t.length===0||(r.help??!1),...ih(c),changedSymbols:Lc(r["changed-symbols"]),depth:V(r.depth),...ah(c),metric:a==="complexity"||a==="cognitiveComplexity"?a:void 0,complexityThreshold:V(r["complexity-threshold"]),limit:V(r.limit),minDuplicateLines:V(r["min-duplicate-lines"]),includeGenerated:r["include-generated"]??!1,maxCoveragePct:V(r["max-coverage-pct"]),minChurn:V(r["min-churn"]),base:r.base,compareBranches:r["compare-branches"],compareFull:r["compare-full"]??!1,compareMaxItems:V(r["compare-max-items"]),entryPoints:o}}var No,nh,_c=d(()=>{"use strict";l();Fo();No={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"},"include-generated":{type:"boolean"},"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"},"compare-branches":{type:"string"},"compare-full":{type:"boolean"},"compare-max-items":{type:"string"}},nh=new Set(Object.entries(No).filter(([,t])=>t.type==="string").map(([t])=>`--${t}`))});async function Po(t){let{graph:e,file:n,testsOnly:r,changedSymbols:o,cached:s,withMeta:i}=t;n||(console.error("Error: --affected requires --file <path>"),process.exit(1));let a=f=>i?f.map(m=>({path:m,...me(e,m)})):f;if(s){let f=$n(e),m=Wn(f,n),h=r?m.filter(b=>e.nodes.get(b)?.category==="test"):m,y=a(h);console.log(JSON.stringify({file:n,affected:y,count:y.length},null,2));return}let c=Lr(e,n,{testsOnly:r,changedSymbols:o}),p=a(c);console.log(JSON.stringify({file:n,affected:p,count:p.length},null,2))}var Gc=d(()=>{"use strict";l();w()});import Do from"path";function ye(t){return t.filter(e=>{let n=Do.basename(e).toLowerCase();return ch.some(r=>n.includes(r))})}function yn(t,e){return new kt().getChangedFiles(t,e).map(n=>Do.relative(t,Do.resolve(t,n)))}var ch,xn=d(()=>{"use strict";l();Hn();ch=[".test.",".spec.","-test.","-spec."]});async function jc(t){let{graph:e}=t,{rootDir:n,scanOptions:r,featureThreshold:o,rawConfig:s,base:i}=t,a=yn(n,i);if(![...e.nodes.values()].some(f=>ye([f.path]).length>0)){let f=O(n,r);e=await _(n,ye(f),e,N(s))}let p=To(e,a,{...o!==void 0&&{featureDetection:{minOutDegree:o}}});console.log(p.join(`
|
|
54
|
-
`))}var
|
|
55
|
-
`):JSON.stringify({file:n,callers:i,count:i.length},null,2))}var
|
|
58
|
+
`;return`${l+h+f+i}
|
|
59
|
+
${u}`}}});import Vy from"path";function Zy(t){let e=Es.exec(t);return e?e[0].replace(/^\/\/ mokosh:tags /,"").trim().split(/\s*,\s*/).filter(Boolean):null}var Es,Qy,Yy,Xy,er,tp=d(()=>{"use strict";p();Es=/^\/\/ mokosh:tags .*\n/m,Qy=/^(?:sealed\s+|abstract\s+|final\s+|private\s+|implicit\s+|case\s+)*(?:class|object|trait)\s+\w+/m,Yy=/\/src\/(test|it)\//,Xy=/(Spec|Suite|Test|Props)\.scala$/;er=class{name="scalatest";canHandle(e){let n=e.replace(/\\/g,"/");return Vy.extname(n).toLowerCase()!==".scala"?!1:Yy.test(n)||Xy.test(n)}apply(e,n,r){let o=Zy(n),s=[...r].sort();if(o!==null&&JSON.stringify([...o].sort())===JSON.stringify(s))return n;if(r.length===0)return o===null?n:n.replace(Es,"");let i=`// mokosh:tags ${s.join(", ")}
|
|
60
|
+
`;if(o!==null)return n.replace(Es,i);let a=Qy.exec(n);return a?n.slice(0,a.index)+i+n.slice(a.index):n}}});import np from"path";import rp from"typescript";var qy,tr,op=d(()=>{"use strict";p();at();qy=/\/\/ <mokosh-tags>[\s\S]*?\/\/ <\/mokosh-tags>\n*/,tr=class{name="vitest";canHandle(e){return ee.has(np.extname(e).toLowerCase())}apply(e,n,r){let o=n.replace(qy,""),s=rp.createSourceFile(np.basename(e),o,rp.ScriptTarget.Latest,!0),i=ms(s),[a]=i;if(!a)return o;let c=ds(a,"tags",s),l=[...r].sort();if(c!==null&&JSON.stringify([...c].sort())===JSON.stringify(l))return o;let u=i.flatMap(f=>{let h=r.length===0?hs(f,"tags",s):gs(f,"tags",xs(l),s);return h?[h]:[]});return u.length>0?ys(o,u):o}}});import Ts from"path";import nr from"typescript";function tx(t){let e=nr.createSourceFile("detect.ts",t,nr.ScriptTarget.Latest,!0);for(let n of e.statements){if(!nr.isImportDeclaration(n)||!nr.isStringLiteral(n.moduleSpecifier))continue;let r=ex[n.moduleSpecifier.text];if(r)return r}return null}function ip(t="vitest",e={},n=process.cwd()){return[new Vn,new qn,new Qn,new Xn,new er,new Fs(n,t,Object.entries(e))]}function ap(t,e){return e.find(n=>n.canHandle(t))??null}var sp,ex,Fs,cp=d(()=>{"use strict";p();Ul();Hl();Jl();Vl();Ql();Zl();ql();ep();tp();at();op();sp={vitest:()=>new tr,playwright:()=>new Zn,cypress:()=>new Jn,jest:()=>new Yn},ex={"@playwright/test":"playwright",cypress:"cypress","@jest/globals":"jest",vitest:"vitest"};Fs=class{constructor(e,n,r){this.rootDir=e;this.defaultFramework=n;this.frameworkOverrides=r}rootDir;defaultFramework;frameworkOverrides;name="auto";canHandle(e){return ee.has(Ts.extname(e).toLowerCase())}apply(e,n,r){let o=tx(n)??this.matchOverride(e)??this.defaultFramework;return(sp[o]??sp.vitest)().apply(e,n,r)}matchOverride(e){let n=Ts.relative(this.rootDir,e).split(Ts.sep).join("/");for(let[r,o]of this.frameworkOverrides)if(Kl(r,n))return o;return null}}});import lp from"fs/promises";import nx from"path";async function rx(t,e,n,r){let o;try{o=await lp.readFile(t,"utf8")}catch(a){return{path:t,status:"error",error:String(a)}}let s=ap(t,r);if(!s)return{path:t,status:"unchanged"};let i=s.apply(t,o,e);return i===o?{path:t,status:"unchanged"}:(n||await lp.writeFile(t,i,"utf8"),{path:t,status:"updated"})}async function Ds(t,e,n){let r=Oe(e),o=r.tagApplier?.framework??"vitest",s=r.tagApplier?.frameworkOverrides??{},i=ip(o,s,e),a={updated:0,unchanged:0,errors:0,files:[]};for(let c of t.nodes.values()){if(c.category!=="test")continue;let l=new Set,u=[];for(let y of c.tags)ye(y)&&(l.has(y.name)||(l.add(y.name),u.push(y.name)));u.sort();let f=nx.resolve(e,c.path),h=await rx(f,u,n.dryRun,i);h.path=c.path,a.files.push(h),h.status==="updated"?a.updated++:h.status==="unchanged"?a.unchanged++:a.errors++}return a}var pp=d(()=>{"use strict";p();Er();xe();cp()});var rr,Ns=d(()=>{"use strict";p();rr=class{isTestNode(e){return e.category==="test"||e.tags.some(n=>n.name==="test")}}});var up=d(()=>{"use strict";p();Vt();Pr();wo();Ar();Mr();Rn();_n();On();$e();xn();Jo();An();ts();cs();ps()});var Ps=d(()=>{"use strict";p();up()});function fp(t,e){return{identifier:e?.identifier??new rr,featureMap:e?.featureDetection===!1?new Map:Pe(t.nodes,e?.featureDetection??void 0)}}function mp(t,e,n,r,o){for(let s of e){let i=t.nodes.get(s);if(!i)continue;let a=new Fe(s,["*",...i.exports.map(c=>c.name)]);t.traverse(s,(c,l,u)=>{if(!u)return!0;if(!a.updateAffectedSymbols(c,u))return!1;if(l>0){let f=n.get(c.path);if(f)return r(f),!1}return o(c),!0},{direction:"incoming"})}}function Rs(t,e,n){let{identifier:r,featureMap:o}=fp(t,n),s=new Set;for(let i of e){let a=o.get(i);a&&s.add(a.tag)}return mp(t,e,o,i=>s.add(i.tag),i=>{if(r.isTestNode(i))for(let a of Cr(i.tags))s.add(a)}),Array.from(s)}function As(t,e,n){let{identifier:r,featureMap:o}=fp(t,n),s=new Set;return mp(t,e,o,()=>{},i=>{r.isTestNode(i)&&s.add(i.path)}),Array.from(s)}var dp=d(()=>{"use strict";p();Ps();xe();Ns()});var gp=d(()=>{"use strict";p();pp();Ns();dp()});import vN from"crypto";import ox from"fs";import sx from"os";import Ae from"path";async function B(t,e,n=null,r={}){let o=r.silent?void 0:a=>{process.stderr.write(`Processed ${a} files...\r`)},s=Ae.resolve(t);return await new Te(s,n,r.pathAliases?new ie(s,{pathAliases:r.pathAliases}):void 0,o,r.gitStats??!1,r.coverageMap??new Map,r.parallelParsing??!0,r.additionalIgnoreDirs??[],r.docFiles??null).build(e)}function ix(t){let e=Number.parseInt(process.env.MOKOSH_WORKSPACE_CONCURRENCY??"",10),n=Number.isFinite(e)&&e>0?e:sx.cpus().length||1;return Math.max(1,Math.min(n,Math.max(1,t)))}function ax(t,e,n){let r=new Map(e.map(s=>[s.name,[]])),o=[...e].sort((s,i)=>i.root.length-s.root.length);for(let s of n){if(!s.endsWith(".md")&&!s.endsWith(".mdx"))continue;let i=Ae.join(t,s),a=o.find(c=>i===c.root||i.startsWith(`${c.root}${Ae.sep}`));a&&r.get(a.name)?.push(i)}return r}async function Ls(t,e={}){let n=Ae.resolve(t),r=e.layout??Lt(n),o=e.projectFiles??z(n),s=e.additionalIgnoreDirs??[],i=e.packages?r.packages.filter(k=>e.packages?.includes(k.name)||e.packages?.includes(k.relativeRoot)):r.packages,a=new Map(r.packages.map(k=>[k.name,k.root])),c=new It(n,r.type),l=new Ee(s),u=ax(n,i,o),f=ix(i.length),h=f>1?!1:e.parallelParsing??!0,y=new Array(i.length),b=0,v=async()=>{for(let k=b++;k<i.length;k=b++){let E=i[k],A=e.silent?void 0:N=>{process.stderr.write(`[${E.name}] Processed ${N} files...\r`)},G=new Te(n,e.previousWorkspace?.packages.get(E.name)?.graph??null,new ie(n,{workspaceMap:a,tsconfigSearchPaths:[E.root,n],pathAliases:e.pathAliases,langResolvers:hn({jvm:l})}),A,e.gitStats??!1,new Map,h,s,u.get(E.name)??[]);y[k]=await G.build(E.entryPoints)}};return await Promise.all(Array.from({length:f},v)),i.forEach((k,E)=>{c.addPackage(k,y[E])}),c.annotateCrossPackageEdges(),c}function z(t,e={}){let n=[],r=new Set([...e.ignoreDirs??$,...e.additionalIgnoreDirs??[]]),o=new Set([...e.extensions??Fr,...e.additionalExtensions??[]]);function s(i){try{let a=ox.readdirSync(i,{withFileTypes:!0});for(let c of a){let l=Ae.join(i,c.name);c.isDirectory()?r.has(c.name)||s(l):c.isFile()&&o.has(Ae.extname(c.name).toLowerCase())&&n.push(Ae.relative(t,l))}}catch{}}return s(t),n}var w=d(()=>{"use strict";p();Er();Y();mi();gi();Vt();Pr();Ar();Mr();ol();Rn();_n();On();mn();$e();Ln();Jo();al();An();ul();ts();cs();Bn();ps();_e();ht();zl();xe();gp();Y();Ps();vo()});var Is=d(()=>{"use strict";p();Y()});import _t from"path";import{parseArgs as cx}from"util";function lx(t){for(let e=0;e<t.length;e++)if(t[e]==="--root"&&t[e+1])return _t.resolve(t[e+1]);return process.cwd()}function J(t){return t?parseInt(t,10):void 0}function hp(t){return t?t.split(",").map(e=>e.trim()):void 0}function px(t){return t==="src"||t==="tests"||t==="all"?t:void 0}function fx(t){let e=[];for(let n=0;n<t.length;n++){let r=t[n];if(r!==void 0)if(!r.startsWith("--"))e.push(r);else if(ux.has(r)){let o=t[n+1];o!==void 0&&!o.startsWith("--")&&(e.push(r,o),n++)}else r.slice(2)in Ms&&e.push(r)}return e}function mx(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 dx(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 gx(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 hx(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 yp(t){let e=lx(t),n=_t.join(_t.resolve(e,ue),Ge),{values:r,positionals:o}=cx({args:fx(t),allowPositionals:!0,options:Ms}),s=r.cache,i=r.config,a=r.metric,c=r;return{rootDir:e,cachePath:s?_t.resolve(e,s):n,configPath:i?_t.resolve(e,i):void 0,query:r.query,file:r.file,packageName:r.package,typeFilter:r.type,functionName:r.function,filterPaths:hp(r.paths),featureThreshold:J(r["feature-threshold"]),minOutDegree:J(r["min-out-degree"]),...mx(c),...dx(c),help:t.length===0||(r.help??!1),...gx(c),changedSymbols:hp(r["changed-symbols"]),depth:J(r.depth),...hx(c),metric:a==="complexity"||a==="cognitiveComplexity"?a:void 0,complexityThreshold:J(r["complexity-threshold"]),limit:J(r.limit),minDuplicateLines:J(r["min-duplicate-lines"]),tagKind:r["tag-kind"],tagPrefix:r["tag-prefix"],tagMinCount:J(r["tag-min-count"]),tagLimit:J(r["tag-limit"]),dupQuery:r["dup-query"],dupSlim:!(r["dup-full"]??!1),includeGenerated:r["include-generated"]??!1,includeSameFile:r["include-same-file"]??!1,includeSvgMarkup:r["include-svg-markup"]??!1,includeDocs:r["include-docs"]??!1,duplicateScope:px(r.scope),maxCoveragePct:J(r["max-coverage-pct"]),minChurn:J(r["min-churn"]),base:r.base,compareBranches:r["compare-branches"],compareFull:r["compare-full"]??!1,compareMaxItems:J(r["compare-max-items"]),entryPoints:o}}var Ms,ux,xp=d(()=>{"use strict";p();Is();Ms={root:{type:"string"},cache:{type:"string"},config:{type:"string"},query:{type:"string"},file:{type:"string"},package:{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"},"tag-kind":{type:"string"},"tag-prefix":{type:"string"},"tag-min-count":{type:"string"},"tag-limit":{type:"string"},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"},"dup-query":{type:"string"},"dup-full":{type:"boolean"},"include-generated":{type:"boolean"},"include-same-file":{type:"boolean"},"include-svg-markup":{type:"boolean"},"include-docs":{type:"boolean"},scope:{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"},"compare-branches":{type:"string"},"compare-full":{type:"boolean"},"compare-max-items":{type:"string"}},ux=new Set(Object.entries(Ms).filter(([,t])=>t.type==="string").map(([t])=>`--${t}`))});async function _s(t){let{graph:e,file:n,testsOnly:r,changedSymbols:o,cached:s,withMeta:i}=t;n||(console.error("Error: --affected requires --file <path>"),process.exit(1));let a=u=>i?u.map(f=>({path:f,...De(e,f)})):u;if(s){let u=Lr(e),f=Ir(u,n),h=r?f.filter(b=>e.nodes.get(b)?.category==="test"):f,y=a(h);console.log(JSON.stringify({file:n,affected:y,count:y.length},null,2));return}let c=_o(e,n,{testsOnly:r,changedSymbols:o}),l=a(c);console.log(JSON.stringify({file:n,affected:l,count:l.length},null,2))}var bp=d(()=>{"use strict";p();w()});import Os from"path";function Le(t){return t.filter(e=>{let n=Os.basename(e).toLowerCase();return yx.some(r=>n.includes(r))})}function or(t,e){return new Xt().getChangedFiles(t,e).map(n=>Os.relative(t,Os.resolve(t,n)))}var yx,sr=d(()=>{"use strict";p();Or();yx=[".test.",".spec.","-test.","-spec."]});async function Sp(t){let{graph:e}=t,{rootDir:n,scanOptions:r,featureThreshold:o,rawConfig:s,base:i}=t,a=or(n,i);if(![...e.nodes.values()].some(u=>Le([u.path]).length>0)){let u=z(n,r);e=await B(n,Le(u),e,F(s))}let l=As(e,a,{...o!==void 0&&{featureDetection:{minOutDegree:o}}});console.log(l.join(`
|
|
61
|
+
`))}var kp=d(()=>{"use strict";p();w();sr()});async function Cp(t){let{graph:e,rootDir:n,entryPoints:r}=t,o=r.length?r:Dr(e,n);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=Nr(e,o);console.log(JSON.stringify(s,null,2))}var vp=d(()=>{"use strict";p();w()});async function wp(t){let{graph:e}=t,{rootDir:n,scanOptions:r,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=z(n,r);e=await B(n,Le(c),e,F(i))}let a=await Ds(e,n,{dryRun:o});console.log(JSON.stringify(a,null,2))}var Ep=d(()=>{"use strict";p();w();sr()});async function Tp(t){let{graph:e,functionName:n}=t;n||(console.error("Error: --call-graph requires --function <name>"),process.exit(1));let r=Rr(e,n);console.log(JSON.stringify(r,null,2))}var Fp=d(()=>{"use strict";p();w()});async function Gs(t){let{graph:e,file:n,plain:r,depth:o,withEdgeDetail:s}=t;n||(console.error("Error: --callers requires --file <path>"),process.exit(1));let i=Oo(e,n,{depth:o??1,withEdgeDetail:s});console.log(r?i.map(a=>a.file).join(`
|
|
62
|
+
`):JSON.stringify({file:n,callers:i,count:i.length},null,2))}var Dp=d(()=>{"use strict";p();w()});async function js(t){let{graph:e}=t,n=e.findCycles();if(n.length>0){process.stderr.write(`Found ${n.length} cycle(s):
|
|
56
63
|
`);for(let r of n)process.stderr.write(` ${r.join(" \u2192 ")}
|
|
57
|
-
`);process.exit(1)}console.log("No cycles detected.")}var
|
|
64
|
+
`);process.exit(1)}console.log("No cycles detected.")}var Np=d(()=>{"use strict";p()});async function $s(t){let{graph:e}=t;if(!$o(e)){process.stderr.write(`Warning: no git-stats data \u2014 rebuild with --git-stats (or config equivalent). Doc drift cannot be detected.
|
|
65
|
+
`),console.log("No doc drift detected.");return}let n=[...e.nodes.values()].filter(r=>r.type==="markdown"&&r.staleFor&&r.staleFor.length>0).map(r=>({doc:r.path,staleFor:r.staleFor}));if(n.length>0){process.stderr.write(`Found ${n.length} doc(s) that may be out of date:
|
|
58
66
|
`);for(let{doc:r,staleFor:o}of n)process.stderr.write(` ${r} \u2014 references changed more recently: ${o.join(", ")}
|
|
59
|
-
`);process.exit(1)}console.log("No doc drift detected.")}var
|
|
60
|
-
`):JSON.stringify({name:n,matches:o,count:o.length},null,2))}var
|
|
61
|
-
`):JSON.stringify({threshold:s,uncovered:i,count:i.length},null,2))}var
|
|
62
|
-
`):JSON.stringify(
|
|
67
|
+
`);process.exit(1)}console.log("No doc drift detected.")}var Pp=d(()=>{"use strict";p();w()});import ir from"fs";import Ws from"path";function Rp(t){let e=Ws.dirname(t),n=Ws.join(e,be),r=Ws.join(e,ft),o=!1;for(let s of[t,n])ir.existsSync(s)&&(ir.unlinkSync(s),console.log(`Cache cleared: ${s}`),o=!0);ir.existsSync(r)&&(ir.rmSync(r,{recursive:!0,force:!0}),console.log(`Cache cleared: ${r}`),o=!0),o||console.log(`No cache file present at ${t}`)}var Ap=d(()=>{"use strict";p();w()});async function Lp(t){let{graph:e,rootDir:n,compareBranches:r,rawConfig:o}=t;if(!r){console.error("Error: --compare-branches requires a base ref, e.g. --compare-branches main"),process.exit(1);return}let s=await Ho(n,r,e,{entryPoints:t.entryPoints,minDuplicateLines:t.minDuplicateLines,complexityMetric:t.metric,complexityThreshold:t.complexityThreshold,maxCoveragePct:t.maxCoveragePct,...F(o)}),i=t.compareFull?s:Uo(s,{metric:t.metric,maxItems:t.compareMaxItems});console.log(JSON.stringify(i,null,2))}var Ip=d(()=>{"use strict";p();w()});async function zs(t){let{graph:e,file:n,depth:r,withMeta:o}=t;n||(console.error("Error: --dependencies requires --file <path>"),process.exit(1));let s=Mo(e,n,r??1),i=o?s.map(a=>({...a,...De(e,a.path)})):s;console.log(JSON.stringify({file:n,dependencies:i},null,2))}var Mp=d(()=>{"use strict";p();w()});async function Bs(t){let{graph:e,file:n,withMeta:r}=t;n||(console.error("Error: --dependents requires --file <path>"),process.exit(1));let o=Dt(e,n),s=r?o.map(i=>({...i,...De(e,i.path)})):o;console.log(JSON.stringify({file:n,dependents:s},null,2))}var _p=d(()=>{"use strict";p();w()});async function Op(t){let{graph:e}=t,{rootDir:n,scanOptions:r,featureThreshold:o,rawConfig:s}=t;if(e.nodes.size===0){let c=z(n,r);e=await B(n,c,e,F(s))}let i=Pe(e.nodes,o!==void 0?{minOutDegree:o}:void 0),a=Array.from(i.values()).sort((c,l)=>l.outDegree-c.outDegree);console.log(JSON.stringify({features:a},null,2))}var Gp=d(()=>{"use strict";p();w()});async function jp(t){let{graph:e}=t,{rootDir:n,scanOptions:r,minOutDegree:o,rawConfig:s}=t;if(e.nodes.size===0){let c=z(n,r);e=await B(n,c,e,F(s))}let i=Nt(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 $p=d(()=>{"use strict";p();w()});async function Us(t){let{graph:e,metric:n,complexityThreshold:r,limit:o}=t,s=r??10,i=rt(e,{metric:n,threshold:s,limit:o});console.log(JSON.stringify({metric:n??"cognitiveComplexity",threshold:s,functions:i,count:i.length},null,2))}var Wp=d(()=>{"use strict";p();w()});import ar from"path";async function Hs(t){let{graph:e,rootDir:n,scanOptions:r,minDuplicateLines:o,includeGenerated:s,includeSameFile:i,includeSvgMarkup:a,includeDocs:c,duplicateScope:l,dupQuery:u,dupSlim:f,limit:h,cachePath:y}=t,b=o??6,v=[...r.ignoreDirs??$,...r.additionalIgnoreDirs??[]],k=ar.join(ar.dirname(y),be),E=Ze(k),A=u?Xe(u):void 0,G=A?Number.MAX_SAFE_INTEGER:h,N={minLines:b,limit:G,ignoreDirs:v,includeGenerated:s||t.rawConfig.duplication?.includeGenerated||!1,includeSameFile:i||t.rawConfig.duplication?.includeSameFile||!1,includeSvgMarkup:a||t.rawConfig.duplication?.includeSvgMarkup||!1,includeDocs:c||t.rawConfig.duplication?.includeDocs||!1,scope:l??t.rawConfig.duplication?.scope,ignoreGlobs:t.rawConfig.duplication?.ignoreGlobs??[]},U=ar.join(ar.dirname(y),Tr),ct={minLines:b,ignoreLiterals:!0,maxPunctuationRatio:.5,limit:h??50,scope:N.scope,includeGenerated:N.includeGenerated,includeSameFile:N.includeSameFile,includeSvgMarkup:N.includeSvgMarkup,includeDocs:N.includeDocs,ignoreDirs:v,ignoreGlobs:N.ignoreGlobs},te=A===void 0,V=te?vn(e.nodes.values()):"",ce=te?wn(ct):"",Ie=te?En(U,V,ce):null,j,H;Ie?{groups:j,clusters:H}=Ie:({groups:j,clusters:H}=await nt(e,n,{...N,...u!==void 0&&{filter:u},tokenCache:E}),qe(E,k),te&&Tn(U,V,ce,j,H));let Gt=Fn(j),pr=A?.limit??h??50,lt=A?Sn(j,{...A,limit:pr}):j,jt=H.slice(0,pr),he=f?lt.map(Nn):lt,S=f?jt.map(Pn):jt;console.log(JSON.stringify({minLines:b,...u!==void 0&&{filter:u},summary:Gt,groups:he,count:he.length,clusters:S},null,2))}var zp=d(()=>{"use strict";p();w()});async function Ks(t){let{graph:e,metric:n,complexityThreshold:r,maxCoveragePct:o,minChurn:s,limit:i}=t;if(!ge(e)){console.log(JSON.stringify({error:"No coverage data available. Set coverageReportPath in mokosh.config and rebuild the graph."},null,2));return}let a=r??10,c=o??50,l=s??0,{hotspots:u,count:f,churnDataAvailable:h}=ot(e,{metric:n,minComplexity:a,maxCoveragePct:c,minChurn:l,limit:i});console.log(JSON.stringify({metric:n??"cognitiveComplexity",minComplexity:a,maxCoveragePct:c,minChurn:l,churnDataAvailable:h,hotspots:u,count:f},null,2))}var Bp=d(()=>{"use strict";p();w()});async function Up(t){let{graph:e,functionName:n,plain:r}=t;n||(console.error("Error: --find-symbol requires --function <name>"),process.exit(1));let o=Vo(e,n);console.log(r?o.map(s=>s.path).join(`
|
|
68
|
+
`):JSON.stringify({name:n,matches:o,count:o.length},null,2))}var Hp=d(()=>{"use strict";p();w()});async function Js(t){let{graph:e,featureThreshold:n,rawConfig:r,plain:o}=t,s=n??r.coverageThreshold??80;if(!ge(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(`
|
|
69
|
+
`):JSON.stringify({threshold:s,uncovered:i,count:i.length},null,2))}var Kp=d(()=>{"use strict";p();w()});import xx from"path";function Sx(t){let e=xx.basename(t).toLowerCase();return bx.some(n=>e.includes(n))}async function Jp(t){let{graph:e,rootDir:n,scanOptions:r,excludeTests:o}=t,s=z(n,r),i=e.findUnusedFiles(s);o&&(i=i.filter(a=>!Sx(a))),console.log(JSON.stringify({unusedFiles:i},null,2))}var bx,Vp=d(()=>{"use strict";p();w();bx=[".test.",".spec.","-test.","-spec.",".stories."]});async function Vs(t){let{graph:e,packageOf:n,queryStr:r,mermaidOutput:o,slim:s}=t,i=e.serialize();if(r){let l=Hn(r);i=Un(i,l,{packageOf:n})}if(o){let l=_.deserialize(i);console.log(Jt.serialize(l));return}let a=e.findCycles();a.length>0&&(i.cycles=a);let c=fo(e);console.log(JSON.stringify(s?{...Go(i),languageCoverage:c}:{...i,languageCoverage:c},null,2))}var Qp=d(()=>{"use strict";p();w()});import kx from"fs";import Qs from"path";function cr(t,e,n){let r=t;for(let o=0;o<6;o++){let s=Qs.join(r,"templates",...e);if(kx.existsSync(Qs.join(s,n)))return s;let i=Qs.dirname(r);if(i===r)break;r=i}throw new Error(`Could not locate mokosh templates/${e.join("/")}`)}var Ys=d(()=>{"use strict";p()});import Yp from"fs";import Xp from"path";function Zp(t,e=process.cwd()){let n=cr(m,["config"],"mokosh.config.js"),r=Xp.join(n,"mokosh.config.js"),o=Xp.join(e,"mokosh.config.js");if(Yp.existsSync(o)&&!t){console.log("skipped mokosh.config.js (already exists, use --force to overwrite)");return}Yp.copyFileSync(r,o),console.log("wrote mokosh.config.js")}var qp=d(()=>{"use strict";p();Ys()});import Xs from"fs";import lr from"path";function eu(t,e=process.cwd()){let n=cr(m,["skill"],"SKILL.md");for(let r of Cx){let o=lr.join(n,r.templateFile),s=lr.join(e,...r.destPath),i=lr.join(...r.destPath);if(Xs.existsSync(s)&&!t){console.log(`skipped ${i} (already exists, use --force to overwrite)`);continue}Xs.mkdirSync(lr.dirname(s),{recursive:!0}),Xs.copyFileSync(o,s),console.log(`wrote ${i}`)}}var Cx,tu=d(()=>{"use strict";p();Ys();Cx=[{templateFile:"SKILL.md",destPath:[".claude","skills","mokosh","SKILL.md"]},{templateFile:"mokosh.md",destPath:[".claude","commands","mokosh.md"]}]});async function Zs(t){let{graph:e,plain:n,tagKind:r,tagPrefix:o,tagMinCount:s,tagLimit:i}=t,a=Zo(Xo([e]),{kind:r,prefix:o,minCount:s,limit:i});console.log(n?a.tags.map(c=>c.name).join(`
|
|
70
|
+
`):JSON.stringify(a,null,2))}var nu=d(()=>{"use strict";p();w()});async function ru(t){let{graph:e,filterPaths:n,minOutDegree:r}=t,o=Ko(e,r!==void 0?{minOutDegree:r}:void 0);if(n?.length){let s=n.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 ou=d(()=>{"use strict";p();w()});async function su(t){let{graph:e}=t,{rootDir:n,scanOptions:r,featureThreshold:o,plain:s,rawConfig:i,base:a}=t;s||console.log("Proposing test tags based on git diff...");let c=or(n,a);if(e.nodes.size===0){let u=z(n,r);e=await B(n,Le(u),e,F(i))}let l=Rs(e,c,{...o!==void 0&&{featureDetection:{minOutDegree:o}}});console.log(s?l.join(" "):JSON.stringify({proposedTags:l},null,2))}var iu=d(()=>{"use strict";p();w();sr()});async function au(t){let{graph:e,typeFilter:n}=t,r=qo(e);if(n){let o=es(r,n);console.log(JSON.stringify(o,null,2))}else{let o=Array.from(r.types.values());console.log(JSON.stringify({count:o.length,types:o},null,2))}}var cu=d(()=>{"use strict";p();w()});function lu(t,e){let n=t.getAffectedAcrossPackages(e);console.log(JSON.stringify({file:e,affected:n,count:n.length},null,2))}var pu=d(()=>{"use strict";p()});function uu(t){console.log(JSON.stringify(jo(t),null,2))}var fu=d(()=>{"use strict";p();w()});import qs from"path";function vx(t,e,n,r){return t!==e?t:n?qs.resolve(r,n):e}function mu(t){let{rootDir:e,entryPoints:n,cachePath:r,configPath:o}=t,s=o?Oe(o,{isExplicitPath:!0}):Oe(e),i=qs.join(qs.resolve(e,ue),Ge),a=n.length>0?n:s.entryPoints??[],c=vx(r,i,s.cachePath,e),l={...s.ignoreDirs!==void 0&&{additionalIgnoreDirs:s.ignoreDirs},...s.extensions!==void 0&&{additionalExtensions:s.extensions}};return{rootDir:e,resolvedEntryPoints:a,resolvedCachePath:c,scanOptions:l,rawConfig:s}}var du=d(()=>{"use strict";p();w();Is()});import Ot from"fs";import wx from"path";function gu(t){if(!Ot.existsSync(t))return null;let e=Ot.readFileSync(t,"utf-8");return _.deserialize(JSON.parse(e))}function ei(t,e){let n=wx.dirname(e);Ot.existsSync(n)||Ot.mkdirSync(n,{recursive:!0}),Ot.writeFileSync(e,JSON.stringify(t.serialize(),null,2))}async function ti(t,e,n,r={silent:!1,...F(void 0)}){return B(t,e,n,r)}var hu=d(()=>{"use strict";p();w()});var yu,xu,bu=d(()=>{"use strict";p();yu=`
|
|
63
71
|
Usage: mokosh [options] <entry-point1> <entry-point2> ...
|
|
64
72
|
|
|
65
73
|
Options:
|
|
@@ -79,10 +87,19 @@ Options:
|
|
|
79
87
|
--find-unused Find files that are not reachable from entry points
|
|
80
88
|
--exclude-tests Exclude test files from --find-unused output
|
|
81
89
|
--find-uncovered List non-test files whose coverage is below the threshold (requires coverageReportPath in config)
|
|
82
|
-
--list-tags
|
|
83
|
-
|
|
90
|
+
--list-tags Bounded tag inventory (always <=250 tags): by default the
|
|
91
|
+
query-meaningful kinds (comment-marker, import) with count>=2,
|
|
92
|
+
top 50, plus a byKind histogram. Use --plain for a bare name list
|
|
93
|
+
--tag-kind <k|all> --list-tags: restrict to one kind (comment-marker|import|function|
|
|
94
|
+
variable|library) or all
|
|
95
|
+
--tag-prefix <s> --list-tags: case-insensitive substring match on the tag name
|
|
96
|
+
--tag-min-count <N> --list-tags: min node count per tag (default: 2)
|
|
97
|
+
--tag-limit <N> --list-tags: max tags to print (default: 50; hard-capped at 250)
|
|
84
98
|
--callers List files whose exported functions call into --file
|
|
85
99
|
--file <path> Target file for --callers/--dependencies/--dependents/--affected/--workspace-affected
|
|
100
|
+
--package <name> On a monorepo root (with no entry points given): narrow every
|
|
101
|
+
command to this one package. Omit to run across the whole
|
|
102
|
+
flattened workspace (see --workspace-packages for the names)
|
|
86
103
|
--check-cycles Check for circular dependencies; exits non-zero if found (CI gate)
|
|
87
104
|
--check-doc-drift Flag markdown docs whose referenced files changed more recently
|
|
88
105
|
than the doc itself; exits non-zero if found (CI gate; requires
|
|
@@ -132,6 +149,23 @@ MCP parity (mirrors the MCP server's tools for use when MCP is unavailable):
|
|
|
132
149
|
--include-generated Scan generated / vendored files too (protobuf output, *.generated.*,
|
|
133
150
|
generated/ & __snapshots__/ dirs, *.snap, @generated-marked
|
|
134
151
|
files); use with --find-duplicates
|
|
152
|
+
--include-same-file Include matches where every occurrence is in one file (default:
|
|
153
|
+
excluded \u2014 usually a file's own repetitive shape, not copy-paste);
|
|
154
|
+
use with --find-duplicates
|
|
155
|
+
--include-svg-markup Include matches whose occurrences are all inline SVG / SVG-shaped
|
|
156
|
+
JSX markup (default: excluded \u2014 two different icons share a
|
|
157
|
+
literal-normalized skeleton); use with --find-duplicates
|
|
158
|
+
--include-docs Include markdown-family matches (default: excluded \u2014 mirrored
|
|
159
|
+
prose docs, README \u2194 *.mdx); use with --find-duplicates
|
|
160
|
+
--scope <src|tests|all> Which duplicates to surface by test-file involvement (default:
|
|
161
|
+
src \u2014 drops test clusters). tests = only substantive shared
|
|
162
|
+
test-logic clusters; all = everything. Use with --find-duplicates
|
|
163
|
+
--dup-query "<k:v,...>" Filter --find-duplicates results (AND across keys): path / allPaths
|
|
164
|
+
/ family / type / kind / defKind / minLines / maxLines / minScore
|
|
165
|
+
/ maxScore / minOccurrences / crossFile / signal, plus sort
|
|
166
|
+
(lines|score|occurrences) / sortDir / limit. Unknown keys error.
|
|
167
|
+
--dup-full Print full --find-duplicates groups/clusters (source text +
|
|
168
|
+
per-occurrence metadata). Default is the compact shape.
|
|
135
169
|
--find-risk-hotspots List functions that are complex, undertested, and (if gitStats is
|
|
136
170
|
enabled) frequently changed \u2014 requires coverageReportPath in config
|
|
137
171
|
--max-coverage-pct <N> Max file coverage % to include (default: 50, use with --find-risk-hotspots)
|
|
@@ -162,9 +196,13 @@ Notes:
|
|
|
162
196
|
pass/fail exit code, is useful to an AI assistant deciding which docs to fix.
|
|
163
197
|
--config files may be .js/.cjs and are executed for CLI convenience (allowJs: true); the MCP
|
|
164
198
|
server only loads JSON config (allowJs: false) for security. This is intentional.
|
|
165
|
-
--workspace-packages/--workspace-affected require explicit opt-in
|
|
166
|
-
|
|
167
|
-
|
|
199
|
+
--workspace-packages/--workspace-affected require explicit opt-in and build a WorkspaceGraph
|
|
200
|
+
directly. Every other command, given no entry points on a detected monorepo root, runs against
|
|
201
|
+
the whole workspace flattened into one Graph (WorkspaceGraph.flatten() \u2014 every package's own
|
|
202
|
+
nodes in one namespace, cross-package edges intact), so blast radius, call graphs and --query
|
|
203
|
+
span package boundaries and results report each node's package. Pass --package <name> to narrow
|
|
204
|
+
to one package, or --entry explicitly for whole-repo-from-these-entry-points behavior.
|
|
205
|
+
`,xu=`
|
|
168
206
|
Query filter reference (--query "key:value,key:value,...")
|
|
169
207
|
All keys are case-insensitive. Multiple keys are AND'd together.
|
|
170
208
|
|
|
@@ -187,6 +225,11 @@ FILTERING
|
|
|
187
225
|
path:<substr> File path contains substring. Negate with !.
|
|
188
226
|
Examples: path:src/api path:!__tests__
|
|
189
227
|
|
|
228
|
+
package:<value> Exact match on the owning workspace package name. Negate with !.
|
|
229
|
+
Monorepo roots only \u2014 on a monorepo, --query runs across the whole
|
|
230
|
+
workspace and every node reports its package; elsewhere this is a no-op.
|
|
231
|
+
Examples: package:@org/app package:!@org/legacy
|
|
232
|
+
|
|
190
233
|
external:<bool> true = node has at least one external (node_modules) import.
|
|
191
234
|
Example: external:true
|
|
192
235
|
|
|
@@ -287,5 +330,5 @@ COMMON PATTERNS
|
|
|
287
330
|
|
|
288
331
|
Large TypeScript logic files:
|
|
289
332
|
--query "type:typescript,category:logic,sort:size,limit:5"
|
|
290
|
-
`});var
|
|
333
|
+
`});var Su,ku=d(()=>{"use strict";p();Su=/(?:^|[/\\])(?:node_modules|\.git|dist|build|coverage)(?:[/\\]|$)/});import Ex from"fs";function Cu(t,e,n){let r=null,o=!1,s=!1,i=async()=>{if(o){s=!0;return}o=!0;try{await n()}finally{o=!1,s&&(s=!1,i())}};i();let a=null;try{a=Ex.watch(t,{recursive:!0},(c,l)=>{!l||Su.test(l)||(r&&clearTimeout(r),r=setTimeout(()=>{i()},e))})}catch(c){console.error(`Warning: unable to watch ${t}: ${c.message}`)}process.on("SIGINT",()=>{r&&clearTimeout(r),a?.close(),process.exit(0)})}var vu=d(()=>{"use strict";p();ku()});function Fx(t){t.help&&(console.log(yu),process.exit(0)),t.queryHelp&&(console.log(xu),process.exit(0)),t.initSkill&&(eu(t.force),process.exit(0)),t.initConfig&&(Zp(t.force),process.exit(0)),t.clearCache&&(Rp(t.cachePath),process.exit(0))}async function Dx(t,e,n){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 r=await Ls(n,F(e.rawConfig));return t.workspacePackages?uu(r):(t.file||(console.error("Error: --workspace-affected requires --file <path>"),process.exit(1)),lu(r,t.file)),!0}async function Nx(t,e,n){let r=await Ls(n,F(e.rawConfig));if(t.packageName){let o=r.packages.get(t.packageName);return o||(console.error(`Error: unknown package "${t.packageName}". Run --workspace-packages to list packages.`),process.exit(1)),{graph:o.graph,packageOf:new Map}}return t.file&&!r.getPackageForFile(t.file)&&(console.error(`Error: no workspace package owns "${t.file}".`),process.exit(1)),r.flatten()}function Px(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||!!t.compareBranches}function Rx(t){let n=[{name:"--propose-tags",flag:t.proposeTags,handler:su},{name:"--apply-tags",flag:t.applyTags,handler:wp},{name:"--affected-tests",flag:t.affectedTests,handler:Sp},{name:"--detect-features",flag:t.detectFeatures,handler:Op},{name:"--find-unused",flag:t.findUnused,handler:Jp},{name:"--check-cycles",flag:t.checkCycles,handler:js},{name:"--check-doc-drift",flag:t.checkDocDrift,handler:$s},{name:"--find-uncovered",flag:t.findUncovered,handler:Js},{name:"--list-tags",flag:t.listTags,handler:Zs},{name:"--callers",flag:t.callers,handler:Gs},{name:"--dependencies",flag:t.dependencies,handler:zs},{name:"--dependents",flag:t.dependents,handler:Bs},{name:"--affected",flag:t.affected,handler:_s},{name:"--find-complex-functions",flag:t.findComplexFunctions,handler:Us},{name:"--find-duplicates",flag:t.findDuplicates,handler:Hs},{name:"--find-risk-hotspots",flag:t.findRiskHotspots,handler:Ks},{name:"--type-graph",flag:t.typeGraph,handler:au},{name:"--module-responsibility",flag:t.moduleResponsibility,handler:ru},{name:"--feature-graph",flag:t.featureGraph,handler:jp},{name:"--call-graph",flag:t.callGraph,handler:Tp},{name:"--find-symbol",flag:t.findSymbol,handler:Up},{name:"--api-surface",flag:t.apiSurface,handler:Cp},{name:"--compare-branches",flag:!!t.compareBranches,handler:Lp}].filter(r=>r.flag);return n.length>1&&(console.error(`Error: conflicting flags: ${n.map(r=>r.name).join(", ")} (pass only one command flag)`),process.exit(1)),n[0]?.handler??Vs}async function Ax(t,e,n,r,o,s,i){Tx.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)),Cu(n,300,async()=>{let a=await ti(n,r,e.graph,{silent:s,...F(i)});ei(a,o),console.log(`--- rebuilt at ${new Date().toISOString()} ---`),await t({...e,graph:a})})}async function wu(){let t=process.argv.slice(2),e=yp(t);Fx(e);let n=mu(e);wr(n.rawConfig);let{rootDir:r,resolvedEntryPoints:o,resolvedCachePath:s,scanOptions:i}=n;if(await Dx(e,n,r))return;let a=Px(e),c=o.length===0&&Lt(r).type!=="none",l,u=new Map;c?(e.watch&&(console.error("Error: --watch is not supported on a monorepo root (use --package/--file with a single package instead)"),process.exit(1)),{graph:l,packageOf:u}=await Nx(e,n,r)):(l=gu(s)??new _(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)),l=await ti(r,o,l,{silent:e.silent,...F(n.rawConfig)}),ei(l,s)));let f={graph:l,packageOf:u,rootDir:r,cachePath:s,entryPoints:o.map(y=>y.replace(`${r}/`,"")),scanOptions:i,rawConfig:n.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,tagKind:e.tagKind,tagPrefix:e.tagPrefix,tagMinCount:e.tagMinCount,tagLimit:e.tagLimit,minDuplicateLines:e.minDuplicateLines,dupQuery:e.dupQuery,dupSlim:e.dupSlim,includeGenerated:e.includeGenerated,includeSameFile:e.includeSameFile,includeSvgMarkup:e.includeSvgMarkup,includeDocs:e.includeDocs,duplicateScope:e.duplicateScope,maxCoveragePct:e.maxCoveragePct,minChurn:e.minChurn,base:e.base,compareBranches:e.compareBranches,compareFull:e.compareFull,compareMaxItems:e.compareMaxItems},h=Rx(e);if(e.watch){await Ax(h,f,r,o,s,e.silent,n.rawConfig);return}await h(f)}var Tx,Eu=d(()=>{"use strict";p();w();xp();bp();kp();vp();Ep();Fp();Dp();Np();Pp();Ap();Ip();Mp();_p();Gp();$p();Wp();zp();Bp();Hp();Kp();Vp();Qp();qp();tu();nu();ou();iu();cu();pu();fu();du();hu();bu();vu();Tx=new Set([Vs,Gs,zs,Bs,_s,Js,Us,Hs,Ks,js,$s,Zs])});var Lx=Fu(()=>{p();Eu();wu().catch(t=>{console.error(t),process.exit(1)})});export default Lx();
|
|
291
334
|
//# sourceMappingURL=cli.mjs.map
|