               :gt [(.max js/Math (+ rhs (/ time-unit 16)) min-t) Infinity]))))
 
 (defn transition-interval [has ha transition]
-  #_(println "Transition" (:id ha) (:x ha) (:target transition) (:guard transition))
+  #_(println "Transition" (:id ha) "et" (:entry-time ha) (:target transition) (:guard transition))
   (let [intervals (map #(simple-interval has ha %) (:guard transition))
         interval (intersect-all intervals)]
     #_(println "interval:" intervals "->" interval)

(defn make-scene-a [x] (let [ids #{:ga :gb :gc :gd}
                             walls #{[0 0 104 8]
                                     [0 8 8 16]
                                     [96 8 8 16]}
                             objects [(goomba :ga x 8 16 :right ids walls)
                                      (goomba :gb (+ x 18) 8 16 :left ids walls)
                                      (goomba :gc (+ x 38) 8 16 :right ids walls)
                                      (goomba :gd (+ x 58) 8 16 :left ids walls)
                                      ; TODO: mario jumper
                                      ]
                             obj-ids (map :id objects)

           (fn [scene _owner]
             [(ha-dependencies (get-in @scene [:objects :a])) (ha-dependencies (get-in @scene [:objects :b]))])
           scene-a)

(defcard interval-list-ops
         (fn [data-atom _]
           (let [{data :data good :good text :text} @data-atom]
             (sab/html [:div
                        [:input {:type      "text"
                                 :style     {:background-color (if good "inherit" "red")
                                             :width            "100%"}
                                 :value     text
                                 :on-change #(swap! data-atom (fn [d]
                                                                (let [new-text (.-value (.-target %))
                                                                      d (assoc d :text new-text)
                                                                      new-data (try (reader/read-string new-text)
                                                                                    (catch :default _e nil))]
                                                                  (if new-data
                                                                    (assoc d :data new-data :good true)
                                                                    (assoc d :good false)))))}]
                        [:br]
                        (when good
                          [:div
                           [:label (str "Intersections: " (map (fn [di]
                                                                 (map (fn [dj]
                                                                        (str di "," dj ":" (intersection di dj)))
                                                                      data))
                                                               data))]
                           [:br]
                           [:label (str "Intersect: " (intersect-all data))]
                           [:br]
                           [:label (str "Union: " (union-all data))]])])))
         {:data [[0 1] [2 3]]
          :text "[[0 1] [2 3]]"
          :good true})


(defcard ha-states-card
         (fn [scene _owner]
