var cr = Object.create;
var Oe = Object.defineProperty;
var lr = Object.getOwnPropertyDescriptor;
var ur = Object.getOwnPropertyNames;
var mr = Object.getPrototypeOf, yr = Object.prototype.hasOwnProperty;
var r = (n, s) => Oe(n, "name", { value: s, configurable: !0 });
var fr = (n, s) => () => (s || n((s = { exports: {} }).exports, s), s.exports);
var dr = (n, s, a, p) => {
  if (s && typeof s == "object" || typeof s == "function")
    for (let c of ur(s))
      !yr.call(n, c) && c !== a && Oe(n, c, { get: () => s[c], enumerable: !(p = lr(s, c)) || p.enumerable });
  return n;
};
var Tr = (n, s, a) => (a = n != null ? cr(mr(n)) : {}, dr(
  // 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.
  s || !n || !n.__esModule ? Oe(a, "default", { value: n, enumerable: !0 }) : a,
  n
));

// ../node_modules/jsdoc-type-pratt-parser/dist/index.js
var lt = fr((le, ct) => {
  (function(n, s) {
    typeof le == "object" && typeof ct < "u" ? s(le) : typeof define == "function" && define.amd ? define(["exports"], s) : (n = typeof globalThis <
    "u" ? globalThis : n || self, s(n.jtpp = {}));
  })(le, function(n) {
    "use strict";
    function s(e) {
      return e.text !== void 0 && e.text !== "" ? `'${e.type}' with value '${e.text}'` : `'${e.type}'`;
    }
    r(s, "tokenToString");
    class a extends Error {
      static {
        r(this, "NoParsletFoundError");
      }
      constructor(t) {
        super(`No parslet found for token: ${s(t)}`), this.token = t, Object.setPrototypeOf(this, a.prototype);
      }
      getToken() {
        return this.token;
      }
    }
    class p extends Error {
      static {
        r(this, "EarlyEndOfParseError");
      }
      constructor(t) {
        super(`The parsing ended early. The next token was: ${s(t)}`), this.token = t, Object.setPrototypeOf(this, p.prototype);
      }
      getToken() {
        return this.token;
      }
    }
    class c extends Error {
      static {
        r(this, "UnexpectedTypeError");
      }
      constructor(t, o) {
        let i = `Unexpected type: '${t.type}'.`;
        o !== void 0 && (i += ` Message: ${o}`), super(i), Object.setPrototypeOf(this, c.prototype);
      }
    }
    function u(e) {
      return (t) => t.startsWith(e) ? { type: e, text: e } : null;
    }
    r(u, "makePunctuationRule");
    function m(e) {
      let t = 0, o, i = e[0], l = !1;
      if (i !== "'" && i !== '"')
        return null;
      for (; t < e.length; ) {
        if (t++, o = e[t], !l && o === i) {
          t++;
          break;
        }
        l = !l && o === "\\";
      }
      if (o !== i)
        throw new Error("Unterminated String");
      return e.slice(0, t);
    }
    r(m, "getQuoted");
    let T = /[$_\p{ID_Start}]|\\u\p{Hex_Digit}{4}|\\u\{0*(?:\p{Hex_Digit}{1,5}|10\p{Hex_Digit}{4})\}/u, g = /[$\-\p{ID_Continue}\u200C\u200D]|\\u\p{Hex_Digit}{4}|\\u\{0*(?:\p{Hex_Digit}{1,5}|10\p{Hex_Digit}{4})\}/u;
    function w(e) {
      let t = e[0];
      if (!T.test(t))
        return null;
      let o = 1;
      do {
        if (t = e[o], !g.test(t))
          break;
        o++;
      } while (o < e.length);
      return e.slice(0, o);
    }
    r(w, "getIdentifier");
    let b = /^(NaN|-?((\d*\.\d+|\d+)([Ee][+-]?\d+)?|Infinity))/;
    function me(e) {
      var t, o;
      return (o = (t = b.exec(e)) === null || t === void 0 ? void 0 : t[0]) !== null && o !== void 0 ? o : null;
    }
    r(me, "getNumber");
    let $ = /* @__PURE__ */ r((e) => {
      let t = w(e);
      return t == null ? null : {
        type: "Identifier",
        text: t
      };
    }, "identifierRule");
    function E(e) {
      return (t) => {
        if (!t.startsWith(e))
          return null;
        let o = t[e.length];
        return o !== void 0 && g.test(o) ? null : {
          type: e,
          text: e
        };
      };
    }
    r(E, "makeKeyWordRule");
    let X = /* @__PURE__ */ r((e) => {
      let t = m(e);
      return t == null ? null : {
        type: "StringValue",
        text: t
      };
    }, "stringValueRule"), ye = /* @__PURE__ */ r((e) => e.length > 0 ? null : {
      type: "EOF",
      text: ""
    }, "eofRule"), fe = /* @__PURE__ */ r((e) => {
      let t = me(e);
      return t === null ? null : {
        type: "Number",
        text: t
      };
    }, "numberRule"), Dt = [
      ye,
      u("=>"),
      u("("),
      u(")"),
      u("{"),
      u("}"),
      u("["),
      u("]"),
      u("|"),
      u("&"),
      u("<"),
      u(">"),
      u(","),
      u(";"),
      u("*"),
      u("?"),
      u("!"),
      u("="),
      u(":"),
      u("..."),
      u("."),
      u("#"),
      u("~"),
      u("/"),
      u("@"),
      E("undefined"),
      E("null"),
      E("function"),
      E("this"),
      E("new"),
      E("module"),
      E("event"),
      E("external"),
      E("typeof"),
      E("keyof"),
      E("readonly"),
      E("import"),
      E("is"),
      E("in"),
      fe,
      $,
      X
    ], vt = /^\s*\n\s*/;
    class q {
      static {
        r(this, "Lexer");
      }
      static create(t) {
        let o = this.read(t);
        t = o.text;
        let i = this.read(t);
        return t = i.text, new q(t, void 0, o.token, i.token);
      }
      constructor(t, o, i, l) {
        this.text = "", this.text = t, this.previous = o, this.current = i, this.next = l;
      }
      static read(t, o = !1) {
        o = o || vt.test(t), t = t.trim();
        for (let i of Dt) {
          let l = i(t);
          if (l !== null) {
            let y = Object.assign(Object.assign({}, l), { startOfLine: o });
            return t = t.slice(y.text.length), { text: t, token: y };
          }
        }
        throw new Error("Unexpected Token " + t);
      }
      advance() {
        let t = q.read(this.text);
        return new q(t.text, this.current, this.next, t.token);
      }
    }
    function P(e) {
      if (e === void 0)
        throw new Error("Unexpected undefined");
      if (e.type === "JsdocTypeKeyValue" || e.type === "JsdocTypeParameterList" || e.type === "JsdocTypeProperty" || e.type === "JsdocTypeRe\
adonlyProperty" || e.type === "JsdocTypeObjectField" || e.type === "JsdocTypeJsdocObjectField" || e.type === "JsdocTypeIndexSignature" || e.
      type === "JsdocTypeMappedType")
        throw new c(e);
      return e;
    }
    r(P, "assertRootResult");
    function de(e) {
      return e.type === "JsdocTypeKeyValue" ? H(e) : P(e);
    }
    r(de, "assertPlainKeyValueOrRootResult");
    function kt(e) {
      return e.type === "JsdocTypeName" ? e : H(e);
    }
    r(kt, "assertPlainKeyValueOrNameResult");
    function H(e) {
      if (e.type !== "JsdocTypeKeyValue")
        throw new c(e);
      return e;
    }
    r(H, "assertPlainKeyValueResult");
    function At(e) {
      var t;
      if (e.type === "JsdocTypeVariadic") {
        if (((t = e.element) === null || t === void 0 ? void 0 : t.type) === "JsdocTypeName")
          return e;
        throw new c(e);
      }
      if (e.type !== "JsdocTypeNumber" && e.type !== "JsdocTypeName")
        throw new c(e);
      return e;
    }
    r(At, "assertNumberOrVariadicNameResult");
    function Te(e) {
      return e.type === "JsdocTypeIndexSignature" || e.type === "JsdocTypeMappedType";
    }
    r(Te, "isSquaredProperty");
    var f;
    (function(e) {
      e[e.ALL = 0] = "ALL", e[e.PARAMETER_LIST = 1] = "PARAMETER_LIST", e[e.OBJECT = 2] = "OBJECT", e[e.KEY_VALUE = 3] = "KEY_VALUE", e[e.UNION =
      4] = "UNION", e[e.INTERSECTION = 5] = "INTERSECTION", e[e.PREFIX = 6] = "PREFIX", e[e.INFIX = 7] = "INFIX", e[e.TUPLE = 8] = "TUPLE", e[e.
      SYMBOL = 9] = "SYMBOL", e[e.OPTIONAL = 10] = "OPTIONAL", e[e.NULLABLE = 11] = "NULLABLE", e[e.KEY_OF_TYPE_OF = 12] = "KEY_OF_TYPE_OF",
      e[e.FUNCTION = 13] = "FUNCTION", e[e.ARROW = 14] = "ARROW", e[e.ARRAY_BRACKETS = 15] = "ARRAY_BRACKETS", e[e.GENERIC = 16] = "GENERIC",
      e[e.NAME_PATH = 17] = "NAME_PATH", e[e.PARENTHESIS = 18] = "PARENTHESIS", e[e.SPECIAL_TYPES = 19] = "SPECIAL_TYPES";
    })(f || (f = {}));
    class L {
      static {
        r(this, "Parser");
      }
      constructor(t, o, i) {
        this.grammar = t, typeof o == "string" ? this._lexer = q.create(o) : this._lexer = o, this.baseParser = i;
      }
      get lexer() {
        return this._lexer;
      }
      /**
       * Parses a given string and throws an error if the parse ended before the end of the string.
       */
      parse() {
        let t = this.parseType(f.ALL);
        if (this.lexer.current.type !== "EOF")
          throw new p(this.lexer.current);
        return t;
      }
      /**
       * Parses with the current lexer and asserts that the result is a {@link RootResult}.
       */
      parseType(t) {
        return P(this.parseIntermediateType(t));
      }
      /**
       * The main parsing function. First it tries to parse the current state in the prefix step, and then it continues
       * to parse the state in the infix step.
       */
      parseIntermediateType(t) {
        let o = this.tryParslets(null, t);
        if (o === null)
          throw new a(this.lexer.current);
        return this.parseInfixIntermediateType(o, t);
      }
      /**
       * In the infix parsing step the parser continues to parse the current state with all parslets until none returns
       * a result.
       */
      parseInfixIntermediateType(t, o) {
        let i = this.tryParslets(t, o);
        for (; i !== null; )
          t = i, i = this.tryParslets(t, o);
        return t;
      }
      /**
       * Tries to parse the current state with all parslets in the grammar and returns the first non null result.
       */
      tryParslets(t, o) {
        for (let i of this.grammar) {
          let l = i(this, o, t);
          if (l !== null)
            return l;
        }
        return null;
      }
      /**
       * If the given type equals the current type of the {@link Lexer} advance the lexer. Return true if the lexer was
       * advanced.
       */
      consume(t) {
        return Array.isArray(t) || (t = [t]), t.includes(this.lexer.current.type) ? (this._lexer = this.lexer.advance(), !0) : !1;
      }
      acceptLexerState(t) {
        this._lexer = t.lexer;
      }
    }
    function Ce(e) {
      return e === "EOF" || e === "|" || e === "," || e === ")" || e === ">";
    }
    r(Ce, "isQuestionMarkUnknownType");
    let ge = /* @__PURE__ */ r((e, t, o) => {
      let i = e.lexer.current.type, l = e.lexer.next.type;
      return o == null && i === "?" && !Ce(l) || o != null && i === "?" ? (e.consume("?"), o == null ? {
        type: "JsdocTypeNullable",
        element: e.parseType(f.NULLABLE),
        meta: {
          position: "prefix"
        }
      } : {
        type: "JsdocTypeNullable",
        element: P(o),
        meta: {
          position: "suffix"
        }
      }) : null;
    }, "nullableParslet");
    function h(e) {
      let t = /* @__PURE__ */ r((o, i, l) => {
        let y = o.lexer.current.type, d = o.lexer.next.type;
        if (l === null) {
          if ("parsePrefix" in e && e.accept(y, d))
            return e.parsePrefix(o);
        } else if ("parseInfix" in e && e.precedence > i && e.accept(y, d))
          return e.parseInfix(o, l);
        return null;
      }, "parslet");
      return Object.defineProperty(t, "name", {
        value: e.name
      }), t;
    }
    r(h, "composeParslet");
    let Q = h({
      name: "optionalParslet",
      accept: /* @__PURE__ */ r((e) => e === "=", "accept"),
      precedence: f.OPTIONAL,
      parsePrefix: /* @__PURE__ */ r((e) => (e.consume("="), {
        type: "JsdocTypeOptional",
        element: e.parseType(f.OPTIONAL),
        meta: {
          position: "prefix"
        }
      }), "parsePrefix"),
      parseInfix: /* @__PURE__ */ r((e, t) => (e.consume("="), {
        type: "JsdocTypeOptional",
        element: P(t),
        meta: {
          position: "suffix"
        }
      }), "parseInfix")
    }), Z = h({
      name: "numberParslet",
      accept: /* @__PURE__ */ r((e) => e === "Number", "accept"),
      parsePrefix: /* @__PURE__ */ r((e) => {
        let t = parseFloat(e.lexer.current.text);
        return e.consume("Number"), {
          type: "JsdocTypeNumber",
          value: t
        };
      }, "parsePrefix")
    }), Rt = h({
      name: "parenthesisParslet",
      accept: /* @__PURE__ */ r((e) => e === "(", "accept"),
      parsePrefix: /* @__PURE__ */ r((e) => {
        if (e.consume("("), e.consume(")"))
          return {
            type: "JsdocTypeParameterList",
            elements: []
          };
        let t = e.parseIntermediateType(f.ALL);
        if (!e.consume(")"))
          throw new Error("Unterminated parenthesis");
        return t.type === "JsdocTypeParameterList" ? t : t.type === "JsdocTypeKeyValue" ? {
          type: "JsdocTypeParameterList",
          elements: [t]
        } : {
          type: "JsdocTypeParenthesis",
          element: P(t)
        };
      }, "parsePrefix")
    }), It = h({
      name: "specialTypesParslet",
      accept: /* @__PURE__ */ r((e, t) => e === "?" && Ce(t) || e === "null" || e === "undefined" || e === "*", "accept"),
      parsePrefix: /* @__PURE__ */ r((e) => {
        if (e.consume("null"))
          return {
            type: "JsdocTypeNull"
          };
        if (e.consume("undefined"))
          return {
            type: "JsdocTypeUndefined"
          };
        if (e.consume("*"))
          return {
            type: "JsdocTypeAny"
          };
        if (e.consume("?"))
          return {
            type: "JsdocTypeUnknown"
          };
        throw new Error("Unacceptable token: " + e.lexer.current.text);
      }, "parsePrefix")
    }), Ft = h({
      name: "notNullableParslet",
      accept: /* @__PURE__ */ r((e) => e === "!", "accept"),
      precedence: f.NULLABLE,
      parsePrefix: /* @__PURE__ */ r((e) => (e.consume("!"), {
        type: "JsdocTypeNotNullable",
        element: e.parseType(f.NULLABLE),
        meta: {
          position: "prefix"
        }
      }), "parsePrefix"),
      parseInfix: /* @__PURE__ */ r((e, t) => (e.consume("!"), {
        type: "JsdocTypeNotNullable",
        element: P(t),
        meta: {
          position: "suffix"
        }
      }), "parseInfix")
    });
    function jt({ allowTrailingComma: e }) {
      return h({
        name: "parameterListParslet",
        accept: /* @__PURE__ */ r((t) => t === ",", "accept"),
        precedence: f.PARAMETER_LIST,
        parseInfix: /* @__PURE__ */ r((t, o) => {
          let i = [
            de(o)
          ];
          t.consume(",");
          do
            try {
              let l = t.parseIntermediateType(f.PARAMETER_LIST);
              i.push(de(l));
            } catch (l) {
              if (e && l instanceof a)
                break;
              throw l;
            }
          while (t.consume(","));
          if (i.length > 0 && i.slice(0, -1).some((l) => l.type === "JsdocTypeVariadic"))
            throw new Error("Only the last parameter may be a rest parameter");
          return {
            type: "JsdocTypeParameterList",
            elements: i
          };
        }, "parseInfix")
      });
    }
    r(jt, "createParameterListParslet");
    let _t = h({
      name: "genericParslet",
      accept: /* @__PURE__ */ r((e, t) => e === "<" || e === "." && t === "<", "accept"),
      precedence: f.GENERIC,
      parseInfix: /* @__PURE__ */ r((e, t) => {
        let o = e.consume(".");
        e.consume("<");
        let i = [];
        do
          i.push(e.parseType(f.PARAMETER_LIST));
        while (e.consume(","));
        if (!e.consume(">"))
          throw new Error("Unterminated generic parameter list");
        return {
          type: "JsdocTypeGeneric",
          left: P(t),
          elements: i,
          meta: {
            brackets: "angle",
            dot: o
          }
        };
      }, "parseInfix")
    }), Lt = h({
      name: "unionParslet",
      accept: /* @__PURE__ */ r((e) => e === "|", "accept"),
      precedence: f.UNION,
      parseInfix: /* @__PURE__ */ r((e, t) => {
        e.consume("|");
        let o = [];
        do
          o.push(e.parseType(f.UNION));
        while (e.consume("|"));
        return {
          type: "JsdocTypeUnion",
          elements: [P(t), ...o]
        };
      }, "parseInfix")
    }), he = [
      ge,
      Q,
      Z,
      Rt,
      It,
      Ft,
      jt({
        allowTrailingComma: !0
      }),
      _t,
      Lt,
      Q
    ];
    function ee({ allowSquareBracketsOnAnyType: e, allowJsdocNamePaths: t, pathGrammar: o }) {
      return /* @__PURE__ */ r(function(l, y, d) {
        if (d == null || y >= f.NAME_PATH)
          return null;
        let x = l.lexer.current.type, N = l.lexer.next.type;
        if (!(x === "." && N !== "<" || x === "[" && (e || d.type === "JsdocTypeName") || t && (x === "~" || x === "#")))
          return null;
        let D, ne = !1;
        l.consume(".") ? D = "property" : l.consume("[") ? (D = "property-brackets", ne = !0) : l.consume("~") ? D = "inner" : (l.consume("#"),
        D = "instance");
        let He = o !== null ? new L(o, l.lexer, l) : l, k = He.parseIntermediateType(f.NAME_PATH);
        l.acceptLexerState(He);
        let G;
        switch (k.type) {
          case "JsdocTypeName":
            G = {
              type: "JsdocTypeProperty",
              value: k.value,
              meta: {
                quote: void 0
              }
            };
            break;
          case "JsdocTypeNumber":
            G = {
              type: "JsdocTypeProperty",
              value: k.value.toString(10),
              meta: {
                quote: void 0
              }
            };
            break;
          case "JsdocTypeStringValue":
            G = {
              type: "JsdocTypeProperty",
              value: k.value,
              meta: {
                quote: k.meta.quote
              }
            };
            break;
          case "JsdocTypeSpecialNamePath":
            if (k.specialType === "event")
              G = k;
            else
              throw new c(k, "Type 'JsdocTypeSpecialNamePath' is only allowed with specialType 'event'");
            break;
          default:
            throw new c(k, "Expecting 'JsdocTypeName', 'JsdocTypeNumber', 'JsdocStringValue' or 'JsdocTypeSpecialNamePath'");
        }
        if (ne && !l.consume("]")) {
          let Qe = l.lexer.current;
          throw new Error(`Unterminated square brackets. Next token is '${Qe.type}' with text '${Qe.text}'`);
        }
        return {
          type: "JsdocTypeNamePath",
          left: P(d),
          right: G,
          pathType: D
        };
      }, "namePathParslet");
    }
    r(ee, "createNamePathParslet");
    function R({ allowedAdditionalTokens: e }) {
      return h({
        name: "nameParslet",
        accept: /* @__PURE__ */ r((t) => t === "Identifier" || t === "this" || t === "new" || e.includes(t), "accept"),
        parsePrefix: /* @__PURE__ */ r((t) => {
          let { type: o, text: i } = t.lexer.current;
          return t.consume(o), {
            type: "JsdocTypeName",
            value: i
          };
        }, "parsePrefix")
      });
    }
    r(R, "createNameParslet");
    let Y = h({
      name: "stringValueParslet",
      accept: /* @__PURE__ */ r((e) => e === "StringValue", "accept"),
      parsePrefix: /* @__PURE__ */ r((e) => {
        let t = e.lexer.current.text;
        return e.consume("StringValue"), {
          type: "JsdocTypeStringValue",
          value: t.slice(1, -1),
          meta: {
            quote: t[0] === "'" ? "single" : "double"
          }
        };
      }, "parsePrefix")
    });
    function te({ pathGrammar: e, allowedTypes: t }) {
      return h({
        name: "specialNamePathParslet",
        accept: /* @__PURE__ */ r((o) => t.includes(o), "accept"),
        parsePrefix: /* @__PURE__ */ r((o) => {
          let i = o.lexer.current.type;
          if (o.consume(i), !o.consume(":"))
            return {
              type: "JsdocTypeName",
              value: i
            };
          let l, y = o.lexer.current;
          if (o.consume("StringValue"))
            l = {
              type: "JsdocTypeSpecialNamePath",
              value: y.text.slice(1, -1),
              specialType: i,
              meta: {
                quote: y.text[0] === "'" ? "single" : "double"
              }
            };
          else {
            let N = "", S = ["Identifier", "@", "/"];
            for (; S.some((D) => o.consume(D)); )
              N += y.text, y = o.lexer.current;
            l = {
              type: "JsdocTypeSpecialNamePath",
              value: N,
              specialType: i,
              meta: {
                quote: void 0
              }
            };
          }
          let d = new L(e, o.lexer, o), x = d.parseInfixIntermediateType(l, f.ALL);
          return o.acceptLexerState(d), P(x);
        }, "parsePrefix")
      });
    }
    r(te, "createSpecialNamePathParslet");
    let Me = [
      R({
        allowedAdditionalTokens: ["external", "module"]
      }),
      Y,
      Z,
      ee({
        allowSquareBracketsOnAnyType: !1,
        allowJsdocNamePaths: !0,
        pathGrammar: null
      })
    ], V = [
      ...Me,
      te({
        allowedTypes: ["event"],
        pathGrammar: Me
      })
    ];
    function xe(e) {
      let t;
      if (e.type === "JsdocTypeParameterList")
        t = e.elements;
      else if (e.type === "JsdocTypeParenthesis")
        t = [e.element];
      else
        throw new c(e);
      return t.map((o) => de(o));
    }
    r(xe, "getParameters");
    function Vt(e) {
      let t = xe(e);
      if (t.some((o) => o.type === "JsdocTypeKeyValue"))
        throw new Error("No parameter should be named");
      return t;
    }
    r(Vt, "getUnnamedParameters");
    function Je({ allowNamedParameters: e, allowNoReturnType: t, allowWithoutParenthesis: o, allowNewAsFunctionKeyword: i }) {
      return h({
        name: "functionParslet",
        accept: /* @__PURE__ */ r((l, y) => l === "function" || i && l === "new" && y === "(", "accept"),
        parsePrefix: /* @__PURE__ */ r((l) => {
          let y = l.consume("new");
          l.consume("function");
          let d = l.lexer.current.type === "(";
          if (!d) {
            if (!o)
              throw new Error("function is missing parameter list");
            return {
              type: "JsdocTypeName",
              value: "function"
            };
          }
          let x = {
            type: "JsdocTypeFunction",
            parameters: [],
            arrow: !1,
            constructor: y,
            parenthesis: d
          }, N = l.parseIntermediateType(f.FUNCTION);
          if (e === void 0)
            x.parameters = Vt(N);
          else {
            if (y && N.type === "JsdocTypeFunction" && N.arrow)
              return x = N, x.constructor = !0, x;
            x.parameters = xe(N);
            for (let S of x.parameters)
              if (S.type === "JsdocTypeKeyValue" && !e.includes(S.key))
                throw new Error(`only allowed named parameters are ${e.join(", ")} but got ${S.type}`);
          }
          if (l.consume(":"))
            x.returnType = l.parseType(f.PREFIX);
          else if (!t)
            throw new Error("function is missing return type");
          return x;
        }, "parsePrefix")
      });
    }
    r(Je, "createFunctionParslet");
    function Pe({ allowPostfix: e, allowEnclosingBrackets: t }) {
      return h({
        name: "variadicParslet",
        accept: /* @__PURE__ */ r((o) => o === "...", "accept"),
        precedence: f.PREFIX,
        parsePrefix: /* @__PURE__ */ r((o) => {
          o.consume("...");
          let i = t && o.consume("[");
          try {
            let l = o.parseType(f.PREFIX);
            if (i && !o.consume("]"))
              throw new Error("Unterminated variadic type. Missing ']'");
            return {
              type: "JsdocTypeVariadic",
              element: P(l),
              meta: {
                position: "prefix",
                squareBrackets: i
              }
            };
          } catch (l) {
            if (l instanceof a) {
              if (i)
                throw new Error("Empty square brackets for variadic are not allowed.");
              return {
                type: "JsdocTypeVariadic",
                meta: {
                  position: void 0,
                  squareBrackets: !1
                }
              };
            } else
              throw l;
          }
        }, "parsePrefix"),
        parseInfix: e ? (o, i) => (o.consume("..."), {
          type: "JsdocTypeVariadic",
          element: P(i),
          meta: {
            position: "suffix",
            squareBrackets: !1
          }
        }) : void 0
      });
    }
    r(Pe, "createVariadicParslet");
    let Ke = h({
      name: "symbolParslet",
      accept: /* @__PURE__ */ r((e) => e === "(", "accept"),
      precedence: f.SYMBOL,
      parseInfix: /* @__PURE__ */ r((e, t) => {
        if (t.type !== "JsdocTypeName")
          throw new Error("Symbol expects a name on the left side. (Reacting on '(')");
        e.consume("(");
        let o = {
          type: "JsdocTypeSymbol",
          value: t.value
        };
        if (!e.consume(")")) {
          let i = e.parseIntermediateType(f.SYMBOL);
          if (o.element = At(i), !e.consume(")"))
            throw new Error("Symbol does not end after value");
        }
        return o;
      }, "parseInfix")
    }), $e = h({
      name: "arrayBracketsParslet",
      precedence: f.ARRAY_BRACKETS,
      accept: /* @__PURE__ */ r((e, t) => e === "[" && t === "]", "accept"),
      parseInfix: /* @__PURE__ */ r((e, t) => (e.consume("["), e.consume("]"), {
        type: "JsdocTypeGeneric",
        left: {
          type: "JsdocTypeName",
          value: "Array"
        },
        elements: [
          P(t)
        ],
        meta: {
          brackets: "square",
          dot: !1
        }
      }), "parseInfix")
    });
    function we({ objectFieldGrammar: e, allowKeyTypes: t }) {
      return h({
        name: "objectParslet",
        accept: /* @__PURE__ */ r((o) => o === "{", "accept"),
        parsePrefix: /* @__PURE__ */ r((o) => {
          o.consume("{");
          let i = {
            type: "JsdocTypeObject",
            meta: {
              separator: "comma"
            },
            elements: []
          };
          if (!o.consume("}")) {
            let l, y = new L(e, o.lexer, o);
            for (; ; ) {
              y.acceptLexerState(o);
              let d = y.parseIntermediateType(f.OBJECT);
              o.acceptLexerState(y), d === void 0 && t && (d = o.parseIntermediateType(f.OBJECT));
              let x = !1;
              if (d.type === "JsdocTypeNullable" && (x = !0, d = d.element), d.type === "JsdocTypeNumber" || d.type === "JsdocTypeName" || d.
              type === "JsdocTypeStringValue") {
                let S;
                d.type === "JsdocTypeStringValue" && (S = d.meta.quote), i.elements.push({
                  type: "JsdocTypeObjectField",
                  key: d.value.toString(),
                  right: void 0,
                  optional: x,
                  readonly: !1,
                  meta: {
                    quote: S
                  }
                });
              } else if (d.type === "JsdocTypeObjectField" || d.type === "JsdocTypeJsdocObjectField")
                i.elements.push(d);
              else
                throw new c(d);
              if (o.lexer.current.startOfLine)
                l = "linebreak";
              else if (o.consume(","))
                l = "comma";
              else if (o.consume(";"))
                l = "semicolon";
              else
                break;
              if (o.lexer.current.type === "}")
                break;
            }
            if (i.meta.separator = l ?? "comma", !o.consume("}"))
              throw new Error("Unterminated record type. Missing '}'");
          }
          return i;
        }, "parsePrefix")
      });
    }
    r(we, "createObjectParslet");
    function be({ allowSquaredProperties: e, allowKeyTypes: t, allowReadonly: o, allowOptional: i }) {
      return h({
        name: "objectFieldParslet",
        precedence: f.KEY_VALUE,
        accept: /* @__PURE__ */ r((l) => l === ":", "accept"),
        parseInfix: /* @__PURE__ */ r((l, y) => {
          var d;
          let x = !1, N = !1;
          i && y.type === "JsdocTypeNullable" && (x = !0, y = y.element), o && y.type === "JsdocTypeReadonlyProperty" && (N = !0, y = y.element);
          let S = (d = l.baseParser) !== null && d !== void 0 ? d : l;
          if (S.acceptLexerState(l), y.type === "JsdocTypeNumber" || y.type === "JsdocTypeName" || y.type === "JsdocTypeStringValue" || Te(y)) {
            if (Te(y) && !e)
              throw new c(y);
            S.consume(":");
            let D;
            y.type === "JsdocTypeStringValue" && (D = y.meta.quote);
            let ne = S.parseType(f.KEY_VALUE);
            return l.acceptLexerState(S), {
              type: "JsdocTypeObjectField",
              key: Te(y) ? y : y.value.toString(),
              right: ne,
              optional: x,
              readonly: N,
              meta: {
                quote: D
              }
            };
          } else {
            if (!t)
              throw new c(y);
            S.consume(":");
            let D = S.parseType(f.KEY_VALUE);
            return l.acceptLexerState(S), {
              type: "JsdocTypeJsdocObjectField",
              left: P(y),
              right: D
            };
          }
        }, "parseInfix")
      });
    }
    r(be, "createObjectFieldParslet");
    function Ee({ allowOptional: e, allowVariadic: t }) {
      return h({
        name: "keyValueParslet",
        precedence: f.KEY_VALUE,
        accept: /* @__PURE__ */ r((o) => o === ":", "accept"),
        parseInfix: /* @__PURE__ */ r((o, i) => {
          let l = !1, y = !1;
          if (e && i.type === "JsdocTypeNullable" && (l = !0, i = i.element), t && i.type === "JsdocTypeVariadic" && i.element !== void 0 &&
          (y = !0, i = i.element), i.type !== "JsdocTypeName")
            throw new c(i);
          o.consume(":");
          let d = o.parseType(f.KEY_VALUE);
          return {
            type: "JsdocTypeKeyValue",
            key: i.value,
            right: d,
            optional: l,
            variadic: y
          };
        }, "parseInfix")
      });
    }
    r(Ee, "createKeyValueParslet");
    let qe = [
      ...he,
      Je({
        allowWithoutParenthesis: !0,
        allowNamedParameters: ["this", "new"],
        allowNoReturnType: !0,
        allowNewAsFunctionKeyword: !1
      }),
      Y,
      te({
        allowedTypes: ["module", "external", "event"],
        pathGrammar: V
      }),
      Pe({
        allowEnclosingBrackets: !0,
        allowPostfix: !0
      }),
      R({
        allowedAdditionalTokens: ["keyof"]
      }),
      Ke,
      $e,
      ee({
        allowSquareBracketsOnAnyType: !1,
        allowJsdocNamePaths: !0,
        pathGrammar: V
      })
    ], Ut = [
      ...qe,
      we({
        // jsdoc syntax allows full types as keys, so we need to pull in the full grammar here
        // we leave out the object type deliberately
        objectFieldGrammar: [
          R({
            allowedAdditionalTokens: ["module", "in"]
          }),
          be({
            allowSquaredProperties: !1,
            allowKeyTypes: !0,
            allowOptional: !1,
            allowReadonly: !1
          }),
          ...qe
        ],
        allowKeyTypes: !0
      }),
      Ee({
        allowOptional: !0,
        allowVariadic: !0
      })
    ], Ye = h({
      name: "typeOfParslet",
      accept: /* @__PURE__ */ r((e) => e === "typeof", "accept"),
      parsePrefix: /* @__PURE__ */ r((e) => (e.consume("typeof"), {
        type: "JsdocTypeTypeof",
        element: P(e.parseType(f.KEY_OF_TYPE_OF))
      }), "parsePrefix")
    }), Bt = [
      R({
        allowedAdditionalTokens: ["module", "keyof", "event", "external", "in"]
      }),
      ge,
      Q,
      Y,
      Z,
      be({
        allowSquaredProperties: !1,
        allowKeyTypes: !1,
        allowOptional: !1,
        allowReadonly: !1
      })
    ], Ct = [
      ...he,
      we({
        allowKeyTypes: !1,
        objectFieldGrammar: Bt
      }),
      R({
        allowedAdditionalTokens: ["event", "external", "in"]
      }),
      Ye,
      Je({
        allowWithoutParenthesis: !1,
        allowNamedParameters: ["this", "new"],
        allowNoReturnType: !0,
        allowNewAsFunctionKeyword: !1
      }),
      Pe({
        allowEnclosingBrackets: !1,
        allowPostfix: !1
      }),
      // additional name parslet is needed for some special cases
      R({
        allowedAdditionalTokens: ["keyof"]
      }),
      te({
        allowedTypes: ["module"],
        pathGrammar: V
      }),
      ee({
        allowSquareBracketsOnAnyType: !1,
        allowJsdocNamePaths: !0,
        pathGrammar: V
      }),
      Ee({
        allowOptional: !1,
        allowVariadic: !1
      }),
      Ke
    ];
    function Mt({ allowQuestionMark: e }) {
      return h({
        name: "tupleParslet",
        accept: /* @__PURE__ */ r((t) => t === "[", "accept"),
        parsePrefix: /* @__PURE__ */ r((t) => {
          t.consume("[");
          let o = {
            type: "JsdocTypeTuple",
            elements: []
          };
          if (t.consume("]"))
            return o;
          let i = t.parseIntermediateType(f.ALL);
          if (i.type === "JsdocTypeParameterList" ? i.elements[0].type === "JsdocTypeKeyValue" ? o.elements = i.elements.map(H) : o.elements =
          i.elements.map(P) : i.type === "JsdocTypeKeyValue" ? o.elements = [H(i)] : o.elements = [P(i)], !t.consume("]"))
            throw new Error("Unterminated '['");
          if (!e && o.elements.some((l) => l.type === "JsdocTypeUnknown"))
            throw new Error("Question mark in tuple not allowed");
          return o;
        }, "parsePrefix")
      });
    }
    r(Mt, "createTupleParslet");
    let Kt = h({
      name: "keyOfParslet",
      accept: /* @__PURE__ */ r((e) => e === "keyof", "accept"),
      parsePrefix: /* @__PURE__ */ r((e) => (e.consume("keyof"), {
        type: "JsdocTypeKeyof",
        element: P(e.parseType(f.KEY_OF_TYPE_OF))
      }), "parsePrefix")
    }), $t = h({
      name: "importParslet",
      accept: /* @__PURE__ */ r((e) => e === "import", "accept"),
      parsePrefix: /* @__PURE__ */ r((e) => {
        if (e.consume("import"), !e.consume("("))
          throw new Error("Missing parenthesis after import keyword");
        let t = e.parseType(f.PREFIX);
        if (t.type !== "JsdocTypeStringValue")
          throw new Error("Only string values are allowed as paths for imports");
        if (!e.consume(")"))
          throw new Error("Missing closing parenthesis after import keyword");
        return {
          type: "JsdocTypeImport",
          element: t
        };
      }, "parsePrefix")
    }), qt = h({
      name: "readonlyPropertyParslet",
      accept: /* @__PURE__ */ r((e) => e === "readonly", "accept"),
      parsePrefix: /* @__PURE__ */ r((e) => (e.consume("readonly"), {
        type: "JsdocTypeReadonlyProperty",
        element: e.parseType(f.KEY_VALUE)
      }), "parsePrefix")
    }), Yt = h({
      name: "arrowFunctionParslet",
      precedence: f.ARROW,
      accept: /* @__PURE__ */ r((e) => e === "=>", "accept"),
      parseInfix: /* @__PURE__ */ r((e, t) => (e.consume("=>"), {
        type: "JsdocTypeFunction",
        parameters: xe(t).map(kt),
        arrow: !0,
        constructor: !1,
        parenthesis: !0,
        returnType: e.parseType(f.OBJECT)
      }), "parseInfix")
    }), Wt = h({
      name: "intersectionParslet",
      accept: /* @__PURE__ */ r((e) => e === "&", "accept"),
      precedence: f.INTERSECTION,
      parseInfix: /* @__PURE__ */ r((e, t) => {
        e.consume("&");
        let o = [];
        do
          o.push(e.parseType(f.INTERSECTION));
        while (e.consume("&"));
        return {
          type: "JsdocTypeIntersection",
          elements: [P(t), ...o]
        };
      }, "parseInfix")
    }), Gt = h({
      name: "predicateParslet",
      precedence: f.INFIX,
      accept: /* @__PURE__ */ r((e) => e === "is", "accept"),
      parseInfix: /* @__PURE__ */ r((e, t) => {
        if (t.type !== "JsdocTypeName")
          throw new c(t, "A typescript predicate always has to have a name on the left side.");
        return e.consume("is"), {
          type: "JsdocTypePredicate",
          left: t,
          right: P(e.parseIntermediateType(f.INFIX))
        };
      }, "parseInfix")
    }), zt = h({
      name: "objectSquareBracketPropertyParslet",
      accept: /* @__PURE__ */ r((e) => e === "[", "accept"),
      parsePrefix: /* @__PURE__ */ r((e) => {
        if (e.baseParser === void 0)
          throw new Error("Only allowed inside object grammar");
        e.consume("[");
        let t = e.lexer.current.text;
        e.consume("Identifier");
        let o;
        if (e.consume(":")) {
          let i = e.baseParser;
          i.acceptLexerState(e), o = {
            type: "JsdocTypeIndexSignature",
            key: t,
            right: i.parseType(f.ARRAY_BRACKETS)
          }, e.acceptLexerState(i);
        } else if (e.consume("in")) {
          let i = e.baseParser;
          i.acceptLexerState(e), o = {
            type: "JsdocTypeMappedType",
            key: t,
            right: i.parseType(f.ARRAY_BRACKETS)
          }, e.acceptLexerState(i);
        } else
          throw new Error("Missing ':' or 'in' inside square bracketed property.");
        if (!e.consume("]"))
          throw new Error("Unterminated square brackets");
        return o;
      }, "parsePrefix")
    }), Xt = [
      qt,
      R({
        allowedAdditionalTokens: ["module", "event", "keyof", "event", "external", "in"]
      }),
      ge,
      Q,
      Y,
      Z,
      be({
        allowSquaredProperties: !0,
        allowKeyTypes: !1,
        allowOptional: !0,
        allowReadonly: !0
      }),
      zt
    ], Ht = [
      ...he,
      we({
        allowKeyTypes: !1,
        objectFieldGrammar: Xt
      }),
      Ye,
      Kt,
      $t,
      Y,
      Je({
        allowWithoutParenthesis: !0,
        allowNoReturnType: !1,
        allowNamedParameters: ["this", "new", "args"],
        allowNewAsFunctionKeyword: !0
      }),
      Mt({
        allowQuestionMark: !1
      }),
      Pe({
        allowEnclosingBrackets: !1,
        allowPostfix: !1
      }),
      R({
        allowedAdditionalTokens: ["event", "external", "in"]
      }),
      te({
        allowedTypes: ["module"],
        pathGrammar: V
      }),
      $e,
      Yt,
      ee({
        allowSquareBracketsOnAnyType: !0,
        allowJsdocNamePaths: !1,
        pathGrammar: V
      }),
      Wt,
      Gt,
      Ee({
        allowVariadic: !0,
        allowOptional: !0
      })
    ];
    function We(e, t) {
      switch (t) {
        case "closure":
          return new L(Ct, e).parse();
        case "jsdoc":
          return new L(Ut, e).parse();
        case "typescript":
          return new L(Ht, e).parse();
      }
    }
    r(We, "parse");
    function Qt(e, t = ["typescript", "closure", "jsdoc"]) {
      let o;
      for (let i of t)
        try {
          return We(e, i);
        } catch (l) {
          o = l;
        }
      throw o;
    }
    r(Qt, "tryParse");
    function W(e, t) {
      let o = e[t.type];
      if (o === void 0)
        throw new Error(`In this set of transform rules exists no rule for type ${t.type}.`);
      return o(t, (i) => W(e, i));
    }
    r(W, "transform");
    function O(e) {
      throw new Error("This transform is not available. Are you trying the correct parsing mode?");
    }
    r(O, "notAvailableTransform");
    function Ge(e) {
      let t = {
        params: []
      };
      for (let o of e.parameters)
        o.type === "JsdocTypeKeyValue" ? o.key === "this" ? t.this = o.right : o.key === "new" ? t.new = o.right : t.params.push(o) : t.params.
        push(o);
      return t;
    }
    r(Ge, "extractSpecialParams");
    function re(e, t, o) {
      return e === "prefix" ? o + t : t + o;
    }
    r(re, "applyPosition");
    function I(e, t) {
      switch (t) {
        case "double":
          return `"${e}"`;
        case "single":
          return `'${e}'`;
        case void 0:
          return e;
      }
    }
    r(I, "quote");
    function ze() {
      return {
        JsdocTypeParenthesis: /* @__PURE__ */ r((e, t) => `(${e.element !== void 0 ? t(e.element) : ""})`, "JsdocTypeParenthesis"),
        JsdocTypeKeyof: /* @__PURE__ */ r((e, t) => `keyof ${t(e.element)}`, "JsdocTypeKeyof"),
        JsdocTypeFunction: /* @__PURE__ */ r((e, t) => {
          if (e.arrow) {
            if (e.returnType === void 0)
              throw new Error("Arrow function needs a return type.");
            let o = `(${e.parameters.map(t).join(", ")}) => ${t(e.returnType)}`;
            return e.constructor && (o = "new " + o), o;
          } else {
            let o = e.constructor ? "new" : "function";
            return e.parenthesis && (o += `(${e.parameters.map(t).join(", ")})`, e.returnType !== void 0 && (o += `: ${t(e.returnType)}`)), o;
          }
        }, "JsdocTypeFunction"),
        JsdocTypeName: /* @__PURE__ */ r((e) => e.value, "JsdocTypeName"),
        JsdocTypeTuple: /* @__PURE__ */ r((e, t) => `[${e.elements.map(t).join(", ")}]`, "JsdocTypeTuple"),
        JsdocTypeVariadic: /* @__PURE__ */ r((e, t) => e.meta.position === void 0 ? "..." : re(e.meta.position, t(e.element), "..."), "Jsdoc\
TypeVariadic"),
        JsdocTypeNamePath: /* @__PURE__ */ r((e, t) => {
          let o = t(e.left), i = t(e.right);
          switch (e.pathType) {
            case "inner":
              return `${o}~${i}`;
            case "instance":
              return `${o}#${i}`;
            case "property":
              return `${o}.${i}`;
            case "property-brackets":
              return `${o}[${i}]`;
          }
        }, "JsdocTypeNamePath"),
        JsdocTypeStringValue: /* @__PURE__ */ r((e) => I(e.value, e.meta.quote), "JsdocTypeStringValue"),
        JsdocTypeAny: /* @__PURE__ */ r(() => "*", "JsdocTypeAny"),
        JsdocTypeGeneric: /* @__PURE__ */ r((e, t) => {
          if (e.meta.brackets === "square") {
            let o = e.elements[0], i = t(o);
            return o.type === "JsdocTypeUnion" || o.type === "JsdocTypeIntersection" ? `(${i})[]` : `${i}[]`;
          } else
            return `${t(e.left)}${e.meta.dot ? "." : ""}<${e.elements.map(t).join(", ")}>`;
        }, "JsdocTypeGeneric"),
        JsdocTypeImport: /* @__PURE__ */ r((e, t) => `import(${t(e.element)})`, "JsdocTypeImport"),
        JsdocTypeObjectField: /* @__PURE__ */ r((e, t) => {
          let o = "";
          return e.readonly && (o += "readonly "), typeof e.key == "string" ? o += I(e.key, e.meta.quote) : o += t(e.key), e.optional && (o +=
          "?"), e.right === void 0 ? o : o + `: ${t(e.right)}`;
        }, "JsdocTypeObjectField"),
        JsdocTypeJsdocObjectField: /* @__PURE__ */ r((e, t) => `${t(e.left)}: ${t(e.right)}`, "JsdocTypeJsdocObjectField"),
        JsdocTypeKeyValue: /* @__PURE__ */ r((e, t) => {
          let o = e.key;
          return e.optional && (o += "?"), e.variadic && (o = "..." + o), e.right === void 0 ? o : o + `: ${t(e.right)}`;
        }, "JsdocTypeKeyValue"),
        JsdocTypeSpecialNamePath: /* @__PURE__ */ r((e) => `${e.specialType}:${I(e.value, e.meta.quote)}`, "JsdocTypeSpecialNamePath"),
        JsdocTypeNotNullable: /* @__PURE__ */ r((e, t) => re(e.meta.position, t(e.element), "!"), "JsdocTypeNotNullable"),
        JsdocTypeNull: /* @__PURE__ */ r(() => "null", "JsdocTypeNull"),
        JsdocTypeNullable: /* @__PURE__ */ r((e, t) => re(e.meta.position, t(e.element), "?"), "JsdocTypeNullable"),
        JsdocTypeNumber: /* @__PURE__ */ r((e) => e.value.toString(), "JsdocTypeNumber"),
        JsdocTypeObject: /* @__PURE__ */ r((e, t) => `{${e.elements.map(t).join((e.meta.separator === "comma" ? "," : ";") + " ")}}`, "Jsdoc\
TypeObject"),
        JsdocTypeOptional: /* @__PURE__ */ r((e, t) => re(e.meta.position, t(e.element), "="), "JsdocTypeOptional"),
        JsdocTypeSymbol: /* @__PURE__ */ r((e, t) => `${e.value}(${e.element !== void 0 ? t(e.element) : ""})`, "JsdocTypeSymbol"),
        JsdocTypeTypeof: /* @__PURE__ */ r((e, t) => `typeof ${t(e.element)}`, "JsdocTypeTypeof"),
        JsdocTypeUndefined: /* @__PURE__ */ r(() => "undefined", "JsdocTypeUndefined"),
        JsdocTypeUnion: /* @__PURE__ */ r((e, t) => e.elements.map(t).join(" | "), "JsdocTypeUnion"),
        JsdocTypeUnknown: /* @__PURE__ */ r(() => "?", "JsdocTypeUnknown"),
        JsdocTypeIntersection: /* @__PURE__ */ r((e, t) => e.elements.map(t).join(" & "), "JsdocTypeIntersection"),
        JsdocTypeProperty: /* @__PURE__ */ r((e) => I(e.value, e.meta.quote), "JsdocTypeProperty"),
        JsdocTypePredicate: /* @__PURE__ */ r((e, t) => `${t(e.left)} is ${t(e.right)}`, "JsdocTypePredicate"),
        JsdocTypeIndexSignature: /* @__PURE__ */ r((e, t) => `[${e.key}: ${t(e.right)}]`, "JsdocTypeIndexSignature"),
        JsdocTypeMappedType: /* @__PURE__ */ r((e, t) => `[${e.key} in ${t(e.right)}]`, "JsdocTypeMappedType")
      };
    }
    r(ze, "stringifyRules");
    let Zt = ze();
    function er(e) {
      return W(Zt, e);
    }
    r(er, "stringify");
    let tr = [
      "null",
      "true",
      "false",
      "break",
      "case",
      "catch",
      "class",
      "const",
      "continue",
      "debugger",
      "default",
      "delete",
      "do",
      "else",
      "export",
      "extends",
      "finally",
      "for",
      "function",
      "if",
      "import",
      "in",
      "instanceof",
      "new",
      "return",
      "super",
      "switch",
      "this",
      "throw",
      "try",
      "typeof",
      "var",
      "void",
      "while",
      "with",
      "yield"
    ];
    function F(e) {
      let t = {
        type: "NameExpression",
        name: e
      };
      return tr.includes(e) && (t.reservedWord = !0), t;
    }
    r(F, "makeName");
    let rr = {
      JsdocTypeOptional: /* @__PURE__ */ r((e, t) => {
        let o = t(e.element);
        return o.optional = !0, o;
      }, "JsdocTypeOptional"),
      JsdocTypeNullable: /* @__PURE__ */ r((e, t) => {
        let o = t(e.element);
        return o.nullable = !0, o;
      }, "JsdocTypeNullable"),
      JsdocTypeNotNullable: /* @__PURE__ */ r((e, t) => {
        let o = t(e.element);
        return o.nullable = !1, o;
      }, "JsdocTypeNotNullable"),
      JsdocTypeVariadic: /* @__PURE__ */ r((e, t) => {
        if (e.element === void 0)
          throw new Error("dots without value are not allowed in catharsis mode");
        let o = t(e.element);
        return o.repeatable = !0, o;
      }, "JsdocTypeVariadic"),
      JsdocTypeAny: /* @__PURE__ */ r(() => ({
        type: "AllLiteral"
      }), "JsdocTypeAny"),
      JsdocTypeNull: /* @__PURE__ */ r(() => ({
        type: "NullLiteral"
      }), "JsdocTypeNull"),
      JsdocTypeStringValue: /* @__PURE__ */ r((e) => F(I(e.value, e.meta.quote)), "JsdocTypeStringValue"),
      JsdocTypeUndefined: /* @__PURE__ */ r(() => ({
        type: "UndefinedLiteral"
      }), "JsdocTypeUndefined"),
      JsdocTypeUnknown: /* @__PURE__ */ r(() => ({
        type: "UnknownLiteral"
      }), "JsdocTypeUnknown"),
      JsdocTypeFunction: /* @__PURE__ */ r((e, t) => {
        let o = Ge(e), i = {
          type: "FunctionType",
          params: o.params.map(t)
        };
        return o.this !== void 0 && (i.this = t(o.this)), o.new !== void 0 && (i.new = t(o.new)), e.returnType !== void 0 && (i.result = t(e.
        returnType)), i;
      }, "JsdocTypeFunction"),
      JsdocTypeGeneric: /* @__PURE__ */ r((e, t) => ({
        type: "TypeApplication",
        applications: e.elements.map((o) => t(o)),
        expression: t(e.left)
      }), "JsdocTypeGeneric"),
      JsdocTypeSpecialNamePath: /* @__PURE__ */ r((e) => F(e.specialType + ":" + I(e.value, e.meta.quote)), "JsdocTypeSpecialNamePath"),
      JsdocTypeName: /* @__PURE__ */ r((e) => e.value !== "function" ? F(e.value) : {
        type: "FunctionType",
        params: []
      }, "JsdocTypeName"),
      JsdocTypeNumber: /* @__PURE__ */ r((e) => F(e.value.toString()), "JsdocTypeNumber"),
      JsdocTypeObject: /* @__PURE__ */ r((e, t) => {
        let o = {
          type: "RecordType",
          fields: []
        };
        for (let i of e.elements)
          i.type !== "JsdocTypeObjectField" && i.type !== "JsdocTypeJsdocObjectField" ? o.fields.push({
            type: "FieldType",
            key: t(i),
            value: void 0
          }) : o.fields.push(t(i));
        return o;
      }, "JsdocTypeObject"),
      JsdocTypeObjectField: /* @__PURE__ */ r((e, t) => {
        if (typeof e.key != "string")
          throw new Error("Index signatures and mapped types are not supported");
        return {
          type: "FieldType",
          key: F(I(e.key, e.meta.quote)),
          value: e.right === void 0 ? void 0 : t(e.right)
        };
      }, "JsdocTypeObjectField"),
      JsdocTypeJsdocObjectField: /* @__PURE__ */ r((e, t) => ({
        type: "FieldType",
        key: t(e.left),
        value: t(e.right)
      }), "JsdocTypeJsdocObjectField"),
      JsdocTypeUnion: /* @__PURE__ */ r((e, t) => ({
        type: "TypeUnion",
        elements: e.elements.map((o) => t(o))
      }), "JsdocTypeUnion"),
      JsdocTypeKeyValue: /* @__PURE__ */ r((e, t) => ({
        type: "FieldType",
        key: F(e.key),
        value: e.right === void 0 ? void 0 : t(e.right)
      }), "JsdocTypeKeyValue"),
      JsdocTypeNamePath: /* @__PURE__ */ r((e, t) => {
        let o = t(e.left), i;
        e.right.type === "JsdocTypeSpecialNamePath" ? i = t(e.right).name : i = I(e.right.value, e.right.meta.quote);
        let l = e.pathType === "inner" ? "~" : e.pathType === "instance" ? "#" : ".";
        return F(`${o.name}${l}${i}`);
      }, "JsdocTypeNamePath"),
      JsdocTypeSymbol: /* @__PURE__ */ r((e) => {
        let t = "", o = e.element, i = !1;
        return o?.type === "JsdocTypeVariadic" && (o.meta.position === "prefix" ? t = "..." : i = !0, o = o.element), o?.type === "JsdocType\
Name" ? t += o.value : o?.type === "JsdocTypeNumber" && (t += o.value.toString()), i && (t += "..."), F(`${e.value}(${t})`);
      }, "JsdocTypeSymbol"),
      JsdocTypeParenthesis: /* @__PURE__ */ r((e, t) => t(P(e.element)), "JsdocTypeParenthesis"),
      JsdocTypeMappedType: O,
      JsdocTypeIndexSignature: O,
      JsdocTypeImport: O,
      JsdocTypeKeyof: O,
      JsdocTypeTuple: O,
      JsdocTypeTypeof: O,
      JsdocTypeIntersection: O,
      JsdocTypeProperty: O,
      JsdocTypePredicate: O
    };
    function nr(e) {
      return W(rr, e);
    }
    r(nr, "catharsisTransform");
    function _(e) {
      switch (e) {
        case void 0:
          return "none";
        case "single":
          return "single";
        case "double":
          return "double";
      }
    }
    r(_, "getQuoteStyle");
    function or(e) {
      switch (e) {
        case "inner":
          return "INNER_MEMBER";
        case "instance":
          return "INSTANCE_MEMBER";
        case "property":
          return "MEMBER";
        case "property-brackets":
          return "MEMBER";
      }
    }
    r(or, "getMemberType");
    function Se(e, t) {
      return t.length === 2 ? {
        type: e,
        left: t[0],
        right: t[1]
      } : {
        type: e,
        left: t[0],
        right: Se(e, t.slice(1))
      };
    }
    r(Se, "nestResults");
    let sr = {
      JsdocTypeOptional: /* @__PURE__ */ r((e, t) => ({
        type: "OPTIONAL",
        value: t(e.element),
        meta: {
          syntax: e.meta.position === "prefix" ? "PREFIX_EQUAL_SIGN" : "SUFFIX_EQUALS_SIGN"
        }
      }), "JsdocTypeOptional"),
      JsdocTypeNullable: /* @__PURE__ */ r((e, t) => ({
        type: "NULLABLE",
        value: t(e.element),
        meta: {
          syntax: e.meta.position === "prefix" ? "PREFIX_QUESTION_MARK" : "SUFFIX_QUESTION_MARK"
        }
      }), "JsdocTypeNullable"),
      JsdocTypeNotNullable: /* @__PURE__ */ r((e, t) => ({
        type: "NOT_NULLABLE",
        value: t(e.element),
        meta: {
          syntax: e.meta.position === "prefix" ? "PREFIX_BANG" : "SUFFIX_BANG"
        }
      }), "JsdocTypeNotNullable"),
      JsdocTypeVariadic: /* @__PURE__ */ r((e, t) => {
        let o = {
          type: "VARIADIC",
          meta: {
            syntax: e.meta.position === "prefix" ? "PREFIX_DOTS" : e.meta.position === "suffix" ? "SUFFIX_DOTS" : "ONLY_DOTS"
          }
        };
        return e.element !== void 0 && (o.value = t(e.element)), o;
      }, "JsdocTypeVariadic"),
      JsdocTypeName: /* @__PURE__ */ r((e) => ({
        type: "NAME",
        name: e.value
      }), "JsdocTypeName"),
      JsdocTypeTypeof: /* @__PURE__ */ r((e, t) => ({
        type: "TYPE_QUERY",
        name: t(e.element)
      }), "JsdocTypeTypeof"),
      JsdocTypeTuple: /* @__PURE__ */ r((e, t) => ({
        type: "TUPLE",
        entries: e.elements.map(t)
      }), "JsdocTypeTuple"),
      JsdocTypeKeyof: /* @__PURE__ */ r((e, t) => ({
        type: "KEY_QUERY",
        value: t(e.element)
      }), "JsdocTypeKeyof"),
      JsdocTypeImport: /* @__PURE__ */ r((e) => ({
        type: "IMPORT",
        path: {
          type: "STRING_VALUE",
          quoteStyle: _(e.element.meta.quote),
          string: e.element.value
        }
      }), "JsdocTypeImport"),
      JsdocTypeUndefined: /* @__PURE__ */ r(() => ({
        type: "NAME",
        name: "undefined"
      }), "JsdocTypeUndefined"),
      JsdocTypeAny: /* @__PURE__ */ r(() => ({
        type: "ANY"
      }), "JsdocTypeAny"),
      JsdocTypeFunction: /* @__PURE__ */ r((e, t) => {
        let o = Ge(e), i = {
          type: e.arrow ? "ARROW" : "FUNCTION",
          params: o.params.map((l) => {
            if (l.type === "JsdocTypeKeyValue") {
              if (l.right === void 0)
                throw new Error("Function parameter without ':' is not expected to be 'KEY_VALUE'");
              return {
                type: "NAMED_PARAMETER",
                name: l.key,
                typeName: t(l.right)
              };
            } else
              return t(l);
          }),
          new: null,
          returns: null
        };
        return o.this !== void 0 ? i.this = t(o.this) : e.arrow || (i.this = null), o.new !== void 0 && (i.new = t(o.new)), e.returnType !==
        void 0 && (i.returns = t(e.returnType)), i;
      }, "JsdocTypeFunction"),
      JsdocTypeGeneric: /* @__PURE__ */ r((e, t) => {
        let o = {
          type: "GENERIC",
          subject: t(e.left),
          objects: e.elements.map(t),
          meta: {
            syntax: e.meta.brackets === "square" ? "SQUARE_BRACKET" : e.meta.dot ? "ANGLE_BRACKET_WITH_DOT" : "ANGLE_BRACKET"
          }
        };
        return e.meta.brackets === "square" && e.elements[0].type === "JsdocTypeFunction" && !e.elements[0].parenthesis && (o.objects[0] = {
          type: "NAME",
          name: "function"
        }), o;
      }, "JsdocTypeGeneric"),
      JsdocTypeObjectField: /* @__PURE__ */ r((e, t) => {
        if (typeof e.key != "string")
          throw new Error("Index signatures and mapped types are not supported");
        if (e.right === void 0)
          return {
            type: "RECORD_ENTRY",
            key: e.key,
            quoteStyle: _(e.meta.quote),
            value: null,
            readonly: !1
          };
        let o = t(e.right);
        return e.optional && (o = {
          type: "OPTIONAL",
          value: o,
          meta: {
            syntax: "SUFFIX_KEY_QUESTION_MARK"
          }
        }), {
          type: "RECORD_ENTRY",
          key: e.key.toString(),
          quoteStyle: _(e.meta.quote),
          value: o,
          readonly: !1
        };
      }, "JsdocTypeObjectField"),
      JsdocTypeJsdocObjectField: /* @__PURE__ */ r(() => {
        throw new Error("Keys may not be typed in jsdoctypeparser.");
      }, "JsdocTypeJsdocObjectField"),
      JsdocTypeKeyValue: /* @__PURE__ */ r((e, t) => {
        if (e.right === void 0)
          return {
            type: "RECORD_ENTRY",
            key: e.key,
            quoteStyle: "none",
            value: null,
            readonly: !1
          };
        let o = t(e.right);
        return e.optional && (o = {
          type: "OPTIONAL",
          value: o,
          meta: {
            syntax: "SUFFIX_KEY_QUESTION_MARK"
          }
        }), {
          type: "RECORD_ENTRY",
          key: e.key,
          quoteStyle: "none",
          value: o,
          readonly: !1
        };
      }, "JsdocTypeKeyValue"),
      JsdocTypeObject: /* @__PURE__ */ r((e, t) => {
        let o = [];
        for (let i of e.elements)
          (i.type === "JsdocTypeObjectField" || i.type === "JsdocTypeJsdocObjectField") && o.push(t(i));
        return {
          type: "RECORD",
          entries: o
        };
      }, "JsdocTypeObject"),
      JsdocTypeSpecialNamePath: /* @__PURE__ */ r((e) => {
        if (e.specialType !== "module")
          throw new Error(`jsdoctypeparser does not support type ${e.specialType} at this point.`);
        return {
          type: "MODULE",
          value: {
            type: "FILE_PATH",
            quoteStyle: _(e.meta.quote),
            path: e.value
          }
        };
      }, "JsdocTypeSpecialNamePath"),
      JsdocTypeNamePath: /* @__PURE__ */ r((e, t) => {
        let o = !1, i, l;
        e.right.type === "JsdocTypeSpecialNamePath" && e.right.specialType === "event" ? (o = !0, i = e.right.value, l = _(e.right.meta.quote)) :
        (i = e.right.value, l = _(e.right.meta.quote));
        let y = {
          type: or(e.pathType),
          owner: t(e.left),
          name: i,
          quoteStyle: l,
          hasEventPrefix: o
        };
        if (y.owner.type === "MODULE") {
          let d = y.owner;
          return y.owner = y.owner.value, d.value = y, d;
        } else
          return y;
      }, "JsdocTypeNamePath"),
      JsdocTypeUnion: /* @__PURE__ */ r((e, t) => Se("UNION", e.elements.map(t)), "JsdocTypeUnion"),
      JsdocTypeParenthesis: /* @__PURE__ */ r((e, t) => ({
        type: "PARENTHESIS",
        value: t(P(e.element))
      }), "JsdocTypeParenthesis"),
      JsdocTypeNull: /* @__PURE__ */ r(() => ({
        type: "NAME",
        name: "null"
      }), "JsdocTypeNull"),
      JsdocTypeUnknown: /* @__PURE__ */ r(() => ({
        type: "UNKNOWN"
      }), "JsdocTypeUnknown"),
      JsdocTypeStringValue: /* @__PURE__ */ r((e) => ({
        type: "STRING_VALUE",
        quoteStyle: _(e.meta.quote),
        string: e.value
      }), "JsdocTypeStringValue"),
      JsdocTypeIntersection: /* @__PURE__ */ r((e, t) => Se("INTERSECTION", e.elements.map(t)), "JsdocTypeIntersection"),
      JsdocTypeNumber: /* @__PURE__ */ r((e) => ({
        type: "NUMBER_VALUE",
        number: e.value.toString()
      }), "JsdocTypeNumber"),
      JsdocTypeSymbol: O,
      JsdocTypeProperty: O,
      JsdocTypePredicate: O,
      JsdocTypeMappedType: O,
      JsdocTypeIndexSignature: O
    };
    function ar(e) {
      return W(sr, e);
    }
    r(ar, "jtpTransform");
    function ir() {
      return {
        JsdocTypeIntersection: /* @__PURE__ */ r((e, t) => ({
          type: "JsdocTypeIntersection",
          elements: e.elements.map(t)
        }), "JsdocTypeIntersection"),
        JsdocTypeGeneric: /* @__PURE__ */ r((e, t) => ({
          type: "JsdocTypeGeneric",
          left: t(e.left),
          elements: e.elements.map(t),
          meta: {
            dot: e.meta.dot,
            brackets: e.meta.brackets
          }
        }), "JsdocTypeGeneric"),
        JsdocTypeNullable: /* @__PURE__ */ r((e) => e, "JsdocTypeNullable"),
        JsdocTypeUnion: /* @__PURE__ */ r((e, t) => ({
          type: "JsdocTypeUnion",
          elements: e.elements.map(t)
        }), "JsdocTypeUnion"),
        JsdocTypeUnknown: /* @__PURE__ */ r((e) => e, "JsdocTypeUnknown"),
        JsdocTypeUndefined: /* @__PURE__ */ r((e) => e, "JsdocTypeUndefined"),
        JsdocTypeTypeof: /* @__PURE__ */ r((e, t) => ({
          type: "JsdocTypeTypeof",
          element: t(e.element)
        }), "JsdocTypeTypeof"),
        JsdocTypeSymbol: /* @__PURE__ */ r((e, t) => {
          let o = {
            type: "JsdocTypeSymbol",
            value: e.value
          };
          return e.element !== void 0 && (o.element = t(e.element)), o;
        }, "JsdocTypeSymbol"),
        JsdocTypeOptional: /* @__PURE__ */ r((e, t) => ({
          type: "JsdocTypeOptional",
          element: t(e.element),
          meta: {
            position: e.meta.position
          }
        }), "JsdocTypeOptional"),
        JsdocTypeObject: /* @__PURE__ */ r((e, t) => ({
          type: "JsdocTypeObject",
          meta: {
            separator: "comma"
          },
          elements: e.elements.map(t)
        }), "JsdocTypeObject"),
        JsdocTypeNumber: /* @__PURE__ */ r((e) => e, "JsdocTypeNumber"),
        JsdocTypeNull: /* @__PURE__ */ r((e) => e, "JsdocTypeNull"),
        JsdocTypeNotNullable: /* @__PURE__ */ r((e, t) => ({
          type: "JsdocTypeNotNullable",
          element: t(e.element),
          meta: {
            position: e.meta.position
          }
        }), "JsdocTypeNotNullable"),
        JsdocTypeSpecialNamePath: /* @__PURE__ */ r((e) => e, "JsdocTypeSpecialNamePath"),
        JsdocTypeObjectField: /* @__PURE__ */ r((e, t) => ({
          type: "JsdocTypeObjectField",
          key: e.key,
          right: e.right === void 0 ? void 0 : t(e.right),
          optional: e.optional,
          readonly: e.readonly,
          meta: e.meta
        }), "JsdocTypeObjectField"),
        JsdocTypeJsdocObjectField: /* @__PURE__ */ r((e, t) => ({
          type: "JsdocTypeJsdocObjectField",
          left: t(e.left),
          right: t(e.right)
        }), "JsdocTypeJsdocObjectField"),
        JsdocTypeKeyValue: /* @__PURE__ */ r((e, t) => ({
          type: "JsdocTypeKeyValue",
          key: e.key,
          right: e.right === void 0 ? void 0 : t(e.right),
          optional: e.optional,
          variadic: e.variadic
        }), "JsdocTypeKeyValue"),
        JsdocTypeImport: /* @__PURE__ */ r((e, t) => ({
          type: "JsdocTypeImport",
          element: t(e.element)
        }), "JsdocTypeImport"),
        JsdocTypeAny: /* @__PURE__ */ r((e) => e, "JsdocTypeAny"),
        JsdocTypeStringValue: /* @__PURE__ */ r((e) => e, "JsdocTypeStringValue"),
        JsdocTypeNamePath: /* @__PURE__ */ r((e) => e, "JsdocTypeNamePath"),
        JsdocTypeVariadic: /* @__PURE__ */ r((e, t) => {
          let o = {
            type: "JsdocTypeVariadic",
            meta: {
              position: e.meta.position,
              squareBrackets: e.meta.squareBrackets
            }
          };
          return e.element !== void 0 && (o.element = t(e.element)), o;
        }, "JsdocTypeVariadic"),
        JsdocTypeTuple: /* @__PURE__ */ r((e, t) => ({
          type: "JsdocTypeTuple",
          elements: e.elements.map(t)
        }), "JsdocTypeTuple"),
        JsdocTypeName: /* @__PURE__ */ r((e) => e, "JsdocTypeName"),
        JsdocTypeFunction: /* @__PURE__ */ r((e, t) => {
          let o = {
            type: "JsdocTypeFunction",
            arrow: e.arrow,
            parameters: e.parameters.map(t),
            constructor: e.constructor,
            parenthesis: e.parenthesis
          };
          return e.returnType !== void 0 && (o.returnType = t(e.returnType)), o;
        }, "JsdocTypeFunction"),
        JsdocTypeKeyof: /* @__PURE__ */ r((e, t) => ({
          type: "JsdocTypeKeyof",
          element: t(e.element)
        }), "JsdocTypeKeyof"),
        JsdocTypeParenthesis: /* @__PURE__ */ r((e, t) => ({
          type: "JsdocTypeParenthesis",
          element: t(e.element)
        }), "JsdocTypeParenthesis"),
        JsdocTypeProperty: /* @__PURE__ */ r((e) => e, "JsdocTypeProperty"),
        JsdocTypePredicate: /* @__PURE__ */ r((e, t) => ({
          type: "JsdocTypePredicate",
          left: t(e.left),
          right: t(e.right)
        }), "JsdocTypePredicate"),
        JsdocTypeIndexSignature: /* @__PURE__ */ r((e, t) => ({
          type: "JsdocTypeIndexSignature",
          key: e.key,
          right: t(e.right)
        }), "JsdocTypeIndexSignature"),
        JsdocTypeMappedType: /* @__PURE__ */ r((e, t) => ({
          type: "JsdocTypeMappedType",
          key: e.key,
          right: t(e.right)
        }), "JsdocTypeMappedType")
      };
    }
    r(ir, "identityTransformRules");
    let Xe = {
      JsdocTypeAny: [],
      JsdocTypeFunction: ["parameters", "returnType"],
      JsdocTypeGeneric: ["left", "elements"],
      JsdocTypeImport: [],
      JsdocTypeIndexSignature: ["right"],
      JsdocTypeIntersection: ["elements"],
      JsdocTypeKeyof: ["element"],
      JsdocTypeKeyValue: ["right"],
      JsdocTypeMappedType: ["right"],
      JsdocTypeName: [],
      JsdocTypeNamePath: ["left", "right"],
      JsdocTypeNotNullable: ["element"],
      JsdocTypeNull: [],
      JsdocTypeNullable: ["element"],
      JsdocTypeNumber: [],
      JsdocTypeObject: ["elements"],
      JsdocTypeObjectField: ["right"],
      JsdocTypeJsdocObjectField: ["left", "right"],
      JsdocTypeOptional: ["element"],
      JsdocTypeParenthesis: ["element"],
      JsdocTypeSpecialNamePath: [],
      JsdocTypeStringValue: [],
      JsdocTypeSymbol: ["element"],
      JsdocTypeTuple: ["elements"],
      JsdocTypeTypeof: ["element"],
      JsdocTypeUndefined: [],
      JsdocTypeUnion: ["elements"],
      JsdocTypeUnknown: [],
      JsdocTypeVariadic: ["element"],
      JsdocTypeProperty: [],
      JsdocTypePredicate: ["left", "right"]
    };
    function Ne(e, t, o, i, l) {
      i?.(e, t, o);
      let y = Xe[e.type];
      for (let d of y) {
        let x = e[d];
        if (x !== void 0)
          if (Array.isArray(x))
            for (let N of x)
              Ne(N, e, d, i, l);
          else
            Ne(x, e, d, i, l);
      }
      l?.(e, t, o);
    }
    r(Ne, "_traverse");
    function pr(e, t, o) {
      Ne(e, void 0, void 0, t, o);
    }
    r(pr, "traverse"), n.catharsisTransform = nr, n.identityTransformRules = ir, n.jtpTransform = ar, n.parse = We, n.stringify = er, n.stringifyRules =
    ze, n.transform = W, n.traverse = pr, n.tryParse = Qt, n.visitorKeys = Xe;
  });
});

// src/docs-tools/argTypes/convert/flow/convert.ts
import { UnknownArgTypesError as gr } from "storybook/internal/preview-errors";
var hr = /* @__PURE__ */ r((n) => n.name === "literal", "isLiteral"), xr = /* @__PURE__ */ r((n) => n.value.replace(/['|"]/g, ""), "toEnumOp\
tion"), Jr = /* @__PURE__ */ r((n) => {
  switch (n.type) {
    case "function":
      return { name: "function" };
    case "object":
      let s = {};
      return n.signature.properties.forEach((a) => {
        s[a.key] = U(a.value);
      }), {
        name: "object",
        value: s
      };
    default:
      throw new gr({ type: n, language: "Flow" });
  }
}, "convertSig"), U = /* @__PURE__ */ r((n) => {
  let { name: s, raw: a } = n, p = {};
  switch (typeof a < "u" && (p.raw = a), n.name) {
    case "literal":
      return { ...p, name: "other", value: n.value };
    case "string":
    case "number":
    case "symbol":
    case "boolean":
      return { ...p, name: s };
    case "Array":
      return { ...p, name: "array", value: n.elements.map(U) };
    case "signature":
      return { ...p, ...Jr(n) };
    case "union":
      return n.elements?.every(hr) ? { ...p, name: "enum", value: n.elements?.map(xr) } : { ...p, name: s, value: n.elements?.map(U) };
    case "intersection":
      return { ...p, name: s, value: n.elements?.map(U) };
    default:
      return { ...p, name: "other", value: s };
  }
}, "convert");

// ../node_modules/es-toolkit/dist/predicate/isPlainObject.mjs
function z(n) {
  if (typeof n != "object" || n == null)
    return !1;
  if (Object.getPrototypeOf(n) === null)
    return !0;
  if (n.toString() !== "[object Object]")
    return !1;
  let s = n;
  for (; Object.getPrototypeOf(s) !== null; )
    s = Object.getPrototypeOf(s);
  return Object.getPrototypeOf(n) === s;
}
r(z, "isPlainObject");

// ../node_modules/es-toolkit/dist/object/mapValues.mjs
function De(n, s) {
  let a = {}, p = Object.keys(n);
  for (let c = 0; c < p.length; c++) {
    let u = p[c], m = n[u];
    a[u] = s(m, u, n);
  }
  return a;
}
r(De, "mapValues");

// src/docs-tools/argTypes/convert/utils.ts
var Ze = /^['"]|['"]$/g, Pr = /* @__PURE__ */ r((n) => n.replace(Ze, ""), "trimQuotes"), wr = /* @__PURE__ */ r((n) => Ze.test(n), "includes\
Quotes"), oe = /* @__PURE__ */ r((n) => {
  let s = Pr(n);
  return wr(n) || Number.isNaN(Number(s)) ? s : Number(s);
}, "parseLiteral");

// src/docs-tools/argTypes/convert/proptypes/convert.ts
var br = /^\(.*\) => /, B = /* @__PURE__ */ r((n) => {
  let { name: s, raw: a, computed: p, value: c } = n, u = {};
  switch (typeof a < "u" && (u.raw = a), s) {
    case "enum": {
      let T = p ? c : c.map((g) => oe(g.value));
      return { ...u, name: s, value: T };
    }
    case "string":
    case "number":
    case "symbol":
      return { ...u, name: s };
    case "func":
      return { ...u, name: "function" };
    case "bool":
    case "boolean":
      return { ...u, name: "boolean" };
    case "arrayOf":
    case "array":
      return { ...u, name: "array", value: c && B(c) };
    case "object":
      return { ...u, name: s };
    case "objectOf":
      return { ...u, name: s, value: B(c) };
    case "shape":
    case "exact":
      let m = De(c, (T) => B(T));
      return { ...u, name: "object", value: m };
    case "union":
      return { ...u, name: "union", value: c.map((T) => B(T)) };
    case "instanceOf":
    case "element":
    case "elementType":
    default: {
      if (s?.indexOf("|") > 0)
        try {
          let w = s.split("|").map((b) => JSON.parse(b));
          return { ...u, name: "enum", value: w };
        } catch {
        }
      let T = c ? `${s}(${c})` : s, g = br.test(s) ? "function" : "other";
      return { ...u, name: g, value: T };
    }
  }
}, "convert");

// src/docs-tools/argTypes/convert/typescript/convert.ts
import { UnknownArgTypesError as Er } from "storybook/internal/preview-errors";
var Sr = /* @__PURE__ */ r((n) => {
  switch (n.type) {
    case "function":
      return { name: "function" };
    case "object":
      let s = {};
      return n.signature.properties.forEach((a) => {
        s[a.key] = C(a.value);
      }), {
        name: "object",
        value: s
      };
    default:
      throw new Er({ type: n, language: "Typescript" });
  }
}, "convertSig"), C = /* @__PURE__ */ r((n) => {
  let { name: s, raw: a } = n, p = {};
  switch (typeof a < "u" && (p.raw = a), n.name) {
    case "string":
    case "number":
    case "symbol":
    case "boolean":
      return { ...p, name: s };
    case "Array":
      return { ...p, name: "array", value: n.elements.map(C) };
    case "signature":
      return { ...p, ...Sr(n) };
    case "union":
      let c;
      return n.elements?.every((u) => u.name === "literal") ? c = {
        ...p,
        name: "enum",
        // @ts-expect-error fix types
        value: n.elements?.map((u) => oe(u.value))
      } : c = { ...p, name: s, value: n.elements?.map(C) }, c;
    case "intersection":
      return { ...p, name: s, value: n.elements?.map(C) };
    default:
      return { ...p, name: "other", value: s };
  }
}, "convert");

// src/docs-tools/argTypes/convert/index.ts
var se = /* @__PURE__ */ r((n) => {
  let { type: s, tsType: a, flowType: p } = n;
  try {
    if (s != null)
      return B(s);
    if (a != null)
      return C(a);
    if (p != null)
      return U(p);
  } catch (c) {
    console.error(c);
  }
  return null;
}, "convert");

// src/docs-tools/argTypes/docgen/types.ts
var Nr = /* @__PURE__ */ ((c) => (c.JAVASCRIPT = "JavaScript", c.FLOW = "Flow", c.TYPESCRIPT = "TypeScript", c.UNKNOWN = "Unknown", c))(Nr ||
{});

// src/docs-tools/argTypes/docgen/utils/defaultValue.ts
var Or = ["null", "undefined"];
function M(n) {
  return Or.some((s) => s === n);
}
r(M, "isDefaultValueBlacklisted");

// src/docs-tools/argTypes/docgen/utils/string.ts
var et = /* @__PURE__ */ r((n) => {
  if (!n)
    return "";
  if (typeof n == "string")
    return n;
  throw new Error(`Description: expected string, got: ${JSON.stringify(n)}`);
}, "str");

// src/docs-tools/argTypes/docgen/utils/docgenInfo.ts
function tt(n) {
  return !!n.__docgenInfo;
}
r(tt, "hasDocgen");
function rt(n) {
  return n != null && Object.keys(n).length > 0;
}
r(rt, "isValidDocgenSection");
function nt(n, s) {
  return tt(n) ? n.__docgenInfo[s] : null;
}
r(nt, "getDocgenSection");
function ot(n) {
  return tt(n) ? et(n.__docgenInfo.description) : "";
}
r(ot, "getDocgenDescription");

// ../node_modules/comment-parser/es6/primitives.js
var v;
(function(n) {
  n.start = "/**", n.nostart = "/***", n.delim = "*", n.end = "*/";
})(v = v || (v = {}));

// ../node_modules/comment-parser/es6/util.js
function ve(n) {
  return /^\s+$/.test(n);
}
r(ve, "isSpace");
function st(n) {
  let s = n.match(/\r+$/);
  return s == null ? ["", n] : [n.slice(-s[0].length), n.slice(0, -s[0].length)];
}
r(st, "splitCR");
function A(n) {
  let s = n.match(/^\s+/);
  return s == null ? ["", n] : [n.slice(0, s[0].length), n.slice(s[0].length)];
}
r(A, "splitSpace");
function at(n) {
  return n.split(/\n/);
}
r(at, "splitLines");
function it(n = {}) {
  return Object.assign({ tag: "", name: "", type: "", optional: !1, description: "", problems: [], source: [] }, n);
}
r(it, "seedSpec");
function ke(n = {}) {
  return Object.assign({ start: "", delimiter: "", postDelimiter: "", tag: "", postTag: "", name: "", postName: "", type: "", postType: "", description: "",
  end: "", lineEnd: "" }, n);
}
r(ke, "seedTokens");

// ../node_modules/comment-parser/es6/parser/block-parser.js
var Dr = /^@\S+/;
function Ae({ fence: n = "```" } = {}) {
  let s = vr(n), a = /* @__PURE__ */ r((p, c) => s(p) ? !c : c, "toggleFence");
  return /* @__PURE__ */ r(function(c) {
    let u = [[]], m = !1;
    for (let T of c)
      Dr.test(T.tokens.description) && !m ? u.push([T]) : u[u.length - 1].push(T), m = a(T.tokens.description, m);
    return u;
  }, "parseBlock");
}
r(Ae, "getParser");
function vr(n) {
  return typeof n == "string" ? (s) => s.split(n).length % 2 === 0 : n;
}
r(vr, "getFencer");

// ../node_modules/comment-parser/es6/parser/source-parser.js
function Re({ startLine: n = 0, markers: s = v } = {}) {
  let a = null, p = n;
  return /* @__PURE__ */ r(function(u) {
    let m = u, T = ke();
    if ([T.lineEnd, m] = st(m), [T.start, m] = A(m), a === null && m.startsWith(s.start) && !m.startsWith(s.nostart) && (a = [], T.delimiter =
    m.slice(0, s.start.length), m = m.slice(s.start.length), [T.postDelimiter, m] = A(m)), a === null)
      return p++, null;
    let g = m.trimRight().endsWith(s.end);
    if (T.delimiter === "" && m.startsWith(s.delim) && !m.startsWith(s.end) && (T.delimiter = s.delim, m = m.slice(s.delim.length), [T.postDelimiter,
    m] = A(m)), g) {
      let w = m.trimRight();
      T.end = m.slice(w.length - s.end.length), m = w.slice(0, -s.end.length);
    }
    if (T.description = m, a.push({ number: p, source: u, tokens: T }), p++, g) {
      let w = a.slice();
      return a = null, w;
    }
    return null;
  }, "parseSource");
}
r(Re, "getParser");

// ../node_modules/comment-parser/es6/parser/spec-parser.js
function Ie({ tokenizers: n }) {
  return /* @__PURE__ */ r(function(a) {
    var p;
    let c = it({ source: a });
    for (let u of n)
      if (c = u(c), !((p = c.problems[c.problems.length - 1]) === null || p === void 0) && p.critical)
        break;
    return c;
  }, "parseSpec");
}
r(Ie, "getParser");

// ../node_modules/comment-parser/es6/parser/tokenizers/tag.js
function ae() {
  return (n) => {
    let { tokens: s } = n.source[0], a = s.description.match(/\s*(@(\S+))(\s*)/);
    return a === null ? (n.problems.push({
      code: "spec:tag:prefix",
      message: 'tag should start with "@" symbol',
      line: n.source[0].number,
      critical: !0
    }), n) : (s.tag = a[1], s.postTag = a[3], s.description = s.description.slice(a[0].length), n.tag = a[2], n);
  };
}
r(ae, "tagTokenizer");

// ../node_modules/comment-parser/es6/parser/tokenizers/type.js
function ie(n = "compact") {
  let s = Ar(n);
  return (a) => {
    let p = 0, c = [];
    for (let [T, { tokens: g }] of a.source.entries()) {
      let w = "";
      if (T === 0 && g.description[0] !== "{")
        return a;
      for (let b of g.description)
        if (b === "{" && p++, b === "}" && p--, w += b, p === 0)
          break;
      if (c.push([g, w]), p === 0)
        break;
    }
    if (p !== 0)
      return a.problems.push({
        code: "spec:type:unpaired-curlies",
        message: "unpaired curlies",
        line: a.source[0].number,
        critical: !0
      }), a;
    let u = [], m = c[0][0].postDelimiter.length;
    for (let [T, [g, w]] of c.entries())
      g.type = w, T > 0 && (g.type = g.postDelimiter.slice(m) + w, g.postDelimiter = g.postDelimiter.slice(0, m)), [g.postType, g.description] =
      A(g.description.slice(w.length)), u.push(g.type);
    return u[0] = u[0].slice(1), u[u.length - 1] = u[u.length - 1].slice(0, -1), a.type = s(u), a;
  };
}
r(ie, "typeTokenizer");
var kr = /* @__PURE__ */ r((n) => n.trim(), "trim");
function Ar(n) {
  return n === "compact" ? (s) => s.map(kr).join("") : n === "preserve" ? (s) => s.join(`
`) : n;
}
r(Ar, "getJoiner");

// ../node_modules/comment-parser/es6/parser/tokenizers/name.js
var Rr = /* @__PURE__ */ r((n) => n && n.startsWith('"') && n.endsWith('"'), "isQuoted");
function pe() {
  let n = /* @__PURE__ */ r((s, { tokens: a }, p) => a.type === "" ? s : p, "typeEnd");
  return (s) => {
    let { tokens: a } = s.source[s.source.reduce(n, 0)], p = a.description.trimLeft(), c = p.split('"');
    if (c.length > 1 && c[0] === "" && c.length % 2 === 1)
      return s.name = c[1], a.name = `"${c[1]}"`, [a.postName, a.description] = A(p.slice(a.name.length)), s;
    let u = 0, m = "", T = !1, g;
    for (let b of p) {
      if (u === 0 && ve(b))
        break;
      b === "[" && u++, b === "]" && u--, m += b;
    }
    if (u !== 0)
      return s.problems.push({
        code: "spec:name:unpaired-brackets",
        message: "unpaired brackets",
        line: s.source[0].number,
        critical: !0
      }), s;
    let w = m;
    if (m[0] === "[" && m[m.length - 1] === "]") {
      T = !0, m = m.slice(1, -1);
      let b = m.split("=");
      if (m = b[0].trim(), b[1] !== void 0 && (g = b.slice(1).join("=").trim()), m === "")
        return s.problems.push({
          code: "spec:name:empty-name",
          message: "empty name",
          line: s.source[0].number,
          critical: !0
        }), s;
      if (g === "")
        return s.problems.push({
          code: "spec:name:empty-default",
          message: "empty default value",
          line: s.source[0].number,
          critical: !0
        }), s;
      if (!Rr(g) && /=(?!>)/.test(g))
        return s.problems.push({
          code: "spec:name:invalid-default",
          message: "invalid default value syntax",
          line: s.source[0].number,
          critical: !0
        }), s;
    }
    return s.optional = T, s.name = m, a.name = w, g !== void 0 && (s.default = g), [a.postName, a.description] = A(p.slice(a.name.length)),
    s;
  };
}
r(pe, "nameTokenizer");

// ../node_modules/comment-parser/es6/parser/tokenizers/description.js
function ce(n = "compact", s = v) {
  let a = Fe(n);
  return (p) => (p.description = a(p.source, s), p);
}
r(ce, "descriptionTokenizer");
function Fe(n) {
  return n === "compact" ? Ir : n === "preserve" ? _r : n;
}
r(Fe, "getJoiner");
function Ir(n, s = v) {
  return n.map(({ tokens: { description: a } }) => a.trim()).filter((a) => a !== "").join(" ");
}
r(Ir, "compactJoiner");
var Fr = /* @__PURE__ */ r((n, { tokens: s }, a) => s.type === "" ? n : a, "lineNo"), jr = /* @__PURE__ */ r(({ tokens: n }) => (n.delimiter ===
"" ? n.start : n.postDelimiter.slice(1)) + n.description, "getDescription");
function _r(n, s = v) {
  if (n.length === 0)
    return "";
  n[0].tokens.description === "" && n[0].tokens.delimiter === s.start && (n = n.slice(1));
  let a = n[n.length - 1];
  return a !== void 0 && a.tokens.description === "" && a.tokens.end.endsWith(s.end) && (n = n.slice(0, -1)), n = n.slice(n.reduce(Fr, 0)), n.
  map(jr).join(`
`);
}
r(_r, "preserveJoiner");

// ../node_modules/comment-parser/es6/parser/index.js
function je({ startLine: n = 0, fence: s = "```", spacing: a = "compact", markers: p = v, tokenizers: c = [
  ae(),
  ie(a),
  pe(),
  ce(a)
] } = {}) {
  if (n < 0 || n % 1 > 0)
    throw new Error("Invalid startLine");
  let u = Re({ startLine: n, markers: p }), m = Ae({ fence: s }), T = Ie({ tokenizers: c }), g = Fe(a);
  return function(w) {
    let b = [];
    for (let me of at(w)) {
      let $ = u(me);
      if ($ === null)
        continue;
      let E = m($), X = E.slice(1).map(T);
      b.push({
        description: g(E[0], p),
        tags: X,
        source: $,
        problems: X.reduce((ye, fe) => ye.concat(fe.problems), [])
      });
    }
    return b;
  };
}
r(je, "getParser");

// ../node_modules/comment-parser/es6/stringifier/index.js
function Lr(n) {
  return n.start + n.delimiter + n.postDelimiter + n.tag + n.postTag + n.type + n.postType + n.name + n.postName + n.description + n.end + n.
  lineEnd;
}
r(Lr, "join");
function _e() {
  return (n) => n.source.map(({ tokens: s }) => Lr(s)).join(`
`);
}
r(_e, "getStringifier");

// ../node_modules/comment-parser/es6/stringifier/inspect.js
var Vr = {
  line: 0,
  start: 0,
  delimiter: 0,
  postDelimiter: 0,
  tag: 0,
  postTag: 0,
  name: 0,
  postName: 0,
  type: 0,
  postType: 0,
  description: 0,
  end: 0,
  lineEnd: 0
};
var Mo = Object.keys(Vr);

// ../node_modules/comment-parser/es6/index.js
function pt(n, s = {}) {
  return je(s)(n);
}
r(pt, "parse");
var cs = _e();

// src/docs-tools/argTypes/jsdocParser.ts
var K = Tr(lt(), 1);
function Ur(n) {
  return n != null && n.includes("@");
}
r(Ur, "containsJsDoc");
function Br(n) {
  let p = `/**
` + (n ?? "").split(`
`).map((u) => ` * ${u}`).join(`
`) + `
*/`, c = pt(p, {
    spacing: "preserve"
  });
  if (!c || c.length === 0)
    throw new Error("Cannot parse JSDoc tags.");
  return c[0];
}
r(Br, "parse");
var Cr = {
  tags: ["param", "arg", "argument", "returns", "ignore", "deprecated"]
}, ut = /* @__PURE__ */ r((n, s = Cr) => {
  if (!Ur(n))
    return {
      includesJsDoc: !1,
      ignore: !1
    };
  let a = Br(n), p = Mr(a, s.tags);
  return p.ignore ? {
    includesJsDoc: !0,
    ignore: !0
  } : {
    includesJsDoc: !0,
    ignore: !1,
    // Always use the parsed description to ensure JSDoc is removed from the description.
    description: a.description.trim(),
    extractedTags: p
  };
}, "parseJsDoc");
function Mr(n, s) {
  let a = {
    params: null,
    deprecated: null,
    returns: null,
    ignore: !1
  };
  for (let p of n.tags)
    if (!(s !== void 0 && !s.includes(p.tag)))
      if (p.tag === "ignore") {
        a.ignore = !0;
        break;
      } else
        switch (p.tag) {
          // arg & argument are aliases for param.
          case "param":
          case "arg":
          case "argument": {
            let c = $r(p);
            c != null && (a.params == null && (a.params = []), a.params.push(c));
            break;
          }
          case "deprecated": {
            let c = qr(p);
            c != null && (a.deprecated = c);
            break;
          }
          case "returns": {
            let c = Yr(p);
            c != null && (a.returns = c);
            break;
          }
          default:
            break;
        }
  return a;
}
r(Mr, "extractJsDocTags");
function Kr(n) {
  return n.replace(/[\.-]$/, "");
}
r(Kr, "normaliseParamName");
function $r(n) {
  if (!n.name || n.name === "-")
    return null;
  let s = ft(n.type);
  return {
    name: n.name,
    type: s,
    description: yt(n.description),
    getPrettyName: /* @__PURE__ */ r(() => Kr(n.name), "getPrettyName"),
    getTypeName: /* @__PURE__ */ r(() => s ? dt(s) : null, "getTypeName")
  };
}
r($r, "extractParam");
function qr(n) {
  return n.name ? mt(n.name, n.description) : null;
}
r(qr, "extractDeprecated");
function mt(n, s) {
  let a = n === "" ? s : `${n} ${s}`;
  return yt(a);
}
r(mt, "joinNameAndDescription");
function yt(n) {
  let s = n.replace(/^- /g, "").trim();
  return s === "" ? null : s;
}
r(yt, "normaliseDescription");
function Yr(n) {
  let s = ft(n.type);
  return s ? {
    type: s,
    description: mt(n.name, n.description),
    getTypeName: /* @__PURE__ */ r(() => dt(s), "getTypeName")
  } : null;
}
r(Yr, "extractReturns");
var j = (0, K.stringifyRules)(), Wr = j.JsdocTypeObject;
j.JsdocTypeAny = () => "any";
j.JsdocTypeObject = (n, s) => `(${Wr(n, s)})`;
j.JsdocTypeOptional = (n, s) => s(n.element);
j.JsdocTypeNullable = (n, s) => s(n.element);
j.JsdocTypeNotNullable = (n, s) => s(n.element);
j.JsdocTypeUnion = (n, s) => n.elements.map(s).join("|");
function ft(n) {
  try {
    return (0, K.parse)(n, "typescript");
  } catch {
    return null;
  }
}
r(ft, "extractType");
function dt(n) {
  return (0, K.transform)(j, n);
}
r(dt, "extractTypeName");

// src/docs-tools/argTypes/utils.ts
var hs = 90, xs = 50;
function Ve(n) {
  return n.length > 90;
}
r(Ve, "isTooLongForTypeSummary");
function Tt(n) {
  return n.length > 50;
}
r(Tt, "isTooLongForDefaultValueSummary");
function J(n, s) {
  return n === s ? { summary: n } : { summary: n, detail: s };
}
r(J, "createSummaryValue");
var Js = /* @__PURE__ */ r((n) => n.replace(/\\r\\n/g, "\\n"), "normalizeNewlines");

// src/docs-tools/argTypes/docgen/flow/createDefaultValue.ts
function gt(n, s) {
  if (n != null) {
    let { value: a } = n;
    if (!M(a))
      return Tt(a) ? J(s?.name, a) : J(a);
  }
  return null;
}
r(gt, "createDefaultValue");

// src/docs-tools/argTypes/docgen/flow/createType.ts
function ht({ name: n, value: s, elements: a, raw: p }) {
  return s ?? (a != null ? a.map(ht).join(" | ") : p ?? n);
}
r(ht, "generateUnionElement");
function Gr({ name: n, raw: s, elements: a }) {
  return a != null ? J(a.map(ht).join(" | ")) : s != null ? J(s.replace(/^\|\s*/, "")) : J(n);
}
r(Gr, "generateUnion");
function zr({ type: n, raw: s }) {
  return s != null ? J(s) : J(n);
}
r(zr, "generateFuncSignature");
function Xr({ type: n, raw: s }) {
  return s != null ? Ve(s) ? J(n, s) : J(s) : J(n);
}
r(Xr, "generateObjectSignature");
function Hr(n) {
  let { type: s } = n;
  return s === "object" ? Xr(n) : zr(n);
}
r(Hr, "generateSignature");
function Qr({ name: n, raw: s }) {
  return s != null ? Ve(s) ? J(n, s) : J(s) : J(n);
}
r(Qr, "generateDefault");
function xt(n) {
  if (n == null)
    return null;
  switch (n.name) {
    case "union":
      return Gr(n);
    case "signature":
      return Hr(n);
    default:
      return Qr(n);
  }
}
r(xt, "createType");

// src/docs-tools/argTypes/docgen/flow/createPropDef.ts
var Jt = /* @__PURE__ */ r((n, s) => {
  let { flowType: a, description: p, required: c, defaultValue: u } = s;
  return {
    name: n,
    type: xt(a),
    required: c,
    description: p,
    defaultValue: gt(u ?? null, a ?? null)
  };
}, "createFlowPropDef");

// src/docs-tools/argTypes/docgen/typeScript/createDefaultValue.ts
function Pt({ defaultValue: n }) {
  if (n != null) {
    let { value: s } = n;
    if (!M(s))
      return J(s);
  }
  return null;
}
r(Pt, "createDefaultValue");

// src/docs-tools/argTypes/docgen/typeScript/createType.ts
function wt({ tsType: n, required: s }) {
  if (n == null)
    return null;
  let a = n.name;
  return s || (a = a.replace(" | undefined", "")), J(
    ["Array", "Record", "signature"].includes(n.name) ? n.raw : a
  );
}
r(wt, "createType");

// src/docs-tools/argTypes/docgen/typeScript/createPropDef.ts
var bt = /* @__PURE__ */ r((n, s) => {
  let { description: a, required: p } = s;
  return {
    name: n,
    type: wt(s),
    required: p,
    description: a,
    defaultValue: Pt(s)
  };
}, "createTsPropDef");

// src/docs-tools/argTypes/docgen/createPropDef.ts
function Zr(n) {
  return n != null ? J(n.name) : null;
}
r(Zr, "createType");
function en(n) {
  let { computed: s, func: a } = n;
  return typeof s > "u" && typeof a > "u";
}
r(en, "isReactDocgenTypescript");
function tn(n) {
  return n ? n.name === "string" ? !0 : n.name === "enum" ? Array.isArray(n.value) && n.value.every(
    ({ value: s }) => typeof s == "string" && s[0] === '"' && s[s.length - 1] === '"'
  ) : !1 : !1;
}
r(tn, "isStringValued");
function rn(n, s) {
  if (n != null) {
    let { value: a } = n;
    if (!M(a))
      return en(n) && tn(s) ? J(JSON.stringify(a)) : J(a);
  }
  return null;
}
r(rn, "createDefaultValue");
function Et(n, s, a) {
  let { description: p, required: c, defaultValue: u } = a;
  return {
    name: n,
    type: Zr(s),
    required: c,
    description: p,
    defaultValue: rn(u, s)
  };
}
r(Et, "createBasicPropDef");
function ue(n, s) {
  if (s?.includesJsDoc) {
    let { description: a, extractedTags: p } = s;
    a != null && (n.description = s.description);
    let c = {
      ...p,
      params: p?.params?.map(
        (u) => ({
          name: u.getPrettyName(),
          description: u.description
        })
      )
    };
    Object.values(c).filter(Boolean).length > 0 && (n.jsDocTags = c);
  }
  return n;
}
r(ue, "applyJsDocResult");
var nn = /* @__PURE__ */ r((n, s, a) => {
  let p = Et(n, s.type, s);
  return p.sbType = se(s), ue(p, a);
}, "javaScriptFactory"), on = /* @__PURE__ */ r((n, s, a) => {
  let p = bt(n, s);
  return p.sbType = se(s), ue(p, a);
}, "tsFactory"), sn = /* @__PURE__ */ r((n, s, a) => {
  let p = Jt(n, s);
  return p.sbType = se(s), ue(p, a);
}, "flowFactory"), an = /* @__PURE__ */ r((n, s, a) => {
  let p = Et(n, { name: "unknown" }, s);
  return ue(p, a);
}, "unknownFactory"), Ue = /* @__PURE__ */ r((n) => {
  switch (n) {
    case "JavaScript":
      return nn;
    case "TypeScript":
      return on;
    case "Flow":
      return sn;
    default:
      return an;
  }
}, "getPropDefFactory");

// src/docs-tools/argTypes/docgen/extractDocgenProps.ts
var St = /* @__PURE__ */ r((n) => n.type != null ? "JavaScript" : n.flowType != null ? "Flow" : n.tsType != null ? "TypeScript" : "Unknown",
"getTypeSystem"), pn = /* @__PURE__ */ r((n) => {
  let s = St(n[0]), a = Ue(s);
  return n.map((p) => {
    let c = p;
    return p.type?.elements && (c = {
      ...p,
      type: {
        ...p.type,
        value: p.type.elements
      }
    }), Nt(c.name, c, s, a);
  });
}, "extractComponentSectionArray"), cn = /* @__PURE__ */ r((n) => {
  let s = Object.keys(n), a = St(n[s[0]]), p = Ue(a);
  return s.map((c) => {
    let u = n[c];
    return u != null ? Nt(c, u, a, p) : null;
  }).filter(Boolean);
}, "extractComponentSectionObject"), ta = /* @__PURE__ */ r((n, s) => {
  let a = nt(n, s);
  return rt(a) ? Array.isArray(a) ? pn(a) : cn(a) : [];
}, "extractComponentProps");
function Nt(n, s, a, p) {
  let c = ut(s.description);
  return c.includesJsDoc && c.ignore ? null : {
    propDef: p(n, s, c),
    jsDocTags: c.extractedTags,
    docgenInfo: s,
    typeSystem: a
  };
}
r(Nt, "extractProp");
function ra(n) {
  return n != null ? ot(n) : "";
}
r(ra, "extractComponentDescription");

// src/preview-api/modules/store/parameters.ts
var Be = /* @__PURE__ */ r((...n) => {
  let s = {}, a = n.filter(Boolean), p = a.reduce((c, u) => (Object.entries(u).forEach(([m, T]) => {
    let g = c[m];
    Array.isArray(T) || typeof g > "u" ? c[m] = T : z(T) && z(g) ? s[m] = !0 : typeof T < "u" && (c[m] = T);
  }), c), {});
  return Object.keys(s).forEach((c) => {
    let u = a.filter(Boolean).map((m) => m[c]).filter((m) => typeof m < "u");
    u.every((m) => z(m)) ? p[c] = Be(...u) : p[c] = u[u.length - 1];
  }), p;
}, "combineParameters");

// src/docs-tools/argTypes/enhanceArgTypes.ts
var ca = /* @__PURE__ */ r((n) => {
  let {
    component: s,
    argTypes: a,
    parameters: { docs: p = {} }
  } = n, { extractArgTypes: c } = p, u = c && s ? c(s) : {};
  return u ? Be(u, a) : a;
}, "enhanceArgTypes");

// src/docs-tools/shared.ts
var Ot = "storybook/docs", ma = `${Ot}/panel`, ya = "docs", fa = `${Ot}/snippet-rendered`, ln = /* @__PURE__ */ ((p) => (p.AUTO = "auto", p.
CODE = "code", p.DYNAMIC = "dynamic", p))(ln || {});

// src/docs-tools/hasDocsOrControls.ts
var un = /(addons\/|addon-|addon-essentials\/)(docs|controls)/, Ta = /* @__PURE__ */ r((n) => n.presetsList?.some((s) => un.test(s.name)), "\
hasDocsOrControls");
export {
  Ot as ADDON_ID,
  xs as MAX_DEFAULT_VALUE_SUMMARY_LENGTH,
  hs as MAX_TYPE_SUMMARY_LENGTH,
  ma as PANEL_ID,
  ya as PARAM_KEY,
  fa as SNIPPET_RENDERED,
  ln as SourceType,
  Nr as TypeSystem,
  se as convert,
  J as createSummaryValue,
  ca as enhanceArgTypes,
  ra as extractComponentDescription,
  ta as extractComponentProps,
  pn as extractComponentSectionArray,
  cn as extractComponentSectionObject,
  ot as getDocgenDescription,
  nt as getDocgenSection,
  tt as hasDocgen,
  Ta as hasDocsOrControls,
  M as isDefaultValueBlacklisted,
  Tt as isTooLongForDefaultValueSummary,
  Ve as isTooLongForTypeSummary,
  rt as isValidDocgenSection,
  Js as normalizeNewlines,
  ut as parseJsDoc,
  et as str
};
