import s from "../../../@babel/runtime/helpers/esm/slicedToArray.mjs";
import k from "../../../@babel/runtime/helpers/esm/toConsumableArray.mjs";
import _ from "../../../@babel/runtime/helpers/esm/classCallCheck.mjs";
import y from "../../../@babel/runtime/helpers/esm/createClass.mjs";
import d from "../../../@babel/runtime/helpers/esm/defineProperty.mjs";
import g from "../../../@babel/runtime/helpers/esm/typeof.mjs";
var m = "__@field_split__";
function o(i) {
  return i.map(function(t) {
    return "".concat(g(t), ":").concat(t);
  }).join(m);
}
var $ = /* @__PURE__ */ function() {
  function i() {
    _(this, i), d(this, "kvs", /* @__PURE__ */ new Map());
  }
  return y(i, [{
    key: "set",
    value: function(e, r) {
      this.kvs.set(o(e), r);
    }
  }, {
    key: "get",
    value: function(e) {
      return this.kvs.get(o(e));
    }
  }, {
    key: "update",
    value: function(e, r) {
      var n = this.get(e), a = r(n);
      a ? this.set(e, a) : this.delete(e);
    }
  }, {
    key: "delete",
    value: function(e) {
      this.kvs.delete(o(e));
    }
    // Since we only use this in test, let simply realize this
  }, {
    key: "map",
    value: function(e) {
      return k(this.kvs.entries()).map(function(r) {
        var n = s(r, 2), a = n[0], c = n[1], f = a.split(m);
        return e({
          key: f.map(function(v) {
            var p = v.match(/^([^:]*):(.*)$/), u = s(p, 3), h = u[1], l = u[2];
            return h === "number" ? Number(l) : l;
          }),
          value: c
        });
      });
    }
  }, {
    key: "toJSON",
    value: function() {
      var e = {};
      return this.map(function(r) {
        var n = r.key, a = r.value;
        return e[n.join(".")] = a, null;
      }), e;
    }
  }]), i;
}();
export {
  $ as default
};
