const require_chunk = require('./chunk-CZg_9w7l.cjs');
let node_path = require("node:path");
node_path = require_chunk.__toESM(node_path);
let fs_extra = require("fs-extra");
fs_extra = require_chunk.__toESM(fs_extra);
let js_runtime = require("js-runtime");
js_runtime = require_chunk.__toESM(js_runtime);

//#region src/fs/clean.ts
async function clean(path) {
	return fs_extra.default.remove(path);
}

//#endregion
//#region src/fs/exists.ts
const reader$1 = (0, js_runtime.switcher)({
	node: async (path) => {
		return fs_extra.default.pathExists(path);
	},
	bun: async (path) => {
		return Bun.file(path).exists();
	}
}, "node");
const syncReader$1 = (0, js_runtime.switcher)({
	node: (path) => {
		return fs_extra.default.pathExistsSync(path);
	},
	bun: () => {
		throw new Error("Bun cannot read sync");
	}
}, "node");
async function exists(path) {
	return reader$1(path);
}

//#endregion
//#region src/fs/read.ts
const reader = (0, js_runtime.switcher)({
	node: async (path) => {
		return fs_extra.default.readFile(path, { encoding: "utf8" });
	},
	bun: async (path) => {
		return Bun.file(path).text();
	}
}, "node");
const syncReader = (0, js_runtime.switcher)({
	node: (path) => {
		return fs_extra.default.readFileSync(path, { encoding: "utf8" });
	},
	bun: () => {
		throw new Error("Bun cannot read sync");
	}
}, "node");
async function read(path) {
	return reader(path);
}
function readSync(path) {
	return syncReader(path);
}

//#endregion
//#region src/fs/unlink.ts
async function unlink(path) {
	return fs_extra.default.unlink(path);
}

//#endregion
//#region src/fs/utils.ts
function slash(path, platform = "linux") {
	const isWindowsPath = /^\\\\\?\\/.test(path);
	const normalizedPath = (0, node_path.normalize)(path);
	if (["linux", "mac"].includes(platform) && !isWindowsPath) return normalizedPath.replaceAll(/\\/g, "/").replace("../", "");
	return normalizedPath.replaceAll(/\\/g, "/").replace("../", "");
}
function getRelativePath(rootDir, filePath, platform = "linux") {
	if (!rootDir || !filePath) throw new Error(`Root and file should be filled in when retrieving the relativePath, ${rootDir || ""} ${filePath || ""}`);
	const relativePath = (0, node_path.relative)(rootDir, filePath);
	const slashedPath = slash(relativePath, platform);
	if (slashedPath.startsWith("../")) return slashedPath;
	return `./${slashedPath}`;
}

//#endregion
//#region src/fs/types.ts
var types_exports = {};

//#endregion
//#region src/fs/index.ts
function trimExtName(text) {
	return text.replace(/\.[^/.]+$/, "");
}

//#endregion
Object.defineProperty(exports, 'clean', {
  enumerable: true,
  get: function () {
    return clean;
  }
});
Object.defineProperty(exports, 'exists', {
  enumerable: true,
  get: function () {
    return exists;
  }
});
Object.defineProperty(exports, 'getRelativePath', {
  enumerable: true,
  get: function () {
    return getRelativePath;
  }
});
Object.defineProperty(exports, 'read', {
  enumerable: true,
  get: function () {
    return read;
  }
});
Object.defineProperty(exports, 'readSync', {
  enumerable: true,
  get: function () {
    return readSync;
  }
});
Object.defineProperty(exports, 'trimExtName', {
  enumerable: true,
  get: function () {
    return trimExtName;
  }
});
Object.defineProperty(exports, 'types_exports', {
  enumerable: true,
  get: function () {
    return types_exports;
  }
});
Object.defineProperty(exports, 'unlink', {
  enumerable: true,
  get: function () {
    return unlink;
  }
});
//# sourceMappingURL=fs-Bi2kuxAm.cjs.map