var lr = Object.create;
var Oe = Object.defineProperty;
var ur = Object.getOwnPropertyDescriptor;
var mr = Object.getOwnPropertyNames;
var fr = Object.getPrototypeOf, yr = Object.prototype.hasOwnProperty;
var r = (n, s) => Oe(n, "name", { value: s, configurable: !0 });
var dr = (n, s) => () => (s || n((s = { exports: {} }).exports, s), s.exports);
var Tr = (n, s, a, p) => {
  if (s && typeof s == "object" || typeof s == "function")
    for (let c of mr(s))
      !yr.call(n, c) && c !== a && Oe(n, c, { get: () => s[c], enumerable: !(p = ur(s, c)) || p.enumerable });
  return n;
};
var gr = (n, s, a) => (a = n != null ? lr(fr(n)) : {}, Tr(
  // 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 = dr((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 P(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(P, "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 = P(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 z = /* @__PURE__ */ r((e) => {
      let t = m(e);
      return t == null ? null : {
        type: "StringValue",
        text: t
      };
    }, "stringValueRule"), fe = /* @__PURE__ */ r((e) => e.length > 0 ? null : {
      type: "EOF",
      text: ""
    }, "eofRule"), ye = /* @__PURE__ */ r((e) => {
      let t = me(e);
      return t === null ? null : {
        type: "Number",
        text: t
      };
    }, "numberRule"), Dt = [
      fe,
      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"),
      E("asserts"),
      ye,
      $,
      z
    ], 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 f = Object.assign(Object.assign({}, l), { startOfLine: o });
            return t = t.slice(f.text.length), { text: t, token: f };
          }
        }
        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 J(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(J, "assertRootResult");
    function de(e) {
      return e.type === "JsdocTypeKeyValue" ? H(e) : J(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 y;
    (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.INDEX_BRACKETS =
      4] = "INDEX_BRACKETS", e[e.UNION = 5] = "UNION", e[e.INTERSECTION = 6] = "INTERSECTION", e[e.PREFIX = 7] = "PREFIX", e[e.INFIX = 8] = "\
INFIX", e[e.TUPLE = 9] = "TUPLE", e[e.SYMBOL = 10] = "SYMBOL", e[e.OPTIONAL = 11] = "OPTIONAL", e[e.NULLABLE = 12] = "NULLABLE", e[e.KEY_OF_TYPE_OF =
      13] = "KEY_OF_TYPE_OF", e[e.FUNCTION = 14] = "FUNCTION", e[e.ARROW = 15] = "ARROW", e[e.ARRAY_BRACKETS = 16] = "ARRAY_BRACKETS", e[e.GENERIC =
      17] = "GENERIC", e[e.NAME_PATH = 18] = "NAME_PATH", e[e.PARENTHESIS = 19] = "PARENTHESIS", e[e.SPECIAL_TYPES = 20] = "SPECIAL_TYPES";
    })(y || (y = {}));
    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(y.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 J(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(y.NULLABLE),
        meta: {
          position: "prefix"
        }
      } : {
        type: "JsdocTypeNullable",
        element: J(o),
        meta: {
          position: "suffix"
        }
      }) : null;
    }, "nullableParslet");
    function x(e) {
      let t = /* @__PURE__ */ r((o, i, l) => {
        let f = o.lexer.current.type, d = o.lexer.next.type;
        if (l === null) {
          if ("parsePrefix" in e && e.accept(f, d))
            return e.parsePrefix(o);
        } else if ("parseInfix" in e && e.precedence > i && e.accept(f, d))
          return e.parseInfix(o, l);
        return null;
      }, "parslet");
      return Object.defineProperty(t, "name", {
        value: e.name
      }), t;
    }
    r(x, "composeParslet");
    let Q = x({
      name: "optionalParslet",
      accept: /* @__PURE__ */ r((e) => e === "=", "accept"),
      precedence: y.OPTIONAL,
      parsePrefix: /* @__PURE__ */ r((e) => (e.consume("="), {
        type: "JsdocTypeOptional",
        element: e.parseType(y.OPTIONAL),
        meta: {
          position: "prefix"
        }
      }), "parsePrefix"),
      parseInfix: /* @__PURE__ */ r((e, t) => (e.consume("="), {
        type: "JsdocTypeOptional",
        element: J(t),
        meta: {
          position: "suffix"
        }
      }), "parseInfix")
    }), Z = x({
      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")
    }), It = x({
      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(y.ALL);
        if (!e.consume(")"))
          throw new Error("Unterminated parenthesis");
        return t.type === "JsdocTypeParameterList" ? t : t.type === "JsdocTypeKeyValue" ? {
          type: "JsdocTypeParameterList",
          elements: [t]
        } : {
          type: "JsdocTypeParenthesis",
          element: J(t)
        };
      }, "parsePrefix")
    }), Rt = x({
      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")
    }), jt = x({
      name: "notNullableParslet",
      accept: /* @__PURE__ */ r((e) => e === "!", "accept"),
      precedence: y.NULLABLE,
      parsePrefix: /* @__PURE__ */ r((e) => (e.consume("!"), {
        type: "JsdocTypeNotNullable",
        element: e.parseType(y.NULLABLE),
        meta: {
          position: "prefix"
        }
      }), "parsePrefix"),
      parseInfix: /* @__PURE__ */ r((e, t) => (e.consume("!"), {
        type: "JsdocTypeNotNullable",
        element: J(t),
        meta: {
          position: "suffix"
        }
      }), "parseInfix")
    });
    function Ft({ allowTrailingComma: e }) {
      return x({
        name: "parameterListParslet",
        accept: /* @__PURE__ */ r((t) => t === ",", "accept"),
        precedence: y.PARAMETER_LIST,
        parseInfix: /* @__PURE__ */ r((t, o) => {
          let i = [
            de(o)
          ];
          t.consume(",");
          do
            try {
              let l = t.parseIntermediateType(y.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(Ft, "createParameterListParslet");
    let _t = x({
      name: "genericParslet",
      accept: /* @__PURE__ */ r((e, t) => e === "<" || e === "." && t === "<", "accept"),
      precedence: y.GENERIC,
      parseInfix: /* @__PURE__ */ r((e, t) => {
        let o = e.consume(".");
        e.consume("<");
        let i = [];
        do
          i.push(e.parseType(y.PARAMETER_LIST));
        while (e.consume(","));
        if (!e.consume(">"))
          throw new Error("Unterminated generic parameter list");
        return {
          type: "JsdocTypeGeneric",
          left: J(t),
          elements: i,
          meta: {
            brackets: "angle",
            dot: o
          }
        };
      }, "parseInfix")
    }), Lt = x({
      name: "unionParslet",
      accept: /* @__PURE__ */ r((e) => e === "|", "accept"),
      precedence: y.UNION,
      parseInfix: /* @__PURE__ */ r((e, t) => {
        e.consume("|");
        let o = [];
        do
          o.push(e.parseType(y.UNION));
        while (e.consume("|"));
        return {
          type: "JsdocTypeUnion",
          elements: [J(t), ...o]
        };
      }, "parseInfix")
    }), xe = [
      ge,
      Q,
      Z,
      It,
      Rt,
      jt,
      Ft({
        allowTrailingComma: !0
      }),
      _t,
      Lt,
      Q
    ];
    function ee({ allowSquareBracketsOnAnyType: e, allowJsdocNamePaths: t, pathGrammar: o }) {
      return /* @__PURE__ */ r(function(l, f, d) {
        if (d == null || f >= y.NAME_PATH)
          return null;
        let h = l.lexer.current.type, O = l.lexer.next.type;
        if (!(h === "." && O !== "<" || h === "[" && (e || d.type === "JsdocTypeName") || t && (h === "~" || h === "#")))
          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(y.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: J(d),
          right: G,
          pathType: D
        };
      }, "namePathParslet");
    }
    r(ee, "createNamePathParslet");
    function I({ allowedAdditionalTokens: e }) {
      return x({
        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(I, "createNameParslet");
    let Y = x({
      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 x({
        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, f = o.lexer.current;
          if (o.consume("StringValue"))
            l = {
              type: "JsdocTypeSpecialNamePath",
              value: f.text.slice(1, -1),
              specialType: i,
              meta: {
                quote: f.text[0] === "'" ? "single" : "double"
              }
            };
          else {
            let O = "", S = ["Identifier", "@", "/"];
            for (; S.some((D) => o.consume(D)); )
              O += f.text, f = o.lexer.current;
            l = {
              type: "JsdocTypeSpecialNamePath",
              value: O,
              specialType: i,
              meta: {
                quote: void 0
              }
            };
          }
          let d = new L(e, o.lexer, o), h = d.parseInfixIntermediateType(l, y.ALL);
          return o.acceptLexerState(d), J(h);
        }, "parsePrefix")
      });
    }
    r(te, "createSpecialNamePathParslet");
    let Me = [
      I({
        allowedAdditionalTokens: ["external", "module"]
      }),
      Y,
      Z,
      ee({
        allowSquareBracketsOnAnyType: !1,
        allowJsdocNamePaths: !0,
        pathGrammar: null
      })
    ], V = [
      ...Me,
      te({
        allowedTypes: ["event"],
        pathGrammar: Me
      })
    ];
    function he(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(he, "getParameters");
    function Vt(e) {
      let t = he(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 x({
        name: "functionParslet",
        accept: /* @__PURE__ */ r((l, f) => l === "function" || i && l === "new" && f === "(", "accept"),
        parsePrefix: /* @__PURE__ */ r((l) => {
          let f = 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 h = {
            type: "JsdocTypeFunction",
            parameters: [],
            arrow: !1,
            constructor: f,
            parenthesis: d
          }, O = l.parseIntermediateType(y.FUNCTION);
          if (e === void 0)
            h.parameters = Vt(O);
          else {
            if (f && O.type === "JsdocTypeFunction" && O.arrow)
              return h = O, h.constructor = !0, h;
            h.parameters = he(O);
            for (let S of h.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(":"))
            h.returnType = l.parseType(y.PREFIX);
          else if (!t)
            throw new Error("function is missing return type");
          return h;
        }, "parsePrefix")
      });
    }
    r(Je, "createFunctionParslet");
    function we({ allowPostfix: e, allowEnclosingBrackets: t }) {
      return x({
        name: "variadicParslet",
        accept: /* @__PURE__ */ r((o) => o === "...", "accept"),
        precedence: y.PREFIX,
        parsePrefix: /* @__PURE__ */ r((o) => {
          o.consume("...");
          let i = t && o.consume("[");
          try {
            let l = o.parseType(y.PREFIX);
            if (i && !o.consume("]"))
              throw new Error("Unterminated variadic type. Missing ']'");
            return {
              type: "JsdocTypeVariadic",
              element: J(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: J(i),
          meta: {
            position: "suffix",
            squareBrackets: !1
          }
        }) : void 0
      });
    }
    r(we, "createVariadicParslet");
    let Ke = x({
      name: "symbolParslet",
      accept: /* @__PURE__ */ r((e) => e === "(", "accept"),
      precedence: y.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(y.SYMBOL);
          if (o.element = At(i), !e.consume(")"))
            throw new Error("Symbol does not end after value");
        }
        return o;
      }, "parseInfix")
    }), $e = x({
      name: "arrayBracketsParslet",
      precedence: y.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: [
          J(t)
        ],
        meta: {
          brackets: "square",
          dot: !1
        }
      }), "parseInfix")
    });
    function Pe({ objectFieldGrammar: e, allowKeyTypes: t }) {
      return x({
        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, f = new L(e, o.lexer, o);
            for (; ; ) {
              f.acceptLexerState(o);
              let d = f.parseIntermediateType(y.OBJECT);
              o.acceptLexerState(f), d === void 0 && t && (d = o.parseIntermediateType(y.OBJECT));
              let h = !1;
              if (d.type === "JsdocTypeNullable" && (h = !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: h,
                  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(Pe, "createObjectParslet");
    function be({ allowSquaredProperties: e, allowKeyTypes: t, allowReadonly: o, allowOptional: i }) {
      return x({
        name: "objectFieldParslet",
        precedence: y.KEY_VALUE,
        accept: /* @__PURE__ */ r((l) => l === ":", "accept"),
        parseInfix: /* @__PURE__ */ r((l, f) => {
          var d;
          let h = !1, O = !1;
          i && f.type === "JsdocTypeNullable" && (h = !0, f = f.element), o && f.type === "JsdocTypeReadonlyProperty" && (O = !0, f = f.element);
          let S = (d = l.baseParser) !== null && d !== void 0 ? d : l;
          if (S.acceptLexerState(l), f.type === "JsdocTypeNumber" || f.type === "JsdocTypeName" || f.type === "JsdocTypeStringValue" || Te(f)) {
            if (Te(f) && !e)
              throw new c(f);
            S.consume(":");
            let D;
            f.type === "JsdocTypeStringValue" && (D = f.meta.quote);
            let ne = S.parseType(y.KEY_VALUE);
            return l.acceptLexerState(S), {
              type: "JsdocTypeObjectField",
              key: Te(f) ? f : f.value.toString(),
              right: ne,
              optional: h,
              readonly: O,
              meta: {
                quote: D
              }
            };
          } else {
            if (!t)
              throw new c(f);
            S.consume(":");
            let D = S.parseType(y.KEY_VALUE);
            return l.acceptLexerState(S), {
              type: "JsdocTypeJsdocObjectField",
              left: J(f),
              right: D
            };
          }
        }, "parseInfix")
      });
    }
    r(be, "createObjectFieldParslet");
    function Ee({ allowOptional: e, allowVariadic: t }) {
      return x({
        name: "keyValueParslet",
        precedence: y.KEY_VALUE,
        accept: /* @__PURE__ */ r((o) => o === ":", "accept"),
        parseInfix: /* @__PURE__ */ r((o, i) => {
          let l = !1, f = !1;
          if (e && i.type === "JsdocTypeNullable" && (l = !0, i = i.element), t && i.type === "JsdocTypeVariadic" && i.element !== void 0 &&
          (f = !0, i = i.element), i.type !== "JsdocTypeName")
            throw new c(i);
          o.consume(":");
          let d = o.parseType(y.KEY_VALUE);
          return {
            type: "JsdocTypeKeyValue",
            key: i.value,
            right: d,
            optional: l,
            variadic: f
          };
        }, "parseInfix")
      });
    }
    r(Ee, "createKeyValueParslet");
    let qe = [
      ...xe,
      Je({
        allowWithoutParenthesis: !0,
        allowNamedParameters: ["this", "new"],
        allowNoReturnType: !0,
        allowNewAsFunctionKeyword: !1
      }),
      Y,
      te({
        allowedTypes: ["module", "external", "event"],
        pathGrammar: V
      }),
      we({
        allowEnclosingBrackets: !0,
        allowPostfix: !0
      }),
      I({
        allowedAdditionalTokens: ["keyof"]
      }),
      Ke,
      $e,
      ee({
        allowSquareBracketsOnAnyType: !1,
        allowJsdocNamePaths: !0,
        pathGrammar: V
      })
    ], Ut = [
      ...qe,
      Pe({
        // 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: [
          I({
            allowedAdditionalTokens: ["module", "in"]
          }),
          be({
            allowSquaredProperties: !1,
            allowKeyTypes: !0,
            allowOptional: !1,
            allowReadonly: !1
          }),
          ...qe
        ],
        allowKeyTypes: !0
      }),
      Ee({
        allowOptional: !0,
        allowVariadic: !0
      })
    ], Ye = x({
      name: "typeOfParslet",
      accept: /* @__PURE__ */ r((e) => e === "typeof", "accept"),
      parsePrefix: /* @__PURE__ */ r((e) => (e.consume("typeof"), {
        type: "JsdocTypeTypeof",
        element: J(e.parseType(y.KEY_OF_TYPE_OF))
      }), "parsePrefix")
    }), Bt = [
      I({
        allowedAdditionalTokens: ["module", "keyof", "event", "external", "in"]
      }),
      ge,
      Q,
      Y,
      Z,
      be({
        allowSquaredProperties: !1,
        allowKeyTypes: !1,
        allowOptional: !1,
        allowReadonly: !1
      })
    ], Ct = [
      ...xe,
      Pe({
        allowKeyTypes: !1,
        objectFieldGrammar: Bt
      }),
      I({
        allowedAdditionalTokens: ["event", "external", "in"]
      }),
      Ye,
      Je({
        allowWithoutParenthesis: !1,
        allowNamedParameters: ["this", "new"],
        allowNoReturnType: !0,
        allowNewAsFunctionKeyword: !1
      }),
      we({
        allowEnclosingBrackets: !1,
        allowPostfix: !1
      }),
      // additional name parslet is needed for some special cases
      I({
        allowedAdditionalTokens: ["keyof"]
      }),
      te({
        allowedTypes: ["module"],
        pathGrammar: V
      }),
      ee({
        allowSquareBracketsOnAnyType: !1,
        allowJsdocNamePaths: !0,
        pathGrammar: V
      }),
      Ee({
        allowOptional: !1,
        allowVariadic: !1
      }),
      Ke
    ], Mt = x({
      name: "assertsParslet",
      accept: /* @__PURE__ */ r((e) => e === "asserts", "accept"),
      parsePrefix: /* @__PURE__ */ r((e) => {
        e.consume("asserts");
        let t = e.parseIntermediateType(y.SYMBOL);
        if (t.type !== "JsdocTypeName")
          throw new c(t, "A typescript asserts always has to have a name on the left side.");
        return e.consume("is"), {
          type: "JsdocTypeAsserts",
          left: t,
          right: J(e.parseIntermediateType(y.INFIX))
        };
      }, "parsePrefix")
    });
    function Kt({ allowQuestionMark: e }) {
      return x({
        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(y.ALL);
          if (i.type === "JsdocTypeParameterList" ? i.elements[0].type === "JsdocTypeKeyValue" ? o.elements = i.elements.map(H) : o.elements =
          i.elements.map(J) : i.type === "JsdocTypeKeyValue" ? o.elements = [H(i)] : o.elements = [J(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(Kt, "createTupleParslet");
    let $t = x({
      name: "keyOfParslet",
      accept: /* @__PURE__ */ r((e) => e === "keyof", "accept"),
      parsePrefix: /* @__PURE__ */ r((e) => (e.consume("keyof"), {
        type: "JsdocTypeKeyof",
        element: J(e.parseType(y.KEY_OF_TYPE_OF))
      }), "parsePrefix")
    }), qt = x({
      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(y.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")
    }), Yt = x({
      name: "readonlyPropertyParslet",
      accept: /* @__PURE__ */ r((e) => e === "readonly", "accept"),
      parsePrefix: /* @__PURE__ */ r((e) => (e.consume("readonly"), {
        type: "JsdocTypeReadonlyProperty",
        element: e.parseType(y.KEY_VALUE)
      }), "parsePrefix")
    }), Wt = x({
      name: "arrowFunctionParslet",
      precedence: y.ARROW,
      accept: /* @__PURE__ */ r((e) => e === "=>", "accept"),
      parseInfix: /* @__PURE__ */ r((e, t) => (e.consume("=>"), {
        type: "JsdocTypeFunction",
        parameters: he(t).map(kt),
        arrow: !0,
        constructor: !1,
        parenthesis: !0,
        returnType: e.parseType(y.OBJECT)
      }), "parseInfix")
    }), Gt = x({
      name: "intersectionParslet",
      accept: /* @__PURE__ */ r((e) => e === "&", "accept"),
      precedence: y.INTERSECTION,
      parseInfix: /* @__PURE__ */ r((e, t) => {
        e.consume("&");
        let o = [];
        do
          o.push(e.parseType(y.INTERSECTION));
        while (e.consume("&"));
        return {
          type: "JsdocTypeIntersection",
          elements: [J(t), ...o]
        };
      }, "parseInfix")
    }), Xt = x({
      name: "predicateParslet",
      precedence: y.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: J(e.parseIntermediateType(y.INFIX))
        };
      }, "parseInfix")
    }), zt = x({
      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(y.INDEX_BRACKETS)
          }, e.acceptLexerState(i);
        } else if (e.consume("in")) {
          let i = e.baseParser;
          i.acceptLexerState(e), o = {
            type: "JsdocTypeMappedType",
            key: t,
            right: i.parseType(y.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")
    }), Ht = [
      Yt,
      I({
        allowedAdditionalTokens: ["module", "event", "keyof", "event", "external", "in"]
      }),
      ge,
      Q,
      Y,
      Z,
      be({
        allowSquaredProperties: !0,
        allowKeyTypes: !1,
        allowOptional: !0,
        allowReadonly: !0
      }),
      zt
    ], Qt = [
      ...xe,
      Pe({
        allowKeyTypes: !1,
        objectFieldGrammar: Ht
      }),
      Ye,
      $t,
      qt,
      Y,
      Je({
        allowWithoutParenthesis: !0,
        allowNoReturnType: !1,
        allowNamedParameters: ["this", "new", "args"],
        allowNewAsFunctionKeyword: !0
      }),
      Kt({
        allowQuestionMark: !1
      }),
      we({
        allowEnclosingBrackets: !1,
        allowPostfix: !1
      }),
      Mt,
      I({
        allowedAdditionalTokens: ["event", "external", "in"]
      }),
      te({
        allowedTypes: ["module"],
        pathGrammar: V
      }),
      $e,
      Wt,
      ee({
        allowSquareBracketsOnAnyType: !0,
        allowJsdocNamePaths: !1,
        pathGrammar: V
      }),
      Gt,
      Xt,
      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(Qt, e).parse();
      }
    }
    r(We, "parse");
    function Zt(e, t = ["typescript", "closure", "jsdoc"]) {
      let o;
      for (let i of t)
        try {
          return We(e, i);
        } catch (l) {
          o = l;
        }
      throw o;
    }
    r(Zt, "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 N(e) {
      throw new Error("This transform is not available. Are you trying the correct parsing mode?");
    }
    r(N, "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 R(e, t) {
      switch (t) {
        case "double":
          return `"${e}"`;
        case "single":
          return `'${e}'`;
        case void 0:
          return e;
      }
    }
    r(R, "quote");
    function Xe() {
      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) => R(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 += R(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}:${R(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) => R(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"),
        JsdocTypeAsserts: /* @__PURE__ */ r((e, t) => `asserts ${t(e.left)} is ${t(e.right)}`, "JsdocTypeAsserts")
      };
    }
    r(Xe, "stringifyRules");
    let er = Xe();
    function tr(e) {
      return W(er, e);
    }
    r(tr, "stringify");
    let rr = [
      "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 j(e) {
      let t = {
        type: "NameExpression",
        name: e
      };
      return rr.includes(e) && (t.reservedWord = !0), t;
    }
    r(j, "makeName");
    let nr = {
      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) => j(R(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) => j(e.specialType + ":" + R(e.value, e.meta.quote)), "JsdocTypeSpecialNamePath"),
      JsdocTypeName: /* @__PURE__ */ r((e) => e.value !== "function" ? j(e.value) : {
        type: "FunctionType",
        params: []
      }, "JsdocTypeName"),
      JsdocTypeNumber: /* @__PURE__ */ r((e) => j(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: j(R(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: j(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 = R(e.right.value, e.right.meta.quote);
        let l = e.pathType === "inner" ? "~" : e.pathType === "instance" ? "#" : ".";
        return j(`${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 += "..."), j(`${e.value}(${t})`);
      }, "JsdocTypeSymbol"),
      JsdocTypeParenthesis: /* @__PURE__ */ r((e, t) => t(J(e.element)), "JsdocTypeParenthesis"),
      JsdocTypeMappedType: N,
      JsdocTypeIndexSignature: N,
      JsdocTypeImport: N,
      JsdocTypeKeyof: N,
      JsdocTypeTuple: N,
      JsdocTypeTypeof: N,
      JsdocTypeIntersection: N,
      JsdocTypeProperty: N,
      JsdocTypePredicate: N,
      JsdocTypeAsserts: N
    };
    function or(e) {
      return W(nr, e);
    }
    r(or, "catharsisTransform");
    function _(e) {
      switch (e) {
        case void 0:
          return "none";
        case "single":
          return "single";
        case "double":
          return "double";
      }
    }
    r(_, "getQuoteStyle");
    function sr(e) {
      switch (e) {
        case "inner":
          return "INNER_MEMBER";
        case "instance":
          return "INSTANCE_MEMBER";
        case "property":
          return "MEMBER";
        case "property-brackets":
          return "MEMBER";
      }
    }
    r(sr, "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 ar = {
      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 f = {
          type: sr(e.pathType),
          owner: t(e.left),
          name: i,
          quoteStyle: l,
          hasEventPrefix: o
        };
        if (f.owner.type === "MODULE") {
          let d = f.owner;
          return f.owner = f.owner.value, d.value = f, d;
        } else
          return f;
      }, "JsdocTypeNamePath"),
      JsdocTypeUnion: /* @__PURE__ */ r((e, t) => Se("UNION", e.elements.map(t)), "JsdocTypeUnion"),
      JsdocTypeParenthesis: /* @__PURE__ */ r((e, t) => ({
        type: "PARENTHESIS",
        value: t(J(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: N,
      JsdocTypeProperty: N,
      JsdocTypePredicate: N,
      JsdocTypeMappedType: N,
      JsdocTypeIndexSignature: N,
      JsdocTypeAsserts: N
    };
    function ir(e) {
      return W(ar, e);
    }
    r(ir, "jtpTransform");
    function pr() {
      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"),
        JsdocTypeAsserts: /* @__PURE__ */ r((e, t) => ({
          type: "JsdocTypeAsserts",
          left: t(e.left),
          right: t(e.right)
        }), "JsdocTypeAsserts")
      };
    }
    r(pr, "identityTransformRules");
    let ze = {
      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"],
      JsdocTypeAsserts: ["left", "right"]
    };
    function Ne(e, t, o, i, l) {
      i?.(e, t, o);
      let f = ze[e.type];
      for (let d of f) {
        let h = e[d];
        if (h !== void 0)
          if (Array.isArray(h))
            for (let O of h)
              Ne(O, e, d, i, l);
          else
            Ne(h, e, d, i, l);
      }
      l?.(e, t, o);
    }
    r(Ne, "_traverse");
    function cr(e, t, o) {
      Ne(e, void 0, void 0, t, o);
    }
    r(cr, "traverse"), n.catharsisTransform = or, n.identityTransformRules = pr, n.jtpTransform = ir, n.parse = We, n.stringify = tr, n.stringifyRules =
    Xe, n.transform = W, n.traverse = cr, n.tryParse = Zt, n.visitorKeys = ze;
  });
});

// src/docs-tools/argTypes/convert/flow/convert.ts
import { UnknownArgTypesError as xr } from "storybook/internal/preview-errors";
var hr = /* @__PURE__ */ r((n) => n.name === "literal", "isLiteral"), Jr = /* @__PURE__ */ r((n) => n.value.replace(/['|"]/g, ""), "toEnumOp\
tion"), wr = /* @__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 xr({ 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, ...wr(n) };
    case "union":
      return n.elements?.every(hr) ? { ...p, name: "enum", value: n.elements?.map(Jr) } : { ...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 X(n) {
  if (!n || typeof n != "object")
    return !1;
  let s = Object.getPrototypeOf(n);
  return s === null || s === Object.prototype || Object.getPrototypeOf(s) === null ? Object.prototype.toString.call(n) === "[object Object]" :
  !1;
}
r(X, "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"), br = /* @__PURE__ */ r((n) => Ze.test(n), "includes\
Quotes"), oe = /* @__PURE__ */ r((n) => {
  let s = Pr(n);
  return br(n) || Number.isNaN(Number(s)) ? s : Number(s);
}, "parseLiteral");

// src/docs-tools/argTypes/convert/proptypes/convert.ts
var Er = /^\(.*\) => /, 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 P = s.split("|").map((b) => JSON.parse(b));
          return { ...u, name: "enum", value: P };
        } catch {
        }
      let T = c ? `${s}(${c})` : s, g = Er.test(s) ? "function" : "other";
      return { ...u, name: g, value: T };
    }
  }
}, "convert");

// src/docs-tools/argTypes/convert/typescript/convert.ts
import { UnknownArgTypesError as Sr } from "storybook/internal/preview-errors";
var Nr = /* @__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 Sr({ 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, ...Nr(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 Or = /* @__PURE__ */ ((c) => (c.JAVASCRIPT = "JavaScript", c.FLOW = "Flow", c.TYPESCRIPT = "TypeScript", c.UNKNOWN = "Unknown", c))(Or ||
{});

// src/docs-tools/argTypes/docgen/utils/defaultValue.ts
var Dr = ["null", "undefined"];
function M(n) {
  return Dr.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 vr = /^@\S+/;
function Ae({ fence: n = "```" } = {}) {
  let s = kr(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)
      vr.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 kr(n) {
  return typeof n == "string" ? (s) => s.split(n).length % 2 === 0 : n;
}
r(kr, "getFencer");

// ../node_modules/comment-parser/es6/parser/source-parser.js
function Ie({ 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 P = m.trimRight();
      T.end = m.slice(P.length - s.end.length), m = P.slice(0, -s.end.length);
    }
    if (T.description = m, a.push({ number: p, source: u, tokens: T }), p++, g) {
      let P = a.slice();
      return a = null, P;
    }
    return null;
  }, "parseSource");
}
r(Ie, "getParser");

// ../node_modules/comment-parser/es6/parser/spec-parser.js
function Re({ 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(Re, "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 = Ir(n);
  return (a) => {
    let p = 0, c = [];
    for (let [T, { tokens: g }] of a.source.entries()) {
      let P = "";
      if (T === 0 && g.description[0] !== "{")
        return a;
      for (let b of g.description)
        if (b === "{" && p++, b === "}" && p--, P += b, p === 0)
          break;
      if (c.push([g, P]), 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, P]] of c.entries())
      g.type = P, T > 0 && (g.type = g.postDelimiter.slice(m) + P, g.postDelimiter = g.postDelimiter.slice(0, m)), [g.postType, g.description] =
      A(g.description.slice(P.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 Ar = /* @__PURE__ */ r((n) => n.trim(), "trim");
function Ir(n) {
  return n === "compact" ? (s) => s.map(Ar).join("") : n === "preserve" ? (s) => s.join(`
`) : n;
}
r(Ir, "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 P = 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 = P, 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 = je(n);
  return (p) => (p.description = a(p.source, s), p);
}
r(ce, "descriptionTokenizer");
function je(n) {
  return n === "compact" ? jr : n === "preserve" ? Lr : n;
}
r(je, "getJoiner");
function jr(n, s = v) {
  return n.map(({ tokens: { description: a } }) => a.trim()).filter((a) => a !== "").join(" ");
}
r(jr, "compactJoiner");
var Fr = /* @__PURE__ */ r((n, { tokens: s }, a) => s.type === "" ? n : a, "lineNo"), _r = /* @__PURE__ */ r(({ tokens: n }) => (n.delimiter ===
"" ? n.start : n.postDelimiter.slice(1)) + n.description, "getDescription");
function Lr(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(_r).join(`
`);
}
r(Lr, "preserveJoiner");

// ../node_modules/comment-parser/es6/parser/index.js
function Fe({ 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 = Ie({ startLine: n, markers: p }), m = Ae({ fence: s }), T = Re({ tokenizers: c }), g = je(a);
  return function(P) {
    let b = [];
    for (let me of at(P)) {
      let $ = u(me);
      if ($ === null)
        continue;
      let E = m($), z = E.slice(1).map(T);
      b.push({
        description: g(E[0], p),
        tags: z,
        source: $,
        problems: z.reduce((fe, ye) => fe.concat(ye.problems), [])
      });
    }
    return b;
  };
}
r(Fe, "getParser");

// ../node_modules/comment-parser/es6/stringifier/index.js
function Vr(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(Vr, "join");
function _e() {
  return (n) => n.source.map(({ tokens: s }) => Vr(s)).join(`
`);
}
r(_e, "getStringifier");

// ../node_modules/comment-parser/es6/stringifier/inspect.js
var Ur = {
  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 Ko = Object.keys(Ur);

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

// src/docs-tools/argTypes/jsdocParser.ts
var K = gr(lt(), 1);
function Br(n) {
  return n != null && n.includes("@");
}
r(Br, "containsJsDoc");
function Cr(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(Cr, "parse");
var Mr = {
  tags: ["param", "arg", "argument", "returns", "ignore", "deprecated"]
}, ut = /* @__PURE__ */ r((n, s = Mr) => {
  if (!Br(n))
    return {
      includesJsDoc: !1,
      ignore: !1
    };
  let a = Cr(n), p = Kr(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 Kr(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 = qr(p);
            c != null && (a.params == null && (a.params = []), a.params.push(c));
            break;
          }
          case "deprecated": {
            let c = Yr(p);
            c != null && (a.deprecated = c);
            break;
          }
          case "returns": {
            let c = Wr(p);
            c != null && (a.returns = c);
            break;
          }
          default:
            break;
        }
  return a;
}
r(Kr, "extractJsDocTags");
function $r(n) {
  return n.replace(/[\.-]$/, "");
}
r($r, "normaliseParamName");
function qr(n) {
  if (!n.name || n.name === "-")
    return null;
  let s = yt(n.type);
  return {
    name: n.name,
    type: s,
    description: ft(n.description),
    getPrettyName: /* @__PURE__ */ r(() => $r(n.name), "getPrettyName"),
    getTypeName: /* @__PURE__ */ r(() => s ? dt(s) : null, "getTypeName")
  };
}
r(qr, "extractParam");
function Yr(n) {
  return n.name ? mt(n.name, n.description) : null;
}
r(Yr, "extractDeprecated");
function mt(n, s) {
  let a = n === "" ? s : `${n} ${s}`;
  return ft(a);
}
r(mt, "joinNameAndDescription");
function ft(n) {
  let s = n.replace(/^- /g, "").trim();
  return s === "" ? null : s;
}
r(ft, "normaliseDescription");
function Wr(n) {
  let s = yt(n.type);
  return s ? {
    type: s,
    description: mt(n.name, n.description),
    getTypeName: /* @__PURE__ */ r(() => dt(s), "getTypeName")
  } : null;
}
r(Wr, "extractReturns");
var F = (0, K.stringifyRules)(), Gr = F.JsdocTypeObject;
F.JsdocTypeAny = () => "any";
F.JsdocTypeObject = (n, s) => `(${Gr(n, s)})`;
F.JsdocTypeOptional = (n, s) => s(n.element);
F.JsdocTypeNullable = (n, s) => s(n.element);
F.JsdocTypeNotNullable = (n, s) => s(n.element);
F.JsdocTypeUnion = (n, s) => n.elements.map(s).join("|");
function yt(n) {
  try {
    return (0, K.parse)(n, "typescript");
  } catch {
    return null;
  }
}
r(yt, "extractType");
function dt(n) {
  return (0, K.transform)(F, n);
}
r(dt, "extractTypeName");

// src/docs-tools/argTypes/utils.ts
var hs = 90, Js = 50;
function Ve(n) {
  return n.length > 90;
}
r(Ve, "isTooLongForTypeSummary");
function Tt(n) {
  return n.length > 50;
}
r(Tt, "isTooLongForDefaultValueSummary");
function w(n, s) {
  return n === s ? { summary: n } : { summary: n, detail: s };
}
r(w, "createSummaryValue");
var ws = /* @__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) ? w(s?.name, a) : w(a);
  }
  return null;
}
r(gt, "createDefaultValue");

// src/docs-tools/argTypes/docgen/flow/createType.ts
function xt({ name: n, value: s, elements: a, raw: p }) {
  return s ?? (a != null ? a.map(xt).join(" | ") : p ?? n);
}
r(xt, "generateUnionElement");
function Xr({ name: n, raw: s, elements: a }) {
  return a != null ? w(a.map(xt).join(" | ")) : s != null ? w(s.replace(/^\|\s*/, "")) : w(n);
}
r(Xr, "generateUnion");
function zr({ type: n, raw: s }) {
  return s != null ? w(s) : w(n);
}
r(zr, "generateFuncSignature");
function Hr({ type: n, raw: s }) {
  return s != null ? Ve(s) ? w(n, s) : w(s) : w(n);
}
r(Hr, "generateObjectSignature");
function Qr(n) {
  let { type: s } = n;
  return s === "object" ? Hr(n) : zr(n);
}
r(Qr, "generateSignature");
function Zr({ name: n, raw: s }) {
  return s != null ? Ve(s) ? w(n, s) : w(s) : w(n);
}
r(Zr, "generateDefault");
function ht(n) {
  if (n == null)
    return null;
  switch (n.name) {
    case "union":
      return Xr(n);
    case "signature":
      return Qr(n);
    default:
      return Zr(n);
  }
}
r(ht, "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: ht(a),
    required: c,
    description: p,
    defaultValue: gt(u ?? null, a ?? null)
  };
}, "createFlowPropDef");

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

// src/docs-tools/argTypes/docgen/typeScript/createType.ts
function Pt({ tsType: n, required: s }) {
  if (n == null)
    return null;
  let a = n.name;
  return s || (a = a.replace(" | undefined", "")), w(
    ["Array", "Record", "signature"].includes(n.name) ? n.raw : a
  );
}
r(Pt, "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: Pt(s),
    required: p,
    description: a,
    defaultValue: wt(s)
  };
}, "createTsPropDef");

// src/docs-tools/argTypes/docgen/createPropDef.ts
function en(n) {
  return n != null ? w(n.name) : null;
}
r(en, "createType");
function tn(n) {
  let { computed: s, func: a } = n;
  return typeof s > "u" && typeof a > "u";
}
r(tn, "isReactDocgenTypescript");
function rn(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(rn, "isStringValued");
function nn(n, s) {
  if (n != null) {
    let { value: a } = n;
    if (!M(a))
      return tn(n) && rn(s) ? w(JSON.stringify(a)) : w(a);
  }
  return null;
}
r(nn, "createDefaultValue");
function Et(n, s, a) {
  let { description: p, required: c, defaultValue: u } = a;
  return {
    name: n,
    type: en(s),
    required: c,
    description: p,
    defaultValue: nn(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 on = /* @__PURE__ */ r((n, s, a) => {
  let p = Et(n, s.type, s);
  return p.sbType = se(s), ue(p, a);
}, "javaScriptFactory"), sn = /* @__PURE__ */ r((n, s, a) => {
  let p = bt(n, s);
  return p.sbType = se(s), ue(p, a);
}, "tsFactory"), an = /* @__PURE__ */ r((n, s, a) => {
  let p = Jt(n, s);
  return p.sbType = se(s), ue(p, a);
}, "flowFactory"), pn = /* @__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 on;
    case "TypeScript":
      return sn;
    case "Flow":
      return an;
    default:
      return pn;
  }
}, "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"), cn = /* @__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"), ln = /* @__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"), ra = /* @__PURE__ */ r((n, s) => {
  let a = nt(n, s);
  return rt(a) ? Array.isArray(a) ? cn(a) : ln(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 na(n) {
  return n != null ? ot(n) : "";
}
r(na, "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 : X(T) && X(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) => X(m)) ? p[c] = Be(...u) : p[c] = u[u.length - 1];
  }), p;
}, "combineParameters");

// src/docs-tools/argTypes/enhanceArgTypes.ts
var la = /* @__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", fa = `${Ot}/panel`, ya = "docs", da = `${Ot}/snippet-rendered`, un = /* @__PURE__ */ ((p) => (p.AUTO = "auto", p.
CODE = "code", p.DYNAMIC = "dynamic", p))(un || {});

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