text: var board = require('./board');
  var data = require('./data');
  var fen = require('./fen');
  var configure = require('./configure');
  var anim = require('./anim');
  var drag = require('./drag');
  
  module.exports = function(cfg) {
  
    this.data = data(cfg);
  
    this.vm = {
      exploding: false
    };
  
    this.getFen = function() {
      return fen.write(this.data.pieces);
    }.bind(this);
  
    this.set = anim(configure, this.data);
  
    this.toggleOrientation = anim(board.toggleOrientation, this.data);
  
    this.setPieces = anim(board.setPieces, this.data);
  
    this.selectSquare = anim(board.selectSquare, this.data, true);
  
    this.apiMove = anim(board.apiMove, this.data);
  
    this.playPremove = anim(board.playPremove, this.data);
  
    this.cancelPremove = anim(board.unsetPremove, this.data, true);
  
    this.setCheck = anim(board.setCheck, this.data, true);
  
    this.cancelMove = anim(function(data) {
      board.cancelMove(data);
      drag.cancel(data);
    }.bind(this), this.data, true);
  
    this.stop = anim(function(data) {
      board.stop(data);
      drag.cancel(data);
    }.bind(this), this.data, true);
  
    this.explode = function(keys) {
      if (!this.data.render) return;
      this.vm.exploding = keys;
      this.data.renderRAF();
      setTimeout(function() {
        this.vm.exploding = false;
        this.data.renderRAF();
      }.bind(this), 200);
    }.bind(this);
  
    this.setAutoShapes = function(shapes) {
      anim(function(data) {
        data.drawable.autoShapes = shapes;
      }, this.data, false)();
    }.bind(this);
  };
  