import {
  __esm,
  __export
} from "./chunk-MZHE4QUL.js";

// src/shims/fs.ts
var fs_exports = {};
__export(fs_exports, {
  default: () => fs_default,
  existsSync: () => existsSync,
  readFileSync: () => readFileSync,
  writeFileSync: () => writeFileSync
});
function existsSync(_p) {
  return false;
}
function nichtImBrowser() {
  throw new Error("node:fs ist im Browser nicht verf\xFCgbar (@findsl/web, Single-File-Modus).");
}
var readFileSync, writeFileSync, fs_default;
var init_fs = __esm({
  "src/shims/fs.ts"() {
    "use strict";
    readFileSync = nichtImBrowser;
    writeFileSync = nichtImBrowser;
    fs_default = { existsSync, readFileSync, writeFileSync };
  }
});

// src/shims/path.ts
var path_exports = {};
__export(path_exports, {
  basename: () => basename,
  default: () => path_default,
  dirname: () => dirname,
  extname: () => extname,
  isAbsolute: () => isAbsolute,
  join: () => join,
  normalize: () => normalize,
  posix: () => posix,
  relative: () => relative,
  resolve: () => resolve,
  sep: () => sep
});
function normalize(p) {
  const isAbs = p.startsWith("/");
  const out = [];
  for (const part of p.split("/")) {
    if (part === "" || part === ".") continue;
    if (part === "..") {
      if (out.length && out[out.length - 1] !== "..") out.pop();
      else if (!isAbs) out.push("..");
    } else {
      out.push(part);
    }
  }
  let res = out.join("/");
  if (isAbs) res = "/" + res;
  if (p.endsWith("/") && res !== "" && res !== "/") res += "/";
  return res === "" ? isAbs ? "/" : "." : res;
}
function join(...segs) {
  const joined = segs.filter((s) => s.length > 0).join("/");
  return joined === "" ? "." : normalize(joined);
}
function dirname(p) {
  if (/^\/+$/.test(p)) return "/";
  const n = p.replace(/\/+$/, "");
  const i = n.lastIndexOf("/");
  if (i < 0) return ".";
  if (i === 0) return "/";
  return n.slice(0, i);
}
function basename(p, ext) {
  let b = p.replace(/\/+$/, "");
  b = b.slice(b.lastIndexOf("/") + 1);
  if (ext && b.length > ext.length && b.endsWith(ext)) b = b.slice(0, -ext.length);
  return b;
}
function extname(p) {
  const b = basename(p);
  const i = b.lastIndexOf(".");
  return i > 0 ? b.slice(i) : "";
}
function isAbsolute(p) {
  return p.startsWith("/");
}
function resolve(...segs) {
  let resolved = "";
  let isAbs = false;
  for (let i = segs.length - 1; i >= 0 && !isAbs; i--) {
    const seg = segs[i];
    if (!seg) continue;
    resolved = resolved ? `${seg}/${resolved}` : seg;
    isAbs = seg.startsWith("/");
  }
  if (!isAbs) resolved = "/" + resolved;
  return normalize(resolved) || "/";
}
function relative(from, to) {
  const f = resolve(from).split("/").filter(Boolean);
  const t = resolve(to).split("/").filter(Boolean);
  let i = 0;
  while (i < f.length && i < t.length && f[i] === t[i]) i++;
  return [...f.slice(i).map(() => ".."), ...t.slice(i)].join("/");
}
var sep, posix, path_default;
var init_path = __esm({
  "src/shims/path.ts"() {
    "use strict";
    sep = "/";
    posix = { sep, normalize, join, dirname, basename, extname, isAbsolute, resolve, relative };
    path_default = { ...posix, posix };
  }
});

export {
  existsSync,
  fs_exports,
  init_fs,
  sep,
  normalize,
  dirname,
  basename,
  resolve,
  relative,
  path_exports,
  init_path
};
