text: // Generated by purs version 0.11.7
  "use strict";
  var Control_Applicative = require("../Control.Applicative");
  var Control_Bind = require("../Control.Bind");
  var Control_Monad_Eff = require("../Control.Monad.Eff");
  var Control_Monad_Eff_Ref = require("../Control.Monad.Eff.Ref");
  var DOM = require("../DOM");
  var DOM_Event_EventTarget = require("../DOM.Event.EventTarget");
  var DOM_Event_Types = require("../DOM.Event.Types");
  var DOM_Node_Types = require("../DOM.Node.Types");
  var Data_Eq = require("../Data.Eq");
  var Data_Foreign = require("../Data.Foreign");
  var Data_Function_Uncurried = require("../Data.Function.Uncurried");
  var Data_Functor = require("../Data.Functor");
  var Data_HeytingAlgebra = require("../Data.HeytingAlgebra");
  var Data_Maybe = require("../Data.Maybe");
  var Data_Nullable = require("../Data.Nullable");
  var Data_Semigroup = require("../Data.Semigroup");
  var Data_StrMap = require("../Data.StrMap");
  var Data_Tuple = require("../Data.Tuple");
  var Data_Unit = require("../Data.Unit");
  var Halogen_VDom = require("../Halogen.VDom");
  var Halogen_VDom_Machine = require("../Halogen.VDom.Machine");
  var Halogen_VDom_Types = require("../Halogen.VDom.Types");
  var Halogen_VDom_Util = require("../Halogen.VDom.Util");
  var Prelude = require("../Prelude");
  var Unsafe_Coerce = require("../Unsafe.Coerce");
  var Created = (function () {
      function Created(value0) {
          this.value0 = value0;
      };
      Created.create = function (value0) {
          return new Created(value0);
      };
      return Created;
  })();
  var Removed = (function () {
      function Removed(value0) {
          this.value0 = value0;
      };
      Removed.create = function (value0) {
          return new Removed(value0);
      };
      return Removed;
  })();
  var Attribute = (function () {
      function Attribute(value0, value1, value2) {
          this.value0 = value0;
          this.value1 = value1;
          this.value2 = value2;
      };
      Attribute.create = function (value0) {
          return function (value1) {
              return function (value2) {
                  return new Attribute(value0, value1, value2);
              };
          };
      };
      return Attribute;
  })();
  var Property = (function () {
      function Property(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      Property.create = function (value0) {
          return function (value1) {
              return new Property(value0, value1);
          };
      };
      return Property;
  })();
  var Handler = (function () {
      function Handler(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      Handler.create = function (value0) {
          return function (value1) {
              return new Handler(value0, value1);
          };
      };
      return Handler;
  })();
  var Ref = (function () {
      function Ref(value0) {
          this.value0 = value0;
      };
      Ref.create = function (value0) {
          return new Ref(value0);
      };
      return Ref;
  })();
  var unsafeGetProperty = Halogen_VDom_Util.unsafeGetAny;
  var setProperty = Halogen_VDom_Util.unsafeSetAny;
  var removeProperty = function (key, el) {
      var v = Data_Foreign.typeOf(Halogen_VDom_Util.unsafeGetAny(key, el));
      if (v === "string") {
          return Halogen_VDom_Util.unsafeSetAny(key, "", el);
      };
      if (key === "rowSpan") {
          return Halogen_VDom_Util.unsafeSetAny(key, 1, el);
      };
      if (key === "colSpan") {
          return Halogen_VDom_Util.unsafeSetAny(key, 1, el);
      };
      return Halogen_VDom_Util.unsafeSetAny(key, Halogen_VDom_Util.jsUndefined, el);
  };
  var propToStrKey = function (v) {
      if (v instanceof Attribute && v.value0 instanceof Data_Maybe.Just) {
          return "attr/" + (v.value0.value0 + (":" + v.value1));
      };
      if (v instanceof Attribute) {
          return "attr/:" + v.value1;
      };
      if (v instanceof Property) {
          return "prop/" + v.value0;
      };
      if (v instanceof Handler) {
          return "handler/" + v.value0;
      };
      if (v instanceof Ref) {
          return "ref";
      };
      throw new Error("Failed pattern match at Halogen.VDom.DOM.Prop line 179, column 16 - line 186, column 1: " + [ v.constructor.name ]);
  };
  var propFromString = Unsafe_Coerce.unsafeCoerce;
  var propFromNumber = Unsafe_Coerce.unsafeCoerce;
  var propFromInt = Unsafe_Coerce.unsafeCoerce;
  var propFromBoolean = Unsafe_Coerce.unsafeCoerce;
  var functorProp = new Data_Functor.Functor(function (f) {
      return function (v) {
          if (v instanceof Handler) {
              return new Handler(v.value0, Data_Functor.map(Data_Functor.functorFn)(Data_Functor.map(Data_Maybe.functorMaybe)(f))(v.value1));
          };
          if (v instanceof Ref) {
              return new Ref(Data_Functor.map(Data_Functor.functorFn)(Data_Functor.map(Data_Maybe.functorMaybe)(f))(v.value0));
          };
          return v;
      };
  });
  var functorElemRef = new Data_Functor.Functor(function (f) {
      return function (v) {
          if (v instanceof Created) {
              return new Created(f(v.value0));
          };
          if (v instanceof Removed) {
              return new Removed(f(v.value0));
          };
          throw new Error("Failed pattern match at Halogen.VDom.DOM.Prop line 48, column 1 - line 48, column 42: " + [ f.constructor.name, v.constructor.name ]);
      };
  });
  var buildProp = function (emit) {
      return function (el) {
          var removeProp = function (prevEvents) {
              return function (v, v1) {
                  if (v1 instanceof Attribute) {
                      return Halogen_VDom_Util.removeAttribute(Data_Nullable.toNullable(v1.value0), v1.value1, el);
                  };
                  if (v1 instanceof Property) {
                      return removeProperty(v1.value0, el);
                  };
                  if (v1 instanceof Handler) {
                      var handler = Halogen_VDom_Util.unsafeLookup(v1.value0, prevEvents);
                      return Halogen_VDom_Util.removeEventListener(v1.value0, Data_Tuple.fst(handler), el);
                  };
                  if (v1 instanceof Ref) {
                      return Halogen_VDom_Util.effUnit;
                  };
                  throw new Error("Failed pattern match at Halogen.VDom.DOM.Prop line 166, column 5 - line 176, column 21: " + [ v1.constructor.name ]);
              };
          };
          var mbEmit = Data_Maybe.maybe(Halogen_VDom_Util.effUnit)(emit);
          var done = function (ps) {
              var v = Data_StrMap.lookup("ref")(ps);
              if (v instanceof Data_Maybe.Just && v.value0 instanceof Ref) {
                  return mbEmit(v.value0.value0(new Removed(el)));
              };
              return Halogen_VDom_Util.effUnit;
          };
          var diffProp = function (prevEvents, events) {
              return function (v, v1, v11, v2) {
                  if (v11 instanceof Attribute && v2 instanceof Attribute) {
                      var v3 = v11.value2 !== v2.value2;
                      if (v3) {
                          return function __do() {
                              Halogen_VDom_Util.setAttribute(Data_Nullable.toNullable(v2.value0), v2.value1, v2.value2, el)();
                              return v2;
                          };
                      };
                      return Halogen_VDom_Util.effPure(v2);
                  };
                  if (v11 instanceof Property && v2 instanceof Property) {
                      var v4 = Halogen_VDom_Util.refEq(v11.value1, v2.value1);
                      if (v4) {
                          return Halogen_VDom_Util.effPure(v2);
                      };
                      if (v2.value0 === "value") {
                          var elVal = unsafeGetProperty("value", el);
                          var v5 = !Halogen_VDom_Util.refEq(elVal, v2.value1);
                          if (v5) {
                              return function __do() {
                                  setProperty(v2.value0, v2.value1, el)();
                                  return v2;
                              };
                          };
                          return Halogen_VDom_Util.effPure(v2);
                      };
                      return function __do() {
                          setProperty(v2.value0, v2.value1, el)();
                          return v2;
                      };
                  };
                  if (v11 instanceof Handler && v2 instanceof Handler) {
                      var handler = Halogen_VDom_Util.unsafeLookup(v2.value0, prevEvents);
                      return function __do() {
                          Control_Monad_Eff_Ref.writeRef(Data_Tuple.snd(handler))(v2.value1)();
                          Halogen_VDom_Util.pokeMutMap(v2.value0, handler, events)();
                          return v2;
                      };
                  };
                  return Halogen_VDom_Util.effPure(v2);
              };
          };
          var applyProp = function (events) {
              return function (v, v1, v2) {
                  if (v2 instanceof Attribute) {
                      return function __do() {
                          Halogen_VDom_Util.setAttribute(Data_Nullable.toNullable(v2.value0), v2.value1, v2.value2, el)();
                          return v2;
                      };
                  };
                  if (v2 instanceof Property) {
                      return function __do() {
                          setProperty(v2.value0, v2.value1, el)();
                          return v2;
                      };
                  };
                  if (v2 instanceof Handler) {
                      var v3 = Halogen_VDom_Util.unsafeGetAny(v2.value0, events);
                      if (Halogen_VDom_Util.unsafeHasAny(v2.value0, events)) {
                          return function __do() {
                              Control_Monad_Eff_Ref.writeRef(Data_Tuple.snd(v3))(v2.value1)();
                              return v2;
                          };
                      };
                      return function __do() {
                          var v4 = Control_Monad_Eff_Ref.newRef(v2.value1)();
                          var listener = DOM_Event_EventTarget.eventListener(function (ev) {
                              return function __do() {
                                  var v5 = Control_Monad_Eff_Ref.readRef(v4)();
                                  return mbEmit(v5(ev))();
                              };
                          });
                          Halogen_VDom_Util.pokeMutMap(v2.value0, new Data_Tuple.Tuple(listener, v4), events)();
                          Halogen_VDom_Util.addEventListener(v2.value0, listener, el)();
                          return v2;
                      };
                  };
                  if (v2 instanceof Ref) {
                      return function __do() {
                          mbEmit(v2.value0(new Created(el)))();
                          return v2;
                      };
                  };
                  throw new Error("Failed pattern match at Halogen.VDom.DOM.Prop line 107, column 5 - line 130, column 15: " + [ v2.constructor.name ]);
              };
          };
          var patch = function (prevEvents, ps1) {
              return function (ps2) {
                  return function __do() {
                      var v = Halogen_VDom_Util.newMutMap();
                      var onThis = removeProp(prevEvents);
                      var onThese = diffProp(prevEvents, v);
                      var onThat = applyProp(v);
                      var v1 = Halogen_VDom_Util.diffWithKeyAndIxE(ps1, ps2, propToStrKey, onThese, onThis, onThat)();
                      return new Halogen_VDom_Machine.Step(Data_Unit.unit, patch(Halogen_VDom_Util.unsafeFreeze(v), v1), done(v1));
                  };
              };
          };
          var render = function (ps1) {
              return function __do() {
                  var v = Halogen_VDom_Util.newMutMap();
                  var v1 = Halogen_VDom_Util.strMapWithIxE(ps1, propToStrKey, applyProp(v))();
                  return new Halogen_VDom_Machine.Step(Data_Unit.unit, patch(Halogen_VDom_Util.unsafeFreeze(v), v1), done(v1));
              };
          };
          return render;
      };
  };
  module.exports = {
      Attribute: Attribute,
      Property: Property,
      Handler: Handler,
      Ref: Ref,
      Created: Created,
      Removed: Removed,
      propFromString: propFromString,
      propFromBoolean: propFromBoolean,
      propFromInt: propFromInt,
      propFromNumber: propFromNumber,
      buildProp: buildProp,
      functorProp: functorProp,
      functorElemRef: functorElemRef
  };
  