 (ns fugue.space
-  (:require [clojure.zip :as zip]
+  (:require-macros [fugue.env :refer [analyzer-state]])
+  (:require [cljs.js]
+            [fugue.api]
+            [clojure.zip :as zip]
             [reagent.core :as r]))
 
-(def init-state
-  {:boxes [1 [2 3]]
+(def init-state-m
+  {:boxes '(1 (2 3))
    :active-box 1
    :next-id 4
-   :files {1 "foo" 2 "bar" 3 "biz"}})
+   :result nil
+   :files {1 "(+ 82 34)" 2 "bar" 3 "biz"}})
 
 (defn in-row? [loc]
   (-> (zip/path loc)

            :left (if (in-row? loc)
                    (zip/insert-left loc new-box)
                    (zip/edit loc #(list new-box %)))
            :down (if (in-row? loc)
                    (zip/edit loc #(list % new-box))
                    (zip/insert-right loc new-box))
            :up (if (in-row? loc)
                  (zip/edit loc #(list new-box %))
                  (zip/insert-left loc new-box))))
        (recur (zip/next loc))))))

(defn boxes [node is-row]
  [:div {:style {:display "flex"
                 :flex-grow 0
                 :flex-flow (if is-row "row" "column")}}
   (if (seqable? node)
     (map #(boxes % (not is-row)) node)
     [:p (str node)])])

(defn app []
  (let [state (r/atom init-state)]
    (fn []
      (boxes (:boxes @state) true))))




      (mod 2)
      (= 1)))

(defn insert [boxes direction box new-box]
  (loop [loc (zip/seq-zip boxes)]
    (print (zip/node loc))
    (if (zip/end? loc)
      (do
        (print "end")
        (zip/root loc))
      (if (= box (zip/node loc))
        (zip/root
          (case direction
