text: import { Validate } from '@microsoft/sp-core-library';
  import PlaceholderContent from './PlaceholderContent';
  import PlaceholderName from './PlaceholderName';
  var Placeholder =  (function () {
      function Placeholder(definition, manager) {
          this._entries = [];
          Validate.isNotNullOrUndefined(definition, 'definition');
          Validate.isNotNullOrUndefined(definition.domElement, 'definition.domElement');
          Validate.isNotNullOrUndefined(manager, 'manager');
          this._name = definition.name;
          this._domElement = definition.domElement;
          this._applicationDomElement = undefined;
      }
      Object.defineProperty(Placeholder.prototype, "name", {
          get: function () {
              return this._name;
          },
          enumerable: true,
          configurable: true
      });
      Placeholder.prototype.createPlaceholderContent = function (sequence, options) {
          var contentDiv = document.createElement('div');
          var position = this._addContentDiv(contentDiv, sequence);
          var placeholderContent = new PlaceholderContent({
              placeholder: this,
              sequence: sequence,
              domElement: contentDiv,
              options: options
          });
          this._entries.splice(position, 0, { placeholderContent: placeholderContent, sequence: sequence });
          return placeholderContent;
      };
      Placeholder.prototype.removePlaceholderContent = function (placeholderContent) {
          for (var i = 0; i < this._entries.length; i++) {
              if (this._entries[i].placeholderContent === placeholderContent) {
                  this._domElement.removeChild(this._entries[i].placeholderContent.domElement);
                  this._entries.splice(i, 1);
                  i--; 
              }
          }
      };
      Placeholder.prototype.attachToApplication = function (applicationDomElement) {
          this._applicationDomElement = applicationDomElement;
          this._applicationDomElement.appendChild(this._domElement);
      };
      Placeholder.prototype.detachFromApplication = function () {
          if (this._applicationDomElement) {
              this._applicationDomElement.appendChild(this._domElement);
              this._applicationDomElement = undefined;
          }
      };
      Placeholder.prototype._addContentDiv = function (domElement, sequence) {
          var i;
          if (this.name === PlaceholderName.Bottom) {
              i = this._entries.length;
              while (i > 0 && sequence > this._entries[i - 1].sequence) {
                  i--;
              }
          }
          else {
              i = 0;
              while (i < this._entries.length && sequence >= this._entries[i].sequence) {
                  i++;
              }
          }
          if (i < this._entries.length) {
              var nextDiv = this._entries[i].placeholderContent.domElement;
              this._domElement.insertBefore(domElement, nextDiv);
          }
          else {
              this._domElement.appendChild(domElement);
          }
          return i;
      };
      return Placeholder;
  }());
  export default Placeholder;
  