import * as fs from "fs";
import * as path from "path";
import { fileURLToPath } from "url";
const __dirname$1 = path.dirname(fileURLToPath(import.meta.url));
function getServiceWorkerContent() {
  let swFilePath = path.join(__dirname$1, "__sw__.js");
  if (!fs.existsSync(swFilePath)) {
    swFilePath = path.join(__dirname$1, "../dist/__sw__.js");
  }
  if (!fs.existsSync(swFilePath)) {
    throw new Error("Service worker file not found. Make sure almostnode is built.");
  }
  return fs.readFileSync(swFilePath, "utf-8");
}
function getServiceWorkerPath() {
  let swFilePath = path.join(__dirname$1, "__sw__.js");
  if (!fs.existsSync(swFilePath)) {
    swFilePath = path.join(__dirname$1, "../dist/__sw__.js");
  }
  if (!fs.existsSync(swFilePath)) {
    throw new Error("Service worker file not found. Make sure almostnode is built.");
  }
  return swFilePath;
}
const nextPlugin = { getServiceWorkerContent, getServiceWorkerPath };
export {
  nextPlugin as default,
  getServiceWorkerContent,
  getServiceWorkerPath
};
