import w from "@arcgis/core/request.js";
/*! All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
v5.0.0-next.14 */
function d() {
  return !!window.MonacoEnvironment?.getWorker;
}
let a = "";
const f = /* @__PURE__ */ new Map(), i = !1;
async function c(s, e, r) {
  if (r)
    return e ? e() : new Worker(s);
  const o = window.location.origin;
  if (new URL(s, window.location.href).origin !== o) {
    const t = await w(s, { responseType: "text" });
    return new Worker(URL.createObjectURL(new Blob([t.data], { type: "text/javascript" })), {
      type: "module"
    });
  }
  return new Worker(s, {
    type: "module"
  });
}
function j(s) {
  if (d())
    return;
  a = s;
  const e = `${a}/code-editor`, r = {
    arcade: `${e}/arcade.worker.js`,
    "arcgis-sql-expression": `${e}/sql-expr.worker.js`,
    html: `${e}/html.worker.js`,
    css: `${e}/css.worker.js`,
    typescript: `${e}/ts.worker.js`,
    json: `${e}/json.worker.js`,
    default: `${e}/editor.worker.js`
  }, o = {
    arcade: {
      url: r.arcade
    },
    "arcgis-sql-expression": {
      url: r["arcgis-sql-expression"]
    },
    html: {
      url: r.html
    },
    css: {
      url: r.css
    },
    typescript: {
      url: r.typescript
    },
    javascript: {
      url: r.typescript
    },
    json: {
      url: r.json
    },
    default: {
      url: r.default
    }
  };
  window.MonacoEnvironment = {
    getWorker: async (l, t) => {
      const n = f.get(t);
      if (n)
        return await c(n, void 0, i);
      const { url: p, localWorker: u } = o[t] || o.default;
      return await c(p, u, i);
    }
  };
}
export {
  j as s
};
