text: // Generated by CoffeeScript 2.4.1
  (function() {
    'use strict';
    define(['immutable', './editor', './editorSupport'], function(immutable, Editor, Support) {
      var DataStore, HamtOrgData, Map, OrgData, getFirst, preserveSelection, setFirst;
      ({Map} = window.Immutable = immutable);
      ({DataStore, preserveSelection} = Editor);
      ({OrgData} = Support);
      // `HamtOrgData` uses a HAMT for blocks instead of a regular JS object,
      // to make it easier to handle merges.
      HamtOrgData = class HamtOrgData extends OrgData {
        constructor() {
          super();
          this.blocks = new Map();
          this.namedBlocks = new Map();
        }
  
        snapshot() {
          var data;
          data = new HamtOrgData();
          data.installSnapshot(this);
          return data;
        }
  
        installSnapshot(data) {
          this.blocks = data.blocks;
          this.blockIndex = data.blockIndex;
          return this.namedBlocks = data.namedBlocks;
        }
  
        getFirst() {
          return getFirst(this.blocks);
        }
  
        setFirst(firstId) {
          return this.blocks = setFirst(this.blocks, firstId);
        }
  
        getBlock(id, changes) {
          var ref;
          if (typeof id !== 'string') {
            return id;
          } else {
            return (ref = changes != null ? changes.sets[id] : void 0) != null ? ref : this.blocks.get(id);
          }
        }
  
        setBlock(id, block) {
          return this.makeChanges(() => {
            this.runFilters(this.getBlock(id), block);
            this.blocks = this.blocks.set(id, block);
            return this.indexBlock(block);
          });
        }
  
        deleteBlock(id) {
          return this.makeChanges(() => {
            this.runFilters(this.getBlock(id), null);
            this.blocks = this.blocks.delete(id);
            return this.unindexBlock(id);
          });
        }
  
        getNamedBlockId(name) {
          return this.namedBlocks.get(name);
        }
  
        setBlockName(name, blockId) {
          return this.namedBlocks = this.namedBlocks.set(name, blockId);
        }
  
        deleteBlockName(name) {
          return this.namedBlocks = this.namedBlocks.delete(name);
        }
  
        load(first, newBlocks) {
          return this.makeChanges(() => {
            return super.load(first, setFirst(new Map(newBlocks), first), {
              sets: newBlocks,
              oldBlocks: {},
              first: first
            });
          });
        }
  
        makeChange(change) {
          var ch;
          ch = super.makeChange(change);
          ch.origin = change.origin;
          return ch;
        }
  
      };
      getFirst = function(blocks) {
        return blocks.get('FIRST');
      };
      setFirst = function(blocks, firstId) {
        return blocks.set('FIRST', firstId);
      };
      return {HamtOrgData};
    });
  
  }).call(this);
  
  //# sourceMappingURL=hamtData.js.map
  