import ESM_COMPAT_Module from "node:module";
import { fileURLToPath as ESM_COMPAT_fileURLToPath } from 'node:url';
import { dirname as ESM_COMPAT_dirname } from 'node:path';
const __filename = ESM_COMPAT_fileURLToPath(import.meta.url);
const __dirname = ESM_COMPAT_dirname(__filename);
const require = ESM_COMPAT_Module.createRequire(import.meta.url);
var Ae = Object.create;
var I = Object.defineProperty;
var ke = Object.getOwnPropertyDescriptor;
var Ce = Object.getOwnPropertyNames;
var Te = Object.getPrototypeOf, xe = Object.prototype.hasOwnProperty;
var n = (t, o) => I(t, "name", { value: o, configurable: !0 });
var _e = (t, o) => () => (o || t((o = { exports: {} }).exports, o), o.exports);
var Me = (t, o, e, r) => {
  if (o && typeof o == "object" || typeof o == "function")
    for (let s of Ce(o))
      !xe.call(t, s) && s !== e && I(t, s, { get: () => o[s], enumerable: !(r = ke(o, s)) || r.enumerable });
  return t;
};
var Ie = (t, o, e) => (e = t != null ? Ae(Te(t)) : {}, Me(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  o || !t || !t.__esModule ? I(e, "default", { value: t, enumerable: !0 }) : e,
  t
));

// ../node_modules/ts-dedent/dist/index.js
var Y = _e((C) => {
  "use strict";
  Object.defineProperty(C, "__esModule", { value: !0 });
  C.dedent = void 0;
  function U(t) {
    for (var o = [], e = 1; e < arguments.length; e++)
      o[e - 1] = arguments[e];
    var r = Array.from(typeof t == "string" ? [t] : t);
    r[r.length - 1] = r[r.length - 1].replace(/\r?\n([\t ]*)$/, "");
    var s = r.reduce(function(g, _) {
      var O = _.match(/\n([\t ]+|(?!\s).)/g);
      return O ? g.concat(O.map(function(M) {
        var y, b;
        return (b = (y = M.match(/[\t ]/g)) === null || y === void 0 ? void 0 : y.length) !== null && b !== void 0 ? b : 0;
      })) : g;
    }, []);
    if (s.length) {
      var c = new RegExp(`
[	 ]{` + Math.min.apply(Math, s) + "}", "g");
      r = r.map(function(g) {
        return g.replace(c, `
`);
      });
    }
    r[0] = r[0].replace(/^\r?\n/, "");
    var l = r[0];
    return o.forEach(function(g, _) {
      var O = l.match(/(?:^|\n)( *)$/), M = O ? O[1] : "", y = g;
      typeof g == "string" && g.includes(`
`) && (y = String(g).split(`
`).map(function(b, Oe) {
        return Oe === 0 ? b : "" + M + b;
      }).join(`
`)), l += y + r[_ + 1];
    }), l;
  }
  n(U, "dedent");
  C.dedent = U;
  C.default = U;
});

// node_modules/chalk/source/vendor/ansi-styles/index.js
var L = /* @__PURE__ */ n((t = 0) => (o) => `\x1B[${o + t}m`, "wrapAnsi16"), B = /* @__PURE__ */ n((t = 0) => (o) => `\x1B[${38 + t};5;${o}m`,
"wrapAnsi256"), W = /* @__PURE__ */ n((t = 0) => (o, e, r) => `\x1B[${38 + t};2;${o};${e};${r}m`, "wrapAnsi16m"), d = {
  modifier: {
    reset: [0, 0],
    // 21 isn't widely supported and 22 does the same thing
    bold: [1, 22],
    dim: [2, 22],
    italic: [3, 23],
    underline: [4, 24],
    overline: [53, 55],
    inverse: [7, 27],
    hidden: [8, 28],
    strikethrough: [9, 29]
  },
  color: {
    black: [30, 39],
    red: [31, 39],
    green: [32, 39],
    yellow: [33, 39],
    blue: [34, 39],
    magenta: [35, 39],
    cyan: [36, 39],
    white: [37, 39],
    // Bright color
    blackBright: [90, 39],
    gray: [90, 39],
    // Alias of `blackBright`
    grey: [90, 39],
    // Alias of `blackBright`
    redBright: [91, 39],
    greenBright: [92, 39],
    yellowBright: [93, 39],
    blueBright: [94, 39],
    magentaBright: [95, 39],
    cyanBright: [96, 39],
    whiteBright: [97, 39]
  },
  bgColor: {
    bgBlack: [40, 49],
    bgRed: [41, 49],
    bgGreen: [42, 49],
    bgYellow: [43, 49],
    bgBlue: [44, 49],
    bgMagenta: [45, 49],
    bgCyan: [46, 49],
    bgWhite: [47, 49],
    // Bright color
    bgBlackBright: [100, 49],
    bgGray: [100, 49],
    // Alias of `bgBlackBright`
    bgGrey: [100, 49],
    // Alias of `bgBlackBright`
    bgRedBright: [101, 49],
    bgGreenBright: [102, 49],
    bgYellowBright: [103, 49],
    bgBlueBright: [104, 49],
    bgMagentaBright: [105, 49],
    bgCyanBright: [106, 49],
    bgWhiteBright: [107, 49]
  }
}, He = Object.keys(d.modifier), Se = Object.keys(d.color), we = Object.keys(d.bgColor), Xe = [...Se, ...we];
function ve() {
  let t = /* @__PURE__ */ new Map();
  for (let [o, e] of Object.entries(d)) {
    for (let [r, s] of Object.entries(e))
      d[r] = {
        open: `\x1B[${s[0]}m`,
        close: `\x1B[${s[1]}m`
      }, e[r] = d[r], t.set(s[0], s[1]);
    Object.defineProperty(d, o, {
      value: e,
      enumerable: !1
    });
  }
  return Object.defineProperty(d, "codes", {
    value: t,
    enumerable: !1
  }), d.color.close = "\x1B[39m", d.bgColor.close = "\x1B[49m", d.color.ansi = L(), d.color.ansi256 = B(), d.color.ansi16m = W(), d.bgColor.
  ansi = L(10), d.bgColor.ansi256 = B(10), d.bgColor.ansi16m = W(10), Object.defineProperties(d, {
    rgbToAnsi256: {
      value(o, e, r) {
        return o === e && e === r ? o < 8 ? 16 : o > 248 ? 231 : Math.round((o - 8) / 247 * 24) + 232 : 16 + 36 * Math.round(o / 255 * 5) + 6 *
        Math.round(e / 255 * 5) + Math.round(r / 255 * 5);
      },
      enumerable: !1
    },
    hexToRgb: {
      value(o) {
        let e = /[a-f\d]{6}|[a-f\d]{3}/i.exec(o.toString(16));
        if (!e)
          return [0, 0, 0];
        let [r] = e;
        r.length === 3 && (r = [...r].map((c) => c + c).join(""));
        let s = Number.parseInt(r, 16);
        return [
          /* eslint-disable no-bitwise */
          s >> 16 & 255,
          s >> 8 & 255,
          s & 255
          /* eslint-enable no-bitwise */
        ];
      },
      enumerable: !1
    },
    hexToAnsi256: {
      value: /* @__PURE__ */ n((o) => d.rgbToAnsi256(...d.hexToRgb(o)), "value"),
      enumerable: !1
    },
    ansi256ToAnsi: {
      value(o) {
        if (o < 8)
          return 30 + o;
        if (o < 16)
          return 90 + (o - 8);
        let e, r, s;
        if (o >= 232)
          e = ((o - 232) * 10 + 8) / 255, r = e, s = e;
        else {
          o -= 16;
          let g = o % 36;
          e = Math.floor(o / 36) / 5, r = Math.floor(g / 6) / 5, s = g % 6 / 5;
        }
        let c = Math.max(e, r, s) * 2;
        if (c === 0)
          return 30;
        let l = 30 + (Math.round(s) << 2 | Math.round(r) << 1 | Math.round(e));
        return c === 2 && (l += 60), l;
      },
      enumerable: !1
    },
    rgbToAnsi: {
      value: /* @__PURE__ */ n((o, e, r) => d.ansi256ToAnsi(d.rgbToAnsi256(o, e, r)), "value"),
      enumerable: !1
    },
    hexToAnsi: {
      value: /* @__PURE__ */ n((o) => d.ansi256ToAnsi(d.hexToAnsi256(o)), "value"),
      enumerable: !1
    }
  }), d;
}
n(ve, "assembleStyles");
var Ne = ve(), h = Ne;

// node_modules/chalk/source/vendor/supports-color/index.js
import S from "node:process";
import Le from "node:os";
import F from "node:tty";
function f(t, o = globalThis.Deno ? globalThis.Deno.args : S.argv) {
  let e = t.startsWith("-") ? "" : t.length === 1 ? "-" : "--", r = o.indexOf(e + t), s = o.indexOf("--");
  return r !== -1 && (s === -1 || r < s);
}
n(f, "hasFlag");
var { env: p } = S, T;
f("no-color") || f("no-colors") || f("color=false") || f("color=never") ? T = 0 : (f("color") || f("colors") || f("color=true") || f("color=\
always")) && (T = 1);
function Be() {
  if ("FORCE_COLOR" in p)
    return p.FORCE_COLOR === "true" ? 1 : p.FORCE_COLOR === "false" ? 0 : p.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(p.FORCE_COLOR,
    10), 3);
}
n(Be, "envForceColor");
function We(t) {
  return t === 0 ? !1 : {
    level: t,
    hasBasic: !0,
    has256: t >= 2,
    has16m: t >= 3
  };
}
n(We, "translateLevel");
function Fe(t, { streamIsTTY: o, sniffFlags: e = !0 } = {}) {
  let r = Be();
  r !== void 0 && (T = r);
  let s = e ? T : r;
  if (s === 0)
    return 0;
  if (e) {
    if (f("color=16m") || f("color=full") || f("color=truecolor"))
      return 3;
    if (f("color=256"))
      return 2;
  }
  if ("TF_BUILD" in p && "AGENT_NAME" in p)
    return 1;
  if (t && !o && s === void 0)
    return 0;
  let c = s || 0;
  if (p.TERM === "dumb")
    return c;
  if (S.platform === "win32") {
    let l = Le.release().split(".");
    return Number(l[0]) >= 10 && Number(l[2]) >= 10586 ? Number(l[2]) >= 14931 ? 3 : 2 : 1;
  }
  if ("CI" in p)
    return "GITHUB_ACTIONS" in p || "GITEA_ACTIONS" in p ? 3 : ["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((l) => l in
    p) || p.CI_NAME === "codeship" ? 1 : c;
  if ("TEAMCITY_VERSION" in p)
    return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(p.TEAMCITY_VERSION) ? 1 : 0;
  if (p.COLORTERM === "truecolor" || p.TERM === "xterm-kitty")
    return 3;
  if ("TERM_PROGRAM" in p) {
    let l = Number.parseInt((p.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
    switch (p.TERM_PROGRAM) {
      case "iTerm.app":
        return l >= 3 ? 3 : 2;
      case "Apple_Terminal":
        return 2;
    }
  }
  return /-256(color)?$/i.test(p.TERM) ? 2 : /^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(p.TERM) || "COLORTERM" in p ?
  1 : c;
}
n(Fe, "_supportsColor");
function K(t, o = {}) {
  let e = Fe(t, {
    streamIsTTY: t && t.isTTY,
    ...o
  });
  return We(e);
}
n(K, "createSupportsColor");
var Ke = {
  stdout: K({ isTTY: F.isatty(1) }),
  stderr: K({ isTTY: F.isatty(2) })
}, P = Ke;

// node_modules/chalk/source/utilities.js
function j(t, o, e) {
  let r = t.indexOf(o);
  if (r === -1)
    return t;
  let s = o.length, c = 0, l = "";
  do
    l += t.slice(c, r) + o + e, c = r + s, r = t.indexOf(o, c);
  while (r !== -1);
  return l += t.slice(c), l;
}
n(j, "stringReplaceAll");
function V(t, o, e, r) {
  let s = 0, c = "";
  do {
    let l = t[r - 1] === "\r";
    c += t.slice(s, l ? r - 1 : r) + o + (l ? `\r
` : `
`) + e, s = r + 1, r = t.indexOf(`
`, s);
  } while (r !== -1);
  return c += t.slice(s), c;
}
n(V, "stringEncaseCRLFWithFirstIndex");

// node_modules/chalk/source/index.js
var { stdout: $, stderr: D } = P, w = Symbol("GENERATOR"), E = Symbol("STYLER"), A = Symbol("IS_EMPTY"), G = [
  "ansi",
  "ansi",
  "ansi256",
  "ansi16m"
], R = /* @__PURE__ */ Object.create(null), Pe = /* @__PURE__ */ n((t, o = {}) => {
  if (o.level && !(Number.isInteger(o.level) && o.level >= 0 && o.level <= 3))
    throw new Error("The `level` option should be an integer from 0 to 3");
  let e = $ ? $.level : 0;
  t.level = o.level === void 0 ? e : o.level;
}, "applyOptions");
var je = /* @__PURE__ */ n((t) => {
  let o = /* @__PURE__ */ n((...e) => e.join(" "), "chalk");
  return Pe(o, t), Object.setPrototypeOf(o, k.prototype), o;
}, "chalkFactory");
function k(t) {
  return je(t);
}
n(k, "createChalk");
Object.setPrototypeOf(k.prototype, Function.prototype);
for (let [t, o] of Object.entries(h))
  R[t] = {
    get() {
      let e = x(this, N(o.open, o.close, this[E]), this[A]);
      return Object.defineProperty(this, t, { value: e }), e;
    }
  };
R.visible = {
  get() {
    let t = x(this, this[E], !0);
    return Object.defineProperty(this, "visible", { value: t }), t;
  }
};
var v = /* @__PURE__ */ n((t, o, e, ...r) => t === "rgb" ? o === "ansi16m" ? h[e].ansi16m(...r) : o === "ansi256" ? h[e].ansi256(h.rgbToAnsi256(
...r)) : h[e].ansi(h.rgbToAnsi(...r)) : t === "hex" ? v("rgb", o, e, ...h.hexToRgb(...r)) : h[e][t](...r), "getModelAnsi"), Ve = ["rgb", "he\
x", "ansi256"];
for (let t of Ve) {
  R[t] = {
    get() {
      let { level: e } = this;
      return function(...r) {
        let s = N(v(t, G[e], "color", ...r), h.color.close, this[E]);
        return x(this, s, this[A]);
      };
    }
  };
  let o = "bg" + t[0].toUpperCase() + t.slice(1);
  R[o] = {
    get() {
      let { level: e } = this;
      return function(...r) {
        let s = N(v(t, G[e], "bgColor", ...r), h.bgColor.close, this[E]);
        return x(this, s, this[A]);
      };
    }
  };
}
var $e = Object.defineProperties(() => {
}, {
  ...R,
  level: {
    enumerable: !0,
    get() {
      return this[w].level;
    },
    set(t) {
      this[w].level = t;
    }
  }
}), N = /* @__PURE__ */ n((t, o, e) => {
  let r, s;
  return e === void 0 ? (r = t, s = o) : (r = e.openAll + t, s = o + e.closeAll), {
    open: t,
    close: o,
    openAll: r,
    closeAll: s,
    parent: e
  };
}, "createStyler"), x = /* @__PURE__ */ n((t, o, e) => {
  let r = /* @__PURE__ */ n((...s) => De(r, s.length === 1 ? "" + s[0] : s.join(" ")), "builder");
  return Object.setPrototypeOf(r, $e), r[w] = t, r[E] = o, r[A] = e, r;
}, "createBuilder"), De = /* @__PURE__ */ n((t, o) => {
  if (t.level <= 0 || !o)
    return t[A] ? "" : o;
  let e = t[E];
  if (e === void 0)
    return o;
  let { openAll: r, closeAll: s } = e;
  if (o.includes("\x1B"))
    for (; e !== void 0; )
      o = j(o, e.close, e.open), e = e.parent;
  let c = o.indexOf(`
`);
  return c !== -1 && (o = V(o, s, r, c)), r + o + s;
}, "applyStyle");
Object.defineProperties(k.prototype, R);
var Ge = k(), ao = k({ level: D ? D.level : 0 });
var m = Ge;

// src/server-errors.ts
var u = Ie(Y(), 1);

// src/storybook-error.ts
function H({
  code: t,
  category: o
}) {
  let e = String(t).padStart(4, "0");
  return `SB_${o}_${e}`;
}
n(H, "parseErrorCode");
var a = class t extends Error {
  constructor(e) {
    super(t.getFullMessage(e));
    /**
     * Data associated with the error. Used to provide additional information in the error message or to be passed to telemetry.
     */
    this.data = {};
    /**
     * Flag used to easily determine if the error originates from Storybook.
     */
    this.fromStorybook = !0;
    this.category = e.category, this.documentation = e.documentation ?? !1, this.code = e.code;
  }
  static {
    n(this, "StorybookError");
  }
  get fullErrorCode() {
    return H({ code: this.code, category: this.category });
  }
  /**
   * Overrides the default `Error.name` property in the format: SB_<CATEGORY>_<CODE>.
   */
  get name() {
    let e = this.constructor.name;
    return `${this.fullErrorCode} (${e})`;
  }
  /**
   * Generates the error message along with additional documentation link (if applicable).
   */
  static getFullMessage({
    documentation: e,
    code: r,
    category: s,
    message: c
  }) {
    let l;
    return e === !0 ? l = `https://storybook.js.org/error/${H({ code: r, category: s })}` : typeof e == "string" ? l = e : Array.isArray(e) &&
    (l = `
${e.map((g) => `	- ${g}`).join(`
`)}`), `${c}${l != null ? `

More info: ${l}
` : ""}`;
  }
};

// src/server-errors.ts
var Ue = /* @__PURE__ */ ((i) => (i.CLI = "CLI", i.CLI_INIT = "CLI_INIT", i.CLI_AUTOMIGRATE = "CLI_AUTOMIGRATE", i.CLI_UPGRADE = "CLI_UPGRAD\
E", i.CLI_ADD = "CLI_ADD", i.CODEMOD = "CODEMOD", i.CORE_SERVER = "CORE-SERVER", i.CSF_PLUGIN = "CSF-PLUGIN", i.CSF_TOOLS = "CSF-TOOLS", i.CORE_COMMON =
"CORE-COMMON", i.NODE_LOGGER = "NODE-LOGGER", i.TELEMETRY = "TELEMETRY", i.BUILDER_MANAGER = "BUILDER-MANAGER", i.BUILDER_VITE = "BUILDER-VI\
TE", i.BUILDER_WEBPACK5 = "BUILDER-WEBPACK5", i.SOURCE_LOADER = "SOURCE-LOADER", i.POSTINSTALL = "POSTINSTALL", i.DOCS_TOOLS = "DOCS-TOOLS",
i.CORE_WEBPACK = "CORE-WEBPACK", i.FRAMEWORK_ANGULAR = "FRAMEWORK_ANGULAR", i.FRAMEWORK_EMBER = "FRAMEWORK_EMBER", i.FRAMEWORK_HTML_VITE = "\
FRAMEWORK_HTML-VITE", i.FRAMEWORK_HTML_WEBPACK5 = "FRAMEWORK_HTML-WEBPACK5", i.FRAMEWORK_NEXTJS = "FRAMEWORK_NEXTJS", i.FRAMEWORK_PREACT_VITE =
"FRAMEWORK_PREACT-VITE", i.FRAMEWORK_PREACT_WEBPACK5 = "FRAMEWORK_PREACT-WEBPACK5", i.FRAMEWORK_REACT_VITE = "FRAMEWORK_REACT-VITE", i.FRAMEWORK_REACT_WEBPACK5 =
"FRAMEWORK_REACT-WEBPACK5", i.FRAMEWORK_SERVER_WEBPACK5 = "FRAMEWORK_SERVER-WEBPACK5", i.FRAMEWORK_SVELTE_VITE = "FRAMEWORK_SVELTE-VITE", i.
FRAMEWORK_SVELTE_WEBPACK5 = "FRAMEWORK_SVELTE-WEBPACK5", i.FRAMEWORK_SVELTEKIT = "FRAMEWORK_SVELTEKIT", i.FRAMEWORK_VUE_VITE = "FRAMEWORK_VU\
E-VITE", i.FRAMEWORK_VUE_WEBPACK5 = "FRAMEWORK_VUE-WEBPACK5", i.FRAMEWORK_VUE3_VITE = "FRAMEWORK_VUE3-VITE", i.FRAMEWORK_VUE3_WEBPACK5 = "FR\
AMEWORK_VUE3-WEBPACK5", i.FRAMEWORK_WEB_COMPONENTS_VITE = "FRAMEWORK_WEB-COMPONENTS-VITE", i.FRAMEWORK_WEB_COMPONENTS_WEBPACK5 = "FRAMEWORK_\
WEB-COMPONENTS-WEBPACK5", i))(Ue || {}), X = class extends a {
  static {
    n(this, "NxProjectDetectedError");
  }
  constructor() {
    super({
      category: "CLI_INIT",
      code: 1,
      documentation: "https://nx.dev/packages/storybook",
      message: u.dedent`
        We have detected Nx in your project. Nx has its own Storybook initializer, so please use it instead.
        Run "nx g @nx/storybook:configuration" to add Storybook to your project.`
    });
  }
}, z = class extends a {
  static {
    n(this, "MissingFrameworkFieldError");
  }
  constructor() {
    super({
      category: "CORE-COMMON",
      code: 1,
      documentation: "https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#new-framework-api",
      message: u.dedent`
        Could not find a 'framework' field in Storybook config.
        
        Please run 'npx storybook automigrate' to automatically fix your config.`
    });
  }
}, J = class extends a {
  constructor(e) {
    super({
      category: "CORE-COMMON",
      code: 2,
      documentation: "https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#new-framework-api",
      message: u.dedent`
        Invalid value of '${e.frameworkName}' in the 'framework' field of Storybook config.
        
        Please run 'npx storybook automigrate' to automatically fix your config.
      `
    });
    this.data = e;
  }
  static {
    n(this, "InvalidFrameworkNameError");
  }
}, q = class extends a {
  constructor(e) {
    super({
      category: "CORE-COMMON",
      code: 3,
      documentation: "",
      message: u.dedent`
        Could not evaluate the '${e.frameworkName}' package from the 'framework' field of Storybook config.
        
        Are you sure it's a valid package and is installed?`
    });
    this.data = e;
  }
  static {
    n(this, "CouldNotEvaluateFrameworkError");
  }
}, Q = class extends a {
  static {
    n(this, "ConflictingStaticDirConfigError");
  }
  constructor() {
    super({
      category: "CORE-SERVER",
      code: 1,
      documentation: "https://storybook.js.org/docs/react/configure/images-and-assets#serving-static-files-via-storybook-configuration",
      message: u.dedent`
        Storybook encountered a conflict when trying to serve statics. You have configured both:
        * Storybook's option in the config file: 'staticDirs'
        * Storybook's (deprecated) CLI flag: '--staticDir' or '-s'
        
        Please remove the CLI flag from your storybook script and use only the 'staticDirs' option instead.`
    });
  }
}, Z = class extends a {
  static {
    n(this, "InvalidStoriesEntryError");
  }
  constructor() {
    super({
      category: "CORE-COMMON",
      code: 4,
      documentation: "https://storybook.js.org/docs/react/faq#can-i-have-a-storybook-with-no-local-stories",
      message: u.dedent`
        Storybook could not index your stories.
        Your main configuration somehow does not contain a 'stories' field, or it resolved to an empty array.
        
        Please check your main configuration file and make sure it exports a 'stories' field that is not an empty array.`
    });
  }
}, ee = class extends a {
  static {
    n(this, "WebpackMissingStatsError");
  }
  constructor() {
    super({
      category: "BUILDER-WEBPACK5",
      code: 1,
      documentation: [
        "https://webpack.js.org/configuration/stats/",
        "https://storybook.js.org/docs/react/builders/webpack#configure"
      ],
      message: u.dedent`
        No Webpack stats found. Did you turn off stats reporting in your Webpack config?
        Storybook needs Webpack stats (including errors) in order to build correctly.`
    });
  }
}, oe = class extends a {
  constructor(e) {
    super({
      category: "BUILDER-WEBPACK5",
      code: 2,
      message: e.error.message.trim()
    });
    this.data = e;
  }
  static {
    n(this, "WebpackInvocationError");
  }
};
function te(t = "") {
  return t.replace(/\u001B\[[0-9;]*m/g, "");
}
n(te, "removeAnsiEscapeCodes");
var re = class extends a {
  constructor(e) {
    e.errors = e.errors.map((r) => ({
      ...r,
      message: te(r.message),
      stack: te(r.stack),
      name: r.name
    }));
    super({
      category: "BUILDER-WEBPACK5",
      code: 3,
      // This error message is a followup of errors logged by Webpack to the user
      message: u.dedent`
        There were problems when compiling your code with Webpack.
        Run Storybook with --debug-webpack for more information.
      `
    });
    this.data = e;
  }
  static {
    n(this, "WebpackCompilationError");
  }
}, ne = class extends a {
  constructor(e) {
    super({
      category: "CLI_INIT",
      code: 2,
      documentation: "https://storybook.js.org/docs/angular/faq#error-no-angularjson-file-found",
      message: u.dedent`
        An angular.json file was not found in the current working directory: ${e.path}
        Storybook needs it to work properly, so please rerun the command at the root of your project, where the angular.json file is located.`
    });
    this.data = e;
  }
  static {
    n(this, "MissingAngularJsonError");
  }
}, se = class extends a {
  static {
    n(this, "AngularLegacyBuildOptionsError");
  }
  constructor() {
    super({
      category: "FRAMEWORK_ANGULAR",
      code: 1,
      documentation: [
        "https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#angular-drop-support-for-calling-storybook-directly",
        "https://github.com/storybookjs/storybook/tree/next/code/frameworks/angular#how-do-i-migrate-to-an-angular-storybook-builder"
      ],
      message: u.dedent`
        Your Storybook startup script uses a solution that is not supported anymore.
        You must use Angular builder to have an explicit configuration on the project used in angular.json.
        
        Please run 'npx storybook automigrate' to automatically fix your config.`
    });
  }
}, ie = class extends a {
  constructor(e) {
    super({
      category: "CORE-SERVER",
      code: 2,
      documentation: "",
      message: u.dedent`
        Storybook failed to load the following preset: ${e.presetName}.
        
        Please check whether your setup is correct, the Storybook dependencies (and their peer dependencies) are installed correctly and there are no package version clashes.
        
        If you believe this is a bug, please open an issue on Github.
        
        ${e.error.stack || e.error.message}`
    });
    this.data = e;
  }
  static {
    n(this, "CriticalPresetLoadError");
  }
}, ae = class extends a {
  static {
    n(this, "MissingBuilderError");
  }
  constructor() {
    super({
      category: "CORE-SERVER",
      code: 3,
      documentation: "https://github.com/storybookjs/storybook/issues/24071",
      message: u.dedent`
        Storybook could not find a builder configuration for your project. 
        Builders normally come from a framework package e.g. '@storybook/react-vite', or from builder packages e.g. '@storybook/builder-vite'.
        
        - Does your main config file contain a 'framework' field configured correctly?
        - Is the Storybook framework package installed correctly?
        - If you don't use a framework, does your main config contain a 'core.builder' configured correctly?
        - Are you in a monorepo and perhaps the framework package is hoisted incorrectly?
        
        If you believe this is a bug, please describe your issue in detail on Github.`
    });
  }
}, ce = class extends a {
  constructor(e) {
    super({
      category: "FRAMEWORK_NEXTJS",
      code: 1,
      documentation: "https://github.com/storybookjs/storybook/blob/next/code/frameworks/nextjs/README.md#nextjs-font-optimization",
      message: u.dedent`
        Failed to fetch \`${e.fontFamily}\` from Google Fonts with URL: \`${e.url}\``
    });
    this.data = e;
  }
  static {
    n(this, "GoogleFontsDownloadError");
  }
}, le = class extends a {
  constructor(e) {
    super({
      category: "FRAMEWORK_NEXTJS",
      code: 2,
      documentation: "https://github.com/storybookjs/storybook/blob/next/code/frameworks/nextjs/README.md#nextjs-font-optimization",
      message: u.dedent`
        An error occurred when trying to load Google Fonts with URL \`${e.url}\`.
        
        ${e.error instanceof Error ? e.error.message : ""}`
    });
    this.data = e;
  }
  static {
    n(this, "GoogleFontsLoadingError");
  }
}, ue = class extends a {
  constructor(e) {
    super({
      category: "CORE-SERVER",
      code: 4,
      documentation: "",
      message: u.dedent`
        There was an exports mismatch error when trying to build Storybook.
        Please check whether the versions of your Storybook packages match whenever possible, as this might be the cause.
        
        Problematic example:
        { "@storybook/react": "7.5.3", "@storybook/react-vite": "7.4.5", "storybook": "7.3.0" }
        
        Correct example:
        { "@storybook/react": "7.5.3", "@storybook/react-vite": "7.5.3", "storybook": "7.5.3" }
        
        Please run \`npx storybook doctor\` for guidance on how to fix this issue.`
    });
    this.data = e;
  }
  static {
    n(this, "NoMatchingExportError");
  }
}, de = class extends a {
  constructor(e) {
    let r = [
      `Storybook failed to load ${e.location}`,
      "",
      "It looks like the file tried to load/import an ESM only module.",
      `Support for this is currently limited in ${e.location}`,
      "You can import ESM modules in your main file, but only as dynamic import.",
      ""
    ];
    e.line && r.push(
      m.white(
        `In your ${m.yellow(e.location)} file, line ${m.bold.cyan(
          e.num
        )} threw an error:`
      ),
      m.grey(e.line)
    ), r.push(
      "",
      m.white(
        `Convert the static import to a dynamic import ${m.underline("where they are used")}.`
      ),
      m.white("Example:") + " " + m.gray("await import(<your ESM only module>);"),
      ""
    );
    super({
      category: "CORE-SERVER",
      code: 5,
      documentation: "https://github.com/storybookjs/storybook/issues/23972#issuecomment-1948534058",
      message: r.join(`
`)
    });
    this.data = e;
  }
  static {
    n(this, "MainFileESMOnlyImportError");
  }
}, pe = class extends a {
  constructor(e) {
    let r = {
      storybook: {
        helperMessage: "You can pass a --config-dir flag to tell Storybook, where your main.js file is located at.",
        documentation: "https://storybook.js.org/docs/configure"
      },
      vitest: {
        helperMessage: "You can pass a configDir plugin option to tell where your main.js file is located at.",
        // TODO: add proper docs once available
        documentation: "https://storybook.js.org/docs/configure"
      }
    }, { documentation: s, helperMessage: c } = r[e.source || "storybook"];
    super({
      category: "CORE-SERVER",
      code: 6,
      documentation: s,
      message: u.dedent`
        No configuration files have been found in your configDir: ${m.yellow(e.location)}.
        Storybook needs a "main.js" file, please add it.
        
        ${c}`
    });
    this.data = e;
  }
  static {
    n(this, "MainFileMissingError");
  }
}, ge = class extends a {
  constructor(e) {
    let r = m.white(
      (e.error.stack || e.error.message).replaceAll(process.cwd(), "")
    );
    super({
      category: "CORE-SERVER",
      code: 7,
      message: u.dedent`
        Storybook couldn't evaluate your ${m.yellow(e.location)} file.
        
        Original error:
        ${r}`
    });
    this.data = e;
  }
  static {
    n(this, "MainFileEvaluationError");
  }
}, fe = class extends a {
  constructor(e) {
    super({
      category: "CLI_INIT",
      code: 3,
      documentation: "",
      message: u.dedent`
        There was an error while using ${e.packageManager} to create a new ${e.projectType} project.
        
        ${e.error instanceof Error ? e.error.message : ""}`
    });
    this.data = e;
  }
  static {
    n(this, "GenerateNewProjectOnInitError");
  }
}, me = class extends a {
  constructor(e) {
    super({
      category: "CLI_UPGRADE",
      code: 3,
      message: u.dedent`
        You are trying to upgrade Storybook to a lower version than the version currently installed. This is not supported.
        
        Storybook version ${e.beforeVersion} was detected in your project, but you are trying to "upgrade" to version ${e.currentVersion}.
        
        This usually happens when running the upgrade command without a version specifier, e.g. "npx storybook upgrade".
        This will cause npm to run the globally cached storybook binary, which might be an older version.
        
        Instead you should always run the Storybook CLI with a version specifier to force npm to download the latest version:
        
        "npx storybook@latest upgrade"`
    });
    this.data = e;
  }
  static {
    n(this, "UpgradeStorybookToLowerVersionError");
  }
}, he = class extends a {
  constructor(e) {
    super({
      category: "CLI_UPGRADE",
      code: 4,
      message: u.dedent`
        You are upgrading Storybook to the same version that is currently installed in the project, version ${e.beforeVersion}.
        
        This usually happens when running the upgrade command without a version specifier, e.g. "npx storybook upgrade".
        This will cause npm to run the globally cached storybook binary, which might be the same version that you already have.
        This also happens if you're running the Storybook CLI that is locally installed in your project.
        
        If you intended to upgrade to the latest version, you should always run the Storybook CLI with a version specifier to force npm to download the latest version:
        
        "npx storybook@latest upgrade"
        
        If you intended to re-run automigrations, you should run the "automigrate" command directly instead:
        
        "npx storybook automigrate"`
    });
    this.data = e;
  }
  static {
    n(this, "UpgradeStorybookToSameVersionError");
  }
}, ye = class extends a {
  static {
    n(this, "UpgradeStorybookUnknownCurrentVersionError");
  }
  constructor() {
    super({
      category: "CLI_UPGRADE",
      code: 5,
      message: u.dedent`
        We couldn't determine the current version of Storybook in your project.
        
        Are you running the Storybook CLI in a project without Storybook?
        It might help if you specify your Storybook config directory with the --config-dir flag.`
    });
  }
}, be = class extends a {
  static {
    n(this, "UpgradeStorybookInWrongWorkingDirectory");
  }
  constructor() {
    super({
      category: "CLI_UPGRADE",
      code: 6,
      message: u.dedent`
        You are running the upgrade command in a CWD that does not contain Storybook dependencies.
        
        Did you mean to run it in a different directory? Make sure the directory you run this command in contains a package.json with your Storybook dependencies.`
    });
  }
}, Ee = class extends a {
  static {
    n(this, "NoStatsForViteDevError");
  }
  constructor() {
    super({
      category: "BUILDER-VITE",
      code: 1,
      message: u.dedent`
        Unable to write preview stats as the Vite builder does not support stats in dev mode.
        
        Please remove the \`--stats-json\` flag when running in dev mode.`
    });
  }
}, Re = class extends a {
  constructor(e) {
    super({
      category: "CLI",
      code: 1,
      message: u.dedent`
        Unable to find versions of "${e.packageName}" using ${e.packageManager}
        ${e.error && `Reason: ${e.error}`}`
    });
    this.data = e;
  }
  static {
    n(this, "FindPackageVersionsError");
  }
};
export {
  se as AngularLegacyBuildOptionsError,
  Ue as Category,
  Q as ConflictingStaticDirConfigError,
  q as CouldNotEvaluateFrameworkError,
  ie as CriticalPresetLoadError,
  Re as FindPackageVersionsError,
  fe as GenerateNewProjectOnInitError,
  ce as GoogleFontsDownloadError,
  le as GoogleFontsLoadingError,
  J as InvalidFrameworkNameError,
  Z as InvalidStoriesEntryError,
  de as MainFileESMOnlyImportError,
  ge as MainFileEvaluationError,
  pe as MainFileMissingError,
  ne as MissingAngularJsonError,
  ae as MissingBuilderError,
  z as MissingFrameworkFieldError,
  ue as NoMatchingExportError,
  Ee as NoStatsForViteDevError,
  X as NxProjectDetectedError,
  be as UpgradeStorybookInWrongWorkingDirectory,
  me as UpgradeStorybookToLowerVersionError,
  he as UpgradeStorybookToSameVersionError,
  ye as UpgradeStorybookUnknownCurrentVersionError,
  re as WebpackCompilationError,
  oe as WebpackInvocationError,
  ee as WebpackMissingStatsError
};
