/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
import { Uri as p, languages as s } from "monaco-editor";
import "monaco-editor/esm/vs/editor/standalone/browser/standaloneServices.js";
import "monaco-editor/esm/vs/editor/standalone/common/standaloneTheme.js";
import "monaco-editor/esm/vs/platform/hover/browser/hover.js";
import "monaco-editor/esm/vs/editor/common/languages/supports/tokenization.js";
import "monaco-editor/esm/vs/base/browser/dom.js";
import "monaco-editor/esm/vs/editor/browser/editorDom.js";
import "monaco-editor/esm/vs/editor/browser/controller/mouseTarget.js";
import { b as t } from "./arcade-defaults.js";
import { a as l } from "./arcade-service-accessors.js";
import { i as d } from "./monaco-importer.js";
import { a } from "./sql-expr-defaults.js";
import { g as f } from "./sql-expr-service-accessors.js";
import { t as h } from "./monaco-theme.js";
const k = [
  "arcade",
  "arcgis-sql-expression",
  "sql-layer-sql-server",
  "sql-layer-postgres",
  "sql-layer-bigquery"
], i = /* @__PURE__ */ new Set(), g = /* @__PURE__ */ new Map();
function c(e) {
  let r = g.get(e);
  return r || (r = Promise.withResolvers(), g.set(e, r)), r;
}
function u(e) {
  c(e).resolve();
}
function _(e) {
  return k.includes(e) ? c(e).promise : Promise.resolve();
}
function m(e, r) {
  return () => {
    i.has(e) || i.add(e), r();
  };
}
async function $(e) {
  if (i.has(e))
    return;
  (await d()).createModel("", e, p.parse("")).dispose();
}
s.register({
  id: t.languageId,
  aliases: ["Arcade", "arcade"],
  extensions: [".arc"],
  mimetypes: ["application/arcade"]
});
s.onLanguage(
  t.languageId,
  m(t.languageId, () => {
    l().then((e) => {
      e.setupMode(t), u(t.languageId);
    }).catch((e) => {
      throw e;
    });
  })
);
s.register({
  id: a.languageId,
  aliases: ["EsiSqlExpression", "sql-expression"],
  extensions: [".sql-expression"],
  mimetypes: ["application/sql-expression"]
});
s.onLanguage(
  a.languageId,
  m(a.languageId, () => {
    f().then((e) => {
      e.setupMode(a), u(a.languageId);
    }).catch((e) => {
      throw e;
    });
  })
);
y();
function y() {
  d().then((e) => {
    ["light", "dark"].forEach((r) => {
      const n = r === "light" ? "vs" : "vs-dark", o = h[`${r}-theme`];
      e.defineTheme(n, {
        base: n,
        inherit: !0,
        rules: [
          { token: "comment.arcgis", foreground: o.comment },
          { token: "constant.arcgis", foreground: o.constant },
          { token: "keyword.arcgis", foreground: o.keyword },
          { token: "identifier.arcgis", foreground: o.identifier },
          { token: "number.arcgis", foreground: o.number },
          { token: "string.arcgis", foreground: o.string },
          { token: "operator.arcgis", foreground: o.operator },
          { token: "predefined.arcgis", foreground: o.predefined },
          { token: "date.arcgis", foreground: o.date }
        ],
        colors: {}
      });
    });
  });
}
export {
  m as a,
  u as m,
  $ as s,
  _ as w
};
