effect-analyzer 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +2 -2
- package/dist/effect-workflow.cjs +1 -1
- package/dist/effect-workflow.cjs.map +1 -1
- package/dist/effect-workflow.js +1 -1
- package/dist/effect-workflow.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lsp/server.js +1 -1
- package/package.json +37 -18
package/dist/cli.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import{resolve as ze,sep as jl,join as Nt,dirname as Sr,extname as Bl}from"path";import{watch as ql,existsSync as zl}from"fs";import*as pe from"fs/promises";import{Project as en}from"ts-morph";import{spawn as _l}from"child_process";import{fileURLToPath as Hl}from"url";import{Effect as k,Console as D,Exit as Ce,Option as tn}from"effect";import{Effect as X,Option as Pt}from"effect";import{Option as B}from"effect";var Se=class extends Error{code;location;constructor(t,r,s){super(r),this.code=t,this.location=s,this.name="AnalysisError"}};var Er=e=>e.type==="unknown";var P=e=>{switch(e.type){case"program":return B.some(e.children);case"generator":return B.some(e.yields.map(t=>t.effect));case"pipe":return B.some([e.initial,...e.transformations]);case"parallel":case"race":return B.some([...e.children]);case"error-handler":return B.some(e.handler?[e.source,e.handler]:[e.source]);case"retry":{let t=e,r=[t.source,t.scheduleNode].filter(s=>s!==void 0);return r.length>0?B.some(r):B.none()}case"timeout":{let t=e.source;return t?B.some([t]):B.none()}case"resource":return B.some(e.use?[e.acquire,e.release,e.use]:[e.acquire,e.release]);case"conditional":return B.some(e.onFalse?[e.onTrue,e.onFalse]:[e.onTrue]);case"loop":return B.some([e.body]);case"cause":return e.children&&e.children.length>0?B.some(e.children):B.none();case"exit":case"schedule":case"match":return B.none();case"transform":return e.source?B.some([e.source]):B.none();case"layer":return B.some([...e.operations]);case"stream":return B.some([e.source]);case"channel":return e.source?B.some([e.source]):B.none();case"sink":return e.source?B.some([e.source]):B.none();case"concurrency-primitive":return e.source?B.some([e.source]):B.none();case"fiber":return e.fiberSource?B.some([e.fiberSource]):B.none();case"interruption":{let t=[];return e.source&&t.push(e.source),e.handler&&t.push(e.handler),t.length>0?B.some(t):B.none()}case"effect":return e.callbackBody&&e.callbackBody.length>0?B.some([...e.callbackBody]):B.none();case"decision":return B.some([...e.onTrue,...e.onFalse??[]]);case"switch":return B.some(e.cases.flatMap(t=>[...t.body]));case"try-catch":return B.some([...e.tryBody,...e.catchBody??[],...e.finallyBody??[]]);case"terminal":return e.value?B.some([...e.value]):B.none();case"opaque":return B.none();default:return B.none()}};import{Effect as Re}from"effect";import{createRequire as Bi}from"module";var rn=null,br=new Map,w=()=>{if(!rn)try{rn=Bi(import.meta.url)("ts-morph")}catch{throw new Error("ts-morph is required but not installed. Please install it as a peer dependency: npm install ts-morph")}return rn},Nr=e=>{let t=e??"__default__",r=br.get(t);if(r)return r;let{Project:s}=w(),n={};e&&(n.tsConfigFilePath=e);let i=new s(n);return br.set(t,i),i};var Cr=(e,t="temp.ts")=>{let{Project:r}=w();return new r({useInMemoryFileSystem:!0,compilerOptions:{strict:!0,esModuleInterop:!0}}).createSourceFile(t,e)};import{Option as vr}from"effect";var qi=/Effect(?:\.Effect)?<([^,]+),\s*([^,]+),\s*([^>]+)>/,zi=/Effect(?:\.Effect)?<([^,>]+),\s*([^,>]+)>/;function on(e){let t=n=>n.replace(/import\([^)]+\)\./g,"").replace(/typeof\s+/g,"").trim().substring(0,200),r=qi.exec(e);if(r)return{successType:t(r[1]),errorType:t(r[2]),requirementsType:t(r[3]),isInferred:!1,typeConfidence:"inferred",rawTypeString:e};let s=zi.exec(e);if(s)return{successType:t(s[1]),errorType:t(s[2]),requirementsType:"never",isInferred:!1,typeConfidence:"inferred",rawTypeString:e}}var Ze=(e,t)=>{let r;try{r=e.getType()}catch{return}if(!Hi(r))return;let s=Ct(r);if(s){let[o,a,d]=s;return{successType:$e(o),errorType:$e(a),requirementsType:$e(d),isInferred:!0,typeConfidence:"declared",rawTypeString:r.getText()}}let n=r.getText(),i=on(n);if(i)return i;let c=_i(e);return c||{successType:"unknown",errorType:"never",requirementsType:"never",isInferred:!1,typeConfidence:"unknown",rawTypeString:n}};function _i(e){try{if(!("getExpression"in e))return;let r=e.getExpression(),n=r.getType().getCallSignatures();if(n.length>0){let c=n[0].getReturnType(),o=Ct(c);if(o){let[l,f,u]=o;return{successType:$e(l),errorType:$e(f),requirementsType:$e(u),isInferred:!0,typeConfidence:"inferred",rawTypeString:c.getText()}}let a=c.getText(),d=on(a);if(d)return d}let i=r.getSymbol();if(!i)return;for(let c of i.getDeclarations()){let o;if("getReturnType"in c)o=c.getReturnType().getText();else if("getType"in c){let d=c.getType().getCallSignatures();if(d.length>0){let l=d[0].getReturnType(),f=Ct(l);if(f){let[u,g,p]=f;return{successType:$e(u),errorType:$e(g),requirementsType:$e(p),isInferred:!0,typeConfidence:"inferred",rawTypeString:l.getText()}}o=l.getText()}}if(o){let a=on(o);if(a)return{...a,typeConfidence:"inferred"}}}}catch{}}var Hi=e=>{let t=e.getSymbol(),r=e.getText();if(t){let n=t.getName();if(n==="Effect"||n.includes("Effect"))return!0}if(r.includes("Effect<")||r.startsWith("Effect."))return!0;let s=e.getAliasSymbol();if(s){let n=s.getName();if(n==="Effect"||n.includes("Effect"))return!0}return!1},Ct=e=>{try{let t=e.getTypeArguments?.();if(!t||t.length<3){let r=e.getAliasTypeArguments?.();return r&&r.length>=3?[r[0],r[1],r[2]]:void 0}return[t[0],t[1],t[2]]}catch{return}},$e=e=>e.getText().replace(/import\([^)]+\)\./g,"").replace(/typeof\s+/g,"").substring(0,200),wt=(e,t)=>{let r=[],s=e.getType(),n=e,i;try{i=typeof s.getTypeArguments=="function"?s.getTypeArguments():void 0}catch{i=void 0}if(!i||i.length<3){let a=e.getParent();if(a?.getKindName()==="VariableDeclaration"){let d=a,l=d.getType();l&&(s=l,n=d)}}let c=Ui(s);if(!c)return r;let o=Gi(c);for(let a of o){let d=n.getSourceFile(),{line:l,column:f}=d.getLineAndColumnAtPos(n.getStart()),u={filePath:d.getFilePath(),line:l,column:f};r.push({serviceId:a.id,serviceType:a.typeName,requiredAt:u})}return r},Ui=e=>{let t=Ct(e);if(t)return t[2]},Gi=e=>{let t=[],r=e.getText(),s=/Context<([^>]+)>/.exec(r);if(s){let n=s[1];t.push({id:wr(n),typeName:n})}if(r.includes("|")){let n=Fe(r);for(let i of n){let c=/Context<([^>]+)>/.exec(i);c&&t.push({id:wr(c[1]),typeName:c[1]})}}return r==="never"||r==="{}"?[]:t},wr=e=>{let t=/Tag<["']([^"']+)["']/.exec(e);return t?t[1]:e.split("<")[0].trim()};function Fe(e){let t=[],r="",s=0,n=null;for(let c=0;c<e.length;c++){let o=e[c];if(n){r+=o,o===n&&e[c-1]!=="\\"&&(n=null);continue}if(o==='"'||o==="'"||o==="`"){n=o,r+=o;continue}if(o==="<"||o==="("){s++,r+=o;continue}if(o===">"||o===")"){s=Math.max(0,s-1),r+=o;continue}if(o==="|"&&s===0){t.push(r.trim()),r="";continue}r+=o}let i=r.trim();return i&&t.push(i),t.filter(Boolean)}var sn=e=>e.replace(/import\([^)]+\)\./g,"").replace(/typeof\s+/g,"").trim().substring(0,200);var Vi=/Layer<([^,]+),\s*([^,]+),\s*([^>]+)>/;function Tr(e){let t=e.getType().getText(),r=Vi.exec(t);if(r)return{providedType:sn(r[1]),errorType:sn(r[2]),requiredType:sn(r[3]),rawTypeString:t}}var an={tsConfigPath:"./tsconfig.json",resolveReferences:!0,maxReferenceDepth:5,includeLocations:!0,assumeImported:!1,enableEffectWorkflow:!1,knownEffectInternalsRoot:void 0,minDiscoveryConfidence:"low",onlyExportedPrograms:!1,enableEffectFlow:!1},Ir=0,Tt=()=>{Ir=0},C=()=>`effect-${++Ir}`,kr=new WeakMap;function kt(e){let t=kr.get(e);return t===void 0&&(t=e.getText(),kr.set(e,t)),t}function $r(e){let t=new Set,r=s=>{for(let n of s){if(n.type==="effect"){let c=n.typeSignature?.errorType?.trim();if(c&&c!=="never")for(let o of Fe(c))t.add(o)}let i=vr.getOrElse(P(n),()=>[]);i.length>0&&r(i)}};return r(e),Array.from(t).sort()}function Fr(e){let t=new Map,r=s=>{for(let n of s){if(n.type==="effect"){let c=n.requiredServices;if(c)for(let o of c)t.has(o.serviceId)||t.set(o.serviceId,{name:o.serviceId,typeSignature:o.serviceType,isLayer:!1});if((n.semanticRole==="environment"||n.semanticRole==="side-effect")&&n.callee){let o=n.callee;/^[A-Z]/.test(o)&&!o.startsWith("Effect.")&&!o.startsWith("Schema.")&&!o.startsWith("Data.")&&!o.startsWith("Config.")&&!o.startsWith("Command.")&&!o.startsWith("Stream.")&&!o.startsWith("Option.")&&!o.startsWith("Either.")&&!o.startsWith("Cause.")&&!o.startsWith("Exit.")&&!t.has(o)&&t.set(o,{name:o,typeSignature:n.typeSignature?.requirementsType,isLayer:!1})}}let i=vr.getOrElse(P(n),()=>[]);i.length>0&&r(i)}};return r(e),Array.from(t.values())}var _=(e,t,r)=>{if(!r)return;let s=e.getSourceFile(),n=e.getStart(),{line:i,column:c}=s.getLineAndColumnAtPos(n),o=e.getEnd(),a=s.getLineAndColumnAtPos(o);return{filePath:t,line:i,column:c,endLine:a.line,endColumn:a.column}},_e=e=>{let t=e.getJsDocs?.();if(t&&t.length>0){let s=t[0];if(!s)return;let n=s.getComment?.();if(n){let o;if(typeof n=="string")o=n;else if(Array.isArray(n))o=n.map(d=>d.text).join(`
|
|
3
3
|
`);else return;let a=o.search(/\n\s*@/);return a!==-1&&(o=o.substring(0,a)),o.trim()||void 0}let i=s.getText(),c=/\/\*\*\s*\n?\s*\*\s*([^@]*?)(?=\n\s*\*\s*@|\*\/)/.exec(i);if(c?.[1])return c[1].replace(/\n\s*\*\s*/g," ").trim()||void 0}let r=e.getLeadingCommentRanges();if(r.length>0){let s=r[r.length-1];if(!s)return;let n=s.getText();if(n.startsWith("/**")){let i=n.replace(/^\/\*\*\s*/,"").replace(/\s*\*\/\s*$/,"").replace(/^\s*\*\s?/gm,"").trim(),c=i.search(/\n@/);return c!==-1?i.substring(0,c).trim()||void 0:i||void 0}}},Ye=e=>{let t=s=>{let n=s.getJsDocs?.();if(n&&n.length>0)return n[0].getText();let i=s.getLeadingCommentRanges();if(i.length>0){let c=i[i.length-1];if(c){let o=c.getText();if(o.startsWith("/**"))return o}}},r=t(e);if(!r){let{SyntaxKind:s}=w(),n=e.getParent();for(;n&&!r;){let i=n.getKind();if(i===s.VariableStatement){r=t(n);break}if(i===s.VariableDeclarationList){let c=n.getParent();c&&(r=t(c));break}if(i===s.CallExpression||i===s.ArrowFunction||i===s.VariableDeclaration||i===s.ParenthesizedExpression)n=n.getParent();else break}}if(r)return Ji(r)};function Ji(e){let t=e.replace(/^\/\*\*/,"").replace(/\*\/$/,"").split(`
|
|
4
4
|
`).map(a=>a.replace(/^\s*\*\s?/,"")).join(`
|
|
5
|
-
`),r=[],s,n=[],i,c=/@(param|returns?|throws?|exception|example)\s*(.*)/gi,o;for(;(o=c.exec(t))!==null;){let a=o[1].toLowerCase(),d=o[2].trim();if(a==="param"){let l=/^(?:\{[^}]*\}\s*)?(\[?\w+(?:=[^\]]*)?]?)\s*(?:-\s*(.*))?$/.exec(d);if(l){let f=l[1].replace(/^\[|\]$/g,"").replace(/=.*/,""),u=l[2]?.trim();r.push(u?{name:f,description:u}:{name:f})}}else if(a==="returns"||a==="return")s=d.replace(/^\{[^}]*\}\s*/,"").trim()||void 0;else if(a==="throws"||a==="throw"||a==="exception"){let l=d.replace(/^\{[^}]*\}\s*/,"").trim();l&&n.push(l)}else if(a==="example"){let l=o.index+o[0].length,f=/\n\s*@\w/.exec(t.slice(l));f?i=t.slice(o.index+o[0].length-d.length,l+f.index).trim()||void 0:i=t.slice(o.index+o[0].length-d.length).trim()||void 0}}if(!(r.length===0&&!s&&n.length===0&&!i))return{params:r,returns:s,throws:n,example:i}}var Ar=e=>{let t=e.getParent(),{SyntaxKind:r}=w();if(t){let s=t.getKind();if(s===r.VariableDeclaration)return _e(t);if(s===r.ArrowFunction){let n=t.getParent();if(n?.getKind()===r.VariableDeclaration)return _e(n)}}};function Rr(e){return e.endsWith(".js")||e.endsWith(".jsx")}var vt=e=>{let t=e.getParent(),{SyntaxKind:r}=w();if(t?.getKind()===r.VariableDeclaration)return t.getName()},He=e=>{let{SyntaxKind:t}=w(),r=i=>{let c=i;for(;c!==void 0;){if(c.getKind()===t.VariableDeclaration)return c.getName();c=c.getParent()}},s=e.getParent();if(s){let i=s.getKind();if(i===t.VariableDeclaration)return s.getName();if(i===t.AwaitExpression){let c=s.getParent();if(c?.getKind()===t.VariableDeclaration)return c.getName()}if(i===t.PropertyAssignment){let o=s.getName(),a=r(s);return a?`${a}.${o}`:o}if(i===t.ArrowFunction){let c=s.getParent();if(c?.getKind()===t.VariableDeclaration)return c.getName();if(c?.getKind()===t.PropertyAssignment){let a=c.getName(),d=r(c);return d?`${d}.${a}`:a}}}let n=e;for(let i=0;n&&i<6&&(n=n.getParent(),!!n);i++){let c=n.getKind();if(c===t.VariableDeclaration)return n.getName();if(c===t.PropertyAssignment){let a=n.getName(),d=r(n);return d?`${d}.${a}`:a}if(c===t.Block||c===t.SourceFile)break}},Dr=e=>{let{SyntaxKind:t}=w(),r=e.getParent();for(let s=0;r&&s<10;s++){if(r.getKind()===t.CallExpression){let n=r,i=n.getExpression().getText();if(i==="Effect.fn"||i.endsWith(".fn")){let c=n.getArguments();if(c.length>0){let o=c[0].getText(),a=/^["'](.+)["']$/.exec(o);if(a?.[1])return a[1]}}}r=r.getParent()}},Pr=()=>({totalEffects:0,parallelCount:0,raceCount:0,errorHandlerCount:0,retryCount:0,timeoutCount:0,resourceCount:0,loopCount:0,conditionalCount:0,layerCount:0,interruptionCount:0,unknownCount:0,decisionCount:0,switchCount:0,tryCatchCount:0,terminalCount:0,opaqueCount:0}),ft=(e,t)=>e.length<=t?e:`${e.slice(0,t)}\u2026`;function G(e,t){switch(e.type){case"effect":{let r=t??e.name;return r?`${r} <- ${e.callee}`:e.callee}case"generator":return`Generator (${e.yields.length} yields)`;case"pipe":return`Pipe (${e.transformations.length} steps)`;case"parallel":return`${e.callee} (${e.children.length})`;case"race":return`${e.callee} (${e.children.length} racing)`;case"error-handler":return e.name?`${e.name}: ${e.handlerType}`:e.handlerType;case"retry":return e.schedule?`retry: ${e.schedule}`:"retry";case"timeout":return e.duration?`timeout: ${e.duration}`:"timeout";case"resource":return"Resource";case"conditional":return ft(e.condition,30);case"loop":return e.iterSource?`${e.loopType}(${e.iterSource})`:e.loopType;case"layer":return e.isMerged?"Layer (merged)":"Layer";case"stream":{let s=["Stream",...e.pipeline.map(n=>n.operation)];return e.sink&&s.push(e.sink),s.join(" \u2192 ")}case"concurrency-primitive":return`${e.primitive}.${e.operation}`;case"fiber":{let r=e.operation;return e.isDaemon?`${r} (daemon)`:e.isScoped?`${r} (scoped)`:r}case"transform":return e.transformType;case"match":return`Match.${e.matchOp}`;case"cause":return`Cause.${e.causeOp}`;case"exit":return`Exit.${e.exitOp}`;case"schedule":return`Schedule.${e.scheduleOp}`;case"interruption":return e.interruptionType;case"channel":{let r=e.pipeline.map(s=>s.operation);return r.length>0?`Channel: ${r.join(" \u2192 ")}`:"Channel"}case"sink":{let r=e.pipeline.map(s=>s.operation);return r.length>0?`Sink: ${r.join(" \u2192 ")}`:"Sink"}case"decision":return ft(e.condition,30);case"switch":return`switch(${ft(e.expression,25)})`;case"try-catch":return"try/catch";case"terminal":return e.label?`${e.terminalKind} ${e.label}`:e.terminalKind;case"opaque":return`Opaque: ${ft(e.reason,25)}`;case"unknown":return`Unknown: ${ft(e.reason,30)}`}}function Q(e){switch(e.type){case"effect":{if(e.serviceCall||e.serviceMethod)return"service-call";let t=e.description?.toLowerCase()??"";if(t.includes("service"))return"service-call";if(t.includes("layer")||e.provideKind==="layer")return"layer";let r=e.callee.toLowerCase();return/^[A-Z][A-Za-z0-9_]*$/.test(e.callee)&&!e.constructorKind?"environment":r.includes("sync")||r.includes("promise")||r.includes("async")||r.includes("log")||r.includes("console")?"side-effect":r.includes("succeed")||r.includes("fail")||r.includes("die")||r.includes("void")||r.includes("never")||r.includes("gen")||r.includes("make")||e.constructorKind?"constructor":"side-effect"}case"generator":case"pipe":return"constructor";case"parallel":case"race":case"concurrency-primitive":return"concurrency";case"error-handler":case"cause":case"exit":return"error-handler";case"retry":case"timeout":case"schedule":return"scheduling";case"resource":return"resource";case"conditional":case"loop":case"match":case"decision":case"switch":case"terminal":return"control-flow";case"try-catch":return"error-handler";case"opaque":return"unknown";case"layer":return"layer";case"stream":case"channel":case"sink":return"stream";case"fiber":case"interruption":return"fiber";case"transform":return"transform";case"unknown":return"unknown"}}var cn=[".catchAll",".catchTag",".catchAllCause",".catchIf",".catchSome",".catchSomeCause",".catchSomeDefect",".catchAllDefect",".catchTags",".orElse",".orElseFail",".orElseSucceed",".orDie",".orDieWith",".flip",".mapError",".mapErrorCause",".mapBoth",".sandbox",".unsandbox",".parallelErrors",".filterOrDie",".filterOrDieMessage",".filterOrElse",".filterOrFail",".match",".matchCause",".matchEffect",".matchCauseEffect",".firstSuccessOf",".ignore",".ignoreLogged",".eventually"],ln=[".if",".when",".whenEffect",".whenFiberRef",".whenRef",".unless",".unlessEffect",".option",".either",".exit",".liftPredicate"],Qi=[".acquireRelease",".acquireUseRelease",".ensuring",".addFinalizer",".onExit",".onError",".parallelFinalizers",".sequentialFinalizers",".finalizersMask",".using",".withEarlyRelease"],dn=[".forEach",".loop",".filter",".filterMap",".partition",".reduce",".reduceRight",".reduceWhile",".reduceEffect",".dropUntil",".dropWhile",".takeUntil",".takeWhile",".every",".exists",".findFirst",".head",".mergeAll",".replicate",".replicateEffect",".validateAll",".validateFirst",".validate",".validateWith"],un=["Effect.fork",".fork",".forkAll",".forkIn",".forkWithErrorHandler","Fiber."],fn={"Effect.map":"map","Effect.flatMap":"flatMap","Effect.andThen":"andThen","Effect.tap":"tap","Effect.tapBoth":"tapBoth","Effect.tapError":"tapError","Effect.tapErrorTag":"tapErrorTag","Effect.tapErrorCause":"tapErrorCause","Effect.tapDefect":"tapDefect","Effect.zipLeft":"zipLeft","Effect.zipRight":"zipRight","Effect.zipWith":"zipWith","Effect.zip":"zip","Effect.as":"as","Effect.asVoid":"asVoid","Effect.asSome":"asSome","Effect.asSomeError":"asSomeError","Effect.flatten":"flatten","Effect.ap":"ap","Effect.negate":"negate","Effect.merge":"merge"},Or=new Set(["flatMap","andThen","tapBoth","tapError","tapErrorTag","tapErrorCause","tapDefect","zipWith","zipLeft","zipRight","zip","ap","flatten"]),Lr=e=>e in fn,pn={"Match.type":"type","Match.tag":"tag","Match.value":"value","Match.when":"when","Match.whenOr":"whenOr","Match.whenAnd":"whenAnd","Match.not":"not","Match.is":"is","Match.exhaustive":"exhaustive","Match.orElse":"orElse","Match.option":"option","Match.either":"either","Match.discriminator":"discriminator","Match.discriminatorsExhaustive":"discriminatorsExhaustive","Match.tags":"tags","Match.tagsExhaustive":"tagsExhaustive","Match.withReturnType":"withReturnType","Match.run":"run"},Wr=new Set(["exhaustive","discriminatorsExhaustive","tagsExhaustive"]),Kr=e=>e.startsWith("Match.")&&e in pn,gn={"Cause.fail":"fail","Cause.die":"die","Cause.interrupt":"interrupt","Cause.parallel":"parallel","Cause.sequential":"sequential","Cause.empty":"empty","Cause.failures":"failures","Cause.defects":"defects","Cause.interruptors":"interruptors","Cause.squash":"squash","Cause.squashWith":"squashWith","Cause.pretty":"pretty","Cause.flatten":"flatten","Cause.isDie":"isDie","Cause.isFailure":"isFailure","Cause.isInterrupted":"isInterrupted","Cause.isEmpty":"isEmpty","Cause.map":"map","Cause.filter":"filter"},jr=new Set(["fail","die","interrupt","parallel","sequential","empty"]),Br=e=>e.startsWith("Cause.")&&e in gn,mn={"Exit.succeed":"succeed","Exit.fail":"fail","Exit.die":"die","Exit.interrupt":"interrupt","Exit.void":"void","Exit.unit":"unit","Exit.match":"match","Exit.isSuccess":"isSuccess","Exit.isFailure":"isFailure","Exit.isInterrupted":"isInterrupted","Exit.when":"when","Exit.whenEffect":"whenEffect","Exit.exists":"exists","Exit.contains":"contains","Exit.flatten":"flatten","Exit.map":"map","Exit.mapBoth":"mapBoth","Exit.mapError":"mapError","Exit.flatMap":"flatMap","Exit.zipWith":"zipWith","Exit.tap":"tap","Exit.tapBoth":"tapBoth","Exit.tapError":"tapError"},qr=new Set(["succeed","fail","die","interrupt","void","unit"]),zr=e=>e.startsWith("Exit.")&&(e in mn||/^Exit\.\w+$/.test(e)),yn={"Schedule.exponential":"exponential","Schedule.fibonacci":"fibonacci","Schedule.spaced":"spaced","Schedule.fixed":"fixed","Schedule.linear":"linear","Schedule.cron":"cron","Schedule.windowed":"windowed","Schedule.duration":"duration","Schedule.elapsed":"elapsed","Schedule.delays":"delays","Schedule.once":"once","Schedule.stop":"stop","Schedule.count":"count","Schedule.forever":"forever","Schedule.jittered":"jittered","Schedule.andThen":"andThen","Schedule.intersect":"intersect","Schedule.union":"union","Schedule.compose":"compose","Schedule.zipWith":"zipWith","Schedule.addDelay":"addDelay","Schedule.modifyDelay":"modifyDelay","Schedule.check":"check","Schedule.resetAfter":"resetAfter","Schedule.resetWhen":"resetWhen","Schedule.ensure":"ensure","Schedule.driver":"driver","Schedule.mapInput":"mapInput"},_r=e=>e.startsWith("Schedule.")&&(e in yn||/^Schedule\.\w+$/.test(e)),hn=[".interruptible",".uninterruptible",".interruptibleMask",".uninterruptibleMask",".onInterrupt",".disconnect",".allowInterrupt","Effect.interrupt",".interruptWith"],Zi=[".Do",".bind",".bindAll",".bindTo"],Yi=[".cached",".cachedWithTTL",".cachedInvalidateWithTTL",".cachedFunction",".once","Cache.","ScopedCache."],Sn=["Effect.","Layer.","Schedule.","Stream.","Queue.","PubSub.","Deferred.","Semaphore.","Mailbox.","SubscriptionRef.","Scope.","Fiber.","Runtime.","ManagedRuntime.","NodeRuntime.","BunRuntime.","DenoRuntime.","Cause.","Exit.","Data.","Option.","Either.","Chunk.","HashMap.","HashSet.","List.","SortedMap.","SortedSet.","RedBlackTree.","Trie.","Graph.","Match.","Config.","Schema.","Cache.","ScopedCache.","RcRef.","RcMap.","Reloadable.","Cache.","ScopedCache.","RateLimiter.","PartitionedSemaphore.","FiberSet.","FiberMap.","FiberHandle.","Metric.","Logger.","Tracer.","Context.","HttpClient.","HttpRouter.","HttpApi.","FileSystem.","Command.","Socket.","SocketServer.","Worker.","Terminal.","KeyValueStore.","Multipart.","Ndjson.","MsgPack.","OpenApi.","OpenApiJsonSchema.","Brand.","Encoding.","Predicate.","DateTime.","Cron.","BigDecimal.","HashRing.","Redacted.","GlobalValue.","Channel.","Sink.","CliApp.","Args.","Options.","AiModel.","AiToolkit.","Completions.","AiInput.","AiResponse.","NodeSdk.","WebSdk.","Entity.","ClusterSchema.","MessageState.","Sharding.","RpcGroup.","RpcApi.","RpcClient.","RpcRouter.","SqlResolver.","SqlMigrator.","Printer.","Doc.","DocTree.","PageWidth.","Optimize."],Hr=new Set(["Array","ReadonlyArray","String","Number","Boolean","Object","Function","Promise","Math","Date","RegExp","Error","Map","Set","WeakMap","WeakSet","Symbol","BigInt","JSON","Console","process","Buffer","EventEmitter","Window","Document","AbortController"]),xn=new Set(["Effect","Layer","Stream","Queue","PubSub","Deferred","Semaphore","Mailbox","SubscriptionRef","Scope","Fiber","Runtime","ManagedRuntime","Cause","Exit","Data","Option","Either","Chunk","HashMap","HashSet","List","SortedMap","SortedSet","Match","Config","Schema","Schedule","Metric","Tracer","Logger","FiberRef","FiberHandle","FiberSet","FiberMap","Cache","ScopedCache","RateLimiter","Supervisor"]),Ur=e=>e.includes(".")||xn.has(e)?!1:/^[A-Z][A-Za-z0-9]*$/.test(e),Mr=e=>{if(e.startsWith("Channel."))return"channel";if(e.startsWith("Sink."))return"sink";if(e.endsWith(".never"))return"never";if(e.endsWith(".void"))return"void-effect";if(e.endsWith(".fromNullable"))return"null-coalescing";if(e.endsWith(".fn")||e.endsWith(".fnUntraced"))return"function-lift";if(e.includes(".async")||e.includes(".asyncEffect")||e.includes(".promise")||e.includes(".sync")||e.includes(".suspend")||e.includes(".succeed")||e.includes(".fail")||e.includes(".try"))return"constructor";if(hn.some(t=>e.includes(t)))return"interruption";if(Zi.some(t=>e.includes(t)))return"do-notation";if(Yi.some(t=>e.includes(t)||e.startsWith(t)))return"caching";if(cn.some(t=>e.includes(t)))return"error-handler";if(ln.some(t=>e.includes(t)))return"conditional";if(Qi.some(t=>e.includes(t)))return"resource";if(dn.some(t=>e.includes(t)))return"collection";if(un.some(t=>e.includes(t)))return"fiber";if(e.startsWith("Stream."))return"stream";if(e.startsWith("Layer."))return"layer";if(e.startsWith("Schema."))return"schema";if(e.startsWith("Config."))return"config";if(e.startsWith("Cause."))return"cause";if(e.startsWith("Exit."))return"exit";if(e==="Data.tagged"||e==="Data.taggedEnum")return"tagged-enum";if(e.startsWith("Data."))return"data";if(e.startsWith("Option."))return"option";if(e.startsWith("Either."))return"either";if(e.startsWith("Match."))return"match";if(e.startsWith("ManagedRuntime.")||e.startsWith("Runtime.")||e.startsWith("NodeRuntime.")||e.startsWith("BunRuntime.")||e.startsWith("DenoRuntime."))return"runtime";if(e.startsWith("Scope."))return"scope";if(e.startsWith("ScopedRef.")||e.startsWith("RcRef.")||e.startsWith("RcMap."))return"resource-ref";if(e.startsWith("Reloadable.")||e.startsWith("Resource."))return"reloadable";if(e.startsWith("Micro."))return"micro";if(e.startsWith("Brand."))return"brand";if(e.startsWith("Encoding."))return"encoding";if(e.startsWith("Predicate."))return"predicate";if(e.startsWith("DateTime."))return"datetime";if(e.startsWith("Cron."))return"cron";if(e.startsWith("Redacted."))return"redacted";if(e.startsWith("GlobalValue."))return"global-value";if(e.startsWith("Supervisor."))return"supervisor";if(e.includes(".locally")||e.includes(".locallyWith")||e.includes(".locallyScoped")||e.includes(".getFiberRefs")||e.includes(".setFiberRefs")||e.includes(".inheritFiberRefs")||e.includes("FiberRef."))return"fiberref";if(e.includes(".withConcurrency")||e.includes(".withScheduler")||e.includes(".withSchedulingPriority")||e.includes(".daemonChildren")||e.includes(".awaitAllChildren")||e.includes(".supervised"))return"structured-concurrency";if(e.startsWith("Context.pick")||e.startsWith("Context.omit")||e==="Effect.provide"||e.startsWith("Effect.")&&e.includes(".provide")&&!e.includes("provideService"))return"context";if(e.includes(".serviceOption")||e.includes(".serviceOptional")||e.includes(".serviceFunction")||e.includes(".serviceFunctionEffect")||e.includes(".serviceFunctions")||e.includes(".serviceConstants")||e.includes(".serviceMembers")||e.includes(".updateService"))return"service";if(e.startsWith("CliApp.")||e.startsWith("Args.")||e.startsWith("Options."))return"cli";if(e.startsWith("AiModel.")||e.startsWith("AiToolkit.")||e.startsWith("Completions.")||e.startsWith("AiInput.")||e.startsWith("AiResponse."))return"ai";if(e.startsWith("NodeSdk.")||e.startsWith("WebSdk.")||e.startsWith("OtelMetrics."))return"opentelemetry";if(e.startsWith("Entity.")||e.startsWith("ClusterSchema.")||e.startsWith("MessageState.")||e.startsWith("Sharding."))return"cluster";if(e.startsWith("RpcGroup.")||e.startsWith("RpcApi.")||e.startsWith("RpcClient.")||e.startsWith("RpcRouter."))return"rpc";if(e.startsWith("SqlResolver.")||e.startsWith("SqlMigrator."))return"sql";if(e.startsWith("DevTools.")||e.startsWith("Server."))return"devtools";if(e.startsWith("BigDecimal."))return"big-decimal";if(e.startsWith("Graph."))return"graph";if(e.startsWith("HashRing."))return"hash-ring";if(e.startsWith("Chunk."))return"chunk";if(e.startsWith("HashMap.")||e.startsWith("HashSet.")||e.startsWith("List.")||e.startsWith("SortedMap.")||e.startsWith("SortedSet.")||e.startsWith("RedBlackTree.")||e.startsWith("Trie."))return"immutable-collection";if(e.includes(".map")||e.includes(".flatMap")||e.includes(".andThen")||e.includes(".tap")||e.includes(".tapBoth")||e.includes(".tapError")||e.includes(".tapErrorTag")||e.includes(".tapErrorCause")||e.includes(".tapDefect")||e.includes(".zip")||e.includes(".zipLeft")||e.includes(".zipRight")||e.includes(".zipWith")||e.includes(".as")||e.includes(".asVoid")||e.includes(".flatten")||e.includes(".merge")||e.includes(".ap")||e.includes(".validate")||e.includes(".negate"))return"transformation";if(e.startsWith("Printer.")||e.startsWith("Doc.")||e.startsWith("DocTree.")||e.startsWith("PageWidth.")||e.startsWith("Optimize."))return"printer";if(e.startsWith("Http")||e.startsWith("FileSystem.")||e.startsWith("Command.")||e.startsWith("Socket.")||e.startsWith("Worker."))return"platform";if(e.includes("channel.")&&!e.includes("Channel"))return"channel"},Gr=(e,t)=>{let r=Mr(e);if(r)return r;if(t){let s=e.indexOf(".");if(s>0){let n=e.substring(0,s);if(t.has(n)){let i=e.substring(s+1);return Mr(`Effect.${i}`)}}}},oe=(e,t,r=new Set)=>{let{SyntaxKind:s}=w(),n=f=>r.has(f),i=f=>/\.run(?:Promise(?:Exit)?|Sync(?:Exit)?|Fork|Callback|Main)$/.test(f)||/^Runtime\.run(?:Promise|Sync|Fork)$/.test(f),c=f=>{if(i(f))return!1;let u=f==="pipe"||f.endsWith(".pipe"),g=f.indexOf(".");return g>0&&n(f.slice(0,g))?!1:u||[...t].some(p=>f.startsWith(`${p}.`))},o=f=>{let u=f.getExpression(),g=u.getText();if(i(g))return!1;let p=g==="pipe",m=u.getKind()===s.PropertyAccessExpression&&u.getName()==="pipe";if(p||m){if(f.getArguments().some(y=>oe(y,t,r)))return!0;if(m){let y=u.getExpression();return oe(y,t,r)}return!1}return u.getKind()===s.Identifier&&t.has(g)&&!n(g)||c(g)||u.getKind()===s.PropertyAccessExpression&&oe(u.getExpression(),t,r)?!0:f.getArguments().some(h=>oe(h,t,r))},a=(f,u)=>{let g=f.getParent();for(;g&&g!==u;){let p=g.getKind();if(p===s.FunctionDeclaration||p===s.FunctionExpression||p===s.ArrowFunction||p===s.MethodDeclaration||p===s.GetAccessor||p===s.SetAccessor||p===s.ClassDeclaration||p===s.ClassExpression||p===s.Constructor||p===s.ClassStaticBlockDeclaration)return!1;g=g.getParent()}return!0},d=f=>f.getDescendantsOfKind(s.CallExpression).some(m=>a(m,f)&&o(m))||f.getDescendantsOfKind(s.AwaitExpression).some(m=>a(m,f)&&oe(m,t,r))?!0:f.getDescendantsOfKind(s.PropertyAccessExpression).some(m=>a(m,f)&&oe(m,t,r)),l=f=>f.getDescendantsOfKind(s.CallExpression).some(u=>a(u,f)&&i(u.getExpression().getText()));if(e.getKind()===s.ObjectLiteralExpression)return e.getProperties().some(u=>{if(u.getKind()===s.PropertyAssignment||u.getKind()===s.ShorthandPropertyAssignment){let g=u.getKind()===s.PropertyAssignment?u.getInitializer():void 0;return g?oe(g,t,r):!1}if(u.getKind()===s.MethodDeclaration||u.getKind()===s.GetAccessor||u.getKind()===s.SetAccessor){let g=u.getBody();return g?d(g):!1}return!1});if(e.getKind()===s.ArrowFunction||e.getKind()===s.FunctionExpression){let u=e.getBody();if(u.getKind()===s.Block){let g=u;return g.getDescendantsOfKind(s.ReturnStatement).some(h=>{if(!a(h,g))return!1;let y=h.getExpression();return y!==void 0&&oe(y,t,r)})?!0:l(g)?!1:d(g)}return oe(u,t,r)}if(e.getKind()===s.CallExpression)return o(e);if(e.getKind()===s.AwaitExpression){let f=e.getExpression();return f.getKind()!==s.CallExpression?!1:o(f)}if(e.getKind()===s.ConditionalExpression){let f=e;return oe(f.getWhenTrue(),t,r)||oe(f.getWhenFalse(),t,r)}if(e.getKind()===s.PropertyAccessExpression){let f=e.getText(),u=f.indexOf(".");return u>0&&n(f.slice(0,u))?!1:[...t].some(g=>f.startsWith(`${g}.`))}return!1};function Me(e){return e==="effect"||e.startsWith("effect/")||e.startsWith("@effect/")}var En=new Set(["Effect","Layer","Schedule","Stream","Queue","PubSub","Deferred","Semaphore","Mailbox","SubscriptionRef","Scope","Fiber","Runtime","ManagedRuntime","Cause","Exit","Data","Option","Either","Chunk","HashMap","HashSet","Match","Config","Schema","Cache","ScopedCache","Metric","Logger","Tracer","Context","Brand","Encoding","Predicate","DateTime","Cron","BigDecimal","Graph","HashRing","Redacted","GlobalValue","NodeRuntime","BunRuntime","DenoRuntime","Channel","Sink"]),Vr=new Set(["core","core-effect","core-stream","fiberRuntime","effectable","channel","sink","layer","schedule","mailbox","pubsub"]);function Jr(e){let t=new Set(["never","unknown","any","{}","object"]),r=e.trim();return!r||t.has(r)?[]:r.split(/[\s|&]+/).map(n=>n.trim().split("<")[0]?.trim()??"").filter(n=>n.length>0&&!t.has(n))}function pt(e){let{SyntaxKind:t}=w(),r=e.getKind();if(r===t.NumericLiteral){let s=e.getText(),n=Number(s);return Number.isFinite(n)?n:void 0}if(r===t.PrefixUnaryExpression){let s=e;if(s.getOperatorToken()===t.MinusToken){let n=s.getOperand(),i=pt(n);return i!==void 0?-i:void 0}}}import{existsSync as Xi}from"fs";import{dirname as bn,resolve as gt,join as Oe,sep as Qr}from"path";var Zr=new WeakMap,Yr=new WeakMap;function Nn(e){let t=new Set;for(let r of e.getExportDeclarations()){let s=r.getModuleSpecifierValue();if(!(!s||!Me(s))){if(r.isNamespaceExport()){En.forEach(n=>t.add(n));continue}for(let n of r.getNamedExports()){t.add(n.getName());let i=n.getAliasNode()?.getText();i&&t.add(i)}}}return t}function Xe(e,t,r){if(!r.startsWith("."))return;let s=bn(t),n=gt(s,r),i=[n,`${n}.ts`,`${n}.tsx`,`${n}.js`,`${n}.jsx`,Oe(n,"index.ts"),Oe(n,"index.tsx"),Oe(n,"index.js"),Oe(n,"index.jsx")];for(let c of i){let o=e.getSourceFile(c);if(o)return o}}function mt(e,t){if(!t.startsWith("."))return;let r=bn(e),s=gt(r,t);return[s,`${s}.ts`,`${s}.tsx`,`${s}.js`,`${s}.jsx`,Oe(s,"index.ts"),Oe(s,"index.tsx"),Oe(s,"index.js"),Oe(s,"index.jsx")].find(i=>Xi(i))}function It(e,t,r){if(!r||!t.startsWith("."))return!1;let s=t.replace(/\\/g,"/"),n=gt(bn(e),t),i=gt(n),c=gt(r);return i===c||i.startsWith(c+Qr)?!0:e==="temp.ts"||e.endsWith(`${Qr}temp.ts`)?s.startsWith("./internal/")||s.startsWith("../internal/"):!1}function eo(e){let t=new Set(En),r=e.getProject(),s=e.getFilePath();for(let n of e.getImportDeclarations()){let i=n.getModuleSpecifierValue();if(Me(i)){let c=n.getDefaultImport();c&&t.add(c.getText());let o=n.getNamespaceImport();o&&t.add(o.getText());for(let a of n.getNamedImports()){let d=a.getAliasNode()?.getText();t.add(d??a.getName())}continue}if(i.startsWith(".")){let c=Xe(r,s,i);if(!c)continue;let o=Nn(c);if(o.size===0)continue;let a=n.getDefaultImport();if(a){let l=a.getText();o.has(l)&&t.add(l)}let d=n.getNamespaceImport();if(d){let l=d.getText();o.has(l)&&t.add(l)}for(let l of n.getNamedImports())o.has(l.getName())&&t.add(l.getAliasNode()?.getText()??l.getName())}}return t}function Cn(e,t){let r=eo(e);for(let s of e.getImportDeclarations()){let n=s.getModuleSpecifierValue(),i=s.getNamespaceImport();if(!i)continue;let c=i.getText();if(n.startsWith("effect")||n.startsWith("@effect/")){r.add(c);continue}if(It(e.getFilePath(),n,t)){r.add(c);continue}let o=n.replace(/\.(js|ts)$/,"").split("/").pop()??"";Vr.has(o)&&r.add(c)}return r}var to=new Set(["BigDecimal","BigInt","Brand","Cause","Chunk","Data","Exit","Option","Either","HashMap","HashSet","List","Redacted"]);function es(e){let t=new Set;for(let r of e.getImportDeclarations()){let i=r.getModuleSpecifierValue().replace(/\\/g,"/").replace(/\.(js|ts|tsx|jsx)$/,"").split("/").pop()??"";if(!to.has(i))continue;let c=r.getDefaultImport();c&&t.add(c.getText());let o=r.getNamespaceImport();o&&t.add(o.getText());for(let a of r.getNamedImports())t.add(a.getAliasNode()?.getText()??a.getName())}return t}function Le(e){let t=Zr.get(e);return t||(t=Cn(e),Zr.set(e,t)),t}var Xr=new WeakMap;function no(e){let t=e.replace(/\\/g,"/").replace(/\.(js|ts|mts|cts)$/,"");return t==="effect"||t.endsWith("/Effect")?"Effect":(t.split("/").pop()??"")||"Effect"}function ro(e){let t=Xr.get(e);if(t)return t;t=new Map;for(let r of e.getImportDeclarations()){let s=r.getModuleSpecifierValue();if(!s||!Me(s))continue;let n=r.getNamespaceImport();if(!n)continue;let i=n.getText(),c=no(s);t.set(i,c)}return Xr.set(e,t),t}function wn(e,t){let r=e.indexOf(".");if(r<=0)return e;let s=e.slice(0,r),n=e.slice(r+1),c=ro(t).get(s);return c?`${c}.${n}`:e}function so(e,t){let r=Yr.get(t);r||(r=new Map,Yr.set(t,r));let s=e.indexOf("."),n=s>0?e.slice(0,s):e,i=r.get(n);if(i!==void 0)return i;let c=!1;try{for(let o of t.getImportDeclarations()){let a=o.getModuleSpecifierValue();if(o.getNamespaceImport()?.getText()===n){c=Me(a);break}if(o.getDefaultImport()?.getText()===n){c=Me(a);break}for(let f of o.getNamedImports())if((f.getAliasNode()?.getText()??f.getName())===n){if(Me(a))c=!0;else if(a.startsWith(".")){let p=Xe(t.getProject(),t.getFilePath(),a);p&&(c=Nn(p).has(f.getName()))}break}if(c)break}}catch{c=!1}return r.set(n,c),c}function io(e,t){let s=e.getExpression().getText();for(let n of t.getImportDeclarations()){let i=n.getModuleSpecifierValue();if(n.getNamespaceImport()?.getText()===s||n.getDefaultImport()?.getText()===s)return i;for(let a of n.getNamedImports())if((a.getAliasNode()?.getText()??a.getName())===s)return i}}function et(e,t,r,s){let n=e.getExpression(),i=n.getText();if(Sn.some(d=>i.startsWith(d))||i.startsWith("pipe("))return!0;for(let d of r)if(i.startsWith(`${d}.`))return!0;let{SyntaxKind:c}=w();if(n.getKind()!==c.PropertyAccessExpression)return!1;let o=n,a=io(o,t);if(!a)return!1;if(Me(a))return!0;if(a.startsWith(".")){let d=Xe(t.getProject(),t.getFilePath(),a);if(d){let l=Nn(d),f=o.getExpression().getText();for(let u of t.getImportDeclarations())if(u.getModuleSpecifierValue()===a){for(let g of u.getNamedImports())if((g.getAliasNode()?.getText()??g.getName())===f&&l.has(g.getName()))return!0}}if(It(t.getFilePath(),a,s))return!0}return!1}function $t(e,t,r){if(Sn.some(s=>e.startsWith(s))||e.startsWith("pipe("))return!0;if(t){for(let s of t)if(e.startsWith(`${s}.`))return!0}return r&&e.includes(".")?so(e,r):!1}var oo=new Set(["createWorkflow","createSagaWorkflow","runSaga"]),ao=e=>Array.from(oo).some(t=>e===t||e.endsWith(`.${t}`)),ts=e=>{let t=e.getExpression();if(t.getKind()!==w().SyntaxKind.PropertyAccessExpression)return!1;let r=t,s=e.getArguments();if(r.getName()!=="make"||s.length<3||!s[2])return!1;let n=s[2].getKind(),{SyntaxKind:i}=w();return n===i.ArrowFunction||n===i.FunctionExpression};function is(e,t){let r=e.replace(/\\/g,"/");return!!(r==="@effect/workflow"||r==="effect/workflow"||r.endsWith("/workflow")||r.includes("/workflow/")||r.endsWith("/Workflow.js")||r.endsWith("/Workflow.ts")||r.endsWith("/Activity.js")||r.endsWith("/Activity.ts")||r.startsWith(".")&&(r.endsWith("Workflow.js")||r.endsWith("Workflow.ts")||r.endsWith("Activity.js")||r.endsWith("Activity.ts")))}function co(e,t,r){return e!=="Workflow"?!1:is(t,r)}function lo(e,t,r){return e!=="Activity"?!1:is(t,r)}function os(e,t){let{SyntaxKind:r}=w(),s=e.getArguments();if(s.length!==1||!s[0])return!1;let n=s[0];if(n.getKind()!==r.ObjectLiteralExpression)return!1;let c=n.getProperties(),o=new Set(t);for(let a of c)if(a.getKind()===r.PropertyAssignment){let d=a.getName();if(o.has(d))return!0}return!1}function uo(e,t,r){let{SyntaxKind:s}=w(),n=e.getExpression();if(n.getKind()!==s.PropertyAccessExpression)return!1;let i=n;if(i.getName()!=="make")return!1;let c=i.getExpression().getText(),o=t.get(c);return!o||!co(c,o,r)?!1:os(e,["name","payload","idempotencyKey"])}function fo(e,t,r){let{SyntaxKind:s}=w(),n=e.getExpression();if(n.getKind()!==s.PropertyAccessExpression)return!1;let i=n;if(i.getName()!=="make")return!1;let c=i.getExpression().getText(),o=t.get(c);return!o||!lo(c,o,r)?!1:os(e,["name","execute"])}var as=(e,t)=>{let r=e.getExpression();if(r.getKind()!==w().SyntaxKind.PropertyAccessExpression||r.getName()!=="run")return null;let n=e.getArguments();if(n.length<1||!n[0])return null;let i=n[0],{SyntaxKind:c}=w();if(i.getKind()===c.CallExpression){let l=i;return ts(l)?l.getArguments()[2]??null:null}if(i.getKind()!==c.Identifier)return null;let a=i.getText(),d=t.getDescendantsOfKind(c.VariableDeclaration);for(let l of d){if(l.getName()!==a)continue;let f=l.getInitializer();if(f?.getKind()===c.CallExpression&&ts(f))return f.getArguments()[2]??null}return null},po=e=>{let{SyntaxKind:t}=w(),r=e.getParent();for(;r;){if(r.getKind()===t.CallExpression){let n=r.getExpression().getText();if(n.includes(".gen")||n==="gen")return!0}r=r.getParent()}return!1},go=e=>{let{SyntaxKind:t}=w();return e.getFirstAncestorByKind(t.VariableStatement)?.getParent()?.getKind()===t.SourceFile},mo=e=>{let{SyntaxKind:t}=w(),r=e.getInitializer();return r?r.getKind()===t.YieldExpression||r.getKind()===t.AwaitExpression&&r.getExpression().getKind()===t.YieldExpression:!1},ns=e=>{let{SyntaxKind:t}=w();if(e.getKind()===t.CallExpression)return e;if(e.getKind()===t.AwaitExpression){let r=e.getExpression();if(r.getKind()===t.CallExpression)return r}},V=(e,t)=>({discoveryConfidence:e,discoveryReason:t}),yo=["Effect<","Layer<","Layer.Layer<","Stream<","Stream.Stream<","Channel<","Channel.Channel<","Sink<","Sink.Sink<","STM<","STM.STM<","Schedule<","Schedule.Schedule<"],Ft=e=>e!==void 0&&yo.some(t=>e.includes(t)),rs={low:0,medium:1,high:2},Tn=e=>{let t=e.getExpression().getText();return t.includes(".runPromise")||t.includes(".runPromiseExit")||t.includes(".runSync")||t.includes(".runSyncExit")||t.includes(".runFork")||t.includes(".runCallback")||t.includes(".runMain")||t.includes("Runtime.runPromise")||t.includes("Runtime.runSync")||t.includes("Runtime.runFork")};function ss(e){let t=e.getBody?.();if(!t)return!1;let r=t.getText();return r.includes(".runMain")||r.includes(".runPromise")||r.includes(".runSync")||r.includes(".runFork")||r.includes("Runtime.runPromise")||r.includes("Runtime.runSync")||r.includes("NodeRuntime.runMain")||r.includes("BunRuntime.runMain")||r.includes("DenoRuntime.runMain")}function ho(e,t){let r=e.getExpression();if(r.getKind()!==w().SyntaxKind.Identifier)return!1;let i=r.getSymbol()?.getValueDeclaration();if(!i)return!1;let c=i.getKind(),{SyntaxKind:o}=w();if(c===o.FunctionDeclaration||c===o.ArrowFunction||c===o.FunctionExpression)return ss(i);if(c===o.VariableDeclaration){let a=i.getInitializer();if(a&&(a.getKind()===o.ArrowFunction||a.getKind()===o.FunctionExpression))return ss(a)}return!1}function So(e){let t=e.getExpression();if(e.getArguments().length!==1)return!1;let{SyntaxKind:r}=w();if(t.getKind()!==r.CallExpression)return!1;let s=t;if(s.getArguments().length!==1)return!1;let n=s.getExpression().getText();return n.includes(".runPromise")||n.includes(".runSync")||n.includes(".runFork")||n.includes(".runCallback")||n.includes("Runtime.runPromise")||n.includes("Runtime.runSync")||n.includes("Runtime.runFork")}var kn=(e,t)=>{let r=[],{SyntaxKind:s}=w(),n=new Set,i=new Set,c=Cn(e,t.knownEffectInternalsRoot),o=es(e),a=new Map;for(let S of e.getImportDeclarations()){let b=S.getModuleSpecifierValue(),T=S.getDefaultImport();T&&a.set(T.getText(),b);let v=S.getNamespaceImport();v&&a.set(v.getText(),b);for(let x of S.getNamedImports())a.set(x.getAliasNode()?.getText()??x.getName(),b)}let d=S=>{let b=a.get(S);if(b){if(b.startsWith("effect")||b.startsWith("@effect/"))return V("high",`imported from ${b}`);if(It(e.getFilePath(),b,t.knownEffectInternalsRoot))return V("high","namespace import resolved under knownEffectInternalsRoot");if(b.startsWith(".")&&/(?:^|\/)Effect(?:\.[jt]sx?)?$/.test(b))return V("high",`relative Effect module namespace import (${b})`)}},l=S=>{let b=v=>{let x=v.getDescendantsOfKind(s.PropertyAccessExpression);for(let F of x){let j=F.getExpression().getText();if(c.has(j)&&!o.has(j))return d(j)?.discoveryConfidence==="high"?V("high",`function body uses ${j}.* from trusted Effect alias`):V("medium",`function body uses Effect-like alias ${j}.*`)}let K=v.getDescendantsOfKind(s.CallExpression);for(let F of K){let j=F.getExpression();if(j.getKind()===s.Identifier){let I=j.getText();if(c.has(I)&&!o.has(I))return d(I)?.discoveryConfidence==="high"?V("high",`function body calls trusted Effect import ${I}(...)`):V("medium",`function body calls Effect-like import ${I}(...)`)}}};if(S.getKind()===s.ArrowFunction||S.getKind()===s.FunctionExpression){let x=S.getBody();if(x.getKind()===s.Block){let K=b(x);if(K)return K}else{let K=b(x);if(K)return K}}let T=ns(S);if(T){let v=T.getExpression(),x=v.getText();if(v.getKind()===s.Identifier){let K=x;if(c.has(K)&&!o.has(K))return d(K)??V("high",`named import call (${K})`);if(K==="pipe")return V("medium","exact pipe() call detection")}if(v.getKind()===s.PropertyAccessExpression){let K=v,F=K.getExpression().getText();if(c.has(F)&&!o.has(F))return d(F)??V("medium",`Effect-like namespace prefix (${F}.*)`);if(K.getName()==="pipe")return V("medium","exact .pipe() call detection")}}if(S.getKind()===s.PropertyAccessExpression){let x=S.getExpression().getText();if(c.has(x)&&!o.has(x))return d(x)??V("medium",`Effect-like namespace property access (${x}.*)`)}if(S.getKind()===s.AwaitExpression){let v=S.getExpression();if(v.getKind()===s.CallExpression)return l(v)}return V("low","heuristic direct initializer match")},f=S=>{let T=(x=>x.getTypeNode?.()?.getText())(S);if(Ft(T))return V("high","explicit Effect-family type annotation");let v=S.getKind()===s.VariableDeclaration?S.getFirstAncestorByKind(s.VariableStatement)?.isExported()??!1:S.getKind()===s.PropertyDeclaration||S.getKind()===s.MethodDeclaration||S.getKind()===s.GetAccessor?S.getFirstAncestorByKind(s.ClassDeclaration)?.isExported()??!1:!1;if(S.getKind()===s.VariableDeclaration||S.getKind()===s.PropertyDeclaration){let x=S.getInitializer();if(x&&(x.getKind()===s.ArrowFunction||x.getKind()===s.FunctionExpression)){let F=x.getReturnTypeNode()?.getText();if(Ft(F))return V("high","function return type annotated as Effect-family");if(v&&T)return V("medium","explicit exported function API type signature")}if(x?.getKind()===s.CallExpression){let F=x.getTypeArguments().map(j=>j.getText()).join(" ");if(Ft(F))return V("high","call type arguments reference Effect-family types");if(v&&T)return V("medium","explicit exported call-based API type signature")}}if(S.getKind()===s.MethodDeclaration||S.getKind()===s.GetAccessor){let x=S.getReturnTypeNode?.()?.getText();if(Ft(x))return V("high","method/getter return type annotated as Effect-family");if(v&&T)return V("medium","explicit exported method/getter API type signature")}},u=S=>{let b=S.node,T=b.getKind();return T===s.CallExpression?!0:T===s.VariableDeclaration?b.getFirstAncestorByKind(s.VariableStatement)?.isExported()??!1:T===s.FunctionDeclaration||T===s.ClassDeclaration?b.isExported():T===s.PropertyDeclaration||T===s.MethodDeclaration||T===s.GetAccessor?b.getFirstAncestorByKind(s.ClassDeclaration)?.isExported()??!1:!0},g=S=>{for(let b of S){let T=b.getExpression();if(T&&oe(T,c,o))return l(T)}return V("low","heuristic method return match")},p=e.getFilePath(),m=e.getDescendantsOfKind(s.VariableDeclaration);for(let S of m){let b=S.getInitializer();if(b?.getKind()===s.CallExpression&&ao(b.getExpression().getText())&&i.add(S.getName()),t.enableEffectWorkflow&&b?.getKind()===s.CallExpression){let T=b;(uo(T,a,p)||fo(T,a,p))&&i.add(S.getName())}}let h=e.getDescendantsOfKind(s.CallExpression);for(let S of h){let b=S.getExpression(),T=b.getText(),v=S.getStart(),x=!1;if(b.getKind()===s.Identifier)x=i.has(T);else if(b.getKind()===s.PropertyAccessExpression){let F=b,j=F.getExpression().getText(),I=F.getName();if(x=i.has(j)&&I==="run",t.enableEffectWorkflow&&!x&&I==="run"&&S.getArguments().length===1&&!T.includes("runPromise")&&!T.includes("runSync")&&!T.includes("runFork")&&!T.includes("runCallback")&&!n.has(v)){let q=He(S)??`workflow-${r.length+1}`;r.push({name:q,node:S,type:"run",...V("low","workflow-like .run(...) shape heuristic")}),n.add(v);continue}}if(x&&!n.has(v)){let F=He(S)??`workflow-${r.length+1}`;r.push({name:F,node:S,type:"run",...V("medium","workflow builder invocation")}),n.add(v);continue}if(t.enableEffectWorkflow&&b.getKind()===s.PropertyAccessExpression){let F=b,j=F.getExpression().getText(),I=F.getName();if((I==="execute"||I==="executeEncoded")&&i.has(j)&&!n.has(v)){let z=He(S)??`${j}.${I}`;r.push({name:z,node:S,type:"workflow-execute",...V("medium","workflow/activity .execute entrypoint")}),n.add(v);continue}}if((T==="gen"||T.includes(".gen")&&et(S,e,c,t.knownEffectInternalsRoot))&&!n.has(v)){let F=He(S)??Dr(S)??`program-${r.length+1}`;r.push({name:F,node:S,type:"generator",...T==="gen"?V("medium","unqualified gen(...) call"):V("high","Effect-like .gen(...) call")}),n.add(v)}let K=He(S);if(T.includes("pipe")&&xo(S,c)&&!n.has(v)&&b.getKind()!==s.PropertyAccessExpression&&K!==void 0&&!po(S)&&(r.push({name:K,node:S,type:"pipe",...V("medium","exact pipe(...) call with Effect-like args")}),n.add(v)),(Tn(S)||So(S))&&!n.has(v)){let F=He(S)??`run-${r.length+1}`;r.push({name:F,node:S,type:"run",...V("high","recognized Runtime/Effect run* entrypoint")}),n.add(v)}}for(let S of m){if(!go(S)||mo(S))continue;let b=S.getInitializer();if(b){let T=S.getName(),v=ns(b);if(v&&Tn(v)||b.getKind()===s.ObjectLiteralExpression)continue;oe(b,c,o)&&!r.some(K=>K.name===T)&&r.push({name:T,node:S,type:"direct",...f(S)??l(b)})}}let y=e.getStatements();for(let S of y){if(S.getKind()!==s.ExpressionStatement)continue;let b=S.getExpression();if(b.getKind()!==s.CallExpression)continue;let T=b,v=T.getStart();if(n.has(v))continue;let x=T.getExpression(),K=x.getText();if(Tn(T)){let F=`run-${r.length+1}`;r.push({name:F,node:T,type:"run",...V("high","recognized top-level run* entrypoint")}),n.add(v);continue}if(K.endsWith(".pipe")||K==="pipe"){let F=T.getArguments(),j=F[F.length-1];if(!j)continue;let I=j.getText();if(I.includes(".runMain")||I.includes(".runPromise")||I.includes(".runSync")||I.includes(".runFork")){let z;x.getKind()===s.PropertyAccessExpression&&(z=x.getExpression().getText().split(".").pop());let Y=z&&!r.some(Z=>Z.name===z)?z:`entrypoint-${r.length+1}`;r.push({name:Y,node:T,type:"run",...V("medium","top-level pipe(...).run* terminator pattern")}),n.add(v)}}if(x.getKind()===s.Identifier&&T.getArguments().length>=1){let F=x.getText();ho(T,e)&&!r.some(I=>I.name===F)&&(r.push({name:F,node:T,type:"run",...V("low","indirect run wrapper body heuristic")}),n.add(v))}}let N=["Data.TaggedError","Data.TaggedClass","Data.Class","Data.Error","Schema.Class","Schema.TaggedClass","Schema.TaggedError","Schema.TaggedRequest","Context.Tag","Context.Reference","Effect.Service"],E=e.getDescendantsOfKind(s.ClassDeclaration);for(let S of E){let b=S.getName();if(!b||r.some(x=>x.name===b))continue;S.getHeritageClauses().some(x=>{let K=x.getText();return N.some(F=>K.includes(F))})&&r.push({name:b,node:S,type:"class",...V("medium","known Data/Schema/Context class pattern")})}let $=E.filter(S=>{let b=S.getParent();return b===e||b?.getParent()===e});for(let S of $){let b=S.getName()??"Anonymous",T=S.getMembers(),v=T.filter(F=>F.getKind()===s.PropertyDeclaration);for(let F of v){let j=F.getInitializer();if(!j)continue;let I=F.getName(),q=`${b}.${I}`;r.some(z=>z.name===q)||oe(j,c,o)&&r.push({name:q,node:F,type:"classProperty",...f(F)??l(j)})}let x=T.filter(F=>F.getKind()===s.MethodDeclaration);for(let F of x){let j=F.getName(),I=`${b}.${j}`;if(r.some(Z=>Z.name===I))continue;let q=F.getBody();if(!q)continue;let z=q.getDescendantsOfKind(s.ReturnStatement);z.some(Z=>{let L=Z.getExpression();return L?oe(L,c,o):!1})&&r.push({name:I,node:F,type:"classMethod",...f(F)??g(z)})}let K=T.filter(F=>F.getKind()===s.GetAccessor);for(let F of K){let j=F.getName(),I=`${b}.${j}`;if(r.some(Z=>Z.name===I))continue;let q=F.getBody();if(!q)continue;let z=q.getDescendantsOfKind(s.ReturnStatement);z.some(Z=>{let L=Z.getExpression();return L?oe(L,c,o):!1})&&r.push({name:I,node:F,type:"classMethod",...f(F)??g(z)})}}return r.filter(S=>{let b=t.minDiscoveryConfidence??"low",T=S.discoveryConfidence??"low";return!(rs[T]<rs[b]||t.onlyExportedPrograms&&!u(S))})},xo=(e,t)=>e.getArguments().map(n=>n.getText()).some(n=>[...t].some(i=>n.includes(`${i}.`)));function cs(e){let{SyntaxKind:t}=w(),r=[],s=e.getProject().getTypeChecker(),n=e.getDescendantsOfKind(t.ClassDeclaration);for(let i of n){let c=i.getName();if(!c)continue;let o=i.getExtends();if(!o)continue;let a=o.getText();if(!a.includes("Context.Tag")&&!a.includes("Effect.Service"))continue;let d=o.getTypeArguments();if(d.length<2){let f=o.getExpression();f&&"getTypeArguments"in f&&typeof f.getTypeArguments=="function"&&(d=f.getTypeArguments())}if(d.length<2)continue;let l=d[1];if(l)try{let f=s.getTypeAtLocation(l),u=[],g=[];for(let y of f.getProperties()){let N=y.getName();if(N.startsWith("_")||N==="constructor")continue;s.getTypeOfSymbolAtLocation(y,l).getCallSignatures().length>0?u.push(N):g.push(N)}let p=i.getText(),m=p.includes("Equal.symbol")||p.includes("[Equal")||p.includes("equal("),h=p.includes("Hash.symbol")||p.includes("[Hash")||p.includes("hash(");r.push({tagId:c,methods:u,properties:g,...m?{hasCustomEquality:m}:{},...h?{hasCustomHash:h}:{}})}catch{}}for(let i of n){let c=i.getName();if(!c)continue;let o=i.getExtends();if(!o)continue;let a=o.getText();if(!a.includes("Data.Class")&&!a.includes("Data.TaggedClass")||r.some(u=>u.tagId===c))continue;let d=i.getText(),l=d.includes("Equal.symbol")||d.includes("[Equal")||d.includes("equal("),f=d.includes("Hash.symbol")||d.includes("[Hash")||d.includes("hash(");(l||f)&&r.push({tagId:c,methods:[],properties:[],hasCustomEquality:l,hasCustomHash:f})}return r}import{Effect as xe,Option as yt}from"effect";import{Effect as ee,Option as Eo}from"effect";var Rt=(e,t,r,s,n,i)=>ee.gen(function*(){let{SyntaxKind:c}=w(),o=e.getArguments(),a=e.getExpression(),d=a.getKind()===c.PropertyAccessExpression&&a.getName()==="pipe",l=d?a.getExpression():o[0],f=d?o:o.slice(1);if(!l)return[];let u=ds(l),g=u.getSourceFile(),p=g.getFilePath(),m=t.getProject();if(m.getSourceFile(p)){let S=m.getSourceFile(p);S&&(g=S)}else{let S=m.addSourceFileAtPath(p);S&&(g=S)}let h=yield*M(u,g,g.getFilePath(),s,n,i),y=[];for(let S of f)if(S){let b=yield*M(S,t,r,s,n,i);y.push(b)}let N;try{let S=t.getProject().getTypeChecker(),b=[],T=Ze(l,S);T&&b.push(T);for(let v of f)if(v){let x=Ze(v,S);x&&b.push(x)}b.length>0&&(N=b)}catch{}let E={id:C(),type:"pipe",initial:h,transformations:y,...N?{typeFlow:N}:{}};return[{...E,displayName:G(E),semanticRole:Q(E)}]}),M=(e,t,r,s,n,i,c)=>ee.gen(function*(){let{SyntaxKind:o}=w();if(e.getKind()===o.ArrowFunction||e.getKind()===o.FunctionExpression){let l=e.getBody();if(!l){let u={id:C(),type:"unknown",reason:"Function has no body",sourceCode:e.getText().slice(0,100),location:_(e,r,s.includeLocations??!1)};return i.unknownCount++,u}if(l.getKind()===o.Block){let p=l.getStatements().find(m=>m.getKind()===o.ReturnStatement)?.getExpression();if(p)return yield*M(p,t,r,s,n,i,c)}else return yield*M(l,t,r,s,n,i,c);let f={id:C(),type:"unknown",reason:"Function does not return an Effect expression",sourceCode:e.getText().slice(0,100),location:_(e,r,s.includeLocations??!1)};return i.unknownCount++,f}if(e.getKind()===o.CallExpression)return yield*vn(e,t,r,s,n,i,c);if(e.getKind()===o.PropertyAccessExpression){let d=e.getText();if(d==="Fiber.roots"||d==="Fiber.getCurrentFiber"){let l=d==="Fiber.roots"?"roots":"getCurrentFiber";return{id:C(),type:"fiber",operation:l,isScoped:!1,isDaemon:!1,location:_(e,r,s.includeLocations??!1)}}if($t(d,Le(t),t)){let l={id:C(),type:"effect",callee:d,location:_(e,r,s.includeLocations??!1)};return i.totalEffects++,l}}if(e.getKind()===o.Identifier){let d={id:C(),type:"effect",callee:e.getText(),location:_(e,r,s.includeLocations??!1)};return i.totalEffects++,d}if(e.getKind()===o.ObjectLiteralExpression){let d=e,l=new Set(["onNone","onSome","onFailure","onSuccess","onLeft","onRight"]),f=d.getProperties(),u=[],g=!1;for(let p of f){if(p.getKind()!==o.PropertyAssignment)continue;let m=p,h=m.getName();if(!l.has(h))continue;g=!0;let y=m.getInitializer();if(y){let N=yield*M(y,t,r,s,n,i,c);u.push(N)}}if(g&&u.length>0)return u.length===1?u[0]:{id:C(),type:"parallel",callee:"match-handlers",mode:"sequential",children:u,location:_(e,r,s.includeLocations??!1)}}let a={id:C(),type:"unknown",reason:"Could not determine effect type",sourceCode:e.getText().slice(0,100),location:_(e,r,s.includeLocations??!1)};return i.unknownCount++,a}),vn=(e,t,r,s,n,i,c)=>ee.gen(function*(){let{SyntaxKind:o}=w(),a=e.getExpression().getText(),d=wn(a,t),l=/([A-Za-z_$][\w$]*)$/.exec(d)?.[1]??d,f=_(e,r,s.includeLocations??!1);if(a==="pipe"&&e.getArguments().length>=1){let L=yield*Rt(e,t,r,s,n,i);if(L.length>0&&L[0])return L[0]}if(d==="Context.pick"||d==="Context.omit"){let L={id:C(),type:"effect",callee:d,description:"context",location:f};return i.totalEffects++,{...L,displayName:G(L),semanticRole:Q(L)}}if(d.startsWith("Layer."))return yield*wo(e,d,t,r,s,n,i);if(d.startsWith("Stream."))return yield*To(e,d,t,r,s,n,i);if(d.startsWith("Channel."))return yield*vo(e,d,t,r,s,n,i);if(a.startsWith("Sink."))return yield*$o(e,a,t,r,s,n,i);if(a.startsWith("Queue.")||a.startsWith("PubSub.")||a.startsWith("Deferred.")||a.startsWith("Semaphore.")||a.startsWith("Mailbox.")||a.startsWith("SubscriptionRef.")||a.startsWith("RateLimiter.")||a.startsWith("PartitionedSemaphore.")||a.startsWith("FiberHandle.")||a.startsWith("FiberSet.")||a.startsWith("FiberMap.")||a.startsWith("Cache.")||a.startsWith("ScopedCache.")||a.startsWith("RcRef.")||a.includes(".RcRef.")||a.startsWith("RcMap.")||a.includes(".RcMap.")||a.startsWith("Reloadable.")||a.includes(".Reloadable.")||a.includes("makeLatch")||a.includes("Latch."))return yield*Fo(e,a,t,r,s,n,i);if(un.some(L=>a.includes(L)||a.startsWith(L)))return yield*Ao(e,a,t,r,s,n,i);if(hn.some(L=>a.includes(L)))return yield*Ro(e,a,t,r,s,n,i);if(a.includes(".all")||a==="all")return yield*Po(e,a,t,r,s,n,i);if(a.includes(".race")||a==="race")return yield*Mo(e,a,t,r,s,n,i);if(cn.some(L=>a.includes(L)))return yield*Oo(e,a,t,r,s,n,i);if(a.includes(".retry"))return yield*Lo(e,t,r,s,n,i);if(a.includes(".timeout"))return yield*Wo(e,t,r,s,n,i);let g=new Set(["acquireRelease","acquireUseRelease","ensuring","addFinalizer","onExit","onError","parallelFinalizers","sequentialFinalizers","finalizersMask","using","withEarlyRelease"]),p=["acquireRelease","acquireUseRelease"],m=L=>g.has(L)||p.some(H=>L.startsWith(H));if(l==="pipe"&&e.getExpression().getKind()===o.PropertyAccessExpression){let H=e.getExpression().getExpression();if(H.getKind()===o.CallExpression){let ge=H,de=ge.getExpression().getText(),ne=/([A-Za-z_$][\w$]*)$/.exec(de)?.[1]??de;if(m(ne))return yield*ls(ge,ne,t,r,s,n,i)}}if(m(l))return yield*ls(e,l,t,r,s,n,i);if(ln.some(L=>a.includes(L)))return yield*Ko(e,a,t,r,s,n,i);if(dn.some(L=>a.includes(L)))return yield*jo(e,a,t,r,s,n,i);if(Lr(a))return yield*Ho(e,a,t,r,s,n,i);if(Kr(a))return Bo(e,a,r,s);if(Br(a))return yield*qo(e,a,t,r,s,n,i);if(zr(a))return zo(e,a,r,s);if(_r(a))return yield*_o(e,a,r,s);i.totalEffects++;let h,N=["Effect.sync","Effect.promise","Effect.async","Effect.asyncEffect","Effect.tryPromise","Effect.suspend"].some(L=>a.includes(L))&&e.getArguments().length>0&&e.getArguments()[0],E;if(N){let L=e.getArguments()[0],{SyntaxKind:H}=w();if(L.getKind()===H.ArrowFunction||L.getKind()===H.FunctionExpression){let de=L,ne=de.getBody(),we=[];if(ne){if(ne.getKind()===H.Block){let ve=ne;for(let te of ve.getStatements())if(te.getKind()===H.ReturnStatement){let A=te.getExpression();if(A&&$t(A.getText(),Le(t),t)){let W=yield*M(A,t,r,s,n,i,void 0);we.push(W)}}else if(te.getKind()===H.ExpressionStatement){let A=te.getExpression();if(A.getKind()===H.CallExpression&&et(A,t,Le(t),s.knownEffectInternalsRoot)){let W=yield*M(A,t,r,s,n,i,void 0);we.push(W)}}}else if($t(ne.getText(),Le(t),t)){let ve=yield*M(ne,t,r,s,n,i,void 0);we.push(ve)}}if(we.length>0&&(h=we),a.includes("Effect.async")||a.includes("Effect.asyncEffect")){let ve=de.getParameters()[0]?.getName?.()??"resume",te=0,A=Ie=>{if(Ie.getKind()===H.CallExpression){let ut=Ie.getExpression();ut.getKind()===H.Identifier&&ut.getText()===ve&&te++}Ie.getChildren().forEach(A)};ne&&A(ne);let W=!1;if(ne?.getKind()===H.Block){let Ie=ne;for(let nn of Ie.getStatements())if(nn.getKind()===H.ReturnStatement){let ut=nn.getExpression();if(ut){let xr=ut.getKind();if(xr===H.ArrowFunction||xr===H.FunctionExpression){W=!0;break}}}}else ne&&(ne.getKind()===H.ArrowFunction||ne.getKind()===H.FunctionExpression)&&(W=!0);E={resumeParamName:ve,resumeCallCount:te,returnsCanceller:W}}}}let $=_e(e),S=t.getProject().getTypeChecker(),b=Ze(e,S),T=wt(e,S),v=bo(e,t),x,K=e.getExpression();if(K.getKind()===w().SyntaxKind.PropertyAccessExpression){let L=K,H=L.getExpression().getText(),ge=L.getName();if(c){let de=c.get(H);de&&(x={serviceId:de,methodName:ge})}!x&&T?.length===1&&T[0]&&(x={serviceId:T[0].serviceId,methodName:ge})}let F;if(a==="Effect.provide"||a.startsWith("Effect.")&&a.includes(".provide")&&!a.includes("provideService")){let L=e.getArguments(),H=(L.length>=2?L[1]:L[0])?.getText()??"";/Runtime\.|defaultRuntime|\.runSync|\.runPromise|\.runFork|\.runCallback/.test(H)||/^\s*runtime\s*$|^\s*rt\s*$/i.test(H.trim())?F="runtime":H.includes("Layer.")?F="layer":F="context"}let j;a.endsWith(".sync")||a.endsWith(".succeed")||a.endsWith(".fail")||a.endsWith(".try")||a.endsWith(".suspend")?j="sync":a.endsWith(".promise")?j="promise":a.endsWith(".async")||a.endsWith(".asyncEffect")?j="async":a.endsWith(".never")?j="never":a.endsWith(".void")?j="void":a.endsWith(".fromNullable")?j="fromNullable":a.endsWith(".fn")?j="fn":a.endsWith(".fnUntraced")&&(j="fnUntraced");let I,q=["currentConcurrency","currentLogLevel","currentScheduler","currentTracerEnabled","currentLogSpan","currentLogAnnotations","currentContext","currentRequestBatching","currentMaxOpsBeforeYield","currentSupervisor","currentMetricLabels","interruptedCause","unhandledLogLevel"];for(let L of q)if(a.includes(L)){I=L;break}let z;if(j==="fn"||j==="fnUntraced"){let L=e.getArguments();if(L.length>0){let H=L[0].getText(),ge=/^["'`](.+?)["'`]$/.exec(H);ge&&(z=ge[1])}}let Y={id:C(),type:"effect",callee:a,description:v?"service-call":Gr(a,Le(t)),location:f,jsdocDescription:$,jsdocTags:Ye(e),typeSignature:b,requiredServices:T,serviceCall:v,serviceMethod:x,callbackBody:h,...E?{asyncCallback:E}:{},...F?{provideKind:F}:{},...j?{constructorKind:j}:{},...I?{fiberRefName:I}:{},...z?{tracedName:z}:{}};return{...Y,displayName:G(Y),semanticRole:Q(Y)}}),bo=(e,t)=>{let{SyntaxKind:r}=w(),s=e.getExpression();if(s.getKind()!==r.PropertyAccessExpression)return;let n=s,i=n.getExpression(),c=n.getName(),o=i.getText(),a=o.split(".")[0]??o;if(!xn.has(a))try{let d=i.getType(),l=d.getSymbol()??d.getAliasSymbol();if(!l)return;let f=l.getName();return!f||f==="__type"||f==="unknown"||f==="any"||Hr.has(f)?void 0:{serviceType:f,methodName:c,objectName:o}}catch{return}};function At(e){let t=e.getExpression().getText(),r=e.getSourceFile(),s=wn(t,r);return s.startsWith("Layer.")||s.startsWith("Effect.")||t==="pipe"||t.endsWith(".pipe")}function No(e,t,r){let{SyntaxKind:s}=w(),n=e.getSourceFile(),i=n.getProject(),c=n.getFilePath(),a=t.getImportDeclaration().getModuleSpecifierValue();if(!a?.startsWith("."))return;let d=Xe(i,c,a);if(!d){let m=mt(c,a);if(m){let h=i.addSourceFileAtPath(m);h&&(d=h)}}if(!d)return;d=i.getSourceFile(d.getFilePath())??d;let l=m=>{if(m.getKind()===s.VariableDeclaration){let y=m.getInitializer();if(y?.getKind()===s.CallExpression&&r(y))return y}if(m.getKind()===s.VariableStatement){let h=m.getDeclarationList();for(let y of h.getDeclarations()){let N=y.getInitializer();if(N?.getKind()===s.CallExpression&&r(N))return N}}},f=t.getName(),u=d.getExportedDeclarations(),g=u.get(f)??[];for(let m of g){let h=l(m);if(h)return h}let p=t.getTargetName?.();if(p&&p!==f)for(let m of u.get(p)??[]){let h=l(m);if(h)return h}for(let[,m]of u)for(let h of m){let y=l(h);if(y)return y}}function Co(e,t,r){let{SyntaxKind:s}=w(),n=e.getSourceFile(),i=n.getProject(),c=n.getFilePath(),o=t.getModuleSpecifierValue();if(!o?.startsWith("."))return;let a=Xe(i,c,o);if(!a){let l=mt(c,o);if(l){let f=i.addSourceFileAtPath(l);f&&(a=f)}}if(!a)return;a=i.getSourceFile(a.getFilePath())??a;let d=l=>{if(l.getKind()===s.VariableDeclaration){let u=l.getInitializer();if(u?.getKind()===s.CallExpression&&r(u))return u}if(l.getKind()===s.VariableStatement){let f=l.getDeclarationList();for(let u of f.getDeclarations()){let g=u.getInitializer();if(g?.getKind()===s.CallExpression&&r(g))return g}}};for(let l of a.getDefaultExportSymbol()?.getDeclarations()??[]){let f=d(l);if(f)return f}for(let l of a.getExportedDeclarations().get("default")??[]){let f=d(l);if(f)return f}}function ds(e){let{SyntaxKind:t}=w();if(e.getKind()!==t.Identifier)return e;let r=e,s=r.getText(),n=r.getSymbol(),i=n?.getValueDeclaration(),c=i?.getKind()===t.ImportSpecifier?i:void 0;if(!c&&n){let o=n.getDeclarations().find(a=>a.getKind()===t.ImportSpecifier);o&&(c=o)}if(!c){let o=r.getSourceFile();for(let a of o.getImportDeclarations()){if(a.getDefaultImport()?.getText()===s){let f=Co(r,a,At);if(f)return f}let l=a.getNamedImports().find(f=>f.getName()===s||f.getAliasNode()?.getText()===s);if(l){c=l;break}}}if(c){let o=No(r,c,At);if(o)return o;n=n?.getImmediatelyAliasedSymbol()??n?.getAliasedSymbol(),i=n?.getValueDeclaration()}if(i?.getKind()===t.ExportSpecifier&&(n=n?.getImmediatelyAliasedSymbol()??n?.getAliasedSymbol(),i=n?.getValueDeclaration()),n&&i?.getKind()!==t.VariableDeclaration){for(let o of n.getDeclarations())if(o.getKind()===t.VariableDeclaration){let d=o.getInitializer();if(d?.getKind()===t.CallExpression&&At(d))return d}}if(i?.getKind()===t.VariableDeclaration){let a=i.getInitializer();if(a?.getKind()===t.CallExpression&&At(a))return a}return e}var wo=(e,t,r,s,n,i,c)=>ee.gen(function*(){let o=e.getArguments(),a=[],{SyntaxKind:d}=w();if(o.length>0&&o[0]){let b=o[0];if(t.includes("mergeAll")&&b.getKind()===d.ArrayLiteralExpression){let v=b.getElements();for(let x of v){let K=yield*M(x,r,s,n,i,c);a.push(K)}}else for(let v of o){if(!v)continue;let x=ds(v),K=x.getSourceFile(),F=yield*M(x,K,K.getFilePath(),n,i,c);a.push(F)}}let l=t.includes("merge")||t.includes("mergeAll"),f;t.includes("fresh")?f="fresh":t.includes("memoize")?f="memoized":t.includes("scoped")?f="scoped":f="default";let u=[],g=b=>{if(b.getKind()===d.Identifier)return b.getText();if(b.getKind()===d.PropertyAccessExpression){let T=b,v=T.getExpression();return v.getKind()===d.Identifier?v.getText():T.getText().split(".")[0]}};if((t.includes("succeed")||t.includes("sync")||t.includes("effect")||t.includes("scoped")||t.includes("scopedDiscard")||t.includes("effectDiscard"))&&o.length>0&&o[0]){let b=g(o[0]);b&&u.push(b)}let p=t.includes("provide")&&!t.includes("provideService"),m=new Set;if(p&&o.length>=1&&o[0]){let b=g(o[0]);b&&m.add(b)}if(p&&o.length>=2&&o[1]){let b=g(o[1]);b&&m.add(b);let T=g(o[0]);T&&u.push(T)}if(t.includes("provideService")&&o.length>0&&o[0]){let b=g(o[0]);b&&u.push(b)}let h=b=>{if(b.type==="effect"){let v=b;for(let K of v.requiredServices??[])m.add(K.serviceId);let x=v.callee??"";(/^[A-Z][A-Za-z0-9_]*(Service|Tag)$/.test(x)||x.endsWith(".Tag"))&&m.add(x)}else if(b.type==="layer"){let v=b;for(let x of v.requires??[])m.add(x)}Eo.getOrElse(P(b),()=>[]).forEach(h)};if(a.forEach(h),m.size===0)try{let b=Tr(e);b?.requiredType&&b.requiredType!=="never"&&Jr(b.requiredType).forEach(v=>m.add(v))}catch{}let y=t.replace(/^Layer\./,"").replace(/^[a-zA-Z]+\./,""),E=new Set(["catchAll","catchAllCause","orDie","orElse","retry","tap","mapError","mapErrorCause","build","launch","toRuntime","passthrough","project","flatMap","flatten","annotateLogs","annotateSpans","setConfigProvider","setClock","setTracer","locally","withSpan","withLogger","withTracer","withClock","mock","suspend","unwrapEffect","unwrapScoped"]).has(y)?`Layer.${y}`:void 0,$=t.includes("MemoMap")||a.some(b=>b.type==="layer"&&b.isMemoMap===!0),S={id:C(),type:"layer",name:E,operations:a,isMerged:l,provides:u.length>0?u:void 0,requires:m.size>0?Array.from(m).sort():void 0,lifecycle:f,...$?{isMemoMap:!0}:{},location:_(e,s,n.includeLocations??!1)};return{...S,displayName:G(S),semanticRole:Q(S)}});function To(e,t,r,s,n,i,c){return ee.gen(function*(){let o=e.getArguments(),a;o.length>0&&o[0]?a=yield*M(o[0],r,s,n,i,c):a={id:C(),type:"unknown",reason:"Stream source not determined"};let d=t.replace(/^Stream\./,"")||"unknown",l;t.startsWith("Stream.")&&(d==="fromIterable"||d==="fromChunk"||d==="fromChunkQueue"?l="fromIterable":d==="fromArray"?l="fromArray":d==="fromQueue"||d==="fromChunkQueue"?l="fromQueue":d==="fromPubSub"||d==="fromChunkPubSub"?l="fromPubSub":d==="fromEffect"||d==="unwrap"||d==="unwrapScoped"?l="fromEffect":d==="fromAsyncIterable"?l="fromAsyncIterable":d==="fromReadableStream"||d==="fromReadableStreamByob"?l="fromReadableStream":d==="fromEventListener"?l="fromEventListener":d==="fromSchedule"?l="fromSchedule":d==="range"?l="range":d==="tick"?l="tick":d==="iterate"||d==="iterateEffect"?l="iterate":d==="unfold"||d==="unfoldEffect"||d==="unfoldChunk"||d==="unfoldChunkEffect"?l="unfold":d==="make"?l="make":d==="empty"?l="empty":d==="never"?l="never":d==="succeed"||d==="sync"?l="succeed":(d==="fail"||d==="failSync"||d==="failCause"||d==="failCauseSync")&&(l="fail"));let f=x=>l!==void 0?"constructor":x.startsWith("run")?"sink":x==="toQueue"||x==="toPubSub"||x==="toReadableStream"||x==="toAsyncIterable"||x==="toChannel"?"conversion":x.includes("pipeThroughChannel")||x.includes("Channel")||x.includes("channel")||x.includes("duplex")?"channel":x.includes("grouped")||x.includes("sliding")||x.includes("groupBy")||x.includes("aggregate")||x.includes("window")?"windowing":x.includes("broadcast")||x==="share"?"broadcasting":x.includes("haltAfter")||x.includes("haltWhen")||x.includes("interruptAfter")?"halting":x.includes("decodeText")||x.includes("encodeText")||x.includes("splitLines")?"text":x.includes("merge")||x==="concat"||x.includes("interleave")||x.includes("zip")?"merge":x.includes("buffer")||x.includes("debounce")||x.includes("throttle")?"backpressure":x.includes("catchAll")||x.includes("catchTag")||x.includes("orElse")||x.includes("orDie")||x.includes("retry")?"error":x.includes("filter")||x.includes("take")||x.includes("drop")||x.includes("head")||x==="first"||x==="last"?"filter":x.includes("acquireRelease")||x.includes("scoped")||x.includes("ensuring")||x.includes("onDone")||x.includes("onError")?"resource":x.includes("provide")||x.includes("withSpan")||x.includes("annotate")?"context":x.includes("map")||x.includes("tap")||x.includes("flatMap")||x.includes("mapChunk")||x.includes("scan")||x.includes("transduce")?"transform":"other",u=d.includes("Effect")||d.startsWith("run")||d.includes("tap"),g=f(d),p=g==="filter"?"fewer":g==="merge"||g==="broadcasting"?"more":g==="halting"||g==="sink"||g==="windowing"?"fewer":"unknown",m,h;(d==="grouped"||d==="groupedWithin"||d.includes("sliding")||d.includes("Sliding"))&&o.length>0&&o[0]&&(m=pt(o[0]),(d.includes("sliding")||d.includes("Sliding"))&&o.length>1&&o[1]&&(h=pt(o[1])));let N={operation:d,isEffectful:u,estimatedCardinality:p,category:g,...m!==void 0?{windowSize:m}:{},...h!==void 0?{stride:h}:{}},E;d.startsWith("run")&&(E=d);let $;d.includes("buffer")?$="buffer":d.includes("drop")||d.includes("Drop")?$="drop":(d.includes("sliding")||d.includes("Sliding"))&&($="sliding");let S=a,b=[N],T=l;if(a.type==="stream"){let x=a;b=[...x.pipeline,N],S=x.source,!T&&x.constructorType&&(T=x.constructorType),!E&&x.sink&&(E=x.sink),!$&&x.backpressureStrategy&&($=x.backpressureStrategy)}let v={id:C(),type:"stream",source:S,pipeline:b,sink:E,backpressureStrategy:$,constructorType:T,location:_(e,s,n.includeLocations??!1)};return{...v,displayName:G(v),semanticRole:Q(v)}})}function ko(e){return e==="fromReadableStream"||e==="fromWritableStream"||e==="fromDuplexStream"||e==="make"||e==="succeed"||e==="fail"||e==="empty"||e==="never"?"constructor":e.includes("map")||e.includes("flatMap")||e.includes("filter")||e.includes("concat")||e.includes("zip")?"transform":e.includes("pipe")||e==="pipeTo"||e==="pipeThrough"?"pipe":"other"}function vo(e,t,r,s,n,i,c){return ee.gen(function*(){let o=e.getArguments(),a;o.length>0&&o[0]&&(a=yield*M(o[0],r,s,n,i,c));let d=t.replace(/^Channel\./,"")||"unknown",l=[{operation:d,category:ko(d)}];if(a?.type==="channel"){let u=a;l.unshift(...u.pipeline),a=u.source}let f={id:C(),type:"channel",source:a,pipeline:l,location:_(e,s,n.includeLocations??!1)};return{...f,displayName:G(f),semanticRole:Q(f)}})}function Io(e){return e==="forEach"||e==="forEachWhile"||e==="run"||e==="runDrain"||e==="runFor"||e==="make"||e==="fromEffect"||e==="fromQueue"?"constructor":e.includes("map")||e.includes("contramap")||e.includes("filter")||e.includes("zip")?"transform":"other"}function $o(e,t,r,s,n,i,c){return ee.gen(function*(){let o=e.getArguments(),a;o.length>0&&o[0]&&(a=yield*M(o[0],r,s,n,i,c));let d=t.replace(/^Sink\./,"")||"unknown",l=[{operation:d,category:Io(d)}];if(a?.type==="sink"){let u=a;l.unshift(...u.pipeline),a=u.source}let f={id:C(),type:"sink",source:a,pipeline:l,location:_(e,s,n.includeLocations??!1)};return{...f,displayName:G(f),semanticRole:Q(f)}})}function Fo(e,t,r,s,n,i,c){let{SyntaxKind:o}=w(),a="queue",d="create",l,f,u;t.startsWith("Queue.")?(a="queue",t.includes("bounded")?l="bounded":t.includes("unbounded")?l="unbounded":t.includes("sliding")?l="sliding":t.includes("dropping")&&(l="dropping"),t.includes("offer")||t.includes("offerAll")?d="offer":t.includes("take")||t.includes("takeAll")||t.includes("poll")?d="take":d="create"):t.startsWith("PubSub.")?(a="pubsub",t.includes("bounded")?l="bounded":t.includes("unbounded")&&(l="unbounded"),t.includes("publish")?d="publish":t.includes("subscribe")?d="subscribe":d="create"):t.startsWith("Deferred.")?(a="deferred",t.includes("succeed")?d="succeed":t.includes("fail")?d="fail":t.includes("await")?d="await":d="create"):t.startsWith("Semaphore.")?(a="semaphore",t.includes("withPermit")?d="withPermit":t.includes("take")?d="take":t.includes("release")?d="release":t.includes("available")?d="available":d="create"):t.startsWith("Mailbox.")?(a="mailbox",t.includes("offer")?d="offer":t.includes("takeAll")?d="takeAll":t.includes("take")?d="take":t.includes("end")?d="end":t.includes("toStream")?d="toStream":d="create"):t.startsWith("SubscriptionRef.")?(a="subscriptionRef",t.includes("changes")?d="changes":t.includes("get")?d="get":t.includes("set")?d="set":t.includes("update")?d="update":d="create"):t.includes("makeLatch")||t.includes("Latch.")?(a="latch",t.includes("open")?d="open":t.includes("close")?d="close":t.includes("await")||t.includes("whenOpen")?d="await":d="create"):t.startsWith("FiberHandle.")?(a="fiberHandle",t.includes("run")?d="run":t.includes("await")?d="await":d="create"):t.startsWith("FiberSet.")?(a="fiberSet",t.includes("run")?d="run":t.includes("join")?d="await":d="create"):t.startsWith("FiberMap.")?(a="fiberMap",t.includes("run")?d="run":t.includes("join")?d="await":d="create"):t.startsWith("RateLimiter.")?(a="rateLimiter",t.includes("withCost")?d="withPermit":d="create"):t.startsWith("ScopedCache.")?(a="scopedCache",t.includes("make")||t.includes("Make")?d="create":t.includes("get")&&!t.includes("getOrElse")||t.includes("getOrElse")?d="get":t.includes("set")||t.includes("Set")?d="set":t.includes("invalidate")?d="invalidate":t.includes("contains")?d="contains":d="create"):t.startsWith("Cache.")?(a="cache",t.includes("make")||t.includes("Make")?d="create":t.includes("get")&&!t.includes("getOrElse")||t.includes("getOrElse")?d="get":t.includes("set")||t.includes("Set")?d="set":t.includes("invalidate")?d="invalidate":t.includes("contains")?d="contains":d="create"):t.startsWith("Reloadable.")||t.includes(".Reloadable.")?(a="reloadable",t.includes("make")||t.includes("Make")?d="create":t.includes("get")&&!t.includes("reload")?d="get":t.includes("reload")?d="reload":d="create"):t.startsWith("RcMap.")||t.includes(".RcMap.")?(a="rcMap",t.includes("make")||t.includes("Make")?d="create":t.includes("get")?d="get":t.includes("set")||t.includes("Set")?d="set":t.includes("update")?d="update":d="create"):(t.startsWith("RcRef.")||t.includes(".RcRef."))&&(a="rcRef",t.includes("make")||t.includes("Make")?d="create":t.includes("get")?d="get":t.includes("set")||t.includes("Set")?d="set":t.includes("update")?d="update":d="create");let g=e.getArguments();if(g.length>0&&l==="bounded"){let h=g[0];h?.getKind()===o.NumericLiteral&&(f=Number.parseInt(h.getText(),10))}a==="semaphore"&&(d==="take"||d==="release")&&g.length>0&&g[0]&&(u=pt(g[0]));let p;if(a==="fiberHandle"&&d==="run")for(let h of g){let y=h.getText();y.includes("onlyIfMissing")&&(p={onlyIfMissing:y.includes("true")})}if(a==="mailbox"&&d==="toStream"||a==="subscriptionRef"&&d==="changes"){let h=a==="mailbox"?"fromMailbox":"fromSubscriptionRef",y={id:C(),type:"concurrency-primitive",primitive:a,operation:d,location:_(e,s,n.includeLocations??!1)},N={id:C(),type:"stream",source:{...y,displayName:G(y),semanticRole:Q(y)},pipeline:[],constructorType:h,location:_(e,s,n.includeLocations??!1)};return ee.succeed({...N,displayName:G(N),semanticRole:Q(N)})}let m={id:C(),type:"concurrency-primitive",primitive:a,operation:d,strategy:l,capacity:f,...u!==void 0?{permitCount:u}:{},...p?{lifecycleOptions:p}:{},location:_(e,s,n.includeLocations??!1)};return ee.succeed({...m,displayName:G(m),semanticRole:Q(m)})}function Ao(e,t,r,s,n,i,c){return ee.gen(function*(){let o=e.getArguments(),a="fork",d=!1,l=!1,f;t.startsWith("Fiber.")?t.includes("awaitAll")?a="awaitAll":t.includes("join")?a="join":t.includes("await")?a="await":t.includes("interruptFork")?a="interruptFork":t.includes("interrupt")?a="interrupt":t.includes("poll")?a="poll":t.includes("status")?a="status":t.includes("all")?a="all":t.includes("children")?a="children":t.includes("dump")?a="dump":t.includes("scoped")?(a="scoped",d=!0):t.includes("inheritAll")?a="inheritAll":t.includes("mapFiber")?a="mapFiber":t.includes("mapEffect")?a="mapEffect":t.includes("map")?a="map":t.includes("roots")?a="roots":t.includes("getCurrentFiber")&&(a="getCurrentFiber"):t.includes("forkWithErrorHandler")?a="forkWithErrorHandler":t.includes("forkAll")?a="forkAll":t.includes("forkIn")?a="forkIn":t.includes("fork")&&(t.includes("forkDaemon")?(a="forkDaemon",l=!0):t.includes("forkScoped")?(a="forkScoped",d=!0):a="fork"),(a==="fork"||a==="forkScoped"||a==="forkDaemon"||a==="forkAll"||a==="forkIn"||a==="forkWithErrorHandler")&&o.length>0&&o[0]&&(f=yield*M(o[0],r,s,n,i,c));let u;if(d)u="safe";else{let p=e.getParent();for(;p;){let m=p.getText?.();if(m&&(m.includes("Effect.scoped")||m.includes("Scope.make"))){u="safe";break}if(p=p.getParent(),p&&p===r)break}}let g={id:C(),type:"fiber",operation:a,fiberSource:f,isScoped:d,isDaemon:l,...u?{scopeContext:u}:{},location:_(e,s,n.includeLocations??!1)};return{...g,displayName:G(g),semanticRole:Q(g)}})}function Ro(e,t,r,s,n,i,c){return ee.gen(function*(){let o=e.getArguments(),{SyntaxKind:a}=w(),d;t.includes("uninterruptibleMask")?d="uninterruptibleMask":t.includes("interruptibleMask")?d="interruptibleMask":t.includes("uninterruptible")?d="uninterruptible":t.includes("interruptible")?d="interruptible":t.includes("onInterrupt")?d="onInterrupt":t.includes("disconnect")?d="disconnect":t.includes("allowInterrupt")?d="allowInterrupt":t.includes("interruptWith")?d="interruptWith":d="interrupt";let l,f,u=e.getExpression();u.getKind()===a.PropertyAccessExpression?(l=yield*M(u.getExpression(),r,s,n,i,c),o.length>0&&o[0]&&(f=yield*M(o[0],r,s,n,i,c))):o.length>0&&o[0]&&(l=yield*M(o[0],r,s,n,i,c),o.length>1&&o[1]&&(f=yield*M(o[1],r,s,n,i,c))),c.interruptionCount++;let g={id:C(),type:"interruption",interruptionType:d,source:l,handler:f,location:_(e,s,n.includeLocations??!1)};return{...g,displayName:G(g),semanticRole:Q(g)}})}function Do(e){let{SyntaxKind:t}=w(),r,s,n;for(let i of e.getProperties()){if(i.getKind()!==t.PropertyAssignment)continue;let c=i.getNameNode().getText(),o=i.getInitializer();if(!o)continue;let a=o.getText();if(c==="concurrency")if(a==='"unbounded"'||a==="'unbounded'")r="unbounded";else if(a==='"sequential"'||a==="'sequential'")r="sequential";else if(a==='"inherit"'||a==="'inherit'")r="sequential";else{let d=Number.parseInt(a,10);!Number.isNaN(d)&&d>=0&&(r=d)}else c==="batching"&&(a==="true"||a==="false")?s=a==="true":c==="discard"&&(a==="true"||a==="false")&&(n=a==="true")}return{concurrency:r,batching:s,discard:n}}var Po=(e,t,r,s,n,i,c)=>ee.gen(function*(){let o=e.getArguments(),a=[],{SyntaxKind:d}=w();if(o.length>0&&o[0]){let h=o[0];if(h.getKind()===d.ArrayLiteralExpression){let y=h.getElements();for(let N of y){let E=yield*M(N,r,s,n,i,c);a.push(E)}}else if(h.getKind()===d.ObjectLiteralExpression){let y=h.getProperties();for(let N of y)if(N.getKind()===d.PropertyAssignment){let E=N.getInitializer();if(E){let $=yield*M(E,r,s,n,i,c);a.push($)}}}}let l,f,u;if(o.length>1&&o[1]?.getKind()===d.ObjectLiteralExpression){let h=Do(o[1]);l=h.concurrency,f=h.batching,u=h.discard}let g=t.includes("Par")?"parallel":"sequential";l===void 0&&(l=g==="parallel"?"unbounded":"sequential"),c.parallelCount++;let p=a.map(h=>G(h)),m={id:C(),type:"parallel",callee:t,mode:g,children:a,concurrency:l,batching:f,discard:u,branchLabels:p,location:_(e,s,n.includeLocations??!1)};return{...m,displayName:G(m),semanticRole:Q(m)}}),Mo=(e,t,r,s,n,i,c)=>ee.gen(function*(){let o=e.getArguments(),a=[];for(let f of o)if(f){let u=yield*M(f,r,s,n,i,c);a.push(u)}c.raceCount++;let d=a.map(f=>G(f)),l={id:C(),type:"race",callee:t,children:a,raceLabels:d,location:_(e,s,n.includeLocations??!1)};return{...l,displayName:G(l),semanticRole:Q(l)}}),Oo=(e,t,r,s,n,i,c)=>ee.gen(function*(){let o=e.getArguments(),a;t.includes("catchAllCause")?a="catchAllCause":t.includes("catchSomeCause")?a="catchSomeCause":t.includes("catchSomeDefect")?a="catchSomeDefect":t.includes("catchAllDefect")?a="catchAllDefect":t.includes("catchTags")?a="catchTags":t.includes("catchIf")?a="catchIf":t.includes("catchSome")?a="catchSome":t.includes("catchTag")?a="catchTag":t.includes("catchAll")?a="catchAll":t.includes("orElseFail")?a="orElseFail":t.includes("orElseSucceed")?a="orElseSucceed":t.includes("orElse")?a="orElse":t.includes("orDieWith")?a="orDieWith":t.includes("orDie")?a="orDie":t.includes("flip")?a="flip":t.includes("mapErrorCause")?a="mapErrorCause":t.includes("mapBoth")?a="mapBoth":t.includes("mapError")?a="mapError":t.includes("unsandbox")?a="unsandbox":t.includes("sandbox")?a="sandbox":t.includes("parallelErrors")?a="parallelErrors":t.includes("filterOrDieMessage")?a="filterOrDieMessage":t.includes("filterOrDie")?a="filterOrDie":t.includes("filterOrElse")?a="filterOrElse":t.includes("filterOrFail")?a="filterOrFail":t.includes("matchCauseEffect")?a="matchCauseEffect":t.includes("matchCause")?a="matchCause":t.includes("matchEffect")?a="matchEffect":t.includes("match")?a="match":t.includes("firstSuccessOf")?a="firstSuccessOf":t.includes("ignoreLogged")?a="ignoreLogged":t.includes("ignore")?a="ignore":t.includes("eventually")?a="eventually":a="catchAll";let d,l,f=e.getExpression();if(f.getKind()===w().SyntaxKind.PropertyAccessExpression){let h=f.getExpression();d=yield*M(h,r,s,n,i,c),o.length>0&&o[0]&&(l=yield*M(o[0],r,s,n,i,c))}else o.length>0&&o[0]?d=yield*M(o[0],r,s,n,i,c):d={id:C(),type:"unknown",reason:"Could not determine source effect"},o.length>1&&o[1]&&(l=yield*M(o[1],r,s,n,i,c));c.errorHandlerCount++;let u,g;if(a==="catchTag"){let m=o[0];m?.getKind()===w().SyntaxKind.StringLiteral&&(u=m.getLiteralValue())}else if(a==="catchTags"){let m=[...o].find(h=>h?.getKind()===w().SyntaxKind.ObjectLiteralExpression);m&&(g=m.getProperties().filter(y=>y.getKind()===w().SyntaxKind.PropertyAssignment||y.getKind()===w().SyntaxKind.MethodDeclaration).map(y=>(y.getKind()===w().SyntaxKind.PropertyAssignment,y.getName())))}let p={id:C(),type:"error-handler",handlerType:a,source:d,handler:l,errorTag:u,errorTags:g,errorEdgeLabel:u?`on ${u}`:g&&g.length>0?`on ${g.join(" | ")}`:"on error",location:_(e,s,n.includeLocations??!1)};return{...p,displayName:G(p),semanticRole:Q(p)}}),Lo=(e,t,r,s,n,i)=>ee.gen(function*(){let c=e.getArguments(),o,a,d,l,f=e.getExpression();if(f.getKind()===w().SyntaxKind.PropertyAccessExpression){let m=f.getExpression();o=yield*M(m,t,r,s,n,i),c.length>0&&c[0]&&(a=c[0].getText(),d=yield*M(c[0],t,r,s,n,i)),l=f.getText().includes("retryOrElse")}else c.length>0&&c[0]?o=yield*M(c[0],t,r,s,n,i):o={id:C(),type:"unknown",reason:"Could not determine source effect"},c.length>1&&c[1]&&(a=c[1].getText(),d=yield*M(c[1],t,r,s,n,i)),l=c.length>2;i.retryCount++;let u=a?us(a):void 0,g={id:C(),type:"retry",source:o,schedule:a,...d!==void 0?{scheduleNode:d}:{},hasFallback:l,scheduleInfo:u,retryEdgeLabel:a?`retry: ${a}`:"retry",location:_(e,r,s.includeLocations??!1)};return{...g,displayName:G(g),semanticRole:Q(g)}});function us(e){let t=e.replace(/\s+/g," "),r="custom";t.includes("Schedule.exponential")||t.includes("exponential(")?r="exponential":t.includes("Schedule.fibonacci")||t.includes("fibonacci(")?r="fibonacci":t.includes("Schedule.spaced")||t.includes("spaced(")?r="spaced":t.includes("Schedule.fixed")||t.includes("fixed(")?r="fixed":t.includes("Schedule.linear")||t.includes("linear(")?r="linear":t.includes("Schedule.cron")||t.includes("cron(")?r="cron":t.includes("Schedule.windowed")||t.includes("windowed(")?r="windowed":t.includes("Schedule.duration")||t.includes("duration(")?r="duration":t.includes("Schedule.elapsed")||t.includes("elapsed(")?r="elapsed":t.includes("Schedule.delays")||t.includes("delays(")?r="delays":t.includes("Schedule.once")||t.includes("once(")?r="once":t.includes("Schedule.stop")||t.includes("stop(")?r="stop":(t.includes("Schedule.count")||t.includes("count("))&&(r="count");let s,n=/recurs\s*\(\s*(\d+)\s*\)/.exec(t);n&&(s=Number.parseInt(n[1],10));let i=/recurUpTo\s*\(\s*(\d+)\s*\)/.exec(t);i?s=Number.parseInt(i[1],10):(t.includes("forever")||t.includes("Schedule.forever"))&&(s="unlimited");let c=t.includes("jittered")||t.includes("Schedule.jittered"),o=[];return t.includes("whileInput")&&o.push("whileInput"),t.includes("whileOutput")&&o.push("whileOutput"),t.includes("untilInput")&&o.push("untilInput"),t.includes("untilOutput")&&o.push("untilOutput"),t.includes("recurUntil")&&o.push("recurUntil"),t.includes("recurWhile")&&o.push("recurWhile"),t.includes("andThen")&&o.push("andThen"),t.includes("intersect")&&o.push("intersect"),t.includes("union")&&o.push("union"),t.includes("compose")&&o.push("compose"),t.includes("zipWith")&&o.push("zipWith"),t.includes("addDelay")&&o.push("addDelay"),t.includes("modifyDelay")&&o.push("modifyDelay"),t.includes("check")&&o.push("check"),t.includes("resetAfter")&&o.push("resetAfter"),t.includes("resetWhen")&&o.push("resetWhen"),t.includes("ensure")&&o.push("ensure"),t.includes("driver")&&o.push("driver"),t.includes("mapInput")&&o.push("mapInput"),{baseStrategy:r,maxRetries:s,jittered:c,conditions:o}}var Wo=(e,t,r,s,n,i)=>ee.gen(function*(){let c=e.getArguments(),o,a,d,l=e.getExpression();if(l.getKind()===w().SyntaxKind.PropertyAccessExpression){let g=l.getExpression();o=yield*M(g,t,r,s,n,i),c.length>0&&c[0]&&(a=kt(c[0]));let p=kt(l);d=p.includes("timeoutFail")||p.includes("timeoutTo")}else c.length>0&&c[0]?o=yield*M(c[0],t,r,s,n,i):o={id:C(),type:"unknown",reason:"Could not determine source effect"},c.length>1&&c[1]&&(a=kt(c[1])),d=c.length>2;i.timeoutCount++;let f={id:C(),type:"timeout",source:o,duration:a,hasFallback:d,location:_(e,r,s.includeLocations??!1)};return{...f,displayName:G(f),semanticRole:Q(f)}}),ls=(e,t,r,s,n,i,c)=>ee.gen(function*(){let o=e.getArguments(),a=/([A-Za-z_$][\w$]*)$/.exec(t)?.[1]??t,d,l,f;if(a.startsWith("acquireUseRelease"))o.length>=3&&o[0]&&o[2]?(d=yield*M(o[0],r,s,n,i,c),l=yield*M(o[2],r,s,n,i,c),o[1]&&(f=yield*M(o[1],r,s,n,i,c))):(d={id:C(),type:"unknown",reason:"Missing acquire"},l={id:C(),type:"unknown",reason:"Missing release"});else if(a.startsWith("acquireRelease"))o.length>=2&&o[0]&&o[1]?(d=yield*M(o[0],r,s,n,i,c),l=yield*M(o[1],r,s,n,i,c)):(d={id:C(),type:"unknown",reason:"Missing acquire"},l={id:C(),type:"unknown",reason:"Missing release"});else if(a==="addFinalizer"||a==="onExit"||a==="onError"||a==="parallelFinalizers"||a==="sequentialFinalizers"||a==="finalizersMask"||a==="using"||a==="withEarlyRelease"){let g=e.getExpression();g.getKind()===w().SyntaxKind.PropertyAccessExpression?d=yield*M(g.getExpression(),r,s,n,i,c):d={id:C(),type:"unknown",reason:"Scoped acquire"},l=o.length>0&&o[0]?yield*M(o[0],r,s,n,i,c):{id:C(),type:"unknown",reason:"Missing finalizer"}}else if(a==="ensuring"){let g=e.getExpression();if(g.getKind()===w().SyntaxKind.PropertyAccessExpression){let m=g.getExpression();d=yield*M(m,r,s,n,i,c),l=o.length>0&&o[0]?yield*M(o[0],r,s,n,i,c):{id:C(),type:"unknown",reason:"Missing cleanup"}}else d=o.length>0&&o[0]?yield*M(o[0],r,s,n,i,c):{id:C(),type:"unknown",reason:"Missing effect"},l=o.length>1&&o[1]?yield*M(o[1],r,s,n,i,c):{id:C(),type:"unknown",reason:"Missing cleanup"}}else d={id:C(),type:"unknown",reason:"Unknown resource pattern"},l={id:C(),type:"unknown",reason:"Unknown resource pattern"};c.resourceCount++;let u={id:C(),type:"resource",acquire:d,release:l,use:f,location:_(e,s,n.includeLocations??!1)};return{...u,displayName:G(u),semanticRole:Q(u)}}),Ko=(e,t,r,s,n,i,c)=>ee.gen(function*(){let o=e.getArguments(),a;t.includes(".if")||t==="if"?a="if":t.includes("whenEffect")?a="whenEffect":t.includes("whenFiberRef")?a="whenFiberRef":t.includes("whenRef")?a="whenRef":t.includes(".when")||t==="when"?a="when":t.includes("unlessEffect")?a="unlessEffect":t.includes(".unless")||t==="unless"?a="unless":t.includes(".option")||t==="option"?a="option":t.includes(".either")||t==="either"?a="either":t.includes(".exit")||t==="exit"?a="exit":t.includes("liftPredicate")?a="liftPredicate":a="unless";let d="<dynamic>",l,f;if(a==="if"){if(o.length>0&&o[0]&&(d=o[0].getText()),o.length>1&&o[1]){let p=o[1],{SyntaxKind:m}=w();if(p.getKind()===m.ObjectLiteralExpression){let h=p.getProperties();for(let y of h)if(y.getKind()===m.PropertyAssignment){let N=y,E=N.getName(),$=N.getInitializer();$&&(E==="onTrue"?l=yield*M($,r,s,n,i,c):E==="onFalse"&&(f=yield*M($,r,s,n,i,c)))}}}}else{let p=e.getExpression();if(p.getKind()===w().SyntaxKind.PropertyAccessExpression){let h=p.getExpression();l||(l=yield*M(h,r,s,n,i,c))}o.length>0&&o[0]&&(d=o[0].getText())}l||(l={id:C(),type:"unknown",reason:"Could not determine true branch"}),c.conditionalCount++;let u=d.length<=30?d:`${d.slice(0,30)}\u2026`,g={id:C(),type:"conditional",conditionalType:a,condition:d,onTrue:l,onFalse:f,conditionLabel:u,trueEdgeLabel:"true",falseEdgeLabel:"false",location:_(e,s,n.includeLocations??!1)};return{...g,displayName:G(g),semanticRole:Q(g)}}),jo=(e,t,r,s,n,i,c)=>ee.gen(function*(){let o=e.getArguments(),a=t.includes("forEach")?"forEach":t.includes("filterMap")?"filterMap":t.includes("filter")?"filter":t.includes("partition")?"partition":t.includes("reduce")?"reduce":t.includes("validateAll")||t.includes("validateFirst")||t.includes("validateWith")?"validate":t.includes("replicate")?"replicate":t.includes("dropUntil")?"dropUntil":t.includes("dropWhile")?"dropWhile":t.includes("takeUntil")?"takeUntil":t.includes("takeWhile")?"takeWhile":t.includes("every")?"every":t.includes("exists")?"exists":t.includes("findFirst")?"findFirst":t.includes("head")?"head":t.includes("mergeAll")?"mergeAll":"loop",d=a==="reduce"||t.includes("reduceRight")||t.includes("reduceWhile")||t.includes("reduceEffect")?2:1,l,f;o.length>0&&o[0]&&(l=o[0].getText()),o.length>d&&o[d]?f=yield*M(o[d],r,s,n,i,c):f={id:C(),type:"unknown",reason:"Could not determine loop body"},c.loopCount++;let u={id:C(),type:"loop",loopType:a,iterSource:l,body:f,location:_(e,s,n.includeLocations??!1)};return{...u,displayName:G(u),semanticRole:Q(u)}}),Bo=(e,t,r,s)=>{let n=pn[t]??"other",i=Wr.has(n),c=e.getArguments(),o=[];if((n==="when"||n==="tag")&&c[0]){let d=c[0].getText().replace(/["'`]/g,"").trim();/^[A-Za-z_][A-Za-z0-9_]*$/.test(d)&&o.push(d)}if(n==="tags"||n==="tagsExhaustive"){let{SyntaxKind:d}=w();for(let l of c)if(l.getKind()===d.ObjectLiteralExpression){let f=l;for(let u of f.getProperties()){let g=u.getKind()===d.PropertyAssignment?u.getName():void 0;g&&o.push(g.replace(/["'`]/g,""))}}}let a={id:C(),type:"match",matchOp:n,isExhaustive:i,...o.length>0?{matchedTags:o}:{},location:_(e,r,s.includeLocations??!1)};return{...a,displayName:G(a),semanticRole:Q(a)}},qo=(e,t,r,s,n,i,c)=>ee.gen(function*(){let o=gn[t]??"other",a=jr.has(o),d;if(o==="parallel"||o==="sequential"){let u=e.getArguments(),g=[];for(let p of u)if(p){let m=yield*M(p,r,s,n,i,c);g.push(m)}g.length>0&&(d=g)}let l;if(o==="fail")l="fail";else if(o==="die")l="die";else if(o==="interrupt")l="interrupt";else if((o==="parallel"||o==="sequential")&&d&&d.length>0){let u=d.filter(g=>g.type==="cause").map(g=>g.causeKind).filter(g=>g!==void 0);u.length>0&&(l=u.every(g=>g===u[0])?u[0]:"mixed")}let f={id:C(),type:"cause",causeOp:o,isConstructor:a,...d?{children:d}:{},...l?{causeKind:l}:{},location:_(e,s,n.includeLocations??!1)};return{...f,displayName:G(f),semanticRole:Q(f)}}),zo=(e,t,r,s)=>{let n=mn[t]??"other",i=qr.has(n),c={id:C(),type:"exit",exitOp:n,isConstructor:i,location:_(e,r,s.includeLocations??!1)};return{...c,displayName:G(c),semanticRole:Q(c)}},_o=(e,t,r,s)=>ee.sync(()=>{let n=yn[t]??"other",i=e.getText(),c=us(i),o={id:C(),type:"schedule",scheduleOp:n,...c?{scheduleInfo:c}:{},location:_(e,r,s.includeLocations??!1)};return{...o,displayName:G(o),semanticRole:Q(o)}}),Ho=(e,t,r,s,n,i,c)=>ee.gen(function*(){let o=e.getArguments(),a=fn[t]??"other",d=Or.has(a),l,f;if(o.length>=2&&o[0]){if(l=yield*M(o[0],r,s,n,i,c),o[1]){let g=o[1].getText();f=g.length<=120?g:g.slice(0,120)+"\u2026"}}else if(o.length===1&&o[0]){let g=o[0].getText();f=g.length<=120?g:g.slice(0,120)+"\u2026"}c.totalEffects++;let u={id:C(),type:"transform",transformType:a,isEffectful:d,...l!==void 0?{source:l}:{},...f!==void 0?{fn:f}:{},location:_(e,s,n.includeLocations??!1)};return{...u,displayName:G(u),semanticRole:Q(u)}});var In=(e,t,r,s,n)=>xe.gen(function*(){let i=[],c=Pr(),o=yield*Uo(e.node,e.type,t,r,s,i,c),a=Ar(e.node),d=t.getProject().getTypeChecker(),l=Ze(e.node,d),f=wt(e.node,d),u={id:C(),type:"program",programName:e.name,source:e.type,...e.discoveryConfidence?{discoveryConfidence:e.discoveryConfidence}:{},...e.discoveryReason?{discoveryReason:e.discoveryReason}:{},children:o,dependencies:Fr(o),errorTypes:$r(o),typeSignature:l,requiredServices:f,location:_(e.node,r,s.includeLocations??!1),jsdocDescription:a,jsdocTags:Ye(e.node)},g=cs(t);return{root:u,metadata:{analyzedAt:Date.now(),filePath:r,tsVersion:n,warnings:i,stats:c,...g.length>0?{serviceDefinitions:g}:{}},references:new Map}}),Uo=(e,t,r,s,n,i,c)=>xe.gen(function*(){switch(t){case"generator":{let o=e.getArguments();if(o.length>0&&o[0]){let a=o[0];return yield*Yo(a,r,s,n,i,c)}return[]}case"pipe":return yield*Rt(e,r,s,n,i,c);case"run":{let o=e,{SyntaxKind:a}=w(),d=yield*Xo(o,r,s,n,i,c);if(yt.isSome(d))return d.value;let l=o.getArguments(),f=l.find(p=>p.getKind()===a.ArrowFunction||p.getKind()===a.FunctionExpression),u=n.enableEffectWorkflow&&f===void 0&&l.length===1?as(o,r):null,g=f??u??l[0];return g?[yield*M(g,r,s,n,i,c)]:[]}case"workflow-execute":{let o=e,a=o.getExpression().getText();return[{id:C(),type:"effect",callee:a,name:a,semanticRole:"side-effect",location:_(o,s,n.includeLocations??!1)}]}case"direct":{let o=e.getInitializer();return o?[yield*M(o,r,s,n,i,c)]:[]}case"class":{let o=e,a="Data.Class";for(let f of o.getHeritageClauses()){let u=f.getText();if(u.includes("Data.TaggedError")){a="Data.TaggedError";break}if(u.includes("Data.TaggedClass")){a="Data.TaggedClass";break}if(u.includes("Data.Error")){a="Data.Error";break}if(u.includes("Schema.TaggedRequest")){a="Schema.TaggedRequest";break}if(u.includes("Schema.TaggedError")){a="Schema.TaggedError";break}if(u.includes("Schema.TaggedClass")){a="Schema.TaggedClass";break}if(u.includes("Schema.Class")){a="Schema.Class";break}if(u.includes("Context.Tag")){a="Context.Tag";break}if(u.includes("Context.Reference")){a="Context.Reference";break}if(u.includes("Effect.Service")){a="Effect.Service";break}}let d=a.includes("Error")?"error-type":a.includes("Schema")?"schema":a==="Context.Tag"||a==="Context.Reference"||a==="Effect.Service"?"service-tag":"data",l={id:C(),type:"effect",callee:a,description:d,location:_(e,s,n.includeLocations??!1),jsdocDescription:_e(o),jsdocTags:Ye(o)};return c.totalEffects++,[l]}case"classProperty":{let a=e.getInitializer();return a?[yield*M(a,r,s,n,i,c)]:[]}case"classMethod":{let a=e.getBody();if(!a)return[];let{SyntaxKind:d}=w(),l=a.getDescendantsOfKind(d.ReturnStatement),f=[];for(let u of l){let g=u.getExpression();if(g){let p=yield*M(g,r,s,n,i,c);f.push(p)}}return f}default:return[]}});function $n(e){let{SyntaxKind:t}=w(),r=e.getKind();return r===t.FunctionDeclaration||r===t.FunctionExpression||r===t.ArrowFunction||r===t.MethodDeclaration||r===t.ClassDeclaration||r===t.ClassExpression||r===t.Constructor}function ae(e){let{SyntaxKind:t}=w();if(e.getKind()===t.YieldExpression)return!0;let r=!1;return e.forEachChild(s=>{if(!r&&!$n(s)){if(s.getKind()===t.YieldExpression){r=!0;return}if(ae(s)){r=!0;return}}}),r}function Go(e){let{SyntaxKind:t}=w();switch(e.getKind()){case t.StringLiteral:return e.getLiteralValue();case t.NumericLiteral:return e.getLiteralValue().toString();case t.TrueKeyword:return"true";case t.FalseKeyword:return"false";case t.NullKeyword:return"null";case t.NoSubstitutionTemplateLiteral:return e.getText().replace(/^`|`$/g,"");default:return}}function nt(e,t){if(t.size===0)return e;let r=e;for(let[s,n]of t){let i=new RegExp(`\\b${s}\\b`,"g"),c=/^\d/.test(n)||n==="true"||n==="false"||n==="null"?n:`'${n}'`;r=r.replace(i,c)}return r}function ht(e){let t=e;return t=t.replace(/\btrue\b\s*&&\s*/g,""),t=t.replace(/\s*&&\s*\btrue\b/g,""),t=t.replace(/\bfalse\b\s*\|\|\s*/g,""),t=t.replace(/\s*\|\|\s*\bfalse\b/g,""),t=t.replace(/\bfalse\b\s*&&\s*[^|&]+/g,"false"),t=t.replace(/\btrue\b\s*\|\|\s*[^|&]+/g,"true"),t.trim()}function Fn(e){let{SyntaxKind:t}=w();switch(e.getKind()){case t.ParenthesizedExpression:case t.AsExpression:case t.TypeAssertionExpression:case t.NonNullExpression:case t.SatisfiesExpression:{let s=e.getExpression();return Fn(s)}default:return e}}function fs(e){let{SyntaxKind:t}=w();if(e.length===0)return!1;let r=e[e.length-1];if(!r)return!1;let s=r.getKind();return s===t.ReturnStatement||s===t.ThrowStatement||s===t.BreakStatement||s===t.ContinueStatement}function gs(e){let{SyntaxKind:t}=w(),r=[];return e.forEachChild(s=>{$n(s)||(s.getKind()===t.YieldExpression?r.push(s):r.push(...gs(s)))}),r}var Vo=new Set(["Step.run","Step.decide","Step.branch","Step.all","Step.forEach","Step.retry","Step.race","Step.sleep"]);function Jo(e){let{SyntaxKind:t}=w();if(e.getKind()!==t.CallExpression)return!1;let r=e.getExpression().getText();return Vo.has(r)}function Ae(e){if(!e)return;let{SyntaxKind:t}=w();if(e.getKind()===t.StringLiteral)return e.getLiteralText()}function Qo(e){if(!e)return[];let{SyntaxKind:t}=w();if(e.getKind()!==t.ObjectLiteralExpression)return[];let r=[],s=e;for(let n of s.getProperties())if(n.getKind()===t.PropertyAssignment){let i=n.getName();r.push({labels:[i],isDefault:i==="default",body:[]})}return r}function Zo(e,t){return xe.gen(function*(){let{SyntaxKind:r}=w(),s=e.getExpression().getText(),n=e.getArguments();switch(s){case"Step.run":{let i=Ae(n[0]),c=n[1];if(!c){let a={id:C(),type:"effect",callee:"Step.run",name:i,displayName:i};return t.stats.totalEffects++,a}let o=yield*M(c,t.sourceFile,t.filePath,t.opts,t.warnings,t.stats,t.serviceScope);return{...o,displayName:i??o.displayName,name:i??o.name}}case"Step.decide":{let i=Ae(n[0]),c=Ae(n[1]);return t.stats.decisionCount++,{id:C(),type:"decision",decisionId:i??C(),label:c??i??"decision",condition:n[2]?.getText()??"unknown",source:"effect-flow",onTrue:[],onFalse:void 0}}case"Step.branch":{let i=Ae(n[0]),c=n[1]?.getText()??"unknown",o=n[2],a=Qo(o);return t.stats.switchCount++,{id:C(),type:"switch",switchId:i,expression:c,cases:a,source:"effect-flow",hasDefault:a.some(l=>l.isDefault),hasFallthrough:!1}}case"Step.all":{let i=Ae(n[0]),c=n[1],o=[];if(c?.getKind()===r.ArrayLiteralExpression){let d=c;for(let l of d.getElements()){let f=yield*M(l,t.sourceFile,t.filePath,t.opts,t.warnings,t.stats,t.serviceScope);o.push(f)}}return t.stats.parallelCount++,{id:C(),type:"parallel",name:i,displayName:i,children:o,mode:"parallel",callee:"Step.all"}}case"Step.forEach":{let i=Ae(n[0]),c=n[1]?.getText(),o=n[2],a={id:C(),type:"effect",callee:"unknown"};return o&&(a=yield*M(o,t.sourceFile,t.filePath,t.opts,t.warnings,t.stats,t.serviceScope)),t.stats.loopCount++,{id:C(),type:"loop",name:i,displayName:i,loopType:"forEach",iterSource:c,body:a}}case"Step.retry":{let i=Ae(n[0]),c=n[1];if(!c){let d={id:C(),type:"effect",callee:"Step.retry",name:i,displayName:i};return t.stats.totalEffects++,d}let o=yield*M(c,t.sourceFile,t.filePath,t.opts,t.warnings,t.stats,t.serviceScope);return t.stats.retryCount++,{id:C(),type:"retry",name:i,displayName:i,source:o,hasFallback:!1}}case"Step.race":{let i=Ae(n[0]),c=n[1],o=[];if(c?.getKind()===r.ArrayLiteralExpression){let d=c;for(let l of d.getElements()){let f=yield*M(l,t.sourceFile,t.filePath,t.opts,t.warnings,t.stats,t.serviceScope);o.push(f)}}return t.stats.raceCount++,{id:C(),type:"race",name:i,displayName:i,children:o,callee:"Step.race"}}case"Step.sleep":{let i=Ae(n[0]),c={id:C(),type:"effect",callee:"Step.sleep",name:i,displayName:i,semanticRole:"scheduling"};return t.stats.totalEffects++,c}default:{let i={id:C(),type:"effect",callee:s,name:s,displayName:s};return t.stats.totalEffects++,i}}})}function ps(e,t){return xe.gen(function*(){let r=e,s=r.getText().startsWith("yield*"),n=r.getExpression();if(!s){let d={id:C(),type:"opaque",reason:"plain-yield",sourceText:e.getText().slice(0,80)};return t.stats.opaqueCount++,t.warnings.push({code:"PLAIN_YIELD",message:`Plain yield (not yield*) detected; this is unusual in Effect generators: ${e.getText().slice(0,60)}`,location:_(e,t.filePath,t.opts.includeLocations??!1)}),{variableName:vt(e),effect:d}}if(!n){let d={id:C(),type:"opaque",reason:"yield-no-expression",sourceText:e.getText().slice(0,80)};return t.stats.opaqueCount++,{variableName:void 0,effect:d}}let i=Fn(n);if(t.opts.enableEffectFlow&&Jo(i)){let d=yield*Zo(i,t),l=vt(e),f={...d,displayName:d.displayName??G(d,l),semanticRole:d.semanticRole??Q(d)};return{variableName:l,effect:f}}let c=yield*M(n,t.sourceFile,t.filePath,t.opts,t.warnings,t.stats,t.serviceScope),o=vt(e);o&&c.type==="effect"&&Ur(c.callee)&&t.serviceScope.set(o,c.callee);let a={...c,displayName:G(c,o),semanticRole:c.semanticRole??Q(c)};return{variableName:o,effect:a}})}function rt(e,t){return xe.gen(function*(){let r=e.getStatements(),s=[];for(let n of r){let i=yield*Dt(n,t);s.push(...i)}return s})}function Dt(e,t){return xe.gen(function*(){let{SyntaxKind:r}=w();switch(e.getKind()){case r.ExpressionStatement:{let i=e.getExpression();return yield*ye(i,t)}case r.VariableStatement:{let n=e,i=[],{VariableDeclarationKind:c}=w(),o=n.getDeclarationKind()===c.Const;for(let a of n.getDeclarations()){let d=a.getInitializer();if(o&&d){let l=Go(d);l!==void 0&&t.constValues.set(a.getName(),l)}if(d&&!ae(d)&&d.getKind()===r.CallExpression){let l=d,f=l.getExpression().getText();if(f==="Context.pick"||f==="Context.omit"){let u=yield*M(l,t.sourceFile,t.filePath,t.opts,t.warnings,t.stats,t.serviceScope);u.type==="effect"&&u.description==="context"&&i.push({variableName:a.getName(),effect:u});continue}}if(d&&ae(d)){let l=yield*ye(d,t);if(l.length>0){let f=a.getName(),u=l[l.length-1];u&&(l[l.length-1]={...u,variableName:u.variableName??f})}i.push(...l)}}return i}case r.IfStatement:{if(!ae(e))return[];let n=e,i=n.getExpression().getText(),c=yield*ye(n.getExpression(),t),o=n.getThenStatement(),a=n.getElseStatement(),d=yield*Ue(o,t),l=a?yield*Ue(a,t):void 0,f=ht(nt(i,t.constValues)),u=f.length>40?f.slice(0,40)+"...":f,g={id:C(),type:"decision",decisionId:C(),label:u,condition:i,source:"raw-if",onTrue:d.map(p=>p.effect),onFalse:l&&l.length>0?l.map(p=>p.effect):void 0};return t.stats.decisionCount++,[...c,{effect:g}]}case r.SwitchStatement:{if(!ae(e))return[];let n=e,i=n.getExpression().getText(),c=n.getClauses(),o=[],a=!1,d=!1,l=[],f=[],u=!1;for(let m of c){if(m.getKind()===r.DefaultClause)d=!0,u=!0,l.push("default");else{let E=m;l.push(E.getExpression().getText())}let y=m.getStatements();if(y.length===0){a=!0;continue}for(let E of y){let $=yield*Dt(E,t);f.push(...$)}fs(y)||(a=!0),o.push({labels:l,isDefault:u,body:f.map(E=>E.effect)}),l=[],f=[],u=!1}l.length>0&&o.push({labels:l,isDefault:u,body:f.map(m=>m.effect)});let g=nt(i,t.constValues),p={id:C(),type:"switch",switchId:C(),expression:g,cases:o,source:"raw-js",hasDefault:d,hasFallthrough:a};return t.stats.switchCount++,[{effect:p}]}case r.ForStatement:{if(!ae(e))return[];let n=e,i=[],c=n.getInitializer();if(c&&ae(c)){let m=yield*ye(c,t);i.push(...m.map(h=>h.effect))}let o=n.getIncrementor();if(o&&ae(o)){let m=yield*ye(o,t);i.push(...m.map(h=>h.effect))}let a=n.getStatement(),d=yield*Ue(a,t),l=tt(a),f=n.getCondition(),u=f?f.getText():void 0,g=d.length===1&&d[0]?d[0].effect:{id:C(),type:"generator",yields:d},p={id:C(),type:"loop",loopType:"for",iterSource:u,body:g,...l?{hasEarlyExit:l}:{},...i.length>0?{headerYields:i}:{}};return t.stats.loopCount++,[{effect:p}]}case r.ForOfStatement:{if(!ae(e))return[];let n=e,i=n.getExpression(),c=i.getText(),o=[];if(ae(i)){let p=yield*ye(i,t);o.push(...p.map(m=>m.effect))}let a=n.getInitializer().getText(),d=n.getStatement(),l=yield*Ue(d,t),f=tt(d),u=l.length===1&&l[0]?l[0].effect:{id:C(),type:"generator",yields:l},g={id:C(),type:"loop",loopType:"forOf",iterSource:c,body:u,...f?{hasEarlyExit:f}:{},...o.length>0?{headerYields:o}:{},iterVariable:a};return t.stats.loopCount++,[{effect:g}]}case r.ForInStatement:{if(!ae(e))return[];let n=e,i=n.getExpression().getText(),c=n.getInitializer().getText(),o=n.getStatement(),a=yield*Ue(o,t),d=tt(o),l=a.length===1&&a[0]?a[0].effect:{id:C(),type:"generator",yields:a},f={id:C(),type:"loop",loopType:"forIn",iterSource:i,body:l,...d?{hasEarlyExit:d}:{},iterVariable:c};return t.stats.loopCount++,[{effect:f}]}case r.WhileStatement:{if(!ae(e))return[];let n=e,i=n.getExpression().getText(),c=n.getStatement(),o=yield*Ue(c,t),a=tt(c),d=o.length===1&&o[0]?o[0].effect:{id:C(),type:"generator",yields:o},l={id:C(),type:"loop",loopType:"while",iterSource:i,body:d,...a?{hasEarlyExit:a}:{}};return t.stats.loopCount++,[{effect:l}]}case r.DoStatement:{if(!ae(e))return[];let n=e,i=n.getExpression().getText(),c=n.getStatement(),o=yield*Ue(c,t),a=tt(c),d=o.length===1&&o[0]?o[0].effect:{id:C(),type:"generator",yields:o},l={id:C(),type:"loop",loopType:"doWhile",iterSource:i,body:d,...a?{hasEarlyExit:a}:{}};return t.stats.loopCount++,[{effect:l}]}case r.TryStatement:{if(!ae(e))return[];let n=e,i=n.getTryBlock(),c=yield*rt(i,t),o=n.getCatchClause(),a,d;if(o){a=o.getVariableDeclaration()?.getName();let m=o.getBlock();d=yield*rt(m,t)}let l=n.getFinallyBlock(),f;l&&(f=yield*rt(l,t));let u=fs(i.getStatements()),g={id:C(),type:"try-catch",tryBody:c.map(p=>p.effect),...a?{catchVariable:a}:{},...d&&d.length>0?{catchBody:d.map(p=>p.effect)}:{},...f&&f.length>0?{finallyBody:f.map(p=>p.effect)}:{},hasTerminalInTry:u};return t.stats.tryCatchCount++,[{effect:g}]}case r.ReturnStatement:{let i=e.getExpression();if(!i||!ae(i))return[];let c=yield*ye(i,t),o={id:C(),type:"terminal",terminalKind:"return",value:c.map(a=>a.effect)};return t.stats.terminalCount++,[{effect:o}]}case r.ThrowStatement:{let i=e.getExpression();if(!ae(i))return[];let c=yield*ye(i,t),o={id:C(),type:"terminal",terminalKind:"throw",...c.length>0?{value:c.map(a=>a.effect)}:{}};return t.stats.terminalCount++,[{effect:o}]}case r.BreakStatement:return[];case r.ContinueStatement:return[];case r.LabeledStatement:return yield*Dt(e.getStatement(),t);case r.Block:return yield*rt(e,t);default:return[]}})}function Ue(e,t){let{SyntaxKind:r}=w();return e.getKind()===r.Block?rt(e,t):Dt(e,t)}function tt(e){let{SyntaxKind:t}=w(),r=!1;return e.forEachChild(s=>{if(r||$n(s))return;let n=s.getKind();if(n===t.BreakStatement||n===t.ReturnStatement){r=!0;return}if(tt(s)){r=!0;return}}),r}function ye(e,t){return xe.gen(function*(){let{SyntaxKind:r}=w();if(!ae(e))return[];let s=Fn(e),n=s.getKind();if(n===r.YieldExpression)return[yield*ps(s,t)];if(n===r.ConditionalExpression){let o=s,a=o.getCondition().getText(),d=o.getWhenTrue(),l=o.getWhenFalse(),f=yield*ye(d,t),u=yield*ye(l,t);if(f.length>0||u.length>0){let g=ht(nt(a,t.constValues)),p={id:C(),type:"decision",decisionId:C(),label:g.length>40?g.slice(0,40)+"...":g,condition:a,source:"raw-ternary",onTrue:f.map(m=>m.effect),onFalse:u.length>0?u.map(m=>m.effect):void 0};return t.stats.decisionCount++,[{effect:p}]}}if(n===r.BinaryExpression){let o=s,a=o.getOperatorToken().getKind(),d=o.getLeft(),l=o.getRight();if(a===r.AmpersandAmpersandToken){let f=yield*ye(l,t);if(f.length>0){let u=d.getText(),g=ht(nt(u,t.constValues)),p={id:C(),type:"decision",decisionId:C(),label:g.length>40?g.slice(0,40)+"...":g,condition:u,source:"raw-short-circuit",onTrue:f.map(m=>m.effect),onFalse:[]};return t.stats.decisionCount++,[{effect:p}]}}if(a===r.BarBarToken){let f=yield*ye(l,t);if(f.length>0){let u=d.getText(),g=ht(nt(u,t.constValues)),p={id:C(),type:"decision",decisionId:C(),label:g.length>40?g.slice(0,40)+"...":g,condition:u,source:"raw-short-circuit",onTrue:[],onFalse:f.map(m=>m.effect)};return t.stats.decisionCount++,[{effect:p}]}}if(a===r.QuestionQuestionToken){let f=yield*ye(l,t);if(f.length>0){let u=`${d.getText()} != null`,g=ht(nt(u,t.constValues)),p={id:C(),type:"decision",decisionId:C(),label:g.length>40?g.slice(0,40)+"...":g,condition:u,source:"raw-short-circuit",onTrue:[],onFalse:f.map(m=>m.effect)};return t.stats.decisionCount++,[{effect:p}]}}}let i=gs(e),c=[];for(let o of i){let a=yield*ps(o,t);c.push(a)}return c})}var Yo=(e,t,r,s,n,i)=>xe.gen(function*(){let{SyntaxKind:c}=w(),o;if((e.getKind()===c.ArrowFunction||e.getKind()===c.FunctionExpression||e.getKind()===c.FunctionDeclaration)&&(o=e.getBody()),!o)return[];let a=new Map,l={sourceFile:t,filePath:r,opts:s,warnings:n,stats:i,serviceScope:a,constValues:new Map},f;o.getKind()===c.Block?f=yield*rt(o,l):f=yield*ye(o,l);let u=o.getDescendantsOfKind(c.CallExpression);for(let h of u){let y=Le(t);if(et(h,t,y,s.knownEffectInternalsRoot)){let N=yield*vn(h,t,r,s,n,i,a);f.push({effect:N})}}let g=_e(e),p={id:C(),type:"generator",yields:f,jsdocDescription:g,jsdocTags:Ye(e)};return[{...p,displayName:G(p),semanticRole:Q(p)}]});function Xo(e,t,r,s,n,i){let o=e.getExpression().getText();if(!(o.endsWith(".pipe")||o==="pipe"))return xe.succeed(yt.none());let d=e.getArguments(),l=d[d.length-1];if(!l)return xe.succeed(yt.none());let f=l.getText();return f.includes(".runMain")||f.includes(".runPromise")||f.includes(".runSync")||f.includes(".runFork")?xe.map(Rt(e,t,r,s,n,i),g=>yt.some(g)):xe.succeed(yt.none())}var St=(e,t)=>Re.gen(function*(){let r={...an,...t},{ts:s,Project:n}=w(),i=yield*Re.try({try:()=>Rr(e)?new n({skipAddingFilesFromTsConfig:!0,compilerOptions:{allowJs:!0}}):Nr(r.tsConfigPath),catch:d=>new Se("PROJECT_CREATION_FAILED",`Failed to create project: ${String(d)}`)}),c=i.getSourceFile(e);c&&i.removeSourceFile(c);let o=yield*Re.try({try:()=>i.addSourceFileAtPath(e),catch:d=>new Se("FILE_NOT_FOUND",`Failed to load file ${e}: ${String(d)}`)}),a=kn(o,r);return a.length===0?yield*Re.fail(new Se("NO_EFFECTS_FOUND",`No Effect programs found in ${e}`)):yield*Re.forEach(a,d=>In(d,o,e,r,s.version),{concurrency:"unbounded"})}),Ge=(e,t="temp.ts",r)=>Re.gen(function*(){let s={...an,...r},{ts:n}=w(),i=yield*Re.try({try:()=>Cr(e,t),catch:o=>new Se("SOURCE_PARSE_FAILED",`Failed to parse source: ${String(o)}`)}),c=kn(i,s);return c.length===0?yield*Re.fail(new Se("NO_EFFECTS_FOUND","No Effect programs found in source")):yield*Re.forEach(c,o=>In(o,i,t,s,n.version),{concurrency:"unbounded"})});var Te=e=>({single:()=>X.gen(function*(){if(e.length===1){let t=e[0];if(t)return t}return yield*X.fail(new Se("NOT_SINGLE_PROGRAM",`Expected exactly 1 program, found ${String(e.length)}`))}),singleOption:()=>X.gen(function*(){if(e.length===1){let t=e[0];if(t)return Pt.some(t)}return Pt.none()}),all:()=>X.succeed(e),named:t=>X.gen(function*(){let r=e.find(s=>s.root.programName===t);if(!r){let s=e.map(n=>n.root.programName).join(", ");return yield*X.fail(new Se("PROGRAM_NOT_FOUND",`Program "${t}" not found. Available: ${s||"(none)"}`))}return r}),first:()=>X.gen(function*(){let t=e[0];return t||(yield*X.fail(new Se("NO_PROGRAMS","No programs found")))}),firstOption:()=>X.gen(function*(){let t=e[0];return t?Pt.some(t):Pt.none()})}),We=(e,t)=>{Tt();let r=St(e,t);return{single:()=>X.gen(function*(){let s=yield*r;return yield*Te(s).single()}),singleOption:()=>X.gen(function*(){let s=yield*r;return yield*Te(s).singleOption()}).pipe(X.orDie),all:()=>r,named:s=>X.gen(function*(){let n=yield*r;return yield*Te(n).named(s)}),first:()=>X.gen(function*(){let s=yield*r;return yield*Te(s).first()}),firstOption:()=>X.gen(function*(){let s=yield*r;return yield*Te(s).firstOption()}).pipe(X.orDie)}};We.source=(e,t)=>{Tt();let r=Ge(e,"temp.ts",t);return{single:()=>X.gen(function*(){let s=yield*r;return yield*Te(s).single()}),singleOption:()=>X.gen(function*(){let s=yield*r;return yield*Te(s).singleOption()}).pipe(X.orDie),all:()=>r,named:s=>X.gen(function*(){let n=yield*r;return yield*Te(n).named(s)}),first:()=>X.gen(function*(){let s=yield*r;return yield*Te(s).first()}),firstOption:()=>X.gen(function*(){let s=yield*r;return yield*Te(s).firstOption()}).pipe(X.orDie)}};import{Effect as ra,Option as au}from"effect";import{Option as ea}from"effect";function ms(e,t){for(let r of e){r.type==="effect"&&t.push(r);let s=ea.getOrElse(P(r),()=>[]);s.length>0&&ms(s,t)}}function ys(e){let t=[],r=[],s=new Set,n=new Map,i=[];ms(e.root.children,i);for(let d of i){let l=d.typeSignature?.successType,f=(d.requiredServices??[]).map(u=>u.serviceId);if(l){s.add(l);let u=n.get(l)??[];u.push(d.id),n.set(l,u)}t.push({id:d.id,name:d.callee,writes:l,reads:f,location:d.location?{line:d.location.line,column:d.location.column}:void 0})}for(let d=0;d<i.length-1;d++){let l=i[d],f=i[d+1];if(l===void 0||f===void 0)continue;let u=l.typeSignature?.successType??"value";r.push({from:l.id,to:f.id,key:u})}let c="__context__";for(let d of t)for(let l of d.reads)r.push({from:c,to:d.id,key:l});let o=[];for(let d of t)for(let l of d.reads)!s.has(l)&&l!==c&&o.push({key:l,readerId:d.id,readerName:d.name});let a=[];for(let[d,l]of n)l.length>1&&a.push({key:d,writerIds:l});return{nodes:t,edges:r,producedKeys:s,undefinedReads:o,duplicateWrites:a}}import{Option as it}from"effect";function An(e){let t=e.trim();return t==="never"||t==="unknown"?[]:Fe(t)}function hs(e,t){for(let r of e){if(r.type==="effect"){let n=r,i=n.typeSignature?.errorType?An(n.typeSignature.errorType):[];t.push({stepId:n.id,stepName:n.callee,errors:i,location:n.location?{line:n.location.line,column:n.location.column}:void 0})}let s=it.getOrElse(P(r),()=>[]);s.length>0&&hs(s,t)}}function Ot(e){let t=[],r=new Set,s=new Map,n=[];hs(e.root.children,t);for(let i of t){i.errors.length===0&&n.push(i.stepId);for(let c of i.errors){r.add(c);let o=s.get(c)??[];o.push(i.stepId),s.set(c,o)}}return{allErrors:Array.from(r).sort(),stepErrors:t,errorToSteps:s,stepsWithoutErrors:n,allStepsDeclareErrors:n.length===0&&t.length>0}}function Mt(e,t){return Array.from(new Set([...e,...t])).sort()}function ta(e,t){let r=new Set(t);return e.filter(s=>!r.has(s))}function na(e){let t=[],r=s=>{if(s.type==="effect"){let i=s.typeSignature?.errorType;i&&t.push(...An(i))}it.getOrElse(P(s),()=>[]).forEach(r)};return r(e),Mt([],t)}function Ss(e){if(e.type==="cause")return e.causeKind;let t=it.getOrElse(P(e),()=>[]);for(let r of t){let s=Ss(r);if(s)return s}}function st(e,t,r){let s=[...t];for(let n of e)if(n.type==="effect"){let i=n,c=i.typeSignature?.errorType?An(i.typeSignature.errorType):[];s=Mt(s,c),r.push({atNode:i.id,possibleErrors:[...s],defects:[],interruptible:!1});let o=it.getOrElse(P(n),()=>[]);o.length>0&&(s=st(o,s,r))}else if(n.type==="error-handler"){let i=n;s=st([i.source],s,r);let c=[...s],o=[];i.handlerType==="catchTag"&&i.errorTag?o.push(i.errorTag):i.handlerType==="catchTags"?i.errorTags&&i.errorTags.length>0?o.push(...c.filter(l=>i.errorTags?i.errorTags.includes(l):!1)):o.push(...c.filter(l=>/Error$|^[A-Z]/.test(l))):i.handlerType==="catchIf"||i.handlerType==="catchSome"||i.handlerType==="catchSomeCause"||i.handlerType==="catchSomeDefect"?o.push(...c.slice(0,Math.ceil(c.length/2))):i.handlerType==="catchAll"||i.handlerType==="catchAllCause"||i.handlerType==="catchAllDefect"||i.handlerType==="orElse"||i.handlerType==="orDie"||i.handlerType==="orDieWith"?o.push(...c):i.handlerType==="mapError"||i.handlerType==="mapErrorCause"||i.handlerType==="mapBoth"?o.push(...c):i.handlerType==="sandbox"?o.push(...c):i.handlerType==="ignore"||i.handlerType==="ignoreLogged"?o.push(...c):i.handlerType==="orElseFail"||i.handlerType==="orElseSucceed"?o.push(...c):(i.handlerType==="filterOrDie"||i.handlerType==="filterOrDieMessage")&&o.push(...c);let a=ta(s,o),d=i.handler?na(i.handler):[];if((i.handlerType==="mapError"||i.handlerType==="mapErrorCause"||i.handlerType==="mapBoth")&&o.length>0&&d.length===0){let l=Ss(i.source);l==="fail"?d=["<mapped-fail>"]:l==="die"?d=["<mapped-defect>"]:d=["<mapped-error>"]}s=Mt(a,d),r.push({atNode:i.id,possibleErrors:[...s],narrowedBy:{handler:i.handlerType,removedErrors:o,addedErrors:d},defects:[],interruptible:!1}),i.handler&&(s=st([i.handler],s,r))}else if(n.type==="parallel"||n.type==="race"){let i=it.getOrElse(P(n),()=>[]),c=[];for(let o of i){let a=st([o],s,r);c=Mt(c,a)}s=c}else{let i=it.getOrElse(P(n),()=>[]);i.length>0&&(s=st(i,s,r))}return s}function Lt(e){let t=[];st(e.root.children,[],t);let r=new Map;for(let s of t)r.set(s.atNode,s);return{propagation:t,byNodeId:r}}var Ns={effect:"fill:#90EE90,stroke:#333,stroke-width:2px",generator:"fill:#FFB6C1,stroke:#333,stroke-width:2px",pipe:"fill:#ADD8E6,stroke:#333,stroke-width:2px",parallel:"fill:#FFA500,stroke:#333,stroke-width:2px",race:"fill:#FF6347,stroke:#333,stroke-width:2px",errorHandler:"fill:#FFD700,stroke:#333,stroke-width:2px",retry:"fill:#EE82EE,stroke:#333,stroke-width:2px",timeout:"fill:#87CEEB,stroke:#333,stroke-width:2px",resource:"fill:#98FB98,stroke:#333,stroke-width:2px",conditional:"fill:#DDA0DD,stroke:#333,stroke-width:2px",loop:"fill:#F0E68C,stroke:#333,stroke-width:2px",layer:"fill:#E6E6FA,stroke:#333,stroke-width:2px",stream:"fill:#E0F7FA,stroke:#333,stroke-width:2px",concurrencyPrimitive:"fill:#B0E0E6,stroke:#333,stroke-width:2px",fiber:"fill:#DDA0DD,stroke:#333,stroke-width:2px",decision:"fill:#DDA0DD,stroke:#333,stroke-width:2px",switch:"fill:#FFD700,stroke:#333,stroke-width:2px",tryCatch:"fill:#FFE4B5,stroke:#333,stroke-width:2px",terminal:"fill:#FF6B6B,stroke:#333,stroke-width:2px",opaque:"fill:#FF9800,stroke:#333,stroke-width:2px",unknown:"fill:#D3D3D3,stroke:#333,stroke-width:1px",start:"fill:#c8e6c9,stroke:#2e7d32",end:"fill:#ffcdd2,stroke:#c62828",cause:"fill:#FF8A80,stroke:#D32F2F,stroke-width:2px",exit:"fill:#B39DDB,stroke:#512DA8,stroke-width:2px",schedule:"fill:#80DEEA,stroke:#00838F,stroke-width:2px",match:"fill:#FFE082,stroke:#F57F17,stroke-width:2px",transform:"fill:#A5D6A7,stroke:#388E3C,stroke-width:2px",channel:"fill:#90CAF9,stroke:#1565C0,stroke-width:2px",sink:"fill:#CE93D8,stroke:#7B1FA2,stroke-width:2px",interruption:"fill:#FFAB91,stroke:#BF360C,stroke-width:2px"},Rn={direction:"TB",includeIds:!1,includeDescriptions:!0,styles:Ns,compact:!1,includeTypeSignatures:!0,useSubgraphs:!0,showConditions:!0,detail:"verbose"};function ie(e){return e.replace(/\r?\n/g," ").replace(/"/g,"'").replace(/\[/g,"(").replace(/\]/g,")").replace(/\{/g,"(").replace(/\}/g,")").replace(/#/g,"#").replace(/\|/g,"|")}function ot(e,t){return e.length<=t?e:e.slice(0,t-3)+"..."}function sa(e){return e.replace(/[^a-zA-Z0-9_]/g,"_")}function Cs(e,t,r){let s={...Rn,...t,useSubgraphs:t?.useSubgraphs??!0,showConditions:t?.showConditions??!0,detail:t?.detail??"verbose"},n={opts:s,nodeCounter:0,edges:[],subgraphs:[],styleClasses:new Map,nodeIdMap:new Map,nodeLabelAnnotations:r},i=[];i.push(`flowchart ${s.direction}`),i.push(""),i.push(` %% Program: ${e.root.programName}`),i.push("");let c="start",o="end_node";i.push(` ${c}((Start))`),i.push(` ${o}((End))`),i.push("");let{firstNodeId:a,lastNodeIds:d}=Ee(e.root.children,n,i);a&&n.edges.push({from:c,to:a});for(let f of d)n.edges.push({from:f,to:o});for(let f of n.subgraphs){i.push(""),i.push(` subgraph ${f.id}["${f.label}"]`);for(let u of f.content)i.push(` ${u}`);i.push(" end")}i.push(""),i.push(" %% Edges");for(let f of n.edges)f.label&&s.showConditions?i.push(` ${f.from} -->|${ie(f.label)}| ${f.to}`):i.push(` ${f.from} --> ${f.to}`);let l={...Ns,...s.styles};i.push(""),i.push(" %% Styles"),l.start&&i.push(` classDef startStyle ${l.start}`),l.end&&i.push(` classDef endStyle ${l.end}`);for(let[f,u]of Object.entries(l))u&&f!=="start"&&f!=="end"&&i.push(` classDef ${f}Style ${u}`);i.push(` class ${c} startStyle`),i.push(` class ${o} endStyle`);for(let[f,u]of n.styleClasses)i.push(` class ${f} ${u}`);if(t?.dataFlowOverlay){let f=ys(e),u=n.nodeIdMap;i.push(""),i.push(" %% Data-flow variable annotations"),i.push(" linkStyle default stroke:#999");for(let g of f.edges){if(g.from==="__context__")continue;let p=u.get(g.from),m=u.get(g.to);p&&m&&g.key&&g.key!=="value"&&i.push(` ${p} -.->|${g.key}| ${m}`)}if(f.undefinedReads.length>0){i.push(""),i.push(" %% Data-flow warnings"),i.push(" classDef dataFlowWarning fill:#fff3cd,stroke:#856404,stroke-width:2px");for(let g of f.undefinedReads){let p=u.get(g.readerId);p&&i.push(` class ${p} dataFlowWarning`)}}if(f.duplicateWrites.length>0){i.push(" classDef duplicateWrite fill:#f8d7da,stroke:#721c24,stroke-width:2px");for(let g of f.duplicateWrites)for(let p of g.writerIds){let m=u.get(p);m&&i.push(` class ${m} duplicateWrite`)}}}if(t?.errorFlowOverlay){let f=Ot(e),u=Lt(e),g=n.nodeIdMap;i.push(""),i.push(" %% Error-flow overlay"),i.push(" classDef canFail fill:#FFECB3,stroke:#F57F17,stroke-width:2px"),i.push(" classDef unhandledError fill:#FFCDD2,stroke:#C62828,stroke-width:3px");for(let p of f.stepErrors)if(p.errors.length>0){let m=g.get(p.stepId);m&&i.push(` class ${m} canFail`)}for(let p of u.propagation)if(p.possibleErrors.length>0&&!p.narrowedBy){let m=g.get(p.atNode);m&&i.push(` class ${m} unhandledError`)}for(let p of u.propagation)if(p.narrowedBy&&p.narrowedBy.removedErrors.length>0){let m=g.get(p.narrowedBy.handler),h=g.get(p.atNode);if(m&&h){let y=p.narrowedBy.removedErrors.join(", ");i.push(` ${h} -.->|catches ${y}| ${m}`)}}}return{lines:i,context:n}}function Ee(e,t,r){if(e.length===0)return{firstNodeId:null,lastNodeIds:[]};let s=null,n=[];for(let i of e){let c=se(i,t,r);if(s===null&&c.firstNodeId&&(s=c.firstNodeId),c.firstNodeId)for(let o of n)t.edges.push({from:o,to:c.firstNodeId});n=c.lastNodeIds}return{firstNodeId:s,lastNodeIds:n}}function ia(e,t){let r=t.opts.includeIds&&"id"in e?e.id:`n${String(++t.nodeCounter)}`;return sa(r)}function oa(e,t,r){if(!t.includeDescriptions)return e.type;let s;switch(e.type){case"effect":s=e.callee||"Effect";break;case"generator":s=`Generator (${e.yields.length} yields)`;break;case"pipe":s=`Pipe (${e.transformations.length+1} steps)`;break;case"parallel":s=`${e.callee} (${e.children.length} effects)`;break;case"race":s=`${e.callee} (${e.children.length} racing)`;break;case"error-handler":s=e.handlerType;break;case"retry":s=`Retry${e.schedule?`(${e.schedule})`:""}`;break;case"timeout":s=`Timeout${e.duration?`(${e.duration})`:""}`;break;case"resource":s="Resource";break;case"conditional":s=`${e.conditionalType} (${ot(e.condition,20)})`;break;case"loop":s=`${e.loopType}${e.iterSource?`(${e.iterSource})`:""}`;break;case"layer":s=`Layer${e.isMerged?" (merged)":""}`;break;case"stream":s=`Stream${e.pipeline.length>0?`.${e.pipeline.map(n=>n.operation).join(" \u2192 ")}`:""}${e.sink?` \u2192 ${e.sink}`:""}`;break;case"concurrency-primitive":s=`${e.primitive}.${e.operation}${e.strategy?` (${e.strategy})`:""}`;break;case"fiber":s=`${e.operation}${e.isDaemon?" (daemon)":""}${e.isScoped?" (scoped)":""}`;break;case"decision":s=e.label||ot(e.condition,30);break;case"switch":s=`Switch: ${ot(e.expression,25)}`;break;case"try-catch":s="Try/Catch";break;case"terminal":s=e.terminalKind;break;case"opaque":s=`\u26A0 ${e.reason}`;break;case"cause":s=`Cause: ${e.causeOp}`;break;case"exit":s=`Exit: ${e.exitOp}`;break;case"schedule":s=`Schedule: ${e.scheduleOp}`;break;case"match":s=`Match: ${e.matchOp}${e.matchedTags?.length?` (${e.matchedTags.join(", ")})`:""}`;break;case"transform":s=`${e.transformType}${e.isEffectful?" (effectful)":""}`;break;case"channel":s=`Channel${e.pipeline.length>0?`.${e.pipeline.map(n=>n.operation).join(" \u2192 ")}`:""}`;break;case"sink":s=`Sink${e.pipeline.length>0?`.${e.pipeline.map(n=>n.operation).join(" \u2192 ")}`:""}`;break;case"interruption":s=e.interruptionType;break;case"unknown":s=`Unknown: ${e.reason}`;break;default:{s=e.type??"unknown";break}}if(t.detail!=="compact"&&e.displayName&&(s=e.displayName),t.detail==="verbose"){if(e.type==="effect"&&t.includeTypeSignatures&&e.typeSignature){let n=e.typeSignature;s+=`
|
|
5
|
+
`),r=[],s,n=[],i,c=/@(param|returns?|throws?|exception|example)\s*(.*)/gi,o;for(;(o=c.exec(t))!==null;){let a=o[1].toLowerCase(),d=o[2].trim();if(a==="param"){let l=/^(?:\{[^}]*\}\s*)?(\[?\w+(?:=[^\]]*)?]?)\s*(?:-\s*(.*))?$/.exec(d);if(l){let f=l[1].replace(/^\[|\]$/g,"").replace(/=.*/,""),u=l[2]?.trim();r.push(u?{name:f,description:u}:{name:f})}}else if(a==="returns"||a==="return")s=d.replace(/^\{[^}]*\}\s*/,"").trim()||void 0;else if(a==="throws"||a==="throw"||a==="exception"){let l=d.replace(/^\{[^}]*\}\s*/,"").trim();l&&n.push(l)}else if(a==="example"){let l=o.index+o[0].length,f=/\n\s*@\w/.exec(t.slice(l));f?i=t.slice(o.index+o[0].length-d.length,l+f.index).trim()||void 0:i=t.slice(o.index+o[0].length-d.length).trim()||void 0}}if(!(r.length===0&&!s&&n.length===0&&!i))return{params:r,returns:s,throws:n,example:i}}var Ar=e=>{let t=e.getParent(),{SyntaxKind:r}=w();if(t){let s=t.getKind();if(s===r.VariableDeclaration)return _e(t);if(s===r.ArrowFunction){let n=t.getParent();if(n?.getKind()===r.VariableDeclaration)return _e(n)}}};function Rr(e){return e.endsWith(".js")||e.endsWith(".jsx")}var vt=e=>{let t=e.getParent(),{SyntaxKind:r}=w();if(t?.getKind()===r.VariableDeclaration)return t.getName()},He=e=>{let{SyntaxKind:t}=w(),r=i=>{let c=i;for(;c!==void 0;){if(c.getKind()===t.VariableDeclaration)return c.getName();c=c.getParent()}},s=e.getParent();if(s){let i=s.getKind();if(i===t.VariableDeclaration)return s.getName();if(i===t.AwaitExpression){let c=s.getParent();if(c?.getKind()===t.VariableDeclaration)return c.getName()}if(i===t.PropertyAssignment){let o=s.getName(),a=r(s);return a?`${a}.${o}`:o}if(i===t.ArrowFunction){let c=s.getParent();if(c?.getKind()===t.VariableDeclaration)return c.getName();if(c?.getKind()===t.PropertyAssignment){let a=c.getName(),d=r(c);return d?`${d}.${a}`:a}}}let n=e;for(let i=0;n&&i<6&&(n=n.getParent(),!!n);i++){let c=n.getKind();if(c===t.VariableDeclaration)return n.getName();if(c===t.PropertyAssignment){let a=n.getName(),d=r(n);return d?`${d}.${a}`:a}if(c===t.Block||c===t.SourceFile)break}},Dr=e=>{let{SyntaxKind:t}=w(),r=e.getParent();for(let s=0;r&&s<10;s++){if(r.getKind()===t.CallExpression){let n=r,i=n.getExpression().getText();if(i==="Effect.fn"||i.endsWith(".fn")){let c=n.getArguments();if(c.length>0){let o=c[0].getText(),a=/^["'](.+)["']$/.exec(o);if(a?.[1])return a[1]}}}r=r.getParent()}},Pr=()=>({totalEffects:0,parallelCount:0,raceCount:0,errorHandlerCount:0,retryCount:0,timeoutCount:0,resourceCount:0,loopCount:0,conditionalCount:0,layerCount:0,interruptionCount:0,unknownCount:0,decisionCount:0,switchCount:0,tryCatchCount:0,terminalCount:0,opaqueCount:0}),ft=(e,t)=>e.length<=t?e:`${e.slice(0,t)}\u2026`;function G(e,t){switch(e.type){case"effect":{let r=t??e.name;return r?`${r} <- ${e.callee}`:e.callee}case"generator":return`Generator (${e.yields.length} yields)`;case"pipe":return`Pipe (${e.transformations.length} steps)`;case"parallel":return`${e.callee} (${e.children.length})`;case"race":return`${e.callee} (${e.children.length} racing)`;case"error-handler":return e.name?`${e.name}: ${e.handlerType}`:e.handlerType;case"retry":return e.schedule?`retry: ${e.schedule}`:"retry";case"timeout":return e.duration?`timeout: ${e.duration}`:"timeout";case"resource":return"Resource";case"conditional":return ft(e.condition,30);case"loop":return e.iterSource?`${e.loopType}(${e.iterSource})`:e.loopType;case"layer":return e.isMerged?"Layer (merged)":"Layer";case"stream":{let s=["Stream",...e.pipeline.map(n=>n.operation)];return e.sink&&s.push(e.sink),s.join(" \u2192 ")}case"concurrency-primitive":return`${e.primitive}.${e.operation}`;case"fiber":{let r=e.operation;return e.isDaemon?`${r} (daemon)`:e.isScoped?`${r} (scoped)`:r}case"transform":return e.transformType;case"match":return`Match.${e.matchOp}`;case"cause":return`Cause.${e.causeOp}`;case"exit":return`Exit.${e.exitOp}`;case"schedule":return`Schedule.${e.scheduleOp}`;case"interruption":return e.interruptionType;case"channel":{let r=e.pipeline.map(s=>s.operation);return r.length>0?`Channel: ${r.join(" \u2192 ")}`:"Channel"}case"sink":{let r=e.pipeline.map(s=>s.operation);return r.length>0?`Sink: ${r.join(" \u2192 ")}`:"Sink"}case"decision":return ft(e.condition,30);case"switch":return`switch(${ft(e.expression,25)})`;case"try-catch":return"try/catch";case"terminal":return e.label?`${e.terminalKind} ${e.label}`:e.terminalKind;case"opaque":return`Opaque: ${ft(e.reason,25)}`;case"unknown":return`Unknown: ${ft(e.reason,30)}`}}function Q(e){switch(e.type){case"effect":{if(e.serviceCall||e.serviceMethod)return"service-call";let t=e.description?.toLowerCase()??"";if(t.includes("service"))return"service-call";if(t.includes("layer")||e.provideKind==="layer")return"layer";let r=e.callee.toLowerCase();return/^[A-Z][A-Za-z0-9_]*$/.test(e.callee)&&!e.constructorKind?"environment":r.includes("sync")||r.includes("promise")||r.includes("async")||r.includes("log")||r.includes("console")?"side-effect":r.includes("succeed")||r.includes("fail")||r.includes("die")||r.includes("void")||r.includes("never")||r.includes("gen")||r.includes("make")||e.constructorKind?"constructor":"side-effect"}case"generator":case"pipe":return"constructor";case"parallel":case"race":case"concurrency-primitive":return"concurrency";case"error-handler":case"cause":case"exit":return"error-handler";case"retry":case"timeout":case"schedule":return"scheduling";case"resource":return"resource";case"conditional":case"loop":case"match":case"decision":case"switch":case"terminal":return"control-flow";case"try-catch":return"error-handler";case"opaque":return"unknown";case"layer":return"layer";case"stream":case"channel":case"sink":return"stream";case"fiber":case"interruption":return"fiber";case"transform":return"transform";case"unknown":return"unknown"}}var cn=[".catchAll",".catchTag",".catchAllCause",".catchIf",".catchSome",".catchSomeCause",".catchSomeDefect",".catchAllDefect",".catchTags",".orElse",".orElseFail",".orElseSucceed",".orDie",".orDieWith",".flip",".mapError",".mapErrorCause",".mapBoth",".sandbox",".unsandbox",".parallelErrors",".filterOrDie",".filterOrDieMessage",".filterOrElse",".filterOrFail",".match",".matchCause",".matchEffect",".matchCauseEffect",".firstSuccessOf",".ignore",".ignoreLogged",".eventually"],ln=[".if",".when",".whenEffect",".whenFiberRef",".whenRef",".unless",".unlessEffect",".option",".either",".exit",".liftPredicate"],Qi=[".acquireRelease",".acquireUseRelease",".ensuring",".addFinalizer",".onExit",".onError",".parallelFinalizers",".sequentialFinalizers",".finalizersMask",".using",".withEarlyRelease"],dn=[".forEach",".loop",".filter",".filterMap",".partition",".reduce",".reduceRight",".reduceWhile",".reduceEffect",".dropUntil",".dropWhile",".takeUntil",".takeWhile",".every",".exists",".findFirst",".head",".mergeAll",".replicate",".replicateEffect",".validateAll",".validateFirst",".validate",".validateWith"],un=["Effect.fork",".fork",".forkAll",".forkIn",".forkWithErrorHandler","Fiber."],fn={"Effect.map":"map","Effect.flatMap":"flatMap","Effect.andThen":"andThen","Effect.tap":"tap","Effect.tapBoth":"tapBoth","Effect.tapError":"tapError","Effect.tapErrorTag":"tapErrorTag","Effect.tapErrorCause":"tapErrorCause","Effect.tapDefect":"tapDefect","Effect.zipLeft":"zipLeft","Effect.zipRight":"zipRight","Effect.zipWith":"zipWith","Effect.zip":"zip","Effect.as":"as","Effect.asVoid":"asVoid","Effect.asSome":"asSome","Effect.asSomeError":"asSomeError","Effect.flatten":"flatten","Effect.ap":"ap","Effect.negate":"negate","Effect.merge":"merge"},Or=new Set(["flatMap","andThen","tapBoth","tapError","tapErrorTag","tapErrorCause","tapDefect","zipWith","zipLeft","zipRight","zip","ap","flatten"]),Lr=e=>e in fn,pn={"Match.type":"type","Match.tag":"tag","Match.value":"value","Match.when":"when","Match.whenOr":"whenOr","Match.whenAnd":"whenAnd","Match.not":"not","Match.is":"is","Match.exhaustive":"exhaustive","Match.orElse":"orElse","Match.option":"option","Match.either":"either","Match.discriminator":"discriminator","Match.discriminatorsExhaustive":"discriminatorsExhaustive","Match.tags":"tags","Match.tagsExhaustive":"tagsExhaustive","Match.withReturnType":"withReturnType","Match.run":"run"},Wr=new Set(["exhaustive","discriminatorsExhaustive","tagsExhaustive"]),Kr=e=>e.startsWith("Match.")&&e in pn,gn={"Cause.fail":"fail","Cause.die":"die","Cause.interrupt":"interrupt","Cause.parallel":"parallel","Cause.sequential":"sequential","Cause.empty":"empty","Cause.failures":"failures","Cause.defects":"defects","Cause.interruptors":"interruptors","Cause.squash":"squash","Cause.squashWith":"squashWith","Cause.pretty":"pretty","Cause.flatten":"flatten","Cause.isDie":"isDie","Cause.isFailure":"isFailure","Cause.isInterrupted":"isInterrupted","Cause.isEmpty":"isEmpty","Cause.map":"map","Cause.filter":"filter"},jr=new Set(["fail","die","interrupt","parallel","sequential","empty"]),Br=e=>e.startsWith("Cause.")&&e in gn,mn={"Exit.succeed":"succeed","Exit.fail":"fail","Exit.die":"die","Exit.interrupt":"interrupt","Exit.void":"void","Exit.unit":"unit","Exit.match":"match","Exit.isSuccess":"isSuccess","Exit.isFailure":"isFailure","Exit.isInterrupted":"isInterrupted","Exit.when":"when","Exit.whenEffect":"whenEffect","Exit.exists":"exists","Exit.contains":"contains","Exit.flatten":"flatten","Exit.map":"map","Exit.mapBoth":"mapBoth","Exit.mapError":"mapError","Exit.flatMap":"flatMap","Exit.zipWith":"zipWith","Exit.tap":"tap","Exit.tapBoth":"tapBoth","Exit.tapError":"tapError"},qr=new Set(["succeed","fail","die","interrupt","void","unit"]),zr=e=>e.startsWith("Exit.")&&(e in mn||/^Exit\.\w+$/.test(e)),yn={"Schedule.exponential":"exponential","Schedule.fibonacci":"fibonacci","Schedule.spaced":"spaced","Schedule.fixed":"fixed","Schedule.linear":"linear","Schedule.cron":"cron","Schedule.windowed":"windowed","Schedule.duration":"duration","Schedule.elapsed":"elapsed","Schedule.delays":"delays","Schedule.once":"once","Schedule.stop":"stop","Schedule.count":"count","Schedule.forever":"forever","Schedule.jittered":"jittered","Schedule.andThen":"andThen","Schedule.intersect":"intersect","Schedule.union":"union","Schedule.compose":"compose","Schedule.zipWith":"zipWith","Schedule.addDelay":"addDelay","Schedule.modifyDelay":"modifyDelay","Schedule.check":"check","Schedule.resetAfter":"resetAfter","Schedule.resetWhen":"resetWhen","Schedule.ensure":"ensure","Schedule.driver":"driver","Schedule.mapInput":"mapInput"},_r=e=>e.startsWith("Schedule.")&&(e in yn||/^Schedule\.\w+$/.test(e)),hn=[".interruptible",".uninterruptible",".interruptibleMask",".uninterruptibleMask",".onInterrupt",".disconnect",".allowInterrupt","Effect.interrupt",".interruptWith"],Zi=[".Do",".bind",".bindAll",".bindTo"],Yi=[".cached",".cachedWithTTL",".cachedInvalidateWithTTL",".cachedFunction",".once","Cache.","ScopedCache."],Sn=["Effect.","Layer.","Schedule.","Stream.","Queue.","PubSub.","Deferred.","Semaphore.","Mailbox.","SubscriptionRef.","Scope.","Fiber.","Runtime.","ManagedRuntime.","NodeRuntime.","BunRuntime.","DenoRuntime.","Cause.","Exit.","Data.","Option.","Either.","Chunk.","HashMap.","HashSet.","List.","SortedMap.","SortedSet.","RedBlackTree.","Trie.","Graph.","Match.","Config.","Schema.","Cache.","ScopedCache.","RcRef.","RcMap.","Reloadable.","Cache.","ScopedCache.","RateLimiter.","PartitionedSemaphore.","FiberSet.","FiberMap.","FiberHandle.","Metric.","Logger.","Tracer.","Context.","HttpClient.","HttpRouter.","HttpApi.","FileSystem.","Command.","Socket.","SocketServer.","Worker.","Terminal.","KeyValueStore.","Multipart.","Ndjson.","MsgPack.","OpenApi.","OpenApiJsonSchema.","Brand.","Encoding.","Predicate.","DateTime.","Cron.","BigDecimal.","HashRing.","Redacted.","GlobalValue.","Channel.","Sink.","CliApp.","Args.","Options.","AiModel.","AiToolkit.","Completions.","AiInput.","AiResponse.","NodeSdk.","WebSdk.","Entity.","ClusterSchema.","MessageState.","Sharding.","RpcGroup.","RpcApi.","RpcClient.","RpcRouter.","SqlResolver.","SqlMigrator.","Printer.","Doc.","DocTree.","PageWidth.","Optimize."],Hr=new Set(["Array","ReadonlyArray","String","Number","Boolean","Object","Function","Promise","Math","Date","RegExp","Error","Map","Set","WeakMap","WeakSet","Symbol","BigInt","JSON","Console","process","Buffer","EventEmitter","Window","Document","AbortController"]),xn=new Set(["Effect","Layer","Stream","Queue","PubSub","Deferred","Semaphore","Mailbox","SubscriptionRef","Scope","Fiber","Runtime","ManagedRuntime","Cause","Exit","Data","Option","Either","Chunk","HashMap","HashSet","List","SortedMap","SortedSet","Match","Config","Schema","Schedule","Metric","Tracer","Logger","FiberRef","FiberHandle","FiberSet","FiberMap","Cache","ScopedCache","RateLimiter","Supervisor"]),Ur=e=>e.includes(".")||xn.has(e)?!1:/^[A-Z][A-Za-z0-9]*$/.test(e),Mr=e=>{if(e.startsWith("Channel."))return"channel";if(e.startsWith("Sink."))return"sink";if(e.endsWith(".never"))return"never";if(e.endsWith(".void"))return"void-effect";if(e.endsWith(".fromNullable"))return"null-coalescing";if(e.endsWith(".fn")||e.endsWith(".fnUntraced"))return"function-lift";if(e.includes(".async")||e.includes(".asyncEffect")||e.includes(".promise")||e.includes(".sync")||e.includes(".suspend")||e.includes(".succeed")||e.includes(".fail")||e.includes(".try"))return"constructor";if(hn.some(t=>e.includes(t)))return"interruption";if(Zi.some(t=>e.includes(t)))return"do-notation";if(Yi.some(t=>e.includes(t)||e.startsWith(t)))return"caching";if(cn.some(t=>e.includes(t)))return"error-handler";if(ln.some(t=>e.includes(t)))return"conditional";if(Qi.some(t=>e.includes(t)))return"resource";if(dn.some(t=>e.includes(t)))return"collection";if(un.some(t=>e.includes(t)))return"fiber";if(e.startsWith("Stream."))return"stream";if(e.startsWith("Layer."))return"layer";if(e.startsWith("Schema."))return"schema";if(e.startsWith("Config."))return"config";if(e.startsWith("Cause."))return"cause";if(e.startsWith("Exit."))return"exit";if(e==="Data.tagged"||e==="Data.taggedEnum")return"tagged-enum";if(e.startsWith("Data."))return"data";if(e.startsWith("Option."))return"option";if(e.startsWith("Either."))return"either";if(e.startsWith("Match."))return"match";if(e.startsWith("ManagedRuntime.")||e.startsWith("Runtime.")||e.startsWith("NodeRuntime.")||e.startsWith("BunRuntime.")||e.startsWith("DenoRuntime."))return"runtime";if(e.startsWith("Scope."))return"scope";if(e.startsWith("ScopedRef.")||e.startsWith("RcRef.")||e.startsWith("RcMap."))return"resource-ref";if(e.startsWith("Reloadable.")||e.startsWith("Resource."))return"reloadable";if(e.startsWith("Micro."))return"micro";if(e.startsWith("Brand."))return"brand";if(e.startsWith("Encoding."))return"encoding";if(e.startsWith("Predicate."))return"predicate";if(e.startsWith("DateTime."))return"datetime";if(e.startsWith("Cron."))return"cron";if(e.startsWith("Redacted."))return"redacted";if(e.startsWith("GlobalValue."))return"global-value";if(e.startsWith("Supervisor."))return"supervisor";if(e.includes(".locally")||e.includes(".locallyWith")||e.includes(".locallyScoped")||e.includes(".getFiberRefs")||e.includes(".setFiberRefs")||e.includes(".inheritFiberRefs")||e.includes("FiberRef."))return"fiberref";if(e.includes(".withConcurrency")||e.includes(".withScheduler")||e.includes(".withSchedulingPriority")||e.includes(".daemonChildren")||e.includes(".awaitAllChildren")||e.includes(".supervised"))return"structured-concurrency";if(e.startsWith("Context.pick")||e.startsWith("Context.omit")||e==="Effect.provide"||e.startsWith("Effect.")&&e.includes(".provide")&&!e.includes("provideService"))return"context";if(e.includes(".serviceOption")||e.includes(".serviceOptional")||e.includes(".serviceFunction")||e.includes(".serviceFunctionEffect")||e.includes(".serviceFunctions")||e.includes(".serviceConstants")||e.includes(".serviceMembers")||e.includes(".updateService"))return"service";if(e.startsWith("CliApp.")||e.startsWith("Args.")||e.startsWith("Options."))return"cli";if(e.startsWith("AiModel.")||e.startsWith("AiToolkit.")||e.startsWith("Completions.")||e.startsWith("AiInput.")||e.startsWith("AiResponse."))return"ai";if(e.startsWith("NodeSdk.")||e.startsWith("WebSdk.")||e.startsWith("OtelMetrics."))return"opentelemetry";if(e.startsWith("Entity.")||e.startsWith("ClusterSchema.")||e.startsWith("MessageState.")||e.startsWith("Sharding."))return"cluster";if(e.startsWith("RpcGroup.")||e.startsWith("RpcApi.")||e.startsWith("RpcClient.")||e.startsWith("RpcRouter."))return"rpc";if(e.startsWith("SqlResolver.")||e.startsWith("SqlMigrator."))return"sql";if(e.startsWith("DevTools.")||e.startsWith("Server."))return"devtools";if(e.startsWith("BigDecimal."))return"big-decimal";if(e.startsWith("Graph."))return"graph";if(e.startsWith("HashRing."))return"hash-ring";if(e.startsWith("Chunk."))return"chunk";if(e.startsWith("HashMap.")||e.startsWith("HashSet.")||e.startsWith("List.")||e.startsWith("SortedMap.")||e.startsWith("SortedSet.")||e.startsWith("RedBlackTree.")||e.startsWith("Trie."))return"immutable-collection";if(e.includes(".map")||e.includes(".flatMap")||e.includes(".andThen")||e.includes(".tap")||e.includes(".tapBoth")||e.includes(".tapError")||e.includes(".tapErrorTag")||e.includes(".tapErrorCause")||e.includes(".tapDefect")||e.includes(".zip")||e.includes(".zipLeft")||e.includes(".zipRight")||e.includes(".zipWith")||e.includes(".as")||e.includes(".asVoid")||e.includes(".flatten")||e.includes(".merge")||e.includes(".ap")||e.includes(".validate")||e.includes(".negate"))return"transformation";if(e.startsWith("Printer.")||e.startsWith("Doc.")||e.startsWith("DocTree.")||e.startsWith("PageWidth.")||e.startsWith("Optimize."))return"printer";if(e.startsWith("Http")||e.startsWith("FileSystem.")||e.startsWith("Command.")||e.startsWith("Socket.")||e.startsWith("Worker."))return"platform";if(e.includes("channel.")&&!e.includes("Channel"))return"channel"},Gr=(e,t)=>{let r=Mr(e);if(r)return r;if(t){let s=e.indexOf(".");if(s>0){let n=e.substring(0,s);if(t.has(n)){let i=e.substring(s+1);return Mr(`Effect.${i}`)}}}},oe=(e,t,r=new Set)=>{let{SyntaxKind:s}=w(),n=f=>r.has(f),i=f=>/\.run(?:Promise(?:Exit)?|Sync(?:Exit)?|Fork|Callback|Main)$/.test(f)||/^Runtime\.run(?:Promise|Sync|Fork)$/.test(f),c=f=>{if(i(f))return!1;let u=f==="pipe"||f.endsWith(".pipe"),g=f.indexOf(".");return g>0&&n(f.slice(0,g))?!1:u||[...t].some(p=>f.startsWith(`${p}.`))},o=f=>{let u=f.getExpression(),g=u.getText();if(i(g))return!1;let p=g==="pipe",m=u.getKind()===s.PropertyAccessExpression&&u.getName()==="pipe";if(p||m){if(f.getArguments().some(y=>oe(y,t,r)))return!0;if(m){let y=u.getExpression();return oe(y,t,r)}return!1}return u.getKind()===s.Identifier&&t.has(g)&&!n(g)||c(g)||u.getKind()===s.PropertyAccessExpression&&oe(u.getExpression(),t,r)?!0:f.getArguments().some(h=>oe(h,t,r))},a=(f,u)=>{let g=f.getParent();for(;g&&g!==u;){let p=g.getKind();if(p===s.FunctionDeclaration||p===s.FunctionExpression||p===s.ArrowFunction||p===s.MethodDeclaration||p===s.GetAccessor||p===s.SetAccessor||p===s.ClassDeclaration||p===s.ClassExpression||p===s.Constructor||p===s.ClassStaticBlockDeclaration)return!1;g=g.getParent()}return!0},d=f=>f.getDescendantsOfKind(s.CallExpression).some(m=>a(m,f)&&o(m))||f.getDescendantsOfKind(s.AwaitExpression).some(m=>a(m,f)&&oe(m,t,r))?!0:f.getDescendantsOfKind(s.PropertyAccessExpression).some(m=>a(m,f)&&oe(m,t,r)),l=f=>f.getDescendantsOfKind(s.CallExpression).some(u=>a(u,f)&&i(u.getExpression().getText()));if(e.getKind()===s.ObjectLiteralExpression)return e.getProperties().some(u=>{if(u.getKind()===s.PropertyAssignment||u.getKind()===s.ShorthandPropertyAssignment){let g=u.getKind()===s.PropertyAssignment?u.getInitializer():void 0;return g?oe(g,t,r):!1}if(u.getKind()===s.MethodDeclaration||u.getKind()===s.GetAccessor||u.getKind()===s.SetAccessor){let g=u.getBody();return g?d(g):!1}return!1});if(e.getKind()===s.ArrowFunction||e.getKind()===s.FunctionExpression){let u=e.getBody();if(u.getKind()===s.Block){let g=u;return g.getDescendantsOfKind(s.ReturnStatement).some(h=>{if(!a(h,g))return!1;let y=h.getExpression();return y!==void 0&&oe(y,t,r)})?!0:l(g)?!1:d(g)}return oe(u,t,r)}if(e.getKind()===s.CallExpression)return o(e);if(e.getKind()===s.AwaitExpression){let f=e.getExpression();return f.getKind()!==s.CallExpression?!1:o(f)}if(e.getKind()===s.ConditionalExpression){let f=e;return oe(f.getWhenTrue(),t,r)||oe(f.getWhenFalse(),t,r)}if(e.getKind()===s.PropertyAccessExpression){let f=e.getText(),u=f.indexOf(".");return u>0&&n(f.slice(0,u))?!1:[...t].some(g=>f.startsWith(`${g}.`))}return!1};function Me(e){return e==="effect"||e.startsWith("effect/")||e.startsWith("@effect/")}var En=new Set(["Effect","Layer","Schedule","Stream","Queue","PubSub","Deferred","Semaphore","Mailbox","SubscriptionRef","Scope","Fiber","Runtime","ManagedRuntime","Cause","Exit","Data","Option","Either","Chunk","HashMap","HashSet","Match","Config","Schema","Cache","ScopedCache","Metric","Logger","Tracer","Context","Brand","Encoding","Predicate","DateTime","Cron","BigDecimal","Graph","HashRing","Redacted","GlobalValue","NodeRuntime","BunRuntime","DenoRuntime","Channel","Sink"]),Vr=new Set(["core","core-effect","core-stream","fiberRuntime","effectable","channel","sink","layer","schedule","mailbox","pubsub"]);function Jr(e){let t=new Set(["never","unknown","any","{}","object"]),r=e.trim();return!r||t.has(r)?[]:r.split(/[\s|&]+/).map(n=>n.trim().split("<")[0]?.trim()??"").filter(n=>n.length>0&&!t.has(n))}function pt(e){let{SyntaxKind:t}=w(),r=e.getKind();if(r===t.NumericLiteral){let s=e.getText(),n=Number(s);return Number.isFinite(n)?n:void 0}if(r===t.PrefixUnaryExpression){let s=e;if(s.getOperatorToken()===t.MinusToken){let n=s.getOperand(),i=pt(n);return i!==void 0?-i:void 0}}}import{existsSync as Xi}from"fs";import{dirname as bn,resolve as gt,join as Oe,sep as Qr}from"path";var Zr=new WeakMap,Yr=new WeakMap;function Nn(e){let t=new Set;for(let r of e.getExportDeclarations()){let s=r.getModuleSpecifierValue();if(!(!s||!Me(s))){if(r.isNamespaceExport()){En.forEach(n=>t.add(n));continue}for(let n of r.getNamedExports()){t.add(n.getName());let i=n.getAliasNode()?.getText();i&&t.add(i)}}}return t}function Xe(e,t,r){if(!r.startsWith("."))return;let s=bn(t),n=gt(s,r),i=[n,`${n}.ts`,`${n}.tsx`,`${n}.js`,`${n}.jsx`,Oe(n,"index.ts"),Oe(n,"index.tsx"),Oe(n,"index.js"),Oe(n,"index.jsx")];for(let c of i){let o=e.getSourceFile(c);if(o)return o}}function mt(e,t){if(!t.startsWith("."))return;let r=bn(e),s=gt(r,t);return[s,`${s}.ts`,`${s}.tsx`,`${s}.js`,`${s}.jsx`,Oe(s,"index.ts"),Oe(s,"index.tsx"),Oe(s,"index.js"),Oe(s,"index.jsx")].find(i=>Xi(i))}function It(e,t,r){if(!r||!t.startsWith("."))return!1;let s=t.replace(/\\/g,"/"),n=gt(bn(e),t),i=gt(n),c=gt(r);return i===c||i.startsWith(c+Qr)?!0:e==="temp.ts"||e.endsWith(`${Qr}temp.ts`)?s.startsWith("./internal/")||s.startsWith("../internal/"):!1}function eo(e){let t=new Set(En),r=e.getProject(),s=e.getFilePath();for(let n of e.getImportDeclarations()){let i=n.getModuleSpecifierValue();if(Me(i)){let c=n.getDefaultImport();c&&t.add(c.getText());let o=n.getNamespaceImport();o&&t.add(o.getText());for(let a of n.getNamedImports()){let d=a.getAliasNode()?.getText();t.add(d??a.getName())}continue}if(i.startsWith(".")){let c=Xe(r,s,i);if(!c)continue;let o=Nn(c);if(o.size===0)continue;let a=n.getDefaultImport();if(a){let l=a.getText();o.has(l)&&t.add(l)}let d=n.getNamespaceImport();if(d){let l=d.getText();o.has(l)&&t.add(l)}for(let l of n.getNamedImports())o.has(l.getName())&&t.add(l.getAliasNode()?.getText()??l.getName())}}return t}function Cn(e,t){let r=eo(e);for(let s of e.getImportDeclarations()){let n=s.getModuleSpecifierValue(),i=s.getNamespaceImport();if(!i)continue;let c=i.getText();if(n.startsWith("effect")||n.startsWith("@effect/")){r.add(c);continue}if(It(e.getFilePath(),n,t)){r.add(c);continue}let o=n.replace(/\.(js|ts)$/,"").split("/").pop()??"";Vr.has(o)&&r.add(c)}return r}var to=new Set(["BigDecimal","BigInt","Brand","Cause","Chunk","Data","Exit","Option","Either","HashMap","HashSet","List","Redacted"]);function es(e){let t=new Set;for(let r of e.getImportDeclarations()){let i=r.getModuleSpecifierValue().replace(/\\/g,"/").replace(/\.(js|ts|tsx|jsx)$/,"").split("/").pop()??"";if(!to.has(i))continue;let c=r.getDefaultImport();c&&t.add(c.getText());let o=r.getNamespaceImport();o&&t.add(o.getText());for(let a of r.getNamedImports())t.add(a.getAliasNode()?.getText()??a.getName())}return t}function Le(e){let t=Zr.get(e);return t||(t=Cn(e),Zr.set(e,t)),t}var Xr=new WeakMap;function no(e){let t=e.replace(/\\/g,"/").replace(/\.(js|ts|mts|cts)$/,"");return t==="effect"||t.endsWith("/Effect")?"Effect":(t.split("/").pop()??"")||"Effect"}function ro(e){let t=Xr.get(e);if(t)return t;t=new Map;for(let r of e.getImportDeclarations()){let s=r.getModuleSpecifierValue();if(!s||!Me(s))continue;let n=r.getNamespaceImport();if(!n)continue;let i=n.getText(),c=no(s);t.set(i,c)}return Xr.set(e,t),t}function wn(e,t){let r=e.indexOf(".");if(r<=0)return e;let s=e.slice(0,r),n=e.slice(r+1),c=ro(t).get(s);return c?`${c}.${n}`:e}function so(e,t){let r=Yr.get(t);r||(r=new Map,Yr.set(t,r));let s=e.indexOf("."),n=s>0?e.slice(0,s):e,i=r.get(n);if(i!==void 0)return i;let c=!1;try{for(let o of t.getImportDeclarations()){let a=o.getModuleSpecifierValue();if(o.getNamespaceImport()?.getText()===n){c=Me(a);break}if(o.getDefaultImport()?.getText()===n){c=Me(a);break}for(let f of o.getNamedImports())if((f.getAliasNode()?.getText()??f.getName())===n){if(Me(a))c=!0;else if(a.startsWith(".")){let p=Xe(t.getProject(),t.getFilePath(),a);p&&(c=Nn(p).has(f.getName()))}break}if(c)break}}catch{c=!1}return r.set(n,c),c}function io(e,t){let s=e.getExpression().getText();for(let n of t.getImportDeclarations()){let i=n.getModuleSpecifierValue();if(n.getNamespaceImport()?.getText()===s||n.getDefaultImport()?.getText()===s)return i;for(let a of n.getNamedImports())if((a.getAliasNode()?.getText()??a.getName())===s)return i}}function et(e,t,r,s){let n=e.getExpression(),i=n.getText();if(Sn.some(d=>i.startsWith(d))||i.startsWith("pipe("))return!0;for(let d of r)if(i.startsWith(`${d}.`))return!0;let{SyntaxKind:c}=w();if(n.getKind()!==c.PropertyAccessExpression)return!1;let o=n,a=io(o,t);if(!a)return!1;if(Me(a))return!0;if(a.startsWith(".")){let d=Xe(t.getProject(),t.getFilePath(),a);if(d){let l=Nn(d),f=o.getExpression().getText();for(let u of t.getImportDeclarations())if(u.getModuleSpecifierValue()===a){for(let g of u.getNamedImports())if((g.getAliasNode()?.getText()??g.getName())===f&&l.has(g.getName()))return!0}}if(It(t.getFilePath(),a,s))return!0}return!1}function $t(e,t,r){if(Sn.some(s=>e.startsWith(s))||e.startsWith("pipe("))return!0;if(t){for(let s of t)if(e.startsWith(`${s}.`))return!0}return r&&e.includes(".")?so(e,r):!1}var oo=new Set(["createWorkflow","createSagaWorkflow","runSaga"]),ao=e=>Array.from(oo).some(t=>e===t||e.endsWith(`.${t}`)),ts=e=>{let t=e.getExpression();if(t.getKind()!==w().SyntaxKind.PropertyAccessExpression)return!1;let r=t,s=e.getArguments();if(r.getName()!=="make"||s.length<3||!s[2])return!1;let n=s[2].getKind(),{SyntaxKind:i}=w();return n===i.ArrowFunction||n===i.FunctionExpression};function is(e,t){let r=e.replace(/\\/g,"/");return!!(r==="@effect/workflow"||r==="effect/workflow"||r.endsWith("/workflow")||r.includes("/workflow/")||r.endsWith("/Workflow.js")||r.endsWith("/Workflow.ts")||r.endsWith("/Activity.js")||r.endsWith("/Activity.ts")||r.startsWith(".")&&(r.endsWith("Workflow.js")||r.endsWith("Workflow.ts")||r.endsWith("Activity.js")||r.endsWith("Activity.ts")))}function co(e,t,r){return e!=="Workflow"?!1:is(t,r)}function lo(e,t,r){return e!=="Activity"?!1:is(t,r)}function os(e,t){let{SyntaxKind:r}=w(),s=e.getArguments();if(s.length!==1||!s[0])return!1;let n=s[0];if(n.getKind()!==r.ObjectLiteralExpression)return!1;let c=n.getProperties(),o=new Set(t);for(let a of c)if(a.getKind()===r.PropertyAssignment){let d=a.getName();if(o.has(d))return!0}return!1}function uo(e,t,r){let{SyntaxKind:s}=w(),n=e.getExpression();if(n.getKind()!==s.PropertyAccessExpression)return!1;let i=n;if(i.getName()!=="make")return!1;let c=i.getExpression().getText(),o=t.get(c);return!o||!co(c,o,r)?!1:os(e,["name","payload","idempotencyKey"])}function fo(e,t,r){let{SyntaxKind:s}=w(),n=e.getExpression();if(n.getKind()!==s.PropertyAccessExpression)return!1;let i=n;if(i.getName()!=="make")return!1;let c=i.getExpression().getText(),o=t.get(c);return!o||!lo(c,o,r)?!1:os(e,["name","execute"])}var as=(e,t)=>{let r=e.getExpression();if(r.getKind()!==w().SyntaxKind.PropertyAccessExpression||r.getName()!=="run")return null;let n=e.getArguments();if(n.length<1||!n[0])return null;let i=n[0],{SyntaxKind:c}=w();if(i.getKind()===c.CallExpression){let l=i;return ts(l)?l.getArguments()[2]??null:null}if(i.getKind()!==c.Identifier)return null;let a=i.getText(),d=t.getDescendantsOfKind(c.VariableDeclaration);for(let l of d){if(l.getName()!==a)continue;let f=l.getInitializer();if(f?.getKind()===c.CallExpression&&ts(f))return f.getArguments()[2]??null}return null},po=e=>{let{SyntaxKind:t}=w(),r=e.getParent();for(;r;){if(r.getKind()===t.CallExpression){let n=r.getExpression().getText();if(n.includes(".gen")||n==="gen")return!0}r=r.getParent()}return!1},go=e=>{let{SyntaxKind:t}=w();return e.getFirstAncestorByKind(t.VariableStatement)?.getParent()?.getKind()===t.SourceFile},mo=e=>{let{SyntaxKind:t}=w(),r=e.getInitializer();return r?r.getKind()===t.YieldExpression||r.getKind()===t.AwaitExpression&&r.getExpression().getKind()===t.YieldExpression:!1},ns=e=>{let{SyntaxKind:t}=w();if(e.getKind()===t.CallExpression)return e;if(e.getKind()===t.AwaitExpression){let r=e.getExpression();if(r.getKind()===t.CallExpression)return r}},V=(e,t)=>({discoveryConfidence:e,discoveryReason:t}),yo=["Effect<","Layer<","Layer.Layer<","Stream<","Stream.Stream<","Channel<","Channel.Channel<","Sink<","Sink.Sink<","STM<","STM.STM<","Schedule<","Schedule.Schedule<"],Ft=e=>e!==void 0&&yo.some(t=>e.includes(t)),rs={low:0,medium:1,high:2},Tn=e=>{let t=e.getExpression().getText();return t.includes(".runPromise")||t.includes(".runPromiseExit")||t.includes(".runSync")||t.includes(".runSyncExit")||t.includes(".runFork")||t.includes(".runCallback")||t.includes(".runMain")||t.includes("Runtime.runPromise")||t.includes("Runtime.runSync")||t.includes("Runtime.runFork")};function ss(e){let t=e.getBody?.();if(!t)return!1;let r=t.getText();return r.includes(".runMain")||r.includes(".runPromise")||r.includes(".runSync")||r.includes(".runFork")||r.includes("Runtime.runPromise")||r.includes("Runtime.runSync")||r.includes("NodeRuntime.runMain")||r.includes("BunRuntime.runMain")||r.includes("DenoRuntime.runMain")}function ho(e,t){let r=e.getExpression();if(r.getKind()!==w().SyntaxKind.Identifier)return!1;let i=r.getSymbol()?.getValueDeclaration();if(!i)return!1;let c=i.getKind(),{SyntaxKind:o}=w();if(c===o.FunctionDeclaration||c===o.ArrowFunction||c===o.FunctionExpression)return ss(i);if(c===o.VariableDeclaration){let a=i.getInitializer();if(a&&(a.getKind()===o.ArrowFunction||a.getKind()===o.FunctionExpression))return ss(a)}return!1}function So(e){let t=e.getExpression();if(e.getArguments().length!==1)return!1;let{SyntaxKind:r}=w();if(t.getKind()!==r.CallExpression)return!1;let s=t;if(s.getArguments().length!==1)return!1;let n=s.getExpression().getText();return n.includes(".runPromise")||n.includes(".runSync")||n.includes(".runFork")||n.includes(".runCallback")||n.includes("Runtime.runPromise")||n.includes("Runtime.runSync")||n.includes("Runtime.runFork")}var kn=(e,t)=>{let r=[],{SyntaxKind:s}=w(),n=new Set,i=new Set,c=Cn(e,t.knownEffectInternalsRoot),o=es(e),a=new Map;for(let S of e.getImportDeclarations()){let b=S.getModuleSpecifierValue(),T=S.getDefaultImport();T&&a.set(T.getText(),b);let v=S.getNamespaceImport();v&&a.set(v.getText(),b);for(let x of S.getNamedImports())a.set(x.getAliasNode()?.getText()??x.getName(),b)}let d=S=>{let b=a.get(S);if(b){if(b.startsWith("effect")||b.startsWith("@effect/"))return V("high",`imported from ${b}`);if(It(e.getFilePath(),b,t.knownEffectInternalsRoot))return V("high","namespace import resolved under knownEffectInternalsRoot");if(b.startsWith(".")&&/(?:^|\/)Effect(?:\.[jt]sx?)?$/.test(b))return V("high",`relative Effect module namespace import (${b})`)}},l=S=>{let b=v=>{let x=v.getDescendantsOfKind(s.PropertyAccessExpression);for(let F of x){let j=F.getExpression().getText();if(c.has(j)&&!o.has(j))return d(j)?.discoveryConfidence==="high"?V("high",`function body uses ${j}.* from trusted Effect alias`):V("medium",`function body uses Effect-like alias ${j}.*`)}let K=v.getDescendantsOfKind(s.CallExpression);for(let F of K){let j=F.getExpression();if(j.getKind()===s.Identifier){let I=j.getText();if(c.has(I)&&!o.has(I))return d(I)?.discoveryConfidence==="high"?V("high",`function body calls trusted Effect import ${I}(...)`):V("medium",`function body calls Effect-like import ${I}(...)`)}}};if(S.getKind()===s.ArrowFunction||S.getKind()===s.FunctionExpression){let x=S.getBody();if(x.getKind()===s.Block){let K=b(x);if(K)return K}else{let K=b(x);if(K)return K}}let T=ns(S);if(T){let v=T.getExpression(),x=v.getText();if(v.getKind()===s.Identifier){let K=x;if(c.has(K)&&!o.has(K))return d(K)??V("high",`named import call (${K})`);if(K==="pipe")return V("medium","exact pipe() call detection")}if(v.getKind()===s.PropertyAccessExpression){let K=v,F=K.getExpression().getText();if(c.has(F)&&!o.has(F))return d(F)??V("medium",`Effect-like namespace prefix (${F}.*)`);if(K.getName()==="pipe")return V("medium","exact .pipe() call detection")}}if(S.getKind()===s.PropertyAccessExpression){let x=S.getExpression().getText();if(c.has(x)&&!o.has(x))return d(x)??V("medium",`Effect-like namespace property access (${x}.*)`)}if(S.getKind()===s.AwaitExpression){let v=S.getExpression();if(v.getKind()===s.CallExpression)return l(v)}return V("low","heuristic direct initializer match")},f=S=>{let T=(x=>x.getTypeNode?.()?.getText())(S);if(Ft(T))return V("high","explicit Effect-family type annotation");let v=S.getKind()===s.VariableDeclaration?S.getFirstAncestorByKind(s.VariableStatement)?.isExported()??!1:S.getKind()===s.PropertyDeclaration||S.getKind()===s.MethodDeclaration||S.getKind()===s.GetAccessor?S.getFirstAncestorByKind(s.ClassDeclaration)?.isExported()??!1:!1;if(S.getKind()===s.VariableDeclaration||S.getKind()===s.PropertyDeclaration){let x=S.getInitializer();if(x&&(x.getKind()===s.ArrowFunction||x.getKind()===s.FunctionExpression)){let F=x.getReturnTypeNode()?.getText();if(Ft(F))return V("high","function return type annotated as Effect-family");if(v&&T)return V("medium","explicit exported function API type signature")}if(x?.getKind()===s.CallExpression){let F=x.getTypeArguments().map(j=>j.getText()).join(" ");if(Ft(F))return V("high","call type arguments reference Effect-family types");if(v&&T)return V("medium","explicit exported call-based API type signature")}}if(S.getKind()===s.MethodDeclaration||S.getKind()===s.GetAccessor){let x=S.getReturnTypeNode?.()?.getText();if(Ft(x))return V("high","method/getter return type annotated as Effect-family");if(v&&T)return V("medium","explicit exported method/getter API type signature")}},u=S=>{let b=S.node,T=b.getKind();return T===s.CallExpression?!0:T===s.VariableDeclaration?b.getFirstAncestorByKind(s.VariableStatement)?.isExported()??!1:T===s.FunctionDeclaration||T===s.ClassDeclaration?b.isExported():T===s.PropertyDeclaration||T===s.MethodDeclaration||T===s.GetAccessor?b.getFirstAncestorByKind(s.ClassDeclaration)?.isExported()??!1:!0},g=S=>{for(let b of S){let T=b.getExpression();if(T&&oe(T,c,o))return l(T)}return V("low","heuristic method return match")},p=e.getFilePath(),m=e.getDescendantsOfKind(s.VariableDeclaration);for(let S of m){let b=S.getInitializer();if(b?.getKind()===s.CallExpression&&ao(b.getExpression().getText())&&i.add(S.getName()),t.enableEffectWorkflow&&b?.getKind()===s.CallExpression){let T=b;(uo(T,a,p)||fo(T,a,p))&&i.add(S.getName())}}let h=e.getDescendantsOfKind(s.CallExpression);for(let S of h){let b=S.getExpression(),T=b.getText(),v=S.getStart(),x=!1;if(b.getKind()===s.Identifier)x=i.has(T);else if(b.getKind()===s.PropertyAccessExpression){let F=b,j=F.getExpression().getText(),I=F.getName();if(x=i.has(j)&&I==="run",t.enableEffectWorkflow&&!x&&I==="run"&&S.getArguments().length===1&&!T.includes("runPromise")&&!T.includes("runSync")&&!T.includes("runFork")&&!T.includes("runCallback")&&!n.has(v)){let q=He(S)??`workflow-${r.length+1}`;r.push({name:q,node:S,type:"run",...V("low","workflow-like .run(...) shape heuristic")}),n.add(v);continue}}if(x&&!n.has(v)){let F=He(S)??`workflow-${r.length+1}`;r.push({name:F,node:S,type:"run",...V("medium","workflow builder invocation")}),n.add(v);continue}if(t.enableEffectWorkflow&&b.getKind()===s.PropertyAccessExpression){let F=b,j=F.getExpression().getText(),I=F.getName();if((I==="execute"||I==="executeEncoded")&&i.has(j)&&!n.has(v)){let z=He(S)??`${j}.${I}`;r.push({name:z,node:S,type:"workflow-execute",...V("medium","workflow/activity .execute entrypoint")}),n.add(v);continue}}if((T==="gen"||T.endsWith(".gen")&&et(S,e,c,t.knownEffectInternalsRoot))&&!n.has(v)){let F=He(S)??Dr(S)??`program-${r.length+1}`;r.push({name:F,node:S,type:"generator",...T==="gen"?V("medium","unqualified gen(...) call"):V("high","Effect-like .gen(...) call")}),n.add(v)}let K=He(S);if(T.includes("pipe")&&xo(S,c)&&!n.has(v)&&b.getKind()!==s.PropertyAccessExpression&&K!==void 0&&!po(S)&&(r.push({name:K,node:S,type:"pipe",...V("medium","exact pipe(...) call with Effect-like args")}),n.add(v)),(Tn(S)||So(S))&&!n.has(v)){let F=He(S)??`run-${r.length+1}`;r.push({name:F,node:S,type:"run",...V("high","recognized Runtime/Effect run* entrypoint")}),n.add(v)}}for(let S of m){if(!go(S)||mo(S))continue;let b=S.getInitializer();if(b){let T=S.getName(),v=ns(b);if(v&&Tn(v)||b.getKind()===s.ObjectLiteralExpression)continue;oe(b,c,o)&&!r.some(K=>K.name===T)&&r.push({name:T,node:S,type:"direct",...f(S)??l(b)})}}let y=e.getStatements();for(let S of y){if(S.getKind()!==s.ExpressionStatement)continue;let b=S.getExpression();if(b.getKind()!==s.CallExpression)continue;let T=b,v=T.getStart();if(n.has(v))continue;let x=T.getExpression(),K=x.getText();if(Tn(T)){let F=`run-${r.length+1}`;r.push({name:F,node:T,type:"run",...V("high","recognized top-level run* entrypoint")}),n.add(v);continue}if(K.endsWith(".pipe")||K==="pipe"){let F=T.getArguments(),j=F[F.length-1];if(!j)continue;let I=j.getText();if(I.includes(".runMain")||I.includes(".runPromise")||I.includes(".runSync")||I.includes(".runFork")){let z;x.getKind()===s.PropertyAccessExpression&&(z=x.getExpression().getText().split(".").pop());let Y=z&&!r.some(Z=>Z.name===z)?z:`entrypoint-${r.length+1}`;r.push({name:Y,node:T,type:"run",...V("medium","top-level pipe(...).run* terminator pattern")}),n.add(v)}}if(x.getKind()===s.Identifier&&T.getArguments().length>=1){let F=x.getText();ho(T,e)&&!r.some(I=>I.name===F)&&(r.push({name:F,node:T,type:"run",...V("low","indirect run wrapper body heuristic")}),n.add(v))}}let N=["Data.TaggedError","Data.TaggedClass","Data.Class","Data.Error","Schema.Class","Schema.TaggedClass","Schema.TaggedError","Schema.TaggedRequest","Context.Tag","Context.Reference","Effect.Service"],E=e.getDescendantsOfKind(s.ClassDeclaration);for(let S of E){let b=S.getName();if(!b||r.some(x=>x.name===b))continue;S.getHeritageClauses().some(x=>{let K=x.getText();return N.some(F=>K.includes(F))})&&r.push({name:b,node:S,type:"class",...V("medium","known Data/Schema/Context class pattern")})}let $=E.filter(S=>{let b=S.getParent();return b===e||b?.getParent()===e});for(let S of $){let b=S.getName()??"Anonymous",T=S.getMembers(),v=T.filter(F=>F.getKind()===s.PropertyDeclaration);for(let F of v){let j=F.getInitializer();if(!j)continue;let I=F.getName(),q=`${b}.${I}`;r.some(z=>z.name===q)||oe(j,c,o)&&r.push({name:q,node:F,type:"classProperty",...f(F)??l(j)})}let x=T.filter(F=>F.getKind()===s.MethodDeclaration);for(let F of x){let j=F.getName(),I=`${b}.${j}`;if(r.some(Z=>Z.name===I))continue;let q=F.getBody();if(!q)continue;let z=q.getDescendantsOfKind(s.ReturnStatement);z.some(Z=>{let L=Z.getExpression();return L?oe(L,c,o):!1})&&r.push({name:I,node:F,type:"classMethod",...f(F)??g(z)})}let K=T.filter(F=>F.getKind()===s.GetAccessor);for(let F of K){let j=F.getName(),I=`${b}.${j}`;if(r.some(Z=>Z.name===I))continue;let q=F.getBody();if(!q)continue;let z=q.getDescendantsOfKind(s.ReturnStatement);z.some(Z=>{let L=Z.getExpression();return L?oe(L,c,o):!1})&&r.push({name:I,node:F,type:"classMethod",...f(F)??g(z)})}}return r.filter(S=>{let b=t.minDiscoveryConfidence??"low",T=S.discoveryConfidence??"low";return!(rs[T]<rs[b]||t.onlyExportedPrograms&&!u(S))})},xo=(e,t)=>e.getArguments().map(n=>n.getText()).some(n=>[...t].some(i=>n.includes(`${i}.`)));function cs(e){let{SyntaxKind:t}=w(),r=[],s=e.getProject().getTypeChecker(),n=e.getDescendantsOfKind(t.ClassDeclaration);for(let i of n){let c=i.getName();if(!c)continue;let o=i.getExtends();if(!o)continue;let a=o.getText();if(!a.includes("Context.Tag")&&!a.includes("Effect.Service"))continue;let d=o.getTypeArguments();if(d.length<2){let f=o.getExpression();f&&"getTypeArguments"in f&&typeof f.getTypeArguments=="function"&&(d=f.getTypeArguments())}if(d.length<2)continue;let l=d[1];if(l)try{let f=s.getTypeAtLocation(l),u=[],g=[];for(let y of f.getProperties()){let N=y.getName();if(N.startsWith("_")||N==="constructor")continue;s.getTypeOfSymbolAtLocation(y,l).getCallSignatures().length>0?u.push(N):g.push(N)}let p=i.getText(),m=p.includes("Equal.symbol")||p.includes("[Equal")||p.includes("equal("),h=p.includes("Hash.symbol")||p.includes("[Hash")||p.includes("hash(");r.push({tagId:c,methods:u,properties:g,...m?{hasCustomEquality:m}:{},...h?{hasCustomHash:h}:{}})}catch{}}for(let i of n){let c=i.getName();if(!c)continue;let o=i.getExtends();if(!o)continue;let a=o.getText();if(!a.includes("Data.Class")&&!a.includes("Data.TaggedClass")||r.some(u=>u.tagId===c))continue;let d=i.getText(),l=d.includes("Equal.symbol")||d.includes("[Equal")||d.includes("equal("),f=d.includes("Hash.symbol")||d.includes("[Hash")||d.includes("hash(");(l||f)&&r.push({tagId:c,methods:[],properties:[],hasCustomEquality:l,hasCustomHash:f})}return r}import{Effect as xe,Option as yt}from"effect";import{Effect as ee,Option as Eo}from"effect";var Rt=(e,t,r,s,n,i)=>ee.gen(function*(){let{SyntaxKind:c}=w(),o=e.getArguments(),a=e.getExpression(),d=a.getKind()===c.PropertyAccessExpression&&a.getName()==="pipe",l=d?a.getExpression():o[0],f=d?o:o.slice(1);if(!l)return[];let u=ds(l),g=u.getSourceFile(),p=g.getFilePath(),m=t.getProject();if(m.getSourceFile(p)){let S=m.getSourceFile(p);S&&(g=S)}else{let S=m.addSourceFileAtPath(p);S&&(g=S)}let h=yield*M(u,g,g.getFilePath(),s,n,i),y=[];for(let S of f)if(S){let b=yield*M(S,t,r,s,n,i);y.push(b)}let N;try{let S=t.getProject().getTypeChecker(),b=[],T=Ze(l,S);T&&b.push(T);for(let v of f)if(v){let x=Ze(v,S);x&&b.push(x)}b.length>0&&(N=b)}catch{}let E={id:C(),type:"pipe",initial:h,transformations:y,...N?{typeFlow:N}:{}};return[{...E,displayName:G(E),semanticRole:Q(E)}]}),M=(e,t,r,s,n,i,c)=>ee.gen(function*(){let{SyntaxKind:o}=w();if(e.getKind()===o.ArrowFunction||e.getKind()===o.FunctionExpression){let l=e.getBody();if(!l){let u={id:C(),type:"unknown",reason:"Function has no body",sourceCode:e.getText().slice(0,100),location:_(e,r,s.includeLocations??!1)};return i.unknownCount++,u}if(l.getKind()===o.Block){let p=l.getStatements().find(m=>m.getKind()===o.ReturnStatement)?.getExpression();if(p)return yield*M(p,t,r,s,n,i,c)}else return yield*M(l,t,r,s,n,i,c);let f={id:C(),type:"unknown",reason:"Function does not return an Effect expression",sourceCode:e.getText().slice(0,100),location:_(e,r,s.includeLocations??!1)};return i.unknownCount++,f}if(e.getKind()===o.CallExpression)return yield*vn(e,t,r,s,n,i,c);if(e.getKind()===o.PropertyAccessExpression){let d=e.getText();if(d==="Fiber.roots"||d==="Fiber.getCurrentFiber"){let l=d==="Fiber.roots"?"roots":"getCurrentFiber";return{id:C(),type:"fiber",operation:l,isScoped:!1,isDaemon:!1,location:_(e,r,s.includeLocations??!1)}}if($t(d,Le(t),t)){let l={id:C(),type:"effect",callee:d,location:_(e,r,s.includeLocations??!1)};return i.totalEffects++,l}}if(e.getKind()===o.Identifier){let d={id:C(),type:"effect",callee:e.getText(),location:_(e,r,s.includeLocations??!1)};return i.totalEffects++,d}if(e.getKind()===o.ObjectLiteralExpression){let d=e,l=new Set(["onNone","onSome","onFailure","onSuccess","onLeft","onRight"]),f=d.getProperties(),u=[],g=!1;for(let p of f){if(p.getKind()!==o.PropertyAssignment)continue;let m=p,h=m.getName();if(!l.has(h))continue;g=!0;let y=m.getInitializer();if(y){let N=yield*M(y,t,r,s,n,i,c);u.push(N)}}if(g&&u.length>0)return u.length===1?u[0]:{id:C(),type:"parallel",callee:"match-handlers",mode:"sequential",children:u,location:_(e,r,s.includeLocations??!1)}}let a={id:C(),type:"unknown",reason:"Could not determine effect type",sourceCode:e.getText().slice(0,100),location:_(e,r,s.includeLocations??!1)};return i.unknownCount++,a}),vn=(e,t,r,s,n,i,c)=>ee.gen(function*(){let{SyntaxKind:o}=w(),a=e.getExpression().getText(),d=wn(a,t),l=/([A-Za-z_$][\w$]*)$/.exec(d)?.[1]??d,f=_(e,r,s.includeLocations??!1);if(a==="pipe"&&e.getArguments().length>=1){let L=yield*Rt(e,t,r,s,n,i);if(L.length>0&&L[0])return L[0]}if(d==="Context.pick"||d==="Context.omit"){let L={id:C(),type:"effect",callee:d,description:"context",location:f};return i.totalEffects++,{...L,displayName:G(L),semanticRole:Q(L)}}if(d.startsWith("Layer."))return yield*wo(e,d,t,r,s,n,i);if(d.startsWith("Stream."))return yield*To(e,d,t,r,s,n,i);if(d.startsWith("Channel."))return yield*vo(e,d,t,r,s,n,i);if(a.startsWith("Sink."))return yield*$o(e,a,t,r,s,n,i);if(a.startsWith("Queue.")||a.startsWith("PubSub.")||a.startsWith("Deferred.")||a.startsWith("Semaphore.")||a.startsWith("Mailbox.")||a.startsWith("SubscriptionRef.")||a.startsWith("RateLimiter.")||a.startsWith("PartitionedSemaphore.")||a.startsWith("FiberHandle.")||a.startsWith("FiberSet.")||a.startsWith("FiberMap.")||a.startsWith("Cache.")||a.startsWith("ScopedCache.")||a.startsWith("RcRef.")||a.includes(".RcRef.")||a.startsWith("RcMap.")||a.includes(".RcMap.")||a.startsWith("Reloadable.")||a.includes(".Reloadable.")||a.includes("makeLatch")||a.includes("Latch."))return yield*Fo(e,a,t,r,s,n,i);if(un.some(L=>a.includes(L)||a.startsWith(L)))return yield*Ao(e,a,t,r,s,n,i);if(hn.some(L=>a.includes(L)))return yield*Ro(e,a,t,r,s,n,i);if(a.includes(".all")||a==="all")return yield*Po(e,a,t,r,s,n,i);if(a.includes(".race")||a==="race")return yield*Mo(e,a,t,r,s,n,i);if(cn.some(L=>a.includes(L)))return yield*Oo(e,a,t,r,s,n,i);if(a.includes(".retry"))return yield*Lo(e,t,r,s,n,i);if(a.includes(".timeout"))return yield*Wo(e,t,r,s,n,i);let g=new Set(["acquireRelease","acquireUseRelease","ensuring","addFinalizer","onExit","onError","parallelFinalizers","sequentialFinalizers","finalizersMask","using","withEarlyRelease"]),p=["acquireRelease","acquireUseRelease"],m=L=>g.has(L)||p.some(H=>L.startsWith(H));if(l==="pipe"&&e.getExpression().getKind()===o.PropertyAccessExpression){let H=e.getExpression().getExpression();if(H.getKind()===o.CallExpression){let ge=H,de=ge.getExpression().getText(),ne=/([A-Za-z_$][\w$]*)$/.exec(de)?.[1]??de;if(m(ne))return yield*ls(ge,ne,t,r,s,n,i)}}if(m(l))return yield*ls(e,l,t,r,s,n,i);if(ln.some(L=>a.includes(L)))return yield*Ko(e,a,t,r,s,n,i);if(dn.some(L=>a.includes(L)))return yield*jo(e,a,t,r,s,n,i);if(Lr(a))return yield*Ho(e,a,t,r,s,n,i);if(Kr(a))return Bo(e,a,r,s);if(Br(a))return yield*qo(e,a,t,r,s,n,i);if(zr(a))return zo(e,a,r,s);if(_r(a))return yield*_o(e,a,r,s);i.totalEffects++;let h,N=["Effect.sync","Effect.promise","Effect.async","Effect.asyncEffect","Effect.tryPromise","Effect.suspend"].some(L=>a.includes(L))&&e.getArguments().length>0&&e.getArguments()[0],E;if(N){let L=e.getArguments()[0],{SyntaxKind:H}=w();if(L.getKind()===H.ArrowFunction||L.getKind()===H.FunctionExpression){let de=L,ne=de.getBody(),we=[];if(ne){if(ne.getKind()===H.Block){let ve=ne;for(let te of ve.getStatements())if(te.getKind()===H.ReturnStatement){let A=te.getExpression();if(A&&$t(A.getText(),Le(t),t)){let W=yield*M(A,t,r,s,n,i,void 0);we.push(W)}}else if(te.getKind()===H.ExpressionStatement){let A=te.getExpression();if(A.getKind()===H.CallExpression&&et(A,t,Le(t),s.knownEffectInternalsRoot)){let W=yield*M(A,t,r,s,n,i,void 0);we.push(W)}}}else if($t(ne.getText(),Le(t),t)){let ve=yield*M(ne,t,r,s,n,i,void 0);we.push(ve)}}if(we.length>0&&(h=we),a.includes("Effect.async")||a.includes("Effect.asyncEffect")){let ve=de.getParameters()[0]?.getName?.()??"resume",te=0,A=Ie=>{if(Ie.getKind()===H.CallExpression){let ut=Ie.getExpression();ut.getKind()===H.Identifier&&ut.getText()===ve&&te++}Ie.getChildren().forEach(A)};ne&&A(ne);let W=!1;if(ne?.getKind()===H.Block){let Ie=ne;for(let nn of Ie.getStatements())if(nn.getKind()===H.ReturnStatement){let ut=nn.getExpression();if(ut){let xr=ut.getKind();if(xr===H.ArrowFunction||xr===H.FunctionExpression){W=!0;break}}}}else ne&&(ne.getKind()===H.ArrowFunction||ne.getKind()===H.FunctionExpression)&&(W=!0);E={resumeParamName:ve,resumeCallCount:te,returnsCanceller:W}}}}let $=_e(e),S=t.getProject().getTypeChecker(),b=Ze(e,S),T=wt(e,S),v=bo(e,t),x,K=e.getExpression();if(K.getKind()===w().SyntaxKind.PropertyAccessExpression){let L=K,H=L.getExpression().getText(),ge=L.getName();if(c){let de=c.get(H);de&&(x={serviceId:de,methodName:ge})}!x&&T?.length===1&&T[0]&&(x={serviceId:T[0].serviceId,methodName:ge})}let F;if(a==="Effect.provide"||a.startsWith("Effect.")&&a.includes(".provide")&&!a.includes("provideService")){let L=e.getArguments(),H=(L.length>=2?L[1]:L[0])?.getText()??"";/Runtime\.|defaultRuntime|\.runSync|\.runPromise|\.runFork|\.runCallback/.test(H)||/^\s*runtime\s*$|^\s*rt\s*$/i.test(H.trim())?F="runtime":H.includes("Layer.")?F="layer":F="context"}let j;a.endsWith(".sync")||a.endsWith(".succeed")||a.endsWith(".fail")||a.endsWith(".try")||a.endsWith(".suspend")?j="sync":a.endsWith(".promise")?j="promise":a.endsWith(".async")||a.endsWith(".asyncEffect")?j="async":a.endsWith(".never")?j="never":a.endsWith(".void")?j="void":a.endsWith(".fromNullable")?j="fromNullable":a.endsWith(".fn")?j="fn":a.endsWith(".fnUntraced")&&(j="fnUntraced");let I,q=["currentConcurrency","currentLogLevel","currentScheduler","currentTracerEnabled","currentLogSpan","currentLogAnnotations","currentContext","currentRequestBatching","currentMaxOpsBeforeYield","currentSupervisor","currentMetricLabels","interruptedCause","unhandledLogLevel"];for(let L of q)if(a.includes(L)){I=L;break}let z;if(j==="fn"||j==="fnUntraced"){let L=e.getArguments();if(L.length>0){let H=L[0].getText(),ge=/^["'`](.+?)["'`]$/.exec(H);ge&&(z=ge[1])}}let Y={id:C(),type:"effect",callee:a,description:v?"service-call":Gr(a,Le(t)),location:f,jsdocDescription:$,jsdocTags:Ye(e),typeSignature:b,requiredServices:T,serviceCall:v,serviceMethod:x,callbackBody:h,...E?{asyncCallback:E}:{},...F?{provideKind:F}:{},...j?{constructorKind:j}:{},...I?{fiberRefName:I}:{},...z?{tracedName:z}:{}};return{...Y,displayName:G(Y),semanticRole:Q(Y)}}),bo=(e,t)=>{let{SyntaxKind:r}=w(),s=e.getExpression();if(s.getKind()!==r.PropertyAccessExpression)return;let n=s,i=n.getExpression(),c=n.getName(),o=i.getText(),a=o.split(".")[0]??o;if(!xn.has(a))try{let d=i.getType(),l=d.getSymbol()??d.getAliasSymbol();if(!l)return;let f=l.getName();return!f||f==="__type"||f==="unknown"||f==="any"||Hr.has(f)?void 0:{serviceType:f,methodName:c,objectName:o}}catch{return}};function At(e){let t=e.getExpression().getText(),r=e.getSourceFile(),s=wn(t,r);return s.startsWith("Layer.")||s.startsWith("Effect.")||t==="pipe"||t.endsWith(".pipe")}function No(e,t,r){let{SyntaxKind:s}=w(),n=e.getSourceFile(),i=n.getProject(),c=n.getFilePath(),a=t.getImportDeclaration().getModuleSpecifierValue();if(!a?.startsWith("."))return;let d=Xe(i,c,a);if(!d){let m=mt(c,a);if(m){let h=i.addSourceFileAtPath(m);h&&(d=h)}}if(!d)return;d=i.getSourceFile(d.getFilePath())??d;let l=m=>{if(m.getKind()===s.VariableDeclaration){let y=m.getInitializer();if(y?.getKind()===s.CallExpression&&r(y))return y}if(m.getKind()===s.VariableStatement){let h=m.getDeclarationList();for(let y of h.getDeclarations()){let N=y.getInitializer();if(N?.getKind()===s.CallExpression&&r(N))return N}}},f=t.getName(),u=d.getExportedDeclarations(),g=u.get(f)??[];for(let m of g){let h=l(m);if(h)return h}let p=t.getTargetName?.();if(p&&p!==f)for(let m of u.get(p)??[]){let h=l(m);if(h)return h}for(let[,m]of u)for(let h of m){let y=l(h);if(y)return y}}function Co(e,t,r){let{SyntaxKind:s}=w(),n=e.getSourceFile(),i=n.getProject(),c=n.getFilePath(),o=t.getModuleSpecifierValue();if(!o?.startsWith("."))return;let a=Xe(i,c,o);if(!a){let l=mt(c,o);if(l){let f=i.addSourceFileAtPath(l);f&&(a=f)}}if(!a)return;a=i.getSourceFile(a.getFilePath())??a;let d=l=>{if(l.getKind()===s.VariableDeclaration){let u=l.getInitializer();if(u?.getKind()===s.CallExpression&&r(u))return u}if(l.getKind()===s.VariableStatement){let f=l.getDeclarationList();for(let u of f.getDeclarations()){let g=u.getInitializer();if(g?.getKind()===s.CallExpression&&r(g))return g}}};for(let l of a.getDefaultExportSymbol()?.getDeclarations()??[]){let f=d(l);if(f)return f}for(let l of a.getExportedDeclarations().get("default")??[]){let f=d(l);if(f)return f}}function ds(e){let{SyntaxKind:t}=w();if(e.getKind()!==t.Identifier)return e;let r=e,s=r.getText(),n=r.getSymbol(),i=n?.getValueDeclaration(),c=i?.getKind()===t.ImportSpecifier?i:void 0;if(!c&&n){let o=n.getDeclarations().find(a=>a.getKind()===t.ImportSpecifier);o&&(c=o)}if(!c){let o=r.getSourceFile();for(let a of o.getImportDeclarations()){if(a.getDefaultImport()?.getText()===s){let f=Co(r,a,At);if(f)return f}let l=a.getNamedImports().find(f=>f.getName()===s||f.getAliasNode()?.getText()===s);if(l){c=l;break}}}if(c){let o=No(r,c,At);if(o)return o;n=n?.getImmediatelyAliasedSymbol()??n?.getAliasedSymbol(),i=n?.getValueDeclaration()}if(i?.getKind()===t.ExportSpecifier&&(n=n?.getImmediatelyAliasedSymbol()??n?.getAliasedSymbol(),i=n?.getValueDeclaration()),n&&i?.getKind()!==t.VariableDeclaration){for(let o of n.getDeclarations())if(o.getKind()===t.VariableDeclaration){let d=o.getInitializer();if(d?.getKind()===t.CallExpression&&At(d))return d}}if(i?.getKind()===t.VariableDeclaration){let a=i.getInitializer();if(a?.getKind()===t.CallExpression&&At(a))return a}return e}var wo=(e,t,r,s,n,i,c)=>ee.gen(function*(){let o=e.getArguments(),a=[],{SyntaxKind:d}=w();if(o.length>0&&o[0]){let b=o[0];if(t.includes("mergeAll")&&b.getKind()===d.ArrayLiteralExpression){let v=b.getElements();for(let x of v){let K=yield*M(x,r,s,n,i,c);a.push(K)}}else for(let v of o){if(!v)continue;let x=ds(v),K=x.getSourceFile(),F=yield*M(x,K,K.getFilePath(),n,i,c);a.push(F)}}let l=t.includes("merge")||t.includes("mergeAll"),f;t.includes("fresh")?f="fresh":t.includes("memoize")?f="memoized":t.includes("scoped")?f="scoped":f="default";let u=[],g=b=>{if(b.getKind()===d.Identifier)return b.getText();if(b.getKind()===d.PropertyAccessExpression){let T=b,v=T.getExpression();return v.getKind()===d.Identifier?v.getText():T.getText().split(".")[0]}};if((t.includes("succeed")||t.includes("sync")||t.includes("effect")||t.includes("scoped")||t.includes("scopedDiscard")||t.includes("effectDiscard"))&&o.length>0&&o[0]){let b=g(o[0]);b&&u.push(b)}let p=t.includes("provide")&&!t.includes("provideService"),m=new Set;if(p&&o.length>=1&&o[0]){let b=g(o[0]);b&&m.add(b)}if(p&&o.length>=2&&o[1]){let b=g(o[1]);b&&m.add(b);let T=g(o[0]);T&&u.push(T)}if(t.includes("provideService")&&o.length>0&&o[0]){let b=g(o[0]);b&&u.push(b)}let h=b=>{if(b.type==="effect"){let v=b;for(let K of v.requiredServices??[])m.add(K.serviceId);let x=v.callee??"";(/^[A-Z][A-Za-z0-9_]*(Service|Tag)$/.test(x)||x.endsWith(".Tag"))&&m.add(x)}else if(b.type==="layer"){let v=b;for(let x of v.requires??[])m.add(x)}Eo.getOrElse(P(b),()=>[]).forEach(h)};if(a.forEach(h),m.size===0)try{let b=Tr(e);b?.requiredType&&b.requiredType!=="never"&&Jr(b.requiredType).forEach(v=>m.add(v))}catch{}let y=t.replace(/^Layer\./,"").replace(/^[a-zA-Z]+\./,""),E=new Set(["catchAll","catchAllCause","orDie","orElse","retry","tap","mapError","mapErrorCause","build","launch","toRuntime","passthrough","project","flatMap","flatten","annotateLogs","annotateSpans","setConfigProvider","setClock","setTracer","locally","withSpan","withLogger","withTracer","withClock","mock","suspend","unwrapEffect","unwrapScoped"]).has(y)?`Layer.${y}`:void 0,$=t.includes("MemoMap")||a.some(b=>b.type==="layer"&&b.isMemoMap===!0),S={id:C(),type:"layer",name:E,operations:a,isMerged:l,provides:u.length>0?u:void 0,requires:m.size>0?Array.from(m).sort():void 0,lifecycle:f,...$?{isMemoMap:!0}:{},location:_(e,s,n.includeLocations??!1)};return{...S,displayName:G(S),semanticRole:Q(S)}});function To(e,t,r,s,n,i,c){return ee.gen(function*(){let o=e.getArguments(),a;o.length>0&&o[0]?a=yield*M(o[0],r,s,n,i,c):a={id:C(),type:"unknown",reason:"Stream source not determined"};let d=t.replace(/^Stream\./,"")||"unknown",l;t.startsWith("Stream.")&&(d==="fromIterable"||d==="fromChunk"||d==="fromChunkQueue"?l="fromIterable":d==="fromArray"?l="fromArray":d==="fromQueue"||d==="fromChunkQueue"?l="fromQueue":d==="fromPubSub"||d==="fromChunkPubSub"?l="fromPubSub":d==="fromEffect"||d==="unwrap"||d==="unwrapScoped"?l="fromEffect":d==="fromAsyncIterable"?l="fromAsyncIterable":d==="fromReadableStream"||d==="fromReadableStreamByob"?l="fromReadableStream":d==="fromEventListener"?l="fromEventListener":d==="fromSchedule"?l="fromSchedule":d==="range"?l="range":d==="tick"?l="tick":d==="iterate"||d==="iterateEffect"?l="iterate":d==="unfold"||d==="unfoldEffect"||d==="unfoldChunk"||d==="unfoldChunkEffect"?l="unfold":d==="make"?l="make":d==="empty"?l="empty":d==="never"?l="never":d==="succeed"||d==="sync"?l="succeed":(d==="fail"||d==="failSync"||d==="failCause"||d==="failCauseSync")&&(l="fail"));let f=x=>l!==void 0?"constructor":x.startsWith("run")?"sink":x==="toQueue"||x==="toPubSub"||x==="toReadableStream"||x==="toAsyncIterable"||x==="toChannel"?"conversion":x.includes("pipeThroughChannel")||x.includes("Channel")||x.includes("channel")||x.includes("duplex")?"channel":x.includes("grouped")||x.includes("sliding")||x.includes("groupBy")||x.includes("aggregate")||x.includes("window")?"windowing":x.includes("broadcast")||x==="share"?"broadcasting":x.includes("haltAfter")||x.includes("haltWhen")||x.includes("interruptAfter")?"halting":x.includes("decodeText")||x.includes("encodeText")||x.includes("splitLines")?"text":x.includes("merge")||x==="concat"||x.includes("interleave")||x.includes("zip")?"merge":x.includes("buffer")||x.includes("debounce")||x.includes("throttle")?"backpressure":x.includes("catchAll")||x.includes("catchTag")||x.includes("orElse")||x.includes("orDie")||x.includes("retry")?"error":x.includes("filter")||x.includes("take")||x.includes("drop")||x.includes("head")||x==="first"||x==="last"?"filter":x.includes("acquireRelease")||x.includes("scoped")||x.includes("ensuring")||x.includes("onDone")||x.includes("onError")?"resource":x.includes("provide")||x.includes("withSpan")||x.includes("annotate")?"context":x.includes("map")||x.includes("tap")||x.includes("flatMap")||x.includes("mapChunk")||x.includes("scan")||x.includes("transduce")?"transform":"other",u=d.includes("Effect")||d.startsWith("run")||d.includes("tap"),g=f(d),p=g==="filter"?"fewer":g==="merge"||g==="broadcasting"?"more":g==="halting"||g==="sink"||g==="windowing"?"fewer":"unknown",m,h;(d==="grouped"||d==="groupedWithin"||d.includes("sliding")||d.includes("Sliding"))&&o.length>0&&o[0]&&(m=pt(o[0]),(d.includes("sliding")||d.includes("Sliding"))&&o.length>1&&o[1]&&(h=pt(o[1])));let N={operation:d,isEffectful:u,estimatedCardinality:p,category:g,...m!==void 0?{windowSize:m}:{},...h!==void 0?{stride:h}:{}},E;d.startsWith("run")&&(E=d);let $;d.includes("buffer")?$="buffer":d.includes("drop")||d.includes("Drop")?$="drop":(d.includes("sliding")||d.includes("Sliding"))&&($="sliding");let S=a,b=[N],T=l;if(a.type==="stream"){let x=a;b=[...x.pipeline,N],S=x.source,!T&&x.constructorType&&(T=x.constructorType),!E&&x.sink&&(E=x.sink),!$&&x.backpressureStrategy&&($=x.backpressureStrategy)}let v={id:C(),type:"stream",source:S,pipeline:b,sink:E,backpressureStrategy:$,constructorType:T,location:_(e,s,n.includeLocations??!1)};return{...v,displayName:G(v),semanticRole:Q(v)}})}function ko(e){return e==="fromReadableStream"||e==="fromWritableStream"||e==="fromDuplexStream"||e==="make"||e==="succeed"||e==="fail"||e==="empty"||e==="never"?"constructor":e.includes("map")||e.includes("flatMap")||e.includes("filter")||e.includes("concat")||e.includes("zip")?"transform":e.includes("pipe")||e==="pipeTo"||e==="pipeThrough"?"pipe":"other"}function vo(e,t,r,s,n,i,c){return ee.gen(function*(){let o=e.getArguments(),a;o.length>0&&o[0]&&(a=yield*M(o[0],r,s,n,i,c));let d=t.replace(/^Channel\./,"")||"unknown",l=[{operation:d,category:ko(d)}];if(a?.type==="channel"){let u=a;l.unshift(...u.pipeline),a=u.source}let f={id:C(),type:"channel",source:a,pipeline:l,location:_(e,s,n.includeLocations??!1)};return{...f,displayName:G(f),semanticRole:Q(f)}})}function Io(e){return e==="forEach"||e==="forEachWhile"||e==="run"||e==="runDrain"||e==="runFor"||e==="make"||e==="fromEffect"||e==="fromQueue"?"constructor":e.includes("map")||e.includes("contramap")||e.includes("filter")||e.includes("zip")?"transform":"other"}function $o(e,t,r,s,n,i,c){return ee.gen(function*(){let o=e.getArguments(),a;o.length>0&&o[0]&&(a=yield*M(o[0],r,s,n,i,c));let d=t.replace(/^Sink\./,"")||"unknown",l=[{operation:d,category:Io(d)}];if(a?.type==="sink"){let u=a;l.unshift(...u.pipeline),a=u.source}let f={id:C(),type:"sink",source:a,pipeline:l,location:_(e,s,n.includeLocations??!1)};return{...f,displayName:G(f),semanticRole:Q(f)}})}function Fo(e,t,r,s,n,i,c){let{SyntaxKind:o}=w(),a="queue",d="create",l,f,u;t.startsWith("Queue.")?(a="queue",t.includes("bounded")?l="bounded":t.includes("unbounded")?l="unbounded":t.includes("sliding")?l="sliding":t.includes("dropping")&&(l="dropping"),t.includes("offer")||t.includes("offerAll")?d="offer":t.includes("take")||t.includes("takeAll")||t.includes("poll")?d="take":d="create"):t.startsWith("PubSub.")?(a="pubsub",t.includes("bounded")?l="bounded":t.includes("unbounded")&&(l="unbounded"),t.includes("publish")?d="publish":t.includes("subscribe")?d="subscribe":d="create"):t.startsWith("Deferred.")?(a="deferred",t.includes("succeed")?d="succeed":t.includes("fail")?d="fail":t.includes("await")?d="await":d="create"):t.startsWith("Semaphore.")?(a="semaphore",t.includes("withPermit")?d="withPermit":t.includes("take")?d="take":t.includes("release")?d="release":t.includes("available")?d="available":d="create"):t.startsWith("Mailbox.")?(a="mailbox",t.includes("offer")?d="offer":t.includes("takeAll")?d="takeAll":t.includes("take")?d="take":t.includes("end")?d="end":t.includes("toStream")?d="toStream":d="create"):t.startsWith("SubscriptionRef.")?(a="subscriptionRef",t.includes("changes")?d="changes":t.includes("get")?d="get":t.includes("set")?d="set":t.includes("update")?d="update":d="create"):t.includes("makeLatch")||t.includes("Latch.")?(a="latch",t.includes("open")?d="open":t.includes("close")?d="close":t.includes("await")||t.includes("whenOpen")?d="await":d="create"):t.startsWith("FiberHandle.")?(a="fiberHandle",t.includes("run")?d="run":t.includes("await")?d="await":d="create"):t.startsWith("FiberSet.")?(a="fiberSet",t.includes("run")?d="run":t.includes("join")?d="await":d="create"):t.startsWith("FiberMap.")?(a="fiberMap",t.includes("run")?d="run":t.includes("join")?d="await":d="create"):t.startsWith("RateLimiter.")?(a="rateLimiter",t.includes("withCost")?d="withPermit":d="create"):t.startsWith("ScopedCache.")?(a="scopedCache",t.includes("make")||t.includes("Make")?d="create":t.includes("get")&&!t.includes("getOrElse")||t.includes("getOrElse")?d="get":t.includes("set")||t.includes("Set")?d="set":t.includes("invalidate")?d="invalidate":t.includes("contains")?d="contains":d="create"):t.startsWith("Cache.")?(a="cache",t.includes("make")||t.includes("Make")?d="create":t.includes("get")&&!t.includes("getOrElse")||t.includes("getOrElse")?d="get":t.includes("set")||t.includes("Set")?d="set":t.includes("invalidate")?d="invalidate":t.includes("contains")?d="contains":d="create"):t.startsWith("Reloadable.")||t.includes(".Reloadable.")?(a="reloadable",t.includes("make")||t.includes("Make")?d="create":t.includes("get")&&!t.includes("reload")?d="get":t.includes("reload")?d="reload":d="create"):t.startsWith("RcMap.")||t.includes(".RcMap.")?(a="rcMap",t.includes("make")||t.includes("Make")?d="create":t.includes("get")?d="get":t.includes("set")||t.includes("Set")?d="set":t.includes("update")?d="update":d="create"):(t.startsWith("RcRef.")||t.includes(".RcRef."))&&(a="rcRef",t.includes("make")||t.includes("Make")?d="create":t.includes("get")?d="get":t.includes("set")||t.includes("Set")?d="set":t.includes("update")?d="update":d="create");let g=e.getArguments();if(g.length>0&&l==="bounded"){let h=g[0];h?.getKind()===o.NumericLiteral&&(f=Number.parseInt(h.getText(),10))}a==="semaphore"&&(d==="take"||d==="release")&&g.length>0&&g[0]&&(u=pt(g[0]));let p;if(a==="fiberHandle"&&d==="run")for(let h of g){let y=h.getText();y.includes("onlyIfMissing")&&(p={onlyIfMissing:y.includes("true")})}if(a==="mailbox"&&d==="toStream"||a==="subscriptionRef"&&d==="changes"){let h=a==="mailbox"?"fromMailbox":"fromSubscriptionRef",y={id:C(),type:"concurrency-primitive",primitive:a,operation:d,location:_(e,s,n.includeLocations??!1)},N={id:C(),type:"stream",source:{...y,displayName:G(y),semanticRole:Q(y)},pipeline:[],constructorType:h,location:_(e,s,n.includeLocations??!1)};return ee.succeed({...N,displayName:G(N),semanticRole:Q(N)})}let m={id:C(),type:"concurrency-primitive",primitive:a,operation:d,strategy:l,capacity:f,...u!==void 0?{permitCount:u}:{},...p?{lifecycleOptions:p}:{},location:_(e,s,n.includeLocations??!1)};return ee.succeed({...m,displayName:G(m),semanticRole:Q(m)})}function Ao(e,t,r,s,n,i,c){return ee.gen(function*(){let o=e.getArguments(),a="fork",d=!1,l=!1,f;t.startsWith("Fiber.")?t.includes("awaitAll")?a="awaitAll":t.includes("join")?a="join":t.includes("await")?a="await":t.includes("interruptFork")?a="interruptFork":t.includes("interrupt")?a="interrupt":t.includes("poll")?a="poll":t.includes("status")?a="status":t.includes("all")?a="all":t.includes("children")?a="children":t.includes("dump")?a="dump":t.includes("scoped")?(a="scoped",d=!0):t.includes("inheritAll")?a="inheritAll":t.includes("mapFiber")?a="mapFiber":t.includes("mapEffect")?a="mapEffect":t.includes("map")?a="map":t.includes("roots")?a="roots":t.includes("getCurrentFiber")&&(a="getCurrentFiber"):t.includes("forkWithErrorHandler")?a="forkWithErrorHandler":t.includes("forkAll")?a="forkAll":t.includes("forkIn")?a="forkIn":t.includes("fork")&&(t.includes("forkDaemon")?(a="forkDaemon",l=!0):t.includes("forkScoped")?(a="forkScoped",d=!0):a="fork"),(a==="fork"||a==="forkScoped"||a==="forkDaemon"||a==="forkAll"||a==="forkIn"||a==="forkWithErrorHandler")&&o.length>0&&o[0]&&(f=yield*M(o[0],r,s,n,i,c));let u;if(d)u="safe";else{let p=e.getParent();for(;p;){let m=p.getText?.();if(m&&(m.includes("Effect.scoped")||m.includes("Scope.make"))){u="safe";break}if(p=p.getParent(),p&&p===r)break}}let g={id:C(),type:"fiber",operation:a,fiberSource:f,isScoped:d,isDaemon:l,...u?{scopeContext:u}:{},location:_(e,s,n.includeLocations??!1)};return{...g,displayName:G(g),semanticRole:Q(g)}})}function Ro(e,t,r,s,n,i,c){return ee.gen(function*(){let o=e.getArguments(),{SyntaxKind:a}=w(),d;t.includes("uninterruptibleMask")?d="uninterruptibleMask":t.includes("interruptibleMask")?d="interruptibleMask":t.includes("uninterruptible")?d="uninterruptible":t.includes("interruptible")?d="interruptible":t.includes("onInterrupt")?d="onInterrupt":t.includes("disconnect")?d="disconnect":t.includes("allowInterrupt")?d="allowInterrupt":t.includes("interruptWith")?d="interruptWith":d="interrupt";let l,f,u=e.getExpression();u.getKind()===a.PropertyAccessExpression?(l=yield*M(u.getExpression(),r,s,n,i,c),o.length>0&&o[0]&&(f=yield*M(o[0],r,s,n,i,c))):o.length>0&&o[0]&&(l=yield*M(o[0],r,s,n,i,c),o.length>1&&o[1]&&(f=yield*M(o[1],r,s,n,i,c))),c.interruptionCount++;let g={id:C(),type:"interruption",interruptionType:d,source:l,handler:f,location:_(e,s,n.includeLocations??!1)};return{...g,displayName:G(g),semanticRole:Q(g)}})}function Do(e){let{SyntaxKind:t}=w(),r,s,n;for(let i of e.getProperties()){if(i.getKind()!==t.PropertyAssignment)continue;let c=i.getNameNode().getText(),o=i.getInitializer();if(!o)continue;let a=o.getText();if(c==="concurrency")if(a==='"unbounded"'||a==="'unbounded'")r="unbounded";else if(a==='"sequential"'||a==="'sequential'")r="sequential";else if(a==='"inherit"'||a==="'inherit'")r="sequential";else{let d=Number.parseInt(a,10);!Number.isNaN(d)&&d>=0&&(r=d)}else c==="batching"&&(a==="true"||a==="false")?s=a==="true":c==="discard"&&(a==="true"||a==="false")&&(n=a==="true")}return{concurrency:r,batching:s,discard:n}}var Po=(e,t,r,s,n,i,c)=>ee.gen(function*(){let o=e.getArguments(),a=[],{SyntaxKind:d}=w();if(o.length>0&&o[0]){let h=o[0];if(h.getKind()===d.ArrayLiteralExpression){let y=h.getElements();for(let N of y){let E=yield*M(N,r,s,n,i,c);a.push(E)}}else if(h.getKind()===d.ObjectLiteralExpression){let y=h.getProperties();for(let N of y)if(N.getKind()===d.PropertyAssignment){let E=N.getInitializer();if(E){let $=yield*M(E,r,s,n,i,c);a.push($)}}}}let l,f,u;if(o.length>1&&o[1]?.getKind()===d.ObjectLiteralExpression){let h=Do(o[1]);l=h.concurrency,f=h.batching,u=h.discard}let g=t.includes("Par")?"parallel":"sequential";l===void 0&&(l=g==="parallel"?"unbounded":"sequential"),c.parallelCount++;let p=a.map(h=>G(h)),m={id:C(),type:"parallel",callee:t,mode:g,children:a,concurrency:l,batching:f,discard:u,branchLabels:p,location:_(e,s,n.includeLocations??!1)};return{...m,displayName:G(m),semanticRole:Q(m)}}),Mo=(e,t,r,s,n,i,c)=>ee.gen(function*(){let o=e.getArguments(),a=[];for(let f of o)if(f){let u=yield*M(f,r,s,n,i,c);a.push(u)}c.raceCount++;let d=a.map(f=>G(f)),l={id:C(),type:"race",callee:t,children:a,raceLabels:d,location:_(e,s,n.includeLocations??!1)};return{...l,displayName:G(l),semanticRole:Q(l)}}),Oo=(e,t,r,s,n,i,c)=>ee.gen(function*(){let o=e.getArguments(),a;t.includes("catchAllCause")?a="catchAllCause":t.includes("catchSomeCause")?a="catchSomeCause":t.includes("catchSomeDefect")?a="catchSomeDefect":t.includes("catchAllDefect")?a="catchAllDefect":t.includes("catchTags")?a="catchTags":t.includes("catchIf")?a="catchIf":t.includes("catchSome")?a="catchSome":t.includes("catchTag")?a="catchTag":t.includes("catchAll")?a="catchAll":t.includes("orElseFail")?a="orElseFail":t.includes("orElseSucceed")?a="orElseSucceed":t.includes("orElse")?a="orElse":t.includes("orDieWith")?a="orDieWith":t.includes("orDie")?a="orDie":t.includes("flip")?a="flip":t.includes("mapErrorCause")?a="mapErrorCause":t.includes("mapBoth")?a="mapBoth":t.includes("mapError")?a="mapError":t.includes("unsandbox")?a="unsandbox":t.includes("sandbox")?a="sandbox":t.includes("parallelErrors")?a="parallelErrors":t.includes("filterOrDieMessage")?a="filterOrDieMessage":t.includes("filterOrDie")?a="filterOrDie":t.includes("filterOrElse")?a="filterOrElse":t.includes("filterOrFail")?a="filterOrFail":t.includes("matchCauseEffect")?a="matchCauseEffect":t.includes("matchCause")?a="matchCause":t.includes("matchEffect")?a="matchEffect":t.includes("match")?a="match":t.includes("firstSuccessOf")?a="firstSuccessOf":t.includes("ignoreLogged")?a="ignoreLogged":t.includes("ignore")?a="ignore":t.includes("eventually")?a="eventually":a="catchAll";let d,l,f=e.getExpression();if(f.getKind()===w().SyntaxKind.PropertyAccessExpression){let h=f.getExpression();d=yield*M(h,r,s,n,i,c),o.length>0&&o[0]&&(l=yield*M(o[0],r,s,n,i,c))}else o.length>0&&o[0]?d=yield*M(o[0],r,s,n,i,c):d={id:C(),type:"unknown",reason:"Could not determine source effect"},o.length>1&&o[1]&&(l=yield*M(o[1],r,s,n,i,c));c.errorHandlerCount++;let u,g;if(a==="catchTag"){let m=o[0];m?.getKind()===w().SyntaxKind.StringLiteral&&(u=m.getLiteralValue())}else if(a==="catchTags"){let m=[...o].find(h=>h?.getKind()===w().SyntaxKind.ObjectLiteralExpression);m&&(g=m.getProperties().filter(y=>y.getKind()===w().SyntaxKind.PropertyAssignment||y.getKind()===w().SyntaxKind.MethodDeclaration).map(y=>(y.getKind()===w().SyntaxKind.PropertyAssignment,y.getName())))}let p={id:C(),type:"error-handler",handlerType:a,source:d,handler:l,errorTag:u,errorTags:g,errorEdgeLabel:u?`on ${u}`:g&&g.length>0?`on ${g.join(" | ")}`:"on error",location:_(e,s,n.includeLocations??!1)};return{...p,displayName:G(p),semanticRole:Q(p)}}),Lo=(e,t,r,s,n,i)=>ee.gen(function*(){let c=e.getArguments(),o,a,d,l,f=e.getExpression();if(f.getKind()===w().SyntaxKind.PropertyAccessExpression){let m=f.getExpression();o=yield*M(m,t,r,s,n,i),c.length>0&&c[0]&&(a=c[0].getText(),d=yield*M(c[0],t,r,s,n,i)),l=f.getText().includes("retryOrElse")}else c.length>0&&c[0]?o=yield*M(c[0],t,r,s,n,i):o={id:C(),type:"unknown",reason:"Could not determine source effect"},c.length>1&&c[1]&&(a=c[1].getText(),d=yield*M(c[1],t,r,s,n,i)),l=c.length>2;i.retryCount++;let u=a?us(a):void 0,g={id:C(),type:"retry",source:o,schedule:a,...d!==void 0?{scheduleNode:d}:{},hasFallback:l,scheduleInfo:u,retryEdgeLabel:a?`retry: ${a}`:"retry",location:_(e,r,s.includeLocations??!1)};return{...g,displayName:G(g),semanticRole:Q(g)}});function us(e){let t=e.replace(/\s+/g," "),r="custom";t.includes("Schedule.exponential")||t.includes("exponential(")?r="exponential":t.includes("Schedule.fibonacci")||t.includes("fibonacci(")?r="fibonacci":t.includes("Schedule.spaced")||t.includes("spaced(")?r="spaced":t.includes("Schedule.fixed")||t.includes("fixed(")?r="fixed":t.includes("Schedule.linear")||t.includes("linear(")?r="linear":t.includes("Schedule.cron")||t.includes("cron(")?r="cron":t.includes("Schedule.windowed")||t.includes("windowed(")?r="windowed":t.includes("Schedule.duration")||t.includes("duration(")?r="duration":t.includes("Schedule.elapsed")||t.includes("elapsed(")?r="elapsed":t.includes("Schedule.delays")||t.includes("delays(")?r="delays":t.includes("Schedule.once")||t.includes("once(")?r="once":t.includes("Schedule.stop")||t.includes("stop(")?r="stop":(t.includes("Schedule.count")||t.includes("count("))&&(r="count");let s,n=/recurs\s*\(\s*(\d+)\s*\)/.exec(t);n&&(s=Number.parseInt(n[1],10));let i=/recurUpTo\s*\(\s*(\d+)\s*\)/.exec(t);i?s=Number.parseInt(i[1],10):(t.includes("forever")||t.includes("Schedule.forever"))&&(s="unlimited");let c=t.includes("jittered")||t.includes("Schedule.jittered"),o=[];return t.includes("whileInput")&&o.push("whileInput"),t.includes("whileOutput")&&o.push("whileOutput"),t.includes("untilInput")&&o.push("untilInput"),t.includes("untilOutput")&&o.push("untilOutput"),t.includes("recurUntil")&&o.push("recurUntil"),t.includes("recurWhile")&&o.push("recurWhile"),t.includes("andThen")&&o.push("andThen"),t.includes("intersect")&&o.push("intersect"),t.includes("union")&&o.push("union"),t.includes("compose")&&o.push("compose"),t.includes("zipWith")&&o.push("zipWith"),t.includes("addDelay")&&o.push("addDelay"),t.includes("modifyDelay")&&o.push("modifyDelay"),t.includes("check")&&o.push("check"),t.includes("resetAfter")&&o.push("resetAfter"),t.includes("resetWhen")&&o.push("resetWhen"),t.includes("ensure")&&o.push("ensure"),t.includes("driver")&&o.push("driver"),t.includes("mapInput")&&o.push("mapInput"),{baseStrategy:r,maxRetries:s,jittered:c,conditions:o}}var Wo=(e,t,r,s,n,i)=>ee.gen(function*(){let c=e.getArguments(),o,a,d,l=e.getExpression();if(l.getKind()===w().SyntaxKind.PropertyAccessExpression){let g=l.getExpression();o=yield*M(g,t,r,s,n,i),c.length>0&&c[0]&&(a=kt(c[0]));let p=kt(l);d=p.includes("timeoutFail")||p.includes("timeoutTo")}else c.length>0&&c[0]?o=yield*M(c[0],t,r,s,n,i):o={id:C(),type:"unknown",reason:"Could not determine source effect"},c.length>1&&c[1]&&(a=kt(c[1])),d=c.length>2;i.timeoutCount++;let f={id:C(),type:"timeout",source:o,duration:a,hasFallback:d,location:_(e,r,s.includeLocations??!1)};return{...f,displayName:G(f),semanticRole:Q(f)}}),ls=(e,t,r,s,n,i,c)=>ee.gen(function*(){let o=e.getArguments(),a=/([A-Za-z_$][\w$]*)$/.exec(t)?.[1]??t,d,l,f;if(a.startsWith("acquireUseRelease"))o.length>=3&&o[0]&&o[2]?(d=yield*M(o[0],r,s,n,i,c),l=yield*M(o[2],r,s,n,i,c),o[1]&&(f=yield*M(o[1],r,s,n,i,c))):(d={id:C(),type:"unknown",reason:"Missing acquire"},l={id:C(),type:"unknown",reason:"Missing release"});else if(a.startsWith("acquireRelease"))o.length>=2&&o[0]&&o[1]?(d=yield*M(o[0],r,s,n,i,c),l=yield*M(o[1],r,s,n,i,c)):(d={id:C(),type:"unknown",reason:"Missing acquire"},l={id:C(),type:"unknown",reason:"Missing release"});else if(a==="addFinalizer"||a==="onExit"||a==="onError"||a==="parallelFinalizers"||a==="sequentialFinalizers"||a==="finalizersMask"||a==="using"||a==="withEarlyRelease"){let g=e.getExpression();g.getKind()===w().SyntaxKind.PropertyAccessExpression?d=yield*M(g.getExpression(),r,s,n,i,c):d={id:C(),type:"unknown",reason:"Scoped acquire"},l=o.length>0&&o[0]?yield*M(o[0],r,s,n,i,c):{id:C(),type:"unknown",reason:"Missing finalizer"}}else if(a==="ensuring"){let g=e.getExpression();if(g.getKind()===w().SyntaxKind.PropertyAccessExpression){let m=g.getExpression();d=yield*M(m,r,s,n,i,c),l=o.length>0&&o[0]?yield*M(o[0],r,s,n,i,c):{id:C(),type:"unknown",reason:"Missing cleanup"}}else d=o.length>0&&o[0]?yield*M(o[0],r,s,n,i,c):{id:C(),type:"unknown",reason:"Missing effect"},l=o.length>1&&o[1]?yield*M(o[1],r,s,n,i,c):{id:C(),type:"unknown",reason:"Missing cleanup"}}else d={id:C(),type:"unknown",reason:"Unknown resource pattern"},l={id:C(),type:"unknown",reason:"Unknown resource pattern"};c.resourceCount++;let u={id:C(),type:"resource",acquire:d,release:l,use:f,location:_(e,s,n.includeLocations??!1)};return{...u,displayName:G(u),semanticRole:Q(u)}}),Ko=(e,t,r,s,n,i,c)=>ee.gen(function*(){let o=e.getArguments(),a;t.includes(".if")||t==="if"?a="if":t.includes("whenEffect")?a="whenEffect":t.includes("whenFiberRef")?a="whenFiberRef":t.includes("whenRef")?a="whenRef":t.includes(".when")||t==="when"?a="when":t.includes("unlessEffect")?a="unlessEffect":t.includes(".unless")||t==="unless"?a="unless":t.includes(".option")||t==="option"?a="option":t.includes(".either")||t==="either"?a="either":t.includes(".exit")||t==="exit"?a="exit":t.includes("liftPredicate")?a="liftPredicate":a="unless";let d="<dynamic>",l,f;if(a==="if"){if(o.length>0&&o[0]&&(d=o[0].getText()),o.length>1&&o[1]){let p=o[1],{SyntaxKind:m}=w();if(p.getKind()===m.ObjectLiteralExpression){let h=p.getProperties();for(let y of h)if(y.getKind()===m.PropertyAssignment){let N=y,E=N.getName(),$=N.getInitializer();$&&(E==="onTrue"?l=yield*M($,r,s,n,i,c):E==="onFalse"&&(f=yield*M($,r,s,n,i,c)))}}}}else{let p=e.getExpression();if(p.getKind()===w().SyntaxKind.PropertyAccessExpression){let h=p.getExpression();l||(l=yield*M(h,r,s,n,i,c))}o.length>0&&o[0]&&(d=o[0].getText())}l||(l={id:C(),type:"unknown",reason:"Could not determine true branch"}),c.conditionalCount++;let u=d.length<=30?d:`${d.slice(0,30)}\u2026`,g={id:C(),type:"conditional",conditionalType:a,condition:d,onTrue:l,onFalse:f,conditionLabel:u,trueEdgeLabel:"true",falseEdgeLabel:"false",location:_(e,s,n.includeLocations??!1)};return{...g,displayName:G(g),semanticRole:Q(g)}}),jo=(e,t,r,s,n,i,c)=>ee.gen(function*(){let o=e.getArguments(),a=t.includes("forEach")?"forEach":t.includes("filterMap")?"filterMap":t.includes("filter")?"filter":t.includes("partition")?"partition":t.includes("reduce")?"reduce":t.includes("validateAll")||t.includes("validateFirst")||t.includes("validateWith")?"validate":t.includes("replicate")?"replicate":t.includes("dropUntil")?"dropUntil":t.includes("dropWhile")?"dropWhile":t.includes("takeUntil")?"takeUntil":t.includes("takeWhile")?"takeWhile":t.includes("every")?"every":t.includes("exists")?"exists":t.includes("findFirst")?"findFirst":t.includes("head")?"head":t.includes("mergeAll")?"mergeAll":"loop",d=a==="reduce"||t.includes("reduceRight")||t.includes("reduceWhile")||t.includes("reduceEffect")?2:1,l,f;o.length>0&&o[0]&&(l=o[0].getText()),o.length>d&&o[d]?f=yield*M(o[d],r,s,n,i,c):f={id:C(),type:"unknown",reason:"Could not determine loop body"},c.loopCount++;let u={id:C(),type:"loop",loopType:a,iterSource:l,body:f,location:_(e,s,n.includeLocations??!1)};return{...u,displayName:G(u),semanticRole:Q(u)}}),Bo=(e,t,r,s)=>{let n=pn[t]??"other",i=Wr.has(n),c=e.getArguments(),o=[];if((n==="when"||n==="tag")&&c[0]){let d=c[0].getText().replace(/["'`]/g,"").trim();/^[A-Za-z_][A-Za-z0-9_]*$/.test(d)&&o.push(d)}if(n==="tags"||n==="tagsExhaustive"){let{SyntaxKind:d}=w();for(let l of c)if(l.getKind()===d.ObjectLiteralExpression){let f=l;for(let u of f.getProperties()){let g=u.getKind()===d.PropertyAssignment?u.getName():void 0;g&&o.push(g.replace(/["'`]/g,""))}}}let a={id:C(),type:"match",matchOp:n,isExhaustive:i,...o.length>0?{matchedTags:o}:{},location:_(e,r,s.includeLocations??!1)};return{...a,displayName:G(a),semanticRole:Q(a)}},qo=(e,t,r,s,n,i,c)=>ee.gen(function*(){let o=gn[t]??"other",a=jr.has(o),d;if(o==="parallel"||o==="sequential"){let u=e.getArguments(),g=[];for(let p of u)if(p){let m=yield*M(p,r,s,n,i,c);g.push(m)}g.length>0&&(d=g)}let l;if(o==="fail")l="fail";else if(o==="die")l="die";else if(o==="interrupt")l="interrupt";else if((o==="parallel"||o==="sequential")&&d&&d.length>0){let u=d.filter(g=>g.type==="cause").map(g=>g.causeKind).filter(g=>g!==void 0);u.length>0&&(l=u.every(g=>g===u[0])?u[0]:"mixed")}let f={id:C(),type:"cause",causeOp:o,isConstructor:a,...d?{children:d}:{},...l?{causeKind:l}:{},location:_(e,s,n.includeLocations??!1)};return{...f,displayName:G(f),semanticRole:Q(f)}}),zo=(e,t,r,s)=>{let n=mn[t]??"other",i=qr.has(n),c={id:C(),type:"exit",exitOp:n,isConstructor:i,location:_(e,r,s.includeLocations??!1)};return{...c,displayName:G(c),semanticRole:Q(c)}},_o=(e,t,r,s)=>ee.sync(()=>{let n=yn[t]??"other",i=e.getText(),c=us(i),o={id:C(),type:"schedule",scheduleOp:n,...c?{scheduleInfo:c}:{},location:_(e,r,s.includeLocations??!1)};return{...o,displayName:G(o),semanticRole:Q(o)}}),Ho=(e,t,r,s,n,i,c)=>ee.gen(function*(){let o=e.getArguments(),a=fn[t]??"other",d=Or.has(a),l,f;if(o.length>=2&&o[0]){if(l=yield*M(o[0],r,s,n,i,c),o[1]){let g=o[1].getText();f=g.length<=120?g:g.slice(0,120)+"\u2026"}}else if(o.length===1&&o[0]){let g=o[0].getText();f=g.length<=120?g:g.slice(0,120)+"\u2026"}c.totalEffects++;let u={id:C(),type:"transform",transformType:a,isEffectful:d,...l!==void 0?{source:l}:{},...f!==void 0?{fn:f}:{},location:_(e,s,n.includeLocations??!1)};return{...u,displayName:G(u),semanticRole:Q(u)}});var In=(e,t,r,s,n)=>xe.gen(function*(){let i=[],c=Pr(),o=yield*Uo(e.node,e.type,t,r,s,i,c),a=Ar(e.node),d=t.getProject().getTypeChecker(),l=Ze(e.node,d),f=wt(e.node,d),u={id:C(),type:"program",programName:e.name,source:e.type,...e.discoveryConfidence?{discoveryConfidence:e.discoveryConfidence}:{},...e.discoveryReason?{discoveryReason:e.discoveryReason}:{},children:o,dependencies:Fr(o),errorTypes:$r(o),typeSignature:l,requiredServices:f,location:_(e.node,r,s.includeLocations??!1),jsdocDescription:a,jsdocTags:Ye(e.node)},g=cs(t);return{root:u,metadata:{analyzedAt:Date.now(),filePath:r,tsVersion:n,warnings:i,stats:c,...g.length>0?{serviceDefinitions:g}:{}},references:new Map}}),Uo=(e,t,r,s,n,i,c)=>xe.gen(function*(){switch(t){case"generator":{let o=e.getArguments();if(o.length>0&&o[0]){let a=o[0];return yield*Yo(a,r,s,n,i,c)}return[]}case"pipe":return yield*Rt(e,r,s,n,i,c);case"run":{let o=e,{SyntaxKind:a}=w(),d=yield*Xo(o,r,s,n,i,c);if(yt.isSome(d))return d.value;let l=o.getArguments(),f=l.find(p=>p.getKind()===a.ArrowFunction||p.getKind()===a.FunctionExpression),u=n.enableEffectWorkflow&&f===void 0&&l.length===1?as(o,r):null,g=f??u??l[0];return g?[yield*M(g,r,s,n,i,c)]:[]}case"workflow-execute":{let o=e,a=o.getExpression().getText();return[{id:C(),type:"effect",callee:a,name:a,semanticRole:"side-effect",location:_(o,s,n.includeLocations??!1)}]}case"direct":{let o=e.getInitializer();return o?[yield*M(o,r,s,n,i,c)]:[]}case"class":{let o=e,a="Data.Class";for(let f of o.getHeritageClauses()){let u=f.getText();if(u.includes("Data.TaggedError")){a="Data.TaggedError";break}if(u.includes("Data.TaggedClass")){a="Data.TaggedClass";break}if(u.includes("Data.Error")){a="Data.Error";break}if(u.includes("Schema.TaggedRequest")){a="Schema.TaggedRequest";break}if(u.includes("Schema.TaggedError")){a="Schema.TaggedError";break}if(u.includes("Schema.TaggedClass")){a="Schema.TaggedClass";break}if(u.includes("Schema.Class")){a="Schema.Class";break}if(u.includes("Context.Tag")){a="Context.Tag";break}if(u.includes("Context.Reference")){a="Context.Reference";break}if(u.includes("Effect.Service")){a="Effect.Service";break}}let d=a.includes("Error")?"error-type":a.includes("Schema")?"schema":a==="Context.Tag"||a==="Context.Reference"||a==="Effect.Service"?"service-tag":"data",l={id:C(),type:"effect",callee:a,description:d,location:_(e,s,n.includeLocations??!1),jsdocDescription:_e(o),jsdocTags:Ye(o)};return c.totalEffects++,[l]}case"classProperty":{let a=e.getInitializer();return a?[yield*M(a,r,s,n,i,c)]:[]}case"classMethod":{let a=e.getBody();if(!a)return[];let{SyntaxKind:d}=w(),l=a.getDescendantsOfKind(d.ReturnStatement),f=[];for(let u of l){let g=u.getExpression();if(g){let p=yield*M(g,r,s,n,i,c);f.push(p)}}return f}default:return[]}});function $n(e){let{SyntaxKind:t}=w(),r=e.getKind();return r===t.FunctionDeclaration||r===t.FunctionExpression||r===t.ArrowFunction||r===t.MethodDeclaration||r===t.ClassDeclaration||r===t.ClassExpression||r===t.Constructor}function ae(e){let{SyntaxKind:t}=w();if(e.getKind()===t.YieldExpression)return!0;let r=!1;return e.forEachChild(s=>{if(!r&&!$n(s)){if(s.getKind()===t.YieldExpression){r=!0;return}if(ae(s)){r=!0;return}}}),r}function Go(e){let{SyntaxKind:t}=w();switch(e.getKind()){case t.StringLiteral:return e.getLiteralValue();case t.NumericLiteral:return e.getLiteralValue().toString();case t.TrueKeyword:return"true";case t.FalseKeyword:return"false";case t.NullKeyword:return"null";case t.NoSubstitutionTemplateLiteral:return e.getText().replace(/^`|`$/g,"");default:return}}function nt(e,t){if(t.size===0)return e;let r=e;for(let[s,n]of t){let i=new RegExp(`\\b${s}\\b`,"g"),c=/^\d/.test(n)||n==="true"||n==="false"||n==="null"?n:`'${n}'`;r=r.replace(i,c)}return r}function ht(e){let t=e;return t=t.replace(/\btrue\b\s*&&\s*/g,""),t=t.replace(/\s*&&\s*\btrue\b/g,""),t=t.replace(/\bfalse\b\s*\|\|\s*/g,""),t=t.replace(/\s*\|\|\s*\bfalse\b/g,""),t=t.replace(/\bfalse\b\s*&&\s*[^|&]+/g,"false"),t=t.replace(/\btrue\b\s*\|\|\s*[^|&]+/g,"true"),t.trim()}function Fn(e){let{SyntaxKind:t}=w();switch(e.getKind()){case t.ParenthesizedExpression:case t.AsExpression:case t.TypeAssertionExpression:case t.NonNullExpression:case t.SatisfiesExpression:{let s=e.getExpression();return Fn(s)}default:return e}}function fs(e){let{SyntaxKind:t}=w();if(e.length===0)return!1;let r=e[e.length-1];if(!r)return!1;let s=r.getKind();return s===t.ReturnStatement||s===t.ThrowStatement||s===t.BreakStatement||s===t.ContinueStatement}function gs(e){let{SyntaxKind:t}=w(),r=[];return e.forEachChild(s=>{$n(s)||(s.getKind()===t.YieldExpression?r.push(s):r.push(...gs(s)))}),r}var Vo=new Set(["Step.run","Step.decide","Step.branch","Step.all","Step.forEach","Step.retry","Step.race","Step.sleep"]);function Jo(e){let{SyntaxKind:t}=w();if(e.getKind()!==t.CallExpression)return!1;let r=e.getExpression().getText();return Vo.has(r)}function Ae(e){if(!e)return;let{SyntaxKind:t}=w();if(e.getKind()===t.StringLiteral)return e.getLiteralText()}function Qo(e){if(!e)return[];let{SyntaxKind:t}=w();if(e.getKind()!==t.ObjectLiteralExpression)return[];let r=[],s=e;for(let n of s.getProperties())if(n.getKind()===t.PropertyAssignment){let i=n.getName();r.push({labels:[i],isDefault:i==="default",body:[]})}return r}function Zo(e,t){return xe.gen(function*(){let{SyntaxKind:r}=w(),s=e.getExpression().getText(),n=e.getArguments();switch(s){case"Step.run":{let i=Ae(n[0]),c=n[1];if(!c){let a={id:C(),type:"effect",callee:"Step.run",name:i,displayName:i};return t.stats.totalEffects++,a}let o=yield*M(c,t.sourceFile,t.filePath,t.opts,t.warnings,t.stats,t.serviceScope);return{...o,displayName:i??o.displayName,name:i??o.name}}case"Step.decide":{let i=Ae(n[0]),c=Ae(n[1]);return t.stats.decisionCount++,{id:C(),type:"decision",decisionId:i??C(),label:c??i??"decision",condition:n[2]?.getText()??"unknown",source:"effect-flow",onTrue:[],onFalse:void 0}}case"Step.branch":{let i=Ae(n[0]),c=n[1]?.getText()??"unknown",o=n[2],a=Qo(o);return t.stats.switchCount++,{id:C(),type:"switch",switchId:i,expression:c,cases:a,source:"effect-flow",hasDefault:a.some(l=>l.isDefault),hasFallthrough:!1}}case"Step.all":{let i=Ae(n[0]),c=n[1],o=[];if(c?.getKind()===r.ArrayLiteralExpression){let d=c;for(let l of d.getElements()){let f=yield*M(l,t.sourceFile,t.filePath,t.opts,t.warnings,t.stats,t.serviceScope);o.push(f)}}return t.stats.parallelCount++,{id:C(),type:"parallel",name:i,displayName:i,children:o,mode:"parallel",callee:"Step.all"}}case"Step.forEach":{let i=Ae(n[0]),c=n[1]?.getText(),o=n[2],a={id:C(),type:"effect",callee:"unknown"};return o&&(a=yield*M(o,t.sourceFile,t.filePath,t.opts,t.warnings,t.stats,t.serviceScope)),t.stats.loopCount++,{id:C(),type:"loop",name:i,displayName:i,loopType:"forEach",iterSource:c,body:a}}case"Step.retry":{let i=Ae(n[0]),c=n[1];if(!c){let d={id:C(),type:"effect",callee:"Step.retry",name:i,displayName:i};return t.stats.totalEffects++,d}let o=yield*M(c,t.sourceFile,t.filePath,t.opts,t.warnings,t.stats,t.serviceScope);return t.stats.retryCount++,{id:C(),type:"retry",name:i,displayName:i,source:o,hasFallback:!1}}case"Step.race":{let i=Ae(n[0]),c=n[1],o=[];if(c?.getKind()===r.ArrayLiteralExpression){let d=c;for(let l of d.getElements()){let f=yield*M(l,t.sourceFile,t.filePath,t.opts,t.warnings,t.stats,t.serviceScope);o.push(f)}}return t.stats.raceCount++,{id:C(),type:"race",name:i,displayName:i,children:o,callee:"Step.race"}}case"Step.sleep":{let i=Ae(n[0]),c={id:C(),type:"effect",callee:"Step.sleep",name:i,displayName:i,semanticRole:"scheduling"};return t.stats.totalEffects++,c}default:{let i={id:C(),type:"effect",callee:s,name:s,displayName:s};return t.stats.totalEffects++,i}}})}function ps(e,t){return xe.gen(function*(){let r=e,s=r.getText().startsWith("yield*"),n=r.getExpression();if(!s){let d={id:C(),type:"opaque",reason:"plain-yield",sourceText:e.getText().slice(0,80)};return t.stats.opaqueCount++,t.warnings.push({code:"PLAIN_YIELD",message:`Plain yield (not yield*) detected; this is unusual in Effect generators: ${e.getText().slice(0,60)}`,location:_(e,t.filePath,t.opts.includeLocations??!1)}),{variableName:vt(e),effect:d}}if(!n){let d={id:C(),type:"opaque",reason:"yield-no-expression",sourceText:e.getText().slice(0,80)};return t.stats.opaqueCount++,{variableName:void 0,effect:d}}let i=Fn(n);if(t.opts.enableEffectFlow&&Jo(i)){let d=yield*Zo(i,t),l=vt(e),f={...d,displayName:d.displayName??G(d,l),semanticRole:d.semanticRole??Q(d)};return{variableName:l,effect:f}}let c=yield*M(n,t.sourceFile,t.filePath,t.opts,t.warnings,t.stats,t.serviceScope),o=vt(e);o&&c.type==="effect"&&Ur(c.callee)&&t.serviceScope.set(o,c.callee);let a={...c,displayName:G(c,o),semanticRole:c.semanticRole??Q(c)};return{variableName:o,effect:a}})}function rt(e,t){return xe.gen(function*(){let r=e.getStatements(),s=[];for(let n of r){let i=yield*Dt(n,t);s.push(...i)}return s})}function Dt(e,t){return xe.gen(function*(){let{SyntaxKind:r}=w();switch(e.getKind()){case r.ExpressionStatement:{let i=e.getExpression();return yield*ye(i,t)}case r.VariableStatement:{let n=e,i=[],{VariableDeclarationKind:c}=w(),o=n.getDeclarationKind()===c.Const;for(let a of n.getDeclarations()){let d=a.getInitializer();if(o&&d){let l=Go(d);l!==void 0&&t.constValues.set(a.getName(),l)}if(d&&!ae(d)&&d.getKind()===r.CallExpression){let l=d,f=l.getExpression().getText();if(f==="Context.pick"||f==="Context.omit"){let u=yield*M(l,t.sourceFile,t.filePath,t.opts,t.warnings,t.stats,t.serviceScope);u.type==="effect"&&u.description==="context"&&i.push({variableName:a.getName(),effect:u});continue}}if(d&&ae(d)){let l=yield*ye(d,t);if(l.length>0){let f=a.getName(),u=l[l.length-1];u&&(l[l.length-1]={...u,variableName:u.variableName??f})}i.push(...l)}}return i}case r.IfStatement:{if(!ae(e))return[];let n=e,i=n.getExpression().getText(),c=yield*ye(n.getExpression(),t),o=n.getThenStatement(),a=n.getElseStatement(),d=yield*Ue(o,t),l=a?yield*Ue(a,t):void 0,f=ht(nt(i,t.constValues)),u=f.length>40?f.slice(0,40)+"...":f,g={id:C(),type:"decision",decisionId:C(),label:u,condition:i,source:"raw-if",onTrue:d.map(p=>p.effect),onFalse:l&&l.length>0?l.map(p=>p.effect):void 0};return t.stats.decisionCount++,[...c,{effect:g}]}case r.SwitchStatement:{if(!ae(e))return[];let n=e,i=n.getExpression().getText(),c=n.getClauses(),o=[],a=!1,d=!1,l=[],f=[],u=!1;for(let m of c){if(m.getKind()===r.DefaultClause)d=!0,u=!0,l.push("default");else{let E=m;l.push(E.getExpression().getText())}let y=m.getStatements();if(y.length===0){a=!0;continue}for(let E of y){let $=yield*Dt(E,t);f.push(...$)}fs(y)||(a=!0),o.push({labels:l,isDefault:u,body:f.map(E=>E.effect)}),l=[],f=[],u=!1}l.length>0&&o.push({labels:l,isDefault:u,body:f.map(m=>m.effect)});let g=nt(i,t.constValues),p={id:C(),type:"switch",switchId:C(),expression:g,cases:o,source:"raw-js",hasDefault:d,hasFallthrough:a};return t.stats.switchCount++,[{effect:p}]}case r.ForStatement:{if(!ae(e))return[];let n=e,i=[],c=n.getInitializer();if(c&&ae(c)){let m=yield*ye(c,t);i.push(...m.map(h=>h.effect))}let o=n.getIncrementor();if(o&&ae(o)){let m=yield*ye(o,t);i.push(...m.map(h=>h.effect))}let a=n.getStatement(),d=yield*Ue(a,t),l=tt(a),f=n.getCondition(),u=f?f.getText():void 0,g=d.length===1&&d[0]?d[0].effect:{id:C(),type:"generator",yields:d},p={id:C(),type:"loop",loopType:"for",iterSource:u,body:g,...l?{hasEarlyExit:l}:{},...i.length>0?{headerYields:i}:{}};return t.stats.loopCount++,[{effect:p}]}case r.ForOfStatement:{if(!ae(e))return[];let n=e,i=n.getExpression(),c=i.getText(),o=[];if(ae(i)){let p=yield*ye(i,t);o.push(...p.map(m=>m.effect))}let a=n.getInitializer().getText(),d=n.getStatement(),l=yield*Ue(d,t),f=tt(d),u=l.length===1&&l[0]?l[0].effect:{id:C(),type:"generator",yields:l},g={id:C(),type:"loop",loopType:"forOf",iterSource:c,body:u,...f?{hasEarlyExit:f}:{},...o.length>0?{headerYields:o}:{},iterVariable:a};return t.stats.loopCount++,[{effect:g}]}case r.ForInStatement:{if(!ae(e))return[];let n=e,i=n.getExpression().getText(),c=n.getInitializer().getText(),o=n.getStatement(),a=yield*Ue(o,t),d=tt(o),l=a.length===1&&a[0]?a[0].effect:{id:C(),type:"generator",yields:a},f={id:C(),type:"loop",loopType:"forIn",iterSource:i,body:l,...d?{hasEarlyExit:d}:{},iterVariable:c};return t.stats.loopCount++,[{effect:f}]}case r.WhileStatement:{if(!ae(e))return[];let n=e,i=n.getExpression().getText(),c=n.getStatement(),o=yield*Ue(c,t),a=tt(c),d=o.length===1&&o[0]?o[0].effect:{id:C(),type:"generator",yields:o},l={id:C(),type:"loop",loopType:"while",iterSource:i,body:d,...a?{hasEarlyExit:a}:{}};return t.stats.loopCount++,[{effect:l}]}case r.DoStatement:{if(!ae(e))return[];let n=e,i=n.getExpression().getText(),c=n.getStatement(),o=yield*Ue(c,t),a=tt(c),d=o.length===1&&o[0]?o[0].effect:{id:C(),type:"generator",yields:o},l={id:C(),type:"loop",loopType:"doWhile",iterSource:i,body:d,...a?{hasEarlyExit:a}:{}};return t.stats.loopCount++,[{effect:l}]}case r.TryStatement:{if(!ae(e))return[];let n=e,i=n.getTryBlock(),c=yield*rt(i,t),o=n.getCatchClause(),a,d;if(o){a=o.getVariableDeclaration()?.getName();let m=o.getBlock();d=yield*rt(m,t)}let l=n.getFinallyBlock(),f;l&&(f=yield*rt(l,t));let u=fs(i.getStatements()),g={id:C(),type:"try-catch",tryBody:c.map(p=>p.effect),...a?{catchVariable:a}:{},...d&&d.length>0?{catchBody:d.map(p=>p.effect)}:{},...f&&f.length>0?{finallyBody:f.map(p=>p.effect)}:{},hasTerminalInTry:u};return t.stats.tryCatchCount++,[{effect:g}]}case r.ReturnStatement:{let i=e.getExpression();if(!i||!ae(i))return[];let c=yield*ye(i,t),o={id:C(),type:"terminal",terminalKind:"return",value:c.map(a=>a.effect)};return t.stats.terminalCount++,[{effect:o}]}case r.ThrowStatement:{let i=e.getExpression();if(!ae(i))return[];let c=yield*ye(i,t),o={id:C(),type:"terminal",terminalKind:"throw",...c.length>0?{value:c.map(a=>a.effect)}:{}};return t.stats.terminalCount++,[{effect:o}]}case r.BreakStatement:return[];case r.ContinueStatement:return[];case r.LabeledStatement:return yield*Dt(e.getStatement(),t);case r.Block:return yield*rt(e,t);default:return[]}})}function Ue(e,t){let{SyntaxKind:r}=w();return e.getKind()===r.Block?rt(e,t):Dt(e,t)}function tt(e){let{SyntaxKind:t}=w(),r=!1;return e.forEachChild(s=>{if(r||$n(s))return;let n=s.getKind();if(n===t.BreakStatement||n===t.ReturnStatement){r=!0;return}if(tt(s)){r=!0;return}}),r}function ye(e,t){return xe.gen(function*(){let{SyntaxKind:r}=w();if(!ae(e))return[];let s=Fn(e),n=s.getKind();if(n===r.YieldExpression)return[yield*ps(s,t)];if(n===r.ConditionalExpression){let o=s,a=o.getCondition().getText(),d=o.getWhenTrue(),l=o.getWhenFalse(),f=yield*ye(d,t),u=yield*ye(l,t);if(f.length>0||u.length>0){let g=ht(nt(a,t.constValues)),p={id:C(),type:"decision",decisionId:C(),label:g.length>40?g.slice(0,40)+"...":g,condition:a,source:"raw-ternary",onTrue:f.map(m=>m.effect),onFalse:u.length>0?u.map(m=>m.effect):void 0};return t.stats.decisionCount++,[{effect:p}]}}if(n===r.BinaryExpression){let o=s,a=o.getOperatorToken().getKind(),d=o.getLeft(),l=o.getRight();if(a===r.AmpersandAmpersandToken){let f=yield*ye(l,t);if(f.length>0){let u=d.getText(),g=ht(nt(u,t.constValues)),p={id:C(),type:"decision",decisionId:C(),label:g.length>40?g.slice(0,40)+"...":g,condition:u,source:"raw-short-circuit",onTrue:f.map(m=>m.effect),onFalse:[]};return t.stats.decisionCount++,[{effect:p}]}}if(a===r.BarBarToken){let f=yield*ye(l,t);if(f.length>0){let u=d.getText(),g=ht(nt(u,t.constValues)),p={id:C(),type:"decision",decisionId:C(),label:g.length>40?g.slice(0,40)+"...":g,condition:u,source:"raw-short-circuit",onTrue:[],onFalse:f.map(m=>m.effect)};return t.stats.decisionCount++,[{effect:p}]}}if(a===r.QuestionQuestionToken){let f=yield*ye(l,t);if(f.length>0){let u=`${d.getText()} != null`,g=ht(nt(u,t.constValues)),p={id:C(),type:"decision",decisionId:C(),label:g.length>40?g.slice(0,40)+"...":g,condition:u,source:"raw-short-circuit",onTrue:[],onFalse:f.map(m=>m.effect)};return t.stats.decisionCount++,[{effect:p}]}}}let i=gs(e),c=[];for(let o of i){let a=yield*ps(o,t);c.push(a)}return c})}var Yo=(e,t,r,s,n,i)=>xe.gen(function*(){let{SyntaxKind:c}=w(),o;if((e.getKind()===c.ArrowFunction||e.getKind()===c.FunctionExpression||e.getKind()===c.FunctionDeclaration)&&(o=e.getBody()),!o)return[];let a=new Map,l={sourceFile:t,filePath:r,opts:s,warnings:n,stats:i,serviceScope:a,constValues:new Map},f;o.getKind()===c.Block?f=yield*rt(o,l):f=yield*ye(o,l);let u=o.getDescendantsOfKind(c.CallExpression);for(let h of u){let y=Le(t);if(et(h,t,y,s.knownEffectInternalsRoot)){let N=yield*vn(h,t,r,s,n,i,a);f.push({effect:N})}}let g=_e(e),p={id:C(),type:"generator",yields:f,jsdocDescription:g,jsdocTags:Ye(e)};return[{...p,displayName:G(p),semanticRole:Q(p)}]});function Xo(e,t,r,s,n,i){let o=e.getExpression().getText();if(!(o.endsWith(".pipe")||o==="pipe"))return xe.succeed(yt.none());let d=e.getArguments(),l=d[d.length-1];if(!l)return xe.succeed(yt.none());let f=l.getText();return f.includes(".runMain")||f.includes(".runPromise")||f.includes(".runSync")||f.includes(".runFork")?xe.map(Rt(e,t,r,s,n,i),g=>yt.some(g)):xe.succeed(yt.none())}var St=(e,t)=>Re.gen(function*(){let r={...an,...t},{ts:s,Project:n}=w(),i=yield*Re.try({try:()=>Rr(e)?new n({skipAddingFilesFromTsConfig:!0,compilerOptions:{allowJs:!0}}):Nr(r.tsConfigPath),catch:d=>new Se("PROJECT_CREATION_FAILED",`Failed to create project: ${String(d)}`)}),c=i.getSourceFile(e);c&&i.removeSourceFile(c);let o=yield*Re.try({try:()=>i.addSourceFileAtPath(e),catch:d=>new Se("FILE_NOT_FOUND",`Failed to load file ${e}: ${String(d)}`)}),a=kn(o,r);return a.length===0?yield*Re.fail(new Se("NO_EFFECTS_FOUND",`No Effect programs found in ${e}`)):yield*Re.forEach(a,d=>In(d,o,e,r,s.version),{concurrency:"unbounded"})}),Ge=(e,t="temp.ts",r)=>Re.gen(function*(){let s={...an,...r},{ts:n}=w(),i=yield*Re.try({try:()=>Cr(e,t),catch:o=>new Se("SOURCE_PARSE_FAILED",`Failed to parse source: ${String(o)}`)}),c=kn(i,s);return c.length===0?yield*Re.fail(new Se("NO_EFFECTS_FOUND","No Effect programs found in source")):yield*Re.forEach(c,o=>In(o,i,t,s,n.version),{concurrency:"unbounded"})});var Te=e=>({single:()=>X.gen(function*(){if(e.length===1){let t=e[0];if(t)return t}return yield*X.fail(new Se("NOT_SINGLE_PROGRAM",`Expected exactly 1 program, found ${String(e.length)}`))}),singleOption:()=>X.gen(function*(){if(e.length===1){let t=e[0];if(t)return Pt.some(t)}return Pt.none()}),all:()=>X.succeed(e),named:t=>X.gen(function*(){let r=e.find(s=>s.root.programName===t);if(!r){let s=e.map(n=>n.root.programName).join(", ");return yield*X.fail(new Se("PROGRAM_NOT_FOUND",`Program "${t}" not found. Available: ${s||"(none)"}`))}return r}),first:()=>X.gen(function*(){let t=e[0];return t||(yield*X.fail(new Se("NO_PROGRAMS","No programs found")))}),firstOption:()=>X.gen(function*(){let t=e[0];return t?Pt.some(t):Pt.none()})}),We=(e,t)=>{Tt();let r=St(e,t);return{single:()=>X.gen(function*(){let s=yield*r;return yield*Te(s).single()}),singleOption:()=>X.gen(function*(){let s=yield*r;return yield*Te(s).singleOption()}).pipe(X.orDie),all:()=>r,named:s=>X.gen(function*(){let n=yield*r;return yield*Te(n).named(s)}),first:()=>X.gen(function*(){let s=yield*r;return yield*Te(s).first()}),firstOption:()=>X.gen(function*(){let s=yield*r;return yield*Te(s).firstOption()}).pipe(X.orDie)}};We.source=(e,t)=>{Tt();let r=Ge(e,"temp.ts",t);return{single:()=>X.gen(function*(){let s=yield*r;return yield*Te(s).single()}),singleOption:()=>X.gen(function*(){let s=yield*r;return yield*Te(s).singleOption()}).pipe(X.orDie),all:()=>r,named:s=>X.gen(function*(){let n=yield*r;return yield*Te(n).named(s)}),first:()=>X.gen(function*(){let s=yield*r;return yield*Te(s).first()}),firstOption:()=>X.gen(function*(){let s=yield*r;return yield*Te(s).firstOption()}).pipe(X.orDie)}};import{Effect as ra,Option as au}from"effect";import{Option as ea}from"effect";function ms(e,t){for(let r of e){r.type==="effect"&&t.push(r);let s=ea.getOrElse(P(r),()=>[]);s.length>0&&ms(s,t)}}function ys(e){let t=[],r=[],s=new Set,n=new Map,i=[];ms(e.root.children,i);for(let d of i){let l=d.typeSignature?.successType,f=(d.requiredServices??[]).map(u=>u.serviceId);if(l){s.add(l);let u=n.get(l)??[];u.push(d.id),n.set(l,u)}t.push({id:d.id,name:d.callee,writes:l,reads:f,location:d.location?{line:d.location.line,column:d.location.column}:void 0})}for(let d=0;d<i.length-1;d++){let l=i[d],f=i[d+1];if(l===void 0||f===void 0)continue;let u=l.typeSignature?.successType??"value";r.push({from:l.id,to:f.id,key:u})}let c="__context__";for(let d of t)for(let l of d.reads)r.push({from:c,to:d.id,key:l});let o=[];for(let d of t)for(let l of d.reads)!s.has(l)&&l!==c&&o.push({key:l,readerId:d.id,readerName:d.name});let a=[];for(let[d,l]of n)l.length>1&&a.push({key:d,writerIds:l});return{nodes:t,edges:r,producedKeys:s,undefinedReads:o,duplicateWrites:a}}import{Option as it}from"effect";function An(e){let t=e.trim();return t==="never"||t==="unknown"?[]:Fe(t)}function hs(e,t){for(let r of e){if(r.type==="effect"){let n=r,i=n.typeSignature?.errorType?An(n.typeSignature.errorType):[];t.push({stepId:n.id,stepName:n.callee,errors:i,location:n.location?{line:n.location.line,column:n.location.column}:void 0})}let s=it.getOrElse(P(r),()=>[]);s.length>0&&hs(s,t)}}function Ot(e){let t=[],r=new Set,s=new Map,n=[];hs(e.root.children,t);for(let i of t){i.errors.length===0&&n.push(i.stepId);for(let c of i.errors){r.add(c);let o=s.get(c)??[];o.push(i.stepId),s.set(c,o)}}return{allErrors:Array.from(r).sort(),stepErrors:t,errorToSteps:s,stepsWithoutErrors:n,allStepsDeclareErrors:n.length===0&&t.length>0}}function Mt(e,t){return Array.from(new Set([...e,...t])).sort()}function ta(e,t){let r=new Set(t);return e.filter(s=>!r.has(s))}function na(e){let t=[],r=s=>{if(s.type==="effect"){let i=s.typeSignature?.errorType;i&&t.push(...An(i))}it.getOrElse(P(s),()=>[]).forEach(r)};return r(e),Mt([],t)}function Ss(e){if(e.type==="cause")return e.causeKind;let t=it.getOrElse(P(e),()=>[]);for(let r of t){let s=Ss(r);if(s)return s}}function st(e,t,r){let s=[...t];for(let n of e)if(n.type==="effect"){let i=n,c=i.typeSignature?.errorType?An(i.typeSignature.errorType):[];s=Mt(s,c),r.push({atNode:i.id,possibleErrors:[...s],defects:[],interruptible:!1});let o=it.getOrElse(P(n),()=>[]);o.length>0&&(s=st(o,s,r))}else if(n.type==="error-handler"){let i=n;s=st([i.source],s,r);let c=[...s],o=[];i.handlerType==="catchTag"&&i.errorTag?o.push(i.errorTag):i.handlerType==="catchTags"?i.errorTags&&i.errorTags.length>0?o.push(...c.filter(l=>i.errorTags?i.errorTags.includes(l):!1)):o.push(...c.filter(l=>/Error$|^[A-Z]/.test(l))):i.handlerType==="catchIf"||i.handlerType==="catchSome"||i.handlerType==="catchSomeCause"||i.handlerType==="catchSomeDefect"?o.push(...c.slice(0,Math.ceil(c.length/2))):i.handlerType==="catchAll"||i.handlerType==="catchAllCause"||i.handlerType==="catchAllDefect"||i.handlerType==="orElse"||i.handlerType==="orDie"||i.handlerType==="orDieWith"?o.push(...c):i.handlerType==="mapError"||i.handlerType==="mapErrorCause"||i.handlerType==="mapBoth"?o.push(...c):i.handlerType==="sandbox"?o.push(...c):i.handlerType==="ignore"||i.handlerType==="ignoreLogged"?o.push(...c):i.handlerType==="orElseFail"||i.handlerType==="orElseSucceed"?o.push(...c):(i.handlerType==="filterOrDie"||i.handlerType==="filterOrDieMessage")&&o.push(...c);let a=ta(s,o),d=i.handler?na(i.handler):[];if((i.handlerType==="mapError"||i.handlerType==="mapErrorCause"||i.handlerType==="mapBoth")&&o.length>0&&d.length===0){let l=Ss(i.source);l==="fail"?d=["<mapped-fail>"]:l==="die"?d=["<mapped-defect>"]:d=["<mapped-error>"]}s=Mt(a,d),r.push({atNode:i.id,possibleErrors:[...s],narrowedBy:{handler:i.handlerType,removedErrors:o,addedErrors:d},defects:[],interruptible:!1}),i.handler&&(s=st([i.handler],s,r))}else if(n.type==="parallel"||n.type==="race"){let i=it.getOrElse(P(n),()=>[]),c=[];for(let o of i){let a=st([o],s,r);c=Mt(c,a)}s=c}else{let i=it.getOrElse(P(n),()=>[]);i.length>0&&(s=st(i,s,r))}return s}function Lt(e){let t=[];st(e.root.children,[],t);let r=new Map;for(let s of t)r.set(s.atNode,s);return{propagation:t,byNodeId:r}}var Ns={effect:"fill:#90EE90,stroke:#333,stroke-width:2px",generator:"fill:#FFB6C1,stroke:#333,stroke-width:2px",pipe:"fill:#ADD8E6,stroke:#333,stroke-width:2px",parallel:"fill:#FFA500,stroke:#333,stroke-width:2px",race:"fill:#FF6347,stroke:#333,stroke-width:2px",errorHandler:"fill:#FFD700,stroke:#333,stroke-width:2px",retry:"fill:#EE82EE,stroke:#333,stroke-width:2px",timeout:"fill:#87CEEB,stroke:#333,stroke-width:2px",resource:"fill:#98FB98,stroke:#333,stroke-width:2px",conditional:"fill:#DDA0DD,stroke:#333,stroke-width:2px",loop:"fill:#F0E68C,stroke:#333,stroke-width:2px",layer:"fill:#E6E6FA,stroke:#333,stroke-width:2px",stream:"fill:#E0F7FA,stroke:#333,stroke-width:2px",concurrencyPrimitive:"fill:#B0E0E6,stroke:#333,stroke-width:2px",fiber:"fill:#DDA0DD,stroke:#333,stroke-width:2px",decision:"fill:#DDA0DD,stroke:#333,stroke-width:2px",switch:"fill:#FFD700,stroke:#333,stroke-width:2px",tryCatch:"fill:#FFE4B5,stroke:#333,stroke-width:2px",terminal:"fill:#FF6B6B,stroke:#333,stroke-width:2px",opaque:"fill:#FF9800,stroke:#333,stroke-width:2px",unknown:"fill:#D3D3D3,stroke:#333,stroke-width:1px",start:"fill:#c8e6c9,stroke:#2e7d32",end:"fill:#ffcdd2,stroke:#c62828",cause:"fill:#FF8A80,stroke:#D32F2F,stroke-width:2px",exit:"fill:#B39DDB,stroke:#512DA8,stroke-width:2px",schedule:"fill:#80DEEA,stroke:#00838F,stroke-width:2px",match:"fill:#FFE082,stroke:#F57F17,stroke-width:2px",transform:"fill:#A5D6A7,stroke:#388E3C,stroke-width:2px",channel:"fill:#90CAF9,stroke:#1565C0,stroke-width:2px",sink:"fill:#CE93D8,stroke:#7B1FA2,stroke-width:2px",interruption:"fill:#FFAB91,stroke:#BF360C,stroke-width:2px"},Rn={direction:"TB",includeIds:!1,includeDescriptions:!0,styles:Ns,compact:!1,includeTypeSignatures:!0,useSubgraphs:!0,showConditions:!0,detail:"verbose"};function ie(e){return e.replace(/\r?\n/g," ").replace(/"/g,"'").replace(/\[/g,"(").replace(/\]/g,")").replace(/\{/g,"(").replace(/\}/g,")").replace(/#/g,"#").replace(/\|/g,"|")}function ot(e,t){return e.length<=t?e:e.slice(0,t-3)+"..."}function sa(e){return e.replace(/[^a-zA-Z0-9_]/g,"_")}function Cs(e,t,r){let s={...Rn,...t,useSubgraphs:t?.useSubgraphs??!0,showConditions:t?.showConditions??!0,detail:t?.detail??"verbose"},n={opts:s,nodeCounter:0,edges:[],subgraphs:[],styleClasses:new Map,nodeIdMap:new Map,nodeLabelAnnotations:r},i=[];i.push(`flowchart ${s.direction}`),i.push(""),i.push(` %% Program: ${e.root.programName}`),i.push("");let c="start",o="end_node";i.push(` ${c}((Start))`),i.push(` ${o}((End))`),i.push("");let{firstNodeId:a,lastNodeIds:d}=Ee(e.root.children,n,i);a&&n.edges.push({from:c,to:a});for(let f of d)n.edges.push({from:f,to:o});for(let f of n.subgraphs){i.push(""),i.push(` subgraph ${f.id}["${f.label}"]`);for(let u of f.content)i.push(` ${u}`);i.push(" end")}i.push(""),i.push(" %% Edges");for(let f of n.edges)f.label&&s.showConditions?i.push(` ${f.from} -->|${ie(f.label)}| ${f.to}`):i.push(` ${f.from} --> ${f.to}`);let l={...Ns,...s.styles};i.push(""),i.push(" %% Styles"),l.start&&i.push(` classDef startStyle ${l.start}`),l.end&&i.push(` classDef endStyle ${l.end}`);for(let[f,u]of Object.entries(l))u&&f!=="start"&&f!=="end"&&i.push(` classDef ${f}Style ${u}`);i.push(` class ${c} startStyle`),i.push(` class ${o} endStyle`);for(let[f,u]of n.styleClasses)i.push(` class ${f} ${u}`);if(t?.dataFlowOverlay){let f=ys(e),u=n.nodeIdMap;i.push(""),i.push(" %% Data-flow variable annotations"),i.push(" linkStyle default stroke:#999");for(let g of f.edges){if(g.from==="__context__")continue;let p=u.get(g.from),m=u.get(g.to);p&&m&&g.key&&g.key!=="value"&&i.push(` ${p} -.->|${g.key}| ${m}`)}if(f.undefinedReads.length>0){i.push(""),i.push(" %% Data-flow warnings"),i.push(" classDef dataFlowWarning fill:#fff3cd,stroke:#856404,stroke-width:2px");for(let g of f.undefinedReads){let p=u.get(g.readerId);p&&i.push(` class ${p} dataFlowWarning`)}}if(f.duplicateWrites.length>0){i.push(" classDef duplicateWrite fill:#f8d7da,stroke:#721c24,stroke-width:2px");for(let g of f.duplicateWrites)for(let p of g.writerIds){let m=u.get(p);m&&i.push(` class ${m} duplicateWrite`)}}}if(t?.errorFlowOverlay){let f=Ot(e),u=Lt(e),g=n.nodeIdMap;i.push(""),i.push(" %% Error-flow overlay"),i.push(" classDef canFail fill:#FFECB3,stroke:#F57F17,stroke-width:2px"),i.push(" classDef unhandledError fill:#FFCDD2,stroke:#C62828,stroke-width:3px");for(let p of f.stepErrors)if(p.errors.length>0){let m=g.get(p.stepId);m&&i.push(` class ${m} canFail`)}for(let p of u.propagation)if(p.possibleErrors.length>0&&!p.narrowedBy){let m=g.get(p.atNode);m&&i.push(` class ${m} unhandledError`)}for(let p of u.propagation)if(p.narrowedBy&&p.narrowedBy.removedErrors.length>0){let m=g.get(p.narrowedBy.handler),h=g.get(p.atNode);if(m&&h){let y=p.narrowedBy.removedErrors.join(", ");i.push(` ${h} -.->|catches ${y}| ${m}`)}}}return{lines:i,context:n}}function Ee(e,t,r){if(e.length===0)return{firstNodeId:null,lastNodeIds:[]};let s=null,n=[];for(let i of e){let c=se(i,t,r);if(s===null&&c.firstNodeId&&(s=c.firstNodeId),c.firstNodeId)for(let o of n)t.edges.push({from:o,to:c.firstNodeId});n=c.lastNodeIds}return{firstNodeId:s,lastNodeIds:n}}function ia(e,t){let r=t.opts.includeIds&&"id"in e?e.id:`n${String(++t.nodeCounter)}`;return sa(r)}function oa(e,t,r){if(!t.includeDescriptions)return e.type;let s;switch(e.type){case"effect":s=e.callee||"Effect";break;case"generator":s=`Generator (${e.yields.length} yields)`;break;case"pipe":s=`Pipe (${e.transformations.length+1} steps)`;break;case"parallel":s=`${e.callee} (${e.children.length} effects)`;break;case"race":s=`${e.callee} (${e.children.length} racing)`;break;case"error-handler":s=e.handlerType;break;case"retry":s=`Retry${e.schedule?`(${e.schedule})`:""}`;break;case"timeout":s=`Timeout${e.duration?`(${e.duration})`:""}`;break;case"resource":s="Resource";break;case"conditional":s=`${e.conditionalType} (${ot(e.condition,20)})`;break;case"loop":s=`${e.loopType}${e.iterSource?`(${e.iterSource})`:""}`;break;case"layer":s=`Layer${e.isMerged?" (merged)":""}`;break;case"stream":s=`Stream${e.pipeline.length>0?`.${e.pipeline.map(n=>n.operation).join(" \u2192 ")}`:""}${e.sink?` \u2192 ${e.sink}`:""}`;break;case"concurrency-primitive":s=`${e.primitive}.${e.operation}${e.strategy?` (${e.strategy})`:""}`;break;case"fiber":s=`${e.operation}${e.isDaemon?" (daemon)":""}${e.isScoped?" (scoped)":""}`;break;case"decision":s=e.label||ot(e.condition,30);break;case"switch":s=`Switch: ${ot(e.expression,25)}`;break;case"try-catch":s="Try/Catch";break;case"terminal":s=e.terminalKind;break;case"opaque":s=`\u26A0 ${e.reason}`;break;case"cause":s=`Cause: ${e.causeOp}`;break;case"exit":s=`Exit: ${e.exitOp}`;break;case"schedule":s=`Schedule: ${e.scheduleOp}`;break;case"match":s=`Match: ${e.matchOp}${e.matchedTags?.length?` (${e.matchedTags.join(", ")})`:""}`;break;case"transform":s=`${e.transformType}${e.isEffectful?" (effectful)":""}`;break;case"channel":s=`Channel${e.pipeline.length>0?`.${e.pipeline.map(n=>n.operation).join(" \u2192 ")}`:""}`;break;case"sink":s=`Sink${e.pipeline.length>0?`.${e.pipeline.map(n=>n.operation).join(" \u2192 ")}`:""}`;break;case"interruption":s=e.interruptionType;break;case"unknown":s=`Unknown: ${e.reason}`;break;default:{s=e.type??"unknown";break}}if(t.detail!=="compact"&&e.displayName&&(s=e.displayName),t.detail==="verbose"){if(e.type==="effect"&&t.includeTypeSignatures&&e.typeSignature){let n=e.typeSignature;s+=`
|
|
6
6
|
<${n.successType}, ${n.errorType}, ${n.requirementsType}>`}e.semanticRole&&e.semanticRole!=="unknown"&&e.semanticRole!=="constructor"&&(s+=`
|
|
7
7
|
(${e.semanticRole})`)}return r?.length&&(s+=`
|
|
8
8
|
`+r.join(`
|
|
@@ -176,7 +176,7 @@ Audit written to ${c}`)}}),Ql=(e,t)=>k.gen(function*(){let r=t.color&&process.st
|
|
|
176
176
|
\`\`\`mermaid
|
|
177
177
|
${y}
|
|
178
178
|
\`\`\`
|
|
179
|
-
`;yield*k.tryPromise(()=>pe.writeFile(N,E,"utf-8")).pipe(k.catchAll(()=>k.succeed(void 0))),t.quiet||(yield*D.log(s.green(" Service graph: ")+s.cyan(N)))}yield*D.log(s.green(`Found ${String(m)} service(s)${p.unresolvedServices.length>0?`, ${String(p.unresolvedServices.length)} unresolved`:""}.`))}}if(l){let p=yield*k.tryPromise(
|
|
179
|
+
`;yield*k.tryPromise(()=>pe.writeFile(N,E,"utf-8")).pipe(k.catchAll(()=>k.succeed(void 0))),t.quiet||(yield*D.log(s.green(" Service graph: ")+s.cyan(N)))}yield*D.log(s.green(`Found ${String(m)} service(s)${p.unresolvedServices.length>0?`, ${String(p.unresolvedServices.length)} unresolved`:""}.`))}}if(l){let p=yield*k.tryPromise(()=>{let m=t.tsconfig?new en({tsConfigFilePath:t.tsconfig}):new en({skipAddingFilesFromTsConfig:!0}),h=[];for(let y of i.keys())try{let N=m.addSourceFileAtPath(y);h.push(...yr(N,y))}catch{}return Promise.resolve(h)}).pipe(k.catchAll(()=>k.succeed([])));if(p.length>0){let m=Nt(e,"api-docs.md"),h=gr(p);yield*k.tryPromise(()=>pe.writeFile(m,h,"utf-8")).pipe(k.catchAll(()=>k.succeed(void 0))),t.quiet||(yield*D.log(s.green(" API docs: ")+s.cyan(m)))}}if(t.format==="matrix"){let p=t.serviceMap&&n.serviceMap?Ti(n.serviceMap):pr(n.allPrograms);yield*D.log(`
|
|
180
180
|
`+p)}else if(t.format==="mermaid-services"){let p=t.direction==="TB"?"LR":t.direction,m=t.serviceMap&&n.serviceMap?Fs(n.serviceMap,{direction:p}):n.allPrograms.map(h=>zt(h,{direction:p})).join(`
|
|
181
181
|
|
|
182
182
|
---
|