import CJS_COMPAT_NODE_URL from 'node:url';
import CJS_COMPAT_NODE_PATH from 'node:path';
import CJS_COMPAT_NODE_MODULE from "node:module";

const __filename = CJS_COMPAT_NODE_URL.fileURLToPath(import.meta.url);
const __dirname = CJS_COMPAT_NODE_PATH.dirname(__filename);
const require = CJS_COMPAT_NODE_MODULE.createRequire(import.meta.url);
// ------------------------------------------------------------
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
// ------------------------------------------------------------
import {
  a as r
} from "./chunk-HRN2KQZP.js";

// ../node_modules/pathe/dist/shared/pathe.ff20891b.mjs
var j = /^[A-Za-z]:\//;
function c(e = "") {
  return e && e.replace(/\\/g, "/").replace(j, (s) => s.toUpperCase());
}
r(c, "normalizeWindowsPath");
var P = /^[/\\]{2}/, y = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/, h = /^[A-Za-z]:$/;
var b = /* @__PURE__ */ r(function(e) {
  if (e.length === 0)
    return ".";
  e = c(e);
  let s = e.match(P), t = a(e), n = e[e.length - 1] === "/";
  return e = d(e, !t), e.length === 0 ? t ? "/" : n ? "./" : "." : (n && (e += "/"), h.test(e) && (e += "/"), s ? t ? `//${e}` : `//./${e}` : t && !a(e) ? `/${e}` : e);
}, "normalize"), u = /* @__PURE__ */ r(function(...e) {
  if (e.length === 0)
    return ".";
  let s;
  for (let t of e)
    t && t.length > 0 && (s === void 0 ? s = t : s += `/${t}`);
  return s === void 0 ? "." : b(s.replace(/\/\/+/g, "/"));
}, "join");
function S() {
  return typeof process < "u" && typeof process.cwd == "function" ? process.cwd().replace(/\\/g, "/") : "/";
}
r(S, "cwd");
var T = /* @__PURE__ */ r(function(...e) {
  e = e.map((n) => c(n));
  let s = "", t = !1;
  for (let n = e.length - 1; n >= -1 && !t; n--) {
    let o = n >= 0 ? e[n] : S();
    !o || o.length === 0 || (s = `${o}/${s}`, t = a(o));
  }
  return s = d(s, !t), t && !a(s) ? `/${s}` : s.length > 0 ? s : ".";
}, "resolve");
function d(e, s) {
  let t = "", n = 0, o = -1, l = 0, f = null;
  for (let i = 0; i <= e.length; ++i) {
    if (i < e.length)
      f = e[i];
    else {
      if (f === "/")
        break;
      f = "/";
    }
    if (f === "/") {
      if (!(o === i - 1 || l === 1)) if (l === 2) {
        if (t.length < 2 || n !== 2 || t[t.length - 1] !== "." || t[t.length - 2] !== ".") {
          if (t.length > 2) {
            let p = t.lastIndexOf("/");
            p === -1 ? (t = "", n = 0) : (t = t.slice(0, p), n = t.length - 1 - t.lastIndexOf("/")), o = i, l = 0;
            continue;
          } else if (t.length > 0) {
            t = "", n = 0, o = i, l = 0;
            continue;
          }
        }
        s && (t += t.length > 0 ? "/.." : "..", n = 2);
      } else
        t.length > 0 ? t += `/${e.slice(o + 1, i)}` : t = e.slice(o + 1, i), n = i - o - 1;
      o = i, l = 0;
    } else f === "." && l !== -1 ? ++l : l = -1;
  }
  return t;
}
r(d, "normalizeString");
var a = /* @__PURE__ */ r(function(e) {
  return y.test(e);
}, "isAbsolute");
var $ = /.(\.[^./]+)$/, v = /* @__PURE__ */ r(function(e) {
  let s = $.exec(c(e));
  return s && s[1] || "";
}, "extname");
var m = /* @__PURE__ */ r(function(e) {
  let s = c(e).replace(/\/$/, "").split("/").slice(0, -1);
  return s.length === 1 && h.test(s[0]) && (s[0] += "/"), s.join("/") || (a(e) ? "/" : ".");
}, "dirname");
var _ = /* @__PURE__ */ r(function(e, s) {
  let t = c(e).split("/").pop();
  return s && t.endsWith(s) ? t.slice(0, -s.length) : t;
}, "basename"), A = /* @__PURE__ */ r(function(e) {
  let s = c(e).split("/").shift() || "/", t = _(e), n = v(t);
  return {
    root: s,
    dir: m(e),
    base: t,
    ext: n,
    name: t.slice(0, t.length - n.length)
  };
}, "parse");

// src/shared/utils/module.ts
import { statSync as z } from "node:fs";
import { createRequire as k, register as I } from "node:module";
import { win32 as w } from "node:path/win32";
import { fileURLToPath as x, pathToFileURL as E } from "node:url";
var g = /* @__PURE__ */ r((...e) => typeof import.meta.resolve != "function" && process.env.VITEST === "true" ? (console.warn(
  "importMetaResolve from within Storybook is being used in a Vitest test, but it shouldn't be. Please report this at https://github.com/storybookjs/storybook/issues/new?template=bug_report.yml"
), E(e[0]).href) : import.meta.resolve(...e), "importMetaResolve"), H = /* @__PURE__ */ r((e, s) => m(x(g(u(e, "package.json"), s))), "resolvePackageDir"), R = !1;
async function J(e) {
  if (!R) {
    let t = g("storybook/internal/bin/loader");
    I(t, import.meta.url), R = !0;
  }
  let s;
  try {
    s = await import(w.isAbsolute(e) ? E(e).href : e);
  } catch {
    s = k(import.meta.url)(e);
  }
  return s.default ?? s;
}
r(J, "importModule");
var K = /* @__PURE__ */ r(({
  specifier: e,
  parent: s,
  extensions: t = [".mjs", ".js", ".cjs"]
}) => {
  for (let n of [""].concat(t))
    try {
      let o = x(g(e + n, s));
      if (z(o).isFile())
        return o;
    } catch {
    }
}, "safeResolveModule");

export {
  u as a,
  T as b,
  A as c,
  g as d,
  H as e,
  J as f,
  K as g
};
