   document.head.appendChild(style)
   style
 
-removeStyleSheet = (style)-> style.parentNode?.removeChild(style)
+removeStyleSheet = (style)->
+  style.parentNode?.removeChild(style)
 
 # Create and initialize a new global stylesheet that will receive merged styles in the right order
 MergedStyles = createStyleSheet("") unless MergedStyles

superagent          = require 'superagent'

Styles     = []


createStyleSheet = (content="", disabled=false)->
  style = document.createElement('style')

getRules = (sheet)->
  return unless sheet?
  sheet.cssRules || sheet.rules

appendRules = (entry, rules)->
  entry.style = rulesToText(entry.prefix, rules)
  true

fetch = (href)->
  new Promise (resolve, reject)->
    return reject() unless !!href
    superagent.get(href).end (err, res)->
      resolve(res.text)

replaceLinkTagUrls = (uri, text)->
  re = new RegExp "url\\(['\"]?([^)]*?)['\"]?\\)", "g"
  text.replace(re, "url('#{uri}$1')")
