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 {
  b as f
} from "../../_node-chunks/chunk-G3SRPRRF.js";
import {
  a as d
} from "../../_node-chunks/chunk-WBEMC3FF.js";
import {
  a as r
} from "../../_node-chunks/chunk-HRN2KQZP.js";

// src/core-server/utils/remove-mdx-entries.ts
import { isAbsolute as y, join as p, relative as P } from "node:path";
import { commonGlobOptions as D, normalizeStories as g } from "storybook/internal/common";
async function b(t, e) {
  let i = g(t, {
    configDir: e.configDir,
    workingDir: e.configDir,
    defaultFilesPattern: "**/*.@(stories.@(js|jsx|mjs|ts|tsx))"
  });
  return (await Promise.all(
    i.map(async ({ directory: s, files: c, titlePrefix: m }) => {
      let o = p(s, c), n = y(o) ? o : p(e.configDir, o), a = y(s) ? s : p(e.configDir, s);
      return {
        files: (await f(d(n), {
          ...D(n),
          follow: !0
        })).map((l) => P(a, l)),
        directory: s,
        titlePrefix: m
      };
    })
  )).flatMap(({ directory: s, files: c, titlePrefix: m }, o) => {
    let n = c.filter((l) => !l.endsWith(".mdx")), a = [];
    return n.length < c.length ? a = n.map((l) => ({
      directory: s,
      titlePrefix: m,
      files: `**/${l}`
    })) : a = [
      { directory: i[o].directory, titlePrefix: i[o].titlePrefix, files: i[o].files }
    ], a;
  });
}
r(b, "removeMDXEntries");

// src/core-server/presets/common-override-preset.ts
var B = /* @__PURE__ */ r(async (t) => {
  let e = typeof t == "string" ? t : t?.name, i = typeof t == "string" ? {} : t?.options || {};
  return {
    name: e,
    options: i
  };
}, "framework"), F = /* @__PURE__ */ r(async (t, e) => e?.build?.test?.disableMDXEntries ? b(t, e) : t, "stories"), T = /* @__PURE__ */ r(async (t, e) => e?.build?.test?.disableDocgen ? { ...t ?? {}, reactDocgen: !1, check: !1 } : t, "typescript"), u = /* @__PURE__ */ r((t) => ({
  disableBlocks: t,
  disabledAddons: t ? ["@storybook/addon-docs", "@storybook/addon-essentials/docs", "@storybook/addon-coverage"] : [],
  disableMDXEntries: t,
  disableAutoDocs: t,
  disableDocgen: t,
  disableSourcemaps: t,
  disableTreeShaking: t,
  esbuildMinify: t
}), "createTestBuildFeatures"), X = /* @__PURE__ */ r(async (t, e) => ({
  ...t,
  test: e.test ? {
    ...u(!!e.test),
    ...t?.test
  } : u(!1)
}), "build");
export {
  X as build,
  B as framework,
  F as stories,
  T as typescript
};
