 {Animator} = require "./animator.coffee"
 {MouseToolCombo} = require "./mousetool.coffee"
 {GenericTransitionFunc, BinaryTransitionFunc,DayNightTransitionFunc,binaryTransitionFunc2GenericCode, dayNightBinaryTransitionFunc2GenericCode, parseGenericTransitionFunction, parseTransitionFunction} = require "./rule.coffee"
+{parseUri} = require "./parseuri.coffee"
 M = require "./matrix3.coffee"
 
 MIN_WIDTH = 100

  getGroup: -> @tessellation.group
  getTransitionFunc: -> @transitionFunc

  initialize: ->
    @tessellation = new Tessellation 7,3
    console.log "Running knuth-bendix algorithm...."
    rewriteRuleset = knuthBendix vdRule @getGroup().n, @getGroup().m
    console.log "Finished"    
    @appendRewrite = makeAppendRewrite rewriteRuleset
    @getNeighbors = mooreNeighborhood @getGroup().n, @getGroup().m, @appendRewrite

    @cells = new NodeHashMap
    @cells.put unity, 1
    
    @observer = new @ObserverClass @tessellation, @appendRewrite, minVisibleSize
    @observer.onFinish = -> redraw()

    updateCanvasSize()
    if found > 0
      @navigator.navigateToResult 0
      
  importData: (data)->
    try
      console.log "importing #{data}"
      @cells = importField parseFieldData data
      console.log "Imported #{@cells.count} cells"
    catch e
      alert "Faield to import data: #{e}"
      @cells = new NodeHashMap


updateCanvasSize = ->
  return if canvasSizeUpdateBlocked
