import {
  a as o
} from "./chunk-IO47FP3U.js";

// src/storybook-error.ts
function s({
  code: c,
  category: n
}) {
  let r = String(c).padStart(4, "0");
  return `SB_${n}_${r}`;
}
o(s, "parseErrorCode");
var t = class t extends Error {
  constructor(r) {
    super(t.getFullMessage(r));
    /**
     * 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 = r.category, this.documentation = r.documentation ?? !1, this.code = r.code;
  }
  get fullErrorCode() {
    return s({ code: this.code, category: this.category });
  }
  /** Overrides the default `Error.name` property in the format: SB_<CATEGORY>_<CODE>. */
  get name() {
    let r = this.constructor.name;
    return `${this.fullErrorCode} (${r})`;
  }
  /** Generates the error message along with additional documentation link (if applicable). */
  static getFullMessage({
    documentation: r,
    code: i,
    category: g,
    message: l
  }) {
    let e;
    return r === !0 ? e = `https://storybook.js.org/error/${s({ code: i, category: g })}` : typeof r == "string" ? e = r : Array.isArray(r) && (e = `
${r.map((d) => `	- ${d}`).join(`
`)}`), `${l}${e != null ? `

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

export {
  a
};
