"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const array = require("../../utils/array.js");
const compareByDepth = require("./compare-by-depth.js");
var FlatTree = (
  /** @class */
  function() {
    function FlatTree2() {
      this.children = [];
      this.isDirty = false;
    }
    FlatTree2.prototype.add = function(child) {
      array.addUniqueItem(this.children, child);
      this.isDirty = true;
    };
    FlatTree2.prototype.remove = function(child) {
      array.removeItem(this.children, child);
      this.isDirty = true;
    };
    FlatTree2.prototype.forEach = function(callback) {
      this.isDirty && this.children.sort(compareByDepth.compareByDepth);
      this.isDirty = false;
      this.children.forEach(callback);
    };
    return FlatTree2;
  }()
);
exports.FlatTree = FlatTree;
//# sourceMappingURL=flat-tree.js.map
