import { Cache, ReflectionTransformer } from './chunk-FEWH5KLD.js';
export { Cache, DeclarationTransformer, ReflectionTransformer, debugPackStruct, declarationTransformer, encodeOps, packSize, packSizeByte, transformer } from './chunk-FEWH5KLD.js';
import { init_esm_shims, __name } from './chunk-7UJRC2SU.js';
import ts from 'typescript';

// src/vendor/type-compiler/index.ts
init_esm_shims();

// ../../node_modules/.pnpm/@deepkit+type-compiler@1.0.5_patch_hash=88e8267ac73f46799c551ae3696181dc1f272895f490f8c_106542caadacebb598a10bd74dc60aae/node_modules/@deepkit/type-compiler/dist/esm/index.js
init_esm_shims();

// ../../node_modules/.pnpm/@deepkit+type-compiler@1.0.5_patch_hash=88e8267ac73f46799c551ae3696181dc1f272895f490f8c_106542caadacebb598a10bd74dc60aae/node_modules/@deepkit/type-compiler/dist/esm/src/loader.js
init_esm_shims();
var DeepkitLoader = class {
  static {
    __name(this, "DeepkitLoader");
  }
  constructor() {
    this.options = {
      allowJs: true,
      declaration: false
    };
    this.host = ts.createCompilerHost(this.options);
    this.program = ts.createProgram([], this.options, this.host);
    this.printer = ts.createPrinter({
      newLine: ts.NewLineKind.LineFeed
    });
    this.cache = new Cache();
    this.knownFiles = {};
    this.sourceFiles = {};
    const originReadFile = this.host.readFile;
    this.host.readFile = (fileName) => {
      if (this.knownFiles[fileName]) return this.knownFiles[fileName];
      return originReadFile.call(this.host, fileName);
    };
    this.host.writeFile = () => {
    };
    const originalGetSourceFile = this.host.getSourceFile;
    this.host.getSourceFile = (fileName, languageVersion, onError, shouldCreateNewSourceFile) => {
      if (this.sourceFiles[fileName]) return this.sourceFiles[fileName];
      return originalGetSourceFile.call(this.host, fileName, languageVersion, onError, shouldCreateNewSourceFile);
    };
  }
  transform(source, path) {
    this.knownFiles[path] = source;
    const sourceFile = ts.createSourceFile(path, source, ts.ScriptTarget.ESNext, true, path.endsWith(".tsx") ? ts.ScriptKind.TSX : ts.ScriptKind.TS);
    let newSource = source;
    ts.transform(sourceFile, [
      (context) => {
        const transformer2 = new ReflectionTransformer(context, this.cache).forHost(this.host).withReflection({
          reflection: "default",
          reflectionLevel: "normal"
        });
        return (node) => {
          const sourceFile2 = transformer2.transformSourceFile(node);
          newSource = this.printer.printNode(ts.EmitHint.SourceFile, sourceFile2, sourceFile2);
          return sourceFile2;
        };
      }
    ], this.options);
    return newSource;
  }
};

export { DeepkitLoader };
//# sourceMappingURL=index.js.map
//# sourceMappingURL=index.js.map