function jssGlobal() {
  function onCreateRule(name, styles, options) {
    if (!name) return null

    if (name === at) {
      return new GlobalContainerRule(name, styles, options)
    }

    if (name[0] === '@' && name.substr(0, atPrefix.length) === atPrefix) {
      return new GlobalPrefixedRule(name, styles, options)
    }

    const {parent} = options

    if (parent) {
      if (
        parent.type === 'global' ||
        (parent.options.parent && parent.options.parent.type === 'global')
      ) {
        options.scoped = false
      }
    }

    if (!options.selector && options.scoped === false) {
      options.selector = name
    }

    return null
  }

  function onProcessRule(rule, sheet) {
    if (rule.type !== 'style' || !sheet) return

    handleNestedGlobalContainerRule(rule, sheet)
    handlePrefixedGlobalRule(rule, sheet)
  }

  return {onCreateRule, onProcessRule}
}
Convert nested rules to separate, remove them from original styles.