             [uxbox.util.uuid :as uuid]
             [uxbox.util.rstore :as rs]
             [uxbox.util.router :as r]
+            [uxbox.util.dom :as dom]
             [uxbox.util.dom.files :as files]
             [uxbox.main.state :as st]
             [uxbox.main.repo :as rp]))

  {:pre [(string? data)]}
  (let [valid-tags #{"defs" "path" "circle" "rect" "metadata" "g"
                     "radialGradient" "stop"}
        div (js/document.createElement "div")
        div2 (js/document.createElement "div")
        gc  (js/document.createElement "div")
        g (js/document.createElementNS "http://www.w3.org/2000/svg" "g")
        _ (set! (.-innerHTML div) data)
        svg (.querySelector div "svg")]
    (loop [child (.-firstChild svg)]
      (if child
        (let [tagname (.-tagName child)]
          (if  (contains? valid-tags tagname)
            (.appendChild g child)
            (.appendChild gc child))
          (recur (.-firstChild svg)))
        (let [width (.. svg -width -baseVal -value)
              header (.. svg -height -baseVal -value)
              view-box [(.. svg -viewBox -baseVal -x)

                     :mimetype "image/svg+xml"
                     :height header
                     :view-box view-box}]
          [(dom/get-outer-html g) props])))))

(defrecord CreateIcons [id files]
  rs/WatchEvent
