import { c as cu, h as hu } from "./codemirror.es2-DH2syXui.js";
var h = Object.defineProperty;
var g = (m, v) => h(m, "name", { value: v, configurable: true });
function T(m, v) {
  for (var n = 0; n < v.length; n++) {
    const r = v[n];
    if (typeof r != "string" && !Array.isArray(r)) {
      for (const c in r)
        if (c !== "default" && !(c in m)) {
          const i = Object.getOwnPropertyDescriptor(r, c);
          i && Object.defineProperty(m, c, i.get ? i : {
            enumerable: true,
            get: () => r[c]
          });
        }
    }
  }
  return Object.freeze(Object.defineProperty(m, Symbol.toStringTag, { value: "Module" }));
}
g(T, "_mergeNamespaces");
var x = { exports: {} };
(function(m, v) {
  (function(n) {
    n(cu());
  })(function(n) {
    function r(i, f, e) {
      var o = i.getWrapperElement(), l;
      return l = o.appendChild(document.createElement("div")), e ? l.className = "CodeMirror-dialog CodeMirror-dialog-bottom" : l.className = "CodeMirror-dialog CodeMirror-dialog-top", typeof f == "string" ? l.innerHTML = f : l.appendChild(f), n.addClass(o, "dialog-opened"), l;
    }
    g(r, "dialogDiv");
    function c(i, f) {
      i.state.currentNotificationClose && i.state.currentNotificationClose(), i.state.currentNotificationClose = f;
    }
    g(c, "closeNotification"), n.defineExtension("openDialog", function(i, f, e) {
      e || (e = {}), c(this, null);
      var o = r(this, i, e.bottom), l = false, s = this;
      function u(t) {
        if (typeof t == "string")
          a.value = t;
        else {
          if (l)
            return;
          l = true, n.rmClass(o.parentNode, "dialog-opened"), o.parentNode.removeChild(o), s.focus(), e.onClose && e.onClose(o);
        }
      }
      g(u, "close");
      var a = o.getElementsByTagName("input")[0], d;
      return a ? (a.focus(), e.value && (a.value = e.value, e.selectValueOnOpen !== false && a.select()), e.onInput && n.on(a, "input", function(t) {
        e.onInput(t, a.value, u);
      }), e.onKeyUp && n.on(a, "keyup", function(t) {
        e.onKeyUp(t, a.value, u);
      }), n.on(a, "keydown", function(t) {
        e && e.onKeyDown && e.onKeyDown(t, a.value, u) || ((t.keyCode == 27 || e.closeOnEnter !== false && t.keyCode == 13) && (a.blur(), n.e_stop(t), u()), t.keyCode == 13 && f(a.value, t));
      }), e.closeOnBlur !== false && n.on(o, "focusout", function(t) {
        t.relatedTarget !== null && u();
      })) : (d = o.getElementsByTagName("button")[0]) && (n.on(d, "click", function() {
        u(), s.focus();
      }), e.closeOnBlur !== false && n.on(d, "blur", u), d.focus()), u;
    }), n.defineExtension("openConfirm", function(i, f, e) {
      c(this, null);
      var o = r(this, i, e && e.bottom), l = o.getElementsByTagName("button"), s = false, u = this, a = 1;
      function d() {
        s || (s = true, n.rmClass(o.parentNode, "dialog-opened"), o.parentNode.removeChild(o), u.focus());
      }
      g(d, "close"), l[0].focus();
      for (var t = 0; t < l.length; ++t) {
        var p = l[t];
        (function(y) {
          n.on(p, "click", function(b) {
            n.e_preventDefault(b), d(), y && y(u);
          });
        })(f[t]), n.on(p, "blur", function() {
          --a, setTimeout(function() {
            a <= 0 && d();
          }, 200);
        }), n.on(p, "focus", function() {
          ++a;
        });
      }
    }), n.defineExtension("openNotification", function(i, f) {
      c(this, u);
      var e = r(this, i, f && f.bottom), o = false, l, s = f && typeof f.duration < "u" ? f.duration : 5e3;
      function u() {
        o || (o = true, clearTimeout(l), n.rmClass(e.parentNode, "dialog-opened"), e.parentNode.removeChild(e));
      }
      return g(u, "close"), n.on(e, "click", function(a) {
        n.e_preventDefault(a), u();
      }), s && (l = setTimeout(u, s)), u;
    });
  });
})();
var N = x.exports;
const k = /* @__PURE__ */ hu(N), j = /* @__PURE__ */ T({
  __proto__: null,
  default: k
}, [N]);
export {
  N as a,
  j as d
};
//# sourceMappingURL=dialog.es-CQI76cVg.js.map
