text: /**
   * Copyright (c) 2021-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
   *
   * @author Jason Pattle <jpattle@exscientia.co.uk>
   * @author Panagiotis Tourlas <panagiot_tourlov@hotmail.com>
   */
  import { Column } from '../../../mol-data/db';
  import { Tokenizer, TokenBuilder } from '../common/text/tokenizer';
  import { TokenColumnProvider as TokenColumn } from '../common/text/column/token';
  export function isV3(versionLine) {
      return versionLine.trim().endsWith('V3000');
  }
  export function handleCountsV3(tokenizer) {
      var atomCount = TokenBuilder.create(tokenizer.data, 1);
      var bondCount = TokenBuilder.create(tokenizer.data, 1);
      Tokenizer.eatLine(tokenizer); // BEGIN CTAB
      skipSingleValue(tokenizer); // M
      skipSingleValue(tokenizer); // V30
      skipSingleValue(tokenizer); // COUNTS
      addSingleValue(tokenizer, atomCount);
      addSingleValue(tokenizer, bondCount);
      Tokenizer.eatLine(tokenizer);
      return {
          atomCount: TokenColumn(atomCount)(Column.Schema.int).value(0),
          bondCount: TokenColumn(bondCount)(Column.Schema.int).value(0)
      };
  }
  export function handleAtomsV3(tokenizer, atomCount) {
      var x = TokenBuilder.create(tokenizer.data, atomCount * 2);
      var y = TokenBuilder.create(tokenizer.data, atomCount * 2);
      var z = TokenBuilder.create(tokenizer.data, atomCount * 2);
      var type_symbol = TokenBuilder.create(tokenizer.data, atomCount * 2);
      for (var i = 0; i < atomCount; ++i) {
          Tokenizer.markLine(tokenizer);
          skipSingleValue(tokenizer); // M
          skipSingleValue(tokenizer); // V30
          skipSingleValue(tokenizer); // Index
          var position = tokenizer.position;
          addSingleValue(tokenizer, type_symbol);
          addSingleValue(tokenizer, x);
          addSingleValue(tokenizer, y);
          addSingleValue(tokenizer, z);
          tokenizer.position = position;
      }
      Tokenizer.eatLine(tokenizer); // Previous Line
      Tokenizer.eatLine(tokenizer); // END ATOM
      return {
          count: atomCount,
          x: TokenColumn(x)(Column.Schema.float),
          y: TokenColumn(y)(Column.Schema.float),
          z: TokenColumn(z)(Column.Schema.float),
          type_symbol: TokenColumn(type_symbol)(Column.Schema.str),
          /* No support for formal charge parsing in V3000 molfiles at the moment,
          so all charges default to 0.*/
          formal_charge: Column.ofConst(0, atomCount, Column.Schema.int)
      };
  }
  export function handleBondsV3(tokenizer, bondCount) {
      var atomIdxA = TokenBuilder.create(tokenizer.data, bondCount * 2);
      var atomIdxB = TokenBuilder.create(tokenizer.data, bondCount * 2);
      var order = TokenBuilder.create(tokenizer.data, bondCount * 2);
      for (var i = 0; i < bondCount; ++i) {
          Tokenizer.markLine(tokenizer);
          skipSingleValue(tokenizer); // M
          skipSingleValue(tokenizer); // V30
          skipSingleValue(tokenizer); // Index
          var position = tokenizer.position;
          addSingleValue(tokenizer, order);
          addSingleValue(tokenizer, atomIdxA);
          addSingleValue(tokenizer, atomIdxB);
          tokenizer.position = position;
      }
      Tokenizer.eatLine(tokenizer); // Previous Line
      Tokenizer.eatLine(tokenizer); // END BOND
      return {
          count: bondCount,
          atomIdxA: TokenColumn(atomIdxA)(Column.Schema.float),
          atomIdxB: TokenColumn(atomIdxB)(Column.Schema.float),
          order: TokenColumn(order)(Column.Schema.float),
      };
  }
  function skipSingleValue(tokenizer) {
      Tokenizer.skipWhitespace(tokenizer);
      Tokenizer.eatValue(tokenizer);
  }
  function addSingleValue(tokenizer, tokens) {
      var valueStart = tokenizer.position;
      Tokenizer.skipWhitespace(tokenizer);
      Tokenizer.eatValue(tokenizer);
      Tokenizer.trim(tokenizer, valueStart, tokenizer.position);
      TokenBuilder.addUnchecked(tokens, tokenizer.tokenStart, tokenizer.tokenEnd);
  }
  //# sourceMappingURL=parser-v3-util.js.map