text: "use strict";
  /**
   * Copyright (c) 2018-2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
   *
   * @author Alexander Rose <alexander.rose@weirdbyte.de>
   */
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.getPositions = exports.getAtomIdForAtomRole = exports.getAtomicMoleculeType = exports.getElementMoleculeType = exports.getCoarseBegCompId = void 0;
  var types_1 = require("./model/types");
  var linear_algebra_1 = require("../../mol-math/linear-algebra");
  function getCoarseBegCompId(unit, element) {
      var entityKey = unit.coarseElements.entityKey[element];
      var seq = unit.model.sequence.byEntityKey[entityKey].sequence;
      var seq_id_begin = unit.coarseElements.seq_id_begin.value(element);
      return seq.compId.value(seq_id_begin - 1); // 1-indexed
  }
  exports.getCoarseBegCompId = getCoarseBegCompId;
  function getElementMoleculeType(unit, element) {
      switch (unit.kind) {
          case 0 /* Atomic */:
              return unit.model.atomicHierarchy.derived.residue.moleculeType[unit.residueIndex[element]];
          case 1 /* Spheres */:
          case 2 /* Gaussians */:
              // TODO add unit.model.coarseHierarchy.derived.residue.moleculeType
              var compId = getCoarseBegCompId(unit, element);
              var cc = unit.model.properties.chemicalComponentMap.get(compId);
              if (cc)
                  return (0, types_1.getMoleculeType)(cc.type, compId);
      }
      return 0 /* Unknown */;
  }
  exports.getElementMoleculeType = getElementMoleculeType;
  function getAtomicMoleculeType(model, rI) {
      return model.atomicHierarchy.derived.residue.moleculeType[rI];
  }
  exports.getAtomicMoleculeType = getAtomicMoleculeType;
  var EmptyAtomIds = new Set();
  function getAtomIdForAtomRole(polymerType, atomRole) {
      var p = types_1.PolymerTypeAtomRoleId[polymerType];
      if (p !== undefined) {
          var a = p[atomRole];
          if (a !== undefined)
              return a;
      }
      return EmptyAtomIds;
  }
  exports.getAtomIdForAtomRole = getAtomIdForAtomRole;
  var tmpPositionsVec = linear_algebra_1.Vec3.zero();
  function getPositions(unit, indices) {
      var pos = unit.conformation.position;
      var positions = new Float32Array(indices.length * 3);
      var elements = unit.elements;
      for (var i = 0, il = indices.length; i < il; ++i) {
          pos(elements[indices[i]], tmpPositionsVec);
          linear_algebra_1.Vec3.toArray(tmpPositionsVec, positions, i * 3);
      }
      return positions;
  }
  exports.getPositions = getPositions;
  //# sourceMappingURL=util.js.map