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 x
} from "./chunk-4Y3IMN4V.js";
import {
  a as r
} from "./chunk-HRN2KQZP.js";

// ../node_modules/find-up/index.js
import m from "node:path";

// ../node_modules/locate-path/index.js
import N from "node:process";
import S from "node:path";
import P, { promises as b } from "node:fs";
import { fileURLToPath as k } from "node:url";

// ../node_modules/locate-path/node_modules/p-limit/index.js
function h(t) {
  if (!((Number.isInteger(t) || t === Number.POSITIVE_INFINITY) && t > 0))
    throw new TypeError("Expected `concurrency` to be a number from 1 and up");
  let e = new x(), n = 0, f = /* @__PURE__ */ r(() => {
    n--, e.size > 0 && e.dequeue()();
  }, "next"), u = /* @__PURE__ */ r(async (s, i, o) => {
    n++;
    let p = (async () => s(...o))();
    i(p);
    try {
      await p;
    } catch {
    }
    f();
  }, "run"), a = /* @__PURE__ */ r((s, i, o) => {
    e.enqueue(u.bind(void 0, s, i, o)), (async () => (await Promise.resolve(), n < t && e.size > 0 && e.dequeue()()))();
  }, "enqueue"), c = /* @__PURE__ */ r((s, ...i) => new Promise((o) => {
    a(s, o, i);
  }), "generator");
  return Object.defineProperties(c, {
    activeCount: {
      get: /* @__PURE__ */ r(() => n, "get")
    },
    pendingCount: {
      get: /* @__PURE__ */ r(() => e.size, "get")
    },
    clearQueue: {
      value: /* @__PURE__ */ r(() => {
        e.clear();
      }, "value")
    }
  }), c;
}
r(h, "pLimit");

// ../node_modules/locate-path/node_modules/p-locate/index.js
var y = class extends Error {
  static {
    r(this, "EndError");
  }
  constructor(e) {
    super(), this.value = e;
  }
}, L = /* @__PURE__ */ r(async (t, e) => e(await t), "testElement"), F = /* @__PURE__ */ r(async (t) => {
  let e = await Promise.all(t);
  if (e[1] === !0)
    throw new y(e[0]);
  return !1;
}, "finder");
async function d(t, e, {
  concurrency: n = Number.POSITIVE_INFINITY,
  preserveOrder: f = !0
} = {}) {
  let u = h(n), a = [...t].map((s) => [s, u(L, s, e)]), c = h(f ? 1 : Number.POSITIVE_INFINITY);
  try {
    await Promise.all(a.map((s) => c(F, s)));
  } catch (s) {
    if (s instanceof y)
      return s.value;
    throw s;
  }
}
r(d, "pLocate");

// ../node_modules/locate-path/index.js
var T = {
  directory: "isDirectory",
  file: "isFile"
};
function v(t) {
  if (!Object.hasOwnProperty.call(T, t))
    throw new Error(`Invalid type specified: ${t}`);
}
r(v, "checkType");
var E = /* @__PURE__ */ r((t, e) => e[T[t]](), "matchType"), g = /* @__PURE__ */ r((t) => t instanceof URL ? k(t) : t, "toPath");
async function w(t, {
  cwd: e = N.cwd(),
  type: n = "file",
  allowSymlinks: f = !0,
  concurrency: u,
  preserveOrder: a
} = {}) {
  v(n), e = g(e);
  let c = f ? b.stat : b.lstat;
  return d(t, async (s) => {
    try {
      let i = await c(S.resolve(e, s));
      return E(n, i);
    } catch {
      return !1;
    }
  }, { concurrency: u, preserveOrder: a });
}
r(w, "locatePath");
function I(t, {
  cwd: e = N.cwd(),
  type: n = "file",
  allowSymlinks: f = !0
} = {}) {
  v(n), e = g(e);
  let u = f ? P.statSync : P.lstatSync;
  for (let a of t)
    try {
      let c = u(S.resolve(e, a), {
        throwIfNoEntry: !1
      });
      if (!c)
        continue;
      if (E(n, c))
        return a;
    } catch {
    }
}
r(I, "locatePathSync");

// ../node_modules/find-up/node_modules/unicorn-magic/node.js
import { fileURLToPath as _ } from "node:url";
function l(t) {
  return t instanceof URL ? _(t) : t;
}
r(l, "toPath");

// ../node_modules/find-up/index.js
var U = Symbol("findUpStop");
async function q(t, e = {}) {
  let n = m.resolve(l(e.cwd) ?? ""), { root: f } = m.parse(n), u = m.resolve(n, l(e.stopAt ?? f)), a = e.limit ?? Number.POSITIVE_INFINITY, c = [t].flat(), s = /* @__PURE__ */ r(async (o) => {
    if (typeof t != "function")
      return w(c, o);
    let p = await t(o.cwd);
    return typeof p == "string" ? w([p], o) : p;
  }, "runMatcher"), i = [];
  for (; ; ) {
    let o = await s({ ...e, cwd: n });
    if (o === U || (o && i.push(m.resolve(n, o)), n === u || i.length >= a))
      break;
    n = m.dirname(n);
  }
  return i;
}
r(q, "findUpMultiple");
function M(t, e = {}) {
  let n = m.resolve(l(e.cwd) ?? ""), { root: f } = m.parse(n), u = m.resolve(n, l(e.stopAt) ?? f), a = e.limit ?? Number.POSITIVE_INFINITY, c = [t].flat(), s = /* @__PURE__ */ r((o) => {
    if (typeof t != "function")
      return I(c, o);
    let p = t(o.cwd);
    return typeof p == "string" ? I([p], o) : p;
  }, "runMatcher"), i = [];
  for (; ; ) {
    let o = s({ ...e, cwd: n });
    if (o === U || (o && i.push(m.resolve(n, o)), n === u || i.length >= a))
      break;
    n = m.dirname(n);
  }
  return i;
}
r(M, "findUpMultipleSync");
async function ct(t, e = {}) {
  return (await q(t, { ...e, limit: 1 }))[0];
}
r(ct, "findUp");
function at(t, e = {}) {
  return M(t, { ...e, limit: 1 })[0];
}
r(at, "findUpSync");

export {
  I as a,
  M as b,
  ct as c,
  at as d
};
