text: 'use strict';
  
  Object.defineProperty(exports, "__esModule", {
    value: true
  });
  
  var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  
  require('babel-polyfill');
  
  var _caEncoderG = require('./ca-encoder-g1');
  
  var _caEncoderG2 = _interopRequireDefault(_caEncoderG);
  
  var _caEncoderG3 = require('./ca-encoder-g2');
  
  var _caEncoderG4 = _interopRequireDefault(_caEncoderG3);
  
  var _goldCode = require('./gold-code');
  
  var _goldCode2 = _interopRequireDefault(_goldCode);
  
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  
  function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  
  function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  
  /**
   * Generates a C/A-Code (coarse acquisition code) chip pattern (i.e. bitstream
   * with no meaningful content). Each Space Vehicle (satellite) transmits a
   * unique code.
   *
   * [GPS specification]{@link http://www.gps.gov/technical/icwg/IS-GPS-200H.pdf}
   * (IS-GPS-200 revision H) § 3.2.1.3
   *
   * > The PRN C/A-Code for SV ID number `i` is a Gold code, *G<sub>i</sub>(t)*,
   * > of 1 millisecond in length at a chipping rate of 1023 Kbps. The
   * > *G<sub>i</sub>(t)* sequence is a linear pattern generated by the modulo-2
   * > addition of two sub-sequences, *G1* and *G2<sub>i</sub>*, each of which is
   * > a 1023 chip long linear pattern. [...] The *G2<sub>i</sub>* sequence is a
   * > *G2* sequence selectively delayed by pre-assigned number of chips, thereby
   * > generating a set of different C/A-codes.
   *
   * § 3.3.2.1
   *
   * > The linear *G<sub>i</sub>(t)* pattern (C/A-code) is the modulo-2 sum of
   * > two 1023-bit linear patterns, *G1* and *G2<sub>i</sub>*. The latter
   * > sequence is selectively delayed by an integer number of chips to produce
   * > many different *G(t)* patterns (defined in Tables 3-Ia and 3-Ib).
   *
   * § 3.3.2.3
   *
   * > Each *G<sub>i</sub>(t)* sequence is a 1023-bit Gold-code which is itself
   * > the modulo-2 sum of two 1023-bit linear patterns, *G1* and
   * > *G2<sub>i</sub>*. The *G2<sub>i</sub>* sequence is formed by effectively
   * > delaying the *G2* sequence by an integer number of chips. The *G1* and
   * > *G2* sequences are generated by 10-stage shift registers having the
   * > following polynomials as referred to in the shift register input (see
   * > Figures 3-8 and 3-9).
   * >
   * > * G1 = X<sup>10</sup> + X<sup>3</sup> + 1, and
   * > * G2 = X<sup>10</sup> + X<sup>9</sup> + X<sup>8</sup> + X<sup>6</sup> + X<sup>3</sup> + X<sup>2</sup> + 1.
   * >
   * > The initialization vector for the *G1* and *G2* sequences is `1111111111`.
   * > The *G1* and *G2* shift registers are initialized at the P-coder *X1*
   * > epoch. The *G1* and *G2* registers are clocked at 1.023 MHz derived from
   * > the 10.23 MHz P-coder clock. [...]
   * >
   * > The effective delay of the *G2* sequence to form the *G2<sub>i</sub>*
   * > sequence may be accomplished by combining the output of two stages of the
   * > *G2* shift register by modulo-2 addition (see Figure 3-10). However, this
   * > two-tap coder implementation generates only a limited set of valid C/A
   * > codes.
   *
   * @augments GoldCode
   * @augments CAEncoderG1
   * @augments CAEncoderG2
   *
   * @see http://what-when-how.com/a-software-defined-gps-and-galileo-receiver/gps-signal-gps-and-galileo-receiver-part-2/
   */
  var CAEncoder = function (_GoldCode) {
    _inherits(CAEncoder, _GoldCode);
  
    /**
     * @param {number} sv - The SV ID.
     *
     * @throws {(RangeError|TypeError)}
     */
    function CAEncoder(sv) {
      _classCallCheck(this, CAEncoder);
  
      var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(CAEncoder).call(this, 10));
  
      if (typeof sv !== 'number') throw new TypeError('sv must be a number');
      if (sv < 1 || sv > 32) throw new RangeError('sv must be in the range 1..32 (inclusive)');
      _this.sv = sv;
      return _this;
    }
  
    /**
     * Gold codes are generated from a pair of {@link LFSR}s.
     *
     * This overrides the {@link GoldCode.lfsrs} implementation to set a custom
     * seed for the first LFSR.
     *
     * @access private
     * @type {Array<FibonacciLFSR, CAEncoderG2>}
     */
  
  
    _createClass(CAEncoder, [{
      key: 'lfsrs',
      get: function get() {
        if (this._lfsrs) return this._lfsrs;
  
        var lfsrA = new _caEncoderG2.default();
        var lfsrB = new _caEncoderG4.default(this.sv);
  
        this._lfsrs = [lfsrA, lfsrB];
  
        return this._lfsrs;
      }
    }]);
  
    return CAEncoder;
  }(_goldCode2.default);
  
  exports.default = CAEncoder;
  //# sourceMappingURL=ca-encoder.js.map