"use strict";

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };

(function (f) {
  if ((typeof exports === "undefined" ? "undefined" : _typeof(exports)) === "object" && typeof module !== "undefined") {
    module.exports = f();
  } else if (typeof define === "function" && define.amd) {
    define([], f);
  } else {
    var g;if (typeof window !== "undefined") {
      g = window;
    } else if (typeof global !== "undefined") {
      g = global;
    } else if (typeof self !== "undefined") {
      g = self;
    } else {
      g = this;
    }g.snabbdom_style = f();
  }
})(function () {
  var define, module, exports;return function e(t, n, r) {
    function s(o, u) {
      if (!n[o]) {
        if (!t[o]) {
          var a = typeof require == "function" && require;if (!u && a) return a(o, !0);if (i) return i(o, !0);var f = new Error("Cannot find module '" + o + "'");throw f.code = "MODULE_NOT_FOUND", f;
        }var l = n[o] = { exports: {} };t[o][0].call(l.exports, function (e) {
          var n = t[o][1][e];return s(n ? n : e);
        }, l, l.exports, e, t, n, r);
      }return n[o].exports;
    }var i = typeof require == "function" && require;for (var o = 0; o < r.length; o++) {
      s(r[o]);
    }return s;
  }({ 1: [function (require, module, exports) {
      var raf = typeof window !== 'undefined' && window.requestAnimationFrame || setTimeout;
      var nextFrame = function nextFrame(fn) {
        raf(function () {
          raf(fn);
        });
      };

      function setNextFrame(obj, prop, val) {
        nextFrame(function () {
          obj[prop] = val;
        });
      }

      function updateStyle(oldVnode, vnode) {
        var cur,
            name,
            elm = vnode.elm,
            oldStyle = oldVnode.data.style || {},
            style = vnode.data.style || {},
            oldHasDel = 'delayed' in oldStyle;
        for (name in oldStyle) {
          if (!style[name]) {
            elm.style[name] = '';
          }
        }
        for (name in style) {
          cur = style[name];
          if (name === 'delayed') {
            for (name in style.delayed) {
              cur = style.delayed[name];
              if (!oldHasDel || cur !== oldStyle.delayed[name]) {
                setNextFrame(elm.style, name, cur);
              }
            }
          } else if (name !== 'remove' && cur !== oldStyle[name]) {
            elm.style[name] = cur;
          }
        }
      }

      function applyDestroyStyle(vnode) {
        var style,
            name,
            elm = vnode.elm,
            s = vnode.data.style;
        if (!s || !(style = s.destroy)) return;
        for (name in style) {
          elm.style[name] = style[name];
        }
      }

      function applyRemoveStyle(vnode, rm) {
        var s = vnode.data.style;
        if (!s || !s.remove) {
          rm();
          return;
        }
        var name,
            elm = vnode.elm,
            idx,
            i = 0,
            maxDur = 0,
            compStyle,
            style = s.remove,
            amount = 0,
            applied = [];
        for (name in style) {
          applied.push(name);
          elm.style[name] = style[name];
        }
        compStyle = getComputedStyle(elm);
        var props = compStyle['transition-property'].split(', ');
        for (; i < props.length; ++i) {
          if (applied.indexOf(props[i]) !== -1) amount++;
        }
        elm.addEventListener('transitionend', function (ev) {
          if (ev.target === elm) --amount;
          if (amount === 0) rm();
        });
      }

      module.exports = { create: updateStyle, update: updateStyle, destroy: applyDestroyStyle, remove: applyRemoveStyle };
    }, {}] }, {}, [1])(1);
});