import {
  b as ae,
  c as rt
} from "./chunk-IU22WWJQ.js";
import {
  a as n,
  c as Tn,
  e as gn
} from "./chunk-IO47FP3U.js";

// ../node_modules/jsdoc-type-pratt-parser/dist/index.js
var dt = Tn((me, ft) => {
  (function(r, s) {
    typeof me == "object" && typeof ft < "u" ? s(me) : typeof define == "function" && define.amd ? define(["exports"], s) : (r = typeof globalThis < "u" ? globalThis : r || self, s(r.jtpp = {}));
  })(me, function(r) {
    "use strict";
    function s(e) {
      return e.text !== void 0 && e.text !== "" ? `'${e.type}' with value '${e.text}'` : `'${e.type}'`;
    }
    n(s, "tokenToString");
    let ne = class ne extends Error {
      constructor(t) {
        super(`No parslet found for token: ${s(t)}`), this.token = t, Object.setPrototypeOf(this, ne.prototype);
      }
      getToken() {
        return this.token;
      }
    };
    n(ne, "NoParsletFoundError");
    let a = ne, re = class re extends Error {
      constructor(t) {
        super(`The parsing ended early. The next token was: ${s(t)}`), this.token = t, Object.setPrototypeOf(this, re.prototype);
      }
      getToken() {
        return this.token;
      }
    };
    n(re, "EarlyEndOfParseError");
    let p = re, oe = class oe extends Error {
      constructor(t, o) {
        let i = `Unexpected type: '${t.type}'.`;
        o !== void 0 && (i += ` Message: ${o}`), super(i), Object.setPrototypeOf(this, oe.prototype);
      }
    };
    n(oe, "UnexpectedTypeError");
    let c = oe;
    function u(e) {
      return (t) => t.startsWith(e) ? { type: e, text: e } : null;
    }
    n(u, "makePunctuationRule");
    function y(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);
    }
    n(y, "getQuoted");
    let T = new RegExp("[$_\\p{ID_Start}]|\\\\u\\p{Hex_Digit}{4}|\\\\u\\{0*(?:\\p{Hex_Digit}{1,5}|10\\p{Hex_Digit}{4})\\}", "u"), g = new RegExp("[$\\-\\p{ID_Continue}\\u200C\\u200D]|\\\\u\\p{Hex_Digit}{4}|\\\\u\\{0*(?:\\p{Hex_Digit}{1,5}|10\\p{Hex_Digit}{4})\\}", "u");
    function x(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);
    }
    n(x, "getIdentifier");
    let b = /^(NaN|-?((\d*\.\d+|\d+)([Ee][+-]?\d+)?|Infinity))/;
    function de(e) {
      var t, o;
      return (o = (t = b.exec(e)) === null || t === void 0 ? void 0 : t[0]) !== null && o !== void 0 ? o : null;
    }
    n(de, "getNumber");
    let q = /* @__PURE__ */ n((e) => {
      let t = x(e);
      return t == null ? null : {
        type: "Identifier",
        text: t
      };
    }, "identifierRule");
    function S(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
        };
      };
    }
    n(S, "makeKeyWordRule");
    let X = /* @__PURE__ */ n((e) => {
      let t = y(e);
      return t == null ? null : {
        type: "StringValue",
        text: t
      };
    }, "stringValueRule"), Te = /* @__PURE__ */ n((e) => e.length > 0 ? null : {
      type: "EOF",
      text: ""
    }, "eofRule"), ge = /* @__PURE__ */ n((e) => {
      let t = de(e);
      return t === null ? null : {
        type: "Number",
        text: t
      };
    }, "numberRule"), kt = [
      Te,
      u("=>"),
      u("("),
      u(")"),
      u("{"),
      u("}"),
      u("["),
      u("]"),
      u("|"),
      u("&"),
      u("<"),
      u(">"),
      u(","),
      u(";"),
      u("*"),
      u("?"),
      u("!"),
      u("="),
      u(":"),
      u("..."),
      u("."),
      u("#"),
      u("~"),
      u("/"),
      u("@"),
      S("undefined"),
      S("null"),
      S("function"),
      S("this"),
      S("new"),
      S("module"),
      S("event"),
      S("external"),
      S("typeof"),
      S("keyof"),
      S("readonly"),
      S("import"),
      S("is"),
      S("in"),
      S("asserts"),
      ge,
      q,
      X
    ], Rt = /^\s*\n\s*/, U = class U {
      static create(t) {
        let o = this.read(t);
        t = o.text;
        let i = this.read(t);
        return t = i.text, new U(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 || Rt.test(t), t = t.trim();
        for (let i of kt) {
          let l = i(t);
          if (l !== null) {
            let m = Object.assign(Object.assign({}, l), { startOfLine: o });
            return t = t.slice(m.text.length), { text: t, token: m };
          }
        }
        throw new Error("Unexpected Token " + t);
      }
      advance() {
        let t = U.read(this.text);
        return new U(t.text, this.current, this.next, t.token);
      }
    };
    n(U, "Lexer");
    let he = U;
    function w(e) {
      if (e === void 0)
        throw new Error("Unexpected undefined");
      if (e.type === "JsdocTypeKeyValue" || e.type === "JsdocTypeParameterList" || e.type === "JsdocTypeProperty" || e.type === "JsdocTypeReadonlyProperty" || e.type === "JsdocTypeObjectField" || e.type === "JsdocTypeJsdocObjectField" || e.type === "JsdocTypeIndexSignature" || e.type === "JsdocTypeMappedType")
        throw new c(e);
      return e;
    }
    n(w, "assertRootResult");
    function Je(e) {
      return e.type === "JsdocTypeKeyValue" ? H(e) : w(e);
    }
    n(Je, "assertPlainKeyValueOrRootResult");
    function jt(e) {
      return e.type === "JsdocTypeName" ? e : H(e);
    }
    n(jt, "assertPlainKeyValueOrNameResult");
    function H(e) {
      if (e.type !== "JsdocTypeKeyValue")
        throw new c(e);
      return e;
    }
    n(H, "assertPlainKeyValueResult");
    function Vt(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;
    }
    n(Vt, "assertNumberOrVariadicNameResult");
    function we(e) {
      return e.type === "JsdocTypeIndexSignature" || e.type === "JsdocTypeMappedType";
    }
    n(we, "isSquaredProperty");
    var f;
    (function(e) {
      e[e.ALL = 0] = "ALL", e[e.PARAMETER_LIST = 1] = "PARAMETER_LIST", e[e.OBJECT = 2] = "OBJECT", e[e.KEY_VALUE = 3] = "KEY_VALUE", e[e.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";
    })(f || (f = {}));
    let Fe = class Fe {
      constructor(t, o, i) {
        this.grammar = t, typeof o == "string" ? this._lexer = he.create(o) : this._lexer = o, this.baseParser = i;
      }
      get lexer() {
        return this._lexer;
      }
      /**
       * Parses a given string and throws an error if the parse ended before the end of the string.
       */
      parse() {
        let t = this.parseType(f.ALL);
        if (this.lexer.current.type !== "EOF")
          throw new p(this.lexer.current);
        return t;
      }
      /**
       * Parses with the current lexer and asserts that the result is a {@link RootResult}.
       */
      parseType(t) {
        return w(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;
      }
    };
    n(Fe, "Parser");
    let I = Fe;
    function qe(e) {
      return e === "EOF" || e === "|" || e === "," || e === ")" || e === ">";
    }
    n(qe, "isQuestionMarkUnknownType");
    let Pe = /* @__PURE__ */ n((e, t, o) => {
      let i = e.lexer.current.type, l = e.lexer.next.type;
      return o == null && i === "?" && !qe(l) || o != null && i === "?" ? (e.consume("?"), o == null ? {
        type: "JsdocTypeNullable",
        element: e.parseType(f.NULLABLE),
        meta: {
          position: "prefix"
        }
      } : {
        type: "JsdocTypeNullable",
        element: w(o),
        meta: {
          position: "suffix"
        }
      }) : null;
    }, "nullableParslet");
    function h(e) {
      let t = /* @__PURE__ */ n((o, i, l) => {
        let m = o.lexer.current.type, d = o.lexer.next.type;
        if (l === null) {
          if ("parsePrefix" in e && e.accept(m, d))
            return e.parsePrefix(o);
        } else if ("parseInfix" in e && e.precedence > i && e.accept(m, d))
          return e.parseInfix(o, l);
        return null;
      }, "parslet");
      return Object.defineProperty(t, "name", {
        value: e.name
      }), t;
    }
    n(h, "composeParslet");
    let z = h({
      name: "optionalParslet",
      accept: /* @__PURE__ */ n((e) => e === "=", "accept"),
      precedence: f.OPTIONAL,
      parsePrefix: /* @__PURE__ */ n((e) => (e.consume("="), {
        type: "JsdocTypeOptional",
        element: e.parseType(f.OPTIONAL),
        meta: {
          position: "prefix"
        }
      }), "parsePrefix"),
      parseInfix: /* @__PURE__ */ n((e, t) => (e.consume("="), {
        type: "JsdocTypeOptional",
        element: w(t),
        meta: {
          position: "suffix"
        }
      }), "parseInfix")
    }), Q = h({
      name: "numberParslet",
      accept: /* @__PURE__ */ n((e) => e === "Number", "accept"),
      parsePrefix: /* @__PURE__ */ n((e) => {
        let t = parseFloat(e.lexer.current.text);
        return e.consume("Number"), {
          type: "JsdocTypeNumber",
          value: t
        };
      }, "parsePrefix")
    }), _t = h({
      name: "parenthesisParslet",
      accept: /* @__PURE__ */ n((e) => e === "(", "accept"),
      parsePrefix: /* @__PURE__ */ n((e) => {
        if (e.consume("("), e.consume(")"))
          return {
            type: "JsdocTypeParameterList",
            elements: []
          };
        let t = e.parseIntermediateType(f.ALL);
        if (!e.consume(")"))
          throw new Error("Unterminated parenthesis");
        return t.type === "JsdocTypeParameterList" ? t : t.type === "JsdocTypeKeyValue" ? {
          type: "JsdocTypeParameterList",
          elements: [t]
        } : {
          type: "JsdocTypeParenthesis",
          element: w(t)
        };
      }, "parsePrefix")
    }), Lt = h({
      name: "specialTypesParslet",
      accept: /* @__PURE__ */ n((e, t) => e === "?" && qe(t) || e === "null" || e === "undefined" || e === "*", "accept"),
      parsePrefix: /* @__PURE__ */ n((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")
    }), Ut = h({
      name: "notNullableParslet",
      accept: /* @__PURE__ */ n((e) => e === "!", "accept"),
      precedence: f.NULLABLE,
      parsePrefix: /* @__PURE__ */ n((e) => (e.consume("!"), {
        type: "JsdocTypeNotNullable",
        element: e.parseType(f.NULLABLE),
        meta: {
          position: "prefix"
        }
      }), "parsePrefix"),
      parseInfix: /* @__PURE__ */ n((e, t) => (e.consume("!"), {
        type: "JsdocTypeNotNullable",
        element: w(t),
        meta: {
          position: "suffix"
        }
      }), "parseInfix")
    });
    function Bt({ allowTrailingComma: e }) {
      return h({
        name: "parameterListParslet",
        accept: /* @__PURE__ */ n((t) => t === ",", "accept"),
        precedence: f.PARAMETER_LIST,
        parseInfix: /* @__PURE__ */ n((t, o) => {
          let i = [
            Je(o)
          ];
          t.consume(",");
          do
            try {
              let l = t.parseIntermediateType(f.PARAMETER_LIST);
              i.push(Je(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")
      });
    }
    n(Bt, "createParameterListParslet");
    let Ct = h({
      name: "genericParslet",
      accept: /* @__PURE__ */ n((e, t) => e === "<" || e === "." && t === "<", "accept"),
      precedence: f.GENERIC,
      parseInfix: /* @__PURE__ */ n((e, t) => {
        let o = e.consume(".");
        e.consume("<");
        let i = [];
        do
          i.push(e.parseType(f.PARAMETER_LIST));
        while (e.consume(","));
        if (!e.consume(">"))
          throw new Error("Unterminated generic parameter list");
        return {
          type: "JsdocTypeGeneric",
          left: w(t),
          elements: i,
          meta: {
            brackets: "angle",
            dot: o
          }
        };
      }, "parseInfix")
    }), Kt = h({
      name: "unionParslet",
      accept: /* @__PURE__ */ n((e) => e === "|", "accept"),
      precedence: f.UNION,
      parseInfix: /* @__PURE__ */ n((e, t) => {
        e.consume("|");
        let o = [];
        do
          o.push(e.parseType(f.UNION));
        while (e.consume("|"));
        return {
          type: "JsdocTypeUnion",
          elements: [w(t), ...o]
        };
      }, "parseInfix")
    }), xe = [
      Pe,
      z,
      Q,
      _t,
      Lt,
      Ut,
      Bt({
        allowTrailingComma: !0
      }),
      Ct,
      Kt,
      z
    ];
    function Z({ allowSquareBracketsOnAnyType: e, allowJsdocNamePaths: t, pathGrammar: o }) {
      return /* @__PURE__ */ n(function(l, m, d) {
        if (d == null || m >= f.NAME_PATH)
          return null;
        let J = l.lexer.current.type, D = l.lexer.next.type;
        if (!(J === "." && D !== "<" || J === "[" && (e || d.type === "JsdocTypeName") || t && (J === "~" || J === "#")))
          return null;
        let O, se = !1;
        l.consume(".") ? O = "property" : l.consume("[") ? (O = "property-brackets", se = !0) : l.consume("~") ? O = "inner" : (l.consume("#"), O = "instance");
        let tt = o !== null ? new I(o, l.lexer, l) : l, A = tt.parseIntermediateType(f.NAME_PATH);
        l.acceptLexerState(tt);
        let W;
        switch (A.type) {
          case "JsdocTypeName":
            W = {
              type: "JsdocTypeProperty",
              value: A.value,
              meta: {
                quote: void 0
              }
            };
            break;
          case "JsdocTypeNumber":
            W = {
              type: "JsdocTypeProperty",
              value: A.value.toString(10),
              meta: {
                quote: void 0
              }
            };
            break;
          case "JsdocTypeStringValue":
            W = {
              type: "JsdocTypeProperty",
              value: A.value,
              meta: {
                quote: A.meta.quote
              }
            };
            break;
          case "JsdocTypeSpecialNamePath":
            if (A.specialType === "event")
              W = A;
            else
              throw new c(A, "Type 'JsdocTypeSpecialNamePath' is only allowed with specialType 'event'");
            break;
          default:
            throw new c(A, "Expecting 'JsdocTypeName', 'JsdocTypeNumber', 'JsdocStringValue' or 'JsdocTypeSpecialNamePath'");
        }
        if (se && !l.consume("]")) {
          let nt = l.lexer.current;
          throw new Error(`Unterminated square brackets. Next token is '${nt.type}' with text '${nt.text}'`);
        }
        return {
          type: "JsdocTypeNamePath",
          left: w(d),
          right: W,
          pathType: O
        };
      }, "namePathParslet");
    }
    n(Z, "createNamePathParslet");
    function k({ allowedAdditionalTokens: e }) {
      return h({
        name: "nameParslet",
        accept: /* @__PURE__ */ n((t) => t === "Identifier" || t === "this" || t === "new" || e.includes(t), "accept"),
        parsePrefix: /* @__PURE__ */ n((t) => {
          let { type: o, text: i } = t.lexer.current;
          return t.consume(o), {
            type: "JsdocTypeName",
            value: i
          };
        }, "parsePrefix")
      });
    }
    n(k, "createNameParslet");
    let Y = h({
      name: "stringValueParslet",
      accept: /* @__PURE__ */ n((e) => e === "StringValue", "accept"),
      parsePrefix: /* @__PURE__ */ n((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 ee({ pathGrammar: e, allowedTypes: t }) {
      return h({
        name: "specialNamePathParslet",
        accept: /* @__PURE__ */ n((o) => t.includes(o), "accept"),
        parsePrefix: /* @__PURE__ */ n((o) => {
          let i = o.lexer.current.type;
          if (o.consume(i), !o.consume(":"))
            return {
              type: "JsdocTypeName",
              value: i
            };
          let l, m = o.lexer.current;
          if (o.consume("StringValue"))
            l = {
              type: "JsdocTypeSpecialNamePath",
              value: m.text.slice(1, -1),
              specialType: i,
              meta: {
                quote: m.text[0] === "'" ? "single" : "double"
              }
            };
          else {
            let D = "", E = ["Identifier", "@", "/"];
            for (; E.some((O) => o.consume(O)); )
              D += m.text, m = o.lexer.current;
            l = {
              type: "JsdocTypeSpecialNamePath",
              value: D,
              specialType: i,
              meta: {
                quote: void 0
              }
            };
          }
          let d = new I(e, o.lexer, o), J = d.parseInfixIntermediateType(l, f.ALL);
          return o.acceptLexerState(d), w(J);
        }, "parsePrefix")
      });
    }
    n(ee, "createSpecialNamePathParslet");
    let Ye = [
      k({
        allowedAdditionalTokens: ["external", "module"]
      }),
      Y,
      Q,
      Z({
        allowSquareBracketsOnAnyType: !1,
        allowJsdocNamePaths: !0,
        pathGrammar: null
      })
    ], L = [
      ...Ye,
      ee({
        allowedTypes: ["event"],
        pathGrammar: Ye
      })
    ];
    function be(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) => Je(o));
    }
    n(be, "getParameters");
    function Mt(e) {
      let t = be(e);
      if (t.some((o) => o.type === "JsdocTypeKeyValue"))
        throw new Error("No parameter should be named");
      return t;
    }
    n(Mt, "getUnnamedParameters");
    function Se({ allowNamedParameters: e, allowNoReturnType: t, allowWithoutParenthesis: o, allowNewAsFunctionKeyword: i }) {
      return h({
        name: "functionParslet",
        accept: /* @__PURE__ */ n((l, m) => l === "function" || i && l === "new" && m === "(", "accept"),
        parsePrefix: /* @__PURE__ */ n((l) => {
          let m = 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 J = {
            type: "JsdocTypeFunction",
            parameters: [],
            arrow: !1,
            constructor: m,
            parenthesis: d
          }, D = l.parseIntermediateType(f.FUNCTION);
          if (e === void 0)
            J.parameters = Mt(D);
          else {
            if (m && D.type === "JsdocTypeFunction" && D.arrow)
              return J = D, J.constructor = !0, J;
            J.parameters = be(D);
            for (let E of J.parameters)
              if (E.type === "JsdocTypeKeyValue" && !e.includes(E.key))
                throw new Error(`only allowed named parameters are ${e.join(", ")} but got ${E.type}`);
          }
          if (l.consume(":"))
            J.returnType = l.parseType(f.PREFIX);
          else if (!t)
            throw new Error("function is missing return type");
          return J;
        }, "parsePrefix")
      });
    }
    n(Se, "createFunctionParslet");
    function Ee({ allowPostfix: e, allowEnclosingBrackets: t }) {
      return h({
        name: "variadicParslet",
        accept: /* @__PURE__ */ n((o) => o === "...", "accept"),
        precedence: f.PREFIX,
        parsePrefix: /* @__PURE__ */ n((o) => {
          o.consume("...");
          let i = t && o.consume("[");
          try {
            let l = o.parseType(f.PREFIX);
            if (i && !o.consume("]"))
              throw new Error("Unterminated variadic type. Missing ']'");
            return {
              type: "JsdocTypeVariadic",
              element: w(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: w(i),
          meta: {
            position: "suffix",
            squareBrackets: !1
          }
        }) : void 0
      });
    }
    n(Ee, "createVariadicParslet");
    let Ge = h({
      name: "symbolParslet",
      accept: /* @__PURE__ */ n((e) => e === "(", "accept"),
      precedence: f.SYMBOL,
      parseInfix: /* @__PURE__ */ n((e, t) => {
        if (t.type !== "JsdocTypeName")
          throw new Error("Symbol expects a name on the left side. (Reacting on '(')");
        e.consume("(");
        let o = {
          type: "JsdocTypeSymbol",
          value: t.value
        };
        if (!e.consume(")")) {
          let i = e.parseIntermediateType(f.SYMBOL);
          if (o.element = Vt(i), !e.consume(")"))
            throw new Error("Symbol does not end after value");
        }
        return o;
      }, "parseInfix")
    }), We = h({
      name: "arrayBracketsParslet",
      precedence: f.ARRAY_BRACKETS,
      accept: /* @__PURE__ */ n((e, t) => e === "[" && t === "]", "accept"),
      parseInfix: /* @__PURE__ */ n((e, t) => (e.consume("["), e.consume("]"), {
        type: "JsdocTypeGeneric",
        left: {
          type: "JsdocTypeName",
          value: "Array"
        },
        elements: [
          w(t)
        ],
        meta: {
          brackets: "square",
          dot: !1
        }
      }), "parseInfix")
    });
    function Ne({ objectFieldGrammar: e, allowKeyTypes: t }) {
      return h({
        name: "objectParslet",
        accept: /* @__PURE__ */ n((o) => o === "{", "accept"),
        parsePrefix: /* @__PURE__ */ n((o) => {
          o.consume("{");
          let i = {
            type: "JsdocTypeObject",
            meta: {
              separator: "comma"
            },
            elements: []
          };
          if (!o.consume("}")) {
            let l, m = new I(e, o.lexer, o);
            for (; ; ) {
              m.acceptLexerState(o);
              let d = m.parseIntermediateType(f.OBJECT);
              o.acceptLexerState(m), d === void 0 && t && (d = o.parseIntermediateType(f.OBJECT));
              let J = !1;
              if (d.type === "JsdocTypeNullable" && (J = !0, d = d.element), d.type === "JsdocTypeNumber" || d.type === "JsdocTypeName" || d.type === "JsdocTypeStringValue") {
                let E;
                d.type === "JsdocTypeStringValue" && (E = d.meta.quote), i.elements.push({
                  type: "JsdocTypeObjectField",
                  key: d.value.toString(),
                  right: void 0,
                  optional: J,
                  readonly: !1,
                  meta: {
                    quote: E
                  }
                });
              } 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")
      });
    }
    n(Ne, "createObjectParslet");
    function De({ allowSquaredProperties: e, allowKeyTypes: t, allowReadonly: o, allowOptional: i }) {
      return h({
        name: "objectFieldParslet",
        precedence: f.KEY_VALUE,
        accept: /* @__PURE__ */ n((l) => l === ":", "accept"),
        parseInfix: /* @__PURE__ */ n((l, m) => {
          var d;
          let J = !1, D = !1;
          i && m.type === "JsdocTypeNullable" && (J = !0, m = m.element), o && m.type === "JsdocTypeReadonlyProperty" && (D = !0, m = m.element);
          let E = (d = l.baseParser) !== null && d !== void 0 ? d : l;
          if (E.acceptLexerState(l), m.type === "JsdocTypeNumber" || m.type === "JsdocTypeName" || m.type === "JsdocTypeStringValue" || we(m)) {
            if (we(m) && !e)
              throw new c(m);
            E.consume(":");
            let O;
            m.type === "JsdocTypeStringValue" && (O = m.meta.quote);
            let se = E.parseType(f.KEY_VALUE);
            return l.acceptLexerState(E), {
              type: "JsdocTypeObjectField",
              key: we(m) ? m : m.value.toString(),
              right: se,
              optional: J,
              readonly: D,
              meta: {
                quote: O
              }
            };
          } else {
            if (!t)
              throw new c(m);
            E.consume(":");
            let O = E.parseType(f.KEY_VALUE);
            return l.acceptLexerState(E), {
              type: "JsdocTypeJsdocObjectField",
              left: w(m),
              right: O
            };
          }
        }, "parseInfix")
      });
    }
    n(De, "createObjectFieldParslet");
    function Oe({ allowOptional: e, allowVariadic: t }) {
      return h({
        name: "keyValueParslet",
        precedence: f.KEY_VALUE,
        accept: /* @__PURE__ */ n((o) => o === ":", "accept"),
        parseInfix: /* @__PURE__ */ n((o, i) => {
          let l = !1, m = !1;
          if (e && i.type === "JsdocTypeNullable" && (l = !0, i = i.element), t && i.type === "JsdocTypeVariadic" && i.element !== void 0 && (m = !0, i = i.element), i.type !== "JsdocTypeName")
            throw new c(i);
          o.consume(":");
          let d = o.parseType(f.KEY_VALUE);
          return {
            type: "JsdocTypeKeyValue",
            key: i.value,
            right: d,
            optional: l,
            variadic: m
          };
        }, "parseInfix")
      });
    }
    n(Oe, "createKeyValueParslet");
    let Xe = [
      ...xe,
      Se({
        allowWithoutParenthesis: !0,
        allowNamedParameters: ["this", "new"],
        allowNoReturnType: !0,
        allowNewAsFunctionKeyword: !1
      }),
      Y,
      ee({
        allowedTypes: ["module", "external", "event"],
        pathGrammar: L
      }),
      Ee({
        allowEnclosingBrackets: !0,
        allowPostfix: !0
      }),
      k({
        allowedAdditionalTokens: ["keyof"]
      }),
      Ge,
      We,
      Z({
        allowSquareBracketsOnAnyType: !1,
        allowJsdocNamePaths: !0,
        pathGrammar: L
      })
    ], $t = [
      ...Xe,
      Ne({
        // 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: [
          k({
            allowedAdditionalTokens: ["module", "in"]
          }),
          De({
            allowSquaredProperties: !1,
            allowKeyTypes: !0,
            allowOptional: !1,
            allowReadonly: !1
          }),
          ...Xe
        ],
        allowKeyTypes: !0
      }),
      Oe({
        allowOptional: !0,
        allowVariadic: !0
      })
    ], He = h({
      name: "typeOfParslet",
      accept: /* @__PURE__ */ n((e) => e === "typeof", "accept"),
      parsePrefix: /* @__PURE__ */ n((e) => (e.consume("typeof"), {
        type: "JsdocTypeTypeof",
        element: w(e.parseType(f.KEY_OF_TYPE_OF))
      }), "parsePrefix")
    }), qt = [
      k({
        allowedAdditionalTokens: ["module", "keyof", "event", "external", "in"]
      }),
      Pe,
      z,
      Y,
      Q,
      De({
        allowSquaredProperties: !1,
        allowKeyTypes: !1,
        allowOptional: !1,
        allowReadonly: !1
      })
    ], Yt = [
      ...xe,
      Ne({
        allowKeyTypes: !1,
        objectFieldGrammar: qt
      }),
      k({
        allowedAdditionalTokens: ["event", "external", "in"]
      }),
      He,
      Se({
        allowWithoutParenthesis: !1,
        allowNamedParameters: ["this", "new"],
        allowNoReturnType: !0,
        allowNewAsFunctionKeyword: !1
      }),
      Ee({
        allowEnclosingBrackets: !1,
        allowPostfix: !1
      }),
      // additional name parslet is needed for some special cases
      k({
        allowedAdditionalTokens: ["keyof"]
      }),
      ee({
        allowedTypes: ["module"],
        pathGrammar: L
      }),
      Z({
        allowSquareBracketsOnAnyType: !1,
        allowJsdocNamePaths: !0,
        pathGrammar: L
      }),
      Oe({
        allowOptional: !1,
        allowVariadic: !1
      }),
      Ge
    ], Gt = h({
      name: "assertsParslet",
      accept: /* @__PURE__ */ n((e) => e === "asserts", "accept"),
      parsePrefix: /* @__PURE__ */ n((e) => {
        e.consume("asserts");
        let t = e.parseIntermediateType(f.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: w(e.parseIntermediateType(f.INFIX))
        };
      }, "parsePrefix")
    });
    function Wt({ allowQuestionMark: e }) {
      return h({
        name: "tupleParslet",
        accept: /* @__PURE__ */ n((t) => t === "[", "accept"),
        parsePrefix: /* @__PURE__ */ n((t) => {
          t.consume("[");
          let o = {
            type: "JsdocTypeTuple",
            elements: []
          };
          if (t.consume("]"))
            return o;
          let i = t.parseIntermediateType(f.ALL);
          if (i.type === "JsdocTypeParameterList" ? i.elements[0].type === "JsdocTypeKeyValue" ? o.elements = i.elements.map(H) : o.elements = i.elements.map(w) : i.type === "JsdocTypeKeyValue" ? o.elements = [H(i)] : o.elements = [w(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")
      });
    }
    n(Wt, "createTupleParslet");
    let Xt = h({
      name: "keyOfParslet",
      accept: /* @__PURE__ */ n((e) => e === "keyof", "accept"),
      parsePrefix: /* @__PURE__ */ n((e) => (e.consume("keyof"), {
        type: "JsdocTypeKeyof",
        element: w(e.parseType(f.KEY_OF_TYPE_OF))
      }), "parsePrefix")
    }), Ht = h({
      name: "importParslet",
      accept: /* @__PURE__ */ n((e) => e === "import", "accept"),
      parsePrefix: /* @__PURE__ */ n((e) => {
        if (e.consume("import"), !e.consume("("))
          throw new Error("Missing parenthesis after import keyword");
        let t = e.parseType(f.PREFIX);
        if (t.type !== "JsdocTypeStringValue")
          throw new Error("Only string values are allowed as paths for imports");
        if (!e.consume(")"))
          throw new Error("Missing closing parenthesis after import keyword");
        return {
          type: "JsdocTypeImport",
          element: t
        };
      }, "parsePrefix")
    }), zt = h({
      name: "readonlyPropertyParslet",
      accept: /* @__PURE__ */ n((e) => e === "readonly", "accept"),
      parsePrefix: /* @__PURE__ */ n((e) => (e.consume("readonly"), {
        type: "JsdocTypeReadonlyProperty",
        element: e.parseType(f.KEY_VALUE)
      }), "parsePrefix")
    }), Qt = h({
      name: "arrowFunctionParslet",
      precedence: f.ARROW,
      accept: /* @__PURE__ */ n((e) => e === "=>", "accept"),
      parseInfix: /* @__PURE__ */ n((e, t) => (e.consume("=>"), {
        type: "JsdocTypeFunction",
        parameters: be(t).map(jt),
        arrow: !0,
        constructor: !1,
        parenthesis: !0,
        returnType: e.parseType(f.OBJECT)
      }), "parseInfix")
    }), Zt = h({
      name: "intersectionParslet",
      accept: /* @__PURE__ */ n((e) => e === "&", "accept"),
      precedence: f.INTERSECTION,
      parseInfix: /* @__PURE__ */ n((e, t) => {
        e.consume("&");
        let o = [];
        do
          o.push(e.parseType(f.INTERSECTION));
        while (e.consume("&"));
        return {
          type: "JsdocTypeIntersection",
          elements: [w(t), ...o]
        };
      }, "parseInfix")
    }), en = h({
      name: "predicateParslet",
      precedence: f.INFIX,
      accept: /* @__PURE__ */ n((e) => e === "is", "accept"),
      parseInfix: /* @__PURE__ */ n((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: w(e.parseIntermediateType(f.INFIX))
        };
      }, "parseInfix")
    }), tn = h({
      name: "objectSquareBracketPropertyParslet",
      accept: /* @__PURE__ */ n((e) => e === "[", "accept"),
      parsePrefix: /* @__PURE__ */ n((e) => {
        if (e.baseParser === void 0)
          throw new Error("Only allowed inside object grammar");
        e.consume("[");
        let t = e.lexer.current.text;
        e.consume("Identifier");
        let o;
        if (e.consume(":")) {
          let i = e.baseParser;
          i.acceptLexerState(e), o = {
            type: "JsdocTypeIndexSignature",
            key: t,
            right: i.parseType(f.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(f.ARRAY_BRACKETS)
          }, e.acceptLexerState(i);
        } else
          throw new Error("Missing ':' or 'in' inside square bracketed property.");
        if (!e.consume("]"))
          throw new Error("Unterminated square brackets");
        return o;
      }, "parsePrefix")
    }), nn = [
      zt,
      k({
        allowedAdditionalTokens: ["module", "event", "keyof", "event", "external", "in"]
      }),
      Pe,
      z,
      Y,
      Q,
      De({
        allowSquaredProperties: !0,
        allowKeyTypes: !1,
        allowOptional: !0,
        allowReadonly: !0
      }),
      tn
    ], rn = [
      ...xe,
      Ne({
        allowKeyTypes: !1,
        objectFieldGrammar: nn
      }),
      He,
      Xt,
      Ht,
      Y,
      Se({
        allowWithoutParenthesis: !0,
        allowNoReturnType: !1,
        allowNamedParameters: ["this", "new", "args"],
        allowNewAsFunctionKeyword: !0
      }),
      Wt({
        allowQuestionMark: !1
      }),
      Ee({
        allowEnclosingBrackets: !1,
        allowPostfix: !1
      }),
      Gt,
      k({
        allowedAdditionalTokens: ["event", "external", "in"]
      }),
      ee({
        allowedTypes: ["module"],
        pathGrammar: L
      }),
      We,
      Qt,
      Z({
        allowSquareBracketsOnAnyType: !0,
        allowJsdocNamePaths: !1,
        pathGrammar: L
      }),
      Zt,
      en,
      Oe({
        allowVariadic: !0,
        allowOptional: !0
      })
    ];
    function ze(e, t) {
      switch (t) {
        case "closure":
          return new I(Yt, e).parse();
        case "jsdoc":
          return new I($t, e).parse();
        case "typescript":
          return new I(rn, e).parse();
      }
    }
    n(ze, "parse");
    function on(e, t = ["typescript", "closure", "jsdoc"]) {
      let o;
      for (let i of t)
        try {
          return ze(e, i);
        } catch (l) {
          o = l;
        }
      throw o;
    }
    n(on, "tryParse");
    function G(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) => G(e, i));
    }
    n(G, "transform");
    function N(e) {
      throw new Error("This transform is not available. Are you trying the correct parsing mode?");
    }
    n(N, "notAvailableTransform");
    function Qe(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;
    }
    n(Qe, "extractSpecialParams");
    function te(e, t, o) {
      return e === "prefix" ? o + t : t + o;
    }
    n(te, "applyPosition");
    function R(e, t) {
      switch (t) {
        case "double":
          return `"${e}"`;
        case "single":
          return `'${e}'`;
        case void 0:
          return e;
      }
    }
    n(R, "quote");
    function Ze() {
      return {
        JsdocTypeParenthesis: /* @__PURE__ */ n((e, t) => `(${e.element !== void 0 ? t(e.element) : ""})`, "JsdocTypeParenthesis"),
        JsdocTypeKeyof: /* @__PURE__ */ n((e, t) => `keyof ${t(e.element)}`, "JsdocTypeKeyof"),
        JsdocTypeFunction: /* @__PURE__ */ n((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__ */ n((e) => e.value, "JsdocTypeName"),
        JsdocTypeTuple: /* @__PURE__ */ n((e, t) => `[${e.elements.map(t).join(", ")}]`, "JsdocTypeTuple"),
        JsdocTypeVariadic: /* @__PURE__ */ n((e, t) => e.meta.position === void 0 ? "..." : te(e.meta.position, t(e.element), "..."), "JsdocTypeVariadic"),
        JsdocTypeNamePath: /* @__PURE__ */ n((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__ */ n((e) => R(e.value, e.meta.quote), "JsdocTypeStringValue"),
        JsdocTypeAny: /* @__PURE__ */ n(() => "*", "JsdocTypeAny"),
        JsdocTypeGeneric: /* @__PURE__ */ n((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__ */ n((e, t) => `import(${t(e.element)})`, "JsdocTypeImport"),
        JsdocTypeObjectField: /* @__PURE__ */ n((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__ */ n((e, t) => `${t(e.left)}: ${t(e.right)}`, "JsdocTypeJsdocObjectField"),
        JsdocTypeKeyValue: /* @__PURE__ */ n((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__ */ n((e) => `${e.specialType}:${R(e.value, e.meta.quote)}`, "JsdocTypeSpecialNamePath"),
        JsdocTypeNotNullable: /* @__PURE__ */ n((e, t) => te(e.meta.position, t(e.element), "!"), "JsdocTypeNotNullable"),
        JsdocTypeNull: /* @__PURE__ */ n(() => "null", "JsdocTypeNull"),
        JsdocTypeNullable: /* @__PURE__ */ n((e, t) => te(e.meta.position, t(e.element), "?"), "JsdocTypeNullable"),
        JsdocTypeNumber: /* @__PURE__ */ n((e) => e.value.toString(), "JsdocTypeNumber"),
        JsdocTypeObject: /* @__PURE__ */ n((e, t) => `{${e.elements.map(t).join((e.meta.separator === "comma" ? "," : ";") + " ")}}`, "JsdocTypeObject"),
        JsdocTypeOptional: /* @__PURE__ */ n((e, t) => te(e.meta.position, t(e.element), "="), "JsdocTypeOptional"),
        JsdocTypeSymbol: /* @__PURE__ */ n((e, t) => `${e.value}(${e.element !== void 0 ? t(e.element) : ""})`, "JsdocTypeSymbol"),
        JsdocTypeTypeof: /* @__PURE__ */ n((e, t) => `typeof ${t(e.element)}`, "JsdocTypeTypeof"),
        JsdocTypeUndefined: /* @__PURE__ */ n(() => "undefined", "JsdocTypeUndefined"),
        JsdocTypeUnion: /* @__PURE__ */ n((e, t) => e.elements.map(t).join(" | "), "JsdocTypeUnion"),
        JsdocTypeUnknown: /* @__PURE__ */ n(() => "?", "JsdocTypeUnknown"),
        JsdocTypeIntersection: /* @__PURE__ */ n((e, t) => e.elements.map(t).join(" & "), "JsdocTypeIntersection"),
        JsdocTypeProperty: /* @__PURE__ */ n((e) => R(e.value, e.meta.quote), "JsdocTypeProperty"),
        JsdocTypePredicate: /* @__PURE__ */ n((e, t) => `${t(e.left)} is ${t(e.right)}`, "JsdocTypePredicate"),
        JsdocTypeIndexSignature: /* @__PURE__ */ n((e, t) => `[${e.key}: ${t(e.right)}]`, "JsdocTypeIndexSignature"),
        JsdocTypeMappedType: /* @__PURE__ */ n((e, t) => `[${e.key} in ${t(e.right)}]`, "JsdocTypeMappedType"),
        JsdocTypeAsserts: /* @__PURE__ */ n((e, t) => `asserts ${t(e.left)} is ${t(e.right)}`, "JsdocTypeAsserts")
      };
    }
    n(Ze, "stringifyRules");
    let sn = Ze();
    function an(e) {
      return G(sn, e);
    }
    n(an, "stringify");
    let pn = [
      "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 pn.includes(e) && (t.reservedWord = !0), t;
    }
    n(j, "makeName");
    let cn = {
      JsdocTypeOptional: /* @__PURE__ */ n((e, t) => {
        let o = t(e.element);
        return o.optional = !0, o;
      }, "JsdocTypeOptional"),
      JsdocTypeNullable: /* @__PURE__ */ n((e, t) => {
        let o = t(e.element);
        return o.nullable = !0, o;
      }, "JsdocTypeNullable"),
      JsdocTypeNotNullable: /* @__PURE__ */ n((e, t) => {
        let o = t(e.element);
        return o.nullable = !1, o;
      }, "JsdocTypeNotNullable"),
      JsdocTypeVariadic: /* @__PURE__ */ n((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__ */ n(() => ({
        type: "AllLiteral"
      }), "JsdocTypeAny"),
      JsdocTypeNull: /* @__PURE__ */ n(() => ({
        type: "NullLiteral"
      }), "JsdocTypeNull"),
      JsdocTypeStringValue: /* @__PURE__ */ n((e) => j(R(e.value, e.meta.quote)), "JsdocTypeStringValue"),
      JsdocTypeUndefined: /* @__PURE__ */ n(() => ({
        type: "UndefinedLiteral"
      }), "JsdocTypeUndefined"),
      JsdocTypeUnknown: /* @__PURE__ */ n(() => ({
        type: "UnknownLiteral"
      }), "JsdocTypeUnknown"),
      JsdocTypeFunction: /* @__PURE__ */ n((e, t) => {
        let o = Qe(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__ */ n((e, t) => ({
        type: "TypeApplication",
        applications: e.elements.map((o) => t(o)),
        expression: t(e.left)
      }), "JsdocTypeGeneric"),
      JsdocTypeSpecialNamePath: /* @__PURE__ */ n((e) => j(e.specialType + ":" + R(e.value, e.meta.quote)), "JsdocTypeSpecialNamePath"),
      JsdocTypeName: /* @__PURE__ */ n((e) => e.value !== "function" ? j(e.value) : {
        type: "FunctionType",
        params: []
      }, "JsdocTypeName"),
      JsdocTypeNumber: /* @__PURE__ */ n((e) => j(e.value.toString()), "JsdocTypeNumber"),
      JsdocTypeObject: /* @__PURE__ */ n((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__ */ n((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__ */ n((e, t) => ({
        type: "FieldType",
        key: t(e.left),
        value: t(e.right)
      }), "JsdocTypeJsdocObjectField"),
      JsdocTypeUnion: /* @__PURE__ */ n((e, t) => ({
        type: "TypeUnion",
        elements: e.elements.map((o) => t(o))
      }), "JsdocTypeUnion"),
      JsdocTypeKeyValue: /* @__PURE__ */ n((e, t) => ({
        type: "FieldType",
        key: j(e.key),
        value: e.right === void 0 ? void 0 : t(e.right)
      }), "JsdocTypeKeyValue"),
      JsdocTypeNamePath: /* @__PURE__ */ n((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__ */ n((e) => {
        let t = "", o = e.element, i = !1;
        return o?.type === "JsdocTypeVariadic" && (o.meta.position === "prefix" ? t = "..." : i = !0, o = o.element), o?.type === "JsdocTypeName" ? t += o.value : o?.type === "JsdocTypeNumber" && (t += o.value.toString()), i && (t += "..."), j(`${e.value}(${t})`);
      }, "JsdocTypeSymbol"),
      JsdocTypeParenthesis: /* @__PURE__ */ n((e, t) => t(w(e.element)), "JsdocTypeParenthesis"),
      JsdocTypeMappedType: N,
      JsdocTypeIndexSignature: N,
      JsdocTypeImport: N,
      JsdocTypeKeyof: N,
      JsdocTypeTuple: N,
      JsdocTypeTypeof: N,
      JsdocTypeIntersection: N,
      JsdocTypeProperty: N,
      JsdocTypePredicate: N,
      JsdocTypeAsserts: N
    };
    function ln(e) {
      return G(cn, e);
    }
    n(ln, "catharsisTransform");
    function _(e) {
      switch (e) {
        case void 0:
          return "none";
        case "single":
          return "single";
        case "double":
          return "double";
      }
    }
    n(_, "getQuoteStyle");
    function un(e) {
      switch (e) {
        case "inner":
          return "INNER_MEMBER";
        case "instance":
          return "INSTANCE_MEMBER";
        case "property":
          return "MEMBER";
        case "property-brackets":
          return "MEMBER";
      }
    }
    n(un, "getMemberType");
    function ve(e, t) {
      return t.length === 2 ? {
        type: e,
        left: t[0],
        right: t[1]
      } : {
        type: e,
        left: t[0],
        right: ve(e, t.slice(1))
      };
    }
    n(ve, "nestResults");
    let yn = {
      JsdocTypeOptional: /* @__PURE__ */ n((e, t) => ({
        type: "OPTIONAL",
        value: t(e.element),
        meta: {
          syntax: e.meta.position === "prefix" ? "PREFIX_EQUAL_SIGN" : "SUFFIX_EQUALS_SIGN"
        }
      }), "JsdocTypeOptional"),
      JsdocTypeNullable: /* @__PURE__ */ n((e, t) => ({
        type: "NULLABLE",
        value: t(e.element),
        meta: {
          syntax: e.meta.position === "prefix" ? "PREFIX_QUESTION_MARK" : "SUFFIX_QUESTION_MARK"
        }
      }), "JsdocTypeNullable"),
      JsdocTypeNotNullable: /* @__PURE__ */ n((e, t) => ({
        type: "NOT_NULLABLE",
        value: t(e.element),
        meta: {
          syntax: e.meta.position === "prefix" ? "PREFIX_BANG" : "SUFFIX_BANG"
        }
      }), "JsdocTypeNotNullable"),
      JsdocTypeVariadic: /* @__PURE__ */ n((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__ */ n((e) => ({
        type: "NAME",
        name: e.value
      }), "JsdocTypeName"),
      JsdocTypeTypeof: /* @__PURE__ */ n((e, t) => ({
        type: "TYPE_QUERY",
        name: t(e.element)
      }), "JsdocTypeTypeof"),
      JsdocTypeTuple: /* @__PURE__ */ n((e, t) => ({
        type: "TUPLE",
        entries: e.elements.map(t)
      }), "JsdocTypeTuple"),
      JsdocTypeKeyof: /* @__PURE__ */ n((e, t) => ({
        type: "KEY_QUERY",
        value: t(e.element)
      }), "JsdocTypeKeyof"),
      JsdocTypeImport: /* @__PURE__ */ n((e) => ({
        type: "IMPORT",
        path: {
          type: "STRING_VALUE",
          quoteStyle: _(e.element.meta.quote),
          string: e.element.value
        }
      }), "JsdocTypeImport"),
      JsdocTypeUndefined: /* @__PURE__ */ n(() => ({
        type: "NAME",
        name: "undefined"
      }), "JsdocTypeUndefined"),
      JsdocTypeAny: /* @__PURE__ */ n(() => ({
        type: "ANY"
      }), "JsdocTypeAny"),
      JsdocTypeFunction: /* @__PURE__ */ n((e, t) => {
        let o = Qe(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__ */ n((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__ */ n((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__ */ n(() => {
        throw new Error("Keys may not be typed in jsdoctypeparser.");
      }, "JsdocTypeJsdocObjectField"),
      JsdocTypeKeyValue: /* @__PURE__ */ n((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__ */ n((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__ */ n((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__ */ n((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 m = {
          type: un(e.pathType),
          owner: t(e.left),
          name: i,
          quoteStyle: l,
          hasEventPrefix: o
        };
        if (m.owner.type === "MODULE") {
          let d = m.owner;
          return m.owner = m.owner.value, d.value = m, d;
        } else
          return m;
      }, "JsdocTypeNamePath"),
      JsdocTypeUnion: /* @__PURE__ */ n((e, t) => ve("UNION", e.elements.map(t)), "JsdocTypeUnion"),
      JsdocTypeParenthesis: /* @__PURE__ */ n((e, t) => ({
        type: "PARENTHESIS",
        value: t(w(e.element))
      }), "JsdocTypeParenthesis"),
      JsdocTypeNull: /* @__PURE__ */ n(() => ({
        type: "NAME",
        name: "null"
      }), "JsdocTypeNull"),
      JsdocTypeUnknown: /* @__PURE__ */ n(() => ({
        type: "UNKNOWN"
      }), "JsdocTypeUnknown"),
      JsdocTypeStringValue: /* @__PURE__ */ n((e) => ({
        type: "STRING_VALUE",
        quoteStyle: _(e.meta.quote),
        string: e.value
      }), "JsdocTypeStringValue"),
      JsdocTypeIntersection: /* @__PURE__ */ n((e, t) => ve("INTERSECTION", e.elements.map(t)), "JsdocTypeIntersection"),
      JsdocTypeNumber: /* @__PURE__ */ n((e) => ({
        type: "NUMBER_VALUE",
        number: e.value.toString()
      }), "JsdocTypeNumber"),
      JsdocTypeSymbol: N,
      JsdocTypeProperty: N,
      JsdocTypePredicate: N,
      JsdocTypeMappedType: N,
      JsdocTypeIndexSignature: N,
      JsdocTypeAsserts: N
    };
    function mn(e) {
      return G(yn, e);
    }
    n(mn, "jtpTransform");
    function fn() {
      return {
        JsdocTypeIntersection: /* @__PURE__ */ n((e, t) => ({
          type: "JsdocTypeIntersection",
          elements: e.elements.map(t)
        }), "JsdocTypeIntersection"),
        JsdocTypeGeneric: /* @__PURE__ */ n((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__ */ n((e) => e, "JsdocTypeNullable"),
        JsdocTypeUnion: /* @__PURE__ */ n((e, t) => ({
          type: "JsdocTypeUnion",
          elements: e.elements.map(t)
        }), "JsdocTypeUnion"),
        JsdocTypeUnknown: /* @__PURE__ */ n((e) => e, "JsdocTypeUnknown"),
        JsdocTypeUndefined: /* @__PURE__ */ n((e) => e, "JsdocTypeUndefined"),
        JsdocTypeTypeof: /* @__PURE__ */ n((e, t) => ({
          type: "JsdocTypeTypeof",
          element: t(e.element)
        }), "JsdocTypeTypeof"),
        JsdocTypeSymbol: /* @__PURE__ */ n((e, t) => {
          let o = {
            type: "JsdocTypeSymbol",
            value: e.value
          };
          return e.element !== void 0 && (o.element = t(e.element)), o;
        }, "JsdocTypeSymbol"),
        JsdocTypeOptional: /* @__PURE__ */ n((e, t) => ({
          type: "JsdocTypeOptional",
          element: t(e.element),
          meta: {
            position: e.meta.position
          }
        }), "JsdocTypeOptional"),
        JsdocTypeObject: /* @__PURE__ */ n((e, t) => ({
          type: "JsdocTypeObject",
          meta: {
            separator: "comma"
          },
          elements: e.elements.map(t)
        }), "JsdocTypeObject"),
        JsdocTypeNumber: /* @__PURE__ */ n((e) => e, "JsdocTypeNumber"),
        JsdocTypeNull: /* @__PURE__ */ n((e) => e, "JsdocTypeNull"),
        JsdocTypeNotNullable: /* @__PURE__ */ n((e, t) => ({
          type: "JsdocTypeNotNullable",
          element: t(e.element),
          meta: {
            position: e.meta.position
          }
        }), "JsdocTypeNotNullable"),
        JsdocTypeSpecialNamePath: /* @__PURE__ */ n((e) => e, "JsdocTypeSpecialNamePath"),
        JsdocTypeObjectField: /* @__PURE__ */ n((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__ */ n((e, t) => ({
          type: "JsdocTypeJsdocObjectField",
          left: t(e.left),
          right: t(e.right)
        }), "JsdocTypeJsdocObjectField"),
        JsdocTypeKeyValue: /* @__PURE__ */ n((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__ */ n((e, t) => ({
          type: "JsdocTypeImport",
          element: t(e.element)
        }), "JsdocTypeImport"),
        JsdocTypeAny: /* @__PURE__ */ n((e) => e, "JsdocTypeAny"),
        JsdocTypeStringValue: /* @__PURE__ */ n((e) => e, "JsdocTypeStringValue"),
        JsdocTypeNamePath: /* @__PURE__ */ n((e) => e, "JsdocTypeNamePath"),
        JsdocTypeVariadic: /* @__PURE__ */ n((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__ */ n((e, t) => ({
          type: "JsdocTypeTuple",
          elements: e.elements.map(t)
        }), "JsdocTypeTuple"),
        JsdocTypeName: /* @__PURE__ */ n((e) => e, "JsdocTypeName"),
        JsdocTypeFunction: /* @__PURE__ */ n((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__ */ n((e, t) => ({
          type: "JsdocTypeKeyof",
          element: t(e.element)
        }), "JsdocTypeKeyof"),
        JsdocTypeParenthesis: /* @__PURE__ */ n((e, t) => ({
          type: "JsdocTypeParenthesis",
          element: t(e.element)
        }), "JsdocTypeParenthesis"),
        JsdocTypeProperty: /* @__PURE__ */ n((e) => e, "JsdocTypeProperty"),
        JsdocTypePredicate: /* @__PURE__ */ n((e, t) => ({
          type: "JsdocTypePredicate",
          left: t(e.left),
          right: t(e.right)
        }), "JsdocTypePredicate"),
        JsdocTypeIndexSignature: /* @__PURE__ */ n((e, t) => ({
          type: "JsdocTypeIndexSignature",
          key: e.key,
          right: t(e.right)
        }), "JsdocTypeIndexSignature"),
        JsdocTypeMappedType: /* @__PURE__ */ n((e, t) => ({
          type: "JsdocTypeMappedType",
          key: e.key,
          right: t(e.right)
        }), "JsdocTypeMappedType"),
        JsdocTypeAsserts: /* @__PURE__ */ n((e, t) => ({
          type: "JsdocTypeAsserts",
          left: t(e.left),
          right: t(e.right)
        }), "JsdocTypeAsserts")
      };
    }
    n(fn, "identityTransformRules");
    let et = {
      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 Ae(e, t, o, i, l) {
      i?.(e, t, o);
      let m = et[e.type];
      for (let d of m) {
        let J = e[d];
        if (J !== void 0)
          if (Array.isArray(J))
            for (let D of J)
              Ae(D, e, d, i, l);
          else
            Ae(J, e, d, i, l);
      }
      l?.(e, t, o);
    }
    n(Ae, "_traverse");
    function dn(e, t, o) {
      Ae(e, void 0, void 0, t, o);
    }
    n(dn, "traverse"), r.catharsisTransform = ln, r.identityTransformRules = fn, r.jtpTransform = mn, r.parse = ze, r.stringify = an, r.stringifyRules = Ze, r.transform = G, r.traverse = dn, r.tryParse = on, r.visitorKeys = et;
  });
});

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

// src/docs-tools/argTypes/convert/utils.ts
var ot = /^['"]|['"]$/g, xn = /* @__PURE__ */ n((r) => r.replace(ot, ""), "trimQuotes"), bn = /* @__PURE__ */ n((r) => ot.test(r), "includesQuotes"), ie = /* @__PURE__ */ n((r) => {
  let s = xn(r);
  return bn(r) || Number.isNaN(Number(s)) ? s : Number(s);
}, "parseLiteral");

// src/docs-tools/argTypes/convert/proptypes/convert.ts
var Sn = /^\(.*\) => /, C = /* @__PURE__ */ n((r) => {
  let { name: s, raw: a, computed: p, value: c } = r, u = {};
  switch (typeof a < "u" && (u.raw = a), s) {
    case "enum": {
      let T = p ? c : c.map((g) => ie(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 && C(c) };
    case "object":
      return { ...u, name: s };
    case "objectOf":
      return { ...u, name: s, value: C(c) };
    case "shape":
    case "exact":
      let y = rt(c, (T) => C(T));
      return { ...u, name: "object", value: y };
    case "union":
      return { ...u, name: "union", value: c.map((T) => C(T)) };
    case "instanceOf":
    case "element":
    case "elementType":
    default: {
      if (s?.indexOf("|") > 0)
        try {
          let x = s.split("|").map((b) => JSON.parse(b));
          return { ...u, name: "enum", value: x };
        } catch {
        }
      let T = c ? `${s}(${c})` : s, g = Sn.test(s) ? "function" : "other";
      return { ...u, name: g, value: T };
    }
  }
}, "convert");

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

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

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

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

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

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

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

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

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

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

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

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

// ../node_modules/comment-parser/es6/parser/tokenizers/type.js
function le(r = "compact") {
  let s = Fn(r);
  return (a) => {
    let p = 0, c = [];
    for (let [T, { tokens: g }] of a.source.entries()) {
      let x = "";
      if (T === 0 && g.description[0] !== "{")
        return a;
      for (let b of g.description)
        if (b === "{" && p++, b === "}" && p--, x += b, p === 0)
          break;
      if (c.push([g, x]), 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 = [], y = c[0][0].postDelimiter.length;
    for (let [T, [g, x]] of c.entries())
      g.type = x, T > 0 && (g.type = g.postDelimiter.slice(y) + x, g.postDelimiter = g.postDelimiter.slice(0, y)), [g.postType, g.description] = F(g.description.slice(x.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;
  };
}
n(le, "typeTokenizer");
var An = /* @__PURE__ */ n((r) => r.trim(), "trim");
function Fn(r) {
  return r === "compact" ? (s) => s.map(An).join("") : r === "preserve" ? (s) => s.join(`
`) : r;
}
n(Fn, "getJoiner");

// ../node_modules/comment-parser/es6/parser/tokenizers/name.js
var In = /* @__PURE__ */ n((r) => r && r.startsWith('"') && r.endsWith('"'), "isQuoted");
function ue() {
  let r = /* @__PURE__ */ n((s, { tokens: a }, p) => a.type === "" ? s : p, "typeEnd");
  return (s) => {
    let { tokens: a } = s.source[s.source.reduce(r, 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] = F(p.slice(a.name.length)), s;
    let u = 0, y = "", T = !1, g;
    for (let b of p) {
      if (u === 0 && ke(b))
        break;
      b === "[" && u++, b === "]" && u--, y += 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 x = y;
    if (y[0] === "[" && y[y.length - 1] === "]") {
      T = !0, y = y.slice(1, -1);
      let b = y.split("=");
      if (y = b[0].trim(), b[1] !== void 0 && (g = b.slice(1).join("=").trim()), y === "")
        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 (!In(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 = y, a.name = x, g !== void 0 && (s.default = g), [a.postName, a.description] = F(p.slice(a.name.length)), s;
  };
}
n(ue, "nameTokenizer");

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

// ../node_modules/comment-parser/es6/parser/index.js
function Ue({ startLine: r = 0, fence: s = "```", spacing: a = "compact", markers: p = v, tokenizers: c = [
  ce(),
  le(a),
  ue(),
  ye(a)
] } = {}) {
  if (r < 0 || r % 1 > 0)
    throw new Error("Invalid startLine");
  let u = Ve({ startLine: r, markers: p }), y = je({ fence: s }), T = _e({ tokenizers: c }), g = Le(a);
  return function(x) {
    let b = [];
    for (let de of ut(x)) {
      let q = u(de);
      if (q === null)
        continue;
      let S = y(q), X = S.slice(1).map(T);
      b.push({
        description: g(S[0], p),
        tags: X,
        source: q,
        problems: X.reduce((Te, ge) => Te.concat(ge.problems), [])
      });
    }
    return b;
  };
}
n(Ue, "getParser");

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

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

// ../node_modules/comment-parser/es6/index.js
function mt(r, s = {}) {
  return Ue(s)(r);
}
n(mt, "parse");
var ys = Be();

// src/docs-tools/argTypes/jsdocParser.ts
var $ = gn(dt(), 1);
function Un(r) {
  return r != null && r.includes("@");
}
n(Un, "containsJsDoc");
function Bn(r) {
  let p = `/**
` + (r ?? "").split(`
`).map((u) => ` * ${u}`).join(`
`) + `
*/`, c = mt(p, {
    spacing: "preserve"
  });
  if (!c || c.length === 0)
    throw new Error("Cannot parse JSDoc tags.");
  return c[0];
}
n(Bn, "parse");
var Cn = {
  tags: ["param", "arg", "argument", "returns", "ignore", "deprecated"]
}, Tt = /* @__PURE__ */ n((r, s = Cn) => {
  if (!Un(r))
    return {
      includesJsDoc: !1,
      ignore: !1
    };
  let a = Bn(r), p = Kn(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 Kn(r, s) {
  let a = {
    params: null,
    deprecated: null,
    returns: null,
    ignore: !1
  };
  for (let p of r.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 = $n(p);
            c != null && (a.params == null && (a.params = []), a.params.push(c));
            break;
          }
          case "deprecated": {
            let c = qn(p);
            c != null && (a.deprecated = c);
            break;
          }
          case "returns": {
            let c = Yn(p);
            c != null && (a.returns = c);
            break;
          }
          default:
            break;
        }
  return a;
}
n(Kn, "extractJsDocTags");
function Mn(r) {
  return r.replace(/[\.-]$/, "");
}
n(Mn, "normaliseParamName");
function $n(r) {
  if (!r.name || r.name === "-")
    return null;
  let s = Jt(r.type);
  return {
    name: r.name,
    type: s,
    description: ht(r.description),
    getPrettyName: /* @__PURE__ */ n(() => Mn(r.name), "getPrettyName"),
    getTypeName: /* @__PURE__ */ n(() => s ? wt(s) : null, "getTypeName")
  };
}
n($n, "extractParam");
function qn(r) {
  return r.name ? gt(r.name, r.description) : null;
}
n(qn, "extractDeprecated");
function gt(r, s) {
  let a = r === "" ? s : `${r} ${s}`;
  return ht(a);
}
n(gt, "joinNameAndDescription");
function ht(r) {
  let s = r.replace(/^- /g, "").trim();
  return s === "" ? null : s;
}
n(ht, "normaliseDescription");
function Yn(r) {
  let s = Jt(r.type);
  return s ? {
    type: s,
    description: gt(r.name, r.description),
    getTypeName: /* @__PURE__ */ n(() => wt(s), "getTypeName")
  } : null;
}
n(Yn, "extractReturns");
var V = (0, $.stringifyRules)(), Gn = V.JsdocTypeObject;
V.JsdocTypeAny = () => "any";
V.JsdocTypeObject = (r, s) => `(${Gn(r, s)})`;
V.JsdocTypeOptional = (r, s) => s(r.element);
V.JsdocTypeNullable = (r, s) => s(r.element);
V.JsdocTypeNotNullable = (r, s) => s(r.element);
V.JsdocTypeUnion = (r, s) => r.elements.map(s).join("|");
function Jt(r) {
  try {
    return (0, $.parse)(r, "typescript");
  } catch {
    return null;
  }
}
n(Jt, "extractType");
function wt(r) {
  return (0, $.transform)(V, r);
}
n(wt, "extractTypeName");

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

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

// src/docs-tools/argTypes/docgen/flow/createType.ts
function bt({ name: r, value: s, elements: a, raw: p }) {
  return s ?? (a != null ? a.map(bt).join(" | ") : p ?? r);
}
n(bt, "generateUnionElement");
function Wn({ name: r, raw: s, elements: a }) {
  return a != null ? P(a.map(bt).join(" | ")) : s != null ? P(s.replace(/^\|\s*/, "")) : P(r);
}
n(Wn, "generateUnion");
function Xn({ type: r, raw: s }) {
  return s != null ? P(s) : P(r);
}
n(Xn, "generateFuncSignature");
function Hn({ type: r, raw: s }) {
  return s != null ? Ke(s) ? P(r, s) : P(s) : P(r);
}
n(Hn, "generateObjectSignature");
function zn(r) {
  let { type: s } = r;
  return s === "object" ? Hn(r) : Xn(r);
}
n(zn, "generateSignature");
function Qn({ name: r, raw: s }) {
  return s != null ? Ke(s) ? P(r, s) : P(s) : P(r);
}
n(Qn, "generateDefault");
function St(r) {
  if (r == null)
    return null;
  switch (r.name) {
    case "union":
      return Wn(r);
    case "signature":
      return zn(r);
    default:
      return Qn(r);
  }
}
n(St, "createType");

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

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

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

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

// src/docs-tools/argTypes/docgen/createPropDef.ts
function Zn(r) {
  return r != null ? P(r.name) : null;
}
n(Zn, "createType");
function er(r) {
  let { computed: s, func: a } = r;
  return typeof s > "u" && typeof a > "u";
}
n(er, "isReactDocgenTypescript");
function tr(r) {
  return r ? r.name === "string" ? !0 : r.name === "enum" ? Array.isArray(r.value) && r.value.every(
    ({ value: s }) => typeof s == "string" && s[0] === '"' && s[s.length - 1] === '"'
  ) : !1 : !1;
}
n(tr, "isStringValued");
function nr(r, s) {
  if (r != null) {
    let { value: a } = r;
    if (!M(a))
      return er(r) && tr(s) ? P(JSON.stringify(a)) : P(a);
  }
  return null;
}
n(nr, "createDefaultValue");
function vt(r, s, a) {
  let { description: p, required: c, defaultValue: u } = a;
  return {
    name: r,
    type: Zn(s),
    required: c,
    description: p,
    defaultValue: nr(u, s)
  };
}
n(vt, "createBasicPropDef");
function fe(r, s) {
  if (s?.includesJsDoc) {
    let { description: a, extractedTags: p } = s;
    a != null && (r.description = s.description);
    let c = {
      ...p,
      params: p?.params?.map(
        (u) => ({
          name: u.getPrettyName(),
          description: u.description
        })
      )
    };
    Object.values(c).filter(Boolean).length > 0 && (r.jsDocTags = c);
  }
  return r;
}
n(fe, "applyJsDocResult");
var rr = /* @__PURE__ */ n((r, s, a) => {
  let p = vt(r, s.type, s);
  return p.sbType = pe(s), fe(p, a);
}, "javaScriptFactory"), or = /* @__PURE__ */ n((r, s, a) => {
  let p = Ot(r, s);
  return p.sbType = pe(s), fe(p, a);
}, "tsFactory"), sr = /* @__PURE__ */ n((r, s, a) => {
  let p = Et(r, s);
  return p.sbType = pe(s), fe(p, a);
}, "flowFactory"), ar = /* @__PURE__ */ n((r, s, a) => {
  let p = vt(r, { name: "unknown" }, s);
  return fe(p, a);
}, "unknownFactory"), Me = /* @__PURE__ */ n((r) => {
  switch (r) {
    case "JavaScript":
      return rr;
    case "TypeScript":
      return or;
    case "Flow":
      return sr;
    default:
      return ar;
  }
}, "getPropDefFactory");

// src/docs-tools/argTypes/docgen/extractDocgenProps.ts
var At = /* @__PURE__ */ n((r) => r.type != null ? "JavaScript" : r.flowType != null ? "Flow" : r.tsType != null ? "TypeScript" : "Unknown", "getTypeSystem"), ir = /* @__PURE__ */ n((r) => {
  let s = At(r[0]), a = Me(s);
  return r.map((p) => {
    let c = p;
    return p.type?.elements && (c = {
      ...p,
      type: {
        ...p.type,
        value: p.type.elements
      }
    }), Ft(c.name, c, s, a);
  });
}, "extractComponentSectionArray"), pr = /* @__PURE__ */ n((r) => {
  let s = Object.keys(r), a = At(r[s[0]]), p = Me(a);
  return s.map((c) => {
    let u = r[c];
    return u != null ? Ft(c, u, a, p) : null;
  }).filter(Boolean);
}, "extractComponentSectionObject"), aa = /* @__PURE__ */ n((r, s) => {
  let a = pt(r, s);
  return it(a) ? Array.isArray(a) ? ir(a) : pr(a) : [];
}, "extractComponentProps");
function Ft(r, s, a, p) {
  let c = Tt(s.description);
  return c.includesJsDoc && c.ignore ? null : {
    propDef: p(r, s, c),
    jsDocTags: c.extractedTags,
    docgenInfo: s,
    typeSystem: a
  };
}
n(Ft, "extractProp");
function ia(r) {
  return r != null ? ct(r) : "";
}
n(ia, "extractComponentDescription");

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

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

// src/docs-tools/shared.ts
var It = "storybook/docs", va = `${It}/panel`, Aa = "docs", Fa = `${It}/snippet-rendered`, cr = /* @__PURE__ */ ((p) => (p.AUTO = "auto", p.CODE = "code", p.DYNAMIC = "dynamic", p))(cr || {});

export {
  $e as a,
  pe as b,
  Ie as c,
  M as d,
  st as e,
  at as f,
  it as g,
  pt as h,
  ct as i,
  Tt as j,
  Ps as k,
  xs as l,
  Ke as m,
  Pt as n,
  P as o,
  bs as p,
  ir as q,
  pr as r,
  aa as s,
  ia as t,
  Ja as u,
  It as v,
  va as w,
  Aa as x,
  Fa as y,
  cr as z
};
