var F = Object.defineProperty;
var t = (c, e) => F(c, "name", { value: e, configurable: !0 });

// ../node_modules/ts-dedent/esm/index.js
function n(c) {
  for (var e = [], r = 1; r < arguments.length; r++)
    e[r - 1] = arguments[r];
  var s = Array.from(typeof c == "string" ? [c] : c);
  s[s.length - 1] = s[s.length - 1].replace(/\r?\n([\t ]*)$/, "");
  var W = s.reduce(function(i, h) {
    var u = h.match(/\n([\t ]+|(?!\s).)/g);
    return u ? i.concat(u.map(function(E) {
      var d, l;
      return (l = (d = E.match(/[\t ]/g)) === null || d === void 0 ? void 0 : d.length) !== null && l !== void 0 ? l : 0;
    })) : i;
  }, []);
  if (W.length) {
    var Y = new RegExp(`
[	 ]{` + Math.min.apply(Math, W) + "}", "g");
    s = s.map(function(i) {
      return i.replace(Y, `
`);
    });
  }
  s[0] = s[0].replace(/^\r?\n/, "");
  var y = s[0];
  return e.forEach(function(i, h) {
    var u = y.match(/(?:^|\n)( *)$/), E = u ? u[1] : "", d = i;
    typeof i == "string" && i.includes(`
`) && (d = String(i).split(`
`).map(function(l, K) {
      return K === 0 ? l : "" + E + l;
    }).join(`
`)), y += d + s[h + 1];
  }), y;
}
t(n, "dedent");

// src/storybook-error.ts
var p = class p extends Error {
  /**
   * Data associated with the error. Used to provide additional information in the error message or to be passed to telemetry.
   */
  data = {};
  /**
   * Specifies the documentation for the error.
   * - If `true`, links to a documentation page on the Storybook website (make sure it exists before enabling).
   * - If a string, uses the provided URL for documentation (external or FAQ links).
   * - If `false` (default), no documentation link is added.
   */
  documentation = !1;
  /**
   * Flag used to easily determine if the error originates from Storybook.
   */
  fromStorybook = !0;
  get fullErrorCode() {
    let e = String(this.code).padStart(4, "0");
    return `SB_${this.category}_${e}`;
  }
  /**
   * 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).
   */
  get message() {
    let e;
    return this.documentation === !0 ? e = `https://storybook.js.org/error/${this.fullErrorCode}` : typeof this.documentation == "string" ? e =
    this.documentation : Array.isArray(this.documentation) && (e = `
${this.documentation.map((r) => `	- ${r}`).join(`
`)}`), `${this.template()}${e != null ? `

More info: ${e}
` : ""}`;
  }
};
t(p, "StorybookError");
var a = p;

// src/preview-errors.ts
var J = /* @__PURE__ */ ((o) => (o.DOCS_TOOLS = "DOCS-TOOLS", o.PREVIEW_CLIENT_LOGGER = "PREVIEW_CLIENT-LOGGER", o.PREVIEW_CHANNELS = "PREVI\
EW_CHANNELS", o.PREVIEW_CORE_EVENTS = "PREVIEW_CORE-EVENTS", o.PREVIEW_INSTRUMENTER = "PREVIEW_INSTRUMENTER", o.PREVIEW_API = "PREVIEW_API",
o.PREVIEW_REACT_DOM_SHIM = "PREVIEW_REACT-DOM-SHIM", o.PREVIEW_ROUTER = "PREVIEW_ROUTER", o.PREVIEW_THEMING = "PREVIEW_THEMING", o.RENDERER_HTML =
"RENDERER_HTML", o.RENDERER_PREACT = "RENDERER_PREACT", o.RENDERER_REACT = "RENDERER_REACT", o.RENDERER_SERVER = "RENDERER_SERVER", o.RENDERER_SVELTE =
"RENDERER_SVELTE", o.RENDERER_VUE = "RENDERER_VUE", o.RENDERER_VUE3 = "RENDERER_VUE3", o.RENDERER_WEB_COMPONENTS = "RENDERER_WEB-COMPONENTS",
o.FRAMEWORK_NEXTJS = "FRAMEWORK_NEXTJS", o))(J || {}), m = class m extends a {
  constructor(r) {
    super();
    this.data = r;
  }
  category = "PREVIEW_API";
  code = 1;
  template() {
    return n`
    Couldn't find story matching id '${this.data.storyId}' after HMR.
    - Did you just rename a story?
    - Did you remove it from your CSF file?
    - Are you sure a story with the id '${this.data.storyId}' exists?
    - Please check the values in the stories field of your main.js config and see if they would match your CSF File.
    - Also check the browser console and terminal for potential error messages.`;
  }
};
t(m, "MissingStoryAfterHmrError");
var w = m, R = class R extends a {
  constructor(r) {
    super();
    this.data = r;
  }
  category = "PREVIEW_API";
  code = 2;
  documentation = "https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#using-implicit-actions-during-rendering-is-deprecated-for\
-example-in-the-play-function";
  template() {
    return n`
      We detected that you use an implicit action arg while ${this.data.phase} of your story.  
      ${this.data.deprecated ? `
This is deprecated and won't work in Storybook 8 anymore.
` : ""}
      Please provide an explicit spy to your args like this:
        import { fn } from '@storybook/test';
        ... 
        args: {
         ${this.data.name}: fn()
        }
    `;
  }
};
t(R, "ImplicitActionsDuringRendering");
var v = R, g = class g extends a {
  category = "PREVIEW_API";
  code = 3;
  template() {
    return n`
    Cannot call \`storyStore.extract()\` without calling \`storyStore.cacheAllCsfFiles()\` first.

    You probably meant to call \`await preview.extract()\` which does the above for you.`;
  }
};
t(g, "CalledExtractOnStoreError");
var $ = g, f = class f extends a {
  category = "PREVIEW_API";
  code = 4;
  documentation = "https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#mainjs-framework-field";
  template() {
    return n`
      Expected your framework's preset to export a \`renderToCanvas\` field.

      Perhaps it needs to be upgraded for Storybook 6.4?`;
  }
};
t(f, "MissingRenderToCanvasError");
var A = f, b = class b extends a {
  constructor(r) {
    super();
    this.data = r;
  }
  category = "PREVIEW_API";
  code = 5;
  template() {
    return n`
      Called \`Preview.${this.data.methodName}()\` before initialization.
      
      The preview needs to load the story index before most methods can be called. If you want
      to call \`${this.data.methodName}\`, try \`await preview.initializationPromise;\` first.
      
      If you didn't call the above code, then likely it was called by an addon that needs to
      do the above.`;
  }
};
t(b, "CalledPreviewMethodBeforeInitializationError");
var O = b, I = class I extends a {
  constructor(r) {
    super();
    this.data = r;
  }
  category = "PREVIEW_API";
  code = 6;
  template() {
    return n`
      Error fetching \`/index.json\`:
      
      ${this.data.text}

      If you are in development, this likely indicates a problem with your Storybook process,
      check the terminal for errors.

      If you are in a deployed Storybook, there may have been an issue deploying the full Storybook
      build.`;
  }
};
t(I, "StoryIndexFetchError");
var D = I, P = class P extends a {
  constructor(r) {
    super();
    this.data = r;
  }
  category = "PREVIEW_API";
  code = 7;
  template() {
    return n`
      Tried to render docs entry ${this.data.storyId} but it is a MDX file that has no CSF
      references, or autodocs for a CSF file that some doesn't refer to itself.
      
      This likely is an internal error in Storybook's indexing, or you've attached the
      \`attached-mdx\` tag to an MDX file that is not attached.`;
  }
};
t(P, "MdxFileWithNoCsfReferencesError");
var C = P, x = class x extends a {
  category = "PREVIEW_API";
  code = 8;
  template() {
    return n`
      Couldn't find any stories in your Storybook.

        - Please check your stories field of your main.js config: does it match correctly?
        - Also check the browser console and terminal for error messages.`;
  }
};
t(x, "EmptyIndexError");
var j = x, _ = class _ extends a {
  constructor(r) {
    super();
    this.data = r;
  }
  category = "PREVIEW_API";
  code = 9;
  template() {
    return n`
      Couldn't find story matching '${this.data.storySpecifier}'.

        - Are you sure a story with that id exists?
        - Please check your stories field of your main.js config.
        - Also check the browser console and terminal for error messages.`;
  }
};
t(_, "NoStoryMatchError");
var L = _, T = class T extends a {
  constructor(r) {
    super();
    this.data = r;
  }
  category = "PREVIEW_API";
  code = 10;
  template() {
    return n`
    Couldn't find story matching id '${this.data.storyId}' after importing a CSF file.

    The file was indexed as if the story was there, but then after importing the file in the browser
    we didn't find the story. Possible reasons:
    - You are using a custom story indexer that is misbehaving.
    - You have a custom file loader that is removing or renaming exports.

    Please check your browser console and terminal for errors that may explain the issue.`;
  }
};
t(T, "MissingStoryFromCsfFileError");
var M = T, V = class V extends a {
  category = "PREVIEW_API";
  code = 11;
  template() {
    return n`
    Cannot access the Story Store until the index is ready.

    It is not recommended to use methods directly on the Story Store anyway, in Storybook 9 we will
    remove access to the store entirely`;
  }
};
t(V, "StoryStoreAccessedBeforeInitializationError");
var G = V, S = class S extends a {
  category = "FRAMEWORK_NEXTJS";
  code = 1;
  documentation = "https://storybook.js.org/docs/get-started/nextjs#faq";
  template() {
    return n`
    You are importing avif images, but you don't have sharp installed.

    You have to install sharp in order to use image optimization features in Next.js.
    `;
  }
};
t(S, "NextJsSharpError");
var H = S, N = class N extends a {
  constructor(r) {
    super();
    this.data = r;
  }
  category = "FRAMEWORK_NEXTJS";
  code = 2;
  template() {
    return n`
      Tried to access router mocks from "${this.data.importType}" but they were not created yet. You might be running code in an unsupported environment.
    `;
  }
};
t(N, "NextjsRouterMocksNotAvailable");
var U = N, k = class k extends a {
  constructor(r) {
    super();
    this.data = r;
  }
  category = "DOCS-TOOLS";
  code = 1;
  documentation = "https://github.com/storybookjs/storybook/issues/26606";
  template() {
    return n`There was a failure when generating detailed ArgTypes in ${this.data.language} for:
    
    ${JSON.stringify(this.data.type, null, 2)} 
    
    Storybook will fall back to use a generic type description instead.

    This type is either not supported or it is a bug in the docgen generation in Storybook.
    If you think this is a bug, please detail it as much as possible in the Github issue.`;
  }
};
t(k, "UnknownArgTypesError");
var X = k;
export {
  $ as CalledExtractOnStoreError,
  O as CalledPreviewMethodBeforeInitializationError,
  J as Category,
  j as EmptyIndexError,
  v as ImplicitActionsDuringRendering,
  C as MdxFileWithNoCsfReferencesError,
  A as MissingRenderToCanvasError,
  w as MissingStoryAfterHmrError,
  M as MissingStoryFromCsfFileError,
  H as NextJsSharpError,
  U as NextjsRouterMocksNotAvailable,
  L as NoStoryMatchError,
  D as StoryIndexFetchError,
  G as StoryStoreAccessedBeforeInitializationError,
  X as UnknownArgTypesError
};
