import { T as ne } from "./TextEditor-BkvWfPZ7.js";
import { d as le, u as $, o as oe, w as V, r as se } from "./menu-DyahFZcX.js";
const ae = {
  value: {
    type: String,
    default: ""
  },
  readOnly: {
    type: Boolean,
    default: !1
  },
  height: {
    type: Number,
    deprecated: !0,
    validator() {
      return console.warn(
        "[TextEditor] The 'height' prop is deprecated. Please use CSS to control the height instead."
      ), !0;
    }
  },
  isFocused: Boolean,
  forceInitialize: null,
  /**
   * Configure the keymap to use. The default is 'default'. Other possible
   * values are 'vim', 'emacs'.
   */
  keymap: {
    type: String,
    validator(e) {
      return ["default", "vim", "emacs"].includes(e);
    },
    default: "default"
  },
  lineWrapping: Boolean,
  lineNumbers: {
    type: Boolean,
    default: !0
  },
  keybindings: {
    type: Object,
    default: () => ({})
  },
  contextMenuItems: [Array, Function],
  // ------- New props below
  /** The id of the language. If language server is enabled, this will be the language id sent to the language server.
   * This replaces `mode: [String, Object]` and `hint: String`. */
  languageId: {
    type: String,
    default: "plaintext"
  },
  /** Enable language server support by passing the configuration. */
  lsConfig: Object,
  replaceExtensions: [Array, Function],
  vimConfig: Object,
  markers: {
    type: Array,
    default: () => []
  },
  lineGutters: {
    type: Array,
    default: () => []
  },
  /** Enable fold gutter. */
  foldGutters: Boolean,
  // cursor: String,
  // initialized: Boolean,
  // autoFocus: Boolean,
  // removeJsonRootBrackets: Boolean,
  // bookmarks: Array,
  /** Fold all folds in the editor. */
  foldAll: null,
  /** Unfold all folds in the editor. */
  unfoldAll: null,
  /**
   * Configure custom key mappings in vim. `vimKeymaps` accepts an array of
   * objects that contain the following properties:
   * - lhs: The key you want to map
   * - rhs: The key you want to map to
   * - mode: (optional) The mode in which you want to map the key ('normal', 'visual', 'insert')
   *
   * For example, to map `;` to `:`, you can do:
   *
   * ```
   * const vimKeymaps = [
   *   { lhs: ';', rhs: ':' }
   * ]
   * ```
   *
   * In vim, that would be `:map ; :`.
   */
  vimKeymaps: Array,
  clipboard: Object
};
var U = {}, X = {}, P = {};
Object.defineProperty(P, "__esModule", { value: !0 });
P.scanToken = void 0;
const ue = [
  "SELECT",
  "INSERT",
  "DELETE",
  "UPDATE",
  "CREATE",
  "DROP",
  "DATABASE",
  "SCHEMA",
  "TABLE",
  "VIEW",
  "TRIGGER",
  "FUNCTION",
  "INDEX",
  "ALTER",
  "TRUNCATE",
  "WITH",
  "AS",
  "MATERIALIZED",
  "BEGIN",
  "DECLARE",
  "CASE",
  "LOOP",
  "IF",
  "REPEAT",
  "WHILE",
  "FOR",
  "PROCEDURE",
  "SHOW",
  "DATABASES",
  "KEYS",
  "TABLES",
  "COLUMNS",
  "STATUS",
  "BINARY",
  "BINLOG",
  "CHARACTER",
  "COLLATION",
  "ENGINE",
  "ENGINES",
  "ERRORS",
  "EVENTS",
  "GRANTS",
  "MASTER",
  "OPEN",
  "PLUGINS",
  "PRIVILEGES",
  "PROCESSLIST",
  "PROFILE",
  "PROFILES",
  "RELAYLOG",
  "REPLICAS",
  "SLAVE",
  "REPLICA",
  "TRIGGERS",
  "VARIABLES",
  "WARNINGS"
], de = {
  ";": "semicolon"
}, B = {
  '"': '"',
  "'": "'",
  "`": "`",
  "[": "]"
};
function pe(e, i = "generic", t = { positional: !0 }) {
  const o = y(e);
  if (_(o))
    return ye(e);
  if (ge(o, e))
    return Ie(e);
  if (De(o, e))
    return he(e);
  if (me(o, i) && o !== null)
    return Ce(e, B[o]);
  if (we(o, e, t))
    return Ne(e, i, t);
  if (Ge(e))
    return Te(e);
  if (F(o, i) && o !== null)
    return ve(e, B[o]);
  if (M(o))
    return Ae(e);
  const E = Oe(e);
  return E || Re(e);
}
P.scanToken = pe;
function y(e, i = 0) {
  return e.position + i === e.input.length - 1 ? null : (e.position += 1 + i, e.input[e.position]);
}
function m(e) {
  e.position !== e.start && e.position--;
}
function ce(e) {
  return e.position == 0 ? null : e.input[e.position - 1];
}
function D(e) {
  return e.position >= e.input.length - 1 ? null : e.input[e.position + 1];
}
function Ee(e) {
  return ue.includes(e.toUpperCase());
}
function fe(e) {
  return de[e];
}
function ye(e) {
  let i;
  do
    i = y(e);
  while (_(i));
  i !== null && !_(i) && m(e);
  const t = e.input.slice(e.start, e.position + 1);
  return {
    type: "whitespace",
    value: t,
    start: e.start,
    end: e.start + t.length - 1
  };
}
function Ie(e) {
  let i;
  do
    i = y(e);
  while (i !== `
` && i !== null);
  i !== null && i !== `
` && m(e);
  const t = e.input.slice(e.start, e.position + 1);
  return {
    type: "comment-inline",
    value: t,
    start: e.start,
    end: e.start + t.length - 1
  };
}
function Te(e) {
  const i = /^(\$[a-zA-Z0-9_]*\$)/.exec(e.input.slice(e.start));
  if (!i)
    throw new Error("Could not find dollar quoted string opener");
  const t = i[1];
  for (let d = 0; d < t.length - 1; d++)
    y(e);
  let o = "";
  for (; e.input.slice(e.position, e.position + t.length) !== t && o !== null; ) {
    do
      o = y(e);
    while (o !== "$" && o !== null);
    o !== "$" && o !== null && m(e);
  }
  for (let d = 0; d < t.length - 1; d++)
    y(e);
  const E = e.input.slice(e.start, e.position + 1);
  return {
    type: "string",
    value: E,
    start: e.start,
    end: e.start + E.length - 1
  };
}
function Ce(e, i) {
  let t;
  do
    t = y(e), t === i && D(e) === i && (t = y(e, 1));
  while (t !== i && t !== null);
  t !== null && i !== t && m(e);
  const o = e.input.slice(e.start, e.position + 1);
  return {
    type: "string",
    value: o,
    start: e.start,
    end: e.start + o.length - 1
  };
}
function Se(e, i) {
  var t;
  const o = (t = i == null ? void 0 : i.custom) === null || t === void 0 ? void 0 : t.map((E) => new RegExp(`^(?:${E})`, "u").exec(e.input.slice(e.start))).filter((E) => !!E)[0];
  return o ? o[0] : null;
}
function Ne(e, i, t) {
  var o, E, d;
  const h = e.input[e.start], f = D(e);
  let S = !1;
  if (!((o = t.numbered) === null || o === void 0) && o.length && t.numbered.some((N) => N === h)) {
    const N = e.input.slice(e.start + 1).split("").findIndex((x) => /^\W+/.test(x)), k = e.input.slice(e.start + 1, N > 0 ? e.start + N + 1 : e.end + 1);
    if (f !== null && !isNaN(Number(f)) && /^\d+$/.test(k)) {
      let x = null;
      do
        x = y(e);
      while (x !== null && !isNaN(Number(x)) && !_(x));
      x !== null && m(e), S = !0;
    }
  }
  if (!S && (!((E = t.named) === null || E === void 0) && E.length) && t.named.some((N) => N === h) && !F(f, i)) {
    for (; K(D(e)); )
      y(e);
    S = !0;
  }
  if (!S && (!((d = t.quoted) === null || d === void 0) && d.length) && t.quoted.some((N) => N === h) && F(f, i)) {
    const N = y(e);
    for (; (K(D(e)) || D(e) === " ") && D(e) != B[N]; )
      y(e);
    y(e), S = !0;
  }
  if (!S && t.custom && t.custom.length) {
    const N = Se(e, t);
    N && (y(e, N.length), S = !0);
  }
  const A = e.input.slice(e.start, e.position + 1);
  return !S && !t.positional && h !== "?" ? {
    type: "unknown",
    value: A,
    start: e.start,
    end: e.start + A.length - 1
  } : {
    type: "parameter",
    value: A,
    start: e.start,
    end: e.start + A.length - 1
  };
}
function he(e) {
  let i = "", t;
  do
    t = i, i = y(e);
  while ((t || "") + (i || "") !== "*/" && i !== null);
  i !== null && i !== "/" && m(e);
  const o = e.input.slice(e.start, e.position + 1);
  return {
    type: "comment-block",
    value: o,
    start: e.start,
    end: e.start + o.length - 1
  };
}
function ve(e, i) {
  let t;
  do
    t = y(e);
  while (i !== t && t !== null);
  t !== null && i !== t && m(e);
  const o = e.input.slice(e.start, e.position + 1);
  return {
    type: "keyword",
    value: o,
    start: e.start,
    end: e.start + o.length - 1
  };
}
function Ae(e) {
  let i;
  do
    i = y(e);
  while (M(i));
  i !== null && !M(i) && m(e);
  const t = e.input.slice(e.start, e.position + 1);
  return Ee(t) ? {
    type: "keyword",
    value: t,
    start: e.start,
    end: e.start + t.length - 1
  } : Le(e, t);
}
function Oe(e) {
  const i = e.input.slice(e.start, e.position + 1), t = fe(i);
  return t ? {
    type: t,
    value: i,
    start: e.start,
    end: e.start + i.length - 1
  } : null;
}
function Re(e) {
  return {
    type: "unknown",
    value: e.input.slice(e.start, e.position + 1),
    start: e.start,
    end: e.start
  };
}
function Le(e, i) {
  return {
    type: "unknown",
    value: i,
    start: e.start,
    end: e.start + i.length - 1
  };
}
function _(e) {
  return e === " " || e === "	" || e === `
` || e === "\r";
}
function K(e) {
  return e !== null && /\w/.test(e);
}
function me(e, i) {
  return (i === "mysql" ? ["'", '"'] : ["'"]).includes(e);
}
function xe(e, i) {
  return i.some((t) => new RegExp(`^(?:${t})`, "uy").test(e.input.slice(e.start)));
}
function we(e, i, t) {
  var o, E, d, h;
  if (!e)
    return !1;
  const f = D(i), S = ce(i);
  return e === ":" && (S === ":" || f === ":") ? !1 : !!(t.positional && e === "?" || !((o = t.numbered) === null || o === void 0) && o.length && t.numbered.some((A) => e === A) && f !== null && !isNaN(Number(f)) || !((E = t.named) === null || E === void 0) && E.length && t.named.some((A) => A === e) || !((d = t.quoted) === null || d === void 0) && d.length && t.quoted.some((A) => A === e) || !((h = t.custom) === null || h === void 0) && h.length && xe(i, t.custom));
}
function Ge(e) {
  return /^\$[\w]*\$/.exec(e.input.slice(e.start)) !== null;
}
function F(e, i) {
  return (i === "mssql" ? ['"', "["] : ['"', "`"]).includes(e);
}
function ge(e, i) {
  let t = e === "-";
  return t ? (t = y(i) === "-", t || m(i), t) : !1;
}
function De(e, i) {
  let t = e === "/";
  return t ? (t = y(i) === "*", t || m(i), t) : !1;
}
function M(e) {
  return e !== null && (e >= "a" && e <= "z" || e >= "A" && e <= "Z" || e === "_");
}
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.defaultParamTypesFor = e.parse = e.EXECUTION_TYPES = void 0;
  const i = P;
  e.EXECUTION_TYPES = {
    SELECT: "LISTING",
    INSERT: "MODIFICATION",
    DELETE: "MODIFICATION",
    UPDATE: "MODIFICATION",
    TRUNCATE: "MODIFICATION",
    CREATE_DATABASE: "MODIFICATION",
    CREATE_SCHEMA: "MODIFICATION",
    CREATE_TABLE: "MODIFICATION",
    CREATE_VIEW: "MODIFICATION",
    CREATE_TRIGGER: "MODIFICATION",
    CREATE_FUNCTION: "MODIFICATION",
    CREATE_INDEX: "MODIFICATION",
    CREATE_PROCEDURE: "MODIFICATION",
    SHOW_BINARY: "LISTING",
    SHOW_BINLOG: "LISTING",
    SHOW_CHARACTER: "LISTING",
    SHOW_COLLATION: "LISTING",
    SHOW_CREATE: "LISTING",
    SHOW_ENGINE: "LISTING",
    SHOW_ENGINES: "LISTING",
    SHOW_ERRORS: "LISTING",
    SHOW_EVENTS: "LISTING",
    SHOW_FUNCTION: "LISTING",
    SHOW_GRANTS: "LISTING",
    SHOW_MASTER: "LISTING",
    SHOW_OPEN: "LISTING",
    SHOW_PLUGINS: "LISTING",
    SHOW_PRIVILEGES: "LISTING",
    SHOW_PROCEDURE: "LISTING",
    SHOW_PROCESSLIST: "LISTING",
    SHOW_PROFILE: "LISTING",
    SHOW_PROFILES: "LISTING",
    SHOW_RELAYLOG: "LISTING",
    SHOW_REPLICAS: "LISTING",
    SHOW_SLAVE: "LISTING",
    SHOW_REPLICA: "LISTING",
    SHOW_STATUS: "LISTING",
    SHOW_TRIGGERS: "LISTING",
    SHOW_VARIABLES: "LISTING",
    SHOW_WARNINGS: "LISTING",
    SHOW_DATABASES: "LISTING",
    SHOW_KEYS: "LISTING",
    SHOW_INDEX: "LISTING",
    SHOW_TABLE: "LISTING",
    SHOW_TABLES: "LISTING",
    SHOW_COLUMNS: "LISTING",
    DROP_DATABASE: "MODIFICATION",
    DROP_SCHEMA: "MODIFICATION",
    DROP_TABLE: "MODIFICATION",
    DROP_VIEW: "MODIFICATION",
    DROP_TRIGGER: "MODIFICATION",
    DROP_FUNCTION: "MODIFICATION",
    DROP_INDEX: "MODIFICATION",
    DROP_PROCEDURE: "MODIFICATION",
    ALTER_DATABASE: "MODIFICATION",
    ALTER_SCHEMA: "MODIFICATION",
    ALTER_TABLE: "MODIFICATION",
    ALTER_VIEW: "MODIFICATION",
    ALTER_TRIGGER: "MODIFICATION",
    ALTER_FUNCTION: "MODIFICATION",
    ALTER_INDEX: "MODIFICATION",
    ALTER_PROCEDURE: "MODIFICATION",
    UNKNOWN: "UNKNOWN",
    ANON_BLOCK: "ANON_BLOCK"
  };
  const t = [
    "CREATE_TRIGGER",
    "CREATE_FUNCTION",
    "CREATE_PROCEDURE",
    "ANON_BLOCK",
    "UNKNOWN"
  ], o = /^from$|^join$|^into$/i, E = {
    generic: ["BEGIN", "CASE"],
    psql: ["BEGIN", "CASE", "LOOP", "IF"],
    mysql: ["BEGIN", "CASE", "LOOP", "IF"],
    mssql: ["BEGIN", "CASE"],
    sqlite: ["BEGIN", "CASE"],
    oracle: ["DECLARE", "BEGIN", "CASE"],
    bigquery: ["BEGIN", "CASE", "IF", "LOOP", "REPEAT", "WHILE", "FOR"]
  };
  function d() {
    return {
      start: -1,
      end: 0,
      parameters: [],
      tables: []
    };
  }
  function h(r, n) {
    let u;
    do
      r = S({ prevState: r }), u = (0, i.scanToken)(r, n);
    while (u.type === "whitespace");
    return u;
  }
  function f(r, n = !0, u = "generic", s = !1, W) {
    const R = S({ input: r }), c = {
      type: "QUERY",
      start: 0,
      end: r.length - 1,
      body: [],
      tokens: []
    };
    let I = R, T = null;
    const p = {
      isCte: !1,
      asSeen: !1,
      statementEnd: !1,
      parens: 0,
      state: R,
      params: []
    }, w = ["whitespace", "comment-inline", "comment-block", "semicolon"];
    for (; I.position < R.end; ) {
      const C = S({ prevState: I }), a = (0, i.scanToken)(C, u, W), l = h(C, u);
      if (!T)
        !p.isCte && w.includes(a.type) ? (c.tokens.push(a), I = C) : !p.isCte && a.type === "keyword" && a.value.toUpperCase() === "WITH" ? (p.isCte = !0, c.tokens.push(a), p.state = C, I = C) : p.isCte && a.type === "semicolon" ? (c.tokens.push(a), I = C, c.body.push({
          start: p.state.start,
          end: a.end,
          type: "UNKNOWN",
          executionType: "UNKNOWN",
          parameters: [],
          tables: []
        }), p.isCte = !1, p.asSeen = !1, p.statementEnd = !1, p.parens = 0) : p.isCte && !p.statementEnd ? (p.asSeen ? a.value === "(" ? p.parens++ : a.value === ")" && (p.parens--, p.parens === 0 && (p.statementEnd = !0)) : a.value.toUpperCase() === "AS" && (p.asSeen = !0), c.tokens.push(a), I = C) : p.isCte && p.statementEnd && a.value === "," ? (p.asSeen = !1, p.statementEnd = !1, c.tokens.push(a), I = C) : p.isCte && p.statementEnd && w.includes(a.type) ? (c.tokens.push(a), I = C) : (T = A(a, l, {
          isStrict: n,
          dialect: u,
          identifyTables: s
        }), p.isCte && (T.getStatement().start = p.state.start, T.getStatement().isCte = !0, T.getStatement().parameters.push(...p.params), p.params = [], p.isCte = !1, p.asSeen = !1, p.statementEnd = !1)), p.isCte && a.type === "parameter" && p.params.push(a.value);
      else {
        T.addToken(a, l), c.tokens.push(a), I = C;
        const L = T.getStatement();
        L.endStatement && (L.end = a.end, c.body.push(L), T = null);
      }
    }
    if (T) {
      const C = T.getStatement();
      C.endStatement || (C.end = c.end, c.body.push(C));
    }
    return c;
  }
  e.parse = f;
  function S({ input: r, prevState: n }) {
    if (n)
      return {
        input: n.input,
        position: n.position,
        start: n.position + 1,
        end: n.input.length - 1
      };
    if (r === void 0)
      throw new Error("You must define either input or prevState");
    return {
      input: r,
      position: -1,
      start: 0,
      end: r.length - 1
    };
  }
  function A(r, n, u) {
    if (r.type === "keyword")
      switch (r.value.toUpperCase()) {
        case "SELECT":
          return N(u);
        case "CREATE":
          return Q(u);
        case "SHOW":
          if (["mysql", "generic"].includes(u.dialect))
            return te(u);
          break;
        case "DROP":
          return Z(u);
        case "ALTER":
          return J(u);
        case "INSERT":
          return x(u);
        case "UPDATE":
          return j(u);
        case "DELETE":
          return z(u);
        case "TRUNCATE":
          return ee(u);
        case "BEGIN":
          if (["bigquery", "oracle"].includes(u.dialect) && n.value !== "TRANSACTION")
            return k(u);
          break;
        case "DECLARE":
          if (u.dialect === "oracle")
            return k(u);
          break;
      }
    if (!u.isStrict)
      return re(u);
    throw new Error(`Invalid statement parser "${r.value}"`);
  }
  function N(r) {
    const n = d();
    return O(n, [
      // Select
      {
        preCanGoToNext: () => !1,
        validation: {
          acceptTokens: [{ type: "keyword", value: "SELECT" }]
        },
        add: (s) => {
          n.type = "SELECT", n.start < 0 && (n.start = s.start);
        },
        postCanGoToNext: () => !0
      }
    ], r);
  }
  function k(r) {
    const n = d();
    n.type = "ANON_BLOCK";
    const u = [
      // Select
      {
        preCanGoToNext: () => !1,
        validation: {
          acceptTokens: [
            ...r.dialect === "oracle" ? [{ type: "keyword", value: "DECLARE" }] : [],
            { type: "keyword", value: "BEGIN" }
          ]
        },
        add: (s) => {
          n.start < 0 && (n.start = s.start);
        },
        postCanGoToNext: () => !0
      }
    ];
    return O(n, u, r);
  }
  function x(r) {
    const n = d();
    return O(n, [
      // Insert
      {
        preCanGoToNext: () => !1,
        validation: {
          acceptTokens: [{ type: "keyword", value: "INSERT" }]
        },
        add: (s) => {
          n.type = "INSERT", n.start < 0 && (n.start = s.start);
        },
        postCanGoToNext: () => !0
      }
    ], r);
  }
  function j(r) {
    const n = d();
    return O(n, [
      // Update
      {
        preCanGoToNext: () => !1,
        validation: {
          acceptTokens: [{ type: "keyword", value: "UPDATE" }]
        },
        add: (s) => {
          n.type = "UPDATE", n.start < 0 && (n.start = s.start);
        },
        postCanGoToNext: () => !0
      }
    ], r);
  }
  function z(r) {
    const n = d();
    return O(n, [
      // Delete
      {
        preCanGoToNext: () => !1,
        validation: {
          acceptTokens: [{ type: "keyword", value: "DELETE" }]
        },
        add: (s) => {
          n.type = "DELETE", n.start < 0 && (n.start = s.start);
        },
        postCanGoToNext: () => !0
      }
    ], r);
  }
  function Q(r) {
    const n = d(), u = [
      // Create
      {
        preCanGoToNext: () => !1,
        validation: {
          acceptTokens: [{ type: "keyword", value: "CREATE" }]
        },
        add: (s) => {
          n.start < 0 && (n.start = s.start);
        },
        postCanGoToNext: () => !0
      },
      // Table/Database
      {
        preCanGoToNext: () => !1,
        validation: {
          requireBefore: ["whitespace"],
          acceptTokens: [
            ...r.dialect !== "sqlite" ? [
              { type: "keyword", value: "DATABASE" },
              { type: "keyword", value: "SCHEMA" },
              { type: "keyword", value: "PROCEDURE" }
            ] : [],
            { type: "keyword", value: "TABLE" },
            { type: "keyword", value: "VIEW" },
            { type: "keyword", value: "TRIGGER" },
            { type: "keyword", value: "FUNCTION" },
            { type: "keyword", value: "INDEX" }
          ]
        },
        add: (s) => {
          n.type = `CREATE_${s.value.toUpperCase()}`;
        },
        postCanGoToNext: () => !0
      }
    ];
    return O(n, u, r);
  }
  function Z(r) {
    const n = d(), u = [
      // Drop
      {
        preCanGoToNext: () => !1,
        validation: {
          acceptTokens: [{ type: "keyword", value: "DROP" }]
        },
        add: (s) => {
          n.start < 0 && (n.start = s.start);
        },
        postCanGoToNext: () => !0
      },
      // Table/Database
      {
        preCanGoToNext: () => !1,
        validation: {
          requireBefore: ["whitespace"],
          acceptTokens: [
            ...r.dialect !== "sqlite" ? [
              { type: "keyword", value: "DATABASE" },
              { type: "keyword", value: "SCHEMA" },
              { type: "keyword", value: "PROCEDURE" }
            ] : [],
            { type: "keyword", value: "TABLE" },
            { type: "keyword", value: "VIEW" },
            { type: "keyword", value: "TRIGGER" },
            { type: "keyword", value: "FUNCTION" },
            { type: "keyword", value: "INDEX" }
          ]
        },
        add: (s) => {
          n.type = `DROP_${s.value.toUpperCase()}`;
        },
        postCanGoToNext: () => !0
      }
    ];
    return O(n, u, r);
  }
  function J(r) {
    const n = d(), u = [
      {
        preCanGoToNext: () => !1,
        validation: {
          acceptTokens: [{ type: "keyword", value: "ALTER" }]
        },
        add: (s) => {
          n.start < 0 && (n.start = s.start);
        },
        postCanGoToNext: () => !0
      },
      {
        preCanGoToNext: () => !1,
        validation: {
          requireBefore: ["whitespace"],
          acceptTokens: [
            ...r.dialect !== "sqlite" ? [
              { type: "keyword", value: "DATABASE" },
              { type: "keyword", value: "SCHEMA" },
              { type: "keyword", value: "TRIGGER" },
              { type: "keyword", value: "FUNCTION" },
              { type: "keyword", value: "INDEX" },
              ...r.dialect !== "bigquery" ? [{ type: "keyword", value: "PROCEDURE" }] : []
            ] : [],
            { type: "keyword", value: "TABLE" },
            { type: "keyword", value: "VIEW" }
          ]
        },
        add: (s) => {
          n.type = `ALTER_${s.value.toUpperCase()}`;
        },
        postCanGoToNext: () => !0
      }
    ];
    return O(n, u, r);
  }
  function ee(r) {
    const n = d();
    return O(n, [
      {
        preCanGoToNext: () => !1,
        validation: {
          acceptTokens: [{ type: "keyword", value: "TRUNCATE" }]
        },
        add: (s) => {
          n.type = "TRUNCATE", n.start < 0 && (n.start = s.start);
        },
        postCanGoToNext: () => !0
      }
    ], r);
  }
  function te(r) {
    const n = d();
    return O(n, [
      {
        preCanGoToNext: () => !1,
        validation: {
          acceptTokens: [{ type: "keyword", value: "SHOW" }]
        },
        add: (s) => {
          n.start < 0 && (n.start = s.start);
        },
        postCanGoToNext: () => !0
      },
      // Database/Table/Columns/...
      {
        preCanGoToNext: () => !1,
        validation: {
          requireBefore: ["whitespace"],
          acceptTokens: [
            { type: "keyword", value: "DATABASES" },
            { type: "keyword", value: "DATABASE" },
            { type: "keyword", value: "KEYS" },
            { type: "keyword", value: "INDEX" },
            { type: "keyword", value: "COLUMNS" },
            { type: "keyword", value: "TABLES" },
            { type: "keyword", value: "TABLE" },
            { type: "keyword", value: "BINARY" },
            { type: "keyword", value: "BINLOG" },
            { type: "keyword", value: "CHARACTER" },
            { type: "keyword", value: "COLLATION" },
            { type: "keyword", value: "CREATE" },
            { type: "keyword", value: "ENGINE" },
            { type: "keyword", value: "ENGINES" },
            { type: "keyword", value: "ERRORS" },
            { type: "keyword", value: "EVENTS" },
            { type: "keyword", value: "FUNCTION" },
            { type: "keyword", value: "GRANTS" },
            { type: "keyword", value: "MASTER" },
            { type: "keyword", value: "OPEN" },
            { type: "keyword", value: "PLUGINS" },
            { type: "keyword", value: "PRIVILEGES" },
            { type: "keyword", value: "PROCEDURE" },
            { type: "keyword", value: "PROCESSLIST" },
            { type: "keyword", value: "PROFILE" },
            { type: "keyword", value: "PROFILES" },
            { type: "keyword", value: "RELAYLOG" },
            { type: "keyword", value: "REPLICAS" },
            { type: "keyword", value: "REPLICA" },
            { type: "keyword", value: "SLAVE" },
            { type: "keyword", value: "STATUS" },
            { type: "keyword", value: "TRIGGERS" },
            { type: "keyword", value: "VARIABLES" },
            { type: "keyword", value: "WARNINGS" }
          ]
        },
        add: (s) => {
          n.type = `SHOW_${s.value.toUpperCase().replace(" ", "_")}`;
        },
        postCanGoToNext: () => !0
      }
    ], r);
  }
  function re(r) {
    const n = d();
    return O(n, [
      {
        preCanGoToNext: () => !1,
        add: (s) => {
          n.type = "UNKNOWN", n.start < 0 && (n.start = s.start);
        },
        postCanGoToNext: () => !0
      }
    ], r);
  }
  function O(r, n, { isStrict: u, dialect: s, identifyTables: W }) {
    let R = 0, c, I, T, p = !1, w = 0;
    const C = (l, L) => l.validation ? l.validation.acceptTokens.filter((g) => {
      const v = L.type === g.type, G = !g.value || L.value.toUpperCase() === g.value;
      return v && G;
    }).length > 0 : !0, a = (l) => {
      c = l, l.type !== "whitespace" && (I = l);
    };
    return {
      getStatement() {
        return r;
      },
      addToken(l, L) {
        var g;
        if (r.endStatement)
          throw new Error("This statement has already got to the end.");
        if (r.type && l.type === "semicolon" && (!t.includes(r.type) || w === 0 && (r.type === "UNKNOWN" || r.canEnd))) {
          r.endStatement = ";";
          return;
        }
        if (w > 0 && l.value.toUpperCase() === "END") {
          w--, w === 0 && (r.canEnd = !0), a(l);
          return;
        }
        if (l.type === "whitespace") {
          a(l);
          return;
        }
        if (l.type === "keyword" && E[s].includes(l.value.toUpperCase()) && (I == null ? void 0 : I.value.toUpperCase()) !== "END" && (l.value.toUpperCase() !== "BEGIN" || l.value.toUpperCase() === "BEGIN" && L.value.toUpperCase() !== "TRANSACTION" && (s !== "sqlite" || s === "sqlite" && !["DEFERRED", "IMMEDIATE", "EXCLUSIVE"].includes(L.value.toUpperCase())))) {
          if (s === "oracle" && (T == null ? void 0 : T.value) === "DECLARE" && l.value.toUpperCase() === "BEGIN") {
            a(l), T = l;
            return;
          }
          if (w++, T = l, a(l), r.type === "ANON_BLOCK" && !p)
            p = !0;
          else if (r.type)
            return;
        }
        if (W && o.exec(l.value) && !r.isCte && (!((g = r.type) === null || g === void 0) && g.match(/SELECT|INSERT/))) {
          const G = L.value;
          r.tables.includes(G) || r.tables.push(G);
        }
        if (l.type === "parameter" && (l.value === "?" || !r.parameters.includes(l.value)) && r.parameters.push(l.value), r.type && r.start >= 0) {
          a(l);
          return;
        }
        if (l.value.toUpperCase() === "UNIQUE" || s === "mysql" && ["FULLTEXT", "SPATIAL"].includes(l.value.toUpperCase()) || s === "mssql" && ["CLUSTERED", "NONCLUSTERED"].includes(l.value.toUpperCase())) {
          a(l);
          return;
        }
        if (["psql", "mssql", "bigquery"].includes(s) && l.value.toUpperCase() === "MATERIALIZED") {
          a(l);
          return;
        }
        if (s !== "sqlite" && (l.value.toUpperCase() === "OR" || (I == null ? void 0 : I.value.toUpperCase()) === "OR" && l.value.toUpperCase() === (s === "mssql" ? "ALTER" : "REPLACE"))) {
          a(l);
          return;
        }
        if (s === "psql" && ["TEMP", "TEMPORARY"].includes(l.value.toUpperCase()) || s === "sqlite" && ["TEMP", "TEMPORARY", "VIRTUAL"].includes(l.value.toUpperCase())) {
          a(l);
          return;
        }
        if (s === "mysql" && l.value.toUpperCase() === "DEFINER") {
          r.definer = 0, a(l);
          return;
        }
        if (r.definer === 0 && l.value === "=") {
          r.definer++, a(l);
          return;
        }
        if (r.definer !== void 0 && r.definer > 0) {
          if (r.definer === 1 && (c == null ? void 0 : c.type) === "whitespace") {
            r.definer++, a(l);
            return;
          }
          if (r.definer > 1 && (c == null ? void 0 : c.type) !== "whitespace") {
            a(l);
            return;
          }
          delete r.definer;
        }
        if (s === "mysql" && l.value.toUpperCase() === "ALGORITHM") {
          r.algorithm = 0, a(l);
          return;
        }
        if (r.algorithm === 0 && l.value === "=") {
          r.algorithm++, a(l);
          return;
        }
        if (r.algorithm !== void 0 && r.algorithm > 0) {
          if (r.algorithm === 1 && (c == null ? void 0 : c.type) === "whitespace") {
            r.algorithm++, a(l);
            return;
          }
          if (r.algorithm > 1 && c && ["UNDEFINED", "MERGE", "TEMPTABLE"].includes(c.value.toUpperCase())) {
            a(l);
            return;
          }
          delete r.algorithm;
        }
        if (s === "mysql" && l.value.toUpperCase() === "SQL") {
          r.sqlSecurity = 0, a(l);
          return;
        }
        if (r.sqlSecurity !== void 0)
          if (r.sqlSecurity === 0 && l.value.toUpperCase() === "SECURITY" || r.sqlSecurity === 1 && ["DEFINER", "INVOKER"].includes(l.value.toUpperCase())) {
            r.sqlSecurity++, a(l);
            return;
          } else r.sqlSecurity === 2 && delete r.sqlSecurity;
        let v = n[R];
        if (v.preCanGoToNext(l) && (R++, v = n[R]), c && v.validation && v.validation.requireBefore && !v.validation.requireBefore.includes(c.type)) {
          const G = v.validation.requireBefore.join(" or ");
          throw new Error(`Expected any of these tokens ${G} before "${l.value}" (currentStep=${R}).`);
        }
        if (!C(v, l) && u) {
          const G = v.validation ? v.validation.acceptTokens.map((H) => `(type="${H.type}" value="${H.value}")`).join(" or ") : "()";
          throw new Error(`Expected any of these tokens ${G} instead of type="${l.type}" value="${l.value}" (currentStep=${R}).`);
        }
        v.add(l), r.executionType = r.type && e.EXECUTION_TYPES[r.type] ? e.EXECUTION_TYPES[r.type] : "UNKNOWN", v.postCanGoToNext(l) && R++, a(l);
      }
    };
  }
  function ie(r) {
    switch (r) {
      case "psql":
        return {
          numbered: ["$"]
        };
      case "mssql":
        return {
          named: [":"]
        };
      case "bigquery":
        return {
          positional: !0,
          named: ["@"],
          quoted: ["@"]
        };
      case "sqlite":
        return {
          positional: !0,
          numbered: ["?"],
          named: [":", "@"]
        };
      default:
        return {
          positional: !0
        };
    }
  }
  e.defaultParamTypesFor = ie;
})(X);
var b = {};
Object.defineProperty(b, "__esModule", { value: !0 });
b.DIALECTS = void 0;
b.DIALECTS = [
  "mssql",
  "sqlite",
  "mysql",
  "oracle",
  "psql",
  "bigquery",
  "generic"
];
Object.defineProperty(U, "__esModule", { value: !0 });
U.getExecutionType = ke = U.identify = void 0;
const q = X, Y = b;
function Ue(e, i = {}) {
  const t = typeof i.strict > "u" ? !0 : i.strict === !0, o = typeof i.dialect > "u" ? "generic" : i.dialect;
  if (!Y.DIALECTS.includes(o))
    throw new Error(`Unknown dialect. Allowed values: ${Y.DIALECTS.join(", ")}`);
  const E = i.paramTypes || (0, q.defaultParamTypesFor)(o), d = (0, q.parse)(e, t, o, i.identifyTables, E), h = o === "psql" && !i.paramTypes;
  return d.body.map((f) => ({
    start: f.start,
    end: f.end,
    text: e.substring(f.start, f.end + 1),
    type: f.type,
    executionType: f.executionType,
    // we want to sort the postgres params: $1 $2 $3, regardless of the order they appear
    parameters: h ? f.parameters.sort() : f.parameters,
    tables: f.tables || []
  }));
}
var ke = U.identify = Ue;
function _e(e) {
  return q.EXECUTION_TYPES[e] || "UNKNOWN";
}
U.getExecutionType = _e;
const We = {
  props: ae,
  data() {
    return {
      textEditor: null,
      internalContextMenuItems: []
    };
  },
  computed: {
    vimOptions() {
      return {
        config: this.vimConfig,
        keymaps: this.vimKeymaps,
        clipboard: this.clipboard
      };
    }
  },
  watch: {
    value() {
      this.textEditor && this.applyValue();
    },
    readOnly() {
      this.textEditor && this.applyReadOnly();
    },
    isFocused() {
      this.textEditor && this.applyFocus();
    },
    keymap() {
      this.textEditor && this.applyKeymap();
    },
    vimOptions() {
      this.textEditor && this.applyKeymap();
    },
    lineWrapping() {
      this.textEditor && this.applyLineWrapping();
    },
    lineNumbers() {
      this.textEditor && this.applyLineNumbers();
    },
    keybindings() {
      this.textEditor && this.applyKeybindings();
    },
    languageId() {
      this.textEditor && this.applyLanguageId();
    },
    markers() {
      this.textEditor && this.applyMarkers();
    },
    lineGutters() {
      this.textEditor && this.applyLineGutters();
    },
    foldAll() {
      this.textEditor && this.applyFoldAll();
    },
    unfoldAll() {
      this.textEditor && this.applyUnfoldAll();
    },
    forceInitialize() {
      this.initialize();
    }
  },
  methods: {
    // Exposed to custom element as `.ls()`
    ls() {
      return this.textEditor.getLsHelpers();
    },
    applyValue() {
      this.value !== this.textEditor.getValue() && this.textEditor.setValue(this.value);
    },
    applyReadOnly() {
      this.textEditor.setReadOnly(this.readOnly);
    },
    applyFocus() {
      this.isFocused && this.textEditor.focus();
    },
    applyKeymap() {
      this.textEditor.setKeymap(this.keymap, this.vimOptions);
    },
    applyLineWrapping() {
      this.textEditor.setLineWrapping(this.lineWrapping);
    },
    applyLineNumbers() {
      this.textEditor.setLineNumbers(this.lineNumbers);
    },
    applyKeybindings() {
      this.textEditor.setKeybindings(this.keybindings);
    },
    applyLanguageId() {
      this.textEditor.setLanguageId(this.languageId);
    },
    applyMarkers() {
      this.textEditor.setMarkers(this.markers);
    },
    applyLineGutters() {
      this.textEditor.setLineGutters(this.lineGutters);
    },
    applyFoldAll() {
      this.textEditor.foldAll();
    },
    applyUnfoldAll() {
      this.textEditor.unfoldAll();
    },
    constructTextEditor() {
      return new ne();
    },
    initialize() {
      var i;
      this.textEditor && (this.textEditor.destroy(), this.textEditor = null);
      const e = this.constructTextEditor();
      e.initialize({
        parent: this.$refs.editor,
        onValueChange: (t) => {
          this.$emit("bks-value-change", { value: t });
        },
        onSelectionChange: (t) => {
          this.$emit("bks-selection-change", { value: t });
        },
        onFocus: (t) => {
          this.$emit("bks-focus", t);
        },
        onBlur: (t) => {
          this.$emit("bks-blur", t);
        },
        onLspReady: (t) => {
          this.$emit("bks-lsp-ready", { capabilities: t });
        },
        languageId: this.languageId,
        replaceExtensions: this.replaceExtensions,
        lsConfig: this.lsConfig,
        initialValue: this.value,
        focus: this.isFocused,
        readOnly: this.readOnly,
        keymap: this.keymap,
        vimOptions: this.vimOptions,
        lineWrapping: this.lineWrapping,
        lineNumbers: this.lineNumbers,
        keybindings: this.keybindings,
        markers: this.markers,
        lineGutters: this.lineGutters,
        foldGutters: this.foldGutters
      }), this.textEditor = e, (i = this.initialized) == null || i.call(this), this.$emit("bks-initialized", { editor: e });
    },
    showContextMenu(e) {
      e.preventDefault();
      const t = this.textEditor.getSelection() ? "" : "disabled", o = {
        options: [
          {
            label: "Undo",
            id: "text-undo",
            handler: () => this.textEditor.execCommand("undo"),
            shortcut: "Control+Z",
            write: !0
          },
          {
            label: "Redo",
            id: "text-redo",
            handler: () => this.textEditor.execCommand("redo"),
            shortcut: "Shift+Z",
            write: !0
          },
          {
            label: "Cut",
            id: "text-cut",
            handler: () => {
              const d = this.textEditor.getSelection();
              this.textEditor.replaceSelection(""), V(d);
            },
            class: t,
            shortcut: "Control+X",
            write: !0
          },
          {
            label: "Copy",
            id: "text-copy",
            handler: async () => {
              const d = this.textEditor.getSelection();
              await V(d);
            },
            class: t,
            shortcut: "Control+C"
          },
          {
            label: "Paste",
            id: "text-paste",
            handler: async () => {
              const d = await se();
              if (this.textEditor.getSelection())
                this.textEditor.replaceSelection(d, "around");
              else {
                const h = this.textEditor.getCursor();
                this.textEditor.replaceRange(d, h);
              }
            },
            shortcut: "Control+V",
            write: !0
          },
          {
            label: "Delete",
            id: "text-delete",
            handler: () => {
              this.textEditor.replaceSelection("");
            },
            class: t,
            write: !0
          },
          {
            label: "Select All",
            id: "text-select-all",
            handler: () => {
              this.textEditor.execCommand("selectAll");
            },
            shortcut: "Control+A"
          },
          le,
          {
            label: "Find",
            id: "text-find",
            handler: () => {
              this.textEditor.execCommand("find");
            },
            shortcut: "Control+F"
          },
          {
            label: "Replace",
            id: "text-replace",
            handler: () => {
              this.textEditor.execCommand("replace");
            },
            shortcut: "Control+R",
            write: !0
          },
          {
            label: "Replace All",
            id: "text-replace-all",
            handler: () => {
              this.textEditor.execCommand("replaceAll");
            },
            shortcut: "Shift+R",
            write: !0
          }
        ]
      };
      this.readOnly && (o.options = o.options.filter((d) => !d.write));
      let E = $(
        e,
        void 0,
        o.options,
        this.internalContextMenuItems
      );
      E = $(
        e,
        void 0,
        E,
        this.contextMenuItems
      ), oe({ event: e, options: E });
    }
  },
  mounted() {
    this.initialize(), this.$refs.editor.addEventListener("contextmenu", this.showContextMenu);
  },
  beforeDestroy() {
    this.textEditor && (this.textEditor.destroy(), this.textEditor = null), this.$refs.editor.removeEventListener("contextmenu", this.showContextMenu);
  }
};
export {
  ke as i,
  We as m,
  ae as p
};
//# sourceMappingURL=mixin-CSr3ZOLS.js.map
