import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
import "./chunk-PZUWP5VK.js";

// src/templates/index.ts
import fs from "fs";
import path from "path";
import { fileURLToPath } from "url";
function resolveTemplatesDir() {
  let dir = path.dirname(fileURLToPath(import.meta.url));
  for (let i = 0; i < 5; i++) {
    if (fs.existsSync(path.join(dir, "package.json"))) {
      return path.join(dir, "dist", "src", "templates");
    }
    if (fs.existsSync(path.join(dir, "portal.md"))) {
      return dir;
    }
    dir = path.dirname(dir);
  }
  return path.dirname(fileURLToPath(import.meta.url));
}
var TEMPLATES_DIR = resolveTemplatesDir();
var templateCache = /* @__PURE__ */ new Map();
function loadTemplate(name, vars = {}) {
  let raw = templateCache.get(name);
  if (!raw) {
    raw = fs.readFileSync(path.join(TEMPLATES_DIR, `${name}.md`), "utf-8");
    templateCache.set(name, raw);
  }
  let result = raw;
  for (const [key, value] of Object.entries(vars)) {
    result = result.replaceAll(`{{${key}}}`, value);
  }
  return result;
}
export {
  loadTemplate
};
//# sourceMappingURL=templates-XPRBOWCE.js.map